Top Description Inners Fields Constructors Methods
javafx.scene.chart

public final Class NumberAxis

extends ValueAxis<Number>
Class Inheritance
Imports
java.text.DecimalFormat, .ParseException, java.util.ArrayList, .Collections, .List, javafx.animation.KeyFrame, .KeyValue, javafx.beans.property.BooleanProperty, .BooleanPropertyBase, .DoubleProperty, .SimpleStringProperty, .StringProperty, javafx.beans.value.ChangeListener, javafx.geometry.Dimension2D, .Side, javafx.util.Duration, .StringConverter, com.sun.javafx.charts.ChartLayoutAnimator, javafx.css.StyleableDoubleProperty, .CssMetaData, .Styleable, .StyleableProperty, javafx.css.converter.SizeConverter

An axis class that plots a range of numbers with major tick marks every tickUnit. You can use any Number type with this axis.
Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
NumberAxis.DefaultFormatter

Default number formatter for NumberAxis, this stays in sync with auto-ranging and formats values appropriately.

private static class

Field Summary

Modifier and TypeField and Description
private final ChartLayoutAnimator
private Object
private final StringProperty
private final NumberAxis.DefaultFormatter
private BooleanProperty
forceZeroInRange

When true zero is always included in the visible range.

private DoubleProperty
tickUnit

The value between each major tick mark in data units.

Inherited from javafx.scene.chart.ValueAxis:
currentLowerBounddataMaxValuedataMinValue

Constructor Summary

AccessConstructor and Description
public
NumberAxis()

Creates an auto-ranging NumberAxis.

public
NumberAxis(double
The lower bound for this axis, i.e. min plottable value
lowerBound
,
double
The upper bound for this axis, i.e. max plottable value
upperBound
,
double
The tick unit, i.e. space between tickmarks
tickUnit
)

Creates a non-auto-ranging NumberAxis with the given upper bound, lower bound and tick unit.

public
NumberAxis(String
The name to display for this axis
axisLabel
,
double
The lower bound for this axis, i.e. min plottable value
lowerBound
,
double
The upper bound for this axis, i.e. max plottable value
upperBound
,
double
The tick unit, i.e. space between tickmarks
tickUnit
)

Creates a non-auto-ranging NumberAxis with the given lower bound, upper bound and tick unit.

Method Summary

Modifier and TypeMethod and Description
protected Object

Returns:

The calculated range
autoRange
(double
The min data value that needs to be plotted on this axis
minValue
,
double
The max data value that needs to be plotted on this axis
maxValue
,
double
The length of the axis in display coordinates
length
,
double
The approximate average size a label takes along the axis
labelSize
)

Overrides javafx.scene.chart.ValueAxis.autoRange.

Called to set the upper and lower bound and anything else that needs to be auto-ranged.

protected List<Number>

Returns:

List of data values where to draw minor tick marks
calculateMinorTickMarks
()

Implements abstract javafx.scene.chart.ValueAxis.calculateMinorTickMarks.

Calculates a list of the data values for every minor tick mark

protected List<Number>

Returns:

A list of tick marks that fit along the axis if it was the given length
calculateTickValues
(double
The length of the axis in display units
length
,
Object
A range object returned from autoRange()
range
)

Implements abstract javafx.scene.chart.Axis.calculateTickValues.

Calculates a list of all the data values for each tick mark in range

public final BooleanProperty
public static List<CssMetaData<? extends Styleable, ?>>

Returns:

the CssMetaData
getClassCssMetaData
()

Hides javafx.scene.chart.ValueAxis.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

public List<CssMetaData<? extends Styleable, ?>>
getCssMetaData()

Overrides javafx.scene.chart.ValueAxis.getCssMetaData.

Implements javafx.css.Styleable.getCssMetaData.

This method should delegate to Node#getClassCssMetaData() so that a Node's CssMetaData can be accessed without the need for reflection.

protected Object

Returns:

A range object that can be passed to setRange() and calculateTickValues()
getRange
()

Implements abstract javafx.scene.chart.Axis.getRange.

Called to get the current axis range.

protected String

Returns:

A formatted string for the given value
getTickMarkLabel
(Number
The value to format into a tick label string
value
)

Implements abstract javafx.scene.chart.Axis.getTickMarkLabel.

Get the string label name for a tick mark with the given value.

public final double
public final boolean
protected Dimension2D

Returns:

size of tick mark label for given value
measureTickMarkSize
(Number
tick mark value
value
,
Object
range to use during calculations
range
)

Overrides javafx.scene.chart.Axis.measureTickMarkSize.

Measures the size of the label for a given tick mark value.

private Dimension2D

Returns:

size of tick mark label for given value
measureTickMarkSize
(Number
tick mark value
value
,
double
The text rotation
rotation
,
String
The number formatter
numFormatter
)

Measures the size of the label for a given tick mark value.

public final void
setForceZeroInRange(boolean value)

protected void
setRange(Object
A range object returned from autoRange()
range
,
boolean
If true animate the change in range
animate
)

Implements abstract javafx.scene.chart.Axis.setRange.

Called to set the current axis range to the given range.

public final void
setTickUnit(double value)

public final DoubleProperty
Inherited from javafx.scene.chart.ValueAxis:
autoRangecalculateNewScalegetDisplayPositiongetLowerBoundgetMinorTickCountgetMinorTickLengthgetScalegetTickLabelFormattergetUpperBoundgetValueForDisplaygetZeroPositioninvalidateRangeisMinorTickVisibleisValueOnAxislayoutChildrenlowerBoundPropertyminorTickCountPropertyminorTickLengthPropertyminorTickVisiblePropertyscalePropertyscalePropertyImplsetLowerBoundsetMinorTickCountsetMinorTickLengthsetMinorTickVisiblesetScalesetTickLabelFormattersetUpperBoundtickLabelFormatterPropertytickMarksUpdatedtoNumericValuetoRealValueupperBoundProperty

Field Detail

animatorback to summary
private final ChartLayoutAnimator animator
currentAnimationIDback to summary
private Object currentAnimationID
currentFormatterPropertyback to summary
private final StringProperty currentFormatterProperty
defaultFormatterback to summary
private final NumberAxis.DefaultFormatter defaultFormatter
forceZeroInRangeback to summary
private BooleanProperty forceZeroInRange

When true zero is always included in the visible range. This only has effect if auto-ranging is on.

tickUnitback to summary
private DoubleProperty tickUnit

The value between each major tick mark in data units. This is automatically set if we are auto-ranging.

Constructor Detail

NumberAxisback to summary
public NumberAxis()

Creates an auto-ranging NumberAxis.

NumberAxisback to summary
public NumberAxis(double lowerBound, double upperBound, double tickUnit)

Creates a non-auto-ranging NumberAxis with the given upper bound, lower bound and tick unit.

Parameters
lowerBound:double

The lower bound for this axis, i.e. min plottable value

upperBound:double

The upper bound for this axis, i.e. max plottable value

tickUnit:double

The tick unit, i.e. space between tickmarks

NumberAxisback to summary
public NumberAxis(String axisLabel, double lowerBound, double upperBound, double tickUnit)

Creates a non-auto-ranging NumberAxis with the given lower bound, upper bound and tick unit.

Parameters
axisLabel:String

The name to display for this axis

lowerBound:double

The lower bound for this axis, i.e. min plottable value

upperBound:double

The upper bound for this axis, i.e. max plottable value

tickUnit:double

The tick unit, i.e. space between tickmarks

Method Detail

autoRangeback to summary
protected Object autoRange(double minValue, double maxValue, double length, double labelSize)

Overrides javafx.scene.chart.ValueAxis.autoRange.

Called to set the upper and lower bound and anything else that needs to be auto-ranged.

Parameters
minValue:double

The min data value that needs to be plotted on this axis

maxValue:double

The max data value that needs to be plotted on this axis

length:double

The length of the axis in display coordinates

labelSize:double

The approximate average size a label takes along the axis

Returns:Object

The calculated range

Annotations
@Override
calculateMinorTickMarksback to summary
protected List<Number> calculateMinorTickMarks()

Implements abstract javafx.scene.chart.ValueAxis.calculateMinorTickMarks.

Calculates a list of the data values for every minor tick mark

Returns:List<Number>

List of data values where to draw minor tick marks

Annotations
@Override
calculateTickValuesback to summary
protected List<Number> calculateTickValues(double length, Object range)

Implements abstract javafx.scene.chart.Axis.calculateTickValues.

Calculates a list of all the data values for each tick mark in range

Parameters
length:double

The length of the axis in display units

range:Object

A range object returned from autoRange()

Returns:List<Number>

A list of tick marks that fit along the axis if it was the given length

Annotations
@Override
forceZeroInRangePropertyback to summary
public final BooleanProperty forceZeroInRangeProperty()
getClassCssMetaDataback to summary
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData()

Hides javafx.scene.chart.ValueAxis.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

Returns:List<CssMetaData<? extends Styleable, ?>>

the CssMetaData

Since
JavaFX 8.0
getCssMetaDataback to summary
public List<CssMetaData<? extends Styleable, ?>> getCssMetaData()

Overrides javafx.scene.chart.ValueAxis.getCssMetaData.

Implements javafx.css.Styleable.getCssMetaData.

Doc from javafx.scene.chart.ValueAxis.getCssMetaData.

This method should delegate to Node#getClassCssMetaData() so that a Node's CssMetaData can be accessed without the need for reflection.

Returns:List<CssMetaData<? extends Styleable, ?>>

Doc from javafx.scene.Node.getCssMetaData.

The CssMetaData associated with this node, which may include the CssMetaData of its superclasses.

Annotations
@Override
Since
JavaFX 8.0
getRangeback to summary
protected Object getRange()

Implements abstract javafx.scene.chart.Axis.getRange.

Called to get the current axis range.

Returns:Object

A range object that can be passed to setRange() and calculateTickValues()

Annotations
@Override
getTickMarkLabelback to summary
protected String getTickMarkLabel(Number value)

Implements abstract javafx.scene.chart.Axis.getTickMarkLabel.

Get the string label name for a tick mark with the given value.

Parameters
value:Number

The value to format into a tick label string

Returns:String

A formatted string for the given value

Annotations
@Override
getTickUnitback to summary
public final double getTickUnit()
isForceZeroInRangeback to summary
public final boolean isForceZeroInRange()
measureTickMarkSizeback to summary
protected Dimension2D measureTickMarkSize(Number value, Object range)

Overrides javafx.scene.chart.Axis.measureTickMarkSize.

Measures the size of the label for a given tick mark value. This uses the font that is set for the tick marks.

Parameters
value:Number

tick mark value

range:Object

range to use during calculations

Returns:Dimension2D

size of tick mark label for given value

Annotations
@Override
measureTickMarkSizeback to summary
private Dimension2D measureTickMarkSize(Number value, double rotation, String numFormatter)

Measures the size of the label for a given tick mark value. This uses the font that is set for the tick marks.

Parameters
value:Number

tick mark value

rotation:double

The text rotation

numFormatter:String

The number formatter

Returns:Dimension2D

size of tick mark label for given value

setForceZeroInRangeback to summary
public final void setForceZeroInRange(boolean value)
setRangeback to summary
protected void setRange(Object range, boolean animate)

Implements abstract javafx.scene.chart.Axis.setRange.

Called to set the current axis range to the given range. If isAnimating() is true then this method should animate the range to the new range.

Parameters
range:Object

A range object returned from autoRange()

animate:boolean

If true animate the change in range

Annotations
@Override
setTickUnitback to summary
public final void setTickUnit(double value)
tickUnitPropertyback to summary
public final DoubleProperty tickUnitProperty()
javafx.scene.chart back to summary

public Class NumberAxis.DefaultFormatter

extends StringConverter<Number>
Class Inheritance

Default number formatter for NumberAxis, this stays in sync with auto-ranging and formats values appropriately. You can wrap this formatter to add prefixes or suffixes;
Since
JavaFX 2.0

Field Summary

Modifier and TypeField and Description
private DecimalFormat
private String
private String

Constructor Summary

AccessConstructor and Description
public
DefaultFormatter(final NumberAxis
The axis to format tick marks for
axis
)

Construct a DefaultFormatter for the given NumberAxis

public
DefaultFormatter(NumberAxis
The axis to format tick marks for
axis
,
String
The prefix to append to the start of formatted number, can be null if not needed
prefix
,
String
The suffix to append to the end of formatted number, can be null if not needed
suffix
)

Construct a DefaultFormatter for the given NumberAxis with a prefix and/or suffix.

Method Summary

Modifier and TypeMethod and Description
public Number

Returns:

a Number representation of the string passed in.
fromString
(String
the String to convert
string
)

Implements abstract javafx.util.StringConverter.fromString.

Converts the string provided into a Number defined by the this converter.

public String

Returns:

a string representation of the object passed in.
toString
(Number
the object of type T to convert
object
)

Implements abstract javafx.util.StringConverter.toString.

Converts the object provided into its string form.

private String
toString(Number object, String numFormatter)

private String
toString(Number object, DecimalFormat formatter)

Field Detail

formatterback to summary
private DecimalFormat formatter
prefixback to summary
private String prefix
suffixback to summary
private String suffix

Constructor Detail

DefaultFormatterback to summary
public DefaultFormatter(final NumberAxis axis)

Construct a DefaultFormatter for the given NumberAxis

Parameters
axis:NumberAxis

The axis to format tick marks for

DefaultFormatterback to summary
public DefaultFormatter(NumberAxis axis, String prefix, String suffix)

Construct a DefaultFormatter for the given NumberAxis with a prefix and/or suffix.

Parameters
axis:NumberAxis

The axis to format tick marks for

prefix:String

The prefix to append to the start of formatted number, can be null if not needed

suffix:String

The suffix to append to the end of formatted number, can be null if not needed

Method Detail

fromStringback to summary
public Number fromString(String string)

Implements abstract javafx.util.StringConverter.fromString.

Converts the string provided into a Number defined by the this converter. Format of the string and type of the resulting object is defined by this converter.

Parameters
string:String

Doc from javafx.util.StringConverter.fromString.

the String to convert

Returns:Number

a Number representation of the string passed in.

Annotations
@Override
See Also
StringConverter#toString
toStringback to summary
public String toString(Number object)

Implements abstract javafx.util.StringConverter.toString.

Converts the object provided into its string form. Format of the returned string is defined by this converter.

Parameters
object:Number

Doc from javafx.util.StringConverter.toString.

the object of type T to convert

Returns:String

a string representation of the object passed in.

Annotations
@Override
See Also
StringConverter#toString
toStringback to summary
private String toString(Number object, String numFormatter)
toStringback to summary
private String toString(Number object, DecimalFormat formatter)
javafx.scene.chart back to summary

private Class NumberAxis.StyleableProperties

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final List<CssMetaData<? extends Styleable, ?>>
private static final CssMetaData<NumberAxis, Number>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

STYLEABLESback to summary
private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES
TICK_UNITback to summary
private static final CssMetaData<NumberAxis, Number> TICK_UNIT

Constructor Detail

StyleablePropertiesback to summary
private StyleableProperties()