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
public void init(Pilot pilot) {
this.pilot = pilot;
if (this.colorScaleEnum == null) {
if (this.colorScaleEnum == null)
this.colorScaleEnum = ColorScaleEnum.RedsScale;
try {
// open the file
FileReader reader = new FileReader(presenceFileName);
// Parsing the file
Scanner scanner = new Scanner(reader);
scanner.useLocale(Locale.ENGLISH); // to have a point as decimal
// separator !!!
// scanner.useDelimiter(Pattern.compile("[;,\r\n]"));
// read the headers
String[] headers = scanner.nextLine().split(",");
presences = new TreeMap<String, Map<String, Integer>>();
for (int i = 2; i < headers.length; i++) {
presences.put(headers[i], new TreeMap<String, Integer>());
}
try {
// open the file
FileReader reader = new FileReader(presenceFileName);
// Parsing the file
Scanner scanner = new Scanner(reader);
scanner.useLocale(Locale.ENGLISH); // to have a point as decimal
// separator !!!
// scanner.useDelimiter(Pattern.compile("[;,\r\n]"));
// read the headers
String[] headers = scanner.nextLine().split(",");
presences = new TreeMap<String, Map<String, Integer>>();
for (int i = 2; i < headers.length; i++) {
presences.put(headers[i], new TreeMap<String, Integer>());
}
// read the lines
while (scanner.hasNextLine()) {
String[] fields = scanner.nextLine().split(",");
// System.out.println(Arrays.toString(fields));
// read the lines
while (scanner.hasNextLine()) {
String[] fields = scanner.nextLine().split(",");
// System.out.println(Arrays.toString(fields));
for (int j = 2; j < headers.length; j++) {
if (j >= fields.length)
for (int j = 2; j < headers.length; j++) {
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);
else {
if (fields[j].compareTo("") == 0)
presences.get(headers[j]).put(fields[1], -1);
else
presences.get(headers[j]).put(fields[1], Integer.valueOf(fields[j]));
}
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
display = new JPanel(new BorderLayout());
......@@ -138,7 +137,6 @@ public class RIOBasinNetworkObserverPresence extends ObserverListener implements
// load basin to a have access to the shape
bn = (RIOBasinNetworkWithContinent) pilot.getAquaticWorld().getEnvironment();
}
......@@ -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, maxY * scaling);
// System.out.println(af.toString());
Graphics2D g2d = (Graphics2D) g;
g2d.setStroke(new BasicStroke(2)); // define the line
......@@ -315,25 +311,22 @@ public class RIOBasinNetworkObserverPresence extends ObserverListener implements
}
g2d.draw(displayShape);
int presence = -1;
if (presences.get(period).get(basinName) != null)
presence = presences.get(period).get(basinName);
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); }
* else g.setColor(Color.LIGHT_GRAY);
*/
if (presence > 0)
g.setColor(colorScaleEnum.getScale().getColor(presence));
else if (presence == 0)
g.setColor(Color.WHITE);
else
g.setColor(Color.GRAY);
g2d.fill(displayShape);
if (basin instanceof RiverBasin | basin instanceof InshoreBasin) {
int presence = -1;
if (presences.get(period).get(basinName) != null)
presence = presences.get(period).get(basinName);
else
System.out.println(basinName + " is not present in the presence file");
if (presence > 0)
g.setColor(colorScaleEnum.getScale().getColor(presence));
else if (presence == 0)
g.setColor(Color.WHITE);
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