Search in sources :

Example 16 with IFigure

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

the class ErDiagramPart method createFigure.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
     */
@Override
protected IFigure createFigure() {
    Figure figure = new FreeformLayer();
    figure.setLayoutManager(new FreeformLayout());
    fig2 = new FreeformLayer();
    getLayer(ErDiagramRootEditPart.PROCESS_BACKGROUND_LAYER).add(fig2);
    return figure;
}
Also used : FreeformLayout(org.eclipse.draw2d.FreeformLayout) FreeformLayer(org.eclipse.draw2d.FreeformLayer) IFigure(org.eclipse.draw2d.IFigure) Figure(org.eclipse.draw2d.Figure)

Example 17 with IFigure

use of org.eclipse.draw2d.IFigure 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)

Example 18 with IFigure

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

the class TableContainerLayout method calculateChildrenSize.

private Dimension calculateChildrenSize(List children, int wHint, int hHint, boolean preferred) {
    Dimension childSize;
    IFigure child;
    int height = 0, width = 0;
    for (int i = 0; i < children.size(); i++) {
        child = (IFigure) children.get(i);
        if (child instanceof AbstractTreeSettingContainer) {
            if (!tableMananger.isActivateCondensedTool()) {
                continue;
            }
        }
        if (child instanceof FilterContainer) {
            if (!tableMananger.isActivateExpressionFilter()) {
                continue;
            }
        }
        if (child instanceof AbstractGlobalMapContainer) {
            if (!tableMananger.isActivateGlobalMap()) {
                continue;
            }
        }
        childSize = transposer.t(preferred ? getChildPreferredSize(child, wHint, hHint) : getChildMinimumSize(child, wHint, hHint));
        height += childSize.height;
        width = Math.max(width, childSize.width);
        // header figure must be the first figure , or there will be problem here
        if (tableMananger.isMinimized()) {
            break;
        }
    }
    return new Dimension(width, height);
}
Also used : FilterContainer(org.talend.designer.gefabstractmap.figures.treesettings.FilterContainer) AbstractGlobalMapContainer(org.talend.designer.gefabstractmap.figures.table.AbstractGlobalMapContainer) Dimension(org.eclipse.draw2d.geometry.Dimension) AbstractTreeSettingContainer(org.talend.designer.gefabstractmap.figures.treesettings.AbstractTreeSettingContainer) IFigure(org.eclipse.draw2d.IFigure)

Example 19 with IFigure

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

the class TableContainerLayout method layout.

@Override
public void layout(IFigure parent) {
    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];
    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 prefMinSumHeight = 0;
    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;
    }
    totalHeight += (numChildren - 1) * spacing;
    totalMinHeight += (numChildren - 1) * spacing;
    prefMinSumHeight = totalHeight - totalMinHeight;
    int amntShrinkHeight = totalHeight - Math.max(availableHeight, totalMinHeight);
    if (amntShrinkHeight < 0) {
        amntShrinkHeight = 0;
    }
    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;
        Rectangle newBounds = new Rectangle(x, y, prefWidth, prefHeight);
        child = (IFigure) children.get(i);
        if (child instanceof AbstractTreeSettingContainer) {
            if (!tableMananger.isActivateCondensedTool()) {
                child.setBounds(new Rectangle(x, y, 0, 0));
                continue;
            }
        }
        if (child instanceof FilterContainer) {
            if (!tableMananger.isActivateExpressionFilter()) {
                child.setBounds(new Rectangle(x, y, 0, 0));
                continue;
            }
        }
        if (child instanceof AbstractGlobalMapContainer) {
            if (!tableMananger.isActivateGlobalMap()) {
                child.setBounds(new Rectangle(x, y, 0, 0));
                continue;
            }
        }
        int width = Math.min(prefWidth, transposer.t(child.getMaximumSize()).width);
        if (matchWidth) {
            width = transposer.t(child.getMaximumSize()).width;
        }
        width = Math.max(minWidth, Math.min(clientArea.width, width));
        newBounds.width = width;
        child.setBounds(transposer.t(newBounds));
        amntShrinkHeight -= amntShrinkCurrentHeight;
        prefMinSumHeight -= (prefHeight - minHeight);
        y += newBounds.height + spacing;
        if (child instanceof ScrollPane) {
            IFigure contents = ((ScrollPane) child).getViewport().getContents();
            if (contents instanceof AbstractTable) {
            // ((AbstractTable) contents).setDefautTableWidth(newBounds.width);
            }
        }
    }
}
Also used : AbstractTable(org.talend.designer.gefabstractmap.figures.table.AbstractTable) ScrollPane(org.eclipse.draw2d.ScrollPane) FilterContainer(org.talend.designer.gefabstractmap.figures.treesettings.FilterContainer) AbstractGlobalMapContainer(org.talend.designer.gefabstractmap.figures.table.AbstractGlobalMapContainer) Rectangle(org.eclipse.draw2d.geometry.Rectangle) List(java.util.List) Dimension(org.eclipse.draw2d.geometry.Dimension) AbstractTreeSettingContainer(org.talend.designer.gefabstractmap.figures.treesettings.AbstractTreeSettingContainer) IFigure(org.eclipse.draw2d.IFigure)

Example 20 with IFigure

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

the class TableItemLayout method layout.

@Override
public void layout(IFigure parent) {
    if (parent.getParent() == null || !(parent.getParent().getParent() instanceof Table)) {
        throw new RuntimeException("Can't find table");
    }
    Table table = (Table) parent.getParent().getParent();
    Rectangle clientArea = parent.getClientArea();
    int X = clientArea.x;
    int Y = clientArea.y;
    List<TableColumn> columns = table.getColumns();
    List children = parent.getChildren();
    if (columns.size() != children.size()) {
        throw new RuntimeException("Table items size don't match column size");
    }
    int rowheight = 0;
    for (int i = 0; i < children.size(); i++) {
        Figure figure = (Figure) children.get(i);
        Dimension size = figure.getPreferredSize();
        rowheight = Math.max(rowheight, size.height);
    }
    for (int i = 0; i < columns.size(); i++) {
        TableColumn tableColumn = columns.get(i);
        Figure figure = (Figure) children.get(i);
        int columnWidth = table.getColumnWidth(tableColumn.getColumnKey());
        Rectangle newBounds = new Rectangle(X, Y, columnWidth, rowheight);
        figure.setBounds(newBounds);
        X += columnWidth;
    }
}
Also used : Table(org.talend.designer.gefabstractmap.figures.table.Table) Rectangle(org.eclipse.draw2d.geometry.Rectangle) List(java.util.List) Dimension(org.eclipse.draw2d.geometry.Dimension) TableColumn(org.talend.designer.gefabstractmap.figures.table.TableColumn) Figure(org.eclipse.draw2d.Figure) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

IFigure (org.eclipse.draw2d.IFigure)440 Rectangle (org.eclipse.draw2d.geometry.Rectangle)120 Point (org.eclipse.draw2d.geometry.Point)77 Dimension (org.eclipse.draw2d.geometry.Dimension)56 Figure (org.eclipse.draw2d.Figure)38 List (java.util.List)37 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)35 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)32 Graphics (org.eclipse.draw2d.Graphics)17 Iterator (java.util.Iterator)15 ArrayList (java.util.ArrayList)14 EditPart (org.eclipse.gef.EditPart)13 StackLayout (org.eclipse.draw2d.StackLayout)12 DefaultSizeNodeFigure (org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure)12 NodeFigure (org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure)12 Insets (org.eclipse.draw2d.geometry.Insets)11 INodeFigure (org.whole.lang.ui.figures.INodeFigure)11 MarginBorder (org.eclipse.draw2d.MarginBorder)10 ToolbarLayout (org.eclipse.draw2d.ToolbarLayout)10 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)10