Class ModuloAxis

All Implemented Interfaces:
Serializable, Cloneable, PublicCloneable

public class ModuloAxis extends NumberAxis
An axis that displays numerical values within a fixed range using a modulo calculation.
See Also:
  • Field Details

    • fixedRange

      private Range fixedRange
      The fixed range for the axis - all data values will be mapped to this range using a modulo calculation.
    • displayStart

      private double displayStart
      The display start value (this will sometimes be > displayEnd, in which case the axis wraps around at some point in the middle of the axis).
    • displayEnd

      private double displayEnd
      The display end value.
  • Constructor Details

    • ModuloAxis

      public ModuloAxis(String label, Range fixedRange)
      Creates a new axis.
      Parameters:
      label - the axis label (null permitted).
      fixedRange - the fixed range (null not permitted).
  • Method Details

    • getDisplayStart

      public double getDisplayStart()
      Returns the display start value.
      Returns:
      The display start value.
    • getDisplayEnd

      public double getDisplayEnd()
      Returns the display end value.
      Returns:
      The display end value.
    • setDisplayRange

      public void setDisplayRange(double start, double end)
      Sets the display range. The values will be mapped to the fixed range if necessary.
      Parameters:
      start - the start value.
      end - the end value.
    • autoAdjustRange

      protected void autoAdjustRange()
      This method should calculate a range that will show all the data values. For now, it just sets the axis range to the fixedRange.
      Overrides:
      autoAdjustRange in class NumberAxis
    • valueToJava2D

      public double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge)
      Translates a data value to a Java2D coordinate.
      Overrides:
      valueToJava2D in class NumberAxis
      Parameters:
      value - the value.
      area - the area.
      edge - the edge.
      Returns:
      A Java2D coordinate.
      See Also:
    • trans

      private double trans(double value, Rectangle2D area, RectangleEdge edge)
      A regular translation from a data value to a Java2D value.
      Parameters:
      value - the value.
      area - the data area.
      edge - the edge along which the axis lies.
      Returns:
      The Java2D coordinate.
    • transStart

      private double transStart(double value, Rectangle2D area, RectangleEdge edge, double length1, double length2)
      Translates a data value to a Java2D value for the first section of the axis.
      Parameters:
      value - the value.
      area - the data area.
      edge - the edge along which the axis lies.
      length1 - the length of the first section.
      length2 - the length of the second section.
      Returns:
      The Java2D coordinate.
    • transEnd

      private double transEnd(double value, Rectangle2D area, RectangleEdge edge, double length1, double length2)
      Translates a data value to a Java2D value for the second section of the axis.
      Parameters:
      value - the value.
      area - the data area.
      edge - the edge along which the axis lies.
      length1 - the length of the first section.
      length2 - the length of the second section.
      Returns:
      The Java2D coordinate.
    • mapValueToFixedRange

      private double mapValueToFixedRange(double value)
      Maps a data value into the fixed range.
      Parameters:
      value - the value.
      Returns:
      The mapped value.
    • java2DToValue

      public double java2DToValue(double java2DValue, Rectangle2D area, RectangleEdge edge)
      Translates a Java2D coordinate into a data value.
      Overrides:
      java2DToValue in class NumberAxis
      Parameters:
      java2DValue - the Java2D coordinate.
      area - the area.
      edge - the edge.
      Returns:
      The Java2D coordinate.
      See Also:
    • getDisplayLength

      private double getDisplayLength()
      Returns the display length for the axis.
      Returns:
      The display length.
    • getDisplayCentralValue

      private double getDisplayCentralValue()
      Returns the central value of the current display range.
      Returns:
      The central value.
    • resizeRange

      public void resizeRange(double percent)
      Increases or decreases the axis range by the specified percentage about the central value and sends an AxisChangeEvent to all registered listeners.

      To double the length of the axis range, use 200% (2.0). To halve the length of the axis range, use 50% (0.5).

      Overrides:
      resizeRange in class ValueAxis
      Parameters:
      percent - the resize factor.
      See Also:
    • resizeRange

      public void resizeRange(double percent, double anchorValue)
      Increases or decreases the axis range by the specified percentage about the specified anchor value and sends an AxisChangeEvent to all registered listeners.

      To double the length of the axis range, use 200% (2.0). To halve the length of the axis range, use 50% (0.5).

      Overrides:
      resizeRange in class ValueAxis
      Parameters:
      percent - the resize factor.
      anchorValue - the new central value after the resize.
      See Also:
    • lengthToJava2D

      public double lengthToJava2D(double length, Rectangle2D area, RectangleEdge edge)
      Converts a length in data coordinates into the corresponding length in Java2D coordinates.
      Overrides:
      lengthToJava2D in class ValueAxis
      Parameters:
      length - the length.
      area - the plot area.
      edge - the edge along which the axis lies.
      Returns:
      The length in Java2D coordinates.
    • equals

      public boolean equals(Object obj)
      Tests this axis for equality with an arbitrary object.
      Overrides:
      equals in class NumberAxis
      Parameters:
      obj - the object (null permitted).
      Returns:
      A boolean.