Package org.geoserver.wms.legendgraphic.ColorMapLegendCreator

Examples of org.geoserver.wms.legendgraphic.ColorMapLegendCreator.Builder


        // background bkgColor
        bgColor = LegendUtils.getBackgroundColor(request);

        // colormap element
        final ColorMap cmap = rasterSymbolizer.getColorMap();
        final Builder cmapLegendBuilder = new ColorMapLegendCreator.Builder();
        if (cmap != null && cmap.getColorMapEntries() != null
                && cmap.getColorMapEntries().length > 0) {

            // passing additional options
            cmapLegendBuilder.setAdditionalOptions(request.getLegendOptions());

            // setting type of colormap
            cmapLegendBuilder.setColorMapType(cmap.getType());

            // is this colormap using extended colors
            cmapLegendBuilder.setExtended(cmap.getExtendedColors());

            // setting the requested colormap entries
            cmapLegendBuilder.setRequestedDimension(new Dimension(width, height));

            // setting transparency and background bkgColor
            cmapLegendBuilder.setTransparent(transparent);
            cmapLegendBuilder.setBackgroundColor(bgColor);

            // setting band

            // Setting label font and font bkgColor
            cmapLegendBuilder.setLabelFont(LegendUtils.getLabelFont(request));
            cmapLegendBuilder.setLabelFontColor(LegendUtils.getLabelFontColor(request));

            // set band
            final ChannelSelection channelSelection = rasterSymbolizer.getChannelSelection();
            cmapLegendBuilder.setBand(channelSelection != null ? channelSelection.getGrayChannel()
                    : null);

            // adding the colormap entries
            final ColorMapEntry[] colorMapEntries = cmap.getColorMapEntries();
            for (ColorMapEntry ce : colorMapEntries)
                if (ce != null)
                    cmapLegendBuilder.addColorMapEntry(ce);

            // check the additional options before proceeding
            cmapLegendBuilder.checkAdditionalOptions();

            // instantiate the creator
            cMapLegendCreator = cmapLegendBuilder.create();

        } else
            cMapLegendCreator = null;

    }
View Full Code Here


            final double min = (Double) statsFilterFunction.evaluate(coverage, "minimum");
            final double max = (Double) statsFilterFunction.evaluate(coverage, "maximum");

            // Getting a colorMap on top of that
            cmap = (ColorMap) colorMapFilterFunction.evaluate(colorMap, min, max);
            final Builder cmapLegendBuilder = new ColorMapLegendCreator.Builder();
            if (cmap != null && cmap.getColorMapEntries() != null
                    && cmap.getColorMapEntries().length > 0) {

                // setting type of colormap
                cmapLegendBuilder.setColorMapType(cmap.getType());

                // is this colormap using extended colors
                cmapLegendBuilder.setExtended(cmap.getExtendedColors());

                // setting the requested colormap entries
                cmapLegendBuilder.setRequestedDimension(new Dimension(request.getWidth(), request
                        .getHeight()));

                // // setting transparency and background bkgColor
                // cmapLegendBuilder.setTransparent(transparent);
                // cmapLegendBuilder.setBackgroundColor(bgColor);

                // setting band

                // Setting label font and font bkgColor
                cmapLegendBuilder.setLabelFont(LegendUtils.getLabelFont(request));
                cmapLegendBuilder.setLabelFontColor(LegendUtils.getLabelFontColor(request));
                cmapLegendBuilder.setUnit(unit);
                cmapLegendBuilder.setDigits(digits);
                cmapLegendBuilder.setAlternativeColorMapEntryBuilder(true);
                // set band
                // final ChannelSelection channelSelection = rasterSymbolizer.getChannelSelection();
                // cmapLegendBuilder.setBand(channelSelection != null ? channelSelection.getGrayChannel()
                // : null);

                // adding the colormap entries
                final ColorMapEntry[] colorMapEntries = cmap.getColorMapEntries();
                for (ColorMapEntry ce : colorMapEntries)
                    if (ce != null)
                        cmapLegendBuilder.addColorMapEntry(ce);

                // check the additional options before proceeding
                cmapLegendBuilder.checkAdditionalOptions();

                // instantiate the creator
                ColorMapLegendCreator cMapLegendCreator = cmapLegendBuilder.create();
                return new BufferedImageLegendGraphic(cMapLegendCreator.getLegend());
            }
            throw new RuntimeException("Unable to create a legend due to missing colorMap");
        } catch (IOException e) {
            throw new RuntimeException(e);
View Full Code Here

        // background bkgColor
        bgColor = LegendUtils.getBackgroundColor(request);

        // colormap element
        final ColorMap cmap = rasterSymbolizer.getColorMap();
        final Builder cmapLegendBuilder = new ColorMapLegendCreator.Builder();
        if (cmap != null && cmap.getColorMapEntries() != null
                && cmap.getColorMapEntries().length > 0) {

            // passing additional options
            cmapLegendBuilder.setAdditionalOptions(request.getLegendOptions());

            // setting type of colormap
            cmapLegendBuilder.setColorMapType(cmap.getType());

            // is this colormap using extended colors
            cmapLegendBuilder.setExtended(cmap.getExtendedColors());

            // setting the requested colormap entries
            cmapLegendBuilder.setRequestedDimension(new Dimension(width, height));

            // setting transparency and background bkgColor
            cmapLegendBuilder.setTransparent(transparent);
            cmapLegendBuilder.setBackgroundColor(bgColor);

            // setting band

            // Setting label font and font bkgColor
            cmapLegendBuilder.setLabelFont(LegendUtils.getLabelFont(request));
            cmapLegendBuilder.setLabelFontColor(LegendUtils.getLabelFontColor(request));

            // set band
            final ChannelSelection channelSelection = rasterSymbolizer.getChannelSelection();
            cmapLegendBuilder.setBand(channelSelection != null ? channelSelection.getGrayChannel()
                    : null);

            // adding the colormap entries
            final ColorMapEntry[] colorMapEntries = cmap.getColorMapEntries();
            for (ColorMapEntry ce : colorMapEntries)
                if (ce != null)
                    cmapLegendBuilder.addColorMapEntry(ce);

            // check the additional options before proceeding
            cmapLegendBuilder.checkAdditionalOptions();

            // instantiate the creator
            cMapLegendCreator = cmapLegendBuilder.create();

        } else
            cMapLegendCreator = null;
        }
View Full Code Here

TOP

Related Classes of org.geoserver.wms.legendgraphic.ColorMapLegendCreator.Builder

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.