Startup
This commit is contained in:
+46
-8
@@ -13,9 +13,11 @@ import ch.psi.utils.IO;
|
||||
import ch.psi.utils.swing.SwingUtils;
|
||||
import ch.psi.utils.swing.ConfigDialog;
|
||||
import ch.psi.utils.swing.StandardDialog;
|
||||
import ch.psi.utils.swing.TextEditor;
|
||||
import ch.psi.pshell.epics.PsiCamera;
|
||||
import ch.psi.pshell.core.JsonSerializer;
|
||||
import ch.psi.pshell.imaging.Data;
|
||||
import ch.psi.utils.swing.Editor.EditorDialog;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Frame;
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -42,6 +44,7 @@ public class Cameras extends Panel {
|
||||
File[] cameraConfigFiles = new File[0];
|
||||
PsiCamera camera;
|
||||
String cameraName;
|
||||
String cameraConfigJson;
|
||||
CameraConfig config;
|
||||
|
||||
//Overridable callbacks
|
||||
@@ -145,12 +148,12 @@ public class Cameras extends Panel {
|
||||
}
|
||||
try{
|
||||
Path configFile= Paths.get(configFolder, cameraName + ".json");
|
||||
String json = new String(Files.readAllBytes(configFile));
|
||||
cameraConfigJson = new String(Files.readAllBytes(configFile));
|
||||
this.cameraName=cameraName;
|
||||
//SwingUtils.showMessage(null, "", json);
|
||||
camera = new PsiCamera("CurrentCamera", cameraName);
|
||||
try{
|
||||
config = (CameraConfig) JsonSerializer.decode(json, CameraConfig.class);
|
||||
config = (CameraConfig) JsonSerializer.decode(cameraConfigJson, CameraConfig.class);
|
||||
camera.getConfig().flipHorizontally = config.getMirrorX();
|
||||
camera.getConfig().flipVertically = config.getMirrorY();
|
||||
camera.getConfig().rotation = config.getRotate();
|
||||
@@ -214,6 +217,7 @@ public class Cameras extends Panel {
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
textState = new javax.swing.JTextField();
|
||||
buttonConfig = new javax.swing.JButton();
|
||||
buttonSetup = new javax.swing.JButton();
|
||||
|
||||
jLabel1.setText("Camera:");
|
||||
|
||||
@@ -237,6 +241,13 @@ public class Cameras extends Panel {
|
||||
}
|
||||
});
|
||||
|
||||
buttonSetup.setText("Setup");
|
||||
buttonSetup.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonSetupActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
@@ -248,15 +259,20 @@ public class Cameras extends Panel {
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(comboCameras, 0, 290, Short.MAX_VALUE)
|
||||
.addComponent(comboCameras, 0, 236, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonConfig)
|
||||
.addGap(10, 10, 10)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonSetup)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel2)
|
||||
.addGap(4, 4, 4)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(textState, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonConfig, buttonSetup});
|
||||
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
@@ -266,7 +282,8 @@ public class Cameras extends Panel {
|
||||
.addComponent(comboCameras, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel2)
|
||||
.addComponent(textState, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(buttonConfig))
|
||||
.addComponent(buttonConfig)
|
||||
.addComponent(buttonSetup))
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE)
|
||||
.addGap(6, 6, 6))
|
||||
@@ -285,13 +302,34 @@ public class Cameras extends Panel {
|
||||
}//GEN-LAST:event_comboCamerasActionPerformed
|
||||
|
||||
private void buttonConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConfigActionPerformed
|
||||
if (camera!=null){
|
||||
this.showDeviceConfigDialog(camera, false);
|
||||
try{
|
||||
if (camera!=null){
|
||||
TextEditor editor = new TextEditor();
|
||||
editor.setText(cameraConfigJson);
|
||||
editor.setReadOnly(true);
|
||||
editor.setTitle(cameraName);
|
||||
EditorDialog dlg = editor.getDialog(getTopLevel(), false);
|
||||
dlg.setSize(480, 640);
|
||||
showWindow(dlg);
|
||||
}
|
||||
} catch(Exception ex){
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonConfigActionPerformed
|
||||
|
||||
private void buttonSetupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetupActionPerformed
|
||||
try{
|
||||
if (camera!=null){
|
||||
this.showDeviceConfigDialog(camera, false);
|
||||
}
|
||||
} catch(Exception ex){
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonSetupActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton buttonConfig;
|
||||
private javax.swing.JButton buttonSetup;
|
||||
private javax.swing.JComboBox comboCameras;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
|
||||
Reference in New Issue
Block a user