Search in sources :

Example 6 with LineSymbolizer

use of org.geotools.styling.LineSymbolizer 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 7 with LineSymbolizer

use of org.geotools.styling.LineSymbolizer 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 8 with LineSymbolizer

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

the class DefaultSymbols method createNewLine.

/**
 * Creates a new line symbol.
 *
 * @return the styled layer descriptor
 */
public static StyledLayerDescriptor createNewLine() {
    StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
    NamedLayer namedLayer = styleFactory.createNamedLayer();
    sld.addStyledLayer(namedLayer);
    Style style = styleFactory.createStyle();
    namedLayer.addStyle(style);
    List<FeatureTypeStyle> ftsList = style.featureTypeStyles();
    FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
    ftsList.add(fts);
    Rule rule = styleFactory.createRule();
    fts.rules().add(rule);
    LineSymbolizer line = createDefaultLineSymbolizer();
    rule.symbolizers().add(line);
    return sld;
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) LineSymbolizer(org.geotools.styling.LineSymbolizer) 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)

Example 9 with LineSymbolizer

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

the class DefaultSymbols method createDefaultLineSymbolizer.

/**
 * Creates the default line symbolizer.
 *
 * @return the line symbolizer
 */
public static LineSymbolizer createDefaultLineSymbolizer() {
    Stroke stroke = styleFactory.createStroke(ff.literal(DEFAULT_LINE_COLOUR), ff.literal(2));
    LineSymbolizer lineSymbolizer = styleFactory.createLineSymbolizer();
    lineSymbolizer.setStroke(stroke);
    return lineSymbolizer;
}
Also used : Stroke(org.geotools.styling.Stroke) LineSymbolizer(org.geotools.styling.LineSymbolizer)

Example 10 with LineSymbolizer

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

the class RuleRenderVisitor method visit.

/**
 * (non-Javadoc)
 *
 * @see org.geotools.styling.visitor.DuplicatingStyleVisitor#visit(org.geotools.styling.LineSymbolizer)
 */
public void visit(LineSymbolizer line) {
    LineSymbolizer copy = sf.getDefaultLineSymbolizer();
    copy.setGeometry(copy(line.getGeometry()));
    copy.setUnitOfMeasure(line.getUnitOfMeasure());
    copy.setStroke(copy(line.getStroke()));
    copy.getOptions().putAll(line.getOptions());
    copy.setPerpendicularOffset(line.getPerpendicularOffset());
    if (STRICT && !copy.equals(line)) {
        throw new IllegalStateException("Was unable to duplicate provided LineSymbolizer:" + line);
    }
    pages.push(copy);
}
Also used : LineSymbolizer(org.geotools.styling.LineSymbolizer)

Aggregations

LineSymbolizer (org.geotools.styling.LineSymbolizer)51 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)24 PointSymbolizer (org.geotools.styling.PointSymbolizer)23 Test (org.junit.Test)18 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)17 Style (org.geotools.styling.Style)17 Rule (org.geotools.styling.Rule)16 Symbolizer (org.geotools.styling.Symbolizer)15 Stroke (org.geotools.styling.Stroke)12 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)10 TextSymbolizer (org.geotools.styling.TextSymbolizer)10 NamedLayer (org.geotools.styling.NamedLayer)9 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)7 StyledLayer (org.geotools.styling.StyledLayer)5 JsonObject (com.google.gson.JsonObject)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 Graphic (org.geotools.styling.Graphic)4 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)4 SelectedSymbol (com.sldeditor.common.data.SelectedSymbol)3 SLDTreeLeafLine (com.sldeditor.common.tree.leaf.SLDTreeLeafLine)3