package be.iminds.ilabt.jfed.experimenter_gui.canvas.rspec;

import be.iminds.ilabt.jfed.experimenter_gui.canvas.CanvasNode;
import be.iminds.ilabt.jfed.experimenter_gui.canvas.NewLinkTarget;
import be.iminds.ilabt.jfed.experimenter_gui.util.ImageUtil;
import be.iminds.ilabt.jfed.rspec.model.javafx_impl.FXGeantTestbedType;
import javafx.geometry.Point2D;
import javafx.scene.image.Image;

/**
 * User: twalcari
 * Date: 4/23/2015
 * Time: 15:21
 */
public class RspecGTSNode extends CanvasNode implements NewLinkTarget {

    private final FXGeantTestbedType gtt;



    public RspecGTSNode(FXGeantTestbedType gtt) {
        this.gtt = gtt;

        setImage(new Image(ImageUtil.class.getResource("/images/gts-cloud.png").toExternalForm()));
        textProperty().bind(gtt.nameProperty());

        layoutXProperty().bindBidirectional(gtt.editorXProperty());
        layoutYProperty().bindBidirectional(gtt.editorYProperty());
    }

    public FXGeantTestbedType getGeantTestbedType() {
        return gtt;
    }


    @Override
    public Point2D getCenterPosition() {
        return new Point2D(NewLinkTarget.getCenterX(this), NewLinkTarget.getCenterY(this));
    }
}
