X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altosuilib%2FAltosUIEnable.java;fp=altosuilib%2FAltosUIEnable.java;h=e5695fa0db96ea34ce034a80134e87730fffe061;hb=9839b0b62d797a8616fc66038e3f3c68e2a214d0;hp=0000000000000000000000000000000000000000;hpb=fd5e6b80a8be5fac7d913b97570f7e11f70a60ba;p=fw%2Faltos 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 + * + * 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()); + } +}