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_2;
21 import java.awt.event.*;
24 import java.util.concurrent.*;
26 import org.altusmetrum.altoslib_4.*;
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 {
44 static final int max_rows = 14;
46 class GraphElement implements ActionListener {
47 AltosUIGrapher grapher;
51 public void actionPerformed(ActionEvent ae) {
52 grapher.set_enable(enable.isSelected());
55 GraphElement (String name, AltosUIGrapher grapher, boolean enabled) {
57 this.grapher = grapher;
58 enable = new JRadioButton(name, enabled);
59 grapher.set_enable(enabled);
60 enable.addActionListener(this);
64 public void add(String name, AltosUIGrapher grapher, boolean enabled) {
66 GraphElement e = new GraphElement(name, grapher, enabled);
67 GridBagConstraints c = new GridBagConstraints();
70 c = new GridBagConstraints();
71 c.gridx = x; c.gridy = y;
72 c.fill = GridBagConstraints.HORIZONTAL;
73 c.anchor = GridBagConstraints.CENTER;
85 public void add_units() {
86 /* Imperial units setting */
89 JRadioButton imperial_units = new JRadioButton("Imperial Units", AltosUIPreferences.imperial_units());
90 imperial_units.addActionListener(new ActionListener() {
91 public void actionPerformed(ActionEvent e) {
92 JRadioButton item = (JRadioButton) e.getSource();
93 boolean enabled = item.isSelected();
94 AltosUIPreferences.set_imperial_units(enabled);
97 imperial_units.setToolTipText("Use Imperial units instead of metric");
98 GridBagConstraints c = new GridBagConstraints();
99 c.gridx = 0; c.gridy = 1000;
100 c.fill = GridBagConstraints.NONE;
101 c.anchor = GridBagConstraints.LINE_START;
103 add(imperial_units, c);
106 public AltosUIEnable() {
107 il = new Insets(4,4,4,4);
108 ir = new Insets(4,4,4,4);
111 setLayout(new GridBagLayout());