Search in sources :

Example 1 with PolygonFillDetails

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

the class PolygonFillDetailsTest method testFillDetailsPolygon.

/**
 * Test method for {@link com.sldeditor.ui.detail.PolygonFillDetailsTest#PolygonFillDetailsTest(java.lang.Class, com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 */
@Test
public void testFillDetailsPolygon() {
    PolygonFillDetails panel = new PolygonFillDetails();
    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);
    PolygonSymbolizer 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);
    SelectedSymbol.getInstance().setSymbolizer(symbolizer);
    panel.populate(SelectedSymbol.getInstance());
    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);
    double expectedAngle = 14.5;
    FieldConfigDouble angleField = (FieldConfigDouble) fieldDataManager.get(FieldIdEnum.ANGLE);
    angleField.populateField(expectedAngle);
    FieldConfigSlider opacityField = (FieldConfigSlider) fieldDataManager.get(FieldIdEnum.OVERALL_OPACITY);
    double opacity = 0.15;
    opacityField.populateField(opacity);
    panel.dataChanged(FieldIdEnum.UNKNOWN);
    double actualValue = angleField.getDoubleValue();
    assertTrue(Math.abs(actualValue - expectedAngle) < 0.01);
    assertTrue(panel.isDataPresent());
    actualValue = opacityField.getDoubleValue();
    assertTrue(Math.abs(actualValue - opacity) < 0.01);
    // Reset to default value
    panel.preLoadSymbol();
    actualValue = angleField.getDoubleValue();
    assertTrue(Math.abs(actualValue - 0.0) < 0.01);
    actualValue = opacityField.getDoubleValue();
    assertTrue(Math.abs(actualValue - 1.0) < 0.01);
}
Also used : PolygonFillDetails(com.sldeditor.ui.detail.PolygonFillDetails) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Aggregations

GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)1 PolygonFillDetails (com.sldeditor.ui.detail.PolygonFillDetails)1 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)1 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)1 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)1 NamedLayer (org.geotools.styling.NamedLayer)1 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)1 Rule (org.geotools.styling.Rule)1 Style (org.geotools.styling.Style)1 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)1 Test (org.junit.Test)1