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);
}
}
}
}
}
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);
}
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;
}
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;
}
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);
}
Aggregations