Mercurial > hg > Database > Alice
view src/main/java/alice/test/topology/aquarium/fx/Aquarium.java @ 387:1cbac5818dca multicast
add scope dataSegment
author | sugi |
---|---|
date | Mon, 16 Jun 2014 16:59:39 +0900 |
parents | 56d4f93a3921 |
children | c0cf9fe00d77 |
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.event.EventHandler; import javafx.scene.Group; 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; import javafx.stage.WindowEvent; public class Aquarium extends Application { private OutputDataSegment ods = new OutputDataSegment(); @Override public void start(Stage primaryStage) throws IOException { String myName = getParameters().getRaw().get(0); // name primaryStage.setTitle("Aquarium "+ myName); primaryStage.setResizable(false); primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>(){ @Override public void handle(WindowEvent event) { // should send finish DataSegment System.exit(0); } }); Scene scene = new Scene(createContent()); scene.setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(KeyEvent t) { switch (t.getCode()) { case RIGHT: ods.update(myName+"FishdiffP", new FishInfo(0.1,0,0)); break; case LEFT: ods.update(myName+"FishdiffP", new FishInfo(-0.1,0,0)); break; case UP: ods.update(myName+"FishdiffP", new FishInfo(0,-0.1,0)); break; case DOWN: ods.update(myName+"FishdiffP", new FishInfo(0,0.1,0)); break; case N: ods.update(myName+"FishdiffP", new FishInfo(0,0,0.1)); break; case M: ods.update(myName+"FishdiffP", new FishInfo(0,0,-0.1)); break; case R: // reset. need absolute position ods.update(myName+"FishdiffP", new FishInfo(0,0,0)); break; default: // do nothing break; } } }); 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(0, Rotate.Y_AXIS), new Rotate(0, 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); } }