Imported GNU Classpath 0.90

Imported GNU Classpath 0.90
       * scripts/makemake.tcl: LocaleData.java moved to gnu/java/locale.

       * sources.am: Regenerated.
       * gcj/javaprims.h: Regenerated.
       * Makefile.in: Regenerated.
       * gcj/Makefile.in: Regenerated.
       * include/Makefile.in: Regenerated.
       * testsuite/Makefile.in: Regenerated.

       * gnu/java/lang/VMInstrumentationImpl.java: New override.
       * gnu/java/net/local/LocalSocketImpl.java: Likewise.
       * gnu/classpath/jdwp/VMMethod.java: Likewise.
       * gnu/classpath/jdwp/VMVirtualMachine.java: Update to latest
       interface.
       * java/lang/Thread.java: Add UncaughtExceptionHandler.
       * java/lang/reflect/Method.java: Implements GenericDeclaration and
       isSynthetic(),
       * java/lang/reflect/Field.java: Likewise.
       * java/lang/reflect/Constructor.java
       * java/lang/Class.java: Implements Type, GenericDeclaration,
       getSimpleName() and getEnclosing*() methods.
       * java/lang/Class.h: Add new public methods.
       * java/lang/Math.java: Add signum(), ulp() and log10().
       * java/lang/natMath.cc (log10): New function.
       * java/security/VMSecureRandom.java: New override.
       * java/util/logging/Logger.java: Updated to latest classpath
       version.
       * java/util/logging/LogManager.java: New override.

From-SVN: r113887
This commit is contained in:
Mark Wielaard
2006-05-18 17:29:21 +00:00
parent eaec4980e1
commit 4f9533c772
1640 changed files with 126485 additions and 104808 deletions
@@ -347,7 +347,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp
* @param dstPt destination point
* @return the location of the transformed source point.
*/
public Point2D getPoint2D (Point2D srcPt, Point2D dstPt)
public final Point2D getPoint2D (Point2D srcPt, Point2D dstPt)
{
return transform.transform (srcPt, dstPt);
}
@@ -1,5 +1,5 @@
/* AreaAveragingScaleFilter.java -- Java class for filtering images
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999,2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -45,86 +45,225 @@ package java.awt.image;
* points should give the desired results although Sun does not
* specify what the exact algorithm should be.
* <br>
* FIXME: Currently this filter does nothing and needs to be implemented.
*
* @author C. Brian Jones (cbj@gnu.org)
*/
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
*/
public AreaAveragingScaleFilter(int width, int height) {
super(width, height);
}
/**
* 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
*/
public AreaAveragingScaleFilter(int width, int height) {
super(width, height);
}
/**
* 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>ImageConsumer</code> interface.
* <br>
* 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
*/
public void setHints(int flags)
{
if (consumer != null)
consumer.setHints(flags);
}
/**
* 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>ImageConsumer</code> interface.
* <br>
* 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
*/
public void setHints(int flags)
{
if (consumer != null)
consumer.setHints(flags);
}
/**
* 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).
*
* @param x the x coordinate of the rectangle
* @param y the y coordinate of the rectangle
* @param w the width of the rectangle
* @param h the height of the rectangle
* @param model the <code>ColorModel</code> used to translate the pixels
* @param pixels the array of pixel values
* @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)
{
if (consumer != null)
consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
}
/**
* 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).
*
* @param x the x coordinate of the rectangle
* @param y the y coordinate of the rectangle
* @param w the width of the rectangle
* @param h the height of the rectangle
* @param model the <code>ColorModel</code> used to translate the pixels
* @param pixels the array of pixel values
* @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)
{
double rx = ((double) srcWidth) / destWidth;
double ry = ((double) srcHeight) / destHeight;
/**
* 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).
*
* @param x the x coordinate of the rectangle
* @param y the y coordinate of the rectangle
* @param w the width of the rectangle
* @param h the height of the rectangle
* @param model the <code>ColorModel</code> used to translate the pixels
* @param pixels the array of pixel values
* @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)
{
if (consumer != null)
consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
}
int destScansize = (int) Math.round(scansize / rx);
byte[] destPixels = averagePixels(x, y, w, h,
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);
}
/**
* 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).
*
* @param x the x coordinate of the rectangle
* @param y the y coordinate of the rectangle
* @param w the width of the rectangle
* @param h the height of the rectangle
* @param model the <code>ColorModel</code> used to translate the pixels
* @param pixels the array of pixel values
* @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)
{
double rx = ((double) srcWidth) / destWidth;
double ry = ((double) srcHeight) / destHeight;
int destScansize = (int) Math.round(scansize / rx);
int[] destPixels = averagePixels(x, y, w, h,
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);
}
/**
* 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
* @param srcw, srch - Source rectangle width and height
* @param model - Pixel color model
* @param srcPixels - Source pixel data.
* @param srcOffset - Starting offset into the source pixel data array.
* @param srcScansize - Source array scanline size.
* @param rx,ry - Scaling factor.
* @param dstScansize - 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)
{
int destW = (int) Math.ceil(srcw/rx);
int destH = (int) Math.ceil(srch/ry);
byte[] destPixels = new byte[ 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);
// 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,
* since it uses the nearest-neighbor method. This filter is rarely used though.
*
* @param srcx, srcy - Source rectangle upper-left corner
* @param srcw, srch - Source rectangle width and height
* @param model - Pixel color model
* @param srcPixels - Source pixel data.
* @param srcOffset - Starting offset into the source pixel data array.
* @param srcScansize - Source array scanline size.
* @param rx,ry - Scaling factor.
* @param dstScansize - 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)
{
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);
}
return destPixels;
}
}
@@ -118,7 +118,7 @@ public class BandCombineOp implements RasterOp
/* (non-Javadoc)
* @see java.awt.image.RasterOp#getBounds2D(java.awt.image.Raster)
*/
public Rectangle2D getBounds2D(Raster src)
public final Rectangle2D getBounds2D(Raster src)
{
return src.getBounds();
}
@@ -144,7 +144,7 @@ public class BandCombineOp implements RasterOp
* @see java.awt.image.RasterOp#getPoint2D(java.awt.geom.Point2D,
*java.awt.geom.Point2D)
*/
public Point2D getPoint2D(Point2D src, Point2D dst)
public final Point2D getPoint2D(Point2D src, Point2D dst)
{
if (dst == null) return (Point2D)src.clone();
dst.setLocation(src);
@@ -154,13 +154,13 @@ public class BandCombineOp implements RasterOp
/* (non-Javadoc)
* @see java.awt.image.RasterOp#getRenderingHints()
*/
public RenderingHints getRenderingHints()
public final RenderingHints getRenderingHints()
{
return hints;
}
/** Return the matrix for this Op. */
public float[][] getMatrix()
public final float[][] getMatrix()
{
return matrix;
}
@@ -452,8 +452,14 @@ public abstract class ColorModel implements Transparency
* This method is typically overriden in subclasses to provide a
* more efficient implementation.
*
* @param array of transferType containing a single pixel. The
* pixel should be encoded in the natural way of the color model.
* @param pixel an array of transferType containing a single pixel. The
* pixel should be encoded in the natural way of the color model. If
* this argument is not an array, as expected, a {@link ClassCastException}
* will be thrown.
* @param components an array that will be filled with the color component
* 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
@@ -521,8 +527,8 @@ public abstract class ColorModel implements Transparency
float[] normComponents,
int normOffset)
{
// subclasses has to implement this method.
throw new UnsupportedOperationException();
int[] components = getComponents(pixel, null, 0);
return getNormalizedComponents(components, 0, normComponents, normOffset);
}
/**
File diff suppressed because it is too large Load Diff
@@ -110,7 +110,7 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
* @see java.awt.image.BufferedImageOp#filter(java.awt.image.BufferedImage,
* java.awt.image.BufferedImage)
*/
public BufferedImage filter(BufferedImage src, BufferedImage dst)
public final BufferedImage filter(BufferedImage src, BufferedImage dst)
{
if (src == dst)
throw new IllegalArgumentException();
@@ -163,7 +163,7 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
/* (non-Javadoc)
* @see java.awt.image.RasterOp#getRenderingHints()
*/
public RenderingHints getRenderingHints()
public final RenderingHints getRenderingHints()
{
return hints;
}
@@ -181,7 +181,7 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
*
* @return The convolution kernel.
*/
public Kernel getKernel()
public final Kernel getKernel()
{
return (Kernel) kernel.clone();
}
@@ -190,7 +190,7 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
* @see java.awt.image.RasterOp#filter(java.awt.image.Raster,
* java.awt.image.WritableRaster)
*/
public WritableRaster filter(Raster src, WritableRaster dest) {
public final WritableRaster filter(Raster src, WritableRaster dest) {
if (src == dest)
throw new IllegalArgumentException();
if (src.getWidth() < kernel.getWidth() ||
@@ -309,7 +309,7 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
/* (non-Javadoc)
* @see java.awt.image.BufferedImageOp#getBounds2D(java.awt.image.BufferedImage)
*/
public Rectangle2D getBounds2D(BufferedImage src)
public final Rectangle2D getBounds2D(BufferedImage src)
{
return src.getRaster().getBounds();
}
@@ -317,7 +317,7 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
/* (non-Javadoc)
* @see java.awt.image.RasterOp#getBounds2D(java.awt.image.Raster)
*/
public Rectangle2D getBounds2D(Raster src)
public final Rectangle2D getBounds2D(Raster src)
{
return src.getBounds();
}
@@ -330,7 +330,7 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
* @see java.awt.image.RasterOp#getPoint2D(java.awt.geom.Point2D,
* java.awt.geom.Point2D)
*/
public Point2D getPoint2D(Point2D src, Point2D dst)
public final Point2D getPoint2D(Point2D src, Point2D dst)
{
if (dst == null) return (Point2D)src.clone();
dst.setLocation(src);
@@ -167,7 +167,7 @@ public class DirectColorModel extends PackedColorModel
private int extractAndNormalizeSample(int pixel, int component)
{
int value = extractAndScaleSample(pixel, component);
if (hasAlpha() && isAlphaPremultiplied())
if (hasAlpha() && isAlphaPremultiplied() && getAlpha(pixel) != 0)
value = value*255/getAlpha(pixel);
return value;
}
@@ -81,7 +81,7 @@ public class LookupOp implements BufferedImageOp, RasterOp
/* (non-Javadoc)
* @see java.awt.image.BufferedImageOp#filter(java.awt.image.BufferedImage, java.awt.image.BufferedImage)
*/
public BufferedImage filter(BufferedImage src, BufferedImage dst)
public final BufferedImage filter(BufferedImage src, BufferedImage dst)
{
if (src.getColorModel() instanceof IndexColorModel)
throw new IllegalArgumentException("LookupOp.filter: IndexColorModel "
@@ -149,7 +149,7 @@ public class LookupOp implements BufferedImageOp, RasterOp
/* (non-Javadoc)
* @see java.awt.image.BufferedImageOp#getBounds2D(java.awt.image.BufferedImage)
*/
public Rectangle2D getBounds2D(BufferedImage src)
public final Rectangle2D getBounds2D(BufferedImage src)
{
return src.getRaster().getBounds();
}
@@ -173,7 +173,7 @@ public class LookupOp implements BufferedImageOp, RasterOp
* @param dst The destination point.
* @see java.awt.image.RasterOp#getPoint2D(java.awt.geom.Point2D, java.awt.geom.Point2D)
*/
public Point2D getPoint2D(Point2D src, Point2D dst)
public final Point2D getPoint2D(Point2D src, Point2D dst)
{
if (dst == null)
return (Point2D) src.clone();
@@ -183,7 +183,7 @@ public class LookupOp implements BufferedImageOp, RasterOp
}
/** Return the LookupTable for this op. */
public LookupTable getTable()
public final LookupTable getTable()
{
return lut;
}
@@ -191,7 +191,7 @@ public class LookupOp implements BufferedImageOp, RasterOp
/* (non-Javadoc)
* @see java.awt.image.RasterOp#getRenderingHints()
*/
public RenderingHints getRenderingHints()
public final RenderingHints getRenderingHints()
{
return hints;
}
@@ -209,7 +209,7 @@ public class LookupOp implements BufferedImageOp, RasterOp
* component but not the same as src and dest.
* @see java.awt.image.RasterOp#filter(java.awt.image.Raster, java.awt.image.WritableRaster)
*/
public WritableRaster filter(Raster src, WritableRaster dest)
public final WritableRaster filter(Raster src, WritableRaster dest)
{
if (dest == null)
// Allocate a raster if needed
@@ -236,7 +236,7 @@ public class LookupOp implements BufferedImageOp, RasterOp
/* (non-Javadoc)
* @see java.awt.image.RasterOp#getBounds2D(java.awt.image.Raster)
*/
public Rectangle2D getBounds2D(Raster src)
public final Rectangle2D getBounds2D(Raster src)
{
return src.getBounds();
}
@@ -46,7 +46,6 @@ import java.util.Hashtable;
* exact method is not defined by Sun but some sort of fast Box filter should
* probably be correct.
* <br>
* Currently this filter does nothing and needs to be implemented.
*
* @author C. Brian Jones (cbj@gnu.org)
*/
@@ -93,7 +93,7 @@ public class RescaleOp implements BufferedImageOp, RasterOp
/* (non-Javadoc)
* @see java.awt.image.BufferedImageOp#getRenderingHints()
*/
public RenderingHints getRenderingHints()
public final RenderingHints getRenderingHints()
{
return hints;
}
+218 -178
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2000, 2001, 2002, 2005 Free Software Foundation
/* Copyright (C) 2000, 2001, 2002, 2005, 2006, Free Software Foundation
This file is part of GNU Classpath.
@@ -57,15 +57,43 @@ public abstract class SampleModel
*/
protected int dataType;
/**
* 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_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
* 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
* to zero.
* @throws IllegalArgumentException if <code>w * h</code> is greater than
* {@link Integer#MAX_VALUE}.
*/
public SampleModel(int dataType, int w, int h, int numBands)
{
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))
throw new IllegalArgumentException((w <= 0 ? " width<=0" : " width is ok")
+(h <= 0 ? " height<=0" : " height is ok"));
// FIXME: How can an int be greater than Integer.MAX_VALUE?
// FIXME: How do we identify an unsupported data type?
+ (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;
@@ -102,8 +130,10 @@ public abstract class SampleModel
public int[] getPixel(int x, int y, int[] iArray, DataBuffer data)
{
if (iArray == null) iArray = new int[numBands];
for (int b=0; b<numBands; b++) iArray[b] = getSample(x, y, b, data);
if (iArray == null)
iArray = new int[numBands];
for (int b = 0; b < numBands; b++)
iArray[b] = getSample(x, y, b, data);
return iArray;
}
@@ -121,94 +151,95 @@ public abstract class SampleModel
* DataBuffer.TYPE_USHORT, then a short[] object is returned.
*/
public abstract Object getDataElements(int x, int y, Object obj,
DataBuffer data);
DataBuffer data);
public Object getDataElements(int x, int y, int w, int h, Object obj,
DataBuffer data)
DataBuffer data)
{
int size = w*h;
int size = w * h;
int numDataElements = getNumDataElements();
int dataSize = numDataElements*size;
int dataSize = numDataElements * size;
if (obj == null)
{
switch (getTransferType())
{
case DataBuffer.TYPE_BYTE:
obj = new byte[dataSize];
break;
case DataBuffer.TYPE_USHORT:
obj = new short[dataSize];
break;
case DataBuffer.TYPE_INT:
obj = new int[dataSize];
break;
default:
// Seems like the only sensible thing to do.
throw new ClassCastException();
}
switch (getTransferType())
{
case DataBuffer.TYPE_BYTE:
obj = new byte[dataSize];
break;
case DataBuffer.TYPE_USHORT:
obj = new short[dataSize];
break;
case DataBuffer.TYPE_INT:
obj = new int[dataSize];
break;
default:
// Seems like the only sensible thing to do.
throw new ClassCastException();
}
}
Object pixelData = null;
int outOffset = 0;
for (int yy = y; yy<(y+h); yy++)
for (int yy = y; yy < (y + h); yy++)
{
for (int xx = x; xx<(x+w); xx++)
{
pixelData = getDataElements(xx, yy, pixelData, data);
System.arraycopy(pixelData, 0, obj, outOffset,
numDataElements);
outOffset += numDataElements;
}
for (int xx = x; xx < (x + w); xx++)
{
pixelData = getDataElements(xx, yy, pixelData, data);
System.arraycopy(pixelData, 0, obj, outOffset,
numDataElements);
outOffset += numDataElements;
}
}
return obj;
}
public abstract void setDataElements(int x, int y, Object obj,
DataBuffer data);
DataBuffer data);
public void setDataElements(int x, int y, int w, int h,
Object obj, DataBuffer data)
Object obj, DataBuffer data)
{
int size = w*h;
int size = w * h;
int numDataElements = getNumDataElements();
int dataSize = numDataElements*size;
int dataSize = numDataElements * size;
Object pixelData;
switch (getTransferType())
{
case DataBuffer.TYPE_BYTE:
pixelData = new byte[numDataElements];
break;
pixelData = new byte[numDataElements];
break;
case DataBuffer.TYPE_USHORT:
pixelData = new short[numDataElements];
break;
pixelData = new short[numDataElements];
break;
case DataBuffer.TYPE_INT:
pixelData = new int[numDataElements];
break;
pixelData = new int[numDataElements];
break;
default:
// Seems like the only sensible thing to do.
throw new ClassCastException();
// Seems like the only sensible thing to do.
throw new ClassCastException();
}
int inOffset = 0;
for (int yy=y; yy<(y+h); yy++)
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
System.arraycopy(obj, inOffset, pixelData, 0,
numDataElements);
setDataElements(xx, yy, pixelData, data);
inOffset += numDataElements;
}
for (int xx = x; xx < (x + w); xx++)
{
System.arraycopy(obj, inOffset, pixelData, 0,
numDataElements);
setDataElements(xx, yy, pixelData, data);
inOffset += numDataElements;
}
}
}
public float[] getPixel(int x, int y, float[] fArray, DataBuffer data)
{
if (fArray == null) fArray = new float[numBands];
if (fArray == null)
fArray = new float[numBands];
for (int b=0; b<numBands; b++)
for (int b = 0; b < numBands; b++)
{
fArray[b] = getSampleFloat(x, y, b, data);
}
@@ -216,10 +247,11 @@ public abstract class SampleModel
}
public double[] getPixel(int x, int y, double[] dArray, DataBuffer data) {
if (dArray == null) dArray = new double[numBands];
for (int b=0; b<numBands; b++)
if (dArray == null)
dArray = new double[numBands];
for (int b = 0; b < numBands; b++)
{
dArray[b] = getSampleDouble(x, y, b, data);
dArray[b] = getSampleDouble(x, y, b, data);
}
return dArray;
}
@@ -227,20 +259,21 @@ public abstract class SampleModel
/* FIXME: Should it return a banded or pixel interleaved array of
samples? (Assume interleaved.) */
public int[] getPixels(int x, int y, int w, int h, int[] iArray,
DataBuffer data)
DataBuffer data)
{
int size = w*h;
int size = w * h;
int outOffset = 0;
int[] pixel = null;
if (iArray == null) iArray = new int[w*h*numBands];
for (int yy=y; yy<(y+h); yy++)
if (iArray == null)
iArray = new int[w * h * numBands];
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
pixel = getPixel(xx, yy, pixel, data);
System.arraycopy(pixel, 0, iArray, outOffset, numBands);
outOffset += numBands;
}
for (int xx = x; xx < (x + w); xx++)
{
pixel = getPixel(xx, yy, pixel, data);
System.arraycopy(pixel, 0, iArray, outOffset, numBands);
outOffset += numBands;
}
}
return iArray;
}
@@ -248,20 +281,20 @@ public abstract class SampleModel
/* FIXME: Should it return a banded or pixel interleaved array of
samples? (Assume interleaved.) */
public float[] getPixels(int x, int y, int w, int h, float[] fArray,
DataBuffer data)
DataBuffer data)
{
int size = w*h;
int size = w * h;
int outOffset = 0;
float[] pixel = null;
if (fArray == null) fArray = new float[w*h*numBands];
for (int yy=y; yy<(y+h); yy++)
if (fArray == null) fArray = new float[w * h * numBands];
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
pixel = getPixel(xx, yy, pixel, data);
System.arraycopy(pixel, 0, fArray, outOffset, numBands);
outOffset += numBands;
}
for (int xx = x; xx < (x + w); xx++)
{
pixel = getPixel(xx, yy, pixel, data);
System.arraycopy(pixel, 0, fArray, outOffset, numBands);
outOffset += numBands;
}
}
return fArray;
}
@@ -269,20 +302,21 @@ public abstract class SampleModel
/* FIXME: Should it return a banded or pixel interleaved array of
samples? (Assume interleaved.) */
public double[] getPixels(int x, int y, int w, int h, double[] dArray,
DataBuffer data)
DataBuffer data)
{
int size = w*h;
int size = w * h;
int outOffset = 0;
double[] pixel = null;
if (dArray == null) dArray = new double[w*h*numBands];
for (int yy=y; yy<(y+h); yy++)
if (dArray == null)
dArray = new double[w * h * numBands];
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
pixel = getPixel(xx, yy, pixel, data);
System.arraycopy(pixel, 0, dArray, outOffset, numBands);
outOffset += numBands;
}
for (int xx = x; xx < (x + w); xx++)
{
pixel = getPixel(xx, yy, pixel, data);
System.arraycopy(pixel, 0, dArray, outOffset, numBands);
outOffset += numBands;
}
}
return dArray;
}
@@ -300,179 +334,185 @@ public abstract class SampleModel
}
public int[] getSamples(int x, int y, int w, int h, int b,
int[] iArray, DataBuffer data)
int[] iArray, DataBuffer data)
{
int size = w*h;
int size = w * h;
int outOffset = 0;
if (iArray == null) iArray = new int[size];
for (int yy=y; yy<(y+h); yy++)
if (iArray == null)
iArray = new int[size];
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
iArray[outOffset++] = getSample(xx, yy, b, data);
}
for (int xx = x; xx < (x + w); xx++)
{
iArray[outOffset++] = getSample(xx, yy, b, data);
}
}
return iArray;
}
public float[] getSamples(int x, int y, int w, int h, int b,
float[] fArray, DataBuffer data)
float[] fArray, DataBuffer data)
{
int size = w*h;
int size = w * h;
int outOffset = 0;
if (fArray == null) fArray = new float[size];
for (int yy=y; yy<(y+h); yy++)
if (fArray == null)
fArray = new float[size];
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
fArray[outOffset++] = getSampleFloat(xx, yy, b, data);
}
for (int xx = x; xx < (x + w); xx++)
{
fArray[outOffset++] = getSampleFloat(xx, yy, b, data);
}
}
return fArray;
}
public double[] getSamples(int x, int y, int w, int h, int b,
double[] dArray, DataBuffer data)
double[] dArray, DataBuffer data)
{
int size = w*h;
int size = w * h;
int outOffset = 0;
if (dArray == null) dArray = new double[size];
for (int yy=y; yy<(y+h); yy++)
if (dArray == null)
dArray = new double[size];
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
dArray[outOffset++] = getSampleDouble(xx, yy, b, data);
}
for (int xx = x; xx < (x + w); xx++)
{
dArray[outOffset++] = getSampleDouble(xx, yy, b, data);
}
}
return dArray;
}
public void setPixel(int x, int y, int[] iArray, DataBuffer data)
{
for (int b=0; b<numBands; b++) setSample(x, y, b, iArray[b], data);
for (int b = 0; b < numBands; b++)
setSample(x, y, b, iArray[b], data);
}
public void setPixel(int x, int y, float[] fArray, DataBuffer data)
{
for (int b=0; b<numBands; b++) setSample(x, y, b, fArray[b], data);
for (int b = 0; b < numBands; b++)
setSample(x, y, b, fArray[b], data);
}
public void setPixel(int x, int y, double[] dArray, DataBuffer data)
{
for (int b=0; b<numBands; b++) setSample(x, y, b, dArray[b], data);
for (int b = 0; b < numBands; b++)
setSample(x, y, b, dArray[b], data);
}
public void setPixels(int x, int y, int w, int h, int[] iArray,
DataBuffer data)
DataBuffer data)
{
int inOffset = 0;
int[] pixel = new int[numBands];
for (int yy=y; yy<(y+h); yy++)
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
System.arraycopy(iArray, inOffset, pixel, 0, numBands);
setPixel(xx, yy, pixel, data);
inOffset += numBands;
}
for (int xx = x; xx < (x + w); xx++)
{
System.arraycopy(iArray, inOffset, pixel, 0, numBands);
setPixel(xx, yy, pixel, data);
inOffset += numBands;
}
}
}
public void setPixels(int x, int y, int w, int h, float[] fArray,
DataBuffer data)
DataBuffer data)
{
int inOffset = 0;
float[] pixel = new float[numBands];
for (int yy=y; yy<(y+h); yy++)
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
System.arraycopy(fArray, inOffset, pixel, 0, numBands);
setPixel(xx, yy, pixel, data);
inOffset += numBands;
}
for (int xx = x; xx < (x + w); xx++)
{
System.arraycopy(fArray, inOffset, pixel, 0, numBands);
setPixel(xx, yy, pixel, data);
inOffset += numBands;
}
}
}
public void setPixels(int x, int y, int w, int h, double[] dArray,
DataBuffer data)
DataBuffer data)
{
int inOffset = 0;
double[] pixel = new double[numBands];
for (int yy=y; yy<(y+h); yy++)
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
System.arraycopy(dArray, inOffset, pixel, 0, numBands);
setPixel(xx, yy, pixel, data);
inOffset += numBands;
}
for (int xx = x; xx < (x + w); xx++)
{
System.arraycopy(dArray, inOffset, pixel, 0, numBands);
setPixel(xx, yy, pixel, data);
inOffset += numBands;
}
}
}
public abstract void setSample(int x, int y, int b, int s,
DataBuffer data);
DataBuffer data);
public void setSample(int x, int y, int b, float s,
DataBuffer data)
DataBuffer data)
{
setSample(x, y, b, (int) s, data);
}
public void setSample(int x, int y, int b, double s,
DataBuffer data)
DataBuffer data)
{
setSample(x, y, b, (float) s, data);
}
public void setSamples(int x, int y, int w, int h, int b,
int[] iArray, DataBuffer data)
int[] iArray, DataBuffer data)
{
int size = w*h;
int size = w * h;
int inOffset = 0;
for (int yy=y; yy<(y+h); yy++)
for (int xx=x; xx<(x+w); xx++)
setSample(xx, yy, b, iArray[inOffset++], data);
for (int yy = y; yy < (y + h); yy++)
for (int xx = x; xx < (x + w); xx++)
setSample(xx, yy, b, iArray[inOffset++], data);
}
public void setSamples(int x, int y, int w, int h, int b,
float[] fArray, DataBuffer data)
float[] fArray, DataBuffer data)
{
int size = w*h;
int size = w * h;
int inOffset = 0;
for (int yy=y; yy<(y+h); yy++)
for (int xx=x; xx<(x+w); xx++)
setSample(xx, yy, b, fArray[inOffset++], data);
for (int yy = y; yy < (y + h); yy++)
for (int xx = x; xx < (x + w); xx++)
setSample(xx, yy, b, fArray[inOffset++], data);
}
}
public void setSamples(int x, int y, int w, int h, int b,
double[] dArray, DataBuffer data) {
int size = w*h;
int inOffset = 0;
for (int yy=y; yy<(y+h); yy++)
for (int xx=x; xx<(x+w); xx++)
setSample(xx, yy, b, dArray[inOffset++], data);
}
public void setSamples(int x, int y, int w, int h, int b,
double[] dArray, DataBuffer data) {
int size = w * h;
int inOffset = 0;
for (int yy = y; yy < (y + h); yy++)
for (int xx = x; xx < (x + w); xx++)
setSample(xx, yy, b, dArray[inOffset++], data);
}
public abstract SampleModel createCompatibleSampleModel(int w, int h);
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);
/**
* 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);
public abstract DataBuffer createDataBuffer();
public abstract DataBuffer createDataBuffer();
public abstract int[] getSampleSize();
public abstract int[] getSampleSize();
public abstract int getSampleSize(int band);
public abstract int getSampleSize(int band);
}
@@ -1,5 +1,5 @@
/* RenderableImageProducer.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,42 +38,129 @@ exception statement from your version. */
package java.awt.image.renderable;
import java.awt.image.ColorModel;
import java.awt.image.DataBuffer;
import java.awt.image.ImageConsumer;
import java.awt.image.ImageProducer;
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
import java.awt.image.SampleModel;
import java.util.ArrayList;
import java.util.Iterator;
public class RenderableImageProducer implements ImageProducer, Runnable
{
private RenderableImage image;
private RenderContext context;
private ArrayList consumers = new ArrayList();
public RenderableImageProducer(RenderableImage image, RenderContext context)
{
throw new Error("not implemented");
this.image = image;
this.context = context;
}
public void setRenderContext(RenderContext context)
{
this.context = context;
}
public void addConsumer(ImageConsumer consumer)
{
synchronized (consumers)
{
if (! consumers.contains(consumer))
consumers.add(consumer);
}
}
public boolean isConsumer(ImageConsumer consumer)
{
return false;
synchronized (consumers)
{
return consumers.contains(consumer);
}
}
public void removeConsumer(ImageConsumer consumer)
{
synchronized (consumers)
{
consumers.remove(consumer);
}
}
public void startProduction(ImageConsumer consumer)
{
addConsumer(consumer);
Thread t = new Thread(this, "RenderableImageProducerWorker");
t.start();
}
public void requestTopDownLeftRightResend(ImageConsumer consumer)
{
// Do nothing. The contract says we can ignore this call, so we do.
}
public void run()
{
// This isn't ideal but it avoids fail-fast problems.
// Alternatively, we could clone 'consumers' here.
synchronized (consumers)
{
RenderedImage newImage;
if (context == null)
newImage = image.createDefaultRendering();
else
newImage = image.createRendering(context);
Raster newData = newImage.getData();
ColorModel colorModel = newImage.getColorModel();
if (colorModel == null)
colorModel = ColorModel.getRGBdefault();
SampleModel sampleModel = newData.getSampleModel();
DataBuffer dataBuffer = newData.getDataBuffer();
int width = newData.getWidth();
int height = newData.getHeight();
// Initialize the consumers.
Iterator it = consumers.iterator();
while (it.hasNext())
{
ImageConsumer target = (ImageConsumer) it.next();
target.setHints(ImageConsumer.COMPLETESCANLINES
| ImageConsumer.SINGLEFRAME
| ImageConsumer.SINGLEPASS
| ImageConsumer.TOPDOWNLEFTRIGHT);
target.setDimensions(width, height);
}
// Work in scan-line order.
int[] newLine = new int[width];
int[] bands = new int[sampleModel.getNumBands()];
for (int y = 0; y < height; ++y)
{
for (int x = 0; x < width; ++x)
{
sampleModel.getPixel(x, y, bands, dataBuffer);
newLine[x] = colorModel.getDataElement(bands, 0);
}
// Tell the consumers about the new scan line.
it = consumers.iterator();
while (it.hasNext())
{
ImageConsumer target = (ImageConsumer) it.next();
target.setPixels(0, y, width, 1, colorModel, newLine, 0, width);
}
}
// Tell the consumers that we're done.
it = consumers.iterator();
while (it.hasNext())
{
ImageConsumer target = (ImageConsumer) it.next();
target.imageComplete(ImageConsumer.STATICIMAGEDONE);
}
}
}
} // class RenderableImageProducer