Commit 5572ae83 authored by Dumoulin Nicolas's avatar Dumoulin Nicolas
Browse files

compilation fixes

1 merge request!1Add Svn history
This commit is part of merge request !1. Comments created here will be created in the context of that merge request.
Showing with 8 additions and 58 deletions
+8 -58
...@@ -6,9 +6,6 @@ import fr.cemagref.simaqualife.kernel.AquaNismsGroup; ...@@ -6,9 +6,6 @@ import fr.cemagref.simaqualife.kernel.AquaNismsGroup;
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 pikelake.pikes.Pike; import pikelake.pikes.Pike;
//import predatorprey.preys.Prey;
import umontreal.iro.lecuyer.probdist.UniformDist;
import umontreal.iro.lecuyer.randvar.UniformGen;
public class Grid extends Grid2D<Cell, Individual> { public class Grid extends Grid2D<Cell, Individual> {
...@@ -17,65 +14,29 @@ public class Grid extends Grid2D<Cell, Individual> { ...@@ -17,65 +14,29 @@ public class Grid extends Grid2D<Cell, Individual> {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
/**
* <code>preyCarryingCapacity</code> number of preys that a cell can support
*/
// private int preyCarryingCapacity;
private double habitatValue0 = .25;
private double habitatValue1 = .5;
private double habitatValue2 = 1;
transient private UniformGen uniformGen;
transient private double[] habitatValues;
@InitTransientParameters @InitTransientParameters
public void initTransientParameters(Pilot pilot) { public void initTransientParameters(Pilot pilot) {
this.pos = neighborsType.getPos(); // TODO
habitatValues = new double[3];
habitatValues[0] = habitatValue0;
habitatValues[1] = habitatValue1;
habitatValues[2] = habitatValue2;
UniformGen uniformGen = new UniformGen(pilot.getRandomStream(), new UniformDist(0, habitatValues.length - 1));
grid = new Cell[gridWidth * gridHeight];
for (int i = 0; i < grid.length; i++) {
double hab = habitatValues[(int) Math.round(uniformGen.nextDouble())];
grid[i] = new Cell(i, hab); // , preyCarryingCapacity); /////////////////////////////////////////////////////////////////
}
} }
@Override @Override
public void addAquaNism(Individual ind, AquaNismsGroup group) { public void addAquaNism(Individual ind, AquaNismsGroup group) {
super.addAquaNism(ind, group); super.addAquaNism(ind, group);
// if (ind instanceof Prey) { ///////////////////////////////////////////////////////////////// ind.getPosition().addPike((Pike) ind);
// ind.getPosition().addPrey((Prey) ind); /////////////////////////////////////////////////////////////////
// } else { /////////////////////////////////////////////////////////////////
ind.getPosition().addPike((Pike) ind);
// } /////////////////////////////////////////////////////////////////
} }
@Override @Override
public void moveAquaNism(Individual ind, AquaNismsGroup group, Cell dest) { public void moveAquaNism(Individual ind, AquaNismsGroup group, Cell dest) {
super.moveAquaNism(ind, group, dest); super.moveAquaNism(ind, group, dest);
this.removeAquaNism(ind, group); this.removeAquaNism(ind, group);
// if (ind instanceof Prey) { ///////////////////////////////////////////////////////////////// dest.addPike((Pike) ind);
// dest.addPrey((Prey) ind); /////////////////////////////////////////////////////////////////
// } else { /////////////////////////////////////////////////////////////////
dest.addPike((Pike) ind);
// } /////////////////////////////////////////////////////////////////
} }
@Override @Override
public void removeAquaNism(Individual ind, AquaNismsGroup group) { public void removeAquaNism(Individual ind, AquaNismsGroup group) {
super.removeAquaNism(ind, group); super.removeAquaNism(ind, group);
// if (ind instanceof Prey) { ///////////////////////////////////////////////////////////////// ind.getPosition().removePike((Pike) ind);
// ind.getPosition().removePrey((Prey) ind); /////////////////////////////////////////////////////////////////
// } else { /////////////////////////////////////////////////////////////////
ind.getPosition().removePike((Pike) ind);
// } /////////////////////////////////////////////////////////////////
} }
} }
...@@ -41,7 +41,6 @@ public class GridObserver extends ObserverListener implements Configurable, Draw ...@@ -41,7 +41,6 @@ public class GridObserver extends ObserverListener implements Configurable, Draw
private String title; private String title;
private Color envColor = Color.GREEN; private Color envColor = Color.GREEN;
private Color preyColor = Color.BLUE;
private Color pikeColor = Color.RED; private Color pikeColor = Color.RED;
@Description (name="Background color",tooltip="Background color") @Description (name="Background color",tooltip="Background color")
private Color bgColor = Color.WHITE; private Color bgColor = Color.WHITE;
...@@ -163,16 +162,6 @@ public class GridObserver extends ObserverListener implements Configurable, Draw ...@@ -163,16 +162,6 @@ public class GridObserver extends ObserverListener implements Configurable, Draw
// filling the cell with a color corresponding to the habitat level // filling the cell with a color corresponding to the habitat level
g.setColor(new Color(envColor.getRed(),envColor.getGreen(),envColor.getBlue(),cellsAlpha[i])); g.setColor(new Color(envColor.getRed(),envColor.getGreen(),envColor.getBlue(),cellsAlpha[i]));
g2d.fill(cellRect); g2d.fill(cellRect);
// drawing preys
if (grid.getCells()[i].getPreys().size() > 0) {
g.setColor(preyColor);
preyDiameterX = cellRect.width*(double)grid.getCells()[i].getPreys().size()/grid.getCells()[i].getPreyCarryingCapacity();
preyDiameterY = cellRect.height*(double)grid.getCells()[i].getPreys().size()/grid.getCells()[i].getPreyCarryingCapacity();
g.fillOval((int)(cellRect.x + (cellRect.width - preyDiameterX)/2), (int)(cellRect.y + (cellRect.height - preyDiameterY)/2), (int)preyDiameterX, (int)preyDiameterY);
// represention as pie ... not very pretty
/*g2d.fill(new Arc2D.Double(cellRect,90,-360*((double)grid.getCells()[i].getPreys().size()/grid.getCells()[i].getPreyCarryingCapacity()),Arc2D.PIE));
g2d.draw(new Arc2D.Double(cellRect,90,360,Arc2D.OPEN));*/
}
// drawing pikes presence // drawing pikes presence
if (grid.getCells()[i].getPikes().size() > 0) { if (grid.getCells()[i].getPikes().size() > 0) {
g.setColor(pikeColor); g.setColor(pikeColor);
...@@ -192,7 +181,7 @@ public class GridObserver extends ObserverListener implements Configurable, Draw ...@@ -192,7 +181,7 @@ public class GridObserver extends ObserverListener implements Configurable, Draw
int y = (int)(e.getY()/cellSizeY); int y = (int)(e.getY()/cellSizeY);
int x = (int)(e.getX()/cellSizeX); int x = (int)(e.getX()/cellSizeX);
Cell cell = grid.getCells()[grid.getGridWidth()*Math.min(y,grid.getGridHeight()-1) + Math.min(x,grid.getGridWidth()-1)]; Cell cell = grid.getCells()[grid.getGridWidth()*Math.min(y,grid.getGridHeight()-1) + Math.min(x,grid.getGridWidth()-1)];
label.setText("( "+x+" , "+y+" ) : habitat value = "+cell.getHabitatQuality()+" / "+cell.getPreys().size() + " preys ( max = "+cell.getPreyCarryingCapacity()+") and " + cell.getPikes().size()+ " pikes."); label.setText("( "+x+" , "+y+" ) : habitat value = "+cell.getHabitatQuality()+" / " + cell.getPikes().size()+ " pikes.");
} }
public static void main (String [] args){ public static void main (String [] args){
......
package pikelake.pikes; package pikelake.pikes;
import fr.cemagref.simaqualife.pilot.Pilot; import fr.cemagref.simaqualife.pilot.Pilot;
import Pike.Cell; import pikelake.Cell;
import Pike.Individual; import pikelake.Individual;
public class Pike extends Individual { public class Pike extends Individual {
......
...@@ -2,7 +2,7 @@ package pikelake.pikes; ...@@ -2,7 +2,7 @@ package pikelake.pikes;
import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess; import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess;
public class PlopProcess extends AquaNismsGroupProcess<Pike,PikesGroup> { public class PikePlopProcess extends AquaNismsGroupProcess<Pike,PikesGroup> {
private int temporisation = 3000; // in ms private int temporisation = 3000; // in ms
......
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