org.jfree.chart.axis
Class HorizontalNumberAxis

java.lang.Object
  |
  +--org.jfree.chart.axis.Axis
        |
        +--org.jfree.chart.axis.ValueAxis
              |
              +--org.jfree.chart.axis.NumberAxis
                    |
                    +--org.jfree.chart.axis.HorizontalNumberAxis
All Implemented Interfaces:
AxisConstants, HorizontalAxis, java.io.Serializable
Direct Known Subclasses:
HorizontalColorBarAxis, HorizontalLogarithmicAxis, HorizontalNumberAxis3D, HorizontalSymbolicAxis

public class HorizontalNumberAxis
extends NumberAxis
implements HorizontalAxis, java.io.Serializable

A horizontal axis that displays numerical values.

Author:
David Gilbert
See Also:
HorizontalCategoryPlot, XYPlot, Serialized Form

Field Summary
static boolean DEFAULT_VERTICAL_TICK_LABELS
          The default setting for the vertical tick labels flag.
 
Fields inherited from class org.jfree.chart.axis.NumberAxis
DEFAULT_AUTO_RANGE_INCLUDES_ZERO, DEFAULT_AUTO_RANGE_STICKY_ZERO, DEFAULT_TICK_UNIT
 
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 interface org.jfree.chart.axis.AxisConstants
BOTTOM, DEFAULT_AXIS_LABEL_FONT, DEFAULT_AXIS_LABEL_INSETS, DEFAULT_AXIS_LABEL_PAINT, 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, LEFT, RIGHT, TOP
 
Constructor Summary
HorizontalNumberAxis(java.lang.String label)
          Constructs a horizontal number axis, using default values where necessary.
 
Method Summary
protected  void autoAdjustRange()
          Rescales the axis to ensure that all data is visible.
 void configure()
          Configures the axis to work with the specified plot.
 void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, int location)
          Draws the axis on a Java 2D graphics device (such as the screen or a printer).
 HorizontalMarkerAxisBand getMarkerBand()
          Returns the (optional) marker band for the axis.
protected  boolean isCompatiblePlot(Plot plot)
          Returns true if a plot is compatible with the axis, and false otherwise.
 boolean isVerticalTickLabels()
          Returns a flag indicating whether the tick labels are drawn 'vertically'.
 void refreshTicks(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, int location)
          Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).
 double reserveHeight(java.awt.Graphics2D g2, Plot plot, java.awt.geom.Rectangle2D drawArea, int location)
          Returns the height required to draw the axis in the specified draw area.
 double reserveHeight(java.awt.Graphics2D g2, Plot plot, java.awt.geom.Rectangle2D drawArea, int location, double reservedWidth, int verticalAxisLocation)
          Returns area in which the axis will be displayed.
protected  void selectAutoTickUnit(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D drawArea, java.awt.geom.Rectangle2D dataArea)
          Selects an appropriate tick value for the axis.
 void setMarkerBand(HorizontalMarkerAxisBand band)
          Sets the marker band for the axis.
 void setVerticalTickLabels(boolean flag)
          Sets the flag that determines whether the tick labels are 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 org.jfree.chart.axis.NumberAxis
autoRangeIncludesZero, autoRangeStickyZero, calculateHighestVisibleTickValue, calculateLowestVisibleTickValue, calculateVisibleTickCount, createIntegerTickUnits, createIntegerTickUnits, createStandardTickUnits, createStandardTickUnits, getNumberFormatOverride, getTickUnit, setAutoRangeIncludesZero, setAutoRangeStickyZero, setNumberFormatOverride, setTickUnit, setTickUnit
 
Methods inherited from class org.jfree.chart.axis.ValueAxis
centerRange, getAnchorValue, getAutoRangeMinimumSize, getAutoTickIndex, getFixedAutoRange, getLowerMargin, getMaximumAxisValue, getMinimumAxisValue, getRange, getStandardTickUnits, getUpperMargin, isAutoRange, isAutoTickUnitSelection, isInverted, resizeRange, resizeRange, setAnchoredRange, setAnchorValue, setAnchorValueAttribute, setAutoRange, setAutoRange, setAutoRangeMinimumSize, setAutoRangeMinimumSize, setAutoTickIndex, setAutoTickUnitSelection, setAutoTickUnitSelection, setFixedAutoRange, setInverted, setLowerMargin, setMaximumAxisValue, setMinimumAxisValue, setRange, setRange, setRangeAboutValue, setRangeAttribute, setStandardTickUnits, setUpperMargin
 
Methods inherited from class org.jfree.chart.axis.Axis
addChangeListener, drawHorizontalLabel, drawVerticalLabel, equals, getFixedDimension, getLabel, getLabelFont, getLabelInsets, getLabelPaint, getMaxTickLabelWidth, getPlot, getTickLabelFont, getTickLabelInsets, getTickLabelPaint, getTickMarkInsideLength, getTickMarkOutsideLength, getTickMarkPaint, getTickMarkStroke, getTicks, isTickLabelsVisible, isTickMarksVisible, isVisible, notifyListeners, removeChangeListener, setFixedDimension, setLabel, setLabelFont, setLabelInsets, setLabelPaint, setPlot, setTickLabelFont, setTickLabelInsets, setTickLabelPaint, setTickLabelsVisible, setTickMarkInsideLength, setTickMarkOutsideLength, setTickMarkPaint, setTickMarkStroke, setTickMarksVisible, setVisible
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_VERTICAL_TICK_LABELS

public static final boolean DEFAULT_VERTICAL_TICK_LABELS
The default setting for the vertical tick labels flag.

See Also:
Constant Field Values
Constructor Detail

HorizontalNumberAxis

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

Parameters:
label - the axis label (null permitted).
Method Detail

isVerticalTickLabels

public boolean isVerticalTickLabels()
Returns a flag indicating whether the tick labels are drawn 'vertically'.

Returns:
The flag.

setVerticalTickLabels

public void setVerticalTickLabels(boolean flag)
Sets the flag that determines whether the tick labels are drawn 'vertically'.

Parameters:
flag - the new value of the flag.

getMarkerBand

public HorizontalMarkerAxisBand getMarkerBand()
Returns the (optional) marker band for the axis.

Returns:
The marker band (possibly null).

setMarkerBand

public void setMarkerBand(HorizontalMarkerAxisBand band)
Sets the marker band for the axis.

The marker band is optional, leave it set to null if you don't require it.

Parameters:
band - the new band (null permitted).

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:
value - 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()
Rescales the axis to ensure that all data is visible.

Specified by:
autoAdjustRange in class ValueAxis

refreshTicks

public void refreshTicks(java.awt.Graphics2D g2,
                         java.awt.geom.Rectangle2D plotArea,
                         java.awt.geom.Rectangle2D dataArea,
                         int location)
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.
plotArea - the area in which the plot (inlcuding axes) should be drawn.
dataArea - the area in which the data should be drawn.
location - the location of the axis.

draw

public void draw(java.awt.Graphics2D g2,
                 java.awt.geom.Rectangle2D plotArea,
                 java.awt.geom.Rectangle2D dataArea,
                 int location)
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.
plotArea - the area within which the axes and data should be drawn.
dataArea - the area within which the data should be drawn.
location - the location of the axis.

reserveHeight

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

Specified by:
reserveHeight in interface HorizontalAxis
Parameters:
g2 - the graphics device.
plot - the plot that the axis belongs to.
drawArea - the area within which the plot should be drawn.
location - the axis location (top or bottom).
Returns:
the height required to draw the axis in the specified draw area.

reserveHeight

public double reserveHeight(java.awt.Graphics2D g2,
                            Plot plot,
                            java.awt.geom.Rectangle2D drawArea,
                            int location,
                            double reservedWidth,
                            int verticalAxisLocation)
Returns area in which the axis will be displayed.

Specified by:
reserveHeight in interface HorizontalAxis
Parameters:
g2 - the graphics device.
plot - a reference to the plot.
drawArea - the area within which the plot and axes should be drawn.
location - the location of the axis.
reservedWidth - the space already reserved for the vertical axis.
verticalAxisLocation - the location of the vertical axis.
Returns:
area in which the axis will be displayed.

selectAutoTickUnit

protected void selectAutoTickUnit(java.awt.Graphics2D g2,
                                  java.awt.geom.Rectangle2D drawArea,
                                  java.awt.geom.Rectangle2D dataArea)
Selects an appropriate tick value for the axis. The strategy is to display as many ticks as possible (selected from an array of 'standard' tick units) without the labels overlapping.

Parameters:
g2 - the graphics device.
drawArea - the area in which the plot and axes should be drawn.
dataArea - the area defined by the axes.

isCompatiblePlot

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

For this axis, the requirement is that the plot implements the HorizontalValuePlot interface.

Specified by:
isCompatiblePlot in class Axis
Parameters:
plot - the plot.
Returns:
true if the plot is compatible with the axis.