private void alignOnBaseline(GridBagConstraints cons,Rectangle r,int cellY,int cellHeight){
  if (cons.ascent >= 0) {
    if (cons.baselineResizeBehavior == Component.BaselineResizeBehavior.CONSTANT_DESCENT) {
      int maxY=cellY + cellHeight - layoutInfo.maxDescent[cons.tempY + cons.tempHeight - 1] + cons.descent - cons.insets.bottom;
      if (!cons.isVerticallyResizable()) {
        r.y=maxY - cons.minHeight;
        r.height=cons.minHeight;
      }
 else {
        r.height=maxY - cellY - cons.insets.top;
      }
    }
 else {
      int baseline;
      int ascent=cons.ascent;
      if (layoutInfo.hasConstantDescent(cons.tempY)) {
        baseline=cellHeight - layoutInfo.maxDescent[cons.tempY];
      }
 else {
        baseline=layoutInfo.maxAscent[cons.tempY];
      }
      if (cons.baselineResizeBehavior == Component.BaselineResizeBehavior.OTHER) {
        boolean fits=false;
        ascent=componentAdjusting.getBaseline(r.width,r.height);
        if (ascent >= 0) {
          ascent+=cons.insets.top;
        }
        if (ascent >= 0 && ascent <= baseline) {
          if (baseline + (r.height - ascent - cons.insets.top) <= cellHeight - cons.insets.bottom) {
            fits=true;
          }
 else           if (cons.isVerticallyResizable()) {
            int ascent2=componentAdjusting.getBaseline(r.width,cellHeight - cons.insets.bottom - baseline + ascent);
            if (ascent2 >= 0) {
              ascent2+=cons.insets.top;
            }
            if (ascent2 >= 0 && ascent2 <= ascent) {
              r.height=cellHeight - cons.insets.bottom - baseline + ascent;
              ascent=ascent2;
              fits=true;
            }
          }
        }
        if (!fits) {
          ascent=cons.ascent;
          r.width=cons.minWidth;
          r.height=cons.minHeight;
        }
      }
      r.y=cellY + baseline - ascent + cons.insets.top;
      if (cons.isVerticallyResizable()) {
switch (cons.baselineResizeBehavior) {
case CONSTANT_ASCENT:
          r.height=Math.max(cons.minHeight,cellY + cellHeight - r.y - cons.insets.bottom);
        break;
case CENTER_OFFSET:
{
        int upper=r.y - cellY - cons.insets.top;
        int lower=cellY + cellHeight - r.y - cons.minHeight - cons.insets.bottom;
        int delta=Math.min(upper,lower);
        delta+=delta;
        if (delta > 0 && (cons.minHeight + cons.centerPadding + delta) / 2 + cons.centerOffset != baseline) {
          delta--;
        }
        r.height=cons.minHeight + delta;
        r.y=cellY + baseline - (r.height + cons.centerPadding) / 2 - cons.centerOffset;
      }
    break;
case OTHER:
  break;
default :
break;
}
}
}
}
 else {
centerVertically(cons,r,cellHeight);
}
}

private void alignOnBaseline ( GridBagConstraints cons , Rectangle r , int cellY , int cellHeight ) { if ( cons . ascent >= 0 ) { if ( cons . baselineResizeBehavior == Component . BaselineResizeBehavior . CONSTANT_DESCENT ) { int maxY = cellY + cellHeight - layoutInfo . maxDescent [ cons . tempY + cons . tempHeight - 1 ] + cons . descent - cons . insets . bottom ; if ( ! cons . isVerticallyResizable ( ) ) { r . y = maxY - cons . minHeight ; r . height = cons . minHeight ; } else { r . height = maxY - cellY - cons . insets . top ; } } else { int baseline ; int ascent = cons . ascent ; if ( layoutInfo . hasConstantDescent ( cons . tempY ) ) { baseline = cellHeight - layoutInfo . maxDescent [ cons . tempY ] ; } else { baseline = layoutInfo . maxAscent [ cons . tempY ] ; } if ( cons . baselineResizeBehavior == Component . BaselineResizeBehavior . OTHER ) { boolean fits = false ; ascent = componentAdjusting . getBaseline ( r . width , r . height ) ; if ( ascent >= 0 ) { ascent += cons . insets . top ; } if ( ascent >= 0 && ascent <= baseline ) { if ( baseline + ( r . height - ascent - cons . insets . top ) <= cellHeight - cons . insets . bottom ) { fits = true ; } else if ( cons . isVerticallyResizable ( ) ) { int ascent2 = componentAdjusting . getBaseline ( r . width , cellHeight - cons . insets . bottom - baseline + ascent ) ; if ( ascent2 >= 0 ) { ascent2 += cons . insets . top ; } if ( ascent2 >= 0 && ascent2 <= ascent ) { r . height = cellHeight - cons . insets . bottom - baseline + ascent ; ascent = ascent2 ; fits = true ; } } } if ( ! fits ) { ascent = cons . ascent ; r . width = cons . minWidth ; r . height = cons . minHeight ; } } r . y = cellY + baseline - ascent + cons . insets . top ; if ( cons . isVerticallyResizable ( ) ) { switch ( cons . baselineResizeBehavior ) { case CONSTANT_ASCENT : r . height = Math . max ( cons . minHeight , cellY + cellHeight - r . y - cons . insets . bottom ) ; break ; case CENTER_OFFSET : { int upper = r . y - cellY - cons . insets . top ; int lower = cellY + cellHeight - r . y - cons . minHeight - cons . insets . bottom ; int delta = Math . min ( upper , lower ) ; delta += delta ; if ( delta > 0 && ( cons . minHeight + cons . centerPadding + delta ) / 2 + cons . centerOffset != baseline ) { delta -- ; } r . height = cons . minHeight + delta ; r . y = cellY + baseline - ( r . height + cons . centerPadding ) / 2 - cons . centerOffset ; } break ; case OTHER : break ; default : break ; } } } } else { centerVertically ( cons , r , cellHeight ) ; } }
positions on the baseline .
