use of org.whole.lang.ui.figures.INodeFigure in project whole by wholeplatform.
the class NodeWithCompositeBranchFigure method paintConnections.
@SuppressWarnings("unchecked")
protected void paintConnections(Graphics g) {
IFigure contentPane = getContentPane(getChildrenPaneIndex());
if (contentPane.isVisible()) {
// TODO test if needed
if (contentPane.getChildren().isEmpty())
return;
ConnectionAnchor[] srcAnchors = getSourceAnchors();
Point sourceLocation = srcAnchors[0].getLocation(null);
List<Point> targetLocations = new ArrayList<>();
for (IFigure targetFigure : (List<IFigure>) contentPane.getChildren()) {
if (targetFigure instanceof INodeFigure) {
INodeFigure targetNode = (INodeFigure) targetFigure;
for (int i = 0; i < targetNode.getTargetAnchorsSize(); i++) {
Point t = targetNode.getTargetAnchor(i).getLocation(sourceLocation);
translateToRelative(t);
targetLocations.add(t);
}
} else {
Point t = targetFigure.getBounds().getLeft();
targetFigure.translateToAbsolute(t);
translateToRelative(t);
targetLocations.add(t);
}
}
translateToRelative(sourceLocation);
g.setForegroundColor(FigureConstants.relationsColor);
DrawUtils.drawHorizontalTree(g, sourceLocation, DrawUtils.SPACING / 2 + 2, targetLocations.toArray(new Point[targetLocations.size()]));
}
}
use of org.whole.lang.ui.figures.INodeFigure in project whole by wholeplatform.
the class XsiCompositeElementNodeFigure method paintConnections.
protected void paintConnections(Graphics graphics) {
IFigure contentsFigure = getContentPane(getContentPanesSize() - 1);
int compositeChildrenNumber = contentsFigure.getChildren().size();
if (compositeChildrenNumber == 0)
return;
Point[] childs = new Point[compositeChildrenNumber];
for (int i = 0; i < compositeChildrenNumber; i++) {
IFigure compositeChild = (IFigure) contentsFigure.getChildren().get(i);
// calculate target point position
Point targetLocation;
if (compositeChild instanceof INodeFigure)
targetLocation = ((INodeFigure) compositeChild).getTargetAnchor(0).getLocation(null);
else {
Rectangle compositeChildBounds = compositeChild.getBounds();
targetLocation = compositeChildBounds.getLeft();
compositeChild.translateToAbsolute(targetLocation);
}
translateToRelative(targetLocation);
childs[i] = targetLocation;
}
Point start = getSourceAnchor(0).getLocation(null);
translateToRelative(start);
graphics.setForegroundColor(ColorConstants.lightGray);
graphics.setLineDash(new int[] { 1, 1 });
DrawUtils.drawOutline(graphics, start, childs);
}
use of org.whole.lang.ui.figures.INodeFigure in project whole by wholeplatform.
the class XsiSimpleStructuralFigure method findTargetAnchors.
@SuppressWarnings("unchecked")
public static List<ConnectionAnchor> findTargetAnchors(IFigure figure) {
List<ConnectionAnchor> anchors = new ArrayList<ConnectionAnchor>();
List<IFigure> children = figure.getChildren();
for (int i = 0; i < children.size(); i++) {
IFigure child = children.get(i);
if (child instanceof INodeFigure) {
INodeFigure nodeFigure = (INodeFigure) child;
for (int j = 0, size = nodeFigure.getTargetAnchorsSize(); j < size; j++) anchors.add(nodeFigure.getTargetAnchor(j));
} else
anchors.addAll(findTargetAnchors(child));
}
return anchors;
}
use of org.whole.lang.ui.figures.INodeFigure in project whole by wholeplatform.
the class CompositeEntityTreeFigure method paintConnections.
protected void paintConnections(Graphics graphics) {
// paint composite connections
graphics.setForegroundColor(FigureConstants.relationsColor);
IFigure compositeFigure = getContentPane(0);
if (compositeFigure.isVisible()) {
int compositeChildrenNumber = compositeFigure.getChildren().size();
if (compositeChildrenNumber == 0)
return;
Point mainToggleLocation = isRightToLeft() ? mainToggle.getBounds().getLeft() : mainToggle.getBounds().getRight();
// translateToRelative(mainToggleLocation);
Point[] childs = new Point[compositeChildrenNumber];
for (int i = 0; i < compositeChildrenNumber; i++) {
IFigure compositeChild = (IFigure) compositeFigure.getChildren().get(i);
// calculate target point position
Point targetLocation;
if (compositeChild instanceof INodeFigure)
targetLocation = ((INodeFigure) compositeChild).getTargetAnchor(0).getLocation(null);
else {
Rectangle compositeChildBounds = compositeChild.getBounds();
targetLocation = isRightToLeft() ? compositeChildBounds.getRight() : compositeChildBounds.getLeft();
compositeChild.translateToAbsolute(targetLocation);
}
translateToRelative(targetLocation);
childs[i] = targetLocation;
}
DrawUtils.drawHorizontalTree(graphics, mainToggleLocation, DrawUtils.SPACING / 2, childs);
}
}
use of org.whole.lang.ui.figures.INodeFigure in project whole by wholeplatform.
the class SimpleEntityTreeFigure method paintConnections.
protected void paintConnections(Graphics graphics) {
if (contents.isVisible()) {
graphics.setForegroundColor(FigureConstants.relationsColor);
int egdeXOffset = DrawUtils.SPACING - DrawUtils.EDGE_SPACING;
ConnectionAnchor[] srcAnchors = getSourceAnchors();
int i;
int prevYSourceLocation = Integer.MAX_VALUE;
for (i = 0; i < srcAnchors.length; i++) {
IFigure contentPane = getContentPane(i);
if (contentPane.isVisible()) {
IFigure targetFigure = (IFigure) contentPane.getChildren().get(0);
Point sourceLocation = srcAnchors[i].getLocation(null);
Point targetLocation = null;
if (targetFigure instanceof INodeFigure)
targetLocation = ((INodeFigure) targetFigure).getTargetAnchor(0).getLocation(null);
else {
targetLocation = isRightToLeft() ? targetFigure.getBounds().getRight() : targetFigure.getBounds().getLeft();
targetFigure.translateToAbsolute(targetLocation);
}
translateToRelative(targetLocation);
translateToRelative(sourceLocation);
if (targetLocation.y > sourceLocation.y)
break;
if (prevYSourceLocation >= targetLocation.y - 1)
egdeXOffset += DrawUtils.EDGE_SPACING;
prevYSourceLocation = sourceLocation.y;
DrawUtils.drawHorizontalEdge(graphics, sourceLocation, targetLocation, egdeXOffset);
}
}
egdeXOffset = DrawUtils.SPACING - DrawUtils.EDGE_SPACING;
prevYSourceLocation = Integer.MIN_VALUE;
for (int j = srcAnchors.length - 1; j >= i; j--) {
IFigure contentPane = getContentPane(j);
if (contentPane.isVisible()) {
IFigure targetFigure = (IFigure) contentPane.getChildren().get(0);
Point sourceLocation = srcAnchors[j].getLocation(null);
Point targetLocation = null;
if (targetFigure instanceof INodeFigure)
targetLocation = ((INodeFigure) targetFigure).getTargetAnchor(0).getLocation(null);
else {
targetLocation = isRightToLeft() ? targetFigure.getBounds().getRight() : targetFigure.getBounds().getLeft();
targetFigure.translateToAbsolute(targetLocation);
}
translateToRelative(targetLocation);
translateToRelative(sourceLocation);
if (prevYSourceLocation <= targetLocation.y + 1)
egdeXOffset += DrawUtils.EDGE_SPACING;
prevYSourceLocation = sourceLocation.y;
DrawUtils.drawHorizontalEdge(graphics, sourceLocation, targetLocation, egdeXOffset);
}
}
}
}
Aggregations