*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-package org.altusmetrum.altosuilib_2;
+package org.altusmetrum.altosuilib_14;
import java.awt.*;
import javax.swing.*;
-import org.altusmetrum.altoslib_4.*;
+import org.altusmetrum.altoslib_14.*;
public abstract class AltosUIIndicator implements AltosFontListener, AltosUnitsListener {
JLabel label;
public void show(String... s) {
int n = Math.min(s.length, values.length);
+
show();
for (int i = 0; i < n; i++)
values[i].setText(s[i]);
label.setText(text);
}
- public AltosUIIndicator (Container container, int y, String text, int number_values, boolean has_lights, int value_width) {
+ public void remove(Container container) {
+ if (lights != null)
+ container.remove(lights);
+ container.remove(label);
+ for (int i = 0; i < values.length; i++)
+ container.remove(values[i]);
+ }
+
+ public AltosUIIndicator (Container container, int x, int y, int label_width, String text, int number_values, boolean has_lights, int value_width, int value_space) {
GridBagLayout layout = (GridBagLayout)(container.getLayout());
GridBagConstraints c = new GridBagConstraints();
if (has_lights) {
lights = new AltosLights();
- c.gridx = 0; c.gridy = y;
+ c.gridx = x; c.gridy = y;
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.VERTICAL;
c.weightx = 0;
label = new JLabel(text);
label.setFont(AltosUILib.label_font);
label.setHorizontalAlignment(SwingConstants.LEFT);
- c.gridx = 1; c.gridy = y;
+ c.gridx = x + 1; c.gridy = y;
+ c.gridwidth = label_width;
c.insets = new Insets(AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad);
c.anchor = GridBagConstraints.WEST;
c.fill = GridBagConstraints.VERTICAL;
values[i].setEditable(false);
values[i].setFont(AltosUILib.value_font);
values[i].setHorizontalAlignment(SwingConstants.RIGHT);
- c.gridx = 2 + i; c.gridy = y;
+ c.gridx = 1 + label_width + x + i * value_space; c.gridy = y;
c.anchor = GridBagConstraints.WEST;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
}
}
- public AltosUIIndicator (Container container, int y, String text) {
- this(container, y, text, 1, false, 1);
+ public AltosUIIndicator (Container container, int x, int y, int label_width, String text, int number_values, boolean has_lights, int value_width) {
+ this(container, x, y, label_width, text, number_values, has_lights, value_width, 1);
}
- public AltosUIIndicator (Container container, int y, String text, int number_values) {
- this(container, y, text, number_values, false, 1);
+ public AltosUIIndicator (Container container, int x, int y, String text, int number_values, boolean has_lights, int value_width) {
+ this(container, x, y, 1, text, number_values, has_lights, value_width);
+ }
+
+ public AltosUIIndicator (Container container, int y, String text, int number_values, boolean has_lights, int value_width) {
+ this(container, 0, y, text, number_values, has_lights, value_width);
}
public AltosUIIndicator (Container container, int y, String text, int number_values, boolean has_lights) {
- this(container, y, text, number_values, has_lights, 1);
+ this(container, 0, y, text, number_values, has_lights, 1);
+ }
+
+ public AltosUIIndicator (Container container, int y, String text, int number_values) {
+ this(container, 0, y, text, number_values, false, 1);
+ }
+
+ public AltosUIIndicator (Container container, int y, String text) {
+ this(container, 0, y, text, 1, false, 1);
}
}