< prev index next >

functional/SceneGraphTests/src/test/scenegraph/lcd/transparency/TransparencyLCDTextTestApp.java

Print this page




  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  */
  24 package test.scenegraph.lcd.transparency;
  25 
  26 import javafx.beans.value.ChangeListener;
  27 import javafx.beans.value.ObservableValue;
  28 import javafx.collections.FXCollections;
  29 import javafx.event.EventHandler;
  30 import javafx.geometry.Insets;
  31 import javafx.geometry.Pos;
  32 import javafx.scene.Parent;
  33 import javafx.scene.Scene;
  34 import javafx.scene.control.Button;
  35 import javafx.scene.control.ButtonBuilder;
  36 import javafx.scene.control.ChoiceBox;
  37 import javafx.scene.input.MouseEvent;
  38 import javafx.scene.layout.HBoxBuilder;
  39 import javafx.scene.layout.Pane;
  40 import javafx.scene.layout.StackPaneBuilder;
  41 import javafx.scene.layout.VBoxBuilder;
  42 import javafx.scene.paint.Color;
  43 import javafx.scene.shape.Circle;
  44 import javafx.scene.shape.CircleBuilder;
  45 import javafx.scene.text.Text;
  46 import test.javaclient.shared.InteroperabilityApp;
  47 import test.javaclient.shared.Utils;
  48 
  49 /**
  50  *
  51  * @author Alexander Petrov
  52  */
  53 public class TransparencyLCDTextTestApp extends InteroperabilityApp {
  54     static {
  55         System.setProperty("prism.lcdtext", "true");
  56     }
  57 
  58     public static final String APPLY_BUTTON_ID = "applyButton";
  59     public static final String ACTION_BUTTON_ID = "actionButton";
  60     public static final String RIGHT_PANE_ID = "rightPane";
  61     public static final String APPLY_INDICATOR_ID = "applyIndicator";
  62     public static final String ACTION_INDICATOR_ID = "actionIndicator";
  63 
  64     public static Factory testingFactory = null;


  72     private Circle actionIndicator;
  73 
  74     /**
  75      * @param args the command line arguments
  76      */
  77     public static void main(String[] args) {
  78         Utils.launch(TransparencyLCDTextTestApp.class, args);
  79     }
  80 
  81     private Parent createGUI(){
  82         factoryChoicer = new ChoiceBox(
  83                 FXCollections.observableArrayList((Factory[]) Factories.values()));
  84         factoryChoicer.setMinWidth(200);
  85         factoryChoicer.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Factory>() {
  86 
  87             public void changed(ObservableValue<? extends Factory> ov, Factory t, Factory t1) {
  88                 apply();
  89             }
  90         });
  91 
  92         applyIndicator = CircleBuilder.create()
  93                 .id(APPLY_INDICATOR_ID)
  94                 .radius(5)
  95                 .fill(Color.RED)
  96                 .build();
  97 
  98         actionIndicator = CircleBuilder.create()
  99                 .id(ACTION_INDICATOR_ID)
 100                 .radius(5)
 101                 .fill(Color.RED)
 102                 .build();
 103 
 104         Button applyButton = ButtonBuilder.create()
 105                 .id(APPLY_BUTTON_ID)
 106                 .text("Apply")
 107                 .onMouseClicked(new EventHandler<MouseEvent>() {
 108                     public void handle(MouseEvent t) {
 109                         if(testingFactory == null){
 110                             factoryChoicer.getSelectionModel().selectNext();
 111                         } else {
 112                             factoryChoicer.getSelectionModel().select(TransparencyLCDTextTestApp.testingFactory);
 113                         }
 114                         applyIndicator.setFill(Color.GREEN);
 115                     }
 116                 })
 117                 .build();
 118 
 119         Button actionButton = ButtonBuilder.create()
 120                 .id(ACTION_BUTTON_ID)
 121                 .text("Action")
 122                 .onMouseClicked(new EventHandler<MouseEvent>() {
 123                     public void handle(MouseEvent t) {
 124                         Factory currentFactory = TransparencyLCDTextTestApp.this.
 125                                 factoryChoicer.getSelectionModel().getSelectedItem();
 126 
 127                         currentFactory.action(TransparencyLCDTextTestApp.this.rightPane.getChildren().get(0));
 128 
 129                         actionIndicator.setFill(Color.GREEN);
 130                     }
 131                 })
 132                 .build();
 133 
 134         //Create panes for testing;
 135 
 136 
 137         rightPane = StackPaneBuilder.create()
 138                 .id(RIGHT_PANE_ID)
 139                 .alignment(Pos.CENTER)
 140                 .minHeight(450)
 141                 .minWidth(300)
 142                 .build();
 143 
 144         //Create root pane.
 145         return VBoxBuilder.create()
 146                 .id("root")
 147                 .children(
 148                     HBoxBuilder.create()
 149                         .padding(new Insets(10))
 150                         .spacing(10)
 151                         .id("toolsPane")
 152                         .alignment(Pos.CENTER)
 153                         .children(factoryChoicer, actionButton, applyButton)
 154                         .build(),
 155                     HBoxBuilder.create()
 156                         .padding(new Insets(10))
 157                         .spacing(10)
 158                         .alignment(Pos.CENTER)
 159                         .children(
 160                             new Text("Apply"),
 161                             applyIndicator,
 162                             new Text("Action"),
 163                             actionIndicator)
 164                         .build(),
 165                     HBoxBuilder.create()
 166                         .id("testPane")
 167                         .alignment(Pos.CENTER)
 168                         .children(rightPane)
 169                         .build())
 170                 .build();
 171     }
 172 
 173     private void apply() {
 174         this.rightPane.getChildren().clear();
 175 
 176         Factory currentFactory =
 177                 this.factoryChoicer.getSelectionModel().getSelectedItem();
 178 
 179         this.rightPane.getChildren().add(currentFactory.createNode(true));
 180 
 181     }
 182 
 183     @Override
 184     protected Scene getScene() {
 185         return new Scene(createGUI(), 600, 540);
 186     }
 187 }


  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  */
  24 package test.scenegraph.lcd.transparency;
  25 
  26 import javafx.beans.value.ChangeListener;
  27 import javafx.beans.value.ObservableValue;
  28 import javafx.collections.FXCollections;
  29 import javafx.event.EventHandler;
  30 import javafx.geometry.Insets;
  31 import javafx.geometry.Pos;
  32 import javafx.scene.Parent;
  33 import javafx.scene.Scene;
  34 import javafx.scene.control.Button;

  35 import javafx.scene.control.ChoiceBox;
  36 import javafx.scene.input.MouseEvent;
  37 import javafx.scene.layout.HBox;
  38 import javafx.scene.layout.Pane;
  39 import javafx.scene.layout.StackPane;
  40 import javafx.scene.layout.VBox;
  41 import javafx.scene.paint.Color;
  42 import javafx.scene.shape.Circle;

  43 import javafx.scene.text.Text;
  44 import test.javaclient.shared.InteroperabilityApp;
  45 import test.javaclient.shared.Utils;
  46 
  47 /**
  48  *
  49  * @author Alexander Petrov
  50  */
  51 public class TransparencyLCDTextTestApp extends InteroperabilityApp {
  52     static {
  53         System.setProperty("prism.lcdtext", "true");
  54     }
  55 
  56     public static final String APPLY_BUTTON_ID = "applyButton";
  57     public static final String ACTION_BUTTON_ID = "actionButton";
  58     public static final String RIGHT_PANE_ID = "rightPane";
  59     public static final String APPLY_INDICATOR_ID = "applyIndicator";
  60     public static final String ACTION_INDICATOR_ID = "actionIndicator";
  61 
  62     public static Factory testingFactory = null;


  70     private Circle actionIndicator;
  71 
  72     /**
  73      * @param args the command line arguments
  74      */
  75     public static void main(String[] args) {
  76         Utils.launch(TransparencyLCDTextTestApp.class, args);
  77     }
  78 
  79     private Parent createGUI(){
  80         factoryChoicer = new ChoiceBox(
  81                 FXCollections.observableArrayList((Factory[]) Factories.values()));
  82         factoryChoicer.setMinWidth(200);
  83         factoryChoicer.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Factory>() {
  84 
  85             public void changed(ObservableValue<? extends Factory> ov, Factory t, Factory t1) {
  86                 apply();
  87             }
  88         });
  89 
  90         applyIndicator = new Circle(5, Color.RED);
  91         applyIndicator.setId(APPLY_INDICATOR_ID);
  92 
  93         actionIndicator = new Circle(5, Color.RED);
  94         actionIndicator.setId(ACTION_INDICATOR_ID);
  95 
  96         Button applyButton = new Button("Apply");
  97         applyButton.setId(APPLY_BUTTON_ID);
  98         applyButton.setOnMouseClicked(new EventHandler<MouseEvent>() {







  99             public void handle(MouseEvent t) {
 100                 if(testingFactory == null){
 101                     factoryChoicer.getSelectionModel().selectNext();
 102                 } else {
 103                     factoryChoicer.getSelectionModel().select(TransparencyLCDTextTestApp.testingFactory);
 104                 }
 105                 applyIndicator.setFill(Color.GREEN);
 106             }
 107         });

 108 
 109         Button actionButton = new Button("Action");
 110         actionButton.setId(ACTION_BUTTON_ID);
 111         actionButton.setOnMouseClicked(new EventHandler<MouseEvent>() {

 112             public void handle(MouseEvent t) {
 113                 Factory currentFactory = TransparencyLCDTextTestApp.this.
 114                         factoryChoicer.getSelectionModel().getSelectedItem();
 115 
 116                 currentFactory.action(TransparencyLCDTextTestApp.this.rightPane.getChildren().get(0));
 117 
 118                 actionIndicator.setFill(Color.GREEN);
 119             }
 120         });

 121 
 122         //Create panes for testing;
 123         rightPane = new StackPane();
 124         rightPane.setId(RIGHT_PANE_ID);
 125         ((StackPane)rightPane).setAlignment(Pos.CENTER);
 126         rightPane.setMinHeight(450);
 127         rightPane.setMinWidth(300);



 128 
 129         //Create root pane.
 130         VBox root = new VBox();
 131         root.setId("root");
 132         HBox tools = new HBox();
 133         tools.setId("toolsPane");
 134         tools.setPadding(new Insets(10));
 135         tools.setSpacing(10);
 136         tools.setAlignment(Pos.CENTER);
 137         tools.getChildren().addAll(factoryChoicer, actionButton, applyButton);
 138         HBox secondone = new HBox(new Text("Apply"), applyIndicator, new Text("Action"), actionIndicator);
 139         secondone.setPadding(new Insets(10));
 140         secondone.setSpacing(10);
 141         HBox testPane = new HBox(rightPane);
 142         testPane.setId("testPane");
 143         testPane.setAlignment(Pos.CENTER);
 144         root.getChildren().addAll(tools, secondone, testPane);
 145         return root;










 146     }
 147 
 148     private void apply() {
 149         this.rightPane.getChildren().clear();
 150 
 151         Factory currentFactory =
 152                 this.factoryChoicer.getSelectionModel().getSelectedItem();
 153 
 154         this.rightPane.getChildren().add(currentFactory.createNode(true));
 155 
 156     }
 157 
 158     @Override
 159     protected Scene getScene() {
 160         return new Scene(createGUI(), 600, 540);
 161     }
 162 }
< prev index next >