Class TraitMap

Object
TraitMap
All Implemented Interfaces:
BasicTooltipProvider, HasPhase2D.Data2Phase

public class 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 Details

    • paraGraph

      private final ParaGraph paraGraph
      The ParaGraph instance.
    • hasFixedAxes

      boolean hasFixedAxes
      Flag indicating whether the axes are fixed. The default is fixed axes.
    • 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

      TraitMap(ParaGraph paraGraph)
      Construct a TraitMap for the given ParaGraph.
      Parameters:
      paraGraph - the ParaGraph instance
  • 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 axes.

      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:
    • hasFixedAxes

      public boolean hasFixedAxes()
      Description copied from interface: HasPhase2D.Data2Phase
      Return whether axes of the phase plane are customizable.
      Specified by:
      hasFixedAxes in interface HasPhase2D.Data2Phase
      Returns:
      true if axes can be customized
      See Also:
    • setFixedAxes

      public void setFixedAxes(boolean hasFixedAxes)
      Description copied from interface: HasPhase2D.Data2Phase
      Set whether axes of the phase plane are customizable. Optional implementation. Axes are fixed by default.
      Specified by:
      setFixedAxes in interface HasPhase2D.Data2Phase
      Parameters:
      hasFixedAxes - true if axes are fixed
    • 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