|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.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.
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. |
Fields inherited from class org.jfree.chart.axis.ValueAxis |
DEFAULT_AUTO_RANGE, DEFAULT_AUTO_RANGE_MINIMUM_SIZE, DEFAULT_AUTO_TICK_UNIT_SELECTION, DEFAULT_AXIS_LINE_PAINT, DEFAULT_AXIS_LINE_STROKE, DEFAULT_INVERTED, DEFAULT_LOWER_BOUND, DEFAULT_LOWER_MARGIN, DEFAULT_RANGE, DEFAULT_UPPER_BOUND, DEFAULT_UPPER_MARGIN, MAXIMUM_TICK_COUNT |
Constructor Summary | |
NumberAxis()
Default constructor. |
|
NumberAxis(java.lang.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. |
boolean |
autoRangeIncludesZero()
Returns the flag that indicates whether or not the automatic axis range (if indeed it is determined automatically) is forced to include zero. |
boolean |
autoRangeStickyZero()
Returns a flag that affects the auto-range when zero falls outside the data range but inside the margins defined for the axis. |
double |
calculateHighestVisibleTickValue()
Calculates the value of the highest visible tick on the axis. |
double |
calculateLowestVisibleTickValue()
Calculates the value of the lowest visible tick on the axis. |
int |
calculateVisibleTickCount()
Calculates the number of visible ticks. |
java.lang.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(java.util.Locale locale)
Returns a collection of tick units for integer values. |
static TickUnitSource |
createStandardTickUnits()
Creates the standard tick units. |
static TickUnitSource |
createStandardTickUnits(java.util.Locale locale)
Creates a collection of standard tick units. |
AxisState |
draw(java.awt.Graphics2D g2,
double cursor,
java.awt.geom.Rectangle2D plotArea,
java.awt.geom.Rectangle2D dataArea,
org.jfree.ui.RectangleEdge edge)
Draws the axis on a Java 2D graphics device (such as the screen or a printer). |
boolean |
equals(java.lang.Object object)
Tests an object for equality with this instance. |
protected double |
estimateMaximumTickLabelHeight(java.awt.Graphics2D g2)
Estimates the maximum tick label height. |
protected double |
estimateMaximumTickLabelWidth(java.awt.Graphics2D g2,
TickUnit tickUnit)
Estimates the maximum width of the tick labels, assuming the specified tick unit is used. |
MarkerAxisBand |
getMarkerBand()
Returns the (optional) marker band for the axis. |
java.text.NumberFormat |
getNumberFormatOverride()
Returns the number format override. |
NumberTickUnit |
getTickUnit()
Returns the tick unit for the axis. |
protected java.util.List |
refreshHorizontalTicks(java.awt.Graphics2D g2,
double cursor,
java.awt.geom.Rectangle2D plotArea,
java.awt.geom.Rectangle2D dataArea,
org.jfree.ui.RectangleEdge edge)
Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing). |
java.util.List |
refreshTicks(java.awt.Graphics2D g2,
AxisState state,
java.awt.geom.Rectangle2D plotArea,
java.awt.geom.Rectangle2D dataArea,
org.jfree.ui.RectangleEdge edge)
Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing). |
protected java.util.List |
refreshVerticalTicks(java.awt.Graphics2D g2,
double cursor,
java.awt.geom.Rectangle2D plotArea,
java.awt.geom.Rectangle2D dataArea,
org.jfree.ui.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(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D drawArea,
java.awt.geom.Rectangle2D dataArea,
org.jfree.ui.RectangleEdge edge)
Selects an appropriate tick value for the axis. |
protected void |
selectHorizontalAutoTickUnit(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D drawArea,
java.awt.geom.Rectangle2D dataArea,
org.jfree.ui.RectangleEdge edge)
Selects an appropriate tick value for the axis. |
protected void |
selectVerticalAutoTickUnit(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D plotArea,
java.awt.geom.Rectangle2D dataArea,
org.jfree.ui.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(java.text.NumberFormat formatter)
Sets the number format override. |
void |
setTickUnit(NumberTickUnit unit)
Sets the tick unit for the axis. |
void |
setTickUnit(NumberTickUnit unit,
boolean notify,
boolean turnOffAutoSelect)
Sets the tick unit for the axis. |
double |
translateJava2DToValue(double java2DValue,
java.awt.geom.Rectangle2D dataArea,
org.jfree.ui.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. |
double |
translateValueToJava2D(double value,
java.awt.geom.Rectangle2D dataArea,
org.jfree.ui.RectangleEdge edge)
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 java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final boolean DEFAULT_AUTO_RANGE_INCLUDES_ZERO
public static final boolean DEFAULT_AUTO_RANGE_STICKY_ZERO
public static final NumberTickUnit DEFAULT_TICK_UNIT
public static final boolean DEFAULT_VERTICAL_TICK_LABELS
Constructor Detail |
public NumberAxis()
public NumberAxis(java.lang.String label)
label
- the axis label (null
permitted).Method Detail |
public boolean autoRangeIncludesZero()
public void setAutoRangeIncludesZero(boolean flag)
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.public boolean autoRangeStickyZero()
public void setAutoRangeStickyZero(boolean flag)
flag
- the new flag.public NumberTickUnit getTickUnit()
public void setTickUnit(NumberTickUnit unit)
AxisChangeEvent
to all registered
listeners.
unit
- the new tick unit.public void setTickUnit(NumberTickUnit unit, boolean notify, boolean turnOffAutoSelect)
AxisChangeEvent
to all
registered listeners.
unit
- the new tick unit.notify
- notify listeners?turnOffAutoSelect
- turn off the auto-tick selection?public java.text.NumberFormat getNumberFormatOverride()
public void setNumberFormatOverride(java.text.NumberFormat formatter)
formatter
- the number formatter (null
permitted).public MarkerAxisBand getMarkerBand()
null
).public void setMarkerBand(MarkerAxisBand band)
The marker band is optional, leave it set to null
if you don't require it.
band
- the new band (null permitted).
public void configure()
configure
in class Axis
protected void autoAdjustRange()
autoAdjustRange
in class ValueAxis
public double translateValueToJava2D(double value, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
Note that it is possible for the coordinate to fall outside the plotArea.
translateValueToJava2D
in class ValueAxis
value
- the data value.dataArea
- the area for plotting the data.edge
- the axis location.
public double translateJava2DToValue(double java2DValue, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
translateJava2DToValue
in class ValueAxis
java2DValue
- the coordinate in Java2D space.dataArea
- the area in which the data is plotted.edge
- the location.
public double calculateLowestVisibleTickValue()
public double calculateHighestVisibleTickValue()
public int calculateVisibleTickCount()
public AxisState draw(java.awt.Graphics2D g2, double cursor, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
draw
in class Axis
g2
- the graphics device.cursor
- the cursor location.plotArea
- the area within which the axes and data should be drawn.dataArea
- the area within which the data should be drawn.edge
- the location of the axis.
public static TickUnitSource createStandardTickUnits()
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.
public static TickUnitSource createIntegerTickUnits()
public static TickUnitSource createStandardTickUnits(java.util.Locale locale)
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.
public static TickUnitSource createIntegerTickUnits(java.util.Locale locale)
locale
- the locale to use to represent Numbers.
protected double estimateMaximumTickLabelHeight(java.awt.Graphics2D g2)
g2
- the graphics device.
protected double estimateMaximumTickLabelWidth(java.awt.Graphics2D g2, TickUnit tickUnit)
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.tickUnit
- the tick unit to use for calculation.
protected void selectAutoTickUnit(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D drawArea, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
g2
- the graphics device.drawArea
- the area in which the plot and axes should be drawn.dataArea
- the area defined by the axes.edge
- the axis location.protected void selectHorizontalAutoTickUnit(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D drawArea, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
g2
- the graphics device.drawArea
- the area in which the plot and axes should be drawn.dataArea
- the area defined by the axes.edge
- the axis location.protected void selectVerticalAutoTickUnit(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
g2
- the graphics device.plotArea
- the area in which the plot and axes should be drawn.dataArea
- the area in which the plot should be drawn.edge
- the axis location.public java.util.List refreshTicks(java.awt.Graphics2D g2, AxisState state, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
refreshTicks
in class Axis
g2
- the graphics device.state
- the axis state.plotArea
- the area in which the plot and the axes should be drawn.dataArea
- the area in which the plot should be drawn.edge
- the location of the axis.
protected java.util.List refreshHorizontalTicks(java.awt.Graphics2D g2, double cursor, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
g2
- the graphics device.cursor
- the cursor.plotArea
- the area in which the plot (inlcuding axes) should be drawn.dataArea
- the area in which the data should be drawn.edge
- the location of the axis.
protected java.util.List refreshVerticalTicks(java.awt.Graphics2D g2, double cursor, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
g2
- the graphics device.cursor
- the cursor location.plotArea
- the area in which the plot and the axes should be drawn.dataArea
- the area in which the plot should be drawn.edge
- the location of the axis.
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in interface org.jfree.util.PublicCloneable
clone
in class ValueAxis
java.lang.CloneNotSupportedException
- if some component of the axis does not support cloning.public boolean equals(java.lang.Object object)
equals
in class ValueAxis
object
- the object.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |