Mercurial > hg > Database > Alice
changeset 379:b162da6aa0c2 multicast
refactor
author | sugi |
---|---|
date | Mon, 09 Jun 2014 21:54:14 +0900 |
parents | ac3cf96f4426 |
children | 29e75b92c358 |
files | src/main/java/alice/test/topology/aquarium/fx/AddObject.java src/main/java/alice/test/topology/aquarium/fx/Aquarium.java |
diffstat | 2 files changed, 17 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/alice/test/topology/aquarium/fx/AddObject.java Mon Jun 09 21:28:47 2014 +0900 +++ b/src/main/java/alice/test/topology/aquarium/fx/AddObject.java Mon Jun 09 21:54:14 2014 +0900 @@ -1,7 +1,6 @@ package alice.test.topology.aquarium.fx; import javafx.application.Platform; -import javafx.collections.ObservableList; import javafx.scene.Group; import javafx.scene.Node; import alice.codesegment.CodeSegment; @@ -10,15 +9,13 @@ public class AddObject extends CodeSegment { // add Object on javaFx Scene - private Receiver info = ids.create(CommandType.TAKE); // ObservableList instance. + private Receiver info = ids.create(CommandType.TAKE); private Receiver info1 = ids.create(CommandType.TAKE); - private Receiver info2 = ids.create(CommandType.TAKE); private boolean executed = false; public AddObject(){ - info.setKey("objList"); + info.setKey("root"); info1.setKey("addOffer"); - info2.setKey("root"); } @Override @@ -29,19 +26,17 @@ Platform.runLater(this); } else { boolean duplication = false; - Node obj = info1.asClass(Node.class); - Group obj1 = info2.asClass(Group.class); - obj1.getChildren().add(obj); - System.out.println(obj.getId()); - ObservableList<Node> objList = info.asClass(ObservableList.class); -// for (Node n : objList){ -// if (n.getId().equals(obj.getId())) -// duplication = true; -// } -// if (!duplication) { -// objList.add(obj); -// } - ods.flip(info1); + Group root = info.asClass(Group.class); + Group obj = info1.asClass(Group.class); + + for (Node n : root.getChildren()){ + if (n.getId().equals(obj.getId())) + duplication = true; + } + if (!duplication) { + root.getChildren().add(obj); + } + ods.put(obj.getId()+"Fish", obj); } }
--- a/src/main/java/alice/test/topology/aquarium/fx/Aquarium.java Mon Jun 09 21:28:47 2014 +0900 +++ b/src/main/java/alice/test/topology/aquarium/fx/Aquarium.java Mon Jun 09 21:54:14 2014 +0900 @@ -22,12 +22,10 @@ public class Aquarium extends Application { private OutputDataSegment ods = new OutputDataSegment(); - private ObservableList<Node> objList; - private String myName; @Override public void start(Stage primaryStage) throws IOException { - myName = getParameters().getRaw().get(0); + String myName = getParameters().getRaw().get(0); primaryStage.setTitle("Aquarium "+ myName); // name primaryStage.setResizable(false); @@ -38,9 +36,7 @@ ods.put(myName+"FishPosition", new FishInfo(1,0,0)); } }); - - //addFishObject(); - ods.put("objList", objList); + primaryStage.setScene(scene); primaryStage.show(); } @@ -48,7 +44,6 @@ private Parent createContent(){ Group root = new Group(); ods.put("root", root); - objList = root.getChildren(); // Create and position camera PerspectiveCamera camera = new PerspectiveCamera(true); @@ -56,8 +51,9 @@ new Rotate(-20, Rotate.Y_AXIS), new Rotate(-20, Rotate.X_AXIS), new Translate(0, 0, -15)); + camera.setId("camera"); - objList.add(camera); + root.getChildren().add(camera); // Use a SubScene SubScene subScene = new SubScene(root, 800, 700, true, SceneAntialiasing.BALANCED); @@ -73,8 +69,4 @@ launch(args); } - public ObservableList<Node> getObjList() { - return objList; - } - }