com.jrefinery.chart
Class VerticalNumberAxis

java.lang.Object
  extended by com.jrefinery.chart.Axis
      extended by com.jrefinery.chart.ValueAxis
          extended by com.jrefinery.chart.NumberAxis
              extended by com.jrefinery.chart.VerticalNumberAxis
All Implemented Interfaces:
AxisConstants, VerticalAxis
Direct Known Subclasses:
VerticalLogarithmicAxis, VerticalNumberAxis3D, VerticalSymbolicAxis

public class VerticalNumberAxis
extends NumberAxis
implements VerticalAxis

A standard linear value axis, for values displayed vertically.

Note that bug 4273469 on the Java Developer Connection talks about why the grid lines don't always line up with the tick marks precisely.


Field Summary
protected  boolean verticalLabel
          A flag indicating whether or not the axis label is drawn vertically.
 
Fields inherited from class com.jrefinery.chart.NumberAxis
autoRangeIncludesZero, autoRangeMinimumSize, autoRangeStickyZero, DEFAULT_AUTO_RANGE_INCLUDES_ZERO, DEFAULT_AUTO_RANGE_STICKY_ZERO, DEFAULT_LOWER_MARGIN, DEFAULT_MINIMUM_AUTO_RANGE, DEFAULT_TICK_UNIT, DEFAULT_UPPER_MARGIN, inverted, lowerMargin, standardTickUnits, tickUnit, upperMargin
 
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
VerticalNumberAxis()
          Constructs a vertical number axis, using default values where necessary.
VerticalNumberAxis(java.lang.String label)
          Constructs a vertical number axis, using default values where necessary.
VerticalNumberAxis(java.lang.String label, java.awt.Font labelFont, double minimumAxisValue, double maximumAxisValue)
          Constructs a vertical number axis.
VerticalNumberAxis(java.lang.String label, java.awt.Font labelFont, java.awt.Paint labelPaint, java.awt.Insets labelInsets, boolean verticalLabel, boolean tickLabelsVisible, java.awt.Font tickLabelFont, java.awt.Paint tickLabelPaint, java.awt.Insets tickLabelInsets, boolean tickMarksVisible, java.awt.Stroke tickMarkStroke, boolean autoRange, boolean autoRangeIncludesZero, boolean autoRangeStickyZero, java.lang.Number autoRangeMinimum, double minimumAxisValue, double maximumAxisValue, boolean inverted, boolean autoTickUnitSelection, NumberTickUnit tickUnit, boolean gridLinesVisible, java.awt.Stroke gridStroke, java.awt.Paint gridPaint, boolean crosshairVisible, double crosshairValue, java.awt.Stroke crosshairStroke, java.awt.Paint crosshairPaint)
          Constructs a new VerticalNumberAxis.
 
Method Summary
protected  void autoAdjustRange()
          Sets the axis minimum and maximum values so that all the data is visible.
 void configure()
          Configures the axis to work with the specified plot.
 void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D drawArea, java.awt.geom.Rectangle2D plotArea)
          Draws the plot on a Java 2D graphics device (such as the screen or a printer).
protected  boolean isCompatiblePlot(Plot plot)
          Returns true if the specified plot is compatible with the axis, and false otherwise.
 boolean isVerticalLabel()
          Returns a flag indicating whether or not the axis label is drawn vertically.
 void refreshTicks(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D drawArea, java.awt.geom.Rectangle2D plotArea)
          Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).
 java.awt.geom.Rectangle2D reserveAxisArea(java.awt.Graphics2D g2, Plot plot, java.awt.geom.Rectangle2D drawArea, double reservedHeight)
          Returns area in which the axis will be displayed.
 double reserveWidth(java.awt.Graphics2D g2, Plot plot, java.awt.geom.Rectangle2D drawArea)
          Returns the width required to draw the axis in the specified draw area.
 void setVerticalLabel(boolean flag)
          Sets a flag indicating whether or not the axis label is drawn vertically.
 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.
 double translateValueToJava2D(double value, 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.NumberAxis
autoRangeIncludesZero, autoRangeStickyZero, calculateHighestVisibleTickValue, calculateLowestVisibleTickValue, calculateVisibleTickCount, getAutoRangeMinimumSize, getLowerMargin, getStandardTickUnits, getTickUnit, getUpperMargin, isInverted, setAutoRangeIncludesZero, setAutoRangeMinimumSize, setAutoRangeStickyZero, setInverted, setLowerMargin, setStandardTickUnits, setTickUnit, setUpperMargin
 
Methods inherited from class com.jrefinery.chart.ValueAxis
centerRange, getAnchorValue, getCrosshairPaint, getCrosshairStroke, getCrosshairValue, getFixedAutoRange, getGridPaint, getGridStroke, getMaximumAxisValue, getMinimumAxisValue, getRange, isAutoRange, isAutoTickUnitSelection, isCrosshairLockedOnData, isCrosshairVisible, isGridLinesVisible, resizeRange, resizeRange, setAnchoredRange, setAnchorValue, setAutoRange, setAutoTickUnitSelection, setCrosshairLockedOnData, setCrosshairPaint, setCrosshairStroke, setCrosshairValue, setCrosshairVisible, setFixedAutoRange, setGridLinesVisible, setGridPaint, setGridStroke, setMaximumAxisValue, setMinimumAxisValue, setRange, setRange, setRangeAboutValue
 
Methods inherited from class com.jrefinery.chart.Axis
addChangeListener, getFixedDimension, getLabel, getLabelFont, getLabelInsets, getLabelPaint, getMaxTickLabelWidth, getPlot, getTickLabelFont, getTickLabelInsets, getTickLabelPaint, getTickMarkStroke, isTickLabelsVisible, isTickMarksVisible, isVisible, notifyListeners, 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

verticalLabel

protected boolean verticalLabel
A flag indicating whether or not the axis label is drawn vertically.

Constructor Detail

VerticalNumberAxis

public VerticalNumberAxis()
Constructs a vertical number axis, using default values where necessary.


VerticalNumberAxis

public VerticalNumberAxis(java.lang.String label)
Constructs a vertical number axis, using default values where necessary.

Parameters:
label - The axis label (null permitted).

VerticalNumberAxis

public VerticalNumberAxis(java.lang.String label,
                          java.awt.Font labelFont,
                          double minimumAxisValue,
                          double maximumAxisValue)
Constructs a vertical number axis.

Parameters:
label - The axis label (null permitted).
labelFont - The font for displaying the axis label.
minimumAxisValue - The lowest value shown on the axis.
maximumAxisValue - The highest value shown on the axis.

VerticalNumberAxis

public VerticalNumberAxis(java.lang.String label,
                          java.awt.Font labelFont,
                          java.awt.Paint labelPaint,
                          java.awt.Insets labelInsets,
                          boolean verticalLabel,
                          boolean tickLabelsVisible,
                          java.awt.Font tickLabelFont,
                          java.awt.Paint tickLabelPaint,
                          java.awt.Insets tickLabelInsets,
                          boolean tickMarksVisible,
                          java.awt.Stroke tickMarkStroke,
                          boolean autoRange,
                          boolean autoRangeIncludesZero,
                          boolean autoRangeStickyZero,
                          java.lang.Number autoRangeMinimum,
                          double minimumAxisValue,
                          double maximumAxisValue,
                          boolean inverted,
                          boolean autoTickUnitSelection,
                          NumberTickUnit tickUnit,
                          boolean gridLinesVisible,
                          java.awt.Stroke gridStroke,
                          java.awt.Paint gridPaint,
                          boolean crosshairVisible,
                          double crosshairValue,
                          java.awt.Stroke crosshairStroke,
                          java.awt.Paint crosshairPaint)
Constructs a new VerticalNumberAxis.

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.
verticalLabel - Flag indicating whether or not the label is drawn vertically.
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 is automatically scaled to fit the data.
autoRangeIncludesZero - A flag indicating whether or not zero *must* be displayed on axis.
autoRangeMinimum - The smallest automatic range allowed.
minimumAxisValue - The lowest value shown on the axis.
maximumAxisValue - The highest value shown on the axis.
inverted - A flag indicating whether the axis is normal or inverted (inverted means running from positive to negative).
autoTickUnitSelection - A flag indicating whether or not the tick units are selected automatically.
tickUnit - The tick unit.
gridLinesVisible - Flag indicating whether or not grid lines are visible for this axis.
gridStroke - The pen/brush used to display grid lines (if visible).
gridPaint - The color 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

isVerticalLabel

public boolean isVerticalLabel()
Returns a flag indicating whether or not the axis label is drawn vertically.

Returns:
The flag.

setVerticalLabel

public void setVerticalLabel(boolean flag)
Sets a flag indicating whether or not the axis label is drawn vertically. If the setting is changed, registered listeners are notified that the axis has changed.

Parameters:
flag - The new flag.

configure

public void configure()
Configures the axis to work with the specified plot. If the axis has auto-scaling, then sets the maximum and minimum values.

Specified by:
configure in class Axis

translateValueToJava2D

public double translateValueToJava2D(double value,
                                     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.

Specified by:
translateValueToJava2D in class ValueAxis
Parameters:
dataValue - The data value.
dataArea - The area for plotting the data.
Returns:
The Java2D coordinate.

translateJava2DtoValue

public 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.

Specified by:
translateJava2DtoValue in class ValueAxis
Parameters:
java2DValue - The coordinate in Java2D space.
dataArea - The area in which the data is plotted.
Returns:
The data value.

autoAdjustRange

protected void autoAdjustRange()
Sets the axis minimum and maximum values so that all the data is visible.

You can control the range calculation in several ways. First, you can define upper and lower margins as a percentage of the data range (the default is a 5% margin for each). Second, you can set a flag that forces the range to include zero. Finally, you can set another flag, the 'sticky zero' flag, that only affects the range when zero falls within the axis margins. When this happens, the margin is truncated so that zero is the upper or lower limit for the axis.

Specified by:
autoAdjustRange in class ValueAxis

draw

public void draw(java.awt.Graphics2D g2,
                 java.awt.geom.Rectangle2D drawArea,
                 java.awt.geom.Rectangle2D plotArea)
Draws the plot on a Java 2D graphics device (such as the screen or a printer).

Specified by:
draw in class Axis
Parameters:
g2 - The graphics device.
drawArea - The area within which the chart should be drawn.
plotArea - The area within which the plot should be drawn (a subset of the drawArea).

reserveWidth

public double reserveWidth(java.awt.Graphics2D g2,
                           Plot plot,
                           java.awt.geom.Rectangle2D drawArea)
Returns the width required to draw the axis in the specified draw area.

Specified by:
reserveWidth in interface VerticalAxis
Parameters:
g2 - The graphics device.
plot - A reference to the plot;
drawArea - The area within which the plot should be drawn.

reserveAxisArea

public java.awt.geom.Rectangle2D reserveAxisArea(java.awt.Graphics2D g2,
                                                 Plot plot,
                                                 java.awt.geom.Rectangle2D drawArea,
                                                 double reservedHeight)
Returns area in which the axis will be displayed.

Specified by:
reserveAxisArea in interface VerticalAxis
Parameters:
g2 - The graphics device.
plot - A reference to the plot.
drawArea - The area in which the plot and axes should be drawn.
reservedHeight - The height reserved for the horizontal axis.

refreshTicks

public void refreshTicks(java.awt.Graphics2D g2,
                         java.awt.geom.Rectangle2D drawArea,
                         java.awt.geom.Rectangle2D plotArea)
Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).

Specified by:
refreshTicks in class Axis
Parameters:
g2 - The graphics device.
drawArea - The area in which the plot and the axes should be drawn.
plotArea - The area in which the plot should be drawn.

isCompatiblePlot

protected boolean isCompatiblePlot(Plot plot)
Returns true if the specified plot is compatible with the axis, and false otherwise.

This class (VerticalNumberAxis) requires that the plot implements the VerticalValuePlot interface.

Specified by:
isCompatiblePlot in class Axis
Parameters:
plot - The plot.
Returns:
True if the specified plot is compatible with the axis, and false otherwise.


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.