Package org.geotools.styling

Examples of org.geotools.styling.StyledLayerDescriptor


     * @param style The UserStyle.
     *
     * @return The StyledLayerDescriptor.
     */
    public static StyledLayerDescriptor sld(Style style) {
        StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
       
        NamedLayer layer = styleFactory.createNamedLayer();
        layer.setName(style.getName());
        sld.addStyledLayer(layer);
       
        layer.addStyle(style);
       
        return sld;
    }
View Full Code Here


                + 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());
View Full Code Here

        InputStream stream = get("wms?service=WMS&version=1.1.1&request=GetStyles&layers=lakesGroup&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("lakesGroup", layer.getName());
       
        // groups have no style
        assertEquals(0, layer.styles().size());
    }
View Full Code Here

                + 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());
View Full Code Here

    @Override
    public Object decode(InputStream input) throws Exception {
        Parser p = new Parser(sldConfiguration);

        // extract the first style in the first sld
        StyledLayerDescriptor sld = (StyledLayerDescriptor) p.parse(input);
        NamedLayer styledLayer = (NamedLayer) sld.getStyledLayers()[0];
        return styledLayer.getStyles()[0];
    }
View Full Code Here

    }

    @Override
    public void encode(Object obj, ContentHandler handler) throws Exception {
        StyleFactory sf = CommonFactoryFinder.getStyleFactory(null);
        StyledLayerDescriptor sld = sf.createStyledLayerDescriptor();
        NamedLayer nl = sf.createNamedLayer();
        nl.setName("");
        nl.styles().add((Style) obj);
        sld.setStyledLayers(new StyledLayer[] { nl });

        Encoder e = new Encoder(sldConfiguration);
        e.encode(sld, element, handler);
    }
View Full Code Here

    @Override
    public Object decode(Object input) throws Exception {
        Parser p = new Parser(sldConfiguration);

        // extract the first style in the first sld
        StyledLayerDescriptor sld = (StyledLayerDescriptor) p.parse(new StringReader((String) input));
        NamedLayer styledLayer = (NamedLayer) sld.getStyledLayers()[0];
        return styledLayer.getStyles()[0];
    }
View Full Code Here

      final byte[] rulesBinary ) {
    final SLDParser parser = new SLDParser(
        CommonFactoryFinder.getStyleFactory(null),
        new ByteArrayInputStream(
            rulesBinary));
    final StyledLayerDescriptor sld = parser.parseSLD();
    final List<StyledLayer> layers = sld.layers();
    if ((layers != null) && !layers.isEmpty()) {
      // drill down to eventually get the rules from the sld
      for (final StyledLayer l : layers) {
        if (l instanceof NamedLayer) {
          final Style[] styles = ((NamedLayer) l).getStyles();
View Full Code Here

    fts.add(styleFactory.createFeatureTypeStyle(rules));
    final NamedLayer nl = styleFactory.createNamedLayer();
    nl.setName("");
    nl.addStyle(style);

    final StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
    sld.setStyledLayers(new StyledLayer[] {
      nl
    });
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final SLDTransformer writer = new SLDTransformer();
    try {
View Full Code Here

        final IModel<String> sldModel = new AbstractReadOnlyModel<String>() {
            public String getObject() {
                try {
                    // if file already in css format transform to sld, otherwise load the SLD file
                    if (CssHandler.FORMAT.equals(style.getFormat())) {
                        StyledLayerDescriptor sld = Styles.sld(style.getStyle());
                        return Styles.string(sld, new SLDHandler(), SLDHandler.VERSION_10, true);
                    } else {
                        File file = findStyleFile(style);
                        if (file != null && file.isFile()) {
                            BufferedReader reader = null;
View Full Code Here

TOP

Related Classes of org.geotools.styling.StyledLayerDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.