Package org.geotools.styling

Examples of org.geotools.styling.StyledLayerDescriptor


        try {
            Parser parser = new Parser( config );
            reader = new FileReader(file);
            Object object = parser.parse( reader );
            if( object instanceof StyledLayerDescriptor){
                StyledLayerDescriptor sld = (StyledLayerDescriptor) object;
                return sld;
            }
            else if ( object instanceof NamedStyle ){
                NamedStyle style = (NamedStyle) object;
                StyledLayerDescriptor sld = createDefaultSLD( style );
                return sld;
            }
        }
        catch(Exception ignore){
            // we are ignoring this error and will try the more forgiving option below
            UiPlugin.trace(SLDs.class,"SLD 1.1 configuration failed to parse "+file, ignore);
        }
        finally {
            if( reader != null){
                reader.close();
            }
        }
        // parse it up
        SLDParser parser = new SLDParser(styleFactory);
        try {
            parser.setInput(file);
            StyledLayerDescriptor sld = parser.parseSLD();
            return sld;
        } catch (FileNotFoundException e) {
            return null; // well that is unexpected since f.exists()
        }
    }
View Full Code Here


        try {
            Parser parser = new Parser( config );
            input = url.openStream();
            Object object = parser.parse( input );
            if( object instanceof StyledLayerDescriptor){
                StyledLayerDescriptor sld = (StyledLayerDescriptor) object;
                Style[] array = SLDs.styles( sld );
                if( array != null && array.length > 0 ){
                    return array[0];
                }
            }
View Full Code Here

        try {
            Parser parser = new Parser( config );
            reader = new FileReader(file);
            Object object = parser.parse( reader );
            if( object instanceof StyledLayerDescriptor){
                StyledLayerDescriptor sld = (StyledLayerDescriptor) object;
                Style[] array = SLDs.styles( sld );
                if( array != null && array.length > 0 ){
                    return array[0];
                }
            }
View Full Code Here

     * @see net.refractions.project.internal.render.SelectionStyleContent#createDefaultStyledLayerDescriptor
     * @param style
     * @return SLD
     */
    public static StyledLayerDescriptor createDefaultSLD(Style style) {
        StyledLayerDescriptor sld = sf.createStyledLayerDescriptor();
        UserLayer layer = sf.createUserLayer();
        //FeatureTypeConstraint ftc = styleFactory.createFeatureTypeConstraint(null, Filter.INCLUDE, null);
        layer.setLayerFeatureConstraints(new FeatureTypeConstraint[] {null});
        sld.addStyledLayer(layer);
        layer.addUserStyle(style);
        return sld;
    }
View Full Code Here

     * @param style the style to convert.
     * @return the style string.
     * @throws Exception
     */
    public String toXml() throws Exception {
        StyledLayerDescriptor sld = sf.createStyledLayerDescriptor();
        UserLayer layer = sf.createUserLayer();
        layer.setLayerFeatureConstraints(new FeatureTypeConstraint[]{null});
        sld.addStyledLayer(layer);
        layer.addUserStyle(style);

        SLDTransformer aTransformer = new SLDTransformer();
        aTransformer.setIndentation(4);
        String xml = aTransformer.transform(sld);
View Full Code Here

        });

        List<StyleWrapper> newStylesList = new ArrayList<StyleWrapper>();
        for( File file : sldFilesArray ) {
            try {
                StyledLayerDescriptor sld = readStyle(file);
                Style style = SLDs.getDefaultStyle(sld);
                String name = FilenameUtils.removeExtension(file.getName());
                style.setName(name);

                StyleWrapper styleWrapper = new StyleWrapper(style);
View Full Code Here

     * @return the styled layer descriptor.
     * @throws IOException
     */
    public static StyledLayerDescriptor readStyle( File file ) throws IOException {
        SLDParser stylereader = new SLDParser(sf, file);
        StyledLayerDescriptor sld = stylereader.parseSLD();
        return sld;
    }
View Full Code Here

     * @param style the style to convert.
     * @return the style string.
     * @throws Exception
     */
    public static String styleToString( Style style ) throws Exception {
        StyledLayerDescriptor sld = sf.createStyledLayerDescriptor();
        UserLayer layer = sf.createUserLayer();
        layer.setLayerFeatureConstraints(new FeatureTypeConstraint[]{null});
        sld.addStyledLayer(layer);
        layer.addUserStyle(style);

        SLDTransformer aTransformer = new SLDTransformer();
        aTransformer.setIndentation(4);
        String xml = aTransformer.transform(sld);
View Full Code Here

        if (name.toLowerCase().endsWith(".png")) {
            exGraphic = sf.createExternalGraphic(graphicsPath.toURI().toURL(), "image/png");
        } else if (name.toLowerCase().endsWith(".svg")) {
            exGraphic = sf.createExternalGraphic(graphicsPath.toURI().toURL(), "image/svg+xml");
        } else if (name.toLowerCase().endsWith(".sld")) {
            StyledLayerDescriptor sld = readStyle(graphicsPath);
            Style style = SLDs.getDefaultStyle(sld);
            return new StyleWrapper(style);
        }

        if (exGraphic == null) {
View Full Code Here

    public static Style parse(URL url) throws IOException {
        return SLDs.parseStyle(url);
    }
   
    public static StyledLayerDescriptor createDefaultStyledLayerDescriptor() {
        StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
        return sld;
    }
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.