KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > ext > awt > image > rendered > RenderedImageCachableRed


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.ext.awt.image.rendered;
19
20 import java.awt.Rectangle JavaDoc;
21 import java.awt.Shape JavaDoc;
22 import java.awt.image.BufferedImage JavaDoc;
23 import java.awt.image.ColorModel JavaDoc;
24 import java.awt.image.Raster JavaDoc;
25 import java.awt.image.RenderedImage JavaDoc;
26 import java.awt.image.SampleModel JavaDoc;
27 import java.awt.image.WritableRaster JavaDoc;
28 import java.util.Vector JavaDoc;
29
30
31 /**
32  * This implements CachableRed around a RenderedImage.
33  * You can use this to wrap a RenderedImage that you want to
34  * appear as a CachableRed.
35  * It essentially ignores the dependency and dirty region methods.
36  *
37  * @author <a HREF="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
38  * @version $Id: RenderedImageCachableRed.java,v 1.4 2004/08/18 07:14:08 vhardy Exp $ */

39 public class RenderedImageCachableRed implements CachableRed {
40
41     public static CachableRed wrap(RenderedImage JavaDoc ri) {
42         if (ri instanceof CachableRed)
43             return (CachableRed) ri;
44         if (ri instanceof BufferedImage JavaDoc)
45             return new BufferedImageCachableRed((BufferedImage JavaDoc)ri);
46         return new RenderedImageCachableRed(ri);
47     }
48
49     private RenderedImage JavaDoc src;
50     private Vector JavaDoc srcs = new Vector JavaDoc(0);
51
52     public RenderedImageCachableRed(RenderedImage JavaDoc src) {
53         if(src == null){
54             throw new IllegalArgumentException JavaDoc();
55         }
56         this.src = src;
57     }
58
59     public Vector JavaDoc getSources() {
60         return srcs; // should always be empty...
61
}
62
63     public Rectangle JavaDoc getBounds() {
64         return new Rectangle JavaDoc(getMinX(),
65                              getMinY(),
66                              getWidth(),
67                              getHeight());
68     }
69
70     public int getMinX() {
71         return src.getMinX();
72     }
73     public int getMinY() {
74         return src.getMinY();
75     }
76
77     public int getWidth() {
78         return src.getWidth();
79     }
80     public int getHeight() {
81         return src.getHeight();
82     }
83
84     public ColorModel JavaDoc getColorModel() {
85         return src.getColorModel();
86     }
87
88     public SampleModel JavaDoc getSampleModel() {
89         return src.getSampleModel();
90     }
91
92     public int getMinTileX() {
93         return src.getMinTileX();
94     }
95     public int getMinTileY() {
96         return src.getMinTileY();
97     }
98
99     public int getNumXTiles() {
100         return src.getNumXTiles();
101     }
102     public int getNumYTiles() {
103         return src.getNumYTiles();
104     }
105
106     public int getTileGridXOffset() {
107         return src.getTileGridXOffset();
108     }
109
110     public int getTileGridYOffset() {
111         return src.getTileGridYOffset();
112     }
113
114     public int getTileWidth() {
115         return src.getTileWidth();
116     }
117     public int getTileHeight() {
118         return src.getTileHeight();
119     }
120
121     public Object JavaDoc getProperty(String JavaDoc name) {
122         return src.getProperty(name);
123     }
124
125     public String JavaDoc[] getPropertyNames() {
126         return src.getPropertyNames();
127     }
128
129     public Raster JavaDoc getTile(int tileX, int tileY) {
130         return src.getTile(tileX, tileY);
131     }
132
133     public WritableRaster JavaDoc copyData(WritableRaster JavaDoc raster) {
134         return src.copyData(raster);
135     }
136
137     public Raster JavaDoc getData() {
138         return src.getData();
139     }
140
141     public Raster JavaDoc getData(Rectangle JavaDoc rect) {
142         return src.getData(rect);
143     }
144
145     public Shape JavaDoc getDependencyRegion(int srcIndex, Rectangle JavaDoc outputRgn) {
146         throw new IndexOutOfBoundsException JavaDoc
147             ("Nonexistant source requested.");
148     }
149
150     public Shape JavaDoc getDirtyRegion(int srcIndex, Rectangle JavaDoc inputRgn) {
151         throw new IndexOutOfBoundsException JavaDoc
152             ("Nonexistant source requested.");
153     }
154 }
155
Popular Tags