use of org.geotoolkit.sld.xml.v110.UserStyle 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.v110.UserStyle in project geotoolkit by Geomatys.
the class SEforSLD100Test method testStyle.
// //////////////////////////////////////////////////////////////////////////
// JAXB TEST MARSHELLING AND UNMARSHELLING FOR STYLE ORDERING //////////////
// //////////////////////////////////////////////////////////////////////////
@Test
public void testStyle() throws JAXBException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_SE_STYLE);
assertNotNull(obj);
UserStyle jax = (UserStyle) obj;
MutableStyle style = TRANSFORMER_GT.visitUserStyle(jax);
assertNotNull(style);
assertEquals(style.getName(), valueName);
assertEquals(style.getDescription().getTitle().toString(), valueTitle);
assertEquals(style.getDescription().getAbstract().toString(), valueAbstract);
assertEquals(style.isDefault(), true);
assertEquals(style.featureTypeStyles().size(), 3);
// Write test
UserStyle pvt = TRANSFORMER_OGC.visit(style, null);
assertNotNull(pvt);
assertEquals(pvt.getName(), valueName);
assertEquals(pvt.getTitle(), valueTitle);
assertEquals(pvt.getAbstract(), valueAbstract);
assertEquals(pvt.isIsDefault(), Boolean.TRUE);
assertEquals(pvt.getFeatureTypeStyle().size(), 3);
MARSHALLER.marshal(pvt, TEST_FILE_SE_STYLE);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.geotoolkit.sld.xml.v110.UserStyle in project geotoolkit by Geomatys.
the class SEforSLD110Test method testStyle.
// //////////////////////////////////////////////////////////////////////////
// JAXB TEST MARSHELLING AND UNMARSHELLING FOR STYLE ORDERING //////////////
// //////////////////////////////////////////////////////////////////////////
@Test
public void testStyle() throws JAXBException, FactoryException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_SE_STYLE);
assertNotNull(obj);
UserStyle jax = (UserStyle) obj;
MutableStyle style = TRANSFORMER_GT.visitUserStyle(jax);
assertNotNull(style);
assertEquals(style.getName(), valueName);
assertEquals(style.getDescription().getTitle().toString(), valueTitle);
assertEquals(style.getDescription().getAbstract().toString(), valueAbstract);
assertEquals(style.isDefault(), true);
assertEquals(style.featureTypeStyles().size(), 3);
// Write test
UserStyle pvt = TRANSFORMER_OGC.visit(style, null);
assertNotNull(pvt);
assertEquals(pvt.getName(), valueName);
assertEquals(String.valueOf(pvt.getDescription().getTitle()), valueTitle);
assertEquals(String.valueOf(pvt.getDescription().getAbstract()), valueAbstract);
assertEquals(pvt.isIsDefault(), Boolean.TRUE);
assertEquals(pvt.getFeatureTypeStyleOrCoverageStyleOrOnlineResource().size(), 3);
MARSHALLER.marshal(pvt, TEST_FILE_SE_STYLE);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.geotoolkit.sld.xml.v110.UserStyle in project geotoolkit by Geomatys.
the class SLD100toGTTransformer method visitStyles.
/**
* Transform a jaxb v1.0.0 layer style in a GT layer style class.
*/
public Collection<? extends MutableLayerStyle> visitStyles(final List<Object> styles) {
if (styles == null || styles.isEmpty()) {
return Collections.emptyList();
} else {
final Collection<MutableLayerStyle> mStyles = new ArrayList<MutableLayerStyle>();
for (final Object obj : styles) {
if (obj instanceof org.geotoolkit.sld.xml.v100.NamedStyle) {
final org.geotoolkit.sld.xml.v100.NamedStyle ns = (org.geotoolkit.sld.xml.v100.NamedStyle) obj;
final MutableNamedStyle mns = sldFactory.createNamedStyle();
mns.setName(ns.getName());
mStyles.add(mns);
} else if (obj instanceof org.geotoolkit.sld.xml.v100.UserStyle) {
final org.geotoolkit.sld.xml.v100.UserStyle us = (org.geotoolkit.sld.xml.v100.UserStyle) obj;
// we call SE transformer for this part
mStyles.add(visitUserStyle(us));
}
}
return mStyles;
}
}
use of org.geotoolkit.sld.xml.v110.UserStyle in project geotoolkit by Geomatys.
the class OwcXmlIO method toStyleSet.
private static StyleSetType toStyleSet(Style style, boolean def) {
final StyleSetType styleSet = OWC_FACTORY.createStyleSetType();
styleSet.setDefault(def);
final ContentType content = OWC_FACTORY.createContentType();
final StyleXmlIO io = new StyleXmlIO();
final UserStyle jaxbStyle = io.getTransformerXMLv110().visit(style, null);
content.getContent().add(jaxbStyle);
styleSet.getNameOrTitleOrAbstract().add(OWC_FACTORY.createStyleSetTypeContent(content));
return styleSet;
}
Aggregations