functional/ControlsTests/src/javafx/scene/control/test/chart/apps/NewNumberScatterChartApp.java

Print this page




  76 
  77         //ScatterChart to be tested.
  78         ScatterChart testedScatterChart;
  79         NumberAxis axis1;
  80         NumberAxis axis2;
  81         TabPaneWithControl pane;
  82 
  83         public ScatterChartScene() {
  84             super("NumberScatterChart", 1300, 800);
  85         }
  86 
  87         @Override
  88         final protected void prepareScene() {
  89             Utils.addBrowser(this);
  90 
  91             axis1 = new NumberAxis(0, 100, 10);
  92             axis2 = new NumberAxis(0, 100, 10);
  93             testedScatterChart = getNewChart();
  94             testedScatterChart.setId(TESTED_CHART_ID);
  95 
  96             Button hardResetButton = ButtonBuilder.create().id(HARD_RESET_BUTTON_ID).text("Hard reset").build();

  97             hardResetButton.setOnAction(new EventHandler<ActionEvent>() {
  98                 public void handle(ActionEvent t) {
  99                     HBox hb = (HBox) getRoot();
 100                     hb.getChildren().clear();
 101                     prepareMainSceneStructure();
 102                     prepareScene();
 103                 }
 104             });
 105 
 106             Button softResetButton = ButtonBuilder.create().id(SOFT_RESET_BUTTON_ID).text("Soft reset").build();

 107             softResetButton.setOnAction(new EventHandler<ActionEvent>() {
 108                 public void handle(ActionEvent t) {
 109                     //throw new UnsupportedOperationException("Not supported yet.");
 110                 }
 111             });
 112 
 113             HBox resetButtonsHBox = new HBox();
 114             resetButtonsHBox.getChildren().addAll(hardResetButton, softResetButton);
 115 
 116             VBox vb = new VBox(5);
 117             vb.getChildren().addAll(resetButtonsHBox, getAddItemHBox(), getAddPointToSerieDialog(), getRemoveDataFromSerieDialog(), getRemoveDataDialog());
 118 
 119             pane = getPaneFor(testedScatterChart, CHART_TAB_NAME, axis1, AXIS_1_TAB_NAME, axis2, AXIS_2_TAB_NAME);
 120 
 121             setTestedControlContainerSize(500, 500);
 122             setTestedControl(testedScatterChart);
 123             setPropertiesContent(pane);
 124             setControllersContent(vb);
 125         }
 126 
 127         public HBox getRemoveDataDialog() {
 128             HBox hb = new HBox();
 129             Label lb = new Label("From position");
 130             final TextField tf = TextFieldBuilder.create().text("0").prefWidth(50).id(REMOVE_ITEM_POS_TEXT_FIELD_ID).build();
 131             Button bt = ButtonBuilder.create().text("Remove!").id(REMOVE_BUTTON_ID).build();



 132             bt.setOnAction(new EventHandler() {
 133                 public void handle(Event t) {
 134                     int index = Integer.parseInt(tf.getText());
 135                     testedScatterChart.getData().remove(index);
 136                 }
 137             });
 138             hb.getChildren().addAll(lb, tf, bt);
 139             return hb;
 140         }
 141 
 142         public HBox getRemoveDataFromSerieDialog() {
 143             HBox hb = new HBox();
 144             Label lb1 = new Label("From serie");
 145             final TextField tf1 = TextFieldBuilder.create().text("0").prefWidth(50).build();

 146 
 147             Label lb2 = new Label("from index");
 148             final TextField tf2 = TextFieldBuilder.create().text("0").prefWidth(50).build();

 149 
 150             Button bt = ButtonBuilder.create().text("remove point!").id(REMOVE_BUTTON_ID).build();

 151             bt.setOnAction(new EventHandler() {
 152                 public void handle(Event t) {
 153                     int serie = Integer.parseInt(tf1.getText());
 154                     int index = Integer.parseInt(tf2.getText());
 155                     ((Series) testedScatterChart.getData().get(serie)).getData().remove(index);
 156                 }
 157             });
 158             hb.getChildren().addAll(lb1, tf1, lb2, tf2, bt);
 159             return hb;
 160         }
 161 
 162         public HBox getAddPointToSerieDialog() {
 163             HBox hb = new HBox();
 164             Label lb1 = new Label("To serie");
 165             final TextField tf1 = TextFieldBuilder.create().text("0").prefWidth(50).build();

 166 
 167             Label lb2 = new Label("to index");
 168             final TextField tf2 = TextFieldBuilder.create().text("0").prefWidth(50).build();

 169 
 170             Label lb3 = new Label("X");
 171             final TextField tf3 = TextFieldBuilder.create().text("0").prefWidth(50).build();

 172 
 173             Label lb4 = new Label("Y");
 174             final TextField tf4 = TextFieldBuilder.create().text("0").prefWidth(50).build();

 175 
 176             Button bt = ButtonBuilder.create().text("add point!").id(REMOVE_BUTTON_ID).build();

 177             bt.setOnAction(new EventHandler() {
 178                 public void handle(Event t) {
 179                     int serie = Integer.parseInt(tf1.getText());
 180                     int index = Integer.parseInt(tf2.getText());
 181                     double X = Double.parseDouble(tf3.getText());
 182                     double Y = Double.parseDouble(tf4.getText());
 183 
 184                     XYChart.Data newData = new XYChart.Data();
 185                     newData.setXValue(X);
 186                     newData.setYValue(Y);
 187 
 188                     ((Series) testedScatterChart.getData().get(serie)).getData().add(index, newData);
 189                 }
 190             });
 191             hb.getChildren().addAll(lb1, tf1, lb2, tf2, lb3, tf3, lb4, tf4, bt);
 192             return hb;
 193         }
 194 
 195         public HBox getAddItemHBox() {
 196             HBox hb = new HBox();
 197             Label lb = new Label("Add series named ");
 198             final TextField tf = TextFieldBuilder.create().prefWidth(50).id(ADDED_SERIES_NAME_TEXTFIELD_ID).build();


 199 
 200             Label minLabel = new Label(" min ");
 201             final TextField minText = TextFieldBuilder.create().prefWidth(50).id(ADDED_SERIES_MIN_VALUE_TEXTFIELD_ID).build();


 202 
 203             Label maxLabel = new Label(" max ");
 204             final TextField maxText = TextFieldBuilder.create().prefWidth(50).id(ADDED_SERIES_MAX_VALUE_TEXTFIELD_ID).build();


 205 
 206             Label amountLabel = new Label(" amount ");
 207             final TextField amountText = TextFieldBuilder.create().prefWidth(50).id(ADDED_SERIES_DOTS_COUNT_TEXTFIELD_ID).build();


 208 
 209             Button bt = ButtonBuilder.create().text("Add!").id(ADD_SERIES_COMMAND_BUTTON_ID).build();

 210             bt.setOnAction(new EventHandler() {
 211                 public void handle(Event t) {
 212                     String serieName = tf.getText();
 213                     double min = Double.parseDouble(minText.getText());
 214                     double max = Double.parseDouble(maxText.getText());
 215                     int amount = Integer.parseInt(amountText.getText());
 216 
 217                     ObservableList list = FXCollections.observableArrayList();
 218 
 219                     Series serie = new XYChart.Series(serieName, list);
 220 
 221                     for (int i = 0; i < amount; i++) {
 222                         Data newData = new Data();
 223                         newData.setXValue(new Random().nextDouble() * (max - min) + min);
 224                         newData.setYValue(new Random().nextDouble() * (max - min) + min);
 225                         list.add(newData);
 226                     }
 227 
 228                     testedScatterChart.getData().add(serie);
 229                     pane.addPropertiesTable(serieName, getTableForProperty(serie, min, max).getVisualRepresentation());




  76 
  77         //ScatterChart to be tested.
  78         ScatterChart testedScatterChart;
  79         NumberAxis axis1;
  80         NumberAxis axis2;
  81         TabPaneWithControl pane;
  82 
  83         public ScatterChartScene() {
  84             super("NumberScatterChart", 1300, 800);
  85         }
  86 
  87         @Override
  88         final protected void prepareScene() {
  89             Utils.addBrowser(this);
  90 
  91             axis1 = new NumberAxis(0, 100, 10);
  92             axis2 = new NumberAxis(0, 100, 10);
  93             testedScatterChart = getNewChart();
  94             testedScatterChart.setId(TESTED_CHART_ID);
  95 
  96             Button hardResetButton = new Button("Hard reset");

  97             hardResetButton.setId(HARD_RESET_BUTTON_ID);

  98             hardResetButton.setOnAction(new EventHandler<ActionEvent>() {
  99                 public void handle(ActionEvent t) {
 100                     HBox hb = (HBox) getRoot();
 101                     hb.getChildren().clear();
 102                     prepareMainSceneStructure();
 103                     prepareScene();
 104                 }
 105             });
 106 
 107             Button softResetButton = new Button("Soft reset");

 108             softResetButton.setId(SOFT_RESET_BUTTON_ID);

 109             softResetButton.setOnAction(new EventHandler<ActionEvent>() {
 110                 public void handle(ActionEvent t) {
 111                     //throw new UnsupportedOperationException("Not supported yet.");
 112                 }
 113             });
 114 
 115             HBox resetButtonsHBox = new HBox();
 116             resetButtonsHBox.getChildren().addAll(hardResetButton, softResetButton);
 117 
 118             VBox vb = new VBox(5);
 119             vb.getChildren().addAll(resetButtonsHBox, getAddItemHBox(), getAddPointToSerieDialog(), getRemoveDataFromSerieDialog(), getRemoveDataDialog());
 120 
 121             pane = getPaneFor(testedScatterChart, CHART_TAB_NAME, axis1, AXIS_1_TAB_NAME, axis2, AXIS_2_TAB_NAME);
 122 
 123             setTestedControlContainerSize(500, 500);
 124             setTestedControl(testedScatterChart);
 125             setPropertiesContent(pane);
 126             setControllersContent(vb);
 127         }
 128 
 129         public HBox getRemoveDataDialog() {
 130             HBox hb = new HBox();
 131             Label lb = new Label("From position");
 132             final TextField tf = new TextField("0");

 133             tf.setPrefWidth(50);

 134             tf.setId(REMOVE_ITEM_POS_TEXT_FIELD_ID);

 135             Button bt = new Button("Remove!");

 136             bt.setId(REMOVE_BUTTON_ID);

 137             bt.setOnAction(new EventHandler() {
 138                 public void handle(Event t) {
 139                     int index = Integer.parseInt(tf.getText());
 140                     testedScatterChart.getData().remove(index);
 141                 }
 142             });
 143             hb.getChildren().addAll(lb, tf, bt);
 144             return hb;
 145         }
 146 
 147         public HBox getRemoveDataFromSerieDialog() {
 148             HBox hb = new HBox();
 149             Label lb1 = new Label("From serie");
 150             final TextField tf1 = new TextField("0");

 151             tf1.setPrefWidth(50);

 152 
 153             Label lb2 = new Label("from index");
 154             final TextField tf2 = new TextField("0");

 155             tf2.setPrefWidth(50);

 156 
 157             Button bt = new Button("remove point!");

 158             bt.setId(REMOVE_BUTTON_ID);

 159             bt.setOnAction(new EventHandler() {
 160                 public void handle(Event t) {
 161                     int serie = Integer.parseInt(tf1.getText());
 162                     int index = Integer.parseInt(tf2.getText());
 163                     ((Series) testedScatterChart.getData().get(serie)).getData().remove(index);
 164                 }
 165             });
 166             hb.getChildren().addAll(lb1, tf1, lb2, tf2, bt);
 167             return hb;
 168         }
 169 
 170         public HBox getAddPointToSerieDialog() {
 171             HBox hb = new HBox();
 172             Label lb1 = new Label("To serie");
 173             final TextField tf1 = new TextField("0");

 174             tf1.setPrefWidth(50);

 175 
 176             Label lb2 = new Label("to index");
 177             final TextField tf2 = new TextField("0");

 178             tf2.setPrefWidth(50);

 179 
 180             Label lb3 = new Label("X");
 181             final TextField tf3 = new TextField("0");

 182             tf3.setPrefWidth(50);

 183 
 184             Label lb4 = new Label("Y");
 185             final TextField tf4 = new TextField("0");

 186             tf4.setPrefWidth(50);

 187 
 188             Button bt = new Button("add point!");

 189             bt.setId(REMOVE_BUTTON_ID);

 190             bt.setOnAction(new EventHandler() {
 191                 public void handle(Event t) {
 192                     int serie = Integer.parseInt(tf1.getText());
 193                     int index = Integer.parseInt(tf2.getText());
 194                     double X = Double.parseDouble(tf3.getText());
 195                     double Y = Double.parseDouble(tf4.getText());
 196 
 197                     XYChart.Data newData = new XYChart.Data();
 198                     newData.setXValue(X);
 199                     newData.setYValue(Y);
 200 
 201                     ((Series) testedScatterChart.getData().get(serie)).getData().add(index, newData);
 202                 }
 203             });
 204             hb.getChildren().addAll(lb1, tf1, lb2, tf2, lb3, tf3, lb4, tf4, bt);
 205             return hb;
 206         }
 207 
 208         public HBox getAddItemHBox() {
 209             HBox hb = new HBox();
 210             Label lb = new Label("Add series named ");
 211             final TextField tf = new TextField();

 212             tf.setPrefWidth(50);

 213             tf.setId(ADDED_SERIES_NAME_TEXTFIELD_ID);

 214 
 215             Label minLabel = new Label(" min ");
 216             final TextField minText = new TextField();

 217             minText.setPrefWidth(50);

 218             minText.setId(ADDED_SERIES_MIN_VALUE_TEXTFIELD_ID);

 219 
 220             Label maxLabel = new Label(" max ");
 221             final TextField maxText = new TextField();

 222             maxText.setPrefWidth(50);

 223             maxText.setId(ADDED_SERIES_MAX_VALUE_TEXTFIELD_ID);

 224 
 225             Label amountLabel = new Label(" amount ");
 226             final TextField amountText = new TextField();

 227             amountText.setPrefWidth(50);

 228             amountText.setId(ADDED_SERIES_DOTS_COUNT_TEXTFIELD_ID);

 229 
 230             Button bt = new Button("Add!");

 231             bt.setId(ADD_SERIES_COMMAND_BUTTON_ID);

 232             bt.setOnAction(new EventHandler() {
 233                 public void handle(Event t) {
 234                     String serieName = tf.getText();
 235                     double min = Double.parseDouble(minText.getText());
 236                     double max = Double.parseDouble(maxText.getText());
 237                     int amount = Integer.parseInt(amountText.getText());
 238 
 239                     ObservableList list = FXCollections.observableArrayList();
 240 
 241                     Series serie = new XYChart.Series(serieName, list);
 242 
 243                     for (int i = 0; i < amount; i++) {
 244                         Data newData = new Data();
 245                         newData.setXValue(new Random().nextDouble() * (max - min) + min);
 246                         newData.setYValue(new Random().nextDouble() * (max - min) + min);
 247                         list.add(newData);
 248                     }
 249 
 250                     testedScatterChart.getData().add(serie);
 251                     pane.addPropertiesTable(serieName, getTableForProperty(serie, min, max).getVisualRepresentation());