Search in sources :

Example 16 with GraphicPanelFieldManager

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

the class RuleDetailsTest method testRuleDetails.

/**
 * Test method for {@link com.sldeditor.ui.detail.RuleDetails#RuleDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 * Test method for {@link com.sldeditor.ui.detail.RuleDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
 * Test method for {@link com.sldeditor.ui.detail.RuleDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link com.sldeditor.ui.detail.RuleDetails#getFieldDataManager()}.
 * Test method for {@link com.sldeditor.ui.detail.RuleDetails#isDataPresent()}.
 * Test method for {@link com.sldeditor.ui.detail.RuleDetails#preLoadSymbol()}.
 */
@Test
public void testRuleDetails() {
    RuleDetails panel = new RuleDetails();
    panel.populate(null);
    // Set up test data
    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    SelectedSymbol.getInstance().createNewSLD(sld);
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    String expectedNameLayerValue = "named layer test value";
    namedLayer.setName(expectedNameLayerValue);
    Style style = DefaultSymbols.createNewStyle();
    String expectedNameStyleValue = "style test value";
    style.setName(expectedNameStyleValue);
    namedLayer.addStyle(style);
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    String expectedNameFTSValue = "feature type style test value";
    fts.setName(expectedNameFTSValue);
    style.featureTypeStyles().add(fts);
    Rule rule = DefaultSymbols.createNewRule();
    String expectedNameValue = "rule test value";
    rule.setName(expectedNameValue);
    Symbolizer symbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
    rule.symbolizers().add(symbolizer);
    fts.rules().add(rule);
    sld.layers().add(namedLayer);
    SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyle(style);
    SelectedSymbol.getInstance().setFeatureTypeStyle(fts);
    SelectedSymbol.getInstance().setRule(rule);
    panel.populate(SelectedSymbol.getInstance());
    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);
    FieldConfigString filterField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.FILTER);
    String filterString = "STATE_ABBR >= 'B' AND STATE_ABBR <= 'O'";
    filterField.populateField(filterString);
    panel.dataChanged(null);
    FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
    String actualValue = nameField.getStringValue();
    assertTrue(expectedNameValue.compareTo(actualValue) == 0);
    assertTrue(panel.isDataPresent());
    // Reset to default value
    panel.preLoadSymbol();
    actualValue = nameField.getStringValue();
    assertTrue("".compareTo(actualValue) == 0);
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer) Symbolizer(org.geotools.styling.Symbolizer) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) RuleDetails(com.sldeditor.ui.detail.RuleDetails) Test(org.junit.Test)

Example 17 with GraphicPanelFieldManager

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

the class FieldConfigPopulationTest method testExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateField(com.sldeditor.ui.detail.config.FieldId, org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateField(com.sldeditor.common.xml.ui.FieldIdEnum, org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getExpression(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getExpression(com.sldeditor.common.xml.ui.FieldIdEnum)}.
 */
@Test
public void testExpression() {
    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;
    StyleBuilder styleBuilder = new StyleBuilder();
    Expression expression = styleBuilder.literalExpression(expectedValue);
    obj.populateField(fieldId, expression);
    LiteralExpressionImpl actualValue = (LiteralExpressionImpl) obj.getExpression(fieldId);
    assertEquals(expectedValue, ((Integer) actualValue.getValue()).intValue());
    actualValue = (LiteralExpressionImpl) obj.getExpression(fieldId);
    assertEquals(expectedValue, ((Integer) actualValue.getValue()).intValue());
    // This shouldn't work as it does not know about the field
    FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
    obj.populateField(wrongFieldEnum, expression);
    assertNull(obj.getExpression(wrongFieldEnum));
    // Try with null
    obj.populateField(fieldId, null);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigPopulation(com.sldeditor.ui.detail.config.FieldConfigPopulation) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) 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) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) Test(org.junit.Test)

Example 18 with GraphicPanelFieldManager

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

the class FieldConfigPopulationTest method testBoolean.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateBooleanField(com.sldeditor.ui.detail.config.FieldId, java.lang.Boolean)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateBooleanField(com.sldeditor.common.xml.ui.FieldIdEnum, java.lang.Boolean)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getBoolean(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getBoolean(com.sldeditor.common.xml.ui.FieldIdEnum)}.
 */
@Test
public void testBoolean() {
    FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
    FieldConfigBoolean booleanField = new FieldConfigBoolean(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
    booleanField.createUI();
    fieldConfigManager.add(fieldId, booleanField);
    FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
    Boolean expectedValue = Boolean.TRUE;
    obj.populateBooleanField(fieldId, expectedValue);
    assertEquals(expectedValue.booleanValue(), obj.getBoolean(fieldId));
    // This shouldn't work as it does not know about the field
    FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
    assertFalse(obj.getBoolean(wrongFieldEnum));
    // Try with null - should revert to default value (false)
    obj.populateBooleanField(fieldId, null);
    assertFalse(obj.getBoolean(fieldId));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigPopulation(com.sldeditor.ui.detail.config.FieldConfigPopulation) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigBoolean(com.sldeditor.ui.detail.config.FieldConfigBoolean) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) FieldConfigBoolean(com.sldeditor.ui.detail.config.FieldConfigBoolean) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 19 with GraphicPanelFieldManager

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

the class FieldConfigPopulationTest method testComboBox.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateComboBoxField(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateComboBoxField(com.sldeditor.common.xml.ui.FieldIdEnum, java.lang.String)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getComboBox(com.sldeditor.common.xml.ui.FieldIdEnum)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getComboBox(com.sldeditor.ui.detail.config.FieldId)}.
 */
@Test
public void testComboBox() {
    SymbolTypeConfig s1 = new SymbolTypeConfig(null);
    s1.addOption("key1", "Value 1");
    s1.addOption("key2", "Value 2");
    s1.addOption("key3", "Value 3");
    s1.addField(FieldIdEnum.ANCHOR_POINT_H, true);
    s1.addField(FieldIdEnum.ANCHOR_POINT_V, false);
    FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
    List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
    configList.add(s1);
    FieldConfigEnum enumField = new FieldConfigEnum(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
    enumField.addConfig(configList);
    enumField.createUI();
    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
    fieldConfigManager.add(fieldId, enumField);
    FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
    String expectedValue = "key2";
    obj.populateComboBoxField(fieldId, expectedValue);
    assertTrue(expectedValue.compareTo(obj.getComboBox(fieldId).getKey()) == 0);
    // This shouldn't work as it does not know about the field
    FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
    assertNull(obj.getComboBox(wrongFieldEnum));
    // Try with null - should revert to default value (first enum item)
    obj.populateComboBoxField(fieldId, null);
    expectedValue = "key1";
    assertTrue(expectedValue.compareTo(obj.getComboBox(fieldId).getKey()) == 0);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigPopulation(com.sldeditor.ui.detail.config.FieldConfigPopulation) FieldConfigEnum(com.sldeditor.ui.detail.config.FieldConfigEnum) ArrayList(java.util.ArrayList) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) SymbolTypeConfig(com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 20 with GraphicPanelFieldManager

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

the class FieldConfigPopulationTest method testGetFieldConfig.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getFieldConfig(com.sldeditor.ui.detail.config.FieldId)}.
 */
@Test
public void testGetFieldConfig() {
    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);
    assertNotNull(obj.getFieldConfig(fieldId));
    FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
    assertNull(obj.getFieldConfig(wrongFieldEnum));
}
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) Test(org.junit.Test)

Aggregations

GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)53 Test (org.junit.Test)51 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)34 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)33 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)23 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)18 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)17 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)16 StyleBuilder (org.geotools.styling.StyleBuilder)16 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)16 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)15 NamedLayer (org.geotools.styling.NamedLayer)15 FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)14 Style (org.geotools.styling.Style)14 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)13 Rule (org.geotools.styling.Rule)13 ColourFieldConfig (com.sldeditor.ui.detail.ColourFieldConfig)12 FieldConfigPopulation (com.sldeditor.ui.detail.config.FieldConfigPopulation)12 Geometry (com.vividsolutions.jts.geom.Geometry)12 StrokeDetails (com.sldeditor.ui.detail.StrokeDetails)9