use of de.embl.rieslab.emu.ui.uiparameters.DoubleUIParameter in project micro-manager by micro-manager.
the class ConfigurablePanelTest method testGetDoubleUIParameterValue.
// get DoubleUIParameter value
@Test
public void testGetDoubleUIParameterValue() throws IncorrectUIParameterTypeException, UnknownUIParameterException {
final double defval = 42.195;
final String param = "Param";
ConfigurableTestPanel cp = new ConfigurableTestPanel("MyPanel") {
private static final long serialVersionUID = 1L;
@Override
protected void initializeParameters() {
this.addUIParameter(new DoubleUIParameter(this, param, "", defval));
}
};
assertEquals(defval, cp.getDoubleUIParameterValue(param), 1E-20);
final String nval = "81.7841";
cp.getUIParameter(param).setStringValue(nval);
assertEquals(nval, String.valueOf(cp.getDoubleUIParameterValue(param)));
}
use of de.embl.rieslab.emu.ui.uiparameters.DoubleUIParameter in project micro-manager by micro-manager.
the class ConfigurablePanelTest method testGetDoubleUIParameterNullValue.
@Test(expected = NullPointerException.class)
public void testGetDoubleUIParameterNullValue() throws IncorrectUIParameterTypeException, UnknownUIParameterException {
final double defval = 42.195;
final String param = "Param";
ConfigurableTestPanel cp = new ConfigurableTestPanel("MyPanel") {
private static final long serialVersionUID = 1L;
@Override
protected void initializeParameters() {
this.addUIParameter(new DoubleUIParameter(this, param, "", defval));
}
};
cp.getDoubleUIParameterValue(null);
}
use of de.embl.rieslab.emu.ui.uiparameters.DoubleUIParameter in project micro-manager by micro-manager.
the class ConfigurablePanelTest method testGetDoubleUIParameterWrongValue.
@Test(expected = UnknownUIParameterException.class)
public void testGetDoubleUIParameterWrongValue() throws IncorrectUIParameterTypeException, UnknownUIParameterException {
final double defval = 42.195;
final String param = "Param";
ConfigurableTestPanel cp = new ConfigurableTestPanel("MyPanel") {
private static final long serialVersionUID = 1L;
@Override
protected void initializeParameters() {
this.addUIParameter(new DoubleUIParameter(this, param, "", defval));
}
};
cp.getDoubleUIParameterValue("Rosebud");
}
use of de.embl.rieslab.emu.ui.uiparameters.DoubleUIParameter in project micro-manager by micro-manager.
the class ConfigurablePanelTest method testGetStringUIParameterWithAllTypes.
public void testGetStringUIParameterWithAllTypes() throws UnknownUIParameterException {
final String parambool = "Param";
final String paramcombo = "Param";
final String paramuiprop = "Param";
final String paramstring = "Param";
final String paramcolor = "Param";
final String paramdouble = "Param";
final String paramint = "Param";
final boolean defbool = false;
final String defstring = "Papouasie";
final String defstring2 = "New Guinea";
final double defdouble = 42.5;
final int defval = 2;
final String[] vals = { "SuperVal", "MediocreVal", "UnitTesting is tough", "SomeVal" };
ConfigurableTestPanel cp = new ConfigurableTestPanel("MyPanel") {
private static final long serialVersionUID = 1L;
@Override
protected void initializeParameters() {
this.addUIParameter(new ComboUIParameter(this, paramcombo, "", vals, defval));
this.addUIParameter(new BoolUIParameter(this, parambool, "", defbool));
UIPropertyParameter p = new UIPropertyParameter(this, paramuiprop, "", new NoFlag());
this.addUIParameter(p);
p.setStringValue(defstring2);
this.addUIParameter(new StringUIParameter(this, paramstring, "", defstring));
this.addUIParameter(new ColorUIParameter(this, paramcolor, "", Color.BLACK));
this.addUIParameter(new DoubleUIParameter(this, paramdouble, "", defdouble));
this.addUIParameter(new IntegerUIParameter(this, paramint, "", defval));
}
};
assertEquals(String.valueOf(defbool), cp.getStringUIParameterValue(parambool));
assertEquals(vals[defval], cp.getStringUIParameterValue(paramcombo));
assertEquals(defstring2, cp.getStringUIParameterValue(paramuiprop));
assertEquals(defstring, cp.getStringUIParameterValue(paramstring));
assertEquals("black", cp.getStringUIParameterValue(paramcolor));
assertEquals(String.valueOf(defdouble), cp.getStringUIParameterValue(paramdouble));
assertEquals(String.valueOf(defval), cp.getStringUIParameterValue(paramint));
}
Aggregations