Mercurial > hg > Database > Alice
view src/main/java/alice/test/topology/aquarium/fx/Aquarium.java @ 379:b162da6aa0c2 multicast
refactor
author | sugi |
---|---|
date | Mon, 09 Jun 2014 21:54:14 +0900 |
parents | ac3cf96f4426 |
children | 29e75b92c358 |
line wrap: on
line source
package alice.test.topology.aquarium.fx; import java.io.IOException; import alice.codesegment.OutputDataSegment; import javafx.application.Application; import javafx.collections.ObservableList; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.PerspectiveCamera; import javafx.scene.Scene; import javafx.scene.SceneAntialiasing; import javafx.scene.SubScene; import javafx.scene.input.KeyEvent; import javafx.scene.paint.Color; import javafx.scene.transform.Rotate; import javafx.scene.transform.Translate; import javafx.stage.Stage; public class Aquarium extends Application { private OutputDataSegment ods = new OutputDataSegment(); @Override public void start(Stage primaryStage) throws IOException { String myName = getParameters().getRaw().get(0); primaryStage.setTitle("Aquarium "+ myName); // name primaryStage.setResizable(false); Scene scene = new Scene(createContent()); scene.setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(KeyEvent t) { System.out.println(t.getCode()); ods.put(myName+"FishPosition", new FishInfo(1,0,0)); } }); primaryStage.setScene(scene); primaryStage.show(); } private Parent createContent(){ Group root = new Group(); ods.put("root", root); // Create and position camera PerspectiveCamera camera = new PerspectiveCamera(true); camera.getTransforms().addAll( new Rotate(-20, Rotate.Y_AXIS), new Rotate(-20, Rotate.X_AXIS), new Translate(0, 0, -15)); camera.setId("camera"); root.getChildren().add(camera); // Use a SubScene SubScene subScene = new SubScene(root, 800, 700, true, SceneAntialiasing.BALANCED); subScene.setFill(Color.TRANSPARENT); subScene.setCamera(camera); Group parent = new Group(subScene); return parent; } public static void main(String[] args) { launch(args); } }