Search in sources :

Example 11 with INodeFigure

use of org.whole.lang.ui.figures.INodeFigure in project whole by wholeplatform.

the class SimpleEntityTreeTableFigure method paintConnections.

@SuppressWarnings("unchecked")
protected void paintConnections(Graphics g) {
    g.setForegroundColor(FigureConstants.relationsColor);
    List<IFigure> contentPanes = contentsFigure.getChildren();
    int contentPanesSize = contentPanes.size();
    Point[] start = new Point[contentPanesSize];
    Point[] end = new Point[contentPanesSize];
    int nodeRight = nodeFigure.getBounds().right();
    int size = 0;
    for (int i = 0; i < contentPanesSize; i++) {
        IFigure contentPane = contentPanes.get(i);
        if (contentPane.isVisible()) {
            start[size] = getFoldingToggle(i + 1).getBounds().getRight();
            start[size].x = nodeRight;
            List<IFigure> children = contentPane.getChildren();
            IFigure targetFigure = children.isEmpty() ? null : (IFigure) children.get(0);
            if (targetFigure instanceof INodeFigure) {
                end[size] = ((INodeFigure) targetFigure).getTargetAnchor(0).getLocation(null);
                translateToRelative(end[size]);
            } else
                end[size] = targetFigure == null ? start[size] : targetFigure.getBounds().getLeft();
            size++;
        }
    }
    DrawUtils.drawRightEdges(g, start, end, size);
}
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 12 with INodeFigure

use of org.whole.lang.ui.figures.INodeFigure in project whole by wholeplatform.

the class SimpleTableNodeWithBranchesFigure method paintConnections.

protected void paintConnections(Graphics g) {
    g.setForegroundColor(FigureConstants.relationsColor);
    int egdeXOffset = DrawUtils.SPACING - DrawUtils.EDGE_SPACING;
    ConnectionAnchor[] srcAnchors = getSourceAnchors();
    int i, j, pi = 0;
    int prevYSourceLocation = Integer.MAX_VALUE;
    for (i = 0, pi = 0; i < srcAnchors.length; i++, pi++) {
        while (featuresStyling[pi].isEmbedded()) pi++;
        IFigure contentPane = getContentPane(typePaneShift + pi);
        if (contentPane.isVisible()) {
            // TODO test if needed
            if (contentPane.getChildren().isEmpty())
                return;
            Point sourceLocation = srcAnchors[i].getLocation(null);
            int yMax = 0;
            IFigure targetFigure = (IFigure) contentPane.getChildren().get(0);
            List<Point> targetLocations = new ArrayList<>();
            if (targetFigure instanceof INodeFigure) {
                INodeFigure targetNode = (INodeFigure) targetFigure;
                for (int ti = 0; ti < targetNode.getTargetAnchorsSize(); ti++) {
                    Point t = targetNode.getTargetAnchor(ti).getLocation(sourceLocation);
                    translateToRelative(t);
                    targetLocations.add(t);
                    yMax = Math.max(yMax, t.y);
                }
            } else {
                Point t = targetFigure.getBounds().getLeft();
                targetFigure.translateToAbsolute(t);
                translateToRelative(t);
                targetLocations.add(t);
                yMax = Math.max(yMax, t.y);
            }
            translateToRelative(sourceLocation);
            if (yMax > sourceLocation.y)
                break;
            if (prevYSourceLocation >= yMax - 1)
                egdeXOffset += DrawUtils.EDGE_SPACING;
            prevYSourceLocation = sourceLocation.y;
            DrawUtils.drawHorizontalTree(g, sourceLocation, egdeXOffset, targetLocations.toArray(new Point[targetLocations.size()]));
        }
    }
    egdeXOffset = DrawUtils.SPACING - DrawUtils.EDGE_SPACING;
    prevYSourceLocation = Integer.MIN_VALUE;
    for (j = srcAnchors.length - 1, pi = featuresStyling.length - 1; j >= i; j--, pi--) {
        while (featuresStyling[pi].isEmbedded()) pi--;
        IFigure contentPane = getContentPane(typePaneShift + pi);
        if (contentPane.isVisible()) {
            // TODO test if needed
            if (contentPane.getChildren().isEmpty())
                return;
            Point sourceLocation = srcAnchors[j].getLocation(null);
            int yMax = 0;
            IFigure targetFigure = (IFigure) contentPane.getChildren().get(0);
            List<Point> targetLocations = new ArrayList<>();
            if (targetFigure instanceof INodeFigure) {
                INodeFigure targetNode = (INodeFigure) targetFigure;
                for (int ti = 0; ti < targetNode.getTargetAnchorsSize(); ti++) {
                    Point t = targetNode.getTargetAnchor(ti).getLocation(sourceLocation);
                    translateToRelative(t);
                    targetLocations.add(t);
                    yMax = Math.max(yMax, t.y);
                }
            } else {
                Point t = targetFigure.getBounds().getLeft();
                targetFigure.translateToAbsolute(t);
                translateToRelative(t);
                targetLocations.add(t);
                yMax = Math.max(yMax, t.y);
            }
            translateToRelative(sourceLocation);
            if (prevYSourceLocation <= yMax + 1)
                egdeXOffset += DrawUtils.EDGE_SPACING;
            prevYSourceLocation = sourceLocation.y;
            DrawUtils.drawHorizontalTree(g, sourceLocation, egdeXOffset, targetLocations.toArray(new Point[targetLocations.size()]));
        }
    }
}
Also used : ConnectionAnchor(org.eclipse.draw2d.ConnectionAnchor) INodeFigure(org.whole.lang.ui.figures.INodeFigure) ArrayList(java.util.ArrayList) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure)

Example 13 with INodeFigure

use of org.whole.lang.ui.figures.INodeFigure in project whole by wholeplatform.

the class AbstractOutlineSimpleNodeFigure method addChildrenLocations.

protected void addChildrenLocations(Point reference, List<Point> childrenLocations, IFigure featureChild) {
    if (featureChild instanceof INodeFigure) {
        for (Point targetLocation : ((INodeFigure) featureChild).getTargetAnchorLocations(reference)) {
            translateToRelative(targetLocation);
            childrenLocations.add(targetLocation);
        }
    } else {
        Rectangle featureChildBounds = featureChild.getBounds();
        Point targetLocation = featureChildBounds.getLeft();
        if (featureChild instanceof IEntityFigure)
            targetLocation.y = featureChildBounds.y + ((IEntityFigure) featureChild).getAscent();
        featureChild.translateToAbsolute(targetLocation);
        translateToRelative(targetLocation);
        childrenLocations.add(targetLocation);
    }
}
Also used : 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)

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