Search in sources :

Example 6 with FieldConfigPopulation

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

the class FieldConfigPopulationTest method testString.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateTextField(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateTextField(com.sldeditor.common.xml.ui.FieldIdEnum, java.lang.String)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getText(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getText(com.sldeditor.common.xml.ui.FieldIdEnum)}.
 */
@Test
public void testString() {
    FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
    FieldConfigString stringField = new FieldConfigString(new FieldConfigCommonData(Geometry.class, fieldId, "label", true), "button text");
    stringField.createUI();
    fieldConfigManager.add(fieldId, stringField);
    FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
    String expectedValue = "test string";
    obj.populateTextField(fieldId, expectedValue);
    assertTrue(expectedValue.compareTo(obj.getText(fieldId)) == 0);
    // This shouldn't work as it does not know about the field
    FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
    assertTrue("".compareTo(obj.getText(wrongFieldEnum)) == 0);
    // Try with null
    obj.populateTextField(fieldId, null);
    obj.populateTextField(wrongFieldEnum, expectedValue);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigPopulation(com.sldeditor.ui.detail.config.FieldConfigPopulation) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 7 with FieldConfigPopulation

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

the class FieldConfigPopulationTest method testColourMap.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateColourMapField(com.sldeditor.common.xml.ui.FieldIdEnum, org.geotools.styling.ColorMap)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getColourMap(com.sldeditor.common.xml.ui.FieldIdEnum)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getColourMap(com.sldeditor.ui.detail.config.FieldId)}.
 */
@Test
public void testColourMap() {
    FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
    FieldConfigColourMap colourMapField = new FieldConfigColourMap(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
    colourMapField.createUI();
    fieldConfigManager.add(fieldId, colourMapField);
    ColorMap expectedValue = new ColorMapImpl();
    ColorMapEntry entry = new ColorMapEntryImpl();
    StyleBuilder styleBuilder = new StyleBuilder();
    entry.setColor(styleBuilder.colorExpression(Color.PINK));
    entry.setQuantity(styleBuilder.literalExpression(2.3));
    expectedValue.addColorMapEntry(entry);
    FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
    obj.populateColourMapField(fieldId, expectedValue);
    assertEquals(expectedValue.getColorMapEntries().length, obj.getColourMap(fieldId).getColorMapEntries().length);
    // This shouldn't work as it does not know about the field
    FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
    obj.populateColourMapField(wrongFieldEnum, expectedValue);
    assertNull(obj.getColourMap(wrongFieldEnum));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigPopulation(com.sldeditor.ui.detail.config.FieldConfigPopulation) ColorMapImpl(org.geotools.styling.ColorMapImpl) FieldConfigColourMap(com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap) ColorMapEntryImpl(org.geotools.styling.ColorMapEntryImpl) ColorMap(org.geotools.styling.ColorMap) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) StyleBuilder(org.geotools.styling.StyleBuilder) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) ColorMapEntry(org.geotools.styling.ColorMapEntry) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 8 with FieldConfigPopulation

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

the class FieldConfigPopulationTest method testIsTreeDataUpdated.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#isTreeDataUpdated()}. Test method
 * for {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#resetTreeDataUpdated()}.
 */
@Test
public void testIsTreeDataUpdated() {
    FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
    FieldConfigString stringField = new FieldConfigString(new FieldConfigCommonData(Geometry.class, fieldId, "label", true), "button text");
    stringField.createUI();
    fieldConfigManager.add(fieldId, stringField);
    FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
    assertFalse(obj.isTreeDataUpdated());
    // Set data
    String expectedValue = "test string";
    obj.populateTextField(fieldId, expectedValue);
    assertTrue(expectedValue.compareTo(obj.getText(fieldId)) == 0);
    assertFalse(obj.isTreeDataUpdated());
    // Simulate a key being pressed
    expectedValue = "test string1";
    stringField.populateField(expectedValue);
    // Data is different so flag should have changed
    assertTrue(expectedValue.compareTo(obj.getText(fieldId)) == 0);
    assertTrue(obj.isTreeDataUpdated());
    obj.resetTreeDataUpdated();
    assertFalse(obj.isTreeDataUpdated());
    // Populate the same data again and the flag should not have changed
    obj.populateTextField(fieldId, expectedValue);
    assertTrue(expectedValue.compareTo(obj.getText(fieldId)) == 0);
    assertFalse(obj.isTreeDataUpdated());
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigPopulation(com.sldeditor.ui.detail.config.FieldConfigPopulation) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 9 with FieldConfigPopulation

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

the class FieldConfigPopulationTest method testFont.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateFontField(com.sldeditor.common.xml.ui.FieldIdEnum, org.geotools.styling.Font)}.
 */
@Test
public void testFont() {
    FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
    FieldConfigFont fontField = new FieldConfigFont(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
    fontField.createUI();
    fieldConfigManager.add(fieldId, fontField);
    FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
    StyleBuilder styleBuilder = new StyleBuilder();
    Font expectedValue = styleBuilder.createFont(java.awt.Font.decode(null));
    obj.populateFontField(fieldId, expectedValue);
    // This shouldn't work as it does not know about the field
    FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
    obj.populateFontField(wrongFieldEnum, expectedValue);
}
Also used : FieldConfigFont(com.sldeditor.ui.detail.config.font.FieldConfigFont) Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigPopulation(com.sldeditor.ui.detail.config.FieldConfigPopulation) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) StyleBuilder(org.geotools.styling.StyleBuilder) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) FieldConfigFont(com.sldeditor.ui.detail.config.font.FieldConfigFont) Font(org.geotools.styling.Font) Test(org.junit.Test)

Example 10 with FieldConfigPopulation

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

the class FieldConfigPopulationTest method testColour.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateColourField(com.sldeditor.ui.detail.config.FieldId, org.opengis.filter.expression.Expression, org.opengis.filter.expression.Expression)}.
 */
@Test
public void testColour() {
    FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
    FieldConfigColour colourField = new FieldConfigColour(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
    colourField.createUI();
    colourField.createUI();
    fieldConfigManager.add(fieldId, colourField);
    FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
    StyleBuilder styleBuilder = new StyleBuilder();
    Expression colour = styleBuilder.colorExpression(Color.red);
    obj.populateColourField(fieldId, colour);
    FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
    obj.populateColourField(wrongFieldEnum, colour);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigPopulation(com.sldeditor.ui.detail.config.FieldConfigPopulation) Expression(org.opengis.filter.expression.Expression) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) StyleBuilder(org.geotools.styling.StyleBuilder) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Aggregations

FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)13 FieldConfigPopulation (com.sldeditor.ui.detail.config.FieldConfigPopulation)13 Test (org.junit.Test)13 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)12 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)12 Geometry (com.vividsolutions.jts.geom.Geometry)12 StyleBuilder (org.geotools.styling.StyleBuilder)4 FieldConfigInteger (com.sldeditor.ui.detail.config.FieldConfigInteger)3 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)3 FeatureTypeConstraint (org.geotools.styling.FeatureTypeConstraint)3 Expression (org.opengis.filter.expression.Expression)3 FieldConfigBoolean (com.sldeditor.ui.detail.config.FieldConfigBoolean)1 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)1 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)1 FieldConfigEnum (com.sldeditor.ui.detail.config.FieldConfigEnum)1 FieldConfigGeometry (com.sldeditor.ui.detail.config.FieldConfigGeometry)1 FieldConfigColourMap (com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap)1 FieldConfigFont (com.sldeditor.ui.detail.config.font.FieldConfigFont)1 SymbolTypeConfig (com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig)1 ArrayList (java.util.ArrayList)1