use of org.geotools.styling.Stroke in project sldeditor by robward-scisys.
the class SimpleFillSymbol 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();
JsonElement jsonOutlineElement = obj.get(SimpleFillSymbolKeys.OUTLINE);
List<Stroke> strokeList = SymbolManager.getInstance().getStrokeList(jsonOutlineElement);
Stroke stroke = null;
if (strokeList != null) {
if (!strokeList.isEmpty()) {
stroke = strokeList.get(0);
}
}
Expression fillColour = getColour(obj.get(SimpleFillSymbolKeys.FILL_COLOUR));
Fill fill = null;
if (fillColour != null) {
fill = styleFactory.createFill(fillColour, getTransparency(transparency));
}
PolygonSymbolizer polygonSymbolizer = styleFactory.createPolygonSymbolizer(stroke, fill, null);
symbolizerList.add(polygonSymbolizer);
}
use of org.geotools.styling.Stroke in project sldeditor by robward-scisys.
the class SimpleLineSymbol method convert.
/**
* Convert.
*
* @param element the element
* @return the list of strokes
*/
@Override
public List<Stroke> convert(JsonElement element) {
if (element == null)
return null;
JsonObject obj = element.getAsJsonObject();
List<Stroke> strokeList = new ArrayList<Stroke>();
double width = getDouble(obj, CommonSymbolKeys.WIDTH);
Expression colour = getColour(obj.get(CommonSymbolKeys.COLOUR));
if (colour != null) {
Stroke stroke = styleFactory.createStroke(colour, ff.literal(width));
strokeList.add(stroke);
}
return strokeList;
}
use of org.geotools.styling.Stroke 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.Stroke in project sldeditor by robward-scisys.
the class SimpleMarkerSymbol method convert.
/**
* Convert.
*
* @param element the element
* @return the graphic marker list
*/
@Override
public List<Graphic> convert(JsonElement element) {
if (element == null)
return null;
JsonObject obj = element.getAsJsonObject();
List<Graphic> markList = new ArrayList<Graphic>();
double angle = getDouble(obj, CommonSymbolKeys.ANGLE);
double outlineSize = getDouble(obj, SimpleMarkerSymbolKeys.OUTLINE_SIZE);
double size = getDouble(obj, CommonSymbolKeys.SIZE);
int style = getInt(obj, CommonSymbolKeys.STYLE);
double xOffset = getDouble(obj, CommonSymbolKeys.X_OFFSET);
double yOffset = getDouble(obj, CommonSymbolKeys.Y_OFFSET);
Expression markerColour = getColour(obj.get(CommonSymbolKeys.COLOUR));
Expression outlineColour = getColour(obj.get(SimpleMarkerSymbolKeys.OUTLINE_COLOUR));
Expression wellKnownName = ff.literal(styleMap.get(style));
Stroke stroke = null;
if (outlineSize > 0.0) {
stroke = styleFactory.createStroke(outlineColour, ff.literal(outlineSize));
}
Fill fill = styleFactory.createFill(markerColour);
Mark mark = styleFactory.createMark(wellKnownName, stroke, fill, ff.literal(size), ff.literal(angle));
Expression expressionOpacity = null;
ExternalGraphic[] externalGraphics = null;
Symbol[] symbols = null;
Mark[] marks = new Mark[1];
marks[0] = mark;
Graphic graphic = styleFactory.createGraphic(externalGraphics, marks, symbols, expressionOpacity, ff.literal(size), ff.literal(angle));
// Set offset
if ((xOffset > 0.0) && (yOffset > 0.0)) {
Displacement displacement = styleFactory.displacement(ff.literal(xOffset), ff.literal(yOffset));
graphic.setDisplacement(displacement);
}
markList.add(graphic);
return markList;
}
use of org.geotools.styling.Stroke in project sldeditor by robward-scisys.
the class DefaultSymbols method createDefaultPolygonSymbolizer.
/**
* Creates the default polygon symbolizer.
*
* @return the polygon symbolizer
*/
public static PolygonSymbolizer createDefaultPolygonSymbolizer() {
Stroke stroke = styleFactory.createStroke(ff.literal(DEFAULT_LINE_COLOUR), ff.literal(2));
Fill fill = styleFactory.getDefaultFill();
PolygonSymbolizer polygonSymbolizer = styleFactory.createPolygonSymbolizer();
polygonSymbolizer.setStroke(stroke);
polygonSymbolizer.setFill(fill);
return polygonSymbolizer;
}
Aggregations