01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2003-2006, Geotools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.renderer.style;
17:
18: // J2SE dependencies
19: import java.awt.image.BufferedImage;
20:
21: import org.apache.batik.transcoder.TranscoderException;
22: import org.apache.batik.transcoder.TranscoderOutput;
23: import org.apache.batik.transcoder.image.ImageTranscoder;
24: import org.w3c.dom.Document;
25:
26: /**
27: *
28: * @author jamesm
29: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/render/src/main/java/org/geotools/renderer/style/InternalTranscoder.java $
30: */
31: final class InternalTranscoder extends ImageTranscoder {
32:
33: private BufferedImage result;
34:
35: private Document doc;
36:
37: /**
38: * Creates a new instance of InternalTranscoder.
39: */
40: public InternalTranscoder() {
41: }
42:
43: protected void transcode(Document document, String uri,
44: TranscoderOutput output) throws TranscoderException {
45: super .transcode(document, uri, output);
46: this .doc = document;
47: }
48:
49: public BufferedImage createImage(int width, int height) {
50: return new BufferedImage(width, height,
51: BufferedImage.TYPE_INT_ARGB);
52: }
53:
54: /**
55: * Gets called by the end of the image transcoder with an actual image.
56: */
57: public void writeImage(BufferedImage img, TranscoderOutput output) {
58: result = img;
59: }
60:
61: public BufferedImage getImage() {
62: return result;
63: }
64:
65: public Document getDocument() {
66: return doc;
67: }
68: }
|