org.jfree.chart.axis
public class NumberAxis extends ValueAxis implements Cloneable, Serializable
If the axis is set up to automatically determine its range to fit the data,
you can ensure that the range includes zero (statisticians usually prefer
this) by setting the autoRangeIncludesZero
flag to
true
.
The NumberAxis
class has a mechanism for automatically
selecting a tick unit that is appropriate for the current axis range. This
mechanism is an adaptation of code suggested by Laurence Vanhelsuwe.
Field Summary | |
---|---|
static boolean | DEFAULT_AUTO_RANGE_INCLUDES_ZERO The default value for the autoRangeIncludesZero flag. |
static boolean | DEFAULT_AUTO_RANGE_STICKY_ZERO The default value for the autoRangeStickyZero flag. |
static NumberTickUnit | DEFAULT_TICK_UNIT The default tick unit. |
static boolean | DEFAULT_VERTICAL_TICK_LABELS The default setting for the vertical tick labels flag. |
Constructor Summary | |
---|---|
NumberAxis()
Default constructor. | |
NumberAxis(String label)
Constructs a number axis, using default values where necessary.
|
Method Summary | |
---|---|
protected void | autoAdjustRange()
Rescales the axis to ensure that all data is visible. |
protected double | calculateHighestVisibleTickValue()
Calculates the value of the highest visible tick on the axis.
|
protected double | calculateLowestVisibleTickValue()
Calculates the value of the lowest visible tick on the axis.
|
protected int | calculateVisibleTickCount()
Calculates the number of visible ticks.
|
Object | clone()
Returns a clone of the axis.
|
void | configure()
Configures the axis to work with the specified plot. |
static TickUnitSource | createIntegerTickUnits()
Returns a collection of tick units for integer values.
|
static TickUnitSource | createIntegerTickUnits(Locale locale)
Returns a collection of tick units for integer values.
|
static TickUnitSource | createStandardTickUnits()
Creates the standard tick units.
|
static TickUnitSource | createStandardTickUnits(Locale locale)
Creates a collection of standard tick units. |
AxisState | draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState)
Draws the axis on a Java 2D graphics device (such as the screen or a
printer).
|
boolean | equals(Object obj)
Tests the axis for equality with an arbitrary object.
|
protected double | estimateMaximumTickLabelHeight(Graphics2D g2)
Estimates the maximum tick label height.
|
protected double | estimateMaximumTickLabelWidth(Graphics2D g2, TickUnit unit)
Estimates the maximum width of the tick labels, assuming the specified
tick unit is used.
|
boolean | getAutoRangeIncludesZero()
Returns the flag that indicates whether or not the automatic axis range
(if indeed it is determined automatically) is forced to include zero.
|
boolean | getAutoRangeStickyZero()
Returns a flag that affects the auto-range when zero falls outside the
data range but inside the margins defined for the axis.
|
MarkerAxisBand | getMarkerBand()
Returns the (optional) marker band for the axis.
|
NumberFormat | getNumberFormatOverride()
Returns the number format override. |
RangeType | getRangeType()
Returns the axis range type.
|
NumberTickUnit | getTickUnit()
Returns the tick unit for the axis.
|
int | hashCode()
Returns a hash code for this object.
|
double | java2DToValue(double java2DValue, Rectangle2D area, 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.
|
List | refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge)
Calculates the positions of the tick labels for the axis, storing the
results in the tick label list (ready for drawing).
|
protected List | refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge)
Calculates the positions of the tick labels for the axis, storing the
results in the tick label list (ready for drawing).
|
protected List | refreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge)
Calculates the positions of the tick labels for the axis, storing the
results in the tick label list (ready for drawing).
|
protected void | selectAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge)
Selects an appropriate tick value for the axis. |
protected void | selectHorizontalAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge)
Selects an appropriate tick value for the axis. |
protected void | selectVerticalAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge)
Selects an appropriate tick value for the axis. |
void | setAutoRangeIncludesZero(boolean flag)
Sets the flag that indicates whether or not the axis range, if
automatically calculated, is forced to include zero.
|
void | setAutoRangeStickyZero(boolean flag)
Sets a flag that affects the auto-range when zero falls outside the data
range but inside the margins defined for the axis.
|
void | setMarkerBand(MarkerAxisBand band)
Sets the marker band for the axis.
|
void | setNumberFormatOverride(NumberFormat formatter)
Sets the number format override. |
void | setRangeType(RangeType rangeType)
Sets the axis range type.
|
void | setTickUnit(NumberTickUnit unit)
Sets the tick unit for the axis and sends an AxisChangeEvent to
all registered listeners. |
void | setTickUnit(NumberTickUnit unit, boolean notify, boolean turnOffAutoSelect)
Sets the tick unit for the axis and, if requested, sends an
AxisChangeEvent to all registered listeners. |
double | valueToJava2D(double value, Rectangle2D area, RectangleEdge edge)
Converts a data value to a coordinate in Java2D space, assuming that the
axis runs along one edge of the specified dataArea.
|
Parameters: label the axis label (null
permitted).
Returns: The value of the highest visible tick on the axis.
See Also: calculateLowestVisibleTickValue
Returns: The value of the lowest visible tick on the axis.
See Also: calculateHighestVisibleTickValue
Returns: The number of visible ticks on the axis.
Returns: A clone
Throws: CloneNotSupportedException if some component of the axis does not support cloning.
Returns: A collection of tick units for integer values.
See Also: NumberAxis createStandardTickUnits
Parameters: locale the locale to use to represent Numbers.
Returns: A collection of tick units for integer values.
See Also: NumberAxis
If you don't like these defaults, create your own instance of TickUnits and then pass it to the setStandardTickUnits() method in the NumberAxis class.
Returns: The standard tick units.
See Also: NumberAxis createIntegerTickUnits
NumberFormat
).
If you don't like these defaults, create your own instance of
TickUnits and then pass it to the
setStandardTickUnits()
method.
Parameters: locale the locale.
Returns: A tick unit collection.
See Also: NumberAxis
Parameters: g2 the graphics device (null
not permitted). cursor the cursor location. plotArea the area within which the axes and data should be drawn
(null
not permitted). dataArea the area within which the data should be drawn
(null
not permitted). edge the location of the axis (null
not permitted). plotState collects information about the plot
(null
permitted).
Returns: The axis state (never null
).
Parameters: obj the object (null
permitted).
Returns: A boolean.
Parameters: g2 the graphics device.
Returns: The maximum height.
Rather than computing the string bounds of every tick on the axis, we just look at two values: the lower bound and the upper bound for the axis. These two values will usually be representative.
Parameters: g2 the graphics device. unit the tick unit to use for calculation.
Returns: The estimated maximum width of the tick labels.
Returns: The flag.
Returns: The flag.
See Also: NumberAxis
Returns: The marker band (possibly null
).
See Also: setMarkerBand
Returns: The number formatter (possibly null
).
See Also: setNumberFormatOverride
Returns: The axis range type (never null
).
See Also: setRangeType
Note: if the autoTickUnitSelection
flag is
true
the tick unit may be changed while the axis is being
drawn, so in that case the return value from this method may be
irrelevant if the method is called before the axis has been drawn.
Returns: The tick unit for the axis.
See Also: setTickUnit isAutoTickUnitSelection
Returns: A hash code.
Parameters: java2DValue the coordinate in Java2D space. area the area in which the data is plotted. edge the location.
Returns: The data value.
See Also: NumberAxis
Parameters: g2 the graphics device. state the axis state. dataArea the area in which the plot should be drawn. edge the location of the axis.
Returns: A list of ticks.
Parameters: g2 the graphics device. dataArea the area in which the data should be drawn. edge the location of the axis.
Returns: A list of ticks.
Parameters: g2 the graphics device. dataArea the area in which the plot should be drawn. edge the location of the axis.
Returns: A list of ticks.
Parameters: g2 the graphics device. dataArea the area defined by the axes. edge the axis location.
Parameters: g2 the graphics device. dataArea the area defined by the axes. edge the axis location.
Parameters: g2 the graphics device. dataArea the area in which the plot should be drawn. edge the axis location.
If the flag is changed to true
, the axis range is
recalculated.
Any change to the flag will trigger an AxisChangeEvent.
Parameters: flag the new value of the flag.
See Also: getAutoRangeIncludesZero
Parameters: flag the new flag.
See Also: getAutoRangeStickyZero
The marker band is optional, leave it set to null
if you
don't require it.
Parameters: band the new band (null
permitted).
See Also: getMarkerBand
Parameters: formatter the number formatter (null
permitted).
See Also: getNumberFormatOverride
Parameters: rangeType the range type (null
not permitted).
See Also: getRangeType
Parameters: unit the new tick unit (null
not permitted).
See Also: getTickUnit NumberAxis
Parameters: unit the new tick unit (null
not permitted). notify notify listeners? turnOffAutoSelect turn off the auto-tick selection?
Note that it is possible for the coordinate to fall outside the plotArea.
Parameters: value the data value. area the area for plotting the data. edge the axis location.
Returns: The Java2D coordinate.
See Also: NumberAxis