/** * Retrieve the default style from the given StyledLayerDescriptor. * * @param sld the StyledLayerDescriptor object * @return the default style; or the first style if no default is defined; or null if there are * not styles */ public static Style defaultStyle(StyledLayerDescriptor sld) { Style[] style = styles(sld); for (int i = 0; i < style.length; i++) { if (style[i].isDefault()) { return style[i]; } } // no default, so just grab the first one if (style.length == 0) { return null; } return style[0]; }
/** * Convenience method for grabbing the default style from the StyledLayerDescriptor. * * @return first Style (in SLD-->UserLayers-->UserStyles) that claims to be the default */ public Style getDefaultStyle() { // descend into the layers for (int i = 0; i < layers.size(); i++) { StyledLayer layer = (StyledLayer) layers.get(i); if (layer instanceof UserLayer) { UserLayer userLayer = (UserLayer) layer; // descend into the styles Style[] styles = userLayer.getUserStyles(); for (int j = 0; j < styles.length; j++) { // return the first style that claims to be the default if (styles[j].isDefault()) { return styles[j]; } } } } return null; }
public StyleBuilder reset(Style style) { if (style == null) { return unset(); } fts.clear(); for (FeatureTypeStyle ft : style.featureTypeStyles()) { fts.add(new FeatureTypeStyleBuilder(this).reset(ft)); } name = style.getName(); styleAbstract = style.getAbstract(); title = style.getTitle(); isDefault = style.isDefault(); unset = false; return this; }
public static Style defaultStyle(StyledLayerDescriptor sld) { Style[] style = styles(sld); for (int i = 0; i < style.length; i++) { if (style[i].isDefault()) { return style[i]; } } //no default, so just grab the first one return style[0]; }
/** * Retrieve the default style from the given StyledLayerDescriptor. * * @param sld the StyledLayerDescriptor object * * @return the default style; or the first style if no default is * defined; or null if there are not styles */ public static Style defaultStyle(StyledLayerDescriptor sld) { Style[] style = styles(sld); for (int i = 0; i < style.length; i++) { if (style[i].isDefault()) { return style[i]; } } //no default, so just grab the first one if (style.length == 0) { return null; } return style[0]; }
/** * Convenience method for grabbing the default style from the * StyledLayerDescriptor. * * @return first Style (in SLD-->UserLayers-->UserStyles) that claims to be * the default */ public Style getDefaultStyle() { //descend into the layers for (int i = 0; i < layers.size(); i++) { StyledLayer layer = (StyledLayer) layers.get(i); if (layer instanceof UserLayer) { UserLayer userLayer = (UserLayer) layer; //descend into the styles Style[] styles = userLayer.getUserStyles(); for (int j = 0; j < styles.length; j++) { //return the first style that claims to be the default if (styles[j].isDefault()) { return styles[j]; } } } } return null; }
/** * Convenience method for grabbing the default style from the * StyledLayerDescriptor. * * @return first Style (in SLD-->UserLayers-->UserStyles) that claims to be * the default */ public Style getDefaultStyle() { //descend into the layers for (int i = 0; i < layers.size(); i++) { StyledLayer layer = (StyledLayer) layers.get(i); if (layer instanceof UserLayer) { UserLayer userLayer = (UserLayer) layer; //descend into the styles Style[] styles = userLayer.getUserStyles(); for (int j = 0; j < styles.length; j++) { //return the first style that claims to be the default if (styles[j].isDefault()) { return styles[j]; } } } } return null; }
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"); } }
/** * Populate. * * @param selectedSymbol the selected symbol */ /* * (non-Javadoc) * * @see com.sldeditor.ui.iface.PopulateDetailsInterface#populate(com.sldeditor.ui.detail.selectedsymbol.SelectedSymbol) */ @Override public void populate(SelectedSymbol selectedSymbol) { if (selectedSymbol != null) { Style style = selectedSymbol.getStyle(); populateStandardData(style); if (style != null) { fieldConfigVisitor.populateBooleanField( FieldIdEnum.DEFAULT_STYLE, style.isDefault()); } } }
if(styleName == null || styleName.equals("") && styles[j].isDefault()) style = styles[j]; else if(styleName != null && styleName.equals(styles[j].getName())) if((styleName == null || styleName.equals("")) && styles[j].isDefault()) style = styles[j]; else if(styleName != null && styleName.equals(styles[j].getName()))
if (styleName == null || styleName.equals("") && styles[j].isDefault()) style = styles[j]; else if (styleName != null && styleName.equals(styles[j].getName())) if ((styleName == null || styleName.equals("")) && styles[j].isDefault()) style = styles[j]; else if (styleName != null && styleName.equals(styles[j].getName()))
@Test public void testMultiStyle() throws Exception { InputStream stream = get( "wms?service=WMS&version=1.1.1&request=GetStyles&layers=" + getLayerId(MockData.LAKES) + "&sldver=1.0.0"); SLDParser parser = new SLDParser(CommonFactoryFinder.getStyleFactory(null)); parser.setInput(stream); StyledLayerDescriptor sld = parser.parseSLD(); assertEquals(1, sld.getStyledLayers().length); NamedLayer layer = (NamedLayer) sld.getStyledLayers()[0]; assertEquals(getLayerId(MockData.LAKES), layer.getName()); assertEquals(2, layer.styles().size()); Style style = layer.styles().get(0); assertTrue(style.isDefault()); assertEquals("Lakes", style.getName()); style = layer.styles().get(1); assertFalse(style.isDefault()); assertEquals("Forests", style.getName()); } }
@Test public void testSimple() throws Exception { InputStream stream = get( "wms?service=WMS&version=1.1.1&&request=GetStyles&layers=" + getLayerId(MockData.BASIC_POLYGONS) + "&sldver=1.0.0"); SLDParser parser = new SLDParser(CommonFactoryFinder.getStyleFactory(null)); parser.setInput(stream); StyledLayerDescriptor sld = parser.parseSLD(); assertEquals(1, sld.getStyledLayers().length); NamedLayer layer = (NamedLayer) sld.getStyledLayers()[0]; assertEquals(getLayerId(MockData.BASIC_POLYGONS), layer.getName()); assertEquals(1, layer.styles().size()); Style style = layer.styles().get(0); assertTrue(style.isDefault()); assertEquals("BasicPolygons", style.getName()); }
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"); } }