Search in sources :

Example 6 with FieldConfigDouble

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

the class FieldConfigDoubleTest method testAttributeSelection.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigDouble#attributeSelection(java.lang.String)}.
 */
@Test
public void testAttributeSelection() {
    boolean valueOnly = true;
    FieldConfigDouble field = new FieldConfigDouble(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly));
    field.attributeSelection(null);
    field.createUI();
    assertTrue(field.isEnabled());
    field.attributeSelection("test");
    assertFalse(field.isEnabled());
    field.attributeSelection(null);
    assertTrue(field.isEnabled());
}
Also used : FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) Test(org.junit.Test)

Example 7 with FieldConfigDouble

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

the class FieldConfigDoubleTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigDouble#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigDouble#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    boolean valueOnly = true;
    FieldConfigDouble field = new FieldConfigDouble(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly));
    field.undoAction(null);
    field.redoAction(null);
    double expectedValue1 = 13.4;
    field.createUI();
    field.populateField(expectedValue1);
    assertTrue(Math.abs(field.getDoubleValue() - expectedValue1) < 0.001);
    double expectedValue2 = 987.6;
    field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue2);
    assertTrue(Math.abs(field.getDoubleValue() - expectedValue2) < 0.001);
    UndoManager.getInstance().undo();
    assertTrue(Math.abs(field.getDoubleValue() - expectedValue1) < 0.001);
    UndoManager.getInstance().redo();
    assertTrue(Math.abs(field.getDoubleValue() - expectedValue2) < 0.001);
    // Increase the code coverage
    field.undoAction(null);
    field.redoAction(null);
    field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
    field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) Test(org.junit.Test)

Example 8 with FieldConfigDouble

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

the class FieldConfigDoubleTest method testSetEnabled.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigDouble#internal_setEnabled(boolean)}. Test
 * method for {@link com.sldeditor.ui.detail.config.FieldConfigDouble#isEnabled()}. Test method
 * for {@link com.sldeditor.ui.detail.config.FieldConfigDouble#createUI(javax.swing.Box)}.
 */
@Test
public void testSetEnabled() {
    // Value only, no attribute/expression dropdown
    boolean valueOnly = true;
    FieldConfigDouble field = new FieldConfigDouble(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly));
    // Text field will not have been created
    boolean expectedValue = true;
    field.internal_setEnabled(expectedValue);
    assertFalse(field.isEnabled());
    // Create text field
    field.createUI();
    assertEquals(expectedValue, field.isEnabled());
    expectedValue = false;
    field.internal_setEnabled(expectedValue);
    assertEquals(expectedValue, field.isEnabled());
    // Has attribute/expression dropdown
    valueOnly = false;
    FieldConfigDouble field2 = new FieldConfigDouble(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly));
    // Text field will not have been created
    expectedValue = true;
    field2.internal_setEnabled(expectedValue);
    assertFalse(field2.isEnabled());
    // Create text field
    field2.createUI();
    assertEquals(expectedValue, field2.isEnabled());
    expectedValue = false;
    field2.internal_setEnabled(expectedValue);
    // Actual value is coming from the attribute panel, not the text field
    assertEquals(!expectedValue, field2.isEnabled());
}
Also used : FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) Test(org.junit.Test)

Example 9 with FieldConfigDouble

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

the class FieldConfigDoubleTest method testRevertToDefaultValue.

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

Example 10 with FieldConfigDouble

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

the class FieldConfigDoubleTest method testSetConfig.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigDouble#testSetConfig(double, double, double, double)}.
 */
@Test
public void testSetConfig() {
    boolean valueOnly = true;
    FieldConfigDouble field = new FieldConfigDouble(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly));
    field.createUI();
    double minValue = 10.0;
    double maxValue = 20.0;
    double stepSize = 1.0;
    int noOfDecimalPlaces = 2;
    field.setConfig(minValue, maxValue, stepSize, noOfDecimalPlaces);
    // Should be set to the minimum value
    double expectedValue1 = 1.4;
    field.populateField(expectedValue1);
    assertTrue(Math.abs(field.getDoubleValue() - minValue) < 0.001);
    // Should be set to the maximum value
    double expectedValue2 = 41.4;
    field.populateField(expectedValue2);
    assertTrue(Math.abs(field.getDoubleValue() - maxValue) < 0.001);
}
Also used : FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) Test(org.junit.Test)

Aggregations

FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)18 Test (org.junit.Test)15 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)12 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)7 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)6 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)6 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 StrokeDetails (com.sldeditor.ui.detail.StrokeDetails)4 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)4 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)3 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)2 FieldConfigBoolean (com.sldeditor.ui.detail.config.FieldConfigBoolean)2 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)2 FieldConfigInteger (com.sldeditor.ui.detail.config.FieldConfigInteger)2 FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)2 Geometry (com.vividsolutions.jts.geom.Geometry)2