Search in sources :

Example 1 with FieldConfigRange

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

the class FieldConfigRangeTest method testAttributeSelection.

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

Example 2 with FieldConfigRange

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

the class FieldConfigRangeTest method testUndoAction.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigRange#undoAction(com.sldeditor.common.undo.UndoInterface)}. Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigRange#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@SuppressWarnings("rawtypes")
@Test
public void testUndoAction() {
    boolean valueOnly = true;
    FieldConfigRange field = new FieldConfigRange(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly), org.jaitools.numeric.Range.class);
    field.undoAction(null);
    field.redoAction(null);
    Range expectedValue1 = Range.create(3.0, false, 11.0, false);
    field.createUI();
    field.populateField(expectedValue1);
    Range actualValue = field.getRange();
    assertTrue(Math.abs(actualValue.getMin().doubleValue() - expectedValue1.getMin().doubleValue()) < 0.001);
    assertEquals(actualValue.isMinIncluded(), expectedValue1.isMinIncluded());
    assertTrue(Math.abs(actualValue.getMax().doubleValue() - expectedValue1.getMax().doubleValue()) < 0.001);
    assertEquals(actualValue.isMaxIncluded(), expectedValue1.isMaxIncluded());
    Range expectedValue2 = Range.create(23.0, true, 51.0, false);
    field.populateField(expectedValue2);
    actualValue = field.getRange();
    assertTrue(Math.abs(actualValue.getMin().doubleValue() - expectedValue2.getMin().doubleValue()) < 0.001);
    assertEquals(actualValue.isMinIncluded(), expectedValue2.isMinIncluded());
    assertTrue(Math.abs(actualValue.getMax().doubleValue() - expectedValue2.getMax().doubleValue()) < 0.001);
    assertEquals(actualValue.isMaxIncluded(), expectedValue2.isMaxIncluded());
    UndoManager.getInstance().undo();
    actualValue = field.getRange();
    assertTrue(Math.abs(actualValue.getMin().doubleValue() - expectedValue1.getMin().doubleValue()) < 0.001);
    assertEquals(actualValue.isMinIncluded(), expectedValue1.isMinIncluded());
    assertTrue(Math.abs(actualValue.getMax().doubleValue() - expectedValue1.getMax().doubleValue()) < 0.001);
    assertEquals(actualValue.isMaxIncluded(), expectedValue1.isMaxIncluded());
    UndoManager.getInstance().redo();
    actualValue = field.getRange();
    assertTrue(Math.abs(actualValue.getMin().doubleValue() - expectedValue2.getMin().doubleValue()) < 0.001);
    assertEquals(actualValue.isMinIncluded(), expectedValue2.isMinIncluded());
    assertTrue(Math.abs(actualValue.getMax().doubleValue() - expectedValue2.getMax().doubleValue()) < 0.001);
    assertEquals(actualValue.isMaxIncluded(), expectedValue2.isMaxIncluded());
    // 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) FieldConfigRange(com.sldeditor.ui.detail.config.FieldConfigRange) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Range(org.jaitools.numeric.Range) FieldConfigRange(com.sldeditor.ui.detail.config.FieldConfigRange) Test(org.junit.Test)

Example 3 with FieldConfigRange

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

the class FieldConfigRangeTest method testSetEnabled.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigRange#internal_setEnabled(boolean)}. Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigRange#isEnabled()}. Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigRange#createUI(javax.swing.Box)}.
 */
@Test
public void testSetEnabled() {
    // Value only, no attribute/expression dropdown
    boolean valueOnly = true;
    FieldConfigRange field = new FieldConfigRange(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly), org.jaitools.numeric.Range.class);
    // 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;
    FieldConfigRange field2 = new FieldConfigRange(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly), org.jaitools.numeric.Range.class);
    // 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);
    assertEquals(expectedValue, field2.isEnabled());
}
Also used : FieldConfigRange(com.sldeditor.ui.detail.config.FieldConfigRange) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 4 with FieldConfigRange

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

the class FieldConfigRangeTest method testSetVisible.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigRange#setVisible(boolean)}.
 */
@Test
public void testSetVisible() {
    boolean valueOnly = true;
    FieldConfigRange field = new FieldConfigRange(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly), org.jaitools.numeric.Range.class);
    boolean expectedValue = true;
    field.setVisible(expectedValue);
    field.createUI();
    field.setVisible(expectedValue);
    expectedValue = false;
    field.setVisible(expectedValue);
}
Also used : FieldConfigRange(com.sldeditor.ui.detail.config.FieldConfigRange) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 5 with FieldConfigRange

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

the class FieldConfigRangeTest method testGenerateExpression.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigRange#generateExpression()}. Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigRange#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}. Test
 * method for {@link com.sldeditor.ui.detail.config.FieldConfigRange#populateField(java.lang.Double)}. Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigRange#setTestValue(com.sldeditor.ui.detail.config.FieldId, double)}. Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigRange#getDoubleValue()}.
 */
@SuppressWarnings("rawtypes")
@Test
public void testGenerateExpression() {
    boolean valueOnly = true;
    FieldConfigRange field = new FieldConfigRange(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly), org.jaitools.numeric.Range.class);
    field.createUI();
    Range expectedValue = Range.create(3.0, false, 11.0, false);
    field.populateField(expectedValue);
    Range actualValueJAITools = field.getRange();
    assertTrue(Math.abs(actualValueJAITools.getMin().doubleValue() - expectedValue.getMin().doubleValue()) < 0.001);
    assertEquals(actualValueJAITools.isMinIncluded(), expectedValue.isMinIncluded());
    assertTrue(Math.abs(actualValueJAITools.getMax().doubleValue() - expectedValue.getMax().doubleValue()) < 0.001);
    assertEquals(actualValueJAITools.isMaxIncluded(), expectedValue.isMaxIncluded());
    field.populateExpression(null);
    actualValueJAITools = field.getRange();
    Range expectedDefaultValue = Range.create(0.0, true, 1.0, true);
    assertTrue(Math.abs(actualValueJAITools.getMin().doubleValue() - expectedDefaultValue.getMin().doubleValue()) < 0.001);
    assertEquals(actualValueJAITools.isMinIncluded(), expectedDefaultValue.isMinIncluded());
    assertTrue(Math.abs(actualValueJAITools.getMax().doubleValue() - expectedDefaultValue.getMax().doubleValue()) < 0.001);
    assertEquals(actualValueJAITools.isMaxIncluded(), expectedDefaultValue.isMaxIncluded());
    // Try using it.geosolutions.jaiext.range.Range
    field = new FieldConfigRange(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly), it.geosolutions.jaiext.range.Range.class);
    field.createUI();
    field.populateField(expectedValue);
    Range actualValueJAIExt = field.getRange();
    assertTrue(Math.abs(actualValueJAIExt.getMin().doubleValue() - expectedValue.getMin().doubleValue()) < 0.001);
    assertEquals(actualValueJAIExt.isMinIncluded(), expectedValue.isMinIncluded());
    assertTrue(Math.abs(actualValueJAIExt.getMax().doubleValue() - expectedValue.getMax().doubleValue()) < 0.001);
    assertEquals(actualValueJAIExt.isMaxIncluded(), expectedValue.isMaxIncluded());
    Expression rangeJAIToolsExpression = field.getExpression();
    field.populate(rangeJAIToolsExpression);
    actualValueJAITools = field.getRange();
    assertTrue(Math.abs(actualValueJAIExt.getMin().doubleValue() - expectedValue.getMin().doubleValue()) < 0.001);
    assertEquals(actualValueJAIExt.isMinIncluded(), expectedValue.isMinIncluded());
    assertTrue(Math.abs(actualValueJAIExt.getMax().doubleValue() - expectedValue.getMax().doubleValue()) < 0.001);
    assertEquals(actualValueJAIExt.isMaxIncluded(), expectedValue.isMaxIncluded());
}
Also used : FieldConfigRange(com.sldeditor.ui.detail.config.FieldConfigRange) Expression(org.opengis.filter.expression.Expression) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Range(org.jaitools.numeric.Range) FieldConfigRange(com.sldeditor.ui.detail.config.FieldConfigRange) Test(org.junit.Test)

Aggregations

FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)8 FieldConfigRange (com.sldeditor.ui.detail.config.FieldConfigRange)8 Test (org.junit.Test)8 Range (org.jaitools.numeric.Range)4 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)1 Expression (org.opengis.filter.expression.Expression)1