protected void createCanvas() { // TODO take bgcolor and transparency from request into account // should move this into a separate function Color bgColor = null; boolean transparent = true; if (layer instanceof WMSLayer) { WMSLayer wmsLayer = (WMSLayer) layer; int[] colorAr = wmsLayer.getBackgroundColor(); if (colorAr != null) { bgColor = new Color(colorAr[0], colorAr[1], colorAr[2]); } transparent = wmsLayer.getTransparent(); } int canvasType; if (bgColor == null && transparent && (outputFormat.supportsAlphaBit() || outputFormat.supportsAlphaChannel())) { canvasType = BufferedImage.TYPE_INT_ARGB; } else { canvasType = BufferedImage.TYPE_INT_RGB; if (bgColor == null) { bgColor = Color.WHITE; } } // Create the actual canvas and graphics object canvas = new BufferedImage(canvasSize[0], canvasSize[1], canvasType); gfx = (Graphics2D) canvas.getGraphics(); if (bgColor != null) { gfx.setColor(bgColor); gfx.fillRect(0, 0, canvasSize[0], canvasSize[1]); } }