Search in sources :

Example 1 with FieldConfigBoundingBox

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

the class FieldConfigBoundingBoxTest method testSetEnabled.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#internal_setEnabled(boolean)}.
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#isEnabled()}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#createUI(javax.swing.Box)}.
 */
@Test
public void testSetEnabled() {
    // Value only, no attribute/expression dropdown
    boolean valueOnly = true;
    FieldConfigBoundingBox field = new FieldConfigBoundingBox(new FieldConfigCommonData(Geometry.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;
    FieldConfigBoundingBox field2 = new FieldConfigBoundingBox(new FieldConfigCommonData(Geometry.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 : 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 2 with FieldConfigBoundingBox

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

the class FieldConfigBoundingBoxTest method testAttributeSelection.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#attributeSelection(java.lang.String)}.
 */
@Test
public void testAttributeSelection() {
    boolean valueOnly = true;
    FieldConfigBoundingBox field = new FieldConfigBoundingBox(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
    field.attributeSelection(null);
// Does nothing
}
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 3 with FieldConfigBoundingBox

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

the class FieldConfigBoundingBoxTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    FieldConfigBoundingBox field = new FieldConfigBoundingBox(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", false));
    field.undoAction(null);
    field.redoAction(null);
    field.createUI();
    field.createUI();
    CoordinateReferenceSystem crs = CoordManager.getInstance().getWGS84();
    ReferencedEnvelope envelope1 = new ReferencedEnvelope(0.0, 1.0, 51.0, 51.1, crs);
    field.populateField(envelope1);
    assertTrue(envelope1.toString().compareTo(field.getStringValue()) == 0);
    ReferencedEnvelope envelope2 = new ReferencedEnvelope(-10.0, -4.0, 31.0, 45.11, crs);
    field.populateField(envelope2);
    assertTrue(envelope2.toString().compareTo(field.getStringValue()) == 0);
    UndoManager.getInstance().undo();
    String actualValue = field.getStringValue();
    assertTrue(actualValue.compareTo(envelope1.toString()) == 0);
    UndoManager.getInstance().redo();
    actualValue = field.getStringValue();
    assertTrue(actualValue.compareTo(envelope2.toString()) == 0);
    field.undoAction(null);
    field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
    field.redoAction(null);
    field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) UndoEvent(com.sldeditor.common.undo.UndoEvent) ReferencedEnvelope(org.geotools.geometry.jts.ReferencedEnvelope) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) FieldConfigBoundingBox(com.sldeditor.ui.detail.config.FieldConfigBoundingBox) Test(org.junit.Test)

Example 4 with FieldConfigBoundingBox

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

the class FieldConfigBoundingBoxTest method testSetVisible.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#setVisible(boolean)}.
 */
@Test
public void testSetVisible() {
    boolean valueOnly = true;
    FieldConfigBoundingBox field = new FieldConfigBoundingBox(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
    boolean expectedValue = true;
    field.setVisible(expectedValue);
    field.createUI();
    field.setVisible(expectedValue);
    expectedValue = false;
    field.setVisible(expectedValue);
}
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 5 with FieldConfigBoundingBox

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

the class FieldConfigBoundingBoxTest method testCreateCopy.

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

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

        public FieldConfigPopulate callCreateCopy(FieldConfigBase fieldConfigBase) {
            return createCopy(fieldConfigBase);
        }
    }
    TestFieldConfigBoundingBox field = new TestFieldConfigBoundingBox(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
    FieldConfigBoundingBox copy = (FieldConfigBoundingBox) field.callCreateCopy(null);
    assertNull(copy);
    copy = (FieldConfigBoundingBox) field.callCreateCopy(field);
    assertEquals(field.getFieldId(), copy.getFieldId());
    assertTrue(field.getLabel().compareTo(copy.getLabel()) == 0);
    assertEquals(field.isValueOnly(), copy.isValueOnly());
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) 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