public static String prettyPrintDips(int px,float scaleFactor){
  String dip;
  if (scaleFactor == 1f) {
    dip=String.valueOf(px);
  }
 else   if (scaleFactor == 2f) {
    dip=String.valueOf(px / 2);
    if (px % 2 == 1) {
      dip+=ONE_HALF;
    }
  }
 else   if (scaleFactor == 3f) {
    dip=String.valueOf(px / 3);
    if (px % 3 == 1) {
      dip+=ONE_THIRD;
    }
 else     if (px % 3 == 2) {
      dip+=TWO_THIRDS;
    }
  }
 else   if (scaleFactor == 4f) {
    dip=String.valueOf(px / 4);
    if (px % 4 == 1) {
      dip+=ONE_FOURTH;
    }
 else     if (px % 4 == 2) {
      dip+=ONE_HALF;
    }
 else     if (px % 4 == 3) {
      dip+=THREE_FOURTHS;
    }
  }
 else {
    dip=DECIMAL_FORMAT.format(px / scaleFactor);
  }
  return dip;
}

public static String prettyPrintDips ( int px , float scaleFactor ) { String dip ; if ( scaleFactor == 1f ) { dip = String . valueOf ( px ) ; } else if ( scaleFactor == 2f ) { dip = String . valueOf ( px / 2 ) ; if ( px % 2 == 1 ) { dip += ONE_HALF ; } } else if ( scaleFactor == 3f ) { dip = String . valueOf ( px / 3 ) ; if ( px % 3 == 1 ) { dip += ONE_THIRD ; } else if ( px % 3 == 2 ) { dip += TWO_THIRDS ; } } else if ( scaleFactor == 4f ) { dip = String . valueOf ( px / 4 ) ; if ( px % 4 == 1 ) { dip += ONE_FOURTH ; } else if ( px % 4 == 2 ) { dip += ONE_HALF ; } else if ( px % 4 == 3 ) { dip += THREE_FOURTHS ; } } else { dip = DECIMAL_FORMAT . format ( px / scaleFactor ) ; } return dip ; }
sophisticated conversion of pixels to dips with the use of vulgar fractions ( to save screen space )
