Search in sources :

Example 16 with FieldConfigInteger

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

the class FieldConfigPopulationTest method testInteger.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateIntegerField(com.sldeditor.ui.detail.config.FieldId, java.lang.Integer)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getInteger(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getInteger(com.sldeditor.common.xml.ui.FieldIdEnum)}.
 */
@Test
public void testInteger() {
    FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
    FieldConfigInteger intField = new FieldConfigInteger(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
    intField.createUI();
    fieldConfigManager.add(fieldId, intField);
    FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
    int expectedValue = 1256;
    obj.populateIntegerField(fieldId, expectedValue);
    assertEquals(expectedValue, obj.getInteger(fieldId));
    // This shouldn't work as it does not know about the field
    FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
    assertEquals(0, obj.getInteger(wrongFieldEnum));
    // Try with null - should revert to default value (0.0)
    obj.populateIntegerField(fieldId, null);
    assertEquals(0, obj.getInteger(fieldId));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigPopulation(com.sldeditor.ui.detail.config.FieldConfigPopulation) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) Test(org.junit.Test)

Aggregations

FieldConfigInteger (com.sldeditor.ui.detail.config.FieldConfigInteger)16 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)14 Test (org.junit.Test)11 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)4 Geometry (com.vividsolutions.jts.geom.Geometry)4 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)3 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)3 FieldConfigPopulation (com.sldeditor.ui.detail.config.FieldConfigPopulation)3 FieldConfigBoolean (com.sldeditor.ui.detail.config.FieldConfigBoolean)2 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)2 BoxLayout (javax.swing.BoxLayout)2 LiteralExpressionImpl (org.geotools.filter.LiteralExpressionImpl)2 FeatureTypeConstraint (org.geotools.styling.FeatureTypeConstraint)2 Expression (org.opengis.filter.expression.Expression)2 ColourRamp (com.sldeditor.colourramp.ColourRamp)1 ColourRampConfigPanel (com.sldeditor.colourramp.ColourRampConfigPanel)1 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 XMLTwoColourRamp (com.sldeditor.common.xml.ui.XMLTwoColourRamp)1 Disjoint (com.sldeditor.filter.v2.function.geometry.Disjoint)1 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)1