Closedown

This commit is contained in:
sfop
2016-06-27 17:02:36 +02:00
parent bf512419fd
commit cbcee1919b
3 changed files with 101 additions and 75 deletions

View File

@@ -20,56 +20,53 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="centroidPlot" pref="0" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonRun" min="-2" pref="92" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="buttonAbort" min="-2" pref="92" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="155" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="buttonRun" max="32767" attributes="0"/>
<Component id="buttonAbort" pref="92" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="100" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
<Component id="progressBar" pref="272" max="32767" attributes="0"/>
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
<Component id="buttonClear" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Component id="centroidPlot" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace min="-2" max="-2" 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="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jPanel1" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="41" max="-2" attributes="0"/>
<Component id="buttonRun" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="buttonAbort" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="centroidPlot" min="-2" pref="289" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonRun" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonAbort" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="buttonClear" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
<Component id="centroidPlot" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="buttonClear" min="-2" max="-2" attributes="0"/>
<Component id="progressBar" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -196,7 +193,7 @@
</Group>
<EmptySpace min="-2" pref="57" max="-2" attributes="0"/>
<Component id="checkSaveImages" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="75" max="32767" attributes="0"/>
<EmptySpace pref="70" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -317,7 +314,10 @@
<Component class="ch.psi.pshell.plot.LinePlotJFree" name="centroidPlot">
<Properties>
<Property name="legendVisible" type="boolean" value="true"/>
<Property name="title" type="java.lang.String" value="Centroid"/>
<Property name="title" type="java.lang.String" value=""/>
<Property name="titleFont" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="DejaVu Sans" size="14" style="0"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonClear">
@@ -328,5 +328,10 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonClearActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JProgressBar" name="progressBar">
<Properties>
<Property name="maximum" type="int" value="1000"/>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@@ -3,6 +3,10 @@
*/
import ch.psi.pshell.plot.LinePlotSeries;
import ch.psi.pshell.plot.Plot;
import ch.psi.pshell.scan.Scan;
import ch.psi.pshell.scan.ScanListener;
import ch.psi.pshell.scan.ScanRecord;
import ch.psi.pshell.scan.ScanResult;
import ch.psi.pshell.ui.Panel;
import ch.psi.pshell.ui.Plugin;
@@ -11,6 +15,7 @@ import ch.psi.utils.State;
import java.awt.Color;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -21,13 +26,22 @@ import java.util.logging.Logger;
public class GunSolenoidAlignment extends Panel {
public GunSolenoidAlignment() {
initComponents();
initComponents();
}
ScanListener scanListener = new ScanListener() {
public void onNewRecord(Scan scan, ScanRecord record) {
progressBar.setValue(getView().getStatusBar().getProgressBar().getValue());
scanSeries.appendData((Double)record.getValues()[0], (Double)record.getValues()[1]);
}
};
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
progressBar.setValue(0);
getController().addScanListener(scanListener);
centroidPlot.getAxis(Plot.AxisId.X).setLabel("Centroid Excursion");
}
@Override
@@ -38,7 +52,7 @@ public class GunSolenoidAlignment extends Panel {
}
@Override
public void onExecutedFile(String fileName, Object result) {
public void onExecutedFile(String fileName, Object result) {
}
@@ -47,20 +61,19 @@ public class GunSolenoidAlignment extends Panel {
protected void doUpdate() {
}
LinePlotSeries scanSeries;
int index=1;
void onEndScan(ScanResult sr){
ArrayList x = sr.getReadable(0);
ArrayList y = sr.getReadable(1);
LinePlotSeries s = new LinePlotSeries(String.valueOf(index++));
centroidPlot.addSeries(s);
System.out.println("END!");
s.setData((double[])Convert.toDouble(x), (double[])Convert.toDouble(y));
System.out.println("OK!");
void onEndScan(ScanResult sr, List hx, List hy){
progressBar.setValue(1000);
//double[] x =(double[]) Convert.toDouble(sr.getReadable(0));
//double[] y =(double[]) Convert.toDouble(sr.getReadable(1));
double[] x =(double[]) Convert.toDouble(hx);
double[] y =(double[]) Convert.toDouble(hy);
LinePlotSeries hull = new LinePlotSeries(scanSeries.getName() + "H", scanSeries.getColor());
centroidPlot.addSeries(hull);
hull.setData((double[])Convert.toDouble(x), (double[])Convert.toDouble(y));
System.out.println("OK!");
}
@@ -90,6 +103,7 @@ public class GunSolenoidAlignment extends Panel {
spinnerNumImages = new javax.swing.JSpinner();
centroidPlot = new ch.psi.pshell.plot.LinePlotJFree();
buttonClear = new javax.swing.JButton();
progressBar = new javax.swing.JProgressBar();
buttonRun.setText("Run");
buttonRun.addActionListener(new java.awt.event.ActionListener() {
@@ -238,11 +252,12 @@ public class GunSolenoidAlignment extends Panel {
.addComponent(spinnerNumBackgrounds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(57, 57, 57)
.addComponent(checkSaveImages)
.addContainerGap(75, Short.MAX_VALUE))
.addContainerGap(70, Short.MAX_VALUE))
);
centroidPlot.setLegendVisible(true);
centroidPlot.setTitle("Centroid");
centroidPlot.setTitle("");
centroidPlot.setTitleFont(new java.awt.Font("DejaVu Sans", 0, 14)); // NOI18N
buttonClear.setText("Clear");
buttonClear.addActionListener(new java.awt.event.ActionListener() {
@@ -251,47 +266,47 @@ public class GunSolenoidAlignment extends Panel {
}
});
progressBar.setMaximum(1000);
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()
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(centroidPlot, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 155, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonRun, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(buttonAbort, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(12, 12, 12)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(buttonRun, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonAbort, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE))
.addGap(100, 100, 100))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(buttonClear)
.addContainerGap())))))
.addGap(12, 12, 12)
.addComponent(progressBar, javax.swing.GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(buttonClear))
.addComponent(centroidPlot, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(41, 41, 41)
.addComponent(buttonRun)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(buttonAbort)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(centroidPlot, javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonRun)
.addComponent(buttonAbort))
.addGap(18, 18, 18)
.addComponent(buttonClear)
.addGap(9, 9, 9)))
.addComponent(centroidPlot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(buttonClear)
.addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
@@ -308,6 +323,12 @@ public class GunSolenoidAlignment extends Panel {
private void buttonRunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRunActionPerformed
try {
progressBar.setValue(0);
scanSeries = new LinePlotSeries(String.valueOf(index++));
centroidPlot.addSeries(scanSeries);
scanSeries.setLinesVisible(false);
scanSeries.setPointSize(4);
HashMap args = new HashMap();
args.put("I1", spinnerI1.getValue());
args.put("I2", spinnerI2.getValue());
@@ -319,8 +340,8 @@ public class GunSolenoidAlignment extends Panel {
args.put("use_background", checkBackground.isSelected());
args.put("multiple_background", radioBackMultiple.isSelected());
((Plugin)this).runAsync("Alignment/Gun_solenoid_alignment",args).thenAccept((Object t) -> {
System.out.println("Finish");
onEndScan((ScanResult) t);
List ret = (List)t;
onEndScan((ScanResult)ret.get(0), (List)ret.get(1), (List)ret.get(2) );
});
} catch (Exception ex) {
System.out.println("Error " + ex.toString());
@@ -358,6 +379,7 @@ public class GunSolenoidAlignment extends Panel {
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1;
private javax.swing.JProgressBar progressBar;
private javax.swing.JRadioButton radioBackMultiple;
private javax.swing.JRadioButton radioBackSimple;
private javax.swing.JSpinner spinnerI1;

View File

@@ -174,7 +174,6 @@ def add_convex_hull_plot(title, x,y, name=None, clear = False, x_range = None, y
s.setLinesVisible(False)
s.setPointSize(3)
s.setData(to_array(x,'d') , to_array(y,'d'))
p.repaint()
#Convex Hull
#In the first time the plot shows, it takes some time for the color to be assigned