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

with an option to not fill in the inshore basin when presence

parent 54962b4b
......@@ -37,8 +37,7 @@ import fr.cemagref.simaqualife.kernel.util.TransientParameters;
import fr.cemagref.simaqualife.pilot.Pilot;
@SuppressWarnings("serial")
public class BasinNetworkObserverPresence extends ObserverListener
implements Configurable, Drawable, MouseMotionListener {
public class BasinNetworkObserverPresence extends ObserverListener implements Configurable, Drawable, MouseMotionListener {
private String title;
......@@ -46,6 +45,8 @@ public class BasinNetworkObserverPresence extends ObserverListener
private String period = "obs_1751_1850";
private Boolean fillInshoreBasin = false;
@Description(name = "Color scale", tooltip = "")
public ColorScaleEnum colorScaleEnum = ColorScaleEnum.BluesScale;
......@@ -73,11 +74,13 @@ public class BasinNetworkObserverPresence extends ObserverListener
// basin under the mouse
private transient Basin basinUnderMouse;
@TransientParameters.InitTransientParameters
public void init(Pilot pilot) {
this.pilot = pilot;
if (fillInshoreBasin == null)
fillInshoreBasin = false;
if (this.colorScaleEnum == null) {
this.colorScaleEnum = ColorScaleEnum.RedsScale;
......@@ -113,13 +116,13 @@ public class BasinNetworkObserverPresence extends ObserverListener
}
}
}
// reader.close();
// scanner.close();
reader.close();
scanner.close();
} catch (Exception e) {
e.printStackTrace();
}
}
// the Jpanal that holds all the components to be displayed
display = new JPanel(new BorderLayout());
......@@ -142,7 +145,6 @@ public class BasinNetworkObserverPresence extends ObserverListener
}
/*
* @Override public void valueChanged(ObservablesHandler arg0, Object arg1, long arg2) {
*
......@@ -152,6 +154,7 @@ public class BasinNetworkObserverPresence extends ObserverListener
* label.setText(txt); display.repaint(); }
*/
@Override
public void mouseDragged(MouseEvent arg0) {
// nothing to do
......@@ -327,12 +330,21 @@ public class BasinNetworkObserverPresence extends ObserverListener
* 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);
if (basin instanceof RiverBasin) {
if (presence > 0)
g.setColor(colorScaleEnum.getScale().getColor(presence));
else if (presence == 0)
g.setColor(Color.WHITE);
else
g.setColor(Color.GRAY);
} else if (basin instanceof InshoreBasin & fillInshoreBasin) {
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);
}
......@@ -341,10 +353,9 @@ public class BasinNetworkObserverPresence extends ObserverListener
public enum ColorScaleEnum {
RedsScale(new RedsScale()), BluesScale(new BluesScale()), BicolorScale(new BicolorScale()), GraysScale(
new GraysScale());
private ColorScale scale;
RedsScale(new RedsScale()), BluesScale(new BluesScale()), BicolorScale(new BicolorScale()), GraysScale(new GraysScale());
private ColorScale scale;
ColorScaleEnum(ColorScale colorScale) {
scale = colorScale;
......
......@@ -45,6 +45,8 @@ public class RIOBasinNetworkObserverPresence extends ObserverListener implements
private String period = "obs_1751_1850";
private Boolean fillInshoreBasin = false;
@Description(name = "Color scale", tooltip = "")
public ColorScaleEnum colorScaleEnum = ColorScaleEnum.BluesScale;
......@@ -72,11 +74,13 @@ public class RIOBasinNetworkObserverPresence extends ObserverListener implements
// basin under the mouse
private transient Basin basinUnderMouse;
@TransientParameters.InitTransientParameters
public void init(Pilot pilot) {
this.pilot = pilot;
if (fillInshoreBasin == null)
fillInshoreBasin = false;
if (this.colorScaleEnum == null)
this.colorScaleEnum = ColorScaleEnum.RedsScale;
......@@ -139,7 +143,6 @@ public class RIOBasinNetworkObserverPresence extends ObserverListener implements
bn = (RIOBasinNetworkWithContinent) pilot.getAquaticWorld().getEnvironment();
}
/*
* @Override public void valueChanged(ObservablesHandler arg0, Object arg1, long arg2) {
*
......@@ -149,6 +152,7 @@ public class RIOBasinNetworkObserverPresence extends ObserverListener implements
* label.setText(txt); display.repaint(); }
*/
@Override
public void mouseDragged(MouseEvent arg0) {
// nothing to do
......@@ -318,12 +322,21 @@ public class RIOBasinNetworkObserverPresence extends ObserverListener implements
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);
if (basin instanceof RiverBasin) {
if (presence > 0)
g.setColor(colorScaleEnum.getScale().getColor(presence));
else if (presence == 0)
g.setColor(Color.WHITE);
else
g.setColor(Color.GRAY);
} else if (basin instanceof InshoreBasin & fillInshoreBasin) {
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);
}
......@@ -334,8 +347,8 @@ public class RIOBasinNetworkObserverPresence extends ObserverListener implements
public enum ColorScaleEnum {
RedsScale(new RedsScale()), BluesScale(new BluesScale()), BicolorScale(new BicolorScale()), GraysScale(new GraysScale());
private ColorScale scale;
private ColorScale scale;
ColorScaleEnum(ColorScale colorScale) {
scale = colorScale;
......
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