private void drawText(String text,RectF rect,Canvas canvas,float originalTop,float originalLeft){
  if (rect.right - rect.left - mEventPadding * 2 < 0)   return;
  StaticLayout textLayout=new StaticLayout(text,mEventTextPaint,(int)(rect.right - originalLeft - mEventPadding * 2),Layout.Alignment.ALIGN_NORMAL,1.0f,0.0f,false);
  int availableHeight=(int)(rect.bottom - originalTop - mEventPadding * 2);
  int lineHeight=textLayout.getHeight() / textLayout.getLineCount();
  if (lineHeight < availableHeight && textLayout.getHeight() > rect.height() - mEventPadding * 2) {
    int lineCount=textLayout.getLineCount();
    int availableLineCount=(int)Math.floor(lineCount * availableHeight / textLayout.getHeight());
    float widthAvailable=(rect.right - originalLeft - mEventPadding * 2) * availableLineCount;
    textLayout=new StaticLayout(TextUtils.ellipsize(text,mEventTextPaint,widthAvailable,TextUtils.TruncateAt.END),mEventTextPaint,(int)(rect.right - originalLeft - mEventPadding * 2),Layout.Alignment.ALIGN_NORMAL,1.0f,0.0f,false);
  }
 else   if (lineHeight >= availableHeight) {
    int width=(int)(rect.right - originalLeft - mEventPadding * 2);
    textLayout=new StaticLayout(TextUtils.ellipsize(text,mEventTextPaint,width,TextUtils.TruncateAt.END),mEventTextPaint,width,Layout.Alignment.ALIGN_NORMAL,1.0f,1.0f,false);
  }
  canvas.save();
  canvas.translate(originalLeft + mEventPadding,originalTop + mEventPadding);
  textLayout.draw(canvas);
  canvas.restore();
}

private void drawText ( String text , RectF rect , Canvas canvas , float originalTop , float originalLeft ) { if ( rect . right - rect . left - mEventPadding * 2 < 0 ) return ; StaticLayout textLayout = new StaticLayout ( text , mEventTextPaint , ( int ) ( rect . right - originalLeft - mEventPadding * 2 ) , Layout . Alignment . ALIGN_NORMAL , 1.0f , 0.0f , false ) ; int availableHeight = ( int ) ( rect . bottom - originalTop - mEventPadding * 2 ) ; int lineHeight = textLayout . getHeight ( ) / textLayout . getLineCount ( ) ; if ( lineHeight < availableHeight && textLayout . getHeight ( ) > rect . height ( ) - mEventPadding * 2 ) { int lineCount = textLayout . getLineCount ( ) ; int availableLineCount = ( int ) Math . floor ( lineCount * availableHeight / textLayout . getHeight ( ) ) ; float widthAvailable = ( rect . right - originalLeft - mEventPadding * 2 ) * availableLineCount ; textLayout = new StaticLayout ( TextUtils . ellipsize ( text , mEventTextPaint , widthAvailable , TextUtils . TruncateAt . END ) , mEventTextPaint , ( int ) ( rect . right - originalLeft - mEventPadding * 2 ) , Layout . Alignment . ALIGN_NORMAL , 1.0f , 0.0f , false ) ; } else if ( lineHeight >= availableHeight ) { int width = ( int ) ( rect . right - originalLeft - mEventPadding * 2 ) ; textLayout = new StaticLayout ( TextUtils . ellipsize ( text , mEventTextPaint , width , TextUtils . TruncateAt . END ) , mEventTextPaint , width , Layout . Alignment . ALIGN_NORMAL , 1.0f , 1.0f , false ) ; } canvas . save ( ) ; canvas . translate ( originalLeft + mEventPadding , originalTop + mEventPadding ) ; textLayout . draw ( canvas ) ; canvas . restore ( ) ; }
draw the name of the event on top of the event rectangle .
