use of org.antlr.xjlib.appkit.gview.shape.SLinkElbow in project antlrworks by antlr.
the class AWTreeGraphView method addChildElement.
public void addChildElement(GElementNode parent, GElementNode child) {
/** Get the far right position of the last child */
double x = parent.getLastChildRightSpan();
/** Add a gap if there is already a child otherwise use the parent left coordinate */
if (x > 0)
x += HORIZONTAL_GAP;
else
x = parent.getLeft();
/** Set the child position */
child.setPositionOfUpperLeftCorner(x, parent.getBottom() + VERTICAL_GAP);
/** Create the link from the parent to this child */
GLink link = new GLink(parent, GLink.ANCHOR_BOTTOM, child, GLink.ANCHOR_TOP, GLink.SHAPE_ELBOW, "", 0);
link.setDraggable(DRAGGABLE);
/** Configure the link geometry */
SLinkElbow l = (SLinkElbow) link.getLink();
l.setOutOffsetLength(10);
l.getArrow().setLength(6);
/** Add the link and the child */
parent.addElement(link);
parent.addElement(child);
}
use of org.antlr.xjlib.appkit.gview.shape.SLinkElbow 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);
}
}
Aggregations