APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javafx.scene.chart

public final Class CategoryAxis

extends Axis<String>
Class Inheritance
Imports
java.util.ArrayList, .List, .Collections, javafx.animation.KeyFrame, .KeyValue, javafx.beans.property.BooleanProperty, .DoubleProperty, .ObjectProperty, .ObjectPropertyBase, .ReadOnlyDoubleProperty, .ReadOnlyDoubleWrapper, .SimpleDoubleProperty, javafx.collections.FXCollections, .ListChangeListener, .ObservableList, javafx.geometry.Dimension2D, .Side, javafx.util.Duration, com.sun.javafx.charts.ChartLayoutAnimator, javafx.css.StyleableBooleanProperty, .StyleableDoubleProperty, .CssMetaData, .Styleable, .StyleableProperty, javafx.css.converter.BooleanConverter, .SizeConverter

A axis implementation that will works on string categories where each value as a unique category(tick mark) along the axis.
Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private List<String>
private final ChartLayoutAnimator
private ObjectProperty<ObservableList<String>>
private final ReadOnlyDoubleWrapper
categorySpacing

This is the gap between one category and the next along this axis

private boolean
private Object
private DoubleProperty
endMargin

The margin between the last tick mark and the axis end

private final DoubleProperty
firstCategoryPos

This is the position of the first category along this axis

private BooleanProperty
gapStartAndEnd

If this is true then half the space between ticks is left at the start and end

private ListChangeListener<String>
private DoubleProperty
startMargin

The margin between the axis start and the first tick-mark

Inherited from javafx.scene.chart.Axis:
measuremeasureInvalidrangeValidtickLabelsVisibleInvalid

Constructor Summary

AccessConstructor and Description
public
CategoryAxis()

Create a auto-ranging category axis with an empty list of categories.

public
CategoryAxis(ObservableList<String>
List of the categories for this axis
categories
)

Create a category axis with the given categories.

Method Summary

Modifier and TypeMethod and Description
protected Object

Returns:

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

Implements abstract javafx.scene.chart.Axis.autoRange.

This calculates the categories based on the data provided to invalidateRange() method.

private double
calculateNewFirstPos(double length, double catSpacing)

private double
calculateNewSpacing(double length, List<String> categories)

private double
calculateRequiredSize(boolean axisVertical, double tickLabelRotation)

protected List<String>

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 range)

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

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

public final ReadOnlyDoubleProperty
private void
public final DoubleProperty
public final BooleanProperty
pack-priv final List<String>
public final ObservableList<String>

Returns:

ObservableList of categories for this axis.
getCategories
()

Returns a ObservableList of categories plotted on this axis.

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

Returns:

the CssMetaData
getClassCssMetaData
()

Hides javafx.scene.chart.Axis.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.Axis.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 double

Returns:

display position or Double.NaN if value not one of the categories
getDisplayPosition
(String
The data value to work out display position for
value
)

Implements abstract javafx.scene.chart.Axis.getDisplayPosition.

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

private String
public final double
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.

public final double
protected String

Returns:

A formatted string for the given value
getTickMarkLabel
(String
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 String

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
)

Implements abstract javafx.scene.chart.Axis.getValueForDisplay.

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

public double

Returns:

always Double.NaN for CategoryAxis
getZeroPosition
()

Implements abstract javafx.scene.chart.Axis.getZeroPosition.

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

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

Overrides javafx.scene.chart.Axis.invalidateRange.

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

public final boolean
public boolean

Returns:

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

Implements abstract javafx.scene.chart.Axis.isValueOnAxis.

Checks if the given value is plottable on this axis

protected Dimension2D

Returns:

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

Overrides javafx.scene.chart.Axis.measureTickMarkSize.

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

public final void
setCategories(ObservableList<String>
the ordered list of categories plotted on this axis
value
)

The ordered list of categories plotted on this axis.

public final void
setEndMargin(double value)

public final void
setGapStartAndEnd(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
setStartMargin(double value)

public final DoubleProperty
public double

Returns:

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

Implements abstract javafx.scene.chart.Axis.toNumericValue.

All axis values must be representable by some numeric value.

public String

Returns:

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

Implements abstract javafx.scene.chart.Axis.toRealValue.

All axis values must be representable by some numeric value.

Inherited from javafx.scene.chart.Axis:
animatedPropertyautoRangingPropertycomputePrefHeightcomputePrefWidthgetAnimatedgetEffectiveSidegetEffectiveTickLabelRotationgetLabelgetSidegetTickLabelFillgetTickLabelFontgetTickLabelGapgetTickLabelRotationgetTickLengthgetTickMarksinvalidateRangeisAutoRangingisRangeValidisTickLabelsVisibleisTickMarkVisiblelabelPropertylayoutChildrenmeasureTickMarkLabelSizemeasureTickMarkSizerequestAxisLayoutrequestLayoutsetAnimatedsetAutoRangingsetEffectiveOrientationsetEffectiveTickLabelRotationsetLabelsetSidesetTickLabelFillsetTickLabelFontsetTickLabelGapsetTickLabelRotationsetTickLabelsVisiblesetTickLengthsetTickMarkVisibleshouldAnimatesidePropertytickLabelFillPropertytickLabelFontPropertytickLabelGapPropertytickLabelRotationPropertytickLabelsVisiblePropertytickLengthPropertytickMarksUpdatedtickMarkVisibleProperty

Field Detail

allDataCategoriesback to summary
private List<String> allDataCategories
animatorback to summary
private final ChartLayoutAnimator animator
categoriesback to summary
private ObjectProperty<ObservableList<String>> categories
categorySpacingback to summary
private final ReadOnlyDoubleWrapper categorySpacing

This is the gap between one category and the next along this axis

changeIsLocalback to summary
private boolean changeIsLocal
currentAnimationIDback to summary
private Object currentAnimationID
endMarginback to summary
private DoubleProperty endMargin

The margin between the last tick mark and the axis end

firstCategoryPosback to summary
private final DoubleProperty firstCategoryPos

This is the position of the first category along this axis

gapStartAndEndback to summary
private BooleanProperty gapStartAndEnd

If this is true then half the space between ticks is left at the start and end

itemsListenerback to summary
private ListChangeListener<String> itemsListener
startMarginback to summary
private DoubleProperty startMargin

The margin between the axis start and the first tick-mark

Constructor Detail

CategoryAxisback to summary
public CategoryAxis()

Create a auto-ranging category axis with an empty list of categories.

CategoryAxisback to summary
public CategoryAxis(ObservableList<String> categories)

Create a category axis with the given categories. This will not auto-range but be fixed with the given categories.

Parameters
categories:ObservableList<String>

List of the categories for this axis

Method Detail

autoRangeback to summary
protected Object autoRange(double length)

Implements abstract javafx.scene.chart.Axis.autoRange.

This calculates the categories based on the data provided to invalidateRange() method. This must not effect the state of the axis, changing any properties of the axis. Any results of the auto-ranging should be returned in the range object. This will we passed to setRange() if it has been decided to adopt this range for this axis.

Parameters
length:double

The length of the axis in screen coordinates

Returns:Object

Range information, this is implementation dependent

Annotations
@Override
calculateNewFirstPosback to summary
private double calculateNewFirstPos(double length, double catSpacing)
calculateNewSpacingback to summary
private double calculateNewSpacing(double length, List<String> categories)
calculateRequiredSizeback to summary
private double calculateRequiredSize(boolean axisVertical, double tickLabelRotation)
calculateTickValuesback to summary
protected List<String> calculateTickValues(double length, Object range)

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

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

Parameters
length:double

The length of the axis in display units

Returns:List<String>

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

Annotations
@Override
categorySpacingPropertyback to summary
public final ReadOnlyDoubleProperty categorySpacingProperty()
checkAndRemoveDuplicatesback to summary
private void checkAndRemoveDuplicates(String category)
endMarginPropertyback to summary
public final DoubleProperty endMarginProperty()
gapStartAndEndPropertyback to summary
public final BooleanProperty gapStartAndEndProperty()
getAllDataCategoriesback to summary
pack-priv final List<String> getAllDataCategories()
getCategoriesback to summary
public final ObservableList<String> getCategories()

Returns a ObservableList of categories plotted on this axis.

Returns:ObservableList<String>

ObservableList of categories for this axis.

getCategorySpacingback to summary
public final double getCategorySpacing()
getClassCssMetaDataback to summary
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData()

Hides javafx.scene.chart.Axis.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.Axis.getCssMetaData.

Implements javafx.css.Styleable.getCssMetaData.

Doc from javafx.scene.chart.Axis.getCssMetaData.

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

Annotations
@Override
Since
JavaFX 8.0
getDisplayPositionback to summary
public double getDisplayPosition(String value)

Implements abstract javafx.scene.chart.Axis.getDisplayPosition.

Get the display position along this axis for a given value. If the value is not equal to any of the categories, Double.NaN is returned

Parameters
value:String

The data value to work out display position for

Returns:double

display position or Double.NaN if value not one of the categories

Annotations
@Override
getDuplicateback to summary
private String getDuplicate()
getEndMarginback to summary
public final double getEndMargin()
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
getStartMarginback to summary
public final double getStartMargin()
getTickMarkLabelback to summary
protected String getTickMarkLabel(String value)

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

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

Parameters
value:String

The value to format into a tick label string

Returns:String

A formatted string for the given value

Annotations
@Override
getValueForDisplayback to summary
public String getValueForDisplay(double displayPosition)

Implements abstract javafx.scene.chart.Axis.getValueForDisplay.

Get the data value for the given display position on this axis. If the axis is a CategoryAxis this will be the nearest value.

Parameters
displayPosition:double

A pixel position on this axis

Returns:String

the nearest data value to the given pixel position or null if not on axis;

Annotations
@Override
getZeroPositionback to summary
public double getZeroPosition()

Implements abstract javafx.scene.chart.Axis.getZeroPosition.

Get the display position of the zero line along this axis. As there is no concept of zero on a CategoryAxis this is always Double.NaN.

Returns:double

always Double.NaN for CategoryAxis

Annotations
@Override
invalidateRangeback to summary
public void invalidateRange(List<String> data)

Overrides javafx.scene.chart.Axis.invalidateRange.

Called when data has changed and the range may not be valid any more. This is only called by the chart if isAutoRanging() returns true. If we are auto ranging it will cause layout to be requested and auto ranging to happen on next layout pass.

Parameters
data:List<String>

The current set of all data that needs to be plotted on this axis

Annotations
@Override
isGapStartAndEndback to summary
public final boolean isGapStartAndEnd()
isValueOnAxisback to summary
public boolean isValueOnAxis(String value)

Implements abstract javafx.scene.chart.Axis.isValueOnAxis.

Checks if the given value is plottable on this axis

Parameters
value:String

The value to check if its on axis

Returns:boolean

true if the given value is plottable on this axis

Annotations
@Override
measureTickMarkSizeback to summary
protected Dimension2D measureTickMarkSize(String value, Object range)

Overrides javafx.scene.chart.Axis.measureTickMarkSize.

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

Parameters
value:String

tick mark value

range:Object

range to use during calculations

Returns:Dimension2D

size of tick mark label for given value

Annotations
@Override
setCategoriesback to summary
public final void setCategories(ObservableList<String> value)

The ordered list of categories plotted on this axis. This is set automatically based on the charts data if autoRanging is true. If the application sets the categories then auto ranging is turned off. If there is an attempt to add duplicate entry into this list, an IllegalArgumentException is thrown.

Parameters
value:ObservableList<String>

the ordered list of categories plotted on this axis

setEndMarginback to summary
public final void setEndMargin(double value)
setGapStartAndEndback to summary
public final void setGapStartAndEnd(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
setStartMarginback to summary
public final void setStartMargin(double value)
startMarginPropertyback to summary
public final DoubleProperty startMarginProperty()
toNumericValueback to summary
public double toNumericValue(String value)

Implements abstract javafx.scene.chart.Axis.toNumericValue.

All axis values must be representable by some numeric value. This gets the numeric value for a given data value.

Parameters
value:String

The data value to convert

Returns:double

Numeric value for the given data value

Annotations
@Override
toRealValueback to summary
public String toRealValue(double value)

Implements abstract javafx.scene.chart.Axis.toRealValue.

All axis values must be representable by some numeric value. This gets the data value for a given numeric value.

Parameters
value:double

The numeric value to convert

Returns:String

Data value for given numeric value

Annotations
@Override
javafx.scene.chart back to summary

private Class CategoryAxis.StyleableProperties

extends Object
Class Inheritance

Field Summary

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

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

END_MARGINback to summary
private static final CssMetaData<CategoryAxis, Number> END_MARGIN
GAP_START_AND_ENDback to summary
private static final CssMetaData<CategoryAxis, Boolean> GAP_START_AND_END
START_MARGINback to summary
private static final CssMetaData<CategoryAxis, Number> START_MARGIN
STYLEABLESback to summary
private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES

Constructor Detail

StyleablePropertiesback to summary
private StyleableProperties()