Package org.geoserver.wms

Examples of org.geoserver.wms.GetLegendGraphicRequest


    @org.junit.Test
    public void testRenderingTransformationRasterVector() throws Exception {
                
        Style transformStyle = readSLD("RenderingTransformRasterVector.sld");
       
        GetLegendGraphicRequest req = new GetLegendGraphicRequest();
        CoverageInfo cInfo = getCatalog()
                .getCoverageByName(MockData.TASMANIA_DEM.getNamespaceURI(),
                        MockData.TASMANIA_DEM.getLocalPart());
        assertNotNull(cInfo);

        GridCoverage coverage = cInfo.getGridCoverage(null, null);
        try {
            SimpleFeatureCollection feature;
            feature = FeatureUtilities.wrapGridCoverage((GridCoverage2D) coverage);
            req.setLayer(feature.getSchema());
            req.setStyle(transformStyle);
            req.setLegendOptions(new HashMap());
           
            this.legendProducer.buildLegendGraphic(req);

            BufferedImage image = this.legendProducer.buildLegendGraphic(req);  
           
View Full Code Here


    @org.junit.Test
    public void testRenderingTransformationVectorRaster() throws Exception {
                
        Style transformStyle = readSLD("RenderingTransformVectorRaster.sld");
       
        GetLegendGraphicRequest req = new GetLegendGraphicRequest();
        FeatureTypeInfo ftInfo = getCatalog()
                .getFeatureTypeByName(MockData.NAMED_PLACES.getNamespaceURI(),
                        MockData.NAMED_PLACES.getLocalPart());
        assertNotNull(ftInfo);
        
        req.setLayer(ftInfo.getFeatureType());
        req.setStyle(transformStyle);
        req.setLegendOptions(new HashMap());
       
        this.legendProducer.buildLegendGraphic(req);

        BufferedImage image = this.legendProducer.buildLegendGraphic(req);
       
View Full Code Here

        // load a style with 3 rules
        Style externalGraphicStyle = readSLD("ExternalGraphicDemo.sld");

        assertNotNull(externalGraphicStyle);

        GetLegendGraphicRequest req = new GetLegendGraphicRequest();
        CoverageInfo cInfo = getCatalog().getCoverageByName("world");
        assertNotNull(cInfo);

        GridCoverage coverage = cInfo.getGridCoverage(null, null);
        try {
            req.setStyle(externalGraphicStyle);
            req.setLayer(null);
            req.setScale(1.0);
           
            final int HEIGHT_HINT = 30;
            req.setHeight(HEIGHT_HINT);
           
            // use default values for the rest of parameters
            this.legendProducer.buildLegendGraphic(req);

            BufferedImage image = this.legendProducer.buildLegendGraphic(req);
View Full Code Here

     * @return
     * @throws Exception
     */
    private Dimension createNewSample(StyleInfo style,
            GetLegendGraphicOutputFormat pngOutputFormat) throws Exception {
        GetLegendGraphicRequest legendGraphicRequest = new GetLegendGraphicRequest();
        File sampleLegendFolder = getSamplesFolder();
       
        legendGraphicRequest.setLayers(Arrays.asList((FeatureType) null));
        legendGraphicRequest.setStyles(Arrays.asList(style.getStyle()));
        legendGraphicRequest.setFormat(pngOutputFormat.getContentType());
        Object legendGraphic = pngOutputFormat
                .produceLegendGraphic(legendGraphicRequest);
        if (legendGraphic instanceof BufferedImageLegendGraphic) {
            BufferedImage image = ((BufferedImageLegendGraphic) legendGraphic)
                    .getLegend();
View Full Code Here

    }
   
    @Test
    public void testWMSGetLegendGraphic() throws Exception {
        WMS wms = new WMS(createMock(GeoServer.class));
        GetLegendGraphicRequest glg = new GetLegendGraphicRequest();
       
        FeatureType type = createMock(FeatureType.class);
        expect(type.getName()).andReturn(new NameImpl("http://acme.org", "foo")).anyTimes();
        replay(type);
       
        glg.setLayer(type);
        callback.operationDispatched(new Request(), op("GetFeatureInfo", "WMS", "1.1.1", glg));
   
        assertEquals("http://acme.org:foo", data.getResources().get(0));
    }
View Full Code Here

                                    style = ((UserLayer) sl).getUserStyles()[0];
                                } else {
                                    style = ((NamedLayer) sl).getStyles()[0];
                                }

                                GetLegendGraphicRequest request = new GetLegendGraphicRequest();
                                request.setStyle(style);
                                request.setLayer(null);
                                request.setStrict(false);
                                Map<String, String> legendOptions = new HashMap<String, String>();
                                legendOptions.put("forceLabels", "on");
                                legendOptions.put("fontAntiAliasing", "true");
                                request.setLegendOptions(legendOptions);
                                BufferedImageLegendGraphicBuilder builder = new BufferedImageLegendGraphicBuilder();
                                BufferedImage image = builder.buildLegendGraphic(request);

                                ByteArrayOutputStream bos = new ByteArrayOutputStream();
View Full Code Here

TOP

Related Classes of org.geoserver.wms.GetLegendGraphicRequest

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.