use of org.opengis.style.TextSymbolizer in project geotoolkit by Geomatys.
the class GTtoSE110Transformer method visit.
/**
* Transform a GT rule in jaxb rule or OnlineResource
*/
@Override
public Object visit(final Rule rule, final Object data) {
if (rule.getOnlineResource() != null) {
// we store only the online resource
return visit(rule.getOnlineResource(), null);
}
final RuleType rt = se_factory.createRuleType();
rt.setName(rule.getName());
rt.setDescription(visit(rule.getDescription(), null));
if (rule.isElseFilter()) {
rt.setElseFilter(se_factory.createElseFilterType());
} else if (rule.getFilter() != null) {
rt.setFilter(apply(rule.getFilter()));
}
if (rule.getLegend() != null) {
rt.setLegendGraphic(visit(rule.getLegend(), null));
}
rt.setMaxScaleDenominator(rule.getMaxScaleDenominator());
rt.setMinScaleDenominator(rule.getMinScaleDenominator());
for (final Symbolizer symbol : rule.symbolizers()) {
if (symbol instanceof LineSymbolizer) {
rt.getSymbolizer().add(visit((LineSymbolizer) symbol, null));
} else if (symbol instanceof PolygonSymbolizer) {
rt.getSymbolizer().add(visit((PolygonSymbolizer) symbol, null));
} else if (symbol instanceof PointSymbolizer) {
rt.getSymbolizer().add(visit((PointSymbolizer) symbol, null));
} else if (symbol instanceof RasterSymbolizer) {
rt.getSymbolizer().add(visit((RasterSymbolizer) symbol, null));
} else if (symbol instanceof TextSymbolizer) {
rt.getSymbolizer().add(visit((TextSymbolizer) symbol, null));
} else if (symbol instanceof ExtensionSymbolizer) {
((List) rt.getSymbolizer()).add(visit((ExtensionSymbolizer) symbol, null));
}
}
return rt;
}
use of org.opengis.style.TextSymbolizer in project geotoolkit by Geomatys.
the class MapfileToSLDProcess method createTextSymbolizer.
private List<Symbolizer> createTextSymbolizer(final Expression label, final Feature lblStyle) {
Expression expLabelColor = (Expression) lblStyle.getPropertyValue(LABEL_COLOR.toString());
Expression expLabelSize = (Expression) lblStyle.getPropertyValue(LABEL_SIZE.toString());
Expression expHaloColor = (Expression) lblStyle.getPropertyValue(LABEL_OUTLINECOLOR.toString());
Integer valHaloWidth = (Integer) lblStyle.getPropertyValue(LABEL_OUTLINEWIDTH.toString());
String valAngle = (String) lblStyle.getPropertyValue(LABEL_ANGLE.toString());
if (expLabelColor == null) {
expLabelColor = SF.literal(Color.BLACK);
}
if (expLabelSize == null) {
expLabelSize = DEFAULT_FONT_SIZE;
}
if (expHaloColor == null) {
expHaloColor = SF.literal(Color.WHITE);
}
if (valHaloWidth == null) {
valHaloWidth = 0;
}
Expression expHaloWidth = FF.literal(valHaloWidth);
final List<Symbolizer> symbolizers = new ArrayList<Symbolizer>();
LabelPlacement placement = SF.pointPlacement();
if (valAngle != null) {
if ("FOLLOW".equalsIgnoreCase(valAngle) || "AUTO".equalsIgnoreCase(valAngle)) {
final Expression offset = FF.divide(expLabelSize, FF.literal(-2));
final Expression initial = FF.literal(20);
Expression gap = LITERAL_ZERO_FLOAT;
boolean repeated = false;
final boolean aligned = false;
final boolean generalize = false;
Integer minDistance = (Integer) lblStyle.getPropertyValue(LABEL_MINDISTANCE.toString());
if (minDistance != null) {
repeated = true;
gap = FF.literal(minDistance);
}
placement = SF.linePlacement(offset, initial, gap, repeated, aligned, generalize);
} else {
Expression rotation = LITERAL_ZERO_FLOAT;
// try if it's a number
try {
double d = Double.valueOf(valAngle);
rotation = FF.literal(d);
} catch (Exception ex) {
}
placement = SF.pointPlacement(DEFAULT_ANCHOR_POINT, DEFAULT_DISPLACEMENT, rotation);
}
}
// general informations
final String name = "";
final Description desc = DEFAULT_DESCRIPTION;
// use the default geometry of the feature
final String geometry = null;
final Unit unit = Units.POINT;
final Font font = SF.font(FF.literal("Arial"), FONT_STYLE_NORMAL, FONT_WEIGHT_NORMAL, expLabelSize);
final Halo halo = SF.halo(SF.fill(expHaloColor), expHaloWidth);
final Fill fill = SF.fill(expLabelColor);
final TextSymbolizer symbol = SF.textSymbolizer(name, geometry, desc, unit, label, font, placement, halo, fill);
symbolizers.add(symbol);
return symbolizers;
}
use of org.opengis.style.TextSymbolizer in project geotoolkit by Geomatys.
the class Styles method defaultText.
// ////////////////////////////////////////////////////////////////////
// TEXT SYMBOLIZER ///////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////////
public static MutableStyle defaultText() {
final TextSymbolizer symbol = DEFAULT_TEXT_SYMBOLIZER;
final MutableStyle style = SF.style(DEFAULT_POLYGON_SYMBOLIZER, symbol);
return style;
}
use of org.opengis.style.TextSymbolizer in project geotoolkit by Geomatys.
the class Styles method linedText.
public static MutableStyle linedText() {
// general informations
final String name = "mySymbol";
final Description desc = DEFAULT_DESCRIPTION;
// use the default geometry of the feature
final String geometry = null;
final Unit unit = Units.POINT;
final Expression label = FF.property("CNTRY_NAME");
final Font font = SF.font(FF.literal("Arial"), FONT_STYLE_ITALIC, FONT_WEIGHT_BOLD, FF.literal(14));
final LabelPlacement placement = SF.linePlacement(FF.literal(0));
final Halo halo = SF.halo(Color.WHITE, 1);
final Fill fill = SF.fill(Color.BLUE);
final TextSymbolizer symbol = SF.textSymbolizer(name, geometry, desc, unit, label, font, placement, halo, fill);
final MutableStyle style = SF.style(DEFAULT_POLYGON_SYMBOLIZER, symbol);
return style;
}
Aggregations