/** * Sets the expand ratio of given column. * * <p> * The expand ratio defines how excess space is distributed among columns. * Excess space means space that is left over from components that are not * sized relatively. By default, the excess space is distributed evenly. * </p> * * <p> * Note, that width of this GridLayout needs to be defined (fixed or * relative, as opposed to undefined height) for this method to have any * effect. * <p> * Note that checking for relative width for the child components is done on * the server so you cannot set a child component to have undefined width on * the server and set it to <code>100%</code> in CSS. You must set it to * <code>100%</code> on the server. * * @see #setWidth(float, Unit) * * @param columnIndex * @param ratio */ public void setColumnExpandRatio(int columnIndex, float ratio) { columnExpandRatio.put(columnIndex, ratio); getState().explicitColRatios.add(columnIndex); markAsDirty(); }
/** * Sets the expand ratio of given row. * * <p> * Expand ratio defines how excess space is distributed among rows. Excess * space means the space left over from components that are not sized * relatively. By default, the excess space is distributed evenly. * </p> * * <p> * Note, that height of this GridLayout needs to be defined (fixed or * relative, as opposed to undefined height) for this method to have any * effect. * <p> * Note that checking for relative height for the child components is done * on the server so you cannot set a child component to have undefined * height on the server and set it to <code>100%</code> in CSS. You must set * it to <code>100%</code> on the server. * * @see #setHeight(float, Unit) * * @param rowIndex * The row index, starting from 0 for the topmost row. * @param ratio */ public void setRowExpandRatio(int rowIndex, float ratio) { rowExpandRatio.put(rowIndex, ratio); getState().explicitRowRatios.add(rowIndex); markAsDirty(); }
/** * Inserts an empty row at the specified position in the grid. * * @param row * Index of the row before which the new row will be inserted. * The leftmost row has index 0. */ public void insertRow(int row) { if (row > getRows()) { throw new IllegalArgumentException("Cannot insert row at " + row + " in a gridlayout with height " + getRows()); } for (ChildComponentData existingArea : getState().childData.values()) { // Areas ending below the row needs to be moved down or stretched if (existingArea.row2 >= row) { existingArea.row2++; // Stretch areas that span over the selected row if (existingArea.row1 >= row) { existingArea.row1++; } } } if (cursorY >= row) { cursorY++; } setRows(getRows() + 1); markAsDirty(); }