public void addLayoutComponent(Component comp, Object constraints) { GridConstraints c = (GridConstraints) constraints; int row = c.getRow(); int rowSpan = c.getRowSpan(); int rowCount = this.getRowCount(); if (row >= 0 && row < rowCount) { if (row + rowSpan - 1 >= rowCount) { throw new IllegalArgumentException( "wrong row span: " + rowSpan + "; row=" + row + " rowCount=" + rowCount); } else { int column = c.getColumn(); int colSpan = c.getColSpan(); int columnCount = this.getColumnCount(); if (column >= 0 && column < columnCount) { if (column + colSpan - 1 >= columnCount) { throw new IllegalArgumentException( "wrong col span: " + colSpan + "; column=" + column + " columnCount=" + columnCount); } else { super.addLayoutComponent(comp, constraints); } } else { throw new IllegalArgumentException("wrong column: " + column); } } } else { throw new IllegalArgumentException("wrong row: " + row); } }
/** * Add component * * @param component Component added * @param column Column where component is added * @param slotIndex Index inside column */ protected void addComponent( Component component, ColumnLayoutState.ColumnState column, int slotIndex) { super.addComponent(component); if (slotIndex < 0 || column.children.size() <= slotIndex) { column.children.add(component); } else { column.children.add(slotIndex, component); } }
@Override public void removeComponent(Component component) { ColumnLayoutState.ColumnState column = findColumn(component); if (column == null) { return; } column.children.remove(component); super.removeComponent(component); }
/** * Sets the layout constraint of the given figure. The constraints can only be of type {@link * Rectangle}. * * @see LayoutManager#setConstraint(IFigure, Object) * @since 2.0 */ public void setConstraint(IFigure figure, Object newConstraint) { super.setConstraint(figure, newConstraint); if (newConstraint != null) constraints.put(figure, newConstraint); }
/** @see LayoutManager#remove(IFigure) */ public void remove(IFigure figure) { super.remove(figure); constraints.remove(figure); }
@Override public void removeAllComponents() { getState().columns.clear(); super.removeAllComponents(); }