# HG changeset patch # User e095732 # Date 1359422968 -32400 # Node ID 4823e45e8a2c36384d7e8d6b1a3aef36313b0e8d # Parent b973de8b678572cc790d53f38dc423d383b1e8c2 add sample diff -r b973de8b6785 -r 4823e45e8a2c src/alice/test/topology/aquarium/fx/aquarium.fxml --- /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 @@ + + + + + + + + + + + + + + + + diff -r b973de8b6785 -r 4823e45e8a2c src/example/CubeSample.java --- /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); } +} diff -r b973de8b6785 -r 4823e45e8a2c src/example/Hello.fxml --- /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 @@ + + + + + + + + + \ No newline at end of file diff -r b973de8b6785 -r 4823e45e8a2c src/example/HelloFXML.java --- /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); + } +} diff -r b973de8b6785 -r 4823e45e8a2c src/example/HelloWorld.class Binary file src/example/HelloWorld.class has changed diff -r b973de8b6785 -r 4823e45e8a2c src/example/HelloWorld.java --- /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); + } +} diff -r b973de8b6785 -r 4823e45e8a2c src/example/LoginDemo.fxml --- /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 @@ + + + + + + + + + + + + + + + + + + + + + + + +