Search in sources :

Example 31 with Rectangle

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

the class ComponentChooseDialog method translateAbsolateToRelative.

public void translateAbsolateToRelative(IFigure owner, Translatable t) {
    owner.translateToRelative(t);
    Rectangle bounds = owner.getBounds();
    t.performTranslate(-bounds.x, -bounds.y);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 32 with Rectangle

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

the class TreeBranchLayout method layout.

@Override
public void layout(IFigure container) {
    TreeAnimation.recordInitialState(container);
    if (TreeAnimation.playbackState(container)) {
        return;
    }
    Rectangle clientArea = container.getClientArea();
    int X = clientArea.x + 15;
    int Y = clientArea.y + clientArea.height;
    xOffset = 15;
    Dimension titleSize = treeBranch.getTitle().getPreferredSize();
    Rectangle titleBounds = new Rectangle();
    titleBounds.setSize(titleSize);
    if (treeBranch.isEnableExpand()) {
        final int tDeeps = treeBranch.getDepth();
        int titleOffset = (tDeeps - 1) * 2 * treeBranch.getGaps();
        X = X + titleOffset;
        xOffset = xOffset + titleOffset;
        ExpandCollapseFigure expandCollapseFigure = treeBranch.getExpandCollapseFigure();
        final Dimension ecSize = expandCollapseFigure.getPreferredSize();
        Rectangle ecBounds = new Rectangle();
        ecBounds.setSize(ecSize);
        int maxHeight = Math.max(titleSize.height, ecSize.height);
        Y = Y - maxHeight;
        int ecX = X - 15 + 1;
        ecBounds.setLocation(ecX, Y);
        expandCollapseFigure.setBounds(ecBounds);
    } else {
        Y = Y - titleSize.height;
    }
    titleBounds.setLocation(X, Y);
    // if (clientArea.getRight().x > titleBounds.getRight().x) {
    // int newWidth = clientArea.getRight().x - titleBounds.x;
    // titleBounds.width = newWidth;
    // }
    treeBranch.getTitle().setBounds(titleBounds);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point) ExpandCollapseFigure(org.talend.designer.gefabstractmap.figures.table.entity.ExpandCollapseFigure)

Example 33 with Rectangle

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

the class ZoneContentLayout method layout.

@Override
public void layout(IFigure parent) {
    Rectangle vBounds = null;
    if (parent.getParent() instanceof Viewport) {
        vBounds = ((Viewport) parent.getParent()).getBounds();
    }
    int wHint = -1;
    int hHint = -1;
    if (isHorizontal()) {
        hHint = parent.getClientArea(Rectangle.SINGLETON).height;
    } else {
        wHint = parent.getClientArea(Rectangle.SINGLETON).width;
    }
    List children = parent.getChildren();
    int numChildren = children.size();
    Rectangle clientArea = transposer.t(parent.getClientArea());
    int x = clientArea.x;
    int y = clientArea.y;
    int availableHeight = clientArea.height;
    Dimension[] prefSizes = new Dimension[numChildren];
    Dimension[] minSizes = new Dimension[numChildren];
    IFigure child;
    int totalHeight = 0;
    int totalMinHeight = 0;
    int prefMinSumHeight = 0;
    int connSize = 0;
    // boolean isLookupConnMax = true;
    for (int i = 0; i < numChildren; i++) {
        child = (IFigure) children.get(i);
        prefSizes[i] = transposer.t(getChildPreferredSize(child, wHint, hHint));
        minSizes[i] = transposer.t(getChildMinimumSize(child, wHint, hHint));
        totalHeight += prefSizes[i].height;
        totalMinHeight += minSizes[i].height;
        if (child instanceof AbstractTableContainer) {
            connSize = getLookupConnectionSize((AbstractTableContainer) child);
        }
    }
    totalHeight += (numChildren - 1) * spacing;
    totalMinHeight += (numChildren - 1) * spacing;
    prefMinSumHeight = totalHeight - totalMinHeight;
    int defaultSize = DEFAULT_OFFSET;
    for (int i = 0; i < numChildren; i++) {
        int amntShrinkCurrentHeight = 0;
        int prefHeight = prefSizes[i].height;
        int minHeight = minSizes[i].height;
        int prefWidth = prefSizes[i].width;
        int minWidth = minSizes[i].width;
        child = (IFigure) children.get(i);
        Rectangle newBounds = new Rectangle(x, y, prefWidth, prefHeight);
        if (connSize > 0) {
            newBounds = new Rectangle(x + (connSize - 1) * defaultSize, y, prefWidth, prefHeight);
        }
        Border border = parent.getBorder();
        Insets insets = border.getInsets(child);
        if (vBounds != null) {
            newBounds.width = vBounds.width - insets.left - insets.right;
            if (connSize > 0) {
                newBounds.width = newBounds.width - (connSize - 1) * defaultSize;
            }
        }
        newBounds.height -= amntShrinkCurrentHeight;
        child.setBounds(transposer.t(newBounds));
        prefMinSumHeight -= (prefHeight - minHeight);
        y += newBounds.height + spacing;
    }
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Viewport(org.eclipse.draw2d.Viewport) List(java.util.List) Dimension(org.eclipse.draw2d.geometry.Dimension) AbstractTableContainer(org.talend.designer.gefabstractmap.figures.table.AbstractTableContainer) Border(org.eclipse.draw2d.Border) IFigure(org.eclipse.draw2d.IFigure)

Example 34 with Rectangle

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

the class ZoneToolBarLayout method layout.

@Override
public void layout(IFigure parent) {
    List children = parent.getChildren();
    int numChildren = children.size();
    Rectangle clientArea = parent.getClientArea();
    int x = clientArea.x + spacing;
    int y = clientArea.y;
    Dimension[] prefSizes = new Dimension[numChildren];
    Dimension[] minSizes = new Dimension[numChildren];
    int wHint = -1;
    int hHint = -1;
    if (isHorizontal()) {
        hHint = parent.getClientArea(Rectangle.SINGLETON).height;
    } else {
        wHint = parent.getClientArea(Rectangle.SINGLETON).width;
    }
    IFigure child;
    int totalHeight = 0;
    int totalMinHeight = 0;
    int maxHeight = 0;
    for (int i = 0; i < numChildren; i++) {
        child = (IFigure) children.get(i);
        prefSizes[i] = getChildPreferredSize(child, wHint, hHint);
        minSizes[i] = getChildMinimumSize(child, wHint, hHint);
        totalHeight += prefSizes[i].height;
        totalMinHeight += minSizes[i].height;
        maxHeight = Math.max(maxHeight, prefSizes[i].height);
    }
    totalHeight += (numChildren - 1) * spacing;
    totalMinHeight += (numChildren - 1) * spacing;
    y = y + (clientArea.height - maxHeight) / 2;
    for (int i = 0; i < numChildren; i++) {
        int prefHeight = prefSizes[i].height;
        int minHeight = minSizes[i].height;
        int prefWidth = prefSizes[i].width;
        Rectangle newBounds = new Rectangle(x, y, prefWidth, prefHeight);
        child = (IFigure) children.get(i);
        child.setBounds(newBounds);
        x = x + newBounds.width + spacing;
    }
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) List(java.util.List) Dimension(org.eclipse.draw2d.geometry.Dimension) IFigure(org.eclipse.draw2d.IFigure)

Example 35 with Rectangle

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

the class LookupConnectionRouter method getEndDirection.

protected Vector getEndDirection(Connection conn) {
    ConnectionAnchor anchor = conn.getTargetAnchor();
    Point p = getEndPoint(conn);
    Rectangle rect;
    if (anchor.getOwner() == null) {
        rect = new Rectangle(p.x - 1, p.y - 1, 2, 2);
    } else {
        rect = conn.getTargetAnchor().getOwner().getBounds().getCopy();
        conn.getTargetAnchor().getOwner().translateToAbsolute(rect);
    }
    return getDirection(rect, p);
}
Also used : ConnectionAnchor(org.eclipse.draw2d.ConnectionAnchor) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point)

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