public void execute(Object parent)
{
if (parent != null)
{
boolean horizontal = isHorizontal();
mxIGraphModel model = graph.getModel();
mxGeometry pgeo = model.getGeometry(parent);
// Handles special case where the parent is either a layer with no
// geometry or the current root of the view in which case the size
// of the graph's container will be used.
if (pgeo == null && model.getParent(parent) == model.getRoot()
|| parent == graph.getView().getCurrentRoot())
{
mxRectangle tmp = getContainerSize();
pgeo = new mxGeometry(0, 0, tmp.getWidth(), tmp.getHeight());
}
double fillValue = 0;
if (pgeo != null)
{
fillValue = (horizontal) ? pgeo.getHeight() : pgeo.getWidth();
}
fillValue -= 2 * spacing + 2 * border;
// Handles swimlane start size
mxRectangle size = graph.getStartSize(parent);
fillValue -= (horizontal) ? size.getHeight() : size.getWidth();
double x0 = this.x0 + size.getWidth() + border;
double y0 = this.y0 + size.getHeight() + border;
model.beginUpdate();
try
{
double tmp = 0;
mxGeometry last = null;
int childCount = model.getChildCount(parent);
for (int i = 0; i < childCount; i++)
{
Object child = model.getChildAt(parent, i);
if (!isVertexIgnored(child) && isVertexMovable(child))
{
mxGeometry geo = model.getGeometry(child);
if (geo != null)
{
geo = (mxGeometry) geo.clone();
if (wrap != 0 && last != null)
{
if ((horizontal && last.getX()
+ last.getWidth() + geo.getWidth() + 2
* spacing > wrap)
|| (!horizontal && last.getY()
+ last.getHeight()
+ geo.getHeight() + 2 * spacing > wrap))
{
last = null;
if (horizontal)
{
y0 += tmp + spacing;
}
else
{
x0 += tmp + spacing;
}
tmp = 0;
}
}
tmp = Math.max(tmp, (horizontal) ? geo
.getHeight() : geo.getWidth());
if (last != null)
{
if (horizontal)
{
geo.setX(last.getX() + last.getWidth()
+ spacing);
}
else
{
geo.setY(last.getY() + last.getHeight()
+ spacing);
}
}
else
{
if (horizontal)
{
geo.setX(x0);
}
else
{
geo.setY(y0);
}
}
if (horizontal)
{
geo.setY(y0);
}
else
{
geo.setX(x0);
}
if (fill && fillValue > 0)
{
if (horizontal)
{
geo.setHeight(fillValue);
}
else
{
geo.setWidth(fillValue);
}
}
model.setGeometry(child, geo);
last = geo;
}
}
}
if (resizeParent && pgeo != null && last != null
&& !graph.isCellCollapsed(parent))
{
pgeo = (mxGeometry) pgeo.clone();
if (horizontal)
{
pgeo.setWidth(last.getX() + last.getWidth() + spacing);
}
else
{
pgeo
.setHeight(last.getY() + last.getHeight()
+ spacing);
}
model.setGeometry(parent, pgeo);
}
}
finally
{
model.endUpdate();
}
}
}