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);
}
Aggregations