private void calculateValueTextHeight ( ) { Rect valueRect = new Rect ( ) ; Rect legendRect = new Rect ( ) ; String str = Utils . getFloatString ( mFocusedPoint . getValue ( ) , mShowDecimal ) + ( ! mIndicatorTextUnit . isEmpty ( ) ? " " + mIndicatorTextUnit : "" ) ; // calculate the boundaries for both texts mIndicatorPaint . getTextBounds ( str , 0 , str . length ( ) , valueRect ) ; mLegendPaint . getTextBounds ( mFocusedPoint . getLegendLabel ( ) , 0 , mFocusedPoint . getLegendLabel ( ) . length ( ) , legendRect ) ; // calculate string positions in overlay mValueTextHeight = valueRect . height ( ) ; mValueLabelY = ( int ) ( mValueTextHeight + mIndicatorTopPadding ) ; mLegendLabelY = ( int ) ( mValueTextHeight + mIndicatorTopPadding + legendRect . height ( ) + Utils . dpToPx ( 7.f ) ) ; int chosenWidth = valueRect . width ( ) > legendRect . width ( ) ? valueRect . width ( ) : legendRect . width ( ) ; // check if text reaches over screen if ( mFocusedPoint . getCoordinates ( ) . getX ( ) + chosenWidth + mIndicatorLeftPadding > - Utils . getTranslationX ( mDrawMatrixValues ) + mGraphWidth ) { mValueLabelX = ( int ) ( mFocusedPoint . getCoordinates ( ) . getX ( ) - ( valueRect . width ( ) + mIndicatorLeftPadding ) ) ; mLegendLabelX = ( int ) ( mFocusedPoint . getCoordinates ( ) . getX ( ) - ( legendRect . width ( ) + mIndicatorLeftPadding ) ) ; } else { mValueLabelX = mLegendLabelX = ( int ) ( mFocusedPoint . getCoordinates ( ) . getX ( ) + mIndicatorLeftPadding ) ; } }
Calculates the text height for the indicator value and sets its x - coordinate .