Search in sources :

Example 1 with Anchor

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);
        }
    }
}
Also used : IdentityAnchor(org.eclipse.gmf.runtime.notation.IdentityAnchor) SlidableAnchor(org.eclipse.gmf.runtime.gef.ui.figures.SlidableAnchor) IdentityAnchor(org.eclipse.gmf.runtime.notation.IdentityAnchor) Anchor(org.eclipse.gmf.runtime.notation.Anchor) BaseSlidableAnchor(org.eclipse.gmf.runtime.draw2d.ui.figures.BaseSlidableAnchor) SlidableAnchor(org.eclipse.gmf.runtime.gef.ui.figures.SlidableAnchor) BaseSlidableAnchor(org.eclipse.gmf.runtime.draw2d.ui.figures.BaseSlidableAnchor) PrecisionPoint(org.eclipse.draw2d.geometry.PrecisionPoint)

Aggregations

PrecisionPoint (org.eclipse.draw2d.geometry.PrecisionPoint)1 BaseSlidableAnchor (org.eclipse.gmf.runtime.draw2d.ui.figures.BaseSlidableAnchor)1 SlidableAnchor (org.eclipse.gmf.runtime.gef.ui.figures.SlidableAnchor)1 Anchor (org.eclipse.gmf.runtime.notation.Anchor)1 IdentityAnchor (org.eclipse.gmf.runtime.notation.IdentityAnchor)1