Search in sources :

Example 1 with UserStyle

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;
}
Also used : UserStyle(org.geotoolkit.sld.xml.v110.UserStyle) ContentType(org.geotoolkit.owc.xml.v10.ContentType) StyleSetType(org.geotoolkit.owc.xml.v10.StyleSetType) StyleXmlIO(org.geotoolkit.sld.xml.StyleXmlIO) JAXBElement(javax.xml.bind.JAXBElement)

Example 2 with UserStyle

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);
}
Also used : UserStyle(org.geotoolkit.sld.xml.v100.UserStyle) Marshaller(javax.xml.bind.Marshaller) MutableStyle(org.geotoolkit.style.MutableStyle) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test)

Example 3 with UserStyle

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);
}
Also used : UserStyle(org.geotoolkit.sld.xml.v110.UserStyle) Marshaller(javax.xml.bind.Marshaller) MutableStyle(org.geotoolkit.style.MutableStyle) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test)

Example 4 with UserStyle

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;
    }
}
Also used : UserStyle(org.geotoolkit.sld.xml.v100.UserStyle) MutableNamedStyle(org.geotoolkit.sld.MutableNamedStyle) ArrayList(java.util.ArrayList) MutableNamedStyle(org.geotoolkit.sld.MutableNamedStyle) UserStyle(org.geotoolkit.sld.xml.v100.UserStyle) MutableLayerStyle(org.geotoolkit.sld.MutableLayerStyle)

Example 5 with UserStyle

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;
}
Also used : UserStyle(org.geotoolkit.sld.xml.v110.UserStyle) ContentType(org.geotoolkit.owc.xml.v10.ContentType) StyleSetType(org.geotoolkit.owc.xml.v10.StyleSetType) StyleXmlIO(org.geotoolkit.sld.xml.StyleXmlIO)

Aggregations

UserStyle (org.geotoolkit.sld.xml.v110.UserStyle)5 ArrayList (java.util.ArrayList)3 Marshaller (javax.xml.bind.Marshaller)2 Unmarshaller (javax.xml.bind.Unmarshaller)2 ContentType (org.geotoolkit.owc.xml.v10.ContentType)2 StyleSetType (org.geotoolkit.owc.xml.v10.StyleSetType)2 MutableLayerStyle (org.geotoolkit.sld.MutableLayerStyle)2 MutableNamedStyle (org.geotoolkit.sld.MutableNamedStyle)2 StyleXmlIO (org.geotoolkit.sld.xml.StyleXmlIO)2 UserStyle (org.geotoolkit.sld.xml.v100.UserStyle)2 MutableStyle (org.geotoolkit.style.MutableStyle)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 JAXBElement (javax.xml.bind.JAXBElement)1 DocumentComparator (org.apache.sis.test.xml.DocumentComparator)1 DescriptionType (org.geotoolkit.se.xml.v110.DescriptionType)1 FeatureTypeStyleType (org.geotoolkit.se.xml.v110.FeatureTypeStyleType)1 StyledLayerDescriptor (org.geotoolkit.sld.xml.v110.StyledLayerDescriptor)1 UserLayer (org.geotoolkit.sld.xml.v110.UserLayer)1