Author: Michael Kaul
(double d)
| 993 | |
| 994 | /** Author: Michael Kaul */ |
| 995 | private static int digits(double d) { |
| 996 | if (d == (int)d) |
| 997 | return 0; |
| 998 | String s = Double.toString(d); |
| 999 | int ePos = s.indexOf("E"); |
| 1000 | if (ePos==-1) |
| 1001 | ePos = s.indexOf("e"); |
| 1002 | int dotPos = s.indexOf( "." ); |
| 1003 | int digits = 0; |
| 1004 | if (ePos==-1 ) |
| 1005 | digits = s.substring(dotPos+1).length(); |
| 1006 | else { |
| 1007 | String number = s.substring( dotPos + 1, ePos ); |
| 1008 | if (!number.equals( "0" )) |
| 1009 | digits += number.length( ); |
| 1010 | digits = digits - Integer.valueOf(s.substring(ePos+1)); |
| 1011 | } |
| 1012 | return digits; |
| 1013 | } |
| 1014 | |
| 1015 | private void addSlider(String label, double minValue, double maxValue, double defaultValue, double scale, int digits) { |
| 1016 | @AstroImageJ(reason = "Value text box on Mac is two characters too narrow.", modified = true) |