assertEquals( "A orange generic style", style.getDescription().getTitle().toString()); assertEquals(1, style.featureTypeStyles().size()); FeatureTypeStyle fts = style.featureTypeStyles().get(0); assertEquals( "raster", fts.rules().get(0).getDescription().getTitle().toString()); assertEquals( "orange polygon", fts.rules().get(1).getDescription().getTitle().toString()); assertEquals( "orange line", fts.rules().get(2).getDescription().getTitle().toString()); assertEquals( "orange point", fts.rules().get(3).getDescription().getTitle().toString());
@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; } });
public DescriptionBuilder reset(Description original) { unset = false; title = original.getTitle(); description = original.getAbstract(); return this; }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { StyledLayerDescriptor sld = (StyledLayerDescriptor) super.parse(instance, node, value); if (node.hasChild("Description")) { Description desc = (Description) node.getChildValue("Description"); if (desc.getAbstract() != null) { sld.setAbstract(desc.getAbstract().toString()); } if (desc.getTitle() != null) { sld.setTitle(desc.getTitle().toString()); } } return sld; } }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { NamedStyle style = (NamedStyle) 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()); } return style; } }
/** * * <!-- 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; } }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { FeatureTypeStyle fts = (FeatureTypeStyle) super.parse(instance, node, value); if (node.hasChild("Description")) { Description d = (Description) node.getChildValue("Description"); fts.getDescription().setTitle(d.getTitle()); fts.getDescription().setAbstract(d.getAbstract()); } return fts; } }
public void visit(FeatureTypeStyle fts) { start("FeatureTypeStyle"); if ((fts.getName() != null) && (fts.getName().length() > 0)) { element("Name", fts.getName()); } if (fts.getDescription() != null && fts.getDescription().getTitle() != null) element("Title", fts.getDescription().getTitle()); if (fts.getDescription() != null && fts.getDescription().getAbstract() != null) element("Abstract", fts.getDescription().getAbstract()); if ((fts.featureTypeNames() != null) && (fts.featureTypeNames().size() > 0)) { element("FeatureTypeName", fts.featureTypeNames().iterator().next().toString()); } if (fts.getTransformation() != null) { element("Transformation", fts.getTransformation()); } String[] sti = fts.getSemanticTypeIdentifiers(); if (sti.length != 1 || !sti[0].equals(SemanticType.ANY.toString())) { for (int i = 0; i < sti.length; i++) { element("SemanticTypeIdentifier", sti[i]); } } Rule[] rules = fts.getRules(); for (int i = 0; i < rules.length; i++) { rules[i].accept(this); } encodeVendorOptions(fts.getOptions()); end("FeatureTypeStyle"); }
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 void visit(Rule rule) { start("Rule"); if (rule.getName() != null) element("Name", rule.getName()); if (rule.getDescription() != null && rule.getDescription().getTitle() != null) element("Title", rule.getDescription().getTitle()); if (rule.getDescription() != null && rule.getDescription().getAbstract() != null) element("Abstract", rule.getDescription().getAbstract());
@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; } }
/** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { StyledLayerDescriptor sld = (StyledLayerDescriptor) super.parse(instance, node, value); if (node.hasChild("Description")) { Description desc = (Description) node.getChildValue("Description"); if (desc.getAbstract() != null) { sld.setAbstract(desc.getAbstract().toString()); } if (desc.getTitle() != null) { sld.setTitle(desc.getTitle().toString()); } } return sld; }
static String getRuleLabel(Rule rule, GetLegendGraphicRequest req) { // What's the label on this rule? We prefer to use // the 'title' if it's available, but fall-back to 'name' final Description description = rule.getDescription(); String label = ""; if (description != null && description.getTitle() != null) { final InternationalString title = description.getTitle(); if (req.getLocale() != null) { label = title.toString(req.getLocale()); } else { label = title.toString(); } } else if (rule.getName() != null) { label = rule.getName(); } 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()); } }
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(); } }
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; }
/** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { NamedStyle style = (NamedStyle) 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()); } return style; }
/** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { FeatureTypeStyle fts = (FeatureTypeStyle) super.parse(instance, node, value); if (node.hasChild("Description")) { Description d = (Description) node.getChildValue("Description"); fts.getDescription().setTitle(d.getTitle()); fts.getDescription().setAbstract(d.getAbstract()); } //TODO: version if (node.hasChild("version")) { } return fts; }