*
* @param e
*/
protected void resizeCell(MouseEvent e)
{
mxGraph graph = graphComponent.getGraph();
double scale = graph.getView().getScale();
Object cell = state.getCell();
mxGeometry geometry = graph.getModel().getGeometry(cell);
if (geometry != null)
{
double dx = (e.getX() - first.x) / scale;
double dy = (e.getY() - first.y) / scale;
if (isLabel(index))
{
geometry = (mxGeometry) geometry.clone();
if (geometry.getOffset() != null)
{
dx += geometry.getOffset().getX();
dy += geometry.getOffset().getY();
}
if (gridEnabledEvent)
{
dx = graph.snap(dx);
dy = graph.snap(dy);
}
geometry.setOffset(new mxPoint(dx, dy));
graph.getModel().setGeometry(cell, geometry);
}
else
{
mxRectangle bounds = union(geometry, dx, dy, index);
Rectangle rect = bounds.getRectangle();
// Snaps new bounds to grid (unscaled)
if (gridEnabledEvent)
{
int x = (int) graph.snap(rect.x);
int y = (int) graph.snap(rect.y);
rect.width = (int) graph.snap(rect.width - x + rect.x);
rect.height = (int) graph.snap(rect.height - y + rect.y);
rect.x = x;
rect.y = y;
}
graph.resizeCell(cell, new mxRectangle(rect));
}
}
}