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);
}
}
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();
}
Aggregations