functional/ControlsTests/src/javafx/scene/control/test/chart/manual/PieChartManualApp.java

Print this page




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package javafx.scene.control.test.chart.manual;
  26 
  27 import javafx.scene.control.test.utils.ptables.WeakPropertyValueController;
  28 import java.util.Arrays;
  29 import javafx.collections.FXCollections;
  30 import javafx.collections.ObservableList;
  31 import javafx.event.ActionEvent;
  32 import javafx.event.EventHandler;
  33 import javafx.scene.chart.PieChart;
  34 import javafx.scene.Scene;
  35 import javafx.scene.control.*;
  36 import javafx.scene.control.ButtonBuilder;
  37 import javafx.scene.control.test.utils.CommonPropertiesScene;
  38 import javafx.geometry.Side;
  39 import javafx.scene.layout.HBox;
  40 import test.javaclient.shared.InteroperabilityApp;
  41 import test.javaclient.shared.Utils;
  42 import javafx.scene.layout.VBox;
  43 import javafx.geometry.Orientation;
  44 
  45 /**
  46  * @author Alexander Kirov
  47  */
  48 public class PieChartManualApp extends InteroperabilityApp {
  49 
  50     public static void main(String[] args) {
  51         Utils.launch(PieChartManualApp.class, args);
  52     }
  53 
  54     @Override
  55     protected Scene getScene() {
  56         Utils.setTitleToStage(stage, "PieChartTestApp");


  87 
  88             Button removeDataButton = new Button("Remove data from index 0");
  89             removeDataButton.setOnAction(new EventHandler<ActionEvent>() {
  90                 public void handle(ActionEvent t) {
  91                     if (testedPieChart.getData().size() > 0) {
  92                         testedPieChart.getData().remove(0);
  93                     }
  94                 }
  95             });
  96 
  97             Button changeDataButton = new Button("Change data at index 0");
  98             changeDataButton.setOnAction(new EventHandler<ActionEvent>() {
  99                 public void handle(ActionEvent t) {
 100                     if (testedPieChart.getData().size() > 0) {
 101                         PieChart.Data data = testedPieChart.getData().get(0);
 102                         data.setPieValue(Math.max(0, data.getPieValue() + (Math.random() - 0.5) * 200));
 103                     }
 104                 }
 105             });
 106 
 107             Button hardResetButton = ButtonBuilder.create().text("Reset").build();
 108             hardResetButton.setOnAction(new EventHandler<ActionEvent>() {
 109                 public void handle(ActionEvent t) {
 110                     HBox hb = (HBox) getRoot();
 111                     hb.getChildren().clear();
 112                     prepareMainSceneStructure();
 113                     prepareScene();
 114                 }
 115             });
 116 
 117             VBox vb = new VBox(5);
 118             vb.getChildren().addAll(hardResetButton,
 119                     new Separator(Orientation.HORIZONTAL), new Label("Add new data : "), addDataButton,
 120                     new Separator(Orientation.HORIZONTAL), new Label("Remove existing data : "), removeDataButton,
 121                     new Separator(Orientation.HORIZONTAL), new Label("Change existing data : "), changeDataButton);
 122 
 123             addController(new WeakPropertyValueController(testedPieChart.animatedProperty(), testedPieChart));
 124             addController(new WeakPropertyValueController(testedPieChart.clockwiseProperty(), testedPieChart));
 125             addController(new WeakPropertyValueController(testedPieChart.legendVisibleProperty(), testedPieChart));
 126             addController(new WeakPropertyValueController(testedPieChart.startAngleProperty(), testedPieChart, -300.0, 0.0, 300.0));
 127             addController(new WeakPropertyValueController(testedPieChart.labelLineLengthProperty(), testedPieChart, -20.0, 10.0, 30.0));




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package javafx.scene.control.test.chart.manual;
  26 
  27 import javafx.scene.control.test.utils.ptables.WeakPropertyValueController;
  28 import java.util.Arrays;
  29 import javafx.collections.FXCollections;
  30 import javafx.collections.ObservableList;
  31 import javafx.event.ActionEvent;
  32 import javafx.event.EventHandler;
  33 import javafx.scene.chart.PieChart;
  34 import javafx.scene.Scene;
  35 import javafx.scene.control.*;

  36 import javafx.scene.control.test.utils.CommonPropertiesScene;
  37 import javafx.geometry.Side;
  38 import javafx.scene.layout.HBox;
  39 import test.javaclient.shared.InteroperabilityApp;
  40 import test.javaclient.shared.Utils;
  41 import javafx.scene.layout.VBox;
  42 import javafx.geometry.Orientation;
  43 
  44 /**
  45  * @author Alexander Kirov
  46  */
  47 public class PieChartManualApp extends InteroperabilityApp {
  48 
  49     public static void main(String[] args) {
  50         Utils.launch(PieChartManualApp.class, args);
  51     }
  52 
  53     @Override
  54     protected Scene getScene() {
  55         Utils.setTitleToStage(stage, "PieChartTestApp");


  86 
  87             Button removeDataButton = new Button("Remove data from index 0");
  88             removeDataButton.setOnAction(new EventHandler<ActionEvent>() {
  89                 public void handle(ActionEvent t) {
  90                     if (testedPieChart.getData().size() > 0) {
  91                         testedPieChart.getData().remove(0);
  92                     }
  93                 }
  94             });
  95 
  96             Button changeDataButton = new Button("Change data at index 0");
  97             changeDataButton.setOnAction(new EventHandler<ActionEvent>() {
  98                 public void handle(ActionEvent t) {
  99                     if (testedPieChart.getData().size() > 0) {
 100                         PieChart.Data data = testedPieChart.getData().get(0);
 101                         data.setPieValue(Math.max(0, data.getPieValue() + (Math.random() - 0.5) * 200));
 102                     }
 103                 }
 104             });
 105 
 106             Button hardResetButton = new Button("Reset");

 107             hardResetButton.setOnAction(new EventHandler<ActionEvent>() {
 108                 public void handle(ActionEvent t) {
 109                     HBox hb = (HBox) getRoot();
 110                     hb.getChildren().clear();
 111                     prepareMainSceneStructure();
 112                     prepareScene();
 113                 }
 114             });
 115 
 116             VBox vb = new VBox(5);
 117             vb.getChildren().addAll(hardResetButton,
 118                     new Separator(Orientation.HORIZONTAL), new Label("Add new data : "), addDataButton,
 119                     new Separator(Orientation.HORIZONTAL), new Label("Remove existing data : "), removeDataButton,
 120                     new Separator(Orientation.HORIZONTAL), new Label("Change existing data : "), changeDataButton);
 121 
 122             addController(new WeakPropertyValueController(testedPieChart.animatedProperty(), testedPieChart));
 123             addController(new WeakPropertyValueController(testedPieChart.clockwiseProperty(), testedPieChart));
 124             addController(new WeakPropertyValueController(testedPieChart.legendVisibleProperty(), testedPieChart));
 125             addController(new WeakPropertyValueController(testedPieChart.startAngleProperty(), testedPieChart, -300.0, 0.0, 300.0));
 126             addController(new WeakPropertyValueController(testedPieChart.labelLineLengthProperty(), testedPieChart, -20.0, 10.0, 30.0));