Search in sources :

Example 26 with FieldConfigSlider

use of com.sldeditor.ui.detail.config.FieldConfigSlider in project sldeditor by robward-scisys.

the class FieldConfigSliderTest method testRevertToDefaultValue.

/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigSlider#revertToDefaultValue()}. Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSlider#setDefaultValue(double)}.
 */
@Test
public void testRevertToDefaultValue() {
    boolean valueOnly = true;
    FieldConfigSlider field = new FieldConfigSlider(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly, false));
    double defaultDefaultValue = 0.5;
    field.revertToDefaultValue();
    assertTrue(Math.abs(field.getDoubleValue() - defaultDefaultValue) < 0.001);
    field.createUI();
    field.createUI();
    Double expectedDefaultValue = 0.42;
    field.setDefaultValue(expectedDefaultValue);
    field.revertToDefaultValue();
    assertTrue(Math.abs(field.getDoubleValue() - expectedDefaultValue) < 0.001);
    assertTrue(String.valueOf(expectedDefaultValue).compareTo(field.getStringValue()) == 0);
}
Also used : FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) Test(org.junit.jupiter.api.Test)

Example 27 with FieldConfigSlider

use of com.sldeditor.ui.detail.config.FieldConfigSlider in project sldeditor by robward-scisys.

the class FieldConfigSliderTest method testValueStored.

@Test
public void testValueStored() {
    boolean valueOnly = true;
    class TestFieldConfigSlider extends FieldConfigSlider {

        public TestFieldConfigSlider(FieldConfigCommonData commonData) {
            super(commonData);
        }

        /*
             * (non-Javadoc)
             *
             * @see com.sldeditor.ui.detail.config.FieldConfigBoundingBox#valueStored()
             */
        @Override
        protected void valueStored(Integer value) {
            super.valueStored(value);
        }
    }
    TestFieldConfigSlider field = new TestFieldConfigSlider(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly, false));
    class TestUpdateSymbol implements UpdateSymbolInterface {

        public boolean dataChanged = false;

        @Override
        public void dataChanged(FieldIdEnum changedField) {
            dataChanged = true;
        }
    }
    ;
    TestUpdateSymbol update = new TestUpdateSymbol();
    int undoListSize = UndoManager.getInstance().getUndoListSize();
    field.createUI();
    field.addDataChangedListener(update);
    assertFalse(update.dataChanged);
    field.valueStored(12);
    assertTrue(update.dataChanged);
    assertEquals(undoListSize + 1, UndoManager.getInstance().getUndoListSize());
    update.dataChanged = false;
    // now suppress undo events
    field = new TestFieldConfigSlider(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly, true));
    undoListSize = UndoManager.getInstance().getUndoListSize();
    field.addDataChangedListener(update);
    assertFalse(update.dataChanged);
    field.valueStored(34);
    assertTrue(update.dataChanged);
    assertEquals(undoListSize, UndoManager.getInstance().getUndoListSize());
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) UpdateSymbolInterface(com.sldeditor.ui.iface.UpdateSymbolInterface) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) Test(org.junit.jupiter.api.Test)

Example 28 with FieldConfigSlider

use of com.sldeditor.ui.detail.config.FieldConfigSlider in project sldeditor by robward-scisys.

the class FieldConfigSliderTest method testGenerateExpression.

/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigSlider#generateExpression()}. Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSlider#populateExpression(java.lang.Object,
 * org.opengis.filter.expression.Expression)}. Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigSlider#populateField(java.lang.Double)}. Test
 * method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigSlider#setTestValue(com.sldeditor.ui.detail.config.FieldId,
 * double)}. Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigSlider#getDoubleValue()}.
 */
@Test
public void testGenerateExpression() {
    boolean valueOnly = true;
    FieldConfigSlider field = new FieldConfigSlider(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly, false));
    double defaultDefaultValue = 0.5;
    double expectedValue = 1.0;
    field.populateField(expectedValue);
    double actualValue = field.getDoubleValue();
    assertTrue(Math.abs(actualValue - defaultDefaultValue) < 0.001);
    field.setTestValue(null, expectedValue);
    actualValue = field.getDoubleValue();
    assertTrue(Math.abs(actualValue - defaultDefaultValue) < 0.001);
    field.populateExpression(null);
    actualValue = field.getDoubleValue();
    assertTrue(Math.abs(actualValue - defaultDefaultValue) < 0.001);
    field.createUI();
    field.populateField(expectedValue);
    actualValue = field.getDoubleValue();
    assertTrue(Math.abs(actualValue - expectedValue) < 0.001);
    double expectedValue2 = 0.14;
    field.setTestValue(null, expectedValue2);
    actualValue = field.getDoubleValue();
    assertTrue(Math.abs(actualValue - expectedValue2) < 0.001);
    Integer expectedValue3a = Integer.valueOf(1);
    field.populateExpression(expectedValue3a);
    actualValue = field.getDoubleValue();
    assertTrue(Math.abs(actualValue - expectedValue3a) < 0.001);
    Double expectedValue3c = Double.valueOf(0.4);
    field.populateExpression(expectedValue3c);
    actualValue = field.getDoubleValue();
    assertTrue(Math.abs(actualValue - expectedValue3c) < 0.001);
    double expectedValue3d = 0.87;
    String expectedValue3dString = String.valueOf(expectedValue3d);
    field.populateExpression(expectedValue3dString);
    actualValue = field.getDoubleValue();
    assertTrue(Math.abs(actualValue - expectedValue3d) < 0.001);
}
Also used : FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) Test(org.junit.jupiter.api.Test)

Aggregations

FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)28 Test (org.junit.jupiter.api.Test)25 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)22 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)17 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)15 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)14 FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)14 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)13 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)12 ColourFieldConfig (com.sldeditor.ui.detail.ColourFieldConfig)10 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)9 StyleBuilder (org.geotools.styling.StyleBuilder)9 Mark (org.geotools.styling.Mark)7 FieldConfigMarker (com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker)6 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)5 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)5 NamedLayer (org.geotools.styling.NamedLayer)5 Rule (org.geotools.styling.Rule)5 Style (org.geotools.styling.Style)5 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)5