Search in sources :

Example 1 with LineSymbolizer

use of org.geotools.styling.LineSymbolizer in project hale by halestudio.

the class StyleHelper method createLineSymbolizer.

/**
 * Create a default line symbolizer.
 *
 * @param color the color
 * @param width the line width
 * @return the line symbolizer
 */
public static LineSymbolizer createLineSymbolizer(Color color, double width) {
    LineSymbolizer symbolizer = styleFactory.createLineSymbolizer();
    SLD.setLineColour(symbolizer, color);
    symbolizer.getStroke().setWidth(filterFactory.literal(width));
    return symbolizer;
}
Also used : LineSymbolizer(org.geotools.styling.LineSymbolizer)

Example 2 with LineSymbolizer

use of org.geotools.styling.LineSymbolizer in project hale by halestudio.

the class StyleHelper method createLineStyle.

/**
 * Create a default line style.
 *
 * @param color the line color
 * @param width the line width
 * @return a Style for Line/LineString objects.
 */
@SuppressWarnings("unused")
private static FeatureTypeStyle createLineStyle(Color color, double width) {
    LineSymbolizer symbolizer = createLineSymbolizer(color, width);
    Rule rule = styleFactory.createRule();
    rule.symbolizers().add(symbolizer);
    FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
    fts.rules().add(rule);
    return fts;
}
Also used : LineSymbolizer(org.geotools.styling.LineSymbolizer) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule)

Example 3 with LineSymbolizer

use of org.geotools.styling.LineSymbolizer in project hale by halestudio.

the class RuleStylePage method createEditor.

/**
 * Create a rule editor
 *
 * @param rule the rule
 * @param parent the parent composite
 *
 * @return the {@link Rule} editor
 */
private Editor<Rule> createEditor(Rule rule, Composite parent) {
    TypeDefinition type = getParent().getType();
    Filter filter = rule.getFilter();
    Symbolizer symbolizer = null;
    Symbolizer[] symbolizers = rule.getSymbolizers();
    if (symbolizers != null && symbolizers.length > 0) {
        symbolizer = symbolizers[0];
    }
    if (symbolizer == null) {
        // fallback if there is no symbolizer defined
        FeatureTypeStyle fts = StyleHelper.getDefaultStyle(type, getParent().getDataSet());
        symbolizer = fts.rules().get(0).getSymbolizers()[0];
    }
    Editor<Rule> editor;
    if (symbolizer instanceof PointSymbolizer) {
        editor = createEditor(parent, type, filter, PointSymbolizer.class, (PointSymbolizer) symbolizer);
    } else if (symbolizer instanceof PolygonSymbolizer) {
        editor = createEditor(parent, type, filter, PolygonSymbolizer.class, (PolygonSymbolizer) symbolizer);
    } else {
        // TODO support other symbolizers
        // default: LineSymbolizer
        editor = createEditor(parent, type, filter, LineSymbolizer.class, (LineSymbolizer) symbolizer);
    }
    return editor;
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) Filter(org.opengis.filter.Filter) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) LineSymbolizer(org.geotools.styling.LineSymbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Symbolizer(org.geotools.styling.Symbolizer) PointSymbolizer(org.geotools.styling.PointSymbolizer) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 4 with LineSymbolizer

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

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

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