Rectangle (final RadContainer grid, final GridConstraints originalConstraints, final Point point, final int resizeMask) { int rowAtMouse = (resizeMask & (Painter.NORTH_MASK | Painter.SOUTH_MASK)) != 0 ? grid.getGridRowAt(point.y) : -1; int colAtMouse = (resizeMask & (Painter.WEST_MASK | Painter.EAST_MASK)) != 0 ? grid.getGridColumnAt(point.x) : -1; if (rowAtMouse != -1 || colAtMouse != -1) { final int origStartCol = originalConstraints.getColumn(); final int origEndCol = originalConstraints.getColumn() + originalConstraints.getColSpan() - 1; int startCol = origStartCol; int endCol = origEndCol; if (colAtMouse >= 0) { if ((resizeMask & Painter.WEST_MASK) != 0 && colAtMouse <= endCol) { // resize to left startCol = colAtMouse; } else if ((resizeMask & Painter.EAST_MASK) != 0 && colAtMouse >= startCol) { endCol = colAtMouse; } } final int origStartRow = originalConstraints.getRow(); final int origEndRow = originalConstraints.getRow() + originalConstraints.getRowSpan() - 1; int startRow = origStartRow; int endRow = origEndRow; if (rowAtMouse >= 0) { if ((resizeMask & Painter.NORTH_MASK) != 0 && rowAtMouse <= endRow) { startRow = rowAtMouse; } else if ((resizeMask & Painter.SOUTH_MASK) != 0 && rowAtMouse >= startRow) { endRow = rowAtMouse; } } return new Rectangle(startCol, startRow, endCol-startCol+1, endRow-startRow+1); } return null; }