use of org.geotools.styling.Stroke in project polymap4-core by Polymap4.
the class DefaultStyles method createPolygonStyle.
/**
* Create a Style to draw polygon features with a thin blue outline and
* a cyan fill
*/
public static Style createPolygonStyle(Style style) {
// create a partially opaque outline stroke
Stroke stroke = sf.createStroke(ff.literal(Color.DARK_GRAY), ff.literal(0.5), ff.literal(0.5));
// create a partial opaque fill
Fill fill = sf.createFill(ff.literal(Color.CYAN), ff.literal(0.5));
/*
* Setting the geometryPropertyName arg to null signals that we want to
* draw the default geometry of features
*/
PolygonSymbolizer sym = sf.createPolygonSymbolizer(stroke, fill, null);
Rule rule = sf.createRule();
rule.setName("Rule for PolygonSymbolizer");
rule.symbolizers().add(sym);
style.featureTypeStyles().get(0).rules().add(rule);
return style;
}
use of org.geotools.styling.Stroke in project polymap4-core by Polymap4.
the class DefaultStyles method createLineStyle.
/**
* Create a Style to draw line features as thin blue lines
*/
public static Style createLineStyle(Style style) {
Stroke stroke = sf.createStroke(ff.literal(Color.DARK_GRAY), ff.literal(0.5));
/*
* Setting the geometryPropertyName arg to null signals that we want to
* draw the default geometry of features
*/
LineSymbolizer sym = sf.createLineSymbolizer(stroke, null);
Rule rule = sf.createRule();
rule.symbolizers().add(sym);
rule.setName("Rule for LineSymbolizer");
style.featureTypeStyles().get(0).rules().add(rule);
return style;
}
use of org.geotools.styling.Stroke in project hale by halestudio.
the class StyledInstanceMarker method strokeStyle.
/**
* retrieves the stroke for the map marker
*
* @param rule a certain rule to apply, maybe null
* @param context the InstanceWayPoint, wich gets marked
*/
private synchronized void strokeStyle(Rule rule, InstanceWaypoint context) {
// retrieve stroke
Stroke stroke = null;
for (int i = 0; rule != null && stroke == null && i < rule.getSymbolizers().length; i++) {
if (rule.getSymbolizers()[i] instanceof LineSymbolizer) {
stroke = SLD.stroke((LineSymbolizer) rule.getSymbolizers()[i]);
} else if (rule.getSymbolizers()[i] instanceof PolygonSymbolizer) {
stroke = SLD.stroke((PolygonSymbolizer) rule.getSymbolizers()[i]);
} else if (rule.getSymbolizers()[i] instanceof PointSymbolizer) {
stroke = SLD.stroke((PointSymbolizer) rule.getSymbolizers()[i]);
}
}
// if we have a stroke now
if (stroke != null) {
// XXX is there any Geotools stroke to AWT stroke lib/code
// somewhere?!
// XXX have a look at the renderer code (StreamingRenderer)
// stroke color
Color sldColor = SLD.color(stroke);
double opacity = SLD.opacity(stroke);
if (Double.isNaN(opacity)) {
// fall back to default opacity
opacity = StyleHelper.DEFAULT_FILL_OPACITY;
}
if (sldColor != null) {
styleStrokeColor = new Color(sldColor.getRed(), sldColor.getGreen(), sldColor.getBlue(), (int) (opacity * 255));
} else {
styleStrokeColor = super.getBorderColor(context);
}
// stroke width
int strokeWidth = SLD.width(stroke);
if (strokeWidth == SLD.NOTFOUND) {
// fall back to default width
strokeWidth = StylePreferences.getDefaultWidth();
}
styleStroke = new BasicStroke(strokeWidth);
} else {
styleStroke = null;
styleStrokeColor = null;
}
}
use of org.geotools.styling.Stroke in project sldeditor by robward-scisys.
the class LineFillSymbol method convertToFill.
/**
* Convert to fill.
*
* @param layerName the layer name
* @param element the element
* @param transparency the transparency
* @return the list
*/
/* (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 (layerName == null) {
return null;
}
if (element == null) {
return null;
}
List<Symbolizer> symbolizerList = new ArrayList<Symbolizer>();
JsonObject obj = element.getAsJsonObject();
Expression size = ff.literal(getDouble(obj, LineFillSymbolKeys.SEPARATION));
Expression opacity = null;
double lineAngle = normaliseAngle(getDouble(obj, CommonSymbolKeys.ANGLE));
Expression rotation = null;
AnchorPoint anchorPoint = null;
Displacement displacement = null;
Expression fillColour = getColour(obj.get(LineFillSymbolKeys.FILL_COLOUR));
Expression fillColourOpacity = null;
Expression join = null;
Expression cap = null;
float[] dashes = null;
Expression offset = null;
Expression width = ff.literal(1.0);
Stroke outlineStroke = null;
List<Stroke> strokeList = SymbolManager.getInstance().getStrokeList(obj.get(LineFillSymbolKeys.OUTLINE));
// TODO
if ((strokeList != null) && (strokeList.size() == 1)) {
outlineStroke = strokeList.get(0);
width = outlineStroke.getWidth();
}
Expression wellKnownName = null;
if (isDoubleEqual(lineAngle, 0.0) || isDoubleEqual(lineAngle, 180.0)) {
wellKnownName = ff.literal("shape://horline");
} else if (isDoubleEqual(lineAngle, 90.0) || isDoubleEqual(lineAngle, 270.0)) {
wellKnownName = ff.literal("shape://vertline");
} else if (isDoubleEqual(lineAngle, 45.0) || isDoubleEqual(lineAngle, 225.0)) {
wellKnownName = ff.literal("shape://slash");
} else if (isDoubleEqual(lineAngle, 135.0) || isDoubleEqual(lineAngle, 315.0)) {
wellKnownName = ff.literal("shape://backslash");
} else {
wellKnownName = ff.literal("shape://vertline");
rotation = ff.literal(lineAngle);
}
Fill fill = null;
Stroke markStroke = styleFactory.stroke(fillColour, fillColourOpacity, width, join, cap, dashes, offset);
Mark mark = styleFactory.createMark(wellKnownName, markStroke, fill, size, rotation);
List<GraphicalSymbol> symbolList = new ArrayList<GraphicalSymbol>();
symbolList.add(mark);
GraphicFill graphicFill = styleFactory.graphicFill(symbolList, opacity, size, rotation, anchorPoint, displacement);
Fill completeFill = styleFactory.fill(graphicFill, null, null);
PolygonSymbolizer polygonSymbolizer = styleFactory.createPolygonSymbolizer();
polygonSymbolizer.setFill(completeFill);
polygonSymbolizer.setStroke(outlineStroke);
symbolizerList.add(polygonSymbolizer);
return symbolizerList;
}
use of org.geotools.styling.Stroke in project sldeditor by robward-scisys.
the class MultiLayerLineSymbol method convert.
/* (non-Javadoc)
* @see com.sldeditor.convert.esri.symbols.EsriLineSymbolInterface#convert(com.google.gson.JsonElement)
*/
@Override
public List<Stroke> convert(JsonElement element) {
if (element == null)
return null;
List<Stroke> strokeList = null;
JsonArray layerList = element.getAsJsonArray();
if (layerList.size() > 0) {
strokeList = new ArrayList<Stroke>();
for (int index = 0; index < layerList.size(); index++) {
JsonObject obj = layerList.get(index).getAsJsonObject();
List<Stroke> strokeSymbolList = SymbolManager.getInstance().getStrokeList(obj.get(MultiLayerLineSymbolKeys.LINE));
if (strokeSymbolList != null) {
strokeList.addAll(strokeSymbolList);
}
}
}
return strokeList;
}
Aggregations