From 7535c8591705a13789ac3d7c5c4cdaddcc72adc6 Mon Sep 17 00:00:00 2001 From: sfop Date: Mon, 29 Aug 2016 10:44:12 +0200 Subject: [PATCH] Startup --- devices/CurrentCamera.properties | 6 ++-- plugins/Cameras.form | 19 ++++++++--- plugins/Cameras.java | 54 +++++++++++++++++++++++++++----- 3 files changed, 64 insertions(+), 15 deletions(-) diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties index dcc1953..a32f569 100644 --- a/devices/CurrentCamera.properties +++ b/devices/CurrentCamera.properties @@ -1,4 +1,4 @@ -#Fri Aug 26 16:44:44 CEST 2016 +#Mon Aug 29 10:42:50 CEST 2016 colormap=Grayscale colormapAutomatic=false colormapMax=255.0 @@ -18,8 +18,8 @@ roiY=0 rotation=0.0 rotationCrop=true scale=1.0 -spatialCalOffsetX=NaN -spatialCalOffsetY=NaN +spatialCalOffsetX=0.0 +spatialCalOffsetY=0.0 spatialCalScaleX=NaN spatialCalScaleY=NaN spatialCalUnits=mm diff --git a/plugins/Cameras.form b/plugins/Cameras.form index bcaae72..d8d55ce 100644 --- a/plugins/Cameras.form +++ b/plugins/Cameras.form @@ -23,12 +23,14 @@ - + - - + + + + - + @@ -46,6 +48,7 @@ + @@ -90,5 +93,13 @@ + + + + + + + + diff --git a/plugins/Cameras.java b/plugins/Cameras.java index 3550e13..47cea86 100644 --- a/plugins/Cameras.java +++ b/plugins/Cameras.java @@ -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;