com.jrefinery.chart
Class DateAxis

java.lang.Object
  extended by com.jrefinery.chart.Axis
      extended by com.jrefinery.chart.ValueAxis
          extended by com.jrefinery.chart.DateAxis
All Implemented Interfaces:
AxisConstants
Direct Known Subclasses:
HorizontalDateAxis

public abstract class DateAxis
extends ValueAxis

The base class for axes that display java.util.Date values.

See Also:
HorizontalDateAxis

Field Summary
protected  java.util.Date anchorDate
          The anchor date (needs to be synchronised with the anchorValue in the ValueAxis superclass, as this form is maintained for convenience only).
protected  java.util.Date crosshairDate
          The crosshair date (needs to be synchronised with the crosshairValue in the ValueAxis superclass, as this form is maintained for convenience only).
static java.util.Date DEFAULT_CROSSHAIR_DATE
          The default crosshair date.
protected static java.lang.String[] standardTickFormats
          An array of strings, corresponding to the tickValues array, and used to create a DateFormat object for displaying tick values.
protected static long[] standardTickUnitMagnitudes
          The approximate magnitude of each of the standard tick units.
protected static int[][] standardTickUnits
          An array of Calendar fields that will be used for automatic tick generation.
protected  java.text.SimpleDateFormat tickLabelFormatter
          A formatter for the tick labels.
protected  DateUnit tickUnit
          The current tick unit.
 
Fields inherited from class com.jrefinery.chart.ValueAxis
anchorValue, autoRange, autoTickIndex, autoTickUnitSelection, crosshairLockedOnData, crosshairPaint, crosshairStroke, crosshairValue, crosshairVisible, DEFAULT_AUTO_RANGE, DEFAULT_CROSSHAIR_PAINT, DEFAULT_CROSSHAIR_STROKE, DEFAULT_CROSSHAIR_VISIBLE, DEFAULT_GRID_LINE_PAINT, DEFAULT_GRID_LINE_STROKE, DEFAULT_MAXIMUM_AXIS_VALUE, DEFAULT_MINIMUM_AXIS_VALUE, fixedAutoRange, gridLinesVisible, gridPaint, gridStroke, maximumRangeLength, minimumRangeLength, range
 
Fields inherited from class com.jrefinery.chart.Axis
fixedDimension, label, labelFont, labelInsets, labelPaint, listeners, plot, tickLabelFont, tickLabelInsets, tickLabelPaint, tickLabelsVisible, tickMarkStroke, tickMarksVisible, ticks, visible
 
Fields inherited from interface com.jrefinery.chart.AxisConstants
DEFAULT_AXIS_LABEL_FONT, DEFAULT_AXIS_LABEL_INSETS, DEFAULT_AXIS_LABEL_PAINT, DEFAULT_TICK_LABEL_FONT, DEFAULT_TICK_LABEL_INSETS, DEFAULT_TICK_LABEL_PAINT, DEFAULT_TICK_STROKE
 
Constructor Summary
protected DateAxis(java.lang.String label)
          Constructs a date axis, using default values where necessary.
protected DateAxis(java.lang.String label, java.awt.Font labelFont, java.awt.Paint labelPaint, java.awt.Insets labelInsets, boolean tickLabelsVisible, java.awt.Font tickLabelFont, java.awt.Paint tickLabelPaint, java.awt.Insets tickLabelInsets, boolean tickMarksVisible, java.awt.Stroke tickMarkStroke, boolean autoRange, Range range, boolean autoTickUnitSelection, DateUnit tickUnit, java.text.SimpleDateFormat tickLabelFormatter, boolean gridLinesVisible, java.awt.Stroke gridStroke, java.awt.Paint gridPaint, boolean crosshairVisible, java.util.Date crosshairDate, java.awt.Stroke crosshairStroke, java.awt.Paint crosshairPaint)
          Constructs a date axis.
 
Method Summary
 java.util.Date calculateHighestVisibleTickValue(DateUnit unit)
          Calculates the value of the highest visible tick on the axis.
 java.util.Date calculateLowestVisibleTickValue(DateUnit unit)
          Calculates the value of the lowest visible tick on the axis.
protected  int findAxisMagnitudeIndex()
          Returns the index of the largest tick unit that will fit within the axis range.
 java.util.Date getAnchorDate()
          Returns the anchor date for the axis.
 java.util.Date getCrosshairDate()
          Returns the crosshair date for the axis.
 java.util.Date getMaximumDate()
          Returns the latest date visible on the axis.
 java.util.Date getMinimumDate()
          Returns the earliest date visible on the axis.
 java.text.SimpleDateFormat getTickLabelFormatter()
          Returns the formatter for the tick labels.
 DateUnit getTickUnit()
          Returns the tick unit for the axis.
protected  java.util.Date nextStandardDate(java.util.Date date, int field, int units)
          Returns the first "standard" date (based on the specified field and units).
protected  java.util.Date previousStandardDate(java.util.Date date, int field, int units)
          Returns the previous "standard" date (based on the specified field and units).
 void setAnchorDate(java.util.Date anchorDate)
          Sets the anchor date for the axis.
 void setAnchorValue(double value)
          Sets the anchor value.
 void setAxisRange(double lower, double upper)
          Sets the axis range.
 void setCrosshairDate(java.util.Date crosshairDate)
          Sets the crosshair date for the axis.
 void setMaximumDate(java.util.Date maximumDate)
          Sets the maximum date visible on the axis.
 void setMinimumDate(java.util.Date minimumDate)
          Sets the minimum date visible on the axis.
 void setRange(Range range)
          Sets the upper and lower bounds for the axis.
 void setTickUnit(DateUnit unit)
          Sets the tick unit for the axis.
 
Methods inherited from class com.jrefinery.chart.ValueAxis
autoAdjustRange, centerRange, getAnchorValue, getCrosshairPaint, getCrosshairStroke, getCrosshairValue, getFixedAutoRange, getGridPaint, getGridStroke, getMaximumAxisValue, getMinimumAxisValue, getRange, isAutoRange, isAutoTickUnitSelection, isCrosshairLockedOnData, isCrosshairVisible, isGridLinesVisible, resizeRange, resizeRange, setAnchoredRange, setAutoRange, setAutoTickUnitSelection, setCrosshairLockedOnData, setCrosshairPaint, setCrosshairStroke, setCrosshairValue, setCrosshairVisible, setFixedAutoRange, setGridLinesVisible, setGridPaint, setGridStroke, setMaximumAxisValue, setMinimumAxisValue, setRange, setRangeAboutValue, translateJava2DtoValue, translateValueToJava2D
 
Methods inherited from class com.jrefinery.chart.Axis
addChangeListener, configure, draw, getFixedDimension, getLabel, getLabelFont, getLabelInsets, getLabelPaint, getMaxTickLabelWidth, getPlot, getTickLabelFont, getTickLabelInsets, getTickLabelPaint, getTickMarkStroke, isCompatiblePlot, isTickLabelsVisible, isTickMarksVisible, isVisible, notifyListeners, refreshTicks, removeChangeListener, setFixedDimension, setLabel, setLabelFont, setLabelInsets, setLabelPaint, setPlot, setTickLabelFont, setTickLabelInsets, setTickLabelPaint, setTickLabelsVisible, setTickMarkStroke, setTickMarksVisible, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CROSSHAIR_DATE

public static final java.util.Date DEFAULT_CROSSHAIR_DATE
The default crosshair date.


anchorDate

protected java.util.Date anchorDate
The anchor date (needs to be synchronised with the anchorValue in the ValueAxis superclass, as this form is maintained for convenience only).


crosshairDate

protected java.util.Date crosshairDate
The crosshair date (needs to be synchronised with the crosshairValue in the ValueAxis superclass, as this form is maintained for convenience only).


tickUnit

protected DateUnit tickUnit
The current tick unit.


tickLabelFormatter

protected java.text.SimpleDateFormat tickLabelFormatter
A formatter for the tick labels.


standardTickUnitMagnitudes

protected static long[] standardTickUnitMagnitudes
The approximate magnitude of each of the standard tick units. This array is used to find an index into the standardTickUnits array.


standardTickUnits

protected static int[][] standardTickUnits
An array of Calendar fields that will be used for automatic tick generation.


standardTickFormats

protected static java.lang.String[] standardTickFormats
An array of strings, corresponding to the tickValues array, and used to create a DateFormat object for displaying tick values.

Constructor Detail

DateAxis

protected DateAxis(java.lang.String label)
Constructs a date axis, using default values where necessary.

Parameters:
label - The axis label.

DateAxis

protected DateAxis(java.lang.String label,
                   java.awt.Font labelFont,
                   java.awt.Paint labelPaint,
                   java.awt.Insets labelInsets,
                   boolean tickLabelsVisible,
                   java.awt.Font tickLabelFont,
                   java.awt.Paint tickLabelPaint,
                   java.awt.Insets tickLabelInsets,
                   boolean tickMarksVisible,
                   java.awt.Stroke tickMarkStroke,
                   boolean autoRange,
                   Range range,
                   boolean autoTickUnitSelection,
                   DateUnit tickUnit,
                   java.text.SimpleDateFormat tickLabelFormatter,
                   boolean gridLinesVisible,
                   java.awt.Stroke gridStroke,
                   java.awt.Paint gridPaint,
                   boolean crosshairVisible,
                   java.util.Date crosshairDate,
                   java.awt.Stroke crosshairStroke,
                   java.awt.Paint crosshairPaint)
Constructs a date axis.

Parameters:
label - The axis label.
labelFont - The font for displaying the axis label.
labelPaint - The paint used to draw the axis label.
labelInsets - Determines the amount of blank space around the label.
tickLabelsVisible - Flag indicating whether or not tick labels are visible.
tickLabelFont - The font used to display tick labels.
tickLabelPaint - The paint used to draw tick labels.
tickLabelInsets - Determines the amount of blank space around tick labels.
tickMarksVisible - Flag indicating whether or not tick marks are visible.
tickMarkStroke - The stroke used to draw tick marks (if visible).
autoRange - Flag indicating whether or not the axis range is automatically adjusted to fit the data.
range - The axis range.
autoTickUnitSelection - A flag indicating whether or not the tick unit is automatically selected.
tickUnit - The tick unit.
gridLinesVisible - Flag indicating whether or not grid lines are visible.
gridStroke - The Stroke used to display grid lines (if visible).
gridPaint - The Paint used to display grid lines (if visible).
crosshairVisible - A flag controlling whether or not the crosshair is visible for this axis.
crosshairDate - The crosshair date.
crosshairStroke - The crosshair stroke.
crosshairPaint - The crosshair paint.
Method Detail

setRange

public void setRange(Range range)
Sets the upper and lower bounds for the axis. Registered listeners are notified of the change.

As a side-effect, the auto-range flag is set to false.

Overrides:
setRange in class ValueAxis
Parameters:
range - The new range.

getMinimumDate

public java.util.Date getMinimumDate()
Returns the earliest date visible on the axis.

Returns:
The earliest date visible on the axis.

setMinimumDate

public void setMinimumDate(java.util.Date minimumDate)
Sets the minimum date visible on the axis.

Parameters:
minimumDate - The new minimum date.

getMaximumDate

public java.util.Date getMaximumDate()
Returns the latest date visible on the axis.

Returns:
The latest date visible on the axis.

setMaximumDate

public void setMaximumDate(java.util.Date maximumDate)
Sets the maximum date visible on the axis.

Parameters:
maximumDate - The new maximum date.

setAnchorValue

public void setAnchorValue(double value)
Sets the anchor value.

This method keeps the anchorDate and anchorValue in synch.

Overrides:
setAnchorValue in class ValueAxis
Parameters:
value - The new value.

setAxisRange

public void setAxisRange(double lower,
                         double upper)
Sets the axis range.

Parameters:
lower - The lower bound for the axis.
upper - The upper bound for the axis.

getCrosshairDate

public java.util.Date getCrosshairDate()
Returns the crosshair date for the axis.

Returns:
The crosshair date for the axis (possibly null).

setCrosshairDate

public void setCrosshairDate(java.util.Date crosshairDate)
Sets the crosshair date for the axis.

Parameters:
maximumDate - The new crosshair date (null permitted).

getAnchorDate

public java.util.Date getAnchorDate()
Returns the anchor date for the axis.

Returns:
The anchor date for the axis (possibly null).

setAnchorDate

public void setAnchorDate(java.util.Date anchorDate)
Sets the anchor date for the axis.

Parameters:
anchorDate - The new anchor date (null permitted).

getTickUnit

public DateUnit getTickUnit()
Returns the tick unit for the axis.

Returns:
The tick unit for the axis.

setTickUnit

public void setTickUnit(DateUnit unit)
Sets the tick unit for the axis.

Parameters:
unit - The new date unit.

getTickLabelFormatter

public java.text.SimpleDateFormat getTickLabelFormatter()
Returns the formatter for the tick labels.

Returns:
The formatter for the tick labels.

calculateLowestVisibleTickValue

public java.util.Date calculateLowestVisibleTickValue(DateUnit unit)
Calculates the value of the lowest visible tick on the axis.

Returns:
The value of the lowest visible tick on the axis.

calculateHighestVisibleTickValue

public java.util.Date calculateHighestVisibleTickValue(DateUnit unit)
Calculates the value of the highest visible tick on the axis.

Returns:
The value of the highest visible tick on the axis.

previousStandardDate

protected java.util.Date previousStandardDate(java.util.Date date,
                                              int field,
                                              int units)
Returns the previous "standard" date (based on the specified field and units).


nextStandardDate

protected java.util.Date nextStandardDate(java.util.Date date,
                                          int field,
                                          int units)
Returns the first "standard" date (based on the specified field and units).


findAxisMagnitudeIndex

protected int findAxisMagnitudeIndex()
Returns the index of the largest tick unit that will fit within the axis range.



Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.