public void layout(Container container){
  Dimension2D size=getPreferredSize(container);
  Rectangle2D bounds=container.getBounds();
  Insets2D insets=container.getInsets();
  double xMin=bounds.getMinX() + insets.getLeft();
  double yMin=bounds.getMinY() + insets.getTop();
  double width=bounds.getWidth() - insets.getLeft() - insets.getRight();
  double height=bounds.getHeight() - insets.getTop() - insets.getBottom();
  int count=0;
  if (getOrientation() == Orientation.HORIZONTAL) {
    xMin+=Math.max(bounds.getWidth() - size.getWidth(),0.0) * defaultConstraints.getAlignmentX();
    for (    Drawable component : container) {
      if (count++ > 0) {
        xMin+=getGapX();
      }
      Dimension2D compBounds=component.getPreferredSize();
      Constraints constraints=getConstraints(component,container);
      double componentHeight;
      double componentY;
      if (constraints.isStrechted()) {
        componentHeight=height;
        componentY=yMin;
      }
 else {
        componentHeight=Math.min(compBounds.getHeight(),height);
        componentY=yMin + (height - componentHeight) * constraints.getAlignmentY();
      }
      component.setBounds(xMin,componentY,compBounds.getWidth(),componentHeight);
      xMin+=compBounds.getWidth();
    }
  }
 else   if (getOrientation() == Orientation.VERTICAL) {
    yMin+=Math.max(bounds.getHeight() - size.getHeight(),0.0) * defaultConstraints.getAlignmentY();
    for (    Drawable component : container) {
      if (count++ > 0) {
        yMin+=getGapY();
      }
      Dimension2D compBounds=component.getPreferredSize();
      Constraints constraints=getConstraints(component,container);
      double componentWidth;
      double componentX;
      if (constraints.isStrechted()) {
        componentWidth=width;
        componentX=xMin;
      }
 else {
        componentWidth=Math.min(compBounds.getWidth(),width);
        componentX=xMin + (width - componentWidth) * constraints.getAlignmentX();
      }
      component.setBounds(componentX,yMin,componentWidth,compBounds.getHeight());
      yMin+=compBounds.getHeight();
    }
  }
}

public void layout ( Container container ) { Dimension2D size = getPreferredSize ( container ) ; Rectangle2D bounds = container . getBounds ( ) ; Insets2D insets = container . getInsets ( ) ; double xMin = bounds . getMinX ( ) + insets . getLeft ( ) ; double yMin = bounds . getMinY ( ) + insets . getTop ( ) ; double width = bounds . getWidth ( ) - insets . getLeft ( ) - insets . getRight ( ) ; double height = bounds . getHeight ( ) - insets . getTop ( ) - insets . getBottom ( ) ; int count = 0 ; if ( getOrientation ( ) == Orientation . HORIZONTAL ) { xMin += Math . max ( bounds . getWidth ( ) - size . getWidth ( ) , 0.0 ) * defaultConstraints . getAlignmentX ( ) ; for ( Drawable component : container ) { if ( count ++ > 0 ) { xMin += getGapX ( ) ; } Dimension2D compBounds = component . getPreferredSize ( ) ; Constraints constraints = getConstraints ( component , container ) ; double componentHeight ; double componentY ; if ( constraints . isStrechted ( ) ) { componentHeight = height ; componentY = yMin ; } else { componentHeight = Math . min ( compBounds . getHeight ( ) , height ) ; componentY = yMin + ( height - componentHeight ) * constraints . getAlignmentY ( ) ; } component . setBounds ( xMin , componentY , compBounds . getWidth ( ) , componentHeight ) ; xMin += compBounds . getWidth ( ) ; } } else if ( getOrientation ( ) == Orientation . VERTICAL ) { yMin += Math . max ( bounds . getHeight ( ) - size . getHeight ( ) , 0.0 ) * defaultConstraints . getAlignmentY ( ) ; for ( Drawable component : container ) { if ( count ++ > 0 ) { yMin += getGapY ( ) ; } Dimension2D compBounds = component . getPreferredSize ( ) ; Constraints constraints = getConstraints ( component , container ) ; double componentWidth ; double componentX ; if ( constraints . isStrechted ( ) ) { componentWidth = width ; componentX = xMin ; } else { componentWidth = Math . min ( compBounds . getWidth ( ) , width ) ; componentX = xMin + ( width - componentWidth ) * constraints . getAlignmentX ( ) ; } component . setBounds ( componentX , yMin , componentWidth , compBounds . getHeight ( ) ) ; yMin += compBounds . getHeight ( ) ; } } }
arranges the components of the specified container according to this layout .
