com.jrefinery.chart
Class ValueAxis

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

public abstract class ValueAxis
extends Axis

The base class for axes that display value data (a "value" can be a Number or a Date).


Field Summary
protected  double anchorValue
          The anchor value for this axis.
protected  boolean autoRange
          Flag that indicates whether or not the axis automatically scales to fit the chart data.
protected  int autoTickIndex
          An index into an array of standard tick values.
protected  boolean autoTickUnitSelection
          Flag that indicates whether or not the tick unit is selected automatically.
protected  boolean crosshairLockedOnData
          A flag that controls whether or not the crosshair locks onto actual data points.
protected  java.awt.Paint crosshairPaint
          The color used to draw the crosshair (if any).
protected  java.awt.Stroke crosshairStroke
          The pen/brush used to draw the crosshair (if any).
protected  double crosshairValue
          The crosshair value for this axis.
protected  boolean crosshairVisible
          A flag that controls whether or not a crosshair is drawn for this axis.
static boolean DEFAULT_AUTO_RANGE
          The default auto-range value.
static java.awt.Paint DEFAULT_CROSSHAIR_PAINT
          The default crosshair paint.
static java.awt.Stroke DEFAULT_CROSSHAIR_STROKE
          The default crosshair stroke.
static boolean DEFAULT_CROSSHAIR_VISIBLE
          The default crosshair visibility.
static java.awt.Paint DEFAULT_GRID_LINE_PAINT
          The default grid line paint.
static java.awt.Stroke DEFAULT_GRID_LINE_STROKE
          The default grid line stroke.
static double DEFAULT_MAXIMUM_AXIS_VALUE
          The default maximum axis value.
static double DEFAULT_MINIMUM_AXIS_VALUE
          The default minimum axis value.
protected  double fixedAutoRange
          If this value is positive, the amount is subtracted from the maximum data value to determine the lower axis range.
protected  boolean gridLinesVisible
          Flag that indicates whether or not grid lines are visible.
protected  java.awt.Paint gridPaint
          The paint used to draw grid lines.
protected  java.awt.Stroke gridStroke
          The stroke used to draw grid lines.
protected  double maximumRangeLength
           
protected  double minimumRangeLength
           
protected  Range range
          The axis 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 ValueAxis(java.lang.String label)
          Constructs a value axis, using default values where necessary.
protected ValueAxis(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, boolean autoTickUnitSelection, boolean gridLinesVisible, java.awt.Stroke gridStroke, java.awt.Paint gridPaint, boolean crosshairVisible, double crosshairValue, java.awt.Stroke crosshairStroke, java.awt.Paint crosshairPaint)
          Constructs a value axis.
 
Method Summary
protected abstract  void autoAdjustRange()
          Automatically determines the maximum and minimum values on the axis to 'fit' the data.
 void centerRange(double value)
          Centers the axis range about the specified value.
 double getAnchorValue()
          Returns the anchor value for this axis.
 java.awt.Paint getCrosshairPaint()
          Returns the crosshair color.
 java.awt.Stroke getCrosshairStroke()
          Returns the Stroke used to draw the crosshair (if visible).
 double getCrosshairValue()
          Returns the crosshair value.
 double getFixedAutoRange()
          Returns the fixed auto range.
 java.awt.Paint getGridPaint()
          Returns the grid line color.
 java.awt.Stroke getGridStroke()
          Returns the Stroke used to draw the grid lines (if visible).
 double getMaximumAxisValue()
          Returns the maximum value for the axis.
 double getMinimumAxisValue()
          Returns the minimum value for the axis.
 Range getRange()
          Returns the range for the axis.
 boolean isAutoRange()
          Returns true if the axis range is automatically adjusted to fit the data, and false otherwise.
 boolean isAutoTickUnitSelection()
          Returns a flag indicating whether or not the tick unit is automatically selected from a range of standard tick units.
 boolean isCrosshairLockedOnData()
          Returns a flag indicating whether or not the crosshair should "lock-on" to actual data values.
 boolean isCrosshairVisible()
          Returns a flag indicating whether or not a crosshair is visible for this axis.
 boolean isGridLinesVisible()
          Returns true if the grid lines are showing, and false otherwise.
 void resizeRange(double percent)
           
 void resizeRange(double percent, double anchorValue)
           
 void setAnchoredRange(double range)
          Sets the axis range so the the anchor value is in the middle of the axis, and the overall range is equal to the value specified.
 void setAnchorValue(double value)
          Sets the anchor value for this axis.
 void setAutoRange(boolean auto)
          Sets a flag that determines whether or not the axis range is automatically adjusted to fit the data, and notifies registered listeners that the axis has been modified.
 void setAutoTickUnitSelection(boolean flag)
          Sets a flag indicating whether or not the tick unit is automatically selected from a range of standard tick units.
 void setCrosshairLockedOnData(boolean flag)
          Sets the flag indicating whether or not the crosshair should "lock-on" to actual data values.
 void setCrosshairPaint(java.awt.Paint paint)
          Sets the Paint used to color the crosshairs (if visible) and notifies registered listeners that the axis has been modified.
 void setCrosshairStroke(java.awt.Stroke stroke)
          Sets the Stroke used to draw the crosshairs (if visible) and notifies registered listeners that the axis has been modified.
 void setCrosshairValue(double value)
          Sets the crosshair value for the axis.
 void setCrosshairVisible(boolean flag)
          Sets the flag indicating whether or not a crosshair is visible for this axis.
 void setFixedAutoRange(double range)
          Sets the fixed auto range for the axis.
 void setGridLinesVisible(boolean flag)
          Sets the visibility of the grid lines and notifies registered listeners that the axis has been modified.
 void setGridPaint(java.awt.Paint paint)
          Sets the Paint used to color the grid lines (if visible) and notifies registered listeners that the axis has been modified.
 void setGridStroke(java.awt.Stroke stroke)
          Sets the Stroke used to draw the grid lines (if visible) and notifies registered listeners that the axis has been modified.
 void setMaximumAxisValue(double max)
          Sets the maximum value for the axis.
 void setMinimumAxisValue(double min)
          Sets the minimum value for the axis.
 void setRange(double lower, double upper)
          Sets the axis range.
 void setRange(Range range)
          Sets the upper and lower bounds for the axis.
 void setRangeAboutValue(double value, double size)
           
abstract  double translateJava2DtoValue(float java2DValue, java.awt.geom.Rectangle2D dataArea)
          Converts a coordinate in Java2D space to the corresponding data value, assuming that the axis runs along one edge of the specified dataArea.
abstract  double translateValueToJava2D(double dataValue, java.awt.geom.Rectangle2D dataArea)
          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 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_AUTO_RANGE

public static final boolean DEFAULT_AUTO_RANGE
The default auto-range value.

See Also:
Constant Field Values

DEFAULT_MINIMUM_AXIS_VALUE

public static final double DEFAULT_MINIMUM_AXIS_VALUE
The default minimum axis value.

See Also:
Constant Field Values

DEFAULT_MAXIMUM_AXIS_VALUE

public static final double DEFAULT_MAXIMUM_AXIS_VALUE
The default maximum axis value.

See Also:
Constant Field Values

DEFAULT_GRID_LINE_STROKE

public static final java.awt.Stroke DEFAULT_GRID_LINE_STROKE
The default grid line stroke.


DEFAULT_GRID_LINE_PAINT

public static final java.awt.Paint DEFAULT_GRID_LINE_PAINT
The default grid line paint.


DEFAULT_CROSSHAIR_VISIBLE

public static final boolean DEFAULT_CROSSHAIR_VISIBLE
The default crosshair visibility.

See Also:
Constant Field Values

DEFAULT_CROSSHAIR_STROKE

public static final java.awt.Stroke DEFAULT_CROSSHAIR_STROKE
The default crosshair stroke.


DEFAULT_CROSSHAIR_PAINT

public static final java.awt.Paint DEFAULT_CROSSHAIR_PAINT
The default crosshair paint.


autoRange

protected boolean autoRange
Flag that indicates whether or not the axis automatically scales to fit the chart data.


minimumRangeLength

protected double minimumRangeLength

maximumRangeLength

protected double maximumRangeLength

fixedAutoRange

protected double fixedAutoRange
If this value is positive, the amount is subtracted from the maximum data value to determine the lower axis range. This can be used to provide a fixed "window" on dynamic data.


range

protected Range range
The axis range.


autoTickUnitSelection

protected boolean autoTickUnitSelection
Flag that indicates whether or not the tick unit is selected automatically.


autoTickIndex

protected int autoTickIndex
An index into an array of standard tick values.


gridLinesVisible

protected boolean gridLinesVisible
Flag that indicates whether or not grid lines are visible.


gridStroke

protected java.awt.Stroke gridStroke
The stroke used to draw grid lines.


gridPaint

protected java.awt.Paint gridPaint
The paint used to draw grid lines.


anchorValue

protected double anchorValue
The anchor value for this axis.


crosshairVisible

protected boolean crosshairVisible
A flag that controls whether or not a crosshair is drawn for this axis.


crosshairValue

protected double crosshairValue
The crosshair value for this axis.


crosshairStroke

protected java.awt.Stroke crosshairStroke
The pen/brush used to draw the crosshair (if any).


crosshairPaint

protected java.awt.Paint crosshairPaint
The color used to draw the crosshair (if any).


crosshairLockedOnData

protected boolean crosshairLockedOnData
A flag that controls whether or not the crosshair locks onto actual data points.

Constructor Detail

ValueAxis

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

Parameters:
label - The axis label.

ValueAxis

protected ValueAxis(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,
                    boolean autoTickUnitSelection,
                    boolean gridLinesVisible,
                    java.awt.Stroke gridStroke,
                    java.awt.Paint gridPaint,
                    boolean crosshairVisible,
                    double crosshairValue,
                    java.awt.Stroke crosshairStroke,
                    java.awt.Paint crosshairPaint)
Constructs a value 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 the 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 the 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.
autoTickUnitSelection - A flag indicating whether or not the tick unit is automatically selected.
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).
crosshairValue - The value at which to draw an optional crosshair (null permitted).
crosshairStroke - The pen/brush used to draw the crosshair.
crosshairPaint - The color used to draw the crosshair.
Method Detail

isAutoRange

public boolean isAutoRange()
Returns true if the axis range is automatically adjusted to fit the data, and false otherwise.

Returns:
The auto-range flag.

setAutoRange

public void setAutoRange(boolean auto)
Sets a flag that determines whether or not the axis range is automatically adjusted to fit the data, and notifies registered listeners that the axis has been modified.

Parameters:
auto - Flag indicating whether or not the axis is automatically scaled to fit the data.

getFixedAutoRange

public double getFixedAutoRange()
Returns the fixed auto range.

Returns:
The autorange.

setFixedAutoRange

public void setFixedAutoRange(double range)
Sets the fixed auto range for the axis.

Parameters:
range - The range.

getMinimumAxisValue

public double getMinimumAxisValue()
Returns the minimum value for the axis.

Returns:
The minimum value for the axis.

setMinimumAxisValue

public void setMinimumAxisValue(double min)
Sets the minimum value for the axis.

Registered listeners are notified that the axis has been modified.

Parameters:
value - The new minimum.

getMaximumAxisValue

public double getMaximumAxisValue()
Returns the maximum value for the axis.

Returns:
The maximum value.

setMaximumAxisValue

public void setMaximumAxisValue(double max)
Sets the maximum value for the axis.

Registered listeners are notified that the axis has been modified.

Parameters:
max - The new maximum.

getRange

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

Returns:
The axis range.

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.

Parameters:
range - The new range.

setRange

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

Parameters:
lower - The lower axis limit.
upper - The upper axis limit.

setRangeAboutValue

public void setRangeAboutValue(double value,
                               double size)

isAutoTickUnitSelection

public boolean isAutoTickUnitSelection()
Returns a flag indicating whether or not the tick unit is automatically selected from a range of standard tick units.

Returns:
A flag indicating whether or not the tick unit is automatically selected.

setAutoTickUnitSelection

public void setAutoTickUnitSelection(boolean flag)
Sets a flag indicating whether or not the tick unit is automatically selected from a range of standard tick units.

Registered listeners are notified of a change to the axis.

Parameters:
flag - The new value of the flag.

isGridLinesVisible

public boolean isGridLinesVisible()
Returns true if the grid lines are showing, and false otherwise.

Returns:
The gridlines flag.

setGridLinesVisible

public void setGridLinesVisible(boolean flag)
Sets the visibility of the grid lines and notifies registered listeners that the axis has been modified.

Parameters:
flag - The new setting.

getGridStroke

public java.awt.Stroke getGridStroke()
Returns the Stroke used to draw the grid lines (if visible).

Returns:
The gridline stroke.

setGridStroke

public void setGridStroke(java.awt.Stroke stroke)
Sets the Stroke used to draw the grid lines (if visible) and notifies registered listeners that the axis has been modified.

Parameters:
stroke - The new grid line stroke.

getGridPaint

public java.awt.Paint getGridPaint()
Returns the grid line color.

Returns:
The grid line color.

setGridPaint

public void setGridPaint(java.awt.Paint paint)
Sets the Paint used to color the grid lines (if visible) and notifies registered listeners that the axis has been modified.

Parameters:
paint - The new grid paint.

getAnchorValue

public double getAnchorValue()
Returns the anchor value for this axis.

Returns:
The anchor value.

setAnchorValue

public void setAnchorValue(double value)
Sets the anchor value for this axis.

Parameters:
The - new anchor value.

isCrosshairVisible

public boolean isCrosshairVisible()
Returns a flag indicating whether or not a crosshair is visible for this axis.

Returns:
The flag.

setCrosshairVisible

public void setCrosshairVisible(boolean flag)
Sets the flag indicating whether or not a crosshair is visible for this axis.

Parameters:
flag - The new value of the flag.

isCrosshairLockedOnData

public boolean isCrosshairLockedOnData()
Returns a flag indicating whether or not the crosshair should "lock-on" to actual data values.

Returns:
The flag.

setCrosshairLockedOnData

public void setCrosshairLockedOnData(boolean flag)
Sets the flag indicating whether or not the crosshair should "lock-on" to actual data values.

Parameters:
The - flag.

getCrosshairValue

public double getCrosshairValue()
Returns the crosshair value.

Returns:
The crosshair value.

setCrosshairValue

public void setCrosshairValue(double value)
Sets the crosshair value for the axis.

Registered listeners are notified that the axis has been modified, but only if the crosshair is visible.

Parameters:
value - The new value (null permitted).

getCrosshairStroke

public java.awt.Stroke getCrosshairStroke()
Returns the Stroke used to draw the crosshair (if visible).

Returns:
The crosshair stroke.

setCrosshairStroke

public void setCrosshairStroke(java.awt.Stroke stroke)
Sets the Stroke used to draw the crosshairs (if visible) and notifies registered listeners that the axis has been modified.

Parameters:
stroke - The new crosshair stroke.

getCrosshairPaint

public java.awt.Paint getCrosshairPaint()
Returns the crosshair color.

Returns:
The crosshair color.

setCrosshairPaint

public void setCrosshairPaint(java.awt.Paint paint)
Sets the Paint used to color the crosshairs (if visible) and notifies registered listeners that the axis has been modified.

Parameters:
paint - The new crosshair paint.

translateValueToJava2D

public abstract double translateValueToJava2D(double dataValue,
                                              java.awt.geom.Rectangle2D dataArea)
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 plotArea.

Parameters:
dataValue - The data value.
dataArea - The area for plotting the data.
Returns:
The Java2D coordinate.

translateJava2DtoValue

public abstract double translateJava2DtoValue(float java2DValue,
                                              java.awt.geom.Rectangle2D dataArea)
Converts a coordinate in Java2D space to the corresponding data value, assuming that the axis runs along one edge of the specified dataArea.

Parameters:
java2DValue - The coordinate in Java2D space.
dataArea - The area in which the data is plotted.
Returns:
The data value.

autoAdjustRange

protected abstract void autoAdjustRange()
Automatically determines the maximum and minimum values on the axis to 'fit' the data.


setAnchoredRange

public void setAnchoredRange(double range)
Sets the axis range so the the anchor value is in the middle of the axis, and the overall range is equal to the value specified.

Parameters:
range - The range.

centerRange

public void centerRange(double value)
Centers the axis range about the specified value.

Parameters:
value - The center value.

resizeRange

public void resizeRange(double percent)

resizeRange

public void resizeRange(double percent,
                        double anchorValue)


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.