Search in sources :

Example 21 with Symbolizer

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

the class SimpleLineSymbol 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();
    List<Stroke> strokeList = convert(obj);
    Stroke stroke = null;
    if (!strokeList.isEmpty()) {
        stroke = strokeList.get(0);
    }
    LineSymbolizer lineSymbolizer = styleFactory.createLineSymbolizer(stroke, null);
    symbolizerList.add(lineSymbolizer);
}
Also used : Stroke(org.geotools.styling.Stroke) LineSymbolizer(org.geotools.styling.LineSymbolizer) JsonObject(com.google.gson.JsonObject) Symbolizer(org.geotools.styling.Symbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer)

Example 22 with Symbolizer

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

the class CartographicLineSymbol method convert.

/**
 * Convert.
 *
 * @param rule the rule
 * @param element the element
 * @param layerName the layer name
 * @param transparency the transparency
 */
@Override
public void convert(Rule rule, JsonElement element, String layerName, int transparency) {
    if (rule == null)
        return;
    if (element == null)
        return;
    JsonObject obj = element.getAsJsonObject();
    List<Symbolizer> symbolizerList = rule.symbolizers();
    List<Stroke> strokeList = convert(obj);
    Stroke stroke = null;
    if (!strokeList.isEmpty()) {
        stroke = strokeList.get(0);
    }
    LineSymbolizer lineSymbolizer = styleFactory.createLineSymbolizer(stroke, null);
    symbolizerList.add(lineSymbolizer);
}
Also used : Stroke(org.geotools.styling.Stroke) LineSymbolizer(org.geotools.styling.LineSymbolizer) JsonObject(com.google.gson.JsonObject) Symbolizer(org.geotools.styling.Symbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer)

Example 23 with Symbolizer

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

the class MultiLayerFillSymbol method convert.

/* (non-Javadoc)
     * @see com.sldeditor.convert.esri.symbols.EsriSymbolInterface#convert(Rule, JsonElement)
     */
@Override
public void convert(Rule rule, JsonElement element, String layerName, int transparency) {
    if (rule == null)
        return;
    if (element == null)
        return;
    JsonArray layerArray = element.getAsJsonArray();
    List<Symbolizer> symbolizerList = rule.symbolizers();
    if (layerArray.size() > 0) {
        for (int index = 0; index < layerArray.size(); index++) {
            JsonObject obj = layerArray.get(index).getAsJsonObject();
            // Handle fills
            List<Symbolizer> createdSymbolizerList = SymbolManager.getInstance().getFillSymbol(layerName, obj.get(MultiLayerFillSymbolKeys.FILL), transparency);
            if (symbolizerList != null) {
                symbolizerList.addAll(createdSymbolizerList);
            }
            // Handle strokes
            JsonElement jsonOutlineElement = obj.get(MultiLayerFillSymbolKeys.OUTLINE);
            List<Stroke> strokeList = SymbolManager.getInstance().getStrokeList(jsonOutlineElement);
            if (strokeList != null) {
                List<Symbolizer> createdLineSymbolizerList = new ArrayList<Symbolizer>();
                for (Stroke stroke : strokeList) {
                    LineSymbolizer lineSymbol = styleFactory.createLineSymbolizer();
                    lineSymbol.setStroke(stroke);
                    createdLineSymbolizerList.add(lineSymbol);
                }
                symbolizerList.addAll(createdLineSymbolizerList);
            }
        }
    }
}
Also used : JsonArray(com.google.gson.JsonArray) Stroke(org.geotools.styling.Stroke) JsonElement(com.google.gson.JsonElement) LineSymbolizer(org.geotools.styling.LineSymbolizer) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) Symbolizer(org.geotools.styling.Symbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer)

Example 24 with Symbolizer

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

the class MultiLayerMarkerSymbol method convert.

/**
 * Convert.
 *
 * @param rule the rule
 * @param element the element
 * @param layerName the layer name
 * @param transparency the transparency
 */
@Override
public void convert(Rule rule, JsonElement element, String layerName, int transparency) {
    if (rule == null)
        return;
    if (element == null)
        return;
    JsonArray layerArray = element.getAsJsonArray();
    List<Symbolizer> symbolizerList = rule.symbolizers();
    if (layerArray.size() > 0) {
        for (int index = 0; index < layerArray.size(); index++) {
            JsonObject obj = layerArray.get(index).getAsJsonObject();
            JsonElement jsonElement = obj.get(MultiLayerMarkerSymbolKeys.MARKER);
            if (jsonElement != null) {
                JsonObject asJsonObject = jsonElement.getAsJsonObject();
                if (asJsonObject != null) {
                    List<Graphic> markerList = SymbolManager.getInstance().getMarkerList(asJsonObject);
                    if (markerList != null) {
                        for (Graphic marker : markerList) {
                            PointSymbolizer pointSymbolizer = styleFactory.createPointSymbolizer(marker, null);
                            symbolizerList.add(pointSymbolizer);
                        }
                    }
                }
            }
        }
    }
}
Also used : JsonArray(com.google.gson.JsonArray) PointSymbolizer(org.geotools.styling.PointSymbolizer) JsonElement(com.google.gson.JsonElement) Graphic(org.geotools.styling.Graphic) JsonObject(com.google.gson.JsonObject) Symbolizer(org.geotools.styling.Symbolizer) PointSymbolizer(org.geotools.styling.PointSymbolizer)

Example 25 with Symbolizer

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

Aggregations

Symbolizer (org.geotools.styling.Symbolizer)65 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)29 LineSymbolizer (org.geotools.styling.LineSymbolizer)28 PointSymbolizer (org.geotools.styling.PointSymbolizer)27 Rule (org.geotools.styling.Rule)21 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)20 Style (org.geotools.styling.Style)18 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)15 TextSymbolizer (org.geotools.styling.TextSymbolizer)15 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)14 Test (org.junit.jupiter.api.Test)13 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)12 JsonObject (com.google.gson.JsonObject)11 StyledLayer (org.geotools.styling.StyledLayer)11 NamedLayer (org.geotools.styling.NamedLayer)10 ArrayList (java.util.ArrayList)8 JsonElement (com.google.gson.JsonElement)7 Stroke (org.geotools.styling.Stroke)6 JsonArray (com.google.gson.JsonArray)5 Expression (org.opengis.filter.expression.Expression)5