((OMRangeRings) circle).setIntervalUnits(Length.get((String) jcb.getSelectedItem())); updateInterval(intervalField.getText());
OMRangeRings rr = (OMRangeRings) circle; Length newLength = Length.get((String) jcb.getSelectedItem()); Length oldLength = rr.getIntervalUnits();    int value = interpretValue(intervalField.getText()); if (value <= 0) { value = 4; }   if (newLength != null && oldLength != null) { value = (int) newLength.fromRadians(oldLength.toRadians(value)); } else { int numSubCircles; if (rr.subCircles == null || rr.subCircles.length == 0) { numSubCircles = 1; } else { numSubCircles = rr.subCircles.length; }  if (newLength == null) { value = numSubCircles; } else if (oldLength == null) { value = (int) newLength.fromRadians(Length.DECIMAL_DEGREE.toRadians(rr.getRadius())) / numSubCircles; } }  ((OMRangeRings) circle).setIntervalUnits(newLength); updateInterval(value);
    protected JToolBar getRangeRingGUI() {        if (rrToolBar == null) {            rrToolBar = new GridBagToolBar();            rrToolBar.setFloatable(false);            rrToolBar.setMargin(new Insets(0, 1, 0, 1));            //  JPanel intervalPanel =            // PaletteHelper.createPaletteJPanel("Interval");            intervalField = new JTextField(Integer.toString(((OMRangeRings) circle).getInterval()), 5);            intervalField.setMargin(new Insets(0, 1, 0, 1));            intervalField.setHorizontalAlignment(JTextField.RIGHT);            intervalField.setToolTipText(i18n.get(this, "intervalField.tooltip"              , "Value for interval between rings."));            intervalField.addActionListener(new ActionListener() {                public void actionPerformed(ActionEvent ae) {                    updateInterval(((JTextField) (ae.getSource())).getText());                }            });            rrToolBar.add(intervalField);            //  JSlider intervalSlide = new JSlider(            //      JSlider.HORIZONTAL, 1/*min*/, 200/*max*/,            //      ((OMRangeRings)circle).getInterval()/*inital*/);            //  java.util.Hashtable dict = new java.util.Hashtable();            //  dict.put(new Integer(1), new JLabel("1"));            //  dict.put(new Integer(50), new JLabel("50"));            //  dict.put(new Integer(100), new JLabel("100"));            //  dict.put(new Integer(150), new JLabel("150"));            //  dict.put(new Integer(200), new JLabel("200"));            //  intervalSlide.setLabelTable(dict);            //  intervalSlide.setPaintLabels(true);            //  intervalSlide.setMajorTickSpacing(10);            //  intervalSlide.setPaintTicks(true);            //  intervalSlide.setSnapToTicks(false);            //  intervalSlide.addChangeListener(new ChangeListener() {            //          public void stateChanged(ChangeEvent ce) {            //              JSlider slider = (JSlider) ce.getSource();            //              if (slider.getValueIsAdjusting()) {            //                  ((OMRangeRings)circle).setInterval(slider.getValue());            //              }            //          }            //      });            Length[] available = Length.getAvailable();            String[] unitStrings = new String[available.length + 1];            String current = null;            Length l = ((OMRangeRings) circle).getIntervalUnits();            if (l != null) {                current = l.toString();            }            int currentIndex = unitStrings.length - 1;            for (int i = 0; i < available.length; i++) {                unitStrings[i] = available[i].toString();                if (current != null && unitStrings[i].equals(current)) {                    currentIndex = i;                }            }            unitStrings[unitStrings.length - 1] = i18n.get(this, "unitStrings.concentric", "concentric");            JComboBox unitList = new JComboBox(unitStrings);            unitList.setBorder(new javax.swing.border.EmptyBorder(0, 1, 0, 1));            unitList.setSelectedIndex(currentIndex);            unitList.addActionListener(new ActionListener() {                public void actionPerformed(ActionEvent e) {                    JComboBox jcb = (JComboBox) e.getSource();                    ((OMRangeRings) circle).setIntervalUnits(Length.get((String) jcb.getSelectedItem()));                    updateInterval(intervalField.getText());                }            });            rrToolBar.add(unitList);        }        return rrToolBar;    }