Search in sources :

Example 36 with Rectangle

use of org.eclipse.draw2d.geometry.Rectangle in project tdi-studio-se by Talend.

the class ColumnSash method outlineShape.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.draw2d.Shape#outlineShape(org.eclipse.draw2d.Graphics)
     */
@Override
protected void outlineShape(Graphics graphics) {
    float lineInset = Math.max(1.0f, getLineWidthFloat()) / 2.0f;
    int inset1 = (int) Math.floor(lineInset);
    int inset2 = (int) Math.ceil(lineInset);
    Rectangle r = Rectangle.SINGLETON.setBounds(getBounds());
    r.x += inset1;
    r.y += inset1;
    r.width -= inset1 + inset2;
    r.height -= inset1 + inset2;
    if (isMouseHover) {
        graphics.setForegroundColor(ColorConstants.orange);
    } else {
        graphics.setForegroundColor(ColorConstants.buttonLightest);
    }
    int X = r.x + r.width / 2;
    graphics.drawLine(X, r.y, X, r.y + r.height);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 37 with Rectangle

use of org.eclipse.draw2d.geometry.Rectangle in project tdi-studio-se by Talend.

the class TableEntityFigure method paintLines.

protected void paintLines(TableEntityFigure entity, Graphics graphics) {
    graphics.drawLine(entity.getElementBounds().x, entity.getElementBounds().getBottom().y - 1, entity.getElementBounds().getRight().x, entity.getElementBounds().getBottom().y - 1);
    List children = entity.getElement().getChildren();
    for (int i = 0; i < children.size() - 1; i++) {
        Figure child = (Figure) children.get(i);
        Rectangle childBounds = child.getBounds();
        graphics.drawLine(childBounds.getTopRight(), childBounds.getBottomRight());
    }
// final Rectangle expBounds = getElementBounds();
// graphics.drawLine(expBounds.x + expBounds.width, expBounds.y, expBounds.x + expBounds.width, getBounds().y
// + getBounds().height);
// paintChildrenLines(this, graphics);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) List(java.util.List) Figure(org.eclipse.draw2d.Figure)

Example 38 with Rectangle

use of org.eclipse.draw2d.geometry.Rectangle in project tdi-studio-se by Talend.

the class ToolBarButtonImageFigure method paintFigure.

/**
     * @see org.eclipse.draw2d.Figure#paintFigure(Graphics)
     */
@Override
protected void paintFigure(Graphics graphics) {
    if (isOpaque()) {
        graphics.fillRectangle(getBounds());
    }
    if (getBorder() instanceof AbstractBackground) {
        ((AbstractBackground) getBorder()).paintBackground(this, graphics, NO_INSETS);
    }
    int x, y;
    Rectangle area = getClientArea();
    y = area.y;
    x = area.x;
    // }
    if (getImage() != null) {
        graphics.drawImage(getImage(), x, y);
        x = x + size.width + iconTextGap;
    }
    if (getText() != null) {
        graphics.drawText(getText(), x, y);
    }
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) AbstractBackground(org.eclipse.draw2d.AbstractBackground)

Example 39 with Rectangle

use of org.eclipse.draw2d.geometry.Rectangle in project tdi-studio-se by Talend.

the class RowSelectionEditPolicy method getLocatorFigure.

private IFigure getLocatorFigure(GraphicalEditPart owner) {
    IFigure figure = owner.getFigure();
    if (owner instanceof TableEntityPart) {
        TableEntityFigure treeNodeFigure = (TableEntityFigure) figure;
        // table figure to restrict the width
        MapperTablePart abstractInOutTreePart = MapperUtils.getMapperTablePart((TableEntityPart) owner);
        IFigure parentFigure = ((GraphicalEditPart) abstractInOutTreePart).getFigure();
        Rectangle treeBounds = parentFigure.getBounds();
        Rectangle rowBounds = treeNodeFigure.getElement().getBounds();
        Rectangle treeNodeBounds = figure.getBounds();
        figure = new Figure();
        if (treeBounds.x + 1 != treeNodeBounds.x || treeNodeBounds.width > treeBounds.width) {
            figure.setBounds(new Rectangle(treeBounds.x + 1, treeNodeBounds.y, treeBounds.width - 2, rowBounds.height));
            return figure;
        } else {
            figure.setBounds(owner.getFigure().getBounds().getCopy());
            figure.getBounds().height = rowBounds.height;
            return figure;
        }
    } else if (figure instanceof VarEntityFigure) {
        Rectangle copy = figure.getBounds().getCopy();
        figure = new Figure();
        figure.setBounds(copy);
        return figure;
    }
    return owner.getFigure();
}
Also used : VarEntityFigure(org.talend.designer.gefabstractmap.figures.var.VarEntityFigure) TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) Rectangle(org.eclipse.draw2d.geometry.Rectangle) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) TableEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IFigure(org.eclipse.draw2d.IFigure) TableEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure) IFigure(org.eclipse.draw2d.IFigure) VarEntityFigure(org.talend.designer.gefabstractmap.figures.var.VarEntityFigure) Figure(org.eclipse.draw2d.Figure)

Example 40 with Rectangle

use of org.eclipse.draw2d.geometry.Rectangle in project tdi-studio-se by Talend.

the class TableTreeEntityFigure method getContents.

@Override
public TreeAnimatingLayer getContents() {
    if (this.contentPane == null) {
        contentPane = new TreeAnimatingLayer() {

            public void setBounds(Rectangle rect) {
                int x = bounds.x, y = bounds.y;
                boolean resize = (rect.width != bounds.width) || (rect.height != bounds.height), translate = (rect.x != x) || (rect.y != y);
                if (isVisible() && (resize || translate))
                    erase();
                if (translate) {
                    int dx = rect.x - x;
                    int dy = rect.y - y;
                    primTranslate(dx, dy);
                }
                bounds.width = rect.width;
                bounds.height = rect.height;
                if (resize)
                    invalidate();
                if (resize || translate) {
                    fireFigureMoved();
                    fireCoordinateSystemChanged();
                    repaint();
                }
            }
        };
        ToolbarLayout layout = new ToolbarLayout() {

            @Override
            public void layout(IFigure parent) {
                TreeAnimation.recordInitialState(parent);
                if (TreeAnimation.playbackState(parent)) {
                    return;
                }
                super.layout(parent);
            }

            @Override
            protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) {
                return super.calculatePreferredSize(container, wHint, hHint);
            }
        };
        layout.setMinorAlignment(ToolbarLayout.ALIGN_TOPLEFT);
        contentPane.setLayoutManager(layout);
        this.add(contentPane);
    // ///////test
    // contentPane.setOpaque(true);
    // contentPane.setBackgroundColor(ColorConstants.yellow);
    }
    return contentPane;
}
Also used : ToolbarLayout(org.eclipse.draw2d.ToolbarLayout) TreeAnimatingLayer(org.talend.commons.ui.swt.geftree.layout.TreeAnimatingLayer) Rectangle(org.eclipse.draw2d.geometry.Rectangle) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

Rectangle (org.eclipse.draw2d.geometry.Rectangle)347 Point (org.eclipse.draw2d.geometry.Point)107 Dimension (org.eclipse.draw2d.geometry.Dimension)80 IFigure (org.eclipse.draw2d.IFigure)43 List (java.util.List)24 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)18 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)17 PointList (org.eclipse.draw2d.geometry.PointList)16 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)15 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)14 ArrayList (java.util.ArrayList)11 Iterator (java.util.Iterator)11 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)11 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)11 AbstractContainerModel (org.csstudio.opibuilder.model.AbstractContainerModel)10 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)10 TableFigure (com.cubrid.common.ui.er.figures.TableFigure)8 Viewport (org.eclipse.draw2d.Viewport)8 Node (org.talend.designer.core.ui.editor.nodes.Node)8 Image (org.eclipse.swt.graphics.Image)7