Files
x11ma/plugins/Imaging.java
2022-11-09 15:03:09 +01:00

882 lines
46 KiB
Java

import ch.psi.pshell.core.Context;
import ch.psi.pshell.imaging.Overlay;
import ch.psi.pshell.imaging.Overlays.Rect;
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.Rectangle;
import java.util.HashMap;
/**
*
*/
public class Imaging extends Panel {
static double NaNd = Double.NaN; //Bug on editor?
public Imaging() {
initComponents();
renderer.addListener(rendererListener);
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
try {
setGlobalVar("IMAGING_RENDERER", renderer);
setRoi(getRoi());
} catch (Exception ex) {
showException(ex);
}
}
@Override
public void onStateChange(State state, State former) {
buttonAbort.setEnabled(state.isProcessing());
updateButtons();
}
@Override
public void onExecutedFile(String fileName, Object result) {
}
//Callback to perform update - in event thread
@Override
protected void doUpdate() {
}
void updateButtons(){
boolean enabled = getState()==State.Ready;
boolean hasRoi = false;
try{
hasRoi = getRoi()!=null;
} catch (Exception ex){
}
buttonStartAutoFocus.setEnabled(hasRoi && enabled);
buttonStartAutoIntensity.setEnabled(enabled);
buttonRoiClear.setEnabled(hasRoi && enabled);
buttonRoiSet.setEnabled(!hasRoi && enabled);
spinnerAverage.setEnabled(enabled);
spinnerRuns.setEnabled(enabled);
spinnerExposition.setEnabled(enabled);
spinnerRangeObj.setEnabled((radioObjective.isSelected() || radioAll.isSelected()) && enabled);
spinnerStepObj.setEnabled(spinnerRangeObj.isEnabled());
spinnerRangeStig.setEnabled((!radioObjective.isSelected()) && enabled);
spinnerStepStig.setEnabled(spinnerRangeStig.isEnabled());
radioObjective.setEnabled(enabled);
radioStigA.setEnabled(enabled);
radioStigB.setEnabled(enabled);
radioAll.setEnabled(enabled);
}
@Override
protected void onShow() {
super.onShow();
renderer.setDeviceName("image");
}
@Override
protected void onHide() {
super.onHide();
renderer.setDeviceName(null);
}
Rectangle getRoi(){
return (Rectangle) getGlobalVar("IMAGING_ROI");
}
void setRoi(Rectangle roi){
setGlobalVar("IMAGING_ROI", roi);
try{
renderer.clearOverlays();
if (roi!=null){
Rect ov = new Rect(renderer.getPenProfile(), roi.getLocation(), roi.getSize());
ov.setMovable(true);
renderer.addOverlay(ov);
}
} finally {
updateButtons();
}
}
final RendererListener rendererListener = new RendererListener(){
@Override
public void onMoveFinished(Renderer renderer, Overlay overlay) {
setGlobalVar("IMAGING_ROI", overlay.getBounds());
}
@Override
public void onDeleted(Renderer renderer, Overlay overlay) {
if (getRoi()!=null){
setRoi(null);
}
}
};
void showArrows(boolean show) throws Exception{
if (show){
setGlobalVar("IMAGING_RENDERER", renderer);
evalAsync("start_arrows(renderer=IMAGING_RENDERER)");
} else {
setGlobalVar("IMAGING_RENDERER", renderer);
evalAsync("stop_arrows(renderer=IMAGING_RENDERER)");
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
renderer = new ch.psi.pshell.imaging.Renderer();
jPanel4 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
buttonStartAutoIntensity = new javax.swing.JButton();
jLabel12 = new javax.swing.JLabel();
spinnerExpositionIntensity = new javax.swing.JSpinner();
processVariablePanel1 = new ch.psi.pshell.swing.ProcessVariablePanel();
processVariablePanel2 = new ch.psi.pshell.swing.ProcessVariablePanel();
buttonAbort = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
buttonRoiSet = new javax.swing.JButton();
buttonRoiClear = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
spinnerWidth = new javax.swing.JSpinner();
jLabel2 = new javax.swing.JLabel();
spinnerHeight = new javax.swing.JSpinner();
jPanel3 = new javax.swing.JPanel();
buttonStartAutoFocus = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
spinnerAverage = new javax.swing.JSpinner();
jLabel4 = new javax.swing.JLabel();
spinnerRuns = new javax.swing.JSpinner();
jPanel5 = new javax.swing.JPanel();
radioObjective = new javax.swing.JRadioButton();
radioStigA = new javax.swing.JRadioButton();
radioStigB = new javax.swing.JRadioButton();
radioAll = new javax.swing.JRadioButton();
jPanel6 = new javax.swing.JPanel();
spinnerRangeObj = new javax.swing.JSpinner();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
spinnerStepObj = new javax.swing.JSpinner();
jLabel7 = new javax.swing.JLabel();
spinnerRangeStig = new javax.swing.JSpinner();
jLabel8 = new javax.swing.JLabel();
spinnerStepStig = new javax.swing.JSpinner();
jLabel9 = new javax.swing.JLabel();
spinnerExposition = new javax.swing.JSpinner();
deviceValuePanel1 = new ch.psi.pshell.swing.DeviceValuePanel();
jLabel10 = new javax.swing.JLabel();
checkArrows = new javax.swing.JCheckBox();
jLabel11 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
deviceValuePanel2 = new ch.psi.pshell.swing.DeviceValuePanel();
renderer.setMode(ch.psi.pshell.imaging.RendererMode.Fit);
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Auto-Intensity"));
buttonStartAutoIntensity.setText("Start");
buttonStartAutoIntensity.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonStartAutoIntensityActionPerformed(evt);
}
});
jLabel12.setText("Exposure:");
spinnerExpositionIntensity.setModel(new javax.swing.SpinnerNumberModel(NaNd, 0.01d, NaNd, 1.0d));
spinnerExpositionIntensity.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spinnerExpositionIntensityStateChanged(evt);
}
});
processVariablePanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Girder X [mm]"));
processVariablePanel1.setDeviceName("girder_x");
processVariablePanel1.setPreferredSize(new java.awt.Dimension(188, 112));
processVariablePanel1.setShowLimitButtons(false);
processVariablePanel1.setShowSlider(false);
processVariablePanel1.setShowStop(false);
processVariablePanel1.setStepIncrement(0.01);
processVariablePanel1.setStepSize(0.01);
processVariablePanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Girder Y [mm]"));
processVariablePanel2.setDeviceName("girder_y");
processVariablePanel2.setShowLimitButtons(false);
processVariablePanel2.setShowSlider(false);
processVariablePanel2.setShowStop(false);
processVariablePanel2.setStepIncrement(0.01);
processVariablePanel2.setStepSize(0.01);
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(processVariablePanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
.addGap(12, 12, 12)
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerExpositionIntensity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(69, 69, 69)
.addComponent(buttonStartAutoIntensity))
.addComponent(processVariablePanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel12)
.addComponent(spinnerExpositionIntensity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonStartAutoIntensity))
.addGap(32, 32, 32)
.addComponent(processVariablePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(processVariablePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(14, Short.MAX_VALUE))
);
buttonAbort.setText("Abort");
buttonAbort.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonAbortActionPerformed(evt);
}
});
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("ROI"));
buttonRoiSet.setText("Set");
buttonRoiSet.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonRoiSetActionPerformed(evt);
}
});
buttonRoiClear.setText("Clear");
buttonRoiClear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonRoiClearActionPerformed(evt);
}
});
jLabel1.setText("Width:");
spinnerWidth.setModel(new javax.swing.SpinnerListModel(new String[] {"16", "32", "64", "128", "256", "512"}));
spinnerWidth.setValue("256");
spinnerWidth.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spinnerWidthStateChanged(evt);
}
});
jLabel2.setText("Height");
spinnerHeight.setModel(new javax.swing.SpinnerListModel(new String[] {"16", "32", "64", "128", "256", "512"}));
spinnerHeight.setValue("256");
spinnerHeight.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spinnerHeightStateChanged(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(buttonRoiClear)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonRoiSet, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, Short.MAX_VALUE)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerWidth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerHeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2});
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerHeight, spinnerWidth});
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonRoiClear, buttonRoiSet});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonRoiClear)
.addComponent(buttonRoiSet)
.addComponent(jLabel1)
.addComponent(spinnerWidth, 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(jLabel2)
.addComponent(spinnerHeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Auto-Focus"));
buttonStartAutoFocus.setText("Start");
buttonStartAutoFocus.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonStartAutoFocusActionPerformed(evt);
}
});
jLabel3.setText("Average:");
spinnerAverage.setModel(new javax.swing.SpinnerNumberModel(1, 1, 10, 1));
spinnerAverage.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spinnerAverageStateChanged(evt);
}
});
jLabel4.setText("Runs:");
spinnerRuns.setModel(new javax.swing.SpinnerNumberModel(1, 0, 10, 1));
spinnerRuns.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spinnerRunsStateChanged(evt);
}
});
buttonGroup1.add(radioObjective);
radioObjective.setSelected(true);
radioObjective.setText("Objective");
radioObjective.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
radioObjectiveActionPerformed(evt);
}
});
buttonGroup1.add(radioStigA);
radioStigA.setText("Stigmator A");
radioStigA.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
radioStigAActionPerformed(evt);
}
});
buttonGroup1.add(radioStigB);
radioStigB.setText("Stigmator B");
radioStigB.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
radioStigBActionPerformed(evt);
}
});
buttonGroup1.add(radioAll);
radioAll.setText("All");
radioAll.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
radioAllActionPerformed(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()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(radioObjective)
.addComponent(radioStigA)
.addComponent(radioStigB)
.addComponent(radioAll))
.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(radioObjective)
.addGap(0, 0, 0)
.addComponent(radioStigA)
.addGap(0, 0, 0)
.addComponent(radioStigB)
.addGap(0, 0, 0)
.addComponent(radioAll)
.addGap(0, 0, 0))
);
spinnerRangeObj.setModel(new javax.swing.SpinnerNumberModel(4.0d, 1.0d, 10.0d, 1.0d));
spinnerRangeObj.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spinnerRangeObjStateChanged(evt);
}
});
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel5.setText("Range Objective:");
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel6.setText("Step Objective:");
spinnerStepObj.setModel(new javax.swing.SpinnerNumberModel(0.2d, 0.1d, 1.0d, 0.1d));
spinnerStepObj.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spinnerStepObjStateChanged(evt);
}
});
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel7.setText("Range Stigmator:");
spinnerRangeStig.setModel(new javax.swing.SpinnerNumberModel(20.0d, 1.0d, 40.0d, 1.0d));
spinnerRangeStig.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spinnerRangeStigStateChanged(evt);
}
});
jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel8.setText("Step Stigmator:");
spinnerStepStig.setModel(new javax.swing.SpinnerNumberModel(2.0d, 1.0d, 10.0d, 1.0d));
spinnerStepStig.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spinnerStepStigStateChanged(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()
.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel6Layout.createSequentialGroup()
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerRangeObj, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel6Layout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerStepObj, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel6Layout.createSequentialGroup()
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerRangeStig, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel6Layout.createSequentialGroup()
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerStepStig, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, 0))
);
jPanel6Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel5, jLabel6, jLabel7, jLabel8});
jPanel6Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerRangeObj, spinnerRangeStig, spinnerStepObj, spinnerStepStig});
jPanel6Layout.setVerticalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel6Layout.createSequentialGroup()
.addGap(0, 0, 0)
.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(spinnerRangeObj, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 0, 0)
.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(spinnerStepObj, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(spinnerRangeStig, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 0, 0)
.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(spinnerStepStig, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 0, 0))
);
jLabel9.setText("Exposure:");
spinnerExposition.setModel(new javax.swing.SpinnerNumberModel(NaNd, 0.01d, NaNd, 1.0d));
spinnerExposition.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spinnerExpositionStateChanged(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()
.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spinnerAverage, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerRuns, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerExposition, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonStartAutoFocus)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerAverage, spinnerExposition, spinnerRuns});
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(4, 4, 4)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(spinnerAverage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(4, 4, 4)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(spinnerRuns, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(4, 4, 4)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(spinnerExposition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel5, 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(jPanel6, 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(buttonStartAutoFocus)
.addContainerGap())
);
deviceValuePanel1.setDeviceName("temp_readout");
jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel10.setText("Temperature (K):");
checkArrows.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
checkArrows.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
checkArrowsActionPerformed(evt);
}
});
jLabel11.setText("Reference arrows:");
jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel13.setText("FOV:");
deviceValuePanel2.setDeviceName("fov");
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonAbort)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel10, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel11, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel13, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(deviceValuePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(checkArrows)
.addComponent(deviceValuePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(15, 15, 15))
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, 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)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(164, 164, 164)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel10)
.addComponent(deviceValuePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel13)
.addComponent(deviceValuePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(checkArrows)
.addComponent(jLabel11))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonAbort)
.addContainerGap())
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 592, Short.MAX_VALUE)
.addGap(18, 18, 18))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(renderer, javax.swing.GroupLayout.PREFERRED_SIZE, 768, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void buttonRoiClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRoiClearActionPerformed
try {
setRoi(null);
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonRoiClearActionPerformed
private void buttonRoiSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRoiSetActionPerformed
try {
Rectangle roi = new Rectangle(0,0,Integer.valueOf(spinnerWidth.getValue().toString()),Integer.valueOf(spinnerHeight.getValue().toString()));
setRoi(roi);
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonRoiSetActionPerformed
private void spinnerWidthStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerWidthStateChanged
try {
Rectangle roi = getRoi();
if (roi!=null){
roi.width = Integer.valueOf(spinnerWidth.getValue().toString());
setRoi(roi);
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_spinnerWidthStateChanged
private void spinnerHeightStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerHeightStateChanged
try {
Rectangle roi = getRoi();
if (roi!=null){
roi.height = Integer.valueOf(spinnerHeight.getValue().toString());
setRoi(roi);
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_spinnerHeightStateChanged
private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed
try {
abort();
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonAbortActionPerformed
private void buttonStartAutoFocusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartAutoFocusActionPerformed
try {
HashMap args = new HashMap();
String scan_type = "all";
if (radioObjective.isSelected()){
scan_type = "obj";
} else if (radioStigA.isSelected()){
scan_type = "stiga";
} else if (radioStigB.isSelected()){
scan_type = "stigb";
}
int average = (Integer)spinnerAverage.getValue();
int runs = (Integer)spinnerRuns.getValue();
Double exposure = (Double) spinnerExposition.getValue();
//runAsync("templates/AutoFocus", args).handle((ret, t) -> {
//auto_focus(range_obj=4.0, step_obj=0.2, range_stig=20.0, step_stig=2.0, average=1, runs=2, roi=None):
String cmd = "auto_focus(scan_type='" + scan_type + "'" +
", range_obj=" + spinnerRangeObj.getValue() +
", step_obj=" + spinnerStepObj.getValue() +
", range_stig=" + spinnerRangeStig.getValue() +
", step_stig=" + spinnerStepStig.getValue() +
", average=" + average +
", runs=" + runs +
", renderer=IMAGING_RENDERER"+
", roi=IMAGING_ROI"+
", exposure=" + (Double.isNaN(exposure) ? "None" : exposure) +
")";
this.evalAsync(cmd).handle((ret, t) -> {
if ((t != null) && (!getContext().isAborted())) {
showException((Exception) t);
}
return t;
});
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonStartAutoFocusActionPerformed
private void buttonStartAutoIntensityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartAutoIntensityActionPerformed
try {
//String cmd = "scan_contrast(girder_x, 0.05, 0.005, average=3)";
Double exposure = (Double) spinnerExpositionIntensity.getValue();
String cmd = "auto_intensity(roi=IMAGING_ROI" +
", exposure=" + (Double.isNaN(exposure) ? "None" : exposure) +
")";
this.evalAsync(cmd).handle((ret, t) -> {
if ((t != null) && (!getContext().isAborted())) {
showException((Exception) t);
}
return t;
});
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonStartAutoIntensityActionPerformed
private void spinnerAverageStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerAverageStateChanged
// TODO add your handling code here:
}//GEN-LAST:event_spinnerAverageStateChanged
private void spinnerRunsStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerRunsStateChanged
// TODO add your handling code here:
}//GEN-LAST:event_spinnerRunsStateChanged
private void radioStigAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioStigAActionPerformed
updateButtons();
}//GEN-LAST:event_radioStigAActionPerformed
private void spinnerRangeObjStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerRangeObjStateChanged
// TODO add your handling code here:
}//GEN-LAST:event_spinnerRangeObjStateChanged
private void spinnerStepObjStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerStepObjStateChanged
// TODO add your handling code here:
}//GEN-LAST:event_spinnerStepObjStateChanged
private void spinnerRangeStigStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerRangeStigStateChanged
// TODO add your handling code here:
}//GEN-LAST:event_spinnerRangeStigStateChanged
private void spinnerStepStigStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerStepStigStateChanged
// TODO add your handling code here:
}//GEN-LAST:event_spinnerStepStigStateChanged
private void radioAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioAllActionPerformed
updateButtons();
}//GEN-LAST:event_radioAllActionPerformed
private void radioObjectiveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioObjectiveActionPerformed
updateButtons();
}//GEN-LAST:event_radioObjectiveActionPerformed
private void radioStigBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioStigBActionPerformed
updateButtons();
}//GEN-LAST:event_radioStigBActionPerformed
private void spinnerExpositionStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerExpositionStateChanged
// TODO add your handling code here:
}//GEN-LAST:event_spinnerExpositionStateChanged
private void checkArrowsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkArrowsActionPerformed
try{
showArrows(checkArrows.isSelected());
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_checkArrowsActionPerformed
private void spinnerExpositionIntensityStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerExpositionIntensityStateChanged
// TODO add your handling code here:
}//GEN-LAST:event_spinnerExpositionIntensityStateChanged
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonAbort;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JButton buttonRoiClear;
private javax.swing.JButton buttonRoiSet;
private javax.swing.JButton buttonStartAutoFocus;
private javax.swing.JButton buttonStartAutoIntensity;
private javax.swing.JCheckBox checkArrows;
private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel1;
private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
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.ProcessVariablePanel processVariablePanel1;
private ch.psi.pshell.swing.ProcessVariablePanel processVariablePanel2;
private javax.swing.JRadioButton radioAll;
private javax.swing.JRadioButton radioObjective;
private javax.swing.JRadioButton radioStigA;
private javax.swing.JRadioButton radioStigB;
private ch.psi.pshell.imaging.Renderer renderer;
private javax.swing.JSpinner spinnerAverage;
private javax.swing.JSpinner spinnerExposition;
private javax.swing.JSpinner spinnerExpositionIntensity;
private javax.swing.JSpinner spinnerHeight;
private javax.swing.JSpinner spinnerRangeObj;
private javax.swing.JSpinner spinnerRangeStig;
private javax.swing.JSpinner spinnerRuns;
private javax.swing.JSpinner spinnerStepObj;
private javax.swing.JSpinner spinnerStepStig;
private javax.swing.JSpinner spinnerWidth;
// End of variables declaration//GEN-END:variables
}