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

    Fields
    Modifier and Type
    Field
    Description
    protected double
    The maximum value of the x-axis.
    protected double
    The maximum value of the y-axis.
    protected double
    The minimum value of the x-axis.
    protected double
    The minimum value of the y-axis.
    protected int[]
    The array of trait indices that are mapped to the x-axis.
    protected int[]
    The array of trait indices that are mapped to the y-axis.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create new trait map.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    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 in idxs.
    private double
    findMin(RingBuffer<double[]> buffer, int[] idxs)
    Find the minimum value of the data in the buffer accross all the indices in idxs.
    double
    getMaxX(RingBuffer<double[]> buffer)
    Return maximum value for x-axis.
    double
    getMaxY(RingBuffer<double[]> buffer)
    Return maximum value for y-axis.
    double
    getMinX(RingBuffer<double[]> buffer)
    Return minimum value for x-axis.
    double
    getMinY(RingBuffer<double[]> buffer)
    Return minimum value for y-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 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[] stateX
      The array of trait indices that are mapped to the x-axis.
    • stateY

      protected int[] stateY
      The array of trait indices that are mapped to the y-axis.
    • minX

      protected double minX
      The minimum value of the x-axis.
    • maxX

      protected double maxX
      The maximum value of the x-axis.
    • minY

      protected double minY
      The minimum value of the y-axis.
    • maxY

      protected double maxY
      The maximum value of the y-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 interface HasPhase2D.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 of nTraits+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 interface HasPhase2D.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 interface HasPhase2D.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 interface HasPhase2D.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 interface HasPhase2D.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 interface HasPhase2D.Data2Phase
      Returns:
      true if axis can be customized
      See Also:
    • data2Phase

      public boolean data2Phase(double[] data, Point2D point)
      Description copied from interface: HasPhase2D.Data2Phase
      Convert data array to point on phase plane. Note: data includes time at node[0] and should not be altered. Point on phase plane is returned in user coordinates.
      Specified by:
      data2Phase in interface HasPhase2D.Data2Phase
      Parameters:
      data - array of data to convert
      point - on phase plane
      Returns:
      true upon successful completion of conversion
    • phase2Data

      public boolean phase2Data(Point2D point, double[] data)
      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 interface HasPhase2D.Data2Phase
      Parameters:
      point - on phase plane to convert (in user coordinates)
      data - array of data
      Returns:
      true upon successful completion of conversion
    • getMinX

      public double getMinX(RingBuffer<double[]> buffer)
      Description copied from interface: HasPhase2D.Data2Phase
      Return minimum value for x-axis. Returns 0 by default.
      Specified by:
      getMinX in interface HasPhase2D.Data2Phase
      Parameters:
      buffer - the buffer with data points
      Returns:
      the lower bound for x-axis
    • getMaxX

      public double getMaxX(RingBuffer<double[]> buffer)
      Description copied from interface: HasPhase2D.Data2Phase
      Return maximum value for x-axis. Returns 1 by default.
      Specified by:
      getMaxX in interface HasPhase2D.Data2Phase
      Parameters:
      buffer - the buffer with data points
      Returns:
      upper bound for x-axis
    • getMinY

      public double getMinY(RingBuffer<double[]> buffer)
      Description copied from interface: HasPhase2D.Data2Phase
      Return minimum value for y-axis. Returns 0 by default.
      Specified by:
      getMinY in interface HasPhase2D.Data2Phase
      Parameters:
      buffer - the buffer with data points
      Returns:
      the lower bound for y-axis
    • getMaxY

      public double getMaxY(RingBuffer<double[]> buffer)
      Description copied from interface: HasPhase2D.Data2Phase
      Return maximum value for y-axis. Returns 1 by default.
      Specified by:
      getMaxY in interface HasPhase2D.Data2Phase
      Parameters:
      buffer - the buffer with data points
      Returns:
      the upper bound for y-axis
    • findMin

      private double findMin(RingBuffer<double[]> buffer, int[] idxs)
      Find the minimum value of the data in the buffer accross all the indices in idxs.
      Parameters:
      buffer - the buffer with data points
      idxs - the array of indices
      Returns:
      the minimum value
    • findMax

      private double findMax(RingBuffer<double[]> buffer, int[] idxs)
      Find the maximum value of the data in the buffer accross all the indices in idxs.
      Parameters:
      buffer - the buffer with data points
      idxs - the array of indices
      Returns:
      the maximum value
    • getTooltipAt

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