Search in sources :

Example 1 with DoubleUIParameter

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)));
}
Also used : DoubleUIParameter(de.embl.rieslab.emu.ui.uiparameters.DoubleUIParameter) Test(org.junit.Test)

Example 2 with DoubleUIParameter

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);
}
Also used : DoubleUIParameter(de.embl.rieslab.emu.ui.uiparameters.DoubleUIParameter) Test(org.junit.Test)

Example 3 with DoubleUIParameter

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");
}
Also used : DoubleUIParameter(de.embl.rieslab.emu.ui.uiparameters.DoubleUIParameter) Test(org.junit.Test)

Example 4 with DoubleUIParameter

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));
}
Also used : BoolUIParameter(de.embl.rieslab.emu.ui.uiparameters.BoolUIParameter) ColorUIParameter(de.embl.rieslab.emu.ui.uiparameters.ColorUIParameter) IntegerUIParameter(de.embl.rieslab.emu.ui.uiparameters.IntegerUIParameter) StringUIParameter(de.embl.rieslab.emu.ui.uiparameters.StringUIParameter) UIPropertyParameter(de.embl.rieslab.emu.ui.uiparameters.UIPropertyParameter) ComboUIParameter(de.embl.rieslab.emu.ui.uiparameters.ComboUIParameter) NoFlag(de.embl.rieslab.emu.ui.uiproperties.flag.NoFlag) DoubleUIParameter(de.embl.rieslab.emu.ui.uiparameters.DoubleUIParameter)

Aggregations

DoubleUIParameter (de.embl.rieslab.emu.ui.uiparameters.DoubleUIParameter)4 Test (org.junit.Test)3 BoolUIParameter (de.embl.rieslab.emu.ui.uiparameters.BoolUIParameter)1 ColorUIParameter (de.embl.rieslab.emu.ui.uiparameters.ColorUIParameter)1 ComboUIParameter (de.embl.rieslab.emu.ui.uiparameters.ComboUIParameter)1 IntegerUIParameter (de.embl.rieslab.emu.ui.uiparameters.IntegerUIParameter)1 StringUIParameter (de.embl.rieslab.emu.ui.uiparameters.StringUIParameter)1 UIPropertyParameter (de.embl.rieslab.emu.ui.uiparameters.UIPropertyParameter)1 NoFlag (de.embl.rieslab.emu.ui.uiproperties.flag.NoFlag)1