Search in sources :

Example 1 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 2 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 3 with Symbolizer

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

the class MultiLayerLineSymbol 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();
            List<Stroke> strokeList = null;
            JsonElement jsonOutlineElement = obj.get(MultiLayerLineSymbolKeys.LINE);
            strokeList = SymbolManager.getInstance().getStrokeList(jsonOutlineElement);
            if (strokeList != null) {
                for (Stroke stroke : strokeList) {
                    LineSymbolizer lineSymbolizer = styleFactory.createLineSymbolizer(stroke, null);
                    symbolizerList.add(lineSymbolizer);
                }
            }
        }
    }
}
Also used : JsonArray(com.google.gson.JsonArray) Stroke(org.geotools.styling.Stroke) JsonElement(com.google.gson.JsonElement) LineSymbolizer(org.geotools.styling.LineSymbolizer) JsonObject(com.google.gson.JsonObject) Symbolizer(org.geotools.styling.Symbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer)

Example 4 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 5 with Symbolizer

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

the class PictureFillSymbol 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>();
    Fill fill = getFill(layerName, obj, transparency);
    PolygonSymbolizer polygon = styleFactory.createPolygonSymbolizer();
    polygon.setStroke(null);
    polygon.setFill(fill);
    symbolizerList.add(polygon);
    return symbolizerList;
}
Also used : Fill(org.geotools.styling.Fill) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Symbolizer(org.geotools.styling.Symbolizer)

Aggregations

Symbolizer (org.geotools.styling.Symbolizer)65 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)30 LineSymbolizer (org.geotools.styling.LineSymbolizer)29 PointSymbolizer (org.geotools.styling.PointSymbolizer)28 Rule (org.geotools.styling.Rule)22 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)20 Style (org.geotools.styling.Style)19 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)16 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)15 TextSymbolizer (org.geotools.styling.TextSymbolizer)15 StyledLayer (org.geotools.styling.StyledLayer)12 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)12 JsonObject (com.google.gson.JsonObject)11 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)10 NamedLayer (org.geotools.styling.NamedLayer)8 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)8 JsonElement (com.google.gson.JsonElement)7 Stroke (org.geotools.styling.Stroke)6 JsonArray (com.google.gson.JsonArray)5