Mercurial > hg > Members > tatsuki > Alice
view src/main/java/alice/test/topology/aquarium/fx/AddObject.java @ 379:b162da6aa0c2 multicast
refactor
author | sugi |
---|---|
date | Mon, 09 Jun 2014 21:54:14 +0900 |
parents | ac3cf96f4426 |
children | 878d397904da |
line wrap: on
line source
package alice.test.topology.aquarium.fx; import javafx.application.Platform; 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); private Receiver info1 = ids.create(CommandType.TAKE); private boolean executed = false; public AddObject(){ info.setKey("root"); info1.setKey("addOffer"); } @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; 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); } } }