This commit is contained in:
x03daop
2016-07-26 15:58:28 +02:00
parent b9b0415e83
commit 652babc564
4 changed files with 37 additions and 16 deletions

View File

@@ -255,7 +255,7 @@
<Component class="javax.swing.JSpinner" name="spinnerToPhi">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="1.0" maximum="1.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
<SpinnerModel initial="10.0" maximum="10.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
@@ -293,7 +293,7 @@
<Component class="javax.swing.JSpinner" name="spinnerToTheta">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="1.0" maximum="1.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
<SpinnerModel initial="10.0" maximum="10.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>

View File

@@ -38,10 +38,20 @@ public class HoloScan extends Panel {
Motor theta = (Motor) getDevice("ManipulatorTheta");
motorPanelPhi.setDevice(phi);
motorPanelTheta.setDevice(theta);
spinnerFromPhi.setModel(new SpinnerNumberModel(phi.getMinValue(), phi.getMinValue(), phi.getMaxValue(), 1.0));
spinnerToPhi.setModel(new SpinnerNumberModel(phi.getMaxValue(), phi.getMinValue(), phi.getMaxValue(), 1.0));
spinnerFromTheta.setModel(new SpinnerNumberModel(theta.getMinValue(), theta.getMinValue(), theta.getMaxValue(), 1.0));
spinnerToTheta.setModel(new SpinnerNumberModel(theta.getMaxValue(), theta.getMinValue(), theta.getMaxValue(), 1.0));
try{
spinnerFromPhi.setModel(new SpinnerNumberModel(Math.max(phi.getMinValue(),(Double)spinnerFromPhi.getValue()), phi.getMinValue(), phi.getMaxValue(), 1.0));
spinnerToPhi.setModel(new SpinnerNumberModel(Math.min(phi.getMaxValue(),(Double)spinnerToPhi.getValue()), phi.getMinValue(), phi.getMaxValue(), 1.0));
} catch (Exception ex){
spinnerFromPhi.setModel(new SpinnerNumberModel(phi.getMinValue(), phi.getMinValue(), phi.getMaxValue(), 1.0));
spinnerToPhi.setModel(new SpinnerNumberModel(phi.getMaxValue(), phi.getMinValue(), phi.getMaxValue(), 1.0));
}
try{
spinnerFromTheta.setModel(new SpinnerNumberModel(Math.max(theta.getMinValue(),(Double)spinnerFromTheta.getValue()), theta.getMinValue(), theta.getMaxValue(), 1.0));
spinnerToTheta.setModel(new SpinnerNumberModel(Math.min(theta.getMaxValue(),(Double)spinnerFromTheta.getValue()), theta.getMinValue(), theta.getMaxValue(), 1.0));
} catch (Exception ex){
spinnerFromTheta.setModel(new SpinnerNumberModel(theta.getMinValue(), theta.getMinValue(), theta.getMaxValue(), 1.0));
spinnerToTheta.setModel(new SpinnerNumberModel(theta.getMaxValue(), theta.getMinValue(), theta.getMaxValue(), 1.0));
}
}
@Override
@@ -192,7 +202,7 @@ public class HoloScan extends Panel {
jLabel5.setText("Phi To:");
spinnerToPhi.setModel(new javax.swing.SpinnerNumberModel(1.0d, 0.0d, 1.0d, 1.0d));
spinnerToPhi.setModel(new javax.swing.SpinnerNumberModel(10.0d, 0.0d, 10.0d, 1.0d));
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel6.setText("Phi:");
@@ -206,7 +216,7 @@ public class HoloScan extends Panel {
spinnerFromTheta.setModel(new javax.swing.SpinnerNumberModel(1.0d, 0.0d, 1.0d, 1.0d));
spinnerToTheta.setModel(new javax.swing.SpinnerNumberModel(1.0d, 0.0d, 1.0d, 1.0d));
spinnerToTheta.setModel(new javax.swing.SpinnerNumberModel(10.0d, 0.0d, 10.0d, 1.0d));
jLabel11.setText("Phi:");

View File

@@ -12,6 +12,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JSpinner;
import javax.swing.JToggleButton;
import javax.swing.SpinnerNumberModel;
@@ -25,9 +26,10 @@ public class ManipulatorScan extends Panel {
initComponents();
//Component persistence
ArrayList<Component> persistedComponents = new ArrayList<>();
ArrayList<Component> persistedComponents = new ArrayList<>();
persistedComponents.addAll(Arrays.asList(SwingUtils.getComponentsByType(this, JToggleButton.class)));
persistedComponents.addAll(Arrays.asList(SwingUtils.getComponentsByType(this, JSpinner.class)));
persistedComponents.addAll(Arrays.asList(SwingUtils.getComponentsByType(this, JSpinner.class)));
persistedComponents.addAll(Arrays.asList(SwingUtils.getComponentsByType(this, JComboBox.class)));
setPersistedComponents(persistedComponents.toArray(new Component[0]));
}
@@ -572,12 +574,19 @@ public class ManipulatorScan extends Panel {
try {
Motor motor = (Motor) getDevice(comboMotor.getSelectedItem().toString());
motorPanel.setDevice(motor);
spinnerFrom.setModel(new SpinnerNumberModel(motor.getMinValue(), motor.getMinValue(), motor.getMaxValue(), 1.0));
spinnerTo.setModel(new SpinnerNumberModel(motor.getMaxValue(), motor.getMinValue(), motor.getMaxValue(), 1.0));
txtSize.setText("Size (" + motor.getUnit() +")");
//spinnerFrom.setModel(new javax.swing.SpinnerNumberModel(3.0, 0.001, 100.0, 1.0));
//spinnerTo.setModel(new javax.swing.SpinnerNumberModel(2.0, 0.001, 100.0, 1.0));
if (motor!=null){
//Try to reload existing values
try{
spinnerFrom.setModel(new SpinnerNumberModel(Math.max(motor.getMinValue(),(Double)spinnerFrom.getValue()), motor.getMinValue(), motor.getMaxValue(), 1.0));
spinnerTo.setModel(new SpinnerNumberModel(Math.min(motor.getMaxValue(),(Double)spinnerTo.getValue()), motor.getMinValue(), motor.getMaxValue(), 1.0));
} catch (Exception ex){
spinnerFrom.setModel(new SpinnerNumberModel(motor.getMinValue(), motor.getMinValue(), motor.getMaxValue(), 1.0));
spinnerTo.setModel(new SpinnerNumberModel(motor.getMaxValue(), motor.getMinValue(), motor.getMaxValue(), 1.0));
}
txtSize.setText("Size (" + motor.getUnit() +")");
}
} catch (Exception ex) {
ex.printStackTrace();
SwingUtils.showException(this, ex);
}
}//GEN-LAST:event_comboMotorActionPerformed

View File

@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JSpinner;
import javax.swing.JToggleButton;
@@ -73,7 +74,8 @@ public class XPSSpectrum extends Panel {
//Component persistence
ArrayList<Component> persistedComponents = new ArrayList<>();
persistedComponents.addAll(Arrays.asList(SwingUtils.getComponentsByType(this, JToggleButton.class)));
persistedComponents.addAll(Arrays.asList(SwingUtils.getComponentsByType(this, ValueSelection.class)));
persistedComponents.addAll(Arrays.asList(SwingUtils.getComponentsByType(this, ValueSelection.class)));
persistedComponents.addAll(Arrays.asList(SwingUtils.getComponentsByType(this, JComboBox.class)));
setPersistedComponents(persistedComponents.toArray(new Component[0]));
}