org.jfree.chart.axis
Class PeriodAxis

java.lang.Object
  extended byorg.jfree.chart.axis.Axis
      extended byorg.jfree.chart.axis.ValueAxis
          extended byorg.jfree.chart.axis.PeriodAxis
All Implemented Interfaces:
java.lang.Cloneable, org.jfree.util.PublicCloneable, java.io.Serializable

public class PeriodAxis
extends ValueAxis
implements java.lang.Cloneable, java.io.Serializable

An axis that displays a date scale based on a RegularTimePeriod.

See Also:
Serialized Form

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_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
PeriodAxis(java.lang.String label)
          Creates a new axis.
PeriodAxis(java.lang.String label, RegularTimePeriod first, RegularTimePeriod last)
          Creates a new axis.
PeriodAxis(java.lang.String label, RegularTimePeriod first, RegularTimePeriod last, java.util.TimeZone timeZone)
          Creates a new axis.
 
Method Summary
protected  void autoAdjustRange()
          Rescales the axis to ensure that all data is visible.
 void configure()
          Configures the axis to work with the current plot.
 AxisState draw(java.awt.Graphics2D g2, double cursor, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge, PlotRenderingInfo plotState)
          Draws the axis on a Java 2D graphics device (such as the screen or a printer).
protected  AxisState drawTickLabels(int band, java.awt.Graphics2D g2, AxisState state, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
          Draws the tick labels for one "band" of time periods.
 boolean equals(java.lang.Object obj)
          Tests the axis for equality with an arbitrary object.
 java.lang.Class getAutoRangeTimePeriodClass()
          Returns the class used to create the first and last time periods for the axis range when the auto-range flag is set to true.
 RegularTimePeriod getFirst()
          Returns the first time period in the axis range.
 PeriodAxisLabelInfo[] getLabelInfo()
          Returns an array of label info records.
 RegularTimePeriod getLast()
          Returns the last time period in the axis range.
 Range getRange()
          Returns the range for the axis.
 java.util.TimeZone getTimeZone()
          Returns the time zone used to convert the periods defining the axis range into absolute milliseconds.
 double java2DToValue(double java2DValue, java.awt.geom.Rectangle2D area, org.jfree.ui.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.
 java.util.List refreshTicks(java.awt.Graphics2D g2, AxisState state, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
          Calculates the positions of the ticks for the axis, storing the results in the tick list (ready for drawing).
 AxisSpace reserveSpace(java.awt.Graphics2D g2, Plot plot, java.awt.geom.Rectangle2D plotArea, org.jfree.ui.RectangleEdge edge, AxisSpace space)
          Estimates the space (height or width) required to draw the axis.
 void setAutoRangeTimePeriodClass(java.lang.Class c)
          Sets the class used to create the first and last time periods for the axis range when the auto-range flag is set to true and sends an AxisChangeEvent to all registered listeners.
 void setFirst(RegularTimePeriod first)
          Sets the first time period in the axis range and sends an AxisChangeEvent to all registered listeners.
 void setLabelInfo(PeriodAxisLabelInfo[] info)
          Sets the array of label info records.
 void setLast(RegularTimePeriod last)
          Sets the last time period in the axis range and sends an AxisChangeEvent to all registered listeners.
 void setTimeZone(java.util.TimeZone zone)
          Sets the time zone that is used to convert the time periods into absolute milliseconds.
 double valueToJava2D(double value, java.awt.geom.Rectangle2D area, org.jfree.ui.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, clone, drawAxisLine, drawTickMarksAndLabels, findMaximumTickLabelHeight, findMaximumTickLabelWidth, getAutoRangeMinimumSize, getAutoTickIndex, getDownArrow, getFixedAutoRange, getLeftArrow, getLowerBound, getLowerMargin, getMaximumAxisValue, getMinimumAxisValue, getRightArrow, getStandardTickUnits, getUpArrow, getUpperBound, getUpperMargin, isAutoRange, isAutoTickUnitSelection, isInverted, isNegativeArrowVisible, isPositiveArrowVisible, isVerticalTickLabels, lengthToJava2D, resizeRange, resizeRange, setAutoRange, setAutoRange, setAutoRangeMinimumSize, setAutoRangeMinimumSize, setAutoTickIndex, setAutoTickUnitSelection, setAutoTickUnitSelection, setDownArrow, setFixedAutoRange, setInverted, setLeftArrow, setLowerBound, setLowerMargin, setMaximumAxisValue, setMinimumAxisValue, setNegativeArrowVisible, setPositiveArrowVisible, setRange, setRange, setRange, setRangeAboutValue, setRangeWithMargins, setRangeWithMargins, setRangeWithMargins, setRightArrow, setStandardTickUnits, setUpArrow, setUpperBound, setUpperMargin, setVerticalTickLabels, translateJava2DToValue, translateJava2DtoValue, translateValueToJava2D, zoomRange
 
Methods inherited from class org.jfree.chart.axis.Axis
addChangeListener, drawLabel, getAxisLinePaint, getAxisLineStroke, getFixedDimension, getLabel, getLabelAngle, getLabelEnclosure, getLabelFont, getLabelInsets, getLabelPaint, getPlot, getTickLabelFont, getTickLabelInsets, getTickLabelPaint, getTickMarkInsideLength, getTickMarkOutsideLength, getTickMarkPaint, getTickMarkStroke, isAxisLineVisible, isTickLabelsVisible, isTickMarksVisible, isVisible, notifyListeners, removeChangeListener, setAxisLinePaint, setAxisLineStroke, setAxisLineVisible, setFixedDimension, setLabel, setLabelAngle, setLabelFont, setLabelInsets, setLabelPaint, setPlot, setTickLabelFont, setTickLabelInsets, setTickLabelPaint, setTickLabelsVisible, setTickMarkInsideLength, setTickMarkOutsideLength, setTickMarkPaint, setTickMarkStroke, setTickMarksVisible, setVisible
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PeriodAxis

public PeriodAxis(java.lang.String label)
Creates a new axis.

Parameters:
label - the axis label.

PeriodAxis

public PeriodAxis(java.lang.String label,
                  RegularTimePeriod first,
                  RegularTimePeriod last)
Creates a new axis.

Parameters:
label - the axis label (null permitted).
first - the first time period in the axis range (null not permitted).
last - the last time period in the axis range (null not permitted).

PeriodAxis

public PeriodAxis(java.lang.String label,
                  RegularTimePeriod first,
                  RegularTimePeriod last,
                  java.util.TimeZone timeZone)
Creates a new axis.

Parameters:
label - the axis label (null permitted).
first - the first time period in the axis range (null not permitted).
last - the last time period in the axis range (null not permitted).
timeZone - the time zone (null not permitted).
Method Detail

getFirst

public RegularTimePeriod getFirst()
Returns the first time period in the axis range.

Returns:
The first time period (never null).

setFirst

public void setFirst(RegularTimePeriod first)
Sets the first time period in the axis range and sends an AxisChangeEvent to all registered listeners.

Parameters:
first - the time period (null not permitted).

getLast

public RegularTimePeriod getLast()
Returns the last time period in the axis range.

Returns:
The last time period (never null).

setLast

public void setLast(RegularTimePeriod last)
Sets the last time period in the axis range and sends an AxisChangeEvent to all registered listeners.

Parameters:
last - the time period (null not permitted).

getTimeZone

public java.util.TimeZone getTimeZone()
Returns the time zone used to convert the periods defining the axis range into absolute milliseconds.

Returns:
The time zone (never null).

setTimeZone

public void setTimeZone(java.util.TimeZone zone)
Sets the time zone that is used to convert the time periods into absolute milliseconds.

Parameters:
zone - the time zone (null not permitted).

getAutoRangeTimePeriodClass

public java.lang.Class getAutoRangeTimePeriodClass()
Returns the class used to create the first and last time periods for the axis range when the auto-range flag is set to true.

Returns:
The class (never null).

setAutoRangeTimePeriodClass

public void setAutoRangeTimePeriodClass(java.lang.Class c)
Sets the class used to create the first and last time periods for the axis range when the auto-range flag is set to true and sends an AxisChangeEvent to all registered listeners.

Parameters:
c - the class (null not permitted).

getLabelInfo

public PeriodAxisLabelInfo[] getLabelInfo()
Returns an array of label info records.

Returns:
An array.

setLabelInfo

public void setLabelInfo(PeriodAxisLabelInfo[] info)
Sets the array of label info records.

Parameters:
info - the info.

getRange

public Range getRange()
Returns the range for the axis.

Overrides:
getRange in class ValueAxis
Returns:
The axis range (never null).

configure

public void configure()
Configures the axis to work with the current plot. Override this method to perform any special processing (such as auto-rescaling).

Specified by:
configure in class Axis

reserveSpace

public AxisSpace reserveSpace(java.awt.Graphics2D g2,
                              Plot plot,
                              java.awt.geom.Rectangle2D plotArea,
                              org.jfree.ui.RectangleEdge edge,
                              AxisSpace space)
Estimates the space (height or width) required to draw the axis.

Overrides:
reserveSpace in class ValueAxis
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(java.awt.Graphics2D g2,
                      double cursor,
                      java.awt.geom.Rectangle2D plotArea,
                      java.awt.geom.Rectangle2D dataArea,
                      org.jfree.ui.RectangleEdge edge,
                      PlotRenderingInfo plotState)
Draws the axis on a Java 2D graphics device (such as the screen or a printer).

Specified by:
draw in class Axis
Parameters:
g2 - the graphics device (null not 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 (null not permitted).
plotState - collects information about the plot (null permitted).
Returns:
The axis state (never null).

drawTickLabels

protected AxisState drawTickLabels(int band,
                                   java.awt.Graphics2D g2,
                                   AxisState state,
                                   java.awt.geom.Rectangle2D dataArea,
                                   org.jfree.ui.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

public java.util.List refreshTicks(java.awt.Graphics2D g2,
                                   AxisState state,
                                   java.awt.geom.Rectangle2D plotArea,
                                   java.awt.geom.Rectangle2D dataArea,
                                   org.jfree.ui.RectangleEdge edge)
Calculates the positions of the ticks for the axis, storing the results in the tick list (ready for drawing).

Specified by:
refreshTicks in class Axis
Parameters:
g2 - the graphics device.
state - the axis state.
plotArea - the area within which the axes and plot should be drawn.
dataArea - the area inside the axes.
edge - the edge on which the axis is located.
Returns:
The list of ticks.

valueToJava2D

public double valueToJava2D(double value,
                            java.awt.geom.Rectangle2D area,
                            org.jfree.ui.RectangleEdge edge)
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:
valueToJava2D in class ValueAxis
Parameters:
value - the data value.
area - the area for plotting the data.
edge - the edge along which the axis lies.
Returns:
The Java2D coordinate.

java2DToValue

public double java2DToValue(double java2DValue,
                            java.awt.geom.Rectangle2D area,
                            org.jfree.ui.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.

Specified by:
java2DToValue in class ValueAxis
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.

autoAdjustRange

protected void autoAdjustRange()
Rescales the axis to ensure that all data is visible.

Specified by:
autoAdjustRange in class ValueAxis

equals

public boolean equals(java.lang.Object obj)
Tests the axis for equality with an arbitrary object.

Overrides:
equals in class ValueAxis
Parameters:
obj - the object (null permitted).
Returns:
A boolean.