/** * Builds and returns a {@link BufferedImageLegendGraphic} appropriate to be encoded as PNG * * @see GetLegendGraphicOutputFormat#produceLegendGraphic(GetLegendGraphicRequest) */ public BufferedImageLegendGraphic produceLegendGraphic(GetLegendGraphicRequest request) throws ServiceException { BufferedImageLegendGraphicBuilder builder = new BufferedImageLegendGraphicBuilder(); BufferedImage legendGraphic = builder.buildLegendGraphic(request); BufferedImageLegendGraphic legend = new BufferedImageLegendGraphic(legendGraphic); return legend; }
/** * @param legend a {@link BufferedImageLegendGraphic} * @param output destination for the image written by {@link ImageIO} in the {@link * #getContentType() supported format} * @see Response#write(Object, OutputStream, Operation) */ @Override public void write(Object legend, OutputStream output, Operation operation) throws IOException, ServiceException { Assert.isInstanceOf(BufferedImageLegendGraphic.class, legend); BufferedImage legendImage = ((BufferedImageLegendGraphic) legend).getLegend(); JAISupport.encode(JPEGLegendOutputFormat.MIME_TYPE, legendImage, output); }
/** * @param legend a {@link BufferedImageLegendGraphic} * @param output image destination * @param operation Operation descriptor the {@code legend} was produced for * @see Response#write(Object, OutputStream, Operation) */ @Override public void write(Object legend, OutputStream output, Operation operation) throws IOException, ServiceException { Assert.isInstanceOf(BufferedImageLegendGraphic.class, legend); BufferedImage legendGraphic = ((BufferedImageLegendGraphic) legend).getLegend(); RenderedImage forcedIndexed8Bitmask = ImageUtils.forceIndexed8Bitmask(legendGraphic, null); ImageWorker imageWorker = new ImageWorker(forcedIndexed8Bitmask); imageWorker.writeGIF(output, "LZW", 0.75f); } }
/** * @return a {@link BufferedImageLegendGraphic} * @see GetLegendGraphicOutputFormat#produceLegendGraphic(GetLegendGraphicRequest) * @see BufferedImageLegendGraphicBuilder */ public BufferedImageLegendGraphic produceLegendGraphic(GetLegendGraphicRequest request) throws ServiceException { BufferedImageLegendGraphicBuilder builder = new BufferedImageLegendGraphicBuilder(); BufferedImage legendGraphic = builder.buildLegendGraphic(request); BufferedImageLegendGraphic legend = new BufferedImageLegendGraphic(legendGraphic); return legend; }
Assert.isInstanceOf(BufferedImageLegendGraphic.class, legend); BufferedImage image = ((BufferedImageLegendGraphic) legend).getLegend();
/** * Builds a JPEG {@link BufferedImageLegendGraphic} * * @return a {@link BufferedImageLegendGraphic} holding a legend image appropriate to be encoded * as JPEG * @see GetLegendGraphicOutputFormat#produceLegendGraphic(GetLegendGraphicRequest) */ public BufferedImageLegendGraphic produceLegendGraphic(GetLegendGraphicRequest request) throws ServiceException { request.setTransparent(false); BufferedImageLegendGraphicBuilder builder = new BufferedImageLegendGraphicBuilder(); BufferedImage legendGraphic = builder.buildLegendGraphic(request); BufferedImageLegendGraphic legend = new BufferedImageLegendGraphic(legendGraphic); return legend; }
Object legendGraphic = pngOutputFormat.produceLegendGraphic(legendGraphicRequest); if (legendGraphic instanceof BufferedImageLegendGraphic) { BufferedImage image = ((BufferedImageLegendGraphic) legendGraphic).getLegend();