Search in sources :

Example 6 with FieldConfigBoundingBox

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

the class FieldConfigBoundingBoxTest method testRevertToDefaultValue.

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

Example 7 with FieldConfigBoundingBox

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

the class FieldConfigBoundingBoxTest method testGenerateExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#generateExpression()}. Test
 * method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#populateField(org.geotools.geometry.jts.ReferencedEnvelope)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#setTestValue(com.sldeditor.ui.detail.config.FieldId, boolean)}.
 */
@Test
public void testGenerateExpression() {
    boolean valueOnly = true;
    class TestFieldConfigBoundingBox extends FieldConfigBoundingBox {

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

        public Expression callGenerateExpression() {
            return generateExpression();
        }
    }
    TestFieldConfigBoundingBox field = new TestFieldConfigBoundingBox(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
    Expression actualExpression = field.callGenerateExpression();
    assertNotNull(actualExpression);
    // Try string values - erroneous
    field.createUI();
    field.populateExpression("");
    CoordinateReferenceSystem crs = CoordManager.getInstance().getWGS84();
    ReferencedEnvelope envelope1 = new ReferencedEnvelope(0.0, 1.0, 51.0, 51.1, crs);
    field.populateExpression(envelope1);
    actualExpression = field.callGenerateExpression();
    assertTrue(envelope1.toString().compareTo(actualExpression.toString()) == 0);
    ReferencedEnvelope envelope2 = new ReferencedEnvelope(-10.0, -4.0, 31.0, 45.11, crs);
    field.setTestValue(null, envelope2);
    actualExpression = field.callGenerateExpression();
    assertTrue(envelope2.toString().compareTo(actualExpression.toString()) == 0);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) ReferencedEnvelope(org.geotools.geometry.jts.ReferencedEnvelope) Expression(org.opengis.filter.expression.Expression) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) FieldConfigBoundingBox(com.sldeditor.ui.detail.config.FieldConfigBoundingBox) Test(org.junit.Test)

Aggregations

FieldConfigBoundingBox (com.sldeditor.ui.detail.config.FieldConfigBoundingBox)7 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)7 Geometry (com.vividsolutions.jts.geom.Geometry)7 Test (org.junit.Test)7 ReferencedEnvelope (org.geotools.geometry.jts.ReferencedEnvelope)2 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)2 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)1 Expression (org.opengis.filter.expression.Expression)1