Search in sources :

Example 1 with OutputComponent

use of org.apache.airavata.workflow.model.component.system.OutputComponent in project airavata by apache.

the class GraphCanvas method mouseClicked.

private void mouseClicked(MouseEvent event) {
    /*
         * If there is multi-selected and a click on a node, switch to that node or deselect node if it is already
         * selected
         */
    Point point = event.getPoint();
    GraphPiece clicked = NodeController.getGUI(this.graph).getGraphPieceAt(point);
    if ((clicked instanceof Node) && this.multipleSelectedNodes != null) {
        Node node = (Node) clicked;
        if (!this.crtlPressed) {
            selectNode(node);
        }
        return;
    } else if ((clicked instanceof Port) && event.getClickCount() == 2) {
        // double click to add Input/Output nodes and connect with them when a DataPort is double clicked
        Port port = (Port) clicked;
        Point pos = port.getNode().getPosition();
        Node node = null;
        int xgap = (int) (1.5 * NodeGUI.MINIMUM_WIDTH);
        int ygap = (int) (NodeGUI.MINIMUM_HEIGHT / 2);
        Point nodePos = null;
        switch(port.getKind()) {
            case DATA_IN:
                if (port.getFromNode() == null) {
                    nodePos = new Point(Math.max(0, pos.x - xgap), Math.max(0, pos.y - ygap));
                    node = addNode(new InputComponent(), nodePos);
                    connect(node.getOutputPorts().get(0), port);
                }
                break;
            case DATA_OUT:
                nodePos = new Point(pos.x + NodeGUI.MINIMUM_WIDTH + xgap, pos.y + ygap);
                node = addNode(new OutputComponent(), nodePos);
                connect(port, node.getInputPorts().get(0));
                break;
            default:
        }
    }
    // delegate the event.
    NodeController.getGUI(this.graph).mouseClicked(event, this.engine);
}
Also used : InputComponent(org.apache.airavata.workflow.model.component.system.InputComponent) GraphPiece(org.apache.airavata.workflow.model.graph.GraphPiece) OutputComponent(org.apache.airavata.workflow.model.component.system.OutputComponent) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) DynamicNode(org.apache.airavata.workflow.model.graph.dynamic.DynamicNode) Node(org.apache.airavata.workflow.model.graph.Node) StreamSourceNode(org.apache.airavata.workflow.model.graph.system.StreamSourceNode) DataPort(org.apache.airavata.workflow.model.graph.DataPort) Port(org.apache.airavata.workflow.model.graph.Port) Point(java.awt.Point)

Aggregations

Point (java.awt.Point)1 InputComponent (org.apache.airavata.workflow.model.component.system.InputComponent)1 OutputComponent (org.apache.airavata.workflow.model.component.system.OutputComponent)1 DataPort (org.apache.airavata.workflow.model.graph.DataPort)1 GraphPiece (org.apache.airavata.workflow.model.graph.GraphPiece)1 Node (org.apache.airavata.workflow.model.graph.Node)1 Port (org.apache.airavata.workflow.model.graph.Port)1 DynamicNode (org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)1 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)1 StreamSourceNode (org.apache.airavata.workflow.model.graph.system.StreamSourceNode)1