diff options
author | Keith Packard <keithp@keithp.com> | 2013-02-09 01:58:23 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2013-02-10 00:30:32 -0800 |
commit | 9839b0b62d797a8616fc66038e3f3c68e2a214d0 (patch) | |
tree | 7fc22e0273996cc77066e0ba138d11a079347d76 /altosuilib/AltosUIEnable.java | |
parent | fd5e6b80a8be5fac7d913b97570f7e11f70a60ba (diff) |
altosuilib: Add graphing routines from MicroPeak
Make these available for AltosUI too
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosuilib/AltosUIEnable.java')
-rw-r--r-- | altosuilib/AltosUIEnable.java | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/altosuilib/AltosUIEnable.java b/altosuilib/AltosUIEnable.java new file mode 100644 index 00000000..e5695fa0 --- /dev/null +++ b/altosuilib/AltosUIEnable.java @@ -0,0 +1,93 @@ +/* + * Copyright © 2013 Keith Packard <keithp@keithp.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_1; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.io.*; +import java.util.concurrent.*; +import java.util.*; +import org.altusmetrum.altoslib_1.*; + +import org.jfree.ui.*; +import org.jfree.chart.*; +import org.jfree.chart.plot.*; +import org.jfree.chart.axis.*; +import org.jfree.chart.renderer.*; +import org.jfree.chart.renderer.xy.*; +import org.jfree.chart.labels.*; +import org.jfree.data.xy.*; +import org.jfree.data.*; + +public class AltosUIEnable extends Container { + + Insets il, ir; + int y; + + class GraphElement implements ActionListener { + AltosUISeries series; + JLabel label; + JRadioButton enable; + String name; + + public void actionPerformed(ActionEvent ae) { + series.set_enable(enable.isSelected()); + } + + GraphElement (String name, AltosUISeries series, boolean enabled) { + this.name = name; + this.series = series; + label = new JLabel(name); + enable = new JRadioButton("Enable", enabled); + series.set_enable(enabled); + enable.addActionListener(this); + } + } + + public void add(String name, AltosUISeries series, boolean enabled) { + + GraphElement e = new GraphElement(name, series, 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 */ + c = new GridBagConstraints(); + c.gridx = 1; c.gridy = y; + c.fill = GridBagConstraints.HORIZONTAL; + c.anchor = GridBagConstraints.CENTER; + c.insets = ir; + add(e.enable, c); + + /* Next row */ + y++; + } + + public AltosUIEnable() { + il = new Insets(4,4,4,4); + ir = new Insets(4,4,4,4); + y = 0; + setLayout(new GridBagLayout()); + } +} |