X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosuilib%2FAltosUIIndicator.java;h=f47a2f29797041aa6698ed4cd786c1e501ea998d;hp=59fe231b5f4be56c5ec0e097b8448b8e36d2ef2a;hb=1085ec5d57e0ed5d132f2bbdac1a0b6a32c0ab4a;hpb=7ed63b6c3d5878a59f52f4114b5b01942735805f diff --git a/altosuilib/AltosUIIndicator.java b/altosuilib/AltosUIIndicator.java index 59fe231b..f47a2f29 100644 --- a/altosuilib/AltosUIIndicator.java +++ b/altosuilib/AltosUIIndicator.java @@ -3,7 +3,8 @@ * * 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 @@ -15,11 +16,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_2; +package org.altusmetrum.altosuilib_11; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altoslib_11.*; public abstract class AltosUIIndicator implements AltosFontListener, AltosUnitsListener { JLabel label; @@ -60,6 +61,7 @@ public abstract class AltosUIIndicator implements AltosFontListener, AltosUnitsL 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]); @@ -102,7 +104,15 @@ public abstract class AltosUIIndicator implements AltosFontListener, AltosUnitsL 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(); @@ -110,7 +120,7 @@ public abstract class AltosUIIndicator implements AltosFontListener, AltosUnitsL 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; @@ -121,7 +131,8 @@ public abstract class AltosUIIndicator implements AltosFontListener, AltosUnitsL 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; @@ -135,7 +146,7 @@ public abstract class AltosUIIndicator implements AltosFontListener, AltosUnitsL 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; @@ -145,15 +156,27 @@ public abstract class AltosUIIndicator implements AltosFontListener, AltosUnitsL } } - 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); } }