use of org.opengis.style.ExtensionSymbolizer in project geotoolkit by Geomatys.
the class KmzContextInterpreter method writeSymbolizer.
/**
* Writes KML color styles mapping SLD Symbolizers.
* Color styles are written into KML Style selector.
*/
private AbstractStyleSelector writeSymbolizer(Symbolizer symbolizer, Style styleSelector) {
if (symbolizer instanceof ExtensionSymbolizer) {
} else // LineSymbolizer mapping
if (symbolizer instanceof LineSymbolizer) {
final LineSymbolizer lineSymbolizer = (LineSymbolizer) symbolizer;
final LineStyle lineStyle = ((styleSelector.getLineStyle() == null) ? KML_FACTORY.createLineStyle() : styleSelector.getLineStyle());
lineStyle.setWidth((Double) this.writeExpression(lineSymbolizer.getStroke().getWidth(), Double.class, null));
lineStyle.setColor((Color) this.writeExpression(lineSymbolizer.getStroke().getColor(), Color.class, null));
styleSelector.setLineStyle(lineStyle);
} else // PointSymbolizezr mapping
if (symbolizer instanceof PointSymbolizer) {
// PointSymbolizer pointSymbolizer = (PointSymbolizer) symbolizer;
// IconStyle iconStyle = KML_FACTORY.createIconStyle();
// GraphicalSymbol gs = ((GraphicalSymbol) pointSymbolizer.getGraphic().graphicalSymbols().get(0));
// gs.
} else // PolygonSymbolizer mapping
if (symbolizer instanceof PolygonSymbolizer) {
final PolygonSymbolizer polygonSymbolizer = (PolygonSymbolizer) symbolizer;
final PolyStyle polyStyle = KML_FACTORY.createPolyStyle();
// Fill
if (polygonSymbolizer.getFill() == null) {
polyStyle.setFill(false);
} else {
polyStyle.setFill(true);
polyStyle.setColor((Color) this.writeExpression(polygonSymbolizer.getFill().getColor(), Color.class, null));
}
// Outline
if (polygonSymbolizer.getStroke() == null) {
polyStyle.setOutline(false);
} else if (styleSelector.getLineStyle() == null) {
polyStyle.setOutline(true);
final LineStyle lineStyle = KML_FACTORY.createLineStyle();
lineStyle.setColor((Color) this.writeExpression(polygonSymbolizer.getStroke().getColor(), Color.class, null));
lineStyle.setWidth((Double) this.writeExpression(polygonSymbolizer.getStroke().getWidth(), Double.class, null));
styleSelector.setLineStyle(lineStyle);
}
styleSelector.setPolyStyle(polyStyle);
} else if (symbolizer instanceof RasterSymbolizer) {
} else if (symbolizer instanceof TextSymbolizer) {
final TextSymbolizer textSymbolizer = (TextSymbolizer) symbolizer;
final LabelStyle labelStyle = KML_FACTORY.createLabelStyle();
if (textSymbolizer.getFont() != null) {
textSymbolizer.getFont().getSize();
}
if (textSymbolizer.getFill() != null) {
labelStyle.setColor((Color) this.writeExpression(textSymbolizer.getFill().getColor(), Color.class, null));
}
styleSelector.setLabelStyle(labelStyle);
}
return styleSelector;
}
use of org.opengis.style.ExtensionSymbolizer in project geotoolkit by Geomatys.
the class GTtoSE100Transformer method visit.
/**
* Transform a GT rule in jaxb rule or OnlineResource
*/
@Override
public org.geotoolkit.sld.xml.v100.Rule visit(final Rule rule, final Object data) {
final org.geotoolkit.sld.xml.v100.Rule rt = sld_factory_v100.createRule();
rt.setName(rule.getName());
if (rule.getDescription() != null) {
if (rule.getDescription().getAbstract() != null)
rt.setAbstract(rule.getDescription().getAbstract().toString());
if (rule.getDescription().getTitle() != null)
rt.setTitle(rule.getDescription().getTitle().toString());
}
if (rule.isElseFilter()) {
rt.setElseFilter(sld_factory_v100.createElseFilter());
} 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) {
// TODO provide jaxb parsing for unknowned symbolizers
// rt.getSymbolizer().add( visit((ExtensionSymbolizer)symbol,null));
}
}
return rt;
}
use of org.opengis.style.ExtensionSymbolizer 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;
}
Aggregations