Commit c4249470 authored by patrick.lambert's avatar patrick.lambert
Browse files

fill only river and inshore basins when presence

parent cdf4e2f9
...@@ -77,48 +77,47 @@ public class RIOBasinNetworkObserverPresence extends ObserverListener implements ...@@ -77,48 +77,47 @@ public class RIOBasinNetworkObserverPresence extends ObserverListener implements
public void init(Pilot pilot) { public void init(Pilot pilot) {
this.pilot = pilot; this.pilot = pilot;
if (this.colorScaleEnum == null) { if (this.colorScaleEnum == null)
this.colorScaleEnum = ColorScaleEnum.RedsScale; this.colorScaleEnum = ColorScaleEnum.RedsScale;
try { try {
// open the file // open the file
FileReader reader = new FileReader(presenceFileName); FileReader reader = new FileReader(presenceFileName);
// Parsing the file // Parsing the file
Scanner scanner = new Scanner(reader); Scanner scanner = new Scanner(reader);
scanner.useLocale(Locale.ENGLISH); // to have a point as decimal scanner.useLocale(Locale.ENGLISH); // to have a point as decimal
// separator !!! // separator !!!
// scanner.useDelimiter(Pattern.compile("[;,\r\n]")); // scanner.useDelimiter(Pattern.compile("[;,\r\n]"));
// read the headers // read the headers
String[] headers = scanner.nextLine().split(","); String[] headers = scanner.nextLine().split(",");
presences = new TreeMap<String, Map<String, Integer>>(); presences = new TreeMap<String, Map<String, Integer>>();
for (int i = 2; i < headers.length; i++) { for (int i = 2; i < headers.length; i++) {
presences.put(headers[i], new TreeMap<String, Integer>()); presences.put(headers[i], new TreeMap<String, Integer>());
} }
// read the lines // read the lines
while (scanner.hasNextLine()) { while (scanner.hasNextLine()) {
String[] fields = scanner.nextLine().split(","); String[] fields = scanner.nextLine().split(",");
// System.out.println(Arrays.toString(fields)); // System.out.println(Arrays.toString(fields));
for (int j = 2; j < headers.length; j++) { for (int j = 2; j < headers.length; j++) {
if (j >= fields.length) if (j >= fields.length)
presences.get(headers[j]).put(fields[1], -1);
else {
if (fields[j].compareTo("") == 0)
presences.get(headers[j]).put(fields[1], -1); presences.get(headers[j]).put(fields[1], -1);
else { else
if (fields[j].compareTo("") == 0) presences.get(headers[j]).put(fields[1], Integer.valueOf(fields[j]));
presences.get(headers[j]).put(fields[1], -1);
else
presences.get(headers[j]).put(fields[1], Integer.valueOf(fields[j]));
}
} }
} }
// reader.close();
// scanner.close();
} catch (Exception e) {
e.printStackTrace();
} }
reader.close();
scanner.close();
} catch (Exception e) {
e.printStackTrace();
} }
// the Jpanal that holds all the components to be displayed // the Jpanal that holds all the components to be displayed
display = new JPanel(new BorderLayout()); display = new JPanel(new BorderLayout());
...@@ -138,7 +137,6 @@ public class RIOBasinNetworkObserverPresence extends ObserverListener implements ...@@ -138,7 +137,6 @@ public class RIOBasinNetworkObserverPresence extends ObserverListener implements
// load basin to a have access to the shape // load basin to a have access to the shape
bn = (RIOBasinNetworkWithContinent) pilot.getAquaticWorld().getEnvironment(); bn = (RIOBasinNetworkWithContinent) pilot.getAquaticWorld().getEnvironment();
} }
...@@ -265,8 +263,6 @@ public class RIOBasinNetworkObserverPresence extends ObserverListener implements ...@@ -265,8 +263,6 @@ public class RIOBasinNetworkObserverPresence extends ObserverListener implements
// AffineTransform af = new AffineTransform(scaling, 0., 0., -scaling, -minX * scaling, H + minY * scaling); // AffineTransform af = new AffineTransform(scaling, 0., 0., -scaling, -minX * scaling, H + minY * scaling);
AffineTransform af = new AffineTransform(scaling, 0., 0., -scaling, -minX * scaling, maxY * scaling); AffineTransform af = new AffineTransform(scaling, 0., 0., -scaling, -minX * scaling, maxY * scaling);
// System.out.println(af.toString());
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
g2d.setStroke(new BasicStroke(2)); // define the line g2d.setStroke(new BasicStroke(2)); // define the line
...@@ -315,25 +311,22 @@ public class RIOBasinNetworkObserverPresence extends ObserverListener implements ...@@ -315,25 +311,22 @@ public class RIOBasinNetworkObserverPresence extends ObserverListener implements
} }
g2d.draw(displayShape); g2d.draw(displayShape);
int presence = -1; if (basin instanceof RiverBasin | basin instanceof InshoreBasin) {
if (presences.get(period).get(basinName) != null) int presence = -1;
presence = presences.get(period).get(basinName); if (presences.get(period).get(basinName) != null)
else presence = presences.get(period).get(basinName);
System.out.println(basinName + " is not present in the presence file"); else
System.out.println(basinName + " is not present in the presence file");
/*
* if (presence == 1) { g.setColor(Color.RED); } else if (presence == 0) { g.setColor(Color.WHITE); } if (presence > 0)
* else g.setColor(Color.LIGHT_GRAY); g.setColor(colorScaleEnum.getScale().getColor(presence));
*/ else if (presence == 0)
g.setColor(Color.WHITE);
if (presence > 0) else
g.setColor(colorScaleEnum.getScale().getColor(presence)); g.setColor(Color.GRAY);
else if (presence == 0)
g.setColor(Color.WHITE); g2d.fill(displayShape);
else }
g.setColor(Color.GRAY);
g2d.fill(displayShape);
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment