diff --git a/plugins/Microscope.form b/plugins/Microscope.form index b72a155..6f0af34 100644 --- a/plugins/Microscope.form +++ b/plugins/Microscope.form @@ -17,23 +17,41 @@ - - - - + + + + + + + + + + + + + + + + - + - + - + + + + + + + @@ -57,5 +75,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/Microscope.java b/plugins/Microscope.java index e1b246d..046f67f 100644 --- a/plugins/Microscope.java +++ b/plugins/Microscope.java @@ -12,6 +12,7 @@ import ch.psi.pshell.ui.Panel; import ch.psi.utils.State; import java.awt.Color; import java.awt.Point; +import java.util.logging.Level; /** * @@ -66,6 +67,9 @@ public class Microscope extends Panel { renderer = new ch.psi.pshell.imaging.Renderer(); jButton1 = new javax.swing.JButton(); + motorPanel1 = new ch.psi.pshell.swing.MotorPanel(); + processVariablePanel1 = new ch.psi.pshell.swing.ProcessVariablePanel(); + buttonDefineBeam = new javax.swing.JButton(); renderer.setAutoscrolls(true); renderer.setDeviceName("mic-low"); @@ -79,25 +83,53 @@ public class Microscope extends Panel { } }); + motorPanel1.setDeviceName("cy"); + motorPanel1.setShowTitle(true); + + processVariablePanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("")); + processVariablePanel1.setDeviceName("omega"); + processVariablePanel1.setShowTitle(true); + + buttonDefineBeam.setText("Define Beam"); + buttonDefineBeam.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonDefineBeamActionPerformed(evt); + } + }); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 392, Short.MAX_VALUE) - .addGap(18, 18, 18) - .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(motorPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(processVariablePanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addGroup(layout.createSequentialGroup() + .addGap(123, 123, 123) + .addComponent(buttonDefineBeam))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(5, 5, 5)) - .addGroup(layout.createSequentialGroup() + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(jButton1) - .addContainerGap(307, Short.MAX_VALUE)) + .addGap(42, 42, 42) + .addComponent(motorPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(111, 111, 111) + .addComponent(processVariablePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 93, Short.MAX_VALUE) + .addComponent(buttonDefineBeam) + .addGap(26, 26, 26)) ); }// //GEN-END:initComponents @@ -117,9 +149,51 @@ public class Microscope extends Panel { showException(ex); } }//GEN-LAST:event_jButton1ActionPerformed + + Overlay beam; + + private void buttonDefineBeamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDefineBeamActionPerformed + try{ + Pen pen = new Pen(Color.RED); + Overlay selection = new Overlays.Rect(pen); + /* + renderer.addListener(new RendererListener() { + @Override + public void onSelectionFinished(Renderer renderer, Overlay overlay) { + try { + if (overlay.getLength() > 0) { + beam = overlay.copy(); + beam.setPen(pen); + beam.setSolid(false); + beam.setMovable(true); + renderer.addOverlay(beam); + } + } catch (Exception ex) { + getLogger().log(Level.WARNING, null, ex); + } finally { + renderer.removeListener(this); + } + } + @Override + public void onSelectionAborted(Renderer renderer, Overlay overlay) { + renderer.removeListener(this); + } + }); + renderer.removeOverlay(beam); + renderer.startSelection(selection); + */ + + } catch (Exception ex){ + showException(ex); + } + + }//GEN-LAST:event_buttonDefineBeamActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton buttonDefineBeam; private javax.swing.JButton jButton1; + private ch.psi.pshell.swing.MotorPanel motorPanel1; + private ch.psi.pshell.swing.ProcessVariablePanel processVariablePanel1; private ch.psi.pshell.imaging.Renderer renderer; // End of variables declaration//GEN-END:variables }