< prev index next >

modules/javafx.controls/src/main/java/javafx/scene/chart/PieChart.java

Print this page




 504                 );
 505         return t;
 506     }
 507 
 508     private void dataItemRemoved(final Data item) {
 509         final Node shape = item.getNode();
 510         if (shouldAnimate()) {
 511             dataRemoveTimeline = createDataRemoveTimeline(item);
 512             dataItemBeingRemoved = item;
 513             animate(dataRemoveTimeline);
 514         } else {
 515             colorBits.clear(item.defaultColorIndex);
 516             getChartChildren().remove(item.textNode);
 517             getChartChildren().remove(shape);
 518             // remove chart references from old data
 519             item.setChart(null);
 520             removeDataItemRef(item);
 521         }
 522     }
 523 
 524     /** @inheritDoc */
 525     @Override protected void layoutChartChildren(double top, double left, double contentWidth, double contentHeight) {
 526         double total = 0.0;
 527         for (Data item = begin; item != null; item = item.next) {
 528             total+= Math.abs(item.getCurrentPieValue());
 529         }
 530         double scale = (total != 0) ? 360 / total : 0;
 531 
 532          // calculate combined bounds of all labels & pie radius
 533         double[] labelsX = null;
 534         double[] labelsY = null;
 535         double[] labelAngles = null;
 536         double labelScale = 1;
 537         List<LabelLayoutInfo> fullPie = null;
 538         boolean shouldShowLabels = getLabelsVisible();
 539         if (shouldShowLabels) {
 540             double xPad = 0d;
 541             double yPad = 0d;
 542 
 543             labelsX = new double[getDataSize()];
 544             labelsY = new double[getDataSize()];


 955         private double getRadiusMultiplier() {
 956             return radiusMultiplier.getValue();
 957         }
 958 
 959         private void setRadiusMultiplier(double value) {
 960             radiusMultiplier.setValue(value);
 961         }
 962 
 963         private DoubleProperty radiusMultiplierProperty() {
 964             return radiusMultiplier;
 965         }
 966 
 967         /**
 968          * Readonly access to the node that represents the pie slice. You can use this to add mouse event listeners etc.
 969          */
 970         private ReadOnlyObjectWrapper<Node> node = new ReadOnlyObjectWrapper<>(this, "node");
 971 
 972         /**
 973          * Returns the node that represents the pie slice. You can use this to
 974          * add mouse event listeners etc.

 975          */
 976         public Node getNode() {
 977             return node.getValue();
 978         }
 979 
 980         private void setNode(Node value) {
 981             node.setValue(value);
 982         }
 983 
 984         public ReadOnlyObjectProperty<Node> nodeProperty() {
 985             return node.getReadOnlyProperty();
 986         }
 987 
 988         // -------------- CONSTRUCTOR -------------------------------------------------
 989 
 990         /**
 991          * Constructs a PieChart.Data object with the given name and value.
 992          *
 993          * @param name  name for Pie
 994          * @param value pie value




 504                 );
 505         return t;
 506     }
 507 
 508     private void dataItemRemoved(final Data item) {
 509         final Node shape = item.getNode();
 510         if (shouldAnimate()) {
 511             dataRemoveTimeline = createDataRemoveTimeline(item);
 512             dataItemBeingRemoved = item;
 513             animate(dataRemoveTimeline);
 514         } else {
 515             colorBits.clear(item.defaultColorIndex);
 516             getChartChildren().remove(item.textNode);
 517             getChartChildren().remove(shape);
 518             // remove chart references from old data
 519             item.setChart(null);
 520             removeDataItemRef(item);
 521         }
 522     }
 523 
 524     /** {@inheritDoc} */
 525     @Override protected void layoutChartChildren(double top, double left, double contentWidth, double contentHeight) {
 526         double total = 0.0;
 527         for (Data item = begin; item != null; item = item.next) {
 528             total+= Math.abs(item.getCurrentPieValue());
 529         }
 530         double scale = (total != 0) ? 360 / total : 0;
 531 
 532          // calculate combined bounds of all labels & pie radius
 533         double[] labelsX = null;
 534         double[] labelsY = null;
 535         double[] labelAngles = null;
 536         double labelScale = 1;
 537         List<LabelLayoutInfo> fullPie = null;
 538         boolean shouldShowLabels = getLabelsVisible();
 539         if (shouldShowLabels) {
 540             double xPad = 0d;
 541             double yPad = 0d;
 542 
 543             labelsX = new double[getDataSize()];
 544             labelsY = new double[getDataSize()];


 955         private double getRadiusMultiplier() {
 956             return radiusMultiplier.getValue();
 957         }
 958 
 959         private void setRadiusMultiplier(double value) {
 960             radiusMultiplier.setValue(value);
 961         }
 962 
 963         private DoubleProperty radiusMultiplierProperty() {
 964             return radiusMultiplier;
 965         }
 966 
 967         /**
 968          * Readonly access to the node that represents the pie slice. You can use this to add mouse event listeners etc.
 969          */
 970         private ReadOnlyObjectWrapper<Node> node = new ReadOnlyObjectWrapper<>(this, "node");
 971 
 972         /**
 973          * Returns the node that represents the pie slice. You can use this to
 974          * add mouse event listeners etc.
 975          * @return the node that represents the pie slice
 976          */
 977         public Node getNode() {
 978             return node.getValue();
 979         }
 980 
 981         private void setNode(Node value) {
 982             node.setValue(value);
 983         }
 984 
 985         public ReadOnlyObjectProperty<Node> nodeProperty() {
 986             return node.getReadOnlyProperty();
 987         }
 988 
 989         // -------------- CONSTRUCTOR -------------------------------------------------
 990 
 991         /**
 992          * Constructs a PieChart.Data object with the given name and value.
 993          *
 994          * @param name  name for Pie
 995          * @param value pie value


< prev index next >