Mercurial > hg > Database > Alice
view src/main/java/alice/test/topology/aquarium/fx/AddObject.java @ 419:aefbe41fcf12 dispose
change tab to space
author | sugi |
---|---|
date | Tue, 15 Jul 2014 16:00:22 +0900 |
parents | 4b38d3e6520e |
children | 6e304a7a60e7 |
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); // objectList private Receiver info1 = ids.create(CommandType.TAKE); // fish Object made from CreateObject CS private Receiver info2 = ids.create(CommandType.PEEK); // node name private boolean executed = false; public AddObject(){ info.setKey("root"); info1.setKey("addOffer"); info2.setKey("host"); } @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); String myName = info2.asString(); for (Node n : root.getChildren()){ if (n.getId().equals(obj.getId())) duplication = true; } if (!duplication) { root.getChildren().add(obj); System.out.println(obj.getId()+" add"); ods.put(obj.getId()+"Fish", obj); // controlled own fish if (myName.equals(obj.getId())){ new CalculatePosition(obj.getId()+"FishdiffP"); } new SetTranslate(obj.getId()+"Fish"); FishInfo fishInfo = new FishInfo(); fishInfo.name = obj.getId(); fishInfo.size = obj.getScaleX(); ods.put("register", fishInfo); } ods.flip(info); new AddObject(); } } }