01: /*
02: * Geotools2 - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002, Geotools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: */
17: package org.geotools.arcsde.gce.band;
18:
19: import java.awt.image.DataBuffer;
20: import java.awt.image.WritableRaster;
21:
22: import org.geotools.data.DataSourceException;
23:
24: import com.esri.sde.sdk.client.SeRaster;
25: import com.esri.sde.sdk.client.SeRasterBand;
26: import com.esri.sde.sdk.client.SeRasterTile;
27:
28: public abstract class ArcSDERasterBandCopier {
29:
30: protected int tileWidth, tileHeight;
31:
32: public static ArcSDERasterBandCopier getInstance(int sePixelType,
33: int tileWidth, int tileHeight) {
34: ArcSDERasterBandCopier ret;
35: if (sePixelType == SeRaster.SE_PIXEL_TYPE_8BIT_U) {
36: ret = new UnsignedByteBandCopier();
37: } else {
38: throw new IllegalArgumentException(
39: "Don't know how to create ArcSDE band reader for pixel type "
40: + sePixelType);
41: }
42: ret.tileWidth = tileWidth;
43: ret.tileHeight = tileHeight;
44: return ret;
45: }
46:
47: /**
48: * @param tile The actual tile you wish to copy from
49: * @param raster The raster into which data should be copied
50: * @param copyOffX The x-coordinate of the TILE at which the raster should start copying
51: * @param copyOffY The y-coordinate of the TILE at which the raster should start copying
52: * @param targetBand The band in the supplied raster into which the data from this tile should be copied
53: * @throws DataSourceException
54: */
55: public abstract void copyPixelData(SeRasterTile tile,
56: WritableRaster raster, int copyOffX, int copyOffY,
57: int targetBand) throws DataSourceException;
58:
59: protected Object createTransferObject(int transferType,
60: int numPixels) {
61: if (transferType == DataBuffer.TYPE_BYTE) {
62: return new byte[numPixels];
63: } else if (transferType == DataBuffer.TYPE_INT) {
64: return new int[numPixels];
65: } else {
66: throw new IllegalArgumentException(
67: "Can't transfer ArcSDE Raster data to a java.awt.Raster with a transferType of "
68: + transferType);
69: }
70:
71: }
72: }
|