Class CyclicNumberAxis

  • All Implemented Interfaces:
    Serializable, Cloneable, PublicCloneable, ChartElement

    public class CyclicNumberAxis
    extends NumberAxis
    This class extends NumberAxis and handles cycling. Traditional representation of data in the range x0..x1
    |-------------------------|
    x0                       x1
    
    Here, the range bounds are at the axis extremities. With cyclic axis, however, the time is split in "cycles", or "time frames", or the same duration : the period. A cycle axis cannot by definition handle a larger interval than the period :
    x1 - x0 >= period
    . Thus, at most a full period can be represented with such an axis. The cycle bound is the number between x0 and x1 which marks the beginning of new time frame:
    |---------------------|----------------------------|
    x0                   cb                           x1
    <---previous cycle---><-------current cycle-------->
    
    It is actually a multiple of the period, plus optionally a start offset:
    cb = n * period + offset
    Thus, by definition, two consecutive cycle bounds period apart, which is precisely why it is called a period. The visual representation of a cyclic axis is like that:
    |----------------------------|---------------------|
    cb                         x1|x0                  cb
    <-------current cycle--------><---previous cycle--->
    
    The cycle bound is at the axis ends, then current cycle is shown, then the last cycle. When using dynamic data, the visual effect is the current cycle erases the last cycle as x grows. Then, the next cycle bound is reached, and the process starts over, erasing the previous cycle. A Cyclic item renderer is provided to do exactly this.
    See Also:
    Serialized Form
    • Constructor Detail

      • CyclicNumberAxis

        public CyclicNumberAxis​(double period)
        Creates a CycleNumberAxis with the given period.
        Parameters:
        period - the period.
      • CyclicNumberAxis

        public CyclicNumberAxis​(double period,
                                double offset)
        Creates a CycleNumberAxis with the given period and offset.
        Parameters:
        period - the period.
        offset - the offset.
      • CyclicNumberAxis

        public CyclicNumberAxis​(double period,
                                String label)
        Creates a named CycleNumberAxis with the given period.
        Parameters:
        period - the period.
        label - the label.
      • CyclicNumberAxis

        public CyclicNumberAxis​(double period,
                                double offset,
                                String label)
        Creates a named CycleNumberAxis with the given period and offset.
        Parameters:
        period - the period.
        offset - the offset.
        label - the label.
    • Method Detail

      • isAdvanceLineVisible

        public boolean isAdvanceLineVisible()
        The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.
        Returns:
        A boolean.
      • setAdvanceLineVisible

        public void setAdvanceLineVisible​(boolean visible)
        The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.
        Parameters:
        visible - the flag.
      • getAdvanceLinePaint

        public Paint getAdvanceLinePaint()
        The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.
        Returns:
        The paint (never null).
      • setAdvanceLinePaint

        public void setAdvanceLinePaint​(Paint paint)
        The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.
        Parameters:
        paint - the paint (null not permitted).
      • getAdvanceLineStroke

        public Stroke getAdvanceLineStroke()
        The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.
        Returns:
        The stroke (never null).
      • setAdvanceLineStroke

        public void setAdvanceLineStroke​(Stroke stroke)
        The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.
        Parameters:
        stroke - the stroke (null not permitted).
      • isBoundMappedToLastCycle

        public boolean isBoundMappedToLastCycle()
        The cycle bound can be associated either with the current or with the last cycle. It's up to the user's choice to decide which, as this is just a convention. By default, the cycle bound is mapped to the current cycle.
        Note that this has no effect on visual appearance, as the cycle bound is mapped successively for both axis ends. Use this function for correct results in translateValueToJava2D.
        Returns:
        true if the cycle bound is mapped to the last cycle, false if it is bound to the current cycle (default)
      • setBoundMappedToLastCycle

        public void setBoundMappedToLastCycle​(boolean boundMappedToLastCycle)
        The cycle bound can be associated either with the current or with the last cycle. It's up to the user's choice to decide which, as this is just a convention. By default, the cycle bound is mapped to the current cycle.
        Note that this has no effect on visual appearance, as the cycle bound is mapped successively for both axis ends. Use this function for correct results in valueToJava2D.
        Parameters:
        boundMappedToLastCycle - Set it to true to map the cycle bound to the last cycle.
      • selectHorizontalAutoTickUnit

        protected void selectHorizontalAutoTickUnit​(Graphics2D g2,
                                                    Rectangle2D drawArea,
                                                    Rectangle2D dataArea,
                                                    RectangleEdge edge)
        Selects a tick unit when the axis is displayed horizontally.
        Parameters:
        g2 - the graphics device.
        drawArea - the drawing area.
        dataArea - the data area.
        edge - the side of the rectangle on which the axis is displayed.
      • selectVerticalAutoTickUnit

        protected void selectVerticalAutoTickUnit​(Graphics2D g2,
                                                  Rectangle2D drawArea,
                                                  Rectangle2D dataArea,
                                                  RectangleEdge edge)
        Selects a tick unit when the axis is displayed vertically.
        Parameters:
        g2 - the graphics device.
        drawArea - the drawing area.
        dataArea - the data area.
        edge - the side of the rectangle on which the axis is displayed.
      • refreshVerticalTicks

        protected List refreshVerticalTicks​(Graphics2D g2,
                                            Rectangle2D dataArea,
                                            RectangleEdge edge)
        Builds a list of ticks for the axis. This method is called when the axis is at the left or right of the chart (so the axis is "vertical").
        Parameters:
        g2 - the graphics device.
        dataArea - the data area.
        edge - the edge.
        Returns:
        A list of ticks.
      • centerRange

        public void centerRange​(double value)
        Centers the range about the given value.
        Overrides:
        centerRange in class ValueAxis
        Parameters:
        value - the data value.
      • setRange

        public void setRange​(Range range,
                             boolean turnOffAutoRange,
                             boolean notify)
        Sets a new axis range. The period is extended to fit the range size, if necessary.
        Overrides:
        setRange in class ValueAxis
        Parameters:
        range - the range.
        turnOffAutoRange - switch off the auto range.
        notify - notify?
        See Also:
        ValueAxis.setRange(Range, boolean, boolean)
      • getCycleBound

        public double getCycleBound()
        The cycle bound is defined as the higest value x such that "offset + period * i = x", with i and integer and x < range.getUpperBound() This is the value which is at both ends of the axis : x...up|low...x The values from x to up are the valued in the current cycle. The values from low to x are the valued in the previous cycle.
        Returns:
        The cycle bound.
      • getOffset

        public double getOffset()
        The cycle bound is a multiple of the period, plus optionally a start offset.
        cb = n * period + offset
        Returns:
        The current offset.
        See Also:
        getCycleBound()
      • setOffset

        public void setOffset​(double offset)
        The cycle bound is a multiple of the period, plus optionally a start offset.
        cb = n * period + offset
        Parameters:
        offset - The offset to set.
        See Also:
        getCycleBound()
      • getPeriod

        public double getPeriod()
        The cycle bound is a multiple of the period, plus optionally a start offset.
        cb = n * period + offset
        Returns:
        The current period.
        See Also:
        getCycleBound()
      • setPeriod

        public void setPeriod​(double period)
        The cycle bound is a multiple of the period, plus optionally a start offset.
        cb = n * period + offset
        Parameters:
        period - The period to set.
        See Also:
        getCycleBound()
      • draw

        public AxisState draw​(Graphics2D g2,
                              double cursor,
                              Rectangle2D plotArea,
                              Rectangle2D dataArea,
                              RectangleEdge edge,
                              PlotRenderingInfo plotState)
        Draws the axis.
        Overrides:
        draw in class NumberAxis
        Parameters:
        g2 - the graphics device (null not permitted).
        cursor - the cursor position.
        plotArea - the plot area (null not permitted).
        dataArea - the data area (null not permitted).
        edge - the edge (null not permitted).
        plotState - collects information about the plot (null permitted).
        Returns:
        The axis state (never null).
      • equals

        public boolean equals​(Object obj)
        Tests the axis for equality with another object.
        Overrides:
        equals in class NumberAxis
        Parameters:
        obj - the object to test against.
        Returns:
        A boolean.