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

public abstract Class Chart

extends Region
Class Inheritance
Known Direct Subclasses
javafx.scene.chart.PieChart, javafx.scene.chart.XYChart
Imports
java.util.ArrayList, .Collections, .List, javafx.animation.Animation, .KeyFrame, javafx.application.Platform, javafx.beans.property.BooleanProperty, .ObjectProperty, .ObjectPropertyBase, .SimpleBooleanProperty, .StringProperty, .StringPropertyBase, javafx.beans.value.WritableValue, javafx.collections.ObservableList, javafx.css.CssMetaData, .Styleable, .StyleableBooleanProperty, .StyleableObjectProperty, .StyleableProperty, javafx.css.converter.BooleanConverter, .EnumConverter, javafx.geometry.Pos, .Side, javafx.scene.Node, .Scene, javafx.scene.control.Label, javafx.scene.layout.Pane, .Region, javafx.util.Subscription, com.sun.javafx.charts.ChartLayoutAnimator, .Legend, com.sun.javafx.scene.NodeHelper, com.sun.javafx.scene.control.skin.Utils

Base class for all charts. It has 3 parts the title, legend and chartContent. The chart content is populated by the specific subclass of Chart.
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 volatile Object
private BooleanProperty
animated

When true any data changes will be animated.

private final ChartLayoutAnimator
animator

Animator for animating stuff on the chart

private final Pane
chartContent

This is the Pane that Chart subclasses use to contain the chart content, It is sized to be inside the chart area leaving space for the title and legend.

private final ObjectProperty<Node>
legend

The node to display as the Legend.

private ObjectProperty<Side>
legendSide

The side of the chart where the legend should be displayed

private final BooleanProperty
legendVisible

When true the chart will display a legend if the chart implementation supports a legend.

private static final int
private static final int
private StringProperty
title

The chart title

private final Label
titleLabel

Title Label

private ObjectProperty<Side>
titleSide

The side of the chart where the title is displayed

pack-priv boolean
Inherited from javafx.scene.layout.Region:
USE_COMPUTED_SIZEUSE_PREF_SIZE

Constructor Summary

AccessConstructor and Description
public
Chart()

Creates a new default Chart instance.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
animate(KeyFrame...
Array of KeyFrames to play
keyFrames
)

Play a animation involving the given keyframes.

protected void
animate(Animation
The animation to play
animation
)

Play the given animation on every frame of the animation the chart will be relayed out until the animation finishes.

public final BooleanProperty
protected double
computeMinHeight(double width)

Overrides javafx.scene.layout.Region.computeMinHeight.

Charts are sized outside in, user tells chart how much space it has and chart draws inside that.

protected double
computeMinWidth(double height)

Overrides javafx.scene.layout.Region.computeMinWidth.

Charts are sized outside in, user tells chart how much space it has and chart draws inside that.

protected double
computePrefHeight(double width)

Overrides javafx.scene.layout.Region.computePrefHeight.

Charts are sized outside in, user tells chart how much space it has and chart draws inside that.

protected double
computePrefWidth(double height)

Overrides javafx.scene.layout.Region.computePrefWidth.

Charts are sized outside in, user tells chart how much space it has and chart draws inside that.

public final boolean

Returns:

true if data changes will be animated and false otherwise.
getAnimated
()

Indicates whether data changes will be animated or not.

protected ObservableList<Node>

Returns:

Observable list of plot children
getChartChildren
()

Modifiable and observable list of all content in the chart.

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.

protected final Node
public final Side
public final String
public final Side
private void
pack-priv final boolean
isAccessibilityActive()

When called from JavaFX application thread, returns the value of the property.

public final boolean
protected abstract void
layoutChartChildren(double
The top offset from the origin to account for any padding on the chart content
top
,
double
The left offset from the origin to account for any padding on the chart content
left
,
double
The width of the area to layout the chart within
width
,
double
The height of the area to layout the chart within
height
)

Called to update and layout the chart children available from getChartChildren()

protected void
layoutChildren()

Overrides javafx.scene.Parent.layoutChildren.

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

protected final ObjectProperty<Node>
public final ObjectProperty<Side>
public final BooleanProperty
protected void
requestChartLayout()

Call this when you know something has changed that needs the chart to be relayed out.

public final void
setAnimated(boolean value)

protected final void
setLegend(Node value)

public final void
public final void
setLegendVisible(boolean value)

public final void
public final void
protected boolean

Returns:

true if animations should run, false otherwise
shouldAnimate
()

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

public final StringProperty
public final ObjectProperty<Side>
pack-priv void
updateSymbolFocusable(boolean
whether the accessibility is active
on
)

Invoked in the FX application thread when accessibility active platform property changes.

Inherited from javafx.scene.layout.Region:
backgroundPropertyborderPropertycacheShapePropertycenterShapePropertycomputeMaxHeightcomputeMaxWidthgetBackgroundgetBordergetHeightgetInsetsgetMaxHeightgetMaxWidthgetMinHeightgetMinWidthgetOpaqueInsetsgetPaddinggetPrefHeightgetPrefWidthgetShapegetUserAgentStylesheetgetWidthheightPropertyinsetsPropertyisCacheShapeisCenterShapeisResizableisScaleShapeisSnapToPixellayoutInArealayoutInArealayoutInArealayoutInAreamaxHeightmaxHeightPropertymaxWidthmaxWidthPropertyminHeightminHeightPropertyminWidthminWidthPropertyopaqueInsetsPropertypaddingPropertypositionInAreapositionInAreaprefHeightprefHeightPropertyprefWidthprefWidthPropertyresizescaleShapePropertysetBackgroundsetBordersetCacheShapesetCenterShapesetHeightsetMaxHeightsetMaxSizesetMaxWidthsetMinHeightsetMinSizesetMinWidthsetOpaqueInsetssetPaddingsetPrefHeightsetPrefSizesetPrefWidthsetScaleShapesetShapesetSnapToPixelsetWidthshapePropertysnappedBottomInsetsnappedLeftInsetsnappedRightInsetsnappedTopInsetsnapPositionsnapPositionXsnapPositionYsnapSizesnapSizeXsnapSizeYsnapSpacesnapSpaceXsnapSpaceYsnapToPixelPropertywidthProperty

Field Detail

accessibilityActiveback to summary
private volatile Object accessibilityActive
animatedback to summary
private BooleanProperty animated

When true any data changes will be animated.

animatorback to summary
private final ChartLayoutAnimator animator

Animator for animating stuff on the chart

chartContentback to summary
private final Pane chartContent

This is the Pane that Chart subclasses use to contain the chart content, It is sized to be inside the chart area leaving space for the title and legend.

legendback to summary
private final ObjectProperty<Node> legend

The node to display as the Legend. Subclasses can set a node here to be displayed on a side as the legend. If no legend is wanted then this can be set to null

legendSideback to summary
private ObjectProperty<Side> legendSide

The side of the chart where the legend should be displayed

Default Value
Side.BOTTOM
legendVisibleback to summary
private final BooleanProperty legendVisible

When true the chart will display a legend if the chart implementation supports a legend.

MIN_HEIGHT_TO_LEAVE_FOR_CHART_CONTENTback to summary
private static final int MIN_HEIGHT_TO_LEAVE_FOR_CHART_CONTENT
MIN_WIDTH_TO_LEAVE_FOR_CHART_CONTENTback to summary
private static final int MIN_WIDTH_TO_LEAVE_FOR_CHART_CONTENT
titleback to summary
private StringProperty title

The chart title

titleLabelback to summary
private final Label titleLabel

Title Label

titleSideback to summary
private ObjectProperty<Side> titleSide

The side of the chart where the title is displayed

Default Value
Side.TOP
useChartContentMirroringback to summary
pack-priv boolean useChartContentMirroring

Constructor Detail

Chartback to summary
public Chart()

Creates a new default Chart instance.

Method Detail

animateback to summary
pack-priv void animate(KeyFrame... keyFrames)

Play a animation involving the given keyframes. On every frame of the animation the chart will be relayed out

Parameters
keyFrames:KeyFrame[]

Array of KeyFrames to play

animateback to summary
protected void animate(Animation animation)

Play the given animation on every frame of the animation the chart will be relayed out until the animation finishes. So to add a animation to a chart, create a animation on data model, during layoutChartContent() map data model to nodes then call this method with the animation.

Parameters
animation:Animation

The animation to play

animatedPropertyback to summary
public final BooleanProperty animatedProperty()
computeMinHeightback to summary
protected double computeMinHeight(double width)

Overrides javafx.scene.layout.Region.computeMinHeight.

Charts are sized outside in, user tells chart how much space it has and chart draws inside that. So minimum height is a constant 150.

Annotations
@Override
computeMinWidthback to summary
protected double computeMinWidth(double height)

Overrides javafx.scene.layout.Region.computeMinWidth.

Charts are sized outside in, user tells chart how much space it has and chart draws inside that. So minimum width is a constant 200.

Annotations
@Override
computePrefHeightback to summary
protected double computePrefHeight(double width)

Overrides javafx.scene.layout.Region.computePrefHeight.

Charts are sized outside in, user tells chart how much space it has and chart draws inside that. So preferred height is a constant 400.

Annotations
@Override
computePrefWidthback to summary
protected double computePrefWidth(double height)

Overrides javafx.scene.layout.Region.computePrefWidth.

Charts are sized outside in, user tells chart how much space it has and chart draws inside that. So preferred width is a constant 500.

Annotations
@Override
getAnimatedback to summary
public final boolean getAnimated()

Indicates whether data changes will be animated or not.

Returns:boolean

true if data changes will be animated and false otherwise.

getChartChildrenback to summary
protected ObservableList<Node> getChartChildren()

Modifiable and observable list of all content in the chart. This is where implementations of Chart should add any nodes they use to draw their chart. This excludes the legend and title which are looked after by this class.

Returns:ObservableList<Node>

Observable list of plot children

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

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

Implements javafx.css.Styleable.getCssMetaData.

Doc from javafx.scene.layout.Region.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
getLegendback to summary
protected final Node getLegend()
getLegendSideback to summary
public final Side getLegendSide()
getTitleback to summary
public final String getTitle()
getTitleSideback to summary
public final Side getTitleSide()
handleAccessibilityActiveback to summary
private void handleAccessibilityActive(boolean on)
isAccessibilityActiveback to summary
pack-priv final boolean isAccessibilityActive()

When called from JavaFX application thread, returns the value of the property. When called from any other thread, returns false and sets up the machinery to invoke updateSymbolFocusable() when needed. The chart implementations should use this method to set focus travesable flags on the nodes which needs to be focus traversable when accessibility is on.

isLegendVisibleback to summary
public final boolean isLegendVisible()
layoutChartChildrenback to summary
protected abstract void layoutChartChildren(double top, double left, double width, double height)

Called to update and layout the chart children available from getChartChildren()

Parameters
top:double

The top offset from the origin to account for any padding on the chart content

left:double

The left offset from the origin to account for any padding on the chart content

width:double

The width of the area to layout the chart within

height:double

The height of the area to layout the chart within

layoutChildrenback to summary
protected void layoutChildren()

Overrides javafx.scene.Parent.layoutChildren.

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

Annotations
@Override
legendPropertyback to summary
protected final ObjectProperty<Node> legendProperty()
legendSidePropertyback to summary
public final ObjectProperty<Side> legendSideProperty()
legendVisiblePropertyback to summary
public final BooleanProperty legendVisibleProperty()
requestChartLayoutback to summary
protected void requestChartLayout()

Call this when you know something has changed that needs the chart to be relayed out.

setAnimatedback to summary
public final void setAnimated(boolean value)
setLegendback to summary
protected final void setLegend(Node value)
setLegendSideback to summary
public final void setLegendSide(Side value)
setLegendVisibleback to summary
public final void setLegendVisible(boolean value)
setTitleback to summary
public final void setTitle(String value)
setTitleSideback to summary
public final void setTitleSide(Side value)
shouldAnimateback to summary
protected boolean shouldAnimate()

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

The default implementation returns true if animation is enabled, the node is visible and in a scene, and reduced-motion mode is not enabled.

Returns:boolean

true if animations should run, false otherwise

titlePropertyback to summary
public final StringProperty titleProperty()
titleSidePropertyback to summary
public final ObjectProperty<Side> titleSideProperty()
updateSymbolFocusableback to summary
pack-priv void updateSymbolFocusable(boolean on)

Invoked in the FX application thread when accessibility active platform property changes. The child classes should override this method to set focus traversable flag on every symbol, as well as other elements that need to be focusable.

Parameters
on:boolean

whether the accessibility is active

javafx.scene.chart back to summary

private Class Chart.StyleableProperties

extends Object
Class Inheritance

Field Summary

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

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LEGEND_SIDEback to summary
private static final CssMetaData<Chart, Side> LEGEND_SIDE
LEGEND_VISIBLEback to summary
private static final CssMetaData<Chart, Boolean> LEGEND_VISIBLE
STYLEABLESback to summary
private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES
TITLE_SIDEback to summary
private static final CssMetaData<Chart, Side> TITLE_SIDE

Constructor Detail

StyleablePropertiesback to summary
private StyleableProperties()