use of org.geotools.styling.Fill in project sldeditor by robward-scisys.
the class CharacterMarkerSymbol method convert.
/**
* Convert.
*
* @param element the element
* @return the marker graphic
*/
@Override
public List<Graphic> convert(JsonElement element) {
if (element == null)
return null;
JsonObject obj = element.getAsJsonObject();
List<Graphic> markerList = new ArrayList<Graphic>();
double angle = getDouble(obj, CommonSymbolKeys.ANGLE);
double symbolSize = getDouble(obj, CommonSymbolKeys.SIZE);
double xOffset = getDouble(obj, CommonSymbolKeys.X_OFFSET);
double yOffset = getDouble(obj, CommonSymbolKeys.Y_OFFSET);
JsonElement fontElement = obj.get(CharacterMarkerSymbolKeys.FONT);
if (fontElement != null) {
JsonObject fontObj = fontElement.getAsJsonObject();
String fontName = getString(fontObj, FontSymbolKeys.FONT_NAME);
int code = getInt(obj, CharacterMarkerSymbolKeys.CHARACTER_INDEX);
Expression wellKnownName = ff.literal(String.format("ttf://%s#%s", fontName, code));
// Create colour
Expression colour = getColour(obj.get(CommonSymbolKeys.COLOUR));
Fill fill = styleFactory.createFill(colour);
Stroke stroke = null;
Mark mark = styleFactory.mark(wellKnownName, fill, stroke);
ExternalGraphic[] externalGraphics = null;
Mark[] marks = new Mark[1];
marks[0] = mark;
Symbol[] symbols = null;
Expression opacity = null;
Expression rotation = ff.literal(angle);
Expression size = ff.literal(symbolSize);
Graphic graphic = styleFactory.createGraphic(externalGraphics, marks, symbols, opacity, size, rotation);
// Displacement (offsets)
if ((xOffset > 0.0) && (yOffset > 0.0)) {
Expression expressionX = ff.literal(xOffset);
Expression expressionY = ff.literal(yOffset);
Displacement displacement = styleFactory.createDisplacement(expressionX, expressionY);
graphic.setDisplacement(displacement);
}
markerList.add(graphic);
}
return markerList;
}
use of org.geotools.styling.Fill in project sldeditor by robward-scisys.
the class PictureFillSymbol method convertToFill.
/* (non-Javadoc)
* @see com.sldeditor.convert.esri.symbols.EsriFillSymbolInterface#convertToFill(java.lang.String, com.google.gson.JsonElement, int)
*/
@Override
public List<Symbolizer> convertToFill(String layerName, JsonElement element, int transparency) {
if (element == null)
return null;
JsonObject obj = element.getAsJsonObject();
List<Symbolizer> symbolizerList = new ArrayList<Symbolizer>();
Fill fill = getFill(layerName, obj, transparency);
PolygonSymbolizer polygon = styleFactory.createPolygonSymbolizer();
polygon.setStroke(null);
polygon.setFill(fill);
symbolizerList.add(polygon);
return symbolizerList;
}
use of org.geotools.styling.Fill in project sldeditor by robward-scisys.
the class PictureFillSymbol 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 (rule == null)
return;
if (element == null)
return;
JsonObject obj = element.getAsJsonObject();
List<Symbolizer> symbolizerList = rule.symbolizers();
List<Stroke> strokeList = SymbolManager.getInstance().getStrokeList(obj.get(PictureFillSymbolKeys.OUTLINE));
Stroke stroke = null;
if (!strokeList.isEmpty()) {
stroke = strokeList.get(0);
}
Fill fill = getFill(layerName, obj, transparency);
PolygonSymbolizer polygonSymbolizer = styleFactory.createPolygonSymbolizer(stroke, fill, null);
symbolizerList.add(polygonSymbolizer);
}
use of org.geotools.styling.Fill 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.Fill in project sldeditor by robward-scisys.
the class SimpleFillSymbol method convertToFill.
/* (non-Javadoc)
* @see com.sldeditor.convert.esri.symbols.EsriFillSymbolInterface#convertToFill(java.lang.String, com.google.gson.JsonElement, int)
*/
@Override
public List<Symbolizer> convertToFill(String layerName, JsonElement element, int transparency) {
if (element == null)
return null;
JsonObject obj = element.getAsJsonObject();
List<Symbolizer> symbolizerList = new ArrayList<Symbolizer>();
Expression fillColour = getColour(obj.get(SimpleFillSymbolKeys.FILL_COLOUR));
Expression transparencyExpression = getTransparency(transparency);
Fill fill = null;
if (fillColour != null) {
fill = styleFactory.createFill(fillColour, transparencyExpression);
}
PolygonSymbolizer polygon = styleFactory.createPolygonSymbolizer();
polygon.setStroke(null);
polygon.setFill(fill);
symbolizerList.add(polygon);
return symbolizerList;
}
Aggregations