Connector endConnector = null;
if (endTerminal != null) {
- endConnector = createConnectorForNode(graph, attachToConnection, endTerminal, EdgeEnd.End, judgment);
+ endConnector = createConnectorForNode(graph, attachToConnection, endTerminal, flagType == FlagClass.Type.In ? EdgeEnd.Begin : EdgeEnd.End, judgment);
} else if (createFlags) {
EdgeEnd end = flagType == FlagClass.Type.In ? EdgeEnd.Begin : EdgeEnd.End;
IElement endFlag = createFlag(graph, attachToConnection, end, controlPoints.getLast(), flagType, null);
EdgeEnd end, ConnectionJudgement judgment) throws DatabaseException {
IConnectionPoint cp = ConnectionUtil.toConnectionPoint(graph, element, terminal);
CPTerminal cpt = (cp instanceof CPTerminal) ? (CPTerminal) cp : null;
- Resource attachment = judgment.attachmentRelations.get(graph, cpt);
+ Resource attachment = null;
+ if (judgment.attachmentRelations != null)
+ attachment = judgment.attachmentRelations.get(graph, cpt);
if (attachment == null)
attachment = cu.toHasConnectorRelation(end);
Resource connector = cu.getOrCreateConnector(connection, element, terminal, end, attachment);
import java.util.Deque;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import org.simantics.Simantics;
endFlagNode.setTransform(AffineTransform.getTranslateInstance(mouseCanvasPos.getX(), mouseCanvasPos.getY()));
}
- TerminalInfo ti = pi.pickTerminal(me.controlPosition);
- if (ti != null) {
- Object canConnect = canConnect(ti.e, ti.t);
- if (canConnect != null) {
- connectionJudgment = (ConnectionJudgement) canConnect;
+ List<TerminalInfo> tis = pi.pickTerminals(me.controlPosition);
+ tis = TerminalUtil.findNearestOverlappingTerminals(tis);
+ if (!tis.isEmpty()) {
+ for (TerminalInfo ti : tis) {
+ Object canConnect = canConnect(ti.e, ti.t);
- if (!isEndingInFlag() || !TerminalUtil.isSameTerminal(ti, endTerminal)) {
- controlPoints.getLast()
- .setPosition(ti.posDia)
- .setAttachedToTerminal(ti);
+ if (canConnect != null) {
+ connectionJudgment = (ConnectionJudgement) canConnect;
- endTerminal = ti;
+ if (!isEndingInFlag() || !TerminalUtil.isSameTerminal(ti, endTerminal)) {
+ controlPoints.getLast().setPosition(ti.posDia).setAttachedToTerminal(ti);
- connect(ti);
-
- }
+ endTerminal = ti;
+
+ connect(ti);
- // Make sure that we are ending with a flag if ALT is pressed
- // and no end terminal is defined.
- endWithoutTerminal(lastMouseCanvasPos, shouldEndWithFlag(me));
+ }
- updateSG(new Point2D.Double(ti.posDia.getTranslateX(), ti.posDia.getTranslateY()));
- return false;
+ // Make sure that we are ending with a flag if ALT is pressed
+ // and no end terminal is defined.
+ endWithoutTerminal(lastMouseCanvasPos, shouldEndWithFlag(me));
+
+ updateSG(new Point2D.Double(ti.posDia.getTranslateX(), ti.posDia.getTranslateY()));
+ return false;
+ }
}
}