use of org.whole.lang.ui.figures.INodeFigure in project whole by wholeplatform.
the class ChildrenBranchesFigure method createTargetAnchors.
@Override
protected ConnectionAnchor[] createTargetAnchors() {
@SuppressWarnings("unchecked") List<IFigure> children = getContentPane(0).getChildren();
int childrenSize = children.size();
if (childrenSize == 0)
return NO_ANCHORS;
else {
ConnectionAnchor[] anchors = new ConnectionAnchor[childrenSize];
for (int i = 0; i < childrenSize; i++) {
IFigure child = children.get(i);
if (child instanceof INodeFigure) {
// TODO x size
anchors[i] = ((INodeFigure) child).getTargetAnchor(0);
} else
anchors[i] = AnchorFactory.createLeftMiddleAnchor(child);
}
return anchors;
}
}
use of org.whole.lang.ui.figures.INodeFigure in project whole by wholeplatform.
the class OutlineCompositeNodeFigure method paintConnections.
protected void paintConnections(Graphics graphics) {
IFigure contentPane = getContentPane(getContentPanesSize() - 1);
List<?> list = contentPane.getChildren();
if (contentPane.isVisible() && !list.isEmpty()) {
IFigure contentsFigure = (IFigure) list.get(0);
Point[] children;
if (contentsFigure instanceof CompositeFigure) {
int compositeChildrenNumber = contentsFigure.getChildren().size();
if (compositeChildrenNumber == 0)
return;
children = 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();
if (compositeChild instanceof IEntityFigure)
targetLocation.y = compositeChildBounds.y + ((IEntityFigure) compositeChild).getAscent();
compositeChild.translateToAbsolute(targetLocation);
}
translateToRelative(targetLocation);
children[i] = targetLocation;
}
} else {
children = new Point[1];
// calculate target point position
Point targetLocation;
if (contentsFigure instanceof INodeFigure)
targetLocation = ((INodeFigure) contentsFigure).getTargetAnchor(0).getLocation(null);
else {
Rectangle compositeChildBounds = contentsFigure.getBounds();
targetLocation = compositeChildBounds.getLeft();
if (contentsFigure instanceof IEntityFigure)
targetLocation.y = compositeChildBounds.y + ((IEntityFigure) contentsFigure).getAscent();
contentsFigure.translateToAbsolute(targetLocation);
}
translateToRelative(targetLocation);
children[0] = targetLocation;
}
Point start = getSourceAnchor(0).getLocation(null);
translateToRelative(start);
graphics.setForegroundColor(ColorConstants.lightGray);
graphics.setLineDash(new int[] { 1, 1 });
DrawUtils.drawOutline(graphics, start, children);
}
}
use of org.whole.lang.ui.figures.INodeFigure in project whole by wholeplatform.
the class CompositeEntityTreeTableNoEmbeddingFigure method paintConnections.
@SuppressWarnings("unchecked")
protected void paintConnections(Graphics g) {
List<IFigure> children = getContentPane(0).getChildren();
int childrenSize = children.size();
if (childrenSize > 0) {
Point start = getTargetAnchor(0).getLocation(null);
translateToRelative(start);
Point[] end = new Point[childrenSize];
for (int i = 0; i < childrenSize; i++) {
IFigure child = children.get(i);
if (child instanceof INodeFigure) {
end[i] = ((INodeFigure) child).getTargetAnchor(0).getLocation(null);
translateToRelative(end[i]);
} else
end[i] = child.getBounds().getLeft();
}
g.setForegroundColor(FigureConstants.relationsColor);
DrawUtils.drawHorizontalTree(g, start, DrawUtils.SPACING, end);
}
}
use of org.whole.lang.ui.figures.INodeFigure in project whole by wholeplatform.
the class AbstractStyledLayout method getChildPoint.
protected Point getChildPoint(int index, IFigure childFigure) {
if (childFigure instanceof INodeFigure) {
Point absoluteRootPoint = new Point(getRootPoint());
childFigure.translateToAbsolute(absoluteRootPoint);
ConnectionAnchor targetAnchor = ((INodeFigure) childFigure).getClosestTargetAnchor(absoluteRootPoint, getDistanceMetric());
if (targetAnchor != null) {
Point childPoint = targetAnchor.getLocation(absoluteRootPoint);
childFigure.translateToRelative(childPoint);
return childPoint;
}
}
return getChildPoint2(index, childFigure);
}
use of org.whole.lang.ui.figures.INodeFigure in project whole by wholeplatform.
the class RBNodeFigure method paintConnections.
protected void paintConnections(Graphics graphics) {
graphics.setForegroundColor(ColorConstants.black);
ConnectionAnchor[] srcAnchors = getSourceAnchors();
for (int i = 0; i < srcAnchors.length; i++) {
IFigure contentPane = getContentPane(i + 1);
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 = targetFigure.getBounds().getTop();
targetFigure.translateToAbsolute(targetLocation);
}
translateToRelative(targetLocation);
translateToRelative(sourceLocation);
graphics.drawLine(sourceLocation, targetLocation);
}
}
Aggregations