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

import be.iminds.ilabt.jfed.experimenter_gui.canvas.CanvasNode;
import be.iminds.ilabt.jfed.experimenter_gui.canvas.NewLinkTarget;
import be.iminds.ilabt.jfed.gts.model.impl.FXGtsPort;
import javafx.geometry.Point2D;
import javafx.scene.image.Image;

/**
 * User: twalcari
 * Date: 2/9/2016
 * Time: 16:58
 */
public class GtsCanvasPort extends CanvasNode implements NewLinkTarget{

    private final FXGtsPort port;

    public GtsCanvasPort(FXGtsPort port) {
        this.port = port;

        textProperty().bind(port.idProperty());
        this.layoutXProperty().bindBidirectional(port.editorXProperty());
        this.layoutYProperty().bindBidirectional(port.editorYProperty());

        setImage(new Image(GtsCanvasPort.class.getResource("/images/gts_types/64/gts-port.png").toExternalForm()));

    }

    public FXGtsPort getPort() {
        return port;
    }

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