changeset 9:4823e45e8a2c

add sample
author e095732
date Tue, 29 Jan 2013 10:29:28 +0900
parents b973de8b6785
children bf24d5200770
files src/alice/test/topology/aquarium/fx/aquarium.fxml src/example/CubeSample.java src/example/Hello.fxml src/example/HelloFXML.java src/example/HelloWorld.class src/example/HelloWorld.java src/example/LoginDemo.fxml src/example/LoginDemo.java src/example/LoginDemo2.java src/example/LoginFormController.java
diffstat 10 files changed, 419 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/alice/test/topology/aquarium/fx/aquarium.fxml	Tue Jan 29 10:29:28 2013 +0900
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<?import java.lang.*?>
+<?import java.util.*?>
+<?import javafx.scene.control.*?>
+<?import javafx.scene.image.*?>
+<?import javafx.scene.layout.*?>
+<?import javafx.scene.paint.*?>
+<?import javafx.scene.shape.*?>
+
+<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="800.0" xmlns:fx="http://javafx.com/fxml" fx:controller="alice.test.topology.aquarium.fx.AquariumController">
+  <children>
+    <TextField fx:id="text" layoutX="14.0" layoutY="564.0" minWidth="1.0" onKeyPressed="#PressedKey3" prefWidth="1.0" />
+    <ImageView fx:id="image" fitHeight="75.0" fitWidth="75.0" layoutX="245.0" layoutY="42.0" pickOnBounds="true" preserveRatio="true" />
+  </children>
+</AnchorPane>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/example/CubeSample.java	Tue Jan 29 10:29:28 2013 +0900
@@ -0,0 +1,155 @@
+package example;
+
+/**
+ * Copyright (c) 2008, 2012 Oracle and/or its affiliates.
+ * All rights reserved. Use is subject to license terms.
+ */
+import javafx.scene.transform.Rotate;
+import javafx.scene.PerspectiveCamera;
+import javafx.scene.transform.Translate;
+import javafx.application.Application;
+import javafx.scene.Group;
+import javafx.scene.Scene;
+import javafx.stage.Stage;
+import javafx.animation.Animation;
+import javafx.animation.KeyFrame;
+import javafx.animation.KeyValue;
+import javafx.animation.Timeline;
+import javafx.scene.Node;
+import javafx.scene.paint.Color;
+import javafx.scene.shape.RectangleBuilder;
+import javafx.util.Duration;
+
+/**
+ * A sample that demonstrates an animated rotation of 3D cubes. When the
+ * application runs in standalone mode, the scene must be constructed with
+ * the depthBuffer argument set to true, and the root node must have depthTest
+ * set to true.
+ *
+ * @see javafx.scene.transform.Rotate
+ * @see javafx.scene.paint.Color
+ * @see javafx.scene.shape.RectangleBuilder
+ */
+public class CubeSample extends Application {
+
+    private Timeline animation;
+
+    private void init(Stage primaryStage) {
+        Group root = new Group();
+        primaryStage.setResizable(false);
+        primaryStage.setScene(new Scene(root, 400,150,true));
+        primaryStage.getScene().setCamera(new PerspectiveCamera());
+        root.getTransforms().addAll(
+            new Translate(400 / 2, 150 / 2),
+            new Rotate(180, Rotate.X_AXIS)
+        );
+        root.getChildren().add(create3dContent());
+    }
+
+    public Node create3dContent() {
+        Cube c = new Cube(50,Color.RED,1);
+        c.rx.setAngle(45);
+        c.ry.setAngle(45);
+        Cube c2 = new Cube(50,Color.GREEN,1);
+        c2.setTranslateX(100);
+        c2.rx.setAngle(45);
+        c2.ry.setAngle(45);
+        Cube c3 = new Cube(50,Color.ORANGE,1);
+        c3.setTranslateX(-100);
+        c3.rx.setAngle(45);
+        c3.ry.setAngle(45);
+
+        animation = new Timeline();
+        animation.getKeyFrames().addAll(
+                new KeyFrame(Duration.ZERO,
+                        new KeyValue(c.ry.angleProperty(), 0d),
+                        new KeyValue(c2.rx.angleProperty(), 0d),
+                        new KeyValue(c3.rz.angleProperty(), 0d)
+                ),
+                new KeyFrame(Duration.seconds(1),
+                        new KeyValue(c.ry.angleProperty(), 360d),
+                        new KeyValue(c2.rx.angleProperty(), 360d),
+                        new KeyValue(c3.rz.angleProperty(), 360d)
+                ));
+        animation.setCycleCount(Animation.INDEFINITE);
+
+        return new Group(c,c2,c3);
+    }
+
+    public void play() {
+        animation.play();
+    }
+
+    @Override public void stop() {
+        animation.pause();
+    }
+
+    public class Cube extends Group {
+        final Rotate rx = new Rotate(0,Rotate.X_AXIS);
+        final Rotate ry = new Rotate(0,Rotate.Y_AXIS);
+        final Rotate rz = new Rotate(0,Rotate.Z_AXIS);
+        public Cube(double size, Color color, double shade) {
+            getTransforms().addAll(rz, ry, rx);
+            getChildren().addAll(
+                RectangleBuilder.create() // back face
+                    .width(size).height(size)
+                    .fill(color.deriveColor(0.0, 1.0, (1 - 0.5*shade), 1.0))
+                    .translateX(-0.5*size)
+                    .translateY(-0.5*size)
+                    .translateZ(0.5*size)
+                    .build(),
+                RectangleBuilder.create() // bottom face
+                    .width(size).height(size)
+                    .fill(color.deriveColor(0.0, 1.0, (1 - 0.4*shade), 1.0))
+                    .translateX(-0.5*size)
+                    .translateY(0)
+                    .rotationAxis(Rotate.X_AXIS)
+                    .rotate(90)
+                    .build(),
+                RectangleBuilder.create() // right face
+                    .width(size).height(size)
+                    .fill(color.deriveColor(0.0, 1.0, (1 - 0.3*shade), 1.0))
+                    .translateX(-1*size)
+                    .translateY(-0.5*size)
+                    .rotationAxis(Rotate.Y_AXIS)
+                    .rotate(90)
+                    .build(),
+                RectangleBuilder.create() // left face
+                    .width(size).height(size)
+                    .fill(color.deriveColor(0.0, 1.0, (1 - 0.2*shade), 1.0))
+                    .translateX(0)
+                    .translateY(-0.5*size)
+                    .rotationAxis(Rotate.Y_AXIS)
+                    .rotate(90)
+                    .build(),
+                RectangleBuilder.create() // top face
+                    .width(size).height(size)
+                    .fill(color.deriveColor(0.0, 1.0, (1 - 0.1*shade), 1.0))
+                    .translateX(-0.5*size)
+                    .translateY(-1*size)
+                    .rotationAxis(Rotate.X_AXIS)
+                    .rotate(90)
+                    .build(),
+                RectangleBuilder.create() // top face
+                    .width(size).height(size)
+                    .fill(color)
+                    .translateX(-0.5*size)
+                    .translateY(-0.5*size)
+                    .translateZ(-0.5*size)
+                    .build()
+            );
+        }
+    }
+
+
+    public double getSampleWidth() { return 400; }
+
+    public double getSampleHeight() { return 150; }
+
+    @Override public void start(Stage primaryStage) throws Exception {
+        init(primaryStage);
+        primaryStage.show();
+        play();
+    }
+    public static void main(String[] args) { launch(args); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/example/Hello.fxml	Tue Jan 29 10:29:28 2013 +0900
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<?import javafx.scene.control.Label?>
+<?import javafx.scene.layout.AnchorPane?>
+
+<AnchorPane prefWidth="100" prefHeight="40" xmlns:fx="http://javafx.com/fxml">
+    <children>
+        <Label text="Hello, World!" />
+    </children>
+</AnchorPane>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/example/HelloFXML.java	Tue Jan 29 10:29:28 2013 +0900
@@ -0,0 +1,27 @@
+package example;
+
+import java.io.File;
+
+import javafx.application.Application;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Parent;
+import javafx.scene.Scene;
+import javafx.stage.Stage;
+ 
+public class HelloFXML extends Application {
+     
+    @Override
+    public void start(Stage stage) throws Exception {
+        Parent root = FXMLLoader.load(getClass().getResource("Hello.fxml"));
+        
+        Scene scene = new Scene(root);
+         
+        stage.setScene(scene);
+        stage.show();
+    }
+ 
+    public static void main(String[] args) {
+    	System.out.println(new File(".").getAbsolutePath());
+        launch(args);
+    }
+}
Binary file src/example/HelloWorld.class has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/example/HelloWorld.java	Tue Jan 29 10:29:28 2013 +0900
@@ -0,0 +1,25 @@
+package example;
+
+import javafx.application.Application;
+import javafx.scene.Scene;
+import javafx.scene.control.Label;
+import javafx.scene.layout.BorderPane;
+import javafx.stage.Stage;
+
+public class HelloWorld extends Application {
+
+	@Override
+	public void start(Stage primaryStage) {
+		BorderPane borderPane = new BorderPane();
+        borderPane.setCenter( new Label( "Hello JavaFX!" ) );
+        
+        Scene scene = new Scene( borderPane, 200, 150 );
+        primaryStage.setScene( scene );
+        
+        primaryStage.show();
+	}
+
+	public static void main(String[] args) {
+		launch(args);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/example/LoginDemo.fxml	Tue Jan 29 10:29:28 2013 +0900
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<?import java.lang.*?>
+<?import javafx.scene.control.*?>
+<?import javafx.scene.layout.*?>
+<?import javafx.scene.text.*?>
+
+<AnchorPane minHeight="138.0" minWidth="100.0" prefHeight="138.0" prefWidth="320.0" xmlns:fx="http://javafx.com/fxml" fx:controller="example.LoginFormController">
+  <children>
+    <VBox AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="14.0">
+      <children>
+        <AnchorPane prefHeight="40.0">
+          <children>
+            <Label prefWidth="80.0" text="Account" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
+              <font>
+                <Font name="System Bold" size="13.0" />
+              </font>
+            </Label>
+            <TextField fx:id="accountField" prefWidth="160.0" AnchorPane.leftAnchor="80.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
+          </children>
+        </AnchorPane>
+        <AnchorPane prefHeight="40.0">
+          <children>
+            <Label prefWidth="80.0" text="Password" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
+            <PasswordField fx:id="passwordField" prefWidth="160.0" AnchorPane.leftAnchor="80.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
+          </children>
+        </AnchorPane>
+        <HBox alignment="TOP_RIGHT" fillHeight="true" prefHeight="30.0" snapToPixel="true" spacing="14.0">
+          <children>
+            <Button text="Login" onAction="#handleLogin"/>
+            <Button text="Cancel" onAction="#handleCancel"/>
+          </children>
+        </HBox>
+      </children>
+    </VBox>
+  </children>
+</AnchorPane>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/example/LoginDemo.java	Tue Jan 29 10:29:28 2013 +0900
@@ -0,0 +1,90 @@
+package example;
+
+import javafx.application.Application;
+import javafx.geometry.Pos;
+import javafx.scene.Scene;
+import javafx.scene.control.Button;
+import javafx.scene.control.Label;
+import javafx.scene.control.PasswordField;
+import javafx.scene.control.TextField;
+import javafx.scene.layout.AnchorPane;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.VBox;
+import javafx.stage.Stage;
+
+public class LoginDemo extends Application {
+    @Override
+    public void start(Stage stage) {
+        stage.setTitle("Login Demo");
+        
+        AnchorPane root = new AnchorPane();
+        Scene scene = new Scene(root);
+        stage.setScene(scene);
+   
+        root.setMinSize(100.0, 138.0);
+        root.setPrefSize(320.0, 138.0);
+ 
+        VBox vbox = new VBox();
+        root.getChildren().add(vbox);
+ 
+        AnchorPane.setTopAnchor(vbox, 14.0);
+        AnchorPane.setBottomAnchor(vbox, 14.0);
+        AnchorPane.setLeftAnchor(vbox, 14.0);
+        AnchorPane.setRightAnchor(vbox, 14.0);
+ 
+        AnchorPane topPane = new AnchorPane();
+        vbox.getChildren().add(topPane);
+        topPane.setPrefHeight(40.0);
+ 
+        Label accountLabel = new Label("Account");
+        topPane.getChildren().add(accountLabel);
+        
+        accountLabel.setPrefWidth(80.0);
+        AnchorPane.setTopAnchor(accountLabel, 0.0);
+        AnchorPane.setLeftAnchor(accountLabel, 0.0);
+        
+        TextField accountField = new TextField();
+        topPane.getChildren().add(accountField);
+         
+        accountField.setPrefWidth(160.0);
+        AnchorPane.setTopAnchor(accountField, 0.0);
+        AnchorPane.setLeftAnchor(accountField, 80.0);
+        AnchorPane.setRightAnchor(accountField, 0.0);
+ 
+        AnchorPane middlePane = new AnchorPane();
+        vbox.getChildren().add(middlePane);
+        middlePane.setPrefHeight(40.0);
+        
+        Label passwordLabel = new Label("Password");
+        middlePane.getChildren().add(passwordLabel);
+        
+        passwordLabel.setPrefWidth(80.0);
+        AnchorPane.setTopAnchor(passwordLabel, 0.0);
+        AnchorPane.setLeftAnchor(passwordLabel, 0.0);
+        
+        PasswordField passwordField = new PasswordField();
+        middlePane.getChildren().add(passwordField);
+         
+        passwordField.setPrefWidth(160.0);
+        AnchorPane.setTopAnchor(passwordField, 0.0);
+        AnchorPane.setLeftAnchor(passwordField, 80.0);
+        AnchorPane.setRightAnchor(passwordField, 0.0);
+ 
+        HBox bottomPane = new HBox(14.0);
+        vbox.getChildren().add(bottomPane);
+
+        bottomPane.setPrefHeight(30.0);
+        bottomPane.setAlignment(Pos.TOP_RIGHT);
+        
+        Button loginButton = new Button("Login");
+        bottomPane.getChildren().add(loginButton);
+        Button cancelButton = new Button("Cancel");
+        bottomPane.getChildren().add(cancelButton);
+         
+        stage.show();
+    }
+ 
+    public static void main(String[] args) {
+        launch(args);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/example/LoginDemo2.java	Tue Jan 29 10:29:28 2013 +0900
@@ -0,0 +1,26 @@
+package example;
+
+import java.io.IOException;
+
+import javafx.application.Application;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Scene;
+import javafx.scene.layout.AnchorPane;
+import javafx.stage.Stage;
+
+
+public class LoginDemo2 extends Application {
+
+	@Override
+	public void start(Stage primaryStage) throws IOException {
+        AnchorPane root = FXMLLoader.load(getClass().getResource("LoginDemo.fxml"));
+        Scene scene = new Scene(root);
+        
+        primaryStage.setScene(scene);
+        primaryStage.show();
+	}
+
+	public static void main(String[] args) {
+		launch(args);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/example/LoginFormController.java	Tue Jan 29 10:29:28 2013 +0900
@@ -0,0 +1,33 @@
+package example;
+
+import java.net.URL;
+import java.util.ResourceBundle;
+
+
+import javafx.event.ActionEvent;
+import javafx.fxml.FXML;
+import javafx.fxml.Initializable;
+import javafx.scene.control.PasswordField;
+import javafx.scene.control.TextField;
+
+public class LoginFormController implements Initializable {
+	@FXML
+    private TextField accountField;
+    
+    @FXML
+    private PasswordField passwordField;
+    
+    @FXML
+    public void handleLogin(ActionEvent event) {
+    	
+    }
+    
+    @FXML
+    public void handleCancel(ActionEvent event) {
+        
+    }
+	@Override
+	public void initialize(URL url, ResourceBundle rb) {
+        accountField.setText("dummy");
+	}
+}