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 TypeFieldDescriptionprotected double
The maximum value of thex
-axis.protected double
The maximum value of they
-axis.protected double
The minimum value of thex
-axis.protected double
The 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 TypeMethodDescriptionboolean
data2Phase
(double[] data, Point2D point) Convert data array to point on phase plane.private double
findMax
(RingBuffer<double[]> buffer, int[] idxs) Find the maximum value of the data in the buffer accross all the indices inidxs
.private double
findMin
(RingBuffer<double[]> buffer, int[] idxs) Find the minimum value of the data in the buffer accross all the indices inidxs
.double
getMaxX
(RingBuffer<double[]> buffer) Return maximum value forx
-axis.double
getMaxY
(RingBuffer<double[]> buffer) Return maximum value fory
-axis.double
getMinX
(RingBuffer<double[]> buffer) Return minimum value forx
-axis.double
getMinY
(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.boolean
Return whether axis of the phase plane are customizable.boolean
Return whether multiple traits can be selected for each axis of the phase plane.boolean
phase2Data
(Point2D point, double[] data) Convert point on phase plane to data array.void
reset()
Reset the map.void
setTraits
(int[] x, int[] y) Allows custom implementations to set the traits displayed on phase plane axis.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface BasicTooltipProvider
getTooltipAt
Methods inherited from interface HasPhase2D.Data2Phase
getXAxisLabel, getYAxisLabel, hasSetTraits
-
Field Details
-
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.Data2Phase
Reset the map. For maps that implement automatic scaling of the axes this should reset the range of the phase plane.- Specified by:
reset
in interfaceHasPhase2D.Data2Phase
-
setTraits
public void setTraits(int[] x, int[] y) Description copied from interface:HasPhase2D.Data2Phase
Allows custom implementations to set the traits displayed on phase plane axis.In multi-species models the traits are numbered sequentially, i.e. if the first species has
nTraits
then e.g. an index ofnTraits+1
refers to the second trait of the second species. Be careful to account for vacant types in density based models.- Specified by:
setTraits
in 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.Data2Phase
Get the array of indices of traits displayed on the horizontal axis of the phase plane.- Specified by:
getTraitsX
in interfaceHasPhase2D.Data2Phase
- Returns:
- the array of indices
-
getTraitsY
public int[] getTraitsY()Description copied from interface:HasPhase2D.Data2Phase
Get the array of indices of traits displayed on the vertical axis of the phase plane.- Specified by:
getTraitsY
in interfaceHasPhase2D.Data2Phase
- Returns:
- the array of indices
-
hasMultitrait
public boolean hasMultitrait()Description copied from interface:HasPhase2D.Data2Phase
Return whether multiple traits can be selected for each axis of the phase plane.- Specified by:
hasMultitrait
in interfaceHasPhase2D.Data2Phase
- Returns:
true
if multiple traits can be selected for each axis- See Also:
-
hasFixedAxis
public boolean hasFixedAxis()Description copied from interface:HasPhase2D.Data2Phase
Return whether axis of the phase plane are customizable.- Specified by:
hasFixedAxis
in interfaceHasPhase2D.Data2Phase
- Returns:
true
if axis can be customized- See Also:
-
data2Phase
Description copied from interface:HasPhase2D.Data2Phase
Convert data array to point on phase plane. Note:data
includes time atnode[0]
and should not be altered. Point on phase plane is returned in user coordinates.- Specified by:
data2Phase
in interfaceHasPhase2D.Data2Phase
- Parameters:
data
- array of data to convertpoint
- on phase plane- Returns:
true
upon successful completion of conversion
-
phase2Data
Description copied from interface:HasPhase2D.Data2Phase
Convert point on phase plane to data array.data
contains a copy of the last data point recorded in the buffer (excluding time).- Specified by:
phase2Data
in interfaceHasPhase2D.Data2Phase
- Parameters:
point
- on phase plane to convert (in user coordinates)data
- array of data- Returns:
true
upon successful completion of conversion
-
getMinX
Description copied from interface:HasPhase2D.Data2Phase
Return minimum value forx
-axis. Returns0
by default.- Specified by:
getMinX
in interfaceHasPhase2D.Data2Phase
- Parameters:
buffer
- the buffer with data points- Returns:
- the lower bound for
x
-axis
-
getMaxX
Description copied from interface:HasPhase2D.Data2Phase
Return maximum value forx
-axis. Returns1
by default.- Specified by:
getMaxX
in interfaceHasPhase2D.Data2Phase
- Parameters:
buffer
- the buffer with data points- Returns:
- upper bound for
x
-axis
-
getMinY
Description copied from interface:HasPhase2D.Data2Phase
Return minimum value fory
-axis. Returns0
by default.- Specified by:
getMinY
in interfaceHasPhase2D.Data2Phase
- Parameters:
buffer
- the buffer with data points- Returns:
- the lower bound for
y
-axis
-
getMaxY
Description copied from interface:HasPhase2D.Data2Phase
Return maximum value fory
-axis. Returns1
by default.- Specified by:
getMaxY
in 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:BasicTooltipProvider
Get the tooltip at the scaled coordinates(x,y)
with the origin in the lower left corner of the graph.- Specified by:
getTooltipAt
in interfaceBasicTooltipProvider
- Parameters:
x
- thex
coordinatey
- they
coordinate- Returns:
- the tooltip
-