/** * Sets the column, row, width, and height; sets the horizontal * and vertical alignment using the specified alignment objects.<p> * * <strong>Examples:</strong><pre> * cc.xywh(1, 3, 2, 1, CellConstraints.LEFT, CellConstraints.BOTTOM); * cc.xywh(1, 3, 7, 3, CellConstraints.CENTER, CellConstraints.FILL); * </pre> * * @param col the new column index * @param row the new row index * @param colSpan the column span or grid width * @param rowSpan the row span or grid height * @param colAlign horizontal component alignment * @param rowAlign vertical component alignment * @return this * @throws IllegalArgumentException if an alignment orientation is invalid */ public CellConstraints xywh(int col, int row, int colSpan, int rowSpan, Alignment colAlign, Alignment rowAlign) { this.gridX = col; this.gridY = row; this.gridWidth = colSpan; this.gridHeight = rowSpan; this.hAlign = colAlign; this.vAlign = rowAlign; ensureValidOrientations(hAlign, vAlign); return this; }
/** * Sets the column, row, width, and height; sets the horizontal * and vertical alignment using the specified alignment objects.<p> * * <strong>Examples:</strong><pre> * cc.xywh(1, 3, 2, 1, CellConstraints.LEFT, CellConstraints.BOTTOM); * cc.xywh(1, 3, 7, 3, CellConstraints.CENTER, CellConstraints.FILL); * </pre> * * @param col the new column index * @param row the new row index * @param colSpan the column span or grid width * @param rowSpan the row span or grid height * @param colAlign horizontal component alignment * @param rowAlign vertical component alignment * @return this * @throws IllegalArgumentException if an alignment orientation is invalid */ public CellConstraints xywh(int col, int row, int colSpan, int rowSpan, Alignment colAlign, Alignment rowAlign) { this.gridX = col; this.gridY = row; this.gridWidth = colSpan; this.gridHeight = rowSpan; this.hAlign = colAlign; this.vAlign = rowAlign; ensureValidOrientations(hAlign, vAlign); return this; }
this.hAlign = colAlign; this.vAlign = rowAlign; ensureValidOrientations(hAlign, vAlign); return this;
if (vAlign == null) throw new NullPointerException("The vertical alignment must not be null."); ensureValidOrientations(hAlign, vAlign);
if (vAlign == null) throw new NullPointerException("The vertical alignment must not be null."); ensureValidOrientations(hAlign, vAlign);
/** * Decodes a string description for the horizontal and vertical alignment * and set the alignment values. * <p> * Valid horizontal aligmnents are: left, middle, right, default, and fill. * Valid vertical alignments are: top, center, bottom, default, and fill. * The anchor's string representation abbreviates the alignment: l, m, r, d, * f, t, c, and b. * <p> * Anchor examples: "mc" is centered, "lt" is northwest, "mt" is north, "rc" * east. "md" is horizontally centered and uses the row's default alignment. * "dt" is on top of the cell and uses the column's default alignment. * <p> * * @param encodedAlignments * represents horizontal and vertical alignment * @throws IllegalArgumentException * if an alignment orientation is invalid */ private void setAlignments(String encodedAlignments) { StringTokenizer tokenizer = new StringTokenizer(encodedAlignments, " ,"); hAlign = decodeAlignment(tokenizer.nextToken()); vAlign = decodeAlignment(tokenizer.nextToken()); ensureValidOrientations(hAlign, vAlign); }
/** * Decodes a string description for the horizontal and vertical alignment * and sets this CellConstraints' alignment values. If the boolean is * <code>true</code> the horizontal alignment is the first token, * and the vertical alignment is the second token. if the boolean is * <code>false</code> the vertical alignment comes first. <p> * * Valid horizontal alignments are: left, middle, right, default, and fill. * Valid vertical alignments are: top, center, bottom, default, and fill. * The anchor's string representation abbreviates the alignment: * l, m, r, d, f, t, c, and b.<p> * * Anchor examples: * "m, c" is centered, "l, t" is northwest, "m, t" is north, "r, c" east. * "m, d" is horizontally centered and uses the row's default alignment. * "d, t" is on top of the cell and uses the column's default alignment.<p> * * @param encodedAlignments represents horizontal and vertical alignment * @throws IllegalArgumentException if an alignment orientation is invalid */ private void setAlignments(String encodedAlignments, boolean horizontalThenVertical) { StringTokenizer tokenizer = new StringTokenizer(encodedAlignments, " ,"); Alignment first = decodeAlignment(tokenizer.nextToken()); Alignment second = decodeAlignment(tokenizer.nextToken()); hAlign = horizontalThenVertical ? first : second; vAlign = horizontalThenVertical ? second : first; ensureValidOrientations(hAlign, vAlign); }
/** * Decodes a string description for the horizontal and vertical alignment * and sets this CellConstraints' alignment values. If the boolean is * {@code true} the horizontal alignment is the first token, * and the vertical alignment is the second token. if the boolean is * {@code false} the vertical alignment comes first. <p> * * Valid horizontal alignments are: left, center, right, default, and fill. * Valid vertical alignments are: top, center, bottom, default, and fill. * The anchor's string representation abbreviates the alignment: * l, c, r, d, f, t, and b.<p> * * Anchor examples: * "c, c" is centered, "l, t" is northwest, "c, t" is north, "r, c" east. * "c, d" is horizontally centered and uses the row's default alignment. * "d, t" is on top of the cell and uses the column's default alignment.<p> * * @param encodedAlignments represents horizontal and vertical alignment * @throws IllegalArgumentException if an alignment orientation is invalid */ private void setAlignments(String encodedAlignments, boolean horizontalThenVertical) { StringTokenizer tokenizer = new StringTokenizer(encodedAlignments, " ,"); Alignment first = decodeAlignment(tokenizer.nextToken()); Alignment second = decodeAlignment(tokenizer.nextToken()); hAlign = horizontalThenVertical ? first : second; vAlign = horizontalThenVertical ? second : first; ensureValidOrientations(hAlign, vAlign); }
ensureValidOrientations(hAlign, vAlign);
ensureValidOrientations(hAlign, vAlign);
ensureValidOrientations(hAlign, vAlign);
ensureValidOrientations(hAlign, vAlign);