@Override public void serializeException( HttpResponseBuffer response, OWSException ex, XMLExceptionSerializer exceptionSerializer, Map<String, String> map ) throws SerializingException { int width = Integer.parseInt( map.get( "WIDTH" ) ); int height = Integer.parseInt( map.get( "HEIGHT" ) ); boolean transparent = map.get( "TRANSPARENT" ) != null && map.get( "TRANSPARENT" ).equalsIgnoreCase( "true" ); String format = map.get( "FORMAT" ); Color color = map.get( "BGCOLOR" ) == null ? white : decode( map.get( "BGCOLOR" ) ); BufferedImage img = prepareImage( format, width, height, transparent, color ); try { controller.sendImage( img, response, format ); } catch ( OWSException e ) { throw new SerializingException( e ); } catch ( IOException e ) { throw new SerializingException( e ); } }
Color color = map.get( "BGCOLOR" ) == null ? white : decode( map.get( "BGCOLOR" ) ); BufferedImage img = prepareImage( format, width, height, transparent, color ); Graphics2D g = img.createGraphics(); g.setColor( black );
/** * @param req * should be a GetMap or GetLegendGraphic * @return an empty image conforming to the request parameters */ public static BufferedImage prepareImage( Object req ) { String format = null; int width = 0, height = 0; Color bgcolor = null; boolean transparent = false; if ( req instanceof GetLegendGraphic ) { GetLegendGraphic glg = (GetLegendGraphic) req; format = glg.getFormat(); width = glg.getWidth(); height = glg.getHeight(); transparent = true; } else { return null; } return ImageUtils.prepareImage( format, width, height, transparent, bgcolor ); }
public static RenderContext createInstance( RenderingInfo info, OutputStream outputStream ) { BufferedImage image = ImageUtils.prepareImage( info.getFormat(), info.getWidth(), info.getHeight(), info.getTransparent(), info.getBgColor() ); return createInstance( info, image, outputStream); }