377
|
1 package alice.test.topology.aquarium.fx;
|
|
2
|
|
3 import javafx.application.Platform;
|
|
4 import javafx.scene.Group;
|
|
5 import alice.codesegment.CodeSegment;
|
|
6 import alice.datasegment.CommandType;
|
|
7 import alice.datasegment.Receiver;
|
|
8
|
|
9 public class SetTranslate extends CodeSegment {
|
|
10
|
|
11 private Receiver info = ids.create(CommandType.TAKE); // object instance
|
387
|
12 private Receiver info1 = ids.create(CommandType.TAKE); // differential value
|
|
13 //private Receiver info2 = ids.create(CommandType.TAKE); // absolute fish position value
|
|
14 private Receiver info3 = ids.create(CommandType.PEEK); // start x
|
377
|
15 private boolean executed = false;
|
|
16 public SetTranslate(String key) {
|
|
17 info.setKey(key);
|
387
|
18 info1.setKey(key+"diffP");
|
|
19 info3.setKey("startX");
|
377
|
20 }
|
|
21
|
|
22 @Override
|
|
23 public void run() {
|
|
24 if (!executed) {
|
|
25 executed = true;
|
383
|
26 new SendDataOthers(info1, info1.key);
|
377
|
27 // javafx's Scene can be accessed only FX application thread.
|
|
28 Platform.runLater(this);
|
|
29 } else {
|
387
|
30 Group fish = info.asClass(Group.class);
|
377
|
31 FishInfo fp = info1.asClass(FishInfo.class);
|
387
|
32 //int scope = info3.asInteger();
|
377
|
33
|
|
34 fish.setTranslateX(fish.getTranslateX()+fp.getX());
|
|
35 fish.setTranslateY(fish.getTranslateY()+fp.getY());
|
|
36 fish.setTranslateZ(fish.getTranslateZ()+fp.getZ());
|
|
37 ods.flip(info);
|
383
|
38 executed = false;
|
377
|
39 new SetTranslate(info.key);
|
|
40 }
|
|
41 }
|
|
42
|
|
43 }
|