Search in sources :

Example 66 with Insets

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

the class TitleBarBorder method setPadding.

/**
 * Sets the padding space to be applied on all sides of the border. The
 * default value is no padding on all sides.
 *
 * @param all
 *            the value of the padding on all sides
 * @since 2.0
 */
public void setPadding(int all) {
    padding = new Insets(all);
    invalidate();
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets)

Example 67 with Insets

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

the class ScrollBarLayout method layoutButtons.

/**
 * Places the buttons and returns the Rectangle into which the track should
 * be placed. The track consists of the pageup, pagedown, and thumb figures.
 * The Rectangle returned should be transposed correctly, that is, it should
 * be vertically oriented. Users of the rectangle will re-transpose it for
 * horizontal use.
 *
 * @param scrollBar
 *            the scrollbar whose buttons are being layed out
 * @return the Rectangle into which the track should be placed
 * @since 2.0
 */
@SuppressWarnings("deprecation")
protected Rectangle layoutButtons(ScrollBar scrollBar) {
    Rectangle bounds = transposer.t(scrollBar.getClientArea());
    Dimension buttonSize = new Dimension(bounds.width, Math.min(bounds.width, bounds.height / 2));
    if (up != null)
        up.setBounds(transposer.t(new Rectangle(bounds.getTopLeft(), buttonSize)));
    if (down != null) {
        Rectangle r = new Rectangle(bounds.x, bounds.bottom() - buttonSize.height, buttonSize.width, buttonSize.height);
        down.setBounds(transposer.t(r));
    }
    Rectangle trackBounds = bounds.getCropped(new Insets((up == null) ? 0 : buttonSize.height, 0, (down == null) ? 0 : buttonSize.height, 0));
    return trackBounds;
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 68 with Insets

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

the class ScrollBarLayout method calculatePreferredSize.

/**
 * @see AbstractLayout#calculatePreferredSize(IFigure, int, int)
 */
@Override
protected Dimension calculatePreferredSize(IFigure parent, int w, int h) {
    Insets insets = transposer.t(parent.getInsets());
    Dimension d = new Dimension(16, 16 * 4);
    d.expand(insets.getWidth(), insets.getHeight());
    return transposer.t(d);
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 69 with Insets

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

the class ScrollPaneLayout method calculatePreferredSize.

/**
 * Calculates and returns the preferred size of the container based on the
 * given hints. If the given ScrollPane's (<i>container</i>) horizontal and
 * vertical scroll bar visibility is not {@link ScrollPane#NEVER}, then
 * space for those bars is always deducted from the hints (whether or not we
 * actually need the scroll bars).
 *
 * @param container
 *            the ScrollPane whose preferred size needs to be calculated
 * @param wHint
 *            the width hint
 * @param hHint
 *            the height hint
 * @return the preferred size of the given container
 * @since 2.0
 */
@Override
protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) {
    ScrollPane scrollpane = (ScrollPane) container;
    ScrollBar hBar = scrollpane.getHorizontalScrollBar();
    ScrollBar vBar = scrollpane.getVerticalScrollBar();
    Insets insets = scrollpane.getInsets();
    int reservedWidth = insets.getWidth();
    int reservedHeight = insets.getHeight();
    if (scrollpane.getVerticalScrollBarVisibility() != ScrollPane.NEVER)
        reservedWidth += vBar.getPreferredSize().width;
    if (scrollpane.getHorizontalScrollBarVisibility() != ScrollPane.NEVER)
        reservedHeight += hBar.getPreferredSize().height;
    if (wHint > -1)
        wHint = Math.max(0, wHint - reservedWidth);
    if (hHint > -1)
        hHint = Math.max(0, hHint - reservedHeight);
    return scrollpane.getViewport().getPreferredSize(wHint, hHint).getExpanded(reservedWidth, reservedHeight);
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets)

Example 70 with Insets

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

the class ToolbarLayout method calculateMinimumSize.

/**
 * Calculates the minimum size of the container based on the given hints. If
 * this is a vertically-oriented Toolbar Layout, then only the widthHint is
 * respected (which means that the children can be as tall as they desire).
 * In this case, the minimum width is that of the widest child, and the
 * minimum height is the sum of the minimum heights of all children, plus
 * the spacing between them. The border and insets of the container figure
 * are also accounted for.
 *
 * @param container
 *            the figure whose minimum size has to be calculated
 * @param wHint
 *            the width hint (the desired width of the container)
 * @param hHint
 *            the height hint (the desired height of the container)
 * @return the minimum size of the container
 * @see #getMinimumSize(IFigure, int, int)
 * @since 2.1
 */
@Override
protected Dimension calculateMinimumSize(IFigure container, int wHint, int hHint) {
    Insets insets = container.getInsets();
    if (isHorizontal()) {
        wHint = -1;
        if (hHint >= 0)
            hHint = Math.max(0, hHint - insets.getHeight());
    } else {
        hHint = -1;
        if (wHint >= 0)
            wHint = Math.max(0, wHint - insets.getWidth());
    }
    List children = container.getChildren();
    Dimension minSize = calculateChildrenSize(children, wHint, hHint, false);
    // Do a second pass, if necessary
    if (wHint >= 0 && minSize.width > wHint) {
        minSize = calculateChildrenSize(children, minSize.width, hHint, false);
    } else if (hHint >= 0 && minSize.width > hHint) {
        minSize = calculateChildrenSize(children, wHint, minSize.width, false);
    }
    minSize.height += Math.max(0, children.size() - 1) * spacing;
    return transposer.t(minSize).expand(insets.getWidth(), insets.getHeight()).union(getBorderPreferredSize(container));
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) List(java.util.List) 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