Search in sources :

Example 1 with IEntityFigure

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

the class EntityOutlineRightFigure method paintConnections.

@SuppressWarnings("unchecked")
protected void paintConnections(Graphics graphics) {
    graphics.setForegroundColor(FigureConstants.contentLighterColor);
    Point rootPoint = getFoldingToggle(0).getBounds().getBottom();
    Object childrenFigure = getContentPane(1).getChildren().get(0);
    Point[] childrenPoints = null;
    if (childrenFigure instanceof TableFigure) {
        TableFigure tableFigure = (TableFigure) childrenFigure;
        TableLayout layoutManager = tableFigure.getLayoutManager();
        int childrenSize = layoutManager.rows();
        childrenPoints = new Point[childrenSize];
        if (childrenSize == 0)
            return;
        for (int i = 0; i < childrenSize; i++) {
            IFigure row = layoutManager.getRow(i);
            List<IFigure> rowChildren = row.getChildren();
            if (row instanceof TableRowFigure && !rowChildren.isEmpty()) {
                childrenPoints[i] = row.getBounds().getLeft().translate(-8, 0);
                childrenPoints[i].y = ((TableRowLayout) row.getLayoutManager()).getBaseline(0);
            } else if (row instanceof IEntityFigure) {
                childrenPoints[i] = row.getBounds().getTopLeft().translate(-4, ((IEntityFigure) row).getAscent());
            } else
                childrenPoints[i] = row.getBounds().getLeft().translate(-4, 0);
        }
    } else {
        IFigure childFigure = (IFigure) childrenFigure;
        List<IFigure> children = childFigure.getChildren();
        int childrenSize = children.size();
        if (childrenSize == 0 || childFigure instanceof ITextFigure) {
            childrenPoints = new Point[1];
            if (childFigure instanceof IEntityFigure)
                childrenPoints[0] = childFigure.getBounds().getTopLeft().translate(-4, ((IEntityFigure) childFigure).getAscent());
            else
                childrenPoints[0] = childFigure.getBounds().getLeft().translate(-4, 0);
        } else {
            childrenPoints = new Point[childrenSize];
            for (int i = 0; i < childrenSize; i++) {
                childFigure = children.get(i);
                if (childFigure instanceof IEntityFigure)
                    childrenPoints[i] = childFigure.getBounds().getTopLeft().translate(-6, ((IEntityFigure) childFigure).getAscent());
                else
                    childrenPoints[i] = childFigure.getBounds().getLeft().translate(-6, 0);
            }
        }
    }
    graphics.setForegroundColor(ColorConstants.lightGray);
    graphics.setLineStyle(SWT.LINE_CUSTOM);
    graphics.setLineDash(new int[] { 1, 1 });
    DrawUtils.drawOutline(graphics, rootPoint, childrenPoints);
    graphics.setLineStyle(SWT.LINE_SOLID);
    graphics.setLineDash((int[]) null);
}
Also used : TableRowFigure(org.whole.lang.ui.figures.TableRowFigure) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) ITextFigure(org.whole.lang.ui.figures.ITextFigure) TableFigure(org.whole.lang.ui.figures.TableFigure) Point(org.eclipse.draw2d.geometry.Point) TableLayout(org.whole.lang.ui.layout.TableLayout) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with IEntityFigure

use of org.whole.lang.ui.figures.IEntityFigure 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 IEntityFigure

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

the class AbstractConnectedFreeformRootPart method createFigure.

protected IFigure createFigure() {
    // Figure figure = new FreeformLayer();
    IEntityFigure figure = new EntityFigure() {

        {
            setLayoutManager(new EntityXYLayout());
            setOpaque(false);
        }

        // FIXME workaround
        public int getIndent() {
            return getInsets().left;
        }

        public int getAscent() {
            return getPreferredSize().height / 2;
        }

        public static final int MINIMUM_SIZE = 50;

        public Dimension getPreferredSize(int wHint, int hHint) {
            Dimension size = super.getPreferredSize(wHint, hHint);
            size.width = Math.max(size.width, MINIMUM_SIZE);
            size.height = Math.max(size.height, MINIMUM_SIZE);
            return size;
        }
    };
    // figure.setLayoutManager(new EntityXYLayout());
    // figure.setOpaque(false);
    setConnectionRouter(createConnectionRouter(figure));
    return figure;
}
Also used : IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) EntityFigure(org.whole.lang.ui.figures.EntityFigure) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) Dimension(org.eclipse.draw2d.geometry.Dimension) EntityXYLayout(org.whole.lang.ui.layout.EntityXYLayout)

Example 4 with IEntityFigure

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

the class AbstractContentPanePart method getContentPane.

public IFigure getContentPane(EditPart childEditPart) {
    IFigure childFigure = ((GraphicalEditPart) childEditPart).getFigure();
    IFigure childParentFigure = childFigure.getParent();
    IEntityFigure cpFigure = getContentPaneFigure();
    for (int i = 0; i < cpFigure.getContentPanesSize(); i++) if (childParentFigure == cpFigure.getContentPane(i))
        return childParentFigure;
    return getContentPane();
}
Also used : IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IFigure(org.eclipse.draw2d.IFigure)

Example 5 with IEntityFigure

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

the class RootFragmentPart method createFigure.

protected IFigure createFigure() {
    // Figure f = new FreeformLayer() {
    IEntityFigure f = new EntityFigure() {

        {
            setOpaque(false);
        }

        @Override
        public void paint(Graphics graphics) {
            graphics.setAdvanced(true);
            graphics.setAntialias(SWT.ON);
            super.paint(graphics);
        }

        protected void paintFigure(Graphics graphics) {
            super.paintFigure(graphics);
            Rectangle r2 = ((IFigure) getChildren().get(0)).getBounds();
            translateToParent(r2 = r2.getCopy());
            Rectangle clipArea = graphics.getClip(new Rectangle()).expand(1, 1);
            graphics.fillRectangle(clipArea);
            graphics.setBackgroundColor(FigureConstants.hostLanguageColor);
            graphics.fillRectangle(clipArea.intersect(r2));
            graphics.setLineWidth(1);
            graphics.setLineStyle(Graphics.LINE_SOLID);
            graphics.setXORMode(false);
            IEntity rootEntity = ((RootFragment) getModelEntity()).getRootEntity().wGetAdaptee(false);
            if (rootEntity.wGetParent() instanceof RootFragment) {
                clipArea = graphics.getClip(new Rectangle()).expand(1, 1);
                int oldAlpha = graphics.getAlpha();
                graphics.setAlpha(60);
                graphics.setForegroundColor(ColorConstants.darkGray);
                graphics.setLineWidth(1);
                graphics.drawRectangle(r2.getTranslated(-1, -1).resize(1, 1));
                graphics.setForegroundColor(ColorConstants.lightGray);
                graphics.setLineWidth(5);
                graphics.drawRoundRectangle(r2.getTranslated(-4, -4).resize(7, 7), 10, 10);
                graphics.setAlpha(oldAlpha);
            } else {
                graphics.setForegroundColor(ColorConstants.lightGray);
                graphics.drawRectangle(r2.x - 1, r2.y - 1, r2.width + 1, r2.height + 1);
            }
        }

        public void validate() {
            super.validate();
            repaint();
        }
    };
    f.setLayoutManager(new StackLayout().withMargin(5).withMinorAlignment(Alignment.CENTER));
    f.setBackgroundColor(FigureUtilities.lighter(ColorConstants.gray));
    f.setOpaque(false);
    f.addLayoutListener(LayoutAnimator.getDefault());
    return f;
}
Also used : Graphics(org.eclipse.draw2d.Graphics) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) EntityFigure(org.whole.lang.ui.figures.EntityFigure) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) IEntity(org.whole.lang.model.IEntity) Rectangle(org.eclipse.draw2d.geometry.Rectangle) StackLayout(org.whole.lang.ui.layout.StackLayout) RootFragment(org.whole.lang.commons.model.RootFragment) IFigure(org.eclipse.draw2d.IFigure)

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