@Override public Void answer() throws Throwable { Object[] args = getCurrentArguments(); InputStream is = (InputStream) args[1]; byte[] input = IOUtils.toByteArray(is); SLDParser parser = new SLDParser(CommonFactoryFinder.getStyleFactory()); parser.setInput(new ByteArrayInputStream(input)); StyledLayerDescriptor sld = parser.parseSLD(); NamedLayer nl = (NamedLayer) sld.getStyledLayers()[0]; assertEquals("foo", nl.getName()); Style style = nl.getStyles()[0]; assertEquals( "A raster style", style.getDescription().getTitle().toString()); assertEquals(1, style.featureTypeStyles().size()); FeatureTypeStyle fts = style.featureTypeStyles().get(0); assertEquals(1, fts.rules().size()); assertThat( fts.rules().get(0).symbolizers().get(0), instanceOf(RasterSymbolizer.class)); // make sure it's valid SLDValidator validator = new SLDValidator(); List errors = validator.validateSLD(new ByteArrayInputStream(input)); assertEquals(0, errors.size()); return null; } });
assertEquals( "A orange generic style", style.getDescription().getTitle().toString()); assertEquals(1, style.featureTypeStyles().size()); FeatureTypeStyle fts = style.featureTypeStyles().get(0);
} else if (childName.equalsIgnoreCase("Title")) { style.getDescription().setTitle(parseInternationalString(child)); } else if (childName.equalsIgnoreCase("Abstract")) { style.getDescription().setAbstract(parseInternationalString(child)); } else if (childName.equalsIgnoreCase("IsDefault")) { if ("1".equals(firstChildValue)) {
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { Style style = (Style) super.parse(instance, node, value); if (node.hasChild("Description")) { Description desc = (Description) node.getChildValue("Description"); style.getDescription().setAbstract(desc.getAbstract()); style.getDescription().setTitle(desc.getTitle()); } // TODO: OnlineResource return style; } }
public void visit(Style style) { if (style instanceof NamedStyle) { start("NamedStyle"); element("Name", style.getName()); end("NamedStyle"); } else { start("UserStyle"); element("Name", style.getName()); if (style.getDescription() != null && style.getDescription().getTitle() != null) element("Title", style.getDescription().getTitle()); if (style.isDefault()) { element("IsDefault", "1"); } if (style.getDescription() != null && style.getDescription().getAbstract() != null) element("Abstract", style.getDescription().getAbstract()); FeatureTypeStyle[] fts = style.getFeatureTypeStyles(); for (int i = 0; i < fts.length; i++) { visit(fts[i]); } end("UserStyle"); } }
public Style build() { if (unset) { return null; } Style s; if (fts.size() == 0) { s = sf.createNamedStyle(); s.setName(name); } else { s = sf.createStyle(); s.setName(name); if (styleAbstract != null) s.getDescription().setAbstract(new SimpleInternationalString(styleAbstract)); if (title != null) s.getDescription().setTitle(new SimpleInternationalString(title)); for (FeatureTypeStyleBuilder builder : fts) { s.featureTypeStyles().add(builder.build()); } s.setDefault(isDefault); } reset(); return s; }
style.getDescription().setTitle((InternationalString) node.getChildValue("Title")); style.getDescription() .setAbstract((InternationalString) node.getChildValue("Abstract"));
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); String text = null; if (value != null) { Style style = (Style) value; InternationalString title = style.getDescription().getTitle(); if (title != null) { text = title.toString(); }else { text = "Default Styler"; } } label.setText(text); return label; } }
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); String text = null; if (value != null) { Style style = (Style) value; InternationalString title = style.getDescription().getTitle(); if (title != null) { text = title.toString(); }else { text = "Default Styler"; } } label.setText(text); return label; } }
private void handleCommonStyleElements(StyleInfo styleInfo) { Style ftStyle; try { ftStyle = styleInfo.getStyle(); } catch (IOException e) { throw new RuntimeException(e); } element("Name", styleInfo.prefixedName()); if (ftStyle.getDescription() != null) { if (ftStyle.getDescription().getTitle() != null) { element("Title", ftStyle.getDescription().getTitle()); } else { // Title is not required by the SLD spec, but it is required // by the WMS 1.1 DTD so we have to provide something. element("Title", styleInfo.prefixedName()); } element("Abstract", ftStyle.getDescription().getAbstract()); } }
/** * Populate standard data. * * @param style the style */ protected void populateStandardData(Style style) { StandardData standardData = new StandardData(); if (style != null) { standardData.name = style.getName(); standardData.description = style.getDescription(); } populateStandardData(standardData); }
} else if (childName.equalsIgnoreCase("Title")) { style.getDescription().setTitle(parseInternationalString(child)); } else if (childName.equalsIgnoreCase("Abstract")) { style.getDescription().setAbstract(parseInternationalString(child)); } else if (childName.equalsIgnoreCase("IsDefault")) { if("1".equals(firstChildValue)) {
private void handleCommonStyleElements(StyleInfo defaultStyle) { Style ftStyle; try { ftStyle = defaultStyle.getStyle(); } catch (IOException e) { throw new RuntimeException(e); } element("Name", defaultStyle.prefixedName()); if (ftStyle.getDescription() != null) { // PMT: WMS capabilities requires at least a title, // if description's title is null, use the name // for title. if (ftStyle.getDescription().getTitle() != null) { element("Title", ftStyle.getDescription().getTitle()); } else { element("Title", defaultStyle.prefixedName()); } element("Abstract", ftStyle.getDescription().getAbstract()); } else { element("Title", defaultStyle.prefixedName()); } }
/** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { Style style = (Style) super.parse(instance, node, value); if (node.hasChild("Description")) { Description desc = (Description) node.getChildValue("Description"); style.getDescription().setAbstract(desc.getAbstract()); style.getDescription().setTitle(desc.getTitle()); } //TODO: OnlineResource return style; }
public void visit(Style style) { if (style instanceof NamedStyle) { start("NamedStyle"); element("Name", style.getName()); end("NamedStyle"); } else { start("UserStyle"); element("Name", style.getName()); if (style.getDescription() != null && style.getDescription().getTitle() != null) element("Title", style.getDescription().getTitle()); if(style.isDefault()) { element("IsDefault", "1"); } if (style.getDescription() != null && style.getDescription().getAbstract() != null) element("Abstract", style.getDescription().getAbstract()); FeatureTypeStyle[] fts = style.getFeatureTypeStyles(); for (int i = 0; i < fts.length; i++) { visit(fts[i]); } end("UserStyle"); } }
private String findTitle(Layer layer, Catalog catalog) { if (layer.getTitle() == null) { return null; } String[] nameparts = layer.getTitle().split(":"); ResourceInfo resource = nameparts.length > 1 ? catalog.getResourceByName(nameparts[0], nameparts[1], ResourceInfo.class) : catalog.getResourceByName(nameparts[0], ResourceInfo.class); if (useSldTitle && layer.getStyle() != null && layer.getStyle().getDescription() != null && layer.getStyle().getDescription().getTitle() != null) { return layer.getStyle().getDescription().getTitle().toString(); } if (resource != null) { return resource.getTitle(); } else { return layer.getTitle(); } }
style.getDescription().setTitle( (InternationalString) node.getChildValue("Title")); style.getDescription().setAbstract( (InternationalString) node.getChildValue("Abstract"));