use of org.geotoolkit.owc.xml.v10.StyleSetType 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.owc.xml.v10.StyleSetType in project geotoolkit by Geomatys.
the class OwcXmlIO method toEntry.
private static void toEntry(String parentPath, final MapItem item, List entries) {
final EntryType entry = ATOM_FACTORY.createEntryType();
entries.add(ATOM_FACTORY.createFeedTypeEntry(entry));
// store other informations
final String name = ((parentPath != null) ? parentPath : "") + item.getIdentifier();
final CharSequence title = item.getTitle();
final CharSequence abstrat = item.getAbstract();
if (name != null) {
final IdType atom = new IdType();
atom.setValue(name);
entry.getAuthorOrCategoryOrContent().add(ATOM_FACTORY.createEntryTypeId(atom));
}
if (title != null) {
final TextType atom = new TextType();
atom.setType(TextTypeType.TEXT);
atom.getContent().add(title.toString());
entry.getAuthorOrCategoryOrContent().add(ATOM_FACTORY.createEntryTypeTitle(atom));
}
if (abstrat != null) {
final TextType atom = new TextType();
atom.setType(TextTypeType.TEXT);
atom.getContent().add(abstrat.toString());
entry.getAuthorOrCategoryOrContent().add(ATOM_FACTORY.createEntryTypeSummary(atom));
}
if (item instanceof MapLayer) {
final MapLayer layer = (MapLayer) item;
entry.getAuthorOrCategoryOrContent().add(GEOTK_FACTORY.createVisible(layer.isVisible()));
entry.getAuthorOrCategoryOrContent().add(GEOTK_FACTORY.createOpacity(layer.getOpacity()));
OfferingType offering = null;
for (OwcExtension ext : getExtensions()) {
if (ext.canHandle(layer)) {
offering = ext.createOffering(layer);
entry.getAuthorOrCategoryOrContent().add(OWC_FACTORY.createOffering(offering));
break;
}
}
// store styles
if (offering != null) {
if (layer.getStyle() != null) {
final StyleSetType styleBase = toStyleSet(layer.getStyle(), true);
offering.getOperationOrContentOrStyleSet().add(OWC_FACTORY.createOfferingTypeStyleSet(styleBase));
}
}
} else if (item instanceof MapLayers) {
final MapLayers mc = (MapLayers) item;
final ContentType content = OWC_FACTORY.createContentType();
content.setType(mc.getIdentifier());
// encode children
for (MapItem child : mc.getComponents()) {
toEntry(name + "/", child, entries);
}
entry.getAuthorOrCategoryOrContent().add(OWC_FACTORY.createOfferingTypeContent(content));
}
}
use of org.geotoolkit.owc.xml.v10.StyleSetType 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