01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: /* $Id: SingleTileRenderedImage.java 496556 2007-01-16 00:59:48Z cam $ */
19:
20: package org.apache.xmlgraphics.image.codec.util;
21:
22: import java.awt.image.ColorModel;
23: import java.awt.image.Raster;
24:
25: /**
26: * A simple class that provides RenderedImage functionality
27: * given a Raster and a ColorModel.
28: *
29: * @version $Id: SingleTileRenderedImage.java 496556 2007-01-16 00:59:48Z cam $
30: */
31: public class SingleTileRenderedImage extends SimpleRenderedImage {
32:
33: Raster ras;
34:
35: /**
36: * Constructs a SingleTileRenderedImage based on a Raster
37: * and a ColorModel.
38: *
39: * @param ras A Raster that will define tile (0, 0) of the image.
40: * @param colorModel A ColorModel that will serve as the image's
41: * ColorModel.
42: */
43: public SingleTileRenderedImage(Raster ras, ColorModel colorModel) {
44: this .ras = ras;
45:
46: this .tileGridXOffset = this .minX = ras.getMinX();
47: this .tileGridYOffset = this .minY = ras.getMinY();
48: this .tileWidth = this .width = ras.getWidth();
49: this .tileHeight = this .height = ras.getHeight();
50: this .sampleModel = ras.getSampleModel();
51: this .colorModel = colorModel;
52: }
53:
54: /**
55: * Returns the image's Raster as tile (0, 0).
56: */
57: public Raster getTile(int tileX, int tileY) {
58: if (tileX != 0 || tileY != 0) {
59: throw new IllegalArgumentException(PropertyUtil
60: .getString("SingleTileRenderedImage0"));
61: }
62: return ras;
63: }
64: }
|