Class S3Map

Object
S3Map
All Implemented Interfaces:
BasicTooltipProvider
Direct Known Subclasses:
Centipede.CentiMap

public class S3Map extends Object implements BasicTooltipProvider
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

    Fields
    Modifier and Type
    Field
    Description
    (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
    Constructor
    Description
    Create a new mapping of data to simplex projections.
    S3Map(int role, String label)
    Create a new mapping of data to simplex projections for different roles.
  • Method Summary

    Modifier and Type
    Method
    Description
    data2S3(double[] s3, Point2D p)
    Convert the data array to cartesian coordinates of point on simplex.
    data2S3(double s1, double s2, double s3, Point2D p)
    Convert data triplet to cartesian coordinates of point on simplex.
    Get the colors of the traits.
    Get the name of the map.
    getName(int idx)
    Get the name of the traits at the corner with index idx.
    Get the names of the traits.
    int[]
    Get the indices of the traits that span the simplex.
    int
    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
    setColors(Color[] colors)
    Set the colors of the traits.
    void
    setNames(String[] names)
    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 label
      The name of the map.
    • names

      String[] names
      The names of the traits.
    • colors

      Color[] colors
      The colors of the traits.
    • order

      int[] order
      The 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 role
      The role of this map.
    • tip

      double[] tip
      Temporary storage for the simplex coordinates of the tooltip.
  • Constructor Details

    • S3Map

      public S3Map()
      Create a new mapping of data to simplex projections.
    • S3Map

      public S3Map(int role, String label)
      Create a new mapping of data to simplex projections for different roles. The role is specified by the index role and names label.
      Parameters:
      role - the role of the data
      label - the name of the map
  • Method Details

    • getLabel

      public String 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 entry order[0] denotes the index of the trait in the lower left corner of the simplex, the second entry order[1] the index of the trait in the lower right corner, and the last entry order[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 of nTraits+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 entry order[0] denotes the index of the trait in the lower left corner of the simplex, the second entry order[1] the index of the trait in the lower right corner, and the last entry order[2] the index of the trait in the top corner.
      Returns:
      the array of indices
    • setNames

      public void setNames(String[] names)
      Set the names of the traits.
      Parameters:
      names - the names of the traits
    • getNames

      public String[] getNames()
      Get the names of the traits.
      Returns:
      the names of the traits
    • getName

      public String getName(int idx)
      Get the name of the traits at the corner with index idx.
      Parameters:
      idx - the index of the corner
      Returns:
      the names of the traits
    • setColors

      public void setColors(Color[] colors)
      Set the colors of the traits.
      Parameters:
      colors - the colors of the traits
    • getColors

      public Color[] getColors()
      Get the colors of the traits.
      Returns:
      the colors of the traits
    • data2S3

      public Point2D data2S3(double[] s3, Point2D p)
      Convert the data array to cartesian coordinates of point on simplex. The conversion observes the selection and order of traits.

      Notes:

      1. The array s includes the time at s[0] and should not be altered.
      2. The point on simplex is returned in scaled user coordinates in [0,1].
      3. 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 simplex
      p - the cartesian coordinates of the point on the simplex
      Returns:
      the point p
      See Also:
    • data2S3

      public Point2D data2S3(double s1, double s2, double s3, Point2D p)
      Convert data triplet to cartesian coordinates of point on simplex.

      Notes:

      1. The point on simplex is returned in scaled user coordinates in [0,1].
      2. In order to deal with projections onto \(S_3\) subspaces the coordinates s1, s2, s3, do not need to sum up to 1.0.
      Parameters:
      s1 - the index of the trait in the lower left corner of the simplex
      s2 - the index of the trait in the lower right corner of the simplex
      s3 - the index of the trait in the top corner of the simplex
      p - the cartesian coordinates of the point on the simplex
      Returns:
      the point p
    • 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 point
      y - the y-coordinate of the point
      s - the point on the simplex
      Returns:
      the array s
    • getTooltipAt

      public String getTooltipAt(double sx, double sy)
      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 interface BasicTooltipProvider
      Parameters:
      sx - the x coordinate
      sy - the y coordinate
      Returns:
      the tooltip