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
0d6d37f2
Commit
0d6d37f2
authored
Sep 14, 2020
by
patrick.lambert
Browse files
Merge branch 'BasinImprovement' into develop
parents
c4249470
f4f8b041
Changes
6
Hide whitespace changes
Inline
Side-by-side
data/input/northeastamerica/RIO_obs_NEA.xml
View file @
0d6d37f2
<hashtable>
<entry>
<java-class>
fr.cemagref.simaqualife.kernel.AquaticWorld
</java-class>
<!--
<java-class>fr.cemagref.simaqualife.kernel.AquaticWorld</java-class>-->
<java-class>
environment.RIOBasinNetworkWithContinent
</java-class>
<fr.cemagref.observation.kernel.ObservablesHandler>
<observers>
<environment.RIOBasinNetworkObserverWithContinent>
<title>
North East America
</title>
<threshold>
1000000
</threshold>
<colorScaleEnum>
RedsScale
</colorScaleEnum>
</environment.RIOBasinNetworkObserverWithContinent>
<environment.RIOBasinNetworkObserverPresence>
...
...
src/main/java/environment/RIOBasinNetwork.java
View file @
0d6d37f2
...
...
@@ -36,6 +36,7 @@ public abstract class RIOBasinNetwork extends BasinNetwork {
@InitTransientParameters
public
void
initTransientParameters
(
Pilot
pilot
)
{
time
=
new
Time
();
}
...
...
src/main/java/environment/RIOBasinNetworkObserverWithContinent.java
View file @
0d6d37f2
...
...
@@ -41,7 +41,7 @@ public class RIOBasinNetworkObserverWithContinent extends ObserverListener
private
double
threshold
=
13000000
.;
@Description
(
name
=
"Color scale"
,
tooltip
=
""
)
p
ublic
ColorScaleEnum
colorScaleEnum
=
ColorScaleEnum
.
RedsScale
;
p
rivate
ColorScaleEnum
colorScaleEnum
=
ColorScaleEnum
.
RedsScale
;
// a basin network
private
transient
RIOBasinNetworkWithContinent
bn
;
...
...
@@ -299,7 +299,9 @@ public class RIOBasinNetworkObserverWithContinent extends ObserverListener
for
(
DiadromousFishGroup
group
:
basin
.
getGroups
())
{
abundance
+=
basin
.
getEffective
(
group
);
}
// System.out.println(basin.getName()+ "-->"+abundance);
if
(
basin
instanceof
RiverBasin
&
abundance
>
0
)
System
.
out
.
println
(
" "
+
basin
.
getName
()
+
" ("
+
basin
.
getClass
().
getSimpleName
()
+
") -->"
+
abundance
);
if
(
abundance
==
0
.)
{
g
.
setColor
(
Color
.
WHITE
);
}
else
{
...
...
src/main/java/environment/RIOBasinNetworkWithContinent.java
View file @
0d6d37f2
...
...
@@ -24,6 +24,7 @@ import com.thoughtworks.xstream.XStream;
import
com.thoughtworks.xstream.io.xml.DomDriver
;
import
environment.OffshoreBasin.OffshoreBasinFunction
;
import
fr.cemagref.observation.kernel.ObservablesHandler
;
import
fr.cemagref.simaqualife.kernel.util.TransientParameters.InitTransientParameters
;
import
fr.cemagref.simaqualife.pilot.Pilot
;
import
miscellaneous.QueueMemoryMap
;
...
...
@@ -55,6 +56,13 @@ public class RIOBasinNetworkWithContinent extends RIOBasinNetwork {
private
transient
Map
<
String
,
Path2D
.
Double
>
mapContinent
;
protected
transient
ObservablesHandler
cobservable
;
public
ObservablesHandler
getCobservable
()
{
return
cobservable
;
}
class
Record
implements
Comparable
<
Record
>
{
private
int
order
;
...
...
@@ -215,6 +223,10 @@ public class RIOBasinNetworkWithContinent extends RIOBasinNetwork {
super
.
initTransientParameters
(
pilot
);
if
(
cobservable
==
null
)
{
cobservable
=
pilot
.
addObservable
(
this
.
getClass
());
}
FileReader
reader
;
Scanner
scanner
;
...
...
@@ -382,13 +394,13 @@ public class RIOBasinNetworkWithContinent extends RIOBasinNetwork {
System
.
out
.
println
(
" "
+
fields
[
i
]
+
" \t<-> "
+
headers
[
i
]);
while
(
scanner
.
hasNextLine
())
{
fields
=
scanner
.
nextLine
().
split
(
","
);
fields
=
scanner
.
nextLine
().
split
(
","
);
basin_id
=
Integer
.
valueOf
(
fields
[
0
]);
// gid
name
=
fields
[
1
];
function
=
fields
[
2
];
//System.out.println(basin_id + " " + name);
//
System.out.println(basin_id + " " + name);
OffshoreBasin
offshorebasin
=
new
OffshoreBasin
(
basin_id
,
name
,
OffshoreBasinFunction
.
valueOf
(
function
));
if
(
mapOffshoreBasin
!=
null
)
{
...
...
src/main/java/species/DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin.java
View file @
0d6d37f2
...
...
@@ -11,10 +11,10 @@ import org.openide.util.lookup.ServiceProvider;
import
com.thoughtworks.xstream.XStream
;
import
com.thoughtworks.xstream.io.xml.DomDriver
;
import
environment.RIOBasinNetwork
;
import
environment.RiverBasin
;
import
environment.InshoreBasin
;
import
environment.RIOBasinNetwork
;
import
environment.RIOBasinNetworkWithContinent
;
import
environment.RiverBasin
;
import
environment.Time
;
import
environment.Time.Season
;
import
fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess
;
...
...
@@ -142,7 +142,7 @@ public class DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin extends Di
for
(
InshoreBasin
departure
:
group
.
getEnvironment
().
getSeaBasins
())
{
RiverBasin
homingDestination
=
(
RiverBasin
)
bn
.
getAssociatedRiverBasin
(
departure
);
RiverBasin
homingDestination
=
bn
.
getAssociatedRiverBasin
(
departure
);
List
<
DiadromousFish
>
fishes
=
departure
.
getFishs
(
group
);
if
(
fishes
!=
null
)
{
...
...
@@ -248,10 +248,16 @@ public class DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin extends Di
}
}
}
System
.
out
.
println
(
this
.
getClass
().
getSimpleName
());
System
.
out
.
println
(
" total abundance in river basins: "
+
group
.
getFishEffective
());
System
.
out
.
println
(
"female spawners: "
+
group
.
getFemaleSpawnerEffective
()
+
" \tmale spawners: "
+
group
.
getMaleSpawnerEffective
());
System
.
out
.
println
(
" female spawners: "
+
group
.
getFemaleSpawnerEffective
()
+
" \tmale spawners: "
+
group
.
getMaleSpawnerEffective
());
// --------------------------------------------------------------------------------------------------
// update the observers
// ------------------------------------------------------------------------------------------------------
((
RIOBasinNetworkWithContinent
)
group
.
getEnvironment
()).
getCobservable
().
fireChanges
((
group
.
getEnvironment
()),
pilot
.
getCurrentTime
());
}
}
}
src/main/java/species/MigrateBetweenOffshores.java
View file @
0d6d37f2
package
species
;
import
java.util.List
;
import
java.util.ListIterator
;
import
org.openide.util.lookup.ServiceProvider
;
import
com.thoughtworks.xstream.XStream
;
import
com.thoughtworks.xstream.io.xml.DomDriver
;
import
environment.Basin
;
import
environment.OffshoreBasin
;
import
environment.RIOBasinNetworkWithContinent
;
import
environment.RiverBasin
;
import
environment.Time
;
import
environment.OffshoreBasin.OffshoreBasinFunction
;
import
environment.Time.Season
;
import
fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess
;
import
species.DiadromousFish.Stage
;
import
java.util.List
;
import
java.util.ListIterator
;
import
org.geotools.data.FeatureEvent.Type
;
import
org.openide.util.lookup.ServiceProvider
;
@ServiceProvider
(
service
=
AquaNismsGroupProcess
.
class
)
public
class
MigrateBetweenOffshores
extends
AquaNismsGroupProcess
<
DiadromousFish
,
DiadromousFishGroup
>
{
/**
* Season to migrate from summering to winteringOffshoreBasin
*/
private
Season
migrationSeasonToReachWinteringOffshore
=
Season
.
AUTOMN
;
private
Season
migrationSeasonToReachWinteringOffshore
=
Season
.
AUTOMN
;
/**
* Season to migrate from wintering to summeringOffshoreBasin
* Season to migrate from wintering to summeringOffshoreBasin
*/
private
Season
migrationSeasonToReachSummeringOffshore
=
Season
.
SPRING
;
private
Season
migrationSeasonToReachSummeringOffshore
=
Season
.
SPRING
;
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
((
new
XStream
(
new
DomDriver
()))
.
toXML
(
new
MigrateBetweenOffshores
()));
System
.
out
.
println
((
new
XStream
(
new
DomDriver
())).
toXML
(
new
MigrateBetweenOffshores
()));
}
@Override
public
void
doProcess
(
DiadromousFishGroup
group
)
{
Basin
destination
=
null
;
Basin
destination
=
null
;
if
(
group
.
getEnvironment
().
getTime
().
getSeason
(
group
.
getPilot
())
==
migrationSeasonToReachWinteringOffshore
)
{
for
(
OffshoreBasin
summeringOffshoreBasin
:
group
.
getEnvironment
().
getSummeringOffshoreBasins
())
{
List
<
DiadromousFish
>
fishInSummeringOffshoreBasin
=
summeringOffshoreBasin
.
getFishs
(
group
);
...
...
@@ -56,7 +51,8 @@ public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFis
DiadromousFish
fish
=
fishIterator
.
next
();
//TODO find a more generic way to memorized a basin which differs from riverBasin (i.e. catadromous fish)
// TODO find a more generic way to memorized a basin which differs from riverBasin (i.e.
// catadromous fish)
destination
=
((
RiverBasin
)
fish
.
getMemorisedBasin
()).
getConnectedWinteringOffshoreBasin
();
fish
.
setPosition
(
destination
);
...
...
@@ -66,8 +62,14 @@ public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFis
}
}
}
}
else
if
(
group
.
getEnvironment
().
getTime
().
getSeason
(
group
.
getPilot
())
==
migrationSeasonToReachSummeringOffshore
)
{
// --------------------------------------------------------------------------------------------------
// update the observers
// ------------------------------------------------------------------------------------------------------
((
RIOBasinNetworkWithContinent
)
group
.
getEnvironment
()).
getCobservable
().
fireChanges
((
group
.
getEnvironment
()),
pilot
.
getCurrentTime
());
}
else
if
(
group
.
getEnvironment
().
getTime
().
getSeason
(
group
.
getPilot
())
==
migrationSeasonToReachSummeringOffshore
)
{
for
(
OffshoreBasin
winteringOffshoreBasin
:
group
.
getEnvironment
().
getWinteringOffshoreBasins
())
{
...
...
@@ -79,7 +81,8 @@ public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFis
DiadromousFish
fish
=
fishIterator
.
next
();
//TODO find a more generic way to memorized a basin which differs from riverBasin (i.e. catadromous fish)
// TODO find a more generic way to memorized a basin which differs from riverBasin (i.e.
// catadromous fish)
destination
=
((
RiverBasin
)
fish
.
getMemorisedBasin
()).
getConnectedSummeringOffshoreBasin
();
// add fish with its new position to destination basin
...
...
@@ -90,6 +93,11 @@ public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFis
}
}
}
// --------------------------------------------------------------------------------------------------
// update the observers
// ------------------------------------------------------------------------------------------------------
((
RIOBasinNetworkWithContinent
)
group
.
getEnvironment
()).
getCobservable
().
fireChanges
((
group
.
getEnvironment
()),
pilot
.
getCurrentTime
());
}
}
}
\ No newline at end of file
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