Top Description Inners Fields Constructors Methods
javafx.scene.chart

public abstract Class Axis<T>

extends Region
Class Inheritance
Known Direct Subclasses
javafx.scene.chart.CategoryAxis, javafx.scene.chart.ValueAxis
Imports
com.sun.javafx.scene.NodeHelper, javafx.css.Styleable, .CssMetaData, .PseudoClass, .StyleableBooleanProperty, .StyleableDoubleProperty, .StyleableObjectProperty, .FontCssMetaData, .StyleableProperty, javafx.css.converter.BooleanConverter, .EnumConverter, .PaintConverter, .SizeConverter, java.util.*, javafx.animation.FadeTransition, javafx.beans.binding.DoubleExpression, .ObjectExpression, .StringExpression, javafx.beans.property.*, javafx.collections.FXCollections, .ObservableList, javafx.geometry.Bounds, .Dimension2D, .Orientation, .Pos, .Side, javafx.scene.control.Label, javafx.scene.layout.Region, javafx.scene.paint.Color, .Paint, javafx.scene.shape.LineTo, .MoveTo, .Path, javafx.scene.text.Font, .Text, javafx.scene.transform.Rotate, .Translate, javafx.util.Duration

Base class for all axes in JavaFX that represents an axis drawn on a chart area. It holds properties for axis auto ranging, ticks and labels along the axis.

Some examples of concrete subclasses include NumberAxis whose axis plots data in numbers and CategoryAxis whose values / ticks represent string categories along its axis.

Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static class
Axis.TickMark<
the axis data type
T
>

TickMark represents the label text, its associated properties for each tick along the Axis.

Field Summary

Modifier and TypeField and Description
private BooleanProperty
animated

When true any changes to the axis and its range will be animated.

private BooleanProperty
autoRanging

This is true when the axis determines its range from the data automatically

private Label
private static final PseudoClass
BOTTOM_PSEUDOCLASS_STATE

pseudo-class indicating this is a vertical Bottom side Axis.

private Orientation
private double
private ObjectProperty<String>
label

The axis label

private BitSet
private static final PseudoClass
LEFT_PSEUDOCLASS_STATE

pseudo-class indicating this is a vertical Left side Axis.

pack-priv Text
pack-priv boolean
private double
pack-priv boolean
rangeValid

True when the current range invalid and all dependent calculations need to be updated

private static final PseudoClass
RIGHT_PSEUDOCLASS_STATE

pseudo-class indicating this is a vertical Right side Axis.

private ObjectProperty<Side>
side

The side of the plot which this axis is being drawn on

private ObjectProperty<Paint>
tickLabelFill

The fill for all tick labels

private ObjectProperty<Font>
tickLabelFont

The font for all tick labels

private DoubleProperty
tickLabelGap

The gap between tick labels and the tick mark lines

private DoubleProperty
tickLabelRotation

Rotation in degrees of tick mark labels from their normal horizontal.

private BooleanProperty
tickLabelsVisible

true if tick mark labels should be displayed

pack-priv boolean
private DoubleProperty
tickLength

The length of tick mark lines

private final Path
private final ObservableList<Axis.TickMark<T>>
private BooleanProperty
tickMarkVisible

true if tick marks should be displayed

private static final PseudoClass
TOP_PSEUDOCLASS_STATE

pseudo-class indicating this is a vertical Top side Axis.

private final ObservableList<Axis.TickMark<T>>
Inherited from javafx.scene.layout.Region:
USE_COMPUTED_SIZEUSE_PREF_SIZE

Constructor Summary

AccessConstructor and Description
public
Axis()

Creates and initializes a new instance of the Axis class.

Method Summary

Modifier and TypeMethod and Description
public final BooleanProperty
protected abstract Object

Returns:

Range information, this is implementation dependent
autoRange
(double
The length of the axis in screen coordinates
length
)

This calculates the upper and lower bound based on the data provided to invalidateRange() method.

public final BooleanProperty
protected abstract List<T>

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
)

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

protected double

Returns:

the computed preferred width for this axis
computePrefHeight
(double width)

Overrides javafx.scene.layout.Region.computePrefHeight.

Computes the preferred height of this axis for the given width.

protected double

Returns:

the computed preferred width for this axis
computePrefWidth
(double height)

Overrides javafx.scene.layout.Region.computePrefWidth.

Computes the preferred width of this axis for the given height.

public final boolean

Returns:

true if axis range changes will be animated and false otherwise
getAnimated
()

Indicates whether the changes to axis range will be animated or not.

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

Returns:

the CssMetaData
getClassCssMetaData
()

Hides javafx.scene.layout.Region.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.layout.Region.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.

public abstract double

Returns:

display position or Double.NaN if value not valid
getDisplayPosition
(T
The data value to work out display position for
value
)

Get the display position along this axis for a given value.

pack-priv final Side
pack-priv final double
public final String
protected abstract Object

Returns:

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

Called to get the current axis range.

public final Side
public final Paint
public final Font
public final double
public final double
public final double
protected abstract String

Returns:

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

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

public ObservableList<Axis.TickMark<T>>

Returns:

Unmodifiable observable list of TickMarks on this axis
getTickMarks
()

Unmodifiable observable list of tickmarks, each TickMark directly representing a tickmark on this axis.

public abstract T

Returns:

the nearest data value to the given pixel position or null if not on axis;
getValueForDisplay
(double
A pixel position on this axis
displayPosition
)

Get the data value for the given display position on this axis.

public abstract double

Returns:

display position or Double.NaN if zero is not in current range;
getZeroPosition
()

Get the display position of the zero line along this axis.

protected final void
invalidateRange()

Mark the current range invalid, this will cause anything that depends on the range to be recalculated on the next layout.

public void
invalidateRange(List<T>
The current set of all data that needs to be plotted on this axis
data
)

Called when data has changed and the range may not be valid any more.

public final boolean
protected final boolean

Returns:

true if current range calculations are valid
isRangeValid
()

See if the current range is valid, if it is not then any range dependent calculations need to redone on the next layout pass

private boolean

Returns:

true if labels overlap
isTickLabelsOverlap
(Side
side of the Axis
side
,
Axis.TickMark<T>
first tick mark
m1
,
Axis.TickMark<T>
second tick mark
m2
,
double
minimum space between labels
gap
)

Checks if two consecutive tick mark labels overlaps.

public final boolean
public final boolean
public abstract boolean

Returns:

true if the given value is plottable on this axis
isValueOnAxis
(T
The value to check if its on axis
value
)

Checks if the given value is plottable on this axis

public final ObjectProperty<String>
protected void
layoutChildren()

Overrides javafx.scene.Parent.layoutChildren.

Invoked during the layout pass to layout this axis and all its content.

protected final Dimension2D

Returns:

size of tick mark label for given value
measureTickMarkLabelSize
(String
tick mark label text
labelText
,
double
The text rotation
rotation
)

Measure the size of the label for given tick mark value.

protected final Dimension2D

Returns:

size of tick mark label for given value
measureTickMarkSize
(T
tick mark value
value
,
double
The text rotation
rotation
)

Measure the size of the label for given tick mark value.

protected Dimension2D

Returns:

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

Measure the size of the label for given tick mark value.

private double

Returns:

size of tick mark label for given value
measureTickMarkSize
(T
tick mark value
value
,
Side
side of this Axis
side
)

Measure the size of the label for given tick mark value.

private void
positionTextNode(Text
The text node to position
node
,
double
The x position, to place text next to
posX
,
double
The y position, to place text next to
posY
,
double
The text rotation
angle
,
Side
The side to place text next to position x,y at
side
)

Positions a text node to one side of the given point, it X height is vertically centered on point if LEFT or RIGHT and its centered horizontally if TOP ot BOTTOM.

public void
requestAxisLayout()

Request that the axis is laid out in the next layout pass.

public void
requestLayout()

Overrides javafx.scene.Parent.requestLayout.

We suppress requestLayout() calls here by doing nothing as we don't want changes to our children to cause layout.

public final void
setAnimated(boolean value)

public final void
setAutoRanging(boolean value)

pack-priv final void
pack-priv final void
setEffectiveTickLabelRotation(double
NaN for using the tickLabelRotationProperty()
rotation
)

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

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

public final void
setSide(Side value)

public final void
public final void
public final void
setTickLabelGap(double value)

public final void
setTickLabelRotation(double value)

public final void
setTickLabelsVisible(boolean value)

public final void
setTickLength(double value)

public final void
setTickMarkVisible(boolean value)

protected final boolean

Returns:

true if animations should happen
shouldAnimate
()

This is used to check if any given animation should run.

public final ObjectProperty<Side>
public final ObjectProperty<Paint>
public final ObjectProperty<Font>
public final DoubleProperty
public final DoubleProperty
public final BooleanProperty
public final DoubleProperty
protected void
tickMarksUpdated()

Called during layout if the tickmarks have been updated, allowing subclasses to do anything they need to in reaction.

public final BooleanProperty
public abstract double

Returns:

Numeric value for the given data value
toNumericValue
(T
The data value to convert
value
)

All axis values must be representable by some numeric value.

public abstract T

Returns:

Data value for given numeric value
toRealValue
(double
The numeric value to convert
value
)

All axis values must be representable by some numeric value.

private void
updateTickMark(Axis.TickMark<T> tick, double length, double startX, double startY, double endX, double endY)

Updates visibility of the text node and adds the tick mark to the path

private void
updateTickMarks(Side side, double length)

Inherited from javafx.scene.layout.Region:
backgroundPropertyborderPropertycacheShapePropertycenterShapePropertycomputeMaxHeightcomputeMaxWidthcomputeMinHeightcomputeMinWidthgetBackgroundgetBordergetHeightgetInsetsgetMaxHeightgetMaxWidthgetMinHeightgetMinWidthgetOpaqueInsetsgetPaddinggetPrefHeightgetPrefWidthgetShapegetUserAgentStylesheetgetWidthheightPropertyinsetsPropertyisCacheShapeisCenterShapeisResizableisScaleShapeisSnapToPixellayoutInArealayoutInArealayoutInArealayoutInAreamaxHeightmaxHeightPropertymaxWidthmaxWidthPropertyminHeightminHeightPropertyminWidthminWidthPropertyopaqueInsetsPropertypaddingPropertypositionInAreapositionInAreaprefHeightprefHeightPropertyprefWidthprefWidthPropertyresizescaleShapePropertysetBackgroundsetBordersetCacheShapesetCenterShapesetHeightsetMaxHeightsetMaxSizesetMaxWidthsetMinHeightsetMinSizesetMinWidthsetOpaqueInsetssetPaddingsetPrefHeightsetPrefSizesetPrefWidthsetScaleShapesetShapesetSnapToPixelsetWidthshapePropertysnappedBottomInsetsnappedLeftInsetsnappedRightInsetsnappedTopInsetsnapPositionsnapPositionXsnapPositionYsnapSizesnapSizeXsnapSizeYsnapSpacesnapSpaceXsnapSpaceYsnapToPixelPropertywidthProperty