Mercurial > hg > Members > tatsuki > Alice
view src/main/java/alice/test/topology/aquarium/fx/AddObject.java @ 378:ac3cf96f4426 multicast
add scooter object with CreateObject and AddObject
author | sugi |
---|---|
date | Mon, 09 Jun 2014 21:28:47 +0900 |
parents | |
children | b162da6aa0c2 |
line wrap: on
line source
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; import alice.datasegment.CommandType; import alice.datasegment.Receiver; public class AddObject extends CodeSegment { // add Object on javaFx Scene private Receiver info = ids.create(CommandType.TAKE); // ObservableList instance. private Receiver info1 = ids.create(CommandType.TAKE); private Receiver info2 = ids.create(CommandType.TAKE); private boolean executed = false; public AddObject(){ info.setKey("objList"); info1.setKey("addOffer"); info2.setKey("root"); } @Override public void run() { if (!executed) { executed = true; // javafx's Scene can be accessed only FX application thread. 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); } } }