Search in sources :

Example 1 with INodeFigure

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;
    }
}
Also used : ConnectionAnchor(org.eclipse.draw2d.ConnectionAnchor) INodeFigure(org.whole.lang.ui.figures.INodeFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with INodeFigure

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);
    }
}
Also used : CompositeFigure(org.whole.lang.ui.figures.CompositeFigure) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) INodeFigure(org.whole.lang.ui.figures.INodeFigure) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure)

Example 3 with INodeFigure

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);
    }
}
Also used : INodeFigure(org.whole.lang.ui.figures.INodeFigure) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure)

Example 4 with INodeFigure

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);
}
Also used : ConnectionAnchor(org.eclipse.draw2d.ConnectionAnchor) INodeFigure(org.whole.lang.ui.figures.INodeFigure) Point(org.eclipse.draw2d.geometry.Point)

Example 5 with INodeFigure

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);
    }
}
Also used : ConnectionAnchor(org.eclipse.draw2d.ConnectionAnchor) INodeFigure(org.whole.lang.ui.figures.INodeFigure) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

INodeFigure (org.whole.lang.ui.figures.INodeFigure)13 IFigure (org.eclipse.draw2d.IFigure)11 Point (org.eclipse.draw2d.geometry.Point)11 ConnectionAnchor (org.eclipse.draw2d.ConnectionAnchor)7 Rectangle (org.eclipse.draw2d.geometry.Rectangle)4 ArrayList (java.util.ArrayList)3 IEntityFigure (org.whole.lang.ui.figures.IEntityFigure)2 List (java.util.List)1 CompositeFigure (org.whole.lang.ui.figures.CompositeFigure)1