use of org.antlr.xjlib.appkit.gview.base.Rect 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.base.Rect in project antlrworks by antlr.
the class GView method autoAdjustSize.
public void autoAdjustSize() {
if (rootElement == null || !autoAdjustSize)
return;
Rect bounds = rootElement.bounds();
setRealSize((int) ((bounds.r.x + bounds.r.width) * zoom), (int) ((bounds.r.y + bounds.r.height) * zoom));
if (delegate != null)
delegate.viewSizeDidChange();
}
use of org.antlr.xjlib.appkit.gview.base.Rect in project antlrworks by antlr.
the class GView method scrollElementToVisible.
public void scrollElementToVisible(GElement element) {
Rectangle r;
Rect frame = element.getFrame();
if (frame == null)
r = new Rectangle((int) element.getPositionX(), (int) element.getPositionY(), 1, 1);
else
r = frame.r;
// Scale according to the current zoom
r.x *= zoom;
r.y *= zoom;
r.width *= zoom;
r.height *= zoom;
// Add some margin to make the element "more" visible
r.x -= SCROLL_TO_VISIBLE_MARGIN;
r.y -= SCROLL_TO_VISIBLE_MARGIN;
r.width += 2 * SCROLL_TO_VISIBLE_MARGIN;
r.height += 2 * SCROLL_TO_VISIBLE_MARGIN;
scrollRectToVisible(r);
//new XJSmoothScrolling(this, r, null);
}