KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > ext > awt > image > codec > SingleTileRenderedImage


1 /*
2
3    Copyright 1999-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
19 package org.apache.batik.ext.awt.image.codec;
20
21 import java.awt.image.ColorModel JavaDoc;
22 import java.awt.image.Raster JavaDoc;
23
24 /**
25  * A simple class that provides RenderedImage functionality
26  * given a Raster and a ColorModel.
27  */

28 public class SingleTileRenderedImage extends SimpleRenderedImage {
29
30     Raster JavaDoc ras;
31
32     /**
33      * Constructs a SingleTileRenderedImage based on a Raster
34      * and a ColorModel.
35      *
36      * @param ras A Raster that will define tile (0, 0) of the image.
37      * @param colorModel A ColorModel that will serve as the image's
38      * ColorModel.
39      */

40     public SingleTileRenderedImage(Raster JavaDoc ras, ColorModel JavaDoc colorModel) {
41         this.ras = ras;
42
43         this.tileGridXOffset = this.minX = ras.getMinX();
44         this.tileGridYOffset = this.minY = ras.getMinY();
45         this.tileWidth = this.width = ras.getWidth();
46         this.tileHeight = this.height = ras.getHeight();
47         this.sampleModel = ras.getSampleModel();
48         this.colorModel = colorModel;
49     }
50
51     /**
52      * Returns the image's Raster as tile (0, 0).
53      */

54     public Raster JavaDoc getTile(int tileX, int tileY) {
55         if (tileX != 0 || tileY != 0) {
56             throw new IllegalArgumentException JavaDoc(PropertyUtil.getString("SingleTileRenderedImage0"));
57         }
58         return ras;
59     }
60 }
61
Popular Tags