This commit is contained in:
2018-04-17 12:05:48 +02:00
parent 14edc0e745
commit 58a1260003
428 changed files with 41350 additions and 477 deletions

243
plugins/Correlation.form Normal file
View File

@@ -0,0 +1,243 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="plot" pref="371" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Component id="plot" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="ch.psi.pshell.plot.LinePlotJFree" name="plot">
<Properties>
<Property name="title" type="java.lang.String" value=""/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel1">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel7" linkSize="3" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel6" linkSize="3" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" linkSize="3" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="textDevX" linkSize="4" alignment="0" pref="250" max="32767" attributes="0"/>
<Component id="textDevY" linkSize="4" alignment="0" pref="250" max="32767" attributes="0"/>
<Component id="textCorrelation" linkSize="4" alignment="0" pref="250" max="32767" attributes="0"/>
<Component id="spinnerInterval" linkSize="2" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="spinnerWindow" linkSize="2" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="checkBS" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="textLinear" linkSize="4" alignment="0" pref="250" max="32767" attributes="0"/>
<Component id="textQuadratic" linkSize="4" alignment="0" pref="250" max="32767" attributes="0"/>
<Component id="checkLinear" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="checkQuadratic" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonStart" min="-2" pref="189" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textDevX" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textDevY" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="checkBS" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerInterval" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerWindow" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="checkLinear" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="checkQuadratic" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="42" max="32767" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="textCorrelation" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel6" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="textLinear" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel7" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="textQuadratic" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="42" max="32767" attributes="0"/>
<Component id="buttonStart" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="45" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="X device:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textDevX">
</Component>
<Component class="javax.swing.JTextField" name="textDevY">
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Y device:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Interval (s):"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerInterval">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.1" minimum="0.001" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Window size:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerWindow">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="50" minimum="3" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonStart">
<Properties>
<Property name="text" type="java.lang.String" value="Start"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonStartActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="Correlation:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textCorrelation">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkBS">
<Properties>
<Property name="text" type="java.lang.String" value="Beam synchronous"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="Liner fit:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textLinear">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel7">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="Quadratric fit:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textQuadratic">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkLinear">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Linear fit"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkQuadratic">
<Properties>
<Property name="text" type="java.lang.String" value="Quadratic fit"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

375
plugins/Correlation.java Normal file
View File

@@ -0,0 +1,375 @@
/*
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
*/
import ch.psi.pshell.plot.Plot;
import ch.psi.pshell.ui.App;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import java.awt.Component;
import java.util.HashMap;
import java.util.List;
/**
*
*/
public class Correlation extends Panel {
public Correlation() {
initComponents();
this.setPersistedComponents(new Component[]{textDevX, textDevY, spinnerInterval, spinnerWindow, checkBS});
plot.getAxis(Plot.AxisId.X).setLabel(null);
plot.getAxis(Plot.AxisId.Y).setLabel(null);
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
super.onInitialize(runCount);
this.startTimer(100, 10);
if (App.hasArgument("dx")) {
textDevX.setText(App.getArgumentValue("dx"));
}
if (App.hasArgument("dy")) {
textDevY.setText(App.getArgumentValue("dy"));
}
try{
if (App.hasArgument("bs")) {
checkBS.setSelected(Boolean.valueOf(App.getArgumentValue("bs")));
}
} catch (Exception ex){
System.err.println(ex.getMessage());
}
try{
if (App.hasArgument("interval")) {
spinnerInterval.setValue(Double.valueOf(App.getArgumentValue("interval")));
}
} catch (Exception ex){
System.err.println(ex.getMessage());
}
try{
if (App.hasArgument("window")) {
spinnerWindow.setValue(Integer.valueOf(App.getArgumentValue("window")));
}
} catch (Exception ex){
System.err.println(ex.getMessage());
}
}
@Override
protected void onTimer(){
if (isRunning()){
updateResults();
}
}
//DecimalFormat formatter = new DecimalFormat("0.##E0");
void updateResults(){
try{
textCorrelation.setText(String.format("%1.4f", Double.valueOf((Double)getContext().getInterpreterVariable("corr"))));
} catch (Exception ex){
textCorrelation.setText("");
}
if (checkLinear.isSelected()){
try{
List pars = (List)getContext().getInterpreterVariable("pars_lin");
//textLinear.setText(String.format("%1.3fx%+1.3f", (Double)(pars.get(1)), (Double)(pars.get(0))));
textLinear.setText(String.format("%1.6gx%+1.6g",pars.get(1), pars.get(0)));
} catch (Exception ex){
textLinear.setText("");
}
}
if (checkQuadratic.isSelected()){
try{
List pars = (List)getContext().getInterpreterVariable("pars_quad");
//textQuadratic.setText(String.format("%1.2fx\u00B2 %+1.2fx%+1.2f", (Double)(pars.get(0)), (Double)(pars.get(1)), (Double)(pars.get(0))));
textQuadratic.setText(String.format("%1.3gx\u00B2%+1.3gx%+1.3g", pars.get(0), pars.get(1), pars.get(0)));
//textQuadratic.setText(formatter.format(pars.get(2))+ formatter.format(pars.get(1)) + formatter.format(pars.get(0)));
} catch (Exception ex){
textQuadratic.setText("");
}
}
}
@Override
public void onStateChange(State state, State former) {
buttonStart.setEnabled((state==State.Ready) || (state==State.Busy));
if (isRunning()){
if (state==State.Ready){
buttonStart.setText("Start");
}
} else {
if (state==State.Busy){
buttonStart.setText("Stop");
}
}
textDevX.setEnabled(state==State.Ready);
textDevY.setEnabled(state==State.Ready);
spinnerInterval.setEnabled(state==State.Ready);
spinnerWindow.setEnabled(state==State.Ready);
checkBS.setEnabled(state==State.Ready);
checkLinear.setEnabled(state==State.Ready);
checkQuadratic.setEnabled(state==State.Ready);
if ((former==State.Initializing) && (state == State.Ready)){
if (App.hasArgument("start")) {
buttonStartActionPerformed(null);
}
}
}
boolean isRunning(){
return buttonStart.getText().equals("Stop");
}
@Override
public void onExecutedFile(String fileName, Object result) {
}
//Callback to perform update - in event thread
@Override
protected void doUpdate() {
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
plot = new ch.psi.pshell.plot.LinePlotJFree();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
textDevX = new javax.swing.JTextField();
textDevY = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
spinnerInterval = new javax.swing.JSpinner();
jLabel4 = new javax.swing.JLabel();
spinnerWindow = new javax.swing.JSpinner();
buttonStart = new javax.swing.JButton();
jLabel5 = new javax.swing.JLabel();
textCorrelation = new javax.swing.JTextField();
checkBS = new javax.swing.JCheckBox();
jLabel6 = new javax.swing.JLabel();
textLinear = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
textQuadratic = new javax.swing.JTextField();
checkLinear = new javax.swing.JCheckBox();
checkQuadratic = new javax.swing.JCheckBox();
plot.setTitle("");
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel1.setText("X device:");
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel2.setText("Y device:");
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel3.setText("Interval (s):");
spinnerInterval.setModel(new javax.swing.SpinnerNumberModel(Double.valueOf(0.1d), Double.valueOf(0.001d), null, Double.valueOf(1.0d)));
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel4.setText("Window size:");
spinnerWindow.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(50), Integer.valueOf(3), null, Integer.valueOf(1)));
buttonStart.setText("Start");
buttonStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonStartActionPerformed(evt);
}
});
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel5.setText("Correlation:");
textCorrelation.setEditable(false);
textCorrelation.setHorizontalAlignment(javax.swing.JTextField.CENTER);
checkBS.setText("Beam synchronous");
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel6.setText("Liner fit:");
textLinear.setEditable(false);
textLinear.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel7.setText("Quadratric fit:");
textQuadratic.setEditable(false);
textQuadratic.setHorizontalAlignment(javax.swing.JTextField.CENTER);
checkLinear.setSelected(true);
checkLinear.setText("Linear fit");
checkQuadratic.setText("Quadratic fit");
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)
.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(textDevX, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(textDevY, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(textCorrelation, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(spinnerInterval, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerWindow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(checkBS)
.addComponent(textLinear, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(textQuadratic, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(checkLinear)
.addComponent(checkQuadratic))
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonStart, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3, jLabel4});
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerInterval, spinnerWindow});
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel5, jLabel6, jLabel7});
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {textCorrelation, textDevX, textDevY, textLinear, textQuadratic});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(textDevX, 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(textDevY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(checkBS)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(spinnerInterval, 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(jLabel4)
.addComponent(spinnerWindow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(checkLinear)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(checkQuadratic)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(textCorrelation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel6)
.addComponent(textLinear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel7)
.addComponent(textQuadratic, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE)
.addComponent(buttonStart)
.addGap(45, 45, 45))
);
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()
.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(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())))
);
}// </editor-fold>//GEN-END:initComponents
private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed
try {
if (isRunning()){
abort();
updateResults();
//buttonStart.setText("Start");
} else {
textCorrelation.setText("");
textLinear.setText("");
textQuadratic.setText("");
HashMap args = new HashMap();
args.put("dx", textDevX.getText());
args.put("dy", textDevY.getText());
args.put("interval", spinnerInterval.getValue());
args.put("window", spinnerWindow.getValue());
args.put("bs", checkBS.isSelected());
args.put("linear_fit", checkLinear.isSelected());
args.put("quadratic_fit", checkQuadratic.isSelected());
args.put("p", plot);
runAsync("Correlation/Correlation", args).handle((ok, ex) -> {
if (ex != null) {
ex.printStackTrace();
}
return ok;
});
///buttonStart.setText("Stop");
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonStartActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonStart;
private javax.swing.JCheckBox checkBS;
private javax.swing.JCheckBox checkLinear;
private javax.swing.JCheckBox checkQuadratic;
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.JPanel jPanel1;
private ch.psi.pshell.plot.LinePlotJFree plot;
private javax.swing.JSpinner spinnerInterval;
private javax.swing.JSpinner spinnerWindow;
private javax.swing.JTextField textCorrelation;
private javax.swing.JTextField textDevX;
private javax.swing.JTextField textDevY;
private javax.swing.JTextField textLinear;
private javax.swing.JTextField textQuadratic;
// End of variables declaration//GEN-END:variables
}

267
plugins/Correlation2.form Normal file
View File

@@ -0,0 +1,267 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="plot" pref="345" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Component id="plot" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="ch.psi.pshell.plot.LinePlotJFree" name="plot">
<Properties>
<Property name="title" type="java.lang.String" value=""/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel1">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonStart" min="-2" pref="189" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel7" linkSize="3" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel6" linkSize="3" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" linkSize="3" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="comboTypeY" min="-2" max="-2" attributes="0"/>
<Component id="comboTypeX" min="-2" max="-2" attributes="0"/>
<Component id="textCorrelation" linkSize="4" alignment="0" pref="250" max="32767" attributes="0"/>
<Component id="spinnerInterval" linkSize="2" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="spinnerWindow" linkSize="2" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="textLinear" linkSize="4" alignment="0" pref="250" max="32767" attributes="0"/>
<Component id="textQuadratic" linkSize="4" alignment="0" pref="250" max="32767" attributes="0"/>
<Component id="checkLinear" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="checkQuadratic" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="26" max="32767" attributes="0"/>
</Group>
<Component id="textDevX" max="32767" attributes="0"/>
<Component id="textDevY" alignment="0" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textDevX" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="comboTypeX" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textDevY" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="3" max="-2" attributes="0"/>
<Component id="comboTypeY" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerInterval" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerWindow" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="checkLinear" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="checkQuadratic" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="22" max="32767" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="textCorrelation" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel6" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="textLinear" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel7" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="textQuadratic" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="24" max="32767" attributes="0"/>
<Component id="buttonStart" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="45" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="X device:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textDevX">
</Component>
<Component class="javax.swing.JTextField" name="textDevY">
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Y device:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Interval (s):"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerInterval">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.1" minimum="0.001" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Window size:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerWindow">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="50" minimum="3" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonStart">
<Properties>
<Property name="text" type="java.lang.String" value="Start"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonStartActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="Correlation:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textCorrelation">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="Liner fit:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textLinear">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel7">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="Quadratric fit:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textQuadratic">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkLinear">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Linear fit"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkQuadratic">
<Properties>
<Property name="text" type="java.lang.String" value="Quadratic fit"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboTypeX">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="3">
<StringItem index="0" value="Channel"/>
<StringItem index="1" value="Stream"/>
<StringItem index="2" value="Camera"/>
</StringArray>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboTypeY">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="3">
<StringItem index="0" value="Channel"/>
<StringItem index="1" value="Stream"/>
<StringItem index="2" value="Camera"/>
</StringArray>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

393
plugins/Correlation2.java Normal file
View File

@@ -0,0 +1,393 @@
/*
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
*/
import ch.psi.pshell.plot.Plot;
import ch.psi.pshell.ui.App;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import java.awt.Component;
import java.util.HashMap;
import java.util.List;
/**
*
*/
public class Correlation2 extends Panel {
public Correlation2() {
initComponents();
this.setPersistedComponents(new Component[]{textDevX, textDevY, spinnerInterval, spinnerWindow, comboTypeX, comboTypeY});
plot.getAxis(Plot.AxisId.X).setLabel(null);
plot.getAxis(Plot.AxisId.Y).setLabel(null);
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
super.onInitialize(runCount);
this.startTimer(100, 10);
if (App.hasArgument("dx")) {
textDevX.setText(App.getArgumentValue("dx"));
}
if (App.hasArgument("dy")) {
textDevY.setText(App.getArgumentValue("dy"));
}
try{
if (App.hasArgument("dxtype")) {
comboTypeX.setSelectedIndex(Integer.valueOf(App.getArgumentValue("dxtype")));
}
} catch (Exception ex){
System.err.println(ex.getMessage());
}
try{
if (App.hasArgument("dytype")) {
comboTypeY.setSelectedIndex(Integer.valueOf(App.getArgumentValue("dytype")));
}
} catch (Exception ex){
System.err.println(ex.getMessage());
}
try{
if (App.hasArgument("interval")) {
spinnerInterval.setValue(Double.valueOf(App.getArgumentValue("interval")));
}
} catch (Exception ex){
System.err.println(ex.getMessage());
}
try{
if (App.hasArgument("window")) {
spinnerWindow.setValue(Integer.valueOf(App.getArgumentValue("window")));
}
} catch (Exception ex){
System.err.println(ex.getMessage());
}
}
@Override
protected void onTimer(){
if (isRunning()){
updateResults();
}
}
//DecimalFormat formatter = new DecimalFormat("0.##E0");
void updateResults(){
try{
textCorrelation.setText(String.format("%1.4f", Double.valueOf((Double)getContext().getInterpreterVariable("corr"))));
} catch (Exception ex){
textCorrelation.setText("");
}
if (checkLinear.isSelected()){
try{
List pars = (List)getContext().getInterpreterVariable("pars_lin");
//textLinear.setText(String.format("%1.3fx%+1.3f", (Double)(pars.get(1)), (Double)(pars.get(0))));
textLinear.setText(String.format("%1.6gx%+1.6g",pars.get(1), pars.get(0)));
} catch (Exception ex){
textLinear.setText("");
}
}
if (checkQuadratic.isSelected()){
try{
List pars = (List)getContext().getInterpreterVariable("pars_quad");
//textQuadratic.setText(String.format("%1.2fx\u00B2 %+1.2fx%+1.2f", (Double)(pars.get(0)), (Double)(pars.get(1)), (Double)(pars.get(0))));
textQuadratic.setText(String.format("%1.3gx\u00B2%+1.3gx%+1.3g", pars.get(0), pars.get(1), pars.get(0)));
//textQuadratic.setText(formatter.format(pars.get(2))+ formatter.format(pars.get(1)) + formatter.format(pars.get(0)));
} catch (Exception ex){
textQuadratic.setText("");
}
}
}
@Override
public void onStateChange(State state, State former) {
buttonStart.setEnabled((state==State.Ready) || (state==State.Busy));
if (isRunning()){
if (state==State.Ready){
buttonStart.setText("Start");
}
} else {
if (state==State.Busy){
buttonStart.setText("Stop");
}
}
textDevX.setEnabled(state==State.Ready);
textDevY.setEnabled(state==State.Ready);
spinnerInterval.setEnabled(state==State.Ready);
spinnerWindow.setEnabled(state==State.Ready);
comboTypeX.setEnabled(state==State.Ready);
comboTypeY.setEnabled(state==State.Ready);
checkLinear.setEnabled(state==State.Ready);
checkQuadratic.setEnabled(state==State.Ready);
if ((former==State.Initializing) && (state == State.Ready)){
if (App.hasArgument("start")) {
buttonStartActionPerformed(null);
}
}
}
boolean isRunning(){
return buttonStart.getText().equals("Stop");
}
@Override
public void onExecutedFile(String fileName, Object result) {
}
//Callback to perform update - in event thread
@Override
protected void doUpdate() {
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
plot = new ch.psi.pshell.plot.LinePlotJFree();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
textDevX = new javax.swing.JTextField();
textDevY = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
spinnerInterval = new javax.swing.JSpinner();
jLabel4 = new javax.swing.JLabel();
spinnerWindow = new javax.swing.JSpinner();
buttonStart = new javax.swing.JButton();
jLabel5 = new javax.swing.JLabel();
textCorrelation = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
textLinear = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
textQuadratic = new javax.swing.JTextField();
checkLinear = new javax.swing.JCheckBox();
checkQuadratic = new javax.swing.JCheckBox();
comboTypeX = new javax.swing.JComboBox();
comboTypeY = new javax.swing.JComboBox();
plot.setTitle("");
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel1.setText("X device:");
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel2.setText("Y device:");
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel3.setText("Interval (s):");
spinnerInterval.setModel(new javax.swing.SpinnerNumberModel(Double.valueOf(0.1d), Double.valueOf(0.001d), null, Double.valueOf(1.0d)));
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel4.setText("Window size:");
spinnerWindow.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(50), Integer.valueOf(3), null, Integer.valueOf(1)));
buttonStart.setText("Start");
buttonStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonStartActionPerformed(evt);
}
});
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel5.setText("Correlation:");
textCorrelation.setEditable(false);
textCorrelation.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel6.setText("Liner fit:");
textLinear.setEditable(false);
textLinear.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel7.setText("Quadratric fit:");
textQuadratic.setEditable(false);
textQuadratic.setHorizontalAlignment(javax.swing.JTextField.CENTER);
checkLinear.setSelected(true);
checkLinear.setText("Linear fit");
checkQuadratic.setText("Quadratic fit");
comboTypeX.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Channel", "Stream", "Camera" }));
comboTypeY.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Channel", "Stream", "Camera" }));
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(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonStart, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(comboTypeY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(comboTypeX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(textCorrelation, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(spinnerInterval, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerWindow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(textLinear, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(textQuadratic, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(checkLinear)
.addComponent(checkQuadratic))
.addContainerGap())
.addComponent(textDevX)
.addComponent(textDevY)))
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3, jLabel4});
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerInterval, spinnerWindow});
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel5, jLabel6, jLabel7});
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {textCorrelation, textLinear, textQuadratic});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(textDevX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(comboTypeX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(textDevY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(3, 3, 3)
.addComponent(comboTypeY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(spinnerInterval, 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(jLabel4)
.addComponent(spinnerWindow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(checkLinear)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(checkQuadratic)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(textCorrelation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel6)
.addComponent(textLinear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel7)
.addComponent(textQuadratic, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE)
.addComponent(buttonStart)
.addGap(45, 45, 45))
);
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()
.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(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 345, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())))
);
}// </editor-fold>//GEN-END:initComponents
private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed
try {
if (isRunning()){
abort();
updateResults();
//buttonStart.setText("Start");
} else {
textCorrelation.setText("");
textLinear.setText("");
textQuadratic.setText("");
HashMap args = new HashMap();
args.put("dx", textDevX.getText());
args.put("dy", textDevY.getText());
args.put("interval", spinnerInterval.getValue());
args.put("window", spinnerWindow.getValue());
args.put("dxtype", comboTypeX.getSelectedIndex());
args.put("dytype", comboTypeY.getSelectedIndex());
args.put("linear_fit", checkLinear.isSelected());
args.put("quadratic_fit", checkQuadratic.isSelected());
args.put("p", plot);
runAsync("Correlation/Correlation2", args).handle((ok, ex) -> {
if (ex != null) {
ex.printStackTrace();
}
return ok;
});
///buttonStart.setText("Stop");
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonStartActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonStart;
private javax.swing.JCheckBox checkLinear;
private javax.swing.JCheckBox checkQuadratic;
private javax.swing.JComboBox comboTypeX;
private javax.swing.JComboBox comboTypeY;
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.JPanel jPanel1;
private ch.psi.pshell.plot.LinePlotJFree plot;
private javax.swing.JSpinner spinnerInterval;
private javax.swing.JSpinner spinnerWindow;
private javax.swing.JTextField textCorrelation;
private javax.swing.JTextField textDevX;
private javax.swing.JTextField textDevY;
private javax.swing.JTextField textLinear;
private javax.swing.JTextField textQuadratic;
// End of variables declaration//GEN-END:variables
}

Binary file not shown.

View File

@@ -38,7 +38,7 @@
<Group type="102" alignment="0" attributes="0">
<Component id="sidePanel" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="renderer" pref="578" max="32767" attributes="0"/>
<Component id="renderer" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
@@ -68,7 +68,7 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="jPanel5" max="32767" attributes="0"/>
@@ -78,7 +78,7 @@
<Component id="panelScreen" max="32767" attributes="0"/>
<Component id="panelFilter" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -97,6 +97,7 @@
<Component id="panelScreen" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelFilter" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -433,16 +434,27 @@
<Component id="textState" min="-2" pref="80" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="filler1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="56" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonServer" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonDirect" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textState" linkSize="2" alignment="3" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="textState" linkSize="2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="filler1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonServer" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonDirect" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@@ -483,6 +495,16 @@
<Property name="enabled" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.Box$Filler" name="filler1">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 32767]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.VerticalGlue"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelScreen">
@@ -865,19 +887,13 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="toolBar" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="comboCameras" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="comboType" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="pauseSelection" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="panelCameraSelection" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Component id="pauseSelection" min="-2" pref="334" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -885,61 +901,16 @@
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="toolBar" min="-2" pref="25" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="comboCameras" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="comboType" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="pauseSelection" alignment="2" min="-2" pref="29" max="-2" attributes="0"/>
<Component id="toolBar" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="panelCameraSelection" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="pauseSelection" alignment="0" min="-2" pref="29" max="-2" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JComboBox" name="comboCameras">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="14" style="1"/>
</Property>
<Property name="maximumRowCount" type="int" value="30"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboCamerasActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Camera:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="text" type="java.lang.String" value="Type:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboType">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="14" style="1"/>
</Property>
<Property name="maximumRowCount" type="int" value="30"/>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="All"/>
<StringItem index="1" value="Laser"/>
<StringItem index="2" value="Electrons"/>
<StringItem index="3" value="Photonics"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboTypeActionPerformed"/>
</Events>
</Component>
<Container class="javax.swing.JToolBar" name="toolBar">
<Properties>
<Property name="floatable" type="boolean" value="false"/>
@@ -977,30 +948,6 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonStreamDataActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonArgs">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;Data&quot;)" type="code"/>
</Property>
<Property name="text" type="java.lang.String" value=" "/>
<Property name="toolTipText" type="java.lang.String" value="Camera Setup"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonArgsActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JToolBar$Separator" name="jSeparator5">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[20, 32767]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[20, 0]"/>
</Property>
<Property name="requestFocusEnabled" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JToggleButton" name="buttonSave">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
@@ -1106,6 +1053,19 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonReticleActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JToggleButton" name="buttonTitle">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;Title&quot;)" type="code"/>
</Property>
<Property name="text" type="java.lang.String" value=" "/>
<Property name="toolTipText" type="java.lang.String" value="Show Camera Name"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonTitleActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Component class="ch.psi.pshell.swing.ValueSelection" name="pauseSelection">
@@ -1113,6 +1073,88 @@
<Property name="decimals" type="int" value="0"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="panelCameraSelection">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="comboCameras" min="-2" pref="222" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="comboType" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="comboType" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="comboCameras" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Camera:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboCameras">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="14" style="1"/>
</Property>
<Property name="maximumRowCount" type="int" value="30"/>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[127, 27]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboCamerasActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="text" type="java.lang.String" value="Type:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboType">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="14" style="1"/>
</Property>
<Property name="maximumRowCount" type="int" value="30"/>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="All"/>
<StringItem index="1" value="Laser"/>
<StringItem index="2" value="Electrons"/>
<StringItem index="3" value="Photonics"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboTypeActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Component class="ch.psi.pshell.imaging.Renderer" name="renderer">

View File

@@ -183,13 +183,15 @@ public class ScreenPanel2 extends Panel {
x_center_of_mass = getServerDouble("x_center_of_mass", cache);
y_center_of_mass = getServerDouble("y_center_of_mass", cache);
x_rms = getServerDouble("x_rms", cache);
y_rms = getServerDouble("y_rms", cache);
y_rms = getServerDouble("y_rms", cache);
if (goodRegion) {
double[] gX2 = new double[x_profile.length];
Arrays.fill(gX2, Double.NaN);
try {
double x = getServerDoubleArray("gr_x_axis", cache)[0];
System.arraycopy(x_fit_gauss_function, 0, gX2, (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageX(x) : x), x_fit_gauss_function.length);
gr_size_x = x_fit_gauss_function.length;
gr_pos_x = (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageX(x) : x);
System.arraycopy(x_fit_gauss_function, 0, gX2, gr_pos_x , gr_size_x);
} catch (Exception ex) {
}
x_fit_gauss_function = gX2;
@@ -197,7 +199,9 @@ public class ScreenPanel2 extends Panel {
Arrays.fill(gY2, Double.NaN);
try {
double y = getServerDoubleArray("gr_y_axis", cache)[0];
System.arraycopy(y_fit_gauss_function, 0, gY2, (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageY(y) : y), y_fit_gauss_function.length);
gr_size_y = y_fit_gauss_function.length;
gr_pos_y = (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageY(y) : y);
System.arraycopy(y_fit_gauss_function, 0, gY2, gr_pos_y, y_fit_gauss_function.length);
} catch (Exception ex) {
}
y_fit_gauss_function = gY2;
@@ -228,6 +232,10 @@ public class ScreenPanel2 extends Panel {
public double[] x_fit_gauss_function;
public double[] y_profile;
public double[] y_fit_gauss_function;
public int gr_size_x;
public int gr_pos_x;
public int gr_size_y;
public int gr_pos_y;
public PointDouble[] sliceCenters;
public StreamValue cache;
}
@@ -664,7 +672,7 @@ public class ScreenPanel2 extends Panel {
try {
fo = getFitOverlays(data);
} catch (Exception ex) {
System.err.println(ex);
ex.printStackTrace();
}
}
synchronized (lockOverlays) {
@@ -1300,60 +1308,75 @@ public class ScreenPanel2 extends Panel {
profileSize /= 4;
if (pX != null) {
int[] x = Arr.indexesInt(pX.length);
int[] y = new int[pX.length];
int[] p = new int[pX.length];
int[] xp = Arr.indexesInt(pX.length);
int[] xg = xp;
int[] yp = new int[pX.length];
int[] yg = new int[pX.length];
List<Double> l = Arrays.asList((Double[]) Convert.toWrapperArray(pX));
Double min = Collections.min(l);
Double max = Collections.max(l);
double minPlot = min;
double rangePlot = max - min;
for (int i = 0; i < x.length; i++) {
double minProfile = Collections.min(l);
double maxProfile = Collections.max(l);
double rangeProfile = maxProfile - minProfile;
double minGauss = minProfile;
double rangeGauss = rangeProfile;
//If not good region, range of profile and fit are similar so save this calcultion
if (goodRegion && id.gr_size_x>0){
l = Arrays.asList( (Double[]) Convert.toWrapperArray(Arrays.copyOfRange(gX, id.gr_pos_x, id.gr_pos_x + id.gr_size_x)));
minGauss = Collections.min(l);
rangeGauss = Collections.max(l) - minGauss;
}
for (int i = 0; i < xp.length; i++) {
if (gX != null) {
y[i] = (int) (height - 1 - (((gX[i] - minPlot) / rangePlot) * profileSize));
yg[i] = (int) (height - 1 - (((gX[i] - minGauss) / rangeGauss) * profileSize));
}
p[i] = (int) (height - 1 - (((pX[i] - minPlot) / rangePlot) * profileSize));
yp[i] = (int) (height - 1 - (((pX[i] - minProfile) / rangeProfile) * profileSize));
}
if (goodRegion) {
for (int i = 0; i < x.length; i++) {
y[i] = (Double.isNaN(gX[i])) ? 100000 : y[i];
}
if (goodRegion && id.gr_size_x>0){
xg = Arrays.copyOfRange(xg, id.gr_pos_x, id.gr_pos_x + id.gr_size_x);
yg = Arrays.copyOfRange(yg, id.gr_pos_x, id.gr_pos_x + id.gr_size_x);
}
vgaussian = new Overlays.Polyline(penFit, x, y);
vprofile = new Overlays.Polyline(renderer.getPenProfile(), x, p);
vgaussian = new Overlays.Polyline(penFit, xg, yg);
vprofile = new Overlays.Polyline(renderer.getPenProfile(), xp, yp);
}
if (pY != null) {
int[] y = Arr.indexesInt(pY.length);
int[] x = new int[pY.length];
int[] p = new int[pY.length];
int[] xp = new int[pY.length];
int[] xg = new int[pY.length];
int[] yp = Arr.indexesInt(pY.length);
int[] yg = yp;
List<Double> l = Arrays.asList((Double[]) Convert.toWrapperArray(pY));
Double min = Collections.min(l);
Double max = Collections.max(l);
double minPlot = min;
double rangePlot = max - min;
double minProfile = Collections.min(l);
double maxProfile = Collections.max(l);
double rangeProfile = maxProfile - minProfile;
double minGauss = minProfile;
double rangeGauss = rangeProfile;
//If not good region, range of profile and fit are similar so save this calcultion
if (goodRegion && id.gr_size_y>0){
l = Arrays.asList( (Double[]) Convert.toWrapperArray(Arrays.copyOfRange(gY, id.gr_pos_y, id.gr_pos_y + id.gr_size_y)));
minGauss = Collections.min(l);
rangeGauss = Collections.max(l) - minGauss;
}
for (int i = 0; i < x.length; i++) {
for (int i = 0; i < xp.length; i++) {
if (gY != null) {
x[i] = (int) (((gY[i] - minPlot) / rangePlot) * profileSize);
xg[i] = (int) (((gY[i] - minGauss) / rangeGauss) * profileSize);
}
p[i] = (int) (((pY[i] - minPlot) / rangePlot) * profileSize);
xp[i] = (int) (((pY[i] - minProfile) / rangeProfile) * profileSize);
}
if (goodRegion) {
for (int i = 0; i < x.length; i++) {
x[i] = (Double.isNaN(gY[i])) ? -1 : x[i];
}
if (goodRegion && id.gr_size_x>0){
xg = Arrays.copyOfRange(xg, id.gr_pos_y, id.gr_pos_y + id.gr_size_y);
yg = Arrays.copyOfRange(yg, id.gr_pos_y, id.gr_pos_y + id.gr_size_y);
}
hgaussian = new Overlays.Polyline(penFit, x, y);
hprofile = new Overlays.Polyline(renderer.getPenProfile(), p, y);
hgaussian = new Overlays.Polyline(penFit, xg, yg);
hprofile = new Overlays.Polyline(renderer.getPenProfile(), xp, yp);
}
} catch (Exception ex) {
System.err.println(ex.getMessage());
ex.printStackTrace();
return null;
}
} else {
@@ -2190,6 +2213,11 @@ public class ScreenPanel2 extends Panel {
} catch (Exception ex) {
dataTableModel.addRow(new Object[]{"Stream", ex.getMessage()});
}
try {
dataTableModel.addRow(new Object[]{"PID", value.getPulseId()});
} catch (Exception ex) {
dataTableModel.addRow(new Object[]{"PID", ex.getMessage()});
}
Collections.sort(ids);
for (String id : ids) {
dataTableModel.addRow(new Object[]{id, ""});
@@ -2197,7 +2225,7 @@ public class ScreenPanel2 extends Panel {
}
Frame frame = getCurrentFrame();
if ((frame != null) && (frame.cache!=null)){
for (int i = 2; i < dataTableModel.getRowCount(); i++) {
for (int i = 3; i < dataTableModel.getRowCount(); i++) {
String id = String.valueOf(dataTableModel.getValueAt(i, 0));
//Object obj = server.getValue(id);
Object obj = frame.cache.getValue(id);