view src/main/java/alice/test/topology/aquarium/fx/SetTranslate.java @ 547:e91a574b69de dispose

remove index
author Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
date Tue, 18 Aug 2015 16:15:17 +0900
parents 15eeb439830c
children
line wrap: on
line source

package alice.test.topology.aquarium.fx;

import javafx.application.Platform;
import javafx.geometry.Point3D;
import javafx.scene.Group;
import alice.codesegment.CodeSegment;
import alice.datasegment.CommandType;
import alice.datasegment.Receiver;

public class SetTranslate extends CodeSegment {

    private Receiver info  = ids.create(CommandType.TAKE); // object instance
    private Receiver info1 = ids.create(CommandType.TAKE); // absolute fish position value
    private Receiver info2 = ids.create(CommandType.PEEK); // median
    private boolean executed = false;

    public SetTranslate(String key) {
        info.setKey(key, this);
        info1.setKey(key+"absoluteP", this);
        info2.setKey("median", this);
    }

    @Override
    public void run() {
        if (!executed) {
            executed = true;
            new SendDataOthers(info1, info1.key);
            ods.update(info.key+"backUp", info1.getReceiveData());
            // javafx's Scene can be accessed only FX application thread.
            Platform.runLater(this);
        } else {
            Group fish = info.asClass(Group.class);
            FishInfo fp = info1.asClass(FishInfo.class);
            int median = info2.asInteger();

            fish.setRotate(fp.rotate);
            fish.setRotationAxis(new Point3D(fp.rolX,fp.rolY,fp.rolZ));
            fish.setTranslateX(fp.getX() - median);
            fish.setTranslateY(fp.getY());
            fish.setTranslateZ(fp.getZ());
            ods.flip(info);

            executed = false;
            new SetTranslate(info.key);
        }
    }

}