src/org/math/plot/components/DatasFrame.java

00001 package org.math.plot.components;
00002 
00003 import java.awt.*;
00004 import java.awt.event.*;
00005 
00006 import javax.swing.*;
00007 import javax.swing.event.*;
00008 
00009 import org.math.plot.*;
00010 import org.math.plot.canvas.*;
00011 import org.math.plot.plots.*;
00012 
00019 public class DatasFrame extends JFrame {
00020 
00021         private static final long serialVersionUID = 1L;
00022 
00023         private PlotCanvas plotCanvas;
00024 
00025         private LegendPanel legend;
00026 
00027         public JTabbedPane panels;
00028 
00029         public DatasFrame(PlotCanvas p, LegendPanel l) {
00030                 super("Data");
00031                 plotCanvas = p;
00032                 legend = l;
00033                 JPanel panel = new JPanel();
00034                 panels = new JTabbedPane();
00035                 
00036                 for (Plot plot: plotCanvas.getPlots()) 
00037                         panels.add(new DataPanel(/*this, */plot), plot.getName());
00038                 
00039 
00040                 panel.add(panels);
00041                 setContentPane(panel);
00042                 pack();
00043                 setVisible(true);
00044         }
00045 
00046         public class DataPanel extends JPanel {
00047 
00048                 private static final long serialVersionUID = 1L;
00049 
00050                 MatrixTablePanel XY;
00051 
00052                 JCheckBox visible;
00053 
00054                 JButton color;
00055 
00056                 JPanel plottoolspanel;
00057 
00058                 Plot plot;
00059 
00060                 DatasFrame dframe;
00061 
00062                 public DataPanel(/*DatasFrame _dframe,*/Plot _plot) {
00063                         plot = _plot;
00064                         //dframe = _dframe;
00065                         visible = new JCheckBox("visible");
00066                         visible.setSelected(plot.getVisible());
00067                         color = new JButton();
00068                         color.setBackground(plot.getColor());
00069                         XY = new MatrixTablePanel( plotCanvas.reverseMapedData( plot.getData()));
00070 
00071                         visible.addChangeListener(new ChangeListener() {
00072                                 public void stateChanged(ChangeEvent e) {
00073                                         if (visible.isSelected())
00074                                                 plot.setVisible(true);
00075                                         else
00076                                                 plot.setVisible(false);
00077                                         /*dframe.*/plotCanvas.repaint();
00078                                 }
00079                         });
00080                         color.addActionListener(new ActionListener() {
00081                                 public void actionPerformed(ActionEvent e) {
00082                                         Color c = JColorChooser.showDialog(plotCanvas, "Choose plot color", plot.getColor());
00083                                         color.setBackground(c);
00084                                         plot.setColor(c);
00085                                         legend.updateLegends();
00086                                         /*dframe.*/plotCanvas.linkedLegendPanel.repaint();
00087                                         /*dframe.*/plotCanvas.repaint();
00088                                 }
00089                         });
00090 
00091                         this.setLayout(new BorderLayout());
00092                         plottoolspanel = new JPanel();
00093                         plottoolspanel.add(visible);
00094                         plottoolspanel.add(color);
00095                         this.add(plottoolspanel, BorderLayout.NORTH);
00096                         this.add(XY, BorderLayout.CENTER);
00097                 }
00098         }
00099 }

Generated on Wed Sep 5 21:44:01 2007 for jmathplot by  doxygen 1.5.1