X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosuilib%2FAltosUIEnable.java;h=da98797a7cfd7ae54f78cc6fe0fa5941bb5c6eab;hp=297cf3208b4544a6e6294ec3ad81c410065417c5;hb=66c4a091bb6a294f9d406e75f3634492c886d139;hpb=0169e56ad030c0096b1068d00f06957990dfb31f diff --git a/altosuilib/AltosUIEnable.java b/altosuilib/AltosUIEnable.java index 297cf320..da98797a 100644 --- a/altosuilib/AltosUIEnable.java +++ b/altosuilib/AltosUIEnable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.awt.*; import java.awt.event.*; @@ -23,7 +23,7 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altoslib_4.*; import org.jfree.ui.*; import org.jfree.chart.*; @@ -39,11 +39,13 @@ public class AltosUIEnable extends Container { Insets il, ir; int y; + int x; + + static final int max_rows = 14; class GraphElement implements ActionListener { AltosUIGrapher grapher; - JLabel label; - JRadioButton enable; + JCheckBox enable; String name; public void actionPerformed(ActionEvent ae) { @@ -53,9 +55,8 @@ public class AltosUIEnable extends Container { GraphElement (String name, AltosUIGrapher grapher, boolean enabled) { this.name = name; this.grapher = grapher; - label = new JLabel(name); - enable = new JRadioButton("Enable", enabled); - grapher.set_enable(enabled); + enable = new JCheckBox(name, enabled); + grapher.set_enable(enabled); enable.addActionListener(this); } } @@ -63,18 +64,11 @@ public class AltosUIEnable extends Container { public void add(String name, AltosUIGrapher grapher, boolean enabled) { GraphElement e = new GraphElement(name, grapher, enabled); - - /* Add label */ GridBagConstraints c = new GridBagConstraints(); - c.gridx = 0; c.gridy = y; - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.LINE_START; - c.insets = il; - add(e.label, c); - /* Add radio button */ + /* Add element */ c = new GridBagConstraints(); - c.gridx = 1; c.gridy = y; + c.gridx = x; c.gridy = y; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.CENTER; c.insets = ir; @@ -82,12 +76,39 @@ public class AltosUIEnable extends Container { /* Next row */ y++; + if (y == max_rows) { + x++; + y = 0; + } + } + + public void add_units() { + /* Imperial units setting */ + + /* Add label */ + JCheckBox imperial_units = new JCheckBox("Imperial Units", AltosUIPreferences.imperial_units()); + imperial_units.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + JCheckBox item = (JCheckBox) e.getSource(); + boolean enabled = item.isSelected(); + AltosUIPreferences.set_imperial_units(enabled); + } + }); + imperial_units.setToolTipText("Use Imperial units instead of metric"); + GridBagConstraints c = new GridBagConstraints(); + c.gridx = 0; c.gridy = 1000; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + add(imperial_units, c); } public AltosUIEnable() { il = new Insets(4,4,4,4); ir = new Insets(4,4,4,4); + x = 0; y = 0; setLayout(new GridBagLayout()); + add_units(); } }