Commit 152d4916 by Tom Tromey Committed by Tom Tromey

Makefile.in: Rebuilt.

	* Makefile.in: Rebuilt.
	* Makefile.am (awt_java_source_files): Added new files.
	* java/awt/image/AreaAveragingScaleFilter.java: New file from
	Classpath.
	* java/awt/image/CropImageFilter.java: New file from Classpath.
	* java/awt/image/FilteredImageSource.java: New file from
	Classpath.
	* java/awt/image/ImageFilter.java: New file from Classpath.
	* java/awt/image/MemoryImageSource.java: New file from Classpath.
	* java/awt/image/PixelGrabber.java: New file from Classpath.
	* java/awt/image/RGBImageFilter.java: New file from Classpath.
	* java/awt/image/ReplicateScaleFilter.java: New file from
	Classpath.
	* java/awt/image/ImageProducer.java: Replaced with Classpath
	version.
	* java/awt/image/ImageObserver.java: Replaced with Classpath
	version.
	* java/awt/image/ImageConsumer.java: Replaced with Classpath
	version.
	* java/awt/GridBagConstraints.java (clone): Catch
	CloneNotSupportedException.

From-SVN: r49157
parent aac0eb5d
2002-01-23 Tom Tromey <tromey@redhat.com>
* Makefile.in: Rebuilt.
* Makefile.am (awt_java_source_files): Added new files.
* java/awt/image/AreaAveragingScaleFilter.java: New file from
Classpath.
* java/awt/image/CropImageFilter.java: New file from Classpath.
* java/awt/image/FilteredImageSource.java: New file from
Classpath.
* java/awt/image/ImageFilter.java: New file from Classpath.
* java/awt/image/MemoryImageSource.java: New file from Classpath.
* java/awt/image/PixelGrabber.java: New file from Classpath.
* java/awt/image/RGBImageFilter.java: New file from Classpath.
* java/awt/image/ReplicateScaleFilter.java: New file from
Classpath.
* java/awt/image/ImageProducer.java: Replaced with Classpath
version.
* java/awt/image/ImageObserver.java: Replaced with Classpath
version.
* java/awt/image/ImageConsumer.java: Replaced with Classpath
version.
* java/awt/GridBagConstraints.java (clone): Catch
CloneNotSupportedException.
2002-01-23 Per Bothner <per@bothner.com>
* java/lang/reflect/natField.cc (setAddr): New function.
......
......@@ -726,22 +726,30 @@ java/awt/geom/Point2D.java \
java/awt/geom/Rectangle2D.java \
java/awt/geom/RectangularShape.java \
java/awt/geom/RoundRectangle2D.java \
java/awt/image/AreaAveragingScaleFilter.java \
java/awt/image/BufferedImage.java \
java/awt/image/ColorModel.java \
java/awt/image/ComponentColorModel.java \
java/awt/image/ComponentSampleModel.java \
java/awt/image/CropImageFilter.java \
java/awt/image/DataBuffer.java \
java/awt/image/DataBufferByte.java \
java/awt/image/DataBufferInt.java \
java/awt/image/DataBufferUShort.java \
java/awt/image/DirectColorModel.java \
java/awt/image/FilteredImageSource.java \
java/awt/image/ImageConsumer.java \
java/awt/image/ImageFilter.java \
java/awt/image/ImageObserver.java \
java/awt/image/ImageProducer.java \
java/awt/image/IndexColorModel.java \
java/awt/image/MemoryImageSource.java \
java/awt/image/PackedColorModel.java \
java/awt/image/PixelGrabber.java \
java/awt/image/RGBImageFilter.java \
java/awt/image/Raster.java \
java/awt/image/RasterOp.java \
java/awt/image/ReplicateScaleFilter.java \
java/awt/image/SampleModel.java \
java/awt/image/SinglePixelPackedSampleModel.java \
java/awt/image/WritableRaster.java \
......
......@@ -477,22 +477,30 @@ java/awt/geom/Point2D.java \
java/awt/geom/Rectangle2D.java \
java/awt/geom/RectangularShape.java \
java/awt/geom/RoundRectangle2D.java \
java/awt/image/AreaAveragingScaleFilter.java \
java/awt/image/BufferedImage.java \
java/awt/image/ColorModel.java \
java/awt/image/ComponentColorModel.java \
java/awt/image/ComponentSampleModel.java \
java/awt/image/CropImageFilter.java \
java/awt/image/DataBuffer.java \
java/awt/image/DataBufferByte.java \
java/awt/image/DataBufferInt.java \
java/awt/image/DataBufferUShort.java \
java/awt/image/DirectColorModel.java \
java/awt/image/FilteredImageSource.java \
java/awt/image/ImageConsumer.java \
java/awt/image/ImageFilter.java \
java/awt/image/ImageObserver.java \
java/awt/image/ImageProducer.java \
java/awt/image/IndexColorModel.java \
java/awt/image/MemoryImageSource.java \
java/awt/image/PackedColorModel.java \
java/awt/image/PixelGrabber.java \
java/awt/image/RGBImageFilter.java \
java/awt/image/Raster.java \
java/awt/image/RasterOp.java \
java/awt/image/ReplicateScaleFilter.java \
java/awt/image/SampleModel.java \
java/awt/image/SinglePixelPackedSampleModel.java \
java/awt/image/WritableRaster.java \
......@@ -2070,19 +2078,27 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/awt/geom/Rectangle2D.P \
.deps/java/awt/geom/RectangularShape.P \
.deps/java/awt/geom/RoundRectangle2D.P \
.deps/java/awt/image/AreaAveragingScaleFilter.P \
.deps/java/awt/image/BufferedImage.P .deps/java/awt/image/ColorModel.P \
.deps/java/awt/image/ComponentColorModel.P \
.deps/java/awt/image/ComponentSampleModel.P \
.deps/java/awt/image/CropImageFilter.P \
.deps/java/awt/image/DataBuffer.P .deps/java/awt/image/DataBufferByte.P \
.deps/java/awt/image/DataBufferInt.P \
.deps/java/awt/image/DataBufferUShort.P \
.deps/java/awt/image/DirectColorModel.P \
.deps/java/awt/image/ImageConsumer.P \
.deps/java/awt/image/FilteredImageSource.P \
.deps/java/awt/image/ImageConsumer.P .deps/java/awt/image/ImageFilter.P \
.deps/java/awt/image/ImageObserver.P \
.deps/java/awt/image/ImageProducer.P \
.deps/java/awt/image/IndexColorModel.P \
.deps/java/awt/image/PackedColorModel.P .deps/java/awt/image/Raster.P \
.deps/java/awt/image/RasterOp.P .deps/java/awt/image/SampleModel.P \
.deps/java/awt/image/MemoryImageSource.P \
.deps/java/awt/image/PackedColorModel.P \
.deps/java/awt/image/PixelGrabber.P \
.deps/java/awt/image/RGBImageFilter.P .deps/java/awt/image/Raster.P \
.deps/java/awt/image/RasterOp.P \
.deps/java/awt/image/ReplicateScaleFilter.P \
.deps/java/awt/image/SampleModel.P \
.deps/java/awt/image/SinglePixelPackedSampleModel.P \
.deps/java/awt/image/WritableRaster.P .deps/java/awt/peer/ButtonPeer.P \
.deps/java/awt/peer/CanvasPeer.P \
......
// GridBagConstraints.java - Constraints for GridBag layout manager
/* Copyright (C) 2000, 2001 Free Software Foundation
/* Copyright (C) 2000, 2001, 2002 Free Software Foundation
This file is part of GNU Classpath.
......@@ -93,9 +93,17 @@ public class GridBagConstraints implements Cloneable, Serializable
/** Create a copy of this object. */
public Object clone ()
{
GridBagConstraints g = (GridBagConstraints) super.clone ();
g.insets = (Insets) insets.clone ();
return g;
try
{
GridBagConstraints g = (GridBagConstraints) super.clone ();
g.insets = (Insets) insets.clone ();
return g;
}
catch (CloneNotSupportedException _)
{
// Can't happen.
return null;
}
}
/** Create a new GridBagConstraints object with the default
......
/* AreaAveragingScaleFilter.java -- Java class for filtering images
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
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
* specify what the exact algorithm should be.
* <br>
* 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);
}
/**
* 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)
{
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)
{
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 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)
{
consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
}
}
/* CropImageFilter.java -- Java class for cropping image filter
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.image;
import java.util.Hashtable;
/**
* <br>
* Currently this filter does almost nothing and needs to be implemented.
*
* @author C. Brian Jones (cbj@gnu.org)
*/
public class CropImageFilter extends ImageFilter
{
int x;
int y;
int width;
int height;
/**
* Construct a new <code>CropImageFilter</code> instance.
*
* @param x the x-coordinate location of the top-left of the cropped rectangle
* @param y the y-coordinate location of the top-left of the cropped rectangle
* @param width the width of the cropped rectangle
* @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;
}
/**
* An <code>ImageProducer</code> indicates the size of the image
* 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
*/
public void setDimensions(int width, int height)
{
consumer.setDimensions(this.width, this.height);
}
/**
* An <code>ImageProducer</code> can set a list of properties
* associated with this image by using this method.
* <br>
* FIXME - What property is set for this class?
*
* @param props the list of properties associated with this image
*/
public void setProperties(Hashtable props)
{
// props.put("filters", "ReplicateScaleFilter");
consumer.setProperties(props);
}
/**
* 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)
{
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 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)
{
consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
}
}
/* FilteredImageSource.java -- Java class for providing image data
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.image;
import java.util.Hashtable;
/**
*
* @see ImageConsumer
* @author C. Brian Jones (cbj@gnu.org)
*/
public class FilteredImageSource implements ImageProducer
{
ImageProducer ip;
ImageFilter filter;
Hashtable consumers = new Hashtable();
/**
* The given filter is applied to the given image producer
* to create a new image producer.
*/
public FilteredImageSource(ImageProducer ip, ImageFilter filter) {
this.ip = ip;
this.filter = filter;
}
/**
* Used to register an <code>ImageConsumer</code> with this
* <code>ImageProducer</code>.
*/
public synchronized void addConsumer(ImageConsumer ic) {
if (consumers.containsKey(ic))
return;
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>.
*/
public synchronized boolean isConsumer(ImageConsumer ic) {
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>.
*/
public synchronized void removeConsumer(ImageConsumer ic) {
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.
*/
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);
}
/**
* 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.
*/
public void requestTopDownLeftRightResend(ImageConsumer ic) {
ImageFilter f = (ImageFilter)consumers.get(ic);
ip.requestTopDownLeftRightResend(f);
}
}
/* ImageFilter.java -- Java class for filtering images
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.image;
import java.util.Hashtable;
/**
* The <code>ImageFilter</code> class is a base class which can be
* 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)
*/
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>.
*/
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.
* <ul>
* <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
* top-down, left-right order.</li>
* <li>The filter can do nothing when this method is called.</li>
* </ul>
*/
public void resendTopDownLeftRight(ImageProducer ip)
{
ip.requestTopDownLeftRightResend(this);
}
/**
* By default, returns a shallow copy of the object created by
* <code>Object.clone()</code>
*
* @see java.lang.Object#clone ()
*/
public Object clone() throws CloneNotSupportedException
{
return (super.clone());
}
/**
* 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.
*
* @see #clone ()
*/
public ImageFilter getFilterInstance(ImageConsumer ic)
{
if ( ic == null )
throw new IllegalArgumentException("null argument for ImageFilter.getFilterInstance(ImageConsumer)");
consumer = ic;
try {
ImageFilter f = (ImageFilter)clone();
consumer = null;
return f;
} catch ( CloneNotSupportedException cnse ) {
cnse.printStackTrace();
consumer = null;
return null;
}
}
/**
* An <code>ImageProducer</code> indicates the size of the image
* 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
*/
public void setDimensions(int width, int height)
{
consumer.setDimensions(width, height);
}
/**
* 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
*/
public void setProperties(Hashtable props)
{
props.put("filters", "ImageFilter");
consumer.setProperties(props);
}
/**
* Override this method to process calls to this method from the
* <code>ImageProducer</code>. By default the <code>setColorModel</code>
* method of the consumer is called with the specified <code>model</code>.
*
* @param model the color model to be used most often by setPixels
* @see ColorModel */
public void setColorModel(ColorModel model)
{
consumer.setColorModel(model);
}
/**
* 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.
*
* @param flags a bit mask of hints
* @see ImageConsumer
*/
public void setHints(int flags)
{
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)
{
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 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)
{
consumer.setPixels(x, y, w, h, model, pixels, offset, 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.
*/
public void imageComplete(int status)
{
consumer.imageComplete(status);
}
}
/* MemoryImageSource.java -- Java class for providing image data
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.image;
import java.awt.Image;
import java.util.Enumeration;
import java.util.Hashtable;
public class MemoryImageSource implements ImageProducer
{
private boolean animated = false;
private boolean fullbuffers = false;
private int pixeli[], width, height, offset, scansize;
private byte pixelb[];
private ColorModel cm;
private Hashtable props, consumers = new Hashtable();
/**
Constructs an ImageProducer from memory
*/
public MemoryImageSource(int w, int h, ColorModel cm,
byte pix[], int off, int scan)
{
this ( w, h, cm, pix, off, scan, null );
}
/**
Constructs an ImageProducer from memory
*/
public MemoryImageSource( int w, int h, ColorModel cm,
byte pix[], int off, int scan,
Hashtable props)
{
width = w;
height = h;
this.cm = cm;
offset = off;
scansize = scan;
this.props = props;
int max = (( scansize > width ) ? scansize : width );
pixelb = new byte[ max * height ];
System.arraycopy( pix, 0, pixelb, 0, max );
}
/**
Constructs an ImageProducer from memory
*/
public MemoryImageSource(int w, int h, ColorModel cm,
int pix[], int off, int scan)
{
this ( w, h, cm, pix, off, scan, null );
}
/**
Constructs an ImageProducer from memory
*/
public MemoryImageSource(int w, int h, ColorModel cm,
int pix[], int off, int scan,
Hashtable props)
{
width = w;
height = h;
this.cm = cm;
offset = off;
scansize = scan;
this.props = props;
int max = (( scansize > width ) ? scansize : width );
pixeli = new int[ max * height ];
System.arraycopy( pix, 0, pixeli, 0, max );
}
/**
Constructs an ImageProducer from memory using the default RGB ColorModel
*/
public MemoryImageSource(int w, int h,
int pix[], int off, int scan,
Hashtable props)
{
this ( w, h, ColorModel.getRGBdefault(), pix, off, scan, props);
}
/**
Constructs an ImageProducer from memory using the default RGB ColorModel
*/
public MemoryImageSource(int w, int h,
byte pix[], int off, int scan)
{
this ( w, h, ColorModel.getRGBdefault(), pix, off, scan, null);
}
/**
* Used to register an <code>ImageConsumer</code> with this
* <code>ImageProducer</code>.
*/
public synchronized void addConsumer(ImageConsumer ic) {
if (consumers.containsKey(ic))
return;
consumers.put(ic, ic);
}
/**
* Used to determine if the given <code>ImageConsumer</code> is
* already registered with this <code>ImageProducer</code>.
*/
public synchronized boolean isConsumer(ImageConsumer ic) {
if (consumers.containsKey(ic))
return true;
return false;
}
/**
* Used to remove an <code>ImageConsumer</code> from the list of
* registered consumers for this <code>ImageProducer</code>.
*/
public synchronized void removeConsumer(ImageConsumer ic) {
consumers.remove(ic);
}
/**
* 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.
*/
public void startProduction(ImageConsumer ic) {
if (!(consumers.containsKey(ic))) {
consumers.put(ic, ic);
}
Enumeration e = consumers.elements();
for( ; e.hasMoreElements(); ) {
ic = (ImageConsumer)e.nextElement();
sendPicture( ic );
ic.imageComplete( ImageConsumer.SINGLEFRAME );
}
}
/**
* 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.
*/
public void requestTopDownLeftRightResend(ImageConsumer ic) {
startProduction ( ic );
}
/**
Changes a flag to indicate whether this MemoryImageSource supports
animations.
@param animated A flag indicating whether this class supports animations
*/
public synchronized void setAnimated(boolean animated)
{
this.animated = animated;
}
/**
A flag to indicate whether or not to send full buffer updates when
sending animation. If this flag is set then full buffers are sent
in the newPixels methods instead of just regions.
@param fullbuffers - a flag indicating whether to send the full buffers
*/
public synchronized void setFullBufferUpdates(boolean fullbuffers)
{
this.fullbuffers = fullbuffers;
}
/**
Send an animation frame to the image consumers.
*/
public void newPixels()
{
if( animated == true ) {
ImageConsumer ic;
Enumeration e = consumers.elements();
for( ; e.hasMoreElements(); ) {
ic = (ImageConsumer)e.nextElement();
sendPicture( ic );
ic.imageComplete( ImageConsumer.SINGLEFRAME );
}
}
}
private void sendPicture ( ImageConsumer ic )
{
ic.setHints( ImageConsumer.TOPDOWNLEFTRIGHT );
if( props != null ) {
ic.setProperties( props );
}
if( pixeli != null ) {
ic.setPixels( 0, 0, width, height, cm, pixeli, offset, scansize );
} else {
ic.setPixels( 0, 0, width, height, cm, pixelb, offset, scansize );
}
}
/**
Send an animation frame to the image consumers containing the specified
pixels unless setFullBufferUpdates is set.
*/
public synchronized void newPixels(int x,
int y,
int w,
int h)
{
if( animated == true )
{
if( fullbuffers ) {
newPixels();
} else {
ImageConsumer ic;
Enumeration e = consumers.elements();
for( ; e.hasMoreElements(); ) {
ic = (ImageConsumer)e.nextElement();
ic.setHints( ImageConsumer.TOPDOWNLEFTRIGHT );
if( props != null ) {
ic.setProperties( props );
}
if( pixeli != null ) {
ic.setPixels( 0, 0, width, height, cm, pixeli, offset, scansize );
} else {
ic.setPixels( 0, 0, width, height, cm, pixelb, offset, scansize );
}
ic.imageComplete( ImageConsumer.SINGLEFRAME );
}
}
}
}
/**
Send an animation frame to the image consumers containing the specified
pixels unless setFullBufferUpdates is set.
If framenotify is set then a notification is sent when the frame
is sent otherwise no status is sent.
*/
public synchronized void newPixels(int x,
int y,
int w,
int h,
boolean framenotify)
{
if( animated == true )
{
if( fullbuffers ) {
newPixels();
} else {
ImageConsumer ic;
Enumeration e = consumers.elements();
for( ; e.hasMoreElements(); ) {
ic = (ImageConsumer)e.nextElement();
ic.setHints( ImageConsumer.TOPDOWNLEFTRIGHT );
if( props != null ) {
ic.setProperties( props );
}
if( pixeli != null ) {
ic.setPixels( 0, 0, width, height, cm, pixeli, offset, scansize );
} else {
ic.setPixels( 0, 0, width, height, cm, pixelb, offset, scansize );
}
if( framenotify == true )
ic.imageComplete( ImageConsumer.SINGLEFRAME );
}
}
}
}
public synchronized void newPixels(byte newpix[],
ColorModel newmodel,
int offset,
int scansize)
{
if( animated == true )
{
//FIXME
}
}
public synchronized void newPixels(int newpix[],
ColorModel newmodel,
int offset,
int scansize)
{
if( animated == true )
{
//FIXME
}
}
}
/* RGBImageFilter.java -- Java class for filtering Pixels by RGB values
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.image;
/**
* A filter designed to filter images in the default RGBColorModel regardless of
* the ImageProducer's ColorModel.
*
* @author Mark Benvenuto <mcb54@columbia.edu>
*/
public abstract class RGBImageFilter extends ImageFilter
{
protected ColorModel origmodel = ColorModel.getRGBdefault();
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
does not depend on the pixel's coordinate.
*/
protected boolean canFilterIndexColorModel = false;
/**
Construct new RGBImageFilter.
*/
public RGBImageFilter()
{
}
/**
* Sets the ColorModel used to filter with. If the specified ColorModel is IndexColorModel
* and canFilterIndexColorModel is true, we subsitute the ColorModel for a filtered one
* here and in setPixels whenever the original one appears. Otherwise overrides the default
* ColorModel of ImageProducer and specifies the default RGBColorModel
*
* @param model the color model to be used most often by setPixels
* @see ColorModel */
public void setColorModel(ColorModel model)
{
origmodel = model;
newmodel = model;
if( ( model instanceof IndexColorModel) && canFilterIndexColorModel ) {
newmodel = filterIndexColorModel( (IndexColorModel) model );
}
}
/**
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
*/
public void substituteColorModel(ColorModel oldcm,
ColorModel newcm)
{
origmodel = oldcm;
newmodel = newcm;
}
/**
Filters an IndexColorModel through the filterRGB function. Uses
coordinates of -1 to indicate its filtering an index and not a pixel.
@param icm an IndexColorModel to filter
*/
public IndexColorModel filterIndexColorModel(IndexColorModel icm)
{
int len = icm.getMapSize(), rgb;
byte reds[] = new byte[len], greens[] = new byte[len], blues[] = new byte[len], alphas[] = new byte[len];
icm.getAlphas( alphas );
icm.getReds( reds );
icm.getGreens( greens );
icm.getBlues( blues );
for( int i = 0; i < len; i++ )
{
rgb = filterRGB( -1, -1, makeColor ( alphas[i], reds[i], greens[i], blues[i] ) );
alphas[i] = (byte)(( 0xff000000 & rgb ) >> 24);
reds[i] = (byte)(( 0xff0000 & rgb ) >> 16);
greens[i] = (byte)(( 0xff00 & rgb ) >> 8);
blues[i] = (byte)(0xff & rgb);
}
return new IndexColorModel( icm.getPixelSize(), len, reds, greens, blues, alphas );
}
private int makeColor( byte a, byte r, byte g, byte b )
{
return ( 0xff000000 & (a << 24) | 0xff0000 & (r << 16) | 0xff00 & (b << 8) | 0xff & g );
}
/**
This functions filters a set of RGB pixels through filterRGB.
@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 filterRGBPixels(int x,
int y,
int w,
int h,
int[] pixels,
int off,
int scansize)
{
int xp, yp, i;
for( xp = x; xp < ( x + w); xp++ )
for( yp = y; yp < (y + h); yp++ )
pixels[ off + yp * scansize + xp ] = filterRGB( xp, yp, pixels[ off + yp * scansize + xp ] );
}
/**
* 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
* @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( model == origmodel ) {
consumer.setPixels(x, y, w, h, newmodel, pixels, offset, scansize);
} else {
//FIXME
//convert to proper CM
int pixelsi[] = new int[ pixels.length / 4 ];
filterRGBPixels( x, y, w, h, pixelsi, offset, scansize );
}
}
/**
* 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( model == origmodel ) {
consumer.setPixels(x, y, w, h, newmodel, pixels, offset, scansize);
} else {
convertColorModelToDefault( x, y, w, h, model, pixels, offset, scansize );
filterRGBPixels( x, y, w, h, pixels, offset, scansize );
}
}
private void convertColorModelToDefault( int x, int y, int w, int h,
ColorModel model, int pixels[], int offset, int scansize)
{
int xp, yp, i;
for( xp = x; xp < ( x + w); xp++ )
for( yp = y; yp < (y + h); yp++ )
pixels[ offset + yp * scansize + xp ] = makeColorbyDefaultCM( pixels[ offset + yp * scansize + xp ] );
}
private int makeColorbyDefaultCM( int rgb )
{
return makeColor( origmodel.getRed( rgb ), origmodel.getGreen( rgb ), origmodel.getGreen( rgb ), origmodel.getBlue( rgb ) );
}
private int makeColor( int a, int r, int g, int b )
{
return (int)( 0xff000000 & (a << 24) | 0xff0000 & (r << 16) | 0xff00 & (b << 8) | 0xff & g );
}
/**
Filters a single pixel from the default ColorModel.
@param x x-coordinate
@param y y-coordinate
@param rgb color
*/
public abstract int filterRGB(int x,
int y,
int rgb);
}
/* ReplicateScaleFilter.java -- Java class for filtering images
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.image;
import java.util.Hashtable;
/**
* This filter should be used for fast scaling of images where the result
* does not need to ensure straight lines are still straight, etc. The
* 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)
*/
public class ReplicateScaleFilter extends ImageFilter
{
public ReplicateScaleFilter(int width, int height) {
destHeight = height;
destWidth = width;
}
/**
* The height of the destination image.
*/
protected int destHeight;
/**
* The width of the destination image.
*/
protected int destWidth;
/**
* The height of the source image.
*/
protected int srcHeight;
/**
* The width of the source image.
*/
protected int srcWidth;
/**
*
*/
protected int srcrows[];
/**
*
*/
protected int srccols[];
/**
*
*/
protected Object outpixbuf;
/**
* An <code>ImageProducer</code> indicates the size of the image
* 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
*/
public void setDimensions(int width, int height)
{
consumer.setDimensions(width, height);
}
/**
* 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
*/
public void setProperties(Hashtable props)
{
props.put("filters", "ReplicateScaleFilter");
consumer.setProperties(props);
}
/**
* 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)
{
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 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)
{
consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment