KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > svggen > SVGCustomBufferedImageOp


1 /*
2
3    Copyright 2001,2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.svggen;
19
20 import java.awt.Rectangle JavaDoc;
21 import java.awt.image.BufferedImageOp JavaDoc;
22
23 import org.w3c.dom.Element JavaDoc;
24
25 /**
26  * Utility class that converts an custom BufferedImageOp object into
27  * an equivalent SVG filter.
28  *
29  * @author <a HREF="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
30  * @version $Id: SVGCustomBufferedImageOp.java,v 1.7 2004/08/18 07:14:59 vhardy Exp $
31  * @see org.apache.batik.svggen.SVGBufferedImageOp
32  */

33 public class SVGCustomBufferedImageOp extends AbstractSVGFilterConverter {
34     private static final String JavaDoc ERROR_EXTENSION =
35         "SVGCustomBufferedImageOp:: ExtensionHandler could not convert filter";
36
37     /**
38      * @param generatorContext for use by SVGCustomBufferedImageOp to
39      * build Elements.
40      */

41     public SVGCustomBufferedImageOp(SVGGeneratorContext generatorContext) {
42         super(generatorContext);
43     }
44
45     /**
46      * @param filter the BufferedImageOp object to convert to SVG
47      * @param filterRect Rectangle, in device space, that defines the area
48      * to which filtering applies. May be null, meaning that the
49      * area is undefined.
50      * @return an SVGFilterDescriptor mapping the SVG
51      * BufferedImageOp equivalent to the input BufferedImageOp.
52      */

53     public SVGFilterDescriptor toSVG(BufferedImageOp JavaDoc filter,
54                                      Rectangle JavaDoc filterRect) {
55         SVGFilterDescriptor filterDesc =
56             (SVGFilterDescriptor)descMap.get(filter);
57
58         if (filterDesc == null) {
59             // First time this filter is used. Request handler
60
// to do the convertion
61
filterDesc =
62                 generatorContext.extensionHandler.
63                 handleFilter(filter, filterRect, generatorContext);
64
65             if (filterDesc != null) {
66                 Element JavaDoc def = filterDesc.getDef();
67                 if(def != null)
68                     defSet.add(def);
69                 descMap.put(filter, filterDesc);
70             } else {
71                 System.err.println(ERROR_EXTENSION);
72             }
73         }
74
75         return filterDesc;
76     }
77
78 }
79
80
Popular Tags