Examples of StyleInfo


Examples of org.geoserver.catalog.StyleInfo

    }

    public void updateStyleImage(AjaxRequestTarget target) {
        String url = wmsURL
                + "REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&STRICT=false&style=";
        StyleInfo styleInfo = (StyleInfo) styleInfoModel.getObject();
        if (styleInfo != null) {
            String style = styleInfo.getName();
            url += style;
            image.add(new AttributeModifier("src", new Model(url)));
            if (target != null) {
                target.addComponent(image);
            }
View Full Code Here

Examples of org.geoserver.catalog.StyleInfo

            handleMetadataList(layer.getResource().getMetadataLinks());

            // add the layer style
            start("Style");

            StyleInfo defaultStyle = layer.getDefaultStyle();
            if (defaultStyle == null) {
                throw new NullPointerException("Layer " + layer.getName() + " has no default style");
            }
            Style ftStyle;
            try {
                ftStyle = defaultStyle.getStyle();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            element("Name", defaultStyle.getName());
            element("Title", ftStyle.getTitle());
            element("Abstract", ftStyle.getAbstract());
            handleLegendURL(layer.getName(), layer.getLegend(), null);
            end("Style");
View Full Code Here

Examples of org.geoserver.catalog.StyleInfo

    }
   
    // Style methods
    public StyleInfo getStyle(String id) {
        for (Iterator s = styles.iterator(); s.hasNext();) {
            StyleInfo style = (StyleInfo) s.next();
            if (id.equals(style.getId())) {
                return ModificationProxy.create(style,StyleInfo.class);
            }
        }

        return null;
View Full Code Here

Examples of org.geoserver.catalog.StyleInfo

        return null;
    }

    public StyleInfo getStyleByName(String name) {
        for (Iterator s = styles.iterator(); s.hasNext();) {
            StyleInfo style = (StyleInfo) s.next();
            if (name.equals(style.getName())) {
                return ModificationProxy.create(style,StyleInfo.class);
            }
        }

        return null;
View Full Code Here

Examples of org.geoserver.catalog.StyleInfo

        }
        if ( isNull(style.getFilename()) ) {
            throw new NullPointerException( "Style fileName must not be null");
        }
       
        StyleInfo existing = getStyleByName( style.getName() );
        if ( existing != null && !existing.getId().equals( style.getId() )) {
            throw new IllegalArgumentException( "Style named '" +  style.getName() +"' already exists.");
        }
    }
View Full Code Here

Examples of org.geoserver.catalog.StyleInfo

            LayerInfo resolved = ResolvingProxy.resolve( this, l );
            lg.getLayers().set( i, resolved );
        }
       
        for ( int i = 0; i < lg.getStyles().size(); i++ ) {
            StyleInfo s = lg.getStyles().get( i );
            if(s != null) {
                StyleInfo resolved = ResolvingProxy.resolve( this, s );
                lg.getStyles().set( i, resolved );
            }
        }
       
    }
View Full Code Here

Examples of org.geoserver.catalog.StyleInfo

   
    public void testStyle() throws Exception {
        Catalog catalog = new CatalogImpl();
        CatalogFactory cFactory = catalog.getFactory();
       
        StyleInfo s1 = cFactory.createStyle();
        s1.setName( "foo" );
        s1.setFilename( "foo.sld" );
       
        ByteArrayOutputStream out = out();
        persister.save( s1, out );
       
        ByteArrayInputStream in = in( out );
       
        StyleInfo s2 = persister.load(in,StyleInfo.class);
        assertEquals( s1, s2 );
       
        Document dom = dom( in( out ) );
        assertEquals( "style", dom.getDocumentElement().getNodeName() );
    }
View Full Code Here

Examples of org.geoserver.catalog.StyleInfo

        CoverageStoreInfo cs = cFactory.createCoverageStore();
        cs.setWorkspace( ws );
        cs.setName( "bar" );
        catalog.add( cs );
       
        StyleInfo s = cFactory.createStyle();
        s.setName( "style" );
        s.setFilename( "style.sld" );
        catalog.add(s);
    
        ByteArrayOutputStream out = out();
        persister.save( catalog, out );
       
        catalog = persister.load( in(out), Catalog.class );
        assertNotNull(catalog);
       
        assertEquals( 1, catalog.getWorkspaces().size() );
        assertNotNull( catalog.getDefaultWorkspace() );
        ws = catalog.getDefaultWorkspace();
        assertEquals( "foo", ws.getName() );
       
        assertEquals( 1, catalog.getNamespaces().size() );
        assertNotNull( catalog.getDefaultNamespace() );
        ns = catalog.getDefaultNamespace();
        assertEquals( "acme", ns.getPrefix() );
        assertEquals( "http://acme.org", ns.getURI() );
       
        assertEquals( 1, catalog.getDataStores().size() );
        ds = catalog.getDataStores().get( 0 );
        assertEquals( "foo", ds.getName() );
        assertNotNull( ds.getWorkspace() );
        assertEquals( ws, ds.getWorkspace() );
       
        assertEquals( 1, catalog.getCoverageStores().size() );
        cs = catalog.getCoverageStores().get( 0 );
        assertEquals( "bar", cs.getName() );
        assertEquals( ws, cs.getWorkspace() );
       
        assertEquals( 1, catalog.getStyles().size() );
        s = catalog.getStyles().get(0);
        assertEquals( "style", s.getName() );
        assertEquals( "style.sld", s.getFilename() );
    }
View Full Code Here

Examples of org.geoserver.catalog.StyleInfo

        ft.setAbstract( "abstract");
        ft.setSRS( "EPSG:4326");
        ft.setNativeCRS( CRS.decode( "EPSG:4326") );
        catalog.add( ft );
       
        StyleInfo s = cFactory.createStyle();
        s.setName( "style" );
        s.setFilename( "style.sld" );
        catalog.add( s );
       
        LayerInfo l = cFactory.createLayer();
        // TODO: reinstate when layer/publish slipt is actually in place
        // l.setName( "layer" );
View Full Code Here

Examples of org.geoserver.catalog.StyleInfo

                }
                layer.setType(LayerInfo.Type.VECTOR);
              
                String defaultStyleName = ftInfoReader.defaultStyle();
                if ( defaultStyleName != null ) {
                    StyleInfo style = catalog.getStyleByName(defaultStyleName);
                    if ( style != null ) {
                        layer.setDefaultStyle(style);
                    }
                }
                List<String> styles = ftInfoReader.styles();
                if(styles != null) {
                    for (String styleName : styles) {
                        StyleInfo style = catalog.getStyleByName(styleName);
                        if ( style != null ) {
                            layer.getStyles().add(style);
                        }
                    }
                }
               
                Map legendURL = ftInfoReader.legendURL();
                if( legendURL != null ) {
                    LegendInfo legend = factory.createLegend();
                    legend.setHeight( (Integer) legendURL.get( "height" ) );
                    legend.setWidth( (Integer) legendURL.get( "width" ) );
                    legend.setFormat( (String) legendURL.get( "format" ) );
                    legend.setOnlineResource( (String) legendURL.get( "onlineResource" ) );
                    layer.setLegend( legend );
                }
               
                layer.setEnabled(featureType.isEnabled());
                catalog.add(layer);
            } catch( Exception e ) {
                LOGGER.warning( "Error loadin '" + featureTypeDirectory.getName() + "/info.xml', ignoring" );
                LOGGER.log( Level.INFO, "", e );
                continue;
            }
        }
       
        // for each coverage definition in coverage, read it
        File coverages = new File(dir, "coverages");
        if(!coverages.exists())
            coverages.mkdir();
        File[] coverageDirectories = coverages.listFiles();
        for (int i = 0; i < coverageDirectories.length; i++) {
            File coverageDirectory = coverageDirectories[i];
            if (!coverageDirectory.isDirectory() || coverageDirectory.isHidden())
                continue;

            // load info.xml
            File cInfoFile = new File(coverageDirectory, "info.xml");
            if (!cInfoFile.exists()) {
                LOGGER.fine("No info.xml found in directory: '" + coverageDirectory.getName() "', ignoring");
                continue;
            }

            LegacyCoverageInfoReader cInfoReader = new LegacyCoverageInfoReader();
            try {
                cInfoReader.read(cInfoFile);
   
                CoverageInfo coverage = readCoverage(cInfoReader);
                if ( coverage == null ) {
                    continue;
                }
                catalog.add(coverage);
   
                // create a wms layer for the feature type
                LayerInfo layer = factory.createLayer();
                layer.setResource(coverage);
                layer.setName(coverage.getName());
                layer.setPath(cInfoReader.wmsPath());
                if ( layer.getPath() == null ) {
                    layer.setPath( "/" );
                }
                layer.setType(LayerInfo.Type.RASTER);
               
                String defaultStyleName = cInfoReader.defaultStyle();
                if ( defaultStyleName != null ) {
                    StyleInfo style = catalog.getStyleByName(defaultStyleName);
                    if ( style != null ) {
                        layer.setDefaultStyle(style);
                    }
                }
                List<String> styles = cInfoReader.styles();
                if(styles != null) {
                    for (String styleName : styles) {
                        StyleInfo style = catalog.getStyleByName(styleName);
                        if ( style != null ) {
                            layer.getStyles().add(style);
                        }
                    }
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.