Search in sources :

Example 11 with FieldConfigString

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

the class PolygonSymbolizerDetailsTest method testPolygonSymbolizerDetails.

/**
 * Test method for {@link com.sldeditor.ui.detail.PolygonSymbolizerDetails#PolygonSymbolizerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 * Test method for {@link com.sldeditor.ui.detail.PolygonSymbolizerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
 * Test method for {@link com.sldeditor.ui.detail.PolygonSymbolizerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link com.sldeditor.ui.detail.PolygonSymbolizerDetails#getFieldDataManager()}.
 * Test method for {@link com.sldeditor.ui.detail.PolygonSymbolizerDetails#isDataPresent()}.
 * Test method for {@link com.sldeditor.ui.detail.PolygonSymbolizerDetails#preLoadSymbol()}.
 */
@Test
public void testPolygonSymbolizerDetails() {
    PolygonSymbolizerDetails panel = new PolygonSymbolizerDetails();
    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 expectedRuleValue = "rule test value";
    rule.setName(expectedRuleValue);
    PolygonSymbolizer symbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
    String expectedNameValue = "symbolizer test value";
    symbolizer.setName(expectedNameValue);
    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);
    SelectedSymbol.getInstance().setSymbolizer(symbolizer);
    panel.populate(SelectedSymbol.getInstance());
    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);
    panel.dataChanged(null);
    FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
    assertNull(nameField);
    assertTrue(panel.isDataPresent());
    // Reset to default value
    panel.preLoadSymbol();
}
Also used : PolygonSymbolizerDetails(com.sldeditor.ui.detail.PolygonSymbolizerDetails) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) 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) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 12 with FieldConfigString

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

the class RasterSymbolizerDetailsTest method testRasterSymbolizerDetailsColourChannel.

/**
 * Test method for {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#RasterSymbolizerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 * Test method for {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#isDataPresent()}.
 * Test method for {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
 * Test method for {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#getFieldDataManager()}.
 * Test method for {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#preLoadSymbol()}.
 */
@Test
public void testRasterSymbolizerDetailsColourChannel() {
    RasterSymbolizerDetails panel = new RasterSymbolizerDetails();
    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 expectedRuleValue = "rule test value";
    rule.setName(expectedRuleValue);
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    ContrastEnhancement contrastEnhancement = (ContrastEnhancement) styleFactory.contrastEnhancement(ff.literal(.5), "ramp");
    SelectedChannelType redChannel = styleFactory.createSelectedChannelType("red", contrastEnhancement);
    SelectedChannelType greenChannel = styleFactory.createSelectedChannelType("green", contrastEnhancement);
    SelectedChannelType blueChannel = styleFactory.createSelectedChannelType("blue", contrastEnhancement);
    SelectedChannelType[] channels = new SelectedChannelType[3];
    channels[0] = redChannel;
    channels[1] = greenChannel;
    channels[2] = blueChannel;
    RasterSymbolizer symbolizer = DefaultSymbols.createDefaultRasterSymbolizer();
    symbolizer.setChannelSelection(styleFactory.createChannelSelection(channels));
    String expectedNameValue = "symbolizer test value";
    symbolizer.setName(expectedNameValue);
    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);
    SelectedSymbol.getInstance().setSymbolizer(symbolizer);
    panel.populate(SelectedSymbol.getInstance());
    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);
    panel.dataChanged(null);
    FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
    assertNull(nameField);
    assertTrue(panel.isDataPresent());
    // Reset to default value
    panel.preLoadSymbol();
}
Also used : FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) RasterSymbolizerDetails(com.sldeditor.ui.detail.RasterSymbolizerDetails) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FilterFactory(org.opengis.filter.FilterFactory) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) SelectedChannelType(org.geotools.styling.SelectedChannelType) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) ContrastEnhancement(org.geotools.styling.ContrastEnhancement) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer) Test(org.junit.Test)

Example 13 with FieldConfigString

use of com.sldeditor.ui.detail.config.FieldConfigString 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 14 with FieldConfigString

use of com.sldeditor.ui.detail.config.FieldConfigString 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 15 with FieldConfigString

use of com.sldeditor.ui.detail.config.FieldConfigString 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)

Aggregations

FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)37 Test (org.junit.Test)32 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)21 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)20 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)13 NamedLayer (org.geotools.styling.NamedLayer)12 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)11 Style (org.geotools.styling.Style)11 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)10 Rule (org.geotools.styling.Rule)10 StrokeDetails (com.sldeditor.ui.detail.StrokeDetails)8 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)5 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)4 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)3 Geometry (com.vividsolutions.jts.geom.Geometry)3 GroupIdEnum (com.sldeditor.common.xml.ui.GroupIdEnum)2 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)2 RasterSymbolizerDetails (com.sldeditor.ui.detail.RasterSymbolizerDetails)2 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)2 FieldConfigPopulation (com.sldeditor.ui.detail.config.FieldConfigPopulation)2