MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / niceNumber

Method niceNumber

ij/src/main/java/ij/gui/Plot.java:3023–3029  ·  view source on GitHub ↗

Returns the smallest "nice" number >= v. "Nice" numbers are .. 0.5, 1, 2, 5, 10, 20 ...

(double v)

Source from the content-addressed store, hash-verified

3021
3022 /** Returns the smallest "nice" number >= v. "Nice" numbers are .. 0.5, 1, 2, 5, 10, 20 ... */
3023 @AstroImageJ(reason = "Access widen for Vector Plot saving", modified = true)
3024 public double niceNumber(double v) {
3025 double base = Math.pow(10,Math.floor(Math.log10(v)-1.e-6));
3026 if (v > 5.0000001*base) return 10*base;
3027 else if (v > 2.0000001*base) return 5*base;
3028 else return 2*base;
3029 }
3030
3031 /** draw something like 1.2 10^-9; returns the width of the string drawn.
3032 * 'Digits' should be >=0 for drawing the mantissa (=1.38 in this example), negative to draw only 10^exponent

Callers 3

makeRangeGetStepsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected