Search in sources :

Example 41 with Rectangle

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

the class TableTreeEntityFigure method animationReset.

/**
     * recursively set all nodes and sub-treebranch nodes to the same location. This gives the appearance of all nodes
     * coming from the same place.
     * 
     * @param bounds where to set
     */
public void animationReset(Rectangle bounds) {
    List subtrees = getContents().getChildren();
    getContents().setBounds(bounds);
    // Make the center of this node match the center of the given bounds
    Rectangle r = element.getBounds();
    int dx = bounds.x + bounds.width / 2 - r.x - r.width / 2;
    int dy = bounds.y + bounds.height / 2 - r.y - r.height / 2;
    getElement().translate(dx, dy);
    // Otherwise, this branch will not layout
    revalidate();
    // Pass the location to all children
    for (int i = 0; i < subtrees.size(); i++) {
        TableTreeEntityFigure subtree = (TableTreeEntityFigure) subtrees.get(i);
        subtree.setBounds(bounds);
        subtree.animationReset(bounds);
    }
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) List(java.util.List) Point(org.eclipse.draw2d.geometry.Point)

Example 42 with Rectangle

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

the class TablePart method refreshVisuals.

@Override
protected void refreshVisuals() {
    Table table = (Table) getModel();
    Point loc = table.getLocation();
    Dimension size = table.getSize();
    Rectangle rectangle = new Rectangle(loc, size);
    ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), rectangle);
}
Also used : Table(org.talend.sqlbuilder.erdiagram.ui.nodes.Table) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Example 43 with Rectangle

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

the class CustomTableFigure method fillShape.

protected void fillShape(Graphics graphics) {
    Rectangle r = getBounds();
    Rectangle.SINGLETON.setBounds(r);
    Rectangle.SINGLETON.y += 1;
    Rectangle.SINGLETON.height -= 1;
    int shadowDepth = 0;
    int rectangleWidth = r.width - shadowDepth;
    int rectangleHeight = r.height - shadowDepth;
    Color foreground = graphics.getForegroundColor();
    Color background = graphics.getBackgroundColor(), shadow = ColorUtilities.darker(foreground);
    int x = r.x + shadowDepth;
    int y = r.y + shadowDepth;
    /**
         * trace shadow
         */
    for (int i = shadowDepth - 1; i >= 0; i--) {
        shadow = lighter(background, i + 1, shadowDepth + 1);
        graphics.setBackgroundColor(shadow);
        graphics.fillRectangle(x, y, rectangleWidth, rectangleHeight);
        if (i > 0) {
            x--;
            y--;
        }
    }
    graphics.setBackgroundColor(background);
    graphics.setForegroundColor(foreground);
    graphics.fillRectangle(x, y, rectangleWidth, rectangleHeight);
    // Gradient
    graphics.setForegroundColor(foreground);
    graphics.fillGradient(x, y - 20, rectangleWidth, figure.getBounds().height + 25, true);
    graphics.setForegroundColor(foreground);
    graphics.drawRectangle(x, y - 1, rectangleWidth - 1, rectangleHeight);
}
Also used : Color(org.eclipse.swt.graphics.Color) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 44 with Rectangle

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

the class MapperDropTargetListener method handleSashDrag.

protected void handleSashDrag(DropTargetEvent event, ISash s) {
    if (s instanceof SashSeparator) {
        SashSeparator separator = (SashSeparator) s;
        final Point dropLocation = getDropLocation();
        Rectangle leftBounds = separator.getLeftFigure().getBounds().getCopy();
        Rectangle rightBounds = separator.getRightFigure().getBounds().getCopy();
        if (dropLocation.x < (leftBounds.x + separator.getZoneMinSize() + separator.getSashWidth()) || dropLocation.x > (rightBounds.x + rightBounds.width - separator.getZoneMinSize() - separator.getSashWidth())) {
            event.detail = DND.DROP_NONE;
            return;
        }
        final LayoutManager layoutManager = separator.getParentFigure().getLayoutManager();
        if (layoutManager instanceof XmlMapDataLayout) {
            XmlMapDataLayout layout = (XmlMapDataLayout) layoutManager;
            int X = getDropLocation().x;
            final Rectangle separatorBounds = separator.getBounds().getCopy();
            separatorBounds.x = X;
            layout.setConstraint(separator, separatorBounds);
            // left figure width
            int wL = X - leftBounds.x;
            // right figure width
            int wR = rightBounds.getTopRight().x - X - separator.getSashWidth();
            int xR = X + separator.getSashWidth();
            if (wL < separator.getZoneMinSize()) {
                wL = separator.getZoneMinSize();
                wR = rightBounds.getTopRight().x - leftBounds.x - separator.getZoneMinSize() - separator.getSashWidth();
                xR = leftBounds.x + separator.getZoneMinSize() + separator.getSashWidth();
            }
            if (wR < separator.getZoneMinSize()) {
                wL = rightBounds.getTopRight().x - separator.getZoneMinSize() - separator.getSashWidth() - leftBounds.x;
                wR = separator.getZoneMinSize();
                xR = rightBounds.getTopRight().x - separator.getZoneMinSize();
            }
            leftBounds.width = wL;
            layout.setConstraint(separator.getLeftFigure(), leftBounds.getCopy());
            separator.getLeftFigure().invalidateTree();
            rightBounds.x = xR;
            rightBounds.width = wR;
            layout.setConstraint(separator.getRightFigure(), rightBounds.getCopy());
            separator.getRightFigure().invalidateTree();
            separator.getParentFigure().revalidate();
        }
    } else if (s instanceof ColumnSash) {
        ColumnSash columnSash = (ColumnSash) s;
        ITable t = columnSash.getTable();
        // if (t instanceof AbstractTable) {
        // AbstractTable table = (AbstractTable) t;
        // Rectangle tableBounds = table.getBounds();
        // int X = getDropLocation().x;
        // if (X < tableBounds.x + columnSash.getSashWidth()
        // || X > tableBounds.x + tableBounds.width - columnSash.getSashWidth()) {
        // event.detail = DND.DROP_NONE;
        // return;
        // }
        //
        // double newExpressionWidth = X - tableBounds.x;
        //
        // double defaultExpressionWidth = table.getDefaultExpressionWidth();
        // double pecnetage = newExpressionWidth / defaultExpressionWidth;
        // table.setExpressWidthPecentage(pecnetage);
        // } else if (t instanceof Table) {
        AbstractTable table = (AbstractTable) t;
        Rectangle tableBounds = table.getBounds();
        int X = getDropLocation().x;
        if (X < tableBounds.x + 10 || X > tableBounds.x + tableBounds.width - 10) {
            event.detail = DND.DROP_NONE;
            return;
        }
        TableColumn leftColumn = columnSash.getLeftColumn();
        TableColumn rightColumn = columnSash.getRightColumn();
        Rectangle leftBounds = leftColumn.getBounds();
        Rectangle rightBounds = rightColumn.getBounds();
        int LW = X - leftBounds.x;
        int RW = rightBounds.x + rightBounds.width - X;
        if (LW < 10) {
            LW = 10;
        }
        if (RW < 10) {
            RW = 10;
        }
        double LP = (double) LW / (double) tableBounds.width;
        double RP = (double) RW / (double) tableBounds.width;
        table.getLayoutManager().setColumnPercentage(leftColumn.getColumnKey(), LP);
        table.getLayoutManager().setColumnPercentage(rightColumn.getColumnKey(), RP);
        table.invalidateTree();
        table.revalidate();
    }
// }
}
Also used : AbstractTable(org.talend.designer.gefabstractmap.figures.table.AbstractTable) XmlMapDataLayout(org.talend.designer.gefabstractmap.figures.layout.XmlMapDataLayout) LayoutManager(org.eclipse.draw2d.LayoutManager) Rectangle(org.eclipse.draw2d.geometry.Rectangle) SashSeparator(org.talend.designer.gefabstractmap.figures.sash.SashSeparator) ITable(org.talend.designer.gefabstractmap.figures.table.ITable) Point(org.eclipse.draw2d.geometry.Point) ColumnSash(org.talend.designer.gefabstractmap.figures.table.ColumnSash) TableColumn(org.talend.designer.gefabstractmap.figures.table.TableColumn) Point(org.eclipse.draw2d.geometry.Point)

Example 45 with Rectangle

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

the class SearchZoneToolBarLayout 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;
        if (i == 1) {
            prefWidth = 200;
        }
        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)

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