Search in sources :

Example 6 with GElement

use of org.antlr.xjlib.appkit.gview.object.GElement in project antlrworks by antlr.

the class GView method selectElementsInRect.

public void selectElementsInRect(int x, int y, int dx, int dy) {
    Rect rectangle = new Rect(x, y, dx, dy);
    if (rootElement == null || rootElement.getElements() == null)
        return;
    for (GElement element : rootElement.getElements()) {
        boolean selected = Rect.intersect(rectangle, element.bounds());
        element.setSelected(selected);
        if (selected)
            addSelectedElement(element);
        else
            removeSelectedElement(element);
    }
}
Also used : Rect(org.antlr.xjlib.appkit.gview.base.Rect) GElement(org.antlr.xjlib.appkit.gview.object.GElement)

Example 7 with GElement

use of org.antlr.xjlib.appkit.gview.object.GElement in project antlrworks by antlr.

the class GEventCreateLinkElement method updateLink.

public void updateLink(Point mouse) {
    GElement ce = delegate.eventQueryElementAtPoint(mouse);
    boolean selfLoop = ce == startElement;
    setLinkStartAnchor(startElement.getAnchor(startAnchorKey));
    if (ce == null || ce instanceof GLink) {
        setLinkEnd(Vector2D.vector(mouse), Anchor2D.DIRECTION_BOTTOM);
    } else {
        Anchor2D anchor = ce.getAnchorClosestToPoint(mouse);
        String anchorKey = ce.getAnchorKeyClosestToPoint(mouse);
        setLinkEnd(anchor.position, anchor.direction);
        if (selfLoop) {
            if (anchor.direction == Anchor2D.DIRECTION_FREE)
                linkArc.setMouse(mouse);
            else
                linkArc.setMouse(anchor.position.add(anchor.direction));
            linkArc.setEndTangentOffset(startElement.getDefaultAnchorOffset(anchorKey));
        } else {
            linkArc.setMouse(mouse);
            linkArc.setEndTangentOffset(ce.getDefaultAnchorOffset(anchorKey));
        }
        if (selfLoop && view.defaultLinkShape() == GLink.SHAPE_ELBOW && startElement.getAnchor(startAnchorKey).equals(anchor)) {
            linkElement = linkArc;
        } else if (view.defaultLinkShape() == GLink.SHAPE_ELBOW)
            linkElement = linkElbow;
        else if (view.defaultLinkShape() == GLink.SHAPE_ARC)
            linkElement = linkArc;
    }
    setLinkSelfLoop(selfLoop);
    linkElement.update();
}
Also used : Anchor2D(org.antlr.xjlib.appkit.gview.base.Anchor2D) GElement(org.antlr.xjlib.appkit.gview.object.GElement) GLink(org.antlr.xjlib.appkit.gview.object.GLink)

Aggregations

GElement (org.antlr.xjlib.appkit.gview.object.GElement)7 GLink (org.antlr.xjlib.appkit.gview.object.GLink)3 Vector2D (org.antlr.xjlib.appkit.gview.base.Vector2D)2 Anchor2D (org.antlr.xjlib.appkit.gview.base.Anchor2D)1 Rect (org.antlr.xjlib.appkit.gview.base.Rect)1 SLinkArc (org.antlr.xjlib.appkit.gview.shape.SLinkArc)1 SLinkElbow (org.antlr.xjlib.appkit.gview.shape.SLinkElbow)1