Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
SimAquaLife
GR3D
Commits
91214804
Commit
91214804
authored
Apr 26, 2021
by
patrick.lambert
Browse files
with an option to not fill in the inshore basin when presence
parent
54962b4b
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/environment/BasinNetworkObserverPresence.java
View file @
91214804
...
...
@@ -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
;
...
...
src/main/java/environment/RIOBasinNetworkObserverPresence.java
View file @
91214804
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment