Search in sources :

Example 56 with Insets

use of org.eclipse.draw2d.geometry.Insets in project dbeaver by dbeaver.

the class EditableLabel method getSelectionRectangle.

private Rectangle getSelectionRectangle() {
    Rectangle bounds = getTextBounds().getCopy();
    bounds.expand(new Insets(2, 2, 0, 0));
    translateToParent(bounds);
    bounds.intersect(getBounds());
    return bounds;
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 57 with Insets

use of org.eclipse.draw2d.geometry.Insets in project archi by archimatetool.

the class Label method getPreferredSize.

/**
 * @see IFigure#getPreferredSize(int, int)
 */
@Override
public Dimension getPreferredSize(int wHint, int hHint) {
    if (prefSize == null) {
        prefSize = calculateLabelSize(getTextSize());
        Insets insets = getInsets();
        prefSize.expand(insets.getWidth(), insets.getHeight());
        if (getLayoutManager() != null)
            prefSize.union(getLayoutManager().getPreferredSize(this, wHint, hHint));
    }
    if (wHint >= 0 && wHint < prefSize.width) {
        Dimension minSize = getMinimumSize(wHint, hHint);
        Dimension result = prefSize.getCopy();
        result.width = Math.min(result.width, wHint);
        result.width = Math.max(minSize.width, result.width);
        return result;
    }
    return prefSize;
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 58 with Insets

use of org.eclipse.draw2d.geometry.Insets in project archi by archimatetool.

the class FreeformHelper method getFreeformExtent.

public Rectangle getFreeformExtent() {
    if (freeformExtent != null)
        return freeformExtent;
    Rectangle r;
    List children = host.getChildren();
    for (int i = 0; i < children.size(); i++) {
        IFigure child = (IFigure) children.get(i);
        if (child instanceof FreeformFigure)
            r = ((FreeformFigure) child).getFreeformExtent();
        else
            r = child.getBounds();
        if (freeformExtent == null)
            freeformExtent = r.getCopy();
        else
            freeformExtent.union(r);
    }
    Insets insets = host.getInsets();
    if (freeformExtent == null)
        freeformExtent = new Rectangle(0, 0, insets.getWidth(), insets.getHeight());
    else {
        host.translateToParent(freeformExtent);
        freeformExtent.expand(insets);
    }
    // freeformExtent);
    return freeformExtent;
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) Rectangle(org.eclipse.draw2d.geometry.Rectangle) List(java.util.List)

Example 59 with Insets

use of org.eclipse.draw2d.geometry.Insets in project archi by archimatetool.

the class BorderLayout method calculateMinimumSize.

/**
 * @see org.eclipse.draw2d.AbstractHintLayout#calculateMinimumSize(IFigure,
 *      int, int)
 */
@Override
protected Dimension calculateMinimumSize(IFigure container, int wHint, int hHint) {
    int minWHint = 0, minHHint = 0;
    if (wHint < 0) {
        minWHint = -1;
    }
    if (hHint < 0) {
        minHHint = -1;
    }
    Insets border = container.getInsets();
    wHint = Math.max(minWHint, wHint - border.getWidth());
    hHint = Math.max(minHHint, hHint - border.getHeight());
    Dimension minSize = new Dimension();
    int middleRowWidth = 0, middleRowHeight = 0;
    int rows = 0, columns = 0;
    if (top != null && top.isVisible()) {
        Dimension childSize = top.getMinimumSize(wHint, hHint);
        hHint = Math.max(minHHint, hHint - (childSize.height + vGap));
        minSize.setSize(childSize);
        rows += 1;
    }
    if (bottom != null && bottom.isVisible()) {
        Dimension childSize = bottom.getMinimumSize(wHint, hHint);
        hHint = Math.max(minHHint, hHint - (childSize.height + vGap));
        minSize.width = Math.max(minSize.width, childSize.width);
        minSize.height += childSize.height;
        rows += 1;
    }
    if (left != null && left.isVisible()) {
        Dimension childSize = left.getMinimumSize(wHint, hHint);
        middleRowWidth = childSize.width;
        middleRowHeight = childSize.height;
        wHint = Math.max(minWHint, wHint - (childSize.width + hGap));
        columns += 1;
    }
    if (right != null && right.isVisible()) {
        Dimension childSize = right.getMinimumSize(wHint, hHint);
        middleRowWidth += childSize.width;
        middleRowHeight = Math.max(childSize.height, middleRowHeight);
        wHint = Math.max(minWHint, wHint - (childSize.width + hGap));
        columns += 1;
    }
    if (center != null && center.isVisible()) {
        Dimension childSize = center.getMinimumSize(wHint, hHint);
        middleRowWidth += childSize.width;
        middleRowHeight = Math.max(childSize.height, middleRowHeight);
        columns += 1;
    }
    rows += columns > 0 ? 1 : 0;
    // Add spacing, insets, and the size of the middle row
    minSize.height += middleRowHeight + border.getHeight() + ((rows - 1) * vGap);
    minSize.width = Math.max(minSize.width, middleRowWidth) + border.getWidth() + ((columns - 1) * hGap);
    return minSize;
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 60 with Insets

use of org.eclipse.draw2d.geometry.Insets in project archi by archimatetool.

the class BorderLayout method calculatePreferredSize.

/**
 * @see AbstractLayout#calculatePreferredSize(IFigure, int, int)
 */
@Override
protected Dimension calculatePreferredSize(IFigure figure, int wHint, int hHint) {
    int minWHint = 0, minHHint = 0;
    if (wHint < 0)
        minWHint = -1;
    if (hHint < 0)
        minHHint = -1;
    Insets border = figure.getInsets();
    wHint = Math.max(minWHint, wHint - border.getWidth());
    hHint = Math.max(minHHint, hHint - border.getHeight());
    Dimension prefSize = new Dimension();
    int middleRowWidth = 0, middleRowHeight = 0;
    int rows = 0, columns = 0;
    if (top != null && top.isVisible()) {
        Dimension childSize = top.getPreferredSize(wHint, hHint);
        hHint = Math.max(minHHint, hHint - (childSize.height + vGap));
        prefSize.setSize(childSize);
        rows += 1;
    }
    if (bottom != null && bottom.isVisible()) {
        Dimension childSize = bottom.getPreferredSize(wHint, hHint);
        hHint = Math.max(minHHint, hHint - (childSize.height + vGap));
        prefSize.width = Math.max(prefSize.width, childSize.width);
        prefSize.height += childSize.height;
        rows += 1;
    }
    if (left != null && left.isVisible()) {
        Dimension childSize = left.getPreferredSize(wHint, hHint);
        middleRowWidth = childSize.width;
        middleRowHeight = childSize.height;
        wHint = Math.max(minWHint, wHint - (childSize.width + hGap));
        columns += 1;
    }
    if (right != null && right.isVisible()) {
        Dimension childSize = right.getPreferredSize(wHint, hHint);
        middleRowWidth += childSize.width;
        middleRowHeight = Math.max(childSize.height, middleRowHeight);
        wHint = Math.max(minWHint, wHint - (childSize.width + hGap));
        columns += 1;
    }
    if (center != null && center.isVisible()) {
        Dimension childSize = center.getPreferredSize(wHint, hHint);
        middleRowWidth += childSize.width;
        middleRowHeight = Math.max(childSize.height, middleRowHeight);
        columns += 1;
    }
    rows += columns > 0 ? 1 : 0;
    // Add spacing, insets, and the size of the middle row
    prefSize.height += middleRowHeight + border.getHeight() + ((rows - 1) * vGap);
    prefSize.width = Math.max(prefSize.width, middleRowWidth) + border.getWidth() + ((columns - 1) * hGap);
    prefSize.union(getBorderPreferredSize(figure));
    return prefSize;
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) Dimension(org.eclipse.draw2d.geometry.Dimension)

Aggregations

Insets (org.eclipse.draw2d.geometry.Insets)77 Rectangle (org.eclipse.draw2d.geometry.Rectangle)33 Dimension (org.eclipse.draw2d.geometry.Dimension)32 IFigure (org.eclipse.draw2d.IFigure)12 List (java.util.List)9 Graphics (org.eclipse.draw2d.Graphics)5 AbstractBorder (org.eclipse.draw2d.AbstractBorder)4 PrintDialog (org.eclipse.swt.printing.PrintDialog)4 Printer (org.eclipse.swt.printing.Printer)4 PrinterData (org.eclipse.swt.printing.PrinterData)4 MarginBorder (org.eclipse.draw2d.MarginBorder)3 PrintFigureOperation (org.eclipse.draw2d.PrintFigureOperation)3 Point (org.eclipse.draw2d.geometry.Point)3 Border (org.eclipse.draw2d.Border)2 ScrollBar (org.eclipse.draw2d.ScrollBar)2 ScrollPane (org.eclipse.draw2d.ScrollPane)2 Viewport (org.eclipse.draw2d.Viewport)2 Node (org.eclipse.draw2d.graph.Node)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 EntityPart (org.jkiss.dbeaver.ext.erd.part.EntityPart)2