protected void drawLabel(Canvas canvas,String labelText,DefaultRenderer renderer,List<RectF> prevLabelsBounds,int centerX,int centerY,float shortRadius,float longRadius,float currentAngle,float angle,int left,int right,int color,Paint paint,boolean line,boolean display){
  if (renderer.isShowLabels() || display) {
    paint.setColor(color);
    double rAngle=Math.toRadians(90 - (currentAngle + angle / 2));
    double sinValue=Math.sin(rAngle);
    double cosValue=Math.cos(rAngle);
    int x1=Math.round(centerX + (float)(shortRadius * sinValue));
    int y1=Math.round(centerY + (float)(shortRadius * cosValue));
    int x2=Math.round(centerX + (float)(longRadius * sinValue));
    int y2=Math.round(centerY + (float)(longRadius * cosValue));
    float size=renderer.getLabelsTextSize();
    float extra=Math.max(size / 2,10);
    paint.setTextAlign(Align.LEFT);
    if (x1 > x2) {
      extra=-extra;
      paint.setTextAlign(Align.RIGHT);
    }
    float xLabel=x2 + extra;
    float yLabel=y2;
    float width=right - xLabel;
    if (x1 > x2) {
      width=xLabel - left;
    }
    labelText=getFitText(labelText,width,paint);
    float widthLabel=paint.measureText(labelText);
    boolean okBounds=false;
    while (!okBounds && line) {
      boolean intersects=false;
      int length=prevLabelsBounds.size();
      for (int j=0; j < length && !intersects; j++) {
        RectF prevLabelBounds=prevLabelsBounds.get(j);
        if (prevLabelBounds.intersects(xLabel,yLabel,xLabel + widthLabel,yLabel + size)) {
          intersects=true;
          yLabel=Math.max(yLabel,prevLabelBounds.bottom);
        }
      }
      okBounds=!intersects;
    }
    if (line) {
      y2=(int)(yLabel - size / 2);
      canvas.drawLine(x1,y1,x2,y2,paint);
      canvas.drawLine(x2,y2,x2 + extra,y2,paint);
    }
 else {
      paint.setTextAlign(Align.CENTER);
    }
    canvas.drawText(labelText,xLabel,yLabel,paint);
    if (line) {
      prevLabelsBounds.add(new RectF(xLabel,yLabel,xLabel + widthLabel,yLabel + size));
    }
  }
}

protected void drawLabel ( Canvas canvas , String labelText , DefaultRenderer renderer , List < RectF > prevLabelsBounds , int centerX , int centerY , float shortRadius , float longRadius , float currentAngle , float angle , int left , int right , int color , Paint paint , boolean line , boolean display ) { if ( renderer . isShowLabels ( ) || display ) { paint . setColor ( color ) ; double rAngle = Math . toRadians ( 90 - ( currentAngle + angle / 2 ) ) ; double sinValue = Math . sin ( rAngle ) ; double cosValue = Math . cos ( rAngle ) ; int x1 = Math . round ( centerX + ( float ) ( shortRadius * sinValue ) ) ; int y1 = Math . round ( centerY + ( float ) ( shortRadius * cosValue ) ) ; int x2 = Math . round ( centerX + ( float ) ( longRadius * sinValue ) ) ; int y2 = Math . round ( centerY + ( float ) ( longRadius * cosValue ) ) ; float size = renderer . getLabelsTextSize ( ) ; float extra = Math . max ( size / 2 , 10 ) ; paint . setTextAlign ( Align . LEFT ) ; if ( x1 > x2 ) { extra = - extra ; paint . setTextAlign ( Align . RIGHT ) ; } float xLabel = x2 + extra ; float yLabel = y2 ; float width = right - xLabel ; if ( x1 > x2 ) { width = xLabel - left ; } labelText = getFitText ( labelText , width , paint ) ; float widthLabel = paint . measureText ( labelText ) ; boolean okBounds = false ; while ( ! okBounds && line ) { boolean intersects = false ; int length = prevLabelsBounds . size ( ) ; for ( int j = 0 ; j < length && ! intersects ; j ++ ) { RectF prevLabelBounds = prevLabelsBounds . get ( j ) ; if ( prevLabelBounds . intersects ( xLabel , yLabel , xLabel + widthLabel , yLabel + size ) ) { intersects = true ; yLabel = Math . max ( yLabel , prevLabelBounds . bottom ) ; } } okBounds = ! intersects ; } if ( line ) { y2 = ( int ) ( yLabel - size / 2 ) ; canvas . drawLine ( x1 , y1 , x2 , y2 , paint ) ; canvas . drawLine ( x2 , y2 , x2 + extra , y2 , paint ) ; } else { paint . setTextAlign ( Align . CENTER ) ; } canvas . drawText ( labelText , xLabel , yLabel , paint ) ; if ( line ) { prevLabelsBounds . add ( new RectF ( xLabel , yLabel , xLabel + widthLabel , yLabel + size ) ) ; } } }
draws a text label .
