public void layout(IFigure figure) { Dimension preferredSize = calculatePreferredClientAreaSize(figure); Rectangle r = figure.getClientArea().getCopy(); List children = figure.getChildren(); int nChildren = children.size(); int extraHorizontalSpace = r.width - preferredSize.width; for (Iterator i = children.iterator(); i.hasNext();) { IFigure child = (IFigure) i.next(); Dimension preferredChildSize = child.getPreferredSize(); if (isHorizontal) { int w = preferredChildSize.width + (extraHorizontalSpace / nChildren); child.setBounds(new Rectangle(r.x, r.y, w, Math.max(preferredSize.height, r.height))); r.x += w + spacing; } else { child.setBounds(new Rectangle(r.x, r.y, Math.max(preferredSize.width, r.width), preferredChildSize.height)); r.y += preferredChildSize.height + spacing; } } } }
rectangle.translate(parent.getClientArea().getLocation()); int availableHorizontalSpace = parent.getClientArea().width - rx; dimension.width += availableHorizontalSpace; rectangle.translate(parent.getClientArea().getLocation());
Rectangle r = container.getClientArea(); dimension = new Dimension(r.width, r.height); Point p = new Point(0, 0); rectangle.translate(container.getClientArea().getLocation()); child.setBounds(rectangle); p.x += childSize.width; rectangle.translate(container.getClientArea().getLocation()); child.setBounds(rectangle); p.y += childSize.height;
Rectangle clientArea = parent.getClientArea(); List children = parent.getChildren(); Rectangle r = new Rectangle();
/** * @param editPart * @return a rectangle that bounds the actual visual rectangle of the column represented * by editPart. The editPart's figure normally only maps to the td in the rendered table. * * The rectangle is translated to absolute bounds */ public static Rectangle getAdjustedColumnBoundingRectangle(GraphicalEditPart editPart) { Rectangle bounds = editPart.getFigure().getBounds().getCopy(); if (editPart.getParent() != null) { IFigure figure = ((GraphicalEditPart) editPart.getParent()) .getFigure(); if (figure instanceof CSSFigure) { CSSFigure cssFigure = (CSSFigure) figure; LayoutManager layoutManager = cssFigure.getLayoutManager(); if (layoutManager instanceof CSSTableLayout2) { CSSTableLayout2 tableLayout = (CSSTableLayout2) layoutManager; bounds.y = tableLayout.getHSpacing(); bounds.height = figure.getClientArea().height - tableLayout.getHSpacing() * 2; } } } bounds = new PrecisionRectangle(bounds.getResized(-1, -1)); editPart.getFigure().translateToAbsolute(bounds); return bounds; }