ui/src/main/java/ucar/nc2/ui/widget/RangeSelector.java
private int calcFracDigits( String d) {
    int pos = d.indexOf(".");
    if (pos < 0) return 0;
    return d.length() - pos - 1;
  }
private int calcFracDigits( String d) {
    int pos = d.indexOf(".");
    if (pos < 0) return 0;
    return d.length() - pos - 1;
  }
/*public void setLevels( ucar.nc2.dataset.grid.GridCoordSys gcs, int current) {
this.zAxis = gcs.getVerticalAxis();
if (zAxis == null) {
slider.setEnabled( false);
return;
}
set up the slider and conversion
slider.setEnabled( true);
slider.setInverted( !gcs.isZPositive());
slider.setToolTipText( zAxis.getUnitString() );
setSelectedIndex(current);

int n = (int) zAxis.getSize();
min = Math.min(zAxis.getCoordEdge(0), zAxis.getCoordEdge(n));
max = Math.max(zAxis.getCoordEdge(0), zAxis.getCoordEdge(n));

setLabels();
slider.setPaintLabels( true );
}

private void setLabels() {
Rectangle bounds = slider.getBounds();
if (debugEvent) System.out.println(" setLevels Bounds= "+bounds);

double h = (bounds.getHeight() > 0) ? bounds.getHeight() : 100.0;
double wh = (max - min) > 0.0 ? (max - min) : 1.0;
scale = 100.0 / wh;
double slider2pixel = h/100.0;

Font font = slider.getFont();
FontMetrics fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics( font);
if (fontMetrics != null)
incrY = fontMetrics.getAscent(); // + fontMetrics.getDescent();
if (debugEvent) System.out.println(" scale= "+scale+ " incrY = "+incrY);

java.util.Hashtable labelTable = new java.util.Hashtable();

if (zAxis == null) return;
int n = (int) zAxis.getSize();
int last = world2slider(zAxis.getCoordValue(n-1));  // always
labelTable.put( new Integer( last), new JLabel(zAxis.getCoordName(n-1)) ); // always
int next = world2slider(zAxis.getCoordValue(0));
labelTable.put( new Integer( next), new JLabel(zAxis.getCoordName(0)) ); // always
if (debugLevels) System.out.println("level = "+slider2pixel*next+" "+ zAxis.getCoordName(0)+" added ");

for (int i=1; i< n-1; i++) {
int ival = world2slider(zAxis.getCoordValue(i));
if (debugLevels) System.out.println("level = "+slider2pixel*ival+" "+ zAxis.getCoordName(i));
if ((slider2pixel*Math.abs(ival-last) > incrY) &&
(slider2pixel*Math.abs(ival-next) > incrY)) {
labelTable.put( new Integer( ival), new JLabel(zAxis.getCoordName(i)) );
next = ival;
if (debugLevels) System.out.println("  added ");
}
}
if (debugLevels) System.out.println("level = "+slider2pixel*last+" "+ zAxis.getCoordName(n-1)+" added ");

slider.setLabelTable( labelTable );
}

private void setSelectedByName( String name) {
if (zAxis == null) return;
for (int i=0; i< zAxis.getSize(); i++)
if (name.equals(zAxis.getCoordName(i))) {
setSelectedIndex(i);
return;
}
System.out.println("ERROR VertScaleSlider cant find = "+name);
}

set current value - no event
private void setSelectedIndex( int idx) {
if (zAxis == null)
return;
eventOK = false;
currentIdx = idx;
slider.setValue( world2slider(zAxis.getCoordValue(currentIdx)));
eventOK = true;
}