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