java.lang.Object | |||
↳ | org.jfree.chart.axis.Axis | ||
↳ | org.jfree.chart.axis.ValueAxis | ||
↳ | org.jfree.chart.axis.NumberAxis |
![]() |
An axis for displaying numerical data.
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.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
boolean | DEFAULT_AUTO_RANGE_INCLUDES_ZERO | The default value for the autoRangeIncludesZero flag. | |||||||||
boolean | DEFAULT_AUTO_RANGE_STICKY_ZERO | The default value for the autoRangeStickyZero flag. | |||||||||
boolean | DEFAULT_VERTICAL_TICK_LABELS | The default setting for the vertical tick labels flag. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
DEFAULT_TICK_UNIT | The default tick unit. |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Default constructor.
| |||||||||||
Constructs a number axis, using default values where necessary.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns a clone of the axis.
| |||||||||||
Configures the axis to work with the specified plot.
| |||||||||||
Returns a collection of tick units for integer values.
| |||||||||||
Returns a collection of tick units for integer values.
| |||||||||||
Creates the standard tick units.
| |||||||||||
Creates a collection of standard tick units.
| |||||||||||
Draws the axis on a Java 2D graphics device (such as the screen or a
printer).
| |||||||||||
Tests the axis for equality with an arbitrary object.
| |||||||||||
Returns the flag that indicates whether or not the automatic axis range
(if indeed it is determined automatically) is forced to include zero.
| |||||||||||
Returns a flag that affects the auto-range when zero falls outside the
data range but inside the margins defined for the axis.
| |||||||||||
Returns the (optional) marker band for the axis.
| |||||||||||
Returns the number format override.
| |||||||||||
Returns the axis range type.
| |||||||||||
Returns the tick unit for the axis.
| |||||||||||
Returns a hash code for this object.
| |||||||||||
Converts a coordinate in Java2D space to the corresponding data value,
assuming that the axis runs along one edge of the specified dataArea.
| |||||||||||
Calculates the positions of the tick labels for the axis, storing the
results in the tick label list (ready for drawing).
| |||||||||||
Sets the flag that indicates whether or not the axis range, if
automatically calculated, is forced to include zero.
| |||||||||||
Sets a flag that affects the auto-range when zero falls outside the data
range but inside the margins defined for the axis.
| |||||||||||
Sets the marker band for the axis.
| |||||||||||
Sets the number format override.
| |||||||||||
Sets the axis range type.
| |||||||||||
Sets the tick unit for the axis and sends an
AxisChangeEvent to
all registered listeners. | |||||||||||
Sets the tick unit for the axis and, if requested, sends an
AxisChangeEvent to all registered listeners. | |||||||||||
Converts a data value to a coordinate in Java2D space, assuming that the
axis runs along one edge of the specified dataArea.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Rescales the axis to ensure that all data is visible.
| |||||||||||
Calculates the value of the highest visible tick on the axis.
| |||||||||||
Calculates the value of the lowest visible tick on the axis.
| |||||||||||
Calculates the number of visible ticks.
| |||||||||||
Estimates the maximum tick label height.
| |||||||||||
Estimates the maximum width of the tick labels, assuming the specified
tick unit is used.
| |||||||||||
Calculates the positions of the tick labels for the axis, storing the
results in the tick label list (ready for drawing).
| |||||||||||
Calculates the positions of the tick labels for the axis, storing the
results in the tick label list (ready for drawing).
| |||||||||||
Selects an appropriate tick value for the axis.
| |||||||||||
Selects an appropriate tick value for the axis.
| |||||||||||
Selects an appropriate tick value for the axis.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() |
The default value for the autoRangeIncludesZero flag.
The default value for the autoRangeStickyZero flag.
The default setting for the vertical tick labels flag.
Default constructor.
Constructs a number axis, using default values where necessary.
label | the axis label (null permitted).
|
---|
Returns a clone of the axis.
CloneNotSupportedException | if some component of the axis does not support cloning. |
---|
Configures the axis to work with the specified plot. If the axis has auto-scaling, then sets the maximum and minimum values.
Returns a collection of tick units for integer values. Uses a given Locale to create the DecimalFormats.
locale | the locale to use to represent Numbers. |
---|
Returns a collection of tick units for integer values.
Creates the standard tick units.
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.
Creates a collection of standard tick units. The supplied locale is
used to create the number formatter (a localised instance of
NumberFormat
).
If you don't like these defaults, create your own instance of
TickUnits
and then pass it to the
setStandardTickUnits()
method.
locale | the locale. |
---|
Draws the axis on a Java 2D graphics device (such as the screen or a printer).
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). |
null
).
Tests the axis for equality with an arbitrary object.
obj | the object (null permitted). |
---|
Returns the flag that indicates whether or not the automatic axis range (if indeed it is determined automatically) is forced to include zero.
Returns a flag that affects the auto-range when zero falls outside the data range but inside the margins defined for the axis.
Returns the (optional) marker band for the axis.
null
).Returns the number format override. If this is non-null, then it will be used to format the numbers on the axis.
null
).Returns the axis range type.
null
).Returns the tick unit for the axis.
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 a hash code for this object.
Converts a coordinate in Java2D space to the corresponding data value, assuming that the axis runs along one edge of the specified dataArea.
java2DValue | the coordinate in Java2D space. |
---|---|
area | the area in which the data is plotted. |
edge | the location. |
Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).
g2 | the graphics device. |
---|---|
state | the axis state. |
dataArea | the area in which the plot should be drawn. |
edge | the location of the axis. |
Sets the flag that indicates whether or not the axis range, if automatically calculated, is forced to include zero.
If the flag is changed to true
, the axis range is
recalculated.
Any change to the flag will trigger an AxisChangeEvent
.
flag | the new value of the flag. |
---|
Sets a flag that affects the auto-range when zero falls outside the data range but inside the margins defined for the axis.
flag | the new flag. |
---|
Sets the marker band for the axis.
The marker band is optional, leave it set to null
if you
don't require it.
band | the new band (null |
---|
Sets the number format override. If this is non-null, then it will be used to format the numbers on the axis.
formatter | the number formatter (null permitted). |
---|
Sets the axis range type.
rangeType | the range type (null not permitted). |
---|
Sets the tick unit for the axis and sends an AxisChangeEvent
to
all registered listeners. A side effect of calling this method is that
the "auto-select" feature for tick units is switched off (you can
restore it using the setAutoTickUnitSelection(boolean)
method).
unit | the new tick unit (null not permitted). |
---|
Sets the tick unit for the axis and, if requested, sends an
AxisChangeEvent
to all registered listeners. In addition, an
option is provided to turn off the "auto-select" feature for tick units
(you can restore it using the
setAutoTickUnitSelection(boolean)
method).
unit | the new tick unit (null not permitted). |
---|---|
notify | notify listeners? |
turnOffAutoSelect | turn off the auto-tick selection? |
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.
value | the data value. |
---|---|
area | the area for plotting the data. |
edge | the axis location. |
Rescales the axis to ensure that all data is visible.
Calculates the value of the highest visible tick on the axis.
Calculates the value of the lowest visible tick on the axis.
Calculates the number of visible ticks.
Estimates the maximum tick label height.
g2 | the graphics device. |
---|
Estimates the maximum width of the tick labels, assuming the specified tick unit is used.
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.
g2 | the graphics device. |
---|---|
unit | the tick unit to use for calculation. |
Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).
g2 | the graphics device. |
---|---|
dataArea | the area in which the data should be drawn. |
edge | the location of the axis. |
Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).
g2 | the graphics device. |
---|---|
dataArea | the area in which the plot should be drawn. |
edge | the location of the axis. |
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.
g2 | the graphics device. |
---|---|
dataArea | the area defined by the axes. |
edge | the axis location. |
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.
g2 | the graphics device. |
---|---|
dataArea | the area defined by the axes. |
edge | the axis location. |
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.
g2 | the graphics device. |
---|---|
dataArea | the area in which the plot should be drawn. |
edge | the axis location. |