# HG changeset patch # User sugi # Date 1402318454 -32400 # Node ID b162da6aa0c261a23e43e984386f1a7cd74deb57 # Parent ac3cf96f4426586f7408fe20a3f2d5c7a8a02f18 refactor diff -r ac3cf96f4426 -r b162da6aa0c2 src/main/java/alice/test/topology/aquarium/fx/AddObject.java --- 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 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); } } diff -r ac3cf96f4426 -r b162da6aa0c2 src/main/java/alice/test/topology/aquarium/fx/Aquarium.java --- 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 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 getObjList() { - return objList; - } - }