functional/SceneGraphTests/src/test/scenegraph/lcd/controls/Factories.java

Print this page




  37 public enum Factories implements Factory{
  38 
  39     Button(new DefaultFactory() {
  40 
  41         @Override
  42         public Parent createControl() {
  43             return new Button("Test");
  44         }
  45     }),
  46     ToggleButton(new DefaultFactory() {
  47 
  48         @Override
  49         public Parent createControl() {
  50             return new ToggleButton("Test");
  51         }
  52     }),
  53     TextField(new DefaultFactory() {
  54 
  55         @Override
  56         public Parent createControl() {
  57             return TextFieldBuilder.create()
  58                     .text("Test")
  59                     .maxHeight(25)
  60                     .maxWidth(50)
  61                     .build();
  62         }
  63     }),
  64     Radio(new DefaultFactory() {
  65 
  66         @Override
  67         public Parent createControl() {
  68             return new RadioButton("Test");
  69         }
  70     }),
  71     CheckBox(new DefaultFactory() {
  72 
  73         @Override
  74         public Parent createControl() {
  75             return new CheckBox("Test");
  76         }
  77     }),
  78     Label(new DefaultFactory() {
  79 
  80         @Override
  81         public Parent createControl() {
  82             StackPane value = new StackPane();
  83 
  84             Label label = new Label("Test");
  85             value.getChildren().add(label);
  86 
  87             return value;
  88         }
  89     }),
  90     TitledPane(new DefaultFactory() {
  91 
  92         @Override
  93         public Parent createControl() {
  94             return TitledPaneBuilder.create()
  95                     .text("Test")
  96                     .maxWidth(200)
  97                     .maxHeight(200)
  98                     .build();
  99         }
 100     }),
 101     ToolBar(new DefaultFactory() {
 102 
 103         @Override
 104         public Parent createControl() {
 105             return new ToolBar(ButtonBuilder.create().text("Test").build());
 106         }
 107     }),
 108     Menu(new DefaultFactory() {
 109 
 110         @Override
 111         public Parent createControl() {
 112 
 113             return MenuBarBuilder.create()
 114                     .menus(
 115                         MenuBuilder.create()
 116                         .text("Text1")
 117                         .items(
 118                             MenuItemBuilder
 119                             .create()
 120                             .text("Text2")
 121                             .build())
 122                         .build())
 123                     .build();
 124         }
 125     }), ListView(new DefaultFactory() {
 126 
 127         @Override
 128         public Parent createControl() {
 129             ListView listView = new ListView();
 130             listView.getItems().addAll(FXCollections.observableArrayList((Object)"Test"));
 131             listView.setMaxHeight(150);
 132             listView.setMaxWidth(150);
 133             return listView;
 134         }
 135     }), TableView(new DefaultFactory() {
 136 
 137         @Override
 138         public Parent createControl() {
 139             TableView tableView = new TableView();
 140 //            tableView.getColumns().addAll(TableColumnBuilder.create()
 141 //                        .minWidth(50)
 142 //                        .cellValueFactory(new PropertyValueFactory("test"))
 143 //                        .text("Test")
 144 //                        .build());
 145             TableColumn tableColumn = new TableColumn("Text");
 146             tableColumn.setMinWidth(50);
 147             tableColumn.setCellValueFactory(new PropertyValueFactory("test"));
 148             tableView.getColumns().add(tableColumn);
 149             System.err.println("TableColumnFactory is temporarily modifier. Please, review once http://javafx-jira.kenai.com/browse/RT-27027 is resolved.");
 150 
 151             tableView.getItems().addAll(FXCollections.observableArrayList((Object)new TestTableItem()));
 152             tableView.setMaxHeight(150);
 153             tableView.setMaxWidth(150);
 154             return tableView;
 155         }
 156     }),
 157 
 158     Accordion(new DefaultFactory() {
 159 
 160         @Override
 161         public Parent createControl() {
 162             TitledPane expandedPane = TitledPaneBuilder.create()
 163                     .text("Test1")
 164                     .content(new Button("Test3"))
 165                     .build();
 166             return AccordionBuilder.create()
 167                     .maxHeight(200)
 168                     .maxWidth(200)
 169                     .panes(expandedPane,
 170                     TitledPaneBuilder.create()
 171                             .text("Test2")
 172                             .build())
 173                     .expandedPane(expandedPane)
 174                     .build();
 175         }
 176     }),
 177     Slider(new DefaultFactory() {
 178 
 179         @Override
 180         public Parent createControl() {
 181             Parent value = SliderBuilder.create()
 182                     .showTickLabels(true)
 183                     .showTickMarks(true)
 184                     .maxWidth(150)
 185                     .id("TestSlider")
 186                     .build();
 187             return value;
 188         }
 189     }),
 190     ProgressIndicator(new DefaultFactory() {
 191 
 192         @Override
 193         public Parent createControl() {
 194             return ProgressIndicatorBuilder.create()
 195                     .maxHeight(50)
 196                     .maxWidth(50)
 197                     .progress(0.02)
 198                     .build();
 199         }
 200     })
 201     ;
 202 
 203     private Factory factory;
 204 
 205     private Factories(Factory factory) {
 206         this.factory = factory;
 207     }
 208 
 209     public Parent createControl(boolean lcd) {
 210         return factory.createControl(lcd);
 211     }
 212 
 213 }
 214 


  37 public enum Factories implements Factory{
  38 
  39     Button(new DefaultFactory() {
  40 
  41         @Override
  42         public Parent createControl() {
  43             return new Button("Test");
  44         }
  45     }),
  46     ToggleButton(new DefaultFactory() {
  47 
  48         @Override
  49         public Parent createControl() {
  50             return new ToggleButton("Test");
  51         }
  52     }),
  53     TextField(new DefaultFactory() {
  54 
  55         @Override
  56         public Parent createControl() {
  57                         TextField temp = new TextField("Test");
  58                         temp.setMaxHeight(25);
  59                         temp.setMaxWidth(50);
  60             return temp;

  61         }
  62     }),
  63     Radio(new DefaultFactory() {
  64 
  65         @Override
  66         public Parent createControl() {
  67             return new RadioButton("Test");
  68         }
  69     }),
  70     CheckBox(new DefaultFactory() {
  71 
  72         @Override
  73         public Parent createControl() {
  74             return new CheckBox("Test");
  75         }
  76     }),
  77     Label(new DefaultFactory() {
  78 
  79         @Override
  80         public Parent createControl() {
  81             StackPane value = new StackPane();
  82 
  83             Label label = new Label("Test");
  84             value.getChildren().add(label);
  85 
  86             return value;
  87         }
  88     }),
  89     TitledPane(new DefaultFactory() {
  90 
  91         @Override
  92         public Parent createControl() {
  93                         TitledPane temp = new TitledPane();
  94                         temp.setText("Test");
  95                         temp.setMaxWidth(200);
  96                         temp.setMaxHeight(200);
  97                         return temp;
  98         }
  99     }),
 100     ToolBar(new DefaultFactory() {
 101 
 102         @Override
 103         public Parent createControl() {
 104             return new ToolBar(new Button("Test"));
 105         }
 106     }),
 107     Menu(new DefaultFactory() {
 108 
 109         @Override
 110         public Parent createControl() {
 111             Menu m = new Menu("Text1");
 112                         m.getItems().addAll(new MenuItem("Text2"));
 113             return new MenuBar(m);









 114         }
 115     }), ListView(new DefaultFactory() {
 116 
 117         @Override
 118         public Parent createControl() {
 119             ListView listView = new ListView();
 120             listView.getItems().addAll(FXCollections.observableArrayList((Object)"Test"));
 121             listView.setMaxHeight(150);
 122             listView.setMaxWidth(150);
 123             return listView;
 124         }
 125     }), TableView(new DefaultFactory() {
 126 
 127         @Override
 128         public Parent createControl() {
 129             TableView tableView = new TableView();
 130 //            tableView.getColumns().addAll(TableColumnBuilder.create()
 131 //                        .minWidth(50)
 132 //                        .cellValueFactory(new PropertyValueFactory("test"))
 133 //                        .text("Test")
 134 //                        .build());
 135             TableColumn tableColumn = new TableColumn("Text");
 136             tableColumn.setMinWidth(50);
 137             tableColumn.setCellValueFactory(new PropertyValueFactory("test"));
 138             tableView.getColumns().add(tableColumn);
 139             System.err.println("TableColumnFactory is temporarily modifier. Please, review once http://javafx-jira.kenai.com/browse/RT-27027 is resolved.");
 140 
 141             tableView.getItems().addAll(FXCollections.observableArrayList((Object)new TestTableItem()));
 142             tableView.setMaxHeight(150);
 143             tableView.setMaxWidth(150);
 144             return tableView;
 145         }
 146     }),
 147 
 148     Accordion(new DefaultFactory() {
 149 
 150         @Override
 151         public Parent createControl() {
 152             TitledPane expandedPane = new TitledPane("Test1", new Button("Test3"));
 153                         TitledPane otherPane = new TitledPane();
 154                         otherPane.setText("Test2");
 155                         Accordion temp = new Accordion(expandedPane, otherPane);
 156                         temp.setMaxHeight(200);
 157                         temp.setMaxWidth(200);
 158                         temp.setExpandedPane(expandedPane);
 159                         return temp;





 160         }
 161     }),
 162     Slider(new DefaultFactory() {
 163 
 164         @Override
 165         public Parent createControl() {
 166             Parent value = new Slider();
 167                         ((Slider)value).setShowTickLabels(true);
 168                         ((Slider)value).setShowTickMarks(true);
 169                         ((Slider)value).setMaxWidth(150);
 170                         value.setId("TestSlider");

 171             return value;
 172         }
 173     }),
 174     ProgressIndicator(new DefaultFactory() {
 175 
 176         @Override
 177         public Parent createControl() {
 178             ProgressIndicator temp = new ProgressIndicator(0.02);
 179                         temp.setMaxHeight(50);
 180                         temp.setMaxWidth(50);
 181                         return temp;

 182         }
 183     })
 184     ;
 185 
 186     private Factory factory;
 187 
 188     private Factories(Factory factory) {
 189         this.factory = factory;
 190     }
 191 
 192     public Parent createControl(boolean lcd) {
 193         return factory.createControl(lcd);
 194     }
 195 
 196 }
 197