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.css.CssMetaData;
  29 import com.sun.javafx.scene.control.skin.CellSkinBase;
  30 import com.sun.javafx.scene.control.skin.ColorPickerSkin;
  31 import com.sun.javafx.scene.control.skin.PaginationSkin;
  32 import com.sun.javafx.scene.control.skin.ProgressIndicatorSkin;
  33 import com.sun.javafx.scene.control.skin.TableColumnHeader;
  34 import com.sun.javafx.scene.control.skin.TextInputControlSkin;
  35 import com.sun.javafx.scene.control.skin.TreeCellSkin;
  36 import java.lang.reflect.Constructor;
  37 import java.lang.reflect.Method;
  38 import java.time.LocalDate;
  39 import java.time.Month;


  40 import java.util.*;
  41 import javafx.application.ConditionalFeature;
  42 import javafx.application.Platform;
  43 import javafx.beans.property.SimpleObjectProperty;
  44 import javafx.beans.value.ObservableValue;
  45 import javafx.collections.FXCollections;
  46 import javafx.collections.ObservableList;

  47 import javafx.css.Styleable;
  48 import javafx.geometry.HPos;
  49 import javafx.geometry.Pos;
  50 import javafx.scene.Node;
  51 import javafx.scene.chart.BarChart;
  52 import javafx.scene.chart.CategoryAxis;
  53 import javafx.scene.chart.LineChart;
  54 import javafx.scene.chart.NumberAxis;
  55 import javafx.scene.chart.PieChart;
  56 import javafx.scene.chart.XYChart;
  57 import javafx.scene.control.Accordion;
  58 import javafx.scene.control.Button;
  59 import javafx.scene.control.ButtonBuilder;
  60 import javafx.scene.control.CheckBox;
  61 import javafx.scene.control.CheckBoxBuilder;
  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.HyperlinkBuilder;
  69 import javafx.scene.control.Label;
  70 import javafx.scene.control.LabelBuilder;
  71 import javafx.scene.control.ListView;
  72 import javafx.scene.control.Menu;
  73 import javafx.scene.control.MenuBar;
  74 import javafx.scene.control.MenuItem;
  75 import javafx.scene.control.Pagination;
  76 import javafx.scene.control.PasswordField;
  77 import javafx.scene.control.PasswordFieldBuilder;
  78 import javafx.scene.control.ProgressBar;
  79 import javafx.scene.control.ProgressBarBuilder;
  80 import javafx.scene.control.ProgressIndicator;
  81 import javafx.scene.control.ProgressIndicatorBuilder;
  82 import javafx.scene.control.RadioButton;
  83 import javafx.scene.control.RadioButtonBuilder;
  84 import javafx.scene.control.ScrollBar;
  85 import javafx.scene.control.ScrollBarBuilder;
  86 import javafx.scene.control.ScrollPane;
  87 import javafx.scene.control.Separator;
  88 import javafx.scene.control.SeparatorBuilder;
  89 import javafx.scene.control.Slider;
  90 import javafx.scene.control.SliderBuilder;
  91 import javafx.scene.control.SplitMenuButton;
  92 import javafx.scene.control.SplitMenuButtonBuilder;
  93 import javafx.scene.control.SplitPane;
  94 import javafx.scene.control.SplitPaneBuilder;
  95 import javafx.scene.control.Tab;
  96 import javafx.scene.control.TabPane;
  97 import javafx.scene.control.TableColumn;
  98 import javafx.scene.control.TableColumn.CellDataFeatures;
  99 import javafx.scene.control.TableView;
 100 import javafx.scene.control.TextField;
 101 import javafx.scene.control.TextFieldBuilder;
 102 import javafx.scene.control.TitledPane;
 103 import javafx.scene.control.ToggleButton;
 104 import javafx.scene.control.ToggleButtonBuilder;
 105 import javafx.scene.control.ToolBar;
 106 import javafx.scene.control.TreeItem;
 107 import javafx.scene.control.TreeView;
 108 import javafx.scene.image.Image;
 109 import javafx.scene.image.ImageView;
 110 import javafx.scene.layout.FlowPane;
 111 import javafx.scene.layout.HBox;
 112 import javafx.scene.layout.StackPaneBuilder;
 113 import javafx.scene.layout.TilePane;
 114 import javafx.scene.layout.VBox;
 115 import javafx.scene.paint.Color;
 116 import javafx.scene.shape.Circle;
 117 import javafx.scene.shape.Rectangle;
 118 import javafx.scene.text.Text;
 119 import javafx.util.Callback;
 120 import javafx.util.StringConverter;
 121 import java.time.format.DateTimeFormatter;
 122 import java.time.format.DateTimeFormatterBuilder;
 123 
 124 /**
 125  *
 126  * @author sergey.lugovoy@oracle.com
 127  */
 128 public enum ControlPage {
 129     Accordions(Accordion.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 130         public Node createControl() {
 131             TitledPane pane1 = new TitledPane();
 132             pane1.setText("title 1\nLong text long text");
 133             pane1.setContent(new Rectangle(100, 40, Color.SKYBLUE));
 134             pane1.setFocusTraversable(false);
 135             TitledPane pane2 = new TitledPane();
 136             pane2.setText("title 2\nLong text long text");
 137             pane2.setContent(new Rectangle(100, 40, Color.BLUEVIOLET));
 138             Accordion acc = new Accordion();
 139             acc.getPanes().addAll(pane1, pane2);
 140             acc.setExpandedPane(pane2);
 141             pane2.setAnimated(false);
 142             pane2.setFocusTraversable(false);
 143             acc.setFocusTraversable(false);
 144             return acc;
 145         }
 146     }, 200), Buttons(Button.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 147         public Control createControl() {
 148             return ButtonBuilder.create().text("Button the first line" + "\nthe sec long line" + "\nthe third line").focusTraversable(false).graphic(new Rectangle(10, 10, Color.RED)).build();



 149         }
 150     }, 200, 100), ChoiceBoxes(ChoiceBox.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 151         public Control createControl() {
 152             return new ChoiceBox() {
 153                 {
 154                     getItems().addAll(Arrays.asList("one", "two", "three"));
 155                     this.getSelectionModel().select(0);
 156                     setFocusTraversable(false);
 157                 }
 158             };
 159         }
 160     }), CheckBoxes(CheckBox.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 161         public Control createControl() {
 162             return CheckBoxBuilder.create().text("Check box the first line" + "\nthe sec long line" + "\nthe third line").graphic(new Rectangle(20, 20, Color.web("lightblue"))).focusTraversable(false).build();



 163         }
 164     }, 200, 100), ComboBoxes(ComboBox.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 165         @Override
 166         public Control createControl() {
 167             return new ComboBox() {
 168                 {
 169                     getItems().addAll(Arrays.asList("one", "two", "three"));
 170                     getSelectionModel().select(0);
 171                     setFocusTraversable(false);
 172                 }
 173             };
 174         }
 175     }), Hyperlinks(Hyperlink.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 176         public Control createControl() {
 177             return HyperlinkBuilder.create().text("Hyperlink the first line" + "\nthe sec long line" + "\nthe third line").focusTraversable(false).graphic(new Circle(10, Color.BLUE)).build();



 178         }
 179     }, 200, 100), Labels(new ArrayList<CssMetaData<? extends Styleable, ?>>(Label.getClassCssMetaData()) {
 180         {
 181             addAll(Text.getClassCssMetaData());
 182         }
 183     }, new ControlsCSSApp.ControlFactory() {
 184         public Control createControl() {
 185             return LabelBuilder.create().text("Label the first line" + "\nthe sec longlong line" + "\nthe third line").focusTraversable(false).graphic(new Rectangle(20, 20, Color.web("lightblue"))).build();



 186         }
 187     }, 200), ListViews(ListView.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 188         public Node createControl() {
 189             ListView list = new ListView();
 190             ObservableListWrapper<String> items = new ObservableListWrapper<String>(Arrays.asList("One", "Two", "Three", "Four", "Five", "Six", "long line long line long line long line"));
 191             list.setItems(items);
 192             list.setPrefWidth(100);
 193             list.setPrefHeight(100);
 194             list.setFocusTraversable(false);
 195             return list;
 196         }
 197     }, 150), PasswordFields(PasswordField.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 198         public Control createControl() {
 199             return PasswordFieldBuilder.create().promptText("Password box the first line" + "\nthe sec long line" + "\nthe third line").focusTraversable(false).build();



 200         }
 201     }), PressedToggleButtons(ToggleButton.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 202         public Control createControl() {
 203             return ToggleButtonBuilder.create().selected(true).text("Button the first line" + "\nthe sec long line" + "\nthe third line").focusTraversable(false).graphic(new Rectangle(10, 10, Color.RED)).build();




 204         }
 205     }, 200, 120), ProgressIndicators(new ArrayList<CssMetaData<? extends Styleable, ?>>(ProgressIndicator.getClassCssMetaData()) {
 206         {
 207             addAll(ProgressIndicatorSkin.getClassCssMetaData());
 208         }
 209     }, new ControlsCSSApp.ControlFactory() {
 210         public Node createControl() {
 211             return ProgressIndicatorBuilder.create().progress(0.85).prefHeight(100).prefWidth(100).focusTraversable(false).build();



 212         }
 213     }), ProgressBars(ProgressBar.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 214         public Node createControl() {
 215             return ProgressBarBuilder.create().progress(0.25).focusTraversable(false).build();


 216         }
 217     }, 200, 100), RadioButtons(RadioButton.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 218         public Control createControl() {
 219             return RadioButtonBuilder.create().text("Radio the first line" + "\nthe sec long line" + "\nthe third line").graphic(new Rectangle(20, 20, Color.web("lightblue"))).focusTraversable(false).build();



 220         }
 221     }, 200, 100), TextFields(new ArrayList<CssMetaData<? extends Styleable, ?>>(TextField.getClassCssMetaData()) {
 222         {
 223             addAll(TextInputControlSkin.getClassCssMetaData());
 224         }
 225     }, new ControlsCSSApp.ControlFactory() {
 226         public Control createControl() {
 227             return TextFieldBuilder.create().text("Text box the first line" + "\nthe sec long line" + "\nthe third line").focusTraversable(false).build();


 228         }
 229     }), Sliders(Slider.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 230         public Control createControl() {
 231             return SliderBuilder.create().min(0).max(100).value(20).focusTraversable(false).build();





 232         }
 233     }, 200), Separators(Separator.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 234         public Control createControl() {
 235             Separator sep = SeparatorBuilder.create().halignment(HPos.CENTER).build();

 236             sep.setPrefWidth(80);
 237             return sep;
 238         }
 239     }, 150), ScrollBars(ScrollBar.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 240         public Control createControl() {
 241             return ScrollBarBuilder.create().value(45).min(0).max(100).focusTraversable(false).build();





 242         }
 243     }, 150), ScrollPanes(ScrollPane.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 244         public Node createControl() {
 245             ScrollPane pane = new ScrollPane();
 246             HBox hbox = new HBox(30);
 247             VBox vbox1 = new VBox(10);
 248             vbox1.getChildren().addAll(new Label("one"), new Button("two"), new CheckBox("three"), new RadioButton("four"), new Label("five"));
 249             VBox vbox2 = new VBox(10);
 250             vbox2.getChildren().addAll(new Label("one"), new Button("two"), new CheckBox("three"), new RadioButton("four"), new Label("five"));
 251             hbox.getChildren().addAll(vbox1, vbox2);
 252             pane.setContent(hbox);
 253             pane.setFocusTraversable(false);
 254             return pane;
 255         }
 256     }, 150), UnPressedToggleButtons(ToggleButton.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 257         public Control createControl() {
 258             return ToggleButtonBuilder.create().selected(false).text("Button the first line" + "\nthe sec long line" + "\nthe third line").focusTraversable(false).graphic(new Rectangle(10, 10, Color.RED)).build();




 259         }
 260     }, 200, 120), Toolbars(ToolBar.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 261         public Node createControl() {
 262             ToolBar toolbar = new ToolBar();
 263             toolbar.getItems().addAll(new Button("One"), new Button("Two"), new Separator(), SplitMenuButtonBuilder.create().text("three").build());


 264             toolbar.setFocusTraversable(false);
 265             return toolbar;
 266         }
 267     }, 250, 150), Menubars(MenuBar.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 268         public Node createControl() {
 269             MenuBar menubar = new MenuBar();
 270             Menu firstMenu = new Menu("File");
 271             MenuItem firstMenuFirstItem = new MenuItem("Save");
 272             MenuItem firstMenuSecondItem = new MenuItem("Open");
 273             MenuItem firstMenuThirdItem = new MenuItem("Exit");
 274             firstMenu.getItems().addAll(firstMenuFirstItem, firstMenuSecondItem, firstMenuThirdItem);
 275             Menu secondMenu = new Menu("Edit");
 276             MenuItem secondMenuFirstItem = new MenuItem("Undo");
 277             MenuItem secondMenuSecondItem = new MenuItem("Cut");
 278             MenuItem secondMenuThirdItem = new MenuItem("Copy");
 279             secondMenu.getItems().addAll(secondMenuFirstItem, secondMenuSecondItem, secondMenuThirdItem);
 280             Menu thirdMenu = new Menu("Help");
 281             MenuItem thirdMenuFirstItem = new MenuItem("Help Contents");
 282             MenuItem thirdMenuSecondItem = new MenuItem("About");
 283             thirdMenu.getItems().addAll(thirdMenuFirstItem, thirdMenuSecondItem);
 284             menubar.getMenus().addAll(firstMenu, secondMenu, thirdMenu);
 285             menubar.setFocusTraversable(false);
 286             return menubar;
 287         }
 288     }, 250, 150), SplitMenuButtons(SplitMenuButton.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 289         public Node createControl() {
 290             SplitMenuButton smb = SplitMenuButtonBuilder.create().text("Split box the first line" + "\nthe sec long line" + "\nthe third line").items(new MenuItem("Split box the first line" + "\nthe sec long line" + "\nthe third line", new Rectangle(10, 10, Color.BLUE))).graphic(new Rectangle(10, 10, Color.RED)).build();


 291             smb.setFocusTraversable(false);
 292             return smb;
 293         }
 294     }, 200, 120), TabPanes(TabPane.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 295         public Node createControl() {
 296             TabPane pane = new TabPane();
 297             Tab tab = new Tab();
 298             tab.setText("tab 1");
 299             HBox content1 = new HBox(10);
 300             content1.getChildren().addAll(new Button("Button"), new Label("Label"), new Rectangle(40, 40, Color.TOMATO));
 301             tab.setContent(content1);
 302             Tab tab2 = new Tab();
 303             tab2.setText("tab 2");
 304             tab2.setContent(new Circle(40, Color.RED));
 305             pane.getTabs().addAll(tab, tab2);
 306             pane.setFocusTraversable(false);
 307             return pane;
 308         }
 309     }, 200), TitledPanes(TitledPane.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 310         public Node createControl() {
 311             TitledPane tpane = new TitledPane();
 312             tpane.setText("Title");
 313             VBox content = new VBox(5);
 314             content.getChildren().addAll(new Label("Label"), new Button("Button"), new CheckBox("Check box"));
 315             tpane.setContent(content);
 316             tpane.setAnimated(false);
 317             tpane.setFocusTraversable(false);
 318             return tpane;
 319         }
 320     }, 150), TableViews(new ArrayList<CssMetaData<? extends Styleable, ?>>(TableView.getClassCssMetaData()) {
 321         {
 322             addAll(CellSkinBase.getClassCssMetaData());
 323             addAll(TableColumnHeader.getClassCssMetaData());
 324         }
 325     }, new ControlsCSSApp.ControlFactory() {
 326         public Node createControl() {
 327             ObservableList<ControlsCSSApp.Person> items = FXCollections.observableArrayList();
 328             for (int i = 0; i < 10; i++) {
 329                 items.add(new ControlsCSSApp.Person("name " + i, "surname " + i));
 330             }
 331             TableColumn<ControlsCSSApp.Person, Node> column1 = new TableColumn<ControlsCSSApp.Person, Node>("First Name");
 332             column1.setCellValueFactory(new Callback<CellDataFeatures<ControlsCSSApp.Person, Node>, ObservableValue<Node>>() {
 333                 @Override
 334                 public ObservableValue<Node> call(final CellDataFeatures<ControlsCSSApp.Person, Node> p) {
 335                     SimpleObjectProperty<Node> text = new SimpleObjectProperty<Node>();
 336                     text.setValue(new Label(p.getValue().getFirstName()));
 337                     return text;
 338                 }
 339             });
 340             TableColumn<ControlsCSSApp.Person, Node> column2 = new TableColumn<ControlsCSSApp.Person, Node>("Last Name");
 341             column2.setCellValueFactory(new Callback<CellDataFeatures<ControlsCSSApp.Person, Node>, ObservableValue<Node>>() {
 342                 @Override
 343                 public ObservableValue<Node> call(final CellDataFeatures<ControlsCSSApp.Person, Node> p) {
 344                     SimpleObjectProperty<Node> text = new SimpleObjectProperty<Node>();
 345                     text.setValue(new Label(p.getValue().getLastName()));
 346                     return text;
 347                 }
 348             });
 349             TableView<ControlsCSSApp.Person> table = new TableView<ControlsCSSApp.Person>(items);
 350             table.getColumns().setAll(column1, column2);
 351             table.setPrefHeight(200);
 352             table.setFocusTraversable(false);
 353             return table;
 354         }
 355     }, 200, 250), TreeViews(new ArrayList<CssMetaData<? extends Styleable, ?>>(TableView.getClassCssMetaData()) {
 356         {
 357             addAll(TreeCellSkin.getClassCssMetaData());
 358         }
 359     }, new ControlsCSSApp.ControlFactory() {
 360         public Node createControl() {
 361             TreeItem<String> root = new TreeItem<String>("ROOT", new Rectangle(20, 20, Color.CHOCOLATE));
 362             root.setExpanded(true);
 363             TreeItem<String> firstBrunch = new TreeItem<String>("brunch 1");
 364             firstBrunch.setExpanded(true);
 365             firstBrunch.getChildren().addAll(new TreeItem<String>("first item"), new TreeItem<String>("second item", new Rectangle(20, 20, Color.DARKGREY)));
 366             root.getChildren().addAll(firstBrunch);
 367             TreeItem<String> secondBrunch = new TreeItem<String>("brunch 2");
 368             secondBrunch.getChildren().addAll(new TreeItem<String>("first item"), new TreeItem<String>("second item", new Rectangle(20, 20, Color.DARKGREY)));
 369             root.getChildren().addAll(secondBrunch);
 370             TreeView tree = new TreeView(root);
 371             tree.setFocusTraversable(false);
 372             tree.setMinSize(147, 127);
 373             tree.setPrefSize(160, 140);
 374             return tree;
 375         }
 376     }, 200, 300), SplitPanes(SplitPane.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 377         public Node createControl() {
 378             SplitPane pane = SplitPaneBuilder.create().items(StackPaneBuilder.create().children(new Rectangle(40, 40, Color.WHITESMOKE)).build(), StackPaneBuilder.create().children(new Rectangle(40, 40, Color.BLUE)).build(), StackPaneBuilder.create().children(new Rectangle(40, 40, Color.RED)).build()).prefWidth(150).prefHeight(150).build();




 379             pane.setDividerPositions(0.33, 0.67);
 380             pane.setFocusTraversable(false);
 381             return pane;
 382         }
 383     }, 250), Paginations(new ArrayList<CssMetaData<? extends Styleable, ?>>(Pagination.getClassCssMetaData()) {
 384         {
 385             addAll(PaginationSkin.getClassCssMetaData());
 386         }
 387     }, new ControlsCSSApp.ControlFactory() {
 388         public Node createControl() {
 389             Pagination node = new Pagination(47);
 390             node.setMaxPageIndicatorCount(5);
 391             node.getStyleClass().add(Pagination.STYLE_CLASS_BULLET);
 392             return node;
 393         }
 394     }, 350, 150), XYChars(new ArrayList<CssMetaData<? extends Styleable, ?>>(LineChart.getClassCssMetaData()) {
 395         {
 396             addAll(NumberAxis.getClassCssMetaData());
 397         }
 398     }, new ControlsCSSApp.ControlFactory() {
 399         public Node createControl() {
 400             XYChart node = new LineChart(new NumberAxis(0, 4, 1), new NumberAxis(0, 4, 1));
 401             node.setPrefSize(200, 200);
 402             XYChart.Series series = new XYChart.Series();
 403             series.getData().add(new XYChart.Data(0d, 0d));
 404             series.getData().add(new XYChart.Data(4d, 4d));
 405             XYChart.Series series2 = new XYChart.Series();
 406             series2.getData().add(new XYChart.Data(0d, 0d));
 407             series2.getData().add(new XYChart.Data(1d, 3d));
 408             XYChart.Series series3 = new XYChart.Series();
 409             series3.getData().add(new XYChart.Data(0d, 0d));
 410             series3.getData().add(new XYChart.Data(2d, 4d));
 411             node.getData().addAll(series, series2, series3);
 412             return node;
 413         }
 414     }, 300, 300), TilePanes(TilePane.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 415         public Node createControl() {
 416             TilePane tile = new TilePane();
 417             tile.setPrefSize(150, 150);
 418             tile.setTileAlignment(Pos.CENTER_LEFT);
 419             for (int i = 0; i < 15; i++) {
 420                 tile.getChildren().add(new Rectangle(20, 20, (i % 2 == 0) ? Color.RED : Color.BLUE));
 421             }
 422             return tile;
 423         }
 424     }, 200, 200), VBoxs(VBox.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 425         @Override
 426         public Node createControl() {
 427             VBox node = new VBox(10);
 428             node.setMinSize(150, 150);
 429             for (int i = 0; i < 4; i++) {
 430                 node.getChildren().add(new Rectangle(20, 20, (i % 2 == 0) ? Color.RED : Color.BLUE));
 431             }
 432             return node;
 433         }
 434     }, 200, 200), BarCharts(new ArrayList<CssMetaData<? extends Styleable, ?>>(BarChart.getClassCssMetaData()) {
 435         {
 436             addAll(CategoryAxis.getClassCssMetaData());
 437         }
 438     }, new ControlsCSSApp.ControlFactory() {
 439         public Node createControl() {
 440             CategoryAxis cAxis = new CategoryAxis();
 441             NumberAxis nAxis = new NumberAxis(0, 5, 1);
 442             BarChart node = new BarChart(cAxis, nAxis);
 443             XYChart.Series series = new XYChart.Series();
 444             series.getData().add(new XYChart.Data("1", 2));
 445             XYChart.Series series1 = new XYChart.Series();
 446             series1.getData().add(new XYChart.Data("2", 3));
 447             XYChart.Series series2 = new XYChart.Series();
 448             series2.getData().add(new XYChart.Data("2", 5));
 449             node.getData().addAll(series, series1, series2);
 450             node.setMaxSize(180, 180);
 451             return node;
 452         }
 453     }, 200, 200), ColorPickers(ColorPickerSkin.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 454         public Node createControl() {
 455             ColorPicker node = new ColorPicker();
 456             node.setPrefSize(100, 100);
 457             node.setStyle("-fx-color-label-visible:false;");
 458             return node;
 459         }
 460     }, 200, 200), FlowPanes(FlowPane.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 461         public Node createControl() {
 462             FlowPane node = new FlowPane();
 463             for (int i = 0; i < 6; i++) {
 464                 node.getChildren().add(new Rectangle(20, 20, (i % 2 == 0) ? Color.RED : Color.BLUE));
 465             }
 466             node.setColumnHalignment(HPos.CENTER);
 467             node.setPrefSize(100, 100);
 468             return node;
 469         }
 470     }, 200, 200), PieCharts(PieChart.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 471         public Node createControl() {
 472             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));
 473             PieChart chart = new PieChart(pieChartData);
 474             chart.setMaxSize(150, 150);
 475             return chart;
 476         }
 477     }, 300, 300), WebViews(getWebViewClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 478         public Node createControl() {
 479             Node node = null;
 480             try {
 481                 Class<?> webViewCl = Class.forName("javafx.scene.web.WebView");
 482                 Constructor<?> constructor = webViewCl.getConstructor();
 483                 constructor.setAccessible(true);
 484                 Object args = null;
 485                 node = (Node) constructor.newInstance();
 486                 Method setViewport = webViewCl.getDeclaredMethod("setPrefSize", double.class, double.class);
 487                 setViewport.invoke(node, 150, 150);
 488                 Method getEngine = webViewCl.getDeclaredMethod("getEngine");
 489                 Object engine = getEngine.invoke(node);
 490                 Method load = engine.getClass().getDeclaredMethod("load", String.class);
 491                 load.invoke(engine, ControlsCSSApp.class.getResource("/test/css/resources/index.html").toExternalForm());
 492             } catch (Exception ignored) {
 493             }
 494             return node;
 495         }
 496     }, 300, 300), HBoxs(HBox.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 497         public Node createControl() {
 498             HBox node = new HBox(10);
 499             node.setMinSize(150, 150);
 500             for (int i = 0; i < 4; i++) {
 501                 node.getChildren().add(new Rectangle(20, 20, (i % 2 == 0) ? Color.RED : Color.BLUE));
 502             }
 503             return node;
 504         }
 505     }, 300, 300), ImageViews(ImageView.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 506         public Node createControl() {
 507             ImageView view = new ImageView(new Image(ControlsCSSApp.class.getResource("/test/css/resources/placeholder.png").toExternalForm()));
 508             return view;
 509         }
 510     }, 300, 300), DatePickers(DatePicker.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 511         public Node createControl() {
 512             DatePicker picker = new DatePicker();
 513             picker.setValue(LocalDate.of(2042, Month.MAY, 27));
 514             picker.setConverter(new StringConverter<LocalDate>() {
 515 
 516                 DateTimeFormatter df = new DateTimeFormatterBuilder().parseLenient()
 517                         .appendPattern("M/dd/YYYY")
 518                         .toFormatter(Locale.ENGLISH)
 519                         .withLocale(Locale.ENGLISH);
 520 
 521                 @Override
 522                 public String toString(LocalDate localDate) {
 523                     return df.format(localDate);
 524                 }
 525 
 526                 @Override
 527                 public LocalDate fromString(String s) {
 528                     return LocalDate.parse(s, df);
 529                 }
 530             });
 531             //picker.setMinSize(100, 30);
 532             return picker;
 533         }
 534     }, 300, 300),
 535     Texts(Text.getClassCssMetaData(), new ControlsCSSApp.ControlFactory() {
 536         public Node createControl() {
 537             Text node = new Text("1234567890");
 538             return node;
 539         }
 540     }, 150, 150);
 541     public static final int DEFAULT_SLOTSIZE = 150;
 542     public static final int INNER_PANE_SHIFT = 20;
 543     public List<CssMetaData<? extends Styleable, ?>> keys;
 544     public ControlsCSSApp.ControlFactory factory;
 545     public int slotHeight;
 546     public int slotWidth;
 547 
 548     public static final String packageName = "functional";
 549 
 550     ControlPage(List<CssMetaData<? extends Styleable, ?>> keys, ControlsCSSApp.ControlFactory factory) {
 551         this(keys, factory, DEFAULT_SLOTSIZE);
 552     }
 553 
 554     ControlPage(List<CssMetaData<? extends Styleable, ?>> keys, ControlsCSSApp.ControlFactory factory, int slotSize) {
 555         this(keys, factory, slotSize, slotSize);
 556     }
 557 
 558     /**
 559      * Returns filtered enumeration values, this is required to support embedded
 560      * execution, cause currently JavaFX Embedded does not contain Web component
 561      * @return filtered enumeration values
 562      */
 563     public static ControlPage[] filteredValues(){
 564         Set<ControlPage> controls = EnumSet.allOf(ControlPage.class);
 565         if(!Platform.isSupported(ConditionalFeature.WEB))
 566             controls.remove(ControlPage.WebViews);
 567         return controls.toArray(new ControlPage[]{});
 568     }
 569 
 570     private ControlPage(List<CssMetaData<? extends Styleable, ?>> keys, ControlsCSSApp.ControlFactory factory, int slotWidth, int slotHeight) {
 571         this.keys = keys;
 572         this.factory = factory;
 573         this.slotHeight = slotHeight;
 574         this.slotWidth = slotWidth;
 575     }
 576 
 577     private static List<CssMetaData<? extends Styleable, ?>> getWebViewClassCssMetaData() {
 578         List<CssMetaData<? extends Styleable, ?>> arrayList = null;
 579         try {
 580             Class<?> webViewCl = Class.forName("javafx.scene.web.WebView");
 581             Method staticMethod = webViewCl.getDeclaredMethod("getClassCssMetaData");
 582             arrayList = (List<CssMetaData<? extends Styleable, ?>>) staticMethod.invoke(null);
 583         } catch (Exception ex) {
 584             arrayList = new ArrayList<CssMetaData<? extends Styleable,?>>();
 585         }
 586         return arrayList;
 587     }
 588 }
--- EOF ---