use of org.geotoolkit.sld.xml.StyleXmlIO in project geotoolkit by Geomatys.
the class PatternSymbolizerTest method testXml.
/**
* Test Jaxb xml support.
*/
@Test
public void testXml() throws JAXBException, IOException {
final MutableStyleFactory SF = GO2Utilities.STYLE_FACTORY;
final FilterFactory2 FF = GO2Utilities.FILTER_FACTORY;
final Map<Expression, List<Symbolizer>> ranges = new LinkedHashMap<>();
ranges.put(FF.literal(-1000), Arrays.asList(SF.polygonSymbolizer(null, SF.fill(Color.BLUE), null)));
ranges.put(FF.literal(-500), Arrays.asList(SF.polygonSymbolizer(null, SF.fill(Color.RED), null)));
ranges.put(FF.literal(-100), Arrays.asList(SF.polygonSymbolizer(null, SF.fill(Color.GREEN), null)));
ranges.put(FF.literal(100), Arrays.asList(SF.polygonSymbolizer(null, SF.fill(Color.YELLOW), null)));
ranges.put(FF.literal(1000), Arrays.asList(SF.polygonSymbolizer(null, SF.fill(Color.GRAY), null)));
final PatternSymbolizer ps = new PatternSymbolizer(FF.literal(0), ranges, ThreshholdsBelongTo.PRECEDING);
final MutableStyle style = GO2Utilities.STYLE_FACTORY.style(ps);
final Path path = Files.createTempFile("xml", ".xml");
IOUtilities.deleteOnExit(path);
new StyleXmlIO().writeStyle(path, style, Specification.StyledLayerDescriptor.V_1_1_0);
}
use of org.geotoolkit.sld.xml.StyleXmlIO in project geotoolkit by Geomatys.
the class OwcXmlIO method readStyle.
private static MutableStyle readStyle(OfferingType offering, boolean def) throws JAXBException, FactoryException {
final List<Object> content = offering.getOperationOrContentOrStyleSet();
for (Object co : content) {
if (co instanceof JAXBElement)
co = ((JAXBElement) co).getValue();
if (!(co instanceof StyleSetType))
continue;
final StyleSetType sst = (StyleSetType) co;
if (sst.isDefault() != def)
continue;
final List<Object> ssc = sst.getNameOrTitleOrAbstract();
for (Object ss : ssc) {
if (ss instanceof JAXBElement)
ss = ((JAXBElement) ss).getValue();
if (!(ss instanceof ContentType))
continue;
final ContentType ct = (ContentType) ss;
final List<Object> subcs = ct.getContent();
for (Object subc : subcs) {
if (subc instanceof JAXBElement)
subc = ((JAXBElement) subc).getValue();
if (!(subc instanceof UserStyle))
continue;
final StyleXmlIO io = new StyleXmlIO();
return io.readStyle(subc, Specification.SymbologyEncoding.V_1_1_0);
}
}
}
return null;
}
use of org.geotoolkit.sld.xml.StyleXmlIO in project geotoolkit by Geomatys.
the class PatternSymbolizer method setChannel.
public void setChannel(Expression value) {
this.channel = value;
this.channelType = new StyleXmlIO().getTransformerXMLv110().visitExpression(value);
}
use of org.geotoolkit.sld.xml.StyleXmlIO in project geotoolkit by Geomatys.
the class PatternSymbolizer method getRanges.
public Map<Expression, List<Symbolizer>> getRanges() {
if (thredholds == null && range != null) {
thredholds = new TreeMap<>(new ExpComparator());
final SLD110toGTTransformer io = new StyleXmlIO().getTransformer110();
final Map<Expression, List<Symbolizer>> visitRanges = io.visitRanges(range);
thredholds.putAll(visitRanges);
}
return thredholds;
}
use of org.geotoolkit.sld.xml.StyleXmlIO in project geotoolkit by Geomatys.
the class PatternSymbolizer method setRanges.
public void setRanges(Map<Expression, List<Symbolizer>> range) {
this.thredholds = new TreeMap<>(new ExpComparator());
if (range != null)
this.thredholds.putAll(range);
final GTtoSLD110Transformer io = new StyleXmlIO().getTransformerXMLv110();
final List<JAXBElement<RangeType>> ranges = new ArrayList<>();
for (Entry<Expression, List<Symbolizer>> entry : this.thredholds.entrySet()) {
final JAXBElement<RangeType> rt = io.visitRange(entry.getKey(), entry.getValue());
ranges.add(rt);
}
this.range = ranges;
}
Aggregations