private JComboBox makeUnitsCombo() {
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 combo = new JComboBox(unitStrings);
combo.setBorder(new EmptyBorder(0, 1, 0, 1));
combo.setSelectedIndex(currentIndex);
combo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JComboBox jcb = (JComboBox) e.getSource();
OMRangeRings rr = (OMRangeRings) circle;
Length newLength = Length.get((String) jcb.getSelectedItem());
Length oldLength = rr.getIntervalUnits();
/*
* If newLength is not null and oldLength is not null, just
* translate the distance that is current specified. If
* newLength is null, then find out how many rings are on the
* range ring and set the interval to that. If oldLength is
* null, find out the radius and divide it by the number of
* rings - 1.
*/
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 {