|
artoflife pre0.1.0-dev | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.artoflife.gui.population.VerticalFitnessPolicy
A RecordPositionPolicy
that positions Individuals vertically
according to their Fitness (scaled to some range) and horizontally by record
index with a constant individual width to fit the population's ideal size
across the entire width of the parent view. The ideal size is collected from
the population when this is first associated with its PopulationView in
setPopulationView(PopulationView)
and when the bounds changes
during updateBounds()
so that transient fluctuations in population
size don't immediately change all IndividualRecord positioning.
Field Summary | |
protected int |
individualWidth
Calculated in updateBounds() . |
protected int |
numberOfIndividuals
Number of individuals to fit across width. |
protected int |
spacer
Horizontal space between individuals. |
protected PopulationView |
view
The parent PopulationView that uses this policy. |
Constructor Summary | |
VerticalFitnessPolicy(float minFitness,
float maxFitness)
Create with a defined min and max fitness to define the vertical scale. |
Method Summary | |
protected float |
getFitnessForY(int y)
|
float |
getMaxFitness()
|
float |
getMinFitness()
|
int |
getSpacer()
|
protected int |
getX(org.artoflife.gui.population.IndividualRecord record,
int index,
int individualWidth)
|
protected int |
getY(org.artoflife.gui.population.IndividualRecord record,
int individualWidth,
int height)
|
void |
positionAfterChange(org.artoflife.gui.population.IndividualRecord record,
int index)
Reposition a record (at a given index within the view) whose Individual changed in some way. |
void |
positionNew(org.artoflife.gui.population.IndividualRecord record,
int index)
Find a position for an Individual newly added to the view at a specified index and set the IndividualRecord's state appropriately. |
void |
positionNewAt(org.artoflife.gui.population.IndividualRecord record,
int index,
java.awt.Point location)
Position a record at a certain location (if possible), altering the Individual within the passed IndividualRecord if necessary to make it fit at that location. |
void |
repositionForViewBounds(org.artoflife.gui.population.IndividualRecord record,
int index,
int x,
int y,
int width,
int height)
Reposition an IndividualRecord (at a given index within the view) so it fits in the parent view's new bounds passed in as parameters. |
void |
setMaxFitness(float maxFitness)
|
void |
setMinFitness(float minFitness)
|
void |
setPopulationView(PopulationView view)
|
void |
setSpacer(int spacer)
|
void |
updateBounds()
The bounds of the owning view have changed so can update cached dimensions here. |
void |
updatePopulation()
Population being viewed has changed in some way so might update some cached dimensions here if the population size has changed for example. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected PopulationView view
protected int numberOfIndividuals
setPopulationView(PopulationView)
and updateBounds()
.
protected int spacer
protected int individualWidth
updateBounds()
.
Constructor Detail |
public VerticalFitnessPolicy(float minFitness, float maxFitness)
Method Detail |
public float getMaxFitness()
public void setMaxFitness(float maxFitness)
public float getMinFitness()
public void setMinFitness(float minFitness)
public int getSpacer()
public void setSpacer(int spacer)
public void positionNew(org.artoflife.gui.population.IndividualRecord record, int index)
RecordPositionPolicy
positionNew
in interface RecordPositionPolicy
org.artoflife.gui.paintable.view.RecordPositionPolicy#positionNew(IndividualRecord, int)
public void positionNewAt(org.artoflife.gui.population.IndividualRecord record, int index, java.awt.Point location)
RecordPositionPolicy
positionNewAt
in interface RecordPositionPolicy
RecordPositionPolicy.positionNewAt(org.artoflife.gui.population.IndividualRecord, int, java.awt.Point)
public void positionAfterChange(org.artoflife.gui.population.IndividualRecord record, int index)
RecordPositionPolicy
positionAfterChange
in interface RecordPositionPolicy
org.artoflife.gui.paintable.view.RecordPositionPolicy#positionAfterChange(IndividualRecord)
public void repositionForViewBounds(org.artoflife.gui.population.IndividualRecord record, int index, int x, int y, int width, int height)
RecordPositionPolicy
repositionForViewBounds
in interface RecordPositionPolicy
org.artoflife.gui.paintable.view.RecordPositionPolicy#repositionToBounds(IndividualRecord, int, int, int, int)
public void updateBounds()
RecordPositionPolicy
RecordPositionPolicy.repositionForViewBounds(org.artoflife.gui.population.IndividualRecord, int, int, int, int, int)
.
updateBounds
in interface RecordPositionPolicy
org.artoflife.gui.paintable.view.RecordPositionPolicy#setNewBounds(int, int, int, int)
public void setPopulationView(PopulationView view)
setPopulationView
in interface RecordPositionPolicy
view
- the parent PopulationView
using this policy.org.artoflife.gui.paintable.view.RecordPositionPolicy#setPopulationView(PopulationView)
public void updatePopulation()
RecordPositionPolicy
updatePopulation
in interface RecordPositionPolicy
RecordPositionPolicy.updatePopulation()
protected int getX(org.artoflife.gui.population.IndividualRecord record, int index, int individualWidth)
protected int getY(org.artoflife.gui.population.IndividualRecord record, int individualWidth, int height)
protected float getFitnessForY(int y)
|
artoflife pre0.1.0-dev | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |