Commit 88afa0f5 authored by guillaume.garbay's avatar guillaume.garbay
Browse files

No commit message

No commit message
1 merge request!1Add Svn history
Showing with 8885 additions and 98 deletions
+8885 -98
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
......@@ -23,5 +18,10 @@
</attributes>
</classpathentry>
<classpathentry kind="lib" path="C:/Users/guillaume.garbay/workspace/Donnees/Lib/jsuntimes-1.0.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.compiler.source=1.7
......@@ -15,7 +15,7 @@
</pikelake.environment.FichierMarnage>
<pikelake.environment.AreaMovement>
<choixDist>1</choixDist> <!-- 0 => distMin; 1 => distMoy; 2 => distMax -->
<choixDist>2</choixDist> <!-- 0 => distMin; 1 => distMoy; 2 => distMax -->
</pikelake.environment.AreaMovement>
<pikelake.pikes.PikesPopulateProcess>
......@@ -45,9 +45,11 @@
<fr.cemagref.simaqualife.kernel.processes.FireAquaNismsChangesToObservers />
</processesEachStep>
<processesAtEnd>
</processesAtEnd>
<processesAtEnd>
<pikelake.SaveLocation>
</pikelake.SaveLocation>
</processesAtEnd>
</processes>
<useCemetery>false</useCemetery>
</pikelake.pikes.PikesGroup>
......
......@@ -44,7 +44,8 @@
</observers>
</fr.cemagref.observation.kernel.ObservablesHandler>
</entry>
<entry>
<!-- entry>
<java-class>pikelake.pikes.Pike</java-class>
<fr.cemagref.observation.kernel.ObservablesHandler>
<observers>
......@@ -56,6 +57,7 @@
</observers>
</fr.cemagref.observation.kernel.ObservablesHandler>
</entry>
<entry>
<java-class>pikelake.pikes.PikesGroup</java-class>
<fr.cemagref.observation.kernel.ObservablesHandler>
......@@ -67,6 +69,6 @@
</fr.cemagref.observation.observers.jfreechart.TemporalSerieChart>
</observers>
</fr.cemagref.observation.kernel.ObservablesHandler>
</entry>
</entry-->
</hashtable>
This diff is collapsed.
......@@ -12,7 +12,6 @@ import pikelake.environment.AreaMovement;
import pikelake.environment.FichierMarnage;
import pikelake.environment.Time;
import pikelake.pikes.Pike;
import fr.cemagref.simaqualife.extensions.spatial2D.Grid2D;
import fr.cemagref.simaqualife.kernel.AquaNismsGroup;
import fr.cemagref.simaqualife.kernel.util.TransientParameters.InitTransientParameters;
......@@ -117,7 +116,7 @@ public class Grid extends Grid2D<Cell, Individual> {
public List<Cell> getNeighbours(Cell position) {
List<Cell> neighbours = new ArrayList<Cell>();
List<String> listeCoord = null;
int[][] listeCoord;
int xPike = 0, yPike = 0;
// Calcul des coordonnees (x, y) a partir de l'Id de la maille
......@@ -174,10 +173,14 @@ public class Grid extends Grid2D<Cell, Individual> {
}
// Calcul des mailles comprises dans le lac
for (String liste : listeCoord) {
String[] coord = liste.split(" ");
boolean stop = false;
for (int cpt=0; cpt<listeCoord[0].length; cpt++) {
if (listeCoord[0][cpt] == 0 & listeCoord[1][cpt] == 0 & stop == true) break;
if (listeCoord[0][cpt] == 0 & listeCoord[1][cpt] == 0) stop = true;
// Calcul de l'indice de la maille partir des coordonnees (x,y)
int newCell = xPike + Integer.parseInt(coord[0]) + (yPike + Integer.parseInt(coord[1])) * gridWidth;
int newCell = xPike + listeCoord[0][cpt] + (yPike + listeCoord[1][cpt]) * gridWidth;
// Test si l'indice calcule appartient la grille totale
if (newCell >= 0 & newCell <= (gridWidth * gridHeight)-2)
......
......@@ -4,6 +4,7 @@ import java.awt.BasicStroke;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Shape;
......@@ -61,9 +62,7 @@ public class GridObserver extends ObserverListener implements Configurable, Draw
}
public void valueChanged(ObservablesHandler clObservable, Object instance, long t) {
// modif pour effectuer les dplacements
display.repaint();
}
......@@ -167,6 +166,7 @@ public class GridObserver extends ObserverListener implements Configurable, Draw
// the bounds of a cell
cellRect = new Rectangle2D.Double((int)cellSizeX*(i%grid.getGridWidth()), (int)cellSizeY*(i/grid.getGridHeight()), (int)cellSizeX, (int)cellSizeY);
// filling the cell with a color corresponding to the habitat level
g.setColor(new Color(envColor.getRed(),envColor.getGreen(),envColor.getBlue(),cellsAlpha[i]));
g2d.fill(cellRect);
// drawing pikes presence
......
......@@ -14,16 +14,15 @@ import pikelake.pikes.PikesGroup;
public class Marnage extends AquaNismsGroupProcess<Pike,PikesGroup> {
public static String marnageOld = null, marnageNew = null;
public static String saison = "";
@Override
public void doProcess(PikesGroup object) {
Grid grid = (Grid) pilot.getAquaticWorld().getEnvironment();
grid = grid.getGrid();
marnageNew = FichierMarnage.dateMarnage[Time.jourMois][Time.mois][Time.heure];
if (!marnageNew.equals(marnageOld))
majCote(grid);
if (!marnageNew.equals(marnageOld) | !saison.equals(Time.getSeason()))
majCote(grid);
}
public void majCote (Grid grid) {
......@@ -33,11 +32,11 @@ public class Marnage extends AquaNismsGroupProcess<Pike,PikesGroup> {
double hsiStd = 0, hsiMoy = 0;
int idCell = 0, yPike = 0, xPike = 0;
marnageOld = marnageNew;
saison = Time.getSeason();
// Initialisation de toute la grille avec hsi = -1
for (int cptCell = 0; cptCell < (grid.getGridWidth() * grid.getGridHeight() - 1); cptCell++)
grid.setCell(cptCell, -1);
// Lecture fichier contenant les HSI de toutes les mailles
String filePath = "data/input/HSI/hsi_BRO" + Time.getSeason() + marnageNew + ".txt";
Scanner scanner;
......@@ -47,7 +46,6 @@ public class Marnage extends AquaNismsGroupProcess<Pike,PikesGroup> {
// On boucle sur chaque ligne detecte
while (scanner.hasNextLine()) {
line = scanner.nextLine();
// Decoupage ligne : id, hsiStd, hsiMoy
sLigne = new StringTokenizer (line);
if (sLigne.hasMoreTokens())
......@@ -56,18 +54,14 @@ public class Marnage extends AquaNismsGroupProcess<Pike,PikesGroup> {
hsiStd = Double.parseDouble(sLigne.nextToken());
if (sLigne.hasMoreTokens())
hsiMoy = Double.parseDouble(sLigne.nextToken());
// Conversion idCell en coordonnees (x, y)
// (x, y) avec les id de cellules de 0 n-1
yPike = (int) Math.floor(idCell / grid.getGridWidth());
xPike = (int) idCell - (yPike * grid.getGridWidth());
// Inversion des coordonnees en Y (place l'origine en bas gauche)
yPike = (grid.getGridHeight()-1) - yPike ;
// Conversion des coordonnees (x, y) en idCell
idCell = xPike + yPike * grid.getGridWidth();
// Initialisation du hsi de la cellule(idCell)
grid.setCell(idCell, hsiMoy);
}
......
package pikelake;
import java.io.File;
import java.io.FileWriter;
import java.text.DecimalFormat;
import pikelake.pikes.Pike;
import pikelake.pikes.PikeTrackLocation;
import pikelake.pikes.PikesGroup;
import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess;
public class SaveLocation extends AquaNismsGroupProcess<Pike, PikesGroup> {
@Override
public void doProcess(PikesGroup group) {
final String chemin = "data/output/Positions.txt";
final File fichier = new File(chemin);
String ligne = null;
DecimalFormat df = new DecimalFormat("00");
try {
// Creation du fichier
fichier.createNewFile();
// creation d'un writer (un écrivain)
final FileWriter writer = new FileWriter(fichier);
try {
// Creation de la ligne d'en-tete du fichier
ligne = "PasTps \t\t Date \t\t";
for (int i=1; i!=Pike.cptIndividu; i++) {
ligne = ligne + "Ind " + i + " \t";
}
writer.write(ligne + "\n\r");
for (int compteur = 0; compteur < PikeTrackLocation.trackLocation[1].length; compteur++) {
// Recuperation pas de la simulation + de la date
ligne = String.valueOf(PikeTrackLocation.trackDate[0][compteur]) + "\t\t";
ligne = ligne + PikeTrackLocation.trackDate[1][compteur] + "/" +
df.format(PikeTrackLocation.trackDate[2][compteur]) + "/" +
df.format(PikeTrackLocation.trackDate[3][compteur]) + "/" +
df.format(PikeTrackLocation.trackDate[4][compteur]) + "\t";
// enregistrement des positions
for (int i=1; i<PikeTrackLocation.trackLocation.length; i++) {
ligne = ligne + PikeTrackLocation.trackLocation[i][compteur] + "\t";;
}
ligne = ligne + "\n";
writer.write(ligne);
}
} finally {
writer.close();
}
} catch (Exception e) {
System.out.println("Impossible de creer le fichier d'enregistrement des positions.");
}
}
}
......@@ -2,8 +2,6 @@ package pikelake.environment;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;
......@@ -16,25 +14,26 @@ public class AreaMovement extends AquaNismsGroupProcess<Pike, PikesGroup> {
int distMin = 0, distMoy = 0, distMax = 0, std = 0, choixDist = 0;
String saison = null, phaseJour = null;
public static List<String> areaPrinAube = new ArrayList<String>();
public static List<String> areaPrinJour = new ArrayList<String>();
public static List<String> areaPrinNuit = new ArrayList<String>();
public static List<String> areaPrinCrep = new ArrayList<String>();
public static int[][] areaPrinAube; // = new ArrayList<String>();
public static int[][] areaPrinJour; // = new ArrayList<String>();
public static int[][] areaPrinNuit; // = new ArrayList<String>();
public static int[][] areaPrinCrep; // = new ArrayList<String>();
public static List<String> areaEteAube = new ArrayList<String>();
public static List<String> areaEteJour = new ArrayList<String>();
public static List<String> areaEteNuit = new ArrayList<String>();
public static List<String> areaEteCrep = new ArrayList<String>();
public static int[][] areaEteAube; // = new ArrayList<String>();
public static int[][] areaEteJour; // = new ArrayList<String>();
public static int[][] areaEteNuit; // = new ArrayList<String>();
public static int[][] areaEteCrep; // = new ArrayList<String>();
public static List<String> areaAutAube = new ArrayList<String>();
public static List<String> areaAutJour = new ArrayList<String>();
public static List<String> areaAutNuit = new ArrayList<String>();
public static List<String> areaAutCrep = new ArrayList<String>();
public static int[][] areaAutAube; // = new ArrayList<String>();
public static int[][] areaAutJour; // = new ArrayList<String>();
public static int[][] areaAutNuit; // = new ArrayList<String>();
public static int[][] areaAutCrep; // = new ArrayList<String>();
public static int[][] areaHivAube; // = new ArrayList<String>();
public static int[][] areaHivJour; // = new ArrayList<String>();
public static int[][] areaHivNuit; // = new ArrayList<String>();
public static int[][] areaHivCrep; // = new ArrayList<String>();
public static List<String> areaHivAube = new ArrayList<String>();
public static List<String> areaHivJour = new ArrayList<String>();
public static List<String> areaHivNuit = new ArrayList<String>();
public static List<String> areaHivCrep = new ArrayList<String>();
@Override
public void doProcess(PikesGroup object) {
......@@ -93,26 +92,31 @@ public class AreaMovement extends AquaNismsGroupProcess<Pike, PikesGroup> {
// TODO Auto-generated catch block
e.printStackTrace();
}
//System.out.println();
}
public List<String> choixDistArea () {
List<String> temp = new ArrayList<String>();
public int[][] choixDistArea () {
int[][] temp = null; // = new ArrayList<String>();
if (choixDist == 0) temp = calculationArea (distMin);
else if (choixDist == 1) temp = calculationArea (distMoy);
else if (choixDist == 2) temp = calculationArea (distMax);
return temp;
}
public List<String> calculationArea (int distance) {
List<String> area = new ArrayList<String>();
int xi = 0, yi = 0;
public int[][] calculationArea (int distance) {
int[][] area = new int[2][80000]; // = new ArrayList<String>();
int xi = 0, yi = 0, cpt = 0;
// Conversion distance en nombre de cellule
int distCell = (int) Math.round(distance/10.);
// Calcul des coordonnees (x,y) des cellules pour une distance donnee
for (xi = -distCell; xi <= distCell; xi++) {
yi = (int) Math.round(Math.sqrt(distCell*distCell - xi*xi));
for (int j = -yi; j <= yi; j++) {
area.add(xi + " " + j);
area[0][cpt] = xi;
area[1][cpt] = j;
cpt++;
}
}
return area;
......
package pikelake.pikes;
import java.io.File;
import java.io.FileWriter;
import pikelake.environment.Time;
import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess;
......@@ -12,49 +9,20 @@ public class PikeTrackLocation extends AquaNismsGroupProcess<Pike, PikesGroup> {
//private static int simDuration = 8760;
public static int trackLocation[][] = new int [11][8760];
public static int trackDate[][] = new int[5][8760];
public static int cpt = 0;
public void doProcess(PikesGroup group) {
trackDate[0][cpt] = (int) group.getPilot().getCurrentTime();
trackDate[1][cpt] = Time.annee;
trackDate[2][cpt] = Time.mois;
trackDate[3][cpt] = Time.jourMois;
trackDate[4][cpt] = Time.heure;
for (Pike pike : group.getAquaNismsList())
trackLocation[pike.idIndividu][cpt] = pike.getPosition().getIndex();
cpt++;
}
public void doEnd (PikesGroup group) {
final String chemin = "data/output/Positions.txt";
final File fichier = new File(chemin);
String ligne = null;
try {
// Creation du fichier
fichier.createNewFile();
// creation d'un writer (un écrivain)
final FileWriter writer = new FileWriter(fichier);
try {
// Creation de la ligne d'en-tete du fichier
ligne = "Pas de temps \t Date(yyyy/mm/jj/hh) \t";
for (int i=1; i!=Pike.cptIndividu; i++) {
ligne = ligne + "Individu " + i + " \t";
}
writer.write(ligne + "\n\r");
for (int compteur = 1; compteur < trackLocation[1].length; compteur++) {
// Recuperation pas de la simulation + de la date
ligne = String.valueOf(group.getPilot().getCurrentTime()) + "\t";
ligne = ligne + Time.annee + "/" + Time.mois + "/" + Time.jourMois + "/" + Time.heure + "\t";
// enregistrement des positions
for (int i=1; i<trackLocation.length; i++) {
ligne = ligne + trackLocation[i][compteur] + "\t";;
}
writer.write(ligne + "\n\r");
}
} finally {
writer.close();
}
} catch (Exception e) {
System.out.println("Impossible de creer le fichier d'enregistrement des positions.");
}
}
}
Supports Markdown
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