/* * Copyright (c) 2014 Paul Scherrer Institute. All rights reserved. */ import ch.psi.pshell.device.Motor; import ch.psi.pshell.device.Positionable; import ch.psi.pshell.imaging.Overlay; import ch.psi.pshell.imaging.Overlays; import ch.psi.pshell.imaging.Pen; import ch.psi.pshell.imaging.Renderer; import ch.psi.pshell.imaging.RendererListener; import ch.psi.pshell.ui.Panel; import ch.psi.utils.State; import java.awt.Color; import java.nio.file.Paths; import java.util.logging.Level; /** * */ public class Microscope extends Panel { public Microscope() { initComponents(); } //Overridable callbacks @Override public void onInitialize(int runCount) { renderer.setPersistenceFile(Paths.get(getController().getSetup().getContextPath(), "BeamMarker.bin")); } @Override public void onStateChange(State state, State former) { } @Override public void onExecutedFile(String fileName, Object result) { } //Callback to perform update - in event thread @Override protected void doUpdate() { } @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { renderer = new ch.psi.pshell.imaging.Renderer(); motorPanel1 = new ch.psi.pshell.swing.MotorPanel(); processVariablePanel1 = new ch.psi.pshell.swing.ProcessVariablePanel(); motorPanel2 = new ch.psi.pshell.swing.MotorPanel(); processVariablePanel2 = new ch.psi.pshell.swing.ProcessVariablePanel(); jPanel1 = new javax.swing.JPanel(); jPanel3 = new javax.swing.JPanel(); buttonLeft = new javax.swing.JButton(); buttonRight = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); spinnerStepAlignment = new javax.swing.JSpinner(); jPanel5 = new javax.swing.JPanel(); buttonUp = new javax.swing.JButton(); jPanel6 = new javax.swing.JPanel(); buttonDown = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); button0 = new javax.swing.JButton(); button270 = new javax.swing.JButton(); button180 = new javax.swing.JButton(); button90 = new javax.swing.JButton(); jPanel4 = new javax.swing.JPanel(); buttonDefineBeam = new javax.swing.JButton(); checkHighDef = new javax.swing.JCheckBox(); renderer.setAutoscrolls(true); renderer.setDeviceName("mic-high"); renderer.setMode(ch.psi.pshell.imaging.RendererMode.Fixed); renderer.setShowStatus(false); motorPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("cy")); motorPanel1.setDecimals(2); motorPanel1.setDeviceName("cy"); motorPanel1.setShowHoming(false); motorPanel1.setShowJog(false); motorPanel1.setShowStatus(false); motorPanel1.setShowTitle(true); processVariablePanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("x")); processVariablePanel1.setDecimals(2); processVariablePanel1.setDeviceName("x"); processVariablePanel1.setShowLimitButtons(false); processVariablePanel1.setShowSlider(false); processVariablePanel1.setShowTitle(true); processVariablePanel1.setStepIncrement(0.001); processVariablePanel1.setStepSize(0.01); motorPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("cz")); motorPanel2.setDecimals(2); motorPanel2.setDeviceName("cz"); motorPanel2.setShowHoming(false); motorPanel2.setShowJog(false); motorPanel2.setShowStatus(false); motorPanel2.setShowTitle(true); processVariablePanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("omega")); processVariablePanel2.setDecimals(2); processVariablePanel2.setDeviceName("omega"); processVariablePanel2.setShowLimitButtons(false); processVariablePanel2.setShowSlider(false); processVariablePanel2.setShowTitle(true); processVariablePanel2.setStepIncrement(10.0); processVariablePanel2.setStepSize(90.0); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Alignment")); buttonLeft.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N buttonLeft.setText("<"); buttonLeft.setMinimumSize(new java.awt.Dimension(65, 25)); buttonLeft.setPreferredSize(new java.awt.Dimension(65, 30)); buttonLeft.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonLeftActionPerformed(evt); } }); buttonRight.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N buttonRight.setText(">"); buttonRight.setMinimumSize(new java.awt.Dimension(65, 25)); buttonRight.setPreferredSize(new java.awt.Dimension(65, 30)); buttonRight.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonRightActionPerformed(evt); } }); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addComponent(buttonLeft, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(77, 77, 77) .addComponent(buttonRight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addGap(0, 0, 0) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(buttonRight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(buttonLeft, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) ); jLabel1.setText("Step:"); spinnerStepAlignment.setModel(new javax.swing.SpinnerNumberModel(0.01d, 0.001d, 1.0d, 0.01d)); buttonUp.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N buttonUp.setText("^"); buttonUp.setMinimumSize(new java.awt.Dimension(65, 25)); buttonUp.setPreferredSize(new java.awt.Dimension(65, 30)); buttonUp.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonUpActionPerformed(evt); } }); javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(buttonUp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel5Layout.setVerticalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addGap(0, 0, 0) .addComponent(buttonUp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0)) ); buttonDown.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N buttonDown.setText("v"); buttonDown.setMinimumSize(new java.awt.Dimension(65, 25)); buttonDown.setPreferredSize(new java.awt.Dimension(65, 30)); buttonDown.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonDownActionPerformed(evt); } }); javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); jPanel6.setLayout(jPanel6Layout); jPanel6Layout.setHorizontalGroup( jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(buttonDown, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel6Layout.setVerticalGroup( jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup() .addGap(0, 0, 0) .addComponent(buttonDown, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0)) ); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(spinnerStepAlignment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap(65, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(66, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(12, 12, 12) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(spinnerStepAlignment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(4, 4, 4)) ); button0.setText("0"); button0.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { button0ActionPerformed(evt); } }); button270.setText("270"); button270.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { button270ActionPerformed(evt); } }); button180.setText("180"); button180.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { button180ActionPerformed(evt); } }); button90.setText("90"); button90.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { button90ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(0, 0, 0) .addComponent(button0) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE) .addComponent(button90) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE) .addComponent(button180) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 48, Short.MAX_VALUE) .addComponent(button270) .addGap(0, 0, 0)) ); jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {button0, button180, button270, button90}); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(0, 0, 0) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(button0) .addComponent(button90) .addComponent(button180) .addComponent(button270)) .addContainerGap()) ); jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Camera")); buttonDefineBeam.setText("Define Beam"); buttonDefineBeam.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonDefineBeamActionPerformed(evt); } }); checkHighDef.setSelected(true); checkHighDef.setText("High definition"); checkHighDef.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { checkHighDefActionPerformed(evt); } }); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addContainerGap() .addComponent(checkHighDef) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(buttonDefineBeam) .addContainerGap()) ); jPanel4Layout.setVerticalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(buttonDefineBeam, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(checkHighDef)) .addGap(4, 4, 4)) ); 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, 512, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(motorPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(motorPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(processVariablePanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE) .addComponent(processVariablePanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE) .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jPanel1, jPanel2, motorPanel1, motorPanel2, processVariablePanel1, processVariablePanel2}); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(5, 5, 5)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(motorPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(motorPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(processVariablePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(processVariablePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); }// //GEN-END:initComponents Overlay beam; private void buttonDefineBeamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDefineBeamActionPerformed try{ Pen pen = new Pen(Color.RED); final Overlay selection = new Overlays.Rect(pen); renderer.addListener(new RendererListener() { @Override public void onSelectionFinished(Renderer renderer, Overlay overlay) { System.out.println(overlay + " - " + selection + " - " + (overlay == selection)); if (overlay == selection){ try { if (overlay.getLength() > 0) { beam = overlay.copy(); beam.setPen(pen); beam.setSolid(false); beam.setMovable(true); renderer.setMarker(beam); } } catch (Exception ex) { getLogger().log(Level.WARNING, null, ex); } finally { renderer.removeListener(this); } } } @Override public void onSelectionAborted(Renderer renderer, Overlay overlay) { if (overlay == selection){ renderer.removeListener(this); } } }); renderer.removeOverlay(beam); renderer.startSelection(selection); } catch (Exception ex){ showException(ex); } }//GEN-LAST:event_buttonDefineBeamActionPerformed private void checkHighDefActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkHighDefActionPerformed renderer.setDeviceName(checkHighDef.isSelected() ? "mic-high" : "mic-low"); }//GEN-LAST:event_checkHighDefActionPerformed private void button0ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button0ActionPerformed try{ ((Positionable)getDevice("omega")).moveAsync(0.0); } catch (Exception ex){ showException(ex); } }//GEN-LAST:event_button0ActionPerformed private void button90ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button90ActionPerformed try{ ((Positionable)getDevice("omega")).moveAsync(90.0); } catch (Exception ex){ showException(ex); } }//GEN-LAST:event_button90ActionPerformed private void button180ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button180ActionPerformed try{ ((Positionable)getDevice("omega")).moveAsync(180.0); } catch (Exception ex){ showException(ex); } }//GEN-LAST:event_button180ActionPerformed private void button270ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button270ActionPerformed try{ ((Positionable)getDevice("omega")).moveAsync(270.0); } catch (Exception ex){ showException(ex); } }//GEN-LAST:event_button270ActionPerformed double getStep(){ //return 0.01; return (Double)spinnerStepAlignment.getValue(); } private void buttonLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonLeftActionPerformed try{ ((ch.psi.pshell.epics.Positionable)getDevice("x")).moveRelAsync(-getStep()); } catch (Exception ex){ showException(ex); } }//GEN-LAST:event_buttonLeftActionPerformed private void buttonRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRightActionPerformed try{ ((ch.psi.pshell.epics.Positionable)getDevice("x")).moveRelAsync(getStep()); } catch (Exception ex){ showException(ex); } }//GEN-LAST:event_buttonRightActionPerformed private void buttonUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUpActionPerformed try{ doVerticalStep(getStep()); } catch (Exception ex){ showException(ex); } }//GEN-LAST:event_buttonUpActionPerformed private void buttonDownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDownActionPerformed try{ doVerticalStep(-getStep()); } catch (Exception ex){ showException(ex); } }//GEN-LAST:event_buttonDownActionPerformed public void doVerticalStep(double offset) throws Exception { //Todo: create motor group double omega = Math.toRadians((Double) ((Positionable)getDevice("omega")).getPosition()); double z = offset * Math.sin(omega); double y = offset * Math.cos(omega); ((Motor)getDevice("cy")).moveRelAsync(y); ((Motor)getDevice("cz")).moveRelAsync(z); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton button0; private javax.swing.JButton button180; private javax.swing.JButton button270; private javax.swing.JButton button90; private javax.swing.JButton buttonDefineBeam; private javax.swing.JButton buttonDown; private javax.swing.JButton buttonLeft; private javax.swing.JButton buttonRight; private javax.swing.JButton buttonUp; private javax.swing.JCheckBox checkHighDef; private javax.swing.JLabel jLabel1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel6; private ch.psi.pshell.swing.MotorPanel motorPanel1; private ch.psi.pshell.swing.MotorPanel motorPanel2; private ch.psi.pshell.swing.ProcessVariablePanel processVariablePanel1; private ch.psi.pshell.swing.ProcessVariablePanel processVariablePanel2; private ch.psi.pshell.imaging.Renderer renderer; private javax.swing.JSpinner spinnerStepAlignment; // End of variables declaration//GEN-END:variables }