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,PublicCloneable
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA special Number tick that also hold information about the cycle bound mapping for this tick. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected PaintThe advance line paint.protected StrokeThe advance line stroke.protected booleanA flag that controls whether or not the advance line is visible.protected boolean??.static final PaintThe default axis line paint.static StrokeThe default axis line stroke.protected doubleThe offset.protected doubleThe period.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_LABELSFields 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_MARGIN, DEFAULT_RANGE, DEFAULT_UPPER_MARGIN, MAXIMUM_TICK_COUNTFields 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
ConstructorsConstructorDescriptionCyclicNumberAxis(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 TypeMethodDescriptionprotected float[]calculateAnchorPoint(ValueTick tick, double cursor, Rectangle2D dataArea, RectangleEdge edge) Calculates the anchor point for a tick.voidcenterRange(double value) Centers the range about the given value.draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) Draws the axis.protected AxisStatedrawTickMarksAndLabels(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge) Draws the tick marks and labels.booleanTests the axis for equality with another object.The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.doubleThe 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.doubleThe cycle bound is a multiple of the period, plus optionally a start offset.doubleThe cycle bound is a multiple of the period, plus optionally a start offset.booleanThe advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.booleanThe cycle bound can be associated either with the current or with the last cycle.doublejava2DToValue(double java2DValue, Rectangle2D dataArea, RectangleEdge edge) Converts a coordinate from Java 2D space to data space.protected ListrefreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) Builds a list of ticks for the axis.protected ListrefreshVerticalTicks(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) Builds a list of ticks for the axis.reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) Reserve some space on each axis side because we draw a centered label at each extremity.protected voidselectHorizontalAutoTickUnit(Graphics2D g2, Rectangle2D drawArea, Rectangle2D dataArea, RectangleEdge edge) Selects a tick unit when the axis is displayed horizontally.protected voidselectVerticalAutoTickUnit(Graphics2D g2, Rectangle2D drawArea, Rectangle2D dataArea, RectangleEdge edge) Selects a tick unit when the axis is displayed vertically.voidsetAdvanceLinePaint(Paint paint) The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.voidsetAdvanceLineStroke(Stroke stroke) The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.voidsetAdvanceLineVisible(boolean visible) The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.voidsetAutoRangeMinimumSize(double size, boolean notify) This function is nearly useless since the auto range is fixed for this class to the period.voidsetBoundMappedToLastCycle(boolean boundMappedToLastCycle) The cycle bound can be associated either with the current or with the last cycle.voidsetFixedAutoRange(double length) The auto range is fixed for this class to the period by default.voidsetOffset(double offset) The cycle bound is a multiple of the period, plus optionally a start offset.voidsetPeriod(double period) The cycle bound is a multiple of the period, plus optionally a start offset.voidSets a new axis range.doublevalueToJava2D(double value, Rectangle2D dataArea, RectangleEdge edge) Translates a value from data space to Java 2D space.Methods inherited from class org.jfree.chart.axis.NumberAxis
autoAdjustRange, calculateHighestVisibleTickValue, calculateLowestVisibleTickValue, calculateVisibleTickCount, clone, configure, createIntegerTickUnits, createIntegerTickUnits, createStandardTickUnits, createStandardTickUnits, estimateMaximumTickLabelHeight, estimateMaximumTickLabelWidth, getAutoRangeIncludesZero, getAutoRangeStickyZero, getMarkerBand, getNumberFormatOverride, getRangeType, getTickUnit, hashCode, refreshTicks, refreshTicksVertical, selectAutoTickUnit, selectHorizontalAutoTickUnit, selectVerticalAutoTickUnit, setAutoRangeIncludesZero, setAutoRangeStickyZero, setMarkerBand, setNumberFormatOverride, setRangeType, setTickUnit, setTickUnitMethods inherited from class org.jfree.chart.axis.ValueAxis
drawAxisLine, findMaximumTickLabelHeight, findMaximumTickLabelWidth, getAutoRangeMinimumSize, getAutoTickIndex, getDefaultAutoRange, getDownArrow, getFixedAutoRange, getLeftArrow, getLowerBound, getLowerMargin, getMinorTickCount, getRange, getRightArrow, getStandardTickUnits, getUpArrow, getUpperBound, getUpperMargin, isAutoRange, isAutoTickUnitSelection, isInverted, isNegativeArrowVisible, isPositiveArrowVisible, isVerticalTickLabels, lengthToJava2D, pan, resizeRange, resizeRange, resizeRange2, setAutoRange, setAutoRange, setAutoRangeMinimumSize, setAutoTickIndex, setAutoTickUnitSelection, setAutoTickUnitSelection, setDefaultAutoRange, setDownArrow, setInverted, setLeftArrow, setLowerBound, setLowerMargin, setMinorTickCount, setNegativeArrowVisible, setPositiveArrowVisible, setRange, setRange, setRangeAboutValue, setRangeWithMargins, setRangeWithMargins, setRangeWithMargins, setRightArrow, setStandardTickUnits, setUpArrow, setUpperBound, setUpperMargin, setVerticalTickLabels, zoomRangeMethods inherited from class org.jfree.chart.axis.Axis
addChangeListener, createAndAddEntity, createAttributedLabel, drawAttributedLabel, drawLabel, fireChangeEvent, getAttributedLabel, getAxisLinePaint, getAxisLineStroke, getFixedDimension, getLabel, getLabelAngle, getLabelEnclosure, getLabelFont, getLabelInsets, getLabelLocation, getLabelPaint, getMinorTickMarkInsideLength, getMinorTickMarkOutsideLength, getPlot, getTickLabelFont, getTickLabelInsets, getTickLabelPaint, getTickMarkInsideLength, getTickMarkOutsideLength, getTickMarkPaint, getTickMarkStroke, hasListener, isAxisLineVisible, isMinorTickMarksVisible, isTickLabelsVisible, isTickMarksVisible, isVisible, labelAnchorH, labelAnchorV, labelLocationX, labelLocationY, notifyListeners, removeChangeListener, setAttributedLabel, setAttributedLabel, setAxisLinePaint, setAxisLineStroke, setAxisLineVisible, setFixedDimension, setLabel, setLabelAngle, setLabelFont, setLabelInsets, setLabelInsets, setLabelLocation, setLabelPaint, setMinorTickMarkInsideLength, setMinorTickMarkOutsideLength, setMinorTickMarksVisible, 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. -
offset
The offset. -
period
The period. -
boundMappedToLastCycle
??. -
advanceLineVisible
A flag that controls whether or not the advance line is visible. -
advanceLineStroke
The advance line stroke. -
advanceLinePaint
The advance line paint.
-
-
Constructor Details
-
CyclicNumberAxis
Creates a CycleNumberAxis with the given period.- Parameters:
period- the period.
-
CyclicNumberAxis
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
-
isAdvanceLineVisible
The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.- Returns:
- A boolean.
-
setAdvanceLineVisible
The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.- Parameters:
visible- the flag.
-
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
The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.- Parameters:
paint- the paint (nullnot permitted).
-
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
The advance line is the line drawn at the limit of the current cycle, when erasing the previous cycle.- Parameters:
stroke- the stroke (nullnot permitted).
-
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:
trueif the cycle bound is mapped to the last cycle,falseif it is bound to the current cycle (default)
-
setBoundMappedToLastCycle
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.
-
calculateAnchorPoint
protected float[] calculateAnchorPoint(ValueTick tick, double cursor, Rectangle2D dataArea, RectangleEdge edge) Calculates the anchor point for a tick.- Overrides:
calculateAnchorPointin classValueAxis- Parameters:
tick- the tick.cursor- the cursor.dataArea- the data area.edge- the side on which the axis is displayed.- Returns:
- The anchor point.
-
refreshTicksHorizontal
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").- Overrides:
refreshTicksHorizontalin classNumberAxis- Parameters:
g2- the graphics device.dataArea- the data area.edge- the edge.- Returns:
- A list of ticks.
-
refreshVerticalTicks
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.
-
java2DToValue
Converts a coordinate from Java 2D space to data space.- Overrides:
java2DToValuein classNumberAxis- Parameters:
java2DValue- the coordinate in Java2D space.dataArea- the data area.edge- the edge.- Returns:
- The data value.
- See Also:
-
valueToJava2D
Translates a value from data space to Java 2D space.- Overrides:
valueToJava2Din classNumberAxis- Parameters:
value- the data value.dataArea- the data area.edge- the edge.- Returns:
- The Java 2D value.
- See Also:
-
centerRange
Centers the range about the given value.- Overrides:
centerRangein classValueAxis- Parameters:
value- the data value.
-
setAutoRangeMinimumSize
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:
setAutoRangeMinimumSizein classValueAxis- Parameters:
size- the size.notify- notify?- See Also:
-
setFixedAutoRange
The auto range is fixed for this class to the period by default. This function will thus set a new period.- Overrides:
setFixedAutoRangein classValueAxis- Parameters:
length- the length.- See Also:
-
setRange
Sets a new axis range. The period is extended to fit the range size, if necessary. -
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
The cycle bound is a multiple of the period, plus optionally a start offset.cb = n * period + offset
- Returns:
- The current offset.
- See Also:
-
setOffset
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:
-
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:
-
setPeriod
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:
-
drawTickMarksAndLabels
protected AxisState drawTickMarksAndLabels(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge) Draws the tick marks and labels.- Overrides:
drawTickMarksAndLabelsin classValueAxis- Parameters:
g2- the graphics device.cursor- the cursor.plotArea- the plot area.dataArea- the area inside the axes.edge- the side on which the axis is displayed.- Returns:
- The axis state.
-
draw
public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) Draws the axis.- Overrides:
drawin classNumberAxis- Parameters:
g2- the graphics device (nullnot permitted).cursor- the cursor position.plotArea- the plot area (nullnot permitted).dataArea- the data area (nullnot permitted).edge- the edge (nullnot permitted).plotState- collects information about the plot (nullpermitted).- Returns:
- The axis state (never
null).
-
reserveSpace
public AxisSpace reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) Reserve some space on each axis side because we draw a centered label at each extremity.- Overrides:
reserveSpacein classValueAxis- 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:
equalsin classNumberAxis- Parameters:
obj- the object to test against.- Returns:
- A boolean.
-