Top Description Inners Fields Constructors Methods
javafx.scene.chart

public Class PieChart

extends Chart
Class Inheritance
Imports
java.text.MessageFormat, java.util.ArrayList, .BitSet, .Collections, .List, .Objects, javafx.animation.Animation, .FadeTransition, .Interpolator, .KeyFrame, .KeyValue, .Timeline, javafx.beans.binding.StringBinding, javafx.beans.property.BooleanProperty, .DoubleProperty, .DoublePropertyBase, .ObjectProperty, .ObjectPropertyBase, .ReadOnlyObjectProperty, .ReadOnlyObjectWrapper, .SimpleDoubleProperty, .StringProperty, .StringPropertyBase, javafx.collections.FXCollections, .ListChangeListener, .ObservableList, javafx.css.CssMetaData, .Styleable, .StyleableBooleanProperty, .StyleableDoubleProperty, .StyleableProperty, javafx.css.converter.BooleanConverter, .SizeConverter, javafx.event.ActionEvent, .EventHandler, javafx.geometry.NodeOrientation, .Side, javafx.scene.AccessibleRole, .Node, javafx.scene.layout.Region, javafx.scene.shape.Arc, .ArcTo, .ArcType, .ClosePath, .LineTo, .MoveTo, .Path, javafx.scene.text.Text, javafx.scene.transform.Scale, javafx.util.Duration, com.sun.javafx.charts.Legend, .Legend.LegendItem, com.sun.javafx.collections.NonIterableChange, com.sun.javafx.scene.control.skin.resources.ControlResources

Displays a PieChart. The chart content is populated by pie slices based on data set on the PieChart.

The clockwise property is set to true by default, which means slices are placed in the clockwise order. The labelsVisible property is used to either display pie slice labels or not.

Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
PieChart.Data

PieChart Data Item, represents one slice in the PieChart

private static class
private static class

Field Summary

Modifier and TypeField and Description
private PieChart.Data
private BooleanProperty
clockwise

When true we start placing slices clockwise from the startAngle

private BitSet
private ObjectProperty<ObservableList<PieChart.Data>>
data

PieCharts data

private final ListChangeListener<PieChart.Data>
private PieChart.Data
private Timeline
private static final double
private static final double
private List<PieChart.LabelLayoutInfo>
private DoubleProperty
labelLineLength

The length of the line from the outside of the pie to the slice labels.

private final Path
private BooleanProperty
labelsVisible

When true pie slice labels are drawn

private Legend
private static final int
private double
private DoubleProperty
startAngle

The angle to start the first pie slice at

Inherited from javafx.scene.chart.Chart:
useChartContentMirroring

Constructor Summary

AccessConstructor and Description
public
PieChart()

Construct a new empty PieChart.

public
PieChart(ObservableList<PieChart.Data>
The data to use, this is the actual list used so any changes to it will be reflected in the chart
data
)

Construct a new PieChart with the given data

Method Summary

Modifier and TypeMethod and Description
private static double
calcX(double angle, double radius, double centerX)

private static double
calcY(double angle, double radius, double centerY)

public final BooleanProperty
private Node
private Timeline
private Text
private void
dataItemAdded(final PieChart.Data item, int index)

private void
private void
private void
public final ObjectProperty<ObservableList<PieChart.Data>>
private void
private int
fuzzyCompare(double o1, double o2)

private boolean
fuzzyGT(double o1, double o2)

private boolean
fuzzyLT(double o1, double o2)

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

Returns:

the CssMetaData
getClassCssMetaData
()

Hides javafx.scene.chart.Chart.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.Chart.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 final ObservableList<PieChart.Data>
private int
public final double
public final boolean

Returns:

true if pie slice labels are visible and false otherwise.
getLabelsVisible
()

Indicates whether pie slice labels are drawn or not

public final double
public final boolean
public final DoubleProperty
public final BooleanProperty
protected void
layoutChartChildren(double top, double left, double contentWidth, double contentHeight)

Implements abstract javafx.scene.chart.Chart.layoutChartChildren.

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

private static double
normalizeAngle(double angle)

Normalize any angle into -180 to 180 deg range

private void
private void
public final void
setClockwise(boolean value)

public final void
public final void
setLabelLineLength(double value)

public final void
setLabelsVisible(boolean value)

public final void
setStartAngle(double value)

public final DoubleProperty
private void
updateDataItemStyleClass(final PieChart.Data item, int index)

private void
updateLegend()

This is called whenever a series is added or removed and the legend needs to be updated

pack-priv void
updateSymbolFocusable(boolean on)

Overrides javafx.scene.chart.Chart.updateSymbolFocusable.

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

Inherited from javafx.scene.chart.Chart:
animateanimateanimatedPropertycomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthgetAnimatedgetChartChildrengetLegendgetLegendSidegetTitlegetTitleSideisAccessibilityActiveisLegendVisiblelayoutChildrenlegendPropertylegendSidePropertylegendVisiblePropertyrequestChartLayoutsetAnimatedsetLegendsetLegendSidesetLegendVisiblesetTitlesetTitleSideshouldAnimatetitlePropertytitleSideProperty

Field Detail

beginback to summary
private PieChart.Data begin
clockwiseback to summary
private BooleanProperty clockwise

When true we start placing slices clockwise from the startAngle

colorBitsback to summary
private BitSet colorBits
databack to summary
private ObjectProperty<ObservableList<PieChart.Data>> data

PieCharts data

dataChangeListenerback to summary
private final ListChangeListener<PieChart.Data> dataChangeListener
dataItemBeingRemovedback to summary
private PieChart.Data dataItemBeingRemoved
dataRemoveTimelineback to summary
private Timeline dataRemoveTimeline
LABEL_BALL_RADIUSback to summary
private static final double LABEL_BALL_RADIUS
LABEL_TICK_GAPback to summary
private static final double LABEL_TICK_GAP
labelLayoutInfosback to summary
private List<PieChart.LabelLayoutInfo> labelLayoutInfos
labelLineLengthback to summary
private DoubleProperty labelLineLength

The length of the line from the outside of the pie to the slice labels.

labelLinePathback to summary
private final Path labelLinePath
labelsVisibleback to summary
private BooleanProperty labelsVisible

When true pie slice labels are drawn

legendback to summary
private Legend legend

Hides javafx.scene.chart.Chart.legend.

MIN_PIE_RADIUSback to summary
private static final int MIN_PIE_RADIUS
pieRadiusback to summary
private double pieRadius
startAngleback to summary
private DoubleProperty startAngle

The angle to start the first pie slice at

Constructor Detail

PieChartback to summary
public PieChart()

Construct a new empty PieChart.

PieChartback to summary
public PieChart(ObservableList<PieChart.Data> data)

Construct a new PieChart with the given data

Parameters
data:ObservableList<PieChart.Data>

The data to use, this is the actual list used so any changes to it will be reflected in the chart

Method Detail

calcXback to summary
private static double calcX(double angle, double radius, double centerX)
calcYback to summary
private static double calcY(double angle, double radius, double centerY)
clockwisePropertyback to summary
public final BooleanProperty clockwiseProperty()
createArcRegionback to summary
private Node createArcRegion(PieChart.Data item)
createDataRemoveTimelineback to summary
private Timeline createDataRemoveTimeline(final PieChart.Data item)
createPieLabelback to summary
private Text createPieLabel(PieChart.Data item)
dataItemAddedback to summary
private void dataItemAdded(final PieChart.Data item, int index)
dataItemRemovedback to summary
private void dataItemRemoved(final PieChart.Data item)
dataNameChangedback to summary
private void dataNameChanged(PieChart.Data item)
dataPieValueChangedback to summary
private void dataPieValueChanged(PieChart.Data item)
dataPropertyback to summary
public final ObjectProperty<ObservableList<PieChart.Data>> dataProperty()
drawLabelLinePathback to summary
private void drawLabelLinePath(PieChart.LabelLayoutInfo info)
fuzzyCompareback to summary
private int fuzzyCompare(double o1, double o2)
fuzzyGTback to summary
private boolean fuzzyGT(double o1, double o2)
fuzzyLTback to summary
private boolean fuzzyLT(double o1, double o2)
getClassCssMetaDataback to summary
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData()

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

Implements javafx.css.Styleable.getCssMetaData.

Doc from javafx.scene.chart.Chart.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
getDataback to summary
public final ObservableList<PieChart.Data> getData()
getDataSizeback to summary
private int getDataSize()
getLabelLineLengthback to summary
public final double getLabelLineLength()
getLabelsVisibleback to summary
public final boolean getLabelsVisible()

Indicates whether pie slice labels are drawn or not

Returns:boolean

true if pie slice labels are visible and false otherwise.

getStartAngleback to summary
public final double getStartAngle()
isClockwiseback to summary
public final boolean isClockwise()
labelLineLengthPropertyback to summary
public final DoubleProperty labelLineLengthProperty()
labelsVisiblePropertyback to summary
public final BooleanProperty labelsVisibleProperty()
layoutChartChildrenback to summary
protected void layoutChartChildren(double top, double left, double contentWidth, double contentHeight)

Implements abstract javafx.scene.chart.Chart.layoutChartChildren.

Doc from javafx.scene.chart.Chart.layoutChartChildren.

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

Annotations
@Override
normalizeAngleback to summary
private static double normalizeAngle(double angle)

Normalize any angle into -180 to 180 deg range

removeDataItemRefback to summary
private void removeDataItemRef(PieChart.Data item)
resolveCollisionback to summary
private void resolveCollision(List<PieChart.LabelLayoutInfo> list)
setClockwiseback to summary
public final void setClockwise(boolean value)
setDataback to summary
public final void setData(ObservableList<PieChart.Data> value)
setLabelLineLengthback to summary
public final void setLabelLineLength(double value)
setLabelsVisibleback to summary
public final void setLabelsVisible(boolean value)
setStartAngleback to summary
public final void setStartAngle(double value)
startAnglePropertyback to summary
public final DoubleProperty startAngleProperty()
updateDataItemStyleClassback to summary
private void updateDataItemStyleClass(final PieChart.Data item, int index)
updateLegendback to summary
private void updateLegend()

This is called whenever a series is added or removed and the legend needs to be updated

updateSymbolFocusableback to summary
pack-priv void updateSymbolFocusable(boolean on)

Overrides javafx.scene.chart.Chart.updateSymbolFocusable.

Doc from javafx.scene.chart.Chart.updateSymbolFocusable.

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.

Annotations
@Override
javafx.scene.chart back to summary

public final Class PieChart.Data

extends Object
Class Inheritance

PieChart Data Item, represents one slice in the PieChart
Since
JavaFX 2.0

Field Summary

Modifier and TypeField and Description
private ReadOnlyObjectWrapper<PieChart>
chart

The chart which this data belongs to.

private DoubleProperty
currentPieValue

The current pie value, used during animation.

private int
defaultColorIndex

Default color index for this slice.

private StringProperty
name

The name of the pie slice

private PieChart.Data
next

Next pointer for the next data item : so we can do animation on data delete.

private ReadOnlyObjectWrapper<Node>
node

Readonly access to the node that represents the pie slice.

private DoubleProperty
pieValue

The value of the pie slice

private DoubleProperty
radiusMultiplier

Multiplier that is used to animate the radius of the pie slice

private Text

Constructor Summary

AccessConstructor and Description
public
Data(String
name for Pie
name
,
double
pie value
value
)

Constructs a PieChart.Data object with the given name and value.

Method Summary

Modifier and TypeMethod and Description
public final ReadOnlyObjectProperty<PieChart>
private DoubleProperty
public final PieChart
private double
public final String
public Node

Returns:

the node that represents the pie slice
getNode
()

Returns the node that represents the pie slice.

public final double
private double
public final StringProperty
public ReadOnlyObjectProperty<Node>
public final DoubleProperty
private DoubleProperty
private void
private void
setCurrentPieValue(double value)

public final void
setName(String value)

private void
setNode(Node value)

public final void
setPieValue(double value)

private void
setRadiusMultiplier(double value)

public String

Returns:

a string representation of this Data object.
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of this Data object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

chartback to summary
private ReadOnlyObjectWrapper<PieChart> chart

The chart which this data belongs to.

currentPieValueback to summary
private DoubleProperty currentPieValue

The current pie value, used during animation. This will be the last data value, new data value or anywhere in between

defaultColorIndexback to summary
private int defaultColorIndex

Default color index for this slice.

nameback to summary
private StringProperty name

The name of the pie slice

nextback to summary
private PieChart.Data next

Next pointer for the next data item : so we can do animation on data delete.

nodeback to summary
private ReadOnlyObjectWrapper<Node> node

Readonly access to the node that represents the pie slice. You can use this to add mouse event listeners etc.

pieValueback to summary
private DoubleProperty pieValue

The value of the pie slice

radiusMultiplierback to summary
private DoubleProperty radiusMultiplier

Multiplier that is used to animate the radius of the pie slice

textNodeback to summary
private Text textNode

Constructor Detail

Databack to summary
public Data(String name, double value)

Constructs a PieChart.Data object with the given name and value.

Parameters
name:String

name for Pie

value:double

pie value

Method Detail

chartPropertyback to summary
public final ReadOnlyObjectProperty<PieChart> chartProperty()
currentPieValuePropertyback to summary
private DoubleProperty currentPieValueProperty()
getChartback to summary
public final PieChart getChart()
getCurrentPieValueback to summary
private double getCurrentPieValue()
getNameback to summary
public final String getName()
getNodeback to summary
public Node getNode()

Returns the node that represents the pie slice. You can use this to add mouse event listeners etc.

Returns:Node

the node that represents the pie slice

getPieValueback to summary
public final double getPieValue()
getRadiusMultiplierback to summary
private double getRadiusMultiplier()
namePropertyback to summary
public final StringProperty nameProperty()
nodePropertyback to summary
public ReadOnlyObjectProperty<Node> nodeProperty()
pieValuePropertyback to summary
public final DoubleProperty pieValueProperty()
radiusMultiplierPropertyback to summary
private DoubleProperty radiusMultiplierProperty()
setChartback to summary
private void setChart(PieChart value)
setCurrentPieValueback to summary
private void setCurrentPieValue(double value)
setNameback to summary
public final void setName(String value)
setNodeback to summary
private void setNode(Node value)
setPieValueback to summary
public final void setPieValue(double value)
setRadiusMultiplierback to summary
private void setRadiusMultiplier(double value)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of this Data object.

Returns:String

a string representation of this Data object.

Annotations
@Override
javafx.scene.chart back to summary

private final Class PieChart.LabelLayoutInfo

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv double
pack-priv double
pack-priv double
pack-priv double
pack-priv double
pack-priv Text
pack-priv double
pack-priv double

Constructor Summary

AccessConstructor and Description
pack-priv
LabelLayoutInfo(double startX, double startY, double endX, double endY, double textX, double textY, Text text, double size)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object o)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

endXback to summary
pack-priv double endX
endYback to summary
pack-priv double endY
sizeback to summary
pack-priv double size
startXback to summary
pack-priv double startX
startYback to summary
pack-priv double startY
textback to summary
pack-priv Text text
textXback to summary
pack-priv double textX
textYback to summary
pack-priv double textY

Constructor Detail

LabelLayoutInfoback to summary
pack-priv LabelLayoutInfo(double startX, double startY, double endX, double endY, double textX, double textY, Text text, double size)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
javafx.scene.chart back to summary

private Class PieChart.StyleableProperties

extends Object
Class Inheritance

Field Summary

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

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CLOCKWISEback to summary
private static final CssMetaData<PieChart, Boolean> CLOCKWISE
LABEL_LINE_LENGTHback to summary
private static final CssMetaData<PieChart, Number> LABEL_LINE_LENGTH
LABELS_VISIBLEback to summary
private static final CssMetaData<PieChart, Boolean> LABELS_VISIBLE
START_ANGLEback to summary
private static final CssMetaData<PieChart, Number> START_ANGLE
STYLEABLESback to summary
private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES

Constructor Detail

StyleablePropertiesback to summary
private StyleableProperties()