use of org.opengis.style.TextSymbolizer in project geotoolkit by Geomatys.
the class Styles method centeredText.
public static MutableStyle centeredText() {
// 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.pointPlacement();
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;
}
use of org.opengis.style.TextSymbolizer 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.TextSymbolizer in project geotoolkit by Geomatys.
the class IsolineSymbolizerRenderer method presentations.
@Override
public Stream<Presentation> presentations(MapLayer layer, Resource resource) {
if (!(resource instanceof GridCoverageResource)) {
return Stream.empty();
}
final GridCoverageResource coverageReference = (GridCoverageResource) resource;
final IsolineSymbolizer isolineSymbolizer = symbol.getSource();
try {
Stream<Presentation> stream = Stream.empty();
// //////////////////
// 1 - Render raster
// //////////////////
final CachedRasterSymbolizer cachedRasterSymbolizer = symbol.getCachedRasterSymbolizer();
if (!isolineSymbolizer.getIsolineOnly() || isJenksFunction(cachedRasterSymbolizer)) {
final MapLayer sublayer = MapBuilder.createLayer(coverageReference);
sublayer.setStyle(GO2Utilities.STYLE_FACTORY.style(cachedRasterSymbolizer.getSource()));
stream = Stream.concat(stream, DefaultPortrayalService.present(sublayer, coverageReference, renderingContext));
}
final LineSymbolizer lineSymbolizer = isolineSymbolizer.getLineSymbolizer();
final TextSymbolizer textSymbolizer = isolineSymbolizer.getTextSymbolizer();
// //////////////////
if (lineSymbolizer != null) {
double[] intervales = symbol.getSteps();
final CoverageQuery query = new CoverageQuery();
query.setSelection(renderingContext.getGridGeometry());
query.setSourceDomainExpansion(2);
final GridCoverageResource res = coverageReference.subset(query);
final GridCoverage inCoverage = res.read(null).forConvertedValues(true);
final GridCoverageResource resampledCovRef = new InMemoryGridCoverageResource(coverageReference.getIdentifier().orElse(null), inCoverage);
// ///////////////////
// 2.2 - Compute isolines
// //////////////////
FeatureSet isolines = null;
final ProcessDescriptor isolineDesc = symbol.getIsolineDesc();
if (isolineDesc != null) {
final Parameters inputs = Parameters.castOrWrap(isolineDesc.getInputDescriptor().createValue());
inputs.getOrCreate(IsolineDescriptor.COVERAGE_REF).setValue(resampledCovRef);
inputs.getOrCreate(IsolineDescriptor.INTERVALS).setValue(intervales);
final org.geotoolkit.process.Process process = isolineDesc.createProcess(inputs);
final ParameterValueGroup result = process.call();
isolines = (FeatureSet) result.parameter(IsolineDescriptor.FCOLL.getName().getCode()).getValue();
}
// //////////////////
if (isolines != null) {
MutableStyle featureStyle = null;
if (textSymbolizer != null) {
featureStyle = GO2Utilities.STYLE_FACTORY.style(lineSymbolizer, textSymbolizer);
} else {
featureStyle = GO2Utilities.STYLE_FACTORY.style(lineSymbolizer);
}
MapLayer fml = MapBuilder.createLayer(isolines);
fml.setStyle(featureStyle);
stream = Stream.concat(stream, DefaultPortrayalService.present(fml, isolines, renderingContext));
}
}
return stream;
} catch (DataStoreException | ProcessException ex) {
ExceptionPresentation ep = new ExceptionPresentation(ex);
ep.setLayer(layer);
ep.setResource(resource);
return Stream.of(ep);
}
}
use of org.opengis.style.TextSymbolizer in project geotoolkit by Geomatys.
the class SLD110Test method testUnitTranscription.
@Test
public void testUnitTranscription() {
final SE110toGTTransformer se2gt = new SE110toGTTransformer(FILTER_FACTORY, STYLE_FACTORY);
final GTtoSE110Transformer gt2se = new GTtoSE110Transformer();
final TextSymbolizerType textSymbol = new TextSymbolizerType();
final ParameterValueType labelType = new ParameterValueType();
labelType.getContent().add("label");
textSymbol.setLabel(labelType);
textSymbol.setUom("km");
TextSymbolizer transcriptedText = se2gt.visit(textSymbol);
assertEquals("Converted unit of measure", Units.KILOMETRE, transcriptedText.getUnitOfMeasure());
TextSymbolizerType revertedSymbol = gt2se.visit(transcriptedText, null).getValue();
assertEquals("Reverted unit of measure", "km", revertedSymbol.getUom());
textSymbol.setUom(null);
transcriptedText = se2gt.visit(textSymbol);
assertEquals("Converted unit of measure", Units.POINT, transcriptedText.getUnitOfMeasure());
revertedSymbol = gt2se.visit(transcriptedText, null).getValue();
assertEquals("Reverted unit of measure", "http://www.opengeospatial.org/se/units/pixel", revertedSymbol.getUom());
textSymbol.setUom("px");
transcriptedText = se2gt.visit(textSymbol);
assertEquals("Converted unit of measure", Units.POINT, transcriptedText.getUnitOfMeasure());
revertedSymbol = gt2se.visit(transcriptedText, null).getValue();
assertEquals("Reverted unit of measure", "http://www.opengeospatial.org/se/units/pixel", revertedSymbol.getUom());
textSymbol.setUom("meter");
transcriptedText = se2gt.visit(textSymbol);
assertEquals("Converted unit of measure", Units.METRE, transcriptedText.getUnitOfMeasure());
revertedSymbol = gt2se.visit(transcriptedText, null).getValue();
assertEquals("Reverted unit of measure", "http://www.opengeospatial.org/se/units/metre", revertedSymbol.getUom());
}
use of org.opengis.style.TextSymbolizer in project geotoolkit by Geomatys.
the class SE100toGTTransformer method visitRule.
/**
* Trasnform SLD v1.0 rule in GT Rule.
*/
public MutableRule visitRule(final org.geotoolkit.sld.xml.v100.Rule rt) {
final MutableRule rule = styleFactory.rule();
rule.setName(rt.getName());
final InternationalString title = (rt.getTitle() == null) ? null : new SimpleInternationalString(rt.getTitle());
final InternationalString abs = (rt.getAbstract() == null) ? null : new SimpleInternationalString(rt.getAbstract());
rule.setDescription(styleFactory.description(title, abs));
rule.setElseFilter(rt.getElseFilter() != null);
rule.setFilter(visitFilter(rt.getFilter()));
rule.setLegendGraphic(visitLegend(rt.getLegendGraphic()));
rule.setMaxScaleDenominator((rt.getMaxScaleDenominator() == null) ? Double.MAX_VALUE : rt.getMaxScaleDenominator());
rule.setMinScaleDenominator((rt.getMinScaleDenominator() == null) ? 0 : rt.getMinScaleDenominator());
if (rt.getSymbolizer() == null || rt.getSymbolizer().isEmpty()) {
} else {
for (final JAXBElement<? extends org.geotoolkit.sld.xml.v100.SymbolizerType> jax : rt.getSymbolizer()) {
final org.geotoolkit.sld.xml.v100.SymbolizerType st = jax.getValue();
if (st == null) {
continue;
}
if (st instanceof org.geotoolkit.sld.xml.v100.PointSymbolizer) {
final org.geotoolkit.sld.xml.v100.PointSymbolizer pst = (org.geotoolkit.sld.xml.v100.PointSymbolizer) st;
rule.symbolizers().add(visit(pst));
} else if (st instanceof org.geotoolkit.sld.xml.v100.LineSymbolizer) {
final org.geotoolkit.sld.xml.v100.LineSymbolizer pst = (org.geotoolkit.sld.xml.v100.LineSymbolizer) st;
rule.symbolizers().add(visit(pst));
} else if (st instanceof org.geotoolkit.sld.xml.v100.PolygonSymbolizer) {
final org.geotoolkit.sld.xml.v100.PolygonSymbolizer pst = (org.geotoolkit.sld.xml.v100.PolygonSymbolizer) st;
rule.symbolizers().add(visit(pst));
} else if (st instanceof org.geotoolkit.sld.xml.v100.TextSymbolizer) {
final org.geotoolkit.sld.xml.v100.TextSymbolizer pst = (org.geotoolkit.sld.xml.v100.TextSymbolizer) st;
rule.symbolizers().add(visit(pst));
} else if (st instanceof org.geotoolkit.sld.xml.v100.RasterSymbolizer) {
final org.geotoolkit.sld.xml.v100.RasterSymbolizer pst = (org.geotoolkit.sld.xml.v100.RasterSymbolizer) st;
rule.symbolizers().add(visit(pst));
}
}
}
return rule;
}
Aggregations