Package org.apache.airavata.xbaya.graph

Examples of org.apache.airavata.xbaya.graph.Port


     */
    protected void setPortPositions() {
        // inputs
        List<? extends Port> inputPorts = this.node.getInputPorts();
        for (int i = 0; i < inputPorts.size(); i++) {
            Port port = inputPorts.get(i);
            Point offset = new Point(PortGUI.DATA_PORT_SIZE / 2, this.headHeight + PORT_INITIAL_GAP + PORT_GAP * i);
            port.getGUI().setOffset(offset);
        }

        // outputs
        List<? extends Port> outputPorts = this.node.getOutputPorts();
        for (int i = 0; i < outputPorts.size(); i++) {
            Port port = outputPorts.get(i);
            // Use getBounds() instead of this.dimension because subclass might
            // overwrite getBounds() to have different shape.
            Point offset = new Point(this.getBounds().width - PortGUI.DATA_PORT_SIZE / 2, this.headHeight
                    + PORT_INITIAL_GAP + PORT_GAP * i);
            port.getGUI().setOffset(offset);
        }

        // control-in
        Port controlInPort = this.node.getControlInPort();
        if (controlInPort != null) {
            controlInPort.getGUI().setOffset(new Point(0, 0));
        }

        // control-outs
        for (Port controlOutPort : this.node.getControlOutPorts()) {
            // By default, all ports will be drawn at the same place. Subclass
View Full Code Here


     * @param node
     */
    private void finishPredecessorNodes(Node node) {
        for (Port inputPort : node.getInputPorts()) {
            for (Edge edge : inputPort.getEdges()) {
                Port fromPort = edge.getFromPort();
                if (!(fromPort instanceof EPRPort)) {
                    Node fromNode = fromPort.getNode();
                    finishNode(fromNode);
                    finishPredecessorNodes(fromNode);
                }
            }
        }
        Port controlInPort = node.getControlInPort();
        if (controlInPort != null) {
            for (Node fromNode : controlInPort.getFromNodes()) {
                finishNode(fromNode);
                finishPredecessorNodes(fromNode);
            }
        }
    }
View Full Code Here

    @Override
    protected void edgeWasAdded(Edge edge) throws GraphException {
        super.edgeWasAdded(edge);

        if (edge instanceof ControlEdge) {
            Port toPort = edge.getToPort();
            Node toNode = toPort.getNode();
            /*
             * check if there is already more than instance node connecting to destination node
             */
            if (!(toNode instanceof InstanceNode)) {
                for (Node node : toNode.getControlInPort().getFromNodes()) {
View Full Code Here

                point2.x, point2.y);
        g.draw(line);
    }

    private Point getFromPosition() {
        Port port = this.edge.getFromPort();
        return port.getGUI().getPosition();
    }
View Full Code Here

        Port port = this.edge.getFromPort();
        return port.getGUI().getPosition();
    }

    private Point getToPosition() {
        Port port = this.edge.getToPort();
        return port.getGUI().getPosition();
    }
View Full Code Here

                piece = node;
            }

            // Find the closest port of this node.
            double minPortDist = Double.MAX_VALUE;
            Port closestPort = null;
            for (Port port : node.getAllPorts()) {
                double dist = port.getGUI().getPosition().distance(point);
                if (dist < minPortDist) {
                    closestPort = port;
                    minPortDist = dist;
View Full Code Here

    @Override
    protected void edgeWasAdded(Edge edge) throws GraphException {
        super.edgeWasAdded(edge);

        if (edge instanceof DataEdge) {
            Port toPort = edge.getToPort();
            Node toNode = toPort.getNode();
            Port fromPort = edge.getFromPort();
            Node fromNode = fromPort.getNode();

            if (!(toNode instanceof ResourceNode && fromNode instanceof ResourceNode)) {
                throw new GraphException("Cannot connect Resource Node to other type of nodes");
            }
        }
View Full Code Here

    public void graphCanvasChanged(GraphCanvasEvent event) {
        GraphCanvasEventType type = event.getType();
        GraphCanvas graphCanvas = event.getGraphCanvas();
        switch (type) {
        case INPUT_PORT_SELECTED:
            Port inputPort = graphCanvas.getSelectedInputPort();
            setInputPort(inputPort);
            break;
        case OUTPUT_PORT_SELECTED:
            Port outputPort = graphCanvas.getSelectedOutputPort();
            setOutputPort(outputPort);
            break;
        case GRAPH_LOADED:
        case NAME_CHANGED:
        case NODE_SELECTED:
View Full Code Here

    @Override
    protected void setPortPositions() {
        // inputs
        List<? extends Port> inputPorts = this.node.getInputPorts();
        for (int i = 0; i < inputPorts.size(); i++) {
            Port port = inputPorts.get(i);
            Point offset = new Point(PortGUI.DATA_PORT_SIZE / 2, this.headHeight + PORT_INITIAL_GAP + PORT_GAP * i);
            port.getGUI().setOffset(offset);
        }

        // outputs
        List<? extends Port> outputPorts = this.node.getOutputPorts();
        for (int i = 0; i < outputPorts.size(); i++) {
            Port port = outputPorts.get(i);
            // Use getBounds() instead of this.dimension because subclass might
            // overwrite getBounds() to have different shape.
            Point offset = new Point(this.getBounds().width - PortGUI.DATA_PORT_SIZE / 2, this.headHeight
                    + PORT_INITIAL_GAP + PORT_GAP * i);
            port.getGUI().setOffset(offset);
        }

        // control in port
        Port controlInPort = this.node.getControlInPort();
        controlInPort.getGUI().setOffset(new Point(0, 0));
    }
View Full Code Here

    @Override
    protected void setPortPositions() {
        // inputs
        List<? extends Port> inputPorts = this.node.getInputPorts();
        for (int i = 0; i < inputPorts.size(); i++) {
            Port port = inputPorts.get(i);
            Point offset = new Point(PortGUI.DATA_PORT_SIZE / 2, this.headHeight + PORT_INITIAL_GAP + PORT_GAP * i);
            port.getGUI().setOffset(offset);
        }

        // outputs
        List<? extends Port> outputPorts = this.node.getOutputPorts();
        for (int i = 0; i < outputPorts.size(); i++) {
            Port port = outputPorts.get(i);
            // Use getBounds() instead of this.dimension because subclass might
            // overwrite getBounds() to have different shape.
            Point offset = new Point(this.getBounds().width - PortGUI.DATA_PORT_SIZE / 2, this.headHeight
                    + PORT_INITIAL_GAP + PORT_GAP * i);
            port.getGUI().setOffset(offset);
        }

        // control out port
        List<? extends Port> controlOutPorts = this.node.getControlOutPorts();
        Port controlOutPort1 = controlOutPorts.get(0);
        Point offset = new Point(getBounds().width / 2, getBounds().height);
        controlOutPort1.getGUI().setOffset(offset);
    }
View Full Code Here

TOP

Related Classes of org.apache.airavata.xbaya.graph.Port

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.