Search in sources :

Example 1 with SLinkArc

use of org.antlr.xjlib.appkit.gview.shape.SLinkArc in project antlrworks by antlr.

the class GEventCreateLinkElement method mousePressed.

public void mousePressed(MouseEvent e, Point mousePosition) {
    GElement selectedElement = delegate.eventQueryElementAtPoint(mousePosition);
    if (startElement != null) {
        if (selectedElement != null) {
            int type;
            if (linkElement instanceof SLinkElbow)
                type = GLink.SHAPE_ELBOW;
            else
                type = GLink.SHAPE_ARC;
            delegate.eventCreateLink(startElement, startAnchorKey, selectedElement, selectedElement.getAnchorKeyClosestToPoint(mousePosition), type, mousePosition);
        }
        removeExclusiveValue(GEventManager.EXCLUSIVE_CREATE_LINK_VALUE);
        startElement = null;
        linkElement = null;
        delegate.eventShouldRepaint();
        return;
    }
    if (selectedElement == null || !selectedElement.acceptOutgoingLink()) {
        return;
    }
    int mask = InputEvent.SHIFT_DOWN_MASK + InputEvent.BUTTON1_DOWN_MASK;
    if ((e.getModifiersEx() & mask) == mask || delegate.eventCanCreateLink()) {
        startElement = selectedElement;
        startAnchorKey = startElement.getAnchorKeyClosestToPoint(mousePosition);
        linkArc = new SLinkArc();
        linkArc.setStartTangentOffset(startElement.getDefaultAnchorOffset(startAnchorKey));
        linkElbow = new SLinkElbow();
        if (view.defaultLinkShape() == GLink.SHAPE_ARC)
            linkElement = linkArc;
        else
            linkElement = linkElbow;
        linkElement.setFlateness(delegate.eventLinkFlateness());
        addExclusiveValue(GEventManager.EXCLUSIVE_CREATE_LINK_VALUE);
    }
}
Also used : SLinkArc(org.antlr.xjlib.appkit.gview.shape.SLinkArc) SLinkElbow(org.antlr.xjlib.appkit.gview.shape.SLinkElbow) GElement(org.antlr.xjlib.appkit.gview.object.GElement)

Aggregations

GElement (org.antlr.xjlib.appkit.gview.object.GElement)1 SLinkArc (org.antlr.xjlib.appkit.gview.shape.SLinkArc)1 SLinkElbow (org.antlr.xjlib.appkit.gview.shape.SLinkElbow)1