diff options
Diffstat (limited to 'java/awt/image')
55 files changed, 2523 insertions, 2531 deletions
diff --git a/java/awt/image/AffineTransformOp.java b/java/awt/image/AffineTransformOp.java index df9db7d96..460804f90 100644 --- a/java/awt/image/AffineTransformOp.java +++ b/java/awt/image/AffineTransformOp.java @@ -1,4 +1,4 @@ -/* AffineTransformOp.java -- This class performs affine +/* AffineTransformOp.java -- This class performs affine transformation between two images or rasters in 2 dimensions. Copyright (C) 2004, 2006 Free Software Foundation @@ -51,19 +51,19 @@ import java.util.Arrays; /** * AffineTransformOp performs matrix-based transformations (translations, * scales, flips, rotations, and shears). - * + * * If interpolation is required, nearest neighbour, bilinear, and bicubic * methods are available. * - * @author Olga Rodimina (rodimina@redhat.com) + * @author Olga Rodimina (rodimina@redhat.com) * @author Francis Kung (fkung@redhat.com) */ public class AffineTransformOp implements BufferedImageOp, RasterOp { public static final int TYPE_NEAREST_NEIGHBOR = 1; - + public static final int TYPE_BILINEAR = 2; - + /** * @since 1.5.0 */ @@ -71,13 +71,13 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp private AffineTransform transform; private RenderingHints hints; - + /** * Construct AffineTransformOp with the given xform and interpolationType. * Interpolation type can be TYPE_BILINEAR, TYPE_BICUBIC or * TYPE_NEAREST_NEIGHBOR. * - * @param xform AffineTransform that will applied to the source image + * @param xform AffineTransform that will applied to the source image * @param interpolationType type of interpolation used * @throws ImagingOpException if the transform matrix is noninvertible */ @@ -90,12 +90,12 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp switch (interpolationType) { case TYPE_BILINEAR: - hints = new RenderingHints (RenderingHints.KEY_INTERPOLATION, + hints = new RenderingHints (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); break; case TYPE_BICUBIC: - hints = new RenderingHints (RenderingHints.KEY_INTERPOLATION, - RenderingHints.VALUE_INTERPOLATION_BICUBIC); + hints = new RenderingHints (RenderingHints.KEY_INTERPOLATION, + RenderingHints.VALUE_INTERPOLATION_BICUBIC); break; default: hints = new RenderingHints (RenderingHints.KEY_INTERPOLATION, @@ -105,7 +105,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp /** * Construct AffineTransformOp with the given xform and rendering hints. - * + * * @param xform AffineTransform that will applied to the source image * @param hints rendering hints that will be used during transformation * @throws ImagingOpException if the transform matrix is noninvertible @@ -119,9 +119,9 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp } /** - * Creates a new BufferedImage with the size equal to that of the - * transformed image and the correct number of bands. The newly created - * image is created with the specified ColorModel. + * Creates a new BufferedImage with the size equal to that of the + * transformed image and the correct number of bands. The newly created + * image is created with the specified ColorModel. * If a ColorModel is not specified, an appropriate ColorModel is used. * * @param src the source image. @@ -149,7 +149,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp } /** - * Creates a new WritableRaster with the size equal to the transformed + * Creates a new WritableRaster with the size equal to the transformed * source raster and correct number of bands . * * @param src the source raster. @@ -159,18 +159,18 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp public WritableRaster createCompatibleDestRaster (Raster src) { Rectangle2D rect = getBounds2D(src); - - if (rect.getWidth() == 0 || rect.getHeight() == 0) + + if (rect.getWidth() == 0 || rect.getHeight() == 0) throw new RasterFormatException("width or height is 0"); - return src.createCompatibleWritableRaster((int) rect.getWidth(), + return src.createCompatibleWritableRaster((int) rect.getWidth(), (int) rect.getHeight()); } /** * Transforms source image using transform specified at the constructor. * The resulting transformed image is stored in the destination image if one - * is provided; otherwise a new BufferedImage is created and returned. + * is provided; otherwise a new BufferedImage is created and returned. * * @param src source image * @param dst destination image @@ -218,7 +218,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp if (src.getNumBands() != dst.getNumBands()) throw new IllegalArgumentException("src and dst must have same number" + " of bands"); - + // Optimization for rasters that can be represented in the RGB colormodel: // wrap the rasters in images, and let Cairo do the transformation if (ColorModel.getRGBdefault().isCompatibleSampleModel(src.getSampleModel()) @@ -232,7 +232,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp src2, false, null); BufferedImage iDst = new BufferedImage(ColorModel.getRGBdefault(), dst, false, null); - + return filter(iSrc, iDst).getRaster(); } @@ -256,7 +256,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp // Use an inverse transform to map each point in the destination to // a point in the source. Note that, while all points in the destination // matrix are integers, this is not necessarily true for points in the - // source (hence why interpolation is required) + // source (hence why interpolation is required) try { AffineTransform inverseTx = transform.createInverse(); @@ -271,18 +271,18 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp // Different interpolation methods... if (hints.containsValue(RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR)) filterNearest(src, dst, dstPts, srcPts); - + else if (hints.containsValue(RenderingHints.VALUE_INTERPOLATION_BILINEAR)) filterBilinear(src, dst, dstPts, srcPts); - + else // bicubic filterBicubic(src, dst, dstPts, srcPts); - return dst; + return dst; } /** - * Transforms source image using transform specified at the constructor and + * Transforms source image using transform specified at the constructor and * returns bounds of the transformed image. * * @param src image to be transformed @@ -292,7 +292,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp { return getBounds2D (src.getRaster()); } - + /** * Returns bounds of the transformed raster. * @@ -313,18 +313,18 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp { if (hints.containsValue(RenderingHints.VALUE_INTERPOLATION_BILINEAR)) return TYPE_BILINEAR; - + else if (hints.containsValue(RenderingHints.VALUE_INTERPOLATION_BICUBIC)) return TYPE_BICUBIC; - - else + + else return TYPE_NEAREST_NEIGHBOR; } - /** - * Returns location of the transformed source point. The resulting point + /** + * Returns location of the transformed source point. The resulting point * is stored in the dstPt if one is specified. - * + * * @param srcPt point to be transformed * @param dstPt destination point * @return the location of the transformed source point. @@ -354,10 +354,10 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp { return transform; } - + /** * Perform nearest-neighbour filtering - * + * * @param src the source raster * @param dst the destination raster * @param dpts array of points on the destination raster @@ -367,14 +367,14 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp double[] pts) { Rectangle srcbounds = src.getBounds(); - + // For all points on the destination raster, copy the value from the // corrosponding (rounded) source point for (int i = 0; i < dpts.length; i += 2) { int srcX = (int) Math.round(pts[i]) + src.getMinX(); int srcY = (int) Math.round(pts[i + 1]) + src.getMinY(); - + if (srcbounds.contains(srcX, srcY)) dst.setDataElements((int) dpts[i] + dst.getMinX(), (int) dpts[i + 1] + dst.getMinY(), @@ -384,7 +384,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp /** * Perform bilinear filtering - * + * * @param src the source raster * @param dst the destination raster * @param dpts array of points on the destination raster @@ -394,26 +394,26 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp double[] pts) { Rectangle srcbounds = src.getBounds(); - + Object xyarr = null; Object xp1arr = null; Object yp1arr = null; Object xyp1arr = null; - + double xy; double xp1; double yp1; double xyp1; double[] result = new double[src.getNumBands()]; - + // For all points in the destination raster, use bilinear interpolation // to find the value from the corrosponding source points for (int i = 0; i < dpts.length; i += 2) { int srcX = (int) Math.round(pts[i]) + src.getMinX(); int srcY = (int) Math.round(pts[i + 1]) + src.getMinY(); - + if (srcbounds.contains(srcX, srcY)) { // Corner case at the bottom or right edge; use nearest neighbour @@ -422,7 +422,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp dst.setDataElements((int) dpts[i] + dst.getMinX(), (int) dpts[i + 1] + dst.getMinY(), src.getDataElements(srcX, srcY, null)); - + // Standard case, apply the bilinear formula else { @@ -448,11 +448,11 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp yp1arr = src.getPixel(x, y+1, (int[])yp1arr); xyp1arr = src.getPixel(x+1, y+1, (int[])xyp1arr); } - // using + // using // array[] pixels = src.getPixels(x, y, 2, 2, pixels); // instead of doing four individual src.getPixel() calls // should be faster, but benchmarking shows that it's not... - + // Run interpolation for each band for (int j = 0; j < src.getNumBands(); j++) { @@ -472,16 +472,16 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp yp1 = ((int[])yp1arr)[j]; xyp1 = ((int[])xyp1arr)[j]; } - - // If all four samples are identical, there's no need to + + // If all four samples are identical, there's no need to // calculate anything if (xy == xp1 && xy == yp1 && xy == xyp1) result[j] = xy; - + // Run bilinear interpolation formula else - result[j] = (xy * (1-xdiff) + xp1 * xdiff) - * (1-ydiff) + result[j] = (xy * (1-xdiff) + xp1 * xdiff) + * (1-ydiff) + (yp1 * (1-xdiff) + xyp1 * xdiff) * ydiff; } @@ -497,7 +497,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp /** * Perform bicubic filtering * based on http://local.wasp.uwa.edu.au/~pbourke/colour/bicubic/ - * + * * @param src the source raster * @param dst the destination raster * @param dpts array of points on the destination raster @@ -522,7 +522,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp double dx = pts[i] + src.getMinX() - x; double dy = pts[i + 1] + src.getMinY() - y; Arrays.fill(result, 0); - + for (int m = - 1; m < 3; m++) for (int n = - 1; n < 3; n++) { @@ -597,7 +597,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp result[j] += ((int[])pixels)[j] * r1 * r2; } } - + // Put it all together dst.setPixel((int)dpts[i] + dst.getMinX(), (int)dpts[i+1] + dst.getMinY(), diff --git a/java/awt/image/AreaAveragingScaleFilter.java b/java/awt/image/AreaAveragingScaleFilter.java index 491a2f519..db2335f1c 100644 --- a/java/awt/image/AreaAveragingScaleFilter.java +++ b/java/awt/image/AreaAveragingScaleFilter.java @@ -42,11 +42,11 @@ package java.awt.image; * This filter should produce images which do not have image artifacts * like broken lines which were originally unbroken. The cost is of * course speed. Using bi-linear interpolation here against 4 pixel - * points should give the desired results although Sun does not + * points should give the desired results although Sun does not * specify what the exact algorithm should be. * <br> * - * @author C. Brian Jones (cbj@gnu.org) + * @author C. Brian Jones (cbj@gnu.org) */ public class AreaAveragingScaleFilter extends ReplicateScaleFilter { @@ -54,7 +54,7 @@ public class AreaAveragingScaleFilter extends ReplicateScaleFilter * Construct an instance of <code>AreaAveragingScaleFilter</code> which * should be used in conjunction with a <code>FilteredImageSource</code> * object. - * + * * @param width the width of the destination image * @param height the height of the destination image */ @@ -66,14 +66,14 @@ public class AreaAveragingScaleFilter extends ReplicateScaleFilter * The <code>ImageProducer</code> should call this method with a * bit mask of hints from any of <code>RANDOMPIXELORDER</code>, * <code>TOPDOWNLEFTRIGHT</code>, <code>COMPLETESCANLINES</code>, - * <code>SINGLEPASS</code>, <code>SINGLEFRAME</code> from the + * <code>SINGLEPASS</code>, <code>SINGLEFRAME</code> from the * <code>ImageConsumer</code> interface. * <br> - * FIXME - more than likely Sun's implementation desires + * FIXME - more than likely Sun's implementation desires * <code>TOPDOWNLEFTRIGHT</code> order and this method is overloaded here * in order to assure that mask is part of the hints added to * the consumer. - * + * * @param flags a bit mask of hints * @see ImageConsumer */ @@ -86,7 +86,7 @@ public class AreaAveragingScaleFilter extends ReplicateScaleFilter /** * This function delivers a rectangle of pixels where any * pixel(m,n) is stored in the array as a <code>byte</code> at - * index (n * scansize + m + offset). + * index (n * scansize + m + offset). * * @param x the x coordinate of the rectangle * @param y the y coordinate of the rectangle @@ -97,8 +97,8 @@ public class AreaAveragingScaleFilter extends ReplicateScaleFilter * @param offset the index of the first pixels in the <code>pixels</code> array * @param scansize the width to use in extracting pixels from the <code>pixels</code> array */ - public void setPixels(int x, int y, int w, int h, - ColorModel model, byte[] pixels, int offset, int scansize) + public void setPixels(int x, int y, int w, int h, + ColorModel model, byte[] pixels, int offset, int scansize) { double rx = ((double) srcWidth) / destWidth; double ry = ((double) srcHeight) / destHeight; @@ -106,19 +106,19 @@ public class AreaAveragingScaleFilter extends ReplicateScaleFilter int destScansize = (int) Math.round(scansize / rx); byte[] destPixels = averagePixels(x, y, w, h, - model, pixels, offset, scansize, - rx, ry, destScansize); + model, pixels, offset, scansize, + rx, ry, destScansize); if (consumer != null) consumer.setPixels((int) Math.floor(x/rx), (int) Math.floor(y/ry), - (int) Math.ceil(w/rx), (int) Math.ceil(h/ry), - model, destPixels, 0, destScansize); + (int) Math.ceil(w/rx), (int) Math.ceil(h/ry), + model, destPixels, 0, destScansize); } /** * This function delivers a rectangle of pixels where any * pixel(m,n) is stored in the array as an <code>int</code> at - * index (n * scansize + m + offset). + * index (n * scansize + m + offset). * * @param x the x coordinate of the rectangle * @param y the y coordinate of the rectangle @@ -129,8 +129,8 @@ public class AreaAveragingScaleFilter extends ReplicateScaleFilter * @param offset the index of the first pixels in the <code>pixels</code> array * @param scansize the width to use in extracting pixels from the <code>pixels</code> array */ - public void setPixels(int x, int y, int w, int h, - ColorModel model, int[] pixels, int offset, int scansize) + public void setPixels(int x, int y, int w, int h, + ColorModel model, int[] pixels, int offset, int scansize) { double rx = ((double) srcWidth) / destWidth; double ry = ((double) srcHeight) / destHeight; @@ -138,17 +138,17 @@ public class AreaAveragingScaleFilter extends ReplicateScaleFilter int destScansize = (int) Math.round(scansize / rx); int[] destPixels = averagePixels(x, y, w, h, - model, pixels, offset, scansize, - rx, ry, destScansize); + model, pixels, offset, scansize, + rx, ry, destScansize); if (consumer != null) consumer.setPixels((int) Math.floor(x/rx), (int) Math.floor(y/ry), - (int) Math.ceil(w/rx), (int) Math.ceil(h/ry), - model, destPixels, 0, destScansize); + (int) Math.ceil(w/rx), (int) Math.ceil(h/ry), + model, destPixels, 0, destScansize); } /** - * This is a really terrible implementation, + * This is a really terrible implementation, * since it uses the nearest-neighbor method. This filter is rarely used though. * * @param srcx, srcy - Source rectangle upper-left corner @@ -161,9 +161,9 @@ public class AreaAveragingScaleFilter extends ReplicateScaleFilter * @param destScansize - Destination array scanline size. */ private byte[] averagePixels(int srcx, int srcy, int srcw, int srch, - ColorModel model, byte[] srcPixels, - int srcOffset, int srcScansize, - double rx, double ry, int destScansize) + ColorModel model, byte[] srcPixels, + int srcOffset, int srcScansize, + double rx, double ry, int destScansize) { int destW = (int) Math.ceil(srcw/rx); int destH = (int) Math.ceil(srch/ry); @@ -175,40 +175,40 @@ public class AreaAveragingScaleFilter extends ReplicateScaleFilter for(int x = 0; x < destW; x++) for(int y = 0; y < destH; y++) - { - sx = (int) (x * rx); - sy = (int) (y * ry); - - int r,g,b,a; - r = g = b = a = 0; - - for(int i = 0; i < w; i++) - { - for(int j = 0; j < h; j++) - { - int idx = srcx + sx + i + (srcy + sy + j)*srcScansize; - r += model.getRed(srcPixels[ idx ]); - g += model.getGreen(srcPixels[ idx ]); - b += model.getBlue(srcPixels[ idx ]); - a += model.getAlpha(srcPixels[ idx ]); - } - } - - r = r / (w * h); - g = g / (w * h); - b = b / (w * h); - a = a / (w * h); - - // Does this really work? - destPixels[x + destScansize*y] = (byte)model.getDataElement - (new int[]{r, g, b, a}, 0); - } + { + sx = (int) (x * rx); + sy = (int) (y * ry); + + int r,g,b,a; + r = g = b = a = 0; + + for(int i = 0; i < w; i++) + { + for(int j = 0; j < h; j++) + { + int idx = srcx + sx + i + (srcy + sy + j)*srcScansize; + r += model.getRed(srcPixels[ idx ]); + g += model.getGreen(srcPixels[ idx ]); + b += model.getBlue(srcPixels[ idx ]); + a += model.getAlpha(srcPixels[ idx ]); + } + } + + r = r / (w * h); + g = g / (w * h); + b = b / (w * h); + a = a / (w * h); + + // Does this really work? + destPixels[x + destScansize*y] = (byte)model.getDataElement + (new int[]{r, g, b, a}, 0); + } return destPixels; } /** - * This is a really terrible implementation, + * This is a really terrible implementation, * since it uses the nearest-neighbor method. This filter is rarely used though. * * @param srcx, srcy - Source rectangle upper-left corner @@ -221,49 +221,48 @@ public class AreaAveragingScaleFilter extends ReplicateScaleFilter * @param destScansize - Destination array scanline size. */ private int[] averagePixels(int srcx, int srcy, int srcw, int srch, - ColorModel model, int[] srcPixels, - int srcOffset, int srcScansize, - double rx, double ry, int destScansize) + ColorModel model, int[] srcPixels, + int srcOffset, int srcScansize, + double rx, double ry, int destScansize) { int destW = (int) Math.ceil(srcw/rx); int destH = (int) Math.ceil(srch/ry); int[] destPixels = new int[ destW * destH ]; int sx, sy; - + int w = (int)Math.ceil(rx); int h = (int)Math.ceil(ry); - + for(int x = 0; x < destW; x++) for(int y = 0; y < destH; y++) - { - sx = (int) (x * rx); - sy = (int) (y * ry); - - int r,g,b,a; - r = g = b = a = 0; - - for(int i = 0; i < w; i++) - { - for(int j = 0; j < h; j++) - { - int idx = srcx + sx + i + (srcy + sy + j)*srcScansize; - r += model.getRed(srcPixels[ idx ]); - g += model.getGreen(srcPixels[ idx ]); - b += model.getBlue(srcPixels[ idx ]); - a += model.getAlpha(srcPixels[ idx ]); - } - } - - r = r / (w * h); - g = g / (w * h); - b = b / (w * h); - a = a / (w * h); - - destPixels[x + destScansize*y] = model.getDataElement - (new int[]{r, g, b, a}, 0); - } - + { + sx = (int) (x * rx); + sy = (int) (y * ry); + + int r,g,b,a; + r = g = b = a = 0; + + for(int i = 0; i < w; i++) + { + for(int j = 0; j < h; j++) + { + int idx = srcx + sx + i + (srcy + sy + j)*srcScansize; + r += model.getRed(srcPixels[ idx ]); + g += model.getGreen(srcPixels[ idx ]); + b += model.getBlue(srcPixels[ idx ]); + a += model.getAlpha(srcPixels[ idx ]); + } + } + + r = r / (w * h); + g = g / (w * h); + b = b / (w * h); + a = a / (w * h); + + destPixels[x + destScansize*y] = model.getDataElement + (new int[]{r, g, b, a}, 0); + } + return destPixels; } } - diff --git a/java/awt/image/BandCombineOp.java b/java/awt/image/BandCombineOp.java index d9ce16fad..f3a6c5756 100644 --- a/java/awt/image/BandCombineOp.java +++ b/java/awt/image/BandCombineOp.java @@ -44,29 +44,29 @@ import java.util.Arrays; /** * Filter Raster pixels by applying a matrix. - * + * * BandCombineOp applies a matrix to each pixel to produce new pixel values. * The width of the matrix must be the same or one more than the number of * bands in the source Raster. If one more, the pixels in the source are * assumed to contain an implicit 1.0 at the end. - * + * * The rows of the matrix are multiplied by the pixel to produce the values * for the destination. Therefore the destination Raster must contain the * same number of bands as the number of rows in the filter matrix. - * + * * This Op assumes that samples are integers; floating point sample types will * be rounded to their nearest integer value during filtering. - * + * * @author Jerry Quinn (jlquinn@optonline.net) */ public class BandCombineOp implements RasterOp { private RenderingHints hints; private float[][] matrix; - + /** * Construct a BandCombineOp. - * + * * @param matrix The matrix to filter pixels with. * @param hints Rendering hints to apply. Ignored. * @throws ArrayIndexOutOfBoundsException if the matrix is invalid @@ -96,7 +96,7 @@ public class BandCombineOp implements RasterOp * by 1, i.e. added to the sum for that dest component. If dest is null, a * suitable Raster is created. This implementation uses * createCompatibleDestRaster. - * + * * @param src The source Raster. * @param dest The destination Raster, or null. * @throws IllegalArgumentException if the destination raster is incompatible @@ -122,7 +122,7 @@ public class BandCombineOp implements RasterOp // In case matrix rows have implicit translation spix[spix.length - 1] = 1; src.getPixel(x, y, spix); - + // Do not re-calculate if pixel is identical to the last one // (ie, blocks of the same colour) if (!Arrays.equals(spix, spix2)) @@ -154,7 +154,7 @@ public class BandCombineOp implements RasterOp * Op. The number of bands in the source raster must equal the number of rows * in the op matrix, which must also be equal to either the number of columns * or (columns - 1) in the matrix. - * + * * @param src The source raster. * @return A compatible raster. * @see java.awt.image.RasterOp#createCompatibleDestRaster(java.awt.image.Raster) @@ -181,18 +181,18 @@ public class BandCombineOp implements RasterOp /** * Return corresponding destination point for source point. Because this is * not a geometric operation, it simply returns a copy of the source. - * + * * @param src The source point. * @param dst The destination point. * @return dst The destination point. * @see java.awt.image.RasterOp#getPoint2D(java.awt.geom.Point2D, - *java.awt.geom.Point2D) + *java.awt.geom.Point2D) */ public final Point2D getPoint2D(Point2D src, Point2D dst) { if (dst == null) return (Point2D)src.clone(); - + dst.setLocation(src); return dst; } @@ -204,7 +204,7 @@ public class BandCombineOp implements RasterOp { return hints; } - + /** * Return the matrix used in this operation. * diff --git a/java/awt/image/BandedSampleModel.java b/java/awt/image/BandedSampleModel.java index 94dbd8d46..7df6c8548 100644 --- a/java/awt/image/BandedSampleModel.java +++ b/java/awt/image/BandedSampleModel.java @@ -55,7 +55,7 @@ public final class BandedSampleModel extends ComponentSampleModel private int numberOfBits; private int numElems; - private static int[] createBankArray(int size) + private static int[] createBankArray(int size) { int[] result = new int[size]; for (int i = 0; i < size; i++) @@ -65,7 +65,7 @@ public final class BandedSampleModel extends ComponentSampleModel /** * Creates a new <code>BandedSampleModel</code>. - * + * * @param dataType the data buffer type. * @param w the width (in pixels). * @param h the height (in pixels). @@ -78,24 +78,24 @@ public final class BandedSampleModel extends ComponentSampleModel /** * Creates a new <code>BandedSampleModel</code>. - * + * * @param dataType the data buffer type. * @param w the width (in pixels). * @param h the height (in pixels). - * @param scanlineStride the number of data elements from a pixel in one + * @param scanlineStride the number of data elements from a pixel in one * row to the corresponding pixel in the next row. * @param bankIndices the bank indices. * @param bandOffsets the band offsets. */ public BandedSampleModel(int dataType, int w, int h, int scanlineStride, - int[] bankIndices, int[] bandOffsets) + int[] bankIndices, int[] bandOffsets) { super(dataType, w, h, 1, scanlineStride, bankIndices, bandOffsets); } - + /** * Creates a new data buffer that is compatible with this sample model. - * + * * @return The new data buffer. */ public DataBuffer createDataBuffer() @@ -107,15 +107,15 @@ public final class BandedSampleModel extends ComponentSampleModel /** * Creates a new <code>SampleModel</code> that is compatible with this * model and has the specified width and height. - * + * * @param w the width (in pixels, must be greater than zero). * @param h the height (in pixels, must be greater than zero). - * + * * @return The new sample model. - * + * * @throws IllegalArgumentException if <code>w</code> or <code>h</code> is * not greater than zero. - * @throws IllegalArgumentException if <code>w * h</code> exceeds + * @throws IllegalArgumentException if <code>w * h</code> exceeds * <code>Integer.MAX_VALUE</code>. */ public SampleModel createCompatibleSampleModel(int w, int h) @@ -150,7 +150,7 @@ public final class BandedSampleModel extends ComponentSampleModel newoffsets[order[i]] = offset; offset += w * scanlineStride; } - + return new BandedSampleModel(dataType, w, h, w, bankIndices, newoffsets); } @@ -159,19 +159,19 @@ public final class BandedSampleModel extends ComponentSampleModel { if (bands.length > bankIndices.length) throw new - RasterFormatException("BandedSampleModel createSubsetSampleModel too" - +" many bands"); + RasterFormatException("BandedSampleModel createSubsetSampleModel too" + +" many bands"); int[] newoff = new int[bands.length]; int[] newbanks = new int[bands.length]; for (int i = 0; i < bands.length; i++) { - int b = bands[i]; - newoff[i] = bandOffsets[b]; - newbanks[i] = bankIndices[b]; + int b = bands[i]; + newoff[i] = bandOffsets[b]; + newbanks[i] = bankIndices[b]; } return new BandedSampleModel(dataType, width, height, scanlineStride, - newbanks, newoff); + newbanks, newoff); } /** @@ -180,15 +180,15 @@ public final class BandedSampleModel extends ComponentSampleModel * Extracts the pixel at x, y from data and stores samples into the array * obj. If obj is null, a new array of getTransferType() is created. * - * @param x The x-coordinate of the pixel rectangle to store in + * @param x The x-coordinate of the pixel rectangle to store in * <code>obj</code>. - * @param y The y-coordinate of the pixel rectangle to store in + * @param y The y-coordinate of the pixel rectangle to store in * <code>obj</code>. - * @param obj The primitive array to store the pixels into or null to force + * @param obj The primitive array to store the pixels into or null to force * creation. * @param data The DataBuffer that is the source of the pixel data. * @return The primitive array containing the pixel data. - * @see java.awt.image.SampleModel#getDataElements(int, int, + * @see java.awt.image.SampleModel#getDataElements(int, int, * java.lang.Object, java.awt.image.DataBuffer) */ public Object getDataElements(int x, int y, Object obj, DataBuffer data) @@ -201,45 +201,45 @@ public final class BandedSampleModel extends ComponentSampleModel { case DataBuffer.TYPE_BYTE: { - byte[] b = (byte[]) obj; - if (b == null) b = new byte[numBands]; - for (int i = 0; i < numBands; i++) - b[i] = (byte)getSample(x, y, i, data); - return b; + byte[] b = (byte[]) obj; + if (b == null) b = new byte[numBands]; + for (int i = 0; i < numBands; i++) + b[i] = (byte)getSample(x, y, i, data); + return b; } case DataBuffer.TYPE_SHORT: case DataBuffer.TYPE_USHORT: { - short[] b = (short[]) obj; - if (b == null) b = new short[numBands]; - for (int i = 0; i < numBands; i++) - b[i] = (short)getSample(x, y, i, data); - return b; + short[] b = (short[]) obj; + if (b == null) b = new short[numBands]; + for (int i = 0; i < numBands; i++) + b[i] = (short)getSample(x, y, i, data); + return b; } case DataBuffer.TYPE_INT: { - int[] b = (int[]) obj; - if (b == null) b = new int[numBands]; - for (int i = 0; i < numBands; i++) - b[i] = getSample(x, y, i, data); - return b; + int[] b = (int[]) obj; + if (b == null) b = new int[numBands]; + for (int i = 0; i < numBands; i++) + b[i] = getSample(x, y, i, data); + return b; } case DataBuffer.TYPE_FLOAT: { - float[] b = (float[]) obj; - if (b == null) b = new float[numBands]; - for (int i = 0; i < numBands; i++) - b[i] = getSampleFloat(x, y, i, data); - return b; + float[] b = (float[]) obj; + if (b == null) b = new float[numBands]; + for (int i = 0; i < numBands; i++) + b[i] = getSampleFloat(x, y, i, data); + return b; } case DataBuffer.TYPE_DOUBLE: { - double[] b = (double[]) obj; - if (b == null) + double[] b = (double[]) obj; + if (b == null) b = new double[numBands]; - for (int i = 0; i < numBands; i++) - b[i] = getSample(x, y, i, data); - return b; + for (int i = 0; i < numBands; i++) + b[i] = getSample(x, y, i, data); + return b; } default: @@ -251,26 +251,26 @@ public final class BandedSampleModel extends ComponentSampleModel /** * Returns all the samples for the pixel at location <code>(x, y)</code> * stored in the specified data buffer. - * + * * @param x the x-coordinate. * @param y the y-coordinate. * @param iArray an array that will be populated with the sample values and - * returned as the result. The size of this array should be equal to the + * returned as the result. The size of this array should be equal to the * number of bands in the model. If the array is <code>null</code>, a new * array is created. * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The samples for the specified pixel. - * + * * @see #setPixel(int, int, int[], DataBuffer) */ public int[] getPixel(int x, int y, int[] iArray, DataBuffer data) { - if (iArray == null) + if (iArray == null) iArray = new int[numBands]; for (int i = 0; i < numBands; i++) iArray[i] = getSample(x, y, i, data); - + return iArray; } @@ -296,43 +296,43 @@ public final class BandedSampleModel extends ComponentSampleModel * @return The primitive array containing the pixel data. */ public int[] getPixels(int x, int y, int w, int h, int[] iArray, - DataBuffer data) + DataBuffer data) { if (x < 0 || y < 0) throw new ArrayIndexOutOfBoundsException( "x and y must not be less than 0."); - if (iArray == null) + if (iArray == null) iArray = new int[w * h * numBands]; int outOffset = 0; int maxX = x + w; int maxY = y + h; for (int yy = x; yy < maxY; yy++) { - for (int xx = x; xx < maxX; xx++) - { - for (int b = 0; b < numBands; b++) - { - int offset = bandOffsets[b] + yy * scanlineStride + xx; - iArray[outOffset++] = - data.getElem(bankIndices[b], offset); - } - } + for (int xx = x; xx < maxX; xx++) + { + for (int b = 0; b < numBands; b++) + { + int offset = bandOffsets[b] + yy * scanlineStride + xx; + iArray[outOffset++] = + data.getElem(bankIndices[b], offset); + } + } } - return iArray; + return iArray; } /** - * Returns a sample value for the pixel at (x, y) in the specified data + * Returns a sample value for the pixel at (x, y) in the specified data * buffer. - * + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The sample value. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public int getSample(int x, int y, int b, DataBuffer data) @@ -340,21 +340,21 @@ public final class BandedSampleModel extends ComponentSampleModel int offset = bandOffsets[b] + y * scanlineStride + x; return data.getElem(bankIndices[b], offset); } - + /** - * Returns a sample value for the pixel at (x, y) in the specified data + * Returns a sample value for the pixel at (x, y) in the specified data * buffer. - * + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The sample value. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. - * + * * @see #getSample(int, int, int, DataBuffer) */ public float getSampleFloat(int x, int y, int b, DataBuffer data) @@ -362,21 +362,21 @@ public final class BandedSampleModel extends ComponentSampleModel int offset = bandOffsets[b] + y * scanlineStride + x; return data.getElemFloat(bankIndices[b], offset); } - + /** - * Returns the sample value for the pixel at (x, y) in the specified data + * Returns the sample value for the pixel at (x, y) in the specified data * buffer. - * + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The sample value. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. - * + * * @see #getSample(int, int, int, DataBuffer) */ public double getSampleDouble(int x, int y, int b, DataBuffer data) @@ -384,7 +384,7 @@ public final class BandedSampleModel extends ComponentSampleModel int offset = bandOffsets[b] + y * scanlineStride + x; return data.getElemDouble(bankIndices[b], offset); } - + /** * Copy one band's samples from a region into an array. * @@ -406,26 +406,26 @@ public final class BandedSampleModel extends ComponentSampleModel * @return The primitive array containing the pixel data. */ public int[] getSamples(int x, int y, int w, int h, int b, int[] iArray, - DataBuffer data) + DataBuffer data) { if (x < 0 || y < 0) throw new ArrayIndexOutOfBoundsException( "x and y must not be less than 0."); - if (iArray == null) + if (iArray == null) iArray = new int[w * h]; int outOffset = 0; int maxX = x + w; int maxY = y + h; for (int yy = y; yy < maxY; yy++) { - for (int xx = x; xx < maxX; xx++) - { - int offset = bandOffsets[b] + yy * scanlineStride + xx; - iArray[outOffset++] = - data.getElem(bankIndices[b], offset); - } + for (int xx = x; xx < maxX; xx++) + { + int offset = bandOffsets[b] + yy * scanlineStride + xx; + iArray[outOffset++] = + data.getElem(bankIndices[b], offset); + } } - return iArray; + return iArray; } /** @@ -443,186 +443,186 @@ public final class BandedSampleModel extends ComponentSampleModel int transferType = getTransferType(); if (getTransferType() != data.getDataType()) { - throw new IllegalArgumentException("transfer type ("+ - getTransferType()+"), "+ - "does not match data "+ - "buffer type (" + - data.getDataType() + - ")."); + throw new IllegalArgumentException("transfer type ("+ + getTransferType()+"), "+ + "does not match data "+ + "buffer type (" + + data.getDataType() + + ")."); } int offset = y * scanlineStride + x; - + try { - switch (transferType) - { - case DataBuffer.TYPE_BYTE: - { - DataBufferByte out = (DataBufferByte) data; - byte[] in = (byte[]) obj; - for (int i = 0; i < numBands; i++) - out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[i]; - return; - } - case DataBuffer.TYPE_SHORT: - { - DataBufferShort out = (DataBufferShort) data; - short[] in = (short[]) obj; - for (int i = 0; i < numBands; i++) - out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[i]; - return; - } - case DataBuffer.TYPE_USHORT: - { - DataBufferUShort out = (DataBufferUShort) data; - short[] in = (short[]) obj; - for (int i = 0; i < numBands; i++) - out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[i]; - return; - } - case DataBuffer.TYPE_INT: - { - DataBufferInt out = (DataBufferInt) data; - int[] in = (int[]) obj; - for (int i = 0; i < numBands; i++) - out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[i]; - return; - } - case DataBuffer.TYPE_FLOAT: - { - DataBufferFloat out = (DataBufferFloat) data; - float[] in = (float[]) obj; - for (int i = 0; i < numBands; i++) - out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[i]; - return; - } - case DataBuffer.TYPE_DOUBLE: - { - DataBufferDouble out = (DataBufferDouble) data; - double[] in = (double[]) obj; - for (int i = 0; i < numBands; i++) - out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[i]; - return; - } - default: - throw new ClassCastException("Unsupported data type"); - } + switch (transferType) + { + case DataBuffer.TYPE_BYTE: + { + DataBufferByte out = (DataBufferByte) data; + byte[] in = (byte[]) obj; + for (int i = 0; i < numBands; i++) + out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[i]; + return; + } + case DataBuffer.TYPE_SHORT: + { + DataBufferShort out = (DataBufferShort) data; + short[] in = (short[]) obj; + for (int i = 0; i < numBands; i++) + out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[i]; + return; + } + case DataBuffer.TYPE_USHORT: + { + DataBufferUShort out = (DataBufferUShort) data; + short[] in = (short[]) obj; + for (int i = 0; i < numBands; i++) + out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[i]; + return; + } + case DataBuffer.TYPE_INT: + { + DataBufferInt out = (DataBufferInt) data; + int[] in = (int[]) obj; + for (int i = 0; i < numBands; i++) + out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[i]; + return; + } + case DataBuffer.TYPE_FLOAT: + { + DataBufferFloat out = (DataBufferFloat) data; + float[] in = (float[]) obj; + for (int i = 0; i < numBands; i++) + out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[i]; + return; + } + case DataBuffer.TYPE_DOUBLE: + { + DataBufferDouble out = (DataBufferDouble) data; + double[] in = (double[]) obj; + for (int i = 0; i < numBands; i++) + out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[i]; + return; + } + default: + throw new ClassCastException("Unsupported data type"); + } } catch (ArrayIndexOutOfBoundsException aioobe) { - String msg = "While writing data elements" - + ", x=" + x + ", y=" + y - + ", width=" + width + ", height=" + height - + ", scanlineStride=" + scanlineStride - + ", offset=" + offset - + ", data.getSize()=" + data.getSize() - + ", data.getOffset()=" + data.getOffset() + String msg = "While writing data elements" + + ", x=" + x + ", y=" + y + + ", width=" + width + ", height=" + height + + ", scanlineStride=" + scanlineStride + + ", offset=" + offset + + ", data.getSize()=" + data.getSize() + + ", data.getOffset()=" + data.getOffset() + ": " + aioobe; - throw new ArrayIndexOutOfBoundsException(msg); + throw new ArrayIndexOutOfBoundsException(msg); } } /** * Sets the samples for the pixel at (x, y) in the specified data buffer to - * the specified values. - * + * the specified values. + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. * @param iArray the sample values (<code>null</code> not permitted). * @param data the data buffer (<code>null</code> not permitted). - * - * @throws NullPointerException if either <code>iArray</code> or + * + * @throws NullPointerException if either <code>iArray</code> or * <code>data</code> is <code>null</code>. */ public void setPixel(int x, int y, int[] iArray, DataBuffer data) { for (int b = 0; b < numBands; b++) data.setElem(bankIndices[b], bandOffsets[b] + y * scanlineStride + x, - iArray[b]); + iArray[b]); } /** - * Sets the sample values for the pixels in the region specified by + * Sets the sample values for the pixels in the region specified by * (x, y, w, h) in the specified data buffer. The array is - * ordered by pixels (that is, all the samples for the first pixel are + * ordered by pixels (that is, all the samples for the first pixel are * grouped together, followed by all the samples for the second pixel, and so - * on). - * + * on). + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. * @param iArray the pixel sample values (<code>null</code> not permitted). * @param data the data buffer (<code>null</code> not permitted). - * - * @throws NullPointerException if either <code>iArray</code> or + * + * @throws NullPointerException if either <code>iArray</code> or * <code>data</code> is <code>null</code>. */ public void setPixels(int x, int y, int w, int h, int[] iArray, - DataBuffer data) + DataBuffer data) { int inOffset = 0; for (int hh = 0; hh < h; hh++) { - for (int ww = 0; ww < w; ww++) - { - int offset = y * scanlineStride + (x + ww); - for (int b = 0; b < numBands; b++) - data.setElem(bankIndices[b], bandOffsets[b] + offset, - iArray[inOffset++]); - } - y++; + for (int ww = 0; ww < w; ww++) + { + int offset = y * scanlineStride + (x + ww); + for (int b = 0; b < numBands; b++) + data.setElem(bankIndices[b], bandOffsets[b] + offset, + iArray[inOffset++]); + } + y++; } } /** * Sets the sample value for band <code>b</code> of the pixel at location * <code>(x, y)</code> in the specified data buffer. - * + * * @param x the x-coordinate. * @param y the y-coordinate. * @param b the band index. * @param s the sample value. * @param data the data buffer (<code>null</code> not permitted). - * + * * @see #getSample(int, int, int, DataBuffer) */ public void setSample(int x, int y, int b, int s, DataBuffer data) { data.setElem(bankIndices[b], bandOffsets[b] + y * scanlineStride + x, s); } - + /** - * Sets the sample value for a band for the pixel at (x, y) in the - * specified data buffer. - * + * Sets the sample value for a band for the pixel at (x, y) in the + * specified data buffer. + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). * @param s the sample value. * @param data the data buffer (<code>null</code> not permitted). - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public void setSample(int x, int y, int b, float s, DataBuffer data) { - data.setElemFloat(bankIndices[b], bandOffsets[b] + y * scanlineStride + x, + data.setElemFloat(bankIndices[b], bandOffsets[b] + y * scanlineStride + x, s); } - + /** - * Sets the sample value for a band for the pixel at (x, y) in the - * specified data buffer. - * + * Sets the sample value for a band for the pixel at (x, y) in the + * specified data buffer. + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). * @param s the sample value. * @param data the data buffer (<code>null</code> not permitted). - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public void setSample(int x, int y, int b, double s, DataBuffer data) @@ -630,25 +630,25 @@ public final class BandedSampleModel extends ComponentSampleModel data.setElemDouble(bankIndices[b], bandOffsets[b] + y * scanlineStride + x, s); } - + /** - * Sets the sample values for one band for the pixels in the region - * specified by (x, y, w, h) in the specified data buffer. - * + * Sets the sample values for one band for the pixels in the region + * specified by (x, y, w, h) in the specified data buffer. + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * </code>getNumBands() - 1</code>). * @param iArray the sample values (<code>null</code> not permitted). * @param data the data buffer (<code>null</code> not permitted). - * - * @throws NullPointerException if either <code>iArray</code> or + * + * @throws NullPointerException if either <code>iArray</code> or * <code>data</code> is <code>null</code>. */ public void setSamples(int x, int y, int w, int h, int b, int[] iArray, - DataBuffer data) + DataBuffer data) { if (x < 0 || y < 0) throw new ArrayIndexOutOfBoundsException( @@ -658,81 +658,81 @@ public final class BandedSampleModel extends ComponentSampleModel switch (getTransferType()) { case DataBuffer.TYPE_BYTE: - { - DataBufferByte out = (DataBufferByte) data; - byte[] bank = out.getData(bankIndices[b]); - for (int hh = 0; hh < h; hh++) - { - for (int ww = 0; ww < w; ww++) - { - int offset = bandOffsets[b] + y * scanlineStride + (x + ww); - bank[offset] = (byte)iArray[inOffset++]; - } - y++; - } - return; - } + { + DataBufferByte out = (DataBufferByte) data; + byte[] bank = out.getData(bankIndices[b]); + for (int hh = 0; hh < h; hh++) + { + for (int ww = 0; ww < w; ww++) + { + int offset = bandOffsets[b] + y * scanlineStride + (x + ww); + bank[offset] = (byte)iArray[inOffset++]; + } + y++; + } + return; + } case DataBuffer.TYPE_SHORT: - { - DataBufferShort out = (DataBufferShort) data; - short[] bank = out.getData(bankIndices[b]); - for (int hh = 0; hh < h; hh++) - { - for (int ww = 0; ww < w; ww++) - { - int offset = bandOffsets[b] + y * scanlineStride + (x + ww); - bank[offset] = (short)iArray[inOffset++]; - } - y++; - } - return; - } + { + DataBufferShort out = (DataBufferShort) data; + short[] bank = out.getData(bankIndices[b]); + for (int hh = 0; hh < h; hh++) + { + for (int ww = 0; ww < w; ww++) + { + int offset = bandOffsets[b] + y * scanlineStride + (x + ww); + bank[offset] = (short)iArray[inOffset++]; + } + y++; + } + return; + } case DataBuffer.TYPE_USHORT: - { - DataBufferShort out = (DataBufferShort) data; - short[] bank = out.getData(bankIndices[b]); - for (int hh = 0; hh < h; hh++) - { - for (int ww = 0; ww < w; ww++) - { - int offset = bandOffsets[b] + y * scanlineStride + (x + ww); - bank[offset] = (short)iArray[inOffset++]; - } - y++; - } - return; - } + { + DataBufferShort out = (DataBufferShort) data; + short[] bank = out.getData(bankIndices[b]); + for (int hh = 0; hh < h; hh++) + { + for (int ww = 0; ww < w; ww++) + { + int offset = bandOffsets[b] + y * scanlineStride + (x + ww); + bank[offset] = (short)iArray[inOffset++]; + } + y++; + } + return; + } case DataBuffer.TYPE_INT: - { - DataBufferInt out = (DataBufferInt) data; - int[] bank = out.getData(bankIndices[b]); - for (int hh = 0; hh < h; hh++) - { - for (int ww = 0; ww < w; ww++) - { - int offset = bandOffsets[b] + y * scanlineStride + (x + ww); - bank[offset] = iArray[inOffset++]; - } - y++; - } - return; - } + { + DataBufferInt out = (DataBufferInt) data; + int[] bank = out.getData(bankIndices[b]); + for (int hh = 0; hh < h; hh++) + { + for (int ww = 0; ww < w; ww++) + { + int offset = bandOffsets[b] + y * scanlineStride + (x + ww); + bank[offset] = iArray[inOffset++]; + } + y++; + } + return; + } case DataBuffer.TYPE_FLOAT: case DataBuffer.TYPE_DOUBLE: - break; + break; default: - throw new ClassCastException("Unsupported data type"); + throw new ClassCastException("Unsupported data type"); } // Default implementation probably slower for float and double for (int hh = 0; hh < h; hh++) { - for (int ww = 0; ww < w; ww++) - { - int offset = bandOffsets[b] + y * scanlineStride + (x + ww); - data.setElem(bankIndices[b], offset, iArray[inOffset++]); - } - y++; + for (int ww = 0; ww < w; ww++) + { + int offset = bandOffsets[b] + y * scanlineStride + (x + ww); + data.setElem(bankIndices[b], offset, iArray[inOffset++]); + } + y++; } } @@ -752,7 +752,7 @@ public final class BandedSampleModel extends ComponentSampleModel result.append(", mask[").append(i).append("]=0x").append( Integer.toHexString(bitMasks[i])); } - + result.append("]"); return result.toString(); } diff --git a/java/awt/image/BufferedImage.java b/java/awt/image/BufferedImage.java index 260d254fd..094c71dd1 100644 --- a/java/awt/image/BufferedImage.java +++ b/java/awt/image/BufferedImage.java @@ -61,7 +61,7 @@ import java.util.Vector; * the image consists of one large tile (0,0) with the width and * height of the image. This tile is always considered to be checked * out. - * + * * @author Rolf W. Rasmussen (rolfwr@ii.uib.no) */ public class BufferedImage extends Image @@ -81,12 +81,12 @@ public class BufferedImage extends Image TYPE_USHORT_GRAY = 11, TYPE_BYTE_BINARY = 12, TYPE_BYTE_INDEXED = 13; - + /** * Vector of TileObservers (or null) */ Vector<TileObserver> tileObservers; - + /** * The image's WritableRaster */ @@ -115,7 +115,7 @@ public class BufferedImage extends Image /** * Creates a new <code>BufferedImage</code> with the specified width, height * and type. Valid <code>type</code> values are: - * + * * <ul> * <li>{@link #TYPE_INT_RGB}</li> * <li>{@link #TYPE_INT_ARGB}</li> @@ -131,11 +131,11 @@ public class BufferedImage extends Image * <li>{@link #TYPE_BYTE_BINARY}</li> * <li>{@link #TYPE_BYTE_INDEXED}</li> * </ul> - * + * * @param width the width (must be > 0). * @param height the height (must be > 0). * @param type the image type (see the list of valid types above). - * + * * @throws IllegalArgumentException if <code>width</code> or * <code>height</code> is less than or equal to zero. * @throws IllegalArgumentException if <code>type</code> is not one of the @@ -151,18 +151,18 @@ public class BufferedImage extends Image switch( type ) { case BufferedImage.TYPE_INT_RGB: - sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_INT, + sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_INT, width, height, - new int[]{ 0x00FF0000, - 0x0000FF00, + new int[]{ 0x00FF0000, + 0x0000FF00, 0x000000FF } ) ; cm = new DirectColorModel( 24, 0xff0000, 0xff00, 0xff ); break; - + case BufferedImage.TYPE_3BYTE_BGR: sm = new PixelInterleavedSampleModel( DataBuffer.TYPE_BYTE, width, height, - 3, width * 3, + 3, width * 3, new int[]{ 2, 1, 0 } ); cm = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), false, false, @@ -172,11 +172,11 @@ public class BufferedImage extends Image case BufferedImage.TYPE_INT_ARGB: case BufferedImage.TYPE_INT_ARGB_PRE: - sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_INT, + sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_INT, width, height, - new int[]{ 0x00FF0000, - 0x0000FF00, - 0x000000FF, + new int[]{ 0x00FF0000, + 0x0000FF00, + 0x000000FF, 0xFF000000 } ); if (premultiplied) cm = new DirectColorModel( ColorSpace.getInstance(ColorSpace.CS_sRGB), @@ -185,12 +185,12 @@ public class BufferedImage extends Image Buffers.smallestAppropriateTransferType(32)); else cm = new DirectColorModel( 32, 0xff0000, 0xff00, 0xff, 0xff000000 ); - + break; case BufferedImage.TYPE_4BYTE_ABGR: case BufferedImage.TYPE_4BYTE_ABGR_PRE: - sm = new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE, + sm = new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE, width, height, 4, 4*width, new int[]{3, 2, 1, 0}); @@ -201,10 +201,10 @@ public class BufferedImage extends Image break; case BufferedImage.TYPE_INT_BGR: - sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_INT, + sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_INT, width, height, - new int[]{ 0x000000FF, - 0x0000FF00, + new int[]{ 0x000000FF, + 0x0000FF00, 0x00FF0000 } ) ; cm = new DirectColorModel( 24, 0xff, 0xff00, 0xff0000 ); break; @@ -212,17 +212,17 @@ public class BufferedImage extends Image case BufferedImage.TYPE_USHORT_565_RGB: sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_USHORT, width, height, - new int[]{ 0xF800, - 0x7E0, + new int[]{ 0xF800, + 0x7E0, 0x1F } ) ; cm = new DirectColorModel( 16, 0xF800, 0x7E0, 0x1F ); break; - + case BufferedImage.TYPE_USHORT_555_RGB: sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_USHORT, width, height, - new int[]{ 0x7C00, - 0x3E0, + new int[]{ 0x7C00, + 0x3E0, 0x1F } ) ; cm = new DirectColorModel( 15, 0x7C00, 0x3E0, 0x1F ); break; @@ -244,7 +244,7 @@ public class BufferedImage extends Image case BufferedImage.TYPE_BYTE_BINARY: cm = createDefaultIndexedColorModel( true ); - sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE, + sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE, width, height, 1); break; @@ -254,8 +254,8 @@ public class BufferedImage extends Image if( sm == null ) throw new IllegalArgumentException("Unknown predefined image type."); - - if( cm == null ) // only for the grayscale types + + if( cm == null ) // only for the grayscale types { int buftype; int[] bits = new int[1]; @@ -270,22 +270,22 @@ public class BufferedImage extends Image bits[0] = 16; } ColorSpace graySpace = ColorSpace.getInstance( ColorSpace.CS_GRAY ); - - cm = new ComponentColorModel( graySpace, bits, false, false, + + cm = new ComponentColorModel( graySpace, bits, false, false, Transparency.OPAQUE, buftype ); } WritableRaster rst = null; - + // Attempt to create an accelerated backend for this image GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); if (env instanceof ClasspathGraphicsEnvironment) rst = ((ClasspathGraphicsEnvironment)env).createRaster(cm, sm); - + // Default to a standard Java raster & databuffer if needed if (rst == null) rst = Raster.createWritableRaster(sm, new Point( 0, 0 ) ); - + init(cm, rst, premultiplied, null, // no properties type ); @@ -308,13 +308,13 @@ public class BufferedImage extends Image } public BufferedImage(ColorModel colormodel, WritableRaster writableraster, - boolean premultiplied, Hashtable<?,?> properties) + boolean premultiplied, Hashtable<?,?> properties) { init(colormodel, writableraster, premultiplied, properties, TYPE_CUSTOM); } - - private void init(ColorModel cm, WritableRaster writableraster, + + private void init(ColorModel cm, WritableRaster writableraster, boolean premultiplied, Hashtable properties, int type) { raster = writableraster; @@ -330,7 +330,7 @@ public class BufferedImage extends Image * * @param binary - If <code>true</code>, a black and white palette, * otherwise a default 256-color palette is returned. - */ + */ private IndexColorModel createDefaultIndexedColorModel( boolean binary ) { if( binary ) @@ -342,7 +342,7 @@ public class BufferedImage extends Image byte[] r = new byte[256]; byte[] g = new byte[256]; byte[] b = new byte[256]; - + int index = 0; for( int i = 0; i < 6; i++ ) for( int j = 0; j < 6; j++ ) @@ -353,17 +353,17 @@ public class BufferedImage extends Image b[ index ] = (byte)(k * 51); index++; } - + while( index < 256 ) { - r[ index ] = g[ index ] = b[ index ] = + r[ index ] = g[ index ] = b[ index ] = (byte)(18 + (index - 216) * 6); index++; } - + return new IndexColorModel( 8, 256, r, g, b ); } - + public void coerceData(boolean premultiplied) { colorModel = colorModel.coerceData(raster, premultiplied); @@ -380,17 +380,17 @@ public class BufferedImage extends Image int y = dest.getMinY(); int w = dest.getWidth(); int h = dest.getHeight(); - + // create a src child that has the right bounds... WritableRaster src = raster.createWritableChild(x, y, w, h, x, y, null); // same bands - + if (src.getSampleModel () instanceof ComponentSampleModel && dest.getSampleModel () instanceof ComponentSampleModel) // Refer to ComponentDataBlitOp for optimized data blitting: ComponentDataBlitOp.INSTANCE.filter(src, dest); - + else { // slower path @@ -410,17 +410,17 @@ public class BufferedImage extends Image public void flush() { } - + public WritableRaster getAlphaRaster() { return colorModel.getAlphaRaster(raster); } - + public ColorModel getColorModel() { return colorModel; } - + public Raster getData() { return copyData(null); @@ -434,7 +434,7 @@ public class BufferedImage extends Image raster.createCompatibleWritableRaster(rectangle); return copyData(dest); } - + public Graphics getGraphics() { return createGraphics(); @@ -444,17 +444,17 @@ public class BufferedImage extends Image { return raster.getHeight(); } - + public int getHeight(ImageObserver imageobserver) { return getHeight(); } - + public int getMinTileX() { return 0; } - + public int getMinTileY() { return 0; @@ -462,14 +462,14 @@ public class BufferedImage extends Image public int getMinX() { - return 0; + return 0; } - public int getMinY() + public int getMinY() { return 0; } - + public int getNumXTiles() { return 1; @@ -477,17 +477,17 @@ public class BufferedImage extends Image public int getNumYTiles() { - return 1; + return 1; } /** - * Returns the value of the specified property, or + * Returns the value of the specified property, or * {@link Image#UndefinedProperty} if the property is not defined. - * + * * @param string the property key (<code>null</code> not permitted). - * + * * @return The property value. - * + * * @throws NullPointerException if <code>string</code> is <code>null</code>. */ public Object getProperty(String string) @@ -511,7 +511,7 @@ public class BufferedImage extends Image /** * Returns <code>null</code> always. - * + * * @return <code>null</code> always. */ public String[] getPropertyNames() @@ -526,29 +526,29 @@ public class BufferedImage extends Image Object rgbElem = raster.getDataElements(x, y, null); return colorModel.getRGB(rgbElem); } - + public int[] getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scanlineStride) { if (rgbArray == null) { /* - 000000000000000000 - 00000[#######----- [ = start - -----########----- ] = end - -----#######]00000 - 000000000000000000 + 000000000000000000 + 00000[#######----- [ = start + -----########----- ] = end + -----#######]00000 + 000000000000000000 */ int size = (h-1)*scanlineStride + w; rgbArray = new int[size]; } - + int endX = startX + w; int endY = startY + h; - + /* *TODO*: Opportunity for optimization by examining color models... - + Perhaps wrap the rgbArray up in a WritableRaster with packed sRGB color model and perform optimized rendering into the array. */ @@ -573,12 +573,12 @@ public class BufferedImage extends Image { return raster; } - + public SampleModel getSampleModel() { return raster.getSampleModel(); } - + public ImageProducer getSource() { return new ImageProducer() @@ -609,8 +609,8 @@ public class BufferedImage extends Image int height = getHeight(); int stride = width; int offset = 0; - int[] pixels = getRGB(x, y, - width, height, + int[] pixels = getRGB(x, y, + width, height, (int[])null, offset, stride); // We already convert the color to RGB in the getRGB call, so // we pass a simple RGB color model to the consumers. @@ -636,17 +636,17 @@ public class BufferedImage extends Image }; } - + public Vector<RenderedImage> getSources() { return null; } - + public BufferedImage getSubimage(int x, int y, int w, int h) { - WritableRaster subRaster = + WritableRaster subRaster = getRaster().createWritableChild(x, y, w, h, 0, 0, null); - + return new BufferedImage(getColorModel(), subRaster, isPremultiplied, properties); } @@ -655,7 +655,7 @@ public class BufferedImage extends Image { return getWritableTile(tileX, tileY); } - + public int getTileGridXOffset() { return 0; // according to javadocs @@ -698,7 +698,7 @@ public class BufferedImage extends Image } private static final Point[] tileIndices = { new Point() }; - + public Point[] getWritableTileIndices() { return tileIndices; @@ -708,7 +708,7 @@ public class BufferedImage extends Image { return true; } - + public boolean isAlphaPremultiplied() { return isPremultiplied; @@ -734,7 +734,7 @@ public class BufferedImage extends Image int y = src.getMinY(); int w = src.getWidth(); int h = src.getHeight(); - + // create a dest child that has the right bounds... WritableRaster dest = raster.createWritableChild(x, y, w, h, x, y, null); @@ -757,13 +757,13 @@ public class BufferedImage extends Image Object rgbElem = colorModel.getDataElements(argb, null); raster.setDataElements(x, y, rgbElem); } - + public void setRGB(int startX, int startY, int w, int h, - int[] argbArray, int offset, int scanlineStride) + int[] argbArray, int offset, int scanlineStride) { int endX = startX + w; int endY = startY + h; - + Object rgbElem = null; for (int y=startY; y<endY; y++) { @@ -774,10 +774,10 @@ public class BufferedImage extends Image rgbElem = colorModel.getDataElements(argb, rgbElem); raster.setDataElements(x, y, rgbElem); } - offset += scanlineStride; + offset += scanlineStride; } } - + public String toString() { CPStringBuilder buf; @@ -806,10 +806,10 @@ public class BufferedImage extends Image { if (tileObservers == null) tileObservers = new Vector<TileObserver>(); - + tileObservers.add (to); } - + /** * Removes a tile observer. If the observer was not registered, * nothing happens. If the observer was registered for multiple @@ -821,7 +821,7 @@ public class BufferedImage extends Image { if (tileObservers == null) return; - + tileObservers.remove (to); } diff --git a/java/awt/image/BufferedImageFilter.java b/java/awt/image/BufferedImageFilter.java index 50d627d66..04b6672c6 100644 --- a/java/awt/image/BufferedImageFilter.java +++ b/java/awt/image/BufferedImageFilter.java @@ -40,10 +40,10 @@ import java.awt.Point; /** * The BufferedImageFilter class wraps BufferedImageOp objects in a Filter. - * + * * When pixels are pushed through the filter, we create a BufferedImage, * apply the BufferedImageOp, and pass the filtered pixels to the base class. - * + * * @author jlquinn@optonline.net */ public class BufferedImageFilter extends ImageFilter implements Cloneable @@ -51,17 +51,17 @@ public class BufferedImageFilter extends ImageFilter implements Cloneable private BufferedImageOp op; /** - * + * */ public BufferedImageFilter(BufferedImageOp op) { super(); if (op == null) throw new NullPointerException("BufferedImageFilter null" - + " op in constructor"); + + " op in constructor"); this.op = op; } - + /** * @return Returns the contained BufferedImageOp. */ @@ -74,7 +74,7 @@ public class BufferedImageFilter extends ImageFilter implements Cloneable // create a compatible sample model that incorporates scansize != w. I // asume off is handled by the db itself. public void setPixels(int x, int y, int w, int h, ColorModel model, - byte[] pixels, int off, int scansize) + byte[] pixels, int off, int scansize) { // Create an input BufferedImage DataBufferByte db = new DataBufferByte(pixels, scansize * h + off, off); @@ -84,16 +84,16 @@ public class BufferedImageFilter extends ImageFilter implements Cloneable new BufferedImage(model, wr, model.isAlphaPremultiplied(), null); BufferedImage out = op.createCompatibleDestImage(in, model); op.filter(in, out); - DataBuffer dbout = out.getRaster().getDataBuffer(); + DataBuffer dbout = out.getRaster().getDataBuffer(); super.setPixels(0, 0, w, h, model, ((DataBufferByte)dbout).getData(), 0, - scansize); + scansize); } // FIXME: Definitely not sure this is the right thing. I'm not sure how // to create a compatible sample model that incorporates // scansize != w. I asume off is handled by the db itself. public void setPixels(int x, int y, int w, int h, ColorModel model, - int[] pixels, int off, int scansize) + int[] pixels, int off, int scansize) { // Create an input BufferedImage DataBufferInt db = new DataBufferInt(pixels, scansize * h + off, off); @@ -103,8 +103,8 @@ public class BufferedImageFilter extends ImageFilter implements Cloneable new BufferedImage(model, wr, model.isAlphaPremultiplied(), null); BufferedImage out = op.createCompatibleDestImage(in, model); op.filter(in, out); - DataBuffer dbout = out.getRaster().getDataBuffer(); + DataBuffer dbout = out.getRaster().getDataBuffer(); super.setPixels(0, 0, w, h, model, ((DataBufferInt)dbout).getData(), 0, - scansize); + scansize); } } diff --git a/java/awt/image/BufferedImageOp.java b/java/awt/image/BufferedImageOp.java index f6a24c976..1aba4bb09 100644 --- a/java/awt/image/BufferedImageOp.java +++ b/java/awt/image/BufferedImageOp.java @@ -1,4 +1,4 @@ -/* BufferedImageOp.java -- +/* BufferedImageOp.java -- Copyright (C) 2002, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -43,65 +43,65 @@ import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; /** - * An operation that is performed on one <code>BufferedImage</code> (the + * An operation that is performed on one <code>BufferedImage</code> (the * source) producing a new <code>BufferedImage</code> (the destination). */ public interface BufferedImageOp { /** * Performs an operation on the source image, returning the result in a - * <code>BufferedImage</code>. If <code>dest</code> is <code>null</code>, a + * <code>BufferedImage</code>. If <code>dest</code> is <code>null</code>, a * new <code>BufferedImage</code> will be created by calling the * {@link #createCompatibleDestImage} method. If <code>dest</code> - * is not <code>null</code>, the result is written to <code>dest</code> then - * returned (this avoids creating a new <code>BufferedImage</code> each + * is not <code>null</code>, the result is written to <code>dest</code> then + * returned (this avoids creating a new <code>BufferedImage</code> each * time this method is called). - * + * * @param src the source image. * @param dst the destination image (<code>null</code> permitted). - * + * * @return The filterd image. */ BufferedImage filter(BufferedImage src, BufferedImage dst); - + /** * Returns the bounds of the destination image on the basis of this * <code>BufferedImageOp</code> being applied to the specified source image. - * + * * @param src the source image. - * + * * @return The destination bounds. */ Rectangle2D getBounds2D(BufferedImage src); - + /** - * Returns a new <code>BufferedImage</code> that can be used by this - * <code>BufferedImageOp</code> as the destination image when filtering + * Returns a new <code>BufferedImage</code> that can be used by this + * <code>BufferedImageOp</code> as the destination image when filtering * the specified source image. - * + * * @param src the source image. * @param dstCM the color model for the destination image. - * + * * @return A new image that can be used as the destination image. */ BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel dstCM); - + /** * Returns the point on the destination image that corresponds to the given * point on the source image. - * + * * @param src the source point. * @param dst the destination point (<code>null</code> permitted). - * + * * @return The destination point. */ Point2D getPoint2D(Point2D src, Point2D dst); - + /** * Returns the rendering hints for this operation. - * + * * @return The rendering hints. */ RenderingHints getRenderingHints(); - -} + +} diff --git a/java/awt/image/ByteLookupTable.java b/java/awt/image/ByteLookupTable.java index ecc0023af..89804c55b 100644 --- a/java/awt/image/ByteLookupTable.java +++ b/java/awt/image/ByteLookupTable.java @@ -58,7 +58,7 @@ public class ByteLookupTable extends LookupTable * Offset is subtracted from pixel values when looking up in the translation * tables. If data.length is one, the same table is applied to all pixel * components. - * + * * @param offset Offset to be subtracted. * @param data Array of lookup tables (<code>null</code> not permitted). * @exception IllegalArgumentException if offset < 0 or data.length < 1. @@ -67,9 +67,9 @@ public class ByteLookupTable extends LookupTable throws IllegalArgumentException { super(offset, data.length); - + // tests show that Sun's implementation creates a new array to store the - // references from the incoming 'data' array - not sure why, but we'll + // references from the incoming 'data' array - not sure why, but we'll // match that behaviour just in case it matters... this.data = new byte[data.length][]; for (int i = 0; i < data.length; i++) @@ -81,9 +81,9 @@ public class ByteLookupTable extends LookupTable * * Offset is subtracted from pixel values when looking up in the translation * table. The same table is applied to all pixel components. - * + * * @param offset Offset to be subtracted. - * @param data Lookup table for all components (<code>null</code> not + * @param data Lookup table for all components (<code>null</code> not * permitted). * @exception IllegalArgumentException if offset < 0. */ @@ -131,11 +131,11 @@ public class ByteLookupTable extends LookupTable if (data.length == 1) for (int i=0; i < src.length; i++) - dst[i] = data[0][src[i] - offset]; + dst[i] = data[0][src[i] - offset]; else for (int i=0; i < src.length; i++) - dst[i] = data[i][src[i] - offset]; - + dst[i] = data[i][src[i] - offset]; + return dst; } @@ -164,11 +164,11 @@ public class ByteLookupTable extends LookupTable if (data.length == 1) for (int i=0; i < src.length; i++) - dst[i] = data[0][((int)src[i]) - offset]; + dst[i] = data[0][((int)src[i]) - offset]; else for (int i=0; i < src.length; i++) - dst[i] = data[i][((int)src[i]) - offset]; - + dst[i] = data[i][((int)src[i]) - offset]; + return dst; } diff --git a/java/awt/image/ColorConvertOp.java b/java/awt/image/ColorConvertOp.java index e6c85412d..b1d6f857d 100644 --- a/java/awt/image/ColorConvertOp.java +++ b/java/awt/image/ColorConvertOp.java @@ -51,17 +51,17 @@ import java.awt.geom.Rectangle2D; /** * ColorConvertOp is a filter for converting images or rasters between - * colorspaces, either through a sequence of colorspaces or just from source to + * colorspaces, either through a sequence of colorspaces or just from source to * destination. - * + * * Color conversion is done on the color components without alpha. Thus * if a BufferedImage has alpha premultiplied, this is divided out before * color conversion, and premultiplication applied if the destination * requires it. - * + * * Color rendering and dithering hints may be applied if specified. This is * likely platform-dependent. - * + * * @author jlquinn@optonline.net */ public class ColorConvertOp implements BufferedImageOp, RasterOp @@ -69,16 +69,16 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp private RenderingHints hints; private ICC_Profile[] profiles = null; private ColorSpace[] spaces; - + /** * Convert a BufferedImage through a ColorSpace. - * + * * Objects created with this constructor can be used to convert * BufferedImage's to a destination ColorSpace. Attempts to convert Rasters * with this constructor will result in an IllegalArgumentException when the - * filter(Raster, WritableRaster) method is called. - * + * filter(Raster, WritableRaster) method is called. + * * @param cspace The target color space. * @param hints Rendering hints to use in conversion, if any (may be null) * @throws NullPointerException if the ColorSpace is null. @@ -90,53 +90,53 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp spaces = new ColorSpace[]{cspace}; this.hints = hints; } - + /** * Convert from a source colorspace to a destination colorspace. - * + * * This constructor takes two ColorSpace arguments as the source and * destination color spaces. It is usually used with the - * filter(Raster, WritableRaster) method, in which case the source colorspace - * is assumed to correspond to the source Raster, and the destination + * filter(Raster, WritableRaster) method, in which case the source colorspace + * is assumed to correspond to the source Raster, and the destination * colorspace with the destination Raster. - * - * If used with BufferedImages that do not match the source or destination - * colorspaces specified here, there is an implicit conversion from the - * source image to the source ColorSpace, or the destination ColorSpace to + * + * If used with BufferedImages that do not match the source or destination + * colorspaces specified here, there is an implicit conversion from the + * source image to the source ColorSpace, or the destination ColorSpace to * the destination image. - * + * * @param srcCspace The source ColorSpace. * @param dstCspace The destination ColorSpace. * @param hints Rendering hints to use in conversion, if any (may be null). * @throws NullPointerException if any ColorSpace is null. */ public ColorConvertOp(ColorSpace srcCspace, ColorSpace dstCspace, - RenderingHints hints) + RenderingHints hints) { if (srcCspace == null || dstCspace == null) throw new NullPointerException(); spaces = new ColorSpace[]{srcCspace, dstCspace}; - this.hints = hints; + this.hints = hints; } /** * Convert from a source colorspace to a destinatino colorspace. - * + * * This constructor builds a ColorConvertOp from an array of ICC_Profiles. * The source will be converted through the sequence of color spaces * defined by the profiles. If the sequence of profiles doesn't give a * well-defined conversion, an IllegalArgumentException is thrown. - * - * If used with BufferedImages that do not match the source or destination - * colorspaces specified here, there is an implicit conversion from the - * source image to the source ColorSpace, or the destination ColorSpace to + * + * If used with BufferedImages that do not match the source or destination + * colorspaces specified here, there is an implicit conversion from the + * source image to the source ColorSpace, or the destination ColorSpace to * the destination image. - * + * * For Rasters, the first and last profiles must have the same number of * bands as the source and destination Rasters, respectively. If this is * not the case, or there fewer than 2 profiles, an IllegalArgumentException - * will be thrown. - * + * will be thrown. + * * @param profiles An array of ICC_Profile's to convert through. * @param hints Rendering hints to use in conversion, if any (may be null). * @throws NullPointerException if the profile array is null. @@ -147,10 +147,10 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp { if (profiles == null) throw new NullPointerException(); - - this.hints = hints; + + this.hints = hints; this.profiles = profiles; - + // Create colorspace array with space for src and dest colorspace // Note that the ICC_ColorSpace constructor will throw an // IllegalArgumentException if the profile is invalid; thus we check @@ -159,17 +159,17 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp for (int i = 0; i < profiles.length; i++) spaces[i] = new ICC_ColorSpace(profiles[i]); } - + /** * Convert from source color space to destination color space. - * + * * Only valid for BufferedImage objects, this Op converts from the source * image's color space to the destination image's color space. - * - * The destination in the filter(BufferedImage, BufferedImage) method cannot + * + * The destination in the filter(BufferedImage, BufferedImage) method cannot * be null for this operation, and it also cannot be used with the * filter(Raster, WritableRaster) method. - * + * * @param hints Rendering hints to use in conversion, if any (may be null). */ public ColorConvertOp(RenderingHints hints) @@ -177,12 +177,12 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp this.hints = hints; spaces = new ColorSpace[0]; } - + /** * Converts the source image using the conversion path specified in the * constructor. The resulting image is stored in the destination image if one - * is provided; otherwise a new BufferedImage is created and returned. - * + * is provided; otherwise a new BufferedImage is created and returned. + * * The source and destination BufferedImage (if one is supplied) must have * the same dimensions. * @@ -196,7 +196,7 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp { // TODO: The plan is to create a scanline buffer for intermediate buffers. // For now we just suck it up and create intermediate buffers. - + if (dst == null && spaces.length == 0) throw new IllegalArgumentException("Not enough color space information " + "to complete conversion."); @@ -245,12 +245,12 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp * Converts the source raster using the conversion path specified in the * constructor. The resulting raster is stored in the destination raster if * one is provided; otherwise a new WritableRaster is created and returned. - * + * * This operation is not valid with every constructor of this class; see * the constructors for details. Further, the source raster must have the * same number of bands as the source ColorSpace, and the destination raster * must have the same number of bands as the destination ColorSpace. - * + * * The source and destination raster (if one is supplied) must also have the * same dimensions. * @@ -303,7 +303,7 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp /** * Creates an empty BufferedImage with the size equal to the source and the - * correct number of bands for the conversion defined in this Op. The newly + * correct number of bands for the conversion defined in this Op. The newly * created image is created with the specified ColorModel, or if no ColorModel * is supplied, an appropriate one is chosen. * @@ -332,11 +332,11 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp dstCM.getTransferType()), src.isPremultiplied, null); } - + /** * Creates a new WritableRaster with the size equal to the source and the * correct number of bands. - * + * * Note, the new Raster will always use a BYTE storage size, regardless of * the color model or defined destination; this is for compatibility with * the reference implementation. @@ -361,7 +361,7 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp /** * Returns the array of ICC_Profiles used to create this Op, or null if the * Op was created using ColorSpace arguments. - * + * * @return The array of ICC_Profiles, or null. */ public final ICC_Profile[] getICC_Profiles() @@ -371,7 +371,7 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp /** * Returns the rendering hints for this op. - * + * * @return The rendering hints for this Op, or null. */ public final RenderingHints getRenderingHints() @@ -383,7 +383,7 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp * Returns the corresponding destination point for a source point. * Because this is not a geometric operation, the destination and source * points will be identical. - * + * * @param src The source point. * @param dst The transformed destination point. * @return The transformed destination point. @@ -392,7 +392,7 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp { if (dst == null) return (Point2D)src.clone(); - + dst.setLocation(src); return dst; } @@ -401,7 +401,7 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp * Returns the corresponding destination boundary of a source boundary. * Because this is not a geometric operation, the destination and source * boundaries will be identical. - * + * * @param src The source boundary. * @return The boundaries of the destination. */ @@ -414,7 +414,7 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp * Returns the corresponding destination boundary of a source boundary. * Because this is not a geometric operation, the destination and source * boundaries will be identical. - * + * * @param src The source boundary. * @return The boundaries of the destination. */ @@ -424,9 +424,9 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp } /** - * Copy a source image to a destination image, respecting their colorspaces - * and performing colorspace conversions if necessary. - * + * Copy a source image to a destination image, respecting their colorspaces + * and performing colorspace conversions if necessary. + * * @param src The source image. * @param dst The destination image. */ @@ -434,21 +434,21 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp { // This is done using Graphics2D in order to respect the rendering hints. Graphics2D gg = dst.createGraphics(); - + // If no hints are set there is no need to call // setRenderingHints on the Graphics2D object. if (hints != null) gg.setRenderingHints(hints); - + gg.drawImage(src, 0, 0, null); gg.dispose(); } - + /** * Copy a source raster to a destination raster, performing a colorspace * conversion between the two. The conversion will respect the * KEY_COLOR_RENDERING rendering hint if one is present. - * + * * @param src The source raster. * @param scs The colorspace of the source raster. * @dst The destination raster. @@ -457,7 +457,7 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp private void copyraster(Raster src, ColorSpace scs, WritableRaster dst, ColorSpace dcs) { float[] sbuf = new float[src.getNumBands()]; - + if (hints != null && hints.get(RenderingHints.KEY_COLOR_RENDERING) == RenderingHints.VALUE_COLOR_RENDER_QUALITY) @@ -466,7 +466,7 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++) for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++) dst.setPixel(x, y, - dcs.fromCIEXYZ(scs.toCIEXYZ(src.getPixel(x, y, sbuf)))); + dcs.fromCIEXYZ(scs.toCIEXYZ(src.getPixel(x, y, sbuf)))); } else { @@ -474,7 +474,7 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++) for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++) dst.setPixel(x, y, - dcs.fromRGB(scs.toRGB(src.getPixel(x, y, sbuf)))); + dcs.fromRGB(scs.toRGB(src.getPixel(x, y, sbuf)))); } } @@ -482,31 +482,31 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp * This method creates a color model with the same colorspace and alpha * settings as the source image. The created color model will always be a * ComponentColorModel and have a BYTE transfer type. - * + * * @param img The source image. * @param cs The ColorSpace to use. * @return A color model compatible with the source image. - */ + */ private ColorModel createCompatibleColorModel(BufferedImage img, ColorSpace cs) { // The choice of ComponentColorModel and DataBuffer.TYPE_BYTE is based on // Mauve testing of the reference implementation. return new ComponentColorModel(cs, - img.getColorModel().hasAlpha(), + img.getColorModel().hasAlpha(), img.isAlphaPremultiplied(), img.getColorModel().getTransparency(), - DataBuffer.TYPE_BYTE); + DataBuffer.TYPE_BYTE); } /** * This method creates a compatible Raster, given a source raster, colorspace, * alpha value, and transfer type. - * + * * @param src The source raster. * @param cs The ColorSpace to use. * @param hasAlpha Whether the raster should include a component for an alpha. * @param transferType The size of a single data element. - * @return A compatible WritableRaster. + * @return A compatible WritableRaster. */ private WritableRaster createCompatibleDestRaster(Raster src, ColorSpace cs, boolean hasAlpha, @@ -514,11 +514,11 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp { // The use of a PixelInterleavedSampleModel weas determined using mauve // tests, based on the reference implementation - + int numComponents = cs.getNumComponents(); if (hasAlpha) numComponents++; - + int[] offsets = new int[numComponents]; for (int i = 0; i < offsets.length; i++) offsets[i] = i; diff --git a/java/awt/image/ColorModel.java b/java/awt/image/ColorModel.java index 005b8d45f..ede9e31d8 100644 --- a/java/awt/image/ColorModel.java +++ b/java/awt/image/ColorModel.java @@ -64,7 +64,7 @@ import java.util.Arrays; * * <li>sRGB pixel int value: a pixel in sRGB color space, encoded in * default 0xAARRGGBB format, assumed not alpha premultiplied.</li> - * + * * <li>single [0, 255] scaled int samples from default sRGB color * space. These are always assumed to be alpha non-premultiplied.</li> * @@ -109,10 +109,10 @@ public abstract class ColorModel implements Transparency byte[] array = new byte[times]; java.util.Arrays.fill(array, value); return array; - } + } /** - * Constructs the default color model. The default color model + * Constructs the default color model. The default color model * can be obtained by calling <code>getRGBdefault</code> of this * class. * @param bits the number of bits wide used for bit size of pixel values @@ -120,12 +120,12 @@ public abstract class ColorModel implements Transparency public ColorModel(int bits) { this(bits * 4, // total bits, sRGB, four channels - nArray(bits, 4), // bits for each channel - ColorSpace.getInstance(ColorSpace.CS_sRGB), // sRGB - true, // has alpha - false, // not premultiplied - TRANSLUCENT, - Buffers.smallestAppropriateTransferType(bits * 4)); + nArray(bits, 4), // bits for each channel + ColorSpace.getInstance(ColorSpace.CS_sRGB), // sRGB + true, // has alpha + false, // not premultiplied + TRANSLUCENT, + Buffers.smallestAppropriateTransferType(bits * 4)); } /** @@ -138,8 +138,8 @@ public abstract class ColorModel implements Transparency * bits is less than 1 or if any of the elements in bits is less than 0. */ protected ColorModel(int pixel_bits, int[] bits, ColorSpace cspace, - boolean hasAlpha, boolean isAlphaPremultiplied, - int transparency, int transferType) + boolean hasAlpha, boolean isAlphaPremultiplied, + int transparency, int transferType) { int bits_sum = 0; for (int i = 0; i < bits.length; i++) @@ -149,7 +149,7 @@ public abstract class ColorModel implements Transparency bits_sum |= bits [i]; } - + if ((bits.length < cspace.getNumComponents()) || (bits_sum < 1)) throw new IllegalArgumentException (); @@ -162,7 +162,7 @@ public abstract class ColorModel implements Transparency this.transparency = transparency; this.transferType = transferType; } - + public void finalize() { // Do nothing here. @@ -194,12 +194,12 @@ public abstract class ColorModel implements Transparency { return pixel_bits; } - + public int getComponentSize(int componentIdx) { return bits[componentIdx]; } - + public int[] getComponentSize() { return bits; @@ -240,7 +240,7 @@ public abstract class ColorModel implements Transparency * @see #getRed(int) */ public abstract int getGreen(int pixel); - + /** * Converts pixel value to sRGB and extract blue int sample * scaled to range [0, 255]. @@ -265,7 +265,7 @@ public abstract class ColorModel implements Transparency * * This method is typically overriden in subclasses to provide a * more efficient implementation. - * + * * @param pixel pixel value that will be interpreted according to * the color model. * @@ -273,13 +273,13 @@ public abstract class ColorModel implements Transparency * 0xAARRGGBB format. */ public int getRGB(int pixel) { - return + return ((getAlpha(pixel) & 0xff) << 24) | (( getRed(pixel) & 0xff) << 16) | ((getGreen(pixel) & 0xff) << 8) | (( getBlue(pixel) & 0xff) << 0); } - + /** * In this color model we know that the whole pixel value will @@ -294,13 +294,13 @@ public abstract class ColorModel implements Transparency return data.getElem(0); } - /** + /** * Converts pixel in the given array to sRGB and extract blue int * sample scaled to range [0-255]. * * This method is typically overriden in subclasses to provide a * more efficient implementation. - * + * * @param inData array of transferType containing a single pixel. The * pixel should be encoded in the natural way of the color model. */ @@ -350,7 +350,7 @@ public abstract class ColorModel implements Transparency */ public int getRGB(Object inData) { - return + return ((getAlpha(inData) & 0xff) << 24) | (( getRed(inData) & 0xff) << 16) | ((getGreen(inData) & 0xff) << 8) | @@ -360,7 +360,7 @@ public abstract class ColorModel implements Transparency /** * Converts an sRGB pixel int value to an array containing a * single pixel of the color space of the color model. - * + * * <p>This method performs the inverse function of * <code>getRGB(Object inData)</code>. * @@ -379,7 +379,7 @@ public abstract class ColorModel implements Transparency * <li>Scale the components to the correct number of bits.</li> * * <li>Arrange the components in the output array</li> - * + * * </ol> * * @param rgb The color to be converted to dataElements. A pixel @@ -392,7 +392,7 @@ public abstract class ColorModel implements Transparency * * @return An array of transferType values representing the color, * in the color model format. The color model defines whether the - * + * * @see #getRGB(Object) */ public Object getDataElements(int rgb, Object pixel) @@ -404,11 +404,11 @@ public abstract class ColorModel implements Transparency /** * Fills an array with the unnormalized component samples from a * pixel value. I.e. decompose the pixel, but not perform any - * color conversion. + * color conversion. * * This method is typically overriden in subclasses to provide a * more efficient implementation. - * + * * @param pixel pixel value encoded according to the color model. * * @return arrays of unnormalized component samples of single @@ -421,7 +421,7 @@ public abstract class ColorModel implements Transparency // subclasses has to implement this method. throw new UnsupportedOperationException(); } - + /** * Fills an array with the unnormalized component samples from an * array of transferType containing a single pixel. I.e. decompose @@ -438,7 +438,7 @@ public abstract class ColorModel implements Transparency * of the pixel. If this is null, a new array will be allocated * @param offset index into the components array at which the result * will be stored - * + * * @return arrays of unnormalized component samples of single * pixel. The scale and multiplication state of the samples are * according to the color model. Each component sample is stored @@ -454,16 +454,16 @@ public abstract class ColorModel implements Transparency * Convert normalized components to unnormalized components. */ public int[] getUnnormalizedComponents(float[] normComponents, - int normOffset, - int[] components, - int offset) + int normOffset, + int[] components, + int offset) { int numComponents = getNumComponents(); if (components == null) { components = new int[offset + numComponents]; } - + for (int i=0; i<numComponents; i++) { float in = normComponents[normOffset++]; @@ -477,9 +477,9 @@ public abstract class ColorModel implements Transparency * Convert unnormalized components to normalized components. */ public float[] getNormalizedComponents(int[] components, - int offset, - float[] normComponents, - int normOffset) + int offset, + float[] normComponents, + int normOffset) { int numComponents = getNumComponents(); if (normComponents == null) @@ -513,10 +513,10 @@ public abstract class ColorModel implements Transparency * Converts the unnormalized component samples from an array to a * pixel value. I.e. composes the pixel from component samples, but * does not perform any color conversion or scaling of the samples. - * + * * This method performs the inverse function of * <code>getComponents(int pixel, int[] components, - * int offset)</code>. I.e. + * int offset)</code>. I.e. * * <code>(pixel == cm.getDataElement(cm.getComponents(pixel, null, * 0), 0))</code>. @@ -542,7 +542,7 @@ public abstract class ColorModel implements Transparency * Converts the normalized component samples from an array to a pixel * value. I.e. composes the pixel from component samples, but does not * perform any color conversion or scaling of the samples. - * + * * This method is typically overriden in subclasses to provide a * more efficient implementation. The method provided by this abstract * class converts the components to unnormalized form and returns @@ -561,9 +561,9 @@ public abstract class ColorModel implements Transparency { return getDataElement(getUnnormalizedComponents(components, offset, null, 0), - 0); + 0); } - + public Object getDataElements(int[] components, int offset, Object obj) { // subclasses have to implement this method. @@ -579,7 +579,7 @@ public abstract class ColorModel implements Transparency * Otherwise the results are stored in obj and obj is returned. If obj is * not long enough, ArrayIndexOutOfBounds is thrown. If obj is not an array * of primitives, ClassCastException is thrown. - * + * * This method is typically overriden in subclasses to provide a * more efficient implementation. The method provided by this abstract * class converts the components to unnormalized form and returns @@ -601,7 +601,7 @@ public abstract class ColorModel implements Transparency { return getDataElements(getUnnormalizedComponents(components, offset, null, 0), - 0, obj); + 0, obj); } public boolean equals(Object obj) @@ -609,7 +609,7 @@ public abstract class ColorModel implements Transparency if (!(obj instanceof ColorModel)) return false; ColorModel o = (ColorModel) obj; - return + return (pixel_bits == o.pixel_bits) && (transferType == o.transferType) && (transparency == o.transparency) && @@ -632,7 +632,7 @@ public abstract class ColorModel implements Transparency } void coerceDataWorker(WritableRaster raster, - boolean isAlphaPremultiplied) + boolean isAlphaPremultiplied) { int w = raster.getWidth(); int h = raster.getHeight(); @@ -659,12 +659,12 @@ public abstract class ColorModel implements Transparency raster.setPixels(0, 0, w, h, pixels); } - + /** * Checks if the given raster has a compatible data-layout (SampleModel). * @param raster The Raster to test. * @return true if raster is compatible. - */ + */ public boolean isCompatibleRaster(Raster raster) { SampleModel sampleModel = raster.getSampleModel(); @@ -675,7 +675,7 @@ public abstract class ColorModel implements Transparency public WritableRaster createCompatibleWritableRaster(int w, int h) { return new WritableRaster(createCompatibleSampleModel(w, h), - new Point(0, 0)); + new Point(0, 0)); } // Typically overridden @@ -705,19 +705,19 @@ public abstract class ColorModel implements Transparency public WritableRaster getAlphaRaster(WritableRaster raster) { return null; - + /* It is a mystery to me why we couldn't use the following code... - - + + if (!hasAlpha()) return null; - + SampleModel sm = raster.getSampleModel(); int[] alphaBand = { sm.getNumBands() - 1 }; SampleModel alphaModel = sm.createSubsetSampleModel(alphaBand); DataBuffer buffer = raster.getDataBuffer(); Point origin = new Point(0, 0); return Raster.createWritableRaster(alphaModel, buffer, origin); - + ...here, and avoided overriding the method in subclasses, but the Sun docs state that this method always will return @@ -746,7 +746,7 @@ public abstract class ColorModel implements Transparency private static class SRGBColorModel extends DirectColorModel { - + SRGBColorModel() { super(32,0x00FF0000,0x0000FF00,0x000000FF,0xFF000000); @@ -781,13 +781,13 @@ public abstract class ColorModel implements Transparency { if(pixel == null) { - pixel = new int[]{rgb}; + pixel = new int[]{rgb}; } else { - ((int[]) pixel)[0] = rgb; + ((int[]) pixel)[0] = rgb; } - + return pixel; } } diff --git a/java/awt/image/ComponentColorModel.java b/java/awt/image/ComponentColorModel.java index e1e85e191..ef0b84f00 100644 --- a/java/awt/image/ComponentColorModel.java +++ b/java/awt/image/ComponentColorModel.java @@ -54,7 +54,7 @@ public class ComponentColorModel extends ColorModel sum += values[i]; return sum; } - + // Create an appropriate array of bits, given a colorspace (ie, number of // bands), size of the storage data type, and presence of an alpha band. private static int[] findBits(ColorSpace colorSpace, int transferType, @@ -67,28 +67,28 @@ public class ComponentColorModel extends ColorModel bits = new int[colorSpace.getNumComponents()]; Arrays.fill(bits, DataBuffer.getDataTypeSize(transferType)); - + return bits; } public ComponentColorModel(ColorSpace colorSpace, int[] bits, - boolean hasAlpha, - boolean isAlphaPremultiplied, - int transparency, int transferType) + boolean hasAlpha, + boolean isAlphaPremultiplied, + int transparency, int transferType) { super(sum(bits), bits, colorSpace, hasAlpha, isAlphaPremultiplied, - transparency, transferType); + transparency, transferType); } /** * Construct a new ComponentColorModel. - * + * * This constructor makes all bits of each sample significant, so for a * transferType of DataBuffer.BYTE, the bits per sample is 8, etc. If * both hasAlpha and isAlphaPremultiplied are true, color samples are * assumed to be premultiplied by the alpha component. Transparency may be - * one of OPAQUE, BITMASK, or TRANSLUCENT. - * + * one of OPAQUE, BITMASK, or TRANSLUCENT. + * * @param colorSpace The colorspace for this color model. * @param hasAlpha True if there is an alpha component. * @param isAlphaPremultiplied True if colors are already multiplied by @@ -98,10 +98,10 @@ public class ComponentColorModel extends ColorModel * @since 1.4 */ public ComponentColorModel(ColorSpace colorSpace, - boolean hasAlpha, - boolean isAlphaPremultiplied, - int transparency, int transferType) - { + boolean hasAlpha, + boolean isAlphaPremultiplied, + int transparency, int transferType) + { this(colorSpace, findBits(colorSpace, transferType, hasAlpha), hasAlpha, isAlphaPremultiplied, transparency, transferType); } @@ -117,7 +117,7 @@ public class ComponentColorModel extends ColorModel if (getNumComponents()>1) throw new IllegalArgumentException(); return (int) getRGBFloat(pixel)[0]; } - + public int getBlue(int pixel) { if (getNumComponents()>1) throw new IllegalArgumentException(); @@ -131,7 +131,7 @@ public class ComponentColorModel extends ColorModel if (shift >= 0) return pixel << shift; return pixel >> (-shift); } - + public int getRGB(int pixel) { float[] rgb = getRGBFloat(pixel); @@ -143,7 +143,7 @@ public class ComponentColorModel extends ColorModel /* Note, it's OK to pass a to large array to toRGB(). Extra elements are ignored. */ - + private float[] getRGBFloat(int pixel) { float[] data = { pixel }; @@ -154,20 +154,20 @@ public class ComponentColorModel extends ColorModel { DataBuffer buffer = Buffers.createBufferFromData(transferType, inData, - getNumComponents()); + getNumComponents()); int colors = getNumColorComponents(); float[] data = new float[colors]; - + // FIXME: unpremultiply data that is premultiplied for (int i=0; i<colors; i++) { - float maxValue = (1<<getComponentSize(i))-1; - data[i] = buffer.getElemFloat(i)/maxValue; + float maxValue = (1<<getComponentSize(i))-1; + data[i] = buffer.getElemFloat(i)/maxValue; } float[] rgb = cspace.toRGB(data); return rgb; } - + public int getRed(Object inData) { return (int) getRGBFloat(inData)[0]*255; @@ -187,7 +187,7 @@ public class ComponentColorModel extends ColorModel { DataBuffer buffer = Buffers.createBufferFromData(transferType, inData, - getNumComponents()); + getNumComponents()); int shift = 8 - getComponentSize(getNumColorComponents()); int alpha = buffer.getElem(getNumColorComponents()); if (shift >= 0) return alpha << shift; @@ -200,7 +200,7 @@ public class ComponentColorModel extends ColorModel avoid bits spilling over from one bit field to another. But, if we assume that floats are in the [0.0, 1.0] range, this will never happen anyway. */ - + /* Remember to multiply BEFORE casting to int, otherwise, decimal point data will be lost. */ int ret = @@ -234,30 +234,30 @@ public class ComponentColorModel extends ColorModel // Convert from rgb to color space components. float[] data = cspace.fromRGB(rgbFloats); DataBuffer buffer = Buffers.createBuffer(transferType, pixel, - getNumComponents()); + getNumComponents()); int numColors = getNumColorComponents(); - + if (hasAlpha()) { - float alpha = ((rgb >> 24)&0xff)/255.0F; - - /* If color model has alpha and should be premultiplied, multiply - color space components with alpha value. */ - if (isAlphaPremultiplied()) { - for (int i=0; i<numColors; i++) - data[i] *= alpha; - } - // Scale the alpha sample to the correct number of bits. - alpha *= (1<<(bits[numColors]-1)); - // Arrange the alpha sample in the output array. - buffer.setElemFloat(numColors, alpha); + float alpha = ((rgb >> 24)&0xff)/255.0F; + + /* If color model has alpha and should be premultiplied, multiply + color space components with alpha value. */ + if (isAlphaPremultiplied()) { + for (int i=0; i<numColors; i++) + data[i] *= alpha; + } + // Scale the alpha sample to the correct number of bits. + alpha *= (1<<(bits[numColors]-1)); + // Arrange the alpha sample in the output array. + buffer.setElemFloat(numColors, alpha); } for (int i=0; i<numColors; i++) { - // Scale the color samples to the correct number of bits. - float value = data[i]*(1<<(bits[i]-1)); - // Arrange the color samples in the output array. - buffer.setElemFloat(i, value); + // Scale the color samples to the correct number of bits. + float value = data[i]*(1<<(bits[i]-1)); + // Arrange the color samples in the output array. + buffer.setElemFloat(i, value); } return Buffers.getData(buffer); } @@ -274,7 +274,7 @@ public class ComponentColorModel extends ColorModel public int[] getComponents(Object pixel, int[] components, int offset) { DataBuffer buffer = Buffers.createBuffer(transferType, pixel, - getNumComponents()); + getNumComponents()); int numComponents = getNumComponents(); if (components == null) @@ -295,7 +295,7 @@ public class ComponentColorModel extends ColorModel public Object getDataElements(int[] components, int offset, Object obj) { DataBuffer buffer = Buffers.createBuffer(transferType, obj, - getNumComponents()); + getNumComponents()); int numComponents = getNumComponents(); for (int i=0; i<numComponents; i++) @@ -305,7 +305,7 @@ public class ComponentColorModel extends ColorModel } public ColorModel coerceData(WritableRaster raster, - boolean isAlphaPremultiplied) { + boolean isAlphaPremultiplied) { if (this.isAlphaPremultiplied == isAlphaPremultiplied || !hasAlpha()) return this; @@ -313,7 +313,7 @@ public class ComponentColorModel extends ColorModel assumptions we can make due to the specific type of the color model. */ coerceDataWorker(raster, isAlphaPremultiplied); - + return new ComponentColorModel(cspace, hasAlpha, isAlphaPremultiplied, transparency, transferType); } @@ -383,7 +383,7 @@ public class ComponentColorModel extends ColorModel public boolean isCompatibleSampleModel(SampleModel sm) { - return + return (sm instanceof ComponentSampleModel) && super.isCompatibleSampleModel(sm); } @@ -391,7 +391,7 @@ public class ComponentColorModel extends ColorModel public WritableRaster getAlphaRaster(WritableRaster raster) { if (!hasAlpha()) return null; - + SampleModel sm = raster.getSampleModel(); int[] alphaBand = { sm.getNumBands() - 1 }; SampleModel alphaModel = sm.createSubsetSampleModel(alphaBand); @@ -399,7 +399,7 @@ public class ComponentColorModel extends ColorModel Point origin = new Point(0, 0); return Raster.createWritableRaster(alphaModel, buffer, origin); } - + public boolean equals(Object obj) { if (!(obj instanceof ComponentColorModel)) return false; diff --git a/java/awt/image/ComponentSampleModel.java b/java/awt/image/ComponentSampleModel.java index 73e7fb4d3..f32eae319 100644 --- a/java/awt/image/ComponentSampleModel.java +++ b/java/awt/image/ComponentSampleModel.java @@ -60,65 +60,65 @@ public class ComponentSampleModel extends SampleModel { /** The offsets to the first sample for each band. */ protected int[] bandOffsets; - + /** The indices of the bank used to store each band in a data buffer. */ protected int[] bankIndices; - - /** + + /** * The number of bands in the image. * @specnote This field shadows the protected numBands in SampleModel. */ protected int numBands; - + /** Used when creating data buffers. */ protected int numBanks; - /** - * The number of data elements between a sample in one row and the + /** + * The number of data elements between a sample in one row and the * corresponding sample in the next row. */ protected int scanlineStride; - + /** - * The number of data elements between a sample for one pixel and the + * The number of data elements between a sample for one pixel and the * corresponding sample for the next pixel in the same row. */ protected int pixelStride; /** - * Creates a new sample model that assumes that all bands are stored in a + * Creates a new sample model that assumes that all bands are stored in a * single bank of the {@link DataBuffer}. * <p> * Note that the <code>bandOffsets</code> array is copied to internal storage * to prevent subsequent changes to the array from affecting this object. - * + * * @param dataType the data type (one of {@link DataBuffer#TYPE_BYTE}, * {@link DataBuffer#TYPE_USHORT}, {@link DataBuffer#TYPE_SHORT}, - * {@link DataBuffer#TYPE_INT}, {@link DataBuffer#TYPE_FLOAT} or + * {@link DataBuffer#TYPE_INT}, {@link DataBuffer#TYPE_FLOAT} or * {@link DataBuffer#TYPE_DOUBLE}). * @param w the width in pixels. * @param h the height in pixels. * @param pixelStride the number of data elements in the step from a sample * in one pixel to the corresponding sample in the next pixel. - * @param scanlineStride the number of data elements in the step from a + * @param scanlineStride the number of data elements in the step from a * sample in a pixel to the corresponding sample in the pixel in the next * row. - * @param bandOffsets the offset to the first element for each band, with + * @param bandOffsets the offset to the first element for each band, with * the size of the array defining the number of bands (<code>null</code> * not permitted). - * + * * @throws IllegalArgumentException if <code>dataType</code> is not one of * the specified values. * @throws IllegalArgumentException if <code>w</code> is less than or equal * to zero. - * @throws IllegalArgumentException if <code>h</code> is less than or equal + * @throws IllegalArgumentException if <code>h</code> is less than or equal * to zero. * @throws IllegalArgumentException if <code>w * h</code> exceeds * {@link Integer#MAX_VALUE}. * @throws IllegalArgumentException if <code>pixelStride</code> is negative. - * @throws IllegalArgumentException if <code>scanlineStride</code> is less + * @throws IllegalArgumentException if <code>scanlineStride</code> is less * than or equal to zero. - * @throws IllegalArgumentException if <code>bandOffsets</code> has zero + * @throws IllegalArgumentException if <code>bandOffsets</code> has zero * length. */ public ComponentSampleModel(int dataType, @@ -130,43 +130,43 @@ public class ComponentSampleModel extends SampleModel this(dataType, w, h, pixelStride, scanlineStride, new int[bandOffsets.length], bandOffsets); } - + /** - * Creates a new sample model that assumes that all bands are stored in a + * Creates a new sample model that assumes that all bands are stored in a * single bank of the {@link DataBuffer}. - * + * * @param dataType the data type (one of {@link DataBuffer#TYPE_BYTE}, * {@link DataBuffer#TYPE_USHORT}, {@link DataBuffer#TYPE_SHORT}, - * {@link DataBuffer#TYPE_INT}, {@link DataBuffer#TYPE_FLOAT} or + * {@link DataBuffer#TYPE_INT}, {@link DataBuffer#TYPE_FLOAT} or * {@link DataBuffer#TYPE_DOUBLE}). * @param w the width in pixels. * @param h the height in pixels. * @param pixelStride the number of data elements in the step from a sample * in one pixel to the corresponding sample in the next pixel. - * @param scanlineStride the number of data elements in the step from a + * @param scanlineStride the number of data elements in the step from a * sample in a pixel to the corresponding sample in the pixel in the next * row. - * @param bankIndices the index of the bank in which each band is stored + * @param bankIndices the index of the bank in which each band is stored * (<code>null</code> not permitted). This array is copied to internal - * storage so that subsequent updates to the array do not affect the sample + * storage so that subsequent updates to the array do not affect the sample * model. - * @param bandOffsets the offset to the first element for each band, with + * @param bandOffsets the offset to the first element for each band, with * the size of the array defining the number of bands (<code>null</code> - * not permitted). This array is copied to internal storage so that + * not permitted). This array is copied to internal storage so that * subsequent updates to the array do not affect the sample model. - * + * * @throws IllegalArgumentException if <code>dataType</code> is not one of * the specified values. * @throws IllegalArgumentException if <code>w</code> is less than or equal * to zero. - * @throws IllegalArgumentException if <code>h</code> is less than or equal + * @throws IllegalArgumentException if <code>h</code> is less than or equal * to zero. * @throws IllegalArgumentException if <code>w * h</code> exceeds * {@link Integer#MAX_VALUE}. * @throws IllegalArgumentException if <code>pixelStride</code> is negative. - * @throws IllegalArgumentException if <code>scanlineStride</code> is less + * @throws IllegalArgumentException if <code>scanlineStride</code> is less * than or equal to zero. - * @throws IllegalArgumentException if <code>bandOffsets</code> has zero + * @throws IllegalArgumentException if <code>bandOffsets</code> has zero * length. */ public ComponentSampleModel(int dataType, @@ -177,15 +177,15 @@ public class ComponentSampleModel extends SampleModel int[] bandOffsets) { super(dataType, w, h, bandOffsets.length); - + // super permits DataBuffer.TYPE_UNDEFINED but this class doesn't... if (dataType == DataBuffer.TYPE_UNDEFINED) throw new IllegalArgumentException("Unsupported dataType."); - - if ((pixelStride < 0) || (scanlineStride < 0) || (bandOffsets.length < 1) + + if ((pixelStride < 0) || (scanlineStride < 0) || (bandOffsets.length < 1) || (bandOffsets.length != bankIndices.length)) throw new IllegalArgumentException(); - + this.bandOffsets = (int[]) bandOffsets.clone(); this.bankIndices = (int[]) bankIndices.clone(); this.numBands = bandOffsets.length; @@ -197,15 +197,15 @@ public class ComponentSampleModel extends SampleModel this.scanlineStride = scanlineStride; this.pixelStride = pixelStride; - } + } /** * Creates a new sample model that is compatible with this one, but with the * specified dimensions. - * + * * @param w the width (must be greater than zero). * @param h the height (must be greater than zero). - * + * * @return A new sample model. */ public SampleModel createCompatibleSampleModel(int w, int h) @@ -218,15 +218,15 @@ public class ComponentSampleModel extends SampleModel /** * Creates a new sample model that provides access to a subset of the bands * that this sample model supports. - * + * * @param bands the bands (<code>null</code> not permitted). - * + * * @return The new sample model. */ public SampleModel createSubsetSampleModel(int[] bands) { int numBands = bands.length; - + int[] bankIndices = new int[numBands]; int[] bandOffsets = new int[numBands]; for (int b = 0; b < numBands; b++) @@ -242,7 +242,7 @@ public class ComponentSampleModel extends SampleModel /** * Creates a new data buffer that is compatible with this sample model. - * + * * @return The new data buffer. */ public DataBuffer createDataBuffer() @@ -250,8 +250,8 @@ public class ComponentSampleModel extends SampleModel // Maybe this value should be precalculated in the constructor? int highestOffset = 0; for (int b = 0; b < numBands; b++) - highestOffset = Math.max(highestOffset, bandOffsets[b]); - int size = pixelStride * (width - 1) + scanlineStride * (height - 1) + highestOffset = Math.max(highestOffset, bandOffsets[b]); + int size = pixelStride * (width - 1) + scanlineStride * (height - 1) + highestOffset + 1; DataBuffer buffer = null; @@ -283,12 +283,12 @@ public class ComponentSampleModel extends SampleModel * Returns the offset of the sample in band 0 for the pixel at location * <code>(x, y)</code>. This offset can be used to read a sample value from * a {@link DataBuffer}. - * + * * @param x the x-coordinate. * @param y the y-coordinate. - * + * * @return The offset. - * + * * @see #getOffset(int, int, int) */ public int getOffset(int x, int y) @@ -300,11 +300,11 @@ public class ComponentSampleModel extends SampleModel * Returns the offset of the sample in band <code>b</code> for the pixel at * location <code>(x, y)</code>. This offset can be used to read a sample * value from a {@link DataBuffer}. - * + * * @param x the x-coordinate. * @param y the y-coordinate. * @param b the band index. - * + * * @return The offset. */ public int getOffset(int x, int y, int b) @@ -316,9 +316,9 @@ public class ComponentSampleModel extends SampleModel * Returns the size in bits for each sample (one per band). For this sample * model, each band has the same sample size and this is determined by the * data type for the sample model. - * + * * @return The sample sizes. - * + * * @see SampleModel#getDataType() */ public final int[] getSampleSize() @@ -332,13 +332,13 @@ public class ComponentSampleModel extends SampleModel /** * Returns the size in bits for the samples in the specified band. In this - * class, the sample size is the same for every band and is determined from + * class, the sample size is the same for every band and is determined from * the data type for the model. - * + * * @param band the band index (ignored here). - * + * * @return The sample size in bits. - * + * * @see SampleModel#getDataType() */ public final int getSampleSize(int band) @@ -347,10 +347,10 @@ public class ComponentSampleModel extends SampleModel } /** - * Returns the indices of the bank(s) in the {@link DataBuffer} used to + * Returns the indices of the bank(s) in the {@link DataBuffer} used to * store the samples for each band. The returned array is a copy, so that * altering it will not impact the sample model. - * + * * @return The bank indices. */ public final int[] getBankIndices() @@ -361,7 +361,7 @@ public class ComponentSampleModel extends SampleModel /** * Returns the offsets to the first sample in each band. The returned array * is a copy, so that altering it will not impact the sample model. - * + * * @return The offsets. */ public final int[] getBandOffsets() @@ -371,10 +371,10 @@ public class ComponentSampleModel extends SampleModel /** * Returns the distance (in terms of element indices) between the sample for - * one pixel and the corresponding sample for the equivalent pixel in the + * one pixel and the corresponding sample for the equivalent pixel in the * next row. This is used in the calculation of the element offset for * retrieving samples from a {@link DataBuffer}. - * + * * @return The distance between pixel samples in consecutive rows. */ public final int getScanlineStride() @@ -383,11 +383,11 @@ public class ComponentSampleModel extends SampleModel } /** - * Returns the distance (in terms of element indices) between the sample for - * one pixel and the corresponding sample for the next pixel in a row. This - * is used in the calculation of the element offset for retrieving samples + * Returns the distance (in terms of element indices) between the sample for + * one pixel and the corresponding sample for the next pixel in a row. This + * is used in the calculation of the element offset for retrieving samples * from a {@link DataBuffer}. - * + * * @return The distance between pixel samples in the same row. */ public final int getPixelStride() @@ -396,10 +396,10 @@ public class ComponentSampleModel extends SampleModel } /** - * Returns the number of data elements used to store the samples for one + * Returns the number of data elements used to store the samples for one * pixel. In this model, this is the same as the number of bands. - * - * @return The number of data elements used to store the samples for one + * + * @return The number of data elements used to store the samples for one * pixel. */ public final int getNumDataElements() @@ -409,17 +409,17 @@ public class ComponentSampleModel extends SampleModel /** * Returns the samples for the pixel at location <code>(x, y)</code> in - * a primitive array (the array type is determined by the data type for + * a primitive array (the array type is determined by the data type for * this model). The <code>obj</code> argument provides an option to supply * an existing array to hold the result, if this is <code>null</code> a new * array will be allocated. - * + * * @param x the x-coordinate. * @param y the y-coordinate. - * @param obj a primitive array that, if not <code>null</code>, will be + * @param obj a primitive array that, if not <code>null</code>, will be * used to store and return the sample values. * @param data the data buffer (<code>null</code> not permitted). - * + * * @return An array of sample values for the specified pixel. */ public Object getDataElements(int x, int y, Object obj, DataBuffer data) @@ -502,23 +502,23 @@ public class ComponentSampleModel extends SampleModel /** * Returns all the samples for the pixel at location <code>(x, y)</code> * stored in the specified data buffer. - * + * * @param x the x-coordinate. * @param y the y-coordinate. * @param iArray an array that will be populated with the sample values and - * returned as the result. The size of this array should be equal to the + * returned as the result. The size of this array should be equal to the * number of bands in the model. If the array is <code>null</code>, a new * array is created. * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The samples for the specified pixel. - * + * * @see #setPixel(int, int, int[], DataBuffer) */ public int[] getPixel(int x, int y, int[] iArray, DataBuffer data) { if (x < 0 || x >= width || y < 0 || y >= height) - throw new ArrayIndexOutOfBoundsException("Pixel (" + x + ", " + y + throw new ArrayIndexOutOfBoundsException("Pixel (" + x + ", " + y + ") is out of bounds."); int offset = pixelStride * x + scanlineStride * y; if (iArray == null) @@ -532,22 +532,22 @@ public class ComponentSampleModel extends SampleModel /** * Returns the samples for all the pixels in a rectangular region. - * + * * @param x the x-coordinate. * @param y the y-coordinate. * @param w the width. * @param h the height. - * @param iArray an array that if non-<code>null</code> will be populated + * @param iArray an array that if non-<code>null</code> will be populated * with the sample values and returned as the result. * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The samples for all the pixels in the rectangle. */ public int[] getPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data) { int offset = pixelStride * x + scanlineStride * y; - if (iArray == null) + if (iArray == null) iArray = new int[numBands * w * h]; int outOffset = 0; for (y = 0; y < h; y++) @@ -557,7 +557,7 @@ public class ComponentSampleModel extends SampleModel { for (int b = 0; b < numBands; b++) { - iArray[outOffset++] + iArray[outOffset++] = data.getElem(bankIndices[b], lineOffset+bandOffsets[b]); } lineOffset += pixelStride; @@ -566,41 +566,41 @@ public class ComponentSampleModel extends SampleModel } return iArray; } - + /** - * Returns the sample for band <code>b</code> of the pixel at + * Returns the sample for band <code>b</code> of the pixel at * <code>(x, y)</code> that is stored in the specified data buffer. - * + * * @param x the x-coordinate. * @param y the y-coordinate. * @param b the band index. * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The sample value. - * - * @throws ArrayIndexOutOfBoundsException if <code>(x, y)</code> is outside + * + * @throws ArrayIndexOutOfBoundsException if <code>(x, y)</code> is outside * the bounds <code>[0, 0, width, height]</code>. - * + * * @see #setSample(int, int, int, int, DataBuffer) */ public int getSample(int x, int y, int b, DataBuffer data) { if (x < 0 || x >= width || y < 0 || y >= height) - throw new ArrayIndexOutOfBoundsException("Sample (" + x + ", " + y + throw new ArrayIndexOutOfBoundsException("Sample (" + x + ", " + y + ") is out of bounds."); return data.getElem(bankIndices[b], getOffset(x, y, b)); } /** - * Sets the samples for the pixel at location <code>(x, y)</code> from the - * supplied primitive array (the array type must be consistent with the data + * Sets the samples for the pixel at location <code>(x, y)</code> from the + * supplied primitive array (the array type must be consistent with the data * type for this model). - * + * * @param x the x-coordinate. * @param y the y-coordinate. * @param obj a primitive array containing the pixel's sample values. * @param data the data buffer (<code>null</code> not permitted). - * + * * @see #setDataElements(int, int, Object, DataBuffer) */ public void setDataElements(int x, int y, Object obj, DataBuffer data) @@ -652,16 +652,16 @@ public class ComponentSampleModel extends SampleModel break; } } - + /** * Sets the sample values for the pixel at location <code>(x, y)</code> * stored in the specified data buffer. - * + * * @param x the x-coordinate. * @param y the y-coordinate. * @param iArray the pixel sample values (<code>null</code> not permitted). * @param data the data buffer (<code>null</code> not permitted). - * + * * @see #getPixel(int, int, int[], DataBuffer) */ public void setPixel(int x, int y, int[] iArray, DataBuffer data) @@ -670,24 +670,24 @@ public class ComponentSampleModel extends SampleModel for (int b = 0; b < numBands; b++) data.setElem(bankIndices[b], offset + bandOffsets[b], iArray[b]); } - + /** * Sets the sample value for band <code>b</code> of the pixel at location * <code>(x, y)</code> in the specified data buffer. - * + * * @param x the x-coordinate. * @param y the y-coordinate. * @param b the band index. * @param s the sample value. * @param data the data buffer (<code>null</code> not permitted). - * + * * @see #getSample(int, int, int, DataBuffer) */ public void setSample(int x, int y, int b, int s, DataBuffer data) { data.setElem(bankIndices[b], getOffset(x, y, b), s); } - + /** * Tests this sample model for equality with an arbitrary object. Returns * <code>true</code> if and only if: @@ -700,10 +700,10 @@ public class ComponentSampleModel extends SampleModel * <code>scanlineStride</code>, <code>bandOffsets</code> and * <code>bankIndices</code> fields.</li> * </ul> - * + * * @param obj the object to test (<code>null</code> permitted). - * - * @return <code>true</code> if this sample model is equal to + * + * @return <code>true</code> if this sample model is equal to * <code>obj</code>, and <code>false</code> otherwise. */ public boolean equals(Object obj) @@ -730,10 +730,10 @@ public class ComponentSampleModel extends SampleModel // couldn't find any difference, so... return true; } - + /** * Returns a hash code for this sample model. - * + * * @return The hash code. */ public int hashCode() diff --git a/java/awt/image/ConvolveOp.java b/java/awt/image/ConvolveOp.java index cf30e7625..10b85f446 100644 --- a/java/awt/image/ConvolveOp.java +++ b/java/awt/image/ConvolveOp.java @@ -44,58 +44,58 @@ import java.awt.geom.Rectangle2D; /** * Convolution filter. - * + * * ConvolveOp convolves the source image with a Kernel to generate a * destination image. This involves multiplying each pixel and its neighbors * with elements in the kernel to compute a new pixel. - * + * * Each band in a Raster is convolved and copied to the destination Raster. - * For BufferedImages, convolution is applied to all components. Color + * For BufferedImages, convolution is applied to all components. Color * conversion will be applied if needed. - * + * * Note that this filter ignores whether the source or destination is alpha * premultiplied. The reference spec states that data will be premultiplied * prior to convolving and divided back out afterwards (if needed), but testing * has shown that this is not the case with their implementation. - * + * * @author jlquinn@optonline.net */ public class ConvolveOp implements BufferedImageOp, RasterOp { /** Edge pixels are set to 0. */ public static final int EDGE_ZERO_FILL = 0; - + /** Edge pixels are copied from the source. */ public static final int EDGE_NO_OP = 1; - + private Kernel kernel; private int edge; private RenderingHints hints; /** * Construct a ConvolveOp. - * + * * The edge condition specifies that pixels outside the area that can be * filtered are either set to 0 or copied from the source image. - * + * * @param kernel The kernel to convolve with. * @param edgeCondition Either EDGE_ZERO_FILL or EDGE_NO_OP. * @param hints Rendering hints for color conversion, or null. */ public ConvolveOp(Kernel kernel, - int edgeCondition, - RenderingHints hints) + int edgeCondition, + RenderingHints hints) { this.kernel = kernel; edge = edgeCondition; this.hints = hints; } - + /** * Construct a ConvolveOp. - * + * * The edge condition defaults to EDGE_ZERO_FILL. - * + * * @param kernel The kernel to convolve with. */ public ConvolveOp(Kernel kernel) @@ -108,8 +108,8 @@ public class ConvolveOp implements BufferedImageOp, RasterOp /** * Converts the source image using the kernel specified in the * constructor. The resulting image is stored in the destination image if one - * is provided; otherwise a new BufferedImage is created and returned. - * + * is provided; otherwise a new BufferedImage is created and returned. + * * The source and destination BufferedImage (if one is supplied) must have * the same dimensions. * @@ -124,10 +124,10 @@ public class ConvolveOp implements BufferedImageOp, RasterOp if (src == dst) throw new IllegalArgumentException("Source and destination images " + "cannot be the same."); - + if (dst == null) dst = createCompatibleDestImage(src, src.getColorModel()); - + // Make sure source image is premultiplied BufferedImage src1 = src; // The spec says we should do this, but mauve testing shows that Sun's @@ -146,15 +146,15 @@ public class ConvolveOp implements BufferedImageOp, RasterOp dst1 = createCompatibleDestImage(src, src.getColorModel()); filter(src1.getRaster(), dst1.getRaster()); - + // Since we don't coerceData above, we don't need to divide it back out. // This is wrong (one mauve test specifically tests converting a non- // premultiplied image to a premultiplied image, and it shows that Sun // simply ignores the premultipled flag, contrary to the spec), but we // mimic it for compatibility. /* - if (! dst.isAlphaPremultiplied()) - dst1.coerceData(false); + if (! dst.isAlphaPremultiplied()) + dst1.coerceData(false); */ // Convert between color models if needed @@ -166,7 +166,7 @@ public class ConvolveOp implements BufferedImageOp, RasterOp /** * Creates an empty BufferedImage with the size equal to the source and the - * correct number of bands. The new image is created with the specified + * correct number of bands. The new image is created with the specified * ColorModel, or if no ColorModel is supplied, an appropriate one is chosen. * * @param src The source image. @@ -191,17 +191,17 @@ public class ConvolveOp implements BufferedImageOp, RasterOp { return hints; } - + /** * Get the edge condition for this Op. - * + * * @return The edge condition. */ public int getEdgeCondition() { return edge; } - + /** * Returns (a clone of) the convolution kernel. * @@ -213,13 +213,13 @@ public class ConvolveOp implements BufferedImageOp, RasterOp } /** - * Converts the source raster using the kernel specified in the constructor. - * The resulting raster is stored in the destination raster if one is + * Converts the source raster using the kernel specified in the constructor. + * The resulting raster is stored in the destination raster if one is * provided; otherwise a new WritableRaster is created and returned. - * + * * If the convolved value for a sample is outside the range of [0-255], it * will be clipped. - * + * * The source and destination raster (if one is supplied) cannot be the same, * and must also have the same dimensions. * @@ -233,7 +233,7 @@ public class ConvolveOp implements BufferedImageOp, RasterOp { if (src == dest) throw new IllegalArgumentException("src == dest is not allowed."); - if (kernel.getWidth() > src.getWidth() + if (kernel.getWidth() > src.getWidth() || kernel.getHeight() > src.getHeight()) throw new ImagingOpException("The kernel is too large."); if (dest == null) @@ -248,12 +248,12 @@ public class ConvolveOp implements BufferedImageOp, RasterOp int right = Math.max(kWidth - left - 1, 0); int top = kernel.getYOrigin(); int bottom = Math.max(kHeight - top - 1, 0); - + // Calculate max sample values for clipping int[] maxValue = src.getSampleModel().getSampleSize(); for (int i = 0; i < maxValue.length; i++) maxValue[i] = (int)Math.pow(2, maxValue[i]) - 1; - + // process the region that is reachable... int regionW = src.width - left - right; int regionH = src.height - top - bottom; @@ -271,8 +271,8 @@ public class ConvolveOp implements BufferedImageOp, RasterOp src.getSamples(x, y, kWidth, kHeight, b, tmp); for (int i = 0; i < tmp.length; i++) v += tmp[tmp.length - i - 1] * kvals[i]; - // FIXME: in the above line, I've had to reverse the order of - // the samples array to make the tests pass. I haven't worked + // FIXME: in the above line, I've had to reverse the order of + // the samples array to make the tests pass. I haven't worked // out why this is necessary. // This clipping is is undocumented, but determined by testing. @@ -281,34 +281,34 @@ public class ConvolveOp implements BufferedImageOp, RasterOp else if (v < 0) v = 0; - dest.setSample(x + kernel.getXOrigin(), y + kernel.getYOrigin(), + dest.setSample(x + kernel.getXOrigin(), y + kernel.getYOrigin(), b, v); } } } - + // fill in the top border fillEdge(src, dest, 0, 0, src.width, top, edge); - + // fill in the bottom border fillEdge(src, dest, 0, src.height - bottom, src.width, bottom, edge); - + // fill in the left border fillEdge(src, dest, 0, top, left, regionH, edge); - + // fill in the right border fillEdge(src, dest, src.width - right, top, right, regionH, edge); - - return dest; + + return dest; } - + /** * Fills a range of pixels (typically at the edge of a raster) with either - * zero values (if <code>edgeOp</code> is <code>EDGE_ZERO_FILL</code>) or the + * zero values (if <code>edgeOp</code> is <code>EDGE_ZERO_FILL</code>) or the * corresponding pixel values from the source raster (if <code>edgeOp</code> - * is <code>EDGE_NO_OP</code>). This utility method is called by the + * is <code>EDGE_NO_OP</code>). This utility method is called by the * {@link #fillEdge(Raster, WritableRaster, int, int, int, int, int)} method. - * + * * @param src the source raster. * @param dest the destination raster. * @param x the x-coordinate of the top left pixel in the range. @@ -318,8 +318,8 @@ public class ConvolveOp implements BufferedImageOp, RasterOp * @param edgeOp indicates how to determine the values for the range * (either {@link #EDGE_ZERO_FILL} or {@link #EDGE_NO_OP}). */ - private void fillEdge(Raster src, WritableRaster dest, int x, int y, int w, - int h, int edgeOp) + private void fillEdge(Raster src, WritableRaster dest, int x, int y, int w, + int h, int edgeOp) { if (w <= 0) return; @@ -328,7 +328,7 @@ public class ConvolveOp implements BufferedImageOp, RasterOp if (edgeOp == EDGE_ZERO_FILL) // fill region with zeroes { float[] zeros = new float[src.getNumBands() * w * h]; - dest.setPixels(x, y, w, h, zeros); + dest.setPixels(x, y, w, h, zeros); } else // copy pixels from source { @@ -366,7 +366,7 @@ public class ConvolveOp implements BufferedImageOp, RasterOp * Returns the corresponding destination point for a source point. Because * this is not a geometric operation, the destination and source points will * be identical. - * + * * @param src The source point. * @param dst The transformed destination point. * @return The transformed destination point. diff --git a/java/awt/image/CropImageFilter.java b/java/awt/image/CropImageFilter.java index 53b415620..4d8fb624f 100644 --- a/java/awt/image/CropImageFilter.java +++ b/java/awt/image/CropImageFilter.java @@ -44,7 +44,7 @@ import java.util.Hashtable; /** * Currently this filter does almost nothing and needs to be implemented. * - * @author C. Brian Jones (cbj@gnu.org) + * @author C. Brian Jones (cbj@gnu.org) */ public class CropImageFilter extends ImageFilter { @@ -62,10 +62,10 @@ public class CropImageFilter extends ImageFilter * @param height the height of the cropped rectangle */ public CropImageFilter(int x, int y, int width, int height) { - this.x = x; - this.y = y; - this.width = width; - this.height = height; + this.x = x; + this.y = y; + this.width = width; + this.height = height; } /** @@ -73,14 +73,14 @@ public class CropImageFilter extends ImageFilter * being produced using this method. This filter overrides this * method in order to set the dimentions to the size of the * cropped rectangle instead of the size of the image. - * + * * @param width the width of the image - * @param height the height of the image + * @param height the height of the image */ public void setDimensions(int width, int height) { if (consumer != null) - consumer.setDimensions(this.width, this.height); + consumer.setDimensions(this.width, this.height); } /** @@ -89,7 +89,7 @@ public class CropImageFilter extends ImageFilter * <br> * FIXME - What property is set for this class? * - * @param props the list of properties associated with this image + * @param props the list of properties associated with this image */ public void setProperties(Hashtable<?, ?> props) { @@ -102,7 +102,7 @@ public class CropImageFilter extends ImageFilter /** * This function delivers a rectangle of pixels where any * pixel(m,n) is stored in the array as a <code>byte</code> at - * index (n * scansize + m + offset). + * index (n * scansize + m + offset). * * @param x the x coordinate of the rectangle * @param y the y coordinate of the rectangle @@ -113,37 +113,37 @@ public class CropImageFilter extends ImageFilter * @param offset the index of the first pixels in the <code>pixels</code> array * @param scansize the width to use in extracting pixels from the <code>pixels</code> array */ - public void setPixels(int x, int y, int w, int h, - ColorModel model, byte[] pixels, int offset, int scansize) + public void setPixels(int x, int y, int w, int h, + ColorModel model, byte[] pixels, int offset, int scansize) { - Rectangle filterBounds = new Rectangle(this.x, this.y, - this.width, this.height); - Rectangle pixelBounds = new Rectangle(x, y, w, h); - - if (filterBounds.intersects(pixelBounds)) - { - Rectangle bounds = filterBounds.intersection(pixelBounds); - - byte[] cropped = new byte[bounds.width * bounds.height]; - for (int i = 0; i < bounds.height; i++) - { - int start = (bounds.y - pixelBounds.y + i) * scansize + offset; - - for (int j = 0; j < bounds.width; j++) - cropped[i * bounds.width + j] = pixels[start + bounds.x + j]; - } - - if (consumer != null) - consumer.setPixels(0, 0, - bounds.width, bounds.height, - model, cropped, 0, bounds.width); - } + Rectangle filterBounds = new Rectangle(this.x, this.y, + this.width, this.height); + Rectangle pixelBounds = new Rectangle(x, y, w, h); + + if (filterBounds.intersects(pixelBounds)) + { + Rectangle bounds = filterBounds.intersection(pixelBounds); + + byte[] cropped = new byte[bounds.width * bounds.height]; + for (int i = 0; i < bounds.height; i++) + { + int start = (bounds.y - pixelBounds.y + i) * scansize + offset; + + for (int j = 0; j < bounds.width; j++) + cropped[i * bounds.width + j] = pixels[start + bounds.x + j]; + } + + if (consumer != null) + consumer.setPixels(0, 0, + bounds.width, bounds.height, + model, cropped, 0, bounds.width); + } } /** * This function delivers a rectangle of pixels where any * pixel(m,n) is stored in the array as an <code>int</code> at - * index (n * scansize + m + offset). + * index (n * scansize + m + offset). * * @param x the x coordinate of the rectangle * @param y the y coordinate of the rectangle @@ -154,32 +154,31 @@ public class CropImageFilter extends ImageFilter * @param offset the index of the first pixels in the <code>pixels</code> array * @param scansize the width to use in extracting pixels from the <code>pixels</code> array */ - public void setPixels(int x, int y, int w, int h, + public void setPixels(int x, int y, int w, int h, ColorModel model, int[] pixels, int offset, int scansize) { - Rectangle filterBounds = new Rectangle(this.x, this.y, - this.width, this.height); - Rectangle pixelBounds = new Rectangle(x, y, w, h); - - if (filterBounds.intersects(pixelBounds)) - { - Rectangle bounds = filterBounds.intersection(pixelBounds); - - int[] cropped = new int[bounds.width * bounds.height]; - for (int i = 0; i < bounds.height; i++) - { - int start = (bounds.y - pixelBounds.y + i) * scansize + offset; - - for (int j = 0; j < bounds.width; j++) - cropped[i * bounds.width + j] = pixels[start + bounds.x + j]; - } - - if (consumer != null) - consumer.setPixels(0, 0, - bounds.width, bounds.height, - model, cropped, 0, bounds.width); - } + Rectangle filterBounds = new Rectangle(this.x, this.y, + this.width, this.height); + Rectangle pixelBounds = new Rectangle(x, y, w, h); + + if (filterBounds.intersects(pixelBounds)) + { + Rectangle bounds = filterBounds.intersection(pixelBounds); + + int[] cropped = new int[bounds.width * bounds.height]; + for (int i = 0; i < bounds.height; i++) + { + int start = (bounds.y - pixelBounds.y + i) * scansize + offset; + + for (int j = 0; j < bounds.width; j++) + cropped[i * bounds.width + j] = pixels[start + bounds.x + j]; + } + + if (consumer != null) + consumer.setPixels(0, 0, + bounds.width, bounds.height, + model, cropped, 0, bounds.width); + } } } - diff --git a/java/awt/image/DataBuffer.java b/java/awt/image/DataBuffer.java index 5a2cfd3b0..78bc75ba5 100644 --- a/java/awt/image/DataBuffer.java +++ b/java/awt/image/DataBuffer.java @@ -36,7 +36,7 @@ exception statement from your version. */ package java.awt.image; -/** +/** * Class that manages arrays of data elements. A data buffer consists * of one or more banks. A bank is a continuous region of data * elements. @@ -52,31 +52,31 @@ public abstract class DataBuffer public static final int TYPE_BYTE = 0; /** - * A constant representing a data type that uses <code>short</code> + * A constant representing a data type that uses <code>short</code> * primitives as the storage unit. */ public static final int TYPE_USHORT = 1; /** - * A constant representing a data type that uses <code>short</code> + * A constant representing a data type that uses <code>short</code> * primitives as the storage unit. */ public static final int TYPE_SHORT = 2; /** - * A constant representing a data type that uses <code>int</code> + * A constant representing a data type that uses <code>int</code> * primitives as the storage unit. */ public static final int TYPE_INT = 3; - + /** - * A constant representing a data type that uses <code>float</code> + * A constant representing a data type that uses <code>float</code> * primitives as the storage unit. */ public static final int TYPE_FLOAT = 4; /** - * A constant representing a data type that uses <code>double</code> + * A constant representing a data type that uses <code>double</code> * primitives as the storage unit. */ public static final int TYPE_DOUBLE = 5; @@ -85,30 +85,30 @@ public abstract class DataBuffer * A constant representing an undefined data type. */ public static final int TYPE_UNDEFINED = 32; - + /** The type of the data elements stored in the data buffer. */ protected int dataType; - + /** The number of banks in this buffer. */ protected int banks = 1; - + /** Offset into the default (0'th) bank). */ protected int offset; // FIXME: Is offsets[0] always mirrored in offset? - + /** The size of the banks. */ protected int size; - + /** Offset into each bank. */ protected int[] offsets; - + /** * Creates a new <code>DataBuffer</code> with the specified data type and - * size. The <code>dataType</code> should be one of the constants - * {@link #TYPE_BYTE}, {@link #TYPE_SHORT}, {@link #TYPE_USHORT}, + * size. The <code>dataType</code> should be one of the constants + * {@link #TYPE_BYTE}, {@link #TYPE_SHORT}, {@link #TYPE_USHORT}, * {@link #TYPE_INT}, {@link #TYPE_FLOAT} and {@link #TYPE_DOUBLE}. * <p> * The physical (array-based) storage is allocated by a subclass. - * + * * @param dataType the data type. * @param size the number of elements in the buffer. */ @@ -119,13 +119,13 @@ public abstract class DataBuffer /** * Creates a new <code>DataBuffer</code> with the specified data type, - * size and number of banks. The <code>dataType</code> should be one of - * the constants {@link #TYPE_BYTE}, {@link #TYPE_SHORT}, - * {@link #TYPE_USHORT}, {@link #TYPE_INT}, {@link #TYPE_FLOAT} and + * size and number of banks. The <code>dataType</code> should be one of + * the constants {@link #TYPE_BYTE}, {@link #TYPE_SHORT}, + * {@link #TYPE_USHORT}, {@link #TYPE_INT}, {@link #TYPE_FLOAT} and * {@link #TYPE_DOUBLE}. * <p> * The physical (array-based) storage is allocated by a subclass. - * + * * @param dataType the data type. * @param size the number of elements in the buffer. * @param numBanks the number of data banks. @@ -137,13 +137,13 @@ public abstract class DataBuffer /** * Creates a new <code>DataBuffer</code> with the specified data type, * size and number of banks. An offset (which applies to all banks) is - * also specified. The <code>dataType</code> should be one of - * the constants {@link #TYPE_BYTE}, {@link #TYPE_SHORT}, - * {@link #TYPE_USHORT}, {@link #TYPE_INT}, {@link #TYPE_FLOAT} and + * also specified. The <code>dataType</code> should be one of + * the constants {@link #TYPE_BYTE}, {@link #TYPE_SHORT}, + * {@link #TYPE_USHORT}, {@link #TYPE_INT}, {@link #TYPE_FLOAT} and * {@link #TYPE_DOUBLE}. * <p> * The physical (array-based) storage is allocated by a subclass. - * + * * @param dataType the data type. * @param size the number of elements in the buffer. * @param numBanks the number of data banks. @@ -163,42 +163,42 @@ public abstract class DataBuffer /** * Creates a new <code>DataBuffer</code> with the specified data type, * size and number of banks. An offset (which applies to all banks) is - * also specified. The <code>dataType</code> should be one of - * the constants {@link #TYPE_BYTE}, {@link #TYPE_SHORT}, - * {@link #TYPE_USHORT}, {@link #TYPE_INT}, {@link #TYPE_FLOAT} and + * also specified. The <code>dataType</code> should be one of + * the constants {@link #TYPE_BYTE}, {@link #TYPE_SHORT}, + * {@link #TYPE_USHORT}, {@link #TYPE_INT}, {@link #TYPE_FLOAT} and * {@link #TYPE_DOUBLE}. * <p> * The physical (array-based) storage is allocated by a subclass. - * + * * @param dataType the data type. * @param size the number of elements in the buffer. * @param numBanks the number of data banks. * @param offsets the offsets to the first element for all banks. - * - * @throws ArrayIndexOutOfBoundsException if + * + * @throws ArrayIndexOutOfBoundsException if * <code>numBanks != offsets.length</code>. */ protected DataBuffer(int dataType, int size, int numBanks, int[] offsets) { - if (numBanks != offsets.length) + if (numBanks != offsets.length) throw new ArrayIndexOutOfBoundsException(); this.dataType = dataType; this.size = size; banks = numBanks; this.offsets = offsets; - + offset = offsets[0]; } - + /** * Returns the size (number of bits) of the specified data type. Valid types - * are defined by the constants {@link #TYPE_BYTE}, {@link #TYPE_SHORT}, - * {@link #TYPE_USHORT}, {@link #TYPE_INT}, {@link #TYPE_FLOAT} and + * are defined by the constants {@link #TYPE_BYTE}, {@link #TYPE_SHORT}, + * {@link #TYPE_USHORT}, {@link #TYPE_INT}, {@link #TYPE_FLOAT} and * {@link #TYPE_DOUBLE}. - * + * * @param dataType the data type. * @return The number of bits for the specified data type. - * @throws IllegalArgumentException if <code>dataType < 0</code> or + * @throws IllegalArgumentException if <code>dataType < 0</code> or * <code>dataType > TYPE_DOUBLE</code>. */ public static int getDataTypeSize(int dataType) { @@ -206,57 +206,57 @@ public abstract class DataBuffer switch (dataType) { case TYPE_BYTE: - return 8; + return 8; case TYPE_USHORT: case TYPE_SHORT: - return 16; + return 16; case TYPE_INT: case TYPE_FLOAT: - return 32; + return 32; case TYPE_DOUBLE: - return 64; + return 64; default: - throw new IllegalArgumentException(); + throw new IllegalArgumentException(); } } /** * Returns the type of the data elements in the data buffer. Valid types - * are defined by the constants {@link #TYPE_BYTE}, {@link #TYPE_SHORT}, - * {@link #TYPE_USHORT}, {@link #TYPE_INT}, {@link #TYPE_FLOAT} and + * are defined by the constants {@link #TYPE_BYTE}, {@link #TYPE_SHORT}, + * {@link #TYPE_USHORT}, {@link #TYPE_INT}, {@link #TYPE_FLOAT} and * {@link #TYPE_DOUBLE}. - * + * * @return The type. */ public int getDataType() { return dataType; } - + /** * Returns the size of the data buffer. - * + * * @return The size. */ public int getSize() { return size; } - + /** * Returns the element offset for the first data bank. - * + * * @return The element offset. */ public int getOffset() { return offset; } - + /** - * Returns the offsets for all the data banks used by this + * Returns the offsets for all the data banks used by this * <code>DataBuffer</code>. - * + * * @return The offsets. */ public int[] getOffsets() @@ -281,9 +281,9 @@ public abstract class DataBuffer /** * Returns an element from the first data bank. The offset (specified in - * the constructor) is added to <code>i</code> before accessing the + * the constructor) is added to <code>i</code> before accessing the * underlying data array. - * + * * @param i the element index. * @return The element. */ @@ -294,20 +294,20 @@ public abstract class DataBuffer /** * Returns an element from a particular data bank. The offset (specified in - * the constructor) is added to <code>i</code> before accessing the + * the constructor) is added to <code>i</code> before accessing the * underlying data array. - * + * * @param bank the bank index. * @param i the element index. * @return The element. */ public abstract int getElem(int bank, int i); - + /** * Sets an element in the first data bank. The offset (specified in the * constructor) is added to <code>i</code> before updating the underlying * data array. - * + * * @param i the element index. * @param val the new element value. */ @@ -320,18 +320,18 @@ public abstract class DataBuffer * Sets an element in a particular data bank. The offset (specified in the * constructor) is added to <code>i</code> before updating the underlying * data array. - * + * * @param bank the data bank index. * @param i the element index. * @param val the new element value. */ public abstract void setElem(int bank, int i, int val); - + /** - * Returns an element from the first data bank, converted to a - * <code>float</code>. The offset (specified in the constructor) is added + * Returns an element from the first data bank, converted to a + * <code>float</code>. The offset (specified in the constructor) is added * to <code>i</code> before accessing the underlying data array. - * + * * @param i the element index. * @return The element. */ @@ -339,12 +339,12 @@ public abstract class DataBuffer { return getElem(i); } - + /** - * Returns an element from a particular data bank, converted to a - * <code>float</code>. The offset (specified in the constructor) is + * Returns an element from a particular data bank, converted to a + * <code>float</code>. The offset (specified in the constructor) is * added to <code>i</code> before accessing the underlying data array. - * + * * @param bank the bank index. * @param i the element index. * @return The element. @@ -357,8 +357,8 @@ public abstract class DataBuffer /** * Sets an element in the first data bank. The offset (specified in the * constructor) is added to <code>i</code> before updating the underlying - * data array. - * + * data array. + * * @param i the element index. * @param val the new element value. */ @@ -371,7 +371,7 @@ public abstract class DataBuffer * Sets an element in a particular data bank. The offset (specified in the * constructor) is added to <code>i</code> before updating the underlying * data array. - * + * * @param bank the data bank index. * @param i the element index. * @param val the new element value. @@ -382,10 +382,10 @@ public abstract class DataBuffer } /** - * Returns an element from the first data bank, converted to a + * Returns an element from the first data bank, converted to a * <code>double</code>. The offset (specified in the constructor) is added * to <code>i</code> before accessing the underlying data array. - * + * * @param i the element index. * @return The element. */ @@ -393,12 +393,12 @@ public abstract class DataBuffer { return getElem(i); } - + /** - * Returns an element from a particular data bank, converted to a - * <code>double</code>. The offset (specified in the constructor) is + * Returns an element from a particular data bank, converted to a + * <code>double</code>. The offset (specified in the constructor) is * added to <code>i</code> before accessing the underlying data array. - * + * * @param bank the bank index. * @param i the element index. * @return The element. @@ -411,8 +411,8 @@ public abstract class DataBuffer /** * Sets an element in the first data bank. The offset (specified in the * constructor) is added to <code>i</code> before updating the underlying - * data array. - * + * data array. + * * @param i the element index. * @param val the new element value. */ @@ -425,7 +425,7 @@ public abstract class DataBuffer * Sets an element in a particular data bank. The offset (specified in the * constructor) is added to <code>i</code> before updating the underlying * data array. - * + * * @param bank the data bank index. * @param i the element index. * @param val the new element value. diff --git a/java/awt/image/DataBufferByte.java b/java/awt/image/DataBufferByte.java index 1113ebb78..01364b07a 100644 --- a/java/awt/image/DataBufferByte.java +++ b/java/awt/image/DataBufferByte.java @@ -48,19 +48,19 @@ package java.awt.image; /** * A {@link DataBuffer} that uses an array of <code>byte</code> primitives - * to represent each of its banks. - * + * to represent each of its banks. + * * @author Rolf W. Rasmussen (rolfwr@ii.uib.no) */ public final class DataBufferByte extends DataBuffer { private byte[] data; private byte[][] bankData; - + /** - * Creates a new data buffer with a single data bank containing the + * Creates a new data buffer with a single data bank containing the * specified number of <code>byte</code> elements. - * + * * @param size the number of elements in the data bank. */ public DataBufferByte(int size) @@ -72,9 +72,9 @@ public final class DataBufferByte extends DataBuffer } /** - * Creates a new data buffer with the specified number of data banks, + * Creates a new data buffer with the specified number of data banks, * each containing the specified number of <code>byte</code> elements. - * + * * @param size the number of elements in the data bank. * @param numBanks the number of data banks. */ @@ -88,10 +88,10 @@ public final class DataBufferByte extends DataBuffer /** * Creates a new data buffer backed by the specified data bank. * <p> - * Note: there is no exception when <code>dataArray</code> is + * Note: there is no exception when <code>dataArray</code> is * <code>null</code>, but in that case an exception will be thrown * later if you attempt to access the data buffer. - * + * * @param dataArray the data bank. * @param size the number of elements in the data bank. */ @@ -102,15 +102,15 @@ public final class DataBufferByte extends DataBuffer data = dataArray; bankData[0] = data; } - + /** * Creates a new data buffer backed by the specified data bank, with * the specified offset to the first element. * <p> - * Note: there is no exception when <code>dataArray</code> is + * Note: there is no exception when <code>dataArray</code> is * <code>null</code>, but in that case an exception will be thrown * later if you attempt to access the data buffer. - * + * * @param dataArray the data bank. * @param size the number of elements in the data bank. * @param offset the offset to the first element in the array. @@ -125,11 +125,11 @@ public final class DataBufferByte extends DataBuffer /** * Creates a new data buffer backed by the specified data banks. - * + * * @param dataArray the data banks. * @param size the number of elements in the data bank. - * - * @throws NullPointerException if <code>dataArray</code> is + * + * @throws NullPointerException if <code>dataArray</code> is * <code>null</code>. */ public DataBufferByte(byte[][] dataArray, int size) @@ -142,12 +142,12 @@ public final class DataBufferByte extends DataBuffer /** * Creates a new data buffer backed by the specified data banks, with * the specified offsets to the first element in each bank. - * + * * @param dataArray the data banks. * @param size the number of elements in the data bank. * @param offsets the offsets to the first element in each data bank. - * - * @throws NullPointerException if <code>dataArray</code> is + * + * @throws NullPointerException if <code>dataArray</code> is * <code>null</code>. */ public DataBufferByte(byte[][] dataArray, int size, int[] offsets) @@ -159,40 +159,40 @@ public final class DataBufferByte extends DataBuffer /** * Returns the first data bank. - * + * * @return The first data bank. */ public byte[] getData() { return data; } - + /** * Returns a data bank. - * + * * @param bank the bank index. * @return A data bank. */ - public byte[] getData(int bank) + public byte[] getData(int bank) { return bankData[bank]; } - + /** * Returns the array underlying this <code>DataBuffer</code>. - * + * * @return The data banks. */ public byte[][] getBankData() { return bankData; } - + /** * Returns an element from the first data bank. The offset (specified in - * the constructor) is added to <code>i</code> before accessing the + * the constructor) is added to <code>i</code> before accessing the * underlying data array. - * + * * @param i the element index. * @return The element. */ @@ -200,12 +200,12 @@ public final class DataBufferByte extends DataBuffer { return data[i+offset] & 0xff; // get unsigned byte as int } - + /** * Returns an element from a particular data bank. The offset (specified in - * the constructor) is added to <code>i</code> before accessing the + * the constructor) is added to <code>i</code> before accessing the * underlying data array. - * + * * @param bank the bank index. * @param i the element index. * @return The element. @@ -220,7 +220,7 @@ public final class DataBufferByte extends DataBuffer * Sets an element in the first data bank. The offset (specified in the * constructor) is added to <code>i</code> before updating the underlying * data array. - * + * * @param i the element index. * @param val the new element value. */ @@ -233,7 +233,7 @@ public final class DataBufferByte extends DataBuffer * Sets an element in a particular data bank. The offset (specified in the * constructor) is added to <code>i</code> before updating the underlying * data array. - * + * * @param bank the data bank index. * @param i the element index. * @param val the new element value. diff --git a/java/awt/image/DataBufferDouble.java b/java/awt/image/DataBufferDouble.java index a8c4b9d05..31c5ebd8c 100644 --- a/java/awt/image/DataBufferDouble.java +++ b/java/awt/image/DataBufferDouble.java @@ -48,8 +48,8 @@ package java.awt.image; /** * A {@link DataBuffer} that uses an array of <code>double</code> primitives - * to represent each of its banks. - * + * to represent each of its banks. + * * @since 1.4 * * @author Rolf W. Rasmussen (rolfwr@ii.uib.no) @@ -60,11 +60,11 @@ public final class DataBufferDouble { private double[] data; private double[][] bankData; - + /** - * Creates a new data buffer with a single data bank containing the + * Creates a new data buffer with a single data bank containing the * specified number of <code>double</code> elements. - * + * * @param size the number of elements in the data bank. */ public DataBufferDouble(int size) @@ -76,9 +76,9 @@ public final class DataBufferDouble } /** - * Creates a new data buffer with the specified number of data banks, + * Creates a new data buffer with the specified number of data banks, * each containing the specified number of <code>double</code> elements. - * + * * @param size the number of elements in the data bank. * @param numBanks the number of data banks. */ @@ -92,10 +92,10 @@ public final class DataBufferDouble /** * Creates a new data buffer backed by the specified data bank. * <p> - * Note: there is no exception when <code>dataArray</code> is + * Note: there is no exception when <code>dataArray</code> is * <code>null</code>, but in that case an exception will be thrown * later if you attempt to access the data buffer. - * + * * @param dataArray the data bank. * @param size the number of elements in the data bank. */ @@ -106,15 +106,15 @@ public final class DataBufferDouble data = dataArray; bankData[0] = data; } - + /** * Creates a new data buffer backed by the specified data bank, with * the specified offset to the first element. * <p> - * Note: there is no exception when <code>dataArray</code> is + * Note: there is no exception when <code>dataArray</code> is * <code>null</code>, but in that case an exception will be thrown * later if you attempt to access the data buffer. - * + * * @param dataArray the data bank. * @param size the number of elements in the data bank. * @param offset the offset to the first element in the array. @@ -129,11 +129,11 @@ public final class DataBufferDouble /** * Creates a new data buffer backed by the specified data banks. - * + * * @param dataArray the data banks. * @param size the number of elements in the data bank. - * - * @throws NullPointerException if <code>dataArray</code> is + * + * @throws NullPointerException if <code>dataArray</code> is * <code>null</code>. */ public DataBufferDouble(double[][] dataArray, int size) @@ -146,12 +146,12 @@ public final class DataBufferDouble /** * Creates a new data buffer backed by the specified data banks, with * the specified offsets to the first element in each bank. - * + * * @param dataArray the data banks. * @param size the number of elements in the data bank. * @param offsets the offsets to the first element in each data bank. - * - * @throws NullPointerException if <code>dataArray</code> is + * + * @throws NullPointerException if <code>dataArray</code> is * <code>null</code>. */ public DataBufferDouble(double[][] dataArray, int size, int[] offsets) @@ -163,17 +163,17 @@ public final class DataBufferDouble /** * Returns the first data bank. - * + * * @return The first data bank. */ public double[] getData() { return data; } - + /** * Returns a data bank. - * + * * @param bank the bank index. * @return A data bank. */ @@ -181,22 +181,22 @@ public final class DataBufferDouble { return bankData[bank]; } - + /** * Returns the array underlying this <code>DataBuffer</code>. - * + * * @return The data banks. */ public double[][] getBankData() { return bankData; } - + /** * Returns an element from the first data bank. The offset (specified in - * the constructor) is added to <code>i</code> before accessing the + * the constructor) is added to <code>i</code> before accessing the * underlying data array. - * + * * @param i the element index. * @return The element. */ @@ -207,9 +207,9 @@ public final class DataBufferDouble /** * Returns an element from a particular data bank. The offset (specified in - * the constructor) is added to <code>i</code> before accessing the + * the constructor) is added to <code>i</code> before accessing the * underlying data array. - * + * * @param bank the bank index. * @param i the element index. * @return The element. @@ -223,7 +223,7 @@ public final class DataBufferDouble * Sets an element in the first data bank. The offset (specified in the * constructor) is added to <code>i</code> before updating the underlying * data array. - * + * * @param i the element index. * @param val the new element value. */ @@ -236,7 +236,7 @@ public final class DataBufferDouble * Sets an element in a particular data bank. The offset (specified in the * constructor) is added to <code>i</code> before updating the underlying * data array. - * + * * @param bank the data bank index. * @param i the element index. * @param val the new element value. @@ -250,7 +250,7 @@ public final class DataBufferDouble { return (float) data[i+offset]; } - + public float getElemFloat(int bank, int i) { return (float) bankData[bank][i+offsets[bank]]; @@ -270,7 +270,7 @@ public final class DataBufferDouble { return data[i + offset]; } - + public double getElemDouble(int bank, int i) { return bankData[bank][i + offsets[bank]]; diff --git a/java/awt/image/DataBufferFloat.java b/java/awt/image/DataBufferFloat.java index 9cf8784d7..44a0a3892 100644 --- a/java/awt/image/DataBufferFloat.java +++ b/java/awt/image/DataBufferFloat.java @@ -48,8 +48,8 @@ package java.awt.image; /** * A {@link DataBuffer} that uses an array of <code>float</code> primitives - * to represent each of its banks. - * + * to represent each of its banks. + * * @author Rolf W. Rasmussen (rolfwr@ii.uib.no) * @author Sascha Brawer (brawer@dandelis.ch) */ @@ -58,11 +58,11 @@ public final class DataBufferFloat { private float[] data; private float[][] bankData; - + /** - * Creates a new data buffer with a single data bank containing the + * Creates a new data buffer with a single data bank containing the * specified number of <code>float</code> elements. - * + * * @param size the number of elements in the data bank. */ public DataBufferFloat(int size) @@ -74,9 +74,9 @@ public final class DataBufferFloat } /** - * Creates a new data buffer with the specified number of data banks, + * Creates a new data buffer with the specified number of data banks, * each containing the specified number of <code>float</code> elements. - * + * * @param size the number of elements in the data bank. * @param numBanks the number of data banks. */ @@ -90,10 +90,10 @@ public final class DataBufferFloat /** * Creates a new data buffer backed by the specified data bank. * <p> - * Note: there is no exception when <code>dataArray</code> is + * Note: there is no exception when <code>dataArray</code> is * <code>null</code>, but in that case an exception will be thrown * later if you attempt to access the data buffer. - * + * * @param dataArray the data bank. * @param size the number of elements in the data bank. */ @@ -104,15 +104,15 @@ public final class DataBufferFloat data = dataArray; bankData[0] = data; } - + /** * Creates a new data buffer backed by the specified data bank, with * the specified offset to the first element. * <p> - * Note: there is no exception when <code>dataArray</code> is + * Note: there is no exception when <code>dataArray</code> is * <code>null</code>, but in that case an exception will be thrown * later if you attempt to access the data buffer. - * + * * @param dataArray the data bank. * @param size the number of elements in the data bank. * @param offset the offset to the first element in the array. @@ -127,11 +127,11 @@ public final class DataBufferFloat /** * Creates a new data buffer backed by the specified data banks. - * + * * @param dataArray the data banks. * @param size the number of elements in the data bank. - * - * @throws NullPointerException if <code>dataArray</code> is + * + * @throws NullPointerException if <code>dataArray</code> is * <code>null</code>. */ public DataBufferFloat(float[][] dataArray, int size) @@ -144,12 +144,12 @@ public final class DataBufferFloat /** * Creates a new data buffer backed by the specified data banks, with * the specified offsets to the first element in each bank. - * + * * @param dataArray the data banks. * @param size the number of elements in the data bank. * @param offsets the offsets to the first element in each data bank. - * - * @throws NullPointerException if <code>dataArray</code> is + * + * @throws NullPointerException if <code>dataArray</code> is * <code>null</code>. */ public DataBufferFloat(float[][] dataArray, int size, int[] offsets) @@ -161,17 +161,17 @@ public final class DataBufferFloat /** * Returns the first data bank. - * + * * @return The first data bank. */ public float[] getData() { return data; } - + /** * Returns a data bank. - * + * * @param bank the bank index. * @return A data bank. */ @@ -179,22 +179,22 @@ public final class DataBufferFloat { return bankData[bank]; } - + /** * Returns the array underlying this <code>DataBuffer</code>. - * + * * @return The data banks. */ public float[][] getBankData() { return bankData; } - + /** * Returns an element from the first data bank. The offset (specified in - * the constructor) is added to <code>i</code> before accessing the + * the constructor) is added to <code>i</code> before accessing the * underlying data array. - * + * * @param i the element index. * @return The element. */ @@ -205,9 +205,9 @@ public final class DataBufferFloat /** * Returns an element from a particular data bank. The offset (specified in - * the constructor) is added to <code>i</code> before accessing the + * the constructor) is added to <code>i</code> before accessing the * underlying data array. - * + * * @param bank the bank index. * @param i the element index. * @return The element. @@ -221,7 +221,7 @@ public final class DataBufferFloat * Sets an element in the first data bank. The offset (specified in the * constructor) is added to <code>i</code> before updating the underlying * data array. - * + * * @param i the element index. * @param val the new element value. */ @@ -234,7 +234,7 @@ public final class DataBufferFloat * Sets an element in a particular data bank. The offset (specified in the * constructor) is added to <code>i</code> before updating the underlying * data array. - * + * * @param bank the data bank index. * @param i the element index. * @param val the new element value. @@ -248,7 +248,7 @@ public final class DataBufferFloat { return data[i+offset]; } - + public float getElemFloat(int bank, int i) { return bankData[bank][i+offsets[bank]]; @@ -268,7 +268,7 @@ public final class DataBufferFloat { return getElemFloat(i); } - + public double getElemDouble(int bank, int i) { return getElemFloat(bank, i); diff --git a/java/awt/image/DataBufferInt.java b/java/awt/image/DataBufferInt.java index 0aac94040..db9d5bc30 100644 --- a/java/awt/image/DataBufferInt.java +++ b/java/awt/image/DataBufferInt.java @@ -48,19 +48,19 @@ package java.awt.image; /** * A {@link DataBuffer} that uses an array of <code>int</code> primitives - * to represent each of its banks. - * + * to represent each of its banks. + * * @author Rolf W. Rasmussen (rolfwr@ii.uib.no) */ public final class DataBufferInt extends DataBuffer { private int[] data; private int[][] bankData; - + /** - * Creates a new data buffer with a single data bank containing the + * Creates a new data buffer with a single data bank containing the * specified number of <code>int</code> elements. - * + * * @param size the number of elements in the data bank. */ public DataBufferInt(int size) @@ -72,9 +72,9 @@ public final class DataBufferInt extends DataBuffer } /** - * Creates a new data buffer with the specified number of data banks, + * Creates a new data buffer with the specified number of data banks, * each containing the specified number of <code>int</code> elements. - * + * * @param size the number of elements in the data bank. * @param numBanks the number of data banks. */ @@ -84,14 +84,14 @@ public final class DataBufferInt extends DataBuffer bankData = new int[numBanks][size]; data = bankData[0]; } - + /** * Creates a new data buffer backed by the specified data bank. * <p> - * Note: there is no exception when <code>dataArray</code> is + * Note: there is no exception when <code>dataArray</code> is * <code>null</code>, but in that case an exception will be thrown * later if you attempt to access the data buffer. - * + * * @param dataArray the data bank. * @param size the number of elements in the data bank. */ @@ -102,15 +102,15 @@ public final class DataBufferInt extends DataBuffer data = dataArray; bankData[0] = data; } - + /** * Creates a new data buffer backed by the specified data bank, with * the specified offset to the first element. * <p> - * Note: there is no exception when <code>dataArray</code> is + * Note: there is no exception when <code>dataArray</code> is * <code>null</code>, but in that case an exception will be thrown * later if you attempt to access the data buffer. - * + * * @param dataArray the data bank. * @param size the number of elements in the data bank. * @param offset the offset to the first element in the array. @@ -122,14 +122,14 @@ public final class DataBufferInt extends DataBuffer data = dataArray; bankData[0] = data; } - + /** * Creates a new data buffer backed by the specified data banks. - * + * * @param dataArray the data banks. * @param size the number of elements in the data bank. - * - * @throws NullPointerException if <code>dataArray</code> is + * + * @throws NullPointerException if <code>dataArray</code> is * <code>null</code>. */ public DataBufferInt(int[][] dataArray, int size) @@ -138,16 +138,16 @@ public final class DataBufferInt extends DataBuffer bankData = dataArray; data = bankData[0]; } - + /** * Creates a new data buffer backed by the specified data banks, with * the specified offsets to the first element in each bank. - * + * * @param dataArray the data banks. * @param size the number of elements in the data bank. * @param offsets the offsets to the first element in each data bank. - * - * @throws NullPointerException if <code>dataArray</code> is + * + * @throws NullPointerException if <code>dataArray</code> is * <code>null</code>. */ public DataBufferInt(int[][] dataArray, int size, int[] offsets) @@ -159,17 +159,17 @@ public final class DataBufferInt extends DataBuffer /** * Returns the first data bank. - * + * * @return The first data bank. */ public int[] getData() { return data; } - + /** * Returns a data bank. - * + * * @param bank the bank index. * @return A data bank. */ @@ -177,21 +177,21 @@ public final class DataBufferInt extends DataBuffer { return bankData[bank]; } - + /** * Returns the array underlying this <code>DataBuffer</code>. - * + * * @return The data banks. */ public int[][] getBankData() { return bankData; } - + /** * Returns an element from the first data bank. The <code>offset</code> is * added to the specified index before accessing the underlying data array. - * + * * @param i the element index. * @return The element. */ @@ -201,10 +201,10 @@ public final class DataBufferInt extends DataBuffer } /** - * Returns an element from a particular data bank. The <code>offset</code> - * is added to the specified index before accessing the underlying data + * Returns an element from a particular data bank. The <code>offset</code> + * is added to the specified index before accessing the underlying data * array. - * + * * @param bank the bank index. * @param i the element index. * @return The element. @@ -219,7 +219,7 @@ public final class DataBufferInt extends DataBuffer * Sets an element in the first data bank. The offset (specified in the * constructor) is added to <code>i</code> before updating the underlying * data array. - * + * * @param i the element index. * @param val the new element value. */ @@ -227,12 +227,12 @@ public final class DataBufferInt extends DataBuffer { data[i+offset] = val; } - + /** * Sets an element in a particular data bank. The offset (specified in the * constructor) is added to <code>i</code> before updating the underlying * data array. - * + * * @param bank the data bank index. * @param i the element index. * @param val the new element value. diff --git a/java/awt/image/DataBufferShort.java b/java/awt/image/DataBufferShort.java index 5c67a8d3c..2156d7571 100644 --- a/java/awt/image/DataBufferShort.java +++ b/java/awt/image/DataBufferShort.java @@ -49,19 +49,19 @@ package java.awt.image; /** * A {@link DataBuffer} that uses an array of <code>short</code> primitives - * to represent each of its banks. - * + * to represent each of its banks. + * * @author Rolf W. Rasmussen (rolfwr@ii.uib.no) */ public final class DataBufferShort extends DataBuffer { private short[] data; private short[][] bankData; - + /** - * Creates a new data buffer with a single data bank containing the + * Creates a new data buffer with a single data bank containing the * specified number of <code>short</code> elements. - * + * * @param size the number of elements in the data bank. */ public DataBufferShort(int size) @@ -73,9 +73,9 @@ public final class DataBufferShort extends DataBuffer } /** - * Creates a new data buffer with the specified number of data banks, + * Creates a new data buffer with the specified number of data banks, * each containing the specified number of <code>short</code> elements. - * + * * @param size the number of elements in the data bank. * @param numBanks the number of data banks. */ @@ -89,10 +89,10 @@ public final class DataBufferShort extends DataBuffer /** * Creates a new data buffer backed by the specified data bank. * <p> - * Note: there is no exception when <code>dataArray</code> is + * Note: there is no exception when <code>dataArray</code> is * <code>null</code>, but in that case an exception will be thrown * later if you attempt to access the data buffer. - * + * * @param dataArray the data bank. * @param size the number of elements in the data bank. */ @@ -103,15 +103,15 @@ public final class DataBufferShort extends DataBuffer data = dataArray; bankData[0] = data; } - + /** * Creates a new data buffer backed by the specified data bank, with * the specified offset to the first element. * <p> - * Note: there is no exception when <code>dataArray</code> is + * Note: there is no exception when <code>dataArray</code> is * <code>null</code>, but in that case an exception will be thrown * later if you attempt to access the data buffer. - * + * * @param dataArray the data bank. * @param size the number of elements in the data bank. * @param offset the offset to the first element in the array. @@ -126,11 +126,11 @@ public final class DataBufferShort extends DataBuffer /** * Creates a new data buffer backed by the specified data banks. - * + * * @param dataArray the data banks. * @param size the number of elements in the data bank. - * - * @throws NullPointerException if <code>dataArray</code> is + * + * @throws NullPointerException if <code>dataArray</code> is * <code>null</code>. */ public DataBufferShort(short[][] dataArray, int size) @@ -143,12 +143,12 @@ public final class DataBufferShort extends DataBuffer /** * Creates a new data buffer backed by the specified data banks, with * the specified offsets to the first element in each bank. - * + * * @param dataArray the data banks. * @param size the number of elements in the data bank. * @param offsets the offsets to the first element in each data bank. - * - * @throws NullPointerException if <code>dataArray</code> is + * + * @throws NullPointerException if <code>dataArray</code> is * <code>null</code>. */ public DataBufferShort(short[][] dataArray, int size, int[] offsets) @@ -160,17 +160,17 @@ public final class DataBufferShort extends DataBuffer /** * Returns the first data bank. - * + * * @return The first data bank. */ public short[] getData() { return data; } - + /** * Returns a data bank. - * + * * @param bank the bank index. * @return A data bank. */ @@ -178,22 +178,22 @@ public final class DataBufferShort extends DataBuffer { return bankData[bank]; } - + /** * Returns the array underlying this <code>DataBuffer</code>. - * + * * @return The data banks. */ public short[][] getBankData() { return bankData; } - + /** * Returns an element from the first data bank. The offset (specified in - * the constructor) is added to <code>i</code> before accessing the + * the constructor) is added to <code>i</code> before accessing the * underlying data array. - * + * * @param i the element index. * @return The element. */ @@ -204,9 +204,9 @@ public final class DataBufferShort extends DataBuffer /** * Returns an element from a particular data bank. The offset (specified in - * the constructor) is added to <code>i</code> before accessing the + * the constructor) is added to <code>i</code> before accessing the * underlying data array. - * + * * @param bank the bank index. * @param i the element index. * @return The element. @@ -220,7 +220,7 @@ public final class DataBufferShort extends DataBuffer * Sets an element in the first data bank. The offset (specified in the * constructor) is added to <code>i</code> before updating the underlying * data array. - * + * * @param i the element index. * @param val the new element value. */ @@ -233,7 +233,7 @@ public final class DataBufferShort extends DataBuffer * Sets an element in a particular data bank. The offset (specified in the * constructor) is added to <code>i</code> before updating the underlying * data array. - * + * * @param bank the data bank index. * @param i the element index. * @param val the new element value. diff --git a/java/awt/image/DataBufferUShort.java b/java/awt/image/DataBufferUShort.java index 981e9e9d2..d2cadcf0b 100644 --- a/java/awt/image/DataBufferUShort.java +++ b/java/awt/image/DataBufferUShort.java @@ -49,19 +49,19 @@ package java.awt.image; /** * A {@link DataBuffer} that uses an array of <code>short</code> primitives - * to represent each of its banks. - * + * to represent each of its banks. + * * @author Rolf W. Rasmussen (rolfwr@ii.uib.no) */ public final class DataBufferUShort extends DataBuffer { private short[] data; private short[][] bankData; - + /** - * Creates a new data buffer with a single data bank containing the + * Creates a new data buffer with a single data bank containing the * specified number of <code>short</code> elements. - * + * * @param size the number of elements in the data bank. */ public DataBufferUShort(int size) @@ -73,9 +73,9 @@ public final class DataBufferUShort extends DataBuffer } /** - * Creates a new data buffer with the specified number of data banks, + * Creates a new data buffer with the specified number of data banks, * each containing the specified number of <code>short</code> elements. - * + * * @param size the number of elements in the data bank. * @param numBanks the number of data banks. */ @@ -88,7 +88,7 @@ public final class DataBufferUShort extends DataBuffer /** * Creates a new data buffer backed by the specified data bank. - * + * * @param dataArray the data bank. * @param size the number of elements in the data bank. * @@ -103,11 +103,11 @@ public final class DataBufferUShort extends DataBuffer data = dataArray; bankData[0] = data; } - + /** * Creates a new data buffer backed by the specified data bank, with * the specified offset to the first element. - * + * * @param dataArray the data bank. * @param size the number of elements in the data bank. * @param offset the offset to the first element in the array. @@ -126,11 +126,11 @@ public final class DataBufferUShort extends DataBuffer /** * Creates a new data buffer backed by the specified data banks. - * + * * @param dataArray the data banks. * @param size the number of elements in the data bank. - * - * @throws NullPointerException if <code>dataArray</code> is + * + * @throws NullPointerException if <code>dataArray</code> is * <code>null</code>. */ public DataBufferUShort(short[][] dataArray, int size) @@ -143,12 +143,12 @@ public final class DataBufferUShort extends DataBuffer /** * Creates a new data buffer backed by the specified data banks, with * the specified offsets to the first element in each bank. - * + * * @param dataArray the data banks. * @param size the number of elements in the data bank. * @param offsets the offsets to the first element in each data bank. - * - * @throws NullPointerException if <code>dataArray</code> is + * + * @throws NullPointerException if <code>dataArray</code> is * <code>null</code>. */ public DataBufferUShort(short[][] dataArray, int size, int[] offsets) @@ -160,17 +160,17 @@ public final class DataBufferUShort extends DataBuffer /** * Returns the first data bank. - * + * * @return The first data bank. */ public short[] getData() { return data; } - + /** * Returns a data bank. - * + * * @param bank the bank index. * @return A data bank. */ @@ -178,22 +178,22 @@ public final class DataBufferUShort extends DataBuffer { return bankData[bank]; } - + /** * Returns the array underlying this <code>DataBuffer</code>. - * + * * @return The data banks. */ public short[][] getBankData() { return bankData; } - + /** * Returns an element from the first data bank. The offset (specified in - * the constructor) is added to <code>i</code> before accessing the + * the constructor) is added to <code>i</code> before accessing the * underlying data array. - * + * * @param i the element index. * @return The element. */ @@ -204,9 +204,9 @@ public final class DataBufferUShort extends DataBuffer /** * Returns an element from a particular data bank. The offset (specified in - * the constructor) is added to <code>i</code> before accessing the + * the constructor) is added to <code>i</code> before accessing the * underlying data array. - * + * * @param bank the bank index. * @param i the element index. * @return The element. @@ -221,7 +221,7 @@ public final class DataBufferUShort extends DataBuffer * Sets an element in the first data bank. The offset (specified in the * constructor) is added to <code>i</code> before updating the underlying * data array. - * + * * @param i the element index. * @param val the new element value. */ @@ -234,7 +234,7 @@ public final class DataBufferUShort extends DataBuffer * Sets an element in a particular data bank. The offset (specified in the * constructor) is added to <code>i</code> before updating the underlying * data array. - * + * * @param bank the data bank index. * @param i the element index. * @param val the new element value. diff --git a/java/awt/image/DirectColorModel.java b/java/awt/image/DirectColorModel.java index 3d43c7642..a464fed30 100644 --- a/java/awt/image/DirectColorModel.java +++ b/java/awt/image/DirectColorModel.java @@ -57,19 +57,19 @@ public class DirectColorModel extends PackedColorModel * Each mask should describe a fully contiguous set of bits in the * most likely order of alpha, red, green, blue from the most significant * byte to the least significant byte. - * + * * @param pixelBits the number of bits wide used for bit size of pixel values * @param rmask the bits describing the red component of a pixel * @param gmask the bits describing the green component of a pixel - * @param bmask the bits describing the blue component of a pixel + * @param bmask the bits describing the blue component of a pixel */ public DirectColorModel(int pixelBits, int rmask, int gmask, int bmask) { this(ColorSpace.getInstance(ColorSpace.CS_sRGB), pixelBits, - rmask, gmask, bmask, 0, - false, // not alpha premultiplied - Buffers.smallestAppropriateTransferType(pixelBits) // find type - ); + rmask, gmask, bmask, 0, + false, // not alpha premultiplied + Buffers.smallestAppropriateTransferType(pixelBits) // find type + ); } /** @@ -78,34 +78,34 @@ public class DirectColorModel extends PackedColorModel * Each mask should describe a fully contiguous set of bits in the * most likely order of red, green, blue from the most significant * byte to the least significant byte. - * + * * @param pixelBits the number of bits wide used for bit size of pixel values * @param rmask the bits describing the red component of a pixel * @param gmask the bits describing the green component of a pixel - * @param bmask the bits describing the blue component of a pixel - * @param amask the bits describing the alpha component of a pixel + * @param bmask the bits describing the blue component of a pixel + * @param amask the bits describing the alpha component of a pixel */ public DirectColorModel(int pixelBits, - int rmask, int gmask, int bmask, int amask) + int rmask, int gmask, int bmask, int amask) { this(ColorSpace.getInstance(ColorSpace.CS_sRGB), pixelBits, - rmask, gmask, bmask, amask, - false, // not alpha premultiplied - Buffers.smallestAppropriateTransferType(pixelBits) // find type - ); + rmask, gmask, bmask, amask, + false, // not alpha premultiplied + Buffers.smallestAppropriateTransferType(pixelBits) // find type + ); } public DirectColorModel(ColorSpace cspace, int pixelBits, - int rmask, int gmask, int bmask, int amask, - boolean isAlphaPremultiplied, - int transferType) + int rmask, int gmask, int bmask, int amask, + boolean isAlphaPremultiplied, + int transferType) { super(cspace, pixelBits, - rmask, gmask, bmask, amask, isAlphaPremultiplied, - ((amask == 0) ? Transparency.OPAQUE : Transparency.TRANSLUCENT), - transferType); + rmask, gmask, bmask, amask, isAlphaPremultiplied, + ((amask == 0) ? Transparency.OPAQUE : Transparency.TRANSLUCENT), + transferType); } - + public final int getRedMask() { return getMask(0); @@ -143,7 +143,7 @@ public class DirectColorModel extends PackedColorModel { return extractAndNormalizeSample(pixel, 1); } - + /** * Get the blue component of the given pixel. * <br> @@ -184,12 +184,12 @@ public class DirectColorModel extends PackedColorModel /** * Get the RGB color value of the given pixel using the default - * RGB color model. + * RGB color model. * <br> * * @param pixel a pixel value */ - public final int getRGB(int pixel) + public final int getRGB(int pixel) { /* FIXME: The Sun docs show that this method is overridden, but I don't see any way to improve on the superclass @@ -211,7 +211,7 @@ public class DirectColorModel extends PackedColorModel { return getBlue(getPixelFromArray(inData)); } - + public int getAlpha(Object inData) { return getAlpha(getPixelFromArray(inData)); @@ -221,7 +221,7 @@ public class DirectColorModel extends PackedColorModel { return getRGB(getPixelFromArray(inData)); } - + /** * Converts a normalized pixel int value in the sRGB color * space to an array containing a single pixel of the color space @@ -231,7 +231,7 @@ public class DirectColorModel extends PackedColorModel * <code>getRGB(Object inData)</code>. * * @param rgb pixel as a normalized sRGB, 0xAARRGGBB value. - * + * * @param pixel to avoid needless creation of arrays, an array to * use to return the pixel can be given. If null, a suitable array * will be created. @@ -244,60 +244,60 @@ public class DirectColorModel extends PackedColorModel public Object getDataElements(int rgb, Object pixel) { // FIXME: handle alpha multiply - + int pixelValue = 0; int a = 0; if (hasAlpha()) { a = (rgb >>> 24) & 0xff; pixelValue = valueToField(a, 3, 8); } - + if (hasAlpha() && isAlphaPremultiplied()) { - int r, g, b; - /* if r=0xff and a=0xff, then resulting - value will be (r*a)>>>8 == 0xfe... This seems wrong. - We should divide by 255 rather than shifting >>>8 after - multiplying. - - Too bad, shifting is probably less expensive. - r = ((rgb >>> 16) & 0xff)*a; - g = ((rgb >>> 8) & 0xff)*a; - b = ((rgb >>> 0) & 0xff)*a; */ - /* The r, g, b values we calculate are 16 bit. This allows - us to avoid discarding the lower 8 bits obtained if - multiplying with the alpha band. */ - - // using 16 bit values - r = ((rgb >>> 8) & 0xff00)*a/255; - g = ((rgb >>> 0) & 0xff00)*a/255; - b = ((rgb << 8) & 0xff00)*a/255; - pixelValue |= - valueToField(r, 0, 16) | // Red - valueToField(g, 1, 16) | // Green - valueToField(b, 2, 16); // Blue + int r, g, b; + /* if r=0xff and a=0xff, then resulting + value will be (r*a)>>>8 == 0xfe... This seems wrong. + We should divide by 255 rather than shifting >>>8 after + multiplying. + + Too bad, shifting is probably less expensive. + r = ((rgb >>> 16) & 0xff)*a; + g = ((rgb >>> 8) & 0xff)*a; + b = ((rgb >>> 0) & 0xff)*a; */ + /* The r, g, b values we calculate are 16 bit. This allows + us to avoid discarding the lower 8 bits obtained if + multiplying with the alpha band. */ + + // using 16 bit values + r = ((rgb >>> 8) & 0xff00)*a/255; + g = ((rgb >>> 0) & 0xff00)*a/255; + b = ((rgb << 8) & 0xff00)*a/255; + pixelValue |= + valueToField(r, 0, 16) | // Red + valueToField(g, 1, 16) | // Green + valueToField(b, 2, 16); // Blue } else { - int r, g, b; - // using 8 bit values - r = (rgb >>> 16) & 0xff; - g = (rgb >>> 8) & 0xff; - b = (rgb >>> 0) & 0xff; - - pixelValue |= - valueToField(r, 0, 8) | // Red - valueToField(g, 1, 8) | // Green - valueToField(b, 2, 8); // Blue + int r, g, b; + // using 8 bit values + r = (rgb >>> 16) & 0xff; + g = (rgb >>> 8) & 0xff; + b = (rgb >>> 0) & 0xff; + + pixelValue |= + valueToField(r, 0, 8) | // Red + valueToField(g, 1, 8) | // Green + valueToField(b, 2, 8); // Blue } - + /* In this color model, the whole pixel fits in the first element of the array. */ DataBuffer buffer = Buffers.createBuffer(transferType, pixel, 1); buffer.setElem(0, pixelValue); return Buffers.getData(buffer); } - + /** * Converts a value to the correct field bits based on the * information derived from the field masks. @@ -307,13 +307,13 @@ public class DirectColorModel extends PackedColorModel */ private int valueToField(int val, int component, int highBit) { - int toFieldShift = + int toFieldShift = getComponentSize(component) + shifts[component] - highBit; int ret = (toFieldShift>0) ? (val << toFieldShift) : (val >>> (-toFieldShift)); return ret & getMask(component); - } + } /** * Converts a 16 bit value to the correct field bits based on the @@ -336,15 +336,15 @@ public class DirectColorModel extends PackedColorModel { int numComponents = getNumComponents(); if (components == null) components = new int[offset + numComponents]; - + for (int b=0; b<numComponents; b++) components[offset++] = (pixel&getMask(b)) >>> shifts[b]; - + return components; } public final int[] getComponents(Object pixel, int[] components, - int offset) + int offset) { return getComponents(getPixelFromArray(pixel), components, offset); } @@ -368,19 +368,19 @@ public class DirectColorModel extends PackedColorModel SampleModel sm = createCompatibleSampleModel(w, h); Point origin = new Point(0, 0); - return Raster.createWritableRaster(sm, origin); + return Raster.createWritableRaster(sm, origin); } public int getDataElement(int[] components, int offset) { int numComponents = getNumComponents(); int pixelValue = 0; - + for (int c=0; c<numComponents; c++) pixelValue |= (components[offset++] << shifts[c]) & getMask(c); return pixelValue; - } + } public Object getDataElements(int[] components, int offset, Object obj) { @@ -392,26 +392,26 @@ public class DirectColorModel extends PackedColorModel buffer.setElem(0, pixelValue); return Buffers.getData(buffer); } - + public final ColorModel coerceData (WritableRaster raster, - boolean isAlphaPremultiplied) + boolean isAlphaPremultiplied) { if (this.isAlphaPremultiplied == isAlphaPremultiplied || !hasAlpha()) return this; - + /* TODO: provide better implementation based on the assumptions we can make due to the specific type of the color model. */ coerceDataWorker(raster, isAlphaPremultiplied); - + return new DirectColorModel(cspace, pixel_bits, getRedMask(), getGreenMask(), getBlueMask(), getAlphaMask(), isAlphaPremultiplied, transferType); - } + } public boolean isCompatibleRaster(Raster raster) { - /* FIXME: the Sun docs say this method is overridden here, + /* FIXME: the Sun docs say this method is overridden here, but I don't see any way to improve upon the implementation in ColorModel. */ return super.isCompatibleRaster(raster); @@ -433,4 +433,3 @@ public class DirectColorModel extends PackedColorModel return super.toString(); } } - diff --git a/java/awt/image/FilteredImageSource.java b/java/awt/image/FilteredImageSource.java index 8893e86a6..f56a93ad1 100644 --- a/java/awt/image/FilteredImageSource.java +++ b/java/awt/image/FilteredImageSource.java @@ -1,4 +1,4 @@ -/* FilteredImageSource.java -- Java class for providing image data +/* FilteredImageSource.java -- Java class for providing image data Copyright (C) 1999 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -43,7 +43,7 @@ import java.util.Hashtable; /** * * @see ImageConsumer - * @author C. Brian Jones (cbj@gnu.org) + * @author C. Brian Jones (cbj@gnu.org) */ public class FilteredImageSource implements ImageProducer { @@ -53,73 +53,72 @@ public class FilteredImageSource implements ImageProducer /** * The given filter is applied to the given image producer - * to create a new image producer. + * to create a new image producer. */ public FilteredImageSource(ImageProducer ip, ImageFilter filter) { - this.ip = ip; - this.filter = filter; + this.ip = ip; + this.filter = filter; } /** * Used to register an <code>ImageConsumer</code> with this - * <code>ImageProducer</code>. + * <code>ImageProducer</code>. */ public synchronized void addConsumer(ImageConsumer ic) { - if (consumers.containsKey(ic)) - return; + if (consumers.containsKey(ic)) + return; - ImageFilter f = filter.getFilterInstance(ic); - consumers.put(ic, f); - ip.addConsumer(f); + ImageFilter f = filter.getFilterInstance(ic); + consumers.put(ic, f); + ip.addConsumer(f); } /** * Used to determine if the given <code>ImageConsumer</code> is - * already registered with this <code>ImageProducer</code>. + * already registered with this <code>ImageProducer</code>. */ public synchronized boolean isConsumer(ImageConsumer ic) { - ImageFilter f = (ImageFilter)consumers.get(ic); - if (f != null) - return ip.isConsumer(f); - return false; + ImageFilter f = (ImageFilter)consumers.get(ic); + if (f != null) + return ip.isConsumer(f); + return false; } /** * Used to remove an <code>ImageConsumer</code> from the list of - * registered consumers for this <code>ImageProducer</code>. + * registered consumers for this <code>ImageProducer</code>. */ public synchronized void removeConsumer(ImageConsumer ic) { - ImageFilter f = (ImageFilter)consumers.remove(ic); - if (f != null) - ip.removeConsumer(f); + ImageFilter f = (ImageFilter)consumers.remove(ic); + if (f != null) + ip.removeConsumer(f); } /** * Used to register an <code>ImageConsumer</code> with this * <code>ImageProducer</code> and then immediately start * reconstruction of the image data to be delivered to all - * registered consumers. + * registered consumers. */ public void startProduction(ImageConsumer ic) { - ImageFilter f; - if (!(consumers.containsKey(ic))) { - f = filter.getFilterInstance(ic); - consumers.put(ic, f); - ip.addConsumer(f); - } else { - f = (ImageFilter)consumers.get( ic ); - } - ip.startProduction(f); + ImageFilter f; + if (!(consumers.containsKey(ic))) { + f = filter.getFilterInstance(ic); + consumers.put(ic, f); + ip.addConsumer(f); + } else { + f = (ImageFilter)consumers.get( ic ); + } + ip.startProduction(f); } /** * Used to register an <code>ImageConsumer</code> with this * <code>ImageProducer</code> and then request that this producer - * resend the image data in the order top-down, left-right. + * resend the image data in the order top-down, left-right. */ public void requestTopDownLeftRightResend(ImageConsumer ic) { - ImageFilter f = (ImageFilter)consumers.get(ic); - ip.requestTopDownLeftRightResend(f); + ImageFilter f = (ImageFilter)consumers.get(ic); + ip.requestTopDownLeftRightResend(f); } } - diff --git a/java/awt/image/ImageConsumer.java b/java/awt/image/ImageConsumer.java index 11f64f978..8f3c2b144 100644 --- a/java/awt/image/ImageConsumer.java +++ b/java/awt/image/ImageConsumer.java @@ -43,7 +43,7 @@ import java.util.Hashtable; /** * An object implementing the <code>ImageProducer</code> interface can * use objects implementing this interface to deliver the image data. - * + * * @author C. Brian Jones (cbj@gnu.org) */ public interface ImageConsumer @@ -52,7 +52,7 @@ public interface ImageConsumer * The pixel order may be random. This should be * the default assumption of the <code>ImageConsumer</code>. * - * @see #setHints + * @see #setHints */ int RANDOMPIXELORDER = 1; @@ -75,7 +75,7 @@ public interface ImageConsumer * most one call to <code>setPixels</code> for any single pixel. * * @see #setHints - * @see #setPixels(int, int, int, int, ColorModel, int[], int, int) + * @see #setPixels(int, int, int, int, ColorModel, int[], int, int) */ int SINGLEPASS = 8; @@ -87,9 +87,9 @@ public interface ImageConsumer * changing such as with video then the end of each frame is * marked by a similar call to <code>imageComplete</code> with the * <code>SINGLEFRAMEDONE</code> flag. - * + * * @see #setHints - * @see #imageComplete + * @see #imageComplete */ int SINGLEFRAME = 16; @@ -102,7 +102,7 @@ public interface ImageConsumer /** * A single frame is complete but more will follow. - * + * * @see #imageComplete */ int SINGLEFRAMEDONE = 2; @@ -124,9 +124,9 @@ public interface ImageConsumer /** * An <code>ImageProducer</code> indicates the size of the image * being produced using this method. - * + * * @param width the width of the image - * @param height the height of the image + * @param height the height of the image */ void setDimensions(int width, int height); @@ -134,7 +134,7 @@ public interface ImageConsumer * An <code>ImageProducer</code> can set a list of properties * associated with this image by using this method. * - * @param props the list of properties associated with this image + * @param props the list of properties associated with this image */ void setProperties(Hashtable<?,?> props); @@ -145,7 +145,7 @@ public interface ImageConsumer * <code>ColorModel</code>. * * @param model the color model to be used most often by setPixels - * @see ColorModel + * @see ColorModel */ void setColorModel(ColorModel model); @@ -154,7 +154,7 @@ public interface ImageConsumer * bit mask of hints from any of <code>RANDOMPIXELORDER</code>, * <code>TOPDOWNLEFTRIGHT</code>, <code>COMPLETESCANLINES</code>, * <code>SINGLEPASS</code>, <code>SINGLEFRAME</code>. - * + * * @param flags a bit mask of hints */ void setHints(int flags); @@ -178,8 +178,8 @@ public interface ImageConsumer * @param offset offset into pixels array * @param scansize width of one row in the pixel block */ - void setPixels(int x, int y, int w, int h, - ColorModel model, byte[] pixels, int offset, int scansize); + void setPixels(int x, int y, int w, int h, + ColorModel model, byte[] pixels, int offset, int scansize); /** * Deliver a subset of an ImageProducer's pixels to this ImageConsumer. @@ -200,14 +200,14 @@ public interface ImageConsumer * @param offset offset into pixels array * @param scansize width of one row in the pixel block */ - void setPixels(int x, int y, int w, int h, + void setPixels(int x, int y, int w, int h, ColorModel model, int[] pixels, int offset, int scansize); /** * The <code>ImageProducer</code> calls this method to indicate a * single frame or the entire image is complete. The method is * also used to indicate an error in loading or producing the - * image. + * image. * * @param status the status of image production, represented by a * bitwise OR of ImageConsumer flags diff --git a/java/awt/image/ImageFilter.java b/java/awt/image/ImageFilter.java index 0ead45a4a..10df82e25 100644 --- a/java/awt/image/ImageFilter.java +++ b/java/awt/image/ImageFilter.java @@ -45,24 +45,24 @@ import java.util.Hashtable; * extended to provide different types of filters for an image. By * default this class does nothing to an image passing through it. * - * @author C. Brian Jones (cbj@gnu.org) + * @author C. Brian Jones (cbj@gnu.org) */ public class ImageFilter implements ImageConsumer, Cloneable { /** * The consumer this filter is filtering an image data stream for. - * It is initialized in the method <code>getFilterInstance</code>. + * It is initialized in the method <code>getFilterInstance</code>. */ protected ImageConsumer consumer = null; /** * The <code>ImageConsumer</code> can use this method to request - * the pixels be delivered in top-down, left-right order. - * <br> - * The filter can respond in three different ways. + * the pixels be delivered in top-down, left-right order. + * <br> + * The filter can respond in three different ways. * <ul> - * <li>The default behavior is to forward the request to the - * <code>ImageProducer</code> + * <li>The default behavior is to forward the request to the + * <code>ImageProducer</code> * using the method <code>requestTopDownLeftRightResend</code> * and using the filter as the consumer.</li> * <li>The filter has the pixels and can retransmit them in the @@ -77,7 +77,7 @@ public class ImageFilter implements ImageConsumer, Cloneable /** * By default, returns a shallow copy of the object created by - * <code>Object.clone()</code> + * <code>Object.clone()</code> * * @see java.lang.Object#clone () */ @@ -98,7 +98,7 @@ public class ImageFilter implements ImageConsumer, Cloneable /** * This is the only method which can set the * <code>ImageConsumer</code> for this filter. By default a clone - * of this filter with the appropriate consumer set is returned. + * of this filter with the appropriate consumer set is returned. * * @see #clone () */ @@ -111,13 +111,13 @@ public class ImageFilter implements ImageConsumer, Cloneable /** * An <code>ImageProducer</code> indicates the size of the image - * being produced using this method. A filter can override this + * being produced using this method. A filter can override this * method to intercept these calls from the producer in order to * change either the width or the height before in turn calling * the consumer's <code>setDimensions</code> method. - * + * * @param width the width of the image - * @param height the height of the image + * @param height the height of the image */ public void setDimensions(int width, int height) { @@ -128,7 +128,7 @@ public class ImageFilter implements ImageConsumer, Cloneable * An <code>ImageProducer</code> can set a list of properties * associated with this image by using this method. * - * @param props the list of properties associated with this image + * @param props the list of properties associated with this image */ public void setProperties(Hashtable<?,?> props) { @@ -160,9 +160,9 @@ public class ImageFilter implements ImageConsumer, Cloneable * The <code>ImageProducer</code> should call this method with a * bit mask of hints from any of <code>RANDOMPIXELORDER</code>, * <code>TOPDOWNLEFTRIGHT</code>, <code>COMPLETESCANLINES</code>, - * <code>SINGLEPASS</code>, <code>SINGLEFRAME</code> from the + * <code>SINGLEPASS</code>, <code>SINGLEFRAME</code> from the * <code>ImageConsumer</code> interface. - * + * * @param flags a bit mask of hints * @see ImageConsumer */ @@ -174,7 +174,7 @@ public class ImageFilter implements ImageConsumer, Cloneable /** * This function delivers a rectangle of pixels where any * pixel(m,n) is stored in the array as a <code>byte</code> at - * index (n * scansize + m + offset). + * index (n * scansize + m + offset). * * @param x the x coordinate of the rectangle * @param y the y coordinate of the rectangle @@ -185,7 +185,7 @@ public class ImageFilter implements ImageConsumer, Cloneable * @param offset the index of the first pixels in the <code>pixels</code> array * @param scansize the width to use in extracting pixels from the <code>pixels</code> array */ - public void setPixels(int x, int y, int w, int h, + public void setPixels(int x, int y, int w, int h, ColorModel model, byte[] pixels, int offset, int scansize) { @@ -195,7 +195,7 @@ public class ImageFilter implements ImageConsumer, Cloneable /** * This function delivers a rectangle of pixels where any * pixel(m,n) is stored in the array as an <code>int</code> at - * index (n * scansize + m + offset). + * index (n * scansize + m + offset). * * @param x the x coordinate of the rectangle * @param y the y coordinate of the rectangle @@ -206,7 +206,7 @@ public class ImageFilter implements ImageConsumer, Cloneable * @param offset the index of the first pixels in the <code>pixels</code> array * @param scansize the width to use in extracting pixels from the <code>pixels</code> array */ - public void setPixels(int x, int y, int w, int h, + public void setPixels(int x, int y, int w, int h, ColorModel model, int[] pixels, int offset, int scansize) { @@ -217,7 +217,7 @@ public class ImageFilter implements ImageConsumer, Cloneable * The <code>ImageProducer</code> calls this method to indicate a * single frame or the entire image is complete. The method is * also used to indicate an error in loading or producing the - * image. + * image. */ public void imageComplete(int status) { diff --git a/java/awt/image/ImageObserver.java b/java/awt/image/ImageObserver.java index 36dd013f4..e63d4bba1 100644 --- a/java/awt/image/ImageObserver.java +++ b/java/awt/image/ImageObserver.java @@ -46,7 +46,7 @@ import java.awt.Image; * <code>ImageProducer</code> asynchronously. * * @see ImageProducer - * @author C. Brian Jones (cbj@gnu.org) + * @author C. Brian Jones (cbj@gnu.org) */ public interface ImageObserver { @@ -54,7 +54,7 @@ public interface ImageObserver * The width of the image has been provided as the * <code>width</code> argument to <code>imageUpdate</code>. * - * @see #imageUpdate + * @see #imageUpdate */ int WIDTH = 1; @@ -62,7 +62,7 @@ public interface ImageObserver * The height of the image has been provided as the * <code>height</code> argument to <code>imageUpdate</code>. * - * @see #imageUpdate + * @see #imageUpdate */ int HEIGHT = 2; @@ -78,7 +78,7 @@ public interface ImageObserver * More pixels are now available for drawing a scaled variation of * the image. * - * @see #imageUpdate + * @see #imageUpdate */ int SOMEBITS = 8; @@ -86,7 +86,7 @@ public interface ImageObserver * All the pixels needed to draw a complete frame of a multi-frame * image are available. * - * @see #imageUpdate + * @see #imageUpdate */ int FRAMEBITS = 16; @@ -121,9 +121,9 @@ public interface ImageObserver * @param y the y coordinate of the image * @param width the width of the image * @param height the height of the image - * - * @see java.awt.Image + * + * @see java.awt.Image */ - boolean imageUpdate(Image image, int flags, int x, - int y, int width, int height); + boolean imageUpdate(Image image, int flags, int x, + int y, int width, int height); } diff --git a/java/awt/image/ImageProducer.java b/java/awt/image/ImageProducer.java index 49846685a..c0f9ad4c7 100644 --- a/java/awt/image/ImageProducer.java +++ b/java/awt/image/ImageProducer.java @@ -45,25 +45,25 @@ package java.awt.image; * resizing the image. * * @see ImageConsumer - * @author C. Brian Jones (cbj@gnu.org) + * @author C. Brian Jones (cbj@gnu.org) */ public interface ImageProducer { /** * Used to register an <code>ImageConsumer</code> with this - * <code>ImageProducer</code>. + * <code>ImageProducer</code>. */ void addConsumer(ImageConsumer ic); /** * Used to determine if the given <code>ImageConsumer</code> is - * already registered with this <code>ImageProducer</code>. + * already registered with this <code>ImageProducer</code>. */ boolean isConsumer(ImageConsumer ic); /** * Used to remove an <code>ImageConsumer</code> from the list of - * registered consumers for this <code>ImageProducer</code>. + * registered consumers for this <code>ImageProducer</code>. */ void removeConsumer(ImageConsumer ic); @@ -71,15 +71,14 @@ public interface ImageProducer * Used to register an <code>ImageConsumer</code> with this * <code>ImageProducer</code> and then immediately start * reconstruction of the image data to be delivered to all - * registered consumers. + * registered consumers. */ void startProduction(ImageConsumer ic); /** * Used to register an <code>ImageConsumer</code> with this * <code>ImageProducer</code> and then request that this producer - * resend the image data in the order top-down, left-right. + * resend the image data in the order top-down, left-right. */ void requestTopDownLeftRightResend(ImageConsumer ic); } - diff --git a/java/awt/image/IndexColorModel.java b/java/awt/image/IndexColorModel.java index d8a27d51f..340d38e89 100644 --- a/java/awt/image/IndexColorModel.java +++ b/java/awt/image/IndexColorModel.java @@ -49,9 +49,9 @@ import java.math.BigInteger; * Thus, pixel values are indexes into the color map. Each color component is * an 8-bit unsigned value. * <br><br> - * The <code>IndexColorModel</code> supports a map of valid pixels, allowing - * the representation of holes in the the color map. The valid map is - * represented as a {@link BigInteger} where each bit indicates the validity + * The <code>IndexColorModel</code> supports a map of valid pixels, allowing + * the representation of holes in the the color map. The valid map is + * represented as a {@link BigInteger} where each bit indicates the validity * of the map entry with the same index. * <br><br> * Colors can have alpha components for transparency support. If alpha @@ -59,11 +59,11 @@ import java.math.BigInteger; * supports a reserved pixel value to represent completely transparent colors, * no matter what the actual color component values are. * <br><br> - * <code>IndexColorModel</code> supports anywhere from 1 to 16 bit index - * values. The allowed transfer types are {@link DataBuffer#TYPE_BYTE} and + * <code>IndexColorModel</code> supports anywhere from 1 to 16 bit index + * values. The allowed transfer types are {@link DataBuffer#TYPE_BYTE} and * {@link DataBuffer#TYPE_USHORT}. * - * @author C. Brian Jones (cbj@gnu.org) + * @author C. Brian Jones (cbj@gnu.org) */ public class IndexColorModel extends ColorModel { @@ -74,22 +74,22 @@ public class IndexColorModel extends ColorModel private BigInteger validBits = BigInteger.ZERO; /** - * Creates a new indexed color model for <code>size</code> color elements - * with no alpha component. Each array must contain at least - * <code>size</code> elements. For each array, the i-th color is described - * by reds[i], greens[i] and blues[i]. + * Creates a new indexed color model for <code>size</code> color elements + * with no alpha component. Each array must contain at least + * <code>size</code> elements. For each array, the i-th color is described + * by reds[i], greens[i] and blues[i]. * - * @param bits the number of bits needed to represent <code>size</code> + * @param bits the number of bits needed to represent <code>size</code> * colors. * @param size the number of colors in the color map. * @param reds the red component of all colors. * @param greens the green component of all colors. * @param blues the blue component of all colors. * - * @throws IllegalArgumentException if <code>bits</code> < 1 or + * @throws IllegalArgumentException if <code>bits</code> < 1 or * <code>bits</code> > 16. * @throws NullPointerException if any of the arrays is <code>null</code>. - * @throws ArrayIndexOutOfBoundsException if <code>size</code> is greater + * @throws ArrayIndexOutOfBoundsException if <code>size</code> is greater * than the length of the component arrays. */ public IndexColorModel(int bits, int size, byte[] reds, byte[] greens, @@ -100,34 +100,34 @@ public class IndexColorModel extends ColorModel /** * Creates a new indexed color model for <code>size</code> color elements. - * Each array must contain at least <code>size</code> elements. For each - * array, the i-th color is described by reds[i], greens[i] and blues[i]. - * All the colors are opaque except for the transparent color. + * Each array must contain at least <code>size</code> elements. For each + * array, the i-th color is described by reds[i], greens[i] and blues[i]. + * All the colors are opaque except for the transparent color. * - * @param bits the number of bits needed to represent <code>size</code> + * @param bits the number of bits needed to represent <code>size</code> * colors * @param size the number of colors in the color map * @param reds the red component of all colors * @param greens the green component of all colors * @param blues the blue component of all colors - * @param trans the index of the transparent color (use -1 for no + * @param trans the index of the transparent color (use -1 for no * transparent color). - * - * @throws IllegalArgumentException if <code>bits</code> < 1 or + * + * @throws IllegalArgumentException if <code>bits</code> < 1 or * <code>bits</code> > 16. * @throws NullPointerException if any of the arrays is <code>null</code>. - * @throws ArrayIndexOutOfBoundsException if <code>size</code> is greater + * @throws ArrayIndexOutOfBoundsException if <code>size</code> is greater * than the length of the component arrays. */ public IndexColorModel(int bits, int size, byte[] reds, byte[] greens, byte[] blues, int trans) { - super(bits, nArray(8, (0 <= trans && trans < size) ? 4 : 3), - ColorSpace.getInstance(ColorSpace.CS_sRGB), - (0 <= trans && trans < size), // hasAlpha - false, OPAQUE, - Buffers.smallestAppropriateTransferType(bits)); - if (bits < 1) + super(bits, nArray(8, (0 <= trans && trans < size) ? 4 : 3), + ColorSpace.getInstance(ColorSpace.CS_sRGB), + (0 <= trans && trans < size), // hasAlpha + false, OPAQUE, + Buffers.smallestAppropriateTransferType(bits)); + if (bits < 1) throw new IllegalArgumentException("bits < 1"); if (bits > 16) throw new IllegalArgumentException("bits > 16"); @@ -150,35 +150,35 @@ public class IndexColorModel extends ColorModel } /** - * Creates a new indexed color model for <code>size</code> color elements - * including alpha. Each array must contain at least <code>size</code> - * elements. For each array, the i-th color is described - * by reds[i], greens[i], blues[i] and alphas[i]. + * Creates a new indexed color model for <code>size</code> color elements + * including alpha. Each array must contain at least <code>size</code> + * elements. For each array, the i-th color is described + * by reds[i], greens[i], blues[i] and alphas[i]. * - * @param bits the number of bits needed to represent <code>size</code> + * @param bits the number of bits needed to represent <code>size</code> * colors. * @param size the number of colors in the color map. * @param reds the red component of all colors. * @param greens the green component of all colors. * @param blues the blue component of all colors. - * @param alphas the alpha component of all colors (<code>null</code> + * @param alphas the alpha component of all colors (<code>null</code> * permitted). * - * @throws IllegalArgumentException if <code>bits</code> < 1 or + * @throws IllegalArgumentException if <code>bits</code> < 1 or * <code>bits</code> > 16. * @throws NullPointerException if <code>reds</code>, <code>greens</code> or * <code>blues</code> is <code>null</code>. - * @throws ArrayIndexOutOfBoundsException if <code>size</code> is greater + * @throws ArrayIndexOutOfBoundsException if <code>size</code> is greater * than the length of the component arrays. */ public IndexColorModel(int bits, int size, byte[] reds, byte[] greens, byte[] blues, byte[] alphas) { - super(bits, nArray(8, (alphas == null ? 3 : 4)), - ColorSpace.getInstance(ColorSpace.CS_sRGB), - (alphas != null), false, TRANSLUCENT, - Buffers.smallestAppropriateTransferType(bits)); - if (bits < 1) + super(bits, nArray(8, (alphas == null ? 3 : 4)), + ColorSpace.getInstance(ColorSpace.CS_sRGB), + (alphas != null), false, TRANSLUCENT, + Buffers.smallestAppropriateTransferType(bits)); + if (bits < 1) throw new IllegalArgumentException("bits < 1"); if (bits > 16) throw new IllegalArgumentException("bits > 16"); @@ -201,11 +201,11 @@ public class IndexColorModel extends ColorModel } else { - byte alphaZero = (byte) 0x00; + byte alphaZero = (byte) 0x00; byte alphaOne = (byte) 0xFF; for (int i = 0; i < size; i++) { - alphaZero = (byte) (alphaZero | alphas[i]); + alphaZero = (byte) (alphaZero | alphas[i]); alphaOne = (byte) (alphaOne & alphas[i]); rgb[i] = ((alphas[i] & 0xff) << 24 | ((reds[i] & 0xff) << 16) @@ -213,9 +213,9 @@ public class IndexColorModel extends ColorModel | (blues[i] & 0xff)); } if ((alphaZero == (byte) 0x00) || (alphaOne == (byte) 0xFF)) - transparency = BITMASK; - else - transparency = TRANSLUCENT; + transparency = BITMASK; + else + transparency = TRANSLUCENT; } // Generate a bigint with 1's for every pixel @@ -223,22 +223,22 @@ public class IndexColorModel extends ColorModel } /** - * Creates a new indexed color model using the color components in + * Creates a new indexed color model using the color components in * <code>cmap</code>. If <code>hasAlpha</code> is <code>true</code> then * <code>cmap</code> contains an alpha component after each of the red, green * and blue components. * - * @param bits the number of bits needed to represent <code>size</code> + * @param bits the number of bits needed to represent <code>size</code> * colors * @param size the number of colors in the color map * @param cmap packed color components * @param start the offset of the first color component in <code>cmap</code> * @param hasAlpha <code>cmap</code> has alpha values - * @throws IllegalArgumentException if bits < 1, bits > 16, or size + * @throws IllegalArgumentException if bits < 1, bits > 16, or size * < 1. * @throws NullPointerException if <code>cmap</code> is <code>null</code>. */ - public IndexColorModel(int bits, int size, byte[] cmap, int start, + public IndexColorModel(int bits, int size, byte[] cmap, int start, boolean hasAlpha) { this(bits, size, cmap, start, hasAlpha, -1); @@ -247,8 +247,8 @@ public class IndexColorModel extends ColorModel /** * Construct an IndexColorModel from an array of red, green, blue, and * optional alpha components. The component values are interleaved as RGB(A). - * - * @param bits the number of bits needed to represent <code>size</code> + * + * @param bits the number of bits needed to represent <code>size</code> * colors * @param size the number of colors in the color map * @param cmap interleaved color components @@ -259,12 +259,12 @@ public class IndexColorModel extends ColorModel * < 1. * @throws NullPointerException if <code>cmap</code> is <code>null</code>. */ - public IndexColorModel(int bits, int size, byte[] cmap, int start, + public IndexColorModel(int bits, int size, byte[] cmap, int start, boolean hasAlpha, int trans) { - super(bits, nArray(8, hasAlpha || (0 <= trans && trans < size) ? 4 : 3), + super(bits, nArray(8, hasAlpha || (0 <= trans && trans < size) ? 4 : 3), ColorSpace.getInstance(ColorSpace.CS_sRGB), - hasAlpha || (0 <= trans && trans < size), false, OPAQUE, + hasAlpha || (0 <= trans && trans < size), false, OPAQUE, Buffers.smallestAppropriateTransferType(bits)); if (bits < 1) throw new IllegalArgumentException("bits < 1"); @@ -282,37 +282,37 @@ public class IndexColorModel extends ColorModel int alphaZero = 0x00; // use to detect all zeros int alphaOne = 0xff; // use to detect all ones for (int i = 0; i < size; i++) { - alpha = cmap[4 * i + 3 + start] & 0xff; + alpha = cmap[4 * i + 3 + start] & 0xff; alphaZero = alphaZero | alpha; alphaOne = alphaOne & alpha; rgb[i] = - ( alpha << 24 - // red - | ((cmap[4 * i + start] & 0xff) << 16) - // green - | ((cmap[4 * i + 1 + start] & 0xff) << 8) - // blue - | (cmap[4 * i + 2 + start] & 0xff)); + ( alpha << 24 + // red + | ((cmap[4 * i + start] & 0xff) << 16) + // green + | ((cmap[4 * i + 1 + start] & 0xff) << 8) + // blue + | (cmap[4 * i + 2 + start] & 0xff)); } - if (alphaZero == 0) - transparency = BITMASK; - else if (alphaOne == 255) + if (alphaZero == 0) + transparency = BITMASK; + else if (alphaOne == 255) transparency = (trans != -1 ? BITMASK : OPAQUE); else - transparency = TRANSLUCENT; + transparency = TRANSLUCENT; } else { for (int i = 0; i < size; i++) - rgb[i] = (0xff000000 - // red - | ((cmap[3 * i + start] & 0xff) << 16) - // green - | ((cmap[3 * i + 1 + start] & 0xff) << 8) - // blue - | (cmap[3 * i + 2 + start] & 0xff)); + rgb[i] = (0xff000000 + // red + | ((cmap[3 * i + start] & 0xff) << 16) + // green + | ((cmap[3 * i + 1 + start] & 0xff) << 8) + // blue + | (cmap[3 * i + 2 + start] & 0xff)); if (trans != -1) - transparency = BITMASK; + transparency = BITMASK; } setTransparentPixel(trans); @@ -327,30 +327,30 @@ public class IndexColorModel extends ColorModel * alpha values packed in order. If hasAlpha is false, then all the colors * are opaque except for the transparent color. * - * @param bits the number of bits needed to represent <code>size</code> + * @param bits the number of bits needed to represent <code>size</code> * colors * @param size the number of colors in the color map * @param cmap packed color components * @param start the offset of the first color component in <code>cmap</code> * @param hasAlpha <code>cmap</code> has alpha values * @param trans the index of the transparent color - * @param transferType {@link DataBuffer#TYPE_BYTE} or + * @param transferType {@link DataBuffer#TYPE_BYTE} or {@link DataBuffer#TYPE_USHORT}. * @throws IllegalArgumentException if bits < 1, bits > 16, or size * < 1. * @throws IllegalArgumentException if <code>transferType</code> is something - * other than {@link DataBuffer#TYPE_BYTE} or + * other than {@link DataBuffer#TYPE_BYTE} or * {@link DataBuffer#TYPE_USHORT}. */ - public IndexColorModel(int bits, int size, int[] cmap, int start, + public IndexColorModel(int bits, int size, int[] cmap, int start, boolean hasAlpha, int trans, int transferType) { - super(bits, - nArray(8, 4), // bits for each channel - ColorSpace.getInstance(ColorSpace.CS_sRGB), // sRGB - true, // has alpha - false, // not premultiplied - TRANSLUCENT, transferType); + super(bits, + nArray(8, 4), // bits for each channel + ColorSpace.getInstance(ColorSpace.CS_sRGB), // sRGB + true, // has alpha + false, // not premultiplied + TRANSLUCENT, transferType); if (transferType != DataBuffer.TYPE_BYTE && transferType != DataBuffer.TYPE_USHORT) throw new IllegalArgumentException(); @@ -363,7 +363,7 @@ public class IndexColorModel extends ColorModel rgb = createColorMap(bits, size); if (!hasAlpha) for (int i = 0; i < size; i++) - rgb[i] = cmap[i + start] | 0xff000000; + rgb[i] = cmap[i + start] | 0xff000000; else System.arraycopy(cmap, start, rgb, 0, size); @@ -383,14 +383,14 @@ public class IndexColorModel extends ColorModel * <br><br> * This constructor permits indicating which colormap entries are valid, * using the validBits argument. Each entry in cmap is valid if the - * corresponding bit in validBits is set. - * - * @param bits the number of bits needed to represent <code>size</code> + * corresponding bit in validBits is set. + * + * @param bits the number of bits needed to represent <code>size</code> * colors. * @param size the number of colors in the color map. * @param cmap packed color components. * @param start the offset of the first color component in <code>cmap</code>. - * @param transferType {@link DataBuffer#TYPE_BYTE} or + * @param transferType {@link DataBuffer#TYPE_BYTE} or * {@link DataBuffer#TYPE_USHORT}. * @param validBits a map of the valid entries in <code>cmap</code>. * @throws IllegalArgumentException if bits < 1, bits > 16, or size @@ -398,15 +398,15 @@ public class IndexColorModel extends ColorModel * @throws IllegalArgumentException if transferType is something other than * {@link DataBuffer#TYPE_BYTE} or {@link DataBuffer#TYPE_USHORT}. */ - public IndexColorModel(int bits, int size, int[] cmap, int start, + public IndexColorModel(int bits, int size, int[] cmap, int start, int transferType, BigInteger validBits) { super(bits, // total bits, sRGB, four channels - nArray(8, 4), // bits for each channel - ColorSpace.getInstance(ColorSpace.CS_sRGB), // sRGB - true, // has alpha - false, // not premultiplied - TRANSLUCENT, transferType); + nArray(8, 4), // bits for each channel + ColorSpace.getInstance(ColorSpace.CS_sRGB), // sRGB + true, // has alpha + false, // not premultiplied + TRANSLUCENT, transferType); if (transferType != DataBuffer.TYPE_BYTE && transferType != DataBuffer.TYPE_USHORT) throw new IllegalArgumentException(); @@ -422,7 +422,7 @@ public class IndexColorModel extends ColorModel rgb = createColorMap(bits, size); if (!hasAlpha) for (int i = 0; i < size; i++) - rgb[i] = cmap[i + start] | 0xff000000; + rgb[i] = cmap[i + start] | 0xff000000; else System.arraycopy(cmap, start, rgb, 0, size); } @@ -440,7 +440,7 @@ public class IndexColorModel extends ColorModel /** * Get the index of the transparent color in this color model. * - * @return The index of the color that is considered transparent, or -1 if + * @return The index of the color that is considered transparent, or -1 if * there is no transparent color. */ public final int getTransparentPixel() @@ -449,13 +449,13 @@ public class IndexColorModel extends ColorModel } /** - * Fills the supplied array with the red component of each color in the + * Fills the supplied array with the red component of each color in the * lookup table. * * @param r an array that is at least as large as {@link #getMapSize()}. * @throws NullPointerException if <code>r</code> is <code>null</code>. - * @throws ArrayIndexOutOfBoundsException if <code>r</code> has less - * than {@link #getMapSize()} elements. + * @throws ArrayIndexOutOfBoundsException if <code>r</code> has less + * than {@link #getMapSize()} elements. */ public final void getReds(byte[] r) { @@ -465,13 +465,13 @@ public class IndexColorModel extends ColorModel } /** - * Fills the supplied array with the green component of each color in the + * Fills the supplied array with the green component of each color in the * lookup table. * * @param g an array that is at least as large as {@link #getMapSize()}. * @throws NullPointerException if <code>g</code> is <code>null</code>. - * @throws ArrayIndexOutOfBoundsException if <code>g</code> has less - * than {@link #getMapSize()} elements. + * @throws ArrayIndexOutOfBoundsException if <code>g</code> has less + * than {@link #getMapSize()} elements. */ public final void getGreens(byte[] g) { @@ -481,13 +481,13 @@ public class IndexColorModel extends ColorModel } /** - * Fills the supplied array with the blue component of each color in the + * Fills the supplied array with the blue component of each color in the * lookup table. * * @param b an array that is at least as large as {@link #getMapSize()}. * @throws NullPointerException if <code>b</code> is <code>null</code>. - * @throws ArrayIndexOutOfBoundsException if <code>b</code> has less - * than {@link #getMapSize()} elements. + * @throws ArrayIndexOutOfBoundsException if <code>b</code> has less + * than {@link #getMapSize()} elements. */ public final void getBlues(byte[] b) { @@ -497,27 +497,27 @@ public class IndexColorModel extends ColorModel } /** - * Fills the supplied array with the alpha component of each color in the + * Fills the supplied array with the alpha component of each color in the * lookup table. If the model has a transparent pixel specified, the alpha * for that pixel will be 0. * * @param a an array that is at least as large as {@link #getMapSize()}. * @throws NullPointerException if <code>a</code> is <code>null</code>. - * @throws ArrayIndexOutOfBoundsException if <code>a</code> has less - * than {@link #getMapSize()} elements. + * @throws ArrayIndexOutOfBoundsException if <code>a</code> has less + * than {@link #getMapSize()} elements. */ public final void getAlphas(byte[] a) { int i; for (i = 0; i < map_size; i++) - if (i == trans) - a[i] = (byte) 0; - else + if (i == trans) + a[i] = (byte) 0; + else a[i] = (byte) ((0xFF000000 & rgb[i]) >> 24); } /** - * Returns the red component of the color in the lookup table for the + * Returns the red component of the color in the lookup table for the * given pixel value. * * @param pixel the pixel lookup value. @@ -529,12 +529,12 @@ public class IndexColorModel extends ColorModel { if (pixel < map_size) return (0x00FF0000 & rgb[pixel]) >> 16; - + return 0; } /** - * Returns the green component of the color in the lookup table for the + * Returns the green component of the color in the lookup table for the * given pixel value. * * @param pixel the pixel lookup value. @@ -546,12 +546,12 @@ public class IndexColorModel extends ColorModel { if (pixel < map_size) return (0x0000FF00 & rgb[pixel]) >> 8; - + return 0; } /** - * Returns the blue component of the color in the lookup table for the + * Returns the blue component of the color in the lookup table for the * given pixel value. * * @param pixel the pixel lookup value. @@ -563,12 +563,12 @@ public class IndexColorModel extends ColorModel { if (pixel < map_size) return 0x000000FF & rgb[pixel]; - + return 0; } /** - * Returns the alpha component of the color in the lookup table for the + * Returns the alpha component of the color in the lookup table for the * given pixel value. If no alpha channel was specified when the color model * was created, then 255 is returned for all pixels except the transparent * pixel (if one is defined - see {@link #getTransparentPixel()}) which @@ -576,7 +576,7 @@ public class IndexColorModel extends ColorModel * * @param pixel the pixel lookup value. * - * @return The alpha component of the color in the lookup table (in the + * @return The alpha component of the color in the lookup table (in the * range 0 to 255). * @throws ArrayIndexOutOfBoundsException if <code>pixel</code> is negative. */ @@ -587,7 +587,7 @@ public class IndexColorModel extends ColorModel /** * Get the RGB color value of the given pixel using the default - * RGB color model. + * RGB color model. * * @param pixel the pixel lookup value. * @return The RGB color value. @@ -597,13 +597,13 @@ public class IndexColorModel extends ColorModel { if (pixel >= 0 && pixel < map_size) return rgb[pixel]; - + return 0; } - + /** * Get the RGB color values of all pixels in the map using the default - * RGB color model. + * RGB color model. * * @param rgb The destination array. */ @@ -611,13 +611,13 @@ public class IndexColorModel extends ColorModel { System.arraycopy(this.rgb, 0, rgb, 0, map_size); } - - /** - * Return <code>true</code> if the lookup table contains valid data for + + /** + * Return <code>true</code> if the lookup table contains valid data for * <code>pixel</code>, and <code>false</code> otherwise. * * @param pixel the pixel value used to index the color lookup table. - * @return <code>true</code> if <code>pixel</code> is valid, + * @return <code>true</code> if <code>pixel</code> is valid, * <code>false</code> otherwise. */ public boolean isValid(int pixel) @@ -626,12 +626,12 @@ public class IndexColorModel extends ColorModel return validBits.testBit(pixel); return false; } - - /** - * Return <code>true</code> if all pixels are valid, <code>false</code> + + /** + * Return <code>true</code> if all pixels are valid, <code>false</code> * otherwise. * - * @return <code>true</code> if all pixels are valid, <code>false</code> + * @return <code>true</code> if all pixels are valid, <code>false</code> * otherwise. */ public boolean isValid() @@ -642,28 +642,28 @@ public class IndexColorModel extends ColorModel allbits = allbits.subtract(new BigInteger("1")); return allbits.equals(validBits); } - - /** - * Returns a binary value ({@link BigInteger}) where each bit represents an + + /** + * Returns a binary value ({@link BigInteger}) where each bit represents an * entry in the color lookup table. If the bit is on, the entry is valid. - * + * * @return The binary value. */ public BigInteger getValidPixels() { return validBits; } - + /** - * Construct a {@link BufferedImage} with rgb pixel values from a + * Construct a {@link BufferedImage} with rgb pixel values from a * {@link Raster}. - * + * * Constructs a new BufferedImage in which each pixel is an RGBA int from * a Raster with index-valued pixels. If this model has no alpha component * or transparent pixel, the type of the new BufferedImage is TYPE_INT_RGB. * Otherwise the type is TYPE_INT_ARGB. If forceARGB is true, the type is * forced to be TYPE_INT_ARGB no matter what. - * + * * @param raster The source of pixel values. * @param forceARGB True if type must be TYPE_INT_ARGB. * @return New BufferedImage with RBGA int pixel values. @@ -672,7 +672,7 @@ public class IndexColorModel extends ColorModel { int type = forceARGB ? BufferedImage.TYPE_INT_ARGB : ((opaque && trans == -1) ? BufferedImage.TYPE_INT_RGB : - BufferedImage.TYPE_INT_ARGB); + BufferedImage.TYPE_INT_ARGB); // FIXME: assuming that raster has only 1 band since pixels are supposed // to be int indexes. diff --git a/java/awt/image/Kernel.java b/java/awt/image/Kernel.java index 8361c0cf9..ae0ff1469 100644 --- a/java/awt/image/Kernel.java +++ b/java/awt/image/Kernel.java @@ -49,10 +49,10 @@ public class Kernel implements Cloneable { /** The kernel width. */ private final int width; - + /** The kernel height. */ private final int height; - + /** Internal storage for the kernel's values. */ private final float[] data; @@ -64,10 +64,10 @@ public class Kernel implements Cloneable * @param width the kernel width. * @param height the kernel height. * @param data the source data array (<code>null</code> not permitted). - * + * * @throws IllegalArgumentException if <code>data.length</code> is less than * <code>width * height</code>. - * @throws IllegalArgumentException if <code>width</code> or + * @throws IllegalArgumentException if <code>width</code> or * <code>height</code> is less than zero. * @throws NullPointerException if <code>data</code> is <code>null</code>. */ @@ -83,9 +83,9 @@ public class Kernel implements Cloneable } /** - * Returns the x-origin for the kernel, which is calculated as + * Returns the x-origin for the kernel, which is calculated as * <code>(width - 1) / 2</code>. - * + * * @return The x-origin for the kernel. */ public final int getXOrigin() @@ -96,7 +96,7 @@ public class Kernel implements Cloneable /** * Returns the y-origin for the kernel, which is calculated as * <code>(height - 1) / 2</code>. - * + * * @return The y-origin for the kernel. */ public final int getYOrigin() @@ -106,7 +106,7 @@ public class Kernel implements Cloneable /** * Returns the kernel width (as supplied to the constructor). - * + * * @return The kernel width. */ public final int getWidth() @@ -116,7 +116,7 @@ public class Kernel implements Cloneable /** * Returns the kernel height (as supplied to the constructor). - * + * * @return The kernel height. */ public final int getHeight() @@ -125,18 +125,18 @@ public class Kernel implements Cloneable } /** - * Returns an array containing a copy of the kernel data. If the + * Returns an array containing a copy of the kernel data. If the * <code>data</code> argument is non-<code>null</code>, the kernel values * are copied into it and then <code>data</code> is returned as the result. - * If the <code>data</code> argument is <code>null</code>, this method + * If the <code>data</code> argument is <code>null</code>, this method * allocates a new array then populates and returns it. * - * @param data an array to copy the return values into (if + * @param data an array to copy the return values into (if * <code>null</code>, a new array is allocated). - * + * * @return The array with copied values. - * - * @throws IllegalArgumentException if <code>data.length</code> is less than + * + * @throws IllegalArgumentException if <code>data.length</code> is less than * the kernel's <code>width * height</code>. */ public final float[] getKernelData(float[] data) @@ -154,7 +154,7 @@ public class Kernel implements Cloneable /** * Returns a clone of this kernel. - * + * * @return a clone of this Kernel. */ public Object clone() diff --git a/java/awt/image/LookupOp.java b/java/awt/image/LookupOp.java index 5b0cf7831..0bc79a00b 100644 --- a/java/awt/image/LookupOp.java +++ b/java/awt/image/LookupOp.java @@ -44,31 +44,31 @@ import java.awt.geom.Rectangle2D; /** * LookupOp is a filter that converts each pixel using a lookup table. - * + * * For filtering Rasters, the lookup table must have either one component * that is applied to all bands, or one component for every band in the * Rasters. - * + * * For BufferedImages, the lookup table may apply to both color and alpha * components. If the lookup table contains one component, or if there are * the same number of components as color components in the source, the table * applies to all color components. Otherwise the table applies to all * components including alpha. Alpha premultiplication is ignored during the * lookup filtering. - * + * * After filtering, if color conversion is necessary, the conversion happens, * taking alpha premultiplication into account. - * + * * @author jlquinn */ public class LookupOp implements BufferedImageOp, RasterOp { private LookupTable lut; private RenderingHints hints; - + /** * Construct a new LookupOp using the given LookupTable. - * + * * @param lookup LookupTable to use. * @param hints Rendering hints (can be null). */ @@ -77,12 +77,12 @@ public class LookupOp implements BufferedImageOp, RasterOp lut = lookup; this.hints = hints; } - + /** * Converts the source image using the lookup table specified in the * constructor. The resulting image is stored in the destination image if one - * is provided; otherwise a new BufferedImage is created and returned. - * + * is provided; otherwise a new BufferedImage is created and returned. + * * The source image cannot use an IndexColorModel, and the destination image * (if one is provided) must have the same size. * @@ -98,17 +98,17 @@ public class LookupOp implements BufferedImageOp, RasterOp { if (src.getColorModel() instanceof IndexColorModel) throw new IllegalArgumentException("LookupOp.filter: IndexColorModel " - + "not allowed"); - + + "not allowed"); + if (lut.getNumComponents() != 1 && lut.getNumComponents() != src.getColorModel().getNumComponents() && lut.getNumComponents() != src.getColorModel().getNumColorComponents()) throw new IllegalArgumentException("LookupOp.filter: Incompatible " + "lookup table and source image"); - + if (dst == null) dst = createCompatibleDestImage(src, null); - + else if (src.getHeight() != dst.getHeight() || src.getWidth() != dst.getWidth()) throw new IllegalArgumentException("Source and destination images are " + "different sizes."); @@ -131,16 +131,16 @@ public class LookupOp implements BufferedImageOp, RasterOp int[] dbuf = new int[src.getColorModel().getNumComponents()]; int tmpBands = src.getColorModel().getNumColorComponents(); int[] tmp = new int[tmpBands]; - + // Filter the pixels for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++) for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++) - { + { // Filter only color components, but also copy alpha sr.getPixel(x, y, dbuf); System.arraycopy(dbuf, 0, tmp, 0, tmpBands); dr.setPixel(x, y, lut.lookupPixel(tmp, dbuf)); - + /* The reference implementation does not use LookupTable.lookupPixel, * but rather it seems to copy the table into a native array. The * effect of this (a probable bug in their implementation) is that @@ -148,7 +148,7 @@ public class LookupOp implements BufferedImageOp, RasterOp * out of bounds exception, but will instead return random garbage. * A bad lookup on a ShortLookupTable, however, will throw an * exception. - * + * * Instead of mimicing this behaviour, we always throw an * ArrayOutofBoundsException by virtue of using * LookupTable.lookupPixle. @@ -159,16 +159,16 @@ public class LookupOp implements BufferedImageOp, RasterOp { // No alpha to ignore int[] dbuf = new int[src.getColorModel().getNumComponents()]; - + // Filter the pixels for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++) for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++) dr.setPixel(x, y, lut.lookupPixel(sr.getPixel(x, y, dbuf), dbuf)); } - + if (tgt != dst) new ColorConvertOp(hints).filter(tgt, dst); - + return dst; } @@ -184,13 +184,13 @@ public class LookupOp implements BufferedImageOp, RasterOp * @see java.awt.image.BufferedImageOp#createCompatibleDestImage(java.awt.image.BufferedImage, java.awt.image.ColorModel) */ public BufferedImage createCompatibleDestImage(BufferedImage src, - ColorModel dstCM) + ColorModel dstCM) { if (dstCM != null) return new BufferedImage(dstCM, src.getRaster().createCompatibleWritableRaster(), src.isAlphaPremultiplied(), null); - + // This is a strange exception, done for compatibility with the reference // (as demonstrated by a mauve testcase) int imgType = src.getType(); @@ -202,9 +202,9 @@ public class LookupOp implements BufferedImageOp, RasterOp /** * Returns the corresponding destination point for a given source point. - * + * * This Op will return the source point unchanged. - * + * * @param src The source point. * @param dst The destination point. */ @@ -219,7 +219,7 @@ public class LookupOp implements BufferedImageOp, RasterOp /** * Return the LookupTable for this op. - * + * * @return The lookup table. */ public final LookupTable getTable() @@ -237,11 +237,11 @@ public class LookupOp implements BufferedImageOp, RasterOp /** * Filter a raster through a lookup table. - * + * * Applies the lookup table for this Rasterop to each pixel of src and * puts the results in dest. If dest is null, a new Raster is created and * returned. - * + * * @param src The source raster. * @param dest The destination raster. * @return The WritableRaster with the filtered pixels. @@ -252,7 +252,7 @@ public class LookupOp implements BufferedImageOp, RasterOp */ public final WritableRaster filter(Raster src, WritableRaster dest) { - if (dest == null) + if (dest == null) // Allocate a raster if needed dest = createCompatibleDestRaster(src); else @@ -260,19 +260,19 @@ public class LookupOp implements BufferedImageOp, RasterOp throw new IllegalArgumentException("Source and destination rasters " + "are incompatible."); - if (lut.getNumComponents() != 1 + if (lut.getNumComponents() != 1 && lut.getNumComponents() != src.getNumBands()) throw new IllegalArgumentException("Lookup table is incompatible with " + "this raster."); - - // Allocate pixel storage. + + // Allocate pixel storage. int[] tmp = new int[src.getNumBands()]; - + // Filter the pixels for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++) for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++) dest.setPixel(x, y, lut.lookupPixel(src.getPixel(x, y, tmp), tmp)); - + /* The reference implementation does not use LookupTable.lookupPixel, * but rather it seems to copy the table into a native array. The * effect of this (a probable bug in their implementation) is that @@ -280,7 +280,7 @@ public class LookupOp implements BufferedImageOp, RasterOp * out of bounds exception, but will instead return random garbage. * A bad lookup on a ShortLookupTable, however, will throw an * exception. - * + * * Instead of mimicing this behaviour, we always throw an * ArrayOutofBoundsException by virtue of using * LookupTable.lookupPixle. diff --git a/java/awt/image/LookupTable.java b/java/awt/image/LookupTable.java index f814b8e09..d104b2fd5 100644 --- a/java/awt/image/LookupTable.java +++ b/java/awt/image/LookupTable.java @@ -61,7 +61,7 @@ public abstract class LookupTable * * If numComponents is 1, the same translation table is used for all pixel * components. - * + * * @param offset Offset to be subtracted. * @param numComponents Number of image components. * @exception IllegalArgumentException if offset < 0 or numComponents < 1. @@ -87,7 +87,7 @@ public abstract class LookupTable return offset; } - + /** * Return translated values for a pixel. * diff --git a/java/awt/image/MemoryImageSource.java b/java/awt/image/MemoryImageSource.java index 83a03ca44..e8780f6f5 100644 --- a/java/awt/image/MemoryImageSource.java +++ b/java/awt/image/MemoryImageSource.java @@ -77,7 +77,7 @@ public class MemoryImageSource implements ImageProducer /** * Constructs an ImageProducer from memory. - * + * * @param w the image width. * @param h the image height. * @param cm the color model. @@ -85,7 +85,7 @@ public class MemoryImageSource implements ImageProducer * @param off the offset to the first pixel in the array. * @param scan the number of array elements from a pixel on one row to the * corresponding pixel on the next row. - * @param props image properties (<code>null</code> permitted). + * @param props image properties (<code>null</code> permitted). */ public MemoryImageSource(int w, int h, ColorModel cm, byte[] pix, int off, int scan, Hashtable<?,?> props) @@ -119,7 +119,7 @@ public class MemoryImageSource implements ImageProducer /** * Constructs an ImageProducer from memory - * + * * @param w the image width. * @param h the image height. * @param cm the color model. @@ -127,7 +127,7 @@ public class MemoryImageSource implements ImageProducer * @param off the offset to the first pixel in the array. * @param scan the number of array elements from a pixel on one row to the * corresponding pixel on the next row. - * @param props image properties (<code>null</code> permitted). + * @param props image properties (<code>null</code> permitted). */ public MemoryImageSource(int w, int h, ColorModel cm, int[] pix, int off, int scan, Hashtable<?,?> props) @@ -144,14 +144,14 @@ public class MemoryImageSource implements ImageProducer /** * Constructs an ImageProducer from memory using the default RGB ColorModel. - * + * * @param w the image width. * @param h the image height. * @param pix the image data. * @param off the offset to the first pixel in the array. * @param scan the number of array elements from a pixel on one row to the * corresponding pixel on the next row. - * @param props image properties (<code>null</code> permitted). + * @param props image properties (<code>null</code> permitted). */ public MemoryImageSource(int w, int h, int[] pix, int off, int scan, @@ -162,13 +162,13 @@ public class MemoryImageSource implements ImageProducer /** * Constructs an ImageProducer from memory using the default RGB ColorModel. - * + * * @param w the image width. * @param h the image height. * @param pix the image data. * @param off the offset to the first pixel in the array. * @param scan the number of array elements from a pixel on one row to the - * corresponding pixel on the next row. + * corresponding pixel on the next row. */ public MemoryImageSource(int w, int h, int[] pix, int off, int scan) { @@ -178,7 +178,7 @@ public class MemoryImageSource implements ImageProducer /** * Used to register an <code>ImageConsumer</code> with this * <code>ImageProducer</code>. - * + * * @param ic the image consumer. */ public synchronized void addConsumer(ImageConsumer ic) @@ -192,7 +192,7 @@ public class MemoryImageSource implements ImageProducer /** * Used to determine if the given <code>ImageConsumer</code> is * already registered with this <code>ImageProducer</code>. - * + * * @param ic the image consumer. */ public synchronized boolean isConsumer(ImageConsumer ic) @@ -205,7 +205,7 @@ public class MemoryImageSource implements ImageProducer /** * Used to remove an <code>ImageConsumer</code> from the list of * registered consumers for this <code>ImageProducer</code>. - * + * * @param ic the image consumer. */ public synchronized void removeConsumer(ImageConsumer ic) @@ -227,12 +227,12 @@ public class MemoryImageSource implements ImageProducer Vector list = (Vector) consumers.clone(); for (int i = 0; i < list.size(); i++) { - ic = (ImageConsumer) list.elementAt(i); - sendPicture(ic); - if (animated) - ic.imageComplete(ImageConsumer.SINGLEFRAMEDONE); - else - ic.imageComplete(ImageConsumer.STATICIMAGEDONE); + ic = (ImageConsumer) list.elementAt(i); + sendPicture(ic); + if (animated) + ic.imageComplete(ImageConsumer.SINGLEFRAMEDONE); + else + ic.imageComplete(ImageConsumer.STATICIMAGEDONE); } } @@ -240,7 +240,7 @@ public class MemoryImageSource implements ImageProducer * Used to register an <code>ImageConsumer</code> with this * <code>ImageProducer</code> and then request that this producer * resend the image data in the order top-down, left-right. - * + * * @param ic the image consumer. */ public void requestTopDownLeftRightResend(ImageConsumer ic) @@ -278,14 +278,14 @@ public class MemoryImageSource implements ImageProducer { if (animated == true) { - ImageConsumer ic; - Vector list = (Vector) consumers.clone(); - for (int i = 0; i < list.size(); i++) - { - ic = (ImageConsumer) list.elementAt(i); - sendPicture(ic); - ic.imageComplete(ImageConsumer.SINGLEFRAME); - } + ImageConsumer ic; + Vector list = (Vector) consumers.clone(); + for (int i = 0; i < list.size(); i++) + { + ic = (ImageConsumer) list.elementAt(i); + sendPicture(ic); + ic.imageComplete(ImageConsumer.SINGLEFRAME); + } } } @@ -305,7 +305,7 @@ public class MemoryImageSource implements ImageProducer /** * Send an animation frame to the image consumers containing the specified * pixels unless setFullBufferUpdates is set. - * + * * @param x the x-coordinate. * @param y the y-coordinate. * @param w the width. @@ -315,38 +315,38 @@ public class MemoryImageSource implements ImageProducer { if (animated == true) { - if (fullbuffers) - newPixels(); - else - { - ImageConsumer ic; - Vector list = (Vector) consumers.clone(); - for (int i = 0; i < list.size(); i++) - { - ic = (ImageConsumer) list.elementAt(i); - ic.setHints(ImageConsumer.TOPDOWNLEFTRIGHT); - if (props != null) - ic.setProperties(props); - if (pixeli != null) - { - int[] pixelbuf = new int[w * h]; - for (int row = y; row < y + h; row++) - System.arraycopy(pixeli, row * scansize + x + offset, - pixelbuf, 0, w * h); - ic.setPixels(x, y, w, h, cm, pixelbuf, 0, w); - } - else - { - byte[] pixelbuf = new byte[w * h]; - for (int row = y; row < y + h; row++) - System.arraycopy(pixelb, row * scansize + x + offset, - pixelbuf, 0, w * h); - - ic.setPixels(x, y, w, h, cm, pixelbuf, 0, w); - } - ic.imageComplete(ImageConsumer.SINGLEFRAME); - } - } + if (fullbuffers) + newPixels(); + else + { + ImageConsumer ic; + Vector list = (Vector) consumers.clone(); + for (int i = 0; i < list.size(); i++) + { + ic = (ImageConsumer) list.elementAt(i); + ic.setHints(ImageConsumer.TOPDOWNLEFTRIGHT); + if (props != null) + ic.setProperties(props); + if (pixeli != null) + { + int[] pixelbuf = new int[w * h]; + for (int row = y; row < y + h; row++) + System.arraycopy(pixeli, row * scansize + x + offset, + pixelbuf, 0, w * h); + ic.setPixels(x, y, w, h, cm, pixelbuf, 0, w); + } + else + { + byte[] pixelbuf = new byte[w * h]; + for (int row = y; row < y + h; row++) + System.arraycopy(pixelb, row * scansize + x + offset, + pixelbuf, 0, w * h); + + ic.setPixels(x, y, w, h, cm, pixelbuf, 0, w); + } + ic.imageComplete(ImageConsumer.SINGLEFRAME); + } + } } } @@ -356,7 +356,7 @@ public class MemoryImageSource implements ImageProducer * * If framenotify is set then a notification is sent when the frame * is sent otherwise no status is sent. - * + * * @param x the x-coordinate. * @param y the y-coordinate. * @param w the width. @@ -368,38 +368,38 @@ public class MemoryImageSource implements ImageProducer { if (animated == true) { - if (fullbuffers) - newPixels(); - else - { - ImageConsumer ic; - Vector list = (Vector) consumers.clone(); - for (int i = 0; i < list.size(); i++) - { - ic = (ImageConsumer) list.elementAt(i); - ic.setHints(ImageConsumer.TOPDOWNLEFTRIGHT); - if (props != null) - ic.setProperties(props); - if (pixeli != null) - { - int[] pixelbuf = new int[w * h]; - for (int row = y; row < y + h; row++) - System.arraycopy(pixeli, row * scansize + x + offset, - pixelbuf, 0, w * h); - ic.setPixels(x, y, w, h, cm, pixelbuf, 0, w); - } - else - { - byte[] pixelbuf = new byte[w * h]; - for (int row = y; row < y + h; row++) - System.arraycopy(pixelb, row * scansize + x + offset, - pixelbuf, 0, w * h); - ic.setPixels(x, y, w, h, cm, pixelbuf, 0, w); - } - if (framenotify == true) - ic.imageComplete(ImageConsumer.SINGLEFRAME); - } - } + if (fullbuffers) + newPixels(); + else + { + ImageConsumer ic; + Vector list = (Vector) consumers.clone(); + for (int i = 0; i < list.size(); i++) + { + ic = (ImageConsumer) list.elementAt(i); + ic.setHints(ImageConsumer.TOPDOWNLEFTRIGHT); + if (props != null) + ic.setProperties(props); + if (pixeli != null) + { + int[] pixelbuf = new int[w * h]; + for (int row = y; row < y + h; row++) + System.arraycopy(pixeli, row * scansize + x + offset, + pixelbuf, 0, w * h); + ic.setPixels(x, y, w, h, cm, pixelbuf, 0, w); + } + else + { + byte[] pixelbuf = new byte[w * h]; + for (int row = y; row < y + h; row++) + System.arraycopy(pixelb, row * scansize + x + offset, + pixelbuf, 0, w * h); + ic.setPixels(x, y, w, h, cm, pixelbuf, 0, w); + } + if (framenotify == true) + ic.imageComplete(ImageConsumer.SINGLEFRAME); + } + } } } diff --git a/java/awt/image/MultiPixelPackedSampleModel.java b/java/awt/image/MultiPixelPackedSampleModel.java index 8db26b52d..592611cbb 100644 --- a/java/awt/image/MultiPixelPackedSampleModel.java +++ b/java/awt/image/MultiPixelPackedSampleModel.java @@ -65,14 +65,14 @@ public class MultiPixelPackedSampleModel extends SampleModel * <li>{@link DataBuffer#TYPE_USHORT};</li> * <li>{@link DataBuffer#TYPE_INT};</li> * </ul> - * + * * @param dataType the data type. * @param w the width (in pixels). * @param h the height (in pixels). * @param numberOfBits the number of bits per pixel (must be a power of 2). */ public MultiPixelPackedSampleModel(int dataType, int w, int h, - int numberOfBits) + int numberOfBits) { this(dataType, w, h, numberOfBits, 0, 0); } @@ -85,35 +85,35 @@ public class MultiPixelPackedSampleModel extends SampleModel * <li>{@link DataBuffer#TYPE_USHORT};</li> * <li>{@link DataBuffer#TYPE_INT};</li> * </ul> - * + * * @param dataType the data type. * @param w the width (in pixels). * @param h the height (in pixels). * @param numberOfBits the number of bits per pixel (must be a power of 2). - * @param scanlineStride the number of data elements from a pixel on one + * @param scanlineStride the number of data elements from a pixel on one * row to the corresponding pixel in the next row. * @param dataBitOffset the offset to the first data bit. */ public MultiPixelPackedSampleModel(int dataType, int w, int h, - int numberOfBits, int scanlineStride, - int dataBitOffset) + int numberOfBits, int scanlineStride, + int dataBitOffset) { super(dataType, w, h, 1); switch (dataType) { case DataBuffer.TYPE_BYTE: - elemBits = 8; - break; + elemBits = 8; + break; case DataBuffer.TYPE_USHORT: - elemBits = 16; - break; + elemBits = 16; + break; case DataBuffer.TYPE_INT: - elemBits = 32; - break; + elemBits = 32; + break; default: - throw new IllegalArgumentException("MultiPixelPackedSampleModel" - + " unsupported dataType"); + throw new IllegalArgumentException("MultiPixelPackedSampleModel" + + " unsupported dataType"); } this.dataBitOffset = dataBitOffset; @@ -121,13 +121,13 @@ public class MultiPixelPackedSampleModel extends SampleModel this.numberOfBits = numberOfBits; if (numberOfBits > elemBits) throw new RasterFormatException("MultiPixelPackedSampleModel pixel size" - + " larger than dataType"); + + " larger than dataType"); switch (numberOfBits) { case 1: case 2: case 4: case 8: case 16: case 32: break; default: - throw new RasterFormatException("MultiPixelPackedSampleModel pixel" - + " size not 2^n bits"); + throw new RasterFormatException("MultiPixelPackedSampleModel pixel" + + " size not 2^n bits"); } numElems = elemBits / numberOfBits; @@ -136,7 +136,7 @@ public class MultiPixelPackedSampleModel extends SampleModel scanlineStride = ((dataBitOffset + w * numberOfBits) - 1) / elemBits + 1; this.scanlineStride = scanlineStride; - + sampleSize = new int[1]; sampleSize[0] = numberOfBits; @@ -144,9 +144,9 @@ public class MultiPixelPackedSampleModel extends SampleModel bitOffsets = new int[numElems]; for (int i=0; i < numElems; i++) { - bitOffsets[numElems - i- 1] = numberOfBits * i; - bitMasks[numElems - i - 1] = ((1 << numberOfBits) - 1) << - bitOffsets[numElems - i - 1]; + bitOffsets[numElems - i- 1] = numberOfBits * i; + bitMasks[numElems - i - 1] = ((1 << numberOfBits) - 1) << + bitOffsets[numElems - i - 1]; } } @@ -154,10 +154,10 @@ public class MultiPixelPackedSampleModel extends SampleModel * Creates a new <code>MultiPixelPackedSample</code> model with the same * data type and bits per pixel as this model, but with the specified * dimensions. - * + * * @param w the width (in pixels). * @param h the height (in pixels). - * + * * @return The new sample model. */ public SampleModel createCompatibleSampleModel(int w, int h) @@ -172,7 +172,7 @@ public class MultiPixelPackedSampleModel extends SampleModel * Creates a DataBuffer for holding pixel data in the format and * layout described by this SampleModel. The returned buffer will * consist of one single bank. - * + * * @return A new data buffer. */ public DataBuffer createDataBuffer() @@ -186,7 +186,7 @@ public class MultiPixelPackedSampleModel extends SampleModel /** * Returns the number of data elements required to transfer a pixel in the * get/setDataElements() methods. - * + * * @return <code>1</code>. */ public int getNumDataElements() @@ -195,29 +195,29 @@ public class MultiPixelPackedSampleModel extends SampleModel } /** - * Returns an array containing the size (in bits) of the samples in each + * Returns an array containing the size (in bits) of the samples in each * band. The <code>MultiPixelPackedSampleModel</code> class supports only - * one band, so this method returns an array with length <code>1</code>. - * - * @return An array containing the size (in bits) of the samples in band zero. - * + * one band, so this method returns an array with length <code>1</code>. + * + * @return An array containing the size (in bits) of the samples in band zero. + * * @see #getSampleSize(int) */ public int[] getSampleSize() { return (int[]) sampleSize.clone(); } - + /** * Returns the size of the samples in the specified band. Note that the * <code>MultiPixelPackedSampleModel</code> supports only one band -- this * method ignored the <code>band</code> argument, and always returns the size * of band zero. - * + * * @param band the band (this parameter is ignored). - * + * * @return The size of the samples in band zero. - * + * * @see #getSampleSize() */ public int getSampleSize(int band) @@ -227,12 +227,12 @@ public class MultiPixelPackedSampleModel extends SampleModel /** * Returns the index in the data buffer that stores the pixel at (x, y). - * + * * @param x the x-coordinate. * @param y the y-coordinate. - * + * * @return The index in the data buffer that stores the pixel at (x, y). - * + * * @see #getBitOffset(int) */ public int getOffset(int x, int y) @@ -241,11 +241,11 @@ public class MultiPixelPackedSampleModel extends SampleModel } /** - * The bit offset (within an element in the data buffer) of the pixels with + * The bit offset (within an element in the data buffer) of the pixels with * the specified x-coordinate. - * + * * @param x the x-coordinate. - * + * * @return The bit offset. */ public int getBitOffset(int x) @@ -255,7 +255,7 @@ public class MultiPixelPackedSampleModel extends SampleModel /** * Returns the offset to the first data bit. - * + * * @return The offset to the first data bit. */ public int getDataBitOffset() @@ -266,7 +266,7 @@ public class MultiPixelPackedSampleModel extends SampleModel /** * Returns the number of data elements from a pixel in one row to the * corresponding pixel in the next row. - * + * * @return The scanline stride. */ public int getScanlineStride() @@ -276,14 +276,14 @@ public class MultiPixelPackedSampleModel extends SampleModel /** * Returns the number of bits per pixel. - * + * * @return The number of bits per pixel. */ public int getPixelBitStride() { return numberOfBits; } - + /** * Returns the transfer type, which is one of the following (depending on * the number of bits per sample for this model): @@ -292,7 +292,7 @@ public class MultiPixelPackedSampleModel extends SampleModel * <li>{@link DataBuffer#TYPE_USHORT};</li> * <li>{@link DataBuffer#TYPE_INT};</li> * </ul> - * + * * @return The transfer type. */ public int getTransferType() @@ -310,12 +310,12 @@ public class MultiPixelPackedSampleModel extends SampleModel * only supports a single band, this overridden implementation just returns * a new instance of <code>MultiPixelPackedSampleModel</code>, with the same * attributes as this instance. - * + * * @param bands the bands to include in the subset (this is ignored, except * that if it is non-<code>null</code> a check is made to ensure that the * array length is equal to <code>1</code>). - * - * @throws RasterFormatException if <code>bands</code> is not + * + * @throws RasterFormatException if <code>bands</code> is not * <code>null</code> and <code>bands.length != 1</code>. */ public SampleModel createSubsetSampleModel(int[] bands) @@ -323,7 +323,7 @@ public class MultiPixelPackedSampleModel extends SampleModel if (bands != null && bands.length != 1) throw new RasterFormatException("MultiPixelPackedSampleModel only" + " supports one band"); - return new MultiPixelPackedSampleModel(dataType, width, height, + return new MultiPixelPackedSampleModel(dataType, width, height, numberOfBits, scanlineStride, dataBitOffset); } @@ -334,15 +334,15 @@ public class MultiPixelPackedSampleModel extends SampleModel * array obj, since there is only one band. If obj is null, a new array of * getTransferType() is created. * - * @param x The x-coordinate of the pixel rectangle to store in + * @param x The x-coordinate of the pixel rectangle to store in * <code>obj</code>. - * @param y The y-coordinate of the pixel rectangle to store in + * @param y The y-coordinate of the pixel rectangle to store in * <code>obj</code>. - * @param obj The primitive array to store the pixels into or null to force + * @param obj The primitive array to store the pixels into or null to force * creation. * @param data The DataBuffer that is the source of the pixel data. * @return The primitive array containing the pixel data. - * @see java.awt.image.SampleModel#getDataElements(int, int, Object, + * @see java.awt.image.SampleModel#getDataElements(int, int, Object, * DataBuffer) */ public Object getDataElements(int x, int y, Object obj, DataBuffer data) @@ -351,17 +351,17 @@ public class MultiPixelPackedSampleModel extends SampleModel switch (getTransferType()) { case DataBuffer.TYPE_BYTE: - if (obj == null) + if (obj == null) obj = new byte[1]; ((byte[]) obj)[0] = (byte) pixel; return obj; case DataBuffer.TYPE_USHORT: - if (obj == null) + if (obj == null) obj = new short[1]; ((short[]) obj)[0] = (short) pixel; return obj; case DataBuffer.TYPE_INT: - if (obj == null) + if (obj == null) obj = new int[1]; ((int[]) obj)[0] = pixel; return obj; @@ -372,42 +372,42 @@ public class MultiPixelPackedSampleModel extends SampleModel } /** - * Returns an array (of length 1) containing the sample for the pixel at - * (x, y) in the specified data buffer. If <code>iArray</code> is not - * <code>null</code>, it will be populated with the sample value and - * returned as the result of this function (this avoids allocating a new + * Returns an array (of length 1) containing the sample for the pixel at + * (x, y) in the specified data buffer. If <code>iArray</code> is not + * <code>null</code>, it will be populated with the sample value and + * returned as the result of this function (this avoids allocating a new * array instance). - * + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param iArray an array to populate with the sample values and return as + * @param iArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return An array containing the pixel sample value. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public int[] getPixel(int x, int y, int[] iArray, DataBuffer data) { - if (iArray == null) + if (iArray == null) iArray = new int[1]; iArray[0] = getSample(x, y, 0, data); return iArray; } /** - * Returns the sample value for the pixel at (x, y) in the specified data + * Returns the sample value for the pixel at (x, y) in the specified data * buffer. - * + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The sample value. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public int getSample(int x, int y, int b, DataBuffer data) @@ -418,7 +418,7 @@ public class MultiPixelPackedSampleModel extends SampleModel int samples = data.getElem(offset); return (samples & bitMasks[pos]) >>> bitOffsets[pos]; } - + /** * Set the pixel at x, y to the value in the first element of the primitive * array obj. @@ -472,17 +472,17 @@ public class MultiPixelPackedSampleModel extends SampleModel } /** - * Sets the sample value for the pixel at (x, y) in the specified data - * buffer to the specified value. - * + * Sets the sample value for the pixel at (x, y) in the specified data + * buffer to the specified value. + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. * @param iArray the sample value (<code>null</code> not permitted). * @param data the data buffer (<code>null</code> not permitted). - * - * @throws NullPointerException if either <code>iArray</code> or + * + * @throws NullPointerException if either <code>iArray</code> or * <code>data</code> is <code>null</code>. - * + * * @see #setSample(int, int, int, int, DataBuffer) */ public void setPixel(int x, int y, int[] iArray, DataBuffer data) @@ -491,16 +491,16 @@ public class MultiPixelPackedSampleModel extends SampleModel } /** - * Sets the sample value for a band for the pixel at (x, y) in the - * specified data buffer. - * + * Sets the sample value for a band for the pixel at (x, y) in the + * specified data buffer. + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). * @param s the sample value. * @param data the data buffer (<code>null</code> not permitted). - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public void setSample(int x, int y, int b, int s, DataBuffer data) @@ -516,13 +516,13 @@ public class MultiPixelPackedSampleModel extends SampleModel sample |= s; data.setElem(offset, sample); } - + /** - * Tests this sample model for equality with an arbitrary object. This + * Tests this sample model for equality with an arbitrary object. This * method returns <code>true</code> if and only if: * <ul> * <li><code>obj</code> is not <code>null</code>; - * <li><code>obj</code> is an instance of + * <li><code>obj</code> is an instance of * <code>MultiPixelPackedSampleModel</code>; * <li>both models have the same: * <ul> @@ -535,17 +535,17 @@ public class MultiPixelPackedSampleModel extends SampleModel * </ul> * </li> * </ul> - * + * * @param obj the object (<code>null</code> permitted) - * + * * @return <code>true</code> if this model is equal to <code>obj</code>, and * <code>false</code> otherwise. */ - public boolean equals(Object obj) + public boolean equals(Object obj) { - if (this == obj) + if (this == obj) return true; - if (! (obj instanceof MultiPixelPackedSampleModel)) + if (! (obj instanceof MultiPixelPackedSampleModel)) return false; MultiPixelPackedSampleModel that = (MultiPixelPackedSampleModel) obj; if (this.dataType != that.dataType) @@ -562,10 +562,10 @@ public class MultiPixelPackedSampleModel extends SampleModel return false; return true; } - + /** * Returns a hash code for this <code>MultiPixelPackedSampleModel</code>. - * + * * @return A hash code. */ public int hashCode() @@ -580,7 +580,7 @@ public class MultiPixelPackedSampleModel extends SampleModel result = 37 * result + dataBitOffset; return result; } - + /** * Creates a String with some information about this SampleModel. * @return A String describing this SampleModel. @@ -596,7 +596,7 @@ public class MultiPixelPackedSampleModel extends SampleModel { result.append(", mask[").append(i).append("]=0x").append(Integer.toHexString(bitMasks[i])); } - + result.append("]"); return result.toString(); } diff --git a/java/awt/image/PackedColorModel.java b/java/awt/image/PackedColorModel.java index b60230fa7..a89d73b8c 100644 --- a/java/awt/image/PackedColorModel.java +++ b/java/awt/image/PackedColorModel.java @@ -48,44 +48,44 @@ import java.awt.color.ColorSpace; public abstract class PackedColorModel extends ColorModel { private int masks[]; - + /* Package accessibility, the DirectColorModel needs this array */ int shifts[]; public PackedColorModel(ColorSpace cspace, int pixelBits, - int[] colorMaskArray, int alphaMask, - boolean isAlphaPremultiplied, - int transparency, - int transferType) + int[] colorMaskArray, int alphaMask, + boolean isAlphaPremultiplied, + int transparency, + int transferType) { super(pixelBits, calcBitsPerComponent(colorMaskArray, alphaMask), - cspace, (alphaMask != 0), isAlphaPremultiplied, transparency, - transferType); + cspace, (alphaMask != 0), isAlphaPremultiplied, transparency, + transferType); initMasks(colorMaskArray, alphaMask); if ((pixelBits<1) || (pixelBits>32)) { throw new IllegalArgumentException("pixels per bits must be " + - "in the range [1, 32]"); + "in the range [1, 32]"); } } - + private static int[] calcBitsPerComponent(int[] colorMaskArray, - int alphaMask) + int alphaMask) { int numComponents = colorMaskArray.length; if (alphaMask != 0) numComponents++; - + int[] bitsPerComponent = new int[numComponents]; - + BitMaskExtent extent = new BitMaskExtent(); for (int b=0; b<colorMaskArray.length; b++) { - extent.setMask(colorMaskArray[b]); - bitsPerComponent[b] = extent.bitWidth; + extent.setMask(colorMaskArray[b]); + bitsPerComponent[b] = extent.bitWidth; } if (alphaMask != 0) { - extent.setMask(alphaMask); - bitsPerComponent[numComponents-1] = extent.bitWidth; + extent.setMask(alphaMask); + bitsPerComponent[numComponents-1] = extent.bitWidth; } return bitsPerComponent; } @@ -96,38 +96,38 @@ public abstract class PackedColorModel extends ColorModel int numComponents = colorMaskArray.length; if (alphaMask == 0) { - masks = colorMaskArray; + masks = colorMaskArray; } else { - masks = new int[numComponents+1]; - System.arraycopy(colorMaskArray, 0, - masks, 0, - numComponents); - masks[numComponents++] = alphaMask; + masks = new int[numComponents+1]; + System.arraycopy(colorMaskArray, 0, + masks, 0, + numComponents); + masks[numComponents++] = alphaMask; } - + shifts = new int[numComponents]; - + // Bit field handling have been moved to a utility class BitMaskExtent extent = new BitMaskExtent(); for (int b=0; b<numComponents; b++) { - extent.setMask(masks[b]); - shifts[b] = extent.leastSignificantBit; + extent.setMask(masks[b]); + shifts[b] = extent.leastSignificantBit; } } - + public PackedColorModel(ColorSpace cspace, int pixelBits, - int rmask, int gmask, int bmask, - int amask, boolean isAlphaPremultiplied, - int transparency, - int transferType) + int rmask, int gmask, int bmask, + int amask, boolean isAlphaPremultiplied, + int transparency, + int transferType) { this(cspace, pixelBits, makeColorMaskArray(rmask, gmask, bmask), - amask, isAlphaPremultiplied, transparency, transferType); + amask, isAlphaPremultiplied, transparency, transferType); } - + /* TODO: If there is a alpha mask, it is inefficient to create a color mask array that will be discarded when the alpha mask is appended. We should probably create a private constructor that @@ -138,13 +138,13 @@ public abstract class PackedColorModel extends ColorModel { int[] colorMaskArray = { rmask, gmask, bmask }; return colorMaskArray; - } + } public final int getMask(int index) { return masks[index]; } - + public final int[] getMasks() { return masks; @@ -154,12 +154,12 @@ public abstract class PackedColorModel extends ColorModel { return new SinglePixelPackedSampleModel(transferType, w, h, masks); } - + public boolean isCompatibleSampleModel(SampleModel sm) { if (!super.isCompatibleSampleModel(sm)) return false; if (!(sm instanceof SinglePixelPackedSampleModel)) return false; - + SinglePixelPackedSampleModel sppsm = (SinglePixelPackedSampleModel) sm; return java.util.Arrays.equals(sppsm.getBitMasks(), masks); @@ -167,7 +167,7 @@ public abstract class PackedColorModel extends ColorModel public WritableRaster getAlphaRaster(WritableRaster raster) { if (!hasAlpha()) return null; - + SampleModel sm = raster.getSampleModel(); int[] alphaBand = { sm.getNumBands() - 1 }; SampleModel alphaModel = sm.createSubsetSampleModel(alphaBand); @@ -175,14 +175,14 @@ public abstract class PackedColorModel extends ColorModel Point origin = new Point(0, 0); return Raster.createWritableRaster(alphaModel, buffer, origin); } - + public boolean equals(Object obj) { if (!super.equals(obj)) return false; if (!(obj instanceof PackedColorModel)) return false; - + PackedColorModel other = (PackedColorModel) obj; - + return java.util.Arrays.equals(masks, other.masks); } } diff --git a/java/awt/image/PixelGrabber.java b/java/awt/image/PixelGrabber.java index fc5e0efc0..b83fab571 100644 --- a/java/awt/image/PixelGrabber.java +++ b/java/awt/image/PixelGrabber.java @@ -95,7 +95,7 @@ public class PixelGrabber implements ImageConsumer * pixels in the grab rectangle */ public PixelGrabber(Image img, int x, int y, int w, int h, - int pix[], int off, int scansize) + int pix[], int off, int scansize) { this (img.getSource(), x, y, w, h, pix, off, scansize); } @@ -130,7 +130,7 @@ public class PixelGrabber implements ImageConsumer * pixels in the grab rectangle */ public PixelGrabber(ImageProducer ip, int x, int y, int w, int h, - int pix[], int off, int scansize) + int pix[], int off, int scansize) { this.ip = ip; this.x = x; @@ -175,9 +175,9 @@ public class PixelGrabber implements ImageConsumer * region's pixel data to RGB */ public PixelGrabber(Image img, - int x, int y, - int w, int h, - boolean forceRGB) + int x, int y, + int w, int h, + boolean forceRGB) { this.ip = img.getSource(); @@ -192,8 +192,8 @@ public class PixelGrabber implements ImageConsumer // initialization until setDimensions is called back by ip. if (width >= 0 && height >= 0) { - int_pixel_buffer = new int[width * height]; - byte_pixel_buffer = new byte[width * height]; + int_pixel_buffer = new int[width * height]; + byte_pixel_buffer = new byte[width * height]; } this.forceRGB = forceRGB; } @@ -209,11 +209,11 @@ public class PixelGrabber implements ImageConsumer // Make sure we're not already grabbing. if (grabbing == false) { - grabbing = true; - grabberThread = new Thread () - { - public void run () - { + grabbing = true; + grabberThread = new Thread () + { + public void run () + { try { ip.startProduction (PixelGrabber.this); @@ -222,9 +222,9 @@ public class PixelGrabber implements ImageConsumer { imageComplete(ImageConsumer.IMAGEABORTED); } - } - }; - grabberThread.start (); + } + }; + grabberThread.start (); } } @@ -235,12 +235,12 @@ public class PixelGrabber implements ImageConsumer { if (grabbing) { - // Interrupt the grabbing thread. + // Interrupt the grabbing thread. Thread moribund = grabberThread; grabberThread = null; moribund.interrupt(); - imageComplete (ImageConsumer.IMAGEABORTED); + imageComplete (ImageConsumer.IMAGEABORTED); } } @@ -282,7 +282,7 @@ public class PixelGrabber implements ImageConsumer { if (ms < 0) return ((observerStatus & (ImageObserver.FRAMEBITS - | ImageObserver.ALLBITS)) != 0); + | ImageObserver.ALLBITS)) != 0); // Spawn a new ImageProducer thread to send us the image data via // our ImageConsumer methods. @@ -290,16 +290,16 @@ public class PixelGrabber implements ImageConsumer if (ms > 0) { - long stop_time = System.currentTimeMillis() + ms; - long time_remaining; - while (grabbing) - { - time_remaining = stop_time - System.currentTimeMillis(); - if (time_remaining <= 0) - break; - wait (time_remaining); - } - abortGrabbing (); + long stop_time = System.currentTimeMillis() + ms; + long time_remaining; + while (grabbing) + { + time_remaining = stop_time - System.currentTimeMillis(); + if (time_remaining <= 0) + break; + wait (time_remaining); + } + abortGrabbing (); } else wait (); @@ -310,7 +310,7 @@ public class PixelGrabber implements ImageConsumer return setObserverStatus (); return ((observerStatus & (ImageObserver.FRAMEBITS - | ImageObserver.ALLBITS)) != 0); + | ImageObserver.ALLBITS)) != 0); } // Set observer status flags based on the current consumer status @@ -328,14 +328,14 @@ public class PixelGrabber implements ImageConsumer if ((consumerStatus & STATICIMAGEDONE) != 0) { - observerStatus |= ImageObserver.ALLBITS; - retval = true; + observerStatus |= ImageObserver.ALLBITS; + retval = true; } if ((consumerStatus & SINGLEFRAMEDONE) != 0) { - observerStatus |= ImageObserver.FRAMEBITS; - retval = true; + observerStatus |= ImageObserver.FRAMEBITS; + retval = true; } return retval; @@ -402,7 +402,7 @@ public class PixelGrabber implements ImageConsumer * ImageConsumer methods should be called by code that instantiates * a PixelGrabber. They are only made public so they can be called * by the PixelGrabber's ImageProducer. - * + * * @param width the width of the image * @param height the height of the image */ @@ -472,7 +472,7 @@ public class PixelGrabber implements ImageConsumer * bit mask of hints from any of <code>RANDOMPIXELORDER</code>, * <code>TOPDOWNLEFTRIGHT</code>, <code>COMPLETESCANLINES</code>, * <code>SINGLEPASS</code>, <code>SINGLEFRAME</code>. - * + * * setHints is an ImageConsumer method. None of PixelGrabber's * ImageConsumer methods should be called by code that instantiates * a PixelGrabber. They are only made public so they can be called @@ -505,9 +505,9 @@ public class PixelGrabber implements ImageConsumer * @param offset offset into pixels array * @param scansize width of one row in the pixel block */ - public synchronized void setPixels(int x, int y, int w, int h, - ColorModel model, byte[] pixels, - int offset, int scansize) + public synchronized void setPixels(int x, int y, int w, int h, + ColorModel model, byte[] pixels, + int offset, int scansize) { ColorModel currentModel; if (model != null) @@ -517,31 +517,31 @@ public class PixelGrabber implements ImageConsumer for(int yp = y; yp < (y + h); yp++) { - for(int xp = x; xp < (x + w); xp++) - { - // Check if the coordinates (xp, yp) are within the - // pixel block that we are grabbing. - if(xp >= this.x - && yp >= this.y - && xp < (this.x + this.width) - && yp < (this.y + this.height)) - { - int i = (yp - this.y) * this.scansize + (xp - this.x) + this.offset; - int p = (yp - y) * scansize + (xp - x) + offset; - if (forceRGB) - { - ints_delivered = true; - - int_pixel_buffer[i] = currentModel.getRGB (pixels[p] & 0xFF); - } - else - { - bytes_delivered = true; - - byte_pixel_buffer[i] = pixels[p]; - } - } - } + for(int xp = x; xp < (x + w); xp++) + { + // Check if the coordinates (xp, yp) are within the + // pixel block that we are grabbing. + if(xp >= this.x + && yp >= this.y + && xp < (this.x + this.width) + && yp < (this.y + this.height)) + { + int i = (yp - this.y) * this.scansize + (xp - this.x) + this.offset; + int p = (yp - y) * scansize + (xp - x) + offset; + if (forceRGB) + { + ints_delivered = true; + + int_pixel_buffer[i] = currentModel.getRGB (pixels[p] & 0xFF); + } + else + { + bytes_delivered = true; + + byte_pixel_buffer[i] = pixels[p]; + } + } + } } } @@ -565,9 +565,9 @@ public class PixelGrabber implements ImageConsumer * @param offset offset into pixels array * @param scansize width of one row in the pixel block */ - public synchronized void setPixels(int x, int y, int w, int h, - ColorModel model, int[] pixels, - int offset, int scansize) + public synchronized void setPixels(int x, int y, int w, int h, + ColorModel model, int[] pixels, + int offset, int scansize) { ColorModel currentModel; if (model != null) @@ -579,23 +579,23 @@ public class PixelGrabber implements ImageConsumer for(int yp = y; yp < (y + h); yp++) { - for(int xp = x; xp < (x + w); xp++) - { - // Check if the coordinates (xp, yp) are within the - // pixel block that we are grabbing. - if(xp >= this.x - && yp >= this.y - && xp < (this.x + this.width) - && yp < (this.y + this.height)) - { - int i = (yp - this.y) * this.scansize + (xp - this.x) + this.offset; - int p = (yp - y) * scansize + (xp - x) + offset; - if (forceRGB) - int_pixel_buffer[i] = currentModel.getRGB (pixels[p]); - else - int_pixel_buffer[i] = pixels[p]; - } - } + for(int xp = x; xp < (x + w); xp++) + { + // Check if the coordinates (xp, yp) are within the + // pixel block that we are grabbing. + if(xp >= this.x + && yp >= this.y + && xp < (this.x + this.width) + && yp < (this.y + this.height)) + { + int i = (yp - this.y) * this.scansize + (xp - this.x) + this.offset; + int p = (yp - y) * scansize + (xp - x) + offset; + if (forceRGB) + int_pixel_buffer[i] = currentModel.getRGB (pixels[p]); + else + int_pixel_buffer[i] = pixels[p]; + } + } } } diff --git a/java/awt/image/PixelInterleavedSampleModel.java b/java/awt/image/PixelInterleavedSampleModel.java index 3a0d4152c..13134b413 100644 --- a/java/awt/image/PixelInterleavedSampleModel.java +++ b/java/awt/image/PixelInterleavedSampleModel.java @@ -58,7 +58,7 @@ public class PixelInterleavedSampleModel bandOffsets); } - + /** * Creates a new <code>SampleModel</code> that is like this one, but * uses the specified width and height. diff --git a/java/awt/image/RGBImageFilter.java b/java/awt/image/RGBImageFilter.java index 3cd14239c..1354c3a80 100644 --- a/java/awt/image/RGBImageFilter.java +++ b/java/awt/image/RGBImageFilter.java @@ -39,7 +39,7 @@ exception statement from your version. */ package java.awt.image; /** - * A filter designed to filter images in the default RGBColorModel regardless of + * A filter designed to filter images in the default RGBColorModel regardless of * the ImageProducer's ColorModel. * * @author Mark Benvenuto (mcb54@columbia.edu) @@ -49,7 +49,7 @@ public abstract class RGBImageFilter extends ImageFilter protected ColorModel origmodel; protected ColorModel newmodel; - + /** * Specifies whether to apply the filter to the index entries of the * IndexColorModel. Subclasses should set this to true if the filter @@ -60,7 +60,7 @@ public abstract class RGBImageFilter extends ImageFilter /** * Construct new RGBImageFilter. */ - public RGBImageFilter() + public RGBImageFilter() { } @@ -75,7 +75,7 @@ public abstract class RGBImageFilter extends ImageFilter * * @see ColorModel */ - public void setColorModel(ColorModel model) + public void setColorModel(ColorModel model) { if ((model instanceof IndexColorModel) && canFilterIndexColorModel) { @@ -90,10 +90,10 @@ public abstract class RGBImageFilter extends ImageFilter } /** - * Registers a new ColorModel to subsitute for the old ColorModel when - * setPixels encounters the a pixel with the old ColorModel. The pixel + * Registers a new ColorModel to subsitute for the old ColorModel when + * setPixels encounters the a pixel with the old ColorModel. The pixel * remains unchanged except for a new ColorModel. - * + * * @param oldcm the old ColorModel * @param newcm the new ColorModel */ @@ -109,7 +109,7 @@ public abstract class RGBImageFilter extends ImageFilter * * @param icm an IndexColorModel to filter */ - public IndexColorModel filterIndexColorModel(IndexColorModel icm) + public IndexColorModel filterIndexColorModel(IndexColorModel icm) { int len = icm.getMapSize(); byte[] reds = new byte[len]; @@ -175,8 +175,8 @@ public abstract class RGBImageFilter extends ImageFilter } /** - * If the ColorModel is the same ColorModel which as already converted - * then it converts it the converted ColorModel. Otherwise it passes the + * If the ColorModel is the same ColorModel which as already converted + * then it converts it the converted ColorModel. Otherwise it passes the * array of pixels through filterRGBpixels. * * @param x the x coordinate of the rectangle @@ -217,7 +217,7 @@ public abstract class RGBImageFilter extends ImageFilter /** * This function delivers a rectangle of pixels where any * pixel(m,n) is stored in the array as an <code>int</code> at - * index (n * scansize + m + offset). + * index (n * scansize + m + offset). * * @param x the x coordinate of the rectangle * @param y the y coordinate of the rectangle diff --git a/java/awt/image/Raster.java b/java/awt/image/Raster.java index 615155fb3..6d99c3683 100644 --- a/java/awt/image/Raster.java +++ b/java/awt/image/Raster.java @@ -46,44 +46,44 @@ import java.awt.Rectangle; * A rectangular collection of pixels composed from a {@link DataBuffer} which * stores the pixel values, and a {@link SampleModel} which is used to retrieve * the pixel values. - * + * * @author Rolf W. Rasmussen (rolfwr@ii.uib.no) */ public class Raster { /** The sample model used to access the pixel values. */ protected SampleModel sampleModel; - + /** The data buffer used to store the pixel values. */ protected DataBuffer dataBuffer; - + /** The x-coordinate of the top left corner of the raster. */ protected int minX; - + /** The y-coordinate of the top left corner of the raster. */ protected int minY; - + /** The width of the raster. */ protected int width; - + /** The height of the raster. */ protected int height; - + protected int sampleModelTranslateX; - + protected int sampleModelTranslateY; - + /** The number of bands. */ protected int numBands; - + protected int numDataElements; - + /** The raster's parent. */ protected Raster parent; - + /** * Creates a new raster. - * + * * @param sampleModel the sample model. * @param origin the origin. */ @@ -91,10 +91,10 @@ public class Raster { this(sampleModel, sampleModel.createDataBuffer(), origin); } - + /** * Creates a new raster. - * + * * @param sampleModel the sample model. * @param dataBuffer the data buffer. * @param origin the origin. @@ -108,7 +108,7 @@ public class Raster /** * Creates a new raster. - * + * * @param sampleModel the sample model. * @param dataBuffer the data buffer. * @param aRegion the raster's bounds. @@ -124,7 +124,7 @@ public class Raster this.minY = aRegion.y; this.width = aRegion.width; this.height = aRegion.height; - + // If sampleModelTranslate is null, use (0,0). Methods such as // Raster.createRaster are specified to allow for a null argument. if (sampleModelTranslate != null) @@ -137,16 +137,16 @@ public class Raster this.numDataElements = sampleModel.getNumDataElements(); this.parent = parent; } - + /** * Creates an interleaved raster using the specified data type. - * + * * @param dataType the data type. * @param w the width. * @param h the height. * @param bands the number of bands. * @param location - * + * * @return The new raster. */ public static WritableRaster createInterleavedRaster(int dataType, @@ -154,9 +154,9 @@ public class Raster { int[] bandOffsets = new int[bands]; // TODO: Maybe not generate this every time. - for (int b = 0; b < bands; b++) + for (int b = 0; b < bands; b++) bandOffsets[b] = b; - + int scanlineStride = bands * w; return createInterleavedRaster(dataType, w, h, scanlineStride, bands, bandOffsets, location); @@ -164,20 +164,20 @@ public class Raster /** * Creates an interleaved raster. - * + * * @param dataType the data type. * @param w the width. * @param h the height. - * @param scanlineStride the number of data elements from a sample on one + * @param scanlineStride the number of data elements from a sample on one * row to the corresponding sample on the next row. * @param pixelStride the number of elements from a sample in one pixel to * the corresponding sample in the next pixel. * @param bandOffsets the band offsets. * @param location - * + * * @return The new raster. */ - public static WritableRaster createInterleavedRaster(int dataType, + public static WritableRaster createInterleavedRaster(int dataType, int w, int h, int scanlineStride, int pixelStride, int[] bandOffsets, Point location) { @@ -188,16 +188,16 @@ public class Raster /** * Creates a new banded raster. - * + * * @param dataType the data type. * @param w the width. * @param h the height. * @param bands the number of bands. - * @param location - * + * @param location + * * @return The new raster. */ - public static WritableRaster createBandedRaster(int dataType, int w, int h, + public static WritableRaster createBandedRaster(int dataType, int w, int h, int bands, Point location) { SampleModel sm = new BandedSampleModel(dataType, w, h, bands); @@ -206,16 +206,16 @@ public class Raster /** * Creates a new banded raster. - * + * * @param dataType the data type. * @param w the width. * @param h the height. - * @param scanlineStride the number of data elements from a sample on one + * @param scanlineStride the number of data elements from a sample on one * row to the corresponding sample on the next row. * @param bankIndices the index for each bank. * @param bandOffsets the offset for each band. * @param location - * + * * @return The new raster. */ public static WritableRaster createBandedRaster(int dataType, int w, int h, @@ -225,16 +225,16 @@ public class Raster bankIndices, bandOffsets); return createWritableRaster(sm, location); } - + /** * Creates a new packed raster. - * + * * @param dataType the data type. * @param w the width. * @param h the height. * @param bandMasks the bit mask for each band. - * @param location - * + * @param location + * * @return The new raster. */ public static WritableRaster createPackedRaster(int dataType, int w, int h, @@ -247,14 +247,14 @@ public class Raster /** * Creates a new raster. - * + * * @param dataType the data type. * @param w the width. * @param h the height. * @param bands the number of bands. * @param bitsPerBand the number of bits per band. * @param location - * + * * @return The new raster. */ public static WritableRaster createPackedRaster(int dataType, @@ -278,7 +278,7 @@ public class Raster bandMasks[i] = mask; mask <<= bitsPerBand; } - + sm = new SinglePixelPackedSampleModel(dataType, w, h, bandMasks); } return createWritableRaster(sm, location); @@ -286,21 +286,21 @@ public class Raster /** * Creates a new interleaved raster. - * + * * @param dataBuffer the data buffer. * @param w the width. * @param h the height. - * @param scanlineStride the number of data elements from a sample on one + * @param scanlineStride the number of data elements from a sample on one * row to the corresponding sample on the next row. * @param pixelStride the number of elements from a sample in one pixel to * the corresponding sample in the next pixel. * @param bandOffsets the offset for each band. * @param location - * + * * @return The new raster. */ - public static WritableRaster createInterleavedRaster(DataBuffer dataBuffer, - int w, int h, int scanlineStride, int pixelStride, int[] bandOffsets, + public static WritableRaster createInterleavedRaster(DataBuffer dataBuffer, + int w, int h, int scanlineStride, int pixelStride, int[] bandOffsets, Point location) { SampleModel sm = new ComponentSampleModel(dataBuffer.getDataType(), @@ -310,16 +310,16 @@ public class Raster /** * Creates a new banded raster. - * + * * @param dataBuffer the data buffer. * @param w the width. * @param h the height. - * @param scanlineStride the number of data elements from a sample on one + * @param scanlineStride the number of data elements from a sample on one * row to the corresponding sample on the next row. * @param bankIndices the index for each bank. * @param bandOffsets the band offsets. * @param location - * + * * @return The new raster. */ public static WritableRaster createBandedRaster(DataBuffer dataBuffer, @@ -330,18 +330,18 @@ public class Raster w, h, scanlineStride, bankIndices, bandOffsets); return createWritableRaster(sm, dataBuffer, location); } - + /** * Creates a new packed raster. - * + * * @param dataBuffer the data buffer. * @param w the width. * @param h the height. - * @param scanlineStride the number of data elements from a sample on one + * @param scanlineStride the number of data elements from a sample on one * row to the corresponding sample on the next row. * @param bandMasks the bit mask for each band. * @param location - * + * * @return The new raster. */ public static WritableRaster createPackedRaster(DataBuffer dataBuffer, @@ -351,16 +351,16 @@ public class Raster w, h, scanlineStride, bandMasks); return createWritableRaster(sm, dataBuffer, location); } - + /** * Creates a new packed raster. - * + * * @param dataBuffer the data buffer. * @param w the width. * @param h the height. * @param bitsPerPixel the number of bits per pixel. * @param location - * + * * @return The new raster. */ public static WritableRaster createPackedRaster(DataBuffer dataBuffer, @@ -370,14 +370,14 @@ public class Raster w, h, bitsPerPixel); return createWritableRaster(sm, dataBuffer, location); } - + /** * Creates a new raster. - * + * * @param sm the sample model. * @param db the data buffer. * @param location - * + * * @return The new raster. */ public static Raster createRaster(SampleModel sm, DataBuffer db, @@ -388,10 +388,10 @@ public class Raster /** * Creates a new writable raster. - * + * * @param sm the sample model. * @param location - * + * * @return The new writable raster. */ public static WritableRaster createWritableRaster(SampleModel sm, @@ -402,11 +402,11 @@ public class Raster /** * Creates a new writable raster. - * + * * @param sm the sample model. * @param db the data buffer. - * @param location - * + * @param location + * * @return The new writable raster. */ public static WritableRaster createWritableRaster(SampleModel sm, @@ -417,7 +417,7 @@ public class Raster /** * Returns the raster's parent. - * + * * @return The raster's parent. */ public Raster getParent() @@ -427,7 +427,7 @@ public class Raster /** * Returns the x-translation. - * + * * @return The x-translation. */ public final int getSampleModelTranslateX() @@ -437,7 +437,7 @@ public class Raster /** * Returns the y-translation. - * + * * @return The y-translation. */ public final int getSampleModelTranslateY() @@ -447,7 +447,7 @@ public class Raster /** * Creates a new writable raster that is compatible with this raster. - * + * * @return A new writable raster. */ public WritableRaster createCompatibleWritableRaster() @@ -457,10 +457,10 @@ public class Raster /** * Creates a new writable raster that is compatible with this raster. - * + * * @param w the width. * @param h the height. - * + * * @return A new writable raster. */ public WritableRaster createCompatibleWritableRaster(int w, int h) @@ -471,9 +471,9 @@ public class Raster /** * Creates a new writable raster that is compatible with this raster, with * the specified bounds. - * + * * @param rect the raster bounds. - * + * * @return A new writable raster. */ public WritableRaster createCompatibleWritableRaster(Rectangle rect) @@ -485,12 +485,12 @@ public class Raster /** * Creates a new writable raster that is compatible with this raster, with * the specified bounds. - * + * * @param x the x-coordinate of the top-left corner of the raster. * @param y the y-coordinate of the top-left corner of the raster. * @param w the raster width. * @param h the raster height. - * + * * @return A new writable raster. */ public WritableRaster createCompatibleWritableRaster(int x, int y, @@ -503,7 +503,7 @@ public class Raster public Raster createTranslatedChild(int childMinX, int childMinY) { int tcx = sampleModelTranslateX - minX + childMinX; int tcy = sampleModelTranslateY - minY + childMinY; - + return new Raster(sampleModel, dataBuffer, new Rectangle(childMinX, childMinY, width, height), new Point(tcx, tcy), this); @@ -516,7 +516,7 @@ public class Raster if (parentX < minX || parentX + width > minX + this.width || parentY < minY || parentY + height > minY + this.height) throw new RasterFormatException("Child raster extends beyond parent"); - + SampleModel sm = (bandList == null) ? sampleModel : sampleModel.createSubsetSampleModel(bandList); @@ -526,18 +526,18 @@ public class Raster / +------------------------- |\. __ parent trans - | \`. + | \`. | \ `. parent origin | \ `. / | /\ +-------- - - |trans\ /<\-- deltaTrans - |child +-+-\---- - - + |child +-+-\---- - - | /|`| \__ parent [x, y] |child | |`. \ |origin| : `.\ | | / `\ | : / + - | child [x, y] + | child [x, y] parent_xy - parent_trans = child_xy - child_trans @@ -553,7 +553,7 @@ public class Raster /** * Returns a new rectangle containing the bounds of this raster. - * + * * @return A new rectangle containing the bounds of this raster. */ public Rectangle getBounds() @@ -563,7 +563,7 @@ public class Raster /** * Returns the x-coordinate of the top left corner of the raster. - * + * * @return The x-coordinate of the top left corner of the raster. */ public final int getMinX() @@ -573,7 +573,7 @@ public class Raster /** * Returns the t-coordinate of the top left corner of the raster. - * + * * @return The t-coordinate of the top left corner of the raster. */ public final int getMinY() @@ -583,7 +583,7 @@ public class Raster /** * Returns the width of the raster. - * + * * @return The width of the raster. */ public final int getWidth() @@ -593,7 +593,7 @@ public class Raster /** * Returns the height of the raster. - * + * * @return The height of the raster. */ public final int getHeight() @@ -603,23 +603,23 @@ public class Raster /** * Returns the number of bands for this raster. - * + * * @return The number of bands. */ public final int getNumBands() { return numBands; } - + public final int getNumDataElements() { return numDataElements; } - + /** - * Returns the transfer type for the raster (this is determined by the + * Returns the transfer type for the raster (this is determined by the * raster's sample model). - * + * * @return The transfer type. */ public final int getTransferType() @@ -629,7 +629,7 @@ public class Raster /** * Returns the data buffer that stores the pixel data for this raster. - * + * * @return The data buffer. */ public DataBuffer getDataBuffer() @@ -640,7 +640,7 @@ public class Raster /** * Returns the sample model that accesses the data buffer (to extract pixel * data) for this raster. - * + * * @return The sample model. */ public SampleModel getSampleModel() @@ -662,15 +662,15 @@ public class Raster /** * Returns an array containing the samples for the pixel at (x, y) in the - * raster. If <code>iArray</code> is not <code>null</code>, it will be + * raster. If <code>iArray</code> is not <code>null</code>, it will be * populated with the sample values and returned as the result of * this function (this avoids allocating a new array instance). - * + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param iArray an array to populate with the sample values and return as + * @param iArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). - * + * * @return The pixel sample values. */ public int[] getPixel(int x, int y, int[] iArray) @@ -681,15 +681,15 @@ public class Raster /** * Returns an array containing the samples for the pixel at (x, y) in the - * raster. If <code>fArray</code> is not <code>null</code>, it will be + * raster. If <code>fArray</code> is not <code>null</code>, it will be * populated with the sample values and returned as the result of * this function (this avoids allocating a new array instance). - * + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param fArray an array to populate with the sample values and return as + * @param fArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). - * + * * @return The pixel sample values. */ public float[] getPixel(int x, int y, float[] fArray) @@ -700,15 +700,15 @@ public class Raster /** * Returns an array containing the samples for the pixel at (x, y) in the - * raster. If <code>dArray</code> is not <code>null</code>, it will be + * raster. If <code>dArray</code> is not <code>null</code>, it will be * populated with the sample values and returned as the result of * this function (this avoids allocating a new array instance). - * + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param dArray an array to populate with the sample values and return as + * @param dArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). - * + * * @return The pixel sample values. */ public double[] getPixel(int x, int y, double[] dArray) @@ -718,21 +718,21 @@ public class Raster } /** - * Returns an array containing the samples for the pixels in the region - * specified by (x, y, w, h) in the raster. The array is ordered by pixels - * (that is, all the samples for the first pixel are grouped together, - * followed by all the samples for the second pixel, and so on). - * If <code>iArray</code> is not <code>null</code>, it will be populated - * with the sample values and returned as the result of this function (this + * Returns an array containing the samples for the pixels in the region + * specified by (x, y, w, h) in the raster. The array is ordered by pixels + * (that is, all the samples for the first pixel are grouped together, + * followed by all the samples for the second pixel, and so on). + * If <code>iArray</code> is not <code>null</code>, it will be populated + * with the sample values and returned as the result of this function (this * avoids allocating a new array instance). - * + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param iArray an array to populate with the sample values and return as + * @param iArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). - * + * * @return The pixel sample values. */ public int[] getPixels(int x, int y, int w, int h, int[] iArray) @@ -742,21 +742,21 @@ public class Raster } /** - * Returns an array containing the samples for the pixels in the region - * specified by (x, y, w, h) in the raster. The array is ordered by pixels - * (that is, all the samples for the first pixel are grouped together, - * followed by all the samples for the second pixel, and so on). - * If <code>fArray</code> is not <code>null</code>, it will be populated - * with the sample values and returned as the result of this function (this + * Returns an array containing the samples for the pixels in the region + * specified by (x, y, w, h) in the raster. The array is ordered by pixels + * (that is, all the samples for the first pixel are grouped together, + * followed by all the samples for the second pixel, and so on). + * If <code>fArray</code> is not <code>null</code>, it will be populated + * with the sample values and returned as the result of this function (this * avoids allocating a new array instance). - * + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param fArray an array to populate with the sample values and return as + * @param fArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). - * + * * @return The pixel sample values. */ public float[] getPixels(int x, int y, int w, int h, float[] fArray) @@ -766,21 +766,21 @@ public class Raster } /** - * Returns an array containing the samples for the pixels in the region - * specified by (x, y, w, h) in the raster. The array is ordered by pixels - * (that is, all the samples for the first pixel are grouped together, - * followed by all the samples for the second pixel, and so on). - * If <code>dArray</code> is not <code>null</code>, it will be populated - * with the sample values and returned as the result of this function (this + * Returns an array containing the samples for the pixels in the region + * specified by (x, y, w, h) in the raster. The array is ordered by pixels + * (that is, all the samples for the first pixel are grouped together, + * followed by all the samples for the second pixel, and so on). + * If <code>dArray</code> is not <code>null</code>, it will be populated + * with the sample values and returned as the result of this function (this * avoids allocating a new array instance). - * + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param dArray an array to populate with the sample values and return as + * @param dArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). - * + * * @return The pixel sample values. */ public double[] getPixels(int x, int y, int w, int h, double[] dArray) @@ -791,12 +791,12 @@ public class Raster /** * Returns the sample value for the pixel at (x, y) in the raster. - * + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). - * + * * @return The sample value. */ public int getSample(int x, int y, int b) @@ -807,14 +807,14 @@ public class Raster /** * Returns the sample value for the pixel at (x, y) in the raster. - * + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). - * + * * @return The sample value. - * + * * @see #getSample(int, int, int) */ public float getSampleFloat(int x, int y, int b) @@ -825,14 +825,14 @@ public class Raster /** * Returns the sample value for the pixel at (x, y) in the raster. - * + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). - * + * * @return The sample value. - * + * * @see #getSample(int, int, int) */ public double getSampleDouble(int x, int y, int b) @@ -842,21 +842,21 @@ public class Raster } /** - * Returns an array containing the samples from one band for the pixels in - * the region specified by (x, y, w, h) in the raster. If - * <code>iArray</code> is not <code>null</code>, it will be - * populated with the sample values and returned as the result of this + * Returns an array containing the samples from one band for the pixels in + * the region specified by (x, y, w, h) in the raster. If + * <code>iArray</code> is not <code>null</code>, it will be + * populated with the sample values and returned as the result of this * function (this avoids allocating a new array instance). - * + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * </code>getNumBands() - 1</code>). - * @param iArray an array to populate with the sample values and return as + * @param iArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). - * + * * @return The sample values. */ public int[] getSamples(int x, int y, int w, int h, int b, @@ -867,23 +867,23 @@ public class Raster } /** - * Returns an array containing the samples from one band for the pixels in - * the region specified by (x, y, w, h) in the raster. If - * <code>fArray</code> is not <code>null</code>, it will be - * populated with the sample values and returned as the result of this + * Returns an array containing the samples from one band for the pixels in + * the region specified by (x, y, w, h) in the raster. If + * <code>fArray</code> is not <code>null</code>, it will be + * populated with the sample values and returned as the result of this * function (this avoids allocating a new array instance). * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * </code>getNumBands() - 1</code>). - * @param fArray an array to populate with the sample values and return as + * @param fArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). - * + * * @return The sample values. - */ + */ public float[] getSamples(int x, int y, int w, int h, int b, float[] fArray) { return sampleModel.getSamples(x - sampleModelTranslateX, @@ -891,39 +891,39 @@ public class Raster } /** - * Returns an array containing the samples from one band for the pixels in - * the region specified by (x, y, w, h) in the raster. If - * <code>dArray</code> is not <code>null</code>, it will be - * populated with the sample values and returned as the result of this + * Returns an array containing the samples from one band for the pixels in + * the region specified by (x, y, w, h) in the raster. If + * <code>dArray</code> is not <code>null</code>, it will be + * populated with the sample values and returned as the result of this * function (this avoids allocating a new array instance). - * + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * </code>getNumBands() - 1</code>). - * @param dArray an array to populate with the sample values and return as + * @param dArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). - * + * * @return The sample values. */ - public double[] getSamples(int x, int y, int w, int h, int b, + public double[] getSamples(int x, int y, int w, int h, int b, double[] dArray) { return sampleModel.getSamples(x - sampleModelTranslateX, y - sampleModelTranslateY, w, h, b, dArray, dataBuffer); } - + /** * Create a String representing the state of this Raster. - * + * * @return A String representing the stat of this Raster. */ public String toString() { CPStringBuilder result = new CPStringBuilder(); - + result.append(getClass().getName()); result.append("[("); result.append(minX).append(",").append(minY).append("), "); @@ -931,12 +931,12 @@ public class Raster result.append(sampleModel).append(","); result.append(dataBuffer); result.append("]"); - + return result.toString(); } /** - * Returns the number of bits used to represent the specified data type. + * Returns the number of bits used to represent the specified data type. * Valid types are: * <ul> * <li>{@link DataBuffer#TYPE_BYTE};</li> @@ -947,9 +947,9 @@ public class Raster * <li>{@link DataBuffer#TYPE_DOUBLE};</li> * </ul> * This method returns 0 for invalid data types. - * + * * @param dataType the data type. - * + * * @return The number of bits used to represent the specified data type. */ private static int getTypeBits(int dataType) diff --git a/java/awt/image/RasterOp.java b/java/awt/image/RasterOp.java index 656370e8b..2b2c0731f 100644 --- a/java/awt/image/RasterOp.java +++ b/java/awt/image/RasterOp.java @@ -53,13 +53,13 @@ public interface RasterOp * writable raster. If <code>dest</code> is <code>null</code>, a new * <code>WritableRaster</code> will be created by calling the * {@link #createCompatibleDestRaster(Raster)} method. If <code>dest</code> - * is not <code>null</code>, the result is written to <code>dest</code> then - * returned (this avoids creating a new <code>WritableRaster</code> each + * is not <code>null</code>, the result is written to <code>dest</code> then + * returned (this avoids creating a new <code>WritableRaster</code> each * time this method is called). - * + * * @param src the source raster. * @param dest the destination raster (<code>null</code> permitted). - * + * * @return The filtered raster. */ WritableRaster filter(Raster src, WritableRaster dest); @@ -67,9 +67,9 @@ public interface RasterOp /** * Returns the bounds of the destination raster on the basis of this * <code>RasterOp</code> being applied to the specified source raster. - * + * * @param src the source raster. - * + * * @return The destination bounds. */ Rectangle2D getBounds2D(Raster src); @@ -77,9 +77,9 @@ public interface RasterOp /** * Returns a raster that can be used by this <code>RasterOp</code> as the * destination raster when operating on the specified source raster. - * + * * @param src the source raster. - * + * * @return A new writable raster that can be used as the destination raster. */ WritableRaster createCompatibleDestRaster(Raster src); @@ -87,19 +87,18 @@ public interface RasterOp /** * Returns the point on the destination raster that corresponds to the given * point on the source raster. - * + * * @param srcPoint the source point. * @param destPoint the destination point (<code>null</code> permitted). - * + * * @return The destination point. */ Point2D getPoint2D(Point2D srcPoint, Point2D destPoint); /** * Returns the rendering hints for this operation. - * + * * @return The rendering hints. */ RenderingHints getRenderingHints(); } - diff --git a/java/awt/image/RenderedImage.java b/java/awt/image/RenderedImage.java index 067e9b98e..fd18871a9 100644 --- a/java/awt/image/RenderedImage.java +++ b/java/awt/image/RenderedImage.java @@ -1,4 +1,4 @@ -/* RenderedImage.java -- +/* RenderedImage.java -- Copyright (C) 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. diff --git a/java/awt/image/ReplicateScaleFilter.java b/java/awt/image/ReplicateScaleFilter.java index 5ba03f182..94aad85dd 100644 --- a/java/awt/image/ReplicateScaleFilter.java +++ b/java/awt/image/ReplicateScaleFilter.java @@ -48,13 +48,13 @@ import java.util.Hashtable; * <br> * Currently this filter does nothing and needs to be implemented. * - * @author C. Brian Jones (cbj@gnu.org) + * @author C. Brian Jones (cbj@gnu.org) */ public class ReplicateScaleFilter extends ImageFilter { public ReplicateScaleFilter(int width, int height) { - destHeight = height; - destWidth = width; + destHeight = height; + destWidth = width; } /** @@ -94,45 +94,45 @@ public class ReplicateScaleFilter extends ImageFilter /** * An <code>ImageProducer</code> indicates the size of the image - * being produced using this method. A filter can override this + * being produced using this method. A filter can override this * method to intercept these calls from the producer in order to * change either the width or the height before in turn calling * the consumer's <code>setDimensions</code> method. - * + * * @param width the width of the image - * @param height the height of the image + * @param height the height of the image */ public void setDimensions(int width, int height) { - srcWidth = width; - srcHeight = height; + srcWidth = width; + srcHeight = height; - /* If either destHeight or destWidth is < 0, the image should - maintain its original aspect ratio. When both are < 0, - just maintain the original width and height. */ - if (destWidth < 0 && destHeight < 0) + /* If either destHeight or destWidth is < 0, the image should + maintain its original aspect ratio. When both are < 0, + just maintain the original width and height. */ + if (destWidth < 0 && destHeight < 0) + { + destWidth = width; + destHeight = height; + } + else if (destWidth < 0) { - destWidth = width; - destHeight = height; - } - else if (destWidth < 0) - { - destWidth = width * destHeight / srcHeight; - } - else if (destHeight < 0) - { - destHeight = height * destWidth / srcWidth; - } + destWidth = width * destHeight / srcHeight; + } + else if (destHeight < 0) + { + destHeight = height * destWidth / srcWidth; + } - if (consumer != null) - consumer.setDimensions(destWidth, destHeight); + if (consumer != null) + consumer.setDimensions(destWidth, destHeight); } /** * An <code>ImageProducer</code> can set a list of properties * associated with this image by using this method. * - * @param props the list of properties associated with this image + * @param props the list of properties associated with this image */ public void setProperties(Hashtable<?, ?> props) { @@ -145,7 +145,7 @@ public class ReplicateScaleFilter extends ImageFilter /** * This function delivers a rectangle of pixels where any * pixel(m,n) is stored in the array as a <code>byte</code> at - * index (n * scansize + m + offset). + * index (n * scansize + m + offset). * * @param x the x coordinate of the rectangle * @param y the y coordinate of the rectangle @@ -156,8 +156,8 @@ public class ReplicateScaleFilter extends ImageFilter * @param offset the index of the first pixels in the <code>pixels</code> array * @param scansize the width to use in extracting pixels from the <code>pixels</code> array */ - public void setPixels(int x, int y, int w, int h, - ColorModel model, byte[] pixels, int offset, int scansize) + public void setPixels(int x, int y, int w, int h, + ColorModel model, byte[] pixels, int offset, int scansize) { if (srcrows == null || srccols == null) setupSources(); @@ -193,7 +193,7 @@ public class ReplicateScaleFilter extends ImageFilter /** * This function delivers a rectangle of pixels where any * pixel(m,n) is stored in the array as an <code>int</code> at - * index (n * scansize + m + offset). + * index (n * scansize + m + offset). * * @param x the x coordinate of the rectangle * @param y the y coordinate of the rectangle @@ -204,7 +204,7 @@ public class ReplicateScaleFilter extends ImageFilter * @param offset the index of the first pixels in the <code>pixels</code> array * @param scansize the width to use in extracting pixels from the <code>pixels</code> array */ - public void setPixels(int x, int y, int w, int h, + public void setPixels(int x, int y, int w, int h, ColorModel model, int[] pixels, int offset, int scansize) { if (srcrows == null || srccols == null) @@ -255,4 +255,3 @@ public class ReplicateScaleFilter extends ImageFilter } } } - diff --git a/java/awt/image/RescaleOp.java b/java/awt/image/RescaleOp.java index d56b12cb9..efab40b7e 100644 --- a/java/awt/image/RescaleOp.java +++ b/java/awt/image/RescaleOp.java @@ -44,20 +44,20 @@ import java.util.Arrays; /** * RescaleOp is a filter that changes each pixel by a scaling factor and offset. - * + * * For filtering Rasters, either one scaling factor and offset can be specified, * which will be applied to all bands; or a scaling factor and offset can be * specified for each band. - * + * * For BufferedImages, the scaling may apply to both color and alpha components. * If only one scaling factor is provided, or if the number of factors provided * equals the number of color components, the scaling is performed on all color * components. Otherwise, the scaling is performed on all components including * alpha. Alpha premultiplication is ignored. - * + * * After filtering, if color conversion is necessary, the conversion happens, * taking alpha premultiplication into account. - * + * * @author Jerry Quinn (jlquinn@optonline.net) * @author Francis Kung (fkung@redhat.com) */ @@ -66,47 +66,47 @@ public class RescaleOp implements BufferedImageOp, RasterOp private float[] scale; private float[] offsets; private RenderingHints hints = null; - + /** * Create a new RescaleOp object using the given scale factors and offsets. - * + * * The length of the arrays must be equal to the number of bands (or number of * data or color components) of the raster/image that this Op will be used on, * otherwise an IllegalArgumentException will be thrown when calling the * filter method. - * + * * @param scaleFactors an array of scale factors. * @param offsets an array of offsets. * @param hints any rendering hints to use (can be null). * @throws NullPointerException if the scaleFactors or offsets array is null. */ public RescaleOp(float[] scaleFactors, - float[] offsets, - RenderingHints hints) + float[] offsets, + RenderingHints hints) { int length = Math.min(scaleFactors.length, offsets.length); - + scale = new float[length]; System.arraycopy(scaleFactors, 0, this.scale, 0, length); - + this.offsets = new float[length]; System.arraycopy(offsets, 0, this.offsets, 0, length); - + this.hints = hints; } - + /** * Create a new RescaleOp object using the given scale factor and offset. - * + * * The same scale factor and offset will be used on all bands/components. - * + * * @param scaleFactor the scale factor to use. * @param offset the offset to use. * @param hints any rendering hints to use (can be null). */ public RescaleOp(float scaleFactor, - float offset, - RenderingHints hints) + float offset, + RenderingHints hints) { scale = new float[]{ scaleFactor }; offsets = new float[]{offset}; @@ -115,10 +115,10 @@ public class RescaleOp implements BufferedImageOp, RasterOp /** * Returns the scaling factors. This method accepts an optional array, which - * will be used to store the factors if not null (this avoids allocating a + * will be used to store the factors if not null (this avoids allocating a * new array). If this array is too small to hold all the scaling factors, * the array will be filled and the remaining factors discarded. - * + * * @param scaleFactors array to store the scaling factors in (can be null). * @return an array of scaling factors. */ @@ -133,10 +133,10 @@ public class RescaleOp implements BufferedImageOp, RasterOp /** * Returns the offsets. This method accepts an optional array, which - * will be used to store the offsets if not null (this avoids allocating a - * new array). If this array is too small to hold all the offsets, the array + * will be used to store the offsets if not null (this avoids allocating a + * new array). If this array is too small to hold all the offsets, the array * will be filled and the remaining factors discarded. - * + * * @param offsets array to store the offsets in (can be null). * @return an array of offsets. */ @@ -151,7 +151,7 @@ public class RescaleOp implements BufferedImageOp, RasterOp /** * Returns the number of scaling factors / offsets. - * + * * @return the number of scaling factors / offsets. */ public final int getNumFactors() @@ -168,13 +168,13 @@ public class RescaleOp implements BufferedImageOp, RasterOp } /** - * Converts the source image using the scale factors and offsets specified in - * the constructor. The resulting image is stored in the destination image if - * one is provided; otherwise a new BufferedImage is created and returned. - * + * Converts the source image using the scale factors and offsets specified in + * the constructor. The resulting image is stored in the destination image if + * one is provided; otherwise a new BufferedImage is created and returned. + * * The source image cannot use an IndexColorModel, and the destination image * (if one is provided) must have the same size. - * + * * If the final value of a sample is beyond the range of the color model, it * will be clipped to the appropriate maximum / minimum. * @@ -264,16 +264,16 @@ public class RescaleOp implements BufferedImageOp, RasterOp Arrays.fill(bands, true); return filter(src, dest, bands); } - + /** * Perform raster-based filtering on a selected number of bands. - * + * * The length of the bands array should equal the number of bands; a true * element indicates filtering should happen on the corresponding band, while * a false element will skip the band. - * + * * The rasters are assumed to be compatible and non-null. - * + * * @param src the source raster. * @param dest the destination raster. * @param bands an array indicating which bands to filter. @@ -285,12 +285,12 @@ public class RescaleOp implements BufferedImageOp, RasterOp { int[] values = new int[src.getHeight() * src.getWidth()]; float scaleFactor, offset; - + // Find max sample value, to be used for clipping later int[] maxValue = src.getSampleModel().getSampleSize(); for (int i = 0; i < maxValue.length; i++) maxValue[i] = (int)Math.pow(2, maxValue[i]) - 1; - + // TODO: can this be optimized further? // Filter all samples of all requested bands for (int band = 0; band < bands.length; band++) @@ -324,22 +324,22 @@ public class RescaleOp implements BufferedImageOp, RasterOp dest.setSamples(dest.getMinX(), dest.getMinY(), dest.getWidth(), dest.getHeight(), band, values); } - + return dest; } /* * (non-Javadoc) - * + * * @see java.awt.image.BufferedImageOp#createCompatibleDestImage(java.awt.image.BufferedImage, * java.awt.image.ColorModel) */ public BufferedImage createCompatibleDestImage(BufferedImage src, - ColorModel dstCM) + ColorModel dstCM) { if (dstCM == null) return new BufferedImage(src.getWidth(), src.getHeight(), src.getType()); - + return new BufferedImage(dstCM, src.getRaster().createCompatibleWritableRaster(), src.isAlphaPremultiplied(), null); @@ -352,7 +352,7 @@ public class RescaleOp implements BufferedImageOp, RasterOp { return src.createCompatibleWritableRaster(); } - + /* (non-Javadoc) * @see java.awt.image.BufferedImageOp#getBounds2D(java.awt.image.BufferedImage) */ @@ -378,7 +378,7 @@ public class RescaleOp implements BufferedImageOp, RasterOp dst = (Point2D) src.clone(); else dst.setLocation(src); - + return dst; } diff --git a/java/awt/image/SampleModel.java b/java/awt/image/SampleModel.java index 506e78a9b..7e0b18c55 100644 --- a/java/awt/image/SampleModel.java +++ b/java/awt/image/SampleModel.java @@ -37,24 +37,24 @@ exception statement from your version. */ package java.awt.image; /** - * A <code>SampleModel</code> is used to access pixel data from a + * A <code>SampleModel</code> is used to access pixel data from a * {@link DataBuffer}. This is used by the {@link Raster} class. - * + * * @author Rolf W. Rasmussen (rolfwr@ii.uib.no) */ public abstract class SampleModel { /** Width of image described. */ protected int width; - + /** Height of image described. */ protected int height; - + /** Number of bands in the image described. Package-private here, shadowed by ComponentSampleModel. */ protected int numBands; - /** + /** * The DataBuffer type that is used to store the data of the image * described. */ @@ -62,20 +62,20 @@ public abstract class SampleModel /** * Creates a new sample model with the specified attributes. - * + * * @param dataType the data type (one of {@link DataBuffer#TYPE_BYTE}, * {@link DataBuffer#TYPE_USHORT}, {@link DataBuffer#TYPE_SHORT}, - * {@link DataBuffer#TYPE_INT}, {@link DataBuffer#TYPE_FLOAT}, + * {@link DataBuffer#TYPE_INT}, {@link DataBuffer#TYPE_FLOAT}, * {@link DataBuffer#TYPE_DOUBLE} or {@link DataBuffer#TYPE_UNDEFINED}). * @param w the width in pixels (must be greater than zero). * @param h the height in pixels (must be greater than zero). * @param numBands the number of bands (must be greater than zero). - * - * @throws IllegalArgumentException if <code>dataType</code> is not one of + * + * @throws IllegalArgumentException if <code>dataType</code> is not one of * the listed values. * @throws IllegalArgumentException if <code>w</code> is less than or equal * to zero. - * @throws IllegalArgumentException if <code>h</code> is less than or equal + * @throws IllegalArgumentException if <code>h</code> is less than or equal * to zero. * @throws IllegalArgumentException if <code>w * h</code> is greater than * {@link Integer#MAX_VALUE}. @@ -85,30 +85,30 @@ public abstract class SampleModel if (dataType != DataBuffer.TYPE_UNDEFINED) if (dataType < DataBuffer.TYPE_BYTE || dataType > DataBuffer.TYPE_DOUBLE) throw new IllegalArgumentException("Unrecognised 'dataType' argument."); - - if ((w <= 0) || (h <= 0)) + + if ((w <= 0) || (h <= 0)) throw new IllegalArgumentException((w <= 0 ? " width<=0" : " width is ok") + (h <= 0 ? " height<=0" : " height is ok")); - + long area = (long) w * (long) h; if (area > Integer.MAX_VALUE) throw new IllegalArgumentException("w * h exceeds Integer.MAX_VALUE."); if (numBands <= 0) throw new IllegalArgumentException("Requires numBands > 0."); - + this.dataType = dataType; this.width = w; this.height = h; - this.numBands = numBands; + this.numBands = numBands; } - + /** - * Returns the width of the pixel data accessible via this + * Returns the width of the pixel data accessible via this * <code>SampleModel</code>. - * + * * @return The width. - * + * * @see #getHeight() */ public final int getWidth() @@ -117,11 +117,11 @@ public abstract class SampleModel } /** - * Returns the height of the pixel data accessible via this + * Returns the height of the pixel data accessible via this * <code>SampleModel</code>. - * + * * @return The height. - * + * * @see #getWidth() */ public final int getHeight() @@ -131,20 +131,20 @@ public abstract class SampleModel /** * Returns the number of bands for this <code>SampleModel</code>. - * + * * @return The number of bands. */ public final int getNumBands() { return numBands; } - + public abstract int getNumDataElements(); - + /** - * Returns the type of the {@link DataBuffer} that this + * Returns the type of the {@link DataBuffer} that this * <code>SampleModel</code> accesses. - * + * * @return The data buffer type. */ public final int getDataType() @@ -163,26 +163,26 @@ public abstract class SampleModel * specified data buffer. If <code>iArray</code> is not <code>null</code>, * it will be populated with the sample values and returned as the result of * this function (this avoids allocating a new array instance). - * + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param iArray an array to populate with the sample values and return as + * @param iArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The pixel sample values. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public int[] getPixel(int x, int y, int[] iArray, DataBuffer data) { - if (iArray == null) + if (iArray == null) iArray = new int[numBands]; - for (int b = 0; b < numBands; b++) + for (int b = 0; b < numBands; b++) iArray[b] = getSample(x, y, b, data); return iArray; } - + /** * * This method is provided as a faster alternative to getPixel(), @@ -199,14 +199,14 @@ public abstract class SampleModel public abstract Object getDataElements(int x, int y, Object obj, DataBuffer data); - + public Object getDataElements(int x, int y, int w, int h, Object obj, DataBuffer data) { int size = w * h; int numDataElements = getNumDataElements(); int dataSize = numDataElements * size; - + if (obj == null) { switch (getTransferType()) @@ -247,7 +247,7 @@ public abstract class SampleModel Object obj, DataBuffer data) { int numDataElements = getNumDataElements(); - + Object pixelData; switch (getTransferType()) { @@ -292,22 +292,22 @@ public abstract class SampleModel * specified data buffer. If <code>fArray</code> is not <code>null</code>, * it will be populated with the sample values and returned as the result of * this function (this avoids allocating a new array instance). - * + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param fArray an array to populate with the sample values and return as + * @param fArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The pixel sample values. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public float[] getPixel(int x, int y, float[] fArray, DataBuffer data) { - if (fArray == null) + if (fArray == null) fArray = new float[numBands]; - + for (int b = 0; b < numBands; b++) { fArray[b] = getSampleFloat(x, y, b, data); @@ -320,19 +320,19 @@ public abstract class SampleModel * specified data buffer. If <code>dArray</code> is not <code>null</code>, * it will be populated with the sample values and returned as the result of * this function (this avoids allocating a new array instance). - * + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param dArray an array to populate with the sample values and return as + * @param dArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The pixel sample values. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public double[] getPixel(int x, int y, double[] dArray, DataBuffer data) { - if (dArray == null) + if (dArray == null) dArray = new double[numBands]; for (int b = 0; b < numBands; b++) { @@ -342,24 +342,24 @@ public abstract class SampleModel } /** - * Returns an array containing the samples for the pixels in the region + * Returns an array containing the samples for the pixels in the region * specified by (x, y, w, h) in the specified data buffer. The array is - * ordered by pixels (that is, all the samples for the first pixel are + * ordered by pixels (that is, all the samples for the first pixel are * grouped together, followed by all the samples for the second pixel, and so - * on). If <code>iArray</code> is not <code>null</code>, it will be - * populated with the sample values and returned as the result of this + * on). If <code>iArray</code> is not <code>null</code>, it will be + * populated with the sample values and returned as the result of this * function (this avoids allocating a new array instance). - * + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param iArray an array to populate with the sample values and return as + * @param iArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The pixel sample values. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public int[] getPixels(int x, int y, int w, int h, int[] iArray, @@ -368,7 +368,7 @@ public abstract class SampleModel int size = w * h; int outOffset = 0; int[] pixel = null; - if (iArray == null) + if (iArray == null) iArray = new int[w * h * numBands]; for (int yy = y; yy < (y + h); yy++) { @@ -383,24 +383,24 @@ public abstract class SampleModel } /** - * Returns an array containing the samples for the pixels in the region + * Returns an array containing the samples for the pixels in the region * specified by (x, y, w, h) in the specified data buffer. The array is - * ordered by pixels (that is, all the samples for the first pixel are + * ordered by pixels (that is, all the samples for the first pixel are * grouped together, followed by all the samples for the second pixel, and so - * on). If <code>fArray</code> is not <code>null</code>, it will be - * populated with the sample values and returned as the result of this + * on). If <code>fArray</code> is not <code>null</code>, it will be + * populated with the sample values and returned as the result of this * function (this avoids allocating a new array instance). - * + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param fArray an array to populate with the sample values and return as + * @param fArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The pixel sample values. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public float[] getPixels(int x, int y, int w, int h, float[] fArray, @@ -421,26 +421,26 @@ public abstract class SampleModel } return fArray; } - + /** - * Returns an array containing the samples for the pixels in the region + * Returns an array containing the samples for the pixels in the region * specified by (x, y, w, h) in the specified data buffer. The array is - * ordered by pixels (that is, all the samples for the first pixel are + * ordered by pixels (that is, all the samples for the first pixel are * grouped together, followed by all the samples for the second pixel, and so - * on). If <code>dArray</code> is not <code>null</code>, it will be - * populated with the sample values and returned as the result of this + * on). If <code>dArray</code> is not <code>null</code>, it will be + * populated with the sample values and returned as the result of this * function (this avoids allocating a new array instance). - * + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param dArray an array to populate with the sample values and return as + * @param dArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The pixel sample values. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public double[] getPixels(int x, int y, int w, int h, double[] dArray, @@ -449,7 +449,7 @@ public abstract class SampleModel int size = w * h; int outOffset = 0; double[] pixel = null; - if (dArray == null) + if (dArray == null) dArray = new double[w * h * numBands]; for (int yy = y; yy < (y + h); yy++) { @@ -464,35 +464,35 @@ public abstract class SampleModel } /** - * Returns the sample value for the pixel at (x, y) in the specified data + * Returns the sample value for the pixel at (x, y) in the specified data * buffer. - * + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The sample value. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public abstract int getSample(int x, int y, int b, DataBuffer data); /** - * Returns the sample value for the pixel at (x, y) in the specified data + * Returns the sample value for the pixel at (x, y) in the specified data * buffer. - * + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The sample value. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. - * + * * @see #getSample(int, int, int, DataBuffer) */ public float getSampleFloat(int x, int y, int b, DataBuffer data) @@ -501,19 +501,19 @@ public abstract class SampleModel } /** - * Returns the sample value for the pixel at (x, y) in the specified data + * Returns the sample value for the pixel at (x, y) in the specified data * buffer. - * + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The sample value. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. - * + * * @see #getSample(int, int, int, DataBuffer) */ public double getSampleDouble(int x, int y, int b, DataBuffer data) @@ -522,24 +522,24 @@ public abstract class SampleModel } /** - * Returns an array containing the samples from one band for the pixels in - * the region specified by (x, y, w, h) in the specified data buffer. If - * <code>iArray</code> is not <code>null</code>, it will be - * populated with the sample values and returned as the result of this + * Returns an array containing the samples from one band for the pixels in + * the region specified by (x, y, w, h) in the specified data buffer. If + * <code>iArray</code> is not <code>null</code>, it will be + * populated with the sample values and returned as the result of this * function (this avoids allocating a new array instance). - * + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * </code>getNumBands() - 1</code>). - * @param iArray an array to populate with the sample values and return as + * @param iArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The sample values. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public int[] getSamples(int x, int y, int w, int h, int b, @@ -547,7 +547,7 @@ public abstract class SampleModel { int size = w * h; int outOffset = 0; - if (iArray == null) + if (iArray == null) iArray = new int[size]; for (int yy = y; yy < (y + h); yy++) { @@ -560,24 +560,24 @@ public abstract class SampleModel } /** - * Returns an array containing the samples from one band for the pixels in - * the region specified by (x, y, w, h) in the specified data buffer. If - * <code>fArray</code> is not <code>null</code>, it will be - * populated with the sample values and returned as the result of this + * Returns an array containing the samples from one band for the pixels in + * the region specified by (x, y, w, h) in the specified data buffer. If + * <code>fArray</code> is not <code>null</code>, it will be + * populated with the sample values and returned as the result of this * function (this avoids allocating a new array instance). - * + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * </code>getNumBands() - 1</code>). - * @param fArray an array to populate with the sample values and return as + * @param fArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The sample values. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public float[] getSamples(int x, int y, int w, int h, int b, @@ -585,7 +585,7 @@ public abstract class SampleModel { int size = w * h; int outOffset = 0; - if (fArray == null) + if (fArray == null) fArray = new float[size]; for (int yy = y; yy < (y + h); yy++) { @@ -598,24 +598,24 @@ public abstract class SampleModel } /** - * Returns an array containing the samples from one band for the pixels in - * the region specified by (x, y, w, h) in the specified data buffer. If - * <code>dArray</code> is not <code>null</code>, it will be - * populated with the sample values and returned as the result of this + * Returns an array containing the samples from one band for the pixels in + * the region specified by (x, y, w, h) in the specified data buffer. If + * <code>dArray</code> is not <code>null</code>, it will be + * populated with the sample values and returned as the result of this * function (this avoids allocating a new array instance). - * + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * </code>getNumBands() - 1</code>). - * @param dArray an array to populate with the sample values and return as + * @param dArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The sample values. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public double[] getSamples(int x, int y, int w, int h, int b, @@ -623,7 +623,7 @@ public abstract class SampleModel { int size = w * h; int outOffset = 0; - if (dArray == null) + if (dArray == null) dArray = new double[size]; for (int yy = y; yy < (y + h); yy++) { @@ -634,76 +634,76 @@ public abstract class SampleModel } return dArray; } - + /** * Sets the samples for the pixel at (x, y) in the specified data buffer to - * the specified values. - * + * the specified values. + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. * @param iArray the sample values (<code>null</code> not permitted). * @param data the data buffer (<code>null</code> not permitted). - * - * @throws NullPointerException if either <code>iArray</code> or + * + * @throws NullPointerException if either <code>iArray</code> or * <code>data</code> is <code>null</code>. */ public void setPixel(int x, int y, int[] iArray, DataBuffer data) { - for (int b = 0; b < numBands; b++) + for (int b = 0; b < numBands; b++) setSample(x, y, b, iArray[b], data); } /** * Sets the samples for the pixel at (x, y) in the specified data buffer to - * the specified values. - * + * the specified values. + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. * @param fArray the sample values (<code>null</code> not permitted). * @param data the data buffer (<code>null</code> not permitted). - * - * @throws NullPointerException if either <code>fArray</code> or + * + * @throws NullPointerException if either <code>fArray</code> or * <code>data</code> is <code>null</code>. */ public void setPixel(int x, int y, float[] fArray, DataBuffer data) { - for (int b = 0; b < numBands; b++) + for (int b = 0; b < numBands; b++) setSample(x, y, b, fArray[b], data); } /** * Sets the samples for the pixel at (x, y) in the specified data buffer to - * the specified values. - * + * the specified values. + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. * @param dArray the sample values (<code>null</code> not permitted). * @param data the data buffer (<code>null</code> not permitted). - * - * @throws NullPointerException if either <code>dArray</code> or + * + * @throws NullPointerException if either <code>dArray</code> or * <code>data</code> is <code>null</code>. */ public void setPixel(int x, int y, double[] dArray, DataBuffer data) { - for (int b = 0; b < numBands; b++) + for (int b = 0; b < numBands; b++) setSample(x, y, b, dArray[b], data); } /** - * Sets the sample values for the pixels in the region specified by + * Sets the sample values for the pixels in the region specified by * (x, y, w, h) in the specified data buffer. The array is - * ordered by pixels (that is, all the samples for the first pixel are + * ordered by pixels (that is, all the samples for the first pixel are * grouped together, followed by all the samples for the second pixel, and so - * on). - * + * on). + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. * @param iArray the pixel sample values (<code>null</code> not permitted). * @param data the data buffer (<code>null</code> not permitted). - * - * @throws NullPointerException if either <code>iArray</code> or + * + * @throws NullPointerException if either <code>iArray</code> or * <code>data</code> is <code>null</code>. */ public void setPixels(int x, int y, int w, int h, int[] iArray, @@ -723,20 +723,20 @@ public abstract class SampleModel } /** - * Sets the sample values for the pixels in the region specified by + * Sets the sample values for the pixels in the region specified by * (x, y, w, h) in the specified data buffer. The array is - * ordered by pixels (that is, all the samples for the first pixel are + * ordered by pixels (that is, all the samples for the first pixel are * grouped together, followed by all the samples for the second pixel, and so - * on). - * + * on). + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. * @param fArray the pixel sample values (<code>null</code> not permitted). * @param data the data buffer (<code>null</code> not permitted). - * - * @throws NullPointerException if either <code>fArray</code> or + * + * @throws NullPointerException if either <code>fArray</code> or * <code>data</code> is <code>null</code>. */ public void setPixels(int x, int y, int w, int h, float[] fArray, @@ -756,20 +756,20 @@ public abstract class SampleModel } /** - * Sets the sample values for the pixels in the region specified by + * Sets the sample values for the pixels in the region specified by * (x, y, w, h) in the specified data buffer. The array is - * ordered by pixels (that is, all the samples for the first pixel are + * ordered by pixels (that is, all the samples for the first pixel are * grouped together, followed by all the samples for the second pixel, and so - * on). - * + * on). + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. * @param dArray the pixel sample values (<code>null</code> not permitted). * @param data the data buffer (<code>null</code> not permitted). - * - * @throws NullPointerException if either <code>dArray</code> or + * + * @throws NullPointerException if either <code>dArray</code> or * <code>data</code> is <code>null</code>. */ public void setPixels(int x, int y, int w, int h, double[] dArray, @@ -789,32 +789,32 @@ public abstract class SampleModel } /** - * Sets the sample value for a band for the pixel at (x, y) in the - * specified data buffer. - * + * Sets the sample value for a band for the pixel at (x, y) in the + * specified data buffer. + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). * @param s the sample value. * @param data the data buffer (<code>null</code> not permitted). - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public abstract void setSample(int x, int y, int b, int s, DataBuffer data); /** - * Sets the sample value for a band for the pixel at (x, y) in the - * specified data buffer. - * + * Sets the sample value for a band for the pixel at (x, y) in the + * specified data buffer. + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). * @param s the sample value. * @param data the data buffer (<code>null</code> not permitted). - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public void setSample(int x, int y, int b, float s, @@ -824,16 +824,16 @@ public abstract class SampleModel } /** - * Sets the sample value for a band for the pixel at (x, y) in the - * specified data buffer. - * + * Sets the sample value for a band for the pixel at (x, y) in the + * specified data buffer. + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). * @param s the sample value. * @param data the data buffer (<code>null</code> not permitted). - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public void setSample(int x, int y, int b, double s, @@ -843,19 +843,19 @@ public abstract class SampleModel } /** - * Sets the sample values for one band for the pixels in the region - * specified by (x, y, w, h) in the specified data buffer. - * + * Sets the sample values for one band for the pixels in the region + * specified by (x, y, w, h) in the specified data buffer. + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * </code>getNumBands() - 1</code>). * @param iArray the sample values (<code>null</code> not permitted). * @param data the data buffer (<code>null</code> not permitted). - * - * @throws NullPointerException if either <code>iArray</code> or + * + * @throws NullPointerException if either <code>iArray</code> or * <code>data</code> is <code>null</code>. */ public void setSamples(int x, int y, int w, int h, int b, @@ -869,19 +869,19 @@ public abstract class SampleModel } /** - * Sets the sample values for one band for the pixels in the region - * specified by (x, y, w, h) in the specified data buffer. - * + * Sets the sample values for one band for the pixels in the region + * specified by (x, y, w, h) in the specified data buffer. + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * </code>getNumBands() - 1</code>). * @param fArray the sample values (<code>null</code> not permitted). * @param data the data buffer (<code>null</code> not permitted). - * - * @throws NullPointerException if either <code>iArray</code> or + * + * @throws NullPointerException if either <code>iArray</code> or * <code>data</code> is <code>null</code>. */ public void setSamples(int x, int y, int w, int h, int b, @@ -896,19 +896,19 @@ public abstract class SampleModel } /** - * Sets the sample values for one band for the pixels in the region - * specified by (x, y, w, h) in the specified data buffer. - * + * Sets the sample values for one band for the pixels in the region + * specified by (x, y, w, h) in the specified data buffer. + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * </code>getNumBands() - 1</code>). * @param dArray the sample values (<code>null</code> not permitted). * @param data the data buffer (<code>null</code> not permitted). - * - * @throws NullPointerException if either <code>iArray</code> or + * + * @throws NullPointerException if either <code>iArray</code> or * <code>data</code> is <code>null</code>. */ public void setSamples(int x, int y, int w, int h, int b, @@ -923,31 +923,31 @@ public abstract class SampleModel /** * Creates a new <code>SampleModel</code> that is compatible with this * model and has the specified width and height. - * + * * @param w the width (in pixels). * @param h the height (in pixels). - * + * * @return The new sample model. */ public abstract SampleModel createCompatibleSampleModel(int w, int h); /** * Return a SampleModel with a subset of the bands in this model. - * + * * Selects bands.length bands from this sample model. The bands chosen * are specified in the indices of bands[]. This also permits permuting * the bands as well as taking a subset. Thus, giving an array with * 1, 2, 3, ..., numbands, will give an identical sample model. - * + * * @param bands Array with band indices to include. * @return A new sample model */ public abstract SampleModel createSubsetSampleModel(int[] bands); /** - * Creates a new {@link DataBuffer} of the correct type and size for this + * Creates a new {@link DataBuffer} of the correct type and size for this * <code>SampleModel</code>. - * + * * @return The data buffer. */ public abstract DataBuffer createDataBuffer(); @@ -955,19 +955,19 @@ public abstract class SampleModel /** * Returns an array containing the size (in bits) for each band accessed by * the <code>SampleModel</code>. - * + * * @return An array. - * + * * @see #getSampleSize(int) */ public abstract int[] getSampleSize(); /** * Returns the size (in bits) of the samples for the specified band. - * - * @param band the band (in the range <code>0</code> to + * + * @param band the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). - * + * * @return The sample size (in bits). */ public abstract int getSampleSize(int band); diff --git a/java/awt/image/ShortLookupTable.java b/java/awt/image/ShortLookupTable.java index 858818cf2..3e276fe9f 100644 --- a/java/awt/image/ShortLookupTable.java +++ b/java/awt/image/ShortLookupTable.java @@ -58,7 +58,7 @@ public class ShortLookupTable extends LookupTable * Offset is subtracted from pixel values when looking up in the translation * tables. If data.length is one, the same table is applied to all pixel * components. - * + * * @param offset Offset to be subtracted. * @param data Array of lookup tables. * @exception IllegalArgumentException if offset < 0 or data.length < 1. @@ -67,9 +67,9 @@ public class ShortLookupTable extends LookupTable throws IllegalArgumentException { super(offset, data.length); - + // tests show that Sun's implementation creates a new array to store the - // references from the incoming 'data' array - not sure why, but we'll + // references from the incoming 'data' array - not sure why, but we'll // match that behaviour just in case it matters... this.data = new short[data.length][]; for (int i = 0; i < data.length; i++) @@ -81,9 +81,9 @@ public class ShortLookupTable extends LookupTable * * Offset is subtracted from pixel values when looking up in the translation * table. The same table is applied to all pixel components. - * + * * @param offset Offset to be subtracted. - * @param data Lookup table for all components (<code>null</code> not + * @param data Lookup table for all components (<code>null</code> not * permitted). * @exception IllegalArgumentException if offset < 0. */ @@ -96,10 +96,10 @@ public class ShortLookupTable extends LookupTable this.data = new short[][] {data}; } - /** + /** * Return the lookup tables. This is a reference to the actual table, so - * modifying the contents of the returned array will modify the lookup table. - * + * modifying the contents of the returned array will modify the lookup table. + * * @return The lookup table. */ public final short[][] getTable() @@ -136,7 +136,7 @@ public class ShortLookupTable extends LookupTable else for (int i = 0; i < src.length; i++) dst[i] = data[i][src[i] - offset]; - + return dst; } @@ -170,7 +170,7 @@ public class ShortLookupTable extends LookupTable else for (int i = 0; i < src.length; i++) dst[i] = data[i][((int) src[i]) - offset]; - + return dst; } diff --git a/java/awt/image/SinglePixelPackedSampleModel.java b/java/awt/image/SinglePixelPackedSampleModel.java index 225138651..143581db9 100644 --- a/java/awt/image/SinglePixelPackedSampleModel.java +++ b/java/awt/image/SinglePixelPackedSampleModel.java @@ -43,9 +43,9 @@ import gnu.java.lang.CPStringBuilder; /** * A <code>SampleModel</code> used when all samples are stored in a single - * data element in the {@link DataBuffer}, and each data element contains + * data element in the {@link DataBuffer}, and each data element contains * samples for one pixel only. - * + * * @author Rolf W. Rasmussen (rolfwr@ii.uib.no) */ public class SinglePixelPackedSampleModel extends SampleModel @@ -54,10 +54,10 @@ public class SinglePixelPackedSampleModel extends SampleModel private int[] bitMasks; private int[] bitOffsets; private int[] sampleSize; - + /** * Creates a new <code>SinglePixelPackedSampleModel</code>. - * + * * @param dataType the data buffer type. * @param w the width (in pixels). * @param h the height (in pixels). @@ -65,14 +65,14 @@ public class SinglePixelPackedSampleModel extends SampleModel * sample value for each band. */ public SinglePixelPackedSampleModel(int dataType, int w, int h, - int[] bitMasks) + int[] bitMasks) { this(dataType, w, h, w, bitMasks); } /** * Creates a new <code>SinglePixelPackedSampleModel</code>. - * + * * @param dataType the data buffer type. * @param w the width (in pixels). * @param h the height (in pixels). @@ -82,7 +82,7 @@ public class SinglePixelPackedSampleModel extends SampleModel * sample value for each band. */ public SinglePixelPackedSampleModel(int dataType, int w, int h, - int scanlineStride, int[] bitMasks) + int scanlineStride, int[] bitMasks) { super(dataType, w, h, bitMasks.length); @@ -91,18 +91,18 @@ public class SinglePixelPackedSampleModel extends SampleModel case DataBuffer.TYPE_BYTE: case DataBuffer.TYPE_USHORT: case DataBuffer.TYPE_INT: - break; + break; default: throw new IllegalArgumentException( "SinglePixelPackedSampleModel unsupported dataType"); } - + this.scanlineStride = scanlineStride; this.bitMasks = bitMasks; - + bitOffsets = new int[numBands]; sampleSize = new int[numBands]; - + BitMaskExtent extent = new BitMaskExtent(); for (int b = 0; b < numBands; b++) { @@ -116,7 +116,7 @@ public class SinglePixelPackedSampleModel extends SampleModel /** * Returns the number of data elements. - * + * * @return <code>1</code>. */ public int getNumDataElements() @@ -127,10 +127,10 @@ public class SinglePixelPackedSampleModel extends SampleModel /** * Creates a new <code>SampleModel</code> that is compatible with this * model and has the specified width and height. - * + * * @param w the width (in pixels). * @param h the height (in pixels). - * + * * @return The new sample model. */ public SampleModel createCompatibleSampleModel(int w, int h) @@ -146,7 +146,7 @@ public class SinglePixelPackedSampleModel extends SampleModel * Creates a DataBuffer for holding pixel data in the format and * layout described by this SampleModel. The returned buffer will * consist of one single bank. - * + * * @return The data buffer. */ public DataBuffer createDataBuffer() @@ -175,22 +175,22 @@ public class SinglePixelPackedSampleModel extends SampleModel /** * Returns an array containing the size (in bits) for each band accessed by * the <code>SampleModel</code>. - * + * * @return An array. - * + * * @see #getSampleSize(int) */ public int[] getSampleSize() { return (int[]) sampleSize.clone(); } - + /** * Returns the size (in bits) of the samples for the specified band. - * - * @param band the band (in the range <code>0</code> to + * + * @param band the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). - * + * * @return The sample size (in bits). */ public int getSampleSize(int band) @@ -200,10 +200,10 @@ public class SinglePixelPackedSampleModel extends SampleModel /** * Returns the index in the data buffer that stores the pixel at (x, y). - * + * * @param x the x-coordinate. * @param y the y-coordinate. - * + * * @return The index in the data buffer that stores the pixel at (x, y). */ public int getOffset(int x, int y) @@ -224,7 +224,7 @@ public class SinglePixelPackedSampleModel extends SampleModel /** * Returns the number of data elements from a pixel in one row to the * corresponding pixel in the next row. - * + * * @return The scanline stride. */ public int getScanlineStride() @@ -235,12 +235,12 @@ public class SinglePixelPackedSampleModel extends SampleModel /** * Creates a new <code>SinglePixelPackedSampleModel</code> that accesses * the specified subset of bands. - * + * * @param bands an array containing band indices (<code>null</code> not * permitted). - * + * * @return A new sample model. - * + * * @throws NullPointerException if <code>bands</code> is <code>null</code>. * @throws RasterFormatException if <code>bands.length</code> is greater * than the number of bands in this model. @@ -249,20 +249,20 @@ public class SinglePixelPackedSampleModel extends SampleModel { if (bands.length > numBands) throw new RasterFormatException("Too many bands."); - + int numBands = bands.length; - + int[] bitMasks = new int[numBands]; for (int b = 0; b < numBands; b++) bitMasks[b] = this.bitMasks[bands[b]]; return new SinglePixelPackedSampleModel(dataType, width, height, - scanlineStride, bitMasks); + scanlineStride, bitMasks); } public Object getDataElements(int x, int y, Object obj, - DataBuffer data) + DataBuffer data) { int type = getTransferType(); Object ret = null; @@ -298,21 +298,21 @@ public class SinglePixelPackedSampleModel extends SampleModel } return ret; } - + /** * Returns an array containing the samples for the pixel at (x, y) in the * specified data buffer. If <code>iArray</code> is not <code>null</code>, * it will be populated with the sample values and returned as the result of * this function (this avoids allocating a new array instance). - * + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param iArray an array to populate with the sample values and return as + * @param iArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The pixel sample values. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public int[] getPixel(int x, int y, int[] iArray, DataBuffer data) @@ -323,63 +323,63 @@ public class SinglePixelPackedSampleModel extends SampleModel for (int b = 0; b < numBands; b++) iArray[b] = (samples & bitMasks[b]) >>> bitOffsets[b]; - + return iArray; } /** - * Returns an array containing the samples for the pixels in the region + * Returns an array containing the samples for the pixels in the region * specified by (x, y, w, h) in the specified data buffer. The array is - * ordered by pixels (that is, all the samples for the first pixel are + * ordered by pixels (that is, all the samples for the first pixel are * grouped together, followed by all the samples for the second pixel, and so - * on). If <code>iArray</code> is not <code>null</code>, it will be - * populated with the sample values and returned as the result of this + * on). If <code>iArray</code> is not <code>null</code>, it will be + * populated with the sample values and returned as the result of this * function (this avoids allocating a new array instance). - * + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param iArray an array to populate with the sample values and return as + * @param iArray an array to populate with the sample values and return as * the result (if <code>null</code>, a new array will be allocated). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The pixel sample values. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public int[] getPixels(int x, int y, int w, int h, int[] iArray, - DataBuffer data) + DataBuffer data) { int offset = scanlineStride*y + x; if (iArray == null) iArray = new int[numBands*w*h]; int outOffset = 0; for (y = 0; y < h; y++) { - int lineOffset = offset; - for (x = 0; x < w; x++) - { - int samples = data.getElem(lineOffset++); - for (int b = 0; b < numBands; b++) - iArray[outOffset++] = (samples & bitMasks[b]) >>> bitOffsets[b]; - } - offset += scanlineStride; + int lineOffset = offset; + for (x = 0; x < w; x++) + { + int samples = data.getElem(lineOffset++); + for (int b = 0; b < numBands; b++) + iArray[outOffset++] = (samples & bitMasks[b]) >>> bitOffsets[b]; + } + offset += scanlineStride; } - return iArray; + return iArray; } /** - * Returns the sample value for the pixel at (x, y) in the specified data + * Returns the sample value for the pixel at (x, y) in the specified data * buffer. - * + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). * @param data the data buffer (<code>null</code> not permitted). - * + * * @return The sample value. - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public int getSample(int x, int y, int b, DataBuffer data) @@ -388,7 +388,7 @@ public class SinglePixelPackedSampleModel extends SampleModel int samples = data.getElem(offset); return (samples & bitMasks[b]) >>> bitOffsets[b]; } - + public void setDataElements(int x, int y, Object obj, DataBuffer data) { int transferType = getTransferType(); @@ -417,20 +417,20 @@ public class SinglePixelPackedSampleModel extends SampleModel /** * Sets the samples for the pixel at (x, y) in the specified data buffer to - * the specified values. - * + * the specified values. + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. * @param iArray the sample values (<code>null</code> not permitted). * @param data the data buffer (<code>null</code> not permitted). - * - * @throws NullPointerException if either <code>iArray</code> or + * + * @throws NullPointerException if either <code>iArray</code> or * <code>data</code> is <code>null</code>. */ public void setPixel(int x, int y, int[] iArray, DataBuffer data) { int offset = scanlineStride*y + x; - + int samples = 0; for (int b = 0; b < numBands; b++) samples |= (iArray[b] << bitOffsets[b]) & bitMasks[b]; @@ -448,18 +448,18 @@ public class SinglePixelPackedSampleModel extends SampleModel * @param h The height of the pixel rectangle in <code>obj</code>. * @param iArray The primitive array containing the pixels to set. * @param data The DataBuffer to store the pixels into. - * @see java.awt.image.SampleModel#setPixels(int, int, int, int, int[], + * @see java.awt.image.SampleModel#setPixels(int, int, int, int, int[], * java.awt.image.DataBuffer) */ public void setPixels(int x, int y, int w, int h, int[] iArray, - DataBuffer data) + DataBuffer data) { int inOffset = 0; for (int yy=y; yy<(y+h); yy++) { int offset = scanlineStride*yy + x; for (int xx=x; xx<(x+w); xx++) - { + { int samples = 0; for (int b = 0; b < numBands; b++) samples |= (iArray[inOffset+b] << bitOffsets[b]) & bitMasks[b]; @@ -469,18 +469,18 @@ public class SinglePixelPackedSampleModel extends SampleModel } } } - + /** - * Sets the sample value for a band for the pixel at (x, y) in the - * specified data buffer. - * + * Sets the sample value for a band for the pixel at (x, y) in the + * specified data buffer. + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). * @param s the sample value. * @param data the data buffer (<code>null</code> not permitted). - * + * * @throws NullPointerException if <code>data</code> is <code>null</code>. */ public void setSample(int x, int y, int b, int s, DataBuffer data) @@ -492,13 +492,13 @@ public class SinglePixelPackedSampleModel extends SampleModel samples |= (s << bitOffsets[b]) & bitMask; data.setElem(offset, samples); } - + /** - * Tests this sample model for equality with an arbitrary object. This + * Tests this sample model for equality with an arbitrary object. This * method returns <code>true</code> if and only if: * <ul> * <li><code>obj</code> is not <code>null</code>; - * <li><code>obj</code> is an instance of + * <li><code>obj</code> is an instance of * <code>SinglePixelPackedSampleModel</code>; * <li>both models have the same: * <ul> @@ -512,17 +512,17 @@ public class SinglePixelPackedSampleModel extends SampleModel * </ul> * </li> * </ul> - * + * * @param obj the object (<code>null</code> permitted) - * + * * @return <code>true</code> if this model is equal to <code>obj</code>, and * <code>false</code> otherwise. */ - public boolean equals(Object obj) + public boolean equals(Object obj) { - if (this == obj) + if (this == obj) return true; - if (! (obj instanceof SinglePixelPackedSampleModel)) + if (! (obj instanceof SinglePixelPackedSampleModel)) return false; SinglePixelPackedSampleModel that = (SinglePixelPackedSampleModel) obj; if (this.dataType != that.dataType) @@ -537,14 +537,14 @@ public class SinglePixelPackedSampleModel extends SampleModel return false; if (!Arrays.equals(this.bitMasks, that.bitMasks)) return false; - if (!Arrays.equals(this.bitOffsets, that.bitOffsets)) + if (!Arrays.equals(this.bitOffsets, that.bitOffsets)) return false; return true; } - + /** * Returns a hash code for this <code>SinglePixelPackedSampleModel</code>. - * + * * @return A hash code. */ public int hashCode() @@ -562,7 +562,7 @@ public class SinglePixelPackedSampleModel extends SampleModel result = 37 * result + bitOffsets[i]; return result; } - + /** * Creates a String with some information about this SampleModel. * @return A String describing this SampleModel. @@ -579,7 +579,7 @@ public class SinglePixelPackedSampleModel extends SampleModel result.append(", mask[").append(i).append("]=0x").append( Integer.toHexString(bitMasks[i])); } - + result.append("]"); return result.toString(); } diff --git a/java/awt/image/TileObserver.java b/java/awt/image/TileObserver.java index 99aafbce8..769888e40 100644 --- a/java/awt/image/TileObserver.java +++ b/java/awt/image/TileObserver.java @@ -1,4 +1,4 @@ -/* TileObserver.java -- +/* TileObserver.java -- Copyright (C) 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. diff --git a/java/awt/image/WritableRaster.java b/java/awt/image/WritableRaster.java index 02789a3d1..68774f785 100644 --- a/java/awt/image/WritableRaster.java +++ b/java/awt/image/WritableRaster.java @@ -42,30 +42,30 @@ import java.awt.Rectangle; /** * A raster with methods to support updating pixel values. - * + * * @author Rolf W. Rasmussen (rolfwr@ii.uib.no) */ public class WritableRaster extends Raster { /** * Creates a new <code>WritableRaster</code>. - * + * * @param sampleModel the sample model. * @param origin the origin. */ - protected WritableRaster(SampleModel sampleModel, Point origin) + protected WritableRaster(SampleModel sampleModel, Point origin) { this(sampleModel, sampleModel.createDataBuffer(), origin); } - + /** * Creates a new <code>WritableRaster</code> instance. - * + * * @param sampleModel the sample model. * @param dataBuffer the data buffer. * @param origin the origin. */ - protected WritableRaster(SampleModel sampleModel, DataBuffer dataBuffer, + protected WritableRaster(SampleModel sampleModel, DataBuffer dataBuffer, Point origin) { this(sampleModel, dataBuffer, @@ -77,14 +77,14 @@ public class WritableRaster extends Raster /** * Creates a new <code>WritableRaster</code> instance. - * + * * @param sampleModel the sample model. * @param dataBuffer the data buffer. * @param aRegion the raster's bounds. * @param sampleModelTranslate the translation. * @param parent the parent. */ - protected WritableRaster(SampleModel sampleModel, + protected WritableRaster(SampleModel sampleModel, DataBuffer dataBuffer, Rectangle aRegion, Point sampleModelTranslate, @@ -95,14 +95,14 @@ public class WritableRaster extends Raster /** * Returns the raster's parent, cast as a {@link WritableRaster}. - * + * * @return The raster's parent. */ public WritableRaster getWritableParent() { return (WritableRaster) getParent(); } - + /** * @param childMinX * @param childMinY @@ -116,7 +116,7 @@ public class WritableRaster extends Raster } /** - * + * * @param parentX * @param parentY * @param w @@ -130,11 +130,11 @@ public class WritableRaster extends Raster int w, int h, int childMinX, int childMinY, int[] bandList) { // This mirrors the code from the super class - + if (parentX < minX || parentX + w > minX + width || parentY < minY || parentY + h > minY + height) throw new RasterFormatException("Child raster extends beyond parent"); - + SampleModel sm = (bandList == null) ? sampleModel : sampleModel.createSubsetSampleModel(bandList); @@ -147,7 +147,7 @@ public class WritableRaster extends Raster parentY), this); } - + public Raster createChild(int parentX, int parentY, int width, int height, int childMinX, int childMinY, int[] bandList) @@ -155,7 +155,7 @@ public class WritableRaster extends Raster if (parentX < minX || parentX + width > minX + this.width || parentY < minY || parentY + height > minY + this.height) throw new RasterFormatException("Child raster extends beyond parent"); - + SampleModel sm = (bandList == null) ? sampleModel : sampleModel.createSubsetSampleModel(bandList); @@ -169,7 +169,7 @@ public class WritableRaster extends Raster public void setDataElements(int x, int y, Object inData) { - sampleModel.setDataElements(x - sampleModelTranslateX, + sampleModel.setDataElements(x - sampleModelTranslateX, y - sampleModelTranslateY, inData, dataBuffer); } @@ -187,7 +187,7 @@ public class WritableRaster extends Raster } /** - * + * * @param srcRaster */ public void setRect(Raster srcRaster) @@ -196,31 +196,31 @@ public class WritableRaster extends Raster } /** - * + * * @param dx * @param dy * @param srcRaster */ - public void setRect(int dx, int dy, Raster srcRaster) + public void setRect(int dx, int dy, Raster srcRaster) { Rectangle targetUnclipped = new Rectangle(srcRaster.getMinX() + dx, srcRaster.getMinY() + dy, srcRaster.getWidth(), srcRaster.getHeight()); - + Rectangle target = getBounds().intersection(targetUnclipped); if (target.isEmpty()) return; - + int sx = target.x - dx; int sy = target.y - dy; - + // FIXME: Do tests on rasters and use get/set data instead. - + /* The JDK documentation seems to imply this implementation. (the trucation of higher bits), but an implementation using get/setDataElements would be more efficient. None of the implementations would do anything sensible when the sample models don't match. - + But this is probably not the place to consider such optimizations.*/ @@ -231,13 +231,13 @@ public class WritableRaster extends Raster } /** - * Sets the samples for the pixel at (x, y) in the raster to the specified - * values. - * + * Sets the samples for the pixel at (x, y) in the raster to the specified + * values. + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. * @param iArray the sample values (<code>null</code> not permitted). - * + * * @throws NullPointerException if <code>iArray</code> is <code>null</code>. */ public void setPixel(int x, int y, int[] iArray) @@ -247,13 +247,13 @@ public class WritableRaster extends Raster } /** - * Sets the samples for the pixel at (x, y) in the raster to the specified - * values. - * + * Sets the samples for the pixel at (x, y) in the raster to the specified + * values. + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. * @param fArray the sample values (<code>null</code> not permitted). - * + * * @throws NullPointerException if <code>fArray</code> is <code>null</code>. */ public void setPixel(int x, int y, float[] fArray) @@ -263,13 +263,13 @@ public class WritableRaster extends Raster } /** - * Sets the samples for the pixel at (x, y) in the raster to the specified - * values. - * + * Sets the samples for the pixel at (x, y) in the raster to the specified + * values. + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. * @param dArray the sample values (<code>null</code> not permitted). - * + * * @throws NullPointerException if <code>dArray</code> is <code>null</code>. */ public void setPixel(int x, int y, double[] dArray) @@ -279,17 +279,17 @@ public class WritableRaster extends Raster } /** - * Sets the sample values for the pixels in the region specified by - * (x, y, w, h) in the raster. The array is ordered by pixels (that is, all - * the samples for the first pixel are grouped together, followed by all the - * samples for the second pixel, and so on). - * + * Sets the sample values for the pixels in the region specified by + * (x, y, w, h) in the raster. The array is ordered by pixels (that is, all + * the samples for the first pixel are grouped together, followed by all the + * samples for the second pixel, and so on). + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. * @param iArray the pixel sample values (<code>null</code> not permitted). - * + * * @throws NullPointerException if <code>iArray</code> is <code>null</code>. */ public void setPixels(int x, int y, int w, int h, int[] iArray) @@ -299,17 +299,17 @@ public class WritableRaster extends Raster } /** - * Sets the sample values for the pixels in the region specified by - * (x, y, w, h) in the raster. The array is ordered by pixels (that is, all - * the samples for the first pixel are grouped together, followed by all the - * samples for the second pixel, and so on). - * + * Sets the sample values for the pixels in the region specified by + * (x, y, w, h) in the raster. The array is ordered by pixels (that is, all + * the samples for the first pixel are grouped together, followed by all the + * samples for the second pixel, and so on). + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. * @param fArray the pixel sample values (<code>null</code> not permitted). - * + * * @throws NullPointerException if <code>fArray</code> is <code>null</code>. */ public void setPixels(int x, int y, int w, int h, float[] fArray) @@ -319,17 +319,17 @@ public class WritableRaster extends Raster } /** - * Sets the sample values for the pixels in the region specified by - * (x, y, w, h) in the raster. The array is ordered by pixels (that is, all - * the samples for the first pixel are grouped together, followed by all the - * samples for the second pixel, and so on). - * + * Sets the sample values for the pixels in the region specified by + * (x, y, w, h) in the raster. The array is ordered by pixels (that is, all + * the samples for the first pixel are grouped together, followed by all the + * samples for the second pixel, and so on). + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. * @param dArray the pixel sample values (<code>null</code> not permitted). - * + * * @throws NullPointerException if <code>dArray</code> is <code>null</code>. */ public void setPixels(int x, int y, int w, int h, double[] dArray) @@ -339,11 +339,11 @@ public class WritableRaster extends Raster } /** - * Sets the sample value for a band for the pixel at (x, y) in the raster. - * + * Sets the sample value for a band for the pixel at (x, y) in the raster. + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). * @param s the sample value. */ @@ -354,11 +354,11 @@ public class WritableRaster extends Raster } /** - * Sets the sample value for a band for the pixel at (x, y) in the raster. - * + * Sets the sample value for a band for the pixel at (x, y) in the raster. + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). * @param s the sample value. */ @@ -369,11 +369,11 @@ public class WritableRaster extends Raster } /** - * Sets the sample value for a band for the pixel at (x, y) in the raster. - * + * Sets the sample value for a band for the pixel at (x, y) in the raster. + * * @param x the x-coordinate of the pixel. * @param y the y-coordinate of the pixel. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * <code>getNumBands() - 1</code>). * @param s the sample value. */ @@ -384,17 +384,17 @@ public class WritableRaster extends Raster } /** - * Sets the sample values for one band for the pixels in the region - * specified by (x, y, w, h) in the raster. - * + * Sets the sample values for one band for the pixels in the region + * specified by (x, y, w, h) in the raster. + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * </code>getNumBands() - 1</code>). * @param iArray the sample values (<code>null</code> not permitted). - * + * * @throws NullPointerException if <code>iArray</code> is <code>null</code>. */ public void setSamples(int x, int y, int w, int h, int b, @@ -405,17 +405,17 @@ public class WritableRaster extends Raster } /** - * Sets the sample values for one band for the pixels in the region - * specified by (x, y, w, h) in the raster. - * + * Sets the sample values for one band for the pixels in the region + * specified by (x, y, w, h) in the raster. + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * </code>getNumBands() - 1</code>). * @param fArray the sample values (<code>null</code> not permitted). - * + * * @throws NullPointerException if <code>fArray</code> is <code>null</code>. */ public void setSamples(int x, int y, int w, int h, int b, @@ -426,17 +426,17 @@ public class WritableRaster extends Raster } /** - * Sets the sample values for one band for the pixels in the region - * specified by (x, y, w, h) in the raster. - * + * Sets the sample values for one band for the pixels in the region + * specified by (x, y, w, h) in the raster. + * * @param x the x-coordinate of the top-left pixel. * @param y the y-coordinate of the top-left pixel. * @param w the width of the region of pixels. * @param h the height of the region of pixels. - * @param b the band (in the range <code>0</code> to + * @param b the band (in the range <code>0</code> to * </code>getNumBands() - 1</code>). * @param dArray the sample values (<code>null</code> not permitted). - * + * * @throws NullPointerException if <code>dArray</code> is <code>null</code>. */ public void setSamples(int x, int y, int w, int h, int b, diff --git a/java/awt/image/WritableRenderedImage.java b/java/awt/image/WritableRenderedImage.java index 4ed9f1013..9142fe004 100644 --- a/java/awt/image/WritableRenderedImage.java +++ b/java/awt/image/WritableRenderedImage.java @@ -1,4 +1,4 @@ -/* WritableRenderedImage.java -- +/* WritableRenderedImage.java -- Copyright (C) 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. diff --git a/java/awt/image/renderable/ContextualRenderedImageFactory.java b/java/awt/image/renderable/ContextualRenderedImageFactory.java index 729d857ac..8852bef1c 100644 --- a/java/awt/image/renderable/ContextualRenderedImageFactory.java +++ b/java/awt/image/renderable/ContextualRenderedImageFactory.java @@ -1,4 +1,4 @@ -/* ContextualRenderedImageFactory.java -- +/* ContextualRenderedImageFactory.java -- Copyright (C) 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. diff --git a/java/awt/image/renderable/ParameterBlock.java b/java/awt/image/renderable/ParameterBlock.java index e484d6b87..f38077816 100644 --- a/java/awt/image/renderable/ParameterBlock.java +++ b/java/awt/image/renderable/ParameterBlock.java @@ -1,4 +1,4 @@ -/* ParameterBlock.java -- +/* ParameterBlock.java -- Copyright (C) 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. diff --git a/java/awt/image/renderable/RenderContext.java b/java/awt/image/renderable/RenderContext.java index 67f0b8adb..8017c1acf 100644 --- a/java/awt/image/renderable/RenderContext.java +++ b/java/awt/image/renderable/RenderContext.java @@ -1,4 +1,4 @@ -/* RenderContext.java -- +/* RenderContext.java -- Copyright (C) 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. diff --git a/java/awt/image/renderable/RenderableImage.java b/java/awt/image/renderable/RenderableImage.java index c2f6ad8b0..31767af2c 100644 --- a/java/awt/image/renderable/RenderableImage.java +++ b/java/awt/image/renderable/RenderableImage.java @@ -1,4 +1,4 @@ -/* RenderableImage.java -- +/* RenderableImage.java -- Copyright (C) 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -45,7 +45,7 @@ import java.util.Vector; public interface RenderableImage { String HINTS_OBSERVED = "HINTS_OBSERVED"; - + Vector<RenderableImage> getSources(); Object getProperty(String name); String[] getPropertyNames(); @@ -59,4 +59,3 @@ public interface RenderableImage RenderedImage createRendering(RenderContext context); } // interface RenderableImage - diff --git a/java/awt/image/renderable/RenderableImageOp.java b/java/awt/image/renderable/RenderableImageOp.java index b9d0cd39e..81e537cd5 100644 --- a/java/awt/image/renderable/RenderableImageOp.java +++ b/java/awt/image/renderable/RenderableImageOp.java @@ -1,4 +1,4 @@ -/* RenderableImageOp.java -- +/* RenderableImageOp.java -- Copyright (C) 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. diff --git a/java/awt/image/renderable/RenderableImageProducer.java b/java/awt/image/renderable/RenderableImageProducer.java index d8cca6535..bd3b507cb 100644 --- a/java/awt/image/renderable/RenderableImageProducer.java +++ b/java/awt/image/renderable/RenderableImageProducer.java @@ -1,4 +1,4 @@ -/* RenderableImageProducer.java -- +/* RenderableImageProducer.java -- Copyright (C) 2002, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. diff --git a/java/awt/image/renderable/RenderedImageFactory.java b/java/awt/image/renderable/RenderedImageFactory.java index 6ff4cb031..ea2bd69f7 100644 --- a/java/awt/image/renderable/RenderedImageFactory.java +++ b/java/awt/image/renderable/RenderedImageFactory.java @@ -1,4 +1,4 @@ -/* RenderedImageFactory.java -- +/* RenderedImageFactory.java -- Copyright (C) 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. |