Package org.jfree.chart.axis
Class CyclicNumberAxis
java.lang.Object
org.jfree.chart.axis.Axis
org.jfree.chart.axis.ValueAxis
org.jfree.chart.axis.NumberAxis
org.jfree.chart.axis.CyclicNumberAxis
- All Implemented Interfaces:
Serializable
,Cloneable
,org.jfree.util.PublicCloneable
public class CyclicNumberAxis extends NumberAxis
This class extends NumberAxis and handles cycling. Traditional representation
of data in the range x0..x1
|-------------------------| x0 x1Here, 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 + offsetThus, 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
-
Field Summary
Fields Modifier and Type Field Description static Paint
DEFAULT_ADVANCE_LINE_PAINT
The default axis line paint.static Stroke
DEFAULT_ADVANCE_LINE_STROKE
The default axis line stroke.Fields inherited from class org.jfree.chart.axis.NumberAxis
DEFAULT_AUTO_RANGE_INCLUDES_ZERO, DEFAULT_AUTO_RANGE_STICKY_ZERO, DEFAULT_TICK_UNIT, DEFAULT_VERTICAL_TICK_LABELS
Fields inherited from class org.jfree.chart.axis.ValueAxis
DEFAULT_AUTO_RANGE, DEFAULT_AUTO_RANGE_MINIMUM_SIZE, DEFAULT_AUTO_TICK_UNIT_SELECTION, DEFAULT_INVERTED, DEFAULT_LOWER_BOUND, DEFAULT_LOWER_MARGIN, DEFAULT_RANGE, DEFAULT_UPPER_BOUND, DEFAULT_UPPER_MARGIN, MAXIMUM_TICK_COUNT
Fields inherited from class org.jfree.chart.axis.Axis
DEFAULT_AXIS_LABEL_FONT, DEFAULT_AXIS_LABEL_INSETS, DEFAULT_AXIS_LABEL_PAINT, DEFAULT_AXIS_LINE_PAINT, DEFAULT_AXIS_LINE_STROKE, DEFAULT_AXIS_VISIBLE, DEFAULT_TICK_LABEL_FONT, DEFAULT_TICK_LABEL_INSETS, DEFAULT_TICK_LABEL_PAINT, DEFAULT_TICK_LABELS_VISIBLE, DEFAULT_TICK_MARK_INSIDE_LENGTH, DEFAULT_TICK_MARK_OUTSIDE_LENGTH, DEFAULT_TICK_MARK_PAINT, DEFAULT_TICK_MARK_STROKE, DEFAULT_TICK_MARKS_VISIBLE
-
Constructor Summary
Constructors Constructor Description CyclicNumberAxis(double period)
Creates a CycleNumberAxis with the given period.CyclicNumberAxis(double period, double offset)
Creates a CycleNumberAxis with the given period and offset.CyclicNumberAxis(double period, double offset, String label)
Creates a named CycleNumberAxis with the given period and offset.CyclicNumberAxis(double period, String label)
Creates a named CycleNumberAxis with the given period. -
Method Summary
Modifier and Type Method Description void
centerRange(double value)
Centers the range about the given value.AxisState
draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge, PlotRenderingInfo plotState)
Draws the axis.boolean
equals(Object object)
Tests the axis for equality with another object.Paint
getAdvanceLinePaint()
The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.Stroke
getAdvanceLineStroke()
The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.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.double
getOffset()
The cycle bound is a multiple of the period, plus optionally a start offset.double
getPeriod()
The cycle bound is a multiple of the period, plus optionally a start offset.boolean
isAdvanceLineVisible()
The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.boolean
isBoundMappedToLastCycle()
The cycle bound can be associated either with the current or with the last cycle.double
java2DToValue(double java2DValue, Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
Converts a coordinate from Java 2D space to data space.List
refreshHorizontalTicks(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
Builds a list of ticks for the axis.List
refreshVerticalTicks(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
Builds a list of ticks for the axis.AxisSpace
reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, org.jfree.ui.RectangleEdge edge, AxisSpace space)
Reserve some space on each axis side because we draw a centered label at each extremity.void
setAdvanceLinePaint(Paint advanceLinePaint)
The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.void
setAdvanceLineStroke(Stroke advanceLineStroke)
The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.void
setAdvanceLineVisible(boolean advanceLineVisible)
The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.void
setAutoRangeMinimumSize(double size, boolean notify)
This function is nearly useless since the auto range is fixed for this class to the period The period is extended if necessary to fit the minimum size.void
setBoundMappedToLastCycle(boolean boundMappedToLastCycle)
The cycle bound can be associated either with the current or with the last cycle.void
setFixedAutoRange(double length)
The auto range is fixed for this class to the period by default.void
setOffset(double offset)
The cycle bound is a multiple of the period, plus optionally a start offset.void
setPeriod(double period)
The cycle bound is a multiple of the period, plus optionally a start offset.void
setRange(Range range, boolean turnOffAutoRange, boolean notify)
Sets a new axis range.double
valueToJava2D(double value, Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
Translates a value from data space to Java 2D space.Methods inherited from class org.jfree.chart.axis.NumberAxis
autoRangeIncludesZero, autoRangeStickyZero, calculateHighestVisibleTickValue, calculateLowestVisibleTickValue, calculateVisibleTickCount, clone, configure, createIntegerTickUnits, createIntegerTickUnits, createStandardTickUnits, createStandardTickUnits, getDecimalFormat, getMarkerBand, getNumberFormatOverride, getTickUnit, refreshTicks, setAutoRangeIncludesZero, setAutoRangeStickyZero, setMarkerBand, setNumberFormatOverride, setTickUnit, setTickUnit, stringReplace, translateJava2DToValue, translateValueToJava2D
Methods inherited from class org.jfree.chart.axis.ValueAxis
getAutoRangeMinimumSize, getDownArrow, getFixedAutoRange, getLeftArrow, getLowerBound, getLowerMargin, getMaximumAxisValue, getMinimumAxisValue, getRange, getRightArrow, getStandardTickUnits, getUpArrow, getUpperBound, getUpperMargin, isAutoRange, isAutoTickUnitSelection, isInverted, isNegativeArrowVisible, isPositiveArrowVisible, isVerticalTickLabels, reserveSpace, resizeRange, resizeRange, setAutoRange, setAutoRangeMinimumSize, setAutoTickUnitSelection, setAutoTickUnitSelection, setDownArrow, setInverted, setLeftArrow, setLowerBound, setLowerMargin, setMaximumAxisValue, setMinimumAxisValue, setNegativeArrowVisible, setPositiveArrowVisible, setRange, setRange, setRangeAboutValue, setRangeWithMargins, setRangeWithMargins, setRangeWithMargins, setRightArrow, setStandardTickUnits, setUpArrow, setUpperBound, setUpperMargin, setVerticalTickLabels, translateJava2DtoValue, zoomRange
Methods inherited from class org.jfree.chart.axis.Axis
addChangeListener, getAxisLinePaint, getAxisLineStroke, getFixedDimension, getLabel, getLabelAngle, getLabelFont, getLabelInsets, getLabelPaint, getPlot, getTickLabelFont, getTickLabelInsets, getTickLabelPaint, getTickMarkInsideLength, getTickMarkOutsideLength, getTickMarkPaint, getTickMarkStroke, isAxisLineVisible, isTickLabelsVisible, isTickMarksVisible, isVisible, removeChangeListener, setAxisLinePaint, setAxisLineStroke, setAxisLineVisible, setFixedDimension, setLabel, setLabelAngle, setLabelFont, setLabelInsets, setLabelPaint, setPlot, setTickLabelFont, setTickLabelInsets, setTickLabelPaint, setTickLabelsVisible, setTickMarkInsideLength, setTickMarkOutsideLength, setTickMarkPaint, setTickMarkStroke, setTickMarksVisible, setVisible
-
Field Details
-
DEFAULT_ADVANCE_LINE_STROKE
The default axis line stroke. -
DEFAULT_ADVANCE_LINE_PAINT
The default axis line paint.
-
-
Constructor Details
-
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
Creates a named CycleNumberAxis with the given period.- Parameters:
period
- the period.label
- the label.
-
CyclicNumberAxis
Creates a named CycleNumberAxis with the given period and offset.- Parameters:
period
- the period.offset
- the offset.label
- the label.
-
-
Method Details
-
getAdvanceLinePaint
The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.- Returns:
- the advance line Paint.
-
setAdvanceLinePaint
The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.- Parameters:
advanceLinePaint
- The new advance line Paint to set.
-
getAdvanceLineStroke
The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.- Returns:
- the advance line Stroke.
-
setAdvanceLineStroke
The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.- Parameters:
advanceLineStroke
- The advance line Stroke to set.
-
isAdvanceLineVisible
public boolean isAdvanceLineVisible()The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.- Returns:
- true if the the advance line is visible.
-
setAdvanceLineVisible
public void setAdvanceLineVisible(boolean advanceLineVisible)The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.- Parameters:
advanceLineVisible
- The advance line will show if set to true
-
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 translateValueToJava2D.- Parameters:
boundMappedToLastCycle
- Set it to true to map the cycle bound to the last cycle.
-
refreshHorizontalTicks
public List refreshHorizontalTicks(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)Builds a list of ticks for the axis. This method is called when the axis is at the top or bottom of the chart (so the axis is "horizontal").- Parameters:
g2
- the graphics device.cursor
- the cursor position.plotArea
- the plot area.dataArea
- the data area.edge
- the edge.- Returns:
- a list of ticks.
-
refreshVerticalTicks
public List refreshVerticalTicks(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, org.jfree.ui.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.cursor
- the cursor position.plotArea
- the plot area.dataArea
- the data area.edge
- the edge.- Returns:
- a list of ticks.
-
java2DToValue
public double java2DToValue(double java2DValue, Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)Converts a coordinate from Java 2D space to data space.- Overrides:
java2DToValue
in classNumberAxis
- Parameters:
java2DValue
- the coordinate in Java2D space.dataArea
- the data area.edge
- the edge.- Returns:
- the data value.
-
valueToJava2D
Translates a value from data space to Java 2D space.- Overrides:
valueToJava2D
in classNumberAxis
- Parameters:
value
- the data value.dataArea
- the data area.edge
- the edge.- Returns:
- the Java 2D value.
-
centerRange
public void centerRange(double value)Centers the range about the given value.- Overrides:
centerRange
in classValueAxis
- Parameters:
value
- the data value.
-
setAutoRangeMinimumSize
public void setAutoRangeMinimumSize(double size, boolean notify)This function is nearly useless since the auto range is fixed for this class to the period The period is extended if necessary to fit the minimum size.- Overrides:
setAutoRangeMinimumSize
in classValueAxis
- Parameters:
size
- the size.notify
- notify?- See Also:
ValueAxis.setAutoRangeMinimumSize(double, boolean)
-
setFixedAutoRange
public void setFixedAutoRange(double length)The auto range is fixed for this class to the period by default. This function will thus set a new period.- Overrides:
setFixedAutoRange
in classValueAxis
- Parameters:
length
- the length.- See Also:
ValueAxis.setFixedAutoRange(double)
-
setRange
Sets a new axis range. The period is extended to fit the range size, if necessary.- Overrides:
setRange
in classValueAxis
- Parameters:
range
- the range.turnOffAutoRange
- switch off the auto range.notify
- notify?- See Also:
ValueAxis.setRange(org.jfree.data.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, org.jfree.ui.RectangleEdge edge, PlotRenderingInfo plotState)Draws the axis.- Overrides:
draw
in classNumberAxis
- 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
).
-
reserveSpace
public AxisSpace reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, org.jfree.ui.RectangleEdge edge, AxisSpace space)Reserve some space on each axis side because we draw a centered label at each extremity.- Parameters:
g2
- the graphics device.plot
- the plot.plotArea
- the plot area.edge
- the edge.space
- the space already reserved.- Returns:
- the reserved space.
-
equals
Tests the axis for equality with another object.- Overrides:
equals
in classNumberAxis
- Parameters:
object
- the object to test against.- Returns:
- a boolean.
-