Search in sources :

Example 6 with PolygonSymbolizer

use of org.geotools.styling.PolygonSymbolizer in project sldeditor by robward-scisys.

the class SimpleFillSymbol method convert.

/* (non-Javadoc)
     * @see com.sldeditor.convert.esri.symbols.EsriSymbolInterface#convert(org.geotools.styling.Rule, com.google.gson.JsonElement, java.lang.String, int)
     */
@Override
public void convert(Rule rule, JsonElement element, String layerName, int transparency) {
    if (element == null)
        return;
    if (rule == null)
        return;
    JsonObject obj = element.getAsJsonObject();
    @SuppressWarnings("unused") int style = getInt(obj, CommonSymbolKeys.STYLE);
    List<Symbolizer> symbolizerList = rule.symbolizers();
    JsonElement jsonOutlineElement = obj.get(SimpleFillSymbolKeys.OUTLINE);
    List<Stroke> strokeList = SymbolManager.getInstance().getStrokeList(jsonOutlineElement);
    Stroke stroke = null;
    if (strokeList != null) {
        if (!strokeList.isEmpty()) {
            stroke = strokeList.get(0);
        }
    }
    Expression fillColour = getColour(obj.get(SimpleFillSymbolKeys.FILL_COLOUR));
    Fill fill = null;
    if (fillColour != null) {
        fill = styleFactory.createFill(fillColour, getTransparency(transparency));
    }
    PolygonSymbolizer polygonSymbolizer = styleFactory.createPolygonSymbolizer(stroke, fill, null);
    symbolizerList.add(polygonSymbolizer);
}
Also used : Stroke(org.geotools.styling.Stroke) Fill(org.geotools.styling.Fill) Expression(org.opengis.filter.expression.Expression) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) Symbolizer(org.geotools.styling.Symbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer)

Example 7 with PolygonSymbolizer

use of org.geotools.styling.PolygonSymbolizer in project sldeditor by robward-scisys.

the class SimpleFillSymbol method convertToFill.

/* (non-Javadoc)
     * @see com.sldeditor.convert.esri.symbols.EsriFillSymbolInterface#convertToFill(java.lang.String, com.google.gson.JsonElement, int)
     */
@Override
public List<Symbolizer> convertToFill(String layerName, JsonElement element, int transparency) {
    if (element == null)
        return null;
    JsonObject obj = element.getAsJsonObject();
    List<Symbolizer> symbolizerList = new ArrayList<Symbolizer>();
    Expression fillColour = getColour(obj.get(SimpleFillSymbolKeys.FILL_COLOUR));
    Expression transparencyExpression = getTransparency(transparency);
    Fill fill = null;
    if (fillColour != null) {
        fill = styleFactory.createFill(fillColour, transparencyExpression);
    }
    PolygonSymbolizer polygon = styleFactory.createPolygonSymbolizer();
    polygon.setStroke(null);
    polygon.setFill(fill);
    symbolizerList.add(polygon);
    return symbolizerList;
}
Also used : Fill(org.geotools.styling.Fill) Expression(org.opengis.filter.expression.Expression) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) Symbolizer(org.geotools.styling.Symbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer)

Example 8 with PolygonSymbolizer

use of org.geotools.styling.PolygonSymbolizer in project sldeditor by robward-scisys.

the class StrokeDetailsTest method testStrokeDetailsPolygon.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.StrokeDetails#StrokeDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 */
@Test
public void testStrokeDetailsPolygon() {
    StrokeDetails panel = new StrokeDetails();
    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);
    FieldConfigSymbolType symbolTypeField = (FieldConfigSymbolType) fieldDataManager.get(FieldIdEnum.STROKE_STYLE);
    symbolTypeField.populateField("circle");
    double expectedAngle = 14.5;
    FieldConfigDouble angleField = (FieldConfigDouble) fieldDataManager.get(FieldIdEnum.STROKE_SYMBOL_ANGLE);
    angleField.populateField(expectedAngle);
    FieldConfigSlider opacityField = (FieldConfigSlider) fieldDataManager.get(FieldIdEnum.OVERALL_OPACITY);
    double opacity = 0.15;
    opacityField.populateField(opacity);
    FieldConfigString dashField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.STROKE_DASH_ARRAY);
    String dashArray = "1 2";
    dashField.populateField(dashArray);
    panel.dataChanged(null);
    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 : FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) StrokeDetails(com.sldeditor.ui.detail.StrokeDetails) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) 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) FieldConfigSymbolType(com.sldeditor.ui.detail.config.FieldConfigSymbolType) Test(org.junit.Test)

Example 9 with PolygonSymbolizer

use of org.geotools.styling.PolygonSymbolizer 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)

Example 10 with PolygonSymbolizer

use of org.geotools.styling.PolygonSymbolizer 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)

Aggregations

PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)65 Test (org.junit.Test)28 PointSymbolizer (org.geotools.styling.PointSymbolizer)25 LineSymbolizer (org.geotools.styling.LineSymbolizer)24 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)19 Rule (org.geotools.styling.Rule)18 Style (org.geotools.styling.Style)18 Symbolizer (org.geotools.styling.Symbolizer)15 Fill (org.geotools.styling.Fill)14 NamedLayer (org.geotools.styling.NamedLayer)12 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)12 Stroke (org.geotools.styling.Stroke)10 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)9 TextSymbolizer (org.geotools.styling.TextSymbolizer)9 SLDTreeLeafPolygon (com.sldeditor.common.tree.leaf.SLDTreeLeafPolygon)8 Graphic (org.geotools.styling.Graphic)8 ArrayList (java.util.ArrayList)7 Expression (org.opengis.filter.expression.Expression)7 JsonObject (com.google.gson.JsonObject)5 SelectedSymbol (com.sldeditor.common.data.SelectedSymbol)5