Search in sources :

Example 6 with IEntityFigure

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

the class ConcatenateFigure method paintFigure.

@SuppressWarnings("unchecked")
protected void paintFigure(Graphics g) {
    super.paintFigure(g);
    ICompositeEntityLayout lm = getLayoutManager();
    int baseline = getBounds().y + getAscent();
    int x = getBounds().x;
    int y = baseline;
    g.drawLine(x - 1, baseline, x + lm.getMarginLeft() + 1, baseline);
    List<IFigure> children = (List<IFigure>) getChildren();
    int size = children.size();
    int interline = 0;
    int py = 0;
    IEntityFigure childFigure;
    Rectangle childBounds = null;
    Rectangle prevBounds = null;
    if (size > 1) {
        childFigure = (IEntityFigure) children.get(0);
        childBounds = childFigure.getBounds();
        y = childBounds.y + childFigure.getAscent();
        for (int i = 1; i < size; i++) {
            interline = Math.max(interline, childBounds.bottom() + 4);
            prevBounds = childBounds;
            py = y;
            childFigure = (IEntityFigure) children.get(i);
            childBounds = childFigure.getBounds();
            x = childBounds.x - 1;
            y = childBounds.y + childFigure.getAscent();
            if (y > py) {
                int px = prevBounds.right() + 1;
                g.drawLine(px - 2, py, px, py);
                g.drawLine(px, py, px, interline);
                g.drawLine(x - lm.getSpacingBefore(i) / 2, interline, px, interline);
                g.drawLine(x - lm.getSpacingBefore(i) / 2, interline, x - lm.getSpacingBefore(i) / 2, y);
                interline = 0;
            }
            g.drawLine(x - lm.getSpacingBefore(i), y, x + 1, y);
        }
    }
    int right = getBounds().right() - 1;
    int lastX = childBounds != null ? childBounds.right() - 1 : right - lm.getMarginRight();
    g.drawLine(lastX, y, right, y);
    g.drawLine(right, y, right, baseline);
}
Also used : ICompositeEntityLayout(org.whole.lang.ui.layout.ICompositeEntityLayout) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) Rectangle(org.eclipse.draw2d.geometry.Rectangle) List(java.util.List) IFigure(org.eclipse.draw2d.IFigure)

Example 7 with IEntityFigure

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

the class BlockBracketsBorder method paint.

@SuppressWarnings("unchecked")
public void paint(IFigure f, Graphics g, Insets i) {
    List<IFigure> children = (List<IFigure>) f.getChildren();
    int yLast = 0;
    int baselineLast = 0;
    int size = children.size();
    if (size > 1) {
        IFigure lastChildFigure = children.get(size - 1);
        Rectangle boundsLast = lastChildFigure.getBounds();
        yLast = boundsLast.y;
        if (lastChildFigure instanceof IEntityFigure)
            baselineLast = ((IEntityFigure) lastChildFigure).getAscent();
        else
            baselineLast = boundsLast.height / 2;
    }
    Rectangle r = getPaintRectangle(f, i);
    r.width--;
    r.height--;
    int leftX = r.x + HPIPE;
    int rightX = r.right() - HPIPE;
    int centerY = yLast == 0 ? r.y + r.height / 2 : yLast + baselineLast;
    g.setForegroundColor(getDelimiterColor());
    if (insets.left > 0) {
        g.drawArc(leftX, r.y, HSIZE1, HSIZE1 * 2, 90, 90);
        if (r.height > HSIZE) {
            if (yLast == 0)
                g.drawLine(leftX, r.y + HSIZE, leftX, centerY - HSIZE);
            else
                g.drawLine(leftX, yLast - HSIZE1, leftX, centerY - HSIZE);
            g.drawArc(leftX - HSIZE1, centerY - HSIZE1 * 2, HSIZE1, HSIZE1 * 2, 270, 90);
            g.drawArc(leftX - HSIZE1, centerY, HSIZE1, HSIZE1 * 2, 0, 90);
            g.drawLine(leftX, centerY + HSIZE, leftX, r.bottom() - HSIZE);
        }
        g.drawArc(leftX, r.bottom() - HSIZE1 * 2, HSIZE1, HSIZE1 * 2, 180, 90);
    }
    if (insets.right > 0) {
        g.drawArc(rightX - HSIZE1, r.y, HSIZE1, HSIZE1 * 2, 0, 90);
        if (r.height > HSIZE) {
            if (yLast == 0)
                g.drawLine(rightX, r.y + HSIZE, rightX, centerY - HSIZE);
            else
                g.drawLine(rightX, yLast - HSIZE1, rightX, centerY - HSIZE);
            g.drawArc(rightX, centerY - HSIZE1 * 2, HSIZE1, HSIZE1 * 2, 180, 90);
            g.drawArc(rightX, centerY, HSIZE1, HSIZE1 * 2, 90, 90);
            g.drawLine(rightX, centerY + HSIZE, rightX, r.bottom() - HSIZE);
        }
        g.drawArc(rightX - HSIZE1, r.bottom() - HSIZE1 * 2, HSIZE1, HSIZE1 * 2, 0, -90);
    }
    if (yLast > 0) {
        g.setLineStyle(SWT.LINE_CUSTOM);
        g.setLineDash(new int[] { 5, 2 });
        if (insets.left > 0 && r.height > HSIZE)
            g.drawLine(leftX, r.y + HSIZE, leftX, yLast - HSIZE1 - 1);
        if (insets.right > 0 && r.height > HSIZE)
            g.drawLine(rightX, r.y + HSIZE, rightX, yLast);
        g.setLineStyle(SWT.LINE_SOLID);
        g.setLineDash((int[]) null);
    }
}
Also used : IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) Rectangle(org.eclipse.draw2d.geometry.Rectangle) List(java.util.List) IFigure(org.eclipse.draw2d.IFigure)

Example 8 with IEntityFigure

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

the class TableLayout method updateMyTabularLayoutServer.

public void updateMyTabularLayoutServer(IFigure container) {
    if (tableInlining) {
        IFigure parent = container.getParent();
        ITabularLayoutServer tls = (parent instanceof IEntityFigure) ? ((IEntityFigure) parent).getTabularLayoutServer() : null;
        if (tls != null)
            myTabularLayoutServer = tls;
    }
}
Also used : IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 9 with IEntityFigure

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

the class PathPart method createFigure.

protected IFigure createFigure() {
    IFigure f = new StringSeparatedCompositeRowFigure("/", new RowLayout().withMarginLeft(8).withMarginRight(5).withSpacing(8)) {

        @Override
        public Color getLocalForegroundColor() {
            return ColorConstants.gray;
        }

        @Override
        protected Font getLocalFont() {
            return FigureConstants.symbolFontLarge;
        }

        @SuppressWarnings("unchecked")
        protected void paintDecorations(Graphics g) {
            // workaround for LabelFactory.createModule
            g.setFont(FigureConstants.symbolFontLarge);
            int spacing = Math.max(1, getLayoutManager().getSpacing() / 5);
            // getSeparatorAscent();
            int separatorAscent = FigureUtilities.getFontMetrics(g.getFont()).getHeight() / 2;
            List<IEntityFigure> children = (List<IEntityFigure>) getChildren();
            if (!children.isEmpty()) {
                for (int i = 0; i < children.size() - 1; i++) {
                    IEntityFigure childFigure = children.get(i);
                    Rectangle childBounds = childFigure.getBounds();
                    g.drawString(separator, childBounds.right() + spacing, childBounds.y + childFigure.getAscent() - separatorAscent);
                }
                IEntityFigure childFigure = children.get(0);
                Rectangle childBounds = childFigure.getBounds();
                g.setForegroundColor(ColorConstants.lightGray);
                g.drawString(separator, childBounds.x - getLayoutManager().getMarginLeft() + 1, childBounds.y + childFigure.getAscent() - separatorAscent);
            }
        }
    };
    return f;
}
Also used : Graphics(org.eclipse.draw2d.Graphics) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) RowLayout(org.whole.lang.ui.layout.RowLayout) Rectangle(org.eclipse.draw2d.geometry.Rectangle) List(java.util.List) StringSeparatedCompositeRowFigure(org.whole.lang.ui.figures.StringSeparatedCompositeRowFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 10 with IEntityFigure

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

the class RepetitionPart method createFigure.

protected IFigure createFigure() {
    return new TypeNameValueTableRowFigure() {

        @Override
        protected IEntityFigure createValueFigure(int paneIndex) {
            EntityFigure row = new EntityFigure(new RowLayout());
            row.add(createContentPane(paneIndex));
            row.add(LabelFactory.createSymbolMediumContentLighter("\u2026"));
            row.addContentLight(" ordered");
            return row;
        }
    };
}
Also used : TypeNameValueTableRowFigure(org.whole.lang.ui.figures.TypeNameValueTableRowFigure) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) EntityFigure(org.whole.lang.ui.figures.EntityFigure) RowLayout(org.whole.lang.ui.layout.RowLayout)

Aggregations

IEntityFigure (org.whole.lang.ui.figures.IEntityFigure)25 IFigure (org.eclipse.draw2d.IFigure)10 Rectangle (org.eclipse.draw2d.geometry.Rectangle)6 IEntity (org.whole.lang.model.IEntity)5 EntityFigure (org.whole.lang.ui.figures.EntityFigure)5 Point (org.eclipse.draw2d.geometry.Point)4 TableFigure (org.whole.lang.ui.figures.TableFigure)4 List (java.util.List)3 Graphics (org.eclipse.draw2d.Graphics)3 CompositeFigure (org.whole.lang.ui.figures.CompositeFigure)3 TableRowFigure (org.whole.lang.ui.figures.TableRowFigure)3 RowLayout (org.whole.lang.ui.layout.RowLayout)3 TableLayout (org.whole.lang.ui.layout.TableLayout)3 Dimension (org.eclipse.draw2d.geometry.Dimension)2 FeatureDescriptorEnum (org.whole.lang.reflect.FeatureDescriptorEnum)2 IGraphicalEntityPart (org.whole.lang.ui.editparts.IGraphicalEntityPart)2 INodeFigure (org.whole.lang.ui.figures.INodeFigure)2 StringSeparatedCompositeRowFigure (org.whole.lang.ui.figures.StringSeparatedCompositeRowFigure)2 ICompositeEntityLayout (org.whole.lang.ui.layout.ICompositeEntityLayout)2 Label (org.eclipse.draw2d.Label)1