Package org.evoludo.simulator.views
Class S3Map
Object
S3Map
- All Implemented Interfaces:
BasicTooltipProvider
- Direct Known Subclasses:
Centipede.CentiMap
Default mapping of data to simplex \(S_3\) projections. Custom
implementations of the
Data2S3
interface can be provided by modules
that implement the HasS3
interface.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) Color[]
The colors of the traits.(package private) String
The name of the map.(package private) String[]
The names of the traits.(package private) int[]
The indices of the traits on the simplex.(package private) int
The role of this map.(package private) double[]
Temporary storage for the simplex coordinates of the tooltip. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConvert the data array to cartesian coordinates of point on simplex.Convert data triplet to cartesian coordinates of point on simplex.Color[]
Get the colors of the traits.getLabel()
Get the name of the map.getName
(int idx) Get the name of the traits at the corner with indexidx
.String[]
getNames()
Get the names of the traits.int[]
getOrder()
Get the indices of the traits that span the simplex.int
getRole()
Get the role of the map.getTooltipAt
(double sx, double sy) Get the tooltip at the scaled coordinates(x,y)
with the origin in the lower left corner of the graph.double[]
s32Data
(double x, double y, double[] s) Convert scaled cartesian coordinates of point on simplex to data array.void
Set the colors of the traits.void
Set the names of the traits.void
setOrder
(int[] order) Set the indices of the traits displayed on the simplex.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface BasicTooltipProvider
getTooltipAt
-
Field Details
-
label
String labelThe name of the map. -
names
String[] namesThe names of the traits. -
colors
Color[] colorsThe colors of the traits. -
order
int[] orderThe indices of the traits on the simplex. The first entry refers to the lower left corner, the second to the lower right and the last entry to the top corner. -
role
int roleThe role of this map. -
tip
double[] tipTemporary storage for the simplex coordinates of the tooltip.
-
-
Constructor Details
-
S3Map
public S3Map()Create a new mapping of data to simplex projections. -
S3Map
Create a new mapping of data to simplex projections for different roles. The role is specified by the indexrole
and nameslabel
.- Parameters:
role
- the role of the datalabel
- the name of the map
-
-
Method Details
-
getLabel
Get the name of the map.- Returns:
- the name of the map
-
getRole
public int getRole()Get the role of the map.- Returns:
- the role of the map
-
setOrder
public void setOrder(int[] order) Set the indices of the traits displayed on the simplex. The first entryorder[0]
denotes the index of the trait in the lower left corner of the simplex, the second entryorder[1]
the index of the trait in the lower right corner, and the last entryorder[2]
the index of the trait in the top corner.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.- Parameters:
order
- the array of indices
-
getOrder
public int[] getOrder()Get the indices of the traits that span the simplex. The first entryorder[0]
denotes the index of the trait in the lower left corner of the simplex, the second entryorder[1]
the index of the trait in the lower right corner, and the last entryorder[2]
the index of the trait in the top corner.- Returns:
- the array of indices
-
setNames
Set the names of the traits.- Parameters:
names
- the names of the traits
-
getNames
Get the names of the traits.- Returns:
- the names of the traits
-
getName
Get the name of the traits at the corner with indexidx
.- Parameters:
idx
- the index of the corner- Returns:
- the names of the traits
-
setColors
Set the colors of the traits.- Parameters:
colors
- the colors of the traits
-
getColors
Get the colors of the traits.- Returns:
- the colors of the traits
-
data2S3
Convert the data array to cartesian coordinates of point on simplex. The conversion observes the selection and order of traits.Notes:
- The array
s
includes the time ats[0]
and should not be altered. - The point on simplex is returned in scaled user coordinates in
[0,1]
. - In order to deal with projections onto \(S_3\) subspaces the coordinates
do not need to sum up to
1.0
.
- Parameters:
s3
- the data array indicating a point on the simplexp
- the cartesian coordinates of the point on the simplex- Returns:
- the point
p
- See Also:
- The array
-
data2S3
Convert data triplet to cartesian coordinates of point on simplex.Notes:
- The point on simplex is returned in scaled user coordinates in
[0,1]
. - In order to deal with projections onto \(S_3\) subspaces the coordinates
s1
,s2
,s3
, do not need to sum up to1.0
.
- Parameters:
s1
- the index of the trait in the lower left corner of the simplexs2
- the index of the trait in the lower right corner of the simplexs3
- the index of the trait in the top corner of the simplexp
- the cartesian coordinates of the point on the simplex- Returns:
- the point
p
- The point on simplex is returned in scaled user coordinates in
-
s32Data
public double[] s32Data(double x, double y, double[] s) Convert scaled cartesian coordinates of point on simplex to data array. The coordinates are in[0,1]
.Note: The array
data
contains a copy of the last data point recorded in the buffer (excluding time).- Parameters:
x
- the x-coordinate of the pointy
- the y-coordinate of the points
- the point on the simplex- Returns:
- the array
s
-
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:
sx
- thex
coordinatesy
- they
coordinate- Returns:
- the tooltip
-