Package org.jfree.chart.axis
Class PeriodAxis
java.lang.Object
org.jfree.chart.axis.Axis
org.jfree.chart.axis.ValueAxis
org.jfree.chart.axis.PeriodAxis
- All Implemented Interfaces:
Serializable,Cloneable,PublicCloneable
An axis that displays a date scale based on a
RegularTimePeriod. This axis works when
displayed across the bottom or top of a plot, but is broken for display at
the left or right of charts.- See Also:
-
Field Summary
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_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
ConstructorsConstructorDescriptionPeriodAxis(String label) Creates a new axis.PeriodAxis(String label, RegularTimePeriod first, RegularTimePeriod last) Creates a new axis.PeriodAxis(String label, RegularTimePeriod first, RegularTimePeriod last, TimeZone timeZone, Locale locale) Creates a new axis. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidRescales the axis to ensure that all data is visible.clone()Returns a clone of the axis.voidConfigures the axis to work with the current plot.draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) Draws the axis on a Java 2D graphics device (such as the screen or a printer).protected AxisStatedrawTickLabels(int band, Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) Draws the tick labels for one "band" of time periods.protected voiddrawTickMarks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) Draws the tick marks for the axis.protected voiddrawTickMarksHorizontal(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) Draws the major and minor tick marks for an axis that lies at the top or bottom of the plot.protected voiddrawTickMarksVertical(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) Draws the tick marks for a vertical axis.booleanTests the axis for equality with an arbitrary object.Returns the class used to create the first and last time periods for the axis range when the auto-range flag is set totrue.getFirst()Returns the first time period in the axis range.Returns an array of label info records.getLast()Returns the last time period in the axis range.Returns the locale for this axis.Returns the class that controls the spacing of the major tick marks.floatReturns the inside length for the minor tick marks.floatReturns the outside length for the minor tick marks.Returns the paint used to display minor tick marks, if they are visible.Returns the stroke used to display minor tick marks, if they are visible.Returns the class that controls the spacing of the minor tick marks.Returns the time zone used to convert the periods defining the axis range into absolute milliseconds.inthashCode()Returns a hash code for this object.booleanReturns the flag that controls whether or not minor tick marks are displayed for the axis.doublejava2DToValue(double java2DValue, Rectangle2D area, RectangleEdge edge) Converts a coordinate in Java2D space to the corresponding data value, assuming that the axis runs along one edge of the specified dataArea.refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) Calculates the positions of the ticks for the axis, storing the results in the tick list (ready for drawing).reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) Estimates the space (height or width) required to draw the axis.voidSets the class used to create the first and last time periods for the axis range when the auto-range flag is set totrueand sends anAxisChangeEventto all registered listeners.voidsetFirst(RegularTimePeriod first) Sets the first time period in the axis range and sends anAxisChangeEventto all registered listeners.voidsetLabelInfo(PeriodAxisLabelInfo[] info) Sets the array of label info records and sends anAxisChangeEventto all registered listeners.voidsetLast(RegularTimePeriod last) Sets the last time period in the axis range and sends anAxisChangeEventto all registered listeners.voidSets the class that controls the spacing of the major tick marks, and sends anAxisChangeEventto all registered listeners.voidsetMinorTickMarkInsideLength(float length) Sets the inside length of the minor tick marks and sends anAxisChangeEventto all registered listeners.voidsetMinorTickMarkOutsideLength(float length) Sets the outside length of the minor tick marks and sends anAxisChangeEventto all registered listeners.voidsetMinorTickMarkPaint(Paint paint) Sets the paint used to display minor tick marks, if they are visible, and sends aAxisChangeEventto all registered listeners.voidsetMinorTickMarkStroke(Stroke stroke) Sets the stroke used to display minor tick marks, if they are visible, and sends aAxisChangeEventto all registered listeners.voidsetMinorTickMarksVisible(boolean visible) Sets the flag that controls whether or not minor tick marks are displayed for the axis, and sends aAxisChangeEventto all registered listeners.voidSets the class that controls the spacing of the minor tick marks, and sends anAxisChangeEventto all registered listeners.voidSets the range for the axis, if requested, sends anAxisChangeEventto all registered listeners.voidsetTimeZone(TimeZone zone) Sets the time zone that is used to convert the time periods into absolute milliseconds.doublevalueToJava2D(double value, Rectangle2D area, RectangleEdge edge) Converts a data value to a coordinate in Java2D space, assuming that the axis runs along one edge of the specified dataArea.Methods inherited from class org.jfree.chart.axis.ValueAxis
calculateAnchorPoint, centerRange, drawAxisLine, drawTickMarksAndLabels, 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, setAutoRangeMinimumSize, setAutoTickIndex, setAutoTickUnitSelection, setAutoTickUnitSelection, setDefaultAutoRange, setDownArrow, setFixedAutoRange, 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, getPlot, getTickLabelFont, getTickLabelInsets, getTickLabelPaint, getTickMarkInsideLength, getTickMarkOutsideLength, getTickMarkPaint, getTickMarkStroke, hasListener, isAxisLineVisible, isTickLabelsVisible, isTickMarksVisible, isVisible, labelAnchorH, labelAnchorV, labelLocationX, labelLocationY, notifyListeners, removeChangeListener, setAttributedLabel, setAttributedLabel, setAxisLinePaint, setAxisLineStroke, setAxisLineVisible, setFixedDimension, setLabel, setLabelAngle, setLabelFont, setLabelInsets, setLabelInsets, setLabelLocation, setLabelPaint, setPlot, setTickLabelFont, setTickLabelInsets, setTickLabelPaint, setTickLabelsVisible, setTickMarkInsideLength, setTickMarkOutsideLength, setTickMarkPaint, setTickMarkStroke, setTickMarksVisible, setVisible
-
Constructor Details
-
PeriodAxis
Creates a new axis.- Parameters:
label- the axis label.
-
PeriodAxis
Creates a new axis.- Parameters:
label- the axis label (nullpermitted).first- the first time period in the axis range (nullnot permitted).last- the last time period in the axis range (nullnot permitted).
-
PeriodAxis
public PeriodAxis(String label, RegularTimePeriod first, RegularTimePeriod last, TimeZone timeZone, Locale locale) Creates a new axis.- Parameters:
label- the axis label (nullpermitted).first- the first time period in the axis range (nullnot permitted).last- the last time period in the axis range (nullnot permitted).timeZone- the time zone (nullnot permitted).locale- the locale (nullnot permitted).
-
-
Method Details
-
getFirst
Returns the first time period in the axis range.- Returns:
- The first time period (never
null).
-
setFirst
Sets the first time period in the axis range and sends anAxisChangeEventto all registered listeners.- Parameters:
first- the time period (nullnot permitted).
-
getLast
Returns the last time period in the axis range.- Returns:
- The last time period (never
null).
-
setLast
Sets the last time period in the axis range and sends anAxisChangeEventto all registered listeners.- Parameters:
last- the time period (nullnot permitted).
-
getTimeZone
Returns the time zone used to convert the periods defining the axis range into absolute milliseconds.- Returns:
- The time zone (never
null).
-
setTimeZone
Sets the time zone that is used to convert the time periods into absolute milliseconds.- Parameters:
zone- the time zone (nullnot permitted).
-
getLocale
Returns the locale for this axis.- Returns:
- The locale (never (
null).
-
getAutoRangeTimePeriodClass
Returns the class used to create the first and last time periods for the axis range when the auto-range flag is set totrue.- Returns:
- The class (never
null).
-
setAutoRangeTimePeriodClass
Sets the class used to create the first and last time periods for the axis range when the auto-range flag is set totrueand sends anAxisChangeEventto all registered listeners.- Parameters:
c- the class (nullnot permitted).
-
getMajorTickTimePeriodClass
Returns the class that controls the spacing of the major tick marks.- Returns:
- The class (never
null).
-
setMajorTickTimePeriodClass
Sets the class that controls the spacing of the major tick marks, and sends anAxisChangeEventto all registered listeners.- Parameters:
c- the class (a subclass ofRegularTimePeriodis expected).
-
isMinorTickMarksVisible
Returns the flag that controls whether or not minor tick marks are displayed for the axis.- Overrides:
isMinorTickMarksVisiblein classAxis- Returns:
- A boolean.
- See Also:
-
setMinorTickMarksVisible
Sets the flag that controls whether or not minor tick marks are displayed for the axis, and sends aAxisChangeEventto all registered listeners.- Overrides:
setMinorTickMarksVisiblein classAxis- Parameters:
visible- the flag.- See Also:
-
getMinorTickTimePeriodClass
Returns the class that controls the spacing of the minor tick marks.- Returns:
- The class (never
null).
-
setMinorTickTimePeriodClass
Sets the class that controls the spacing of the minor tick marks, and sends anAxisChangeEventto all registered listeners.- Parameters:
c- the class (a subclass ofRegularTimePeriodis expected).
-
getMinorTickMarkStroke
Returns the stroke used to display minor tick marks, if they are visible.- Returns:
- A stroke (never
null).
-
setMinorTickMarkStroke
Sets the stroke used to display minor tick marks, if they are visible, and sends aAxisChangeEventto all registered listeners.- Parameters:
stroke- the stroke (nullnot permitted).
-
getMinorTickMarkPaint
Returns the paint used to display minor tick marks, if they are visible.- Returns:
- A paint (never
null).
-
setMinorTickMarkPaint
Sets the paint used to display minor tick marks, if they are visible, and sends aAxisChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).
-
getMinorTickMarkInsideLength
Returns the inside length for the minor tick marks.- Overrides:
getMinorTickMarkInsideLengthin classAxis- Returns:
- The length.
- See Also:
-
setMinorTickMarkInsideLength
Sets the inside length of the minor tick marks and sends anAxisChangeEventto all registered listeners.- Overrides:
setMinorTickMarkInsideLengthin classAxis- Parameters:
length- the length.- See Also:
-
getMinorTickMarkOutsideLength
Returns the outside length for the minor tick marks.- Overrides:
getMinorTickMarkOutsideLengthin classAxis- Returns:
- The length.
- See Also:
-
setMinorTickMarkOutsideLength
Sets the outside length of the minor tick marks and sends anAxisChangeEventto all registered listeners.- Overrides:
setMinorTickMarkOutsideLengthin classAxis- Parameters:
length- the length.- See Also:
-
getLabelInfo
Returns an array of label info records.- Returns:
- An array.
-
setLabelInfo
Sets the array of label info records and sends anAxisChangeEventto all registered listeners.- Parameters:
info- the info.
-
setRange
Sets the range for the axis, if requested, sends anAxisChangeEventto all registered listeners. As a side-effect, the auto-range flag is set tofalse(optional). -
configure
Configures the axis to work with the current plot. Override this method to perform any special processing (such as auto-rescaling). -
reserveSpace
public AxisSpace reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) Estimates the space (height or width) required to draw the axis.- Overrides:
reserveSpacein classValueAxis- Parameters:
g2- the graphics device.plot- the plot that the axis belongs to.plotArea- the area within which the plot (including axes) should be drawn.edge- the axis location.space- space already reserved.- Returns:
- The space required to draw the axis (including pre-reserved space).
-
draw
public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) Draws the axis on a Java 2D graphics device (such as the screen or a printer).- Specified by:
drawin classAxis- Parameters:
g2- the graphics device (nullnot permitted).cursor- the cursor location (determines where to draw the axis).plotArea- the area within which the axes and plot should be drawn.dataArea- the area within which the data should be drawn.edge- the axis location (nullnot permitted).plotState- collects information about the plot (nullpermitted).- Returns:
- The axis state (never
null).
-
drawTickMarks
protected void drawTickMarks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) Draws the tick marks for the axis.- Parameters:
g2- the graphics device.state- the axis state.dataArea- the data area.edge- the edge.
-
drawTickMarksHorizontal
protected void drawTickMarksHorizontal(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) Draws the major and minor tick marks for an axis that lies at the top or bottom of the plot.- Parameters:
g2- the graphics device.state- the axis state.dataArea- the data area.edge- the edge.
-
drawTickMarksVertical
protected void drawTickMarksVertical(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) Draws the tick marks for a vertical axis.- Parameters:
g2- the graphics device.state- the axis state.dataArea- the data area.edge- the edge.
-
drawTickLabels
protected AxisState drawTickLabels(int band, Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) Draws the tick labels for one "band" of time periods.- Parameters:
band- the band index (zero-based).g2- the graphics device.state- the axis state.dataArea- the data area.edge- the edge where the axis is located.- Returns:
- The updated axis state.
-
refreshTicks
Calculates the positions of the ticks for the axis, storing the results in the tick list (ready for drawing).- Specified by:
refreshTicksin classAxis- Parameters:
g2- the graphics device.state- the axis state.dataArea- the area inside the axes.edge- the edge on which the axis is located.- Returns:
- The list of ticks.
-
valueToJava2D
Converts a data value to a coordinate in Java2D space, assuming that the axis runs along one edge of the specified dataArea.Note that it is possible for the coordinate to fall outside the area.
- Specified by:
valueToJava2Din classValueAxis- Parameters:
value- the data value.area- the area for plotting the data.edge- the edge along which the axis lies.- Returns:
- The Java2D coordinate.
- See Also:
-
java2DToValue
Converts a coordinate in Java2D space to the corresponding data value, assuming that the axis runs along one edge of the specified dataArea.- Specified by:
java2DToValuein classValueAxis- Parameters:
java2DValue- the coordinate in Java2D space.area- the area in which the data is plotted.edge- the edge along which the axis lies.- Returns:
- The data value.
- See Also:
-
autoAdjustRange
Rescales the axis to ensure that all data is visible.- Specified by:
autoAdjustRangein classValueAxis
-
equals
Tests the axis for equality with an arbitrary object. -
hashCode
Returns a hash code for this object. -
clone
Returns a clone of the axis.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classValueAxis- Returns:
- A clone.
- Throws:
CloneNotSupportedException- this class is cloneable, but subclasses may not be.
-