use of org.eclipse.gmf.runtime.notation.Anchor in project statecharts by Yakindu.
the class AdjustIdentityAnchorCommand method handleEdge.
private void handleEdge(Edge edge, EditPart editPart, boolean sourceAnchor) {
Anchor anchorToModify;
if (sourceAnchor) {
anchorToModify = edge.getSourceAnchor();
} else {
anchorToModify = edge.getTargetAnchor();
}
String terminalString = composeTerminalString(DEFAULT_POINT);
if (anchorToModify instanceof IdentityAnchor) {
terminalString = ((IdentityAnchor) anchorToModify).getId();
}
PrecisionPoint anchorPoint = BaseSlidableAnchor.parseTerminalString(terminalString);
PrecisionPoint newPoint = computeNewAnchor(anchorPoint, editPart);
String newTerminalString = new SlidableAnchor(null, newPoint).getTerminal();
if (anchorToModify instanceof IdentityAnchor) {
((IdentityAnchor) anchorToModify).setId(newTerminalString);
} else if (anchorToModify == null) {
// Create a new one
IdentityAnchor newAnchor = NotationFactory.eINSTANCE.createIdentityAnchor();
newAnchor.setId(newTerminalString);
if (sourceAnchor) {
edge.setSourceAnchor(newAnchor);
} else {
edge.setTargetAnchor(newAnchor);
}
}
}
Aggregations