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_1;
21 import java.awt.event.*;
24 import java.util.concurrent.*;
26 import org.altusmetrum.altoslib_2.*;
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 class GraphElement implements ActionListener {
44 AltosUIGrapher grapher;
49 public void actionPerformed(ActionEvent ae) {
50 grapher.set_enable(enable.isSelected());
53 GraphElement (String name, AltosUIGrapher grapher, boolean enabled) {
55 this.grapher = grapher;
56 label = new JLabel(name);
57 enable = new JRadioButton("Enable", enabled);
58 grapher.set_enable(enabled);
59 enable.addActionListener(this);
63 public void add(String name, AltosUIGrapher grapher, boolean enabled) {
65 GraphElement e = new GraphElement(name, grapher, enabled);
68 GridBagConstraints c = new GridBagConstraints();
69 c.gridx = 0; c.gridy = y;
70 c.fill = GridBagConstraints.NONE;
71 c.anchor = GridBagConstraints.LINE_START;
75 /* Add radio button */
76 c = new GridBagConstraints();
77 c.gridx = 1; c.gridy = y;
78 c.fill = GridBagConstraints.HORIZONTAL;
79 c.anchor = GridBagConstraints.CENTER;
87 public void add_units() {
88 /* Imperial units setting */
90 GridBagConstraints c = new GridBagConstraints();
91 c.gridx = 0; c.gridy = 1000;
92 c.fill = GridBagConstraints.NONE;
93 c.anchor = GridBagConstraints.LINE_START;
95 add(new JLabel("Imperial Units"), c);
97 JRadioButton imperial_units = new JRadioButton("Enable", AltosUIPreferences.imperial_units());
98 imperial_units.addActionListener(new ActionListener() {
99 public void actionPerformed(ActionEvent e) {
100 JRadioButton item = (JRadioButton) e.getSource();
101 boolean enabled = item.isSelected();
102 AltosUIPreferences.set_imperial_units(enabled);
105 imperial_units.setToolTipText("Use Imperial units instead of metric");
106 c = new GridBagConstraints();
107 c.gridx = 1; c.gridy = 1000;
108 c.fill = GridBagConstraints.NONE;
109 c.anchor = GridBagConstraints.LINE_START;
111 add(imperial_units, c);
114 public AltosUIEnable() {
115 il = new Insets(4,4,4,4);
116 ir = new Insets(4,4,4,4);
118 setLayout(new GridBagLayout());