Search in sources :

Example 1 with FieldConfigGeometry

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

the class ExtractGeometryFieldTest method testGetGeometryField.

/**
 * Test method for {@link com.sldeditor.ui.detail.ExtractGeometryField#getGeometryField(com.sldeditor.ui.detail.config.FieldConfigPopulation)}.
 */
@Test
public void testGetGeometryField() {
    assertNull(ExtractGeometryField.getGeometryField(null));
    FieldIdEnum fieldId = FieldIdEnum.GEOMETRY;
    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(Geometry.class);
    FieldConfigGeometry geometryField = new FieldConfigGeometry(new FieldConfigCommonData(Geometry.class, fieldId, "label", true), "button");
    geometryField.createUI();
    fieldConfigManager.add(fieldId, geometryField);
    FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
    // Try valid geometry field name
    geometryField.populateField("ValidTestField");
    Expression actualExpression = ExtractGeometryField.getGeometryField(obj);
    assertNotNull(actualExpression);
    // Try invalid geometry field name
    geometryField.populateField("");
    actualExpression = ExtractGeometryField.getGeometryField(obj);
    assertNull(actualExpression);
    // Try invalid geometry field name
    geometryField.populateField("    ");
    actualExpression = ExtractGeometryField.getGeometryField(obj);
    assertNull(actualExpression);
    // Try when there is no geometry field
    obj = new FieldConfigPopulation(fieldConfigManager);
    actualExpression = ExtractGeometryField.getGeometryField(obj);
    assertNull(actualExpression);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigGeometry(com.sldeditor.ui.detail.config.FieldConfigGeometry) FieldConfigPopulation(com.sldeditor.ui.detail.config.FieldConfigPopulation) FieldConfigGeometry(com.sldeditor.ui.detail.config.FieldConfigGeometry) Expression(org.opengis.filter.expression.Expression) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 2 with FieldConfigGeometry

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

the class FieldConfigGeometryTest method testGenerateExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#generateExpression()}. Test method
 * for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#populateField(java.lang.String)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#getStringValue()}.
 */
@Test
public void testGenerateExpression() {
    FieldConfigGeometry field = new FieldConfigGeometry(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", true), "button text");
    field.createUI();
    field.setTestValue(FieldIdEnum.UNKNOWN, (String) null);
    field.populateField((String) null);
    field.populateExpression((String) null);
    String wktPoint = "POINT( 48.44 -123.37)";
    field.populateField(wktPoint);
    String actualValue = field.getStringValue();
    assertTrue(wktPoint.compareTo(actualValue) == 0);
    String wktPolygon = "POLYGON((20 10, 30 0, 40 10, 30 20, 20 10))";
    field.setTestValue(FieldIdEnum.UNKNOWN, wktPolygon);
    actualValue = field.getStringValue();
    assertTrue(wktPolygon.compareTo(actualValue) == 0);
    String wktLine = "LINESTRING(0 2, 2 0, 8 6)";
    field.populateExpression(wktLine);
    actualValue = field.getStringValue();
    assertTrue(wktLine.compareTo(actualValue) == 0);
}
Also used : FieldConfigGeometry(com.sldeditor.ui.detail.config.FieldConfigGeometry) Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigGeometry(com.sldeditor.ui.detail.config.FieldConfigGeometry) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 3 with FieldConfigGeometry

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

the class FieldConfigGeometryTest method testSetVisible.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#setVisible(boolean)}.
 */
@Test
public void testSetVisible() {
    boolean valueOnly = true;
    FieldConfigGeometry field = new FieldConfigGeometry(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly), "button text");
    boolean expectedValue = true;
    field.setVisible(expectedValue);
    field.createUI();
    field.setVisible(expectedValue);
    expectedValue = false;
    field.setVisible(expectedValue);
}
Also used : FieldConfigGeometry(com.sldeditor.ui.detail.config.FieldConfigGeometry) Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigGeometry(com.sldeditor.ui.detail.config.FieldConfigGeometry) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 4 with FieldConfigGeometry

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

the class FieldConfigGeometryTest method testCreateCopy.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#createCopy(com.sldeditor.ui.detail.config.FieldConfigBase)}.
 */
@Test
public void testCreateCopy() {
    boolean valueOnly = true;
    class TestFieldConfigGeometry extends FieldConfigGeometry {

        public TestFieldConfigGeometry(FieldConfigCommonData commonData, String buttonText) {
            super(commonData, buttonText);
        }

        public FieldConfigPopulate callCreateCopy(FieldConfigBase fieldConfigBase) {
            return createCopy(fieldConfigBase);
        }
    }
    TestFieldConfigGeometry field = new TestFieldConfigGeometry(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly), "button text");
    FieldConfigGeometry copy = (TestFieldConfigGeometry) field.callCreateCopy(null);
    assertNull(copy);
    copy = (FieldConfigGeometry) field.callCreateCopy(field);
    assertEquals(field.getFieldId(), copy.getFieldId());
    assertTrue(field.getLabel().compareTo(copy.getLabel()) == 0);
    assertEquals(field.isValueOnly(), copy.isValueOnly());
}
Also used : FieldConfigGeometry(com.sldeditor.ui.detail.config.FieldConfigGeometry) Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) FieldConfigGeometry(com.sldeditor.ui.detail.config.FieldConfigGeometry) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 5 with FieldConfigGeometry

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

the class FieldConfigGeometryTest method testRevertToDefaultValue.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#revertToDefaultValue()}. Test
 * method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#setDefaultValue(java.lang.String)}.
 */
@Test
public void testRevertToDefaultValue() {
    boolean valueOnly = true;
    FieldConfigGeometry field = new FieldConfigGeometry(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly), "button text");
    field.revertToDefaultValue();
    assertNull(field.getStringValue());
    field.createUI();
    field.createUI();
    field.revertToDefaultValue();
    String expectedDefaultValue = "default value";
    assertTrue(expectedDefaultValue.compareTo(field.getStringValue()) != 0);
    field.setDefaultValue(expectedDefaultValue);
    field.revertToDefaultValue();
    assertTrue(expectedDefaultValue.compareTo(field.getStringValue()) == 0);
}
Also used : FieldConfigGeometry(com.sldeditor.ui.detail.config.FieldConfigGeometry) Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigGeometry(com.sldeditor.ui.detail.config.FieldConfigGeometry) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Aggregations

FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)10 FieldConfigGeometry (com.sldeditor.ui.detail.config.FieldConfigGeometry)10 Geometry (com.vividsolutions.jts.geom.Geometry)10 Test (org.junit.Test)9 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)2 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)2 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 Disjoint (com.sldeditor.filter.v2.function.geometry.Disjoint)1 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)1 FieldConfigBoolean (com.sldeditor.ui.detail.config.FieldConfigBoolean)1 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)1 FieldConfigDate (com.sldeditor.ui.detail.config.FieldConfigDate)1 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)1 FieldConfigInteger (com.sldeditor.ui.detail.config.FieldConfigInteger)1 FieldConfigMapUnits (com.sldeditor.ui.detail.config.FieldConfigMapUnits)1 FieldConfigPopulation (com.sldeditor.ui.detail.config.FieldConfigPopulation)1 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)1 GroupConfig (com.sldeditor.ui.detail.config.base.GroupConfig)1 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)1 LineString (com.vividsolutions.jts.geom.LineString)1