use of org.talend.designer.gefabstractmap.figures.table.entity.TableEntityElement in project tdi-studio-se by Talend.
the class TableEntityLayout method layout.
@Override
public void layout(IFigure parent) {
Rectangle clientArea = transposer.t(parent.getClientArea());
int x = clientArea.x;
int y = clientArea.y;
final TreeAnimatingLayer contents = treeNode.getContents();
final TableEntityElement element = treeNode.getElement();
final Dimension elementSize = element.getPreferredSize(clientArea.width, -1);
int maxWidth = Math.max(elementSize.width, clientArea.width);
Dimension contentsSize = null;
if (contents != null) {
contentsSize = contents.getPreferredSize(clientArea.width, -1);
maxWidth = Math.max(contentsSize.width, elementSize.width);
// ajust to parent
if (parent.getParent() instanceof TreeAnimatingLayer) {
maxWidth = Math.max(maxWidth, parent.getParent().getBounds().width);
} else {
maxWidth = Math.max(maxWidth, clientArea.width);
}
contentsSize.width = maxWidth;
}
elementSize.width = maxWidth;
Rectangle rectangle = new Rectangle();
rectangle.setLocation(x, y);
rectangle.setSize(elementSize);
element.setBounds(rectangle);
y = y + rectangle.height;
if (contents != null) {
rectangle = new Rectangle();
rectangle.setLocation(x, y);
rectangle.setSize(contentsSize);
contents.setBounds(rectangle);
}
}
Aggregations