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; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 package org.altusmetrum.altosuilib_11;
22 import java.awt.event.*;
25 import java.util.concurrent.*;
27 import org.altusmetrum.altoslib_11.*;
29 import org.jfree.ui.*;
30 import org.jfree.chart.*;
31 import org.jfree.chart.plot.*;
32 import org.jfree.chart.axis.*;
33 import org.jfree.chart.renderer.*;
34 import org.jfree.chart.renderer.xy.*;
35 import org.jfree.chart.labels.*;
36 import org.jfree.data.xy.*;
37 import org.jfree.data.*;
39 public class AltosUIEnable extends Container {
44 JCheckBox imperial_units;
46 static final int max_rows = 14;
48 public void units_changed(boolean imperial_units) {
49 if (this.imperial_units != null) {
50 this.imperial_units.setSelected(imperial_units);
54 class GraphElement implements ActionListener {
55 AltosUIGrapher grapher;
59 public void actionPerformed(ActionEvent ae) {
60 grapher.set_enable(enable.isSelected());
63 GraphElement (String name, AltosUIGrapher grapher, boolean enabled) {
65 this.grapher = grapher;
66 enable = new JCheckBox(name, enabled);
67 grapher.set_enable(enabled);
68 enable.addActionListener(this);
72 public void add(String name, AltosUIGrapher grapher, boolean enabled) {
74 GraphElement e = new GraphElement(name, grapher, enabled);
75 GridBagConstraints c = new GridBagConstraints();
78 c = new GridBagConstraints();
79 c.gridx = x; c.gridy = y;
80 c.fill = GridBagConstraints.HORIZONTAL;
81 c.anchor = GridBagConstraints.CENTER;
93 public void add_units() {
94 /* Imperial units setting */
97 imperial_units = new JCheckBox("Imperial Units", AltosUIPreferences.imperial_units());
98 imperial_units.addActionListener(new ActionListener() {
99 public void actionPerformed(ActionEvent e) {
100 JCheckBox item = (JCheckBox) e.getSource();
101 boolean enabled = item.isSelected();
102 AltosUIPreferences.set_imperial_units(enabled);
105 imperial_units.setToolTipText("Use Imperial units instead of metric");
106 GridBagConstraints c = new GridBagConstraints();
107 c.gridx = 0; 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);
119 setLayout(new GridBagLayout());