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();
}
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;
}
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);
}
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);
}
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));
}
Aggregations