Commit 0d6d37f2 authored by patrick.lambert's avatar patrick.lambert
Browse files

Merge branch 'BasinImprovement' into develop

parents c4249470 f4f8b041
<hashtable> <hashtable>
<entry> <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> <fr.cemagref.observation.kernel.ObservablesHandler>
<observers> <observers>
<environment.RIOBasinNetworkObserverWithContinent> <environment.RIOBasinNetworkObserverWithContinent>
<title>North East America</title> <title>North East America</title>
<threshold>1000000</threshold> <threshold>1000000</threshold>
<colorScaleEnum>RedsScale</colorScaleEnum>
</environment.RIOBasinNetworkObserverWithContinent> </environment.RIOBasinNetworkObserverWithContinent>
<environment.RIOBasinNetworkObserverPresence> <environment.RIOBasinNetworkObserverPresence>
......
...@@ -36,6 +36,7 @@ public abstract class RIOBasinNetwork extends BasinNetwork { ...@@ -36,6 +36,7 @@ public abstract class RIOBasinNetwork extends BasinNetwork {
@InitTransientParameters @InitTransientParameters
public void initTransientParameters(Pilot pilot) { public void initTransientParameters(Pilot pilot) {
time = new Time(); time = new Time();
} }
......
...@@ -41,7 +41,7 @@ public class RIOBasinNetworkObserverWithContinent extends ObserverListener ...@@ -41,7 +41,7 @@ public class RIOBasinNetworkObserverWithContinent extends ObserverListener
private double threshold = 13000000.; private double threshold = 13000000.;
@Description(name = "Color scale", tooltip = "") @Description(name = "Color scale", tooltip = "")
public ColorScaleEnum colorScaleEnum = ColorScaleEnum.RedsScale; private ColorScaleEnum colorScaleEnum = ColorScaleEnum.RedsScale;
// a basin network // a basin network
private transient RIOBasinNetworkWithContinent bn; private transient RIOBasinNetworkWithContinent bn;
...@@ -299,7 +299,9 @@ public class RIOBasinNetworkObserverWithContinent extends ObserverListener ...@@ -299,7 +299,9 @@ public class RIOBasinNetworkObserverWithContinent extends ObserverListener
for (DiadromousFishGroup group : basin.getGroups()) { for (DiadromousFishGroup group : basin.getGroups()) {
abundance += basin.getEffective(group); 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.) { if (abundance == 0.) {
g.setColor(Color.WHITE); g.setColor(Color.WHITE);
} else { } else {
......
...@@ -24,6 +24,7 @@ import com.thoughtworks.xstream.XStream; ...@@ -24,6 +24,7 @@ import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver; import com.thoughtworks.xstream.io.xml.DomDriver;
import environment.OffshoreBasin.OffshoreBasinFunction; import environment.OffshoreBasin.OffshoreBasinFunction;
import fr.cemagref.observation.kernel.ObservablesHandler;
import fr.cemagref.simaqualife.kernel.util.TransientParameters.InitTransientParameters; import fr.cemagref.simaqualife.kernel.util.TransientParameters.InitTransientParameters;
import fr.cemagref.simaqualife.pilot.Pilot; import fr.cemagref.simaqualife.pilot.Pilot;
import miscellaneous.QueueMemoryMap; import miscellaneous.QueueMemoryMap;
...@@ -55,6 +56,13 @@ public class RIOBasinNetworkWithContinent extends RIOBasinNetwork { ...@@ -55,6 +56,13 @@ public class RIOBasinNetworkWithContinent extends RIOBasinNetwork {
private transient Map<String, Path2D.Double> mapContinent; private transient Map<String, Path2D.Double> mapContinent;
protected transient ObservablesHandler cobservable;
public ObservablesHandler getCobservable() {
return cobservable;
}
class Record implements Comparable<Record> { class Record implements Comparable<Record> {
private int order; private int order;
...@@ -215,6 +223,10 @@ public class RIOBasinNetworkWithContinent extends RIOBasinNetwork { ...@@ -215,6 +223,10 @@ public class RIOBasinNetworkWithContinent extends RIOBasinNetwork {
super.initTransientParameters(pilot); super.initTransientParameters(pilot);
if (cobservable == null) {
cobservable = pilot.addObservable(this.getClass());
}
FileReader reader; FileReader reader;
Scanner scanner; Scanner scanner;
...@@ -387,7 +399,7 @@ public class RIOBasinNetworkWithContinent extends RIOBasinNetwork { ...@@ -387,7 +399,7 @@ public class RIOBasinNetworkWithContinent extends RIOBasinNetwork {
basin_id = Integer.valueOf(fields[0]); // gid basin_id = Integer.valueOf(fields[0]); // gid
name = fields[1]; name = fields[1];
function = fields[2]; 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)); OffshoreBasin offshorebasin = new OffshoreBasin(basin_id, name, OffshoreBasinFunction.valueOf(function));
......
...@@ -11,10 +11,10 @@ import org.openide.util.lookup.ServiceProvider; ...@@ -11,10 +11,10 @@ import org.openide.util.lookup.ServiceProvider;
import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver; import com.thoughtworks.xstream.io.xml.DomDriver;
import environment.RIOBasinNetwork;
import environment.RiverBasin;
import environment.InshoreBasin; import environment.InshoreBasin;
import environment.RIOBasinNetwork; import environment.RIOBasinNetwork;
import environment.RIOBasinNetworkWithContinent;
import environment.RiverBasin;
import environment.Time; import environment.Time;
import environment.Time.Season; import environment.Time.Season;
import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess; import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess;
...@@ -142,7 +142,7 @@ public class DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin extends Di ...@@ -142,7 +142,7 @@ public class DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin extends Di
for (InshoreBasin departure : group.getEnvironment().getSeaBasins()) { for (InshoreBasin departure : group.getEnvironment().getSeaBasins()) {
RiverBasin homingDestination = (RiverBasin) bn.getAssociatedRiverBasin(departure); RiverBasin homingDestination = bn.getAssociatedRiverBasin(departure);
List<DiadromousFish> fishes = departure.getFishs(group); List<DiadromousFish> fishes = departure.getFishs(group);
if (fishes != null) { if (fishes != null) {
...@@ -248,10 +248,16 @@ public class DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin extends Di ...@@ -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(" total abundance in river basins: " + group.getFishEffective());
System.out.println( System.out.println(" female spawners: " + group.getFemaleSpawnerEffective() + " \tmale spawners: "
"female spawners: " + group.getFemaleSpawnerEffective() + " \tmale spawners: " + group.getMaleSpawnerEffective()); + group.getMaleSpawnerEffective());
// --------------------------------------------------------------------------------------------------
// update the observers
// ------------------------------------------------------------------------------------------------------
((RIOBasinNetworkWithContinent) group.getEnvironment()).getCobservable().fireChanges((group.getEnvironment()),
pilot.getCurrentTime());
} }
} }
} }
package species; 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.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver; import com.thoughtworks.xstream.io.xml.DomDriver;
import environment.Basin; import environment.Basin;
import environment.OffshoreBasin; import environment.OffshoreBasin;
import environment.RIOBasinNetworkWithContinent;
import environment.RiverBasin; import environment.RiverBasin;
import environment.Time;
import environment.OffshoreBasin.OffshoreBasinFunction;
import environment.Time.Season; import environment.Time.Season;
import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess; 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) @ServiceProvider(service = AquaNismsGroupProcess.class)
public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFish, DiadromousFishGroup> { public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFish, DiadromousFishGroup> {
/** /**
* Season to migrate from summering to winteringOffshoreBasin * Season to migrate from summering to winteringOffshoreBasin
*/ */
...@@ -34,10 +30,10 @@ public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFis ...@@ -34,10 +30,10 @@ public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFis
public static void main(String[] args) { public static void main(String[] args) {
System.out.println((new XStream(new DomDriver())) System.out.println((new XStream(new DomDriver())).toXML(new MigrateBetweenOffshores()));
.toXML(new MigrateBetweenOffshores()));
} }
@Override @Override
public void doProcess(DiadromousFishGroup group) { public void doProcess(DiadromousFishGroup group) {
...@@ -45,7 +41,6 @@ public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFis ...@@ -45,7 +41,6 @@ public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFis
if (group.getEnvironment().getTime().getSeason(group.getPilot()) == migrationSeasonToReachWinteringOffshore) { if (group.getEnvironment().getTime().getSeason(group.getPilot()) == migrationSeasonToReachWinteringOffshore) {
for (OffshoreBasin summeringOffshoreBasin : group.getEnvironment().getSummeringOffshoreBasins()) { for (OffshoreBasin summeringOffshoreBasin : group.getEnvironment().getSummeringOffshoreBasins()) {
List<DiadromousFish> fishInSummeringOffshoreBasin = summeringOffshoreBasin.getFishs(group); List<DiadromousFish> fishInSummeringOffshoreBasin = summeringOffshoreBasin.getFishs(group);
...@@ -56,7 +51,8 @@ public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFis ...@@ -56,7 +51,8 @@ public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFis
DiadromousFish fish = fishIterator.next(); 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(); destination = ((RiverBasin) fish.getMemorisedBasin()).getConnectedWinteringOffshoreBasin();
fish.setPosition(destination); fish.setPosition(destination);
...@@ -66,8 +62,14 @@ public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFis ...@@ -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()) { for (OffshoreBasin winteringOffshoreBasin : group.getEnvironment().getWinteringOffshoreBasins()) {
...@@ -79,7 +81,8 @@ public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFis ...@@ -79,7 +81,8 @@ public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFis
DiadromousFish fish = fishIterator.next(); 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(); destination = ((RiverBasin) fish.getMemorisedBasin()).getConnectedSummeringOffshoreBasin();
// add fish with its new position to destination basin // add fish with its new position to destination basin
...@@ -90,6 +93,11 @@ public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFis ...@@ -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
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