KickJava   Java API By Example, From Geeks To Geeks.

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


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.RenderingHints JavaDoc;
22 import java.awt.geom.Point2D JavaDoc;
23 import java.awt.geom.Rectangle2D JavaDoc;
24 import java.awt.image.BufferedImage JavaDoc;
25 import java.awt.image.BufferedImageOp JavaDoc;
26 import java.awt.image.ColorModel JavaDoc;
27
28 class NullOp implements BufferedImageOp JavaDoc {
29     public BufferedImage JavaDoc filter(BufferedImage JavaDoc src, BufferedImage JavaDoc dest){
30         java.awt.Graphics2D JavaDoc g = dest.createGraphics();
31         g.drawImage(src, 0, 0, null);
32         g.dispose();
33         return dest;
34     }
35
36     public Rectangle2D JavaDoc getBounds2D(BufferedImage JavaDoc src){
37         return new Rectangle JavaDoc(0, 0, src.getWidth(), src.getHeight());
38     }
39
40
41     /**
42      * Creates a destination image compatible with the source.
43      */

44     public BufferedImage JavaDoc createCompatibleDestImage (BufferedImage JavaDoc src,
45                                                     ColorModel JavaDoc destCM){
46         BufferedImage JavaDoc dest = null;
47         if(destCM==null)
48             destCM = src.getColorModel();
49
50         dest = new BufferedImage JavaDoc(destCM, destCM.createCompatibleWritableRaster(src.getWidth(), src.getHeight()),
51                                  destCM.isAlphaPremultiplied(), null);
52
53         return dest;
54     }
55
56     /**
57      * Returns the location of the destination point given a
58      * point in the source image. If DestPt is non-null, it
59      * will be used to hold the return value.
60      */

61     public Point2D JavaDoc getPoint2D (Point2D JavaDoc srcPt, Point2D JavaDoc destPt){
62         // This operation does not affect pixel location
63
if(destPt==null)
64             destPt = new Point2D.Double JavaDoc();
65         destPt.setLocation(srcPt.getX(), srcPt.getY());
66         return destPt;
67     }
68
69     /**
70      * Returns the rendering hints for this BufferedImageOp. Returns
71      * null if no hints have been set.
72      */

73     public RenderingHints JavaDoc getRenderingHints(){
74         return null;
75     }
76 }
77
78
Popular Tags