{
model.beginUpdate();
try
{
mxRectangle size = getPreferredSizeForCell(cell);
mxGeometry geo = model.getGeometry(cell);
if (size != null && geo != null)
{
boolean collapsed = isCellCollapsed(cell);
geo = (mxGeometry) geo.clone();
if (isSwimlane(cell))
{
mxCellState state = view.getState(cell);
Map<String, Object> style = (state != null) ? state
.getStyle() : getCellStyle(cell);
String cellStyle = model.getStyle(cell);
if (cellStyle == null)
{
cellStyle = "";
}
if (mxUtils.isTrue(style, mxConstants.STYLE_HORIZONTAL,
true))
{
cellStyle = mxStyleUtils.setStyle(cellStyle,
mxConstants.STYLE_STARTSIZE,
String.valueOf(size.getHeight() + 8));
if (collapsed)
{
geo.setHeight(size.getHeight() + 8);
}
geo.setWidth(size.getWidth());
}
else
{
cellStyle = mxStyleUtils.setStyle(cellStyle,
mxConstants.STYLE_STARTSIZE,
String.valueOf(size.getWidth() + 8));
if (collapsed)
{
geo.setWidth(size.getWidth() + 8);
}
geo.setHeight(size.getHeight());
}
model.setStyle(cell, cellStyle);
}
else
{
geo.setWidth(size.getWidth());
geo.setHeight(size.getHeight());
}
if (!ignoreChildren && !collapsed)
{
mxRectangle bounds = view.getBounds(mxGraphModel
.getChildren(model, cell));
if (bounds != null)
{
mxPoint tr = view.getTranslate();
double scale = view.getScale();
double width = (bounds.getX() + bounds.getWidth())
/ scale - geo.getX() - tr.getX();
double height = (bounds.getY() + bounds.getHeight())
/ scale - geo.getY() - tr.getY();
geo.setWidth(Math.max(geo.getWidth(), width));
geo.setHeight(Math.max(geo.getHeight(), height));
}
}
cellsResized(new Object[] { cell },
new mxRectangle[] { geo });