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