use of org.eclipse.draw2d.geometry.Insets in project tdi-studio-se by Talend.
the class ParallelFigure method getFinalDisplayText.
public String getFinalDisplayText() {
Dimension textSize = calculateTextSize(getText());
Rectangle area = getClientArea();
Insets i = getInsets();
if (textSize.width >= area.width - i.left - i.right - OFFSET * 2) {
return ELLIPSIS;
}
return text;
}
use of org.eclipse.draw2d.geometry.Insets in project tdi-studio-se by Talend.
the class ZoneContentLayout method layout.
@Override
public void layout(IFigure parent) {
Rectangle vBounds = null;
if (parent.getParent() instanceof Viewport) {
vBounds = ((Viewport) parent.getParent()).getBounds();
}
int wHint = -1;
int hHint = -1;
if (isHorizontal()) {
hHint = parent.getClientArea(Rectangle.SINGLETON).height;
} else {
wHint = parent.getClientArea(Rectangle.SINGLETON).width;
}
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];
IFigure child;
int totalHeight = 0;
int totalMinHeight = 0;
int prefMinSumHeight = 0;
int connSize = 0;
// boolean isLookupConnMax = true;
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;
if (child instanceof AbstractTableContainer) {
connSize = getLookupConnectionSize((AbstractTableContainer) child);
}
}
totalHeight += (numChildren - 1) * spacing;
totalMinHeight += (numChildren - 1) * spacing;
prefMinSumHeight = totalHeight - totalMinHeight;
int defaultSize = DEFAULT_OFFSET;
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;
child = (IFigure) children.get(i);
Rectangle newBounds = new Rectangle(x, y, prefWidth, prefHeight);
if (connSize > 0) {
newBounds = new Rectangle(x + (connSize - 1) * defaultSize, y, prefWidth, prefHeight);
}
Border border = parent.getBorder();
Insets insets = border.getInsets(child);
if (vBounds != null) {
newBounds.width = vBounds.width - insets.left - insets.right;
if (connSize > 0) {
newBounds.width = newBounds.width - (connSize - 1) * defaultSize;
}
}
newBounds.height -= amntShrinkCurrentHeight;
child.setBounds(transposer.t(newBounds));
prefMinSumHeight -= (prefHeight - minHeight);
y += newBounds.height + spacing;
}
}
use of org.eclipse.draw2d.geometry.Insets in project tdi-studio-se by Talend.
the class ToolBarButtonImageFigure method getPreferredSize.
/**
* Calculates the necessary size to display the Image within the figure's client area.
*
* @see org.eclipse.draw2d.Figure#getPreferredSize(int, int)
*/
@Override
public Dimension getPreferredSize(int wHint, int hHint) {
Insets i = getInsets();
Dimension dimension = new Dimension(size);
Dimension labelSize = calculateLabelSize(getTextSize());
dimension.width = dimension.width + labelSize.width;
dimension.height = Math.max(dimension.height, labelSize.height);
return dimension.getExpanded(i.getWidth(), i.getHeight());
}
use of org.eclipse.draw2d.geometry.Insets in project tdi-studio-se by Talend.
the class TableEntityLayout method calculatePreferredSize.
@Override
protected Dimension calculatePreferredSize(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 prefSize = calculateChildrenSize(children, wHint, hHint, true);
// Do a second pass, if necessary
if (wHint >= 0 && prefSize.width > wHint) {
prefSize = calculateChildrenSize(children, prefSize.width, hHint, true);
} else if (hHint >= 0 && prefSize.width > hHint) {
prefSize = calculateChildrenSize(children, wHint, prefSize.width, true);
}
prefSize.height += Math.max(0, children.size() - 1) * spacing;
return transposer.t(prefSize).expand(insets.getWidth(), insets.getHeight()).union(getBorderPreferredSize(container));
}
use of org.eclipse.draw2d.geometry.Insets in project tdi-studio-se by Talend.
the class TalendDrawerFigure method getTitleBorder.
protected Border getTitleBorder() {
Insets insets = cssStyleSetting.getTitleMarginBorder().getInsets(null);
Border talendTitleBorder = new MarginBorder(insets.top, insets.left + customizedCSSStyleSetting.getXOffset() * childLevel, insets.bottom, insets.right);
return talendTitleBorder;
}
Aggregations