This commit is contained in:
gac-S_Changer
2018-07-06 09:56:19 +02:00
parent 4371d9c6d8
commit 4c38bcba7c
34 changed files with 1820 additions and 968 deletions

View File

@@ -3,11 +3,15 @@
*/
import ch.psi.pshell.core.Context;
import ch.psi.pshell.plot.TimePlotBase;
import ch.psi.pshell.swing.StripChart;
import ch.psi.pshell.ui.App;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import ch.psi.utils.swing.SwingUtils;
import java.awt.Dimension;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -16,6 +20,7 @@ import java.util.logging.Logger;
*/
public class LN2 extends Panel {
final StripChart stripChart;
TimePlotBase plot;
public LN2() {
initComponents();
stripChart = new StripChart(this.getTopLevel(), false, App.getStripChartFolderArg());
@@ -27,23 +32,30 @@ public class LN2 extends Panel {
} catch (Exception ex) {
showException(ex);
Logger.getLogger(LN2.class.getName()).log(Level.WARNING, null, ex);
}
}
plot = (TimePlotBase) SwingUtils.getComponentsByType(stripChart.getPlotPanel(),TimePlotBase.class)[0];
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
}
@Override
public void onStop() {
//saveImage();
super.onStop();
}
@Override
public void onStateChange(State state, State former) {
if ( (state == State.Closing) ||
((state == State.Initializing) && (former != State.Invalid))
){
saveImage();
}
}
@@ -51,6 +63,17 @@ public class LN2 extends Panel {
public void onExecutedFile(String fileName, Object result) {
}
public void saveImage(){
getLogger().severe("Saving image");
try {
String fileName = new File(getContext().getSetup().expandPath("{images}/ln2/{date}_{time}.png")).getCanonicalPath();
getLogger().severe("File: " + fileName);
plot.saveSnapshot(fileName, "png", new Dimension(1200,800));
} catch (Exception ex) {
getLogger().log(Level.SEVERE, null, ex);
}
getLogger().severe("Done");
}
//Callback to perform update - in event thread
@Override