Package org.evoludo.graphics
Class ParaGraph.TraitMap
Object
TraitMap
- All Implemented Interfaces:
BasicTooltipProvider,HasPhase2D.Data2Phase
- Enclosing class:
ParaGraph
public class ParaGraph.TraitMap
extends Object
implements HasPhase2D.Data2Phase, BasicTooltipProvider
Default mapping of data to the phase plane or phase plane projections.
Projections can be the sum of several dynamical variables. Custom
implementations of the
Data2Phase interface can be provided by
modules that implement the HasPhase2D interface.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) booleanFlag indicating whether the axes are fixed.protected doubleThe maximum value of thex-axis.protected doubleThe maximum value of they-axis.protected doubleThe minimum value of thex-axis.protected doubleThe minimum value of they-axis.protected int[]The array of trait indices that are mapped to thex-axis.protected int[]The array of trait indices that are mapped to they-axis. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleandata2Phase(double[] data, Point2D point) Convert data array to point on phase plane.private doublefindMax(RingBuffer<double[]> buffer, int[] idxs) Find the maximum value of the data in the buffer accross all the indices inidxs.private doublefindMin(RingBuffer<double[]> buffer, int[] idxs) Find the minimum value of the data in the buffer accross all the indices inidxs.doublegetMaxX(RingBuffer<double[]> buffer) Return maximum value forx-axis.doublegetMaxY(RingBuffer<double[]> buffer) Return maximum value fory-axis.doublegetMinX(RingBuffer<double[]> buffer) Return minimum value forx-axis.doublegetMinY(RingBuffer<double[]> buffer) Return minimum value fory-axis.getTooltipAt(double x, double y) Get the tooltip at the scaled coordinates(x,y)with the origin in the lower left corner of the graph.int[]Get the array of indices of traits displayed on the horizontal axis of the phase plane.int[]Get the array of indices of traits displayed on the vertical axis of the phase plane.booleanReturn whether axes of the phase plane are customizable.booleanReturn whether multiple traits can be selected for each axis of the phase plane.booleanphase2Data(Point2D point, double[] data) Convert point on phase plane to data array.voidreset()Reset the map.voidsetFixedAxes(boolean hasFixedAxes) Set whether axes of the phase plane are customizable.voidsetTraits(int[] x, int[] y) Allows custom implementations to set the traits displayed on phase plane axes.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BasicTooltipProvider
getTooltipAtMethods inherited from interface HasPhase2D.Data2Phase
getXAxisLabel, getYAxisLabel, hasSetTraits
-
Field Details
-
hasFixedAxes
boolean hasFixedAxesFlag indicating whether the axes are fixed. The default is fixed axes. -
stateX
protected int[] stateXThe array of trait indices that are mapped to thex-axis. -
stateY
protected int[] stateYThe array of trait indices that are mapped to they-axis. -
minX
protected double minXThe minimum value of thex-axis. -
maxX
protected double maxXThe maximum value of thex-axis. -
minY
protected double minYThe minimum value of they-axis. -
maxY
protected double maxYThe maximum value of they-axis.
-
-
Constructor Details
-
TraitMap
public TraitMap()Create new trait map.
-
-
Method Details
-
reset
public void reset()Description copied from interface:HasPhase2D.Data2PhaseReset the map. For maps that implement automatic scaling of the axes this should reset the range of the phase plane.- Specified by:
resetin interfaceHasPhase2D.Data2Phase
-
setTraits
public void setTraits(int[] x, int[] y) Description copied from interface:HasPhase2D.Data2PhaseAllows custom implementations to set the traits displayed on phase plane axes.In multi-species models the traits are numbered sequentially, i.e. if the first species has
nTraitsthen e.g. an index ofnTraits+1refers to the second trait of the second species. Be careful to account for vacant types in density based models.- Specified by:
setTraitsin interfaceHasPhase2D.Data2Phase- Parameters:
x- the array of indices of horizontal trait(s)y- the array of indices of vertical trait(s)
-
getTraitsX
public int[] getTraitsX()Description copied from interface:HasPhase2D.Data2PhaseGet the array of indices of traits displayed on the horizontal axis of the phase plane.- Specified by:
getTraitsXin interfaceHasPhase2D.Data2Phase- Returns:
- the array of indices
-
getTraitsY
public int[] getTraitsY()Description copied from interface:HasPhase2D.Data2PhaseGet the array of indices of traits displayed on the vertical axis of the phase plane.- Specified by:
getTraitsYin interfaceHasPhase2D.Data2Phase- Returns:
- the array of indices
-
hasMultitrait
public boolean hasMultitrait()Description copied from interface:HasPhase2D.Data2PhaseReturn whether multiple traits can be selected for each axis of the phase plane.- Specified by:
hasMultitraitin interfaceHasPhase2D.Data2Phase- Returns:
trueif multiple traits can be selected for each axis- See Also:
-
hasFixedAxes
public boolean hasFixedAxes()Description copied from interface:HasPhase2D.Data2PhaseReturn whether axes of the phase plane are customizable.- Specified by:
hasFixedAxesin interfaceHasPhase2D.Data2Phase- Returns:
trueif axes can be customized- See Also:
-
setFixedAxes
public void setFixedAxes(boolean hasFixedAxes) Description copied from interface:HasPhase2D.Data2PhaseSet whether axes of the phase plane are customizable. Optional implementation. Axes are fixed by default.- Specified by:
setFixedAxesin interfaceHasPhase2D.Data2Phase- Parameters:
hasFixedAxes-trueif axes are fixed
-
data2Phase
Description copied from interface:HasPhase2D.Data2PhaseConvert data array to point on phase plane. Note:dataincludes time atnode[0]and should not be altered. Point on phase plane is returned in user coordinates.- Specified by:
data2Phasein interfaceHasPhase2D.Data2Phase- Parameters:
data- array of data to convertpoint- on phase plane- Returns:
trueupon successful completion of conversion
-
phase2Data
Description copied from interface:HasPhase2D.Data2PhaseConvert point on phase plane to data array.datacontains a copy of the last data point recorded in the buffer (excluding time).- Specified by:
phase2Datain interfaceHasPhase2D.Data2Phase- Parameters:
point- on phase plane to convert (in user coordinates)data- array of data- Returns:
trueupon successful completion of conversion
-
getMinX
Description copied from interface:HasPhase2D.Data2PhaseReturn minimum value forx-axis. Returns0by default.- Specified by:
getMinXin interfaceHasPhase2D.Data2Phase- Parameters:
buffer- the buffer with data points- Returns:
- the lower bound for
x-axis
-
getMaxX
Description copied from interface:HasPhase2D.Data2PhaseReturn maximum value forx-axis. Returns1by default.- Specified by:
getMaxXin interfaceHasPhase2D.Data2Phase- Parameters:
buffer- the buffer with data points- Returns:
- upper bound for
x-axis
-
getMinY
Description copied from interface:HasPhase2D.Data2PhaseReturn minimum value fory-axis. Returns0by default.- Specified by:
getMinYin interfaceHasPhase2D.Data2Phase- Parameters:
buffer- the buffer with data points- Returns:
- the lower bound for
y-axis
-
getMaxY
Description copied from interface:HasPhase2D.Data2PhaseReturn maximum value fory-axis. Returns1by default.- Specified by:
getMaxYin interfaceHasPhase2D.Data2Phase- Parameters:
buffer- the buffer with data points- Returns:
- the upper bound for
y-axis
-
findMin
Find the minimum value of the data in the buffer accross all the indices inidxs.- Parameters:
buffer- the buffer with data pointsidxs- the array of indices- Returns:
- the minimum value
-
findMax
Find the maximum value of the data in the buffer accross all the indices inidxs.- Parameters:
buffer- the buffer with data pointsidxs- the array of indices- Returns:
- the maximum value
-
getTooltipAt
Description copied from interface:BasicTooltipProviderGet the tooltip at the scaled coordinates(x,y)with the origin in the lower left corner of the graph.- Specified by:
getTooltipAtin interfaceBasicTooltipProvider- Parameters:
x- thexcoordinatey- theycoordinate- Returns:
- the tooltip
-