public class PieChart extends Chart
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.
Modifier and Type | Class and Description |
---|---|
static class |
PieChart.Data
PieChart Data Item, represents one slice in the PieChart
|
(package private) static class |
PieChart.LabelLayoutInfo |
private static class |
PieChart.StyleableProperties
Super-lazy instantiation pattern from Bill Pugh.
|
Modifier and Type | Field and Description |
---|---|
private PieChart.Data |
begin |
private double |
centerX |
private double |
centerY |
private BooleanProperty |
clockwise
When true we start placing slices clockwise from the startAngle
|
private java.util.BitSet |
colorBits |
private ObjectProperty<ObservableList<PieChart.Data>> |
data
PieCharts data
|
private ListChangeListener<PieChart.Data> |
dataChangeListener |
private PieChart.Data |
dataItemBeingRemoved |
private Timeline |
dataRemoveTimeline |
private static double |
LABEL_BALL_RADIUS |
private static double |
LABEL_TICK_GAP |
private DoubleProperty |
labelLineLength
The length of the line from the outside of the pie to the slice labels.
|
private Path |
labelLinePath |
private BooleanProperty |
labelsVisible
When true pie slice labels are drawn
|
private Legend |
legend |
private static int |
MIN_PIE_RADIUS |
private double |
pieRadius |
private DoubleProperty |
startAngle
The angle to start the first pie slice at
|
useChartContentMirroring
USE_COMPUTED_SIZE, USE_PREF_SIZE
BASELINE_OFFSET_SAME_AS_HEIGHT
Constructor and Description |
---|
PieChart()
Construct a new empty PieChart.
|
PieChart(ObservableList<PieChart.Data> data)
Construct a new PieChart with the given data
|
Modifier and Type | Method and Description |
---|---|
private static double |
calcX(double angle,
double radius,
double centerX) |
private static double |
calcY(double angle,
double radius,
double centerY) |
BooleanProperty |
clockwiseProperty() |
private Node |
createArcRegion(PieChart.Data item) |
private Timeline |
createDataRemoveTimeline(PieChart.Data item) |
private Text |
createPieLabel(PieChart.Data item) |
private void |
dataItemAdded(PieChart.Data item,
int index) |
private void |
dataItemRemoved(PieChart.Data item) |
private void |
dataNameChanged(PieChart.Data item) |
private void |
dataPieValueChanged(PieChart.Data item) |
ObjectProperty<ObservableList<PieChart.Data>> |
dataProperty() |
private void |
drawLabelLinePath(PieChart.LabelLayoutInfo info) |
private int |
fuzzyCompare(double o1,
double o2) |
private boolean |
fuzzyGT(double o1,
double o2) |
private boolean |
fuzzyLT(double o1,
double o2) |
static java.util.List<CssMetaData<? extends Styleable,?>> |
getClassCssMetaData() |
java.util.List<CssMetaData<? extends Styleable,?>> |
getCssMetaData()
This method should delegate to
Node.getClassCssMetaData() so that
a Node's CssMetaData can be accessed without the need for reflection. |
ObservableList<PieChart.Data> |
getData() |
private int |
getDataSize() |
double |
getLabelLineLength() |
boolean |
getLabelsVisible()
Indicates whether pie slice labels are drawn or not
|
double |
getStartAngle() |
boolean |
isClockwise() |
DoubleProperty |
labelLineLengthProperty() |
BooleanProperty |
labelsVisibleProperty() |
protected void |
layoutChartChildren(double top,
double left,
double contentWidth,
double contentHeight)
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 |
removeDataItemRef(PieChart.Data item) |
private void |
resolveCollision(java.util.ArrayList<PieChart.LabelLayoutInfo> list) |
void |
setClockwise(boolean value) |
void |
setData(ObservableList<PieChart.Data> value) |
void |
setLabelLineLength(double value) |
void |
setLabelsVisible(boolean value) |
void |
setStartAngle(double value) |
DoubleProperty |
startAngleProperty() |
private void |
updateDataItemStyleClass(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
|
animate, animate, animatedProperty, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, getAnimated, getChartChildren, getLegend, getLegendSide, getTitle, getTitleSide, isLegendVisible, layoutChildren, legendProperty, legendSideProperty, legendVisibleProperty, requestChartLayout, setAnimated, setLegend, setLegendSide, setLegendVisible, setTitle, setTitleSide, shouldAnimate, titleProperty, titleSideProperty
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, impl_computeContains, impl_computeGeomBounds, impl_computeLayoutBounds, impl_createPeer, impl_notifyLayoutBoundsChanged, impl_pickNodeLocal, impl_updatePeer, insetsProperty, isCacheShape, isCenterShape, isResizable, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapSize, snapSpace, snapToPixelProperty, widthProperty
getBaselineOffset, getChildren, getChildrenUnmodifiable, getImpl_traversalEngine, getManagedChildren, getStylesheets, impl_getAllParentStylesheets, impl_processCSS, impl_processMXNode, impl_traversalEngineProperty, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout, requestParentLayout, setImpl_traversalEngine, setNeedsLayout, updateBounds
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, containsBounds, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, hasProperties, hoverProperty, idProperty, impl_clearDirty, impl_computeIntersects, impl_cssGetCursorInitialValue, impl_cssGetFocusTraversableInitialValue, impl_findStyles, impl_geomChanged, impl_getLeafTransform, impl_getMatchingStyles, impl_getPeer, impl_getPivotX, impl_getPivotY, impl_getPivotZ, impl_getStyleMap, impl_hasTransforms, impl_intersects, impl_intersectsBounds, impl_isDirty, impl_isDirtyEmpty, impl_isShowMnemonics, impl_isTreeVisible, impl_layoutBoundsChanged, impl_markDirty, impl_pickNode, impl_processCSS, impl_reapplyCSS, impl_setShowMnemonics, impl_setStyleMap, impl_showMnemonicsProperty, impl_syncPeer, impl_transformsChanged, impl_traverse, impl_treeVisibleProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, visibleProperty
private static final int MIN_PIE_RADIUS
private static final double LABEL_TICK_GAP
private static final double LABEL_BALL_RADIUS
private java.util.BitSet colorBits
private double centerX
private double centerY
private double pieRadius
private PieChart.Data begin
private final Path labelLinePath
private Legend legend
private PieChart.Data dataItemBeingRemoved
private Timeline dataRemoveTimeline
private final ListChangeListener<PieChart.Data> dataChangeListener
private ObjectProperty<ObservableList<PieChart.Data>> data
private DoubleProperty startAngle
private BooleanProperty clockwise
private DoubleProperty labelLineLength
private BooleanProperty labelsVisible
public PieChart()
public PieChart(ObservableList<PieChart.Data> data)
data
- The data to use, this is the actual list used so any changes to it will be reflected in the chartpublic final ObservableList<PieChart.Data> getData()
public final void setData(ObservableList<PieChart.Data> value)
public final ObjectProperty<ObservableList<PieChart.Data>> dataProperty()
public final double getStartAngle()
public final void setStartAngle(double value)
public final DoubleProperty startAngleProperty()
public final void setClockwise(boolean value)
public final boolean isClockwise()
public final BooleanProperty clockwiseProperty()
public final double getLabelLineLength()
public final void setLabelLineLength(double value)
public final DoubleProperty labelLineLengthProperty()
public final void setLabelsVisible(boolean value)
public final boolean getLabelsVisible()
public final BooleanProperty labelsVisibleProperty()
private void dataNameChanged(PieChart.Data item)
private void dataPieValueChanged(PieChart.Data item)
private Node createArcRegion(PieChart.Data item)
private Text createPieLabel(PieChart.Data item)
private void updateDataItemStyleClass(PieChart.Data item, int index)
private void dataItemAdded(PieChart.Data item, int index)
private void removeDataItemRef(PieChart.Data item)
private Timeline createDataRemoveTimeline(PieChart.Data item)
private void dataItemRemoved(PieChart.Data item)
protected void layoutChartChildren(double top, double left, double contentWidth, double contentHeight)
Chart
layoutChartChildren
in class Chart
top
- The top offset from the origin to account for any padding on the chart contentleft
- The left offset from the origin to account for any padding on the chart contentcontentWidth
- The width of the area to layout the chart withincontentHeight
- The height of the area to layout the chart withinprivate void resolveCollision(java.util.ArrayList<PieChart.LabelLayoutInfo> list)
private int fuzzyCompare(double o1, double o2)
private boolean fuzzyGT(double o1, double o2)
private boolean fuzzyLT(double o1, double o2)
private void drawLabelLinePath(PieChart.LabelLayoutInfo info)
private void updateLegend()
private int getDataSize()
private static double calcX(double angle, double radius, double centerX)
private static double calcY(double angle, double radius, double centerY)
private static double normalizeAngle(double angle)
public static java.util.List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
public java.util.List<CssMetaData<? extends Styleable,?>> getCssMetaData()
Node.getClassCssMetaData()
so that
a Node's CssMetaData can be accessed without the need for reflection.getCssMetaData
in interface Styleable
getCssMetaData
in class Chart