Commit in hps-java/src/main/java/org/lcsim/hps/monitoring on MAIN | |||
RunControlDialog.java | +33 | -4 | 1.1 -> 1.2 |
button to save plots
diff -u -r1.1 -r1.2 --- RunControlDialog.java 23 May 2012 18:22:16 -0000 1.1 +++ RunControlDialog.java 28 May 2012 19:41:56 -0000 1.2 @@ -2,22 +2,27 @@
import java.awt.event.ActionEvent; import java.awt.event.ActionListener;
+import java.io.File; +import java.io.IOException;
import javax.swing.BoxLayout; import javax.swing.JButton;
+import javax.swing.JFileChooser;
import javax.swing.JFrame; import org.lcsim.event.EventHeader;
+import org.lcsim.util.aida.AIDA;
/** * Lightweight driver for stepping through events in offline analysis, without * running the MonitoringApp. * * @author Sho Uemura <[log in to unmask]>
- * @version $Id: RunControlDialog.java,v 1.1 2012/05/23 18:22:16 meeg Exp $
+ * @version $Id: RunControlDialog.java,v 1.2 2012/05/28 19:41:56 meeg Exp $
*/ public class RunControlDialog implements ActionListener { JButton nextButton; JButton runButton;
+ JButton saveButton;
JFrame nextFrame; boolean run = false; final Object syncObject = new Object();
@@ -30,16 +35,21 @@
nextButton = new JButton("Next event"); nextButton.addActionListener(this); nextFrame.add(nextButton);
+
runButton = new JButton("Run"); runButton.addActionListener(this); nextFrame.add(runButton);
+ saveButton = new JButton("Save"); + saveButton.addActionListener(this); + nextFrame.add(saveButton); +
nextFrame.pack(); nextFrame.setVisible(true); nextFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
- //return true to process the event; return false to discard; waits if in pause mode
+ //return true to process the event; return false to discard; waits if in pause mode
public boolean process(EventHeader event) { if (!run) { synchronized (syncObject) {
@@ -49,10 +59,10 @@
} } }
- return true;
+ return true;
}
- @Override
+ @Override
public void actionPerformed(ActionEvent ae) { if (ae.getSource() == nextButton) { synchronized (syncObject) {
@@ -71,5 +81,24 @@
runButton.setText("Run"); } }
+ if (ae.getSource() == saveButton) { + savePlots(); + } + } + + /** + * Save plots to a selected output file. + */ + private void savePlots() { + JFileChooser fc = new JFileChooser(); + int r = fc.showSaveDialog(nextFrame); + if (r == JFileChooser.APPROVE_OPTION) { + File fileName = fc.getSelectedFile(); + try { + AIDA.defaultInstance().saveAs(fileName); + } catch (IOException e) { + e.printStackTrace(); + } + }
} }
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1