public static final double calcNiceNumber(final double RANGE,final boolean ROUND){
  double niceFraction;
  double exponent=Math.floor(Math.log10(RANGE));
  double fraction=RANGE / Math.pow(10,exponent);
  if (ROUND) {
    if (Double.compare(fraction,1.5) < 0) {
      niceFraction=1;
    }
 else     if (Double.compare(fraction,3) < 0) {
      niceFraction=2;
    }
 else     if (Double.compare(fraction,7) < 0) {
      niceFraction=5;
    }
 else {
      niceFraction=10;
    }
  }
 else {
    if (Double.compare(fraction,1) <= 0) {
      niceFraction=1;
    }
 else     if (Double.compare(fraction,2) <= 0) {
      niceFraction=2;
    }
 else     if (Double.compare(fraction,5) <= 0) {
      niceFraction=5;
    }
 else {
      niceFraction=10;
    }
  }
  return niceFraction * Math.pow(10,exponent);
}

public static final double calcNiceNumber ( final double RANGE , final boolean ROUND ) { double niceFraction ; double exponent = Math . floor ( Math . log10 ( RANGE ) ) ; double fraction = RANGE / Math . pow ( 10 , exponent ) ; if ( ROUND ) { if ( Double . compare ( fraction , 1.5 ) < 0 ) { niceFraction = 1 ; } else if ( Double . compare ( fraction , 3 ) < 0 ) { niceFraction = 2 ; } else if ( Double . compare ( fraction , 7 ) < 0 ) { niceFraction = 5 ; } else { niceFraction = 10 ; } } else { if ( Double . compare ( fraction , 1 ) <= 0 ) { niceFraction = 1 ; } else if ( Double . compare ( fraction , 2 ) <= 0 ) { niceFraction = 2 ; } else if ( Double . compare ( fraction , 5 ) <= 0 ) { niceFraction = 5 ; } else { niceFraction = 10 ; } } return niceFraction * Math . pow ( 10 , exponent ) ; }
returns a " nicescaling " number approximately equal to the range . rounds the number if round = = true . takes the ceiling if round = false .
