Mercurial > hg > Members > sugi > javafx
diff src/alice/test/topology/aquarium/fx/SetTranslation.java @ 4:50d77513d52e
Platform runLater must use for handling instance from other thread (Not on FX application thread )
author | e095732 |
---|---|
date | Mon, 28 Jan 2013 00:22:17 +0900 |
parents | |
children | ae0a39622a58 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/aquarium/fx/SetTranslation.java Mon Jan 28 00:22:17 2013 +0900 @@ -0,0 +1,54 @@ +package alice.test.topology.aquarium.fx; + +import javafx.scene.image.ImageView; +import javafx.scene.shape.Rectangle; +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + +public class SetTranslation extends CodeSegment { + + private Receiver data = ids.create(CommandType.PEEK); + private ImageView image; + private Rectangle rect; + + public SetTranslation(ImageView image, String key){ + this.image = image; + data.setKey(key); + } + + public SetTranslation(ImageView image, String key, int index) { + this.image = image; + data.setKey(key, index); + } + + public SetTranslation(Rectangle rect, String key){ + this.rect = rect; + data.setKey(key); + } + + public SetTranslation(Rectangle rect, String key, int index) { + this.rect = rect; + data.setKey(key, index); + } + + @Override + public void run() { + FishData fd = data.asClass(FishData.class); + if (image!=null){ + image.setTranslateX(fd.x); + image.setTranslateY(fd.y); + image.setTranslateZ(fd.z); + + new SetTranslation(image, data.key, data.index); + } else if (rect != null){ + rect.setTranslateX(fd.x); + rect.setTranslateY(fd.y); + rect.setTranslateZ(fd.z); + + new SetTranslation(rect, data.key, data.index); + } + + } + +}