2 * Copyright © 2013 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
18 package org.altusmetrum.altosuilib_11;
21 import java.awt.event.*;
24 import java.util.concurrent.*;
26 import org.altusmetrum.altoslib_11.*;
28 import org.jfree.ui.*;
29 import org.jfree.chart.*;
30 import org.jfree.chart.plot.*;
31 import org.jfree.chart.axis.*;
32 import org.jfree.chart.renderer.*;
33 import org.jfree.chart.renderer.xy.*;
34 import org.jfree.chart.labels.*;
35 import org.jfree.data.xy.*;
36 import org.jfree.data.*;
38 public class AltosUIEnable extends Container {
43 JCheckBox imperial_units;
45 static final int max_rows = 14;
47 public void units_changed(boolean imperial_units) {
48 if (this.imperial_units != null) {
49 this.imperial_units.setSelected(imperial_units);
53 class GraphElement implements ActionListener {
54 AltosUIGrapher grapher;
58 public void actionPerformed(ActionEvent ae) {
59 grapher.set_enable(enable.isSelected());
62 GraphElement (String name, AltosUIGrapher grapher, boolean enabled) {
64 this.grapher = grapher;
65 enable = new JCheckBox(name, enabled);
66 grapher.set_enable(enabled);
67 enable.addActionListener(this);
71 public void add(String name, AltosUIGrapher grapher, boolean enabled) {
73 GraphElement e = new GraphElement(name, grapher, enabled);
74 GridBagConstraints c = new GridBagConstraints();
77 c = new GridBagConstraints();
78 c.gridx = x; c.gridy = y;
79 c.fill = GridBagConstraints.HORIZONTAL;
80 c.anchor = GridBagConstraints.CENTER;
92 public void add_units() {
93 /* Imperial units setting */
96 imperial_units = new JCheckBox("Imperial Units", AltosUIPreferences.imperial_units());
97 imperial_units.addActionListener(new ActionListener() {
98 public void actionPerformed(ActionEvent e) {
99 JCheckBox item = (JCheckBox) e.getSource();
100 boolean enabled = item.isSelected();
101 AltosUIPreferences.set_imperial_units(enabled);
104 imperial_units.setToolTipText("Use Imperial units instead of metric");
105 GridBagConstraints c = new GridBagConstraints();
106 c.gridx = 0; c.gridy = 1000;
107 c.fill = GridBagConstraints.NONE;
108 c.anchor = GridBagConstraints.LINE_START;
110 add(imperial_units, c);
113 public AltosUIEnable() {
114 il = new Insets(4,4,4,4);
115 ir = new Insets(4,4,4,4);
118 setLayout(new GridBagLayout());