Beispiel #1
0
 /**
  * Computes and returns the pixel size of the given component using the given form specification,
  * measures, and cell size.
  *
  * @param component the component to measure
  * @param formSpec the specification of the component's column/row
  * @param minMeasure the measure for the minimum size
  * @param prefMeasure the measure for the preferred size
  * @param cellSize the cell size
  * @return the component size as measured or a constant
  */
 private int componentSize(
     Control component,
     FormSpec formSpec,
     int cellSize,
     FormLayout.Measure minMeasure,
     FormLayout.Measure prefMeasure) {
   if (formSpec == null) {
     return prefMeasure.sizeOf(component);
   } else if (formSpec.getSize() == Sizes.MINIMUM) {
     return minMeasure.sizeOf(component);
   } else if (formSpec.getSize() == Sizes.PREFERRED) {
     return prefMeasure.sizeOf(component);
   } else { // default mode
     return Math.min(cellSize, prefMeasure.sizeOf(component));
   }
 }
Beispiel #2
0
 /**
  * Returns the alignment used for a given form constraints object. The cell alignment overrides
  * the column or row default, unless it is <code>DEFAULT</code>. In the latter case, we use the
  * column or row alignment.
  *
  * @param cellAlignment this cell constraint's alignment
  * @param formSpec the associated column or row specification
  * @return the alignment used
  */
 private Alignment usedAlignment(Alignment cellAlignment, FormSpec formSpec) {
   if (cellAlignment != CellConstraints.DEFAULT) {
     // Cell alignments other than DEFAULT override col/row alignments
     return cellAlignment;
   }
   FormSpec.DefaultAlignment defaultAlignment = formSpec.getDefaultAlignment();
   if (defaultAlignment == FormSpec.FILL_ALIGN) return FILL;
   if (defaultAlignment == ColumnSpec.LEFT) return LEFT;
   else if (defaultAlignment == FormSpec.CENTER_ALIGN) return CENTER;
   else if (defaultAlignment == ColumnSpec.RIGHT) return RIGHT;
   else if (defaultAlignment == RowSpec.TOP) return TOP;
   else return BOTTOM;
 }