Example #1
0
        protected Raster(SampleModel sampleModel, DataBuffer dataBuffer,
            Rectangle aRegion, Point sampleModelTranslate, Raster parent)
        {
            if (sampleModel == null || dataBuffer == null || aRegion == null
                || sampleModelTranslate == null) {
            // awt.281=sampleModel, dataBuffer, aRegion or sampleModelTranslate is null
            throw new java.lang.NullPointerException("sampleModel, dataBuffer, aRegion or sampleModelTranslate is null"); //$NON-NLS-1$
            }

            if (aRegion.width <= 0 || aRegion.height <= 0) {
            // awt.282=aRegion has width or height less than or equal to zero
            throw new RasterFormatException("aRegion has width or height less than or equal to zero"); //$NON-NLS-1$
            }

            if ((long) aRegion.x + (long) aRegion.width > java.lang.Integer.MAX_VALUE) {
            // awt.283=Overflow X coordinate of Raster
            throw new RasterFormatException("Overflow X coordinate of Raster"); //$NON-NLS-1$
            }

            if ((long) aRegion.y + (long) aRegion.height > java.lang.Integer.MAX_VALUE) {
            // awt.284=Overflow Y coordinate of Raster
            throw new RasterFormatException("Overflow Y coordinate of Raster"); //$NON-NLS-1$
            }

            validateDataBuffer(dataBuffer, aRegion.width, aRegion.height,
                sampleModel);

            this.sampleModel = sampleModel;
            this.dataBuffer = dataBuffer;
            this.minX = aRegion.x;
            this.minY = aRegion.y;
            this.width = aRegion.width;
            this.height = aRegion.height;
            this.sampleModelTranslateX = sampleModelTranslate.x;
            this.sampleModelTranslateY = sampleModelTranslate.y;
            this.parent = parent;
            this.numBands = sampleModel.getNumBands();
            this.numDataElements = sampleModel.getNumDataElements();
        }
Example #2
0
 public bool isCompatibleRaster(Raster raster)
 {
     throw new java.lang.UnsupportedOperationException("This method is not " + //$NON-NLS-1$
             "supported by this ColorModel"); //$NON-NLS-1$
 }
Example #3
0
        public virtual void setRect(int dx, int dy, Raster srcRaster)
        {
            int w = srcRaster.getWidth();
            int h = srcRaster.getHeight();

            int srcX = srcRaster.getMinX();
            int srcY = srcRaster.getMinY();

            int dstX = srcX + dx;
            int dstY = srcY + dy;

            if (dstX < this.minX)
            {
                int minOffX = this.minX - dstX;
                w    -= minOffX;
                dstX  = this.minX;
                srcX += minOffX;
            }

            if (dstY < this.minY)
            {
                int minOffY = this.minY - dstY;
                h    -= minOffY;
                dstY  = this.minY;
                srcY += minOffY;
            }

            if (dstX + w > this.minX + this.width)
            {
                int maxOffX = (dstX + w) - (this.minX + this.width);
                w -= maxOffX;
            }

            if (dstY + h > this.minY + this.height)
            {
                int maxOffY = (dstY + h) - (this.minY + this.height);
                h -= maxOffY;
            }

            if (w <= 0 || h <= 0)
            {
                return;
            }

            switch (sampleModel.getDataType())
            {
            case DataBuffer.TYPE_BYTE:
            case DataBuffer.TYPE_SHORT:
            case DataBuffer.TYPE_USHORT:
            case DataBuffer.TYPE_INT:
                int[] iPixelsLine = null;
                for (int i = 0; i < h; i++)
                {
                    iPixelsLine = srcRaster.getPixels(srcX, srcY + i, w, 1,
                                                      iPixelsLine);
                    setPixels(dstX, dstY + i, w, 1, iPixelsLine);
                }
                break;

            case DataBuffer.TYPE_FLOAT:
                float[] fPixelsLine = null;
                for (int i = 0; i < h; i++)
                {
                    fPixelsLine = srcRaster.getPixels(srcX, srcY + i, w, 1,
                                                      fPixelsLine);
                    setPixels(dstX, dstY + i, w, 1, fPixelsLine);
                }
                break;

            case DataBuffer.TYPE_DOUBLE:
                double[] dPixelsLine = null;
                for (int i = 0; i < h; i++)
                {
                    dPixelsLine = srcRaster.getPixels(srcX, srcY + i, w, 1,
                                                      dPixelsLine);
                    setPixels(dstX, dstY + i, w, 1, dPixelsLine);
                }
                break;
            }
        }
Example #4
0
 public virtual void setRect(Raster srcRaster)
 {
     setRect(0, 0, srcRaster);
 }
Example #5
0
        public virtual void setRect(int dx, int dy, Raster srcRaster)
        {
            int w = srcRaster.getWidth();
            int h = srcRaster.getHeight();

            int srcX = srcRaster.getMinX();
            int srcY = srcRaster.getMinY();

            int dstX = srcX + dx;
            int dstY = srcY + dy;

            if (dstX < this.minX)
            {
                int minOffX = this.minX - dstX;
                w -= minOffX;
                dstX = this.minX;
                srcX += minOffX;
            }

            if (dstY < this.minY)
            {
                int minOffY = this.minY - dstY;
                h -= minOffY;
                dstY = this.minY;
                srcY += minOffY;
            }

            if (dstX + w > this.minX + this.width)
            {
                int maxOffX = (dstX + w) - (this.minX + this.width);
                w -= maxOffX;
            }

            if (dstY + h > this.minY + this.height)
            {
                int maxOffY = (dstY + h) - (this.minY + this.height);
                h -= maxOffY;
            }

            if (w <= 0 || h <= 0)
            {
                return;
            }

            switch (sampleModel.getDataType())
            {
                case DataBuffer.TYPE_BYTE:
                case DataBuffer.TYPE_SHORT:
                case DataBuffer.TYPE_USHORT:
                case DataBuffer.TYPE_INT:
                    int[] iPixelsLine = null;
                    for (int i = 0; i < h; i++)
                    {
                        iPixelsLine = srcRaster.getPixels(srcX, srcY + i, w, 1,
                                iPixelsLine);
                        setPixels(dstX, dstY + i, w, 1, iPixelsLine);
                    }
                    break;

                case DataBuffer.TYPE_FLOAT:
                    float[] fPixelsLine = null;
                    for (int i = 0; i < h; i++)
                    {
                        fPixelsLine = srcRaster.getPixels(srcX, srcY + i, w, 1,
                                fPixelsLine);
                        setPixels(dstX, dstY + i, w, 1, fPixelsLine);
                    }
                    break;

                case DataBuffer.TYPE_DOUBLE:
                    double[] dPixelsLine = null;
                    for (int i = 0; i < h; i++)
                    {
                        dPixelsLine = srcRaster.getPixels(srcX, srcY + i, w, 1,
                                dPixelsLine);
                        setPixels(dstX, dstY + i, w, 1, dPixelsLine);
                    }
                    break;
            }
        }
Example #6
0
 public virtual void setRect(Raster srcRaster)
 {
     setRect(0, 0, srcRaster);
 }
Example #7
0
        public virtual void setDataElements(int x, int y, Raster inRaster)
        {
            int dstX = x + inRaster.getMinX();
            int dstY = y + inRaster.getMinY();

            int w = inRaster.getWidth();
            int h = inRaster.getHeight();

            if (dstX < this.minX || dstX + w > this.minX + this.width ||
                    dstY < this.minY || dstY + h > this.minY + this.height)
            {
                // awt.63=Coordinates are not in bounds
                throw new java.lang.ArrayIndexOutOfBoundsException("Coordinates are not in bounds"); //$NON-NLS-1$
            }

            int srcX = inRaster.getMinX();
            int srcY = inRaster.getMinY();
            Object line = null;

            for (int i = 0; i < h; i++)
            {
                line = inRaster.getDataElements(srcX, srcY + i, w, 1, line);
                setDataElements(dstX, dstY + i, w, 1, line);
            }
        }
Example #8
0
 public bool isCompatibleRaster(Raster raster)
 {
     throw new java.lang.UnsupportedOperationException("This method is not " +          //$NON-NLS-1$
                                                       "supported by this ColorModel"); //$NON-NLS-1$
 }