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

import be.iminds.ilabt.jfed.experimenter_gui.canvas.CanvasLink;
import be.iminds.ilabt.jfed.gts.model.impl.FXGtsType;
import javafx.scene.Node;

/**
 * User: twalcari
 * Date: 2/10/2016
 * Time: 16:51
 */
public class GtsCanvasAdjacency extends CanvasLink {

    private GtsCanvasAdjacency(Node nodeA, Node nodeB) {
        super(nodeA, nodeB);
    }

    public static GtsCanvasAdjacency createGtsCanvasAdjacency(FXGtsType.AdjacencyInfo info, GtsTypeToCanvasBinding binding) {
        if (info instanceof FXGtsType.NodeToLinkAdjacencyInfo) {
            FXGtsType.NodeToLinkAdjacencyInfo ntlInfo = (FXGtsType.NodeToLinkAdjacencyInfo) info;
            return new GtsCanvasAdjacency(binding.getGtsCanvasNode(ntlInfo.getNode()), binding.getGtsCanvasLink(ntlInfo.getLink()));

        } else if (info instanceof FXGtsType.PortsAdjacencyInfo) {
            FXGtsType.PortsAdjacencyInfo pInfo = (FXGtsType.PortsAdjacencyInfo) info;
            return new GtsCanvasAdjacency(binding.getGtsCanvasNode(pInfo.getNode()), binding.getGtsCanvasPort(pInfo.getStandalonePort()));
        } else {
            return null;
        }
    }
}
