00001
00002
00003
00004
00005
00006
00007 package DisplayGUI.plotters;
00008
00009 import java.awt.event.*;
00010 import javax.swing.event.*;
00011
00016 public class IVPlotDisplay extends javax.swing.JFrame implements ListSelectionListener,DisplayGUI.displayParams {
00017
00018
00019 private javax.swing.JButton jButton1;
00020 private javax.swing.JLabel jLabel1;
00021
00022 private javax.swing.JList snList;
00023 private String[] defaultString = {"No data"};
00024
00025 private boolean selectionListenerIsActive=true;
00026
00027 private IVScanPlotter ivPlotter;
00028
00029 private IVScansData ivScansData;
00030
00032 public IVPlotDisplay() {
00033 ivPlotter = IVScanPlotter.getInstance();
00034 initComponents();
00035 }
00036
00042 private void initComponents() {
00043 java.awt.GridBagConstraints gridBagConstraints;
00044
00045 jLabel1 = new javax.swing.JLabel();
00046 jLabel1.setFont(displayBoldFont);
00047 jLabel1.setForeground(darkBlueColor);
00048 jLabel1.setBackground(backgroundColor);
00049 jButton1 = new javax.swing.JButton();
00050
00051 snList = new javax.swing.JList(defaultString);
00052 snList.setFont(displayScaleFont);
00053 snList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
00054
00055 snList.setSelectedIndex(0);
00056 snList.addListSelectionListener(this);
00057
00058 javax.swing.JScrollPane viewScrollPane = new javax.swing.JScrollPane(snList);
00059 javax.swing.JLabel header2 = new javax.swing.JLabel("Plot Options");
00060 header2.setForeground(darkBlueColor);
00061 header2.setBackground(backgroundColor);
00062 header2.setFont(displayTextFont);
00063 viewScrollPane.setColumnHeaderView(header2);
00064 viewScrollPane.getColumnHeader().setBackground(backgroundColor);
00065 viewScrollPane.setBorder(new javax.swing.border.EmptyBorder(0,0,0,0));
00066 viewScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
00067 viewScrollPane.getVerticalScrollBar().setBackground(backgroundColor);
00068
00069
00070 getContentPane().setLayout(new java.awt.GridBagLayout());
00071
00072 addWindowListener(new java.awt.event.WindowAdapter() {
00073 public void windowClosing(java.awt.event.WindowEvent evt) {
00074 exitForm(evt);
00075 }
00076 });
00077
00078 gridBagConstraints = new java.awt.GridBagConstraints();
00079 gridBagConstraints.gridx = 0;
00080 gridBagConstraints.gridy = 0;
00081
00082
00083 gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
00084 gridBagConstraints.weighty = 0.1;
00085 getContentPane().add(jLabel1, gridBagConstraints);
00086
00087 gridBagConstraints = new java.awt.GridBagConstraints();
00088 gridBagConstraints.gridx = 0;
00089 gridBagConstraints.gridy = 1;
00090 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00091 gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
00092 getContentPane().add(IVScanPlotter.getInstance().getPlotPanel(), gridBagConstraints);
00093 IVScanPlotter.getInstance().getPlotPanel().setBackground(backgroundColor);
00094
00095 gridBagConstraints = new java.awt.GridBagConstraints();
00096 gridBagConstraints.gridx = 1;
00097 gridBagConstraints.gridy = 0;
00098 gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
00099 gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER;
00100 gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
00101 gridBagConstraints.weightx = 0.1;
00102 gridBagConstraints.weighty = 0.9;
00103 gridBagConstraints.gridheight = 2;
00104 getContentPane().add(viewScrollPane, gridBagConstraints);
00105
00106 jButton1.setText("Close");
00107 jButton1.setFont(displayScaleFont);
00108 gridBagConstraints = new java.awt.GridBagConstraints();
00109 gridBagConstraints.gridx = 0;
00110 gridBagConstraints.gridy = 2;
00111 gridBagConstraints.gridwidth = 2;
00112 gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
00113 gridBagConstraints.weighty = 0.1;
00114 gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER;
00115 jButton1.addActionListener(new java.awt.event.ActionListener() {
00116 public void actionPerformed(java.awt.event.ActionEvent evt) {
00117 exitForm(null);
00118 }
00119 });
00120
00121
00122
00123 getContentPane().add(jButton1, gridBagConstraints);
00124 getContentPane().setBackground(backgroundColor);
00125 setBackground(backgroundColor);
00126
00127 }
00128
00130 private void exitForm(java.awt.event.WindowEvent evt) {
00131 setVisible(false);
00132 }
00133
00134 public void showData(IVScansData ivScansData, String selectedModule) {
00135 this.ivScansData=ivScansData;
00136
00137
00138 snList.setListData(ivScansData.getModuleList().toArray());
00139 if(selectedModule!=null) snList.setSelectedValue(selectedModule,true);
00140 else snList.setSelectedIndex(0);
00141 plotData(snList.getSelectedIndex());
00142
00143
00144 }
00145
00146 public void valueChanged(ListSelectionEvent e) {
00147
00148 if (e.getValueIsAdjusting())
00149 return;
00150
00151 javax.swing.JList theList = (javax.swing.JList)e.getSource();
00152 if (theList.isSelectionEmpty()) {
00153
00154 } else {
00155
00156 if(!selectionListenerIsActive) {
00157 return;
00158 }
00159 plotData(theList.getSelectedIndex());
00160
00161
00162 }
00163 }
00164
00165 private void plotData(int index) {
00166 if(index<0) return;
00167 jLabel1.setText(ivScansData.getTitle()+" : "+(String)snList.getSelectedValue());
00168 hep.aida.IPlotter iPlotter = ivPlotter.getIPlotter();
00169 iPlotter.clearRegions();
00170 if(index==0) for(int i=0;i<ivScansData.size();i++) iPlotter.region(0).plot(ivScansData.getDataPointSet(i));
00171 else iPlotter.region(0).plot(ivScansData.getDataPointSet(index-1));
00172
00173
00174
00175 iPlotter.region(0).style().dataStyle().setParameter("showHistogramBars","false");
00176 iPlotter.region(0).style().dataStyle().setParameter("showErrorBars","false");
00177 iPlotter.region(0).style().dataStyle().setParameter("fillHistogramBars","false");
00178 iPlotter.region(0).style().dataStyle().setParameter("showDataPoints","true");
00179 iPlotter.region(0).style().dataStyle().setParameter("connectDataPoints","true");
00180
00181 iPlotter.region(0).style().xAxisStyle().setLabel("Voltage (Volts)");
00182 iPlotter.region(0).style().yAxisStyle().setLabel("Current (microAmps)");
00183
00184
00185
00186
00187 iPlotter.region(0).style().setParameter("showStatisticsBox","false");
00188 iPlotter.region(0).style().setParameter("legendFont","Arial");
00189
00190
00191
00192
00193
00194
00195
00196 pack();
00197 show();
00198 }
00199
00200
00201
00202
00203
00204
00205
00206
00207 }