예제 #1
0
 /**
  * Sets the component's bounds using the given component and cell bounds.
  *
  * @param c the component to set bounds
  * @param layout the FormLayout instance that computes the bounds
  * @param cellBounds the cell's bounds
  * @param minWidthMeasure measures the minimum width
  * @param minHeightMeasure measures the minimum height
  * @param prefWidthMeasure measures the preferred width
  * @param prefHeightMeasure measures the preferred height
  */
 void setBounds(
     Control c,
     FormLayout layout,
     Rectangle cellBounds,
     FormLayout.Measure minWidthMeasure,
     FormLayout.Measure minHeightMeasure,
     FormLayout.Measure prefWidthMeasure,
     FormLayout.Measure prefHeightMeasure) {
   ColumnSpec colSpec = gridWidth == 1 ? layout.getColumnSpec(gridX) : null;
   RowSpec rowSpec = gridHeight == 1 ? layout.getRowSpec(gridY) : null;
   Alignment concreteHAlign = concreteAlignment(this.hAlign, colSpec);
   Alignment concreteVAlign = concreteAlignment(this.vAlign, rowSpec);
   Insets concreteInsets = this.insets != null ? this.insets : EMPTY_INSETS;
   int cellX = cellBounds.x + concreteInsets.getLeft();
   int cellY = cellBounds.y + concreteInsets.getTop();
   int cellW = cellBounds.width - concreteInsets.getLeft() - concreteInsets.getRight();
   int cellH = cellBounds.height - concreteInsets.getTop() - concreteInsets.getBottom();
   int compW = componentSize(c, colSpec, cellW, minWidthMeasure, prefWidthMeasure);
   int compH = componentSize(c, rowSpec, cellH, minHeightMeasure, prefHeightMeasure);
   int x = origin(concreteHAlign, cellX, cellW, compW);
   int y = origin(concreteVAlign, cellY, cellH, compH);
   int w = extent(concreteHAlign, cellW, compW);
   int h = extent(concreteVAlign, cellH, compH);
   c.setBounds(x, y, w, h);
 }
예제 #2
0
 public static Insets add(Insets insets1, Insets insets2) {
   if (insets1 == null) {
     return insets2;
   } else if (insets2 == null) {
     return insets1;
   }
   return new Insets(
       insets1.getTop() + insets2.getTop(),
       insets1.getRight() + insets2.getRight(),
       insets1.getBottom() + insets2.getBottom(),
       insets1.getLeft() + insets2.getLeft());
 }