Fix grab_frame
This commit is contained in:
747
plugins/Imaging.java
Normal file
747
plugins/Imaging.java
Normal file
@@ -0,0 +1,747 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@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();
|
||||
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();
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
|
||||
jPanel2.setLayout(jPanel2Layout);
|
||||
jPanel2Layout.setHorizontalGroup(
|
||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonStartAutoIntensity)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
jPanel2Layout.setVerticalGroup(
|
||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonStartAutoIntensity)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, 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))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
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()
|
||||
.addGap(97, 97, 97)
|
||||
.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.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonStartAutoFocus)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
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()
|
||||
.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(jPanel2, 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))
|
||||
.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)
|
||||
.addComponent(buttonAbort)
|
||||
.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)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonAbort)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
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, 376, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, 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)";
|
||||
String cmd = "auto_intensity(roi=IMAGING_ROI)";
|
||||
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
|
||||
|
||||
// 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.JLabel jLabel1;
|
||||
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 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 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
|
||||
}
|
||||
Reference in New Issue
Block a user