1 /*
   2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation. Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  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 test.css.controls;
  26 
  27 import com.sun.javafx.collections.ObservableListWrapper;
  28 import javafx.scene.control.skin.CellSkinBase;
  29 import javafx.scene.control.skin.ColorPickerSkin;
  30 import javafx.scene.control.skin.PaginationSkin;
  31 import javafx.scene.control.skin.ProgressIndicatorSkin;
  32 import javafx.scene.control.skin.TableColumnHeader;
  33 import javafx.scene.control.skin.TextInputControlSkin;
  34 import javafx.scene.control.skin.TreeCellSkin;

  35 import java.lang.reflect.Constructor;
  36 import java.lang.reflect.Method;
  37 import java.time.LocalDate;
  38 import java.time.Month;
  39 import java.time.format.DateTimeFormatter;
  40 import java.time.format.DateTimeFormatterBuilder;
  41 import java.util.*;
  42 import javafx.application.ConditionalFeature;
  43 import javafx.application.Platform;
  44 import javafx.beans.property.SimpleObjectProperty;
  45 import javafx.beans.value.ObservableValue;
  46 import javafx.collections.FXCollections;
  47 import javafx.collections.ObservableList;
  48 import javafx.css.CssMetaData;
  49 import javafx.css.Styleable;
  50 import javafx.geometry.HPos;
  51 import javafx.geometry.Pos;
  52 import javafx.scene.Node;
  53 import javafx.scene.chart.BarChart;
  54 import javafx.scene.chart.CategoryAxis;
  55 import javafx.scene.chart.LineChart;
  56 import javafx.scene.chart.NumberAxis;
  57 import javafx.scene.chart.PieChart;
  58 import javafx.scene.chart.XYChart;
  59 import javafx.scene.control.Accordion;
  60 import javafx.scene.control.Button;

  61 import javafx.scene.control.CheckBox;

  62 import javafx.scene.control.ChoiceBox;
  63 import javafx.scene.control.ColorPicker;
  64 import javafx.scene.control.ComboBox;
  65 import javafx.scene.control.Control;
  66 import javafx.scene.control.DatePicker;
  67 import javafx.scene.control.Hyperlink;

  68 import javafx.scene.control.Label;

  69 import javafx.scene.control.ListView;
  70 import javafx.scene.control.Menu;
  71 import javafx.scene.control.MenuBar;
  72 import javafx.scene.control.MenuItem;
  73 import javafx.scene.control.Pagination;
  74 import javafx.scene.control.PasswordField;

  75 import javafx.scene.control.ProgressBar;

  76 import javafx.scene.control.ProgressIndicator;

  77 import javafx.scene.control.RadioButton;

  78 import javafx.scene.control.ScrollBar;

  79 import javafx.scene.control.ScrollPane;
  80 import javafx.scene.control.Separator;

  81 import javafx.scene.control.Slider;

  82 import javafx.scene.control.SplitMenuButton;

  83 import javafx.scene.control.SplitPane;

  84 import javafx.scene.control.Tab;
  85 import javafx.scene.control.TabPane;
  86 import javafx.scene.control.TableColumn;
  87 import javafx.scene.control.TableColumn.CellDataFeatures;
  88 import javafx.scene.control.TableView;
  89 import javafx.scene.control.TextField;

  90 import javafx.scene.control.TitledPane;
  91 import javafx.scene.control.ToggleButton;

  92 import javafx.scene.control.ToolBar;
  93 import javafx.scene.control.TreeItem;
  94 import javafx.scene.control.TreeView;
  95 import javafx.scene.image.Image;
  96 import javafx.scene.image.ImageView;
  97 import javafx.scene.layout.FlowPane;
  98 import javafx.scene.layout.HBox;
  99 import javafx.scene.layout.StackPane;
 100 import javafx.scene.layout.TilePane;
 101 import javafx.scene.layout.VBox;
 102 import javafx.scene.paint.Color;
 103 import javafx.scene.shape.Circle;
 104 import javafx.scene.shape.Rectangle;
 105 import javafx.scene.text.Text;
 106 import javafx.util.Callback;
 107 import javafx.util.StringConverter;


 108 
 109 /**
 110  *
 111  * @author sergey.lugovoy@oracle.com
 112  */
 113 public enum ControlPage {
 114     Accordions(Accordion.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 115         public Node createControl() {
 116             TitledPane pane1 = new TitledPane();
 117             pane1.setText("title 1\nLong text long text");
 118             pane1.setContent(new Rectangle(100, 40, Color.SKYBLUE));
 119             pane1.setFocusTraversable(false);
 120             TitledPane pane2 = new TitledPane();
 121             pane2.setText("title 2\nLong text long text");
 122             pane2.setContent(new Rectangle(100, 40, Color.BLUEVIOLET));
 123             Accordion acc = new Accordion();
 124             acc.getPanes().addAll(pane1, pane2);
 125             acc.setExpandedPane(pane2);
 126             pane2.setAnimated(false);
 127             pane2.setFocusTraversable(false);
 128             acc.setFocusTraversable(false);
 129             return acc;
 130         }
 131     }, 200), Buttons(Button.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 132         public Control createControl() {
 133             Button temp = new Button("Button the first line" + "\nthe sec long line" + "\nthe third line");
 134             temp.setFocusTraversable(false);
 135             temp.setGraphic(new Rectangle(10, 10, Color.RED));
 136             return temp;
 137         }
 138     }, 200, 100), ChoiceBoxes(ChoiceBox.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 139         public Control createControl() {
 140             return new ChoiceBox() {
 141                 {
 142                     getItems().addAll(Arrays.asList("one", "two", "three"));
 143                     this.getSelectionModel().select(0);
 144                     setFocusTraversable(false);
 145                 }
 146             };
 147         }
 148     }), CheckBoxes(CheckBox.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 149         public Control createControl() {
 150             CheckBox temp = new CheckBox("Check box the first line" + "\nthe sec long line" + "\nthe third line");
 151             temp.setFocusTraversable(false);
 152             temp.setGraphic(new Rectangle(20, 20, Color.web("lightblue")));
 153             return temp;
 154         }
 155     }, 200, 100), ComboBoxes(ComboBox.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 156         @Override
 157         public Control createControl() {
 158             return new ComboBox() {
 159                 {
 160                     getItems().addAll(Arrays.asList("one", "two", "three"));
 161                     getSelectionModel().select(0);
 162                     setFocusTraversable(false);
 163                 }
 164             };
 165         }
 166     }), Hyperlinks(Hyperlink.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 167         public Control createControl() {
 168             Hyperlink temp = new Hyperlink("Hyperlink the first line" + "\nthe sec long line" + "\nthe third line");
 169             temp.setFocusTraversable(false);
 170             temp.setGraphic(new Circle(10, Color.BLUE));
 171             return temp;
 172         }
 173     }, 200, 100), Labels(new ArrayList<CssMetaData<? extends Styleable, ?>>(Label.getClassCssMetaData()) {
 174         {
 175             addAll(Text.getClassCssMetaData());
 176         }
 177     }, new ControlsCSSApp.ControlFactory() {
 178         public Control createControl() {
 179             Label temp = new Label("Label the first line" + "\nthe sec longlong line" + "\nthe third line");
 180             temp.setFocusTraversable(false);
 181             temp.setGraphic(new Rectangle(20, 20, Color.web("lightblue")));
 182             return temp;
 183         }
 184     }, 200), ListViews(ListView.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 185         public Node createControl() {
 186             ListView list = new ListView();
 187             ObservableListWrapper<String> items = new ObservableListWrapper<String>(Arrays.asList("One", "Two", "Three", "Four", "Five", "Six", "long line long line long line long line"));
 188             list.setItems(items);
 189             list.setPrefWidth(100);
 190             list.setPrefHeight(100);
 191             list.setFocusTraversable(false);
 192             return list;
 193         }
 194     }, 150), PasswordFields(PasswordField.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 195         public Control createControl() {
 196             PasswordField temp = new PasswordField();
 197             temp.setPromptText("Password box the first line" + "\nthe sec long line" + "\nthe third line");
 198             temp.setFocusTraversable(false);
 199             return temp;
 200         }
 201     }), PressedToggleButtons(ToggleButton.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 202         public Control createControl() {
 203             ToggleButton temp = new ToggleButton("Button the first line" + "\nthe sec long line" + "\nthe third line");
 204             temp.setSelected(true);
 205             temp.setFocusTraversable(false);
 206             temp.setGraphic(new Rectangle(10, 10, Color.RED));
 207             return temp;
 208         }
 209     }, 200, 120), ProgressIndicators(new ArrayList<CssMetaData<? extends Styleable, ?>>(ProgressIndicator.getClassCssMetaData()) {
 210         {
 211             addAll(ProgressIndicatorSkin.getClassCssMetaData());
 212         }
 213     }, new ControlsCSSApp.ControlFactory() {
 214         public Node createControl() {
 215             ProgressIndicator temp = new ProgressIndicator(0.85);
 216             temp.setPrefSize(100, 100);
 217             temp.setFocusTraversable(false);
 218             return temp;
 219         }
 220     }), ProgressBars(ProgressBar.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 221         public Node createControl() {
 222             ProgressBar temp = new ProgressBar(0.25);
 223             temp.setFocusTraversable(false);
 224             return temp;
 225         }
 226     }, 200, 100), RadioButtons(RadioButton.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 227         public Control createControl() {
 228             RadioButton temp = new RadioButton("Radio the first line" + "\nthe sec long line" + "\nthe third line");
 229             temp.setFocusTraversable(false);
 230             temp.setGraphic(new Rectangle(20, 20, Color.web("lightblue")));
 231             return temp;
 232         }
 233     }, 200, 100), TextFields(new ArrayList<CssMetaData<? extends Styleable, ?>>(TextField.getClassCssMetaData()) {
 234         {
 235             addAll(TextInputControlSkin.getClassCssMetaData());
 236         }
 237     }, new ControlsCSSApp.ControlFactory() {
 238         public Control createControl() {
 239             TextField temp = new TextField("Text box the first line" + "\nthe sec long line" + "\nthe third line");
 240             temp.setFocusTraversable(false);
 241             return temp;
 242         }
 243     }), Sliders(Slider.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 244         public Control createControl() {
 245             Slider temp = new Slider();
 246             temp.setMin(0);
 247             temp.setMax(100);
 248             temp.setValue(20);
 249             temp.setFocusTraversable(false);
 250             return temp;
 251         }
 252     }, 200), Separators(Separator.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 253         public Control createControl() {
 254             Separator sep = new Separator();
 255             sep.setHalignment(HPos.CENTER);
 256             sep.setPrefWidth(80);
 257             return sep;
 258         }
 259     }, 150), ScrollBars(ScrollBar.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 260         public Control createControl() {
 261             ScrollBar temp = new ScrollBar();
 262             temp.setValue(45);
 263             temp.setMin(0);
 264             temp.setMax(100);
 265             temp.setFocusTraversable(false);
 266             return temp;
 267         }
 268     }, 150), ScrollPanes(ScrollPane.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 269         public Node createControl() {
 270             ScrollPane pane = new ScrollPane();
 271             HBox hbox = new HBox(30);
 272             VBox vbox1 = new VBox(10);
 273             vbox1.getChildren().addAll(new Label("one"), new Button("two"), new CheckBox("three"), new RadioButton("four"), new Label("five"));
 274             VBox vbox2 = new VBox(10);
 275             vbox2.getChildren().addAll(new Label("one"), new Button("two"), new CheckBox("three"), new RadioButton("four"), new Label("five"));
 276             hbox.getChildren().addAll(vbox1, vbox2);
 277             pane.setContent(hbox);
 278             pane.setFocusTraversable(false);
 279             return pane;
 280         }
 281     }, 150), UnPressedToggleButtons(ToggleButton.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 282         public Control createControl() {
 283             ToggleButton temp = new ToggleButton("Button the first line" + "\nthe sec long line" + "\nthe third line");
 284             temp.setGraphic(new Rectangle(10, 10, Color.RED));
 285             temp.setSelected(false);
 286             temp.setFocusTraversable(false);
 287             return temp;
 288         }
 289     }, 200, 120), Toolbars(ToolBar.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 290         public Node createControl() {
 291             ToolBar toolbar = new ToolBar();
 292             SplitMenuButton temp = new SplitMenuButton();
 293             temp.setText("three");
 294             toolbar.getItems().addAll(new Button("One"), new Button("Two"), new Separator(), temp);
 295             toolbar.setFocusTraversable(false);
 296             return toolbar;
 297         }
 298     }, 250, 150), Menubars(MenuBar.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 299         public Node createControl() {
 300             MenuBar menubar = new MenuBar();
 301             Menu firstMenu = new Menu("File");
 302             MenuItem firstMenuFirstItem = new MenuItem("Save");
 303             MenuItem firstMenuSecondItem = new MenuItem("Open");
 304             MenuItem firstMenuThirdItem = new MenuItem("Exit");
 305             firstMenu.getItems().addAll(firstMenuFirstItem, firstMenuSecondItem, firstMenuThirdItem);
 306             Menu secondMenu = new Menu("Edit");
 307             MenuItem secondMenuFirstItem = new MenuItem("Undo");
 308             MenuItem secondMenuSecondItem = new MenuItem("Cut");
 309             MenuItem secondMenuThirdItem = new MenuItem("Copy");
 310             secondMenu.getItems().addAll(secondMenuFirstItem, secondMenuSecondItem, secondMenuThirdItem);
 311             Menu thirdMenu = new Menu("Help");
 312             MenuItem thirdMenuFirstItem = new MenuItem("Help Contents");
 313             MenuItem thirdMenuSecondItem = new MenuItem("About");
 314             thirdMenu.getItems().addAll(thirdMenuFirstItem, thirdMenuSecondItem);
 315             menubar.getMenus().addAll(firstMenu, secondMenu, thirdMenu);
 316             menubar.setFocusTraversable(false);
 317             return menubar;
 318         }
 319     }, 250, 150), SplitMenuButtons(SplitMenuButton.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 320         public Node createControl() {
 321             SplitMenuButton smb = new SplitMenuButton(new MenuItem("Split box the first line" + "\nthe sec long line" + "\nthe third line", new Rectangle(10, 10, Color.BLUE)));
 322             smb.setText("Split box the first line" + "\nthe sec long line" + "\nthe third line");
 323             smb.setGraphic(new Rectangle(10, 10, Color.RED));
 324             smb.setFocusTraversable(false);
 325             return smb;
 326         }
 327     }, 200, 120), TabPanes(TabPane.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 328         public Node createControl() {
 329             TabPane pane = new TabPane();
 330             Tab tab = new Tab();
 331             tab.setText("tab 1");
 332             HBox content1 = new HBox(10);
 333             content1.getChildren().addAll(new Button("Button"), new Label("Label"), new Rectangle(40, 40, Color.TOMATO));
 334             tab.setContent(content1);
 335             Tab tab2 = new Tab();
 336             tab2.setText("tab 2");
 337             tab2.setContent(new Circle(40, Color.RED));
 338             pane.getTabs().addAll(tab, tab2);
 339             pane.setFocusTraversable(false);
 340             return pane;
 341         }
 342     }, 200), TitledPanes(TitledPane.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 343         public Node createControl() {
 344             TitledPane tpane = new TitledPane();
 345             tpane.setText("Title");
 346             VBox content = new VBox(5);
 347             content.getChildren().addAll(new Label("Label"), new Button("Button"), new CheckBox("Check box"));
 348             tpane.setContent(content);
 349             tpane.setAnimated(false);
 350             tpane.setFocusTraversable(false);
 351             return tpane;
 352         }
 353     }, 150), TableViews(new ArrayList<CssMetaData<? extends Styleable, ?>>(TableView.getClassCssMetaData()) {
 354         {
 355             addAll(CellSkinBase.getClassCssMetaData());
 356             addAll(TableColumnHeader.getClassCssMetaData());
 357         }
 358     }, new ControlsCSSApp.ControlFactory() {
 359         public Node createControl() {
 360             ObservableList<ControlsCSSApp.Person> items = FXCollections.observableArrayList();
 361             for (int i = 0; i < 10; i++) {
 362                 items.add(new ControlsCSSApp.Person("name " + i, "surname " + i));
 363             }
 364             TableColumn<ControlsCSSApp.Person, Node> column1 = new TableColumn<ControlsCSSApp.Person, Node>("First Name");
 365             column1.setCellValueFactory(new Callback<CellDataFeatures<ControlsCSSApp.Person, Node>, ObservableValue<Node>>() {
 366                 @Override
 367                 public ObservableValue<Node> call(final CellDataFeatures<ControlsCSSApp.Person, Node> p) {
 368                     SimpleObjectProperty<Node> text = new SimpleObjectProperty<Node>();
 369                     text.setValue(new Label(p.getValue().getFirstName()));
 370                     return text;
 371                 }
 372             });
 373             TableColumn<ControlsCSSApp.Person, Node> column2 = new TableColumn<ControlsCSSApp.Person, Node>("Last Name");
 374             column2.setCellValueFactory(new Callback<CellDataFeatures<ControlsCSSApp.Person, Node>, ObservableValue<Node>>() {
 375                 @Override
 376                 public ObservableValue<Node> call(final CellDataFeatures<ControlsCSSApp.Person, Node> p) {
 377                     SimpleObjectProperty<Node> text = new SimpleObjectProperty<Node>();
 378                     text.setValue(new Label(p.getValue().getLastName()));
 379                     return text;
 380                 }
 381             });
 382             TableView<ControlsCSSApp.Person> table = new TableView<ControlsCSSApp.Person>(items);
 383             table.getColumns().setAll(column1, column2);
 384             table.setPrefHeight(200);
 385             table.setFocusTraversable(false);
 386             return table;
 387         }
 388     }, 200, 250), TreeViews(new ArrayList<CssMetaData<? extends Styleable, ?>>(TableView.getClassCssMetaData()) {
 389         {
 390             addAll(TreeCellSkin.getClassCssMetaData());
 391         }
 392     }, new ControlsCSSApp.ControlFactory() {
 393         public Node createControl() {
 394             TreeItem<String> root = new TreeItem<String>("ROOT", new Rectangle(20, 20, Color.CHOCOLATE));
 395             root.setExpanded(true);
 396             TreeItem<String> firstBrunch = new TreeItem<String>("brunch 1");
 397             firstBrunch.setExpanded(true);
 398             firstBrunch.getChildren().addAll(new TreeItem<String>("first item"), new TreeItem<String>("second item", new Rectangle(20, 20, Color.DARKGREY)));
 399             root.getChildren().addAll(firstBrunch);
 400             TreeItem<String> secondBrunch = new TreeItem<String>("brunch 2");
 401             secondBrunch.getChildren().addAll(new TreeItem<String>("first item"), new TreeItem<String>("second item", new Rectangle(20, 20, Color.DARKGREY)));
 402             root.getChildren().addAll(secondBrunch);
 403             TreeView tree = new TreeView(root);
 404             tree.setFocusTraversable(false);
 405             tree.setMinSize(147, 127);
 406             tree.setPrefSize(160, 140);
 407             return tree;
 408         }
 409     }, 200, 300), SplitPanes(SplitPane.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 410         public Node createControl() {
 411             StackPane sp1 = new StackPane(new Rectangle(40, 40, Color.WHITESMOKE));
 412             StackPane sp2 = new StackPane(new Rectangle(40, 40, Color.BLUE));
 413             StackPane sp3 = new StackPane(new Rectangle(40, 40, Color.RED));
 414             SplitPane pane = new SplitPane(sp1, sp2, sp3);
 415             pane.setPrefSize(150, 150);
 416             pane.setDividerPositions(0.33, 0.67);
 417             pane.setFocusTraversable(false);
 418             return pane;
 419         }
 420     }, 250), Paginations(new ArrayList<CssMetaData<? extends Styleable, ?>>(Pagination.getClassCssMetaData()) {
 421         {
 422             addAll(PaginationSkin.getClassCssMetaData());
 423         }
 424     }, new ControlsCSSApp.ControlFactory() {
 425         public Node createControl() {
 426             Pagination node = new Pagination(47);
 427             node.setMaxPageIndicatorCount(5);
 428             node.getStyleClass().add(Pagination.STYLE_CLASS_BULLET);
 429             return node;
 430         }
 431     }, 350, 150), XYChars(new ArrayList<CssMetaData<? extends Styleable, ?>>(LineChart.getClassCssMetaData()) {
 432         {
 433             addAll(NumberAxis.getClassCssMetaData());
 434         }
 435     }, new ControlsCSSApp.ControlFactory() {
 436         public Node createControl() {
 437             XYChart node = new LineChart(new NumberAxis(0, 4, 1), new NumberAxis(0, 4, 1));
 438             node.setPrefSize(200, 200);
 439             XYChart.Series series = new XYChart.Series();
 440             series.getData().add(new XYChart.Data(0d, 0d));
 441             series.getData().add(new XYChart.Data(4d, 4d));
 442             XYChart.Series series2 = new XYChart.Series();
 443             series2.getData().add(new XYChart.Data(0d, 0d));
 444             series2.getData().add(new XYChart.Data(1d, 3d));
 445             XYChart.Series series3 = new XYChart.Series();
 446             series3.getData().add(new XYChart.Data(0d, 0d));
 447             series3.getData().add(new XYChart.Data(2d, 4d));
 448             node.getData().addAll(series, series2, series3);
 449             return node;
 450         }
 451     }, 300, 300), TilePanes(TilePane.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 452         public Node createControl() {
 453             TilePane tile = new TilePane();
 454             tile.setPrefSize(150, 150);
 455             tile.setTileAlignment(Pos.CENTER_LEFT);
 456             for (int i = 0; i < 15; i++) {
 457                 tile.getChildren().add(new Rectangle(20, 20, (i % 2 == 0) ? Color.RED : Color.BLUE));
 458             }
 459             return tile;
 460         }
 461     }, 200, 200), VBoxs(VBox.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 462         @Override
 463         public Node createControl() {
 464             VBox node = new VBox(10);
 465             node.setMinSize(150, 150);
 466             for (int i = 0; i < 4; i++) {
 467                 node.getChildren().add(new Rectangle(20, 20, (i % 2 == 0) ? Color.RED : Color.BLUE));
 468             }
 469             return node;
 470         }
 471     }, 200, 200), BarCharts(new ArrayList<CssMetaData<? extends Styleable, ?>>(BarChart.getClassCssMetaData()) {
 472         {
 473             addAll(CategoryAxis.getClassCssMetaData());
 474         }
 475     }, new ControlsCSSApp.ControlFactory() {
 476         public Node createControl() {
 477             CategoryAxis cAxis = new CategoryAxis();
 478             NumberAxis nAxis = new NumberAxis(0, 5, 1);
 479             BarChart node = new BarChart(cAxis, nAxis);
 480             XYChart.Series series = new XYChart.Series();
 481             series.getData().add(new XYChart.Data("1", 2));
 482             XYChart.Series series1 = new XYChart.Series();
 483             series1.getData().add(new XYChart.Data("2", 3));
 484             XYChart.Series series2 = new XYChart.Series();
 485             series2.getData().add(new XYChart.Data("2", 5));
 486             node.getData().addAll(series, series1, series2);
 487             node.setMaxSize(180, 180);
 488             return node;
 489         }
 490     }, 200, 200), ColorPickers(ColorPickerSkin.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 491         public Node createControl() {
 492             ColorPicker node = new ColorPicker();
 493             node.setPrefSize(100, 100);
 494             node.setStyle("-fx-color-label-visible:false;");
 495             return node;
 496         }
 497     }, 200, 200), FlowPanes(FlowPane.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 498         public Node createControl() {
 499             FlowPane node = new FlowPane();
 500             for (int i = 0; i < 6; i++) {
 501                 node.getChildren().add(new Rectangle(20, 20, (i % 2 == 0) ? Color.RED : Color.BLUE));
 502             }
 503             node.setColumnHalignment(HPos.CENTER);
 504             node.setPrefSize(100, 100);
 505             return node;
 506         }
 507     }, 200, 200), PieCharts(PieChart.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 508         public Node createControl() {
 509             ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(new PieChart.Data("", 13), new PieChart.Data("", 25), new PieChart.Data("", 10), new PieChart.Data("", 22), new PieChart.Data("", 30));
 510             PieChart chart = new PieChart(pieChartData);
 511             chart.setMaxSize(150, 150);
 512             return chart;
 513         }
 514     }, 300, 300), WebViews(getWebViewClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 515         public Node createControl() {
 516             Node node = null;
 517             try {
 518                 Class<?> webViewCl = Class.forName("javafx.scene.web.WebView");
 519                 Constructor<?> constructor = webViewCl.getConstructor();
 520                 constructor.setAccessible(true);
 521                 Object args = null;
 522                 node = (Node) constructor.newInstance();
 523                 Method setViewport = webViewCl.getDeclaredMethod("setPrefSize", double.class, double.class);
 524                 setViewport.invoke(node, 150, 150);
 525                 Method getEngine = webViewCl.getDeclaredMethod("getEngine");
 526                 Object engine = getEngine.invoke(node);
 527                 Method load = engine.getClass().getDeclaredMethod("load", String.class);
 528                 load.invoke(engine, ControlsCSSApp.class.getResource("/test/css/resources/index.html").toExternalForm());
 529             } catch (Exception ignored) {
 530             }
 531             return node;
 532         }
 533     }, 300, 300), HBoxs(HBox.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 534         public Node createControl() {
 535             HBox node = new HBox(10);
 536             node.setMinSize(150, 150);
 537             for (int i = 0; i < 4; i++) {
 538                 node.getChildren().add(new Rectangle(20, 20, (i % 2 == 0) ? Color.RED : Color.BLUE));
 539             }
 540             return node;
 541         }
 542     }, 300, 300), ImageViews(ImageView.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 543         public Node createControl() {
 544             ImageView view = new ImageView(new Image(ControlsCSSApp.class.getResource("/test/css/resources/placeholder.png").toExternalForm()));
 545             return view;
 546         }
 547     }, 300, 300), DatePickers(DatePicker.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 548         public Node createControl() {
 549             DatePicker picker = new DatePicker();
 550             picker.setValue(LocalDate.of(2042, Month.MAY, 27));
 551             picker.setConverter(new StringConverter<LocalDate>() {
 552 
 553                 DateTimeFormatter df = new DateTimeFormatterBuilder().parseLenient()
 554                         .appendPattern("M/dd/YYYY")
 555                         .toFormatter(Locale.ENGLISH)
 556                         .withLocale(Locale.ENGLISH);
 557 
 558                 @Override
 559                 public String toString(LocalDate localDate) {
 560                     return df.format(localDate);
 561                 }
 562 
 563                 @Override
 564                 public LocalDate fromString(String s) {
 565                     return LocalDate.parse(s, df);
 566                 }
 567             });
 568             //picker.setMinSize(100, 30);
 569             return picker;
 570         }
 571     }, 300, 300),
 572     Texts(Text.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 573         public Node createControl() {
 574             Text node = new Text("1234567890");
 575             return node;
 576         }
 577     }, 150, 150);
 578     public static final int DEFAULT_SLOTSIZE = 150;
 579     public static final int INNER_PANE_SHIFT = 20;
 580     public List<CssMetaData<? extends Styleable, ?>> keys;
 581     public ControlsCSSApp.ControlFactory factory;
 582     public int slotHeight;
 583     public int slotWidth;
 584 
 585     public static final String packageName = "functional";
 586 
 587     ControlPage(List<CssMetaData<? extends Styleable, ?>> keys, ControlsCSSApp.ControlFactory factory) {
 588         this(keys, factory, DEFAULT_SLOTSIZE);
 589     }
 590 
 591     ControlPage(List<CssMetaData<? extends Styleable, ?>> keys, ControlsCSSApp.ControlFactory factory, int slotSize) {
 592         this(keys, factory, slotSize, slotSize);
 593     }
 594 
 595     /**
 596      * Returns filtered enumeration values, this is required to support embedded
 597      * execution, cause currently JavaFX Embedded does not contain Web component
 598      * @return filtered enumeration values
 599      */
 600     public static ControlPage[] filteredValues(){
 601         Set<ControlPage> controls = EnumSet.allOf(ControlPage.class);
 602         if(!Platform.isSupported(ConditionalFeature.WEB))
 603             controls.remove(ControlPage.WebViews);
 604         return controls.toArray(new ControlPage[]{});
 605     }
 606 
 607     private ControlPage(List<CssMetaData<? extends Styleable, ?>> keys, ControlsCSSApp.ControlFactory factory, int slotWidth, int slotHeight) {
 608         this.keys = keys;
 609         this.factory = factory;
 610         this.slotHeight = slotHeight;
 611         this.slotWidth = slotWidth;
 612     }
 613 
 614     private static List<CssMetaData<? extends Styleable, ?>> getWebViewClassCssMetaData() {
 615         List<CssMetaData<? extends Styleable, ?>> arrayList = null;
 616         try {
 617             Class<?> webViewCl = Class.forName("javafx.scene.web.WebView");
 618             Method staticMethod = webViewCl.getDeclaredMethod("getClassCssMetaData");
 619             arrayList = (List<CssMetaData<? extends Styleable, ?>>) staticMethod.invoke(null);
 620         } catch (Exception ex) {
 621             arrayList = new ArrayList<CssMetaData<? extends Styleable,?>>();
 622         }
 623         return arrayList;
 624     }
 625 }
--- EOF ---