- public class Value {
- JLabel label;
- JTextField value;
- void show(AltosState state, AltosListenerState listener_state) {}
-
- void reset() {
- value.setText("");
- }
-
- void show() {
- label.setVisible(true);
- value.setVisible(true);
- }
-
- void show(String s) {
- show();
- value.setText(s);
- }
-
- void show(AltosUnits units, double v) {
- show(units.show(8, v));
- }
-
- void show(String format, double v) {
- show(String.format(format, v));
- }
-
- void hide() {
- label.setVisible(false);
- value.setVisible(false);
- }
- void set_font() {
- label.setFont(AltosUILib.label_font);
- value.setFont(AltosUILib.value_font);
- }
-
- public Value (GridBagLayout layout, int y, String text) {
- GridBagConstraints c = new GridBagConstraints();
- c.weighty = 1;
-
- label = new JLabel(text);
- label.setFont(AltosUILib.label_font);
- label.setHorizontalAlignment(SwingConstants.LEFT);
- c.gridx = 1; c.gridy = y;
- 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;
- c.weightx = 0;
- layout.setConstraints(label, c);
- add(label);
-
- value = new JTextField(AltosUILib.text_width);
- value.setFont(AltosUILib.value_font);
- value.setHorizontalAlignment(SwingConstants.RIGHT);
- c.gridx = 2; c.gridy = y;
- c.anchor = GridBagConstraints.WEST;
- c.fill = GridBagConstraints.BOTH;
- c.gridwidth = 2;
- c.weightx = 1;
- layout.setConstraints(value, c);
- add(value);
- }
- }
-
- public abstract class DualValue {
- JLabel label;
- JTextField value1;
- JTextField value2;
-
- void reset() {
- value1.setText("");
- value2.setText("");
- }
-
- void show() {
- label.setVisible(true);
- value1.setVisible(true);
- value2.setVisible(true);
- }
-
- void hide() {
- label.setVisible(false);
- value1.setVisible(false);
- value2.setVisible(false);
- }
-
- void set_font() {
- label.setFont(AltosUILib.label_font);
- value1.setFont(AltosUILib.value_font);
- value2.setFont(AltosUILib.value_font);
- }
-
- abstract void show(AltosState state, AltosListenerState listener_state);
-
- void show(String v1, String v2) {
- show();
- value1.setText(v1);
- value2.setText(v2);
- }
- void show(String f1, double v1, String f2, double v2) {
- show();
- value1.setText(String.format(f1, v1));
- value2.setText(String.format(f2, v2));
- }
-
- public DualValue (GridBagLayout layout, int x, int y, String text) {
- GridBagConstraints c = new GridBagConstraints();
- c.weighty = 1;
-
- label = new JLabel(text);
- label.setFont(AltosUILib.label_font);
- label.setHorizontalAlignment(SwingConstants.LEFT);
- c.gridx = x + 1; c.gridy = y;
- 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;
- c.weightx = 0;
- layout.setConstraints(label, c);
- add(label);
-
- value1 = new JTextField(AltosUILib.text_width);
- value1.setFont(AltosUILib.value_font);
- value1.setHorizontalAlignment(SwingConstants.RIGHT);
- c.gridx = x + 2; c.gridy = y;
- c.anchor = GridBagConstraints.WEST;
- c.fill = GridBagConstraints.BOTH;
- c.weightx = 1;
- layout.setConstraints(value1, c);
- add(value1);
-
- value2 = new JTextField(AltosUILib.text_width);
- value2.setFont(AltosUILib.value_font);
- value2.setHorizontalAlignment(SwingConstants.RIGHT);
- c.gridx = x + 3; c.gridy = y;
- c.anchor = GridBagConstraints.WEST;
- c.fill = GridBagConstraints.BOTH;
- c.weightx = 1;
- c.gridwidth = 1;
- layout.setConstraints(value2, c);
- add(value2);