public int add(GL10 gl,Drawable background,String text,Paint textPaint,int minWidth,int minHeight){
  checkState(STATE_ADDING,STATE_ADDING);
  boolean drawBackground=background != null;
  boolean drawText=(text != null) && (textPaint != null);
  Rect padding=new Rect();
  if (drawBackground) {
    background.getPadding(padding);
    minWidth=Math.max(minWidth,background.getMinimumWidth());
    minHeight=Math.max(minHeight,background.getMinimumHeight());
  }
  int ascent=0;
  int descent=0;
  int measuredTextWidth=0;
  if (drawText) {
    ascent=(int)Math.ceil(-textPaint.ascent());
    descent=(int)Math.ceil(textPaint.descent());
    measuredTextWidth=(int)Math.ceil(textPaint.measureText(text));
  }
  int textHeight=ascent + descent;
  int textWidth=Math.min(mStrikeWidth,measuredTextWidth);
  int padHeight=padding.top + padding.bottom;
  int padWidth=padding.left + padding.right;
  int height=Math.max(minHeight,textHeight + padHeight);
  int width=Math.max(minWidth,textWidth + padWidth);
  int effectiveTextHeight=height - padHeight;
  int effectiveTextWidth=width - padWidth;
  int centerOffsetHeight=(effectiveTextHeight - textHeight) / 2;
  int centerOffsetWidth=(effectiveTextWidth - textWidth) / 2;
  int u=mU;
  int v=mV;
  int lineHeight=mLineHeight;
  if (width > mStrikeWidth) {
    width=mStrikeWidth;
  }
  if (u + width > mStrikeWidth) {
    u=0;
    v+=lineHeight;
    lineHeight=0;
  }
  lineHeight=Math.max(lineHeight,height);
  if (v + lineHeight > mStrikeHeight) {
    throw new IllegalArgumentException("Out of texture space.");
  }
  int u2=u + width;
  int vBase=v + ascent;
  int v2=v + height;
  if (drawBackground) {
    background.setBounds(u,v,u + width,v + height);
    background.draw(mCanvas);
  }
  if (drawText) {
    mCanvas.drawText(text,u + padding.left + centerOffsetWidth,vBase + padding.top + centerOffsetHeight,textPaint);
  }
  mU=u + width;
  mV=v;
  mLineHeight=lineHeight;
  mLabels.add(new Label(width,height,ascent,u,v + height,width,-height));
  return mLabels.size() - 1;
}

public int add ( GL10 gl , Drawable background , String text , Paint textPaint , int minWidth , int minHeight ) { checkState ( STATE_ADDING , STATE_ADDING ) ; boolean drawBackground = background != null ; boolean drawText = ( text != null ) && ( textPaint != null ) ; Rect padding = new Rect ( ) ; if ( drawBackground ) { background . getPadding ( padding ) ; minWidth = Math . max ( minWidth , background . getMinimumWidth ( ) ) ; minHeight = Math . max ( minHeight , background . getMinimumHeight ( ) ) ; } int ascent = 0 ; int descent = 0 ; int measuredTextWidth = 0 ; if ( drawText ) { ascent = ( int ) Math . ceil ( - textPaint . ascent ( ) ) ; descent = ( int ) Math . ceil ( textPaint . descent ( ) ) ; measuredTextWidth = ( int ) Math . ceil ( textPaint . measureText ( text ) ) ; } int textHeight = ascent + descent ; int textWidth = Math . min ( mStrikeWidth , measuredTextWidth ) ; int padHeight = padding . top + padding . bottom ; int padWidth = padding . left + padding . right ; int height = Math . max ( minHeight , textHeight + padHeight ) ; int width = Math . max ( minWidth , textWidth + padWidth ) ; int effectiveTextHeight = height - padHeight ; int effectiveTextWidth = width - padWidth ; int centerOffsetHeight = ( effectiveTextHeight - textHeight ) / 2 ; int centerOffsetWidth = ( effectiveTextWidth - textWidth ) / 2 ; int u = mU ; int v = mV ; int lineHeight = mLineHeight ; if ( width > mStrikeWidth ) { width = mStrikeWidth ; } if ( u + width > mStrikeWidth ) { u = 0 ; v += lineHeight ; lineHeight = 0 ; } lineHeight = Math . max ( lineHeight , height ) ; if ( v + lineHeight > mStrikeHeight ) { throw new IllegalArgumentException ( "Out of texture space." ) ; } int u2 = u + width ; int vBase = v + ascent ; int v2 = v + height ; if ( drawBackground ) { background . setBounds ( u , v , u + width , v + height ) ; background . draw ( mCanvas ) ; } if ( drawText ) { mCanvas . drawText ( text , u + padding . left + centerOffsetWidth , vBase + padding . top + centerOffsetHeight , textPaint ) ; } mU = u + width ; mV = v ; mLineHeight = lineHeight ; mLabels . add ( new Label ( width , height , ascent , u , v + height , width , - height ) ) ; return mLabels . size ( ) - 1 ; }
call to add a label
