[llvm-commits] [llvm-gcc-4.2] r43913 [36/80] - in /llvm-gcc-4.2/trunk: boehm-gc/ boehm-gc/Mac_files/ boehm-gc/cord/ boehm-gc/doc/ boehm-gc/include/ boehm-gc/include/private/ boehm-gc/tests/ libffi/ libffi/include/ libffi/src/ libffi/src/alpha/ libffi/src/arm/ libffi/src/cris/ libffi/src/frv/ libffi/src/ia64/ libffi/src/m32r/ libffi/src/m68k/ libffi/src/mips/ libffi/src/pa/ libffi/src/powerpc/ libffi/src/s390/ libffi/src/sh/ libffi/src/sh64/ libffi/src/sparc/ libffi/src/x86/ libffi/testsuite/ libffi/testsuite/config/ li...

Bill Wendling isanbard at gmail.com
Thu Nov 8 14:57:11 PST 2007


Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/BufferedImage.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/BufferedImage.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/BufferedImage.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/BufferedImage.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,761 @@
+/* BufferedImage.java --
+   Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006,  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 gnu.java.awt.ComponentDataBlitOp;
+
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsEnvironment;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Transparency;
+import java.awt.color.ColorSpace;
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ * A buffered image always starts at coordinates (0, 0).
+ *
+ * The buffered image is not subdivided into multiple tiles. Instead,
+ * 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 at ii.uib.no)
+ */
+public class BufferedImage extends Image
+  implements WritableRenderedImage, Transparency
+{
+  public static final int TYPE_CUSTOM         =  0,
+                          TYPE_INT_RGB        =  1,
+                          TYPE_INT_ARGB       =  2,
+                          TYPE_INT_ARGB_PRE   =  3,
+                          TYPE_INT_BGR        =  4,
+                          TYPE_3BYTE_BGR      =  5,
+                          TYPE_4BYTE_ABGR     =  6,
+                          TYPE_4BYTE_ABGR_PRE =  7,
+                          TYPE_USHORT_565_RGB =  8,
+                          TYPE_USHORT_555_RGB =  9,
+                          TYPE_BYTE_GRAY      = 10,
+                          TYPE_USHORT_GRAY    = 11,
+                          TYPE_BYTE_BINARY    = 12,
+                          TYPE_BYTE_INDEXED   = 13;
+  
+  static final int[] bits3 = { 8, 8, 8 };
+  static final int[] bits4 = { 8, 8, 8, 8 };
+  static final int[] bits1byte = { 8 };
+  static final int[] bits1ushort = { 16 };
+  
+  static final int[] masks_int = { 0x00ff0000,
+				   0x0000ff00,
+				   0x000000ff,
+				   DataBuffer.TYPE_INT };
+  static final int[] masks_565 = { 0xf800,
+				   0x07e0,
+				   0x001f,
+				   DataBuffer.TYPE_USHORT};
+  static final int[] masks_555 = { 0x7c00,
+				   0x03e0,
+				   0x001f,
+				   DataBuffer.TYPE_USHORT};
+
+  Vector observers;
+  
+  /**
+   * 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>
+   *   <li>{@link #TYPE_INT_ARGB_PRE}</li>
+   *   <li>{@link #TYPE_INT_BGR}</li>
+   *   <li>{@link #TYPE_3BYTE_BGR}</li>
+   *   <li>{@link #TYPE_4BYTE_ABGR}</li>
+   *   <li>{@link #TYPE_4BYTE_ABGR_PRE}</li>
+   *   <li>{@link #TYPE_USHORT_565_RGB}</li>
+   *   <li>{@link #TYPE_USHORT_555_RGB}</li>
+   *   <li>{@link #TYPE_BYTE_GRAY}</li>
+   *   <li>{@link #TYPE_USHORT_GRAY}</li>
+   *   <li>{@link #TYPE_BYTE_BINARY}</li>
+   *   <li>{@link #TYPE_BYTE_INDEXED}</li>
+   * </ul>
+   * 
+   * @param w  the width (must be > 0).
+   * @param h  the height (must be > 0).
+   * @param type  the image type (see the list of valid types above).
+   * 
+   * @throws IllegalArgumentException if <code>w</code> or <code>h</code> is
+   *     less than or equal to zero.
+   * @throws IllegalArgumentException if <code>type</code> is not one of the
+   *     specified values.
+   */
+  public BufferedImage(int w, int h, int type)
+  {
+    ColorModel cm = null;
+    
+    boolean alpha = false;
+    boolean premultiplied = false;
+    switch (type)
+      {
+      case TYPE_4BYTE_ABGR_PRE:
+      case TYPE_INT_ARGB_PRE:
+	premultiplied = true;
+	// fall through
+      case TYPE_INT_ARGB:
+      case TYPE_4BYTE_ABGR:
+	alpha = true;
+      }
+	
+    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
+    switch (type)
+      {
+      case TYPE_INT_RGB:
+      case TYPE_INT_ARGB:
+      case TYPE_INT_ARGB_PRE:
+      case TYPE_USHORT_565_RGB:
+      case TYPE_USHORT_555_RGB:
+	int[] masks = null;
+	switch (type)
+	  {
+	  case TYPE_INT_RGB:
+	  case TYPE_INT_ARGB:
+	  case TYPE_INT_ARGB_PRE:
+	    masks = masks_int;
+	    break;
+	  case TYPE_USHORT_565_RGB:
+	    masks = masks_565;
+	    break;
+	  case TYPE_USHORT_555_RGB:
+	    masks = masks_555;
+	    break;
+	  }
+	
+	cm = new DirectColorModel(cs,
+				  32, // 32 bits in an int
+				  masks[0], // r
+				  masks[1], // g
+				  masks[2], // b
+				  alpha ? 0xff000000 : 0,
+				  premultiplied,
+				  masks[3] // data type
+				  );
+	break;
+	
+      case TYPE_INT_BGR:
+	String msg =
+	  "FIXME: Programmer is confused. Why (and how) does a " +
+	  "TYPE_INT_BGR image use ComponentColorModel to store " +
+	  "8-bit values? Is data type TYPE_INT or TYPE_BYTE. What " +
+	  "is the difference between TYPE_INT_BGR and TYPE_3BYTE_BGR?";
+	throw new UnsupportedOperationException(msg);
+	
+      case TYPE_3BYTE_BGR:
+      case TYPE_4BYTE_ABGR:
+      case TYPE_4BYTE_ABGR_PRE:
+      case TYPE_BYTE_GRAY:
+      case TYPE_USHORT_GRAY:
+	int[] bits = null;
+	int dataType = DataBuffer.TYPE_BYTE;
+	switch (type) {
+	case TYPE_3BYTE_BGR:
+	  bits = bits3;
+	  break;
+	case TYPE_4BYTE_ABGR:
+	case TYPE_4BYTE_ABGR_PRE:
+	  bits = bits4;
+	  break;
+        case TYPE_BYTE_GRAY:
+          bits = bits1byte;
+          cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
+          break;
+        case TYPE_USHORT_GRAY:
+          bits = bits1ushort;
+          cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
+          dataType = DataBuffer.TYPE_USHORT;
+          break;
+	}
+	cm = new ComponentColorModel(cs, bits, alpha, premultiplied,
+				     alpha ?
+				     Transparency.TRANSLUCENT:
+				     Transparency.OPAQUE,
+				     dataType);
+	break;
+      case TYPE_BYTE_BINARY:
+	byte[] vals = { 0, (byte) 0xff };
+	cm = new IndexColorModel(8, 2, vals, vals, vals);
+	break;
+      case TYPE_BYTE_INDEXED:
+	String msg2 = "type not implemented yet";
+	throw new UnsupportedOperationException(msg2);
+	// FIXME: build color-cube and create color model
+      default:
+        throw new IllegalArgumentException("Unknown image type " + type);
+      }
+    
+    init(cm,
+	 cm.createCompatibleWritableRaster(w, h),
+	 premultiplied,
+	 null, // no properties
+	 type
+	 );
+  }
+
+  public BufferedImage(int w, int h, int type,
+		       IndexColorModel indexcolormodel)
+  {
+    if ((type != TYPE_BYTE_BINARY) && (type != TYPE_BYTE_INDEXED))
+      throw new IllegalArgumentException("type must be binary or indexed");
+
+    init(indexcolormodel,
+	 indexcolormodel.createCompatibleWritableRaster(w, h),
+	 false, // not premultiplied (guess)
+	 null, // no properties
+	 type);
+  }
+
+  public BufferedImage(ColorModel colormodel, 
+		       WritableRaster writableraster,
+		       boolean premultiplied,
+		       Hashtable properties)
+  {
+    init(colormodel, writableraster, premultiplied, properties,
+	 TYPE_CUSTOM);
+    // TODO: perhaps try to identify type?
+  }
+ 
+  WritableRaster raster;
+  ColorModel colorModel;
+  Hashtable properties;
+  boolean isPremultiplied;
+  int type;
+  
+  private void init(ColorModel cm,
+		    WritableRaster writableraster,
+		    boolean premultiplied,
+		    Hashtable properties,
+		    int type)
+  {
+    raster = writableraster;
+    colorModel = cm;
+    this.properties = properties;
+    isPremultiplied = premultiplied;
+    this.type = type;
+  }
+    
+  //public void addTileObserver(TileObserver tileobserver) {}
+  
+  public void coerceData(boolean premultiplied)
+  {
+    colorModel = colorModel.coerceData(raster, premultiplied);
+  }
+
+  public WritableRaster copyData(WritableRaster dest)
+  {
+    if (dest == null)
+      dest = raster.createCompatibleWritableRaster(getMinX(), getMinY(),
+                                                   getWidth(),getHeight());
+
+    int x = dest.getMinX();
+    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
+        int samples[] = src.getPixels (x, y, w, h, (int [])null);
+        dest.setPixels (x, y, w, h, samples);
+      }
+    return dest;
+  }
+
+  public Graphics2D createGraphics()
+  {
+    GraphicsEnvironment env;
+    env = GraphicsEnvironment.getLocalGraphicsEnvironment ();
+    return env.createGraphics (this);
+  }
+
+  public void flush() {
+  }
+  
+  public WritableRaster getAlphaRaster()
+  {
+    return colorModel.getAlphaRaster(raster);
+  }
+  
+  public ColorModel getColorModel()
+  {
+    return colorModel;
+  }
+  
+  public Raster getData()
+  {
+    return copyData(null);
+    /* TODO: this might be optimized by returning the same
+       raster (not writable) as long as image data doesn't change. */
+  }
+
+  public Raster getData(Rectangle rectangle)
+  {
+    WritableRaster dest =
+      raster.createCompatibleWritableRaster(rectangle);
+    return copyData(dest);
+  }
+  
+  public Graphics getGraphics()
+  {
+    return createGraphics();
+  }
+
+  public int getHeight()
+  {
+    return raster.getHeight();
+  }
+  
+  public int getHeight(ImageObserver imageobserver)
+  {
+    return getHeight();
+  }
+    
+  public int getMinTileX()
+  {
+    return 0;
+  }
+  
+  public int getMinTileY()
+  {
+    return 0;
+  }
+
+  public int getMinX()
+  {
+    return 0; 
+  }
+
+  public int getMinY() 
+  {
+    return 0;
+  }
+  
+  public int getNumXTiles()
+  {
+    return 1;
+  }
+
+  public int getNumYTiles()
+  {
+	return 1;
+  }
+
+  /**
+   * 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)
+  {
+    if (string == null)
+      throw new NullPointerException("The property name cannot be null.");
+    Object result = Image.UndefinedProperty;
+    if (properties != null)
+      {
+        Object v = properties.get(string);
+        if (v != null)
+          result = v;
+      }
+    return result;
+  }
+
+  public Object getProperty(String string, ImageObserver imageobserver)
+  {
+    return getProperty(string);
+  }
+
+  /**
+   * Returns <code>null</code> always.
+   * 
+   * @return <code>null</code> always.
+   */
+  public String[] getPropertyNames()
+  {
+    // This method should always return null, see:
+    // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4640609
+    return null;
+  }
+
+  public int getRGB(int x, int y)
+  {
+    Object rgbElem = raster.getDataElements(x, y,
+					    null // create as needed
+					    );
+    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  */
+      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. */
+
+    Object rgbElem = null;
+    for (int y=startY; y<endY; y++)
+      {
+	int xoffset = offset;
+	for (int x=startX; x<endX; x++)
+	  {
+	    int rgb;
+	    rgbElem = raster.getDataElements(x, y, rgbElem);
+	    rgb = colorModel.getRGB(rgbElem);
+	    rgbArray[xoffset++] = rgb;
+	  }
+	offset += scanlineStride;
+      }
+    return rgbArray;
+  }
+
+  public WritableRaster getRaster()
+  {
+    return raster;
+  }
+  
+  public SampleModel getSampleModel()
+  {
+    return raster.getSampleModel();
+  }
+    
+  public ImageProducer getSource()
+  {
+    return new ImageProducer() {
+        
+	Vector consumers = new Vector();
+
+        public void addConsumer(ImageConsumer ic)
+        {
+	  if(!consumers.contains(ic))
+	    consumers.add(ic);
+        }
+
+        public boolean isConsumer(ImageConsumer ic)
+        {
+          return consumers.contains(ic);
+        }
+
+        public void removeConsumer(ImageConsumer ic)
+        {
+	  consumers.remove(ic);
+        }
+
+        public void startProduction(ImageConsumer ic)
+        {
+          int x = 0;
+          int y = 0;
+          int width = getWidth();
+          int height = getHeight();
+          int stride = width;
+          int offset = 0;
+          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.
+          ColorModel model = new DirectColorModel(32, 0xff0000, 0xff00, 0xff,
+                                                  0xff000000);
+
+          consumers.add(ic);
+
+	  for(int i=0;i<consumers.size();i++)
+            {
+              ImageConsumer c = (ImageConsumer) consumers.elementAt(i);
+              c.setHints(ImageConsumer.SINGLEPASS);
+              c.setDimensions(getWidth(), getHeight());
+              c.setPixels(x, y, width, height, model, pixels, offset, stride);
+              c.imageComplete(ImageConsumer.STATICIMAGEDONE);
+            }
+        }
+
+        public void requestTopDownLeftRightResend(ImageConsumer ic)
+        {
+          startProduction(ic);
+        }
+
+      };
+  }
+  
+  public Vector getSources()
+  {
+    return null;
+  }
+  
+  public BufferedImage getSubimage(int x, int y, int w, int h)
+  {
+    WritableRaster subRaster = 
+      getRaster().createWritableChild(x, y, w, h, 0, 0, null);
+    
+    return new BufferedImage(getColorModel(),
+			     subRaster,
+			     isPremultiplied,
+			     properties);
+  }
+
+  public Raster getTile(int tileX, int tileY)
+  {
+    return getWritableTile(tileX, tileY);
+  }
+    
+  public int getTileGridXOffset()
+  {
+    return 0; // according to javadocs
+  }
+
+  public int getTileGridYOffset()
+  {
+    return 0; // according to javadocs
+  }
+
+  public int getTileHeight()
+  {
+    return getHeight(); // image is one big tile
+  }
+
+  public int getTileWidth()
+  {
+    return getWidth(); // image is one big tile
+  }
+
+  public int getType()
+  {
+    return type;
+  }
+
+  public int getWidth()
+  {
+    return raster.getWidth();
+  }
+
+  public int getWidth(ImageObserver imageobserver)
+  {
+    return getWidth();
+  }
+
+  public WritableRaster getWritableTile(int tileX, int tileY)
+  {
+    isTileWritable(tileX, tileY);  // for exception
+    return raster;
+  }
+
+  private static final Point[] tileIndices = { new Point() };
+    
+  public Point[] getWritableTileIndices()
+  {
+    return tileIndices;
+  }
+
+  public boolean hasTileWriters()
+  {
+    return true;
+  }
+  
+  public boolean isAlphaPremultiplied()
+  {
+    return isPremultiplied;
+  }
+
+  public boolean isTileWritable(int tileX, int tileY)
+  {
+    if ((tileX != 0) || (tileY != 0))
+      throw new ArrayIndexOutOfBoundsException("only tile is (0,0)");
+    return true;
+  }
+
+  public void releaseWritableTile(int tileX, int tileY)
+  {
+    isTileWritable(tileX, tileY);  // for exception
+  }
+
+  //public void removeTileObserver(TileObserver tileobserver) {}
+
+  public void setData(Raster src)
+  {
+    int x = src.getMinX();
+    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  // 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
+        int samples[] = src.getPixels (x, y, w, h, (int [])null);
+        dest.setPixels (x, y, w, h, samples);
+      }
+  }
+
+  public void setRGB(int x, int y, int argb)
+  {
+    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 endX = startX + w;
+    int endY = startY + h;
+    
+    Object rgbElem = null;
+    for (int y=startY; y<endY; y++)
+      {
+	int xoffset = offset;
+	for (int x=startX; x<endX; x++)
+	  {
+	    int argb = argbArray[xoffset++];
+	    rgbElem = colorModel.getDataElements(argb, rgbElem);
+	    raster.setDataElements(x, y, rgbElem);
+	  }
+	offset += scanlineStride;    
+      }
+  }
+    
+  public String toString()
+  {
+    StringBuffer buf;
+
+    buf = new StringBuffer(/* estimated length */ 120);
+    buf.append("BufferedImage@");
+    buf.append(Integer.toHexString(hashCode()));
+    buf.append(": type=");
+    buf.append(type);
+    buf.append(' ');
+    buf.append(colorModel);
+    buf.append(' ');
+    buf.append(raster);
+
+    return buf.toString();
+  }
+
+
+  /**
+   * Adds a tile observer. If the observer is already present, it receives
+   * multiple notifications.
+   *
+   * @param to The TileObserver to add.
+   */
+  public void addTileObserver (TileObserver to)
+  {
+    if (observers == null)
+      observers = new Vector ();
+	
+    observers.add (to);
+  }
+	
+  /**
+   * Removes a tile observer. If the observer was not registered,
+   * nothing happens. If the observer was registered for multiple
+   * notifications, it is now registered for one fewer notification.
+   *
+   * @param to The TileObserver to remove.
+   */
+  public void removeTileObserver (TileObserver to)
+  {
+    if (observers == null)
+      return;
+	
+    observers.remove (to);
+  }
+
+  /**
+   * Return the transparency type.
+   *
+   * @return One of {@link #OPAQUE}, {@link #BITMASK}, or {@link #TRANSLUCENT}.
+   * @see Transparency#getTransparency()
+   * @since 1.5
+   */
+  public int getTransparency()
+  {
+    return colorModel.getTransparency();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/BufferedImageFilter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/BufferedImageFilter.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/BufferedImageFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/BufferedImageFilter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,110 @@
+/* Copyright (C) 2004  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.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 at optonline.net
+ */
+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");
+    this.op = op;
+  }
+  
+  /**
+   * @return Returns the contained BufferedImageOp.
+   */
+  public BufferedImageOp getBufferedImageOp()
+  {
+    return op;
+  }
+
+  // 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,
+			byte[] pixels, int off, int scansize)
+  {
+    // Create an input BufferedImage
+    DataBufferByte db = new DataBufferByte(pixels, scansize * h + off, off);
+    SampleModel sm = model.createCompatibleSampleModel(scansize, h);
+    WritableRaster wr = new WritableRaster(sm, db, new Point(0, 0));
+    BufferedImage in =
+      new BufferedImage(model, wr, model.isAlphaPremultiplied(), null);
+    BufferedImage out = op.createCompatibleDestImage(in, model);
+    op.filter(in, out);
+    DataBuffer dbout = out.getRaster().getDataBuffer(); 
+    super.setPixels(0, 0, w, h, model, ((DataBufferByte)dbout).getData(), 0,
+		    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)
+  {
+    // Create an input BufferedImage
+    DataBufferInt db = new DataBufferInt(pixels, scansize * h + off, off);
+    SampleModel sm = model.createCompatibleSampleModel(scansize, h);
+    WritableRaster wr = new WritableRaster(sm, db, new Point(0, 0));
+    BufferedImage in =
+      new BufferedImage(model, wr, model.isAlphaPremultiplied(), null);
+    BufferedImage out = op.createCompatibleDestImage(in, model);
+    op.filter(in, out);
+    DataBuffer dbout = out.getRaster().getDataBuffer(); 
+    super.setPixels(0, 0, w, h, model, ((DataBufferInt)dbout).getData(), 0,
+		    scansize);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/BufferedImageOp.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/BufferedImageOp.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/BufferedImageOp.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/BufferedImageOp.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,107 @@
+/* BufferedImageOp.java -- 
+   Copyright (C) 2002, 2006, 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.RenderingHints;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+/**
+ * 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 
+   * 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 
+   * 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 
+   * 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();
+  
+} 

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ByteLookupTable.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ByteLookupTable.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ByteLookupTable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ByteLookupTable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,175 @@
+/* ByteLookupTable.java -- Java class for a pixel translation table.
+   Copyright (C) 2004, 2005, 2006,  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * ByteLookupTable represents translation arrays for pixel values.  It wraps
+ * one or more data arrays for each layer (or component) in an image, such as
+ * Alpha, R, G, and B.  When doing translation, the offset is subtracted from
+ * the pixel values to allow a subset of an array to be used.
+ *
+ * @author Jerry Quinn (jlquinn at optonline.net)
+ * @version 1.0
+ */
+public class ByteLookupTable extends LookupTable
+{
+  // Array of translation tables.
+  private byte data[][];
+
+  /**
+   * Creates a new <code>ByteLookupTable</code> instance.
+   *
+   * 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.
+   */
+  public ByteLookupTable(int offset, byte[][] data)
+    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 
+    // match that behaviour just in case it matters...
+    this.data = new byte[data.length][];
+    for (int i = 0; i < data.length; i++)
+      this.data[i] = data[i];
+  }
+
+  /**
+   * Creates a new <code>ByteLookupTable</code> instance.
+   *
+   * 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 
+   *     permitted).
+   * @exception IllegalArgumentException if offset < 0.
+   */
+  public ByteLookupTable(int offset, byte[] data)
+    throws IllegalArgumentException
+  {
+    super(offset, 1);
+    if (data == null)
+      throw new NullPointerException("Null 'data' argument.");
+    this.data = new byte[][] {data};
+  }
+
+  /**
+   * Return the lookup tables.
+   *
+   * @return the tables
+   */
+  public final byte[][] getTable()
+  {
+    return data;
+  }
+
+  /**
+   * Return translated values for a pixel.
+   *
+   * For each value in the pixel src, use the value minus offset as an index
+   * in the component array and copy the value there to the output for the
+   * component.  If dest is null, the output is a new array, otherwise the
+   * translated values are written to dest.  Dest can be the same array as
+   * src.
+   *
+   * For example, if the pixel src is [2, 4, 3], and offset is 1, the output
+   * is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the
+   * translation arrays.
+   *
+   * @param src Component values of a pixel.
+   * @param dst Destination array for values, or null.
+   * @return Translated values for the pixel.
+   */
+  public int[] lookupPixel(int[] src, int[] dst)
+    throws ArrayIndexOutOfBoundsException
+  {
+    if (dst == null)
+      dst = new int[src.length];
+
+    if (data.length == 1)
+      for (int i=0; i < src.length; i++)
+	dst[i] = data[0][src[i] - offset];
+    else
+      for (int i=0; i < src.length; i++)
+	dst[i] = data[i][src[i] - offset];
+      
+    return dst;
+  }
+
+  /**
+   * Return translated values for a pixel.
+   *
+   * For each value in the pixel src, use the value minus offset as an index
+   * in the component array and copy the value there to the output for the
+   * component.  If dest is null, the output is a new array, otherwise the
+   * translated values are written to dest.  Dest can be the same array as
+   * src.
+   *
+   * For example, if the pixel src is [2, 4, 3], and offset is 1, the output
+   * is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the
+   * translation arrays.
+   *
+   * @param src Component values of a pixel.
+   * @param dst Destination array for values, or null.
+   * @return Translated values for the pixel.
+   */
+  public byte[] lookupPixel(byte[] src, byte[] dst)
+    throws ArrayIndexOutOfBoundsException
+  {
+    if (dst == null)
+      dst = new byte[src.length];
+
+    if (data.length == 1)
+      for (int i=0; i < src.length; i++)
+	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];
+      
+    return dst;
+
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ColorConvertOp.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ColorConvertOp.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ColorConvertOp.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ColorConvertOp.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,324 @@
+/* ColorConvertOp.java --
+   Copyright (C) 2004, 2006  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.color.ColorSpace;
+import java.awt.color.ICC_ColorSpace;
+import java.awt.color.ICC_Profile;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+/**
+ * ColorConvertOp is a filter for converting an image from one colorspace to
+ * another colorspace.  The filter can convert the image 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 at optonline.net
+ */
+public class ColorConvertOp implements BufferedImageOp, RasterOp
+{
+  private ColorSpace srccs;
+  private ColorSpace dstcs;
+  private RenderingHints hints;
+  private ICC_Profile[] profiles;
+  private ColorSpace[] spaces;
+  private boolean rasterValid;
+  
+
+  /**
+   * Convert BufferedImage through a ColorSpace.
+   * 
+   * This filter version is only valid for BufferedImages.  The source image
+   * is converted to cspace.  If the destination is not null, it is then
+   * converted to the destination colorspace.  Normally this filter will only
+   * be used with a null destination.
+   * 
+   * @param cspace The target color space.
+   * @param hints Rendering hints to use in conversion, or null.
+   */
+  public ColorConvertOp(ColorSpace cspace, RenderingHints hints)
+  {
+    if (cspace == null)
+      throw new NullPointerException();
+    spaces = new ColorSpace[]{cspace};
+    this.hints = hints;
+    rasterValid = false;
+  }
+  
+  public ColorConvertOp(ColorSpace srcCspace, ColorSpace dstCspace,
+			RenderingHints hints)
+  {
+    if (srcCspace == null || dstCspace == null)
+      throw new NullPointerException();
+    spaces = new ColorSpace[]{srcCspace, dstCspace};
+    this.hints = hints;     
+  }
+
+  /**
+   * Convert from a source image destination image color space.
+   * 
+   * This constructor builds a ColorConvertOp from an array of ICC_Profiles.
+   * The source image 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, throws IllegalArgumentException.
+   * 
+   * NOTE: Sun's docs don't clearly define what a well-defined conversion is
+   *  - or perhaps someone smarter can come along and sort it out.  
+   * 
+   * For BufferedImages, when the first and last profiles match the
+   * requirements of the source and destination color space respectively, the
+   * corresponding conversion is unnecessary.  TODO: code this up.  I don't
+   * yet understand how you determine this.
+   * 
+   * 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. 
+   * 
+   * @param profiles
+   * @param hints
+   */
+  public ColorConvertOp(ICC_Profile[] profiles, RenderingHints hints)
+  {
+    if (profiles == null)
+      throw new NullPointerException();
+    this.hints = hints; 
+    this.profiles = profiles;
+    // TODO: Determine if this is well-defined.
+    // Create colorspace array with space for src and dest colorspace
+    spaces = new ColorSpace[profiles.length];
+    for (int i = 0; i < profiles.length; i++)
+      spaces[i] = new ICC_ColorSpace(profiles[i]);
+  }
+  
+  /** Convert from source image color space to destination image color space.
+   * 
+   * Only valid for BufferedImage objects, this Op converts from the source
+   * color space to the destination color space.  The destination can't be
+   * null for this operation.
+   * 
+   * @param hints Rendering hints to use during conversion, or null.
+   */
+  public ColorConvertOp(RenderingHints hints)
+  {
+    this.hints = hints; 
+    srccs = null;
+    dstcs = null;
+    rasterValid = false;
+  }
+  
+  /* (non-Javadoc)
+   * @see java.awt.image.BufferedImageOp#filter(java.awt.image.BufferedImage,
+   java.awt.image.BufferedImage)
+   */
+  public final BufferedImage filter(BufferedImage src, BufferedImage dst)
+  {
+    // 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();
+
+    // Make sure input isn't premultiplied by alpha
+    if (src.isAlphaPremultiplied())
+    {
+      BufferedImage tmp = createCompatibleDestImage(src, src.getColorModel());
+      copyimage(src, tmp);
+      tmp.coerceData(false);
+      src = tmp;
+    }
+
+    ColorModel scm = src.getColorModel();
+    for (int i = 0; i < spaces.length; i++)
+    {
+      BufferedImage tmp = createCompatibleDestImage(src, scm);
+      copyimage(src, tmp);
+      src = tmp;
+    }
+
+    // Intermediate conversions leave result in src
+    if (dst == null)
+      return src;
+    
+    // Apply final conversion
+    copyimage(src, dst);
+    
+    return dst;
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.BufferedImageOp#createCompatibleDestImage(java.awt.image.BufferedImage, java.awt.image.ColorModel)
+   */
+  public BufferedImage createCompatibleDestImage(BufferedImage src,
+						 ColorModel dstCM)
+  {
+    // FIXME: set properties to those in src
+    return new BufferedImage(dstCM,
+			     src.getRaster().createCompatibleWritableRaster(),
+			     src.isPremultiplied,
+			     null);
+  }
+  
+  public final ICC_Profile[] getICC_Profiles()
+  {
+    return profiles;
+  }
+
+  /** Return the rendering hints for this op. */
+  public final RenderingHints getRenderingHints()
+  {
+    return hints;
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.RasterOp#filter(java.awt.image.Raster, java.awt.image.WritableRaster)
+   */
+  public final WritableRaster filter(Raster src, WritableRaster dest)
+  {
+    if (!rasterValid)
+      throw new IllegalArgumentException();
+    
+    // Need to iterate through each color space - there must be at least 2
+    for (int i = 1; i < spaces.length - 1; i++)
+    {
+      // FIXME: this is wrong.  tmp needs to have the same number of bands as
+      // spaces[i] has.
+      WritableRaster tmp = createCompatibleDestRaster(src);
+      copyraster(src, spaces[i - 1], tmp, spaces[i]);
+      src = tmp;
+    }
+    
+    // FIXME: this is wrong.  dst needs to have the same number of bands as
+    // spaces[i] has.
+    if (dest == null)
+      dest = createCompatibleDestRaster(src);
+    copyraster(src, spaces[spaces.length - 2],
+	       dest, spaces[spaces.length - 1]);
+    
+    return dest;
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.RasterOp#createCompatibleDestRaster(java.awt.image.Raster)
+   */
+  public WritableRaster createCompatibleDestRaster(Raster src)
+  {
+    return src.createCompatibleWritableRaster();
+  }
+
+  /** Return corresponding destination point for source point.
+   * 
+   * LookupOp will return the value of src unchanged.
+   * @param src The source point.
+   * @param dst The destination point.
+   * @see java.awt.image.RasterOp#getPoint2D(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;
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.BufferedImageOp#getBounds2D(java.awt.image.BufferedImage)
+   */
+  public final Rectangle2D getBounds2D(BufferedImage src)
+  {
+    return src.getRaster().getBounds();
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.RasterOp#getBounds2D(java.awt.image.Raster)
+   */
+  public final Rectangle2D getBounds2D(Raster src)
+  {
+    return src.getBounds();
+  }
+  
+  // According to Sven de Marothy, we need to copy the src into the dest
+  // using Graphics2D, in order to use the rendering hints.
+  private void copyimage(BufferedImage src, BufferedImage dst)
+  {
+    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();
+  }
+  
+  private void copyraster(Raster src, ColorSpace scs, WritableRaster dst,
+      					  ColorSpace dcs)
+  {
+    float[] sbuf = new float[src.getNumBands()];
+    
+    if (hints.get(RenderingHints.KEY_COLOR_RENDERING) ==
+        RenderingHints.VALUE_COLOR_RENDER_QUALITY)
+    {
+      // use cie for accuracy
+      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))));
+    }
+    else
+    {
+      // use rgb - it's probably faster
+      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))));
+    }
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ColorModel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ColorModel.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ColorModel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ColorModel.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,794 @@
+/* ColorModel.java --
+   Copyright (C) 1999, 2000, 2002, 2003, 2004, 2006  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 gnu.java.awt.Buffers;
+
+import java.awt.Point;
+import java.awt.Transparency;
+import java.awt.color.ColorSpace;
+import java.util.Arrays;
+
+/**
+ * A color model operates with colors in several formats:
+ *
+ * <ul>
+ * <li>normalized: component samples are in range [0.0, 1.0].</li>
+ *
+ * <li>color model pixel value: all the color component samples for a
+ * sigle pixel packed/encoded in a way natural for the color
+ * model.</li>
+ *
+ * <li>color model pixel int value: only makes sense if the natural
+ * encoding of a single pixel can fit in a single int value.</li>
+ *
+ * <li>array of transferType containing a single pixel: the pixel is
+ * encoded in the natural way of the color model, taking up as many
+ * array elements as needed.</li>
+ *
+ * <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>
+ *
+ * <li>arrays of unnormalized component samples of single pixel: these
+ * samples are scaled and multiplied according to the color model, but
+ * is otherwise not packed or encoded. Each element of the array is one
+ * separate component sample. The color model only operate on the
+ * components from one pixel at a time, but using offsets, allows
+ * manipulation of arrays that contain the components of more than one
+ * pixel.</li>
+ *
+ * </ul>
+ *
+ * @author Rolf W. Rasmussen (rolfwr at ii.uib.no)
+ * @author C. Brian Jones (cbj at gnu.org)
+ */
+public abstract class ColorModel implements Transparency
+{
+  protected int pixel_bits;
+  protected int transferType;
+
+  int[] bits;
+  ColorSpace cspace;
+  int transparency;
+  boolean hasAlpha;
+  boolean isAlphaPremultiplied;
+
+  /**
+   * The standard color model for the common sRGB.
+   */
+  private static final ColorModel S_RGB_MODEL = new SRGBColorModel();
+
+  static int[] nArray(int value, int times)
+  {
+    int[] array = new int[times];
+    java.util.Arrays.fill(array, value);
+    return array;
+  }
+
+  static byte[] nArray(byte value, int times)
+  {
+    byte[] array = new byte[times];
+    java.util.Arrays.fill(array, value);
+    return array;
+  } 
+
+  /**
+   * 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
+   */
+  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));
+  }
+
+  /**
+   * Constructs a ColorModel that translates pixel values to
+   * color/alpha components.
+   *
+   * @exception IllegalArgumentException If the length of the bit array is less
+   * than the number of color or alpha components in this ColorModel, or if the
+   * transparency is not a valid value, or if the sum of the number of bits in
+   * 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)
+  {
+    int bits_sum = 0;
+    for (int i = 0; i < bits.length; i++)
+      {
+        if (bits [i] < 0)
+          throw new IllegalArgumentException ();
+
+        bits_sum |= bits [i];
+      }
+    
+    if ((bits.length < cspace.getNumComponents())
+        || (bits_sum < 1))
+      throw new IllegalArgumentException ();
+
+    this.pixel_bits = pixel_bits;
+    this.bits = bits;
+    this.cspace = cspace;
+    this.hasAlpha = hasAlpha;
+    this.isAlphaPremultiplied = isAlphaPremultiplied;
+    this.transparency = transparency;
+    this.transferType = transferType;
+  }
+  
+  public void finalize()
+  {
+    // Do nothing here.
+  }
+
+  /**
+   * Returns the default color model which in Sun's case is an instance
+   * of <code>DirectColorModel</code>.
+   */
+  public static ColorModel getRGBdefault()
+  {
+    return S_RGB_MODEL;
+  }
+
+  public final boolean hasAlpha()
+  {
+    return hasAlpha;
+  }
+
+  public final boolean isAlphaPremultiplied()
+  {
+    return isAlphaPremultiplied;
+  }
+
+  /**
+   * Get get number of bits wide used for the bit size of pixel values
+   */
+  public int getPixelSize()
+  {
+    return pixel_bits;
+  }
+    
+  public int getComponentSize(int componentIdx)
+  {
+    return bits[componentIdx];
+  }
+    
+  public int[] getComponentSize()
+  {
+    return bits;
+  }
+
+  public int getTransparency()
+  {
+    return transparency;
+  }
+
+  public int getNumComponents()
+  {
+    return getNumColorComponents() + (hasAlpha ? 1 : 0);
+  }
+
+  public int getNumColorComponents()
+  {
+    return cspace.getNumComponents();
+  }
+
+  /**
+   * Converts pixel value to sRGB and extract red int sample scaled
+   * to range [0, 255].
+   *
+   * @param pixel pixel value that will be interpreted according to
+   * the color model, (assumed alpha premultiplied if color model says
+   * so.)
+   *
+   * @return red sample scaled to range [0, 255], from default color
+   * space sRGB, alpha non-premultiplied.
+   */
+  public abstract int getRed(int pixel);
+
+  /**
+   * Converts pixel value to sRGB and extract green int sample
+   * scaled to range [0, 255].
+   *
+   * @see #getRed(int)
+   */
+  public abstract int getGreen(int pixel);
+    
+  /**
+   * Converts pixel value to sRGB and extract blue int sample
+   * scaled to range [0, 255].
+   *
+   * @see #getRed(int)
+   */
+  public abstract int getBlue(int pixel);
+
+  /**
+   * Extract alpha int sample from pixel value, scaled to [0, 255].
+   *
+   * @param pixel pixel value that will be interpreted according to
+   * the color model.
+   *
+   * @return alpha sample, scaled to range [0, 255].
+   */
+  public abstract int getAlpha(int pixel);
+
+  /**
+   * Converts a pixel int value of the color space of the color
+   * model to a sRGB pixel int value.
+   *
+   * 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.
+   *
+   * @return a pixel in sRGB color space, encoded in default
+   * 0xAARRGGBB format.  */
+  public int getRGB(int pixel)
+  {
+    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
+   * always be contained within the first element of the pixel
+   * array.
+   */
+  final int getPixelFromArray(Object inData) {
+    DataBuffer data =
+      Buffers.createBufferFromData(transferType, inData, 1);
+    Object da = Buffers.getData(data);
+
+    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.
+   */
+  public int getRed(Object inData)
+  {
+    return getRed(getPixelFromArray(inData));
+  }
+
+  /**
+   * @see #getRed(Object)
+   */
+  public int getGreen(Object inData)
+  {
+    return getGreen(getPixelFromArray(inData));
+  }
+
+  /**
+   * @see #getRed(Object)
+   */
+  public int getBlue(Object inData) {
+    return getBlue(getPixelFromArray(inData));
+  }
+
+  /**
+   * @see #getRed(Object)
+   */
+  public int getAlpha(Object inData) {
+    return getAlpha(getPixelFromArray(inData));
+  }
+
+  /**
+   * Converts a pixel in the given array of the color space of the
+   * color model to an sRGB pixel int value.
+   *
+   * <p>This method performs the inverse function of
+   * <code>getDataElements(int rgb, Object pixel)</code>.
+   * I.e. <code>(rgb == cm.getRGB(cm.getDataElements(rgb,
+   * null)))</code>.
+   *
+   * @param inData array of transferType containing a single pixel. The
+   * pixel should be encoded in the natural way of the color model.
+   *
+   * @return a pixel in sRGB color space, encoded in default
+   * 0xAARRGGBB format.
+   *
+   * @see #getDataElements(int, Object)
+   */
+  public int getRGB(Object inData)
+  {
+    return 
+      ((getAlpha(inData) & 0xff) << 24) |
+      ((  getRed(inData) & 0xff) << 16) |
+      ((getGreen(inData) & 0xff) <<  8) |
+      (( getBlue(inData) & 0xff) <<  0);
+  }
+
+  /**
+   * 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>.
+   *
+   * Outline of conversion process:
+   *
+   * <ol>
+   *
+   * <li>Convert rgb to normalized [0.0, 1.0] sRGB values.</li>
+   *
+   * <li>Convert to color space components using fromRGB in
+   * ColorSpace.</li>
+   *
+   * <li>If color model has alpha and should be premultiplied,
+   * multiply color space components with alpha value</li>
+   *
+   * <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
+   * in sRGB color space, encoded in default 0xAARRGGBB format,
+   * assumed not alpha premultiplied.
+   *
+   * @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.
+   *
+   * @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)
+  {
+    // subclasses has to implement this method.
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Fills an array with the unnormalized component samples from a
+   * pixel value. I.e. decompose the pixel, but not perform any
+   * 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
+   * pixel.  The scale and multiplication state of the samples are
+   * according to the color model. Each component sample is stored
+   * as a separate element in the array.
+   */
+  public int[] getComponents(int pixel, int[] components, int offset)
+  {
+    // 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
+   * the pixel, but not perform any color conversion.
+   *
+   * This method is typically overriden in subclasses to provide a
+   * more efficient implementation.
+   *
+   * @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
+   * according to the color model. Each component sample is stored
+   * as a separate element in the array.
+   */
+  public int[] getComponents(Object pixel, int[] components, int offset)
+  {
+    // subclasses has to implement this method.
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Convert normalized components to unnormalized components.
+   */
+  public int[] getUnnormalizedComponents(float[] normComponents,
+					 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++];
+      int out = (int) (in * ((1<<getComponentSize(i)) - 1));
+      components[offset++] = out;
+    }
+    return components;
+  }
+
+  /**
+   * Convert unnormalized components to normalized components.
+   */
+  public float[] getNormalizedComponents(int[] components,
+					 int offset,
+					 float[] normComponents,
+					 int normOffset)
+  {
+    int numComponents = getNumComponents();
+    if (normComponents == null)
+    {
+      normComponents = new float[normOffset + numComponents];
+    }
+
+    for (int i=0; i<numComponents; i++)
+    {
+      float in = components[offset++];
+      float out = in / ((1<<getComponentSize(i)) - 1);
+      normComponents[normOffset++] = out;
+    }
+    return normComponents;
+  }
+
+  /**
+   * Convert unnormalized components to normalized components.
+   *
+   * @since 1.4
+   */
+  public float[] getNormalizedComponents (Object pixel,
+                                          float[] normComponents,
+                                          int normOffset)
+  {
+    int[] components = getComponents(pixel, null, 0);
+    return getNormalizedComponents(components, 0, normComponents, normOffset);
+  }
+
+  /**
+   * 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.
+   *
+   * <code>(pixel == cm.getDataElement(cm.getComponents(pixel, null,
+   * 0), 0))</code>.
+   *
+   * This method is overriden in subclasses since this abstract class throws
+   * UnsupportedOperationException().
+   *
+   * @param components Array 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 as a separate element
+   * in the array.
+   * @param offset Position of the first value of the pixel in components.
+   *
+   * @return pixel value encoded according to the color model.
+   */
+  public int getDataElement(int[] components, int offset)
+  {
+    // subclasses have to implement this method.
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * 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
+   * getDataElement(int[], int).
+   *
+   * @param components Array of normalized component samples of single pixel.
+   * The scale and multiplication state of the samples are according to the
+   * color model. Each component sample is stored as a separate element in the
+   * array.
+   * @param offset Position of the first value of the pixel in components.
+   *
+   * @return pixel value encoded according to the color model.
+   * @since 1.4
+   */
+  public int getDataElement (float[] components, int offset)
+  {
+    return
+      getDataElement(getUnnormalizedComponents(components, offset, null, 0),
+		     0);
+  }
+  
+  public Object getDataElements(int[] components, int offset, Object obj)
+  {
+    // subclasses have to implement this method.
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Converts the normalized component samples from an array to an array of
+   * TransferType values. I.e. composes the pixel from component samples, but
+   * does not perform any color conversion or scaling of the samples.
+   *
+   * If obj is null, a new array of TransferType is allocated and returned.
+   * 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
+   * getDataElement(int[], int, Object).
+   *
+   * @param components Array of normalized component samples of single pixel.
+   * The scale and multiplication state of the samples are according to the
+   * color model. Each component sample is stored as a separate element in the
+   * array.
+   * @param offset Position of the first value of the pixel in components.
+   * @param obj Array of TransferType or null.
+   *
+   * @return pixel value encoded according to the color model.
+   * @throws ArrayIndexOutOfBoundsException
+   * @throws ClassCastException
+   * @since 1.4
+   */
+  public Object getDataElements(float[] components, int offset, Object obj)
+  {
+    return
+      getDataElements(getUnnormalizedComponents(components, offset, null, 0),
+		      0, obj);
+  }
+
+  public boolean equals(Object obj)
+  {
+    if (!(obj instanceof ColorModel)) return false;
+
+    ColorModel o = (ColorModel) obj;
+    return 
+      (pixel_bits == o.pixel_bits) &&
+      (transferType == o.transferType) &&
+      (transparency == o.transparency) &&
+      (hasAlpha == o.hasAlpha) &&
+      (isAlphaPremultiplied == o.isAlphaPremultiplied) &&
+      Arrays.equals(bits, o.bits) &&
+      (cspace.equals(o.cspace));
+  }
+
+  public final ColorSpace getColorSpace()
+  {
+    return cspace;
+  }
+
+  // Typically overridden
+  public ColorModel coerceData(WritableRaster raster,
+			       boolean isAlphaPremultiplied)
+  {
+    if (this.isAlphaPremultiplied == isAlphaPremultiplied)
+      return this;
+
+    int w = raster.getWidth();
+    int h = raster.getHeight();
+    int x = raster.getMinX();
+    int y = raster.getMinY();
+    int size = w*h;
+    int numColors = getNumColorComponents();
+    int numComponents = getNumComponents();
+    int alphaScale = (1<<getComponentSize(numColors)) - 1;
+    double[] pixels = raster.getPixels(x, y, w, h, (double[]) null);
+
+    for (int i=0; i<size; i++)
+      {
+	double alpha = pixels[i*numComponents+numColors]*alphaScale;
+	for (int c=0; c<numColors; c++)
+	  {
+	    int offset = i*numComponents+c;
+	    if (isAlphaPremultiplied)
+		pixels[offset] = pixels[offset]/alpha;
+	    else
+	      pixels[offset] = pixels[offset]*alpha;
+	  }
+      }
+    
+    raster.setPixels(0, 0, w, h, pixels);
+
+    // FIXME: what can we return?
+    return null;
+  }
+    
+  /**
+   * 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();
+    return isCompatibleSampleModel(sampleModel);
+  }
+
+  // Typically overridden
+  public WritableRaster createCompatibleWritableRaster(int w, int h)
+  {
+    return new WritableRaster(createCompatibleSampleModel(w, h),
+			      new Point(0, 0));
+  }
+
+  // Typically overridden
+  public SampleModel createCompatibleSampleModel(int w, int h)
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  // Typically overridden
+  public boolean isCompatibleSampleModel(SampleModel sm)
+  {
+    return sm.getTransferType() == transferType;
+  }
+
+  public final int getTransferType ()
+  {
+    return transferType;
+  }
+
+  /**
+   * Subclasses must override this method if it is possible for the
+   * color model to have an alpha channel.
+   *
+   * @return null, as per JDK 1.3 doc. Subclasses will only return
+   * null if no alpha raster exists.
+   */
+  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
+       null, and that overriding is required. Oh, well.
+    */
+  }
+
+  String stringParam()
+  {
+    return "pixel_bits=" + pixel_bits +
+      ", cspace=" + cspace +
+      ", transferType=" + transferType +
+      ", transparency=" + transparency +
+      ", hasAlpha=" + hasAlpha +
+      ", isAlphaPremultiplied=" + isAlphaPremultiplied;
+  }
+
+  public String toString()
+  {
+    return getClass().getName() + "[" + stringParam() + "]";
+  }
+
+  /**
+   * A color model optimized for standard sRGB.
+   */
+  private static class SRGBColorModel
+    extends DirectColorModel
+  {
+    
+    SRGBColorModel()
+    {
+      super(32,0x00FF0000,0x0000FF00,0x000000FF,0xFF000000);
+    }
+
+    public int getAlpha(Object inData)
+    {
+      return ((((int[]) inData)[0]) >> 24) & 0xFF;
+    }
+
+    public int getBlue(Object inData)
+    {
+      return ((((int[]) inData)[0])) & 0xFF;
+    }
+
+    public int getGreen(Object inData)
+    {
+      return ((((int[]) inData)[0]) >>  8) & 0xFF;
+    }
+
+    public int getRed(Object inData)
+    {
+      return ((((int[]) inData)[0]) >> 16) & 0xFF;
+    }
+
+    public int getRGB(Object inData)
+    {
+      return ((int[]) inData)[0];
+    }
+
+    public Object getDataElements(int rgb, Object pixel)
+    {
+      if(pixel == null)
+        {
+          pixel = new int[]{rgb};  
+        }
+      else
+        {
+          ((int[]) pixel)[0] = rgb;  
+        }
+      
+      return pixel;
+    }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ComponentColorModel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ComponentColorModel.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ComponentColorModel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ComponentColorModel.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,391 @@
+/* ComponentColorModel.java --
+   Copyright (C) 2000, 2002, 2004  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 gnu.java.awt.Buffers;
+
+import java.awt.Point;
+import java.awt.color.ColorSpace;
+
+public class ComponentColorModel extends ColorModel
+{
+  private static int sum(int[] values)
+  {
+    int sum = 0;
+    for (int i=0; i<values.length; i++)
+      sum += values[i];
+    return sum;
+  }
+
+  public ComponentColorModel(ColorSpace colorSpace, int[] bits,
+			     boolean hasAlpha,
+			     boolean isAlphaPremultiplied,
+			     int transparency, int transferType)
+  {
+    super(sum(bits), bits, colorSpace, hasAlpha, isAlphaPremultiplied,
+	  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. 
+   * 
+   * @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
+   * alpha.
+   * @param transparency The type of alpha values.
+   * @param transferType Data type of pixel sample values.
+   * @since 1.4
+   */
+  public ComponentColorModel(ColorSpace colorSpace,
+			     boolean hasAlpha,
+			     boolean isAlphaPremultiplied,
+			     int transparency, int transferType)
+  {	
+    this(colorSpace, null, hasAlpha, isAlphaPremultiplied,
+         transparency, transferType);
+  }
+
+  public int getRed(int pixel)
+  {
+    if (getNumComponents()>1) throw new IllegalArgumentException();
+    return (int) getRGBFloat(pixel)[0];
+  }
+
+  public int getGreen(int pixel)
+  {
+    if (getNumComponents()>1) throw new IllegalArgumentException();
+    return (int) getRGBFloat(pixel)[0];
+  }
+  
+  public int getBlue(int pixel)
+  {
+    if (getNumComponents()>1) throw new IllegalArgumentException();
+    return (int) getRGBFloat(pixel)[0];
+  }
+
+  public int getAlpha(int pixel)
+  {
+    if (getNumComponents()>1) throw new IllegalArgumentException();
+    int shift = 8 - getComponentSize(getNumColorComponents());
+    if (shift >= 0) return pixel << shift;
+    return pixel >> (-shift);
+  }
+   
+  public int getRGB(int pixel)
+  {
+    float[] rgb = getRGBFloat(pixel);
+    int ret = getRGB(rgb);
+    if (hasAlpha()) ret |= getAlpha(pixel) << 24;
+    return ret;
+  }
+
+
+  /* Note, it's OK to pass a to large array to toRGB(). Extra
+     elements are ignored. */
+  
+  private float[] getRGBFloat(int pixel)
+  {
+    float[] data = { pixel };
+    return cspace.toRGB(data);
+  }
+
+  private float[] getRGBFloat(Object inData)
+  {
+    DataBuffer buffer =
+    Buffers.createBufferFromData(transferType, inData,
+				 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[] rgb = cspace.toRGB(data);
+    return rgb;
+  }
+  
+  public int getRed(Object inData)
+  {
+    return (int) getRGBFloat(inData)[0]*255;
+  }
+
+  public int getGreen(Object inData)
+  {
+    return (int) getRGBFloat(inData)[1]*255;
+  }
+
+  public int getBlue(Object inData)
+  {
+    return (int) getRGBFloat(inData)[2]*255;
+  }
+
+  public int getAlpha(Object inData)
+  {
+    DataBuffer buffer =
+      Buffers.createBufferFromData(transferType, inData,
+				   getNumComponents());
+    int shift = 8 - getComponentSize(getNumColorComponents());
+    int alpha = buffer.getElem(getNumColorComponents());
+    if (shift >= 0) return alpha << shift;
+    return alpha >> (-shift);
+  }
+
+  private int getRGB(float[] rgb)
+  {
+    /* NOTE: We could cast to byte instead of int here. This would
+       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 =
+      (((int) (rgb[0]*255F)) << 16) |
+      (((int) (rgb[1]*255F)) <<  8) |
+      (((int) (rgb[2]*255F)) <<  0);
+    return ret;
+  }
+
+  /**
+   * @param inData pixel data of transferType, as returned by the
+   * getDataElements method in SampleModel.
+   */
+  public int getRGB(Object inData)
+  {
+    float[] rgb = getRGBFloat(inData);
+    int ret = getRGB(rgb);
+    if (hasAlpha()) ret |= getAlpha(inData) << 24;
+    return ret;
+  }
+
+  public Object getDataElements(int rgb, Object pixel)
+  {
+    // Convert rgb to [0.0, 1.0] sRGB values.
+    float[] rgbFloats = {
+      ((rgb >> 16)&0xff)/255.0F,
+      ((rgb >>  8)&0xff)/255.0F,
+      ((rgb >>  0)&0xff)/255.0F
+    };
+
+    // Convert from rgb to color space components.
+    float[] data = cspace.fromRGB(rgbFloats);
+    DataBuffer buffer = Buffers.createBuffer(transferType, pixel,
+					     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);
+      }
+    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);
+      }
+    return Buffers.getData(buffer);
+  }
+
+  public int[] getComponents(int pixel, int[] components, int offset)
+  {
+    if (getNumComponents()>1) throw new IllegalArgumentException();
+    if (components == null)
+    components = new int[getNumComponents() + offset];
+    components[offset] = pixel;
+    return components;
+  }
+
+  public int[] getComponents(Object pixel, int[] components, int offset)
+  {
+    DataBuffer buffer = Buffers.createBuffer(transferType, pixel,
+					     getNumComponents());
+    int numComponents = getNumComponents();
+
+    if (components == null)
+      components = new int[numComponents + offset];
+
+    for (int i=0; i<numComponents; i++)
+      components[offset++] = buffer.getElem(i);
+
+    return components;
+  }
+
+  public int getDataElement(int[] components, int offset)
+  {
+    if (getNumComponents()>1) throw new IllegalArgumentException();
+    return components[offset];
+  }
+
+  public Object getDataElements(int[] components, int offset, Object obj)
+  {
+    DataBuffer buffer = Buffers.createBuffer(transferType, obj,
+					     getNumComponents());
+    int numComponents = getNumComponents();
+
+    for (int i=0; i<numComponents; i++)
+      buffer.setElem(i, components[offset++]);
+
+    return Buffers.getData(buffer);
+  }
+
+  public ColorModel coerceData(WritableRaster raster,
+			       boolean isAlphaPremultiplied) {
+    if (this.isAlphaPremultiplied == isAlphaPremultiplied)
+      return this;
+
+    /* TODO: provide better implementation based on the
+       assumptions we can make due to the specific type of the
+       color model. */
+    super.coerceData(raster, isAlphaPremultiplied);
+    
+    return new ComponentColorModel(cspace, bits, hasAlpha(),
+				   isAlphaPremultiplied, // argument
+				   transparency, transferType);
+  }
+
+  public boolean isCompatibleRaster(Raster raster)
+  {
+    return super.isCompatibleRaster(raster);
+    // FIXME: Should we test something more here? (Why override?)
+  }
+
+  public WritableRaster createCompatibleWritableRaster(int w, int h)
+  {
+    SampleModel sm = createCompatibleSampleModel(w, h);
+    Point origin = new Point(0, 0);
+    return Raster.createWritableRaster(sm, origin);
+  }
+
+
+  /**
+   * Creates a <code>SampleModel</code> whose arrangement of pixel
+   * data is compatible to this <code>ColorModel</code>.
+   *
+   * @param w the number of pixels in the horizontal direction.
+   * @param h the number of pixels in the vertical direction.
+   */
+  public SampleModel createCompatibleSampleModel(int w, int h)
+  {
+    int pixelStride, scanlineStride;
+    int[] bandOffsets;
+
+    pixelStride = getNumComponents();
+    scanlineStride = pixelStride * w;
+
+    /* We might be able to re-use the same bandOffsets array among
+     * multiple calls to this method. However, this optimization does
+     * not seem worthwile because setting up descriptive data
+     * structures (such as SampleModels) is neglectible in comparision
+     * to shuffling around masses of pixel data.
+     */
+    bandOffsets = new int[pixelStride];
+    for (int i = 0; i < pixelStride; i++)
+      bandOffsets[i] = i;
+
+    /* FIXME: Think about whether it would make sense to return the
+     * possibly more efficient PixelInterleavedSampleModel for other
+     * transferTypes as well. It seems unlikely that this would break
+     * any user applications, so the Mauve tests on this method
+     * might be too restrictive.
+     */
+    switch (transferType)
+      {
+      case DataBuffer.TYPE_BYTE:
+      case DataBuffer.TYPE_USHORT:
+        return new PixelInterleavedSampleModel(transferType, w, h,
+                                               pixelStride,
+                                               scanlineStride,
+                                               bandOffsets);
+
+      default:
+        return new ComponentSampleModel(transferType, w, h,
+                                        pixelStride,
+                                        scanlineStride,
+                                        bandOffsets);
+      }
+  }
+
+
+  public boolean isCompatibleSampleModel(SampleModel sm)
+  {
+    return 
+      (sm instanceof ComponentSampleModel) &&
+      super.isCompatibleSampleModel(sm);
+  }
+
+  public WritableRaster getAlphaRaster(WritableRaster raster)
+  {
+    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);
+  }
+    
+  public boolean equals(Object obj)
+  {
+    if (!(obj instanceof ComponentColorModel)) return false;
+    return super.equals(obj);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ComponentSampleModel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ComponentSampleModel.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ComponentSampleModel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ComponentSampleModel.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,941 @@
+/* Copyright (C) 2000, 2002, 2006,  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 gnu.java.awt.Buffers;
+
+import java.util.Arrays;
+
+/* FIXME: This class does not yet support data type TYPE_SHORT */
+
+/**
+ * ComponentSampleModel supports a flexible organization of pixel samples in
+ * memory, permitting pixel samples to be interleaved by band, by scanline,
+ * and by pixel.
+ *
+ * A DataBuffer for this sample model has K banks of data.  Pixels have N
+ * samples, so there are N bands in the DataBuffer.  Each band is completely
+ * contained in one bank of data, but a bank may contain more than one band.
+ * Each pixel sample is stored in a single data element.
+ *
+ * Within a bank, each band begins at an offset stored in bandOffsets.  The
+ * banks containing the band is given by bankIndices.  Within the bank, there
+ * are three dimensions - band, pixel, and scanline.  The dimension ordering
+ * is controlled by bandOffset, pixelStride, and scanlineStride, which means
+ * that any combination of interleavings is supported.
+ *
+ * @author Rolf W. Rasmussen (rolfwr at ii.uib.no)
+ */
+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 
+   * corresponding sample in the next row.
+   */
+  protected int scanlineStride;
+  
+  /**
+   * 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;
+  
+  private boolean tightPixelPacking = false;
+  
+  /**
+   * 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_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 
+   *   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 
+   *   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 
+   *   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 
+   *   than or equal to zero.
+   * @throws IllegalArgumentException if <code>bandOffsets</code> has zero 
+   *   length.
+   */
+  public ComponentSampleModel(int dataType,
+                              int w, int h,
+                              int pixelStride,
+                              int scanlineStride,
+                              int[] bandOffsets)
+  {
+    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 
+   * 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_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 
+   *   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 
+   *   (<code>null</code> not permitted).  This array is copied to internal
+   *   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 
+   *   the size of the array defining the number of bands (<code>null</code>
+   *   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 
+   *   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 
+   *   than or equal to zero.
+   * @throws IllegalArgumentException if <code>bandOffsets</code> has zero 
+   *   length.
+   */
+  public ComponentSampleModel(int dataType,
+                              int w, int h,
+                              int pixelStride,
+                              int scanlineStride,
+                              int[] bankIndices,
+                              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) 
+        || (bandOffsets.length != bankIndices.length))
+      throw new IllegalArgumentException();
+    
+    this.bandOffsets = (int[]) bandOffsets.clone();
+    this.bankIndices = (int[]) bankIndices.clone();
+    this.numBands = bandOffsets.length;
+
+    this.numBanks = 0;
+    for (int b = 0; b < bankIndices.length; b++)
+      this.numBanks = Math.max(this.numBanks, bankIndices[b] + 1);
+
+    this.scanlineStride = scanlineStride;
+    this.pixelStride = pixelStride;
+
+    // See if we can use some speedups
+
+    /* FIXME: May these checks should be reserved for the
+       PixelInterleavedSampleModel? */
+        
+    if (pixelStride == numBands)
+      {
+        tightPixelPacking = true;
+        for (int b = 0; b < numBands; b++) {
+          if ((bandOffsets[b] != b) || (bankIndices[b] != 0))
+            {
+              tightPixelPacking = false;
+              break;
+            }
+        }
+      }
+  }             
+
+  /**
+   * 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)
+  {
+    return new ComponentSampleModel(dataType, w, h, pixelStride,
+                                    scanlineStride, bankIndices,
+                                    bandOffsets);
+  }
+
+  /**
+   * 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++)
+      {
+        bankIndices[b] = this.bankIndices[bands[b]];
+        bandOffsets[b] = this.bandOffsets[bands[b]];
+      }
+
+    return new ComponentSampleModel(dataType, width, height, pixelStride,
+                                    scanlineStride, bankIndices,
+                                    bandOffsets);
+  }
+
+  /**
+   * Creates a new data buffer that is compatible with this sample model.
+   * 
+   * @return The new data buffer.
+   */
+  public DataBuffer createDataBuffer()
+  {
+    // 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 + 1;
+    
+    return Buffers.createBuffer(getDataType(), size, numBanks);
+  }
+
+  /**
+   * 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)
+  {
+    return getOffset(x, y, 0);
+  }
+
+  /**
+   * 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)
+  {
+    return bandOffsets[b] + pixelStride * x + scanlineStride * y;
+  }
+
+  /**
+   * 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()
+  {
+    int size = DataBuffer.getDataTypeSize(getDataType());
+    int[] sizes = new int[numBands];
+
+    java.util.Arrays.fill(sizes, size);
+    return sizes;
+  }
+
+  /**
+   * 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 
+   * 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)
+  {
+    return DataBuffer.getDataTypeSize(getDataType());
+  }
+
+  /**
+   * 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()
+  {
+    return (int[]) bankIndices.clone();
+  }
+
+  /**
+   * 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()
+  {
+    return (int[]) bandOffsets.clone();
+  }
+
+  /**
+   * Returns the distance (in terms of element indices) between the sample for
+   * 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()
+  {
+    return scanlineStride;
+  }
+
+  /**
+   * 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()
+  {
+    return pixelStride;
+  }
+
+  /**
+   * 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 
+   *   pixel.
+   */
+  public final int getNumDataElements()
+  {
+    return numBands;
+  }
+
+  /**
+   * 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 
+   * 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 
+   *   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)
+  {
+    int xyOffset = pixelStride * x + scanlineStride * y;
+    
+    int[] totalBandDataOffsets = new int[numBands];
+    
+    /* Notice that band and bank offsets are different. Band offsets
+       are managed by the sample model, and bank offsets are managed
+       by the data buffer. Both must be accounted for. */
+    
+    /* FIXME: For single pixels, it is probably easier to simple
+       call getElem instead of calculating the bank offset ourself.
+       
+       On the other hand, then we need to push the value through
+       the int type returned by the getElem method.  */
+    
+    int[] bankOffsets = data.getOffsets();
+    
+    for (int b = 0; b < numBands; b++)
+      {
+        totalBandDataOffsets[b] = bandOffsets[b] + bankOffsets[bankIndices[b]] 
+                                  + xyOffset;
+      }
+        
+    try
+      {
+        switch (getTransferType())
+          {
+          case DataBuffer.TYPE_BYTE:
+            DataBufferByte inByte = (DataBufferByte) data;
+            byte[] outByte = (byte[]) obj;
+            if (outByte == null) 
+              outByte = new byte[numBands];
+                
+            for (int b = 0; b < numBands; b++)
+              {
+                int dOffset = totalBandDataOffsets[b];
+                outByte[b] = inByte.getData(bankIndices[b])[dOffset];
+              }
+            return outByte;
+                
+          case DataBuffer.TYPE_USHORT:
+            DataBufferUShort inUShort = (DataBufferUShort) data;
+            short[] outUShort = (short[]) obj;
+            if (outUShort == null) 
+              outUShort = new short[numBands];
+                
+            for (int b = 0; b < numBands; b++)
+              {
+                int dOffset = totalBandDataOffsets[b];
+                outUShort[b] = inUShort.getData(bankIndices[b])[dOffset];
+              }
+            return outUShort;
+
+          case DataBuffer.TYPE_SHORT:
+            DataBufferShort inShort = (DataBufferShort) data;
+            short[] outShort = (short[]) obj;
+            if (outShort == null) 
+              outShort = new short[numBands];
+                
+            for (int b = 0; b < numBands; b++)
+              {
+                int dOffset = totalBandDataOffsets[b];
+                outShort[b] = inShort.getData(bankIndices[b])[dOffset];
+              }
+            return outShort;
+
+          case DataBuffer.TYPE_INT:
+            DataBufferInt inInt = (DataBufferInt) data;
+            int[] outInt = (int[]) obj;
+            if (outInt == null) 
+              outInt = new int[numBands];
+                
+            for (int b = 0; b < numBands; b++)
+              {
+                int dOffset = totalBandDataOffsets[b];
+                outInt[b] = inInt.getData(bankIndices[b])[dOffset];
+              }
+            return outInt;
+
+          case DataBuffer.TYPE_FLOAT:
+            DataBufferFloat inFloat = (DataBufferFloat) data;
+            float[] outFloat = (float[]) obj;
+            if (outFloat == null) 
+              outFloat = new float[numBands];
+
+            for (int b = 0; b < numBands; b++)
+              {
+                int dOffset = totalBandDataOffsets[b];
+                outFloat[b] = inFloat.getData(bankIndices[b])[dOffset];
+              }
+            return outFloat;
+            
+          case DataBuffer.TYPE_DOUBLE:
+            DataBufferDouble inDouble = (DataBufferDouble) data;
+            double[] outDouble = (double[]) obj;
+            if (outDouble == null) 
+              outDouble = new double[numBands];
+
+            for (int b = 0; b < numBands; b++)
+              {
+                int dOffset = totalBandDataOffsets[b];
+                outDouble[b] = inDouble.getData(bankIndices[b])[dOffset];
+              }
+            return outDouble;
+            
+          default:
+              throw new IllegalStateException("unknown transfer type " 
+                                              + getTransferType());
+          }
+      }
+    catch (ArrayIndexOutOfBoundsException aioobe)
+      {
+        String msg = "While reading data elements, " +
+          "x=" + x + ", y=" + y +", " + ", xyOffset=" + xyOffset +
+          ", data.getSize()=" + data.getSize() + ": " + aioobe;
+        throw new ArrayIndexOutOfBoundsException(msg);
+      }
+  }
+
+  /**
+   * Returns the samples for the pixels in the region defined by 
+   * <code>(x, y, w, h)</code> in 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 w  the width.
+   * @param h  the height.
+   * @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 pixels.
+   * 
+   * @see #setDataElements(int, int, int, int, Object, DataBuffer)
+   */
+  public Object getDataElements(int x, int y, int w, int h, Object obj,
+                                DataBuffer data)
+  {
+    if (!tightPixelPacking)
+      {
+        return super.getDataElements(x, y, w, h, obj, data);
+      }
+
+    // using get speedup
+    
+    // We can copy whole rows
+    int rowSize = w * numBands;
+    int dataSize = rowSize * h;
+    
+    DataBuffer transferBuffer = Buffers.createBuffer(getTransferType(), obj, 
+                                                     dataSize);
+    obj = Buffers.getData(transferBuffer);
+
+    int inOffset = pixelStride * x + scanlineStride * y + data.getOffset(); 
+                                           // Assumes only one band is used
+
+    /* We don't add band offsets since we assume that bands have
+       offsets 0, 1, 2, ... */
+
+    // See if we can copy everything in one go
+    if (scanlineStride == rowSize)
+      {
+        // Collapse scan lines:
+        rowSize *= h;
+        // We ignore scanlineStride since it won't be of any use
+        h = 1;
+      }
+
+    int outOffset = 0;
+    Object inArray = Buffers.getData(data);
+    for (int yd = 0; yd < h; yd++)
+      {
+        System.arraycopy(inArray, inOffset, obj, outOffset, rowSize);
+        inOffset  += scanlineStride;
+        outOffset += rowSize;
+      }
+    return obj;
+  }
+
+  /**
+   * Sets the samples for the pixels in the region defined by 
+   * <code>(x, y, w, h)</code> from a 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 w  the width.
+   * @param h  the height.
+   * @param obj  a primitive array containing the sample values.
+   * @param data  the data buffer (<code>null</code> not permitted).
+   * 
+   * @see #getDataElements(int, int, int, int, Object, DataBuffer)
+   */
+  public void setDataElements(int x, int y, int w, int h,
+                              Object obj, DataBuffer data)
+  {
+    if (!tightPixelPacking)
+      {
+        super.setDataElements(x, y, w, h, obj, data);
+        return;
+      }
+
+    // using set speedup, we can copy whole rows
+    int rowSize = w * numBands;
+    int dataSize = rowSize * h;
+    
+    DataBuffer transferBuffer 
+        = Buffers.createBufferFromData(getTransferType(), obj, dataSize);
+
+    int[] bankOffsets = data.getOffsets();
+
+    int outOffset = pixelStride * x + scanlineStride * y + bankOffsets[0]; 
+                                                // same assumptions as in get...
+
+    // See if we can copy everything in one go
+    if (scanlineStride == rowSize)
+      {
+        // Collapse scan lines:
+        rowSize *= h;
+        h = 1;
+      }
+
+    int inOffset = 0;
+    Object outArray = Buffers.getData(data);
+    for (int yd = 0; yd < h; yd++)
+      {
+        System.arraycopy(obj, inOffset, outArray, outOffset, rowSize);
+        outOffset += scanlineStride;
+        inOffset += rowSize;
+      }
+  }
+
+  /**
+   * 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 
+   *   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 
+                                               + ") is out of bounds.");
+    int offset = pixelStride * x + scanlineStride * y;
+    if (iArray == null)
+      iArray = new int[numBands];
+    for (int b = 0; b < numBands; b++)
+      {
+        iArray[b] = data.getElem(bankIndices[b], offset + bandOffsets[b]);
+      }
+    return iArray;
+  }
+
+  /**
+   * 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 
+   *   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) 
+      iArray = new int[numBands * w * h];
+    int outOffset = 0;
+    for (y = 0; y < h; y++)
+      {
+        int lineOffset = offset;
+        for (x = 0; x < w; x++)
+          {
+            for (int b = 0; b < numBands; b++)
+              {
+                iArray[outOffset++] 
+                    = data.getElem(bankIndices[b], lineOffset+bandOffsets[b]);
+              }
+            lineOffset += pixelStride;
+          }
+        offset += scanlineStride;
+      }
+    return iArray;
+  }
+ 
+  /**
+   * 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 
+   *     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 
+                                               + ") 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 
+   * 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)
+  {
+    int offset = pixelStride * x + scanlineStride * y;
+    int[] totalBandDataOffsets = new int[numBands];
+    int[] bankOffsets = data.getOffsets();
+    for (int b = 0; b < numBands; b++)
+      totalBandDataOffsets[b] = bandOffsets[b] + bankOffsets[bankIndices[b]] 
+                                + offset;
+
+    switch (getTransferType())
+      {
+      case DataBuffer.TYPE_BYTE:
+        {
+          DataBufferByte out = (DataBufferByte) data;
+          byte[] in = (byte[]) obj;
+          
+          for (int b = 0; b < numBands; b++)
+            out.getData(bankIndices[b])[totalBandDataOffsets[b]] = in[b];
+          
+          return;
+        }
+      case DataBuffer.TYPE_USHORT:
+        {
+          DataBufferUShort out = (DataBufferUShort) data;
+          short[] in = (short[]) obj;
+          
+          for (int b = 0; b < numBands; b++)
+            out.getData(bankIndices[b])[totalBandDataOffsets[b]] = in[b];
+          
+          return;
+        }
+      case DataBuffer.TYPE_SHORT:
+        {
+          DataBufferShort out = (DataBufferShort) data;
+          short[] in = (short[]) obj;
+          
+          for (int b = 0; b < numBands; b++)
+            out.getData(bankIndices[b])[totalBandDataOffsets[b]] = in[b];
+          
+          return;
+        }
+      case DataBuffer.TYPE_INT:
+        {
+          DataBufferInt out = (DataBufferInt) data;
+          int[] in = (int[]) obj;
+          
+          for (int b = 0; b < numBands; b++)
+            out.getData(bankIndices[b])[totalBandDataOffsets[b]] = in[b];
+          
+          return;
+        }
+      case DataBuffer.TYPE_FLOAT:
+        {
+          DataBufferFloat out = (DataBufferFloat) data;
+          float[] in = (float[]) obj;
+          
+          for (int b = 0; b < numBands; b++)
+            out.getData(bankIndices[b])[totalBandDataOffsets[b]] = in[b];
+          
+          return;
+        }
+      case DataBuffer.TYPE_DOUBLE:
+        {
+          DataBufferDouble out = (DataBufferDouble) data;
+          double[] in = (double[]) obj;
+          
+          for (int b = 0; b < numBands; b++)
+            out.getData(bankIndices[b])[totalBandDataOffsets[b]] = in[b];
+          
+          return;
+        }
+      default:
+        throw new UnsupportedOperationException("transfer type not " +
+                                                "implemented");
+      }
+  }
+  
+  /**
+   * 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)
+  {
+    int offset = pixelStride * x + scanlineStride * y;
+    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:
+   * <ul>
+   * <li><code>obj</code> is not <code>null</code>;</li>
+   * <li><code>obj</code> is an instance of <code>ComponentSampleModel</code>;
+   *   </li>
+   * <li>both models have the same values for the <code>dataType</code>,
+   *   <code>width</code>, <code>height</code>, <code>pixelStride</code>,
+   *   <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 
+   *   <code>obj</code>, and <code>false</code> otherwise.
+   */
+  public boolean equals(Object obj)
+  {
+    if (obj == null)
+      return false;
+    if (! (obj instanceof ComponentSampleModel))
+      return false;
+    ComponentSampleModel that = (ComponentSampleModel) obj;
+    if (this.dataType != that.dataType)
+      return false;
+    if (this.width != that.width)
+      return false;
+    if (this.height != that.height)
+      return false;
+    if (this.pixelStride != that.pixelStride)
+      return false;
+    if (this.scanlineStride != that.scanlineStride)
+      return false;
+    if (! Arrays.equals(this.bandOffsets, that.bandOffsets))
+      return false;
+    if (! Arrays.equals(this.bankIndices, that.bankIndices))
+      return false;
+    // couldn't find any difference, so...
+    return true;
+  }
+  
+  /**
+   * Returns a hash code for this sample model.
+   * 
+   * @return The hash code.
+   */
+  public int hashCode()
+  {
+    // this computation is based on the method described in Chapter 3
+    // of Joshua Bloch's Effective Java...
+    int result = 17;
+    result = 37 * result + dataType;
+    result = 37 * result + width;
+    result = 37 * result + height;
+    result = 37 * result + pixelStride;
+    result = 37 * result + scanlineStride;
+    for (int i = 0; i < bandOffsets.length; i++)
+      result = 37 * result + bandOffsets[i];
+    for (int i = 0; i < bankIndices.length; i++)
+      result = 37 * result + bankIndices[i];
+    return result;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ConvolveOp.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ConvolveOp.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ConvolveOp.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ConvolveOp.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,327 @@
+/* ConvolveOp.java --
+   Copyright (C) 2004, 2005, 2006, Free Software Foundation -- ConvolveOp
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.Point2D;
+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.  If the
+ * source is not premultiplied, the data will be premultiplied before
+ * convolving.  Premultiplication will be undone if the destination is not
+ * premultiplied.  Color conversion will be applied if needed.
+ * 
+ * @author jlquinn at 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)
+  {
+    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)
+  {
+    this.kernel = kernel;
+    edge = EDGE_ZERO_FILL;
+    hints = null;
+  }
+
+  
+  /* (non-Javadoc)
+   * @see java.awt.image.BufferedImageOp#filter(java.awt.image.BufferedImage,
+   * java.awt.image.BufferedImage)
+   */
+  public final BufferedImage filter(BufferedImage src, BufferedImage dst)
+  {
+    if (src == dst)
+      throw new IllegalArgumentException();
+    
+    if (dst == null)
+      dst = createCompatibleDestImage(src, src.getColorModel());
+    
+    // Make sure source image is premultiplied
+    BufferedImage src1 = src;
+    if (!src.isPremultiplied)
+    {
+      src1 = createCompatibleDestImage(src, src.getColorModel());
+      src.copyData(src1.getRaster());
+      src1.coerceData(true);
+    }
+
+    BufferedImage dst1 = dst;
+    if (!src.getColorModel().equals(dst.getColorModel()))
+      dst1 = createCompatibleDestImage(src, src.getColorModel());
+
+    filter(src1.getRaster(), dst1.getRaster());
+    
+    if (dst1 != dst)
+    {
+      // Convert between color models.
+      // TODO Check that premultiplied alpha is handled correctly here.
+      Graphics2D gg = dst.createGraphics();
+      gg.setRenderingHints(hints);
+      gg.drawImage(dst1, 0, 0, null);
+      gg.dispose();
+    }
+    
+    return dst;
+  }
+
+  /* (non-Javadoc)
+   * @see
+   * java.awt.image.BufferedImageOp#createCompatibleDestImage(java.awt.image.BufferedImage,
+   * java.awt.image.ColorModel)
+   */
+  public BufferedImage createCompatibleDestImage(BufferedImage src,
+						 ColorModel dstCM)
+  {
+    // FIXME: set properties to those in src
+    return new BufferedImage(dstCM,
+			     src.getRaster().createCompatibleWritableRaster(),
+			     src.isPremultiplied, null);
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.RasterOp#getRenderingHints()
+   */
+  public final RenderingHints getRenderingHints()
+  {
+    return hints;
+  }
+  
+  /**
+   * @return The edge condition.
+   */
+  public int getEdgeCondition()
+  {
+    return edge;
+  }
+  
+  /**
+   * Returns (a clone of) the convolution kernel.
+   *
+   * @return The convolution kernel.
+   */
+  public final Kernel getKernel()
+  {
+    return (Kernel) kernel.clone();
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.RasterOp#filter(java.awt.image.Raster,
+   * java.awt.image.WritableRaster)
+   */
+  public final WritableRaster filter(Raster src, WritableRaster dest)
+  {
+    if (src == dest)
+      throw new IllegalArgumentException("src == dest is not allowed.");
+    if (kernel.getWidth() > src.getWidth() 
+        || kernel.getHeight() > src.getHeight())
+      throw new ImagingOpException("The kernel is too large.");
+    if (dest == null)
+      dest = createCompatibleDestRaster(src);
+    else if (src.getNumBands() != dest.getNumBands())
+      throw new ImagingOpException("src and dest have different band counts.");
+
+    // calculate the borders that the op can't reach...
+    int kWidth = kernel.getWidth();
+    int kHeight = kernel.getHeight();
+    int left = kernel.getXOrigin();
+    int right = Math.max(kWidth - left - 1, 0);
+    int top = kernel.getYOrigin();
+    int bottom = Math.max(kHeight - top - 1, 0);
+    
+    // process the region that is reachable...
+    int regionW = src.width - left - right;
+    int regionH = src.height - top - bottom;
+    float[] kvals = kernel.getKernelData(null);
+    float[] tmp = new float[kWidth * kHeight];
+
+    for (int x = 0; x < regionW; x++)
+      {
+        for (int y = 0; y < regionH; y++)
+          {
+            // FIXME: This needs a much more efficient implementation
+            for (int b = 0; b < src.getNumBands(); b++)
+            {
+              float v = 0;
+              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 
+                // out why this is necessary. 
+              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;  
+  }
+  
+  /**
+   * 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 
+   * corresponding pixel values from the source raster (if <code>edgeOp</code>
+   * 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.
+   * @param y  the y-coordinate of the top left pixel in the range.
+   * @param w  the width of the pixel range.
+   * @param h  the height of the pixel range.
+   * @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) 
+  {
+    if (w <= 0)
+      return;
+    if (h <= 0)
+      return;
+    if (edgeOp == EDGE_ZERO_FILL)  // fill region with zeroes
+      {
+        float[] zeros = new float[src.getNumBands() * w * h];
+        dest.setPixels(x, y, w, h, zeros); 
+      }
+    else  // copy pixels from source
+      {
+        float[] pixels = new float[src.getNumBands() * w * h];
+        src.getPixels(x, y, w, h, pixels);
+        dest.setPixels(x, y, w, h, pixels);
+      }
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.RasterOp#createCompatibleDestRaster(java.awt.image.Raster)
+   */
+  public WritableRaster createCompatibleDestRaster(Raster src)
+  {
+    return src.createCompatibleWritableRaster();
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.BufferedImageOp#getBounds2D(java.awt.image.BufferedImage)
+   */
+  public final Rectangle2D getBounds2D(BufferedImage src)
+  {
+    return src.getRaster().getBounds();
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.RasterOp#getBounds2D(java.awt.image.Raster)
+   */
+  public final Rectangle2D getBounds2D(Raster src)
+  {
+    return src.getBounds();
+  }
+
+  /** Return corresponding destination point for source point.
+   * 
+   * ConvolveOp will return the value of src unchanged.
+   * @param src The source point.
+   * @param dst The destination point.
+   * @see java.awt.image.RasterOp#getPoint2D(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;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/CropImageFilter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/CropImageFilter.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/CropImageFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/CropImageFilter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,184 @@
+/* CropImageFilter.java -- Java class for cropping image filter
+   Copyright (C) 1999, 2004  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Rectangle;
+import java.util.Hashtable;
+
+/**
+ * Currently this filter does almost nothing and needs to be implemented.
+ *
+ * @author C. Brian Jones (cbj at 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)
+    {
+      if (consumer != null)
+	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", "CropImageFilter");
+	if (consumer != null)
+	  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)
+    {
+	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).  
+     *
+     * @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)
+    {
+	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);
+	}
+    }
+
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBuffer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBuffer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBuffer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBuffer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,437 @@
+/* Copyright (C) 2000, 2002, 2005  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/** 
+ * 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.
+ *
+ * @author Rolf W. Rasmussen (rolfwr at ii.uib.no)
+ */
+public abstract class DataBuffer
+{
+  /**
+   * A constant representing a data type that uses <code>byte</code> primitives
+   * as the storage unit.
+   */
+  public static final int TYPE_BYTE      =  0;
+
+  /**
+   * 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> 
+   * primitives as the storage unit.
+   */
+  public static final int TYPE_SHORT     =  2;
+
+  /**
+   * 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> 
+   * primitives as the storage unit.
+   */
+  public static final int TYPE_FLOAT     =  4;
+
+  /**
+   * A constant representing a data type that uses <code>double</code> 
+   * primitives as the storage unit.
+   */
+  public static final int TYPE_DOUBLE    =  5;
+
+  /**
+   * 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}, 
+   * {@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.
+   */
+  protected DataBuffer(int dataType, int size)
+  {
+    this(dataType, size, 1);
+  }
+
+  /**
+   * 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 
+   * {@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.
+   */
+  protected DataBuffer(int dataType, int size, int numBanks) {
+    this(dataType, size, numBanks, 0);
+  }
+
+  /**
+   * 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 
+   * {@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 offset the offset to the first element for all banks.
+   */
+  protected DataBuffer(int dataType, int size, int numBanks, int offset) {
+    banks = numBanks;
+    this.dataType = dataType;
+    this.size = size;
+    this.offset = offset;
+
+    offsets = new int[ numBanks ];
+    for(int i = 0; i < numBanks; i++ )
+      offsets[i] = offset;
+  }
+
+  /**
+   * 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 
+   * {@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 
+   *         <code>numBanks != offsets.length</code>.
+   */
+  protected DataBuffer(int dataType, int size, int numBanks, int[] offsets) {
+    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 
+   * {@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 
+   *         <code>dataType > TYPE_DOUBLE</code>.
+   */
+  public static int getDataTypeSize(int dataType) {
+    // Maybe this should be a lookup table instead.
+    switch (dataType)
+      {
+      case TYPE_BYTE:
+	return 8;
+      case TYPE_USHORT:
+      case TYPE_SHORT:
+	return 16;
+      case TYPE_INT:
+      case TYPE_FLOAT:
+	return 32;
+      case TYPE_DOUBLE:
+	return 64;
+      default:
+	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 
+   * {@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 
+   * <code>DataBuffer</code>.
+   * 
+   * @return The offsets.
+   */
+  public int[] getOffsets()
+  {
+    if (offsets == null)
+    {
+      // is this necessary?
+      offsets = new int[1];
+      offsets[0] = offset;
+    }
+    return offsets;
+  }
+
+  /**
+   * Returns the number of data banks for this <code>DataBuffer</code>.
+   * @return The number of data banks.
+   */
+  public int getNumBanks()
+  {
+    return banks;
+  }
+
+  /**
+   * Returns an element from the first data bank.  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.
+   */
+  public int getElem(int i)
+  {
+    return getElem(0, i);
+  }
+
+  /**
+   * Returns an element from a particular data bank.  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.
+   */
+  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.
+   */
+  public void setElem(int i, int val)
+  {
+    setElem(0, i, 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.
+   */
+  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 
+   * to <code>i</code> before accessing the underlying data array.
+   * 
+   * @param i the element index.
+   * @return The element.
+   */
+  public float getElemFloat(int i)
+  {
+    return getElem(i);
+  }
+    
+  /**
+   * 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.
+   */
+  public float getElemFloat(int bank, int i)
+  {
+    return getElem(bank, 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.
+   */
+  public void setElemFloat(int i, float val)
+  {
+    setElem(i, (int) 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.
+   */
+  public void setElemFloat(int bank, int i, float val)
+  {
+    setElem(bank, i, (int) val);
+  }
+
+  /**
+   * 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.
+   */
+  public double getElemDouble(int i)
+  {
+    return getElem(i);
+  }
+    
+  /**
+   * 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.
+   */
+  public double getElemDouble(int bank, int i)
+  {
+    return getElem(bank, 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.
+   */
+  public void setElemDouble(int i, double val)
+  {
+    setElem(i, (int) 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.
+   */
+  public void setElemDouble(int bank, int i, double val)
+  {
+    setElem(bank, i, (int) val);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferByte.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferByte.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferByte.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferByte.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,245 @@
+/* Copyright (C) 2000, 2002  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 is one of several classes that are nearly identical. Maybe we
+   should have a central template and generate all these files. This
+   is one of the cases where templates or macros would have been
+   useful to have in Java.
+
+   This file has been created using search-replace. My only fear is
+   that these classes will grow out-of-sync as of a result of changes
+   that are not propagated to the other files. As always, mirroring
+   code is a maintenance nightmare.  */
+
+/**
+ * A {@link DataBuffer} that uses an array of <code>byte</code> primitives
+ * to represent each of its banks. 
+ * 
+ * @author Rolf W. Rasmussen (rolfwr at 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 
+   * specified number of <code>byte</code> elements.
+   * 
+   * @param size the number of elements in the data bank.
+   */
+  public DataBufferByte(int size)
+  {
+    super(TYPE_BYTE, size, 1, 0);
+    bankData = new byte[1][];
+    data = new byte[size];
+    bankData[0] = data;
+  }
+
+  /**
+   * 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.
+   */
+  public DataBufferByte(int size, int numBanks)
+  {
+    super(TYPE_BYTE, size, numBanks);
+    bankData = new byte[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 
+   * <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.
+   */
+  public DataBufferByte(byte[] dataArray, int size)
+  {
+    super(TYPE_BYTE, size, 1, 0);
+    bankData = new byte[1][];
+    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 
+   * <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.
+   */
+  public DataBufferByte(byte[] dataArray, int size, int offset)
+  {
+    super(TYPE_BYTE, size, 1, offset);
+    bankData = new byte[1][];
+    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 
+   *         <code>null</code>.
+   */
+  public DataBufferByte(byte[][] dataArray, int size)
+  {
+    super(TYPE_BYTE, size, dataArray.length);
+    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 
+   *         <code>null</code>.
+   */
+  public DataBufferByte(byte[][] dataArray, int size, int[] offsets)
+  {
+    super(TYPE_BYTE, size, dataArray.length, offsets);
+    bankData = dataArray;
+    data = bankData[0];
+  }
+
+  /**
+   * 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) 
+  {
+    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 
+   * underlying data array.
+   * 
+   * @param i the element index.
+   * @return The element.
+   */
+  public int getElem(int i)
+  {
+    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 
+   * underlying data array.
+   * 
+   * @param bank the bank index.
+   * @param i the element index.
+   * @return The element.
+   */
+  public int getElem(int bank, int i)
+  {
+    // get unsigned byte as int
+    return bankData[bank][i+offsets[bank]] & 0xff;
+  }
+
+  /**
+   * 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.
+   */
+  public void setElem(int i, int val)
+  {
+    data[i+offset] = (byte) 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.
+   */
+  public void setElem(int bank, int i, int val)
+  {
+    bankData[bank][i+offsets[bank]] = (byte) val;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferDouble.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferDouble.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferDouble.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferDouble.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,288 @@
+/* Copyright (C) 2004, 2005  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 is one of several classes that are nearly identical. Maybe we
+   should have a central template and generate all these files. This
+   is one of the cases where templates or macros would have been
+   useful to have in Java.
+
+   This file has been created using search-replace. My only fear is
+   that these classes will grow out-of-sync as of a result of changes
+   that are not propagated to the other files. As always, mirroring
+   code is a maintenance nightmare.  */
+
+/**
+ * A {@link DataBuffer} that uses an array of <code>double</code> primitives
+ * to represent each of its banks. 
+ * 
+ * @since 1.4
+ *
+ * @author Rolf W. Rasmussen (rolfwr at ii.uib.no)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public final class DataBufferDouble
+  extends DataBuffer
+{
+  private double[] data;
+  private double[][] bankData;
+  
+  /**
+   * 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)
+  {
+    super(TYPE_DOUBLE, size, 1, 0);
+    bankData = new double[1][];
+    data = new double[size];
+    bankData[0] = data;
+  }
+
+  /**
+   * 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.
+   */
+  public DataBufferDouble(int size, int numBanks)
+  {
+    super(TYPE_DOUBLE, size, numBanks);
+    bankData = new double[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 
+   * <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.
+   */
+  public DataBufferDouble(double[] dataArray, int size)
+  {
+    super(TYPE_DOUBLE, size, 1, 0);
+    bankData = new double[1][];
+    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 
+   * <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.
+   */
+  public DataBufferDouble(double[] dataArray, int size, int offset)
+  {
+    super(TYPE_DOUBLE, size, 1, offset);
+    bankData = new double[1][];
+    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 
+   *         <code>null</code>.
+   */
+  public DataBufferDouble(double[][] dataArray, int size)
+  {
+    super(TYPE_DOUBLE, size, dataArray.length);
+    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 
+   *         <code>null</code>.
+   */
+  public DataBufferDouble(double[][] dataArray, int size, int[] offsets)
+  {
+    super(TYPE_DOUBLE, size, dataArray.length, offsets);
+    bankData = dataArray;
+    data = bankData[0];
+  }
+
+  /**
+   * 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.
+   */
+  public double[] getData(int bank)
+  {
+    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 
+   * underlying data array.
+   * 
+   * @param i the element index.
+   * @return The element.
+   */
+  public int getElem(int i)
+  {
+    return (int) data[i+offset];
+  }
+
+  /**
+   * Returns an element from a particular data bank.  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.
+   */
+  public int getElem(int bank, int i)
+  {
+    return (int) bankData[bank][i+offsets[bank]];
+  }
+
+  /**
+   * 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.
+   */
+  public void setElem(int i, int val)
+  {
+    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.
+   */
+  public void setElem(int bank, int i, int val)
+  {
+    bankData[bank][i+offsets[bank]] = val;
+  }
+
+  public float getElemFloat(int i)
+  {
+    return (float) data[i+offset];
+  }
+    
+  public float getElemFloat(int bank, int i)
+  {
+    return (float) bankData[bank][i+offsets[bank]];
+  }
+
+  public void setElemFloat(int i, float val)
+  {
+    data[i+offset] = val;
+  }
+
+  public void setElemFloat(int bank, int i, float val)
+  {
+    bankData[bank][i+offsets[bank]] = val;
+  }
+
+  public double getElemDouble(int i)
+  {
+    return data[i + offset];
+  }
+    
+  public double getElemDouble(int bank, int i)
+  {
+    return bankData[bank][i + offsets[bank]];
+  }
+
+  public void setElemDouble(int i, double val)
+  {
+    data[i + offset] = val;
+  }
+
+  public void setElemDouble(int bank, int i, double val)
+  {
+    bankData[bank][i + offsets[bank]] = val;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferFloat.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferFloat.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferFloat.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferFloat.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,286 @@
+/* Copyright (C) 2004, 2005  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 is one of several classes that are nearly identical. Maybe we
+   should have a central template and generate all these files. This
+   is one of the cases where templates or macros would have been
+   useful to have in Java.
+
+   This file has been created using search-replace. My only fear is
+   that these classes will grow out-of-sync as of a result of changes
+   that are not propagated to the other files. As always, mirroring
+   code is a maintenance nightmare.  */
+
+/**
+ * A {@link DataBuffer} that uses an array of <code>float</code> primitives
+ * to represent each of its banks. 
+ * 
+ * @author Rolf W. Rasmussen (rolfwr at ii.uib.no)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public final class DataBufferFloat
+  extends DataBuffer
+{
+  private float[] data;
+  private float[][] bankData;
+  
+  /**
+   * 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)
+  {
+    super(TYPE_FLOAT, size, 1, 0);
+    bankData = new float[1][];
+    data = new float[size];
+    bankData[0] = data;
+  }
+
+  /**
+   * 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.
+   */
+  public DataBufferFloat(int size, int numBanks)
+  {
+    super(TYPE_FLOAT, size, numBanks);
+    bankData = new float[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 
+   * <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.
+   */
+  public DataBufferFloat(float[] dataArray, int size)
+  {
+    super(TYPE_FLOAT, size, 1, 0);
+    bankData = new float[1][];
+    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 
+   * <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.
+   */
+  public DataBufferFloat(float[] dataArray, int size, int offset)
+  {
+    super(TYPE_FLOAT, size, 1, offset);
+    bankData = new float[1][];
+    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 
+   *         <code>null</code>.
+   */
+  public DataBufferFloat(float[][] dataArray, int size)
+  {
+    super(TYPE_FLOAT, size, dataArray.length);
+    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 
+   *         <code>null</code>.
+   */
+  public DataBufferFloat(float[][] dataArray, int size, int[] offsets)
+  {
+    super(TYPE_FLOAT, size, dataArray.length, offsets);
+    bankData = dataArray;
+    data = bankData[0];
+  }
+
+  /**
+   * 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.
+   */
+  public float[] getData(int bank)
+  {
+    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 
+   * underlying data array.
+   * 
+   * @param i the element index.
+   * @return The element.
+   */
+  public int getElem(int i)
+  {
+    return (int) data[i+offset];
+  }
+
+  /**
+   * Returns an element from a particular data bank.  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.
+   */
+  public int getElem(int bank, int i)
+  {
+    return (int) bankData[bank][i+offsets[bank]];
+  }
+
+  /**
+   * 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.
+   */
+  public void setElem(int i, int val)
+  {
+    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.
+   */
+  public void setElem(int bank, int i, int val)
+  {
+    bankData[bank][i+offsets[bank]] = val;
+  }
+
+  public float getElemFloat(int i)
+  {
+    return data[i+offset];
+  }
+    
+  public float getElemFloat(int bank, int i)
+  {
+    return bankData[bank][i+offsets[bank]];
+  }
+
+  public void setElemFloat(int i, float val)
+  {
+    data[i+offset] = val;
+  }
+
+  public void setElemFloat(int bank, int i, float val)
+  {
+    bankData[bank][i+offsets[bank]] = val;
+  }
+
+  public double getElemDouble(int i)
+  {
+    return getElemFloat(i);
+  }
+    
+  public double getElemDouble(int bank, int i)
+  {
+    return getElemFloat(bank, i);
+  }
+
+  public void setElemDouble(int i, double val)
+  {
+    setElemFloat(i, (float) val);
+  }
+
+  public void setElemDouble(int bank, int i, double val)
+  {
+    setElemFloat(bank, i, (float) val);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferInt.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferInt.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferInt.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferInt.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,244 @@
+/* Copyright (C) 2000, 2002, 2005  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 is one of several classes that are nearly identical. Maybe we
+   should have a central template and generate all these files. This
+   is one of the cases where templates or macros would have been
+   useful to have in Java.
+
+   This file has been created using search-replace. My only fear is
+   that these classes will grow out-of-sync as of a result of changes
+   that are not propagated to the other files. As always, mirroring
+   code is a maintenance nightmare.  */
+
+/**
+ * A {@link DataBuffer} that uses an array of <code>int</code> primitives
+ * to represent each of its banks. 
+ * 
+ * @author Rolf W. Rasmussen (rolfwr at 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 
+   * specified number of <code>int</code> elements.
+   * 
+   * @param size the number of elements in the data bank.
+   */
+  public DataBufferInt(int size)
+  {
+    super(TYPE_INT, size, 1, 0);
+    bankData = new int[1][];
+    data = new int[size];
+    bankData[0] = data;
+  }
+
+  /**
+   * 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.
+   */
+  public DataBufferInt(int size, int numBanks)
+  {
+    super(TYPE_INT, size, numBanks);
+    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 
+   * <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.
+   */
+  public DataBufferInt(int[] dataArray, int size)
+  {
+    super(TYPE_INT, size, 1, 0);
+    bankData = new int[1][];
+    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 
+   * <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.
+   */
+  public DataBufferInt(int[] dataArray, int size, int offset)
+  {
+    super(TYPE_INT, size, 1, offset);
+    bankData = new int[1][];
+    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 
+   *         <code>null</code>.
+   */
+  public DataBufferInt(int[][] dataArray, int size)
+  {
+    super(TYPE_INT, size, dataArray.length);
+    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 
+   *         <code>null</code>.
+   */
+  public DataBufferInt(int[][] dataArray, int size, int[] offsets)
+  {
+    super(TYPE_INT, size, dataArray.length, offsets);
+    bankData = dataArray;
+    data = bankData[0];
+  }
+
+  /**
+   * 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.
+   */
+  public int[] getData(int bank)
+  {
+    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.
+   */
+  public int getElem(int i)
+  {
+    return data[i+offset];
+  }
+
+  /**
+   * 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.
+   */
+  public int getElem(int bank, int i)
+  {
+    // get unsigned int as int
+    return bankData[bank][i+offsets[bank]];
+  }
+
+  /**
+   * 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.
+   */
+  public void setElem(int i, int val)
+  {
+    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.
+   */
+  public void setElem(int bank, int i, int val)
+  {
+    bankData[bank][i+offsets[bank]] = val;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferShort.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferShort.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferShort.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferShort.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,245 @@
+/* DataBufferShort.java --
+   Copyright (C) 2004, 2005  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 is one of several classes that are nearly identical. Maybe we
+   should have a central template and generate all these files. This
+   is one of the cases where templates or macros would have been
+   useful to have in Java.
+
+   This file has been created using search-replace. My only fear is
+   that these classes will grow out-of-sync as of a result of changes
+   that are not propagated to the other files. As always, mirroring
+   code is a maintenance nightmare.  */
+
+/**
+ * A {@link DataBuffer} that uses an array of <code>short</code> primitives
+ * to represent each of its banks. 
+ * 
+ * @author Rolf W. Rasmussen (rolfwr at 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 
+   * specified number of <code>short</code> elements.
+   * 
+   * @param size the number of elements in the data bank.
+   */
+  public DataBufferShort(int size)
+  {
+    super(TYPE_SHORT, size, 1, 0);
+    bankData = new short[1][];
+    data = new short[size];
+    bankData[0] = data;
+  }
+
+  /**
+   * 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.
+   */
+  public DataBufferShort(int size, int numBanks)
+  {
+    super(TYPE_SHORT, size, numBanks);
+    bankData = new short[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 
+   * <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.
+   */
+  public DataBufferShort(short[] dataArray, int size)
+  {
+    super(TYPE_SHORT, size, 1, 0);
+    bankData = new short[1][];
+    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 
+   * <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.
+   */
+  public DataBufferShort(short[] dataArray, int size, int offset)
+  {
+    super(TYPE_SHORT, size, 1, offset);
+    bankData = new short[1][];
+    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 
+   *         <code>null</code>.
+   */
+  public DataBufferShort(short[][] dataArray, int size)
+  {
+    super(TYPE_SHORT, size, dataArray.length);
+    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 
+   *         <code>null</code>.
+   */
+  public DataBufferShort(short[][] dataArray, int size, int[] offsets)
+  {
+    super(TYPE_SHORT, size, dataArray.length, offsets);
+    bankData = dataArray;
+    data = bankData[0];
+  }
+
+  /**
+   * 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.
+   */
+  public short[] getData(int bank)
+  {
+    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 
+   * underlying data array.
+   * 
+   * @param i the element index.
+   * @return The element.
+   */
+  public int getElem(int i)
+  {
+    return data[i+offset];
+  }
+
+  /**
+   * Returns an element from a particular data bank.  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.
+   */
+  public int getElem(int bank, int i)
+  {
+    return bankData[bank][i+offsets[bank]];
+  }
+
+  /**
+   * 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.
+   */
+  public void setElem(int i, int val)
+  {
+    data[i+offset] = (short) 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.
+   */
+  public void setElem(int bank, int i, int val)
+  {
+    bankData[bank][i+offsets[bank]] = (short) val;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferUShort.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferUShort.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferUShort.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DataBufferUShort.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,246 @@
+/* DataBufferUShort.java --
+   Copyright (C) 2000, 2002, 2004, 2005 Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 is one of several classes that are nearly identical. Maybe we
+   should have a central template and generate all these files. This
+   is one of the cases where templates or macros would have been
+   useful to have in Java.
+
+   This file has been created using search-replace. My only fear is
+   that these classes will grow out-of-sync as of a result of changes
+   that are not propagated to the other files. As always, mirroring
+   code is a maintenance nightmare.  */
+
+/**
+ * A {@link DataBuffer} that uses an array of <code>short</code> primitives
+ * to represent each of its banks. 
+ * 
+ * @author Rolf W. Rasmussen (rolfwr at 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 
+   * specified number of <code>short</code> elements.
+   * 
+   * @param size the number of elements in the data bank.
+   */
+  public DataBufferUShort(int size)
+  {
+    super(TYPE_USHORT, size, 1, 0);
+    bankData = new short[1][];
+    data = new short[size];
+    bankData[0] = data;
+  }
+
+  /**
+   * 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.
+   */
+  public DataBufferUShort(int size, int numBanks)
+  {
+    super(TYPE_USHORT, size, numBanks);
+    bankData = new short[numBanks][size];
+    data = bankData[0];
+  }
+
+  /**
+   * 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.
+   *
+   * @throws NullPointerException if dataArray is null
+   */
+  public DataBufferUShort(short[] dataArray, int size)
+  {
+    super(TYPE_USHORT, size, 1, 0);
+    if (dataArray == null)
+      throw new NullPointerException();
+    bankData = new short[1][];
+    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.
+   *
+   * @throws NullPointerException if dataArray is null
+   */
+  public DataBufferUShort(short[] dataArray, int size, int offset)
+  {
+    super(TYPE_USHORT, size, 1, offset);
+    if (dataArray == null)
+      throw new NullPointerException();
+    bankData = new short[1][];
+    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 
+   *         <code>null</code>.
+   */
+  public DataBufferUShort(short[][] dataArray, int size)
+  {
+    super(TYPE_USHORT, size, dataArray.length);
+    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 
+   *         <code>null</code>.
+   */
+  public DataBufferUShort(short[][] dataArray, int size, int[] offsets)
+  {
+    super(TYPE_USHORT, size, dataArray.length, offsets);
+    bankData = dataArray;
+    data = bankData[0];
+  }
+
+  /**
+   * 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.
+   */
+  public short[] getData(int bank)
+  {
+    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 
+   * underlying data array.
+   * 
+   * @param i the element index.
+   * @return The element.
+   */
+  public int getElem(int i)
+  {
+    return data[i+offset] & 0xffff; // get unsigned short 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 
+   * underlying data array.
+   * 
+   * @param bank the bank index.
+   * @param i the element index.
+   * @return The element.
+   */
+  public int getElem(int bank, int i)
+  {
+    // get unsigned short as int
+    return bankData[bank][i+offsets[bank]] & 0xffff;
+  }
+
+  /**
+   * 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.
+   */
+  public void setElem(int i, int val)
+  {
+    data[i+offset] = (short) 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.
+   */
+  public void setElem(int bank, int i, int val)
+  {
+    bankData[bank][i+offsets[bank]] = (short) val;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DirectColorModel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DirectColorModel.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DirectColorModel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/DirectColorModel.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,436 @@
+/* DirectColorModel.java --
+   Copyright (C) 1999, 2000, 2002, 2004  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 gnu.java.awt.Buffers;
+
+import java.awt.Point;
+import java.awt.Transparency;
+import java.awt.color.ColorSpace;
+
+/**
+ * @author Rolf W. Rasmussen (rolfwr at ii.uib.no)
+ * @author C. Brian Jones (cbj at gnu.org)
+ * @author Mark Benvenuto (mcb54 at columbia.edu)
+ */
+public class DirectColorModel extends PackedColorModel
+{
+  /**
+   * For the color model created with this constructor the pixels
+   * will have fully opaque alpha components with a value of 255.
+   * 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 
+   */
+  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
+	 );
+  }
+
+  /**
+   * For the color model created with this constructor the pixels
+   * will have fully opaque alpha components with a value of 255.
+   * 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 
+   */
+  public DirectColorModel(int pixelBits,
+			  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
+	 );
+  }
+
+  public DirectColorModel(ColorSpace cspace, int pixelBits,
+			  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);
+  }
+    
+  public final int getRedMask()
+  {
+    return getMask(0);
+  }
+
+  public final int getGreenMask()
+  {
+    return getMask(1);
+  }
+
+  public final int getBlueMask()
+  {
+    return getMask(2);
+  }
+
+  public final int getAlphaMask()
+  {
+    return hasAlpha() ? getMask(3) : 0;
+  }
+
+  /**
+   * Get the red component of the given pixel.
+   * <br>
+   */
+  public final int getRed(int pixel)
+  {
+    return extractAndNormalizeSample(pixel, 0);
+  }
+
+  /**
+   * Get the green component of the given pixel.
+   * <br>
+   */
+  public final int getGreen(int pixel)
+  {
+    return extractAndNormalizeSample(pixel, 1);
+  }
+  
+  /**
+   * Get the blue component of the given pixel.
+   * <br>
+   */
+  public final int getBlue(int pixel)
+  {
+    return extractAndNormalizeSample(pixel, 2);
+  }
+
+  /**
+   * Get the alpha component of the given pixel.
+   * <br>
+   */
+  public final int getAlpha(int pixel)
+  {
+    if (!hasAlpha())
+      return 255;
+    return extractAndScaleSample(pixel, 3);
+  }
+
+  private int extractAndNormalizeSample(int pixel, int component)
+  {
+    int value = extractAndScaleSample(pixel, component);
+    if (hasAlpha() && isAlphaPremultiplied() && getAlpha(pixel) != 0)
+      value = value*255/getAlpha(pixel);
+    return value;
+  }
+
+  private int extractAndScaleSample(int pixel, int component)
+  {
+    int field = pixel & getMask(component);
+    int to8BitShift =
+      8 - shifts[component] - getComponentSize(component);
+    return (to8BitShift>0) ?
+      (field << to8BitShift) :
+      (field >>> (-to8BitShift));
+  }
+
+  /**
+   * Get the RGB color value of the given pixel using the default
+   * RGB color model. 
+   * <br>
+   *
+   * @param pixel a pixel value
+   */
+  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
+       implementation. */
+    return super.getRGB(pixel);
+  }
+
+  public int getRed(Object inData)
+  {
+    return getRed(getPixelFromArray(inData));
+  }
+
+  public int getGreen(Object inData)
+  {
+    return getGreen(getPixelFromArray(inData));
+  }
+
+  public int getBlue(Object inData)
+  {
+    return getBlue(getPixelFromArray(inData));
+  }
+    
+  public int getAlpha(Object inData)
+  {
+    return getAlpha(getPixelFromArray(inData));
+  }
+
+  public int getRGB(Object inData)
+  {
+    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
+   * of the color model.
+   *
+   * <p>This method performs the inverse function of
+   * <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.
+   *
+   * @return array of transferType containing a single pixel. The
+   * pixel should be encoded in the natural way of the color model.
+   *
+   * @see #getRGB(Object)
+   */
+  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
+      }
+    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
+      }
+    
+    /* 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.
+   *
+   * @param highBit the position of the most significant bit in the
+   * val parameter.
+   */
+  private int valueToField(int val, int component, int highBit)
+  {
+    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
+   * information derived from the field masks.
+   */
+  private int value16ToField(int val, int component)
+  {
+    int toFieldShift = getComponentSize(component) + shifts[component] - 16;
+    return (toFieldShift>0) ?
+      (val << toFieldShift) :
+      (val >>> (-toFieldShift));
+  }
+
+  /**
+   * Fills an array with the unnormalized component samples from a
+   * pixel value. I.e. decompose the pixel, but not perform any
+   * color conversion.
+   */
+  public final int[] getComponents(int pixel, int[] components, int offset)
+  {
+    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)
+  {
+    return getComponents(getPixelFromArray(pixel), components, offset);
+  }
+
+  /**
+   * Creates a <code>WriteableRaster</code> that has a <code>SampleModel</code>
+   * that is compatible with this <code>ColorModel</code>.
+   *
+   * @param w the width of the writeable raster to create
+   * @param h the height of the writeable raster to create
+   *
+   * @throws IllegalArgumentException if <code>w</code> or <code>h</code>
+   *         is less than or equal to zero
+   */
+  public final WritableRaster createCompatibleWritableRaster(int w, int h)
+  {
+    // Sun also makes this check here.
+    if(w <= 0 || h <= 0)
+      throw new IllegalArgumentException("width (=" + w + ") and height (="
+                                         + h + ") must be > 0");
+
+    SampleModel sm = createCompatibleSampleModel(w, h);
+    Point origin = new Point(0, 0);
+    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)
+  {
+    /* In this color model, the whole pixel fits in the first element
+       of the array. */
+    int pixelValue = getDataElement(components, offset);
+
+    DataBuffer buffer = Buffers.createBuffer(transferType, obj, 1);
+    buffer.setElem(0, pixelValue);
+    return Buffers.getData(buffer);
+  }
+    
+  public final ColorModel coerceData (WritableRaster raster,
+				      boolean isAlphaPremultiplied)
+  {
+    if (this.isAlphaPremultiplied == isAlphaPremultiplied)
+      return this;
+	
+    /* TODO: provide better implementation based on the
+       assumptions we can make due to the specific type of the
+       color model. */
+    super.coerceData(raster, isAlphaPremultiplied);
+	
+    return new ComponentColorModel(cspace, bits, hasAlpha(),
+				   isAlphaPremultiplied, // argument
+				   transparency, transferType);
+  } 
+
+  public boolean isCompatibleRaster(Raster raster)
+  {
+    /* 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);
+  }
+
+  String stringParam()
+  {
+    return super.stringParam() +
+      ", redMask=" + Integer.toHexString(getRedMask()) +
+      ", greenMask=" + Integer.toHexString(getGreenMask()) +
+      ", blueMask=" + Integer.toHexString(getBlueMask()) +
+      ", alphaMask=" + Integer.toHexString(getAlphaMask());
+  }
+
+  public String toString()
+  {
+    /* FIXME: Again, docs say override, but how do we improve upon the
+       superclass implementation? */
+    return super.toString();
+  }
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/FilteredImageSource.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/FilteredImageSource.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/FilteredImageSource.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/FilteredImageSource.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,125 @@
+/* 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 at 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);
+    }
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImageConsumer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImageConsumer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImageConsumer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImageConsumer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,216 @@
+/* ImageConsumer.java -- Java interface for image consumption
+   Copyright (C) 1999, 2003 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * An object implementing the <code>ImageProducer</code> interface can
+ * use objects implementing this interface to deliver the image data.
+ * 
+ * @author C. Brian Jones (cbj at gnu.org)
+ */
+public interface ImageConsumer
+{
+    /**
+     * The pixel order may be random.  This should be
+     * the default assumption of the <code>ImageConsumer</code>.
+     *
+     * @see #setHints 
+     */
+    int RANDOMPIXELORDER = 1;
+
+    /**
+     * The pixel order is top-down, left-right.
+     *
+     * @see #setHints
+     */
+    int TOPDOWNLEFTRIGHT = 2;
+
+    /**
+     * The pixel order is in multiples of complete scanlines.
+     *
+     * @see #setHints
+     */
+    int COMPLETESCANLINES = 4;
+
+    /**
+     * The pixels will be delivered in a single pass.  There is at
+     * most one call to <code>setPixels</code> for any single pixel.
+     *
+     * @see #setHints
+     * @see #setPixels(int, int, int, int, ColorModel, int[], int, int) 
+     */
+    int SINGLEPASS = 8;
+
+    /**
+     * The pixels will be delivered with multiple calls to
+     * <code>setPixels</code>.  The image contains a single frame
+     * which ends when <code>imageComplete</code> is called with the
+     * <code>STATICIMAGEDONE</code> flag.  If the image is constantly
+     * 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 
+     */
+    int SINGLEFRAME = 16;
+
+    /**
+     * Indicates an error occurred while producing an image.
+     *
+     * @see #imageComplete
+     */
+    int IMAGEERROR = 1;
+
+    /**
+     * A single frame is complete but more will follow.
+     * 
+     * @see #imageComplete
+     */
+    int SINGLEFRAMEDONE = 2;
+
+    /**
+     * The image is complete and no more pixels or frames will follow.
+     *
+     * @see #imageComplete
+     */
+    int STATICIMAGEDONE = 3;
+
+    /**
+     * Production of the image has been aborted.
+     *
+     * @see #imageComplete
+     */
+    int IMAGEABORTED = 4;
+
+    /**
+     * 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 
+     */
+    void setDimensions(int width, int 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 
+     */
+    void setProperties(Hashtable props);
+
+    /**
+     * This <code>ColorModel</code> should indicate the model used by
+     * the majority of calls to <code>setPixels</code>.  Each call to
+     * <code>setPixels</code> could however indicate a different
+     * <code>ColorModel</code>.
+     *
+     * @param model the color model to be used most often by setPixels
+     * @see ColorModel 
+     */
+    void setColorModel(ColorModel 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>.
+     * 
+     * @param flags a bit mask of hints
+     */
+    void setHints(int flags);
+
+    /**
+     * Deliver a subset of an ImageProducer's pixels to this ImageConsumer.
+     *
+     * Each element of the pixels array represents one pixel.  The
+     * pixel data is formatted according to the color model model.
+     * The x and y parameters are the coordinates of the block of
+     * pixels being delivered to this ImageConsumer.  They are
+     * specified relative to the top left corner of the image being
+     * produced.  Likewise, w and h are the pixel block's dimensions.
+     *
+     * @param x x coordinate of pixel block
+     * @param y y coordinate of pixel block
+     * @param w width of pixel block
+     * @param h height of pixel block
+     * @param model color model used to interpret pixel data
+     * @param pixels pixel block data
+     * @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);
+
+    /**
+     * Deliver a subset of an ImageProducer's pixels to this ImageConsumer.
+     *
+     * Each element of the pixels array represents one pixel.  The
+     * pixel data is formatted according to the color model model.
+     * The x and y parameters are the coordinates of the rectangular
+     * region of pixels being delivered to this ImageConsumer,
+     * specified relative to the top left corner of the image being
+     * produced.  Likewise, w and h are the pixel region's dimensions.
+     *
+     * @param x x coordinate of pixel block
+     * @param y y coordinate of pixel block
+     * @param w width of pixel block
+     * @param h height of pixel block
+     * @param model color model used to interpret pixel data
+     * @param pixels pixel block data
+     * @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, 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.  
+     *
+     * @param status the status of image production, represented by a
+     * bitwise OR of ImageConsumer flags
+     */
+    void imageComplete(int status);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImageFilter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImageFilter.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImageFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImageFilter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,228 @@
+/* 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 at 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()
+    {
+      try
+        {
+          return super.clone();
+        }
+      catch (CloneNotSupportedException e)
+        {
+          // This should never happen as this class implements the
+          // Cloneable interface.
+          throw new InternalError ();
+        }
+    }
+
+    /**
+     * 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;
+	ImageFilter f = (ImageFilter)clone();
+	consumer = null;
+	return f;
+    }
+
+    /**
+     * 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)
+    {
+      if (consumer != null)
+	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");
+	if (consumer != null)
+	  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)
+    {
+      if (consumer != null)
+	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)
+    {
+      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 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);
+    }
+
+    /**
+     * 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)
+    {
+      if (consumer != null)
+	consumer.imageComplete(status);
+    }
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImageObserver.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImageObserver.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImageObserver.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImageObserver.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,129 @@
+/* ImageObserver.java -- Java interface for asynchronous updates to an image
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * An object implementing the <code>ImageObserver</code> interface can
+ * receive updates on image construction from an
+ * <code>ImageProducer</code> asynchronously.
+ *
+ * @see ImageProducer
+ * @author C. Brian Jones (cbj at gnu.org) 
+ */
+public interface ImageObserver
+{
+    /**
+     * The width of the image has been provided as the
+     * <code>width</code> argument to <code>imageUpdate</code>.
+     *
+     * @see #imageUpdate 
+     */
+    int WIDTH = 1;
+
+    /**
+     * The height of the image has been provided as the
+     * <code>height</code> argument to <code>imageUpdate</code>.
+     *
+     * @see #imageUpdate 
+     */
+    int HEIGHT = 2;
+
+    /**
+     * The properties of the image have been provided.
+     *
+     * @see #imageUpdate
+     * @see java.awt.Image#getProperty (java.lang.String, java.awt.image.ImageObserver)
+     */
+    int PROPERTIES = 4;
+
+    /**
+     * More pixels are now available for drawing a scaled variation of
+     * the image.
+     *
+     * @see #imageUpdate 
+     */
+    int SOMEBITS = 8;
+
+    /**
+     * All the pixels needed to draw a complete frame of a multi-frame
+     * image are available.
+     *
+     * @see #imageUpdate 
+     */
+    int FRAMEBITS = 16;
+
+    /**
+     * An image with a single frame, a static image, is complete.
+     *
+     * @see #imageUpdate
+     */
+    int ALLBITS = 32;
+
+    /**
+     * An error was encountered while producing the image.
+     *
+     * @see #imageUpdate
+     */
+    int ERROR = 64;
+
+    /**
+     * Production of the image was aborted.
+     *
+     * @see #imageUpdate
+     */
+    int ABORT = 128;
+
+    /**
+     * This is a callback method for an asynchronous image producer to
+     * provide updates on the production of the image as it happens.
+     *
+     * @param image the image the update refers to
+     * @param flags a bit mask indicating what is provided with this update
+     * @param x the x coordinate of the image
+     * @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 
+     */
+    boolean imageUpdate(Image image, int flags, int x, 
+					int y, int width, int height);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImageProducer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImageProducer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImageProducer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImageProducer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,85 @@
+/* ImageProducer.java -- Java interface for image production
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * An object implementing the <code>ImageProducer</code> interface can
+ * produce data for images.  Each image has a corresponding
+ * <code>ImageProducer</code> which is needed for things such as
+ * resizing the image.
+ *
+ * @see ImageConsumer
+ * @author C. Brian Jones (cbj at gnu.org) 
+ */
+public interface ImageProducer
+{
+    /**
+     * Used to register an <code>ImageConsumer</code> with this
+     * <code>ImageProducer</code>.  
+     */
+    void addConsumer(ImageConsumer ic);
+
+    /**
+     * Used to determine if the given <code>ImageConsumer</code> is
+     * 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>.  
+     */
+    void removeConsumer(ImageConsumer 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.  
+     */
+    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.  
+     */
+    void requestTopDownLeftRightResend(ImageConsumer ic);
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImagingOpException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImagingOpException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImagingOpException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ImagingOpException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,66 @@
+/* ImagingOpException.java -- indicates an imaging filter failure
+   Copyright (C) 2002, 2003, 2005  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 exception is thrown when <code>BufferedImageOp</code> or
+ * <code>RasterOp</code> filters cannot process an image.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see BufferedImageOp
+ * @see RasterOp
+ * @status updated to 1.4
+ */
+public class ImagingOpException extends RuntimeException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 8026288481846276658L;
+
+  /**
+   * Create a new instance with a descriptive error message.
+   *
+   * @param message the descriptive error message
+   */
+  public ImagingOpException(String message)
+  {
+    super(message);
+  }
+} // class ImagingOpException

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/IndexColorModel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/IndexColorModel.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/IndexColorModel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/IndexColorModel.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,697 @@
+/* IndexColorModel.java -- Java class for interpreting Pixel objects
+   Copyright (C) 1999, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 gnu.java.awt.Buffers;
+
+import java.awt.color.ColorSpace;
+import java.math.BigInteger;
+
+/**
+ * Color model similar to pseudo visual in X11.
+ * <br><br>
+ * This color model maps linear pixel values to actual RGB and alpha colors.
+ * 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 
+ * of the map entry with the same index.
+ * <br><br>
+ * Colors can have alpha components for transparency support.  If alpha
+ * component values aren't given, color values are opaque.  The model also
+ * 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 
+ * {@link DataBuffer#TYPE_USHORT}.
+ *
+ * @author C. Brian Jones (cbj at gnu.org) 
+ */
+public class IndexColorModel extends ColorModel
+{
+  private int map_size;
+  private boolean opaque;  // no alpha, but doesn't account for trans
+  private int trans = -1;
+  private int[] rgb;
+  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]. 
+   *
+   * @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 
+   *         <code>bits</code> > 16.
+   * @throws NullPointerException if any of the arrays is <code>null</code>.
+   * @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)
+  {
+    this(bits, size, reds, greens, blues, (byte[]) null);
+  }
+
+  /**
+   * 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. 
+   *
+   * @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 
+   *              transparent color).
+   * 
+   * @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 
+   *         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) 
+      throw new IllegalArgumentException("bits < 1");
+    if (bits > 16)
+      throw new IllegalArgumentException("bits > 16");
+    if (size < 1)
+      throw new IllegalArgumentException("size < 1");
+    map_size = size;
+    if (0 <= trans && trans < size) {
+      this.trans = trans;
+      transparency = BITMASK;
+    }
+    rgb = new int[size];
+    for (int i = 0; i < size; i++)
+      {
+        rgb[i] = (0xff000000
+                  | ((reds[i] & 0xff) << 16)
+                  | ((greens[i] & 0xff) << 8)
+                  | (blues[i] & 0xff));
+      }
+    // Generate a bigint with 1's for every pixel
+    validBits = validBits.setBit(size).subtract(BigInteger.ONE);
+  }
+
+  /**
+   * 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> 
+   *             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> 
+   *               permitted).
+   *
+   * @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 
+   *         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) 
+      throw new IllegalArgumentException("bits < 1");
+    if (bits > 16)
+      throw new IllegalArgumentException("bits > 16");
+    if (size < 1)
+      throw new IllegalArgumentException("size < 1");
+    map_size = size;
+    opaque = (alphas == null);
+
+    rgb = new int[size];
+    if (alphas == null)
+      {
+        for (int i = 0; i < size; i++)
+          {
+            rgb[i] = (0xff000000
+                      | ((reds[i] & 0xff) << 16)
+                      | ((greens[i] & 0xff) << 8)
+                      | (blues[i] & 0xff));
+          }
+        transparency = OPAQUE;
+      }
+    else
+      {
+	byte alphaZero = (byte) 0x00;
+        byte alphaOne = (byte) 0xFF;
+        for (int i = 0; i < size; i++)
+          {
+	    alphaZero = (byte) (alphaZero | alphas[i]);
+            alphaOne = (byte) (alphaOne & alphas[i]);
+            rgb[i] = ((alphas[i] & 0xff) << 24
+                      | ((reds[i] & 0xff) << 16)
+                      | ((greens[i] & 0xff) << 8)
+                      | (blues[i] & 0xff));
+          }
+        if ((alphaZero == (byte) 0x00) || (alphaOne == (byte) 0xFF))
+	  transparency = BITMASK;
+	else
+	  transparency = TRANSLUCENT;
+      }
+
+    // Generate a bigint with 1's for every pixel
+    validBits = validBits.setBit(size).subtract(BigInteger.ONE);
+  }
+
+  /**
+   * 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> 
+   *             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 
+   *         < 1.
+   * @throws NullPointerException if <code>cmap</code> is <code>null</code>.
+   */
+  public IndexColorModel(int bits, int size, byte[] cmap, int start, 
+                         boolean hasAlpha)
+  {
+    this(bits, size, cmap, start, hasAlpha, -1);
+  }
+
+  /**
+   * 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> 
+   *             colors
+   * @param size the number of colors in the color map
+   * @param cmap interleaved 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
+   * @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, 
+                         boolean hasAlpha, int trans)
+  {
+    super(bits, nArray(8, hasAlpha || (0 <= trans && trans < size) ? 4 : 3), 
+        ColorSpace.getInstance(ColorSpace.CS_sRGB),
+        hasAlpha || (0 <= trans && trans < size), false, OPAQUE, 
+        Buffers.smallestAppropriateTransferType(bits));
+    if (bits < 1)
+      throw new IllegalArgumentException("bits < 1");
+    if (bits > 16)
+      throw new IllegalArgumentException("bits > 16");
+    if (size < 1)
+      throw new IllegalArgumentException("size < 1");
+    map_size = size;
+    opaque = !hasAlpha;
+    if (0 <= trans && trans < size)
+      this.trans = trans;
+
+    rgb = new int[size];
+    if (hasAlpha)
+    {
+      int alpha;
+      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;  
+        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));
+      }
+      if (alphaZero == 0) 
+	transparency = BITMASK;
+      else if (alphaOne == 255) 
+        transparency = (trans != -1 ? BITMASK : OPAQUE);
+      else
+	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));
+      if (trans != -1)
+	transparency = BITMASK;
+    }
+
+    // Generate a bigint with 1's for every pixel
+    validBits = validBits.setBit(size).subtract(BigInteger.ONE);
+  }
+
+  /**
+   * Construct an IndexColorModel from an array of <code>size</code> packed
+   * colors.  Each int element contains 8-bit red, green, blue, and optional
+   * 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> 
+   *             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 
+            {@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 
+   *         {@link DataBuffer#TYPE_USHORT}.
+   */
+  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);
+    if (transferType != DataBuffer.TYPE_BYTE
+        && transferType != DataBuffer.TYPE_USHORT)
+      throw new IllegalArgumentException();
+    if (bits > 16)
+      throw new IllegalArgumentException("bits > 16");
+    if (size < 1)
+      throw new IllegalArgumentException("size < 1");
+    map_size = size;
+    opaque = !hasAlpha;
+    if (0 <= trans && trans < size)
+      this.trans = trans;
+
+    rgb = new int[size];
+    if (!hasAlpha)
+      for (int i = 0; i < size; i++)
+	rgb[i] = cmap[i + start] | 0xff000000;
+    else
+      System.arraycopy(cmap, start, rgb, 0, size);
+
+    // Generate a bigint with 1's for every pixel
+    validBits = validBits.setBit(size).subtract(BigInteger.ONE);
+  }
+
+  /**
+   * Construct an IndexColorModel using a colormap with holes.
+   * <br><br>
+   * The IndexColorModel is built from the array of ints defining the
+   * colormap.  Each element contains red, green, blue, and alpha
+   * components.    The ColorSpace is sRGB.  The transparency value is
+   * automatically determined.
+   * <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> 
+   *             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 
+   *                     {@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
+   *         < 1.
+   * @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, 
+                         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);
+    if (transferType != DataBuffer.TYPE_BYTE
+        && transferType != DataBuffer.TYPE_USHORT)
+      throw new IllegalArgumentException();
+    if (bits > 16)
+      throw new IllegalArgumentException("bits > 16");
+    if (size < 1)
+      throw new IllegalArgumentException("size < 1");
+    map_size = size;
+    opaque = false;
+    this.trans = -1;
+    this.validBits = validBits;
+
+    rgb = new int[size];
+    if (!hasAlpha)
+      for (int i = 0; i < size; i++)
+	rgb[i] = cmap[i + start] | 0xff000000;
+    else
+      System.arraycopy(cmap, start, rgb, 0, size);
+  }
+
+  /**
+   * Returns the size of the color lookup table.
+   *
+   * @return The size of the color lookup table.
+   */
+  public final int getMapSize()
+  {
+    return map_size;
+  }
+
+  /**
+   * Get the index of the transparent color in this color model.
+   *
+   * @return The index of the color that is considered transparent, or -1 if 
+   *         there is no transparent color.
+   */
+  public final int getTransparentPixel()
+  {
+    return trans;
+  }
+
+  /**
+   * 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. 
+   */
+  public final void getReds(byte[] r)
+  {
+    int i;
+    for (i = 0; i < map_size; i++)
+      r[i] = (byte) ((0x00FF0000  & rgb[i]) >> 16);
+  }
+
+  /**
+   * 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. 
+   */
+  public final void getGreens(byte[] g)
+  {
+    int i;
+    for (i = 0; i < map_size; i++)
+      g[i] = (byte) ((0x0000FF00  & rgb[i]) >> 8);
+  }
+
+  /**
+   * 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. 
+   */
+  public final void getBlues(byte[] b)
+  {
+    int i;
+    for (i = 0; i < map_size; i++)
+      b[i] = (byte) (0x000000FF & rgb[i]);
+  }
+
+  /**
+   * 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. 
+   */
+  public final void getAlphas(byte[] a)
+  {
+    int i;
+    for (i = 0; i < map_size; i++)
+      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 
+   * given pixel value.
+   *
+   * @param pixel  the pixel lookup value.
+   *
+   * @return The red component of the color in the lookup table.
+   * @throws ArrayIndexOutOfBoundsException if <code>pixel</code> is negative.
+   */
+  public final int getRed(int pixel)
+  {
+    if (pixel < map_size)
+      return (0x00FF0000 & rgb[pixel]) >> 16;
+    
+    return 0;
+  }
+
+  /**
+   * Returns the green component of the color in the lookup table for the 
+   * given pixel value.
+   *
+   * @param pixel  the pixel lookup value.
+   *
+   * @return The green component of the color in the lookup table.
+   * @throws ArrayIndexOutOfBoundsException if <code>pixel</code> is negative.
+   */
+  public final int getGreen(int pixel)
+  {
+    if (pixel < map_size)
+      return (0x0000FF00 & rgb[pixel]) >> 8;
+    
+    return 0;
+  }
+
+  /**
+   * Returns the blue component of the color in the lookup table for the 
+   * given pixel value.
+   *
+   * @param pixel  the pixel lookup value.
+   *
+   * @return The blue component of the color in the lookup table.
+   * @throws ArrayIndexOutOfBoundsException if <code>pixel</code> is negative.
+   */
+  public final int getBlue(int pixel)
+  {
+    if (pixel < map_size)
+      return 0x000000FF & rgb[pixel];
+    
+    return 0;
+  }
+
+  /**
+   * 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
+   * returns an alpha of 0.
+   *
+   * @param pixel  the pixel lookup value.
+   *
+   * @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.
+   */
+  public final int getAlpha(int pixel)
+  {
+    if (opaque && pixel != trans) 
+      return 255;
+    if ((pixel == trans && trans != -1) || pixel >= map_size)
+      return 0;
+
+    return (0xFF000000 & rgb[pixel]) >> 24;
+  }
+
+  /**
+   * Get the RGB color value of the given pixel using the default
+   * RGB color model. 
+   *
+   * @param pixel the pixel lookup value.
+   * @return The RGB color value.
+   * @throws ArrayIndexOutOfBoundsException if <code>pixel</code> is negative.
+   */
+  public final int getRGB(int pixel)
+  {
+    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. 
+   *
+   * @param rgb The destination array.
+   */
+  public final void getRGBs(int[] rgb)
+  {
+    System.arraycopy(this.rgb, 0, rgb, 0, map_size);
+  }
+    
+  /** 
+   * 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, 
+   *         <code>false</code> otherwise.
+   */
+  public boolean isValid(int pixel)
+  {
+    if (pixel >= 0)
+      return validBits.testBit(pixel);
+    return false;
+  }
+  
+  /** 
+   * 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> 
+   * otherwise.
+   */
+  public boolean isValid()
+  {
+    // Generate a bigint with 1's for every pixel
+    BigInteger allbits = new BigInteger("0");
+    allbits = allbits.setBit(map_size);
+    allbits = allbits.subtract(new BigInteger("1"));
+    return allbits.equals(validBits);
+  }
+  
+  /** 
+   * 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 
+   * {@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.
+   */
+  public BufferedImage convertToIntDiscrete(Raster raster, boolean forceARGB)
+  {
+    int type = forceARGB ? BufferedImage.TYPE_INT_ARGB
+      : ((opaque && trans == -1) ? BufferedImage.TYPE_INT_RGB :
+	 BufferedImage.TYPE_INT_ARGB); 
+
+    // FIXME: assuming that raster has only 1 band since pixels are supposed
+    // to be int indexes.
+    // FIXME: it would likely be more efficient to fetch a complete array,
+    // but it would take much more memory.
+    // FIXME: I'm not sure if transparent pixels or alpha values need special
+    // handling here.
+    BufferedImage im = new BufferedImage(raster.width, raster.height, type);
+    for (int x = raster.minX; x < raster.width + raster.minX; x++)
+      for (int y = raster.minY; y < raster.height + raster.minY; y++)
+        im.setRGB(x, y, rgb[raster.getSample(x, y, 0)]);
+
+    return im;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/Kernel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/Kernel.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/Kernel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/Kernel.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,171 @@
+/* Kernel.java -- Java class for an image processing kernel
+   Copyright (C) 2004, 2005, 2006,  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * Kernel represents an image processing kernel.  It gets used to hold
+ * convolution filters among other purposes.  It stores an array of float
+ * values representing a 2-dimensional array in row-major order.
+ *
+ * @author Jerry Quinn (jlquinn at optonline.net)
+ */
+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;
+
+  /**
+   * Creates a new <code>Kernel</code> instance with the specified dimensions
+   * and values.  The first <code>width * height</code> values in the specified
+   * <code>data</code> array are copied to internal storage.
+   *
+   * @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 
+   *      <code>height</code> is less than zero.
+   * @throws NullPointerException if <code>data</code> is <code>null</code>.
+   */
+  public Kernel(int width, int height, float[] data)
+    throws IllegalArgumentException
+  {
+    this.width = width;
+    this.height = height;
+    if (data.length < width * height || width < 0 || height < 0)
+      throw new IllegalArgumentException();
+    this.data = new float[width * height];
+    System.arraycopy(data, 0, this.data, 0, width * height);
+  }
+
+  /**
+   * 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()
+  {
+    return (width - 1) / 2;
+  }
+
+  /**
+   * 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()
+  {
+    return (height - 1) / 2;
+  }
+
+  /**
+   * Returns the kernel width (as supplied to the constructor).
+   * 
+   * @return The kernel width.
+   */
+  public final int getWidth()
+  {
+    return width;
+  }
+
+  /**
+   * Returns the kernel height (as supplied to the constructor).
+   * 
+   * @return The kernel height.
+   */
+  public final int getHeight()
+  {
+    return height;
+  }
+
+  /**
+   * 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 
+   * allocates a new array then populates and returns it.
+   *
+   * @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 
+   *     the kernel's <code>width * height</code>.
+   */
+  public final float[] getKernelData(float[] data)
+    throws IllegalArgumentException
+  {
+    if (data == null)
+      return (float[]) this.data.clone();
+
+    if (data.length < this.data.length)
+      throw new IllegalArgumentException();
+
+    System.arraycopy(this.data, 0, data, 0, this.data.length);
+    return data;
+  }
+
+  /**
+   * Returns a clone of this kernel.
+   * 
+   * @return a clone of this Kernel.
+   */
+  public Object clone()
+  {
+    try
+      {
+        return super.clone();
+      }
+    catch (CloneNotSupportedException e)
+      {
+        throw (Error) new InternalError().initCause(e); // Impossible
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/LookupOp.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/LookupOp.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/LookupOp.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/LookupOp.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,252 @@
+/* LookupOp.java -- Filter that converts each pixel using a lookup table.
+   Copyright (C) 2004  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.Point2D;
+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.
+   * 
+   * @param lookup LookupTable to use.
+   * @param hints Rendering hints (can be null).
+   */
+  public LookupOp(LookupTable lookup, RenderingHints hints)
+  {
+    lut = lookup;
+    this.hints = hints;
+  }
+  
+  /* (non-Javadoc)
+   * @see java.awt.image.BufferedImageOp#filter(java.awt.image.BufferedImage, java.awt.image.BufferedImage)
+   */
+  public final BufferedImage filter(BufferedImage src, BufferedImage dst)
+  {
+    if (src.getColorModel() instanceof IndexColorModel)
+      throw new IllegalArgumentException("LookupOp.filter: IndexColorModel "
+					 + "not allowed");
+    if (dst == null)
+      dst = createCompatibleDestImage(src, src.getColorModel());
+
+    // Set up for potential colormodel mismatch
+    BufferedImage tgt;
+    if (dst.getColorModel().equals(src.getColorModel()))
+      tgt = dst;
+    else
+      tgt = createCompatibleDestImage(src, src.getColorModel());
+
+    Raster sr = src.getRaster();
+    WritableRaster dr = tgt.getRaster();
+
+    if (src.getColorModel().hasAlpha() &&
+        (lut.getNumComponents() == 1 ||
+         lut.getNumComponents() == src.getColorModel().getNumColorComponents()))
+    {
+      // Need to ignore alpha for lookup
+      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));
+        }
+    }
+    else if (lut.getNumComponents() != 1
+	     &&
+	     lut.getNumComponents() != src.getColorModel().getNumComponents())
+      throw new IllegalArgumentException("LookupOp.filter: "
+					 + "Incompatible lookup "
+					 + "table and source image");
+
+    // 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)
+    {
+      // Convert between color models.
+      // TODO Check that premultiplied alpha is handled correctly here.
+      Graphics2D gg = dst.createGraphics();
+      gg.setRenderingHints(hints);
+      gg.drawImage(tgt, 0, 0, null);
+      gg.dispose();
+    }
+    
+    return dst;
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.BufferedImageOp#getBounds2D(java.awt.image.BufferedImage)
+   */
+  public final Rectangle2D getBounds2D(BufferedImage src)
+  {
+    return src.getRaster().getBounds();
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.BufferedImageOp#createCompatibleDestImage(java.awt.image.BufferedImage, java.awt.image.ColorModel)
+   */
+  public BufferedImage createCompatibleDestImage(BufferedImage src,
+						 ColorModel dstCM)
+  {
+    // FIXME: set properties to those in src
+    return new BufferedImage(dstCM,
+			     src.getRaster().createCompatibleWritableRaster(),
+			     src.isPremultiplied, null);
+  }
+
+  /** Return corresponding destination point for source point.
+   * 
+   * LookupOp will return the value of src unchanged.
+   * @param src The source point.
+   * @param dst The destination point.
+   * @see java.awt.image.RasterOp#getPoint2D(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;
+  }
+
+  /** Return the LookupTable for this op. */
+  public final LookupTable getTable()
+  {
+    return lut;
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.RasterOp#getRenderingHints()
+   */
+  public final RenderingHints getRenderingHints()
+  {
+    return hints;
+  }
+
+  /** 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.
+   * @throws IllegalArgumentException if lookup table has more than one
+   * component but not the same as src and dest.
+   * @see java.awt.image.RasterOp#filter(java.awt.image.Raster, java.awt.image.WritableRaster)
+   */
+  public final WritableRaster filter(Raster src, WritableRaster dest)
+  {
+    if (dest == null) 
+      // Allocate a raster if needed
+      dest = createCompatibleDestRaster(src);
+    else
+      if (src.getNumBands() != dest.getNumBands())
+        throw new IllegalArgumentException();
+
+    if (lut.getNumComponents() != 1
+	&& lut.getNumComponents() != src.getNumBands())
+      throw new IllegalArgumentException();
+
+   
+    // 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));
+    return dest;
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.RasterOp#getBounds2D(java.awt.image.Raster)
+   */
+  public final Rectangle2D getBounds2D(Raster src)
+  {
+    return src.getBounds();
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.RasterOp#createCompatibleDestRaster(java.awt.image.Raster)
+   */
+  public WritableRaster createCompatibleDestRaster(Raster src)
+  {
+    return src.createCompatibleWritableRaster();
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/LookupTable.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/LookupTable.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/LookupTable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/LookupTable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,109 @@
+/* LookupTable.java -- Java class for a pixel translation table.
+   Copyright (C) 2004, 2005  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * LookupTable represents translation arrays for pixel values.  It wraps one
+ * or more data arrays for each layer (or component) in an image, such as
+ * Alpha, R, G, and B.  When doing translation, the offset is subtracted from
+ * the pixel values to allow a subset of an array to be used.
+ *
+ * @see ByteLookupTable
+ * @see ShortLookupTable
+ *
+ * @author Jerry Quinn (jlquinn at optonline.net)
+ * @version 1.0
+ */
+public abstract class LookupTable
+{
+  // Not protected since that's part of the public API.
+  int offset;
+  int numComponents;
+
+  /**
+   * Creates a new <code>LookupTable</code> instance.
+   *
+   * 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.
+   */
+  protected LookupTable(int offset, int numComponents)
+    throws IllegalArgumentException
+  {
+    if (offset < 0 || numComponents < 1)
+      throw new IllegalArgumentException();
+    this.offset = offset;
+    this.numComponents = numComponents;
+  }
+
+  /** Return the number of components. */
+  public int getNumComponents()
+  {
+    return numComponents;
+  }
+
+  /** Return the offset. */
+  public int getOffset()
+  {
+    return offset;
+  }
+
+  
+  /**
+   * Return translated values for a pixel.
+   *
+   * For each value in the pixel src, use the value minus offset as an index
+   * in the component array and copy the value there to the output for the
+   * component.  If dest is null, the output is a new array, otherwise the
+   * translated values are written to dest.  Dest can be the same array as
+   * src.
+   *
+   * For example, if the pixel src is [2, 4, 3], and offset is 1, the output
+   * is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the
+   * translation arrays.
+   *
+   * @param src Component values of a pixel.
+   * @param dest Destination array for values, or null.
+   * @return Translated values for the pixel.
+   */
+  public abstract int[] lookupPixel(int[] src, int[] dest);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/MemoryImageSource.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/MemoryImageSource.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/MemoryImageSource.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/MemoryImageSource.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,373 @@
+/* MemoryImageSource.java -- Java class for providing image data
+   Copyright (C) 1999, 2004  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+import java.util.Vector;
+
+public class MemoryImageSource implements ImageProducer
+{
+  private boolean animated = false;
+  private boolean fullbuffers = false;
+  private int[] pixeli;
+  private int width;
+  private int height;
+  private int offset;
+  private int scansize;
+  private byte[] pixelb;
+  private ColorModel cm;
+  private Hashtable props = new Hashtable();
+  private Vector consumers = new Vector();
+
+  /**
+   * Construct an image producer that reads image data from a byte
+   * array.
+   *
+   * @param w width of image
+   * @param h height of image
+   * @param cm the color model used to represent pixel values
+   * @param pix a byte array of pixel values
+   * @param off the offset into the array at which the first pixel is stored
+   * @param scan the number of array elements that represents a single pixel row
+   */
+  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 = pix;
+  }
+
+  /**
+   * Construct an image producer that reads image data from an
+   * integer array.
+   *
+   * @param w width of image
+   * @param h height of image
+   * @param cm the color model used to represent pixel values
+   * @param pix an integer array of pixel values
+   * @param off the offset into the array at which the first pixel is stored
+   * @param scan the number of array elements that represents a single pixel row
+   */
+  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 = pix;
+  }
+
+  /**
+   * 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, int[] 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.contains(ic))
+      return;
+
+    consumers.addElement(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.contains(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.removeElement(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.contains(ic)))
+      consumers.addElement(ic);
+
+    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);
+      }
+  }
+
+  /**
+   * 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;
+	Vector list = (Vector) consumers.clone();
+	for (int i = 0; i < list.size(); i++)
+	  {
+	    ic = (ImageConsumer) list.elementAt(i);
+	    sendPicture(ic);
+	    ic.imageComplete(ImageConsumer.SINGLEFRAME);
+	  }
+      }
+  }
+
+  private void sendPicture(ImageConsumer ic)
+  {
+    ic.setHints(ImageConsumer.TOPDOWNLEFTRIGHT);
+    if (props != null)
+      ic.setProperties(props);
+    ic.setDimensions(width, height);
+    ic.setColorModel(cm);
+    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;
+	    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);
+	      }
+	  }
+      }
+  }
+
+  /**
+   * 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;
+	    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);
+	      }
+	  }
+      }
+  }
+
+  public synchronized void newPixels(byte[] newpix, ColorModel newmodel,
+                                     int offset, int scansize)
+  {
+    pixeli = null;
+    pixelb = newpix;
+    cm = newmodel;
+    this.offset = offset;
+    this.scansize = scansize;
+    if (animated == true)
+      newPixels();
+  }
+
+  public synchronized void newPixels(int[] newpix, ColorModel newmodel,
+                                     int offset, int scansize)
+  {
+    pixelb = null;
+    pixeli = newpix;
+    cm = newmodel;
+    this.offset = offset;
+    this.scansize = scansize;
+    if (animated == true)
+      newPixels();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/MultiPixelPackedSampleModel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/MultiPixelPackedSampleModel.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/MultiPixelPackedSampleModel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/MultiPixelPackedSampleModel.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,602 @@
+/* Copyright (C) 2004, 2006,  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 gnu.java.awt.Buffers;
+
+/**
+ * MultiPixelPackedSampleModel provides a single band model that supports
+ * multiple pixels in a single unit.  Pixels have 2^n bits and 2^k pixels fit
+ * per data element.
+ *
+ * @author Jerry Quinn (jlquinn at optonline.net)
+ */
+public class MultiPixelPackedSampleModel extends SampleModel
+{
+  private int scanlineStride;
+  private int[] bitMasks;
+  private int[] bitOffsets;
+  private int[] sampleSize;
+  private int dataBitOffset;
+  private int elemBits;
+  private int numberOfBits;
+  private int numElems;
+
+  /**
+   * Creates a new <code>MultiPixelPackedSampleModel</code> with the specified
+   * data type, which should be one of:
+   * <ul>
+   *   <li>{@link DataBuffer#TYPE_BYTE};</li>
+   *   <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)
+  {
+    this(dataType, w, h, numberOfBits, 0, 0);
+  }
+
+  /**
+   * Creates a new <code>MultiPixelPackedSampleModel</code> with the specified
+   * data type, which should be one of:
+   * <ul>
+   *   <li>{@link DataBuffer#TYPE_BYTE};</li>
+   *   <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 
+   *     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)
+  {
+    super(dataType, w, h, 1);
+
+    switch (dataType)
+      {
+      case DataBuffer.TYPE_BYTE:
+	elemBits = 8;
+	break;
+      case DataBuffer.TYPE_USHORT:
+	elemBits = 16;
+	break;
+      case DataBuffer.TYPE_INT:
+	elemBits = 32;
+	break;
+      default:
+	throw new IllegalArgumentException("MultiPixelPackedSampleModel"
+					   + " unsupported dataType");
+      }
+
+    this.dataBitOffset = dataBitOffset;
+
+    this.numberOfBits = numberOfBits;
+    if (numberOfBits > elemBits)
+      throw new RasterFormatException("MultiPixelPackedSampleModel pixel size"
+				      + " 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");
+      }
+    numElems = elemBits / numberOfBits;
+
+    // Compute scan line large enough for w pixels.
+    if (scanlineStride == 0)
+      scanlineStride = ((dataBitOffset + w * numberOfBits) - 1) / elemBits + 1;
+    this.scanlineStride = scanlineStride;
+
+    
+    sampleSize = new int[1];
+    sampleSize[0] = numberOfBits;
+
+    bitMasks = new int[numElems];
+    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];
+      }
+  }
+
+  /**
+   * 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)
+  {
+    /* FIXME: We can avoid recalculation of bit offsets and sample
+       sizes here by passing these from the current instance to a
+       special private constructor. */
+    return new MultiPixelPackedSampleModel(dataType, w, h, numberOfBits);
+  }
+
+  /**
+   * 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()
+  {
+    int size = scanlineStride * height;
+    if (dataBitOffset > 0)
+      size += (dataBitOffset - 1) / elemBits + 1;
+    return Buffers.createBuffer(getDataType(), size);
+  }
+
+  /**
+   * Returns the number of data elements required to transfer a pixel in the
+   * get/setDataElements() methods.
+   * 
+   * @return <code>1</code>.
+   */
+  public int getNumDataElements()
+  {
+    return 1;
+  }
+
+  /**
+   * 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. 
+   *     
+   * @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)
+  {
+    return sampleSize[0];
+  }
+
+  /**
+   * 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)
+  {
+    return scanlineStride * y + ((dataBitOffset + x * numberOfBits) / elemBits);
+  }
+
+  /**
+   * 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)
+  {
+    return (dataBitOffset + x * numberOfBits) % elemBits;
+  }
+
+  /**
+   * Returns the offset to the first data bit.
+   * 
+   * @return The offset to the first data bit.
+   */
+  public int getDataBitOffset()
+  {
+    return dataBitOffset;
+  }
+
+  /**
+   * 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()
+  {
+    return scanlineStride;
+  }
+
+  /**
+   * 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):
+   * <ul>
+   *   <li>{@link DataBuffer#TYPE_BYTE};</li>
+   *   <li>{@link DataBuffer#TYPE_USHORT};</li>
+   *   <li>{@link DataBuffer#TYPE_INT};</li>
+   * </ul>
+   * 
+   * @return The transfer type.
+   */
+  public int getTransferType()
+  {
+    if (numberOfBits <= DataBuffer.getDataTypeSize(DataBuffer.TYPE_BYTE))
+      return DataBuffer.TYPE_BYTE;
+    else if (numberOfBits <= DataBuffer.getDataTypeSize(DataBuffer.TYPE_USHORT))
+      return DataBuffer.TYPE_USHORT;
+    return DataBuffer.TYPE_INT;
+  }
+
+  /**
+   * Normally this method returns a sample model for accessing a subset of
+   * bands of image data, but since <code>MultiPixelPackedSampleModel</code>
+   * 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 
+   *     <code>null</code> and <code>bands.length != 1</code>.
+   */
+  public SampleModel createSubsetSampleModel(int[] bands)
+  {
+    if (bands != null && bands.length != 1)
+      throw new RasterFormatException("MultiPixelPackedSampleModel only"
+          + " supports one band");
+    return new MultiPixelPackedSampleModel(dataType, width, height, 
+        numberOfBits, scanlineStride, dataBitOffset);
+  }
+
+  /**
+   * Extract one pixel and return in an array of transfer type.
+   *
+   * Extracts the pixel at x, y from data and stores into the 0th index of the
+   * 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 
+   *     <code>obj</code>.
+   * @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 
+   *     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, 
+   *     DataBuffer)
+   */
+  public Object getDataElements(int x, int y, Object obj, DataBuffer data)
+  {
+    int pixel = getSample(x, y, 0, data);
+    switch (getTransferType())
+      {
+        case DataBuffer.TYPE_BYTE:
+          if (obj == null) 
+            obj = new byte[1];
+          ((byte[]) obj)[0] = (byte) pixel;
+          return obj;
+        case DataBuffer.TYPE_USHORT:
+          if (obj == null) 
+            obj = new short[1];
+          ((short[]) obj)[0] = (short) pixel;
+          return obj;
+        case DataBuffer.TYPE_INT:
+          if (obj == null) 
+            obj = new int[1];
+          ((int[]) obj)[0] = pixel;
+          return obj;
+        default:
+          // Seems like the only sensible thing to do.
+          throw new ClassCastException();
+      }
+  }
+
+  /**
+   * 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 
+   *     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) 
+      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 
+   * 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 
+   *     <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)
+  {
+    int pos =
+      ((dataBitOffset + x * numberOfBits) % elemBits) / numberOfBits;
+    int offset = getOffset(x, y);
+    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.
+   *
+   * @param x The x-coordinate of the data elements in <code>obj</code>.
+   * @param y The y-coordinate of the data elements in <code>obj</code>.
+   * @param obj The primitive array containing the data elements to set.
+   * @param data The DataBuffer to store the data elements into.
+   */
+  public void setDataElements(int x, int y, Object obj, DataBuffer data)
+  {
+    int transferType = getTransferType();
+    try
+      {
+        switch (transferType)
+          {
+            case DataBuffer.TYPE_BYTE:
+              {
+                byte[] in = (byte[]) obj;
+                setSample(x, y, 0, in[0] & 0xFF, data);
+                return;
+              }
+            case DataBuffer.TYPE_USHORT:
+              {
+                short[] in = (short[]) obj;
+                setSample(x, y, 0, in[0] & 0xFFFF, data);
+                return;
+              }
+            case DataBuffer.TYPE_INT:
+              {
+                int[] in = (int[]) obj;
+                setSample(x, y, 0, in[0], data);
+                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=" + getOffset(x, y) +
+          ", data.getSize()=" + data.getSize() +
+          ", data.getOffset()=" + data.getOffset() +
+          ": " + aioobe;
+        throw new ArrayIndexOutOfBoundsException(msg);
+      }
+  }
+
+  /**
+   * 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 
+   *     <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)
+  {
+    setSample(x, y, 0, iArray[0], data);
+  }
+
+  /**
+   * 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 
+   *     <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)
+  {
+    int bitpos =
+      ((dataBitOffset + x * numberOfBits) % elemBits) / numberOfBits;
+    int offset = getOffset(x, y);
+
+    s = s << bitOffsets[bitpos];
+    s = s & bitMasks[bitpos];
+
+    int sample = data.getElem(offset);
+    sample |= s;
+    data.setElem(offset, sample);
+  }
+  
+  /**
+   * 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 
+   *       <code>MultiPixelPackedSampleModel</code>;
+   *   <li>both models have the same:
+   *     <ul>
+   *       <li><code>dataType</code>;
+   *       <li><code>width</code>;
+   *       <li><code>height</code>;
+   *       <li><code>numberOfBits</code>;
+   *       <li><code>scanlineStride</code>;
+   *       <li><code>dataBitOffsets</code>.
+   *     </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) 
+  {
+    if (this == obj) 
+      return true;
+    if (! (obj instanceof MultiPixelPackedSampleModel)) 
+      return false;
+    MultiPixelPackedSampleModel that = (MultiPixelPackedSampleModel) obj;
+    if (this.dataType != that.dataType)
+      return false;
+    if (this.width != that.width)
+      return false;
+    if (this.height != that.height)
+      return false;
+    if (this.numberOfBits != that.numberOfBits)
+      return false;
+    if (this.scanlineStride != that.scanlineStride)
+      return false;
+    if (this.dataBitOffset != that.dataBitOffset)
+      return false;
+    return true;
+  }
+  
+  /**
+   * Returns a hash code for this <code>MultiPixelPackedSampleModel</code>.
+   * 
+   * @return A hash code.
+   */
+  public int hashCode()
+  {
+    // this hash code won't match Sun's, but that shouldn't matter...
+    int result = 193;
+    result = 37 * result + dataType;
+    result = 37 * result + width;
+    result = 37 * result + height;
+    result = 37 * result + numberOfBits;
+    result = 37 * result + scanlineStride;
+    result = 37 * result + dataBitOffset;
+    return result;
+  }
+  
+  /**
+   * Creates a String with some information about this SampleModel.
+   * @return A String describing this SampleModel.
+   * @see java.lang.Object#toString()
+   */
+  public String toString()
+  {
+    StringBuffer result = new StringBuffer();
+    result.append(getClass().getName());
+    result.append("[");
+    result.append("scanlineStride=").append(scanlineStride);
+    for(int i=0; i < bitMasks.length; i+=1)
+    {
+      result.append(", mask[").append(i).append("]=0x").append(Integer.toHexString(bitMasks[i]));
+    }
+    
+    result.append("]");
+    return result.toString();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/PackedColorModel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/PackedColorModel.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/PackedColorModel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/PackedColorModel.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,188 @@
+/* Copyright (C) 2000, 2002, 2004  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 gnu.java.awt.BitMaskExtent;
+
+import java.awt.Point;
+import java.awt.color.ColorSpace;
+
+/**
+ * @author Rolf W. Rasmussen (rolfwr at ii.uib.no)
+ */
+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)
+  {
+    super(pixelBits, calcBitsPerComponent(colorMaskArray, alphaMask),
+	  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]");
+    }
+  }
+    
+  private static int[] calcBitsPerComponent(int[] colorMaskArray,
+					    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;
+      }
+    if (alphaMask != 0)
+      {
+	extent.setMask(alphaMask);
+	bitsPerComponent[numComponents-1] = extent.bitWidth;
+      }
+    return bitsPerComponent;
+  }
+
+  /** Initializes the masks.  */
+  private void initMasks(int[] colorMaskArray, int alphaMask)
+  {
+    int numComponents = colorMaskArray.length;
+    if (alphaMask == 0)
+      {
+	masks = colorMaskArray;
+      }
+    else
+      {
+	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;
+      }
+  }
+    
+  public PackedColorModel(ColorSpace cspace, int pixelBits,
+			  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);
+  }
+    
+  /* 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
+     takes a complete array of masks (color+alpha) as an
+     argument. */
+
+  private static int[] makeColorMaskArray(int rmask, int gmask, int bmask)
+  {
+    int[] colorMaskArray = { rmask, gmask, bmask };
+    return colorMaskArray;
+  }   
+
+  public final int getMask(int index)
+  {
+    return masks[index];
+  }
+  
+  public final int[] getMasks()
+  {
+    return masks;
+  }
+
+  public SampleModel createCompatibleSampleModel(int w, int h)
+  {
+    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);
+  }
+
+  public WritableRaster getAlphaRaster(WritableRaster raster) {
+    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);
+  }
+    
+  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);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/PixelGrabber.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/PixelGrabber.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/PixelGrabber.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/PixelGrabber.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,631 @@
+/* PixelGrabber.java -- retrieve a subset of an image's data
+   Copyright (C) 1999, 2003, 2004  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Hashtable;
+
+/**
+ * PixelGrabber is an ImageConsumer that extracts a rectangular region
+ * of pixels from an Image.
+ */
+public class PixelGrabber implements ImageConsumer
+{
+  int x, y, offset;
+  int width = -1;
+  int height = -1;
+  int scansize = -1;
+  boolean forceRGB = true;
+
+  ColorModel model = ColorModel.getRGBdefault();
+  int hints;
+  Hashtable props;
+
+  int int_pixel_buffer[];
+  boolean ints_delivered = false;
+  byte byte_pixel_buffer[];
+  boolean bytes_delivered = false;
+
+  ImageProducer ip;
+  int observerStatus;
+  int consumerStatus;
+
+  private Thread grabberThread;
+  boolean grabbing = false;
+
+  /**
+   * Construct a PixelGrabber that will retrieve RGB data from a given
+   * Image.
+   *
+   * The RGB data will be retrieved from a rectangular region
+   * <code>(x, y, w, h)</code> within the image.  The data will be
+   * stored in the provided <code>pix</code> array, which must have
+   * been initialized to a size of at least <code>w * h</code>.  The
+   * data for a pixel (m, n) in the grab rectangle will be stored at
+   * <code>pix[(n - y) * scansize + (m - x) + off]</code>.
+   *
+   * @param img the Image from which to grab pixels
+   * @param x the x coordinate, relative to <code>img</code>'s
+   * top-left corner, of the grab rectangle's top-left pixel
+   * @param y the y coordinate, relative to <code>img</code>'s
+   * top-left corner, of the grab rectangle's top-left pixel
+   * @param w the width of the grab rectangle, in pixels
+   * @param h the height of the grab rectangle, in pixels
+   * @param pix the array in which to store grabbed RGB pixel data
+   * @param off the offset into the <code>pix</code> array at which to
+   * start storing RGB data
+   * @param scansize a set of <code>scansize</code> consecutive
+   * elements in the <code>pix</code> array represents one row of
+   * pixels in the grab rectangle
+   */
+  public PixelGrabber(Image img, int x, int y, int w, int h,
+		      int pix[], int off, int scansize)
+  {
+    this (img.getSource(), x, y, w, h, pix, off, scansize);
+  }
+
+  /**
+   * Construct a PixelGrabber that will retrieve RGB data from a given
+   * ImageProducer.
+   *
+   * The RGB data will be retrieved from a rectangular region
+   * <code>(x, y, w, h)</code> within the image produced by
+   * <code>ip</code>.  The data will be stored in the provided
+   * <code>pix</code> array, which must have been initialized to a
+   * size of at least <code>w * h</code>.  The data for a pixel (m, n)
+   * in the grab rectangle will be stored at
+   * <code>pix[(n - y) * scansize + (m - x) + off]</code>.
+   *
+   * @param ip the ImageProducer from which to grab pixels. This can
+   * be null.
+   * @param x the x coordinate of the grab rectangle's top-left pixel,
+   * specified relative to the top-left corner of the image produced
+   * by <code>ip</code>
+   * @param y the y coordinate of the grab rectangle's top-left pixel,
+   * specified relative to the top-left corner of the image produced
+   * by <code>ip</code>
+   * @param w the width of the grab rectangle, in pixels
+   * @param h the height of the grab rectangle, in pixels
+   * @param pix the array in which to store grabbed RGB pixel data
+   * @param off the offset into the <code>pix</code> array at which to
+   * start storing RGB data
+   * @param scansize a set of <code>scansize</code> consecutive
+   * elements in the <code>pix</code> array represents one row of
+   * pixels in the grab rectangle
+   */
+  public PixelGrabber(ImageProducer ip, int x, int y, int w, int h,
+		      int pix[], int off, int scansize)
+  {
+    this.ip = ip;
+    this.x = x;
+    this.y = y;
+    this.width = w;
+    this.height = h;
+    this.offset = off;
+    this.scansize = scansize;
+
+    int_pixel_buffer = pix;
+    // Initialize the byte array in case ip sends us byte-formatted
+    // pixel data.
+    byte_pixel_buffer = new byte[pix.length * 4];
+  }
+
+  /**
+   * Construct a PixelGrabber that will retrieve data from a given
+   * Image.
+   *
+   * The RGB data will be retrieved from a rectangular region
+   * <code>(x, y, w, h)</code> within the image.  The data will be
+   * stored in an internal array which can be accessed by calling
+   * <code>getPixels</code>.  The data for a pixel (m, n) in the grab
+   * rectangle will be stored in the returned array at index
+   * <code>(n - y) * scansize + (m - x) + off</code>.
+   * If forceRGB is false, then the returned data will be not be
+   * converted to RGB from its format in <code>img</code>.
+   *
+   * If <code>w</code> is negative, the width of the grab region will
+   * be from x to the right edge of the image.  Likewise, if
+   * <code>h</code> is negative, the height of the grab region will be
+   * from y to the bottom edge of the image.
+   *
+   * @param img the Image from which to grab pixels
+   * @param x the x coordinate, relative to <code>img</code>'s
+   * top-left corner, of the grab rectangle's top-left pixel
+   * @param y the y coordinate, relative to <code>img</code>'s
+   * top-left corner, of the grab rectangle's top-left pixel
+   * @param w the width of the grab rectangle, in pixels
+   * @param h the height of the grab rectangle, in pixels
+   * @param forceRGB true to force conversion of the rectangular
+   * region's pixel data to RGB
+   */
+  public PixelGrabber(Image img,
+		      int x, int y,
+		      int w, int h,
+		      boolean forceRGB)
+  {
+    this.ip = img.getSource();
+
+    if (this.ip == null)
+      throw new NullPointerException("The ImageProducer must not be null.");
+
+    this.x = x;
+    this.y = y;
+    width = w;
+    height = h;
+    // If width or height is negative, postpone pixel buffer
+    // 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];
+      }
+    this.forceRGB = forceRGB;
+  }
+
+  /**
+   * Start grabbing pixels.
+   *
+   * Spawns an image production thread that calls back to this
+   * PixelGrabber's ImageConsumer methods.
+   */
+  public synchronized void startGrabbing()
+  {
+    // Make sure we're not already grabbing.
+    if (grabbing == false)
+      {
+	grabbing = true;
+	grabberThread = new Thread ()
+	  {
+	    public void run ()
+	    {
+              try
+                {
+                  ip.startProduction (PixelGrabber.this);
+                }
+              catch (Exception ex)
+                {
+                  imageComplete(ImageConsumer.IMAGEABORTED);
+                }
+	    }
+	  };
+	grabberThread.start ();
+      }
+  }
+
+  /**
+   * Abort pixel grabbing.
+   */
+  public synchronized void abortGrabbing()
+  {
+    if (grabbing)
+      {
+	// Interrupt the grabbing thread.
+        Thread moribund = grabberThread;
+        grabberThread = null;
+        moribund.interrupt();
+
+	imageComplete (ImageConsumer.IMAGEABORTED);
+      }
+  }
+
+  /**
+   * Have our Image or ImageProducer start sending us pixels via our
+   * ImageConsumer methods and wait for all pixels in the grab
+   * rectangle to be delivered.
+   *
+   * @return true if successful, false on abort or error
+   *
+   * @throws InterruptedException if interrupted by another thread.
+   */
+  public synchronized boolean grabPixels() throws InterruptedException
+  {
+    return grabPixels(0);
+  }
+
+  /**
+   * grabPixels's behavior depends on the value of <code>ms</code>.
+   *
+   * If ms < 0, return true if all pixels from the source image have
+   * been delivered, false otherwise.  Do not wait.
+   *
+   * If ms >= 0 then we request that our Image or ImageProducer start
+   * delivering pixels to us via our ImageConsumer methods.
+   *
+   * If ms > 0, wait at most <code>ms</code> milliseconds for
+   * delivery of all pixels within the grab rectangle.
+   *
+   * If ms == 0, wait until all pixels have been delivered.
+   *
+   * @return true if all pixels from the source image have been
+   * delivered, false otherwise
+   *
+   * @throws InterruptedException if this thread is interrupted while
+   * we are waiting for pixels to be delivered
+   */
+  public synchronized boolean grabPixels(long ms) throws InterruptedException
+  {
+    if (ms < 0)
+      return ((observerStatus & (ImageObserver.FRAMEBITS
+				 | ImageObserver.ALLBITS)) != 0);
+
+    // Spawn a new ImageProducer thread to send us the image data via
+    // our ImageConsumer methods.
+    startGrabbing();
+
+    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 ();
+      }
+    else
+      wait ();
+
+    // If consumerStatus is non-zero then the image is done loading or
+    // an error has occurred.
+    if (consumerStatus != 0)
+      return setObserverStatus ();
+
+    return ((observerStatus & (ImageObserver.FRAMEBITS
+			       | ImageObserver.ALLBITS)) != 0);
+  }
+
+  // Set observer status flags based on the current consumer status
+  // flags.  Return true if the consumer flags indicate that the
+  // image was loaded successfully, or false otherwise.
+  private synchronized boolean setObserverStatus ()
+  {
+    boolean retval = false;
+
+    if ((consumerStatus & IMAGEERROR) != 0)
+      observerStatus |= ImageObserver.ERROR;
+
+    if ((consumerStatus & IMAGEABORTED) != 0)
+      observerStatus |= ImageObserver.ABORT;
+
+    if ((consumerStatus & STATICIMAGEDONE) != 0)
+      {
+	observerStatus |= ImageObserver.ALLBITS;
+	retval = true;
+      }
+
+    if ((consumerStatus & SINGLEFRAMEDONE) != 0)
+      {
+	observerStatus |= ImageObserver.FRAMEBITS;
+	retval = true;
+      }
+
+    return retval;
+  }
+
+  /**
+   * @return the status of the pixel grabbing thread, represented by a
+   * bitwise OR of ImageObserver flags
+   */
+  public synchronized int getStatus()
+  {
+    return observerStatus;
+  }
+
+  /**
+   * @return the width of the grab rectangle in pixels, or a negative
+   * number if the ImageProducer has not yet called our setDimensions
+   * method
+   */
+  public synchronized int getWidth()
+  {
+    return width;
+  }
+
+  /**
+   * @return the height of the grab rectangle in pixels, or a negative
+   * number if the ImageProducer has not yet called our setDimensions
+   * method
+   */
+  public synchronized int getHeight()
+  {
+    return height;
+  }
+
+  /**
+   * @return a byte array of pixel data if ImageProducer delivered
+   * pixel data using the byte[] variant of setPixels, or an int array
+   * otherwise
+   */
+  public synchronized Object getPixels()
+  {
+    if (ints_delivered)
+      return int_pixel_buffer;
+    else if (bytes_delivered)
+      return byte_pixel_buffer;
+    else
+      return null;
+  }
+
+  /**
+   * @return the ColorModel currently being used for the majority of
+   * pixel data conversions
+   */
+  public synchronized ColorModel getColorModel()
+  {
+    return model;
+  }
+
+  /**
+   * Our <code>ImageProducer</code> calls this method to indicate the
+   * size of the image being produced.
+   *
+   * setDimensions 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
+   * by the PixelGrabber's ImageProducer.
+   * 
+   * @param width the width of the image
+   * @param height the height of the image
+   */
+  public synchronized void setDimensions(int width, int height)
+  {
+    // Our width wasn't set when we were constructed.  Set our width
+    // so that the grab region includes all pixels from x to the right
+    // edge of the source image.
+    if (this.width < 0)
+      this.width = width - x;
+
+    // Our height wasn't set when we were constructed.  Set our height
+    // so that the grab region includes all pixels from y to the
+    // bottom edge of the source image.
+    if (this.height < 0)
+      this.height = height - y;
+
+    if (scansize < 0)
+      scansize = this.width;
+
+    if (int_pixel_buffer == null)
+      int_pixel_buffer = new int[this.width * this.height];
+
+    if (byte_pixel_buffer == null)
+      byte_pixel_buffer = new byte[this.width * this.height];
+  }
+
+  /**
+   * Our <code>ImageProducer</code> may call this method to send us a
+   * list of its image's properties.
+   *
+   * setProperties 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
+   * by the PixelGrabber's ImageProducer.
+   *
+   * @param props a list of properties associated with the image being
+   * produced
+   */
+  public synchronized void setProperties(Hashtable props)
+  {
+    this.props = props;
+  }
+
+  /**
+   * Our ImageProducer will call <code>setColorModel</code> to
+   * indicate the model used by the majority of calls to
+   * <code>setPixels</code>.  Each call to <code>setPixels</code>
+   * could however indicate a different <code>ColorModel</code>.
+   *
+   * setColorModel 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
+   * by the PixelGrabber's ImageProducer.
+   *
+   * @param model the color model to be used most often by setPixels
+   *
+   * @see ColorModel
+   */
+  public synchronized void setColorModel(ColorModel model)
+  {
+    this.model = model;
+  }
+
+  /**
+   * Our <code>ImageProducer</code> may 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>.
+   * 
+   * 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
+   * by the PixelGrabber's ImageProducer.
+   *
+   * @param flags a bit mask of hints
+   */
+  public synchronized void setHints(int flags)
+  {
+    hints = flags;
+  }
+
+  /**
+   * Our ImageProducer calls setPixels to deliver a subset of its
+   * pixels.
+   *
+   * Each element of the pixels array represents one pixel.  The
+   * pixel data is formatted according to the color model model.
+   * The x and y parameters are the coordinates of the rectangular
+   * region of pixels being delivered to this ImageConsumer,
+   * specified relative to the top left corner of the image being
+   * produced.  Likewise, w and h are the pixel region's dimensions.
+   *
+   * @param x x coordinate of pixel block
+   * @param y y coordinate of pixel block
+   * @param w width of pixel block
+   * @param h height of pixel block
+   * @param model color model used to interpret pixel data
+   * @param pixels pixel block data
+   * @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)
+  {
+    ColorModel currentModel;
+    if (model != null)
+      currentModel = model;
+    else
+      currentModel = this.model;
+
+    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];
+		  }
+	      }
+	  }
+      }
+  }
+
+  /**
+   * Our ImageProducer calls setPixels to deliver a subset of its
+   * pixels.
+   *
+   * Each element of the pixels array represents one pixel.  The
+   * pixel data is formatted according to the color model model.
+   * The x and y parameters are the coordinates of the rectangular
+   * region of pixels being delivered to this ImageConsumer,
+   * specified relative to the top left corner of the image being
+   * produced.  Likewise, w and h are the pixel region's dimensions.
+   *
+   * @param x x coordinate of pixel block
+   * @param y y coordinate of pixel block
+   * @param w width of pixel block
+   * @param h height of pixel block
+   * @param model color model used to interpret pixel data
+   * @param pixels pixel block data
+   * @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)
+  {
+    ColorModel currentModel;
+    if (model != null)
+      currentModel = model;
+    else
+      currentModel = this.model;
+
+    ints_delivered = true;
+
+    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];
+	      }
+	  }
+      }
+  }
+
+  /**
+   * Our <code>ImageProducer</code> calls this method to inform us
+   * that a single frame or the entire image is complete.  The method
+   * is also used to inform us of an error in loading or producing the
+   * image.
+   *
+   * @param status the status of image production, represented by a
+   * bitwise OR of ImageConsumer flags
+   */
+  public synchronized void imageComplete(int status)
+  {
+    consumerStatus = status;
+    setObserverStatus ();
+    grabbing = false;
+    if (ip != null)
+      ip.removeConsumer (this);
+
+    notifyAll ();
+  }
+
+  /**
+   * @return the return value of getStatus
+   *
+   * @specnote The newer getStatus should be used in place of status.
+   */
+  public synchronized int status()
+  {
+    return getStatus();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/PixelInterleavedSampleModel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/PixelInterleavedSampleModel.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/PixelInterleavedSampleModel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/PixelInterleavedSampleModel.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,98 @@
+/* PixelInterleavedSampleModel.java
+   Copyright (C) 2004, 2005  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <code>SampleModel</code> that uses exactly one element of the
+ * raster&#x2019;s {@link DataBuffer} per pixel, holds all bands in a
+ * single bank, and stores band data in pixel-interleaved manner.
+ *
+ * @since 1.2
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public class PixelInterleavedSampleModel
+  extends ComponentSampleModel
+{
+  public PixelInterleavedSampleModel(int dataType, int width, int height,
+                                     int pixelStride, int scanlineStride,
+                                     int[] bandOffsets)
+  {
+    super(dataType, width, height, pixelStride, scanlineStride,
+          bandOffsets);
+  }
+
+  
+  /**
+   * Creates a new <code>SampleModel</code> that is like this one, but
+   * uses the specified width and height.
+   *
+   * @param width the number of pixels in the horizontal direction.
+   *
+   * @param height the number of pixels in the vertical direction.
+   */
+  public SampleModel createCompatibleSampleModel(int width, int height)
+  {
+    return new PixelInterleavedSampleModel(dataType, width, height,
+                                           pixelStride, scanlineStride,
+                                           bandOffsets);
+  }
+
+
+  /**
+   * Creates a new <code>SampleModel</code> that is like this one, but
+   * uses only a subset of its bands.
+   *
+   * @param bands an array whose elements indicate which bands shall
+   * be part of the subset. For example, <code>[0, 2, 3]</code> would
+   * create a SampleModel containing bands #0, #2 and #3.
+   */
+  public SampleModel createSubsetSampleModel(int[] bands)
+  {
+    int[] subOffsets;
+
+    subOffsets = new int[bands.length];
+    for (int i = 0; i < bands.length; i++)
+      subOffsets[i] = bandOffsets[bands[i]];
+
+    return new PixelInterleavedSampleModel(dataType, width, height,
+                                           pixelStride, scanlineStride,
+                                           subOffsets);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RGBImageFilter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RGBImageFilter.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RGBImageFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RGBImageFilter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,273 @@
+/* RGBImageFilter.java -- Java class for filtering Pixels by RGB values
+   Copyright (C) 1999, 2005  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 at columbia.edu)
+ */
+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 
+       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 );
+		if (consumer != null)
+		  consumer.setColorModel(newmodel);
+	    }
+	else {
+	  if (consumer != null)
+	    consumer.setColorModel(ColorModel.getRGBdefault());
+	}
+    }
+    
+    /**
+       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 & (g << 8) | 0xff & b ); 
+    }
+
+    /**
+       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 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 offset, int scansize)
+    {
+      for (int yp = 0; yp < h; yp++)
+	{
+	  for (int xp = 0; xp < w; xp++)
+	    {
+	      pixels[offset + xp] = filterRGB(xp + x, yp + y, pixels[offset + xp]);
+	    }
+	  offset += scansize;
+	}
+    }
+
+
+    /**
+     * 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 && (model instanceof IndexColorModel) && canFilterIndexColorModel)
+	{
+	  if (consumer != null)
+	    consumer.setPixels(x, y, w, h, newmodel, pixels, offset, scansize);
+	}
+	else
+	{
+	    int intPixels[] =
+		convertColorModelToDefault( x, y, w, h, model, pixels, offset, scansize );
+	    filterRGBPixels( x, y, w, h, intPixels, offset, scansize );
+	    if (consumer != null)
+	      consumer.setPixels(x, y, w, h, ColorModel.getRGBdefault(), intPixels, 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 && (model instanceof IndexColorModel) && canFilterIndexColorModel)
+	{
+	  if (consumer != null)
+	    consumer.setPixels(x, y, w, h, newmodel, pixels, offset, scansize);
+	}
+	else
+	{
+	    //FIXME: Store the filtered pixels in a separate temporary buffer?
+	  convertColorModelToDefault( x, y, w, h, model, pixels, offset, scansize );
+	  filterRGBPixels( x, y, w, h, pixels, offset, scansize );
+	  if (consumer != null)
+	    consumer.setPixels(x, y, w, h, ColorModel.getRGBdefault(), pixels, offset, scansize);
+	}
+    }
+
+    private int[] convertColorModelToDefault(int x, int y, int w, int h, 
+                                            ColorModel model, byte pixels[],
+                                            int offset, int scansize)
+    {
+	int intPixels[] = new int[pixels.length];
+	for (int i = 0; i < pixels.length; i++)
+	    intPixels[i] = makeColorbyDefaultCM(model, pixels[i]);
+	return intPixels;
+    }
+
+    private void convertColorModelToDefault(int x, int y, int w, int h, 
+                                            ColorModel model, int pixels[],
+                                            int offset, int scansize)
+    {
+	for (int i = 0; i < pixels.length; i++)
+	    pixels[i] = makeColorbyDefaultCM(model, pixels[i]);
+    }
+
+    private int makeColorbyDefaultCM(ColorModel model, byte rgb) 
+    {
+	return makeColor( model.getAlpha( rgb ) * 4, model.getRed( rgb ) * 4, model.getGreen( rgb ) * 4, model.getBlue( rgb ) * 4 );
+    }
+
+    private int makeColorbyDefaultCM(ColorModel model, int rgb) 
+    {
+	return makeColor( model.getAlpha( rgb ), model.getRed( rgb ), model.getGreen( rgb ), model.getBlue( rgb ) );
+    }
+
+    private int makeColor( int a, int r, int g, int b )
+    {
+	return (int)( 0xff000000 & (a << 24) | 0xff0000 & (r << 16) | 0xff00 & (g << 8) | 0xff & b ); 
+    }
+
+
+    /**
+       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);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/Raster.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/Raster.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/Raster.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/Raster.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,970 @@
+/* Copyright (C) 2000, 2002, 2003, 2006,  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Point;
+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 at 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.
+   */
+  protected Raster(SampleModel sampleModel, Point origin)
+  {
+    this(sampleModel, sampleModel.createDataBuffer(), origin);
+  }
+  
+  /**
+   * Creates a new raster.
+   * 
+   * @param sampleModel  the sample model.
+   * @param dataBuffer  the data buffer.
+   * @param origin  the origin.
+   */
+  protected Raster(SampleModel sampleModel, DataBuffer dataBuffer,
+                   Point origin)
+  {
+    this(sampleModel, dataBuffer, new Rectangle(origin.x, origin.y,
+         sampleModel.getWidth(), sampleModel.getHeight()), origin, null);
+  }
+
+  /**
+   * Creates a new raster.
+   * 
+   * @param sampleModel  the sample model.
+   * @param dataBuffer  the data buffer.
+   * @param aRegion  the raster's bounds.
+   * @param sampleModelTranslate  the translation (<code>null</code> permitted).
+   * @param parent  the raster's parent.
+   */
+  protected Raster(SampleModel sampleModel, DataBuffer dataBuffer,
+      Rectangle aRegion, Point sampleModelTranslate, Raster parent)
+  {
+    this.sampleModel = sampleModel;
+    this.dataBuffer = dataBuffer;
+    this.minX = aRegion.x;
+    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)
+    {
+      this.sampleModelTranslateX = sampleModelTranslate.x;
+      this.sampleModelTranslateY = sampleModelTranslate.y;
+    }
+
+    this.numBands = sampleModel.getNumBands();
+    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,
+      int w, int h, int bands, Point location)
+  {
+    int[] bandOffsets = new int[bands];
+    // TODO: Maybe not generate this every time.
+    for (int b = 0; b < bands; b++) 
+      bandOffsets[b] = b;
+    
+    int scanlineStride = bands * w;
+    return createInterleavedRaster(dataType, w, h, scanlineStride, bands,
+                                   bandOffsets, location);
+  }
+
+  /**
+   * 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 
+   *     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, 
+      int w, int h, int scanlineStride, int pixelStride, int[] bandOffsets,
+      Point location)
+  {
+    SampleModel sm = new ComponentSampleModel(dataType, w, h, pixelStride,
+        scanlineStride, bandOffsets);
+    return createWritableRaster(sm, location);
+  }
+
+  /**
+   * 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  
+   * 
+   * @return The new raster.
+   */
+  public static WritableRaster createBandedRaster(int dataType, int w, int h, 
+      int bands, Point location)
+  {
+    SampleModel sm = new BandedSampleModel(dataType, w, h, bands);
+    return createWritableRaster(sm, location);
+  }
+
+  /**
+   * 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 
+   *     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,
+      int scanlineStride, int[] bankIndices, int[] bandOffsets, Point location)
+  {
+    SampleModel sm = new BandedSampleModel(dataType, w, h, scanlineStride,
+                                           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 
+   * 
+   * @return The new raster.
+   */
+  public static WritableRaster createPackedRaster(int dataType, int w, int h,
+      int[] bandMasks, Point location)
+  {
+    SampleModel sm = new SinglePixelPackedSampleModel(dataType, w, h,
+                                                     bandMasks);
+    return createWritableRaster(sm, location);
+  }
+
+  /**
+   * 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,
+      int w, int h, int bands, int bitsPerBand, Point location)
+  {
+    if (bands <= 0 || (bands * bitsPerBand > getTypeBits(dataType)))
+      throw new IllegalArgumentException();
+
+    SampleModel sm;
+
+    if (bands == 1)
+      sm = new MultiPixelPackedSampleModel(dataType, w, h, bitsPerBand);
+    else
+      {
+        int[] bandMasks = new int[bands];
+        int mask = 0x1;
+        for (int bits = bitsPerBand; --bits != 0;)
+          mask = (mask << 1) | 0x1;
+        for (int i = 0; i < bands; i++)
+          {
+            bandMasks[i] = mask;
+            mask <<= bitsPerBand;
+          }
+          
+        sm = new SinglePixelPackedSampleModel(dataType, w, h, bandMasks);
+      }
+    return createWritableRaster(sm, location);
+  }
+
+  /**
+   * 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 
+   *     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, 
+      Point location)
+  {
+    SampleModel sm = new ComponentSampleModel(dataBuffer.getDataType(),
+        w, h, scanlineStride, pixelStride, bandOffsets);
+    return createWritableRaster(sm, dataBuffer, location);
+  }
+
+  /**
+   * 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 
+   *     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,
+      int w, int h, int scanlineStride, int[] bankIndices, int[] bandOffsets,
+      Point location)
+  {
+    SampleModel sm = new BandedSampleModel(dataBuffer.getDataType(),
+        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 
+   *     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,
+      int w, int h, int scanlineStride, int[] bandMasks, Point location)
+ {
+    SampleModel sm = new SinglePixelPackedSampleModel(dataBuffer.getDataType(),
+        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,
+      int w, int h, int bitsPerPixel, Point location)
+  {
+    SampleModel sm = new MultiPixelPackedSampleModel(dataBuffer.getDataType(),
+        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,
+                                    Point location)
+  {
+    return new Raster(sm, db, location);
+  }
+
+  /**
+   * Creates a new writable raster.
+   * 
+   * @param sm  the sample model.
+   * @param location
+   * 
+   * @return The new writable raster.
+   */
+  public static WritableRaster createWritableRaster(SampleModel sm,
+                                                    Point location)
+  {
+    return new WritableRaster(sm, location);
+  }
+
+  /**
+   * Creates a new writable raster.
+   * 
+   * @param sm  the sample model.
+   * @param db  the data buffer.
+   * @param location 
+   * 
+   * @return The new writable raster.
+   */
+  public static WritableRaster createWritableRaster(SampleModel sm,
+      DataBuffer db, Point location)
+  {
+    return new WritableRaster(sm, db, location);
+  }
+
+  /**
+   * Returns the raster's parent.
+   * 
+   * @return The raster's parent.
+   */
+  public Raster getParent()
+  {
+    return parent;
+  }
+
+  /**
+   * Returns the x-translation.
+   * 
+   * @return The x-translation.
+   */
+  public final int getSampleModelTranslateX()
+  {
+    return sampleModelTranslateX;
+  }
+
+  /**
+   * Returns the y-translation.
+   * 
+   * @return The y-translation.
+   */
+  public final int getSampleModelTranslateY()
+  {
+    return sampleModelTranslateY;
+  }
+
+  /**
+   * Creates a new writable raster that is compatible with this raster.
+   * 
+   * @return A new writable raster.
+   */
+  public WritableRaster createCompatibleWritableRaster()
+  {
+    return new WritableRaster(getSampleModel(), new Point(minX, minY));
+  }
+
+  /**
+   * 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)
+  {
+    return createCompatibleWritableRaster(minX, minY, w, h);
+  }
+
+  /**
+   * 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)
+  {
+    return createCompatibleWritableRaster(rect.x, rect.y,
+                                          rect.width, rect.height);
+  }
+
+  /**
+   * 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,
+                                                       int w, int h)
+  {
+    SampleModel sm = getSampleModel().createCompatibleSampleModel(w, h);
+    return new WritableRaster(sm, sm.createDataBuffer(), new Point(x, y));
+  }
+
+  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);
+  }
+
+  public Raster createChild(int parentX, int parentY, int width,
+                            int height, int childMinX, int childMinY,
+                            int[] bandList)
+  {
+    /* FIXME: Throw RasterFormatException if child bounds extends
+       beyond the bounds of this raster. */
+
+    SampleModel sm = (bandList == null) ?
+      sampleModel :
+      sampleModel.createSubsetSampleModel(bandList);
+
+    /*
+        data origin
+       /
+      +-------------------------
+      |\. __ parent trans
+      | \`.  
+      |  \ `.    parent origin
+      |   \  `. /
+      |   /\   +-------- - -
+      |trans\ /<\-- deltaTrans
+      |child +-+-\---- - - 
+      |     /|`|  \__ parent [x, y]
+      |child | |`. \
+      |origin| :  `.\
+      |      |    / `\
+      |      :   /    +
+      | child [x, y] 
+
+      parent_xy - parent_trans = child_xy - child_trans
+
+      child_trans = parent_trans + child_xy - parent_xy
+    */
+
+    return new Raster(sm, dataBuffer,
+        new Rectangle(childMinX, childMinY, width, height),
+        new Point(sampleModelTranslateX + childMinX - parentX,
+                  sampleModelTranslateY + childMinY - parentY),
+        this);
+  }
+
+  /**
+   * Returns a new rectangle containing the bounds of this raster.
+   * 
+   * @return A new rectangle containing the bounds of this raster.
+   */
+  public Rectangle getBounds()
+  {
+    return new Rectangle(minX, minY, width, height);
+  }
+
+  /**
+   * 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()
+  {
+    return minX;
+  }
+
+  /**
+   * 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()
+  {
+    return minY;
+  }
+
+  /**
+   * Returns the width of the raster.
+   * 
+   * @return The width of the raster.
+   */
+  public final int getWidth()
+  {
+    return width;
+  }
+
+  /**
+   * Returns the height of the raster.
+   * 
+   * @return The height of the raster.
+   */
+  public final int getHeight()
+  {
+    return height;
+  }
+
+  /**
+   * 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 
+   * raster's sample model).
+   * 
+   * @return The transfer type.
+   */
+  public final int getTransferType()
+  {
+    return sampleModel.getTransferType();
+  }
+
+  /**
+   * Returns the data buffer that stores the pixel data for this raster.
+   * 
+   * @return The data buffer.
+   */
+  public DataBuffer getDataBuffer()
+  {
+    return dataBuffer;
+  }
+
+  /**
+   * Returns the sample model that accesses the data buffer (to extract pixel
+   * data) for this raster.
+   * 
+   * @return The sample model.
+   */
+  public SampleModel getSampleModel()
+  {
+    return sampleModel;
+  }
+
+  public Object getDataElements(int x, int y, Object outData)
+  {
+    return sampleModel.getDataElements(x - sampleModelTranslateX,
+        y - sampleModelTranslateY, outData, dataBuffer);
+  }
+
+  public Object getDataElements(int x, int y, int w, int h, Object outData)
+  {
+    return sampleModel.getDataElements(x - sampleModelTranslateX,
+        y - sampleModelTranslateY, w, h, outData, dataBuffer);
+  }
+
+  /**
+   * 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 
+   * 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 
+   *     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)
+  {
+    return sampleModel.getPixel(x - sampleModelTranslateX,
+        y - sampleModelTranslateY, iArray, dataBuffer);
+  }
+
+  /**
+   * 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 
+   * 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 
+   *     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)
+  {
+    return sampleModel.getPixel(x - sampleModelTranslateX,
+        y - sampleModelTranslateY, fArray, dataBuffer);
+  }
+
+  /**
+   * 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 
+   * 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 
+   *     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)
+  {
+    return sampleModel.getPixel(x - sampleModelTranslateX,
+        y - sampleModelTranslateY, dArray, dataBuffer);
+  }
+
+  /**
+   * 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 
+   *     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)
+  {
+    return sampleModel.getPixels(x - sampleModelTranslateX,
+        y - sampleModelTranslateY, w, h, iArray, dataBuffer);
+  }
+
+  /**
+   * 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 
+   *     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)
+  {
+    return sampleModel.getPixels(x - sampleModelTranslateX,
+        y - sampleModelTranslateY, w, h, fArray, dataBuffer);
+  }
+
+  /**
+   * 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 
+   *     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)
+  {
+    return sampleModel.getPixels(x - sampleModelTranslateX,
+        y - sampleModelTranslateY, w, h, dArray, dataBuffer);
+  }
+
+  /**
+   * 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 
+   *     <code>getNumBands() - 1</code>).
+   * 
+   * @return The sample value.
+   */
+  public int getSample(int x, int y, int b)
+  {
+    return sampleModel.getSample(x - sampleModelTranslateX,
+        y - sampleModelTranslateY, b, dataBuffer);
+  }
+
+  /**
+   * 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 
+   *     <code>getNumBands() - 1</code>).
+   * 
+   * @return The sample value.
+   * 
+   * @see #getSample(int, int, int)
+   */
+  public float getSampleFloat(int x, int y, int b)
+  {
+    return sampleModel.getSampleFloat(x - sampleModelTranslateX,
+        y - sampleModelTranslateY, b, dataBuffer);
+  }
+
+  /**
+   * 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 
+   *     <code>getNumBands() - 1</code>).
+   * 
+   * @return The sample value.
+   * 
+   * @see #getSample(int, int, int)
+   */
+  public double getSampleDouble(int x, int y, int b)
+  {
+    return sampleModel.getSampleDouble(x - sampleModelTranslateX,
+        y - sampleModelTranslateY, b, dataBuffer);
+  }
+
+  /**
+   * 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 
+   *     </code>getNumBands() - 1</code>).
+   * @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,
+                          int[] iArray)
+  {
+    return sampleModel.getSamples(x - sampleModelTranslateX,
+        y - sampleModelTranslateY, w, h, b, iArray, dataBuffer);
+  }
+
+  /**
+   * 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 
+   *     </code>getNumBands() - 1</code>).
+   * @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,
+        y - sampleModelTranslateY, w, h, b, fArray, dataBuffer);
+  }
+
+  /**
+   * 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 
+   *     </code>getNumBands() - 1</code>).
+   * @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, 
+                             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()
+  {
+    StringBuffer result = new StringBuffer();
+    
+    result.append(getClass().getName());
+    result.append("[(");
+    result.append(minX).append(",").append(minY).append("), ");
+    result.append(width).append(" x ").append(height).append(",");
+    result.append(sampleModel).append(",");
+    result.append(dataBuffer);
+    result.append("]");
+    
+    return result.toString();
+  }
+
+  /**
+   * Returns the number of bits used to represent the specified data type.  
+   * Valid types are:
+   * <ul>
+   *   <li>{@link DataBuffer#TYPE_BYTE};</li>
+   *   <li>{@link DataBuffer#TYPE_USHORT};</li>
+   *   <li>{@link DataBuffer#TYPE_SHORT};</li>
+   *   <li>{@link DataBuffer#TYPE_INT};</li>
+   *   <li>{@link DataBuffer#TYPE_FLOAT};</li>
+   *   <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)
+  {
+    switch (dataType)
+      {
+      case DataBuffer.TYPE_BYTE:
+        return 8;
+      case DataBuffer.TYPE_USHORT:
+      case DataBuffer.TYPE_SHORT:
+        return 16;
+      case DataBuffer.TYPE_INT:
+      case DataBuffer.TYPE_FLOAT:
+        return 32;
+      case DataBuffer.TYPE_DOUBLE:
+        return 64;
+      default:
+        return 0;
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RasterFormatException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RasterFormatException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RasterFormatException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RasterFormatException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,65 @@
+/* RasterFormatException.java -- indicates invalid layout in Raster
+   Copyright (C) 2002, 2005  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 exception is thrown when there is invalid layout information in
+ * <code>Raster</code>
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Raster
+ * @status updated to 1.4
+ */
+public class RasterFormatException extends RuntimeException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 96598996116164315L;
+
+  /**
+   * Create a new instance with a descriptive error message.
+   *
+   * @param message the descriptive error message
+   */
+  public RasterFormatException(String message)
+  {
+    super(message);
+  }
+} // class RasterFormatException

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RasterOp.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RasterOp.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RasterOp.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RasterOp.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,105 @@
+/* RasterOp.java --
+   Copyright (C) 2000, 2002, 2004, 2005, 2006,  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.RenderingHints;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+/**
+ * An operation that is performed on one raster (the source) producing a new
+ * raster (the destination).
+ */
+public interface RasterOp
+{
+  /**
+   * Performs an operation on the source raster, returning the result in a
+   * 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 
+   * 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);
+
+  /**
+   * 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);
+
+  /**
+   * 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);
+
+  /**
+   * 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();
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RenderedImage.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RenderedImage.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RenderedImage.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RenderedImage.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,70 @@
+/* RenderedImage.java -- 
+   Copyright (C) 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Rectangle;
+import java.util.Vector;
+
+/**
+ * NEEDS DOCUMENTATION
+ */
+public interface RenderedImage
+{
+  Vector getSources();
+  Object getProperty(String name);
+  String[] getPropertyNames();
+  ColorModel getColorModel();
+  SampleModel getSampleModel();
+  int getWidth();
+  int getHeight();
+  int getMinX();
+  int getMinY();
+  int getNumXTiles();
+  int getNumYTiles();
+  int getMinTileX();
+  int getMinTileY();
+  int getTileWidth();
+  int getTileHeight();
+  int getTileGridXOffset();
+  int getTileGridYOffset();
+  Raster getTile(int x, int y);
+  Raster getData();
+  Raster getData(Rectangle r);
+  WritableRaster copyData(WritableRaster raster);
+} // interface RenderedImage

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ReplicateScaleFilter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ReplicateScaleFilter.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ReplicateScaleFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ReplicateScaleFilter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,247 @@
+/* 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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>
+ *
+ * @author C. Brian Jones (cbj at 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)
+    {
+	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)
+        {
+	    destWidth = width;
+	    destHeight = height;
+	}
+	else if (destWidth < 0)
+	{
+	    destWidth = (int) (width * ((double) destHeight / srcHeight));
+	}
+	else if (destHeight < 0)
+	{
+	    destHeight = (int) (height * ((double) destWidth / srcWidth));
+	}
+
+	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 
+     */
+    public void setProperties(Hashtable props)
+    {
+	props.put("filters", "ReplicateScaleFilter");
+	if (consumer != null)
+	  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)
+    {
+	double rx = ((double) srcWidth) / destWidth;
+	double ry = ((double) srcHeight) / destHeight;
+
+	int destScansize = (int) Math.round(scansize / rx);
+
+	byte[] destPixels = replicatePixels(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 = replicatePixels(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);
+    }
+
+    private byte[] replicatePixels(int srcx, int srcy, int srcw, int srch,
+                                   ColorModel model, byte[] srcPixels,
+                                   int srcOffset, int srcScansize,
+                                   double rx, double ry, int destScansize)
+    {
+	byte[] destPixels =
+	  new byte[(int) Math.ceil(srcw/rx) * (int) Math.ceil(srch/ry)];
+
+	int a, b;
+	for (int i = 0; i < destPixels.length; i++)
+	{
+	    a = (int) ((int) ( ((double) i) / destScansize) * ry) * srcScansize;
+	    b = (int) ((i % destScansize) * rx);
+	    if ((a + b + srcOffset) < srcPixels.length)
+		destPixels[i] = srcPixels[a + b + srcOffset];
+	}
+
+	return destPixels;
+    }
+
+    private int[] replicatePixels(int srcx, int srcy, int srcw, int srch,
+                                  ColorModel model, int[] srcPixels,
+                                  int srcOffset, int srcScansize,
+                                  double rx, double ry, int destScansize)
+    {
+	int[] destPixels =
+	  new int[(int) Math.ceil(srcw/rx) * (int) Math.ceil(srch/ry)];
+
+	int a, b;
+	for (int i = 0; i < destPixels.length; i++)
+	{
+	    a = (int) ((int) ( ((double) i) / destScansize) * ry) * srcScansize;
+	    b = (int) ((i % destScansize) * rx);
+	    if ((a + b + srcOffset) < srcPixels.length)
+		destPixels[i] = srcPixels[a + b + srcOffset];
+	}
+
+	return destPixels;
+    }
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RescaleOp.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RescaleOp.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RescaleOp.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/RescaleOp.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,218 @@
+/* Copyright (C) 2004  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.RenderingHints;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.util.Arrays;
+
+/**
+ * @author Jerry Quinn (jlquinn at optonline.net)
+ */
+public class RescaleOp implements BufferedImageOp, RasterOp
+{
+  private float[] scale;
+  private float[] offsets;
+  private RenderingHints hints = null;
+  
+  public RescaleOp(float[] scaleFactors,
+		   float[] offsets,
+		   RenderingHints hints)
+  {
+    this.scale = scaleFactors;
+    this.offsets = offsets;
+    this.hints = hints;
+  }
+  
+  public RescaleOp(float scaleFactor,
+		   float offset,
+		   RenderingHints hints)
+  {
+    scale = new float[]{ scaleFactor };
+    offsets = new float[]{offset};
+    this.hints = hints;
+  }
+
+  public final float[] getScaleFactors(float[] scaleFactors)
+  {
+    if (scaleFactors == null)
+      scaleFactors = new float[scale.length];
+    System.arraycopy(scale, 0, scaleFactors, 0, scale.length);
+    return scaleFactors;
+  }
+
+  public final float[] getOffsets(float[] offsets)
+  {
+    if (offsets == null)
+      offsets = new float[this.offsets.length];
+    System.arraycopy(this.offsets, 0, offsets, 0, this.offsets.length);
+    return offsets;
+  }
+
+  public final int getNumFactors()
+  {
+    return scale.length;
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.BufferedImageOp#getRenderingHints()
+   */
+  public final RenderingHints getRenderingHints()
+  {
+    return hints;
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.BufferedImageOp#filter(java.awt.image.BufferedImage, java.awt.image.BufferedImage)
+   */
+  public final BufferedImage filter(BufferedImage src, BufferedImage dst)
+  {
+    // TODO Make sure premultiplied alpha is handled correctly.
+    // TODO See that color conversion is handled.
+    // TODO figure out how to use rendering hints.
+    if (scale.length != offsets.length)
+      throw new IllegalArgumentException();
+
+    ColorModel scm = src.getColorModel();
+    if (dst == null) dst = createCompatibleDestImage(src, null);
+
+    WritableRaster wsrc = src.getRaster();
+    WritableRaster wdst = dst.getRaster();
+    
+    // Share constant across colors except alpha
+    if (scale.length == 1 || scale.length == scm.getNumColorComponents())
+      {
+	// Construct a raster that doesn't include an alpha band.
+	int[] subbands = new int[scm.getNumColorComponents()];
+	for (int i=0; i < subbands.length; i++) subbands[i] = i;
+	wsrc = 
+	  wsrc.createWritableChild(wsrc.minX, wsrc.minY, wsrc.width, wsrc.height,
+				   wsrc.minX, wsrc.minY, subbands);
+      }
+    // else all color bands
+
+    filter(wsrc, wdst);
+    return dst;
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.RasterOp#filter(java.awt.image.Raster, java.awt.image.WritableRaster)
+   */
+  public final WritableRaster filter(Raster src, WritableRaster dest)
+  {
+    if (dest == null) dest = src.createCompatibleWritableRaster();
+
+    // Required sanity checks
+    if (src.numBands != dest.numBands || scale.length != offsets.length)
+      throw new IllegalArgumentException();
+    if (scale.length != 1 && scale.length != src.numBands)
+      throw new IllegalArgumentException();
+
+    // Create scaling arrays if needed
+    float[] lscale = scale;
+    float[] loff = offsets;
+    if (scale.length == 1)
+      {
+	lscale = new float[src.numBands];
+	Arrays.fill(lscale, scale[0]);
+	loff = new float[src.numBands];
+	Arrays.fill(loff, offsets[0]);
+      }
+
+    // TODO The efficiency here can be improved for various data storage
+    // patterns, aka SampleModels.
+    float[] pixel = new float[src.numBands];
+    for (int y = src.minY; y < src.height + src.minY; y++)
+      for (int x = src.minX; x < src.width + src.minX; x++)
+	{
+	  src.getPixel(x, y, pixel);
+	  for (int b = 0; b < src.numBands; b++)
+	    pixel[b] = pixel[b] * lscale[b] + loff[b];
+	  dest.setPixel(x, y, pixel);
+	}
+    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)
+  {
+    if (dstCM == null) dstCM = src.getColorModel();
+    WritableRaster wr = src.getRaster().createCompatibleWritableRaster();
+    BufferedImage image
+      = new BufferedImage(dstCM, wr, src.isPremultiplied, null);
+    return image;
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.RasterOp#createCompatibleDestRaster(java.awt.image.Raster)
+   */
+  public WritableRaster createCompatibleDestRaster(Raster src)
+  {
+    return src.createCompatibleWritableRaster();
+  }
+  
+  /* (non-Javadoc)
+   * @see java.awt.image.BufferedImageOp#getBounds2D(java.awt.image.BufferedImage)
+   */
+  public final Rectangle2D getBounds2D(BufferedImage src)
+  {
+    return src.getRaster().getBounds();
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.RasterOp#getBounds2D(java.awt.image.Raster)
+   */
+  public final Rectangle2D getBounds2D(Raster src)
+  {
+    return src.getBounds();
+  }
+
+  /* (non-Javadoc)
+   * @see java.awt.image.BufferedImageOp#getPoint2D(java.awt.geom.Point2D, java.awt.geom.Point2D)
+   */
+  public final Point2D getPoint2D(Point2D src, Point2D dst) {
+    if (dst == null) dst = (Point2D) src.clone();
+    else dst.setLocation(src);
+    return dst;
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/SampleModel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/SampleModel.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/SampleModel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/SampleModel.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,967 @@
+/* Copyright (C) 2000, 2001, 2002, 2005, 2006,  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <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 at 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.
+   */
+  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"));
+        
+    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;  
+  }
+  
+  /**
+   * Returns the width of the pixel data accessible via this 
+   * <code>SampleModel</code>.
+   * 
+   * @return The width.
+   * 
+   * @see #getHeight()
+   */
+  public final int getWidth()
+  {
+    return width;
+  }
+
+  /**
+   * Returns the height of the pixel data accessible via this 
+   * <code>SampleModel</code>.
+   * 
+   * @return The height.
+   * 
+   * @see #getWidth()
+   */
+  public final int getHeight()
+  {
+    return height;
+  }
+
+  /**
+   * 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 
+   * <code>SampleModel</code> accesses.
+   * 
+   * @return The data buffer type.
+   */
+  public final int getDataType()
+  {
+    return dataType;
+  }
+
+  public int getTransferType()
+  {
+    // FIXME: Is this a reasonable default implementation?
+    return dataType;
+  }
+
+  /**
+   * 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 
+   *     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) 
+      iArray = new int[numBands];
+    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(),
+   * that can be used when there is no need to decode the pixel into
+   * separate sample values.
+   *
+   * @param obj An array to return the pixel data in. If null, an
+   * array of the right type and size will be created.
+   *
+   * @return A single pixel as an array object of a primitive type,
+   * based on the transfer type. Eg. if transfer type is
+   * DataBuffer.TYPE_USHORT, then a short[] object is returned.
+   */
+  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())
+          {
+          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 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);
+
+  public void setDataElements(int x, int y, int w, int h,
+                              Object obj, DataBuffer data)
+  {
+    int size = w * h;
+    int numDataElements = getNumDataElements();
+    int dataSize = numDataElements * size;
+    
+    Object pixelData;
+    switch (getTransferType())
+      {
+      case DataBuffer.TYPE_BYTE:
+        pixelData = new byte[numDataElements];
+        break;
+      case DataBuffer.TYPE_USHORT:
+        pixelData = new short[numDataElements];
+        break;
+      case DataBuffer.TYPE_INT:
+        pixelData = new int[numDataElements];
+        break;
+      default:
+        // Seems like the only sensible thing to do.
+        throw new ClassCastException();
+      }
+    int inOffset = 0;
+
+    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;
+          }
+      }
+  }
+
+  /**
+   * Returns an array containing the samples for the pixel at (x, y) 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 pixel.
+   * @param y  the y-coordinate of the pixel.
+   * @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) 
+      fArray = new float[numBands];
+    
+    for (int b = 0; b < numBands; b++)
+      {
+        fArray[b] = getSampleFloat(x, y, b, data);
+      }
+    return fArray;
+  }
+
+  /**
+   * Returns an array containing the samples for the pixel at (x, y) 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 pixel.
+   * @param y  the y-coordinate of the pixel.
+   * @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) 
+      dArray = new double[numBands];
+    for (int b = 0; b < numBands; b++)
+      {
+        dArray[b] = getSampleDouble(x, y, b, data);
+      }
+    return dArray;
+  }
+
+  /**
+   * 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 
+   * 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 
+   *     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)
+  {
+    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++)
+      {
+        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;
+  }
+
+  /**
+   * 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 
+   * 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 
+   *     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,
+                           DataBuffer data)
+  {
+    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++)
+      {
+        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;
+  }
+    
+  /**
+   * 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 
+   * 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 
+   *     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,
+                            DataBuffer data)
+  {
+    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++)
+      {
+        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;
+  }
+
+  /**
+   * 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 
+   *     <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 
+   * 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 
+   *     <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)
+  {
+    return getSample(x, y, b, 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 
+   *     <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)
+  {
+    return getSampleFloat(x, y, b, data);
+  }
+
+  /**
+   * 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 
+   *     </code>getNumBands() - 1</code>).
+   * @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,
+                          int[] iArray, DataBuffer data)
+  {
+    int size = w * h;
+    int outOffset = 0;
+    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);
+          }
+      }
+    return iArray;
+  }
+
+  /**
+   * 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 
+   *     </code>getNumBands() - 1</code>).
+   * @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,
+                            float[] fArray, DataBuffer data)
+  {
+    int size = w * h;
+    int outOffset = 0;
+    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);
+          }
+      }
+    return fArray;
+  }
+
+  /**
+   * 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 
+   *     </code>getNumBands() - 1</code>).
+   * @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,
+                             double[] dArray, DataBuffer data)
+  {
+    int size = w * h;
+    int outOffset = 0;
+    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);
+          }
+      }
+    return dArray;
+  }
+  
+  /**
+   * Sets the samples for the pixel at (x, y) in the specified data buffer 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).
+   * @param data  the data buffer (<code>null</code> not permitted).
+   * 
+   * @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++) 
+      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. 
+   * 
+   * @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 
+   *     <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++) 
+      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. 
+   * 
+   * @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 
+   *     <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++) 
+      setSample(x, y, b, dArray[b], data);
+  }
+
+  /**
+   * 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 
+   * 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).
+   * @param data  the data buffer (<code>null</code> not permitted).
+   * 
+   * @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)
+  {
+    int inOffset = 0;
+    int[] pixel = new int[numBands];
+    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;
+          }
+      }
+  }
+
+  /**
+   * 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 
+   * 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).
+   * @param data  the data buffer (<code>null</code> not permitted).
+   * 
+   * @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,
+                        DataBuffer data)
+  {
+    int inOffset = 0;
+    float[] pixel = new float[numBands];
+    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;
+          }
+      }
+  }
+
+  /**
+   * 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 
+   * 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).
+   * @param data  the data buffer (<code>null</code> not permitted).
+   * 
+   * @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,
+                        DataBuffer data)
+  {
+    int inOffset = 0;
+    double[] pixel = new double[numBands];
+    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;
+          }
+      }
+  }
+
+  /**
+   * 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 
+   *     <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. 
+   * 
+   * @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 
+   *     <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)
+  {
+    setSample(x, y, b, (int) s, data);
+  }
+
+  /**
+   * 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 
+   *     <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)
+  {
+    setSample(x, y, b, (float) s, data);
+  }
+
+  /**
+   * 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 
+   *     </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 
+   *     <code>data</code> is <code>null</code>.
+   */
+  public void setSamples(int x, int y, int w, int h, int b,
+                         int[] iArray, 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, iArray[inOffset++], data);
+  }
+
+  /**
+   * 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 
+   *     </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 
+   *     <code>data</code> is <code>null</code>.
+   */
+  public void setSamples(int x, int y, int w, int h, int b,
+                         float[] fArray, 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, fArray[inOffset++], data);
+
+  }
+
+  /**
+   * 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 
+   *     </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 
+   *     <code>data</code> is <code>null</code>.
+   */
+  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);
+  }
+
+  /**
+   * 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 
+   * <code>SampleModel</code>.
+   * 
+   * @return The data buffer.
+   */
+  public abstract DataBuffer createDataBuffer();
+
+  /**
+   * 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 
+   *     <code>getNumBands() - 1</code>).
+   *     
+   * @return The sample size (in bits).
+   */
+  public abstract int getSampleSize(int band);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ShortLookupTable.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ShortLookupTable.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ShortLookupTable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/ShortLookupTable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,177 @@
+/* ShortLookupTable.java -- Java class for a pixel translation table.
+   Copyright (C) 2004, 2005, 2006,  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * ShortLookupTable represents translation arrays for pixel values.  It wraps
+ * one or more data arrays for each layer (or component) in an image, such as
+ * Alpha, R, G, and B.  When doing translation, the offset is subtracted from
+ * the pixel values to allow a subset of an array to be used.
+ *
+ * @author Jerry Quinn (jlquinn at optonline.net)
+ * @version 1.0
+ */
+public class ShortLookupTable extends LookupTable
+{
+  // Array of translation tables.
+  private short data[][];
+
+  /**
+   * Creates a new <code>ShortLookupTable</code> instance.
+   *
+   * 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.
+   */
+  public ShortLookupTable(int offset, short[][] data)
+    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 
+    // match that behaviour just in case it matters...
+    this.data = new short[data.length][];
+    for (int i = 0; i < data.length; i++)
+      this.data[i] = data[i];
+  }
+
+  /**
+   * Creates a new <code>ShortLookupTable</code> instance.
+   *
+   * 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 
+   *     permitted).
+   * @exception IllegalArgumentException if offset < 0.
+   */
+  public ShortLookupTable(int offset, short[] data)
+    throws IllegalArgumentException
+  {
+    super(offset, 1);
+    if (data == null)
+      throw new NullPointerException("Null 'data' argument.");
+    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. 
+   * 
+   * @return The lookup table.
+   */
+  public final short[][] getTable()
+  {
+    return data;
+  }
+
+  /**
+   * Return translated values for a pixel.
+   *
+   * For each value in the pixel src, use the value minus offset as an index
+   * in the component array and copy the value there to the output for the
+   * component.  If dest is null, the output is a new array, otherwise the
+   * translated values are written to dest.  Dest can be the same array as
+   * src.
+   *
+   * For example, if the pixel src is [2, 4, 3], and offset is 1, the output
+   * is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the
+   * translation arrays.
+   *
+   * @param src Component values of a pixel.
+   * @param dst Destination array for values, or null.
+   * @return Translated values for the pixel.
+   */
+  public int[] lookupPixel(int[] src, int[] dst)
+    throws ArrayIndexOutOfBoundsException
+  {
+    if (dst == null)
+      dst = new int[src.length];
+
+    if (data.length == 1)
+      for (int i = 0; i < src.length; i++)
+        dst[i] = data[0][src[i] - offset];
+    else
+      for (int i = 0; i < src.length; i++)
+        dst[i] = data[i][src[i] - offset];
+      
+    return dst;
+  }
+
+  /**
+   * Return translated values for a pixel.
+   *
+   * For each value in the pixel src, use the value minus offset as an index
+   * in the component array and copy the value there to the output for the
+   * component.  If dest is null, the output is a new array, otherwise the
+   * translated values are written to dest.  Dest can be the same array as
+   * src.
+   *
+   * For example, if the pixel src is [2, 4, 3], and offset is 1, the output
+   * is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the
+   * translation arrays.
+   *
+   * @param src Component values of a pixel.
+   * @param dst Destination array for values, or null.
+   * @return Translated values for the pixel.
+   *
+   */
+  public short[] lookupPixel(short[] src, short[] dst)
+    throws ArrayIndexOutOfBoundsException
+  {
+    if (dst == null)
+      dst = new short[src.length];
+
+    if (data.length == 1)
+      for (int i = 0; i < src.length; i++)
+        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];
+      
+    return dst;
+
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/SinglePixelPackedSampleModel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/SinglePixelPackedSampleModel.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/SinglePixelPackedSampleModel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/SinglePixelPackedSampleModel.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,690 @@
+/* Copyright (C) 2000, 2002, 2003, 2004, 2006,  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Arrays;
+
+import gnu.java.awt.BitMaskExtent;
+import gnu.java.awt.Buffers;
+
+/**
+ * A <code>SampleModel</code> used when all samples are stored in a single
+ * data element in the {@link DataBuffer}, and each data element contains 
+ * samples for one pixel only.
+ * 
+ * @author Rolf W. Rasmussen (rolfwr at ii.uib.no)
+ */
+public class SinglePixelPackedSampleModel extends SampleModel
+{
+  private int scanlineStride;
+  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).
+   * @param bitMasks  an array containing the bit mask used to extract the
+   *     sample value for each band.
+   */
+  public SinglePixelPackedSampleModel(int dataType, int w, int h,
+				      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).
+   * @param scanlineStride  the number of data elements between a pixel on one
+   *     row and the corresponding pixel on the next row.
+   * @param bitMasks  an array containing the bit mask used to extract the
+   *     sample value for each band.
+   */
+  public SinglePixelPackedSampleModel(int dataType, int w, int h,
+				      int scanlineStride, int[] bitMasks)
+  {
+    super(dataType, w, h, bitMasks.length);
+
+    switch (dataType)
+      {
+      case DataBuffer.TYPE_BYTE:
+      case DataBuffer.TYPE_USHORT:
+      case DataBuffer.TYPE_INT:
+	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++)
+      {
+        // the mask is an unsigned integer
+        long mask = bitMasks[b] & 0xFFFFFFFFL;
+        extent.setMask(mask);
+        sampleSize[b] = extent.bitWidth;
+        bitOffsets[b] = extent.leastSignificantBit;
+      }
+  }
+
+  /**
+   * Returns the number of data elements.
+   * 
+   * @return <code>1</code>.
+   */
+  public int getNumDataElements()
+  {
+    return 1;
+  }
+
+  /**
+   * 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)
+  {
+    /* FIXME: We can avoid recalculation of bit offsets and sample
+       sizes here by passing these from the current instance to a
+       special private constructor. */
+    return new SinglePixelPackedSampleModel(dataType, w, h, bitMasks);
+  }
+
+
+  /**
+   * 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()
+  {
+    int size;
+
+    // We can save (scanlineStride - width) pixels at the very end of
+    // the buffer. The Sun reference implementation (J2SE 1.3.1 and
+    // 1.4.1_01) seems to do this; tested with Mauve test code.
+    size = scanlineStride * (height - 1) + width;
+
+    return Buffers.createBuffer(getDataType(), size);
+  }
+
+  /**
+   * 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 
+   *     <code>getNumBands() - 1</code>).
+   *     
+   * @return The sample size (in bits).
+   */
+  public int getSampleSize(int band)
+  {
+    return sampleSize[band];
+  }
+
+  /**
+   * 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)
+  {
+    return scanlineStride*y + x;
+  }
+
+  public int[] getBitOffsets()
+  {
+    return bitOffsets;
+  }
+
+  public int[] getBitMasks()
+  {
+    return bitMasks;
+  }
+
+  /**
+   * 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()
+  {
+    return scanlineStride;
+  }
+
+  /**
+   * 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.
+   */
+  public SampleModel createSubsetSampleModel(int[] bands)
+  {
+    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);
+  }
+
+  public Object getDataElements(int x, int y, Object obj,
+				DataBuffer data)
+  {
+    int offset = scanlineStride*y + x + data.getOffset();
+    
+    return Buffers.getData(data, offset, obj,
+			   0, // destination offset,
+			   1  // length
+			   );
+  }
+  
+  /**
+   * This is a more efficient implementation of the default implementation in 
+   * the super class. 
+   * @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 
+   *     <code>obj</code>.
+   * @param w The width of the pixel rectangle to store in <code>obj</code>.
+   * @param h The height of the pixel rectangle to store in <code>obj</code>.
+   * @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, int, int, 
+   *     java.lang.Object, java.awt.image.DataBuffer)
+   */
+  public Object getDataElements(int x, int y, int w, int h, Object obj,
+							DataBuffer data)
+  {
+    int size = w*h;
+    int dataSize = size;
+    Object pixelData = null;
+    switch (getTransferType())
+    {
+      case DataBuffer.TYPE_BYTE:
+        pixelData = ((DataBufferByte) data).getData();
+        if (obj == null) obj = new byte[dataSize];
+        break;
+       case DataBuffer.TYPE_USHORT:
+         pixelData = ((DataBufferUShort) data).getData();
+         if (obj == null) obj = new short[dataSize];
+         break;
+        case DataBuffer.TYPE_INT:
+          pixelData = ((DataBufferInt) data).getData();
+          if (obj == null) obj = new int[dataSize];
+          break;
+         default:
+             // Seems like the only sensible thing to do.
+           throw new ClassCastException();
+      }
+      if(x == 0 && scanlineStride == w)
+      { 
+        // The full width need to be copied therefore we can copy in one shot.
+        System.arraycopy(pixelData, scanlineStride*y + data.getOffset(), obj, 
+                         0, size);
+      }
+      else
+      {  
+        // Since we do not need the full width we need to copy line by line.
+        int outOffset = 0;
+        int dataOffset = scanlineStride*y + x + data.getOffset();
+        for (int yy = y; yy<(y+h); yy++)
+        {
+          System.arraycopy(pixelData, dataOffset, obj, outOffset, w);
+          dataOffset += scanlineStride;
+          outOffset += w;
+        }
+      }
+    return obj;
+  }
+  
+  /**
+   * 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 
+   *     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)
+  {
+    int offset = scanlineStride*y + x;
+    if (iArray == null) iArray = new int[numBands];
+    int samples = data.getElem(offset);
+
+    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 
+   * 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 
+   * 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 
+   *     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)
+  {
+    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;
+      }
+    return iArray;	
+  }
+
+  /**
+   * 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 
+   *     <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)
+  {
+    int offset = scanlineStride*y + x;
+    int samples = data.getElem(offset);
+    return (samples & bitMasks[b]) >>> bitOffsets[b];
+  }
+  
+  /**
+   * This method implements a more efficient way to set data elements than the 
+   * default implementation of the super class. It sets the data elements line 
+   * by line instead of pixel by pixel.
+   * 
+   * @param x The x-coordinate of the data elements in <code>obj</code>.
+   * @param y The y-coordinate of the data elements in <code>obj</code>.
+   * @param w The width of the data elements in <code>obj</code>.
+   * @param h The height of the data elements in <code>obj</code>.
+   * @param obj The primitive array containing the data elements to set.
+   * @param data The DataBuffer to store the data elements into.
+   * @see java.awt.image.SampleModel#setDataElements(int, int, int, int, 
+   *     java.lang.Object, java.awt.image.DataBuffer)
+   */
+  public void setDataElements(int x, int y, int w, int h,
+				Object obj, DataBuffer data)
+  {
+    
+    Object pixelData;
+    switch (getTransferType())
+    {
+      case DataBuffer.TYPE_BYTE:
+        pixelData = ((DataBufferByte) data).getData();
+        break;
+       case DataBuffer.TYPE_USHORT:
+         pixelData = ((DataBufferUShort) data).getData();
+         break;
+       case DataBuffer.TYPE_INT:
+         pixelData = ((DataBufferInt) data).getData();
+         break;
+       default:
+          // Seems like the only sensible thing to do.
+          throw new ClassCastException();
+    }
+    
+    int inOffset = 0;
+    int dataOffset = scanlineStride*y + x + data.getOffset();
+    for (int yy=y; yy<(y+h); yy++)
+    {
+      System.arraycopy(obj,inOffset,pixelData,dataOffset,w);
+      dataOffset += scanlineStride;
+      inOffset += w;
+    }
+  }
+  
+  
+  public void setDataElements(int x, int y, Object obj, DataBuffer data)
+  {
+    int offset = scanlineStride*y + x + data.getOffset();
+    
+    int transferType = getTransferType();
+    if (getTransferType() != data.getDataType())
+      {
+	throw new IllegalArgumentException("transfer type ("+
+					   getTransferType()+"), "+
+					   "does not match data "+
+					   "buffer type (" +
+					   data.getDataType() +
+					   ").");
+      }
+
+    try
+      {
+	switch (transferType)
+	  {
+	  case DataBuffer.TYPE_BYTE:
+	    {
+	      DataBufferByte out = (DataBufferByte) data;
+	      byte[] in = (byte[]) obj;
+	      out.getData()[offset] = in[0];
+	      return;
+	    }
+	  case DataBuffer.TYPE_USHORT:
+	    {
+	      DataBufferUShort out = (DataBufferUShort) data;
+	      short[] in = (short[]) obj;
+	      out.getData()[offset] = in[0];
+	      return;
+	    }
+	  case DataBuffer.TYPE_INT:
+	    {
+	      DataBufferInt out = (DataBufferInt) data;
+	      int[] in = (int[]) obj;
+	      out.getData()[offset] = in[0];
+	      return;
+	    }
+	    // FIXME: Fill in the other possible types.
+	  default:
+	    throw new InternalError();
+	  }
+      }
+    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()+
+	  ": " +
+	  aioobe;
+	throw new ArrayIndexOutOfBoundsException(msg);
+      }
+    }
+
+  /**
+   * Sets the samples for the pixel at (x, y) in the specified data buffer 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).
+   * @param data  the data buffer (<code>null</code> not permitted).
+   * 
+   * @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];
+
+    data.setElem(offset, samples);
+  }
+
+  /**
+   * This method implements a more efficient way to set pixels than the default
+   * implementation of the super class. It copies the pixel components directly
+   * from the input array instead of creating a intermediate buffer.
+   * @param x The x-coordinate of the pixel rectangle in <code>obj</code>.
+   * @param y The y-coordinate of the pixel rectangle in <code>obj</code>.
+   * @param w The width of the pixel rectangle in <code>obj</code>.
+   * @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[], 
+   *     java.awt.image.DataBuffer)
+   */
+  public void setPixels(int x, int y, int w, int h, int[] iArray,
+						DataBuffer data)
+  {
+    int inOffset = 0;
+    int[] pixel = new int[numBands];
+    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];
+        data.setElem(0, offset, samples);
+        inOffset += numBands;
+        offset += 1;
+      }
+    }
+  }
+  
+  /**
+   * 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 
+   *     <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)
+  {
+    int offset = scanlineStride*y + x;
+    int samples = data.getElem(offset);
+    int bitMask = bitMasks[b];
+    samples &= ~bitMask;
+    samples |= (s << bitOffsets[b]) & bitMask;
+    data.setElem(offset, samples);
+  }
+  
+  /**
+   * 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 
+   *       <code>SinglePixelPackedSampleModel</code>;
+   *   <li>both models have the same:
+   *     <ul>
+   *       <li><code>dataType</code>;
+   *       <li><code>width</code>;
+   *       <li><code>height</code>;
+   *       <li><code>numBands</code>;
+   *       <li><code>scanlineStride</code>;
+   *       <li><code>bitMasks</code>;
+   *       <li><code>bitOffsets</code>.
+   *     </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) 
+  {
+    if (this == obj) 
+      return true;
+    if (! (obj instanceof SinglePixelPackedSampleModel)) 
+      return false;
+    SinglePixelPackedSampleModel that = (SinglePixelPackedSampleModel) obj;
+    if (this.dataType != that.dataType)
+      return false;
+    if (this.width != that.width)
+      return false;
+    if (this.height != that.height)
+      return false;
+    if (this.numBands != that.numBands)
+      return false;
+    if (this.scanlineStride != that.scanlineStride)
+      return false;
+    if (!Arrays.equals(this.bitMasks, that.bitMasks))
+      return false;
+    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()
+  {
+    // this hash code won't match Sun's, but that shouldn't matter...
+    int result = 193;
+    result = 37 * result + dataType;
+    result = 37 * result + width;
+    result = 37 * result + height;
+    result = 37 * result + numBands;
+    result = 37 * result + scanlineStride;
+    for (int i = 0; i < bitMasks.length; i++)
+      result = 37 * result + bitMasks[i];
+    for (int i = 0; i < bitOffsets.length; i++)
+      result = 37 * result + bitOffsets[i];
+    return result;
+  }
+  
+  /**
+   * Creates a String with some information about this SampleModel.
+   * @return A String describing this SampleModel.
+   * @see java.lang.Object#toString()
+   */
+  public String toString()
+  {
+    StringBuffer result = new StringBuffer();
+    result.append(getClass().getName());
+    result.append("[");
+    result.append("scanlineStride=").append(scanlineStride);
+    for(int i = 0; i < bitMasks.length; i+=1)
+    {
+      result.append(", mask[").append(i).append("]=0x").append(
+          Integer.toHexString(bitMasks[i]));
+    }
+    
+    result.append("]");
+    return result.toString();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/TileObserver.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/TileObserver.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/TileObserver.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/TileObserver.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,47 @@
+/* TileObserver.java -- 
+   Copyright (C) 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * NEEDS DOCUMENTATION
+ */
+public interface TileObserver
+{
+  void tileUpdate(WritableRenderedImage src, int x, int y, boolean writable);
+} // interface TileObserver

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/VolatileImage.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/VolatileImage.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/VolatileImage.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/VolatileImage.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,253 @@
+/* VolatileImage.java -- a hardware-accelerated image buffer
+   Copyright (C) 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.Image;
+import java.awt.Transparency;
+import java.awt.ImageCapabilities;
+
+/**
+ * VolatileImage represents a hardware-accelerated graphics buffer.
+ * The native graphics system may free or damage the resources
+ * occupied by a VolatileImage at any time.  As such, one must
+ * frequently check the "validity" of the image buffer's resources.
+ *
+ * A volatile image's "validity" depends on multiple factors.  Its
+ * resources may have become unavailble in which case you must
+ * reallocate them.  If you move the image from one output device to
+ * another, you may need to recreate the image's resources if the new
+ * output device's capabilities don't match the old one's.  Finally,
+ * if the contents of the image's buffer have been damaged you must
+ * re-render the image.
+ *
+ * VolatileImages should always be created using either
+ * Component.createVolatileImage or
+ * GraphicsConfiguration.createCompatibleVolatileImage.
+ */
+public abstract class VolatileImage extends Image
+  implements Transparency
+{
+  /**
+   * One of validate's possible return values.  Indicates that the
+   * image buffer matches its graphics configuration's capabilities
+   * and that its resources are initialized and ready to be drawn
+   * into.  Also implies that any existing image rendered to the
+   * buffer is intact and need not be re-rendered.
+   */
+  public static final int IMAGE_OK = 0;
+
+  /**
+   * One of validate's possible return values.  Indicates that the
+   * image buffer has been restored, meaning that it is valid and
+   * ready-to-use but that its previous contents have been lost.  This
+   * return value implies that the image needs to be re-rendered.
+   */
+  public static final int IMAGE_RESTORED = 1;
+
+  /**
+   * One of validate's possible return values.  Indicates that the
+   * image buffer type is unsupported by the current graphics
+   * configuration.  The graphics configuration may have changed, for
+   * example if the image moved from one output device to another.
+   * This return value implies that the image buffer's resources
+   * should be re-acquired.
+   */
+  public static final int IMAGE_INCOMPATIBLE = 2;
+
+  /**
+   * This image's transparency type.  One of Transparency.BITMASK,
+   * Transparency.OPAQUE or Transparency.TRANSLUCENT.
+   *
+   * @since 1.5
+   */
+  protected int transparency;
+
+  /**
+   * Default constructor.  VolatileImages should not be created
+   * directly.  Rather, you should use Component.createVolatileImage
+   * or GraphicsConfiguration.createCompatibleVolatileImage.
+   */
+  public VolatileImage()
+  {
+  }
+
+  /**
+   * Returns an image representing the current state of the volatile
+   * image buffer.  The returned image is static meaning that it is
+   * not updated after being created.  It is a snapshot of the
+   * volatile image buffer at the time getSnapshot is called.
+   *
+   * This method, which reads pixels from the volatile image buffer,
+   * may be less-performant than methods that write pixels since
+   * VolatileImages are typically optimized for writing.
+   *
+   * @return a BufferedImage representing this VolatileImage
+   */
+  public abstract BufferedImage getSnapshot();
+
+  /**
+   * Returns the width of this image buffer.
+   *
+   * @return the width of this VolatileImage
+   */
+  public abstract int getWidth();
+
+  /**
+   * Returns the height of this image buffer.
+   *
+   * @return the height of this VolatileImage
+   */
+  public abstract int getHeight();
+
+  /**
+   * Calling this method is equivalent to calling
+   * getSnapshot().getSource().  The ImageProducer produces pixels
+   * from the BufferedImage snapshot and not from the VolatileImage
+   * itself.  Thus, changes to the VolatileImage that occur after this
+   * ImageProducer has been retrieved will not be reflected in the
+   * produced pixels.
+   *
+   * This method, which reads pixels from the volatile image buffer,
+   * may be less-performant than methods that write pixels since
+   * VolatileImages are typically optimized for writing.
+   *
+   * @return an ImageProducer for a static BufferedImage snapshot of
+   * this image buffer
+   */
+  public ImageProducer getSource()
+  {
+    return getSnapshot().getSource();
+  }
+
+  /**
+   * Releases the system resources taken by this image.
+   */
+  public void flush()
+  {
+  }
+
+  /**
+   * Returns a Graphics2D object that can be used to draw onto this
+   * image.  This method is present for backwards-compatibility.  It
+   * simply returns the result of createGraphics.
+   *
+   * @return a Graphics2D object that can be used to draw onto this
+   * image
+   */
+  public Graphics getGraphics()
+  {
+    return createGraphics();
+  }
+
+  /**
+   * Returns a Graphics2D object that can be used to draw onto this
+   * image.
+   *
+   * @return a Graphics2D object that can be used to draw onto this
+   * image
+   */
+  public abstract Graphics2D createGraphics();
+
+  /**
+   * Validates and restores this image.  If the image buffer has
+   * become unavailable for further use since the last call to
+   * validate, validate will allocate a new image buffer.  The image
+   * is also "validated" against the GraphicsConfiguration parameter.
+   *
+   * "Validating" the image means checking that the capabilities it
+   * requires of the output device are indeed supported by the given
+   * output device.  If the image's characteristics, which can be
+   * highly output device-specific, are not supported by the graphics
+   * configuration, then IMAGE_INCOMPATIBLE will be returned.  This
+   * can happen, for example, if this image was created on one output
+   * device, then validated against a different output device with
+   * different capabilities.  Calling validate with a NULL gc argument
+   * causes validate to skip the validation test.
+   *
+   * @param gc graphics configuration against which to validate or
+   * NULL
+   *
+   * @return a code indicating the result of validation. One of:
+   * <ul>
+   *   <li><code>IMAGE_OK</code> if the image did not need to be
+   *   validated and didn't need to be restored</li>
+   *   <li><code>IMAGE_RESTORED</code> if the image may need to be
+   *   re-rendered.</li>
+   *   <li><code>IMAGE_INCOMPATIBLE</code> if this image's
+   *   requirements are not fulfilled by the graphics configuration
+   *   parameter.  This implies that you need to create a new
+   *   VolatileImage for the different GraphicsConfiguration or
+   *   Component. This return value implies nothing about whether the
+   *   image is valid or needs to be re-rendered.</li>
+   * </ul>
+   */
+  public abstract int validate(GraphicsConfiguration gc);
+
+  /**
+   * Returns true if the contents of the image buffer have been
+   * damaged or if the image buffer's resources have been reclaimed by
+   * the graphics system.  You should call this method after a series
+   * of rendering operations to or from the image, to see if the image
+   * buffer needs to be revalidated or the image re-rendered.
+   *
+   * @return true if the validate should be called, false otherwise
+   */
+  public abstract boolean contentsLost();
+
+  /**
+   * Returns the capabilities of this image buffer.
+   *
+   * @return the capabilities of this image buffer
+   */
+  public abstract ImageCapabilities getCapabilities();
+
+  /**
+   * Returns the transparency type of this image.
+   *
+   * @return Transparency.OPAQUE, Transparency.BITMASK or
+   * Transparency.TRANSLUCENT
+   */
+  public int getTransparency()
+  {
+    return transparency;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/WritableRaster.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/WritableRaster.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/WritableRaster.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/WritableRaster.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,431 @@
+/* Copyright (C) 2000, 2002, 2003, 2006,  Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Point;
+import java.awt.Rectangle;
+
+/**
+ * A raster with methods to support updating pixel values.
+ * 
+ * @author Rolf W. Rasmussen (rolfwr at 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) 
+  {
+    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, 
+                           Point origin)
+  {
+    this(sampleModel, dataBuffer,
+         new Rectangle(origin != null ? origin.x : 0,
+                       origin != null ? origin.y : 0,
+                       sampleModel.getWidth(), sampleModel.getHeight()),
+         origin, null);
+  }
+
+  /**
+   * 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, 
+                           DataBuffer dataBuffer,
+                           Rectangle aRegion,
+                           Point sampleModelTranslate,
+                           WritableRaster parent)
+  {
+    super(sampleModel, dataBuffer, aRegion, sampleModelTranslate, parent);
+  }
+
+  /**
+   * 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
+   * @return
+   */
+  public WritableRaster createWritableTranslatedChild(int childMinX,
+                                                      int childMinY)
+  {
+    // This mirrors the code from the super class
+    int tcx = sampleModelTranslateX - minX + childMinX;
+    int tcy = sampleModelTranslateY - minY + childMinY;
+    
+    return new WritableRaster(sampleModel, dataBuffer,
+        new Rectangle(childMinX, childMinY, width, height), 
+        new Point(tcx, tcy), this);
+  }
+
+  /**
+   * 
+   * @param parentX
+   * @param parentY
+   * @param w
+   * @param h
+   * @param childMinX
+   * @param childMinY
+   * @param bandList
+   * @return
+   */
+  public WritableRaster createWritableChild(int parentX, int parentY,
+      int w, int h, int childMinX, int childMinY, int[] bandList)
+  {
+    // This mirrors the code from the super class
+    
+    // FIXME: Throw RasterFormatException if child bounds extends
+    // beyond the bounds of this raster.
+    
+    SampleModel sm = (bandList == null) ?
+      sampleModel :
+      sampleModel.createSubsetSampleModel(bandList);
+    
+    return new WritableRaster(sm, dataBuffer,
+        new Rectangle(childMinX, childMinY, w, h),
+        new Point(sampleModelTranslateX + childMinX - parentX,
+                  sampleModelTranslateY + childMinY - parentY),
+        this);
+  }
+
+  public void setDataElements(int x, int y, Object inData)
+  {
+    sampleModel.setDataElements(x - sampleModelTranslateX, 
+        y - sampleModelTranslateY, inData, dataBuffer);
+  }
+
+  public void setDataElements(int x, int y, Raster inRaster)
+  {
+    Object dataElements = getDataElements(0, 0, inRaster.getWidth(),
+        inRaster.getHeight(), null);
+    setDataElements(x, y, dataElements);
+  }
+
+  public void setDataElements(int x, int y, int w, int h, Object inData)
+  {
+    sampleModel.setDataElements(x - sampleModelTranslateX,
+        y - sampleModelTranslateY, w, h, inData, dataBuffer);
+  }
+
+  /**
+   * 
+   * @param srcRaster
+   */
+  public void setRect(Raster srcRaster)
+  {
+    setRect(0, 0, srcRaster);
+  }
+
+  /**
+   * 
+   * @param dx
+   * @param dy
+   * @param 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.*/
+
+    int[] pixels = srcRaster.getPixels(sx, sy, target.width, target.height,
+                                       (int[]) null);
+
+    setPixels(target.x, target.y, target.width, target.height, pixels);
+  }
+
+  /**
+   * 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)
+  {
+    sampleModel.setPixel(x - sampleModelTranslateX, y - sampleModelTranslateY,
+                         iArray, dataBuffer);
+  }
+
+  /**
+   * 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)
+  {
+    sampleModel.setPixel(x - sampleModelTranslateX, y - sampleModelTranslateY,
+                         fArray, dataBuffer);
+  }
+
+  /**
+   * 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)
+  {
+    sampleModel.setPixel(x - sampleModelTranslateX, y - sampleModelTranslateY,
+                         dArray, dataBuffer);
+  }
+
+  /**
+   * 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)
+  {
+    sampleModel.setPixels(x - sampleModelTranslateX, y - sampleModelTranslateY,
+                          w, h, iArray, dataBuffer);
+  }
+
+  /**
+   * 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)
+  {
+    sampleModel.setPixels(x - sampleModelTranslateX, y - sampleModelTranslateY,
+                          w, h, fArray, dataBuffer);
+  }
+
+  /**
+   * 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)
+  {
+    sampleModel.setPixels(x - sampleModelTranslateX, y - sampleModelTranslateY,
+                          w, h, dArray, dataBuffer);
+  }
+
+  /**
+   * 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 
+   *     <code>getNumBands() - 1</code>).
+   * @param s  the sample value.
+   */
+  public void setSample(int x, int y, int b, int s)
+  {
+    sampleModel.setSample(x - sampleModelTranslateX, y - sampleModelTranslateY,
+                          b, s, dataBuffer);
+  }
+
+  /**
+   * 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 
+   *     <code>getNumBands() - 1</code>).
+   * @param s  the sample value.
+   */
+  public void setSample(int x, int y, int b, float s)
+  {
+    sampleModel.setSample(x - sampleModelTranslateX, y - sampleModelTranslateY,
+                          b, s, dataBuffer);
+  }
+
+  /**
+   * 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 
+   *     <code>getNumBands() - 1</code>).
+   * @param s  the sample value.
+   */
+  public void setSample(int x, int y, int b, double s)
+  {
+    sampleModel.setSample(x - sampleModelTranslateX, y - sampleModelTranslateY,
+                          b, s, dataBuffer);
+  }
+
+  /**
+   * 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 
+   *     </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,
+                         int[] iArray)
+  {
+    sampleModel.setSamples(x - sampleModelTranslateX, y - sampleModelTranslateY,
+                           w, h, b, iArray, dataBuffer);
+  }
+
+  /**
+   * 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 
+   *     </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,
+                         float[] fArray)
+  {
+    sampleModel.setSamples(x - sampleModelTranslateX, y - sampleModelTranslateY,
+                           w, h, b, fArray, dataBuffer);
+  }
+
+  /**
+   * 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 
+   *     </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,
+                         double[] dArray)
+  {
+    sampleModel.setSamples(x - sampleModelTranslateX, y - sampleModelTranslateY,
+                           w, h, b, dArray, dataBuffer);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/WritableRenderedImage.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/WritableRenderedImage.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/WritableRenderedImage.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/WritableRenderedImage.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,56 @@
+/* WritableRenderedImage.java -- 
+   Copyright (C) 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Point;
+
+/**
+ * NEEDS DOCUMENTATION
+ */
+public interface WritableRenderedImage extends RenderedImage
+{
+  void addTileObserver(TileObserver to);
+  void removeTileObserver(TileObserver to);
+  WritableRaster getWritableTile(int x, int y);
+  void releaseWritableTile(int x, int y);
+  boolean isTileWritable(int x, int y);
+  Point[] getWritableTileIndices();
+  boolean hasTileWriters();
+  void setData(Raster r);
+} // interface WritableRenderedImage

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.awt.image package.
+   Copyright (C) 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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. -->
+
+<html>
+<head><title>GNU Classpath - java.awt.image</title></head>
+
+<body>
+<p>Image consumers, producers and filters.</p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/ContextualRenderedImageFactory.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/ContextualRenderedImageFactory.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/ContextualRenderedImageFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/ContextualRenderedImageFactory.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,56 @@
+/* ContextualRenderedImageFactory.java -- 
+   Copyright (C) 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.renderable;
+
+import java.awt.geom.Rectangle2D;
+import java.awt.image.RenderedImage;
+
+/**
+ * STUBBED
+ */
+public interface ContextualRenderedImageFactory extends RenderedImageFactory
+{
+  RenderContext mapRenderContext(int i, RenderContext context,
+                                 ParameterBlock block, RenderableImage image);
+  RenderedImage create(RenderContext context, ParameterBlock block);
+  Rectangle2D getBounds2D(ParameterBlock block);
+  Object getProperty(ParameterBlock block, String name);
+  String[] getPropertyNames();
+  boolean isDynamic();
+} // interface ContextualRenderedImageFactory

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/ParameterBlock.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/ParameterBlock.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/ParameterBlock.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/ParameterBlock.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,308 @@
+/* ParameterBlock.java -- 
+   Copyright (C) 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.renderable;
+
+import java.awt.image.RenderedImage;
+import java.io.Serializable;
+import java.util.Vector;
+
+public class ParameterBlock implements Cloneable, Serializable
+{
+  private static final long serialVersionUID = -7577115551785240750L;
+  protected Vector sources;
+  protected Vector parameters;
+
+  public ParameterBlock()
+  {
+    this(new Vector(), new Vector());
+  }
+
+  public ParameterBlock(Vector sources)
+  {
+    this(sources, new Vector());
+  }
+
+  public ParameterBlock(Vector sources, Vector parameters)
+  {
+    this.sources = sources;
+    this.parameters = parameters;
+  }
+
+  public Object shallowClone()
+  {
+    try
+      {
+        return super.clone();
+      }
+    catch (CloneNotSupportedException e)
+      {
+        throw (Error) new InternalError().initCause(e); // impossible
+      }
+  }
+
+  public Object clone()
+  {
+    ParameterBlock pb = (ParameterBlock) shallowClone();
+    if (sources != null)
+      pb.sources = (Vector) sources.clone();
+    if (parameters != null)
+      pb.parameters = (Vector) parameters.clone();
+    return pb;
+  }
+
+  public ParameterBlock addSource(Object source)
+  {
+    sources.add(source);
+    return this;
+  }
+
+  public Object getSource(int index)
+  {
+    return sources.get(index);
+  }
+
+  public ParameterBlock setSource(Object source, int index)
+  {
+    sources.ensureCapacity(index);
+    sources.set(index, source);
+    return this;
+  }
+
+  public RenderedImage getRenderedSource(int index)
+  {
+    return (RenderedImage) sources.get(index);
+  }
+
+  public RenderableImage getRenderableSource(int index)
+  {
+    return (RenderableImage) sources.get(index);
+  }
+
+  public int getNumSources()
+  {
+    return sources.size();
+  }
+
+  public Vector getSources()
+  {
+    return sources;
+  }
+
+  public void setSources(Vector sources)
+  {
+    this.sources = sources;
+  }
+
+  public void removeSources()
+  {
+    if (sources != null)
+      sources.clear();
+  }
+
+  public int getNumParameters()
+  {
+    return parameters.size();
+  }
+
+  public Vector getParameters()
+  {
+    return parameters;
+  }
+
+  public void setParameters(Vector parameters)
+  {
+    this.parameters = parameters;
+  }
+
+  public void removeParameters()
+  {
+    if (parameters != null)
+      parameters.clear();
+  }
+
+  public ParameterBlock add(Object o)
+  {
+    parameters.add(o);
+    return this;
+  }
+
+  public ParameterBlock add(byte b)
+  {
+    return add(new Byte(b));
+  }
+
+  public ParameterBlock add(char c)
+  {
+    return add(new Character(c));
+  }
+
+  public ParameterBlock add(short s)
+  {
+    return add(new Short(s));
+  }
+
+  public ParameterBlock add(int i)
+  {
+    return add(new Integer(i));
+  }
+
+  public ParameterBlock add(long l)
+  {
+    return add(new Long(l));
+  }
+
+  public ParameterBlock add(float f)
+  {
+    return add(new Float(f));
+  }
+
+  public ParameterBlock add(double d)
+  {
+    return add(new Double(d));
+  }
+
+  public ParameterBlock set(Object o, int index)
+  {
+    parameters.ensureCapacity(index);
+    parameters.set(index, o);
+    return this;
+  }
+
+  public ParameterBlock set(byte b, int index)
+  {
+    return set(new Byte(b), index);
+  }
+
+  public ParameterBlock set(char c, int index)
+  {
+    return set(new Character(c), index);
+  }
+
+  public ParameterBlock set(short s, int index)
+  {
+    return set(new Short(s), index);
+  }
+
+  public ParameterBlock set(int i, int index)
+  {
+    return set(new Integer(i), index);
+  }
+
+  public ParameterBlock set(long l, int index)
+  {
+    return set(new Long(l), index);
+  }
+
+  public ParameterBlock set(float f, int index)
+  {
+    return set(new Float(f), index);
+  }
+
+  public ParameterBlock set(double d, int index)
+  {
+    return set(new Double(d), index);
+  }
+
+  public Object getObjectParameter(int index)
+  {
+    return parameters.get(index);
+  }
+
+  public byte getByteParameter(int index)
+  {
+    return ((Byte) parameters.get(index)).byteValue();
+  }
+
+  public char getCharParameter(int index)
+  {
+    return ((Character) parameters.get(index)).charValue();
+  }
+
+  public short getShortParameter(int index)
+  {
+    return ((Short) parameters.get(index)).shortValue();
+  }
+
+  public int getIntParameter(int index)
+  {
+    return ((Integer) parameters.get(index)).intValue();
+  }
+
+  public long getLongParameter(int index)
+  {
+    return ((Long) parameters.get(index)).longValue();
+  }
+
+  public float getFloatParameter(int index)
+  {
+    return ((Float) parameters.get(index)).floatValue();
+  }
+
+  public double getDoubleParameter(int index)
+  {
+    return ((Double) parameters.get(index)).doubleValue();
+  }
+
+  public Class[] getParamClasses()
+  {
+    int i = parameters.size();
+    Class[] result = new Class[i];
+    while (--i >= 0)
+      {
+        Class c = parameters.get(i).getClass();
+        if (c == Byte.class)
+          result[i] = byte.class;
+        else if (c == Character.class)
+          result[i] = char.class;
+        else if (c == Short.class)
+          result[i] = short.class;
+        else if (c == Integer.class)
+          result[i] = int.class;
+        else if (c == Long.class)
+          result[i] = long.class;
+        else if (c == Float.class)
+          result[i] = float.class;
+        else if (c == Double.class)
+          result[i] = double.class;
+        else
+          result[i] = c;
+      }
+    return result;
+  }
+} // class ParameterBlock

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderContext.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderContext.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderContext.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderContext.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,141 @@
+/* RenderContext.java -- 
+   Copyright (C) 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.renderable;
+
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+
+public class RenderContext implements Cloneable
+{
+  private AffineTransform xform;
+  private Shape aoi;
+  private RenderingHints hints;
+
+  public RenderContext(AffineTransform xform, Shape aoi, RenderingHints hints)
+  {
+    this.xform = xform;
+    this.aoi = aoi;
+    this.hints = hints;
+  }
+
+  public RenderContext(AffineTransform xform)
+  {
+    this(xform, null, null);
+  }
+
+  public RenderContext(AffineTransform xform, RenderingHints hints)
+  {
+    this(xform, null, hints);
+  }
+
+  public RenderContext(AffineTransform xform, Shape aoi)
+  {
+    this(xform, aoi, null);
+  }
+
+  public RenderingHints getRenderingHints()
+  {
+    return hints;
+  }
+
+  public void setRenderingHints(RenderingHints hints)
+  {
+    this.hints = hints;
+  }
+
+  public void setTransform(AffineTransform xform)
+  {
+    this.xform = xform;
+  }
+
+  public void preConcatenateTransform(AffineTransform pre)
+  {
+    preConcetenateTransform (pre);
+  }
+
+  /** @deprecated */
+  public void preConcetenateTransform(AffineTransform pre)
+  {
+    xform.preConcatenate (pre);
+  }
+
+  public void concatenateTransform(AffineTransform post)
+  {
+    concetenateTransform (post);
+  }
+
+  /** @deprecated */
+  public void concetenateTransform(AffineTransform post)
+  {
+    xform.concatenate (post);
+  }
+
+  public AffineTransform getTransform()
+  {
+    return xform;
+  }
+
+  public void setAreaOfInterest(Shape aoi)
+  {
+    this.aoi = aoi;
+  }
+
+  public Shape getAreaOfInterest()
+  {
+    return aoi;
+  }
+
+  public Object clone()
+  {
+    try
+      {
+        RenderContext copy = (RenderContext) super.clone();
+        if (xform != null)
+          copy.xform = (AffineTransform) xform.clone();
+        if (hints != null)
+          copy.hints = (RenderingHints) hints.clone();
+        return copy;
+      }
+    catch (CloneNotSupportedException e)
+      {
+        throw (Error) new InternalError().initCause(e); // impossible
+      }
+  }
+} // class RenderContext

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderableImage.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderableImage.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderableImage.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderableImage.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,62 @@
+/* RenderableImage.java -- 
+   Copyright (C) 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.renderable;
+
+import java.awt.RenderingHints;
+import java.awt.image.RenderedImage;
+import java.util.Vector;
+
+public interface RenderableImage
+{
+  String HINTS_OBSERVED = "HINTS_OBSERVED";
+  
+  Vector getSources();
+  Object getProperty(String name);
+  String[] getPropertyNames();
+  boolean isDynamic();
+  float getWidth();
+  float getHeight();
+  float getMinX();
+  float getMinY();
+  RenderedImage createScaledRendering(int w, int h, RenderingHints hints);
+  RenderedImage createDefaultRendering();
+  RenderedImage createRendering(RenderContext context);
+
+} // interface RenderableImage
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderableImageOp.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderableImageOp.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderableImageOp.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderableImageOp.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,157 @@
+/* RenderableImageOp.java -- 
+   Copyright (C) 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.renderable;
+
+import java.awt.RenderingHints;
+import java.awt.geom.AffineTransform;
+import java.awt.image.RenderedImage;
+import java.util.Vector;
+
+public class RenderableImageOp implements RenderableImage
+{
+  private final ContextualRenderedImageFactory crif;
+  private ParameterBlock block;
+
+  public RenderableImageOp(ContextualRenderedImageFactory crif,
+                           ParameterBlock block)
+  {
+    this.crif = crif;
+    this.block = (ParameterBlock) block.clone();
+  }
+
+  public Vector getSources()
+  {
+    if (block.sources == null)
+      return null;
+    int size = block.sources.size();
+    Vector v = new Vector();
+    for (int i = 0; i < size; i++)
+      {
+        Object o = block.sources.get(i);
+        if (o instanceof RenderableImage)
+          v.add(o);
+      }
+    return v;
+  }
+
+  public Object getProperty(String name)
+  {
+    return crif.getProperty(block, name);
+  }
+
+  public String[] getPropertyNames()
+  {
+    return crif.getPropertyNames();
+  }
+
+  public boolean isDynamic()
+  {
+    return crif.isDynamic();
+  }
+
+  public float getWidth()
+  {
+    return (float) crif.getBounds2D(block).getWidth();
+  }
+
+  public float getHeight()
+  {
+    return (float) crif.getBounds2D(block).getHeight();
+  }
+
+  public float getMinX()
+  {
+    return (float) crif.getBounds2D(block).getX();
+  }
+
+  public float getMinY()
+  {
+    return (float) crif.getBounds2D(block).getY();
+  }
+
+  public ParameterBlock setParameterBlock(ParameterBlock block)
+  {
+    ParameterBlock result = this.block;
+    this.block = (ParameterBlock) block.clone();
+    return result;
+  }
+
+  public ParameterBlock getParameterBlock()
+  {
+    return block;
+  }
+
+  public RenderedImage createScaledRendering(int w, int h,
+                                             RenderingHints hints)
+  {
+    if (w == 0)
+      if (h == 0)
+        throw new IllegalArgumentException();
+      else
+        w = Math.round(h * getWidth() / getHeight());
+    if (h == 0)
+      h = Math.round(w * getHeight() / getWidth());
+    AffineTransform xform = AffineTransform.getScaleInstance(w * getWidth(),
+                                                             h * getHeight());
+    return createRendering(new RenderContext(xform, hints));
+  }
+
+  public RenderedImage createDefaultRendering()
+  {
+    return createRendering(new RenderContext(new AffineTransform()));
+  }
+
+  public RenderedImage createRendering(RenderContext context)
+  {
+    ParameterBlock copy = (ParameterBlock) block.clone();
+    int i = block.sources.size();
+    while (--i >= 0)
+      {
+        Object o = block.sources.get(i);
+        if (o instanceof RenderableImage)
+          {
+            RenderableImage ri = (RenderableImage) o;
+            RenderContext rc = crif.mapRenderContext(i, context, block, ri);
+            copy.sources.set(i, ri.createRendering(rc));
+          }
+      }
+    // Now copy.sources should be only RenderedImages.
+    return crif.create(context, copy);
+  }
+} // class RenderableImageOp

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderableImageProducer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderableImageProducer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderableImageProducer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderableImageProducer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,166 @@
+/* RenderableImageProducer.java -- 
+   Copyright (C) 2002, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.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)
+  {
+    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)
+  {
+    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

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderedImageFactory.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderedImageFactory.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderedImageFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/RenderedImageFactory.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,47 @@
+/* RenderedImageFactory.java -- 
+   Copyright (C) 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.renderable;
+
+import java.awt.RenderingHints;
+import java.awt.image.RenderedImage;
+
+public interface RenderedImageFactory
+{
+  RenderedImage create(ParameterBlock block, RenderingHints hints);
+} // interface RenderedImageFactory

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/image/renderable/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.awt.image.renderable package.
+   Copyright (C) 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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. -->
+
+<html>
+<head><title>GNU Classpath - java.awt.image.renderable</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.awt package.
+   Copyright (C) 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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. -->
+
+<html>
+<head><title>GNU Classpath - java.awt</title></head>
+
+<body>
+<p>Abstract Window Toolkit classes.</p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ButtonPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ButtonPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ButtonPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ButtonPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+/* ButtonPeer.java -- Peer interface for buttons
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+public interface ButtonPeer extends ComponentPeer
+{
+  void setLabel (String label);
+  
+} // interface ButtonPeer
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/CanvasPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/CanvasPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/CanvasPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/CanvasPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,45 @@
+/* CanvasPeer.java -- Peer interface for a canvas
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+public interface CanvasPeer extends ComponentPeer
+{
+
+} // interface CanvasPeer 
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/CheckboxMenuItemPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/CheckboxMenuItemPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/CheckboxMenuItemPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/CheckboxMenuItemPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+/* CheckboxMenuItemPeer.java -- Peer interface for checkbox menu items
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+public interface CheckboxMenuItemPeer extends MenuItemPeer
+{
+  void setState (boolean state);
+  
+} // interface CheckboxMenuItemPeer
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/CheckboxPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/CheckboxPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/CheckboxPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/CheckboxPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,52 @@
+/* CheckboxPeer.java -- Interface for checkbox peer
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+import java.awt.CheckboxGroup;
+
+public interface CheckboxPeer extends ComponentPeer
+{
+  void setCheckboxGroup (CheckboxGroup group);
+
+  void setLabel (String label);
+
+  void setState (boolean state);
+
+} // interface CheckboxPeer
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ChoicePeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ChoicePeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ChoicePeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ChoicePeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,54 @@
+/* ChoicePeer.java -- Peer for choice box
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+public interface ChoicePeer extends ComponentPeer
+{
+  void add (String item, int index);
+
+  void addItem (String item, int index);
+
+  void remove (int index);
+
+  void removeAll();
+
+  void select (int index);  
+
+} // interface ChoicePeer 
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ComponentPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ComponentPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ComponentPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ComponentPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,521 @@
+/* ComponentPeer.java -- Toplevel component peer
+   Copyright (C) 1999, 2000, 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+import java.awt.AWTEvent;
+import java.awt.AWTException;
+import java.awt.BufferCapabilities;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.GraphicsConfiguration;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
+import java.awt.event.PaintEvent;
+import java.awt.image.ColorModel;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.image.VolatileImage;
+
+/**
+ * Defines the methods that a component peer is required to implement.
+ */
+public interface ComponentPeer
+{
+  /**
+   * Returns the construction status of the specified image. This is called
+   * by {@link Component#checkImage(Image, int, int, ImageObserver)}.
+   *
+   * @param img the image
+   * @param width the width of the image
+   * @param height the height of the image
+   * @param ob the image observer to be notified of updates of the status
+   *
+   * @return a bitwise ORed set of ImageObserver flags
+   */
+  int checkImage(Image img, int width, int height, 
+                 ImageObserver ob);
+
+  /**
+   * Creates an image by starting the specified image producer. This is called
+   * by {@link Component#createImage(ImageProducer)}.
+   *
+   * @param prod the image producer to be used to create the image
+   *
+   * @return the created image
+   */
+  Image createImage(ImageProducer prod);
+
+  /**
+   * Creates an empty image with the specified <code>width</code> and
+   * <code>height</code>.
+   *
+   * @param width the width of the image to be created
+   * @param height the height of the image to be created
+   *
+   * @return the created image
+   */
+  Image createImage(int width, int height);
+
+  /**
+   * Disables the component. This is called by {@link Component#disable()}.
+   */
+  void disable();
+
+  /**
+   * Disposes the component peer. This should release all resources held by the
+   * peer. This is called when the component is no longer in use.
+   */
+  void dispose();
+
+  /**
+   * Enables the component. This is called by {@link Component#enable()}.
+   */
+  void enable();
+
+  /**
+   * Returns the color model of the component. This is currently not used.
+   *
+   * @return the color model of the component
+   */
+  ColorModel getColorModel();
+
+  /**
+   * Returns the font metrics for the specified font. This is called by
+   * {@link Component#getFontMetrics(Font)}.
+   *
+   * @param f the font for which to query the font metrics
+   *
+   * @return the font metrics for the specified font
+   */
+  FontMetrics getFontMetrics(Font f);
+
+  /**
+   * Returns a {@link Graphics} object suitable for drawing on this component.
+   * This is called by {@link Component#getGraphics()}.
+   *
+   * @return a graphics object suitable for drawing on this component
+   */
+  Graphics getGraphics();
+
+  /**
+   * Returns the location of this component in screen coordinates. This is
+   * called by {@link Component#getLocationOnScreen()}.
+   *
+   * @return the location of this component in screen coordinates
+   */
+  Point getLocationOnScreen();
+
+  /**
+   * Returns the minimum size for the component. This is called by
+   * {@link Component#getMinimumSize()}.
+   *
+   * @return the minimum size for the component
+   *
+   * @specnote Presumably this method got added to replace minimumSize().
+   *           However, testing shows that this is never called in the RI
+   *           (tested with JDK5), but instead minimumSize() is called
+   *           directly. It is advisable to implement this method to delegate
+   *           to minimumSize() and put the real implementation in there.
+   */
+  Dimension getMinimumSize();
+
+  /**
+   * Returns the preferred size for the component. This is called by
+   * {@link Component#getPreferredSize()}.
+   *
+   * @return the preferred size for the component
+   *
+   * @specnote Presumably this method got added to replace preferredSize().
+   *           However, testing shows that this is never called in the RI
+   *           (tested with JDK5), but instead preferredSize() is called
+   *           directly. It is advisable to implement this method to delegate
+   *           to preferredSize() and put the real implementation in there.
+   */
+  Dimension getPreferredSize();
+
+  /**
+   * Returns the toolkit that created this peer.
+   *
+   * @return the toolkit that created this peer
+   */
+  Toolkit getToolkit();
+
+  /**
+   * Handles the given event. This is called from
+   * {@link Component#dispatchEvent(AWTEvent)} to give the peer a chance to 
+   * react to events for the component.
+   *
+   * @param e the event
+   */
+  void handleEvent(AWTEvent e);
+
+  /**
+   * Makes the component invisible. This is called from
+   * {@link Component#hide()}.
+   */
+  void hide();
+
+  /**
+   * Returns <code>true</code> if the component can receive keyboard input
+   * focus. This is called from {@link Component#isFocusTraversable()}.
+   * 
+   * @specnote Part of the earlier 1.1 API, replaced by isFocusable().
+   */
+  boolean isFocusTraversable();
+
+  /**
+   * Returns <code>true</code> if the component can receive keyboard input
+   * focus. This is called from {@link Component#isFocusable()}.
+   */
+  boolean isFocusable();
+
+  /**
+   * Returns the minimum size for the component. This is called by
+   * {@link Component#minimumSize()}.
+   *
+   * @return the minimum size for the component
+   */
+  Dimension minimumSize();
+
+  /**
+   * Returns the preferred size for the component. This is called by
+   * {@link Component#getPreferredSize()}.
+   *
+   * @return the preferred size for the component
+   */
+  Dimension preferredSize();
+
+  void paint(Graphics graphics);
+
+  /**
+   * Prepares an image for rendering on this component. This is called by
+   * {@link Component#prepareImage(Image, int, int, ImageObserver)}.
+   *
+   * @param img the image to prepare
+   * @param width the desired width of the rendered image
+   * @param height the desired height of the rendered image
+   * @param ob the image observer to be notified of updates in the preparation
+   *        process
+   *
+   * @return <code>true</code> if the image has been fully prepared,
+   *         <code>false</code> otherwise (in which case the image observer
+   *         receives updates)
+   */
+  boolean prepareImage(Image img, int width, int height,
+			      ImageObserver ob);
+
+  void print(Graphics graphics);
+
+  /**
+   * Repaints the specified rectangle of this component. This is called from
+   * {@link Component#repaint(long, int, int, int, int)}.
+   *
+   * @param tm number of milliseconds to wait with repainting
+   * @param x the X coordinate of the upper left corner of the damaged rectangle
+   * @param y the Y coordinate of the upper left corner of the damaged rectangle
+   * @param width the width of the damaged rectangle
+   * @param height the height of the damaged rectangle
+   */
+  void repaint(long tm, int x, int y, int width, int height);
+
+  /**
+   * Requests that this component receives the focus. This is called from
+   * {@link Component#requestFocus()}.
+   * 
+   * @specnote Part of the earlier 1.1 API, apparently replaced by argument 
+   *           form of the same method.
+   */
+  void requestFocus();
+
+  /**
+   * Requests that this component receives the focus. This is called from
+   * {@link Component#requestFocus()}.
+   *
+   * This method is only called for heavyweight component's peers. Lightweight
+   * components ask their nearest heavyweight component to request focus.
+   * It's up to the heavyweight peer to decide if any of it's lightweight
+   * descendants are allowed to receive keyboard input focus or not. If the
+   * focus request is finally approved, then the peer must post a FOCUS_GAINED
+   * event for the requested component.
+   *
+   * @param request the component for which the focus is requested
+   * @param temporary indicates if the focus change is temporary (true) or
+   *        permanent (false)
+   * @param allowWindowFocus indicates if it's allowed to change window focus
+   * @param time the timestamp
+   */
+  boolean requestFocus(Component request, boolean temporary,
+                       boolean allowWindowFocus, long time);
+
+  /**
+   * Notifies the peer that the bounds of this component have changed. This
+   * is called by {@link Component#reshape(int, int, int, int)}.
+   *
+   * @param x the X coordinate of the upper left corner of the component
+   * @param y the Y coordinate of the upper left corner of the component
+   * @param width the width of the component
+   * @param height the height of the component
+   */
+  void reshape(int x, int y, int width, int height);
+
+  /**
+   * Sets the background color of the component. This is called by
+   * {@link Component#setBackground(Color)}.
+   *
+   * @param color the background color to set
+   */
+  void setBackground(Color color);
+
+  /**
+   * Notifies the peer that the bounds of this component have changed. This
+   * is called by {@link Component#setBounds(int, int, int, int)}.
+   *
+   * @param x the X coordinate of the upper left corner of the component
+   * @param y the Y coordinate of the upper left corner of the component
+   * @param width the width of the component
+   * @param height the height of the component
+   */
+  void setBounds(int x, int y, int width, int height);
+
+  /**
+   * Sets the cursor of the component. This is called by
+   * {@link Component#setCursor(Cursor)}.
+   *
+   * @specnote Part of the earlier 1.1 API, apparently no longer needed.
+   */
+  void setCursor(Cursor cursor);
+
+  /**
+   * Sets the enabled/disabled state of this component. This is called by
+   * {@link Component#setEnabled(boolean)}.
+   *
+   * @param enabled <code>true</code> to enable the component,
+   *        <code>false</code> to disable it
+   */
+  void setEnabled(boolean enabled);
+
+  /**
+   * Sets the font of the component. This is called by
+   * {@link Component#setFont(Font)}.
+   *
+   * @param font the font to set
+   */
+  void setFont(Font font);
+
+  /**
+   * Sets the foreground color of the component. This is called by
+   * {@link Component#setForeground(Color)}.
+   *
+   * @param color the foreground color to set
+   */
+  void setForeground(Color color);
+
+  /**
+   * Sets the visibility state of the component. This is called by
+   * {@link Component#setVisible(boolean)}.
+   *
+   * @param visible <code>true</code> to make the component visible,
+   *        <code>false</code> to make it invisible
+   */
+  void setVisible(boolean visible);
+
+  /**
+   * Makes the component visible. This is called by {@link Component#show()}.
+   */
+  void show();
+
+  /** 
+   * Get the graphics configuration of the component. The color model
+   * of the component can be derived from the configuration.
+   *
+   * @return the graphics configuration of the component
+   */
+  GraphicsConfiguration getGraphicsConfiguration();
+
+  /**
+   * Part of an older API, no longer needed.
+   */
+  void setEventMask(long mask);
+
+  /**
+   * Returns <code>true</code> if this component has been obscured,
+   * <code>false</code> otherwise. This will only work if
+   * {@link #canDetermineObscurity()} also returns <code>true</code>.
+   *
+   * @return <code>true</code> if this component has been obscured,
+   *         <code>false</code> otherwise.
+   */
+  boolean isObscured();
+
+  /**
+   * Returns <code>true</code> if this component peer can determine if the
+   * component has been obscured, <code>false</code> otherwise.
+   *
+   * @return <code>true</code> if this component peer can determine if the
+   *         component has been obscured, <code>false</code> otherwise
+   */
+  boolean canDetermineObscurity();
+
+  /**
+   * Coalesces the specified paint event.
+   *
+   * @param e the paint event
+   */
+  void coalescePaintEvent(PaintEvent e);
+
+  /**
+   * Updates the cursor.
+   */
+  void updateCursorImmediately();
+
+  /**
+   * Returns true, if this component can handle wheel scrolling,
+   * <code>false</code> otherwise.
+   *
+   * @return true, if this component can handle wheel scrolling,
+   *         <code>false</code> otherwise
+   */
+  boolean handlesWheelScrolling();
+
+  /**
+   * A convenience method that creates a volatile image.  The volatile
+   * image is created on the screen device on which this component is
+   * displayed, in the device's current graphics configuration.
+   *
+   * @param width width of the image
+   * @param height height of the image
+   *
+   * @see VolatileImage
+   *
+   * @since 1.2
+   */
+  VolatileImage createVolatileImage(int width, int height);
+
+  /**
+   * Create a number of image buffers that implement a buffering
+   * strategy according to the given capabilities.
+   *
+   * @param numBuffers the number of buffers
+   * @param caps the buffering capabilities
+   *
+   * @throws AWTException if the specified buffering strategy is not
+   * implemented
+   *
+   * @since 1.2
+   */
+  void createBuffers(int numBuffers, BufferCapabilities caps)
+    throws AWTException;
+
+  /**
+   * Return the back buffer of this component.
+   *
+   * @return the back buffer of this component.
+   *
+   * @since 1.2
+   */
+  Image getBackBuffer();
+
+  /**
+   * Perform a page flip, leaving the contents of the back buffer in
+   * the specified state.
+   *
+   * @param contents the state in which to leave the back buffer
+   *
+   * @since 1.2
+   */
+  void flip(BufferCapabilities.FlipContents contents);
+
+  /**
+   * Destroy the resources created by createBuffers.
+   *
+   * @since 1.2
+   */
+  void destroyBuffers();
+  
+  /**
+   * Get the bounds of this component peer.
+   * 
+   * @return component peer bounds
+   * @since 1.5
+   */
+  Rectangle getBounds();
+
+  /**
+   * Reparent this component under another container.
+   * 
+   * @param parent
+   * @since 1.5
+   */
+  void reparent(ContainerPeer parent);
+  
+  /**
+   * Set the bounds of this component peer.
+   * 
+   * @param x the new x co-ordinate
+   * @param y the new y co-ordinate
+   * @param width the new width
+   * @param height the new height
+   * @param z the new stacking level
+   * @since 1.5
+   */
+  void setBounds (int x, int y, int width, int height, int z);
+  
+  /**
+   * Check if this component supports being reparented.
+   * 
+   * @return true if this component can be reparented,
+   * false otherwise.
+   * @since 1.5
+   */
+  boolean isReparentSupported();
+
+  /**
+   * Layout this component peer.
+   *
+   * @since 1.5
+   */
+  void layout();
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ContainerPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ContainerPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ContainerPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ContainerPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,84 @@
+/* ContainerPeer.java -- Interface for container peers
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+import java.awt.Insets;
+
+public interface ContainerPeer extends ComponentPeer
+{
+  Insets insets();
+
+  Insets getInsets();
+
+  void beginValidate();
+
+  void endValidate();
+
+  void beginLayout();
+
+  void endLayout();
+
+  boolean isPaintPending();
+  
+  /**
+   * Check if this container peer can be restacked.
+   * 
+   * @return true if this container peer supports being restacked, false otherwise
+   * @since 1.5
+   */
+  boolean isRestackSupported();
+
+  /**
+   * Cancel a pending paint event on a region of this container.
+   * 
+   * @param x the x co-ordinate of the region
+   * @param y the y co-ordinate of the region
+   * @param width the width of the region
+   * @param height the height of the region
+   * @since 1.5
+   */
+  void cancelPendingPaint(int x, int y, int width, int height);
+  
+  /**
+   * Restack the component peers in this container peer.
+   * 
+   * @since 1.5
+   */
+  void restack();
+} // interface ContainerPeer 
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/DialogPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/DialogPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/DialogPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/DialogPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,48 @@
+/* DialogPeer.java -- Interface for dialog box peer
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+public interface DialogPeer extends WindowPeer
+{
+  void setResizable (boolean resizeable);
+
+  void setTitle (String title);
+
+} // interface DialogPeer 
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/FileDialogPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/FileDialogPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/FileDialogPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/FileDialogPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,52 @@
+/* FileDialogPeer.java -- Interface for file selection dialog box peer
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+import java.io.FilenameFilter;
+
+public interface FileDialogPeer extends DialogPeer
+{
+  void setFile (String file);
+
+  void setDirectory (String dir);
+
+  void setFilenameFilter (FilenameFilter ff);
+
+} // interface FileDialogPeer 
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/FontPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/FontPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/FontPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/FontPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,45 @@
+/* FontPeer.java -- Interface for font peers
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+public interface FontPeer
+{
+
+} // interface FontPeer
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/FramePeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/FramePeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/FramePeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/FramePeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* FramePeer.java -- Interface for frame peers
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+import java.awt.Image;
+import java.awt.MenuBar;
+import java.awt.Rectangle;
+
+public interface FramePeer extends WindowPeer
+{
+  void setIconImage(Image image);
+  void setMenuBar(MenuBar mb);
+  void setResizable(boolean resizable);
+  void setTitle(String title);
+  int getState();
+  void setState(int state);
+  void setMaximizedBounds(Rectangle r);
+  
+  /**
+   * Check if this frame peer supports being restacked.
+   * 
+   * @return true if this frame peer can be restacked,
+   * false otherwise
+   * @since 1.5
+   */
+  boolean isRestackSupported();
+  
+  /**
+   * Sets the bounds of this frame peer.
+   * 
+   * @param x the new x co-ordinate
+   * @param y the new y co-ordinate
+   * @param width the new width
+   * @param height the new height
+   * @since 1.5
+   */
+  void setBoundsPrivate(int x, int y, int width, int height);
+} // interface FramePeer
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/LabelPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/LabelPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/LabelPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/LabelPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+/* LabelPeer.java -- Interface for simple text lable peer
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+public interface LabelPeer extends ComponentPeer
+{
+  void setAlignment(int alignment);
+  void setText(String text);
+} // interface LabelPeer 
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/LightweightPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/LightweightPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/LightweightPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/LightweightPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,45 @@
+/* LightweightPeer.java -- Interface for lightweight peers
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+public interface LightweightPeer extends ComponentPeer
+{
+
+} // interface LightweightPeer
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ListPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ListPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ListPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ListPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,61 @@
+/* ListPeer.java -- Interface for list box peer
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+import java.awt.Dimension;
+
+public interface ListPeer extends ComponentPeer
+{
+  void add(String item, int index);
+  void addItem(String item, int index);
+  void clear();
+  void delItems(int start_index, int end_index);
+  void deselect(int index);
+  int[] getSelectedIndexes();
+  void makeVisible(int index);
+  Dimension minimumSize(int s);
+  Dimension preferredSize(int s);
+  void removeAll();
+  void select(int index);
+  void setMultipleMode(boolean multi);
+  void setMultipleSelections(boolean multi);
+  Dimension getPreferredSize(int s);
+  Dimension getMinimumSize(int s);
+} // interface ListPeer 
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MenuBarPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MenuBarPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MenuBarPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MenuBarPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,49 @@
+/* MenuBarPeer.java -- Interface for menu bar peer
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+import java.awt.Menu;
+
+public interface MenuBarPeer extends MenuComponentPeer
+{
+  void addMenu(Menu m);
+  void addHelpMenu(Menu menu);
+  void delMenu(int index);
+} // interface MenuBarPeer 
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MenuComponentPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MenuComponentPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MenuComponentPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MenuComponentPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* MenuComponentPeer.java -- 
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+import java.awt.Font;
+
+public interface MenuComponentPeer
+{
+  void dispose();
+  
+  /**
+   * Set the font on this menu component peer.
+   * 
+   * @param font the new font
+   * @since 1.5
+   */
+  void setFont (Font font);
+} // interface MenuComponentPeer
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MenuItemPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MenuItemPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MenuItemPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MenuItemPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,48 @@
+/* MenuItemPeer.java -- Interface for menu item peers
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+public interface MenuItemPeer extends MenuComponentPeer
+{
+  void disable();
+  void enable();
+  void setEnabled(boolean enabled);
+  void setLabel(String text);
+} // interface MenuItemPeer 
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MenuPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MenuPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MenuPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MenuPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,49 @@
+/* MenuPeer.java -- Interface for menu peers
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+import java.awt.MenuItem;
+
+public interface MenuPeer extends MenuItemPeer
+{
+  void addItem (MenuItem item);
+  void addSeparator ();
+  void delItem (int index);
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MouseInfoPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MouseInfoPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MouseInfoPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/MouseInfoPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,61 @@
+/* MouseInfoPeer.java -- peer interface for MouseInfo
+   Copyright (C) 2006 Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+import java.awt.Point;
+import java.awt.Window;
+
+/**
+ * MouseInfoPeer is the peer interface java.awt.MouseInfo.
+ *
+ * @author Sven de Marothy
+ * @since 1.5
+ */
+public interface MouseInfoPeer
+{
+  /**
+   * Get the mouse pointer coordinates and store them in p (obviously non-null)
+   * returns the index of the current screen device of the mouse.
+   */ 
+  public int fillPointWithCoords(Point p);
+
+  /**
+   * Returns whether a given Window is under the mouse.
+   */ 
+  public boolean isWindowUnderMouse(Window w);
+} 

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/PanelPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/PanelPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/PanelPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/PanelPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,45 @@
+/* PanelPeer.java -- Interface for panel peers
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+public interface PanelPeer extends ContainerPeer
+{
+
+} // interface PanelPeer
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/PopupMenuPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/PopupMenuPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/PopupMenuPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/PopupMenuPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,53 @@
+/* PopupMenuPeer.java -- Interface for popup menu peers
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+import java.awt.Component;
+import java.awt.Event;
+
+public interface PopupMenuPeer extends MenuPeer
+{
+  /**
+   * Part of the older API, replaced by event version instead.
+   */
+  void show (Component origin, int x, int y);
+
+  void show (Event e);
+} // interface PopupMenuPeer
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/RobotPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/RobotPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/RobotPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/RobotPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,54 @@
+/* RobotPeer.java -- Interface for programatically driving GUI
+   Copyright (C) 2003 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+import java.awt.Rectangle;
+
+public interface RobotPeer
+{
+  void mouseMove (int x, int y);
+  void mousePress (int buttons);
+  void mouseRelease (int buttons);
+  void mouseWheel (int wheelAmt);
+  void keyPress (int keycode);
+  void keyRelease (int keycode);
+  int getRGBPixel (int x, int y);
+  int[] getRGBPixels (Rectangle screen);
+} // interface RobotPeer
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ScrollPanePeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ScrollPanePeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ScrollPanePeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ScrollPanePeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,52 @@
+/* ScrollPanePeer.java -- Interface for scrollable panes
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+import java.awt.Adjustable;
+
+public interface ScrollPanePeer extends ContainerPeer
+{
+  int getHScrollbarHeight();
+  int getVScrollbarWidth();
+  void setScrollPosition(int h, int v);
+  void childResized(int width, int height);
+  void setUnitIncrement(Adjustable item, int inc);
+  void setValue(Adjustable item, int value);
+} // interface ScollPanePeer
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ScrollbarPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ScrollbarPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ScrollbarPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/ScrollbarPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,47 @@
+/* ScrollbarPeer.java -- Interface for scrollbar peers
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+public interface ScrollbarPeer extends ComponentPeer
+{
+  void setLineIncrement(int inc);
+  void setPageIncrement(int inc);
+  void setValues(int value, int visible, int min, int max);
+} // interface ScrollbarPeer 
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/TextAreaPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/TextAreaPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/TextAreaPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/TextAreaPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,53 @@
+/* TextAreaPeer.java -- Interface for text area peers
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+import java.awt.Dimension;
+
+public interface TextAreaPeer extends TextComponentPeer
+{
+  void insert(String text, int pos);
+  void insertText(String text, int pos);
+  Dimension minimumSize(int rows, int cols);
+  Dimension getMinimumSize(int rows, int cols);
+  Dimension preferredSize(int rows, int cols);
+  Dimension getPreferredSize(int rows, int cols);
+  void replaceRange(String text, int start_pos, int end_pos);
+  void replaceText(String text, int start_pos, int end_pos);
+} // interface TextAreaPeer

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/TextComponentPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/TextComponentPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/TextComponentPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/TextComponentPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,66 @@
+/* TextComponentPeer.java -- Superclass interface for text components
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+import java.awt.Rectangle;
+import java.awt.im.InputMethodRequests;
+
+public interface TextComponentPeer extends ComponentPeer
+{
+  int getSelectionEnd();
+  int getSelectionStart();
+  String getText();
+  void setText(String text);
+  void select(int start_pos, int end_pos);
+  void setEditable(boolean editable);
+  int getCaretPosition();
+  void setCaretPosition(int pos);
+  int getIndexAtPoint(int x, int y);
+  Rectangle getCharacterBounds(int pos);
+  long filterEvents(long filter);
+  
+  /**
+   * Retrieve this text component peer's input method requests.
+   * 
+   * @return the input method requests made by this text component peer
+   * @since 1.5
+   */
+  InputMethodRequests getInputMethodRequests();
+} // interface TextComponentPeer 
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/TextFieldPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/TextFieldPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/TextFieldPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/TextFieldPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,52 @@
+/* TextFieldPeer.java -- Interface for text field peers
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+import java.awt.Dimension;
+
+public interface TextFieldPeer extends TextComponentPeer
+{
+  Dimension minimumSize(int len);
+  Dimension preferredSize(int len);
+  Dimension getMinimumSize(int len);
+  Dimension getPreferredSize(int len);
+  void setEchoChar(char echo_char);
+  void setEchoCharacter(char echo_char);  
+} // interface TextFieldPeer 
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/WindowPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/WindowPeer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/WindowPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/WindowPeer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,61 @@
+/* WindowPeer.java -- Interface for window peers
+   Copyright (C) 1999, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.peer;
+
+public interface WindowPeer extends ContainerPeer
+{
+  void toBack();
+  void toFront();
+  
+  /**
+   * Update the always-on-top status of the Window.
+   *
+   * @since 1.5
+   */
+  void updateAlwaysOnTop();
+  
+  /**
+   * Request that this window peer be given the window focus.
+   * 
+   * @return true if the window received focus, false otherwise
+   * @since 1.5
+   */
+  boolean requestWindowFocus();
+} // interface WindowPeer 
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/peer/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.awt.peer package.
+   Copyright (C) 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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. -->
+
+<html>
+<head><title>GNU Classpath - java.awt.peer</title></head>
+
+<body>
+<p>Interfaces for using native interface components.</p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/Book.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/Book.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/Book.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/Book.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,159 @@
+/* Book.java -- A mixed group of pages to print.
+   Copyright (C) 1999, 2004  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.print;
+
+import java.util.Vector;
+
+/**
+ * This class allows documents to be created with different paper types,
+ * page formatters, and painters.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class Book implements Pageable
+{
+  /**
+   * Painter objects for the book.
+   */
+  Vector printables = new Vector();
+
+  /**
+   * Page formats for the book.
+   */
+  Vector page_formats = new Vector();
+
+  /**
+   * Initializes a new instance of <code>Book</code> that is empty.
+   */
+  public Book()
+  {
+  }
+
+  /**
+   * Returns the number of pages in this book.
+   *
+   * @return The number of pages in this book.
+   */
+  public int getNumberOfPages()
+  {
+    return printables.size();
+  }
+
+  /**
+   * This method returns the <code>PageFormat</code> object for the
+   * specified page.
+   *
+   * @param page_number The number of the page to get information for, where
+   * page numbers start at 0.
+   *
+   * @return The <code>PageFormat</code> object for the specified page.
+   *
+   * @exception IndexOutOfBoundsException If the page number is not valid.
+   */
+  public PageFormat getPageFormat(int page_number)
+  {
+    return (PageFormat) page_formats.elementAt(page_number);
+  }
+
+  /**
+   * This method returns the <code>Printable</code> object for the
+   * specified page.
+   *
+   * @param page_number The number of the page to get information for, where
+   * page numbers start at 0.
+   *
+   * @return The <code>Printable</code> object for the specified page.
+   *
+   * @exception IndexOutOfBoundsException If the page number is not valid.
+   */
+  public Printable getPrintable(int page_number)
+  {
+    return (Printable) printables.elementAt(page_number);
+  }
+
+  /**
+   * This method appends a page to the end of the book.
+   *
+   * @param printable The <code>Printable</code> for this page.
+   * @param page_format The <code>PageFormat</code> for this page.
+   *
+   * @exception NullPointerException If either argument is <code>null</code>.
+   */
+  public void append(Printable printable, PageFormat page_format)
+  {
+    append(printable, page_format, 1);
+  }
+
+  /**
+   * This method appends the specified number of pages to the end of the book.
+   * Each one will be associated with the specified <code>Printable</code>
+   * and <code>PageFormat</code>.
+   *
+   * @param printable The <code>Printable</code> for this page.
+   * @param page_format The <code>PageFormat</code> for this page.
+   * @param num_pages The number of pages to append.
+   *
+   * @exception NullPointerException If any argument is <code>null</code>.
+   */
+  public void append(Printable printable, PageFormat page_format, int num_pages)
+  {
+    for (int i = 0; i < num_pages; i++)
+      {
+	printables.addElement(printable);
+	page_formats.addElement(page_format);
+      }
+  }
+
+  /**
+   * This method changes the <code>Printable</code> and <code>PageFormat</code>
+   * for the specified page.  The page must already exist or an exception
+   * will be thrown.
+   *
+   * @param page_num The page number to alter.
+   * @param printable The new <code>Printable</code> for the page.
+   * @param page_format The new <code>PageFormat</code> for the page.
+   *
+   * @throws IndexOutOfBoundsException If the specified page does not exist.
+   */
+  public void setPage(int page_num, Printable printable, PageFormat page_format)
+  {
+    printables.setElementAt(printable, page_num);
+    page_formats.setElementAt(page_format, page_num);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/NoPrinterJob.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/NoPrinterJob.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/NoPrinterJob.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/NoPrinterJob.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,124 @@
+/* NoPrinterJob.java -- Fake PrinterJob that just signals no print service.
+   Copyright (C) 2006  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.print;
+
+/**
+ * Fake PrinterJob that just signals no print service.  This is only
+ * here so applications can call
+ * <code>PrintJob.getPrinterJob().getPrinterJob()</code> and check
+ * that it returns <code>null</code> which indicates no actual
+ * printing support is available.
+ */
+class NoPrinterJob extends PrinterJob
+{
+  public int getCopies()
+  {
+    return 0;
+  }
+
+  public void setCopies(int copies)
+  {
+    // Do nothing.
+  }
+
+  public String getJobName()
+  {
+    return "NoPrinterJob";
+  }
+
+  public void setJobName(String job_name)
+  {
+    // Do nothing.
+  }
+
+  public String getUserName()
+  {
+    return "NoUser";
+  }
+
+  public void cancel()
+  {
+    // Do nothing.
+  }
+
+  public boolean isCancelled()
+  {
+    return true;
+  }
+
+  public PageFormat defaultPage(PageFormat page_format)
+  {
+    return page_format;
+  }
+
+  public PageFormat pageDialog(PageFormat page_format)
+  {
+    return page_format;
+  }
+
+  public void print() throws PrinterException
+  {
+    throw new PrinterException("No printer");
+  }
+
+  public boolean printDialog()
+  {
+    return false;
+  }
+
+  public void setPageable(Pageable pageable)
+  {
+    // Do nothing.
+  }
+
+  public void setPrintable(Printable printable)
+  {
+    // Do nothing.
+  }
+
+  public void setPrintable(Printable printable, PageFormat page_format)
+  {
+    // Do nothing.
+  }
+
+  public PageFormat validatePage(PageFormat page_format)
+  {
+    return page_format;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PageFormat.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PageFormat.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PageFormat.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PageFormat.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,233 @@
+/* PageFormat.java -- Information about the page format
+   Copyright (C) 1999, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.print;
+
+/**
+ * This class contains information about the desired page format to use for
+ * printing a particular set of pages.
+ * 
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class PageFormat
+  implements Cloneable
+{
+  /**
+   * A constant for a landscaped page orientation. Used by
+   * <code>getOrientation</code> and <code>setOrientation</code>.
+   */
+  public static final int LANDSCAPE = 0;
+
+  /**
+   * A constant for a portrait page orientation. Used by
+   * <code>getOrientation</code> and <code>setOrientation</code>.
+   */
+  public static final int PORTRAIT = 1;
+
+  /**
+   * A constant for a reversed landscaped page orientation. This is the
+   * orientation used by Macintosh's for landscape. The origin is in the 
+   * upper right hand corner instead of the upper left. The X and Y axes 
+   * are reversed. Used by <code>getOrientation</code> and 
+   * <code>setOrientation</code>.
+   */
+  public static final int REVERSE_LANDSCAPE = 2;
+
+  // The page orientation
+  private int orientation;
+
+  // The paper type
+  private Paper paper;
+
+  /**
+   * This method creates a default page layout, which will be in portrait
+   * format.
+   */
+  public PageFormat()
+  {
+    this.paper = new Paper();
+    this.orientation = PORTRAIT;
+  }
+
+  /**
+   * This method returns the width of the page, in 1/72nd's of an inch. The
+   * "width" measured depends on orientation.
+   * 
+   * @return The width of the page.
+   */
+  public double getWidth()
+  {
+    return paper.getWidth();
+  }
+
+  /**
+   * This method returns the height of the page, in 1/72nd's of an inch. The
+   * "height" measured depends on the orientation.
+   * 
+   * @return The height of the page.
+   */
+  public double getHeight()
+  {
+    return paper.getHeight();
+  }
+
+  /**
+   * This method returns the X coordinate value of the upper leftmost drawable
+   * area of the paper.
+   * 
+   * @return The upper leftmost imageable X coordinate.
+   */
+  public double getImageableX()
+  {
+    return paper.getImageableX();
+  }
+
+  /**
+   * This method returns the Y coordinate value of the upper leftmost drawable
+   * area of the paper.
+   * 
+   * @return The upper leftmost imageable Y coordinate.
+   */
+  public double getImageableY()
+  {
+    return paper.getImageableY();
+  }
+
+  /**
+   * This method returns the imageable width of the paper, in 1/72nd's of an
+   * inch.
+   * 
+   * @return The imageable width of the paper.
+   */
+  public double getImageableWidth()
+  {
+    return paper.getImageableWidth();
+  }
+
+  /**
+   * This method returns the imageable height of the paper, in 1/72nd's of an
+   * inch.
+   * 
+   * @return The imageable height of the paper.
+   */
+  public double getImageableHeight()
+  {
+    return paper.getImageableHeight();
+  }
+
+  /**
+   * Returns a copy of the <code>paper</code> object being used for this page
+   * format.
+   * 
+   * @return A copy of the <code>Paper</code> object for this format.
+   */
+  public Paper getPaper()
+  {
+    return (Paper) paper.clone();
+  }
+
+  /**
+   * Sets the <code>Paper</code> object to be used by this page format.
+   * 
+   * @param paper The new <code>Paper</code> object for this page format.
+   */
+  public void setPaper(Paper paper)
+  {
+    this.paper = paper;
+  }
+
+  /**
+   * This method returns the current page orientation. The value returned will
+   * be one of the page orientation constants from this class.
+   * 
+   * @return The current page orientation.
+   */
+  public int getOrientation()
+  {
+    return orientation;
+  }
+
+  /**
+   * This method sets the page orientation for this format to the specified
+   * value. It must be one of the page orientation constants from this class 
+   * or an exception will be thrown.
+   * 
+   * @param orientation The new page orientation.
+   * @exception IllegalArgumentException If the specified page orientation 
+   *            value is not one of the constants from this class.
+   */
+  public void setOrientation(int orientation) throws IllegalArgumentException
+  {
+    if ((orientation != PORTRAIT) && (orientation != LANDSCAPE)
+        && (orientation != REVERSE_LANDSCAPE))
+      throw new IllegalArgumentException("Bad page orientation value: "
+                                         + orientation);
+
+    this.orientation = orientation;
+  }
+
+  /**
+   * This method returns a matrix used for transforming user space coordinates
+   * to page coordinates. The value returned will be six doubles as described 
+   * in <code>java.awt.geom.AffineTransform</code>.
+   * 
+   * @return The transformation matrix for this page format.
+   */
+  public double[] getMatrix()
+  {
+    throw new RuntimeException("Not implemented since I don't know what to do");
+  }
+
+  /**
+   * This method returns a copy of this object.
+   *
+   * @return A copy of this object.
+   */
+  public Object clone()
+  {
+    try
+      {
+        return (super.clone());
+      }
+    catch (CloneNotSupportedException e)
+      {
+        return (null);
+      }
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/Pageable.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/Pageable.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/Pageable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/Pageable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,90 @@
+/* Pageable.java -- Pages to be printed
+   Copyright (C) 1999, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.print;
+
+/**
+ * This interface represents pages that are to be printed.
+ * 
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public interface Pageable
+{
+  /**
+   * This constant is returned when <code>getNumberOfPages()</code> cannot
+   * determine the number of pages available for printing.
+   */
+  int UNKNOWN_NUMBER_OF_PAGES = - 1;
+
+  /**
+   * This method returns the number of pages this object contains, or
+   * <code>UNKNOWN_NUMBER_OF_PAGES</code> if it cannot determine the number 
+   * of pages to be printed.
+   * 
+   * @return The number of pages to be printed, or
+   *         <code>UNKNOWN_NUMBER_OF_PAGES</code> if this is unknown.
+   */
+  int getNumberOfPages();
+
+  /**
+   * This method returns the <code>PageFormat</code> instance for the
+   * specified page. Page numbers start at zero. An exception is thrown if the
+   * requested page does not exist.
+   * 
+   * @param pageIndex The index of the page to return the
+   *          <code>PageFormat</code> for.
+   * @return The <code>PageFormat</code> for the requested page.
+   * @exception IndexOutOfBoundsException If the requested page number does 
+   *            not exist.
+   */
+  PageFormat getPageFormat(int pageIndex) throws IndexOutOfBoundsException;
+
+  /**
+   * This method returns the <code>Printable</code> instance for the specified
+   * page. Page numbers start at zero. An exception is thrown if the requested
+   * page does not exist.
+   * 
+   * @param pageIndex The index of the page to return the 
+   *        <code>Printable</code> for.
+   * @return The <code>Printable</code> for the requested page.
+   * @exception IndexOutOfBoundsException If the requested page number does 
+   *            not exist.
+   */
+  Printable getPrintable(int pageIndex) throws IndexOutOfBoundsException;
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/Paper.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/Paper.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/Paper.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/Paper.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,197 @@
+/* Paper.java -- Information about a paper type.
+   Copyright (C) 1999, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.print;
+
+/**
+ * This class describes a particular type of paper.
+ * 
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class Paper
+  implements Cloneable
+{
+  // Height of the paper
+  private double height;
+
+  // Width of the paper
+  private double width;
+
+  // Upper left imageable X coordinate
+  private double imageableX;
+
+  // Upper left imageable Y coordinate
+  private double imageableY;
+
+  // Imageable width of the page
+  private double imageableWidth;
+
+  // Imageable height of the page
+  private double imageableHeight;
+
+  /**
+   * This method creates a letter sized paper with one inch margins
+   */
+  public Paper()
+  {
+    width = 8.5 * 72;
+    height = 11 * 72;
+    imageableX = 72;
+    imageableY = 72;
+    imageableWidth = width - (2 * 72);
+    imageableHeight = height - (2 * 72);
+  }
+
+  /**
+   * This method returns the height of the paper in 1/72nds of an inch.
+   * 
+   * @return The height of the paper in 1/72nds of an inch.
+   */
+  public double getHeight()
+  {
+    return height;
+  }
+
+  /**
+   * Returns the width of the paper in 1/72nds of an inch.
+   * 
+   * @return The width of the paper in 1/72nds of an inch.
+   */
+  public double getWidth()
+  {
+    return width;
+  }
+
+  /**
+   * This method returns the X coordinate of the upper left hand corner of the
+   * imageable area of the paper.
+   * 
+   * @return The X coordinate of the upper left hand corner of the imageable
+   *         area of the paper.
+   */
+  public double getImageableX()
+  {
+    return imageableX;
+  }
+
+  /**
+   * This method returns the Y coordinate of the upper left hand corner of the
+   * imageable area of the paper.
+   * 
+   * @return The Y coordinate of the upper left hand corner of the imageable
+   *         area of the paper.
+   */
+  public double getImageableY()
+  {
+    return imageableY;
+  }
+
+  /**
+   * Returns the width of the imageable area of the paper.
+   * 
+   * @return The width of the imageable area of the paper.
+   */
+  public double getImageableWidth()
+  {
+    return imageableWidth;
+  }
+
+  /**
+   * Returns the height of the imageable area of the paper.
+   * 
+   * @return The height of the imageable area of the paper.
+   */
+  public double getImageableHeight()
+  {
+    return imageableHeight;
+  }
+
+  /**
+   * This method sets the size of the paper to the specified width and height,
+   * which are specified in 1/72nds of an inch.
+   * 
+   * @param width The width of the paper in 1/72nds of an inch.
+   * @param height The height of the paper in 1/72nds of an inch.
+   */
+  public void setSize(double width, double height)
+  {
+    this.width = width;
+    this.height = height;
+  }
+
+  /**
+   * This method sets the imageable area of the paper by specifying the
+   * coordinates of the upper left hand corner of that area, and its length 
+   * and height. All values are in 1/72nds of an inch.
+   * 
+   * @param imageableX The X coordinate of the upper left hand corner of the
+   *          imageable area, in 1/72nds of an inch.
+   * @param imageableY The Y coordinate of the upper left hand corner of the
+   *          imageable area, in 1/72nds of an inch.
+   * @param imageableWidth The width of the imageable area of the paper, in
+   *          1/72nds of an inch.
+   * @param imageableHeight The heigth of the imageable area of the paper, in
+   *          1/72nds of an inch.
+   */
+  public void setImageableArea(double imageableX, double imageableY,
+      double imageableWidth, double imageableHeight)
+  {
+    this.imageableX = imageableX;
+    this.imageableY = imageableY;
+    this.imageableWidth = imageableWidth;
+    this.imageableHeight = imageableHeight;
+  }
+
+  /**
+   * This method creates a copy of this object.
+   * 
+   * @return A copy of this object.
+   */
+  public Object clone()
+  {
+    try
+      {
+        return (super.clone());
+      }
+    catch (CloneNotSupportedException e)
+      {
+        return (null);
+      }
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/Printable.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/Printable.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/Printable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/Printable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,80 @@
+/* Printable.java -- Renders a page to the print device
+   Copyright (C) 1999, 2004  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.print;
+
+import java.awt.Graphics;
+
+
+/**
+ * This interface provides a mechanism for the actual printing of pages to the
+ * printer.  The object implementing this interface performs the page
+ * rendering.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public interface Printable
+{
+  /**
+   * This value is returned by the <code>print()</code> method to indicate
+   * that the requested page exists and has been printed.
+   */
+  int PAGE_EXISTS = 0;
+
+  /**
+   * This value is returned by the <code>print()</code> method to indicate
+   * that the requested page number does not exist.
+   */
+  int NO_SUCH_PAGE = 1;
+
+  /**
+   * This method prints the specified page to the specified graphics
+   * context in the specified format.  The pages are numbered starting
+   * from zero.
+   *
+   * @param graphics The graphics context to render the pages on.
+   * @param format The format in which to print the page.
+   * @param page_number The page number to print, where numbers start at zero.
+   *
+   * @return <code>PAGE_EXISTS</code> if the requested page exists and was
+   * successfully printed, <code>NO_SUCH_PAGE</code> otherwise.
+   *
+   * @exception PrinterException If an error occurs during printing.
+   */
+  int print(Graphics graphics, PageFormat format, int page_number)
+    throws PrinterException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterAbortException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterAbortException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterAbortException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterAbortException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,71 @@
+/* PrinterAbortException.java -- Indicates the print job was aborted
+   Copyright (C) 1999, 2002, 2005  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.print;
+
+/**
+ * This exception is thrown when the print job is aborted, either by the
+ * user or by the application.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @status updated to 1.4
+ */
+public class PrinterAbortException extends PrinterException
+{
+  /**
+   * Compatible with JDK 1.2+.
+   */
+  private static final long serialVersionUID = 4725169026278854136L;
+
+  /**
+   * Create a new instance with no detailed error message.
+   */
+  public PrinterAbortException()
+  {
+  }
+
+  /**
+   * Create a new instance with a descriptive error message.
+   *
+   * @param message the descriptive error message
+   */
+  public PrinterAbortException(String message)
+  {
+    super(message);
+  }
+} // class PrinterAbortException

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,71 @@
+/* PrinterException.java -- generic problem in the printing subsystem
+   Copyright (C) 1999, 2002, 2005  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.print;
+
+/**
+ * This is the generic toplevel exception for printing errors.  Subclasses
+ * provide more detailed descriptions of the problem.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @status updated to 1.4
+ */
+public class PrinterException extends Exception
+{
+  /**
+   * Compatible with JDK 1.2+.
+   */
+  private static final long serialVersionUID = -3757589981158265819L;
+
+  /**
+   * Create a new instance with no detailed error message.
+   */
+  public PrinterException()
+  {
+  }
+
+  /**
+   * Create a new instance with a descriptive error message.
+   *
+   * @param message the descriptive error message
+   */
+  public PrinterException(String message)
+  {
+    super(message);
+  }
+} // class PrinterException

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterGraphics.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterGraphics.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterGraphics.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterGraphics.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,58 @@
+/* PrinterGraphics.java -- Hook to return print job controller.
+   Copyright (C) 1999, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.print;
+
+/**
+ * This interface is implemented by the <code>Graphics</code> instance that is
+ * used for rendering pages. It provides a hook to return the object that is
+ * controlling the print job.
+ * 
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public interface PrinterGraphics
+{
+  /**
+   * This method returns the instance of <code>PrinterJob</code> that is
+   * controlling this print job.
+   * 
+   * @return The <code>PrinterJob</code> that is controlling this print job.
+   */
+  PrinterJob getPrinterJob();
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterIOException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterIOException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterIOException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterIOException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,98 @@
+/* PrinterIOException.java -- The print job encountered an I/O error
+   Copyright (C) 1999, 2002, 2005  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.print;
+
+import java.io.IOException;
+
+/**
+ * This exception is thrown when the print job encounters an I/O problem
+ * of some kind.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @status updated to 1.4
+ */
+public class PrinterIOException extends PrinterException
+{
+  /**
+   * Compatible with JDK 1.2+.
+   */
+  private static final long serialVersionUID = 5850870712125932846L;
+
+  /**
+   * The exception that caused this (duplicates Throwable).
+   *
+   * @serial the I/O exception that terminated the job
+  */
+  private final IOException mException;
+
+  /**
+   * Initializes a new instance with the given cause.
+   *
+   * @param mException the cause
+   */
+  public PrinterIOException(IOException mException)
+  {
+    super(mException == null ? null : mException.toString());
+    initCause(mException);
+    this.mException = mException;  
+  }
+
+  /**
+   * Gets the underlying <code>IOException</code> that caused this exception.
+   * This legacy method has been replaced by {@link #getCause()}.
+   *
+   * @return the cause
+  */
+  public IOException getIOException()
+  {
+    return mException;
+  }
+
+  /**
+   * Gets the cause.
+   *
+   * @return the cause
+   */
+  public Throwable getCause()
+  {
+    return mException;
+  }
+} // class PrinterIOException
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterJob.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterJob.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterJob.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/PrinterJob.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,303 @@
+/* PrinterJob.java -- This job is the printer control class
+   Copyright (C) 1999, 2004, 2005, 2006  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.print;
+
+import gnu.java.awt.print.JavaPrinterJob;
+
+import java.awt.HeadlessException;
+import javax.print.PrintService;
+import javax.print.PrintServiceLookup;
+import javax.print.DocFlavor;
+import javax.print.StreamPrintServiceFactory;
+import javax.print.attribute.PrintRequestAttributeSet;
+
+/**
+ * This class controls printing.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public abstract class PrinterJob
+{
+  // The print service associated with this job
+  private PrintService printer = null;
+
+  /**
+   * Creates a new print job.
+   *
+   * @return A <code>PrinterJob</code> object for the newly created print job.
+   */
+  public static PrinterJob getPrinterJob()
+  {
+    return new JavaPrinterJob();
+  }
+
+  /**
+   * Initializes a new instance of <code>PrinterJob</code>. 
+   */
+  public PrinterJob()
+  {
+  }
+
+  /**
+   * Returns the number of copies to be printed.
+   *
+   * @return The number of copies to be printed.
+   */
+  public abstract int getCopies();
+
+  /**
+   * Sets the number of copies to be printed.
+   *
+   * @param copies The number of copies to be printed.
+   */
+  public abstract void setCopies(int copies);
+
+  /**
+   * Returns the name of the print job.
+   *
+   * @return The name of the print job.
+   */
+  public abstract String getJobName();
+
+  /**
+   * Sets the name of the print job.
+   *
+   * @param job_name The name of the print job.
+   */
+  public abstract void setJobName(String job_name);
+
+  /**
+   * Returns the printing user name.
+   *
+   * @return The printing username.
+   */
+  public abstract String getUserName();
+
+  /**
+   * Cancels an in progress print job.
+   */
+  public abstract void cancel();
+
+  /**
+   * Tests whether or not this job has been cancelled.
+   *
+   * @return <code>true</code> if this job has been cancelled, <code>false</code>
+   * otherwise.
+   */
+  public abstract boolean isCancelled();
+
+  /**
+   * Returns an instance of the default page which will have the default
+   * paper and orientation.
+   *
+   * @return A default instance of <code>PageFormat</code>.
+   */
+  public PageFormat defaultPage()
+  {
+    return new PageFormat();
+  }
+
+  /**
+   * Clones the specified <code>PageFormat</code> object then alters the
+   * clone so that it represents the default page format.
+   *
+   * @param page_format The <code>PageFormat</code> to clone.
+   *
+   * @return A new default page format.
+   */
+  public abstract PageFormat defaultPage(PageFormat page_format);
+
+  /**
+   * Displays a dialog box to the user which allows the page format
+   * attributes to be modified.
+   *
+   * @param page_format The <code>PageFormat</code> object to modify.
+   *
+   * @return The modified <code>PageFormat</code>.
+   */
+  public abstract PageFormat pageDialog(PageFormat page_format)
+    throws HeadlessException;
+
+  /**
+   * @since 1.4
+   */
+  public PageFormat pageDialog(PrintRequestAttributeSet attributes)
+    throws HeadlessException
+  {
+    // FIXME: Implement this for real.
+    return pageDialog((PageFormat) null);
+  }
+  
+  /**
+   * Prints the pages.
+   */
+  public abstract void print () throws PrinterException;
+
+  /**
+   * Prints the page with given attributes.
+   */
+  public void print (PrintRequestAttributeSet attributes)
+    throws PrinterException
+  {
+    print ();
+  }
+
+  /**
+   * Displays a dialog box to the user which allows the print job
+   * attributes to be modified.
+   *
+   * @return <code>false</code> if the user cancels the dialog box,
+   * <code>true</code> otherwise.
+   */
+  public abstract boolean printDialog()
+    throws HeadlessException;
+
+  /**
+   * Displays a dialog box to the user which allows the print job
+   * attributes to be modified.
+   *
+   * @return <code>false</code> if the user cancels the dialog box,
+   * <code>true</code> otherwise.
+   */
+  public boolean printDialog(PrintRequestAttributeSet attributes)
+    throws HeadlessException
+  {
+    // FIXME: Implement this for real.
+    return printDialog();
+  }
+
+  /**
+   * This sets the pages that are to be printed.
+   *
+   * @param pageable The pages to be printed, which may not be <code>null</code>.
+   */
+  public abstract void setPageable(Pageable pageable);
+
+  /**
+   * Sets this specified <code>Printable</code> as the one to use for
+   * rendering the pages on the print device.
+   *
+   * @param printable The <code>Printable</code> for the print job.
+   */
+  public abstract void setPrintable(Printable printable);
+
+  /**
+   * Sets the <code>Printable</code> and the page format for the pages
+   * to be printed.
+   *
+   * @param printable The <code>Printable</code> for the print job.
+   * @param page_format The <code>PageFormat</code> for the print job.
+   */
+  public abstract void setPrintable(Printable printable, PageFormat page_format);
+
+  /**
+   * Makes any alterations to the specified <code>PageFormat</code>
+   * necessary to make it work with the current printer.  The alterations
+   * are made to a clone of the input object, which is then returned.
+   *
+   * @param page_format The <code>PageFormat</code> to validate.
+   *
+   * @return The validated <code>PageFormat</code>.
+   */
+  public abstract PageFormat validatePage(PageFormat page_format);
+
+  /**
+   * Find and return 2D image print services.
+   * 
+   * This is the same as calling PrintServiceLookup.lookupPrintServices()
+   * with Pageable service-specified DocFlavor.
+   * @return Array of PrintService objects, could be empty.
+   * @since 1.4
+   */
+  public static PrintService[] lookupPrintServices()
+  {
+    return PrintServiceLookup.lookupPrintServices
+      (
+       new DocFlavor("application/x-java-jvm-local-objectref",
+		     "java.awt.print.Pageable"),
+       null);
+  }
+
+  /**
+   * Find and return 2D image stream print services.
+   * 
+   * This is the same as calling
+   * StreamPrintServiceFactory.lookupStreamPrintServices()
+   * with Pageable service-specified DocFlavor.
+   * @param mimeType The output format mime type, or null for any type.
+   * @return Array of stream print services, could be empty.
+   * @since 1.4
+   */
+  // FIXME:
+  // Enable when StreamPrintServiceFactory has lookupStreamServiceFactories
+//  public static StreamPrintServiceFactory[] lookupStreamPrintServices(String mimeType)
+//  {
+//    return StreamPrintServiceFactory.lookupStreamServiceFactories(
+//      new DocFlavor("application/x-java-jvm-local-objectref",
+//      "java.awt.print.Pageable"),
+//    	mimeType);
+//  }
+
+  /**
+   * Return the printer for this job.  If print services aren't supported by
+   * the subclass, returns null.
+   * 
+   * @return The associated PrintService.
+   * @since 1.4
+   */
+  public PrintService getPrintService()
+  {
+    return printer;
+  }
+
+  /**
+   * Change the printer for this print job to service.  Subclasses that
+   * support setting the print service override this method.  Throws
+   * PrinterException when the class doesn't support setting the printer,
+   * the service doesn't support Pageable or Printable interfaces for 2D
+   * print output.
+   * @param service The new printer to use.
+   * @throws PrinterException if service is not valid.
+   */
+  public void setPrintService(PrintService service)
+    throws PrinterException
+  {
+    printer = service;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/print/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.awt.print package.
+   Copyright (C) 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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. -->
+
+<html>
+<head><title>GNU Classpath - java.awt.print</title></head>
+
+<body>
+<p>Classes for printer jobs, pages, paper sizes, graphics and formats.</p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/AppletInitializer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/AppletInitializer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/AppletInitializer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/AppletInitializer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,61 @@
+/* java.beans.AppletInitializer
+   Copyright (C) 2001, 2005  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+import java.applet.Applet;
+import java.beans.beancontext.BeanContext;
+
+
+/** This interface is a mechanism for the initialization of a Java
+ * Bean that is also an Applet.  It is used by
+ * <code>Beans.instantiate()</code>.
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @since 1.2
+ */
+public interface AppletInitializer
+{
+  /** Activate the applet.  */
+  void activate (Applet applet);
+
+  /** This method will be called by <code>Beans.instantiate()</code>
+   * to associated the new Applet with its AppletContext, AppletStub,
+   * and Container.
+   */
+  void initialize (Applet applet, BeanContext context);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/BeanDescriptor.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/BeanDescriptor.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/BeanDescriptor.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/BeanDescriptor.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* java.beans.BeanDescriptor
+   Copyright (C) 1998, 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+/**
+ ** BeanDescriptor describes general information about a Bean, plus
+ ** stores the Bean's Class and it's customizer's Class.<P>
+ **
+ ** @author John Keiser
+ ** @since JDK1.1
+ ** @version 1.1.0, 31 May 1998
+ **/
+
+public class BeanDescriptor extends FeatureDescriptor {
+	Class beanClass;
+	Class customizerClass;
+
+	/** Create a new BeanDescriptor with the given beanClass and
+	 ** no customizer class.
+	 ** @param beanClass the class of the Bean.
+	 **/
+	public BeanDescriptor(Class beanClass) {
+		this(beanClass,null);
+	}
+
+	/** Create a new BeanDescriptor with the given bean class and
+	 ** customizer class.
+	 ** @param beanClass the class of the Bean.
+	 ** @param customizerClass the class of the Bean's Customizer.
+	 **/
+	public BeanDescriptor(Class beanClass, Class customizerClass) {
+		this.beanClass = beanClass;
+		this.customizerClass = customizerClass;
+
+		// Set the FeatureDescriptor programmatic name.
+		String name = beanClass.getName();
+		int lastInd = name.lastIndexOf('.');
+		if (lastInd != -1)
+		  name = name.substring(lastInd + 1);
+
+		setName(name);
+	}
+
+	/** Get the Bean's class. **/
+	public Class getBeanClass() {
+		return beanClass;
+	}
+
+	/** Get the Bean's customizer's class. **/
+	public Class getCustomizerClass() {
+		return customizerClass;
+	}
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/BeanInfo.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/BeanInfo.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/BeanInfo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/BeanInfo.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,181 @@
+/* java.beans.BeanInfo
+   Copyright (C) 1998 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+/**
+ ** BeanInfo can be implemented in order to provide explicit information to the Introspector.
+ **
+ ** When you write a BeanInfo class, you implement this interface
+ ** and provide explicit information by returning a non-null
+ ** value from the appropriate method.  If you wish the
+ ** Introspector to determine certain information in the normal
+ ** way, just return null (or in the case of int methods, return
+ ** -1).  There is a class called SimpleBeanInfo which returns
+ ** null from all methods, which you may extend and only
+ ** override the methods you wish to override.<P>
+ **
+ ** When you have written the class, give it the name
+ ** <CODE><Bean Class Name>BeanInfo</CODE> and place it in
+ ** the same package as the Bean, or in the bean info search path
+ ** (see Introspector for information on search paths).<P>
+ **
+ ** A simple note about the way the Introspector interacts with
+ ** BeanInfo.  Introspectors look at a Bean class and determine
+ ** if there is a BeanInfo class with it.  If there is not a
+ ** BeanInfo class, it will behave as if the BeanInfo class
+ ** provided was a SimpleBeanInfo class (i.e. it will determine
+ ** all information automatically).<P>If there is a BeanInfo
+ ** class, then any methods that do *not* return null are
+ ** regarded as providing definitive information about the class
+ ** and all of its superclasses for those information types.
+ ** Even if a parent BeanInfo class explicitly returns that
+ ** information, it will not be used.
+ **
+ ** @author John Keiser
+ ** @since JDK1.1
+ ** @version 1.1.0, 28 Jul 1998
+ **/
+
+public interface BeanInfo {
+	/** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/
+	int ICON_COLOR_16x16 = 1;
+	/** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/
+	int ICON_COLOR_32x32 = 2;
+	/** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/
+	int ICON_MONO_16x16 = 3;
+	/** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/
+	int ICON_MONO_32x32 = 4;
+
+	/** Get the general description of this Bean type.
+	 ** @return the BeanDescriptor for the Bean, or null if
+	 **         the BeanDescriptor should be obtained by
+	 **         Introspection.
+	 **/
+	BeanDescriptor getBeanDescriptor();
+
+	/** Get the events this Bean type fires.
+	 ** @return the EventDescriptors representing events this
+	 **         Bean fires.  Returns <CODE>null</CODE> if the
+	 **         events are to be acquired by Introspection.
+	 **/
+	EventSetDescriptor[] getEventSetDescriptors();
+
+	/** Get the "default" event, basically the one a RAD tool
+	 ** user is most likely to select.
+	 ** @return the index into the getEventSetDescriptors()
+	 **         that the user is most likely to use.  Returns
+	 **         <CODE>-1</CODE> if there is no default event.
+	 **/
+	int getDefaultEventIndex();
+
+	/** Get the properties (get/set method pairs) this Bean
+	 ** type supports.
+	 ** @return the PropertyDescriptors representing the
+	 **         properties this Bean type supports.
+	 **         Returns <CODE>null</CODE> if the properties
+	 **         are to be obtained by Introspection.
+	 **/
+	PropertyDescriptor[] getPropertyDescriptors();
+
+	/** Get the "default" property, basically the one a RAD
+	 ** tool user is most likely to select.
+	 ** @return the index into the getPropertyDescriptors()
+	 **         that the user is most likely to use.  Returns
+	 **         <CODE>-1</CODE> if there is no default event.
+	 **/
+	int getDefaultPropertyIndex();
+
+	/** Get the methods this Bean type supports.
+	 ** @return the MethodDescriptors representing the
+	 **         methods this Bean type supports.  Returns
+	 **         <CODE>null</CODE> if the methods are to be
+	 **         obtained by Introspection.
+	 **/
+	MethodDescriptor[] getMethodDescriptors();
+
+	/** Get additional BeanInfos representing this Bean.
+	 ** In this version of JavaBeans, this method is used so
+	 ** that space and time can be saved by reading a BeanInfo
+	 ** for each class in the hierarchy (super, super(super),
+	 ** and so on).<P>
+	 **
+	 ** The order of precedence when two pieces of BeanInfo
+	 ** conflict (such as two PropertyDescriptors that have
+	 ** the same name), in order from highest precedence to
+	 ** lowest, is:
+	 ** <OL>
+	 ** <LI>This BeanInfo object.</LI>
+	 ** <LI><CODE>getAdditionalBeanInfo()[getAdditionalBeanInfo().length]</CODE></LI>
+	 ** <LI> ... </LI>
+	 ** <LI><CODE>getAdditionalBeanInfo()[1]</CODE></LI>
+	 ** <LI><CODE>getAdditionalBeanInfo()[0]</CODE></LI>
+	 ** </OL><P>
+	 **
+	 ** <STRONG>Spec Note:</STRONG> It is possible that
+	 ** returning <CODE>null</CODE> from this method could
+	 ** stop Introspection in its tracks, but it is unclear
+	 ** from the spec whether this is the case.
+	 **
+	 ** @return additional BeanInfos representing this Bean.
+	 **         <CODE>null</CODE> may be returned (see Spec
+	 **         Note, above).
+	 **/
+	BeanInfo[] getAdditionalBeanInfo();
+
+	/** Get a visual icon for this Bean.
+	 ** A Bean does not have to support icons, and if it does
+	 ** support icons, it does not have to support every single
+	 ** type.  Sun recommends that if you only support one
+	 ** type, you support 16x16 color.  Sun also notes that you
+	 ** should try to use a type (like GIF) that allows for
+	 ** transparent pixels, so that the background of the RAD
+	 ** tool can show through.<P>
+	 **
+	 ** <STRONG>Spec Note:</STRONG> If you do not support the
+	 ** type of icon that is being asked for, but you do
+	 ** support another type, it is unclear whether you should
+	 ** return the other type or not.  I would presume not.
+	 **
+	 ** @param iconType the type of icon to get (see the
+	 **        ICON_* constants in this class).
+	 ** @return the icon, or null if that type of icon is
+	 **         unsupported by this Bean.
+	 **/
+	java.awt.Image getIcon(int iconType);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Beans.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Beans.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Beans.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Beans.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,368 @@
+/* java.beans.Beans
+   Copyright (C) 1998, 1999, 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+import gnu.java.beans.DummyAppletStub;
+import gnu.java.io.ClassLoaderObjectInputStream;
+
+import java.applet.Applet;
+import java.beans.beancontext.BeanContext;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.net.URL;
+
+/**
+ * <code>Beans</code> provides some helper methods that allow the basic
+ * operations of Bean-ness.
+ *
+ * @author John Keiser
+ * @author Robert Schuster
+ * 
+ * @since 1.1
+ * @status updated to 1.4
+ *
+ */
+public class Beans
+{
+  static boolean designTime = false;
+  static boolean guiAvailable = true;
+
+  /**
+   * Once again, we have a java.beans class with only
+   * static methods that can be instantiated.  When
+   * will the madness end? :)
+   */
+  public Beans()
+  {
+    // Does intentionally nothing here.
+  }
+
+   /** Creates a bean.
+    * <p>This is a convenience method that calls <code>instantiate(cl, beanName, null, null)</code>.</p>
+    * 
+    * @see instantiate(ClassLoader, String, BeanContext, AppletInitializer)
+    * @param cl ClassLoader to be used or <code>null</code> for the system classloader.
+    * @param beanName Name of a serialized bean or class name.
+    * @return A newly created bean.
+    * @throws IOException If access of an IO resource failed.
+    * @throws ClassNotFoundException If the class name is not known or does not lead to a proper bean class. 
+    */
+    public static Object instantiate(ClassLoader cl, String beanName)
+        throws IOException, ClassNotFoundException
+    {
+        return instantiate(cl, beanName, null, null);
+    }
+
+   /** Creates a bean.
+    * 
+    * <p>This is a convenience method that calls <code>instantiate(cl, beanName, beanContext, null)</code>.</p>
+    * 
+    * @see instantiate(ClassLoader, String, BeanContext, AppletInitializer)
+    * @param cl ClassLoader to be used or <code>null</code> for the system classloader.
+    * @param beanName Name of a serialized bean or class name.
+    * @param beanContext Context to which the newly created Bean should be added.
+    * @return A newly created bean.
+    * @throws IOException If access of an IO resource failed.
+    * @throws ClassNotFoundException If the class name is not known or does not lead to a proper bean class. 
+    */
+    public static Object instantiate(
+        ClassLoader cl,
+        String beanName,
+        BeanContext beanContext)
+        throws IOException, ClassNotFoundException
+    {
+        return instantiate(cl, beanName, beanContext, null);
+    }
+
+   /** Instantiates a bean according to Beans 1.0.
+    * 
+    * <p>In Beans 1.0 the instantiation scheme is as follows:</p>
+    * <p>The name should be dot-separated (e.g "place.for.beans.myBean") and indicate either a
+    * serialized object or a class name. In the first case all dots in the name are replaced with
+    * slashes ('/') and ".ser" is appended ("place.for.beans.myBean" becomes "place/for/beans/myBean.ser").
+    * The bean is then loaded as an application or system resource depending on whether a
+    * <code>ClassLoader</code> was provided.</p>
+    * 
+    * <p>If no such resource exists or if it contains no bean the name is interpreted as a class name of
+    * which an instance is then created.</p>
+    * 
+    * <p>If a <code>BeanContext</code> instance is available the created bean is added to it.</p>
+    * 
+    * <p>If the created Bean is an <code>Applet</code> or subclass and an <code>AppletInitializer</code>
+    * instance is available the applet is initialized and afterwards activated using the initializer. Additionally
+    * every instantiated <code>Applet</code> bean is initialized using the {@link Applet.init} method.
+    * Furthermore every applet gets a default <code>AppletStub</code>. The <code>Applet</code>'s
+    * document base is the location of the ".ser" file if it was deserialized or the location of its class
+    * file if it was instantiated.</p>
+    * 
+    * <p>A <code>ClassNotFoundException</code> is not only thrown when a class name was unknown
+    * but even when the class has public no-argument constructor
+    * (<code>IllegalAccessException</code> is wrapped) or an exception is thrown while
+    * invoking such a constructor (causing exception is wrapped).</p>
+    * 
+    * @param cl ClassLoader to be used or <code>null</code> for the system classloader.
+    * @param beanName Name of a serialized bean or class name.
+    * @param beanContext Context to which the newly created Bean should be added.
+    * @param initializer The AppletInitializer which is used for initializing <code>Applet</code> beans.
+    * @return A newly created bean.
+    * @throws IOException If access of an IO resource failed.
+    * @throws ClassNotFoundException If the class name is not known or does not lead to a proper bean class. 
+    */
+   public static Object instantiate(
+        ClassLoader cl,
+        String beanName,
+        BeanContext beanContext,
+        AppletInitializer initializer)
+        throws IOException, ClassNotFoundException
+   {
+        Object bean = null;
+        URL beanLocation = null;
+        URL classLocation = null;
+
+        // Converts bean name into a resource name (eg. "a.b.c" -> "a/b/c").  
+        String resourceName = beanName.replace('.', '/');
+
+        /* Tries to get an input stream of the Bean, reading it as a system resource
+         * if no ClassLoader is present or as an application resource if a classloader
+         * is given. 
+         */
+        beanLocation =
+            (cl == null)
+                ? ClassLoader.getSystemResource(resourceName + ".ser")
+                : cl.getResource(resourceName + ".ser");
+
+        // Reads the serialized Bean from the returned URL.
+        if (beanLocation != null)
+        {
+            // Deserializes the bean instance.
+            ObjectInputStream ois =
+                (cl == null)
+                    ? new ObjectInputStream(beanLocation.openStream())
+                    : new ClassLoaderObjectInputStream(
+                        beanLocation.openStream(),
+                        cl);
+
+            bean = ois.readObject();
+
+            /* Implementation note: The result of ObjectInputStream.readObject()
+            * may have been null at this point (its a valid value to deserialize)
+            * and we explicitly want to try instantiation in such a case
+            * (this is important for compatibility).
+            */
+        }
+
+        // Instantiates the Bean using reflective instantiation if it has not been created yet.
+        if (bean == null)
+        {
+            // Makes sure that the deserialization was NOT done.
+            beanLocation = null;
+
+            Class beanClass;
+            if (cl == null)
+            {
+                beanClass = Class.forName(beanName);
+                classLocation =
+                    ClassLoader.getSystemResource(resourceName + ".class");
+            }
+            else
+            {
+                beanClass = cl.loadClass(beanName);
+                classLocation = cl.getResource(resourceName + ".class");
+            }
+
+            // Instantiates and optionally registers the new bean.
+            try
+            {
+                bean = beanClass.newInstance();
+            }
+            catch(Exception e) {
+		/* Wraps all kinds of Exceptions in a ClassNotFoundException (this behavior
+		 * matches with official >= 1.5, this was different for <=1.4)
+		 */
+		throw new ClassNotFoundException(null, e);
+            }
+        }
+
+        /* Applet beans are treated in the following way:
+         * - all AppletS get a default AppletStub
+         * - all AppletS are initialized using the AppletInitializer instance (if it is available)
+         * - as every other Bean Applets are added to a BeanContext if one is available
+         * - each instantiated Applet is initialized using Applet.init() (this is not done for deserialized ones)
+         * - finally AppletS get activated using the AppletInitializerS activate-Method
+         * 
+         * The order of operations is important for compatibility.    
+         */
+        Applet applet = null;
+        if (bean instanceof Applet)
+        {
+            // Makes a second instanceof call unneccessary (instanceof is expensive).
+            applet = (Applet) bean;
+
+            /* The AppletStub's code and document base is set as follows:
+             * The code base is always the URL from where the class data originated
+             * (without the package name).
+             * If the Applet was deserialized the document base is the location of
+             * the serialized instance (usually the ".ser" file) otherwise its the URL
+             * from where the class data originated (usually the absolute directory
+             * location of the ".class" file).
+             */
+            applet.setStub(
+                new DummyAppletStub(
+                    applet
+                        .getClass()
+                        .getProtectionDomain()
+                        .getCodeSource()
+                        .getLocation(),
+                    (beanLocation == null) ? classLocation : beanLocation));
+
+            // Runs the Applet's initialization using an AppletInitializer.
+            if (initializer != null)
+            {
+                initializer.initialize(applet, beanContext);
+            }
+        }
+
+        // Adds the new bean to its BeanContext.
+        if (beanContext != null)
+        {
+            beanContext.add(bean);
+        }
+
+        if (applet != null)
+        {
+
+            // Initializes an instantiated (not deserialized) Applet using its own method.
+            if (beanLocation == null)
+            {
+                applet.init();
+            }
+
+            // Runs the Applet's activation using an AppletInitializer.
+            if (initializer != null)
+            {
+                initializer.activate(applet);
+            }
+        }
+
+        return bean;
+   }
+
+   /**
+    * Returns the Bean as a different class type.
+    * This should be used instead of casting to get a new
+    * type view of a Bean, because in the future there may
+    * be new types of Bean, even Beans spanning multiple
+    * Objects.
+    *
+    * @param bean the Bean to cast.
+    * @param newClass the Class to cast it to.
+    *
+    * @return the Bean as a new view, or if the operation
+    *         could not be performed, the Bean itself.
+    */
+   public static Object getInstanceOf(Object bean, Class newClass)
+   {
+        return bean;
+   }
+
+   /**
+    * Determines whether the Bean can be cast to a different
+    * class type.
+    * This should be used instead of instanceof to determine
+    * a Bean's castability, because in the future there may
+    * be new types of Bean, even Beans spanning multiple
+    * Objects.
+    *
+    * @param bean the Bean to cast.
+    * @param newClass the Class to cast it to.
+    *
+    * @return whether the Bean can be cast to the class type
+    *         in question.
+    */
+   public static boolean isInstanceOf(Object bean, Class newBeanClass)
+   {
+       return newBeanClass.isInstance(bean);
+   }
+
+   /**
+    * Returns whether the GUI is available to use.
+    * <p>Defaults to true.</p>
+    *
+    * @return whether the GUI is available to use.
+    */
+   public static boolean isGuiAvailable()
+   {
+       return guiAvailable;
+   }
+
+   /**
+    * Returns whether it is design time.  Design time means
+    * we are in a RAD tool.
+    * <p>Defaults to false.</p>
+    *
+    * @return whether it is design time.
+    */
+   public static boolean isDesignTime()
+   {
+       return designTime;
+   }
+
+   /**
+    * Sets whether the GUI is available to use.
+    * 
+    * @param guiAvailable whether the GUI is available to use.
+    */
+   public static void setGuiAvailable(boolean guiAvailable)
+       throws SecurityException
+   {
+        Beans.guiAvailable = guiAvailable;
+   }
+
+   /**
+    * Sets whether it is design time.  Design time means we
+    * are in a RAD tool.
+    *
+    * @param designTime whether it is design time.
+    */
+   public static void setDesignTime(boolean designTime)
+       throws SecurityException
+   {
+       Beans.designTime = designTime;
+   }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Customizer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Customizer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Customizer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Customizer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,86 @@
+/* java.beans.Customizer
+   Copyright (C) 1998 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+/**
+ ** You may explicitly provide a Customizer for your Bean
+ ** class, which allows you complete control of the editing
+ ** of the Bean.<P>
+ **
+ ** A Customizer is meant to be embedded in an RAD tool,
+ ** and thus must be a descendant of <CODE>java.awt.Component</CODE>.<P>
+ **
+ ** It must also have a constructor with no arguments.  This
+ ** is the constructor that will be called by the RAD tool to
+ ** instantiate the Customizer.<P>
+ **
+ ** Over its lifetime, an instance of a Customizer will only
+ ** customize one single Bean.  A new instance of the
+ ** Customizer will be instantiated to edit any other Beans.<P>
+ **
+ ** The Customizer is responsible for notifying its
+ ** PropertyChangeListeners of any changes that are made,
+ ** according to the rules of PropertyChangeListeners (i.e.
+ ** notify the clients <EM>after</EM> the property has
+ ** changed).
+ **
+ ** @author John Keiser
+ ** @since JDK1.1
+ ** @version 1.1.0, 29 Jul 1998
+ ** @see java.beans.BeanDescriptor.getCustomizerClass()
+ **/
+
+public interface Customizer {
+	/** Set the object to Customize.  This will always be a
+	 ** Bean that had a BeanDescriptor indicating this
+	 ** Customizer.
+	 ** @param bean the Bean to customize.
+	 **/
+	void setObject(Object bean);
+
+	/** Add a PropertyChangeListener.
+	 ** @param l the PropertyChangeListener to add.
+	 **/
+	void addPropertyChangeListener(PropertyChangeListener l);
+
+	/** Remove a PropertyChangeListener.
+	 ** @param l the PropertyChangeListener to remove.
+	 **/
+	void removePropertyChangeListener(PropertyChangeListener l);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/DefaultPersistenceDelegate.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/DefaultPersistenceDelegate.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/DefaultPersistenceDelegate.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/DefaultPersistenceDelegate.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,211 @@
+/* DefaultPersistenceDelegate.java
+ Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.beans;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/** <p><code>DefaultPersistenceDelegate</code> is a {@link PersistenceDelegate}
+ * implementation that can be used to serialize objects which adhere to the
+ * Java Beans naming convention.</p>
+ * 
+ * @author Robert Schuster (robertschuster at fsfe.org)
+ * @since 1.4
+ */
+public class DefaultPersistenceDelegate extends PersistenceDelegate
+{
+
+  private String[] constructorPropertyNames;
+
+  /** Using this constructor the object to be serialized will be instantiated
+   * with the default non-argument constructor.
+   */
+  public DefaultPersistenceDelegate()
+  {
+  }
+
+  /** This constructor allows to specify which Bean properties appear
+   * in the constructor.
+   * 
+   * <p>The implementation reads the mentioned properties from the Bean
+   * instance and applies it in the given order to a corresponding
+   * constructor.</p>
+   * 
+   * @param constructorPropertyNames The properties the Bean's constructor
+   * should be given to.
+   */
+  public DefaultPersistenceDelegate(String[] constructorPropertyNames)
+  {
+    this.constructorPropertyNames = constructorPropertyNames;
+  }
+
+  protected boolean mutatesTo(Object oldInstance, Object newInstance)
+  {
+    try
+      {
+
+        return (constructorPropertyNames != null
+               && constructorPropertyNames.length > 0
+               && oldInstance.getClass()
+               .getDeclaredMethod("equals",
+                                  new Class[] { Object.class }) != null)
+                                  ? oldInstance.equals(newInstance)
+                                  : super.mutatesTo(oldInstance, newInstance);
+      }
+    catch (NoSuchMethodException nsme)
+      {
+        return super.mutatesTo(oldInstance, newInstance);
+      }
+  }
+
+  protected Expression instantiate(Object oldInstance, Encoder out)
+  {
+    Object[] args = null;
+
+    try
+      {
+        // If there are property names in the array, then we create
+        // a corresponding argument array and store every
+        // argument in it. To retrieve an argument object we have
+        // dig up the right property in the bean class' BeanInfo
+        // object.
+        // This is so costly in terms of execution time I better
+        // not think twice about it ...
+        if (constructorPropertyNames != null)
+          {
+            args = new Object[constructorPropertyNames.length];
+
+            // Look up the properties of oldInstance's class to find matches for
+            // the
+            // names given in the constructor.
+            PropertyDescriptor[] propertyDescs = Introspector.getBeanInfo(
+                                                                          oldInstance.getClass()).getPropertyDescriptors();
+
+            for (int i = 0; i < constructorPropertyNames.length; i++)
+              {
+                // Scan the property descriptions for a matching name.
+                for (int j = 0; j < propertyDescs.length; j++)
+                  {
+                    if (propertyDescs[i].getName().equals(
+                                                          constructorPropertyNames[i]))
+                      {
+                        Method readMethod = propertyDescs[i].getReadMethod();
+
+                        args[i] = readMethod.invoke(oldInstance, null);
+                      }
+                  }
+              }
+          }
+
+      }
+    catch (IllegalAccessException iae)
+      {
+        out.getExceptionListener().exceptionThrown(iae);
+      }
+    catch (IllegalArgumentException iarge)
+      {
+        out.getExceptionListener().exceptionThrown(iarge);
+      }
+    catch (InvocationTargetException ite)
+      {
+        out.getExceptionListener().exceptionThrown(ite);
+      }
+    catch (IntrospectionException ie)
+      {
+        out.getExceptionListener().exceptionThrown(ie);
+      }
+
+    return new Expression(oldInstance, oldInstance.getClass(), "new", args);
+  }
+
+  protected void initialize(Class type, Object oldInstance, Object newInstance,
+                            Encoder out)
+  {
+    // Calling the supertype's implementation of initialize makes it
+    // possible that descendants of classes like AbstractHashMap
+    // or Hashtable are serialized correctly. This mechanism grounds on
+    // two other facts:
+    // * Each class which has not registered a special purpose
+    //   PersistenceDelegate is handled by a DefaultPersistenceDelegate
+    //   instance.
+    // * PersistenceDelegate.initialize() is implemented in a way that it
+    //   calls the initialize method of the superclass' persistence delegate.
+    super.initialize(type, oldInstance, newInstance, out);
+    
+    // Suppresses the writing of property setting statements when this delegate
+    // is not used for the exact instance type. By doing so the following code
+    // is called only once per object.
+    if (type != oldInstance.getClass())
+      return;
+    
+    try
+      {
+        PropertyDescriptor[] propertyDescs = Introspector.getBeanInfo(
+                                                                      oldInstance.getClass()).getPropertyDescriptors();
+
+        for (int i = 0; i < propertyDescs.length; i++)
+          {
+            Method readMethod = propertyDescs[i].getReadMethod();
+            Method writeMethod = propertyDescs[i].getWriteMethod();
+
+            if (readMethod != null && writeMethod != null)
+              {
+                Object oldValue = readMethod.invoke(oldInstance, null);
+
+                if (oldValue != null)
+                  out.writeStatement(new Statement(oldInstance,
+                                                   writeMethod.getName(),
+                                                   new Object[] { oldValue }));
+              }
+          }
+      }
+    catch (IntrospectionException ie)
+      {
+        out.getExceptionListener().exceptionThrown(ie);
+      }
+    catch (IllegalAccessException iae)
+      {
+        out.getExceptionListener().exceptionThrown(iae);
+      }
+    catch (InvocationTargetException ite)
+      {
+        out.getExceptionListener().exceptionThrown(ite);
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/DesignMode.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/DesignMode.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/DesignMode.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/DesignMode.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,93 @@
+/* java.beans.DesignMode
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+/**
+ * <code>BeanContextChild</code> implementors implement this to get information about whether they are in a design time or runtime environment.
+ * The reason this is restricted to <code>BeanContextChild</code>ren is that
+ * only things in the <code>BeanContext</code> hierarchy are given this
+ * information in the first place.
+ *
+ * @author John Keiser
+ * @since JDK1.2
+ * @see java.beans.beancontext.BeanContextChild
+ */
+
+public interface DesignMode {
+	/**
+	 * Use this name when firing <code>PropertyChangeEvent</code>s from your Bean.  
+	 * @fixme Check whether PROPERTYNAME is set to same value as Sun.
+	 */
+	String PROPERTYNAME = "designTime";
+
+	/**
+	 * The environment will call this method on your
+	 * <code>BeanContextChild</code> when it is registered in a parent
+	 * <code>BeanContext</code> or when behavior needs to switch from
+	 * design time to runtime behavior (or vice versa).
+	 * <P>
+	 *
+	 * <code>BeanContext</code>s are required to fire
+	 * <code>PropertyChangeEvent</code>s when properties change.
+	 * <code>designTime</code> is a property, and therefore when you
+	 * implement <code>setDesignTime()</code>, you need to fire a
+	 * <code>PropertyChangeEvent</code> with the old value, the new
+	 * value and using <code>PROPERTYNAME</code> as the property name.
+	 *
+	 * @param designTime the new value of design time,
+	 *        <code>true</code> if it is design time,
+	 *        <code>false</code> if it is runtime.
+	 *
+	 * @fixme I'm frankly not really sure whether it's the case that
+	 *        the BeanContext can <em>change</em> the status of the Bean from
+	 *        design time to runtime.  But it appears that it may be so.
+	 *
+	 * @see java.util.PropertyChangeEvent
+	 * @see java.beans.beancontext.BeanContext
+	 * @see #PROPERTYNAME
+	 */
+	void setDesignTime(boolean designTime);
+
+	/**
+	 * This method should tell whether it is design time or runtime.
+	 * @return <code>true</code> if design time, <code>false</code> if
+	 *         runtime.
+	 */
+	boolean isDesignTime();
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Encoder.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Encoder.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Encoder.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Encoder.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,432 @@
+/* Encoder.java
+ Copyright (C) 2005, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.beans;
+
+import gnu.java.beans.DefaultExceptionListener;
+import gnu.java.beans.encoder.ArrayPersistenceDelegate;
+import gnu.java.beans.encoder.ClassPersistenceDelegate;
+import gnu.java.beans.encoder.CollectionPersistenceDelegate;
+import gnu.java.beans.encoder.MapPersistenceDelegate;
+import gnu.java.beans.encoder.PrimitivePersistenceDelegate;
+
+import java.util.AbstractCollection;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+
+/**
+ * @author Robert Schuster (robertschuster at fsfe.org)
+ * @since 1.4
+ */
+public class Encoder
+{
+
+  /**
+   * An internal DefaultPersistenceDelegate instance that is used for every
+   * class that does not a have a special special PersistenceDelegate.
+   */
+  private static PersistenceDelegate defaultPersistenceDelegate;
+
+  private static PersistenceDelegate fakePersistenceDelegate;
+
+  /**
+   * Stores the relation Class->PersistenceDelegate.
+   */
+  private static HashMap delegates = new HashMap();
+
+  /**
+   * Stores the relation oldInstance->newInstance
+   */
+  private IdentityHashMap candidates = new IdentityHashMap();
+
+  private ExceptionListener exceptionListener;
+
+  /**
+   * A simple number that is used to restrict the access to writeExpression and
+   * writeStatement. The rule is that both methods should only be used when an
+   * object is written to the stream (= writeObject). Therefore accessCounter is
+   * incremented just before the call to writeObject and decremented afterwards.
+   * Then writeStatement and writeExpression allow execution only if
+   * accessCounter is bigger than zero.
+   */
+  private int accessCounter = 0;
+
+  public Encoder()
+  {
+    setupDefaultPersistenceDelegates();
+
+    setExceptionListener(null);
+  }
+
+  /**
+   * Sets up a bunch of {@link PersistenceDelegate} instances which are needed
+   * for the basic working of a {@link Encoder}s.
+   */
+  private static void setupDefaultPersistenceDelegates()
+  {
+    synchronized (delegates)
+      {
+        if (defaultPersistenceDelegate != null)
+          return;
+
+        delegates.put(Class.class, new ClassPersistenceDelegate());
+
+        PersistenceDelegate pd = new PrimitivePersistenceDelegate();
+        delegates.put(Boolean.class, pd);
+        delegates.put(Byte.class, pd);
+        delegates.put(Short.class, pd);
+        delegates.put(Integer.class, pd);
+        delegates.put(Long.class, pd);
+        delegates.put(Float.class, pd);
+        delegates.put(Double.class, pd);
+
+        delegates.put(Object[].class, new ArrayPersistenceDelegate());
+
+        pd = new CollectionPersistenceDelegate();
+        delegates.put(AbstractCollection.class, pd);
+        
+        pd = new MapPersistenceDelegate();
+        delegates.put(java.util.AbstractMap.class, pd);
+        delegates.put(java.util.Hashtable.class, pd);
+        
+        defaultPersistenceDelegate = new DefaultPersistenceDelegate();
+        delegates.put(Object.class, defaultPersistenceDelegate);
+
+        // Creates a PersistenceDelegate implementation which is
+        // returned for 'null'. In practice this instance is
+        // not used in any way and is just here to be compatible
+        // with the reference implementation which returns a
+        // similar instance when calling getPersistenceDelegate(null) .
+        fakePersistenceDelegate = new PersistenceDelegate()
+        {
+          protected Expression instantiate(Object o, Encoder e)
+          {
+            return null;
+          }
+        };
+
+      }
+  }
+
+  protected void writeObject(Object o)
+  {
+    // 'null' has no PersistenceDelegate and will not
+    // create an Expression which has to be cloned.
+    // However subclasses should be aware that writeObject
+    // may be called with a 'null' argument and should
+    // write the proper representation of it.
+    if (o == null)
+      return;
+
+    PersistenceDelegate pd = getPersistenceDelegate(o.getClass());
+
+    accessCounter++;
+    pd.writeObject(o, this);
+    accessCounter--;
+    
+  }
+
+  /**
+   * Sets the {@link ExceptionListener} instance to be used for reporting
+   * recorable exceptions in the instantiation and initialization sequence. If
+   * the argument is <code>null</code> a default instance will be used that
+   * prints the thrown exception to <code>System.err</code>.
+   */
+  public void setExceptionListener(ExceptionListener listener)
+  {
+    exceptionListener = (listener != null) 
+	? listener : DefaultExceptionListener.INSTANCE;
+  }
+
+  /**
+   * Returns the currently active {@link ExceptionListener} instance.
+   */
+  public ExceptionListener getExceptionListener()
+  {
+    return exceptionListener;
+  }
+
+  public PersistenceDelegate getPersistenceDelegate(Class type)
+  {
+    // This is not specified but the JDK behaves like this.
+    if (type == null)
+      return fakePersistenceDelegate;
+
+    // Treats all array classes in the same way and assigns
+    // them a shared PersistenceDelegate implementation tailored
+    // for array instantation and initialization.
+    if (type.isArray())
+      return (PersistenceDelegate) delegates.get(Object[].class);
+
+    PersistenceDelegate pd = (PersistenceDelegate) delegates.get(type);
+
+    return (pd != null) ? pd : (PersistenceDelegate) defaultPersistenceDelegate;
+  }
+
+  /**
+   * Sets the {@link PersistenceDelegate} instance for the given class.
+   * <p>
+   * Note: Throws a <code>NullPointerException</code> if the argument is
+   * <code>null</code>.
+   * </p>
+   * <p>
+   * Note: Silently ignores PersistenceDelegates for Array types and primitive
+   * wrapper classes.
+   * </p>
+   * <p>
+   * Note: Although this method is not declared <code>static</code> changes to
+   * the {@link PersistenceDelegate}s affect <strong>all</strong>
+   * {@link Encoder} instances. <strong>In this implementation</strong> the
+   * access is thread safe.
+   * </p>
+   */
+  public void setPersistenceDelegate(Class type, PersistenceDelegate delegate)
+  {
+    // If the argument is null this will cause a NullPointerException
+    // which is expected behavior.
+
+    // This makes custom PDs for array, primitive types and their wrappers
+    // impossible but this is how the JDK behaves.
+    if (type.isArray() || type.isPrimitive() || type == Boolean.class
+        || type == Byte.class || type == Short.class || type == Integer.class
+        || type == Long.class || type == Float.class || type == Double.class)
+      return;
+
+    synchronized (delegates)
+      {
+        delegates.put(type, delegate);
+      }
+
+  }
+
+  public Object remove(Object oldInstance)
+  {
+    return candidates.remove(oldInstance);
+  }
+
+  /**
+   * Returns the replacement object which has been created by the encoder during
+   * the instantiation sequence or <code>null</code> if the object has not
+   * been processed yet.
+   * <p>
+   * Note: The <code>String</code> class acts as an endpoint for the
+   * inherently recursive algorithm of the {@link Encoder}. Therefore instances
+   * of <code>String</code> will always be returned by this method. In other
+   * words the assertion: <code>
+   * assert (anyEncoder.get(anyString) == anyString)
+   * </code<
+   * will always hold.</p>
+   *
+   * <p>Note: If <code>null</code> is requested, the result will
+   * always be <code>null</code>.</p>
+   */
+  public Object get(Object oldInstance)
+  {
+    // String instances are handled in a special way.
+    // No one knows why this is not officially specified
+    // because this is a rather important design decision.
+    return (oldInstance == null) ? null : 
+             (oldInstance.getClass() == String.class) ?
+               oldInstance : candidates.get(oldInstance);
+  }
+
+  /**
+   * <p>
+   * Note: If you call this method not from within an object instantiation and
+   * initialization sequence it will be silently ignored.
+   * </p>
+   */
+  public void writeStatement(Statement stmt)
+  {
+    // Silently ignore out of bounds calls.
+    if (accessCounter <= 0)
+      return;
+
+    Object target = stmt.getTarget();
+
+    Object newTarget = get(target);
+    if (newTarget == null)
+      {
+        writeObject(target);
+        newTarget = get(target);
+      }
+
+    Object[] args = stmt.getArguments();
+    Object[] newArgs = new Object[args.length];
+
+    for (int i = 0; i < args.length; i++)
+      {
+        newArgs[i] = get(args[i]);
+        if (newArgs[i] == null || isImmutableType(args[i].getClass()))
+          {
+            writeObject(args[i]);
+            newArgs[i] = get(args[i]);
+          }
+      }
+
+    Statement newStmt = new Statement(newTarget, stmt.getMethodName(), newArgs);
+
+    try
+      {
+        newStmt.execute();
+      }
+    catch (Exception e)
+      {
+        exceptionListener.exceptionThrown(e);
+      }
+
+  }
+
+  /**
+   * <p>
+   * Note: If you call this method not from within an object instantiation and
+   * initialization sequence it will be silently ignored.
+   * </p>
+   */
+  public void writeExpression(Expression expr)
+  {
+    // Silently ignore out of bounds calls.
+    if (accessCounter <= 0)
+      return;
+
+    Object target = expr.getTarget();
+    Object value = null;
+    Object newValue = null;
+
+    try
+      {
+        value = expr.getValue();
+      }
+    catch (Exception e)
+      {
+        exceptionListener.exceptionThrown(e);
+        return;
+      }
+    
+    
+    newValue = get(value);
+
+    if (newValue == null)
+      {
+        Object newTarget = get(target);
+        if (newTarget == null)
+          {
+            writeObject(target);
+            newTarget = get(target);
+
+            // May happen if exception was thrown.
+            if (newTarget == null)
+              {
+                return;
+              }
+          }
+
+        Object[] args = expr.getArguments();
+        Object[] newArgs = new Object[args.length];
+
+        for (int i = 0; i < args.length; i++)
+          {
+            newArgs[i] = get(args[i]);
+            if (newArgs[i] == null || isImmutableType(args[i].getClass()))
+              {
+                writeObject(args[i]);
+                newArgs[i] = get(args[i]);
+              }
+          }
+        
+        Expression newExpr = new Expression(newTarget, expr.getMethodName(),
+                                            newArgs);
+        
+        // Fakes the result of Class.forName(<primitiveType>) to make it possible
+        // to hand such a type to the encoding process.
+        if (value instanceof Class && ((Class) value).isPrimitive())
+          newExpr.setValue(value);
+        
+        // Instantiates the new object.
+        try
+          {
+            newValue = newExpr.getValue();
+
+            candidates.put(value, newValue);
+          }
+        catch (Exception e)
+          {
+            exceptionListener.exceptionThrown(e);
+            
+            return;
+          }
+        
+        writeObject(value);
+
+      }
+    else if(value.getClass() == String.class || value.getClass() == Class.class)
+      {
+        writeObject(value);
+      }
+
+  }
+
+  /** Returns whether the given class is an immutable
+   * type which has to be handled differently when serializing it.
+   * 
+   * <p>Immutable objects always have to be instantiated instead of
+   * modifying an existing instance.</p>
+   * 
+   * @param type The class to test.
+   * @return Whether the first argument is an immutable type.
+   */
+  boolean isImmutableType(Class type)
+  {
+    return type == String.class || type == Class.class
+      || type == Integer.class || type == Boolean.class
+      || type == Byte.class || type == Short.class
+      || type == Long.class || type == Float.class
+      || type == Double.class;
+  }
+  
+  /** Sets the stream candidate for a given object.
+   * 
+   * @param oldObject The object given to the encoder.
+   * @param newObject The object the encoder generated.
+   */
+  void putCandidate(Object oldObject, Object newObject)
+  {
+    candidates.put(oldObject, newObject);
+  }
+  
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/EventHandler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/EventHandler.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/EventHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/EventHandler.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,606 @@
+/* java.beans.EventHandler
+   Copyright (C) 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+/**
+ * <p>EventHandler forms a bridge between dynamically created listeners and
+ * arbitrary properties and methods.</p>
+ * 
+ * <p>You can use this class to easily create listener implementations for
+ * some basic interactions between an event source and its target. Using
+ * the three static methods named <code>create</code> you can create
+ * these listener implementations.</p>
+ * 
+ * <p>See the documentation of each method for usage examples.</p>
+ *  
+ * @author Jerry Quinn (jlquinn at optonline.net)
+ * @author Robert Schuster (thebohemian at gmx.net)
+ * @since 1.4
+ */
+public class EventHandler implements InvocationHandler
+{
+  // The name of the method that will be implemented.  If null, any method.
+  private String listenerMethod;
+
+  // The object to call action on.
+  private Object target;
+
+  // The name of the method or property setter in target.
+  private String action;
+
+  // The property to extract from an event passed to listenerMethod.
+  private String property;
+
+  // The target objects Class.
+  private Class targetClass;
+  
+  // String class doesn't already have a capitalize routine.
+  private String capitalize(String s)
+  {
+    return s.substring(0, 1).toUpperCase() + s.substring(1);
+  }
+
+  /**
+   * Creates a new <code>EventHandler</code> instance.
+   *
+   * <p>Typical creation is done with the create method, not by knewing an
+   * EventHandler.</p>
+   *
+   * <p>This constructs an EventHandler that will connect the method
+   * listenerMethodName to target.action, extracting eventPropertyName from
+   * the first argument of listenerMethodName. and sending it to action.</p>
+   * 
+   * <p>Throws a <code>NullPointerException</code> if the <code>target</code>
+   * argument is <code>null</code>. 
+   *
+   * @param target Object that will perform the action.
+   * @param action A property or method of the target.
+   * @param eventPropertyName A readable property of the inbound event.
+   * @param listenerMethodName The listener method name triggering the action.
+   */
+  public EventHandler(Object target, String action, String eventPropertyName,
+		      String listenerMethodName)
+  {
+    this.target = target;
+    
+    // Retrieving the class is done for two reasons:
+    // 1) The class object is needed very frequently in the invoke() method.
+    // 2) The constructor should throw a NullPointerException if target is null.
+    targetClass = target.getClass();
+    
+    this.action = action;	// Turn this into a method or do we wait till
+    		// runtime
+    property = eventPropertyName;
+    listenerMethod = listenerMethodName;
+  }
+
+  /**
+   * Returns the event property name.
+   */
+  public String getEventPropertyName()
+  {
+    return property;
+  }
+
+  /**
+   * Returns the listener's method name.
+   */
+  public String getListenerMethodName()
+  {
+    return listenerMethod;
+  }
+
+  /**
+   * Returns the target object.
+   */
+  public Object getTarget()
+  {
+    return target;
+  }
+
+  /**
+   * Returns the action method name.
+   */
+  public String getAction()
+  {
+    return action;
+  }
+
+  // Fetch a qualified property like a.b.c from object o.  The properties can
+  // be boolean isProp or object getProp properties.
+  //
+  // Returns a length 2 array with the first entry containing the value
+  // extracted from the property, and the second entry contains the class of
+  // the method return type.
+  //
+  // We play this game because if the method returns a native type, the return
+  // value will be a wrapper.  If we then take the type of the wrapper and use
+  // it to locate the action method that takes the native type, it won't match.
+  private Object[] getProperty(Object o, String prop)
+  {
+    // Isolate the first property name from a.b.c.
+    int pos;
+    String rest = null;
+    if ((pos = prop.indexOf('.')) != -1)
+      {
+	rest = prop.substring(pos + 1);
+	prop = prop.substring(0, pos);
+      }
+
+    // Find a method named getProp.  It could be isProp instead.
+    Method getter;
+    try
+      {
+	// Look for boolean property getter isProperty
+	getter = o.getClass().getMethod("is" + capitalize(prop),
+						 null);
+      }
+    catch (NoSuchMethodException nsme1)
+      {
+        try {
+          // Look for regular property getter getProperty
+          getter = o.getClass().getMethod("get" + capitalize(prop),
+						 null);
+        } catch(NoSuchMethodException nsme2) {
+            try {
+            // Finally look for a method of the name prop
+            getter = o.getClass().getMethod(prop, null);
+            } catch(NoSuchMethodException nsme3) {
+                // Ok, give up with an intelligent hint for the user.
+                throw new RuntimeException("Method not called: Could not find a property or method '" + prop
+                        + "' in " + o.getClass() + " while following the property argument '" + property + "'.");
+            }
+        }
+      }
+    try {
+      Object val = getter.invoke(o, null);
+
+      if (rest != null)
+        return getProperty(val, rest);
+
+      return new Object[] {val, getter.getReturnType()};
+    } catch(InvocationTargetException ite) {
+        throw new RuntimeException("Method not called: Property or method '" + prop + "' has thrown an exception.", ite);
+    } catch(IllegalAccessException iae) {
+        // This cannot happen because we looked up method with Class.getMethod()
+        // which returns public methods only.
+        throw (InternalError) new InternalError("Non-public method was invoked.").initCause(iae);
+    }
+  }
+
+  /**
+   * Invokes the <code>EventHandler</code>.
+   * 
+   * <p>This method is normally called by the listener's proxy implementation.</p>
+   * 
+   * @param proxy The listener interface that is implemented using
+   * the proxy mechanism.
+   * @param method The method that was called on the proxy instance.
+   * @param arguments The arguments which where given to the method.
+   * @throws Throwable <code>NoSuchMethodException</code> is thrown when the EventHandler's
+   * action method or property cannot be found.
+   */
+  public Object invoke(Object proxy, Method method, Object[] arguments)
+  {
+      try {
+      // The method instance of the target object. We have to find out which
+      // one we have to invoke.
+      Method actionMethod = null;
+
+    // Listener methods that weren't specified are ignored.  If listenerMethod
+    // is null, then all listener methods are processed.
+    if (listenerMethod != null && !method.getName().equals(listenerMethod))
+      return null;
+
+    // If a property is defined we definitely need a valid object at
+    // arguments[0] that can be used to retrieve a value to which the
+    // property of the target gets set.
+    if(property != null) {
+      // Extracts the argument. We will let it fail with a NullPointerException
+      // the caller used a listener method that has no arguments.
+      Object event = arguments[0];
+
+      // Obtains the property XXX propertyType keeps showing up null - why?
+      // because the object inside getProperty changes, but the ref variable
+      // can't change this way, dolt!  need a better way to get both values out
+      // - need method and object to do the invoke and get return type
+      Object v[] = getProperty(event, property);
+      Object[] args = new Object[] { v[0] };
+      
+      // Changes the class array that controls which method signature we are going
+      // to look up in the target object.
+      Class[] argTypes = new Class[] { initClass((Class) v[1]) };
+    
+      // Tries to  find a setter method to which we can apply the
+      while(argTypes[0] != null) {
+      try
+      {
+        // Look for a property setter for action.
+        actionMethod = targetClass.getMethod("set" + capitalize(action), argTypes);
+
+        return actionMethod.invoke(target, args);
+      }
+    catch (NoSuchMethodException e)
+      {
+        // If action as property didn't work, try as method later.
+      }
+    
+      argTypes[0] = nextClass(argTypes[0]);
+      }
+      
+      // We could not find a suitable setter method. Now we try again interpreting
+      // action as the method name itself.
+      // Since we probably have changed the block local argTypes array 
+      // we need to rebuild it.
+      argTypes = new Class[] { initClass((Class) v[1]) };
+    
+      // Tries to  find a setter method to which we can apply the
+      while(argTypes[0] != null) {
+        try
+        {
+          actionMethod = targetClass.getMethod(action, argTypes);
+
+          return actionMethod.invoke(target, args);
+        }
+        catch (NoSuchMethodException e)
+        {
+        }
+        
+        argTypes[0] = nextClass(argTypes[0]);
+      }
+        
+        throw new RuntimeException("Method not called: Could not find a public method named '"
+                + action + "' in target " + targetClass + " which takes a '"
+                + v[1] + "' argument or a property of this type.");
+      }      
+  
+    // If property was null we will search for a no-argument method here.
+    // Note: The ordering of method lookups is important because we want to prefer no-argument
+    // calls like the JDK does. This means if we have actionMethod() and actionMethod(Event) we will
+    // call the first *EVEN* if we have a valid argument for the second method. This is behavior compliant
+    // to the JDK.
+    // If actionMethod() is not available but there is a actionMethod(Event) we take this. That makes us
+    // more specification compliant than the JDK itself because this one will fail in such a case.
+    try
+      {
+      actionMethod = targetClass.getMethod(action, null);
+      }
+    catch(NoSuchMethodException nsme)
+      {
+        // Note: If we want to be really strict the specification says that a no-argument method should
+        // accept an EventObject (or subclass I guess). However since the official implementation is broken
+        // anyways, it's more flexible without the EventObject restriction and we are compatible on everything
+        // else this can stay this way.
+        if(arguments != null && arguments.length >= 1/* && arguments[0] instanceof EventObject*/) {
+            Class[] targetArgTypes = new Class[] { initClass(arguments[0].getClass()) };
+            
+            while(targetArgTypes[0] != null) {
+                try
+                {
+                  // If no property exists we expect the first element of the arguments to be
+                  // an EventObject which is then applied to the target method.
+      
+                  actionMethod = targetClass.getMethod(action, targetArgTypes);
+              
+                  return actionMethod.invoke(target, new Object[] { arguments[0] });
+                }
+                catch(NoSuchMethodException nsme2)
+                {
+                    
+                }
+                
+                targetArgTypes[0] = nextClass(targetArgTypes[0]);
+            }
+          
+        }
+      }
+
+    // If we do not have a Method instance at this point this means that all our tries
+    // failed. The JDK throws an ArrayIndexOutOfBoundsException in this case.
+    if(actionMethod == null)
+      throw new ArrayIndexOutOfBoundsException(0);
+    
+    // Invoke target.action(property)
+    return actionMethod.invoke(target, null);
+      } catch(InvocationTargetException ite) {
+         throw new RuntimeException(ite.getCause());
+      } catch(IllegalAccessException iae) {
+          // Cannot happen because we always use getMethod() which returns public
+          // methods only. Otherwise there is something seriously broken in
+          // GNU Classpath.
+          throw (InternalError) new InternalError("Non-public method was invoked.").initCause(iae);
+      }
+  }
+  
+  /**
+   * <p>Returns the primitive type for every wrapper class or the
+   * class itself if it is no wrapper class.</p>
+   * 
+   * <p>This is needed because to be able to find both kinds of methods:
+   * One that takes a wrapper class as the first argument and one that
+   * accepts a primitive instead.</p>
+   */
+  private Class initClass(Class klass) {
+   if(klass == Boolean.class) {
+    return Boolean.TYPE;    
+   } else if(klass == Byte.class) {
+    return Byte.TYPE;   
+   } else if(klass == Short.class) {
+    return Short.TYPE;   
+   } else if(klass == Integer.class) {
+    return Integer.TYPE;   
+   } else if(klass == Long.class) {
+    return Long.TYPE;   
+   } else if(klass == Float.class) {
+    return Float.TYPE;   
+   } else if(klass == Double.class) {
+    return Double.TYPE;   
+   } else {
+    return klass;   
+   }
+  }
+
+  /**
+   * 
+   * 
+   * @param klass
+   * @return
+   */
+  private Class nextClass(Class klass) {
+    if(klass == Boolean.TYPE) {
+    return Boolean.class;    
+   } else if(klass == Byte.TYPE) {
+    return Byte.class;   
+   } else if(klass == Short.TYPE) {
+    return Short.class;   
+   } else if(klass == Integer.TYPE) {
+    return Integer.class;   
+   } else if(klass == Long.TYPE) {
+    return Long.class;   
+   } else if(klass == Float.TYPE) {
+    return Float.class;   
+   } else if(klass == Double.TYPE) {
+    return Double.class;   
+   } else {
+    return klass.getSuperclass();
+   }
+   }
+  
+  /**
+   * <p>Constructs an implementation of <code>listenerInterface</code>
+   * to dispatch events.</p>
+   * 
+   * <p>You can use such an implementation to simply call a public
+   * no-argument method of an arbitrary target object or to forward
+   * the first argument of the listener method to the target method.</p>
+   * 
+   * <p>Call this method like:</p>
+   * <code>
+   * button.addActionListener((ActionListener)
+   *    EventHandler.create(ActionListener.class, target, "dispose"));
+   * </code>
+   * 
+   * <p>to achieve the following behavior:</p>
+   * <code>
+   * button.addActionListener(new ActionListener() {
+   *    public void actionPerformed(ActionEvent ae) {
+   *        target.dispose();
+   *    }
+   * });
+   * </code>
+   * 
+   * <p>That means if you need a listener implementation that simply calls a
+   * a no-argument method on a given instance for <strong>each</strong>
+   * method of the listener interface.</p>
+   * 
+   * <p>Note: The <code>action</code> is interpreted as a method name. If your target object
+   * has no no-argument method of the given name the EventHandler tries to find
+   * a method with the same name but which can accept the first argument of the
+   * listener method. Usually this will be an event object but any other object
+   * will be forwarded, too. Keep in mind that using a property name instead of a
+   * real method here is wrong and will throw an <code>ArrayIndexOutOfBoundsException</code>
+   * whenever one of the listener methods is called.<p/>
+   *
+   * <p>The <code>EventHandler</code> will automatically convert primitives
+   * to their wrapper class and vice versa. Furthermore it will call
+   * a target method if it accepts a superclass of the type of the
+   * first argument of the listener method.</p>
+   * 
+   * <p>In case that the method of the target object throws an exception
+   * it will be wrapped in a <code>RuntimeException</code> and thrown out
+   * of the listener method.</p>
+   * 
+   * <p>In case that the method of the target object cannot be found an
+   * <code>ArrayIndexOutOfBoundsException</code> will be thrown when the
+   * listener method is invoked.</p>
+   * 
+   * <p>A call to this method is equivalent to:
+   * <code>create(listenerInterface, target, action, null, null)</code></p>
+   *
+   * @param listenerInterface Listener interface to implement.
+   * @param target Object to invoke action on.
+   * @param action Target property or method to invoke.
+   * @return A constructed proxy object.
+   */
+  public static Object create(Class listenerInterface, Object target, String action)
+  {
+    return create(listenerInterface, target, action, null, null);
+  }
+
+  /**
+   * <p>Constructs an implementation of <code>listenerInterface</code>
+   * to dispatch events.</p>
+   *
+   * <p>Use this method if you want to create an implementation that retrieves
+   * a property value from the <b>first</b> argument of the listener method
+   * and applies it to the target's property or method. This first argument
+   * of the listener is usually an event object but any other object is
+   * valid, too.</p>
+   * 
+   * <p>You can set the value of <code>eventPropertyName</code> to "prop"
+   * to denote the retrieval of a property named "prop" from the event
+   * object. In case that no such property exists the <code>EventHandler</code>
+   * will try to find a method with that name.</p>
+   * 
+   * <p>If you set <code>eventPropertyName</code> to a value like this "a.b.c"
+   * <code>EventHandler</code> will recursively evaluate the properties "a", "b"
+   * and "c". Again if no property can be found the <code>EventHandler</code>
+   * tries a method name instead. This allows mixing the names, too: "a.toString"
+   * will retrieve the property "a" from the event object and will then call
+   * the method "toString" on it.</p>
+   * 
+   * <p>An exception thrown in any of these methods will provoke a
+   * <code>RuntimeException</code> to be thrown which contains an
+   * <code>InvocationTargetException</code> containing the triggering exception.</p>
+   * 
+   * <p>If you set <code>eventPropertyName</code> to a non-null value the
+   * <code>action</code> parameter will be interpreted as a property name
+   * or a method name of the target object.</p>
+   *   
+   * <p>Any object retrieved from the event object and applied to the
+   * target will converted from primitives to their wrapper class or
+   * vice versa or applied to a method that accepts a superclass
+   * of the object.</p>
+   *
+   * <p>Examples:</p>
+   * <p>The following code:</p><code>
+   * button.addActionListener(
+   *    new ActionListener() {
+   *        public void actionPerformed(ActionEvent ae) {
+   *            Object o = ae.getSource().getClass().getName();
+   *            textField.setText((String) o);
+   *        }
+   *    });
+   * </code>
+   * 
+   * <p>Can be expressed using the <code>EventHandler</code> like this:</p>
+   * <p>
+   * <code>button.addActionListener((ActionListener)
+   *    EventHandler.create(ActionListener.class, textField, "text", "source.class.name");
+   * <code>
+   * </p>
+   * 
+   * <p>As said above you can specify the target as a method, too:</p>
+   * <p>
+   * <code>button.addActionListener((ActionListener)
+   *    EventHandler.create(ActionListener.class, textField, "setText", "source.class.name");
+   * <code>
+   * </p>
+   * 
+   * <p>Furthermore you can use method names in the property:</p>
+   * <p>
+   * <code>button.addActionListener((ActionListener)
+   *    EventHandler.create(ActionListener.class, textField, "setText", "getSource.getClass.getName");
+   * <code>
+   * </p>
+   * 
+   * <p>Finally you can mix names:</p>
+   * <p>
+   * <code>button.addActionListener((ActionListener)
+   *    EventHandler.create(ActionListener.class, textField, "setText", "source.getClass.name");
+   * <code>
+   * </p>
+   * 
+   * <p>A call to this method is equivalent to:
+   * <code>create(listenerInterface, target, action, null, null)</code>
+   * </p>
+   *
+   * @param listenerInterface Listener interface to implement.
+   * @param target Object to invoke action on.
+   * @param action Target property or method to invoke.
+   * @param eventPropertyName Name of property to extract from event.
+   * @return A constructed proxy object.
+   */
+  public static Object create(Class listenerInterface, Object target,
+			      String action, String eventPropertyName)
+  {
+    return create(listenerInterface, target, action, eventPropertyName, null);
+  }
+
+  /**
+   * <p>Constructs an implementation of <code>listenerInterface</code>
+   * to dispatch events.</p>
+   *
+   * <p>Besides the functionality described for {@link create(Class, Object, String)}
+   * and {@link create(Class, Object, String, String)} this method allows you
+   * to filter the listener method that should have an effect. Look at these
+   * method's documentation for more information about the <code>EventHandler</code>'s
+   * usage.</p>
+   * 
+   * <p>If you want to call <code>dispose</code> on a <code>JFrame</code> instance
+   * when the <code>WindowListener.windowClosing()</code> method was invoked use
+   * the following code:</p>
+   * <p>
+   * <code>
+   * EventHandler.create(WindowListener.class, jframeInstance, "dispose", null, "windowClosing");
+   * </code>
+   * </p>
+   * 
+   * <p>A <code>NullPointerException</code> is thrown if the <code>listenerInterface</code>
+   * or <code>target</code> argument are <code>null</code>.
+   * 
+   * @param listenerInterface Listener interface to implement.
+   * @param target Object to invoke action on.
+   * @param action Target method name to invoke.
+   * @param eventPropertyName Name of property to extract from event.
+   * @param listenerMethodName Listener method to implement.
+   * @return A constructed proxy object.
+   */
+  public static Object create(Class listenerInterface, Object target,
+			      String action, String eventPropertyName,
+			      String listenerMethodName)
+  {
+    // Create EventHandler instance
+    EventHandler eh = new EventHandler(target, action, eventPropertyName,
+				       listenerMethodName);
+
+    // Create proxy object passing in the event handler
+    Object proxy = Proxy.newProxyInstance(listenerInterface.getClassLoader(),
+					  new Class[] {listenerInterface},
+					  eh);
+
+    return proxy;
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/EventSetDescriptor.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/EventSetDescriptor.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/EventSetDescriptor.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/EventSetDescriptor.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,763 @@
+/* java.beans.EventSetDescriptor
+ Copyright (C) 1998, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.beans;
+
+import gnu.java.lang.ClassHelper;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Vector;
+
+/**
+ * EventSetDescriptor describes the hookup between an event source class and
+ * an event listener class.
+ * 
+ * <p>EventSets have several attributes: the listener class,
+ * the events that can be fired to the listener (methods in the listener
+ * class), and an add and remove listener method from the event firer's
+ * class.
+ * </p>
+ * 
+ * <p>
+ * The methods have these constraints on them:
+ * <ul>
+ * <li>event firing methods: must have <code>void</code> return value. Any
+ * parameters and exceptions are allowed. May be public, protected or
+ * package-protected. (Don't ask me why that is, I'm just following the spec.
+ * The only place it is even mentioned is in the Java Beans white paper, and
+ * there it is only implied.)</li>
+ * 
+ * <li>add listener method: must have <code>void</code> return value. Must
+ * take exactly one argument, of the listener class's type. May fire either
+ * zero exceptions, or one exception of type
+ * <code>java.util.TooManyListenersException</code>.
+ * Must be public.</li>
+ * 
+ * <li>remove listener method: must have <code>void</code> return value. Must
+ * take exactly one argument, of the listener class's type. May not fire any
+ * exceptions. Must be public.</li>
+ * </ul>
+ * 
+ * <p>
+ * A final constraint is that event listener classes must extend from
+ * EventListener.
+ * </p>
+ * 
+ * <p>
+ * There are also various design patterns associated with some of the methods
+ * of construction. Those are explained in more detail in the appropriate
+ * constructors.
+ * </p>
+ * 
+ * <p>
+ * <strong>Documentation Convention:</strong> for proper Internalization of
+ * Beans inside an RAD tool, sometimes there are two names for a property or
+ * method: a programmatic, or locale-independent name, which can be used
+ * anywhere, and a localized, display name, for ease of use. In the
+ * documentation I will specify different String values as either
+ * <em>programmatic</em> or <em>localized</em> to make this distinction clear.
+ * 
+ * @author John Keiser
+ * @author Robert Schuster (robertschuster at fsfe.org)
+ * @since 1.1
+ */
+
+public class EventSetDescriptor extends FeatureDescriptor
+{
+  private Method addListenerMethod;
+
+  private Method removeListenerMethod;
+
+  private Class listenerType;
+
+  private MethodDescriptor[] listenerMethodDescriptors;
+
+  private Method[] listenerMethods;
+
+  private Method getListenerMethod;
+
+  private boolean unicast;
+
+  private boolean inDefaultEventSet = true;
+
+  /**
+   * Creates a new <code>EventSetDescriptor</code<.
+   * 
+   * <p>
+   * This version of the constructor enforces the rules imposed on the methods
+   * described at the top of this class, as well as searching for:
+   * </p>
+   * 
+   * <ol>
+   * <li>
+   * The event-firing method must be non-private with signature <code>void
+   * <listenerMethodName>(<eventSetName>Event)</code> (where
+   * <code><eventSetName></code> has its first character capitalized
+   * by the constructor and the Event is a descendant of
+   * {@link java.util.EventObject}) in class <code>listenerType</code>
+   * (any exceptions may be thrown). <b>Implementation note:</b> Note that
+   * there could conceivably be multiple methods with this type of signature
+   * (example: <code>java.util.MouseEvent</code> vs.
+   * <code>my.very.own.MouseEvent</code>). In this implementation, all
+   * methods fitting the description will be put into the
+   * <code>EventSetDescriptor</code>, even though the spec says only one
+   * should be chosen (they probably weren't thinking as pathologically as I
+   * was). I don't like arbitrarily choosing things. If your class has only one
+   * such signature, as most do, you'll have no problems.</li>
+   * 
+   * <li>The add and remove methods must be public and named <code>void
+   * add<eventSetName>Listener(<listenerType>)</code> and
+   * <code>void remove<eventSetName>Listener(<listenerType>)</code>
+   * in in class <code>eventSourceClass</code>, where
+   * <code><eventSetName></code> will have its first letter capitalized.
+   * Standard exception rules (see class description) apply.</li>
+   * </ol>
+   * 
+   * @param eventSourceClass
+   *          the class containing the add/remove listener methods.
+   * @param eventSetName
+   *          the programmatic name of the event set, generally starting with a
+   *          lowercase letter (i.e. fooManChu instead of FooManChu). This will
+   *          be used to generate the name of the event object as well as the
+   *          names of the add and remove methods.
+   * @param listenerType
+   *          the class containing the event firing method.
+   * @param listenerMethodName
+   *          the name of the event firing method.
+   * @exception IntrospectionException
+   *              if listenerType is not an EventListener, or if methods are not
+   *              found or are invalid.
+   */
+  public EventSetDescriptor(Class eventSourceClass, String eventSetName,
+                            Class listenerType, String listenerMethodName)
+      throws IntrospectionException
+  {
+    setName(eventSetName);
+    if (!java.util.EventListener.class.isAssignableFrom(listenerType))
+      {
+        throw new IntrospectionException(
+                  "Listener type is not an EventListener.");
+      }
+
+    String[] names = new String[1];
+    names[0] = listenerMethodName;
+
+    try
+      {
+        eventSetName = Character.toUpperCase(eventSetName.charAt(0))
+                       + eventSetName.substring(1);
+      }
+    catch (StringIndexOutOfBoundsException e)
+      {
+        eventSetName = "";
+      }
+
+    findMethods(eventSourceClass, listenerType, names,
+                "add" + eventSetName + "Listener",
+                "remove" + eventSetName + "Listener", eventSetName + "Event");
+    this.listenerType = listenerType;
+    checkAddListenerUnicast();
+    if (this.removeListenerMethod.getExceptionTypes().length > 0)
+      {
+        throw new IntrospectionException(
+                  "Listener remove method throws exceptions.");
+      }
+  }
+
+  /**
+   * Creates a new <code>EventSetDescriptor</code>.
+   * 
+   * <p>This form of the constructor allows you to specify the names of the
+   * methods and adds no new constraints on top of the rules already described
+   * at the top of the class.
+   * </p>
+   * 
+   * @param eventSourceClass
+   *          the class containing the add and remove listener methods.
+   * @param eventSetName
+   *          the programmatic name of the event set, generally starting with a
+   *          lowercase letter (i.e. fooManChu instead of FooManChu).
+   * @param listenerType
+   *          the class containing the event firing methods.
+   * @param listenerMethodNames
+   *          the names of the even firing methods.
+   * @param addListenerMethodName
+   *          the name of the add listener method.
+   * @param removeListenerMethodName
+   *          the name of the remove listener method.
+   * @exception IntrospectionException
+   *              if listenerType is not an EventListener or if methods are not
+   *              found or are invalid.
+   */
+  public EventSetDescriptor(Class eventSourceClass, String eventSetName,
+                            Class listenerType, String[] listenerMethodNames,
+                            String addListenerMethodName,
+                            String removeListenerMethodName)
+      throws IntrospectionException
+  {
+    setName(eventSetName);
+    if (!java.util.EventListener.class.isAssignableFrom(listenerType))
+      {
+        throw new IntrospectionException(
+                  "Listener type is not an EventListener.");
+      }
+
+    findMethods(eventSourceClass, listenerType, listenerMethodNames,
+                addListenerMethodName, removeListenerMethodName, null);
+    this.listenerType = listenerType;
+    checkAddListenerUnicast();
+    if (this.removeListenerMethod.getExceptionTypes().length > 0)
+      {
+        throw new IntrospectionException(
+                  "Listener remove method throws exceptions.");
+      }
+  }
+
+  /**
+   * Creates a new <code>EventSetDescriptor</code>.
+   * 
+   * <p>
+   * This variant of the constructor allows you to specify the names of the
+   * methods and adds no new constraints on top of the rules already described
+   * at the top of the class.
+   * </p>
+   * <p>
+   * A valid GetListener method is public, flags no exceptions and has one
+   * argument which is of type <code>Class</code>
+   * {@link java.awt.Component#getListeners(Class)} is such a method.
+   * </p>
+   * <p>
+   * Note: The validity of the return value of the GetListener method is not
+   * checked.
+   * </p>
+   * 
+   * @param eventSourceClass
+   *          the class containing the add and remove listener methods.
+   * @param eventSetName
+   *          the programmatic name of the event set, generally starting with a
+   *          lowercase letter (i.e. fooManChu instead of FooManChu).
+   * @param listenerType
+   *          the class containing the event firing methods.
+   * @param listenerMethodNames
+   *          the names of the even firing methods.
+   * @param addListenerMethodName
+   *          the name of the add listener method.
+   * @param removeListenerMethodName
+   *          the name of the remove listener method.
+   * @param getListenerMethodName
+   *          Name of a method which returns the array of listeners.
+   * @exception IntrospectionException
+   *              if listenerType is not an EventListener or if methods are not
+   *              found or are invalid.
+   * @since 1.4
+   */
+  public EventSetDescriptor(Class eventSourceClass, String eventSetName,
+                            Class listenerType, String[] listenerMethodNames,
+                            String addListenerMethodName,
+                            String removeListenerMethodName,
+                            String getListenerMethodName)
+      throws IntrospectionException
+  {
+    this(eventSourceClass, eventSetName, listenerType, listenerMethodNames,
+         addListenerMethodName, removeListenerMethodName);
+
+    Method newGetListenerMethod = null;
+
+    try
+      {
+        newGetListenerMethod 
+          = eventSourceClass.getMethod(getListenerMethodName,
+                                       new Class[] { Class.class });
+      }
+    catch (NoSuchMethodException nsme)
+      {
+        throw (IntrospectionException) 
+          new IntrospectionException("No method named " + getListenerMethodName
+                                      + " in class " + listenerType
+                                      + " which can be used as"
+                                      + " getListenerMethod.").initCause(nsme);
+      }
+
+    // Note: This does not check the return value (which
+    // should be EventListener[]) but the JDK does not either.
+
+    getListenerMethod = newGetListenerMethod;
+
+  }
+
+  /**
+   * Creates a new <code>EventSetDescriptor.</code>
+   * 
+   * <p>
+   * This variant of the constructor allows you to specify the names of the
+   * methods and adds no new constraints on top of the rules already described
+   * at the top of the class.
+   * </p>
+   * <p>
+   * A valid GetListener method is public, flags no exceptions and has one
+   * argument which is of type <code>Class</code>
+   * {@link java.awt.Component#getListeners(Class)} is such a method.
+   * </p>
+   * <p>
+   * Note: The validity of the return value of the GetListener method is not
+   * checked.
+   * </p>
+   * 
+   * @param eventSetName
+   *          the programmatic name of the event set, generally starting with a
+   *          lowercase letter (i.e. fooManChu instead of FooManChu).
+   * @param listenerType
+   *          the class containing the listenerMethods.
+   * @param listenerMethods
+   *          the event firing methods.
+   * @param addListenerMethod
+   *          the add listener method.
+   * @param removeListenerMethod
+   *          the remove listener method.
+   * @param getListenerMethod
+   *          The method which returns an array of the listeners.
+   * @exception IntrospectionException
+   *              if the listenerType is not an EventListener, or any of the
+   *              methods are invalid.
+   * @since 1.4
+   */
+  public EventSetDescriptor(String eventSetName, Class listenerType,
+                            Method[] listenerMethods, Method addListenerMethod,
+                            Method removeListenerMethod,
+                            Method getListenerMethod)
+      throws IntrospectionException
+  {
+    this(eventSetName, listenerType, listenerMethods, addListenerMethod,
+         removeListenerMethod);
+
+    // Do no checks if the getListenerMethod is null.
+    if (getListenerMethod.getParameterTypes().length != 1
+        || getListenerMethod.getParameterTypes()[0] != Class.class
+        || getListenerMethod.getExceptionTypes().length > 0
+        || !Modifier.isPublic(getListenerMethod.getModifiers()))
+      throw new IntrospectionException("GetListener method is invalid.");
+
+    // Note: This does not check the return value (which
+    // should be EventListener[]) but the JDK does not either.
+
+    this.getListenerMethod = getListenerMethod;
+  }
+
+  /**
+   * Creates a new <code>EventSetDescriptor</code>.
+   * 
+   * <p>This form of constructor allows you to explicitly say which methods
+   * do what, and no reflection is done by the <code>EventSetDescriptor</code>.
+   * The methods are, however, checked to ensure that they follow the rules
+   * set forth at the top of the class.
+   * 
+   * @param eventSetName
+   *          the programmatic name of the event set, generally starting with a
+   *          lowercase letter (i.e. fooManChu instead of FooManChu).
+   * @param listenerType
+   *          the class containing the listenerMethods.
+   * @param listenerMethods
+   *          the event firing methods.
+   * @param addListenerMethod
+   *          the add listener method.
+   * @param removeListenerMethod
+   *          the remove listener method.
+   * @exception IntrospectionException
+   *              if the listenerType is not an EventListener, or any of the
+   *              methods are invalid.
+   */
+  public EventSetDescriptor(String eventSetName, Class listenerType,
+                            Method[] listenerMethods, Method addListenerMethod,
+                            Method removeListenerMethod)
+      throws IntrospectionException
+  {
+    setName(eventSetName);
+    if (!java.util.EventListener.class.isAssignableFrom(listenerType))
+      {
+        throw new IntrospectionException(
+                  "Listener type is not an EventListener.");
+      }
+
+    this.listenerMethods = listenerMethods;
+    this.addListenerMethod = addListenerMethod;
+    this.removeListenerMethod = removeListenerMethod;
+    this.listenerType = listenerType;
+    checkMethods();
+    checkAddListenerUnicast();
+    if (this.removeListenerMethod.getExceptionTypes().length > 0)
+      {
+        throw new IntrospectionException(
+                  "Listener remove method throws exceptions.");
+      }
+  }
+
+  /** Creates a new <code>EventSetDescriptor</code>.
+   * 
+   * <p>This form of constructor allows you to explicitly say which methods do
+   * what, and no reflection is done by the <code>EventSetDescriptor</code>.
+   * The methods are, however, checked to ensure that they follow the rules
+   * set forth at the top of the class.
+   * 
+   * @param eventSetName
+   *          the programmatic name of the event set, generally starting with a
+   *          lowercase letter (i.e. fooManChu instead of FooManChu).
+   * @param listenerType
+   *          the class containing the listenerMethods.
+   * @param listenerMethodDescriptors
+   *          the event firing methods.
+   * @param addListenerMethod
+   *          the add listener method.
+   * @param removeListenerMethod
+   *          the remove listener method.
+   * @exception IntrospectionException
+   *              if the listenerType is not an EventListener, or any of the
+   *              methods are invalid.
+   */
+  public EventSetDescriptor(String eventSetName, Class listenerType,
+                            MethodDescriptor[] listenerMethodDescriptors,
+                            Method addListenerMethod,
+                            Method removeListenerMethod)
+      throws IntrospectionException
+  {
+    setName(eventSetName);
+    if (!java.util.EventListener.class.isAssignableFrom(listenerType))
+      {
+        throw new IntrospectionException(
+                  "Listener type is not an EventListener.");
+      }
+
+    this.listenerMethodDescriptors = listenerMethodDescriptors;
+    this.listenerMethods = new Method[listenerMethodDescriptors.length];
+    for (int i = 0; i < this.listenerMethodDescriptors.length; i++)
+      {
+        this.listenerMethods[i]
+           = this.listenerMethodDescriptors[i].getMethod();
+      }
+
+    this.addListenerMethod = addListenerMethod;
+    this.removeListenerMethod = removeListenerMethod;
+    this.listenerType = listenerType;
+    checkMethods();
+    checkAddListenerUnicast();
+    if (this.removeListenerMethod.getExceptionTypes().length > 0)
+      {
+        throw new IntrospectionException(
+                  "Listener remove method throws exceptions.");
+      }
+  }
+
+  /** Returns the class that contains the event firing methods.
+   */
+  public Class getListenerType()
+  {
+    return listenerType;
+  }
+
+  /** Returns the event firing methods.
+   */
+  public Method[] getListenerMethods()
+  {
+    return listenerMethods;
+  }
+
+  /** Returns the event firing methods as {@link MethodDescriptor}.
+   */
+  public MethodDescriptor[] getListenerMethodDescriptors()
+  {
+    if (listenerMethodDescriptors == null)
+      {
+        listenerMethodDescriptors
+          = new MethodDescriptor[listenerMethods.length];
+        
+        for (int i = 0; i < listenerMethods.length; i++)
+          {
+            listenerMethodDescriptors[i]
+              = new MethodDescriptor(listenerMethods[i]);
+          }
+      }
+    
+    return listenerMethodDescriptors;
+  }
+
+  /** Returns the add listener method.
+   */
+  public Method getAddListenerMethod()
+  {
+    return addListenerMethod;
+  }
+
+  /* Returns the remove listener method.
+   */
+  public Method getRemoveListenerMethod()
+  {
+    return removeListenerMethod;
+  }
+
+  /**
+   * Returns the method that retrieves the listeners or <code>null</code> if
+   * it does not exist.
+   */
+  public Method getGetListenerMethod()
+  {
+    return getListenerMethod;
+  }
+
+  /** Sets whether or not multiple listeners may be added.
+   * 
+   * @param unicast
+   *          whether or not multiple listeners may be added.
+   */
+  public void setUnicast(boolean unicast)
+  {
+    this.unicast = unicast;
+  }
+
+  /** Returns whether or not multiple listeners may be added.
+   * (Defaults to false.)
+   */
+  public boolean isUnicast()
+  {
+    return unicast;
+  }
+
+  /** Sets whether or not this is in the default event set.
+   * 
+   * @param inDefaultEventSet
+   *          whether this is in the default event set.
+   */
+  public void setInDefaultEventSet(boolean inDefaultEventSet)
+  {
+    this.inDefaultEventSet = inDefaultEventSet;
+  }
+
+  /** Returns whether or not this is in the default event set.
+   * (Defaults to true.)
+   */
+  public boolean isInDefaultEventSet()
+  {
+    return inDefaultEventSet;
+  }
+
+  private void checkAddListenerUnicast() throws IntrospectionException
+  {
+    Class[] addListenerExceptions = this.addListenerMethod.getExceptionTypes();
+    if (addListenerExceptions.length > 1)
+      {
+        throw new IntrospectionException(
+                  "Listener add method throws too many exceptions.");
+      }
+    else if (addListenerExceptions.length == 1
+             && !java.util.TooManyListenersException.class
+                .isAssignableFrom(addListenerExceptions[0]))
+      {
+        throw new IntrospectionException(
+                  "Listener add method throws too many exceptions.");
+      }
+  }
+
+  private void checkMethods() throws IntrospectionException
+  {
+    if (!addListenerMethod.getDeclaringClass()
+        .isAssignableFrom(removeListenerMethod.getDeclaringClass())
+        && !removeListenerMethod.getDeclaringClass()
+        .isAssignableFrom(addListenerMethod.getDeclaringClass()))
+      {
+        throw new IntrospectionException(
+                  "add and remove listener methods do not come from the"
+                  + " same class.  This is bad.");
+      }
+    if (!addListenerMethod.getReturnType().equals(java.lang.Void.TYPE)
+        || addListenerMethod.getParameterTypes().length != 1
+        || !listenerType.equals(addListenerMethod.getParameterTypes()[0])
+        || !Modifier.isPublic(addListenerMethod.getModifiers()))
+      {
+        throw new IntrospectionException("Add Listener Method invalid.");
+      }
+    if (!removeListenerMethod.getReturnType().equals(java.lang.Void.TYPE)
+        || removeListenerMethod.getParameterTypes().length != 1
+        || !listenerType.equals(removeListenerMethod.getParameterTypes()[0])
+        || removeListenerMethod.getExceptionTypes().length > 0
+        || !Modifier.isPublic(removeListenerMethod.getModifiers()))
+      {
+        throw new IntrospectionException("Remove Listener Method invalid.");
+      }
+
+    for (int i = 0; i < listenerMethods.length; i++)
+      {
+        if (!listenerMethods[i].getReturnType().equals(java.lang.Void.TYPE)
+            || Modifier.isPrivate(listenerMethods[i].getModifiers()))
+          {
+            throw new IntrospectionException("Event Method "
+                                             + listenerMethods[i].getName()
+                                             + " non-void or private.");
+          }
+        if (!listenerMethods[i].getDeclaringClass()
+            .isAssignableFrom(listenerType))
+          {
+            throw new IntrospectionException("Event Method "
+                                             + listenerMethods[i].getName()
+                                             + " not from class "
+                                             + listenerType.getName());
+          }
+      }
+  }
+
+  private void findMethods(Class eventSourceClass, Class listenerType,
+                           String listenerMethodNames[],
+                           String addListenerMethodName,
+                           String removeListenerMethodName,
+                           String absurdEventClassCheckName)
+      throws IntrospectionException
+  {
+
+    /* Find add listener method and remove listener method. */
+    Class[] listenerArgList = new Class[1];
+    listenerArgList[0] = listenerType;
+    try
+      {
+        this.addListenerMethod
+          = eventSourceClass.getMethod(addListenerMethodName,
+                                       listenerArgList);
+      }
+    catch (SecurityException E)
+      {
+        throw new IntrospectionException(
+                  "SecurityException trying to access method "
+                  + addListenerMethodName + ".");
+      }
+    catch (NoSuchMethodException E)
+      {
+        throw new IntrospectionException("Could not find method "
+                                         + addListenerMethodName + ".");
+      }
+
+    if (this.addListenerMethod == null
+        || !this.addListenerMethod.getReturnType().equals(java.lang.Void.TYPE))
+      {
+        throw new IntrospectionException(
+                  "Add listener method does not exist, is not public,"
+                  + " or is not void.");
+      }
+
+    try
+      {
+        this.removeListenerMethod
+          = eventSourceClass.getMethod(removeListenerMethodName,
+                                       listenerArgList);
+      }
+    catch (SecurityException E)
+      {
+        throw new IntrospectionException(
+                  "SecurityException trying to access method "
+                  + removeListenerMethodName + ".");
+      }
+    catch (NoSuchMethodException E)
+      {
+        throw new IntrospectionException("Could not find method "
+                                         + removeListenerMethodName + ".");
+      }
+    if (this.removeListenerMethod == null
+        || !this.removeListenerMethod.getReturnType()
+           .equals(java.lang.Void.TYPE))
+      {
+        throw new IntrospectionException(
+                  "Remove listener method does not exist, is not public,"
+                  + " or is not void.");
+      }
+
+    /* Find the listener methods. */
+    Method[] methods;
+    try
+      {
+        methods = ClassHelper.getAllMethods(listenerType);
+      }
+    catch (SecurityException E)
+      {
+        throw new IntrospectionException(
+                  "Security: You cannot access fields in this class.");
+      }
+
+    Vector chosenMethods = new Vector();
+    boolean[] listenerMethodFound = new boolean[listenerMethodNames.length];
+    for (int i = 0; i < methods.length; i++)
+      {
+        if (Modifier.isPrivate(methods[i].getModifiers()))
+          {
+            continue;
+          }
+        Method currentMethod = methods[i];
+        Class retval = currentMethod.getReturnType();
+        if (retval.equals(java.lang.Void.TYPE))
+          {
+            for (int j = 0; j < listenerMethodNames.length; j++)
+              {
+                if (currentMethod.getName().equals(listenerMethodNames[j])
+                    && (absurdEventClassCheckName == null
+                    || (currentMethod.getParameterTypes().length == 1
+                    && ((currentMethod.getParameterTypes()[0])
+                        .getName().equals(absurdEventClassCheckName)
+                    || (currentMethod.getParameterTypes()[0])
+                       .getName().endsWith("." + absurdEventClassCheckName)))))
+                  {
+                    chosenMethods.addElement(currentMethod);
+                    listenerMethodFound[j] = true;
+                  }
+              }
+          }
+      }
+
+    /* Make sure we found all the methods we were looking for. */
+    for (int i = 0; i < listenerMethodFound.length; i++)
+      {
+        if (!listenerMethodFound[i])
+          {
+            throw new IntrospectionException("Could not find event method "
+                                             + listenerMethodNames[i]);
+          }
+      }
+
+    /* Now that we've chosen the listener methods we want, store them. */
+    this.listenerMethods = new Method[chosenMethods.size()];
+    for (int i = 0; i < chosenMethods.size(); i++)
+      {
+        this.listenerMethods[i] = (Method) chosenMethods.elementAt(i);
+      }
+  }
+  
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/ExceptionListener.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/ExceptionListener.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/ExceptionListener.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/ExceptionListener.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,57 @@
+/* ExceptionListener.java -- listen for recoverable internal exceptions
+   Copyright (C) 2002, 2005  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+/**
+ * This interface allows a class to monitor internal exceptions, to try to
+ * recover from them.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public interface ExceptionListener
+{
+  /**
+   * Fired after an exception occurs.
+   *
+   * @param e the trapped exception
+   */
+  void exceptionThrown(Exception e);
+} // interface ExceptionListener

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Expression.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Expression.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Expression.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Expression.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,138 @@
+/* java.beans.Expression
+   Copyright (C) 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+/**
+ * <p>An Expression captures the execution of an object method
+ * that returns a value.</p>
+ * 
+ * <p>It stores an object, the method to call, and the arguments to pass to
+ * the method.</p>
+ * 
+ * <p>While this class can generally be used to describe method calls it is
+ * part of the XML serialization API.</p> 
+ * 
+ * @author Robert Schuster (robertschuster at fsfe.org)
+ * @since 1.4
+ */
+public class Expression extends Statement
+{
+  // This is a placeholder to indicate that value hasn't been set
+  // yet;
+  private static final Object UNSET = new Object();
+
+  // The value to return. This is equal to unset until getValue is called.
+  private Object value;
+
+  /**
+   * Constructor Constructs an Expression representing the invocation of
+   * object.methodName(arg[0], arg[1], ...); However, it will never be executed.
+   * Instead, value will always be returned.
+   * 
+   * @param value
+   *          The value to return.
+   * @param target
+   *          The object to invoke the method on.
+   * @param methodName
+   *          The object method to invoke.
+   * @param arguments
+   *          An array of arguments to pass to the method.
+   */
+  public Expression(Object value, Object target, String methodName,
+                    Object[] arguments)
+  {
+    super(target, methodName, arguments);
+    this.value = value;
+  }
+
+  /**
+   * Constructor Constructs an Expression representing the invocation of
+   * object.methodName(arg[0], arg[1], ...);
+   * 
+   * @param target
+   *          The object to invoke the method on.
+   * @param methodName
+   *          The object method to invoke.
+   * @param arguments
+   *          An array of arguments to pass to the method.
+   */
+  public Expression(Object target, String methodName, Object[] arguments)
+  {
+    super(target, methodName, arguments);
+    this.value = UNSET;
+  }
+
+  /**
+   * Return the result of executing the method. If the cached value has not yet
+   * been set, the method is executed in the same way as Statement.execute(),
+   * except that the value is cached, and then returned. If the value has been
+   * set, it is returned without executing the method again.
+   * 
+   * @return the result of executing the method.
+   * @exception Exception
+   *              if an error occurs
+   */
+  public Object getValue() throws Exception
+  {
+    if (value == UNSET)
+      value = doExecute();
+    return value;
+  }
+
+  /**
+   * Set the cached value to be returned by getValue()
+   * 
+   * @param value
+   *          the value to cache and return.
+   */
+  public void setValue(Object value)
+  {
+    this.value = value;
+  }
+
+  /**
+   * Return a string representation of this expression.
+   */
+  public String toString()
+  {
+    String result = super.toString();
+    if (value != UNSET)
+      return value.getClass().getName() + "=" + result;
+    return result;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/FeatureDescriptor.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/FeatureDescriptor.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/FeatureDescriptor.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/FeatureDescriptor.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,232 @@
+/* java.beans.FeatureDescriptor
+   Copyright (C) 1998, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+/**
+ * FeatureDescriptor is the common superclass for all JavaBeans Descriptor
+ * classes. JavaBeans descriptors are abstract descriptors of properties,
+ * events, methods, beans, etc.<P>
+ *
+ * <STRONG>Documentation Convention:</STRONG> for proper
+ * Internalization of Beans inside an RAD tool, sometimes there
+ * are two names for a property or method: a programmatic, or
+ * locale-independent name, which can be used anywhere, and a
+ * localized, display name, for ease of use.  In the
+ * documentation I will specify different String values as
+ * either <EM>programmatic</EM> or <EM>localized</EM> to
+ * make this distinction clear.
+ *
+ * @author John Keiser
+ * @since 1.1
+ */
+
+public class FeatureDescriptor
+{
+  String name;
+  String displayName;
+  String shortDescription;
+  boolean expert;
+  boolean hidden;
+  boolean preferred;
+
+  Hashtable valueHash;
+
+  /**
+   * Instantiate this FeatureDescriptor with appropriate default values.
+   */
+  public FeatureDescriptor()
+  {
+    valueHash = new Hashtable();
+  }
+
+  /**
+   * Get the programmatic name of this feature.
+   */
+  public String getName()
+  {
+    return name;
+  }
+
+  /**
+   * Set the programmatic name of this feature.
+   *
+   * @param name the new name for this feature.
+   */
+  public void setName(String name)
+  {
+    this.name = name;
+  }
+
+  /**
+   * Get the localized (display) name of this feature.
+   *
+   * @returns The localized display name of this feature or falls
+   * back to the programmatic name.
+   */
+  public String getDisplayName()
+  {
+    return (displayName == null) ? name : displayName;
+  }
+
+  /**
+   * Set the localized (display) name of this feature.
+   *
+   * @param displayName the new display name for this feature.
+   */
+  public void setDisplayName(String displayName)
+  {
+    this.displayName = displayName;
+  }
+
+  /**
+   * Get the localized short description for this feature.
+   *
+   * @returns A short localized description of this feature or
+   * what <code>getDisplayName</code> returns in case, that no short description
+   * is available.
+   */
+  public String getShortDescription()
+  {
+    return (shortDescription == null) ? getDisplayName() : shortDescription;
+  }
+
+  /**
+   * Set the localized short description for this feature.
+   *
+   * @param shortDescription the new short description for this feature.
+   */
+  public void setShortDescription(String shortDescription)
+  {
+    this.shortDescription = shortDescription;
+  }
+
+  /**
+   * Indicates whether this feature is for expert use only.
+   *
+   * @return true if for use by experts only,
+   * or false if anyone can use it.
+   */
+  public boolean isExpert()
+  {
+    return expert;
+  }
+
+  /**
+   * Set whether this feature is for expert use only.
+   *
+   * @param expert true if for use by experts only,
+   * or false if anyone can use it.
+   */
+  public void setExpert(boolean expert)
+  {
+    this.expert = expert;
+  }
+
+  /**
+   * Indicates whether this feature is for use by tools only.
+   * If it is for use by tools only, then it should not be displayed.
+   *
+   * @return true if tools only should use it,
+   * or false if anyone can see it.
+   */
+  public boolean isHidden()
+  {
+    return hidden;
+  }
+
+  /**
+   * Set whether this feature is for use by tools only.
+   * If it is for use by tools only, then it should not be displayed.
+   *
+   * @param hidden true if tools only should use it,
+   * or false if anyone can see it.
+   */
+  public void setHidden(boolean hidden)
+  {
+    this.hidden = hidden;
+  }
+
+  public boolean isPreferred ()
+  {
+    return preferred;
+  }
+
+  public void setPreferred (boolean preferred)
+  {
+    this.preferred = preferred;
+  }
+
+  /**
+   * Get an arbitrary value set with setValue().
+   *
+   * @param name the programmatic name of the key.
+   *
+   * @return the value associated with this name,
+   * or null if there is none.
+   */
+  public Object getValue(String name)
+  {
+    return valueHash.get(name);
+  }
+
+  /**
+   * Set an arbitrary string-value pair with this feature.
+   *
+   * @param name the programmatic name of the key.
+   * @param value the value to associate with the name.
+   */
+  public void setValue(String name, Object value)
+  {
+    valueHash.put(name, value);
+  }
+
+  /**
+   * Get a list of the programmatic key names set with setValue().
+   *
+   * @return an Enumerator over all the programmatic key names associated
+   * with this feature.
+   */
+  public Enumeration attributeNames()
+  {
+    return valueHash.keys();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/IndexedPropertyChangeEvent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/IndexedPropertyChangeEvent.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/IndexedPropertyChangeEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/IndexedPropertyChangeEvent.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,81 @@
+/* Indexed property change event
+   Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+/**
+ * This is like a PropertyChangeEvent, but also carries with it the
+ * index of the property which changed.
+ * @author Tom Tromey (tromey at redhat.com)
+ * @since 1.5
+ */
+public class IndexedPropertyChangeEvent extends PropertyChangeEvent
+{
+  private static final long serialVersionUID = -320227448495806870L;
+
+  /**
+   * Index of the item that was changed.
+   */
+  private int index;
+
+  /**
+   * Create a new IndexedPropertyChangeEvent.
+   * @param source the Bean containing the property
+   * @param name the property's name
+   * @param oldValue the old value of the property
+   * @param newValue the new value of the property
+   * @param index the index of the element in the property which changed
+   * @throws IllegalArgumentException if source is null
+   */
+  public IndexedPropertyChangeEvent(Object source, String name,
+                                    Object oldValue, Object newValue,
+                                    int index)
+  {
+    super(source, name, oldValue, newValue);
+    this.index = index;
+  }
+
+  /**
+   * Return the index of the changed property. 
+   * @return the index
+   */
+  public int getIndex()
+  {
+    return index;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/IndexedPropertyDescriptor.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/IndexedPropertyDescriptor.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/IndexedPropertyDescriptor.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/IndexedPropertyDescriptor.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,421 @@
+/* IndexedPropertyDescriptor.java --
+   Copyright (C) 1998, 2003 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Method;
+
+/**
+ * IndexedPropertyDescriptor describes information about a JavaBean
+ * indexed property, by which we mean an array-like property that
+ * has been exposed via a pair of get and set methods and another
+ * pair that allows you to get to the property by an index.<P>
+ *
+ * An example property would have four methods like this:<P>
+ * <CODE>FooBar[] getFoo()</CODE><BR>
+ * <CODE>void setFoo(FooBar[])</CODE><BR>
+ * <CODE>FooBar getFoo(int)</CODE><BR>
+ * <CODE>void setFoo(int,FooBar)</CODE><P>
+ *
+ * The constraints put on get and set methods are:<P>
+ * <OL>
+ * <LI>There must be at least a get(int) or a set(int,...) method.
+ * Nothing else is required.  <B>Spec note:</B>One nice restriction
+ * would be that if there is a get() there must be a get(int), same
+ * with set, but that is not in the spec and is fairly harmless.)</LI>
+ * <LI>A get array method must have signature
+ *     <CODE><propertyType>[] <getMethodName>()</CODE></LI>
+ * <LI>A set array method must have signature
+ *     <CODE>void <setMethodName>(<propertyType>[])</CODE></LI>
+ * <LI>A get index method must have signature
+ *     <CODE><propertyType> <getMethodName>(int)</CODE></LI>
+ * <LI>A set index method must have signature
+ *     <CODE>void <setMethodName>(int,<propertyType>)</CODE></LI>
+ * <LI>All these methods may throw any exception.</LI>
+ * <LI>All these methods must be public.</LI>
+ * </OL>
+ *
+ * @author John Keiser
+ * @since JDK1.1
+ */
+public class IndexedPropertyDescriptor extends PropertyDescriptor
+{
+  private Class indexedPropertyType;
+  private Method setIndex;
+  private Method getIndex;
+
+  /**
+   * Create a new IndexedPropertyDescriptor by introspection.
+   * This form of constructor creates the PropertyDescriptor by
+   * looking for getter methods named <CODE>get<name>()</CODE>
+   * and setter methods named
+   * <CODE>set<name>()</CODE> in class
+   * <CODE><beanClass></CODE>, where <name> has its
+   * first letter capitalized by the constructor.<P>
+   *
+   * <B>Implementation note:</B> If there is a get(int) method,
+   * then the return type of that method is used to find the
+   * remaining methods.  If there is no get method, then the
+   * set(int) method is searched for exhaustively and that type
+   * is used to find the others.<P>
+   *
+   * <B>Spec note:</B>
+   * If there is no get(int) method and multiple set(int) methods with
+   * the same name and the correct parameters (different type of course),
+   * then an IntrospectionException is thrown.  While Sun's spec
+   * does not state this, it can make Bean behavior different on
+   * different systems (since method order is not guaranteed) and as
+   * such, can be treated as a bug in the spec.  I am not aware of
+   * whether Sun's implementation catches this.
+   *
+   * @param name the programmatic name of the property, usually
+   *             starting with a lowercase letter (e.g. fooManChu
+   *             instead of FooManChu).
+   * @param beanClass the class the get and set methods live in.
+   *
+   * @exception IntrospectionException if the methods are not found or
+   *            invalid.
+   */
+  public IndexedPropertyDescriptor(String name, Class beanClass)
+    throws IntrospectionException
+  {
+    super(name);
+    String capitalized;
+    try
+      {
+        capitalized = Character.toUpperCase(name.charAt(0))
+          + name.substring(1);
+      }
+    catch(StringIndexOutOfBoundsException e)
+      {
+        capitalized = "";
+      }
+    findMethods(beanClass, "get" + capitalized, "set" + capitalized,
+                "get" + capitalized, "set" + capitalized);
+  }
+
+  /**
+   * Create a new IndexedPropertyDescriptor by introspection.
+   * This form of constructor allows you to specify the
+   * names of the get and set methods to search for.<P>
+   *
+   * <B>Implementation note:</B> If there is a get(int) method,
+   * then the return type of that method is used to find the
+   * remaining methods.  If there is no get method, then the
+   * set(int) method is searched for exhaustively and that type
+   * is used to find the others.<P>
+   *
+   * <B>Spec note:</B>
+   * If there is no get(int) method and multiple set(int) methods with
+   * the same name and the correct parameters (different type of course),
+   * then an IntrospectionException is thrown.  While Sun's spec
+   * does not state this, it can make Bean behavior different on
+   * different systems (since method order is not guaranteed) and as
+   * such, can be treated as a bug in the spec.  I am not aware of
+   * whether Sun's implementation catches this.
+   *
+   * @param name the programmatic name of the property, usually
+   *             starting with a lowercase letter (e.g. fooManChu
+   *             instead of FooManChu).
+   * @param beanClass the class the get and set methods live in.
+   * @param getMethodName the name of the get array method.
+   * @param setMethodName the name of the set array method.
+   * @param getIndexName the name of the get index method.
+   * @param setIndexName the name of the set index method.
+   *
+   * @exception IntrospectionException if the methods are not found or invalid.
+   */
+  public IndexedPropertyDescriptor(String name, Class beanClass,
+                                   String getMethodName, String setMethodName,
+                                   String getIndexName, String setIndexName)
+    throws IntrospectionException
+  {
+    super(name);
+    findMethods(beanClass, getMethodName, setMethodName, getIndexName,
+                setIndexName);
+  }
+
+  /**
+   * Create a new PropertyDescriptor using explicit Methods.
+   * Note that the methods will be checked for conformance to standard
+   * Property method rules, as described above at the top of this class.
+   * 
+   * @param name the programmatic name of the property, usually
+   *             starting with a lowercase letter (e.g. fooManChu
+   *             instead of FooManChu).
+   * @param getMethod the get array method.
+   * @param setMethod the set array method.
+   * @param getIndex the get index method.
+   * @param setIndex the set index method.
+   *
+   * @exception IntrospectionException if the methods are not found or invalid.
+   */
+  public IndexedPropertyDescriptor(String name, Method getMethod,
+                                   Method setMethod, Method getIndex,
+                                   Method setIndex)
+    throws IntrospectionException
+  {
+    super(name);
+    if(getMethod != null && getMethod.getParameterTypes().length > 0)
+      throw new IntrospectionException("get method has parameters");
+    if(getMethod != null && setMethod.getParameterTypes().length != 1)
+      throw new IntrospectionException("set method does not have exactly one parameter");
+    if(getMethod != null && setMethod != null)
+      {
+        if(!getMethod.getReturnType().equals(setMethod.getParameterTypes()[0]))
+          {
+            throw new IntrospectionException("set and get methods do not "
+                                             + "share the same type");
+          }
+        if(!getMethod.getDeclaringClass().isAssignableFrom
+           (setMethod.getDeclaringClass())
+           && !setMethod.getDeclaringClass().isAssignableFrom
+           (getMethod.getDeclaringClass()))
+          {
+            throw new IntrospectionException("set and get methods are not in "
+                                             + "the same class.");
+          }
+      }
+
+    if (getIndex != null
+        && (getIndex.getParameterTypes().length != 1
+         || !(getIndex.getParameterTypes()[0]).equals(java.lang.Integer.TYPE)))
+      {
+        throw new IntrospectionException("get index method has wrong "
+                                         + "parameters");
+      }
+    if (setIndex != null
+       && (setIndex.getParameterTypes().length != 2
+         || !(setIndex.getParameterTypes()[0]).equals(java.lang.Integer.TYPE)))
+      {
+        throw new IntrospectionException("set index method has wrong "
+                                         + "parameters");
+      }
+    if (getIndex != null && setIndex != null)
+      {
+        if(!getIndex.getReturnType().equals(setIndex.getParameterTypes()[1]))
+          {
+            throw new IntrospectionException("set index methods do not share "
+                                             + "the same type");
+          }
+        if(!getIndex.getDeclaringClass().isAssignableFrom
+           (setIndex.getDeclaringClass())
+           && !setIndex.getDeclaringClass().isAssignableFrom
+           (getIndex.getDeclaringClass()))
+          {
+            throw new IntrospectionException("get and set index methods are "
+                                             + "not in the same class.");
+          }
+      }
+
+    if (getIndex != null && getMethod != null
+        && !getIndex.getDeclaringClass().isAssignableFrom
+        (getMethod.getDeclaringClass())
+        && !getMethod.getDeclaringClass().isAssignableFrom
+        (getIndex.getDeclaringClass()))
+      {
+        throw new IntrospectionException("methods are not in the same class.");
+      }
+
+    if (getIndex != null && getMethod != null
+        && !Array.newInstance(getIndex.getReturnType(),0)
+        .getClass().equals(getMethod.getReturnType()))
+      {
+        throw new IntrospectionException("array methods do not match index "
+                                         + "methods.");
+      }
+
+    this.getMethod = getMethod;
+    this.setMethod = setMethod;
+    this.getIndex = getIndex;
+    this.setIndex = setIndex;
+    this.indexedPropertyType = getIndex != null ? getIndex.getReturnType()
+                                             : setIndex.getParameterTypes()[1];
+    this.propertyType = getMethod != null ? getMethod.getReturnType()
+      : (setMethod != null ? setMethod.getParameterTypes()[0]
+         : Array.newInstance(this.indexedPropertyType,0).getClass());
+  }
+
+  public Class getIndexedPropertyType()
+  {
+    return indexedPropertyType;
+  }
+
+  public Method getIndexedReadMethod()
+  {
+    return getIndex;
+  }
+
+  /**
+   * Sets the method that is used to read an indexed property.
+   *
+   * @param m the method to set
+   */
+  public void setIndexedReadMethod(Method m) throws IntrospectionException
+  {
+    getIndex = m;
+  }
+
+  public Method getIndexedWriteMethod()
+  {
+    return setIndex;
+  }
+
+  /**
+   * Sets the method that is used to write an indexed property.
+   *
+   * @param m the method to set
+   */
+  public void setIndexedWriteMethod(Method m) throws IntrospectionException
+  {
+    setIndex = m;
+  }
+
+  private void findMethods(Class beanClass, String getMethodName,
+                           String setMethodName, String getIndexName,
+                           String setIndexName)
+    throws IntrospectionException
+  {
+    try
+      {
+        if(getIndexName != null)
+          {
+            try
+              {
+                Class[] getArgs = new Class[1];
+                getArgs[0] = java.lang.Integer.TYPE;
+                getIndex = beanClass.getMethod(getIndexName,getArgs);
+                indexedPropertyType = getIndex.getReturnType();
+              }
+            catch(NoSuchMethodException E)
+              {
+              }
+          }
+        if(getIndex != null)
+          {
+            if(setIndexName != null)
+              {
+                try
+                  {
+                    Class[] setArgs = new Class[2];
+                    setArgs[0] = java.lang.Integer.TYPE;
+                    setArgs[1] = indexedPropertyType;
+                    setIndex = beanClass.getMethod(setIndexName,setArgs);
+                    if(!setIndex.getReturnType().equals(java.lang.Void.TYPE))
+                      {
+                        throw new IntrospectionException(setIndexName
+                                                + " has non-void return type");
+                      }
+                  }
+                catch(NoSuchMethodException E)
+                  {
+                  }
+              }
+          }
+        else if(setIndexName != null)
+          {
+            Method[] m = beanClass.getMethods();
+            for(int i=0;i<m.length;i++)
+              {
+                Method current = m[i];
+                if(current.getName().equals(setIndexName)
+                   && current.getParameterTypes().length == 2
+                   && (current.getParameterTypes()[0])
+                   .equals(java.lang.Integer.TYPE)
+                   && current.getReturnType().equals(java.lang.Void.TYPE))
+                  {
+                    if(setIndex != null)
+                      {
+                        throw new IntrospectionException("Multiple, different "
+                                     + "set methods found that fit the bill!");
+                      }
+                    else
+                      {
+                        setIndex = current;
+                        indexedPropertyType = current.getParameterTypes()[1];
+                      }
+                  }
+              }
+            if(setIndex == null)
+              {
+                throw new IntrospectionException("Cannot find get or set "
+                                                 + "methods.");
+              }
+          }
+        else
+          {
+           throw new IntrospectionException("Cannot find get or set methods.");
+          }
+
+        Class arrayType = Array.newInstance(indexedPropertyType,0).getClass();
+
+        Class[] setArgs = new Class[1];
+        setArgs[0] = arrayType;
+        try
+          {
+            setMethod = beanClass.getMethod(setMethodName,setArgs);
+            if (!setMethod.getReturnType().equals(java.lang.Void.TYPE))
+              {
+                setMethod = null;
+              }
+          }
+        catch(NoSuchMethodException E)
+          {
+          }
+
+        Class[] getArgs = new Class[0];
+        try
+          {
+            getMethod = beanClass.getMethod(getMethodName,getArgs);
+            if (!getMethod.getReturnType().equals(arrayType))
+              {
+                getMethod = null;
+              }
+          }
+        catch(NoSuchMethodException E)
+          {
+          }
+      }
+    catch(SecurityException E)
+      {
+        throw new IntrospectionException("SecurityException while trying to "
+                                         + "find methods.");
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/IntrospectionException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/IntrospectionException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/IntrospectionException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/IntrospectionException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,67 @@
+/* IntrospectionException -- thrown when an exception occurs in introspection
+   Copyright (C) 1998, 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+/**
+ * IntrospectionException is thrown when the Introspector fails. Typical
+ * causes are the inability to map a name to its Class, or specifying a
+ * wrong type signature.
+ *
+ * @author John Keiser
+ * @see Introspector
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class IntrospectionException extends Exception
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  private static final long serialVersionUID = -3728150539969542619L;
+
+  /**
+   * Instantiate this exception with the given message.
+   *
+   * @param msg the message for the exception
+   */
+  public IntrospectionException(String msg)
+  {
+    super(msg);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Introspector.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Introspector.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Introspector.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/Introspector.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,704 @@
+/* java.beans.Introspector
+   Copyright (C) 1998, 2002, 2003 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+import gnu.java.beans.BeanInfoEmbryo;
+import gnu.java.beans.ExplicitBeanInfo;
+import gnu.java.beans.IntrospectionIncubator;
+import gnu.java.lang.ClassHelper;
+
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ * Introspector is the class that does the bulk of the
+ * design-time work in Java Beans.  Every class must have
+ * a BeanInfo in order for an RAD tool to use it; but, as
+ * promised, you don't have to write the BeanInfo class
+ * yourself if you don't want to.  All you have to do is
+ * call getBeanInfo() in the Introspector and it will use
+ * standard JavaBeans-defined method signatures to
+ * determine the information about your class.<P>
+ *
+ * Don't worry about it too much, though: you can provide
+ * JavaBeans with as much customized information as you
+ * want, or as little as you want, using the BeanInfo
+ * interface (see BeanInfo for details).<P>
+ *
+ * <STRONG>Order of Operations</STRONG><P>
+ *
+ * When you call getBeanInfo(class c), the Introspector
+ * first searches for BeanInfo class to see if you
+ * provided any explicit information.  It searches for a
+ * class named <bean class name>BeanInfo in different
+ * packages, first searching the bean class's package
+ * and then moving on to search the beanInfoSearchPath.<P>
+ *
+ * If it does not find a BeanInfo class, it acts as though
+ * it had found a BeanInfo class returning null from all
+ * methods (meaning it should discover everything through
+ * Introspection).  If it does, then it takes the
+ * information it finds in the BeanInfo class to be
+ * canonical (that is, the information speaks for its
+ * class as well as all superclasses).<P>
+ *
+ * When it has introspected the class, calls
+ * getBeanInfo(c.getSuperclass) and adds that information
+ * to the information it has, not adding to any information
+ * it already has that is canonical.<P>
+ *
+ * <STRONG>Introspection Design Patterns</STRONG><P>
+ *
+ * When the Introspector goes in to read the class, it
+ * follows a well-defined order in order to not leave any
+ * methods unaccounted for.  Its job is to step over all
+ * of the public methods in a class and determine whether
+ * they are part of a property, an event, or a method (in
+ * that order).
+ *
+ *
+ * <STRONG>Properties:</STRONG><P>
+ * 
+ * <OL>
+ * <LI>If there is a <CODE>public boolean isXXX()</CODE>
+ *     method, then XXX is a read-only boolean property.
+ *     <CODE>boolean getXXX()</CODE> may be supplied in
+ *     addition to this method, although isXXX() is the
+ *     one that will be used in this case and getXXX()
+ *     will be ignored.  If there is a
+ *     <CODE>public void setXXX(boolean)</CODE> method,
+ *     it is part of this group and makes it a read-write
+ *     property.</LI>
+ * <LI>If there is a
+ *     <CODE>public <type> getXXX(int)</CODE>
+ *     method, then XXX is a read-only indexed property of
+ *     type <type>.  If there is a
+ *     <CODE>public void setXXX(int,<type>)</CODE>
+ *     method, then it is a read-write indexed property of
+ *     type <type>.  There may also be a
+ *     <CODE>public <type>[] getXXX()</CODE> and a
+ *     <CODE>public void setXXX(<type>)</CODE>
+ *     method as well.</LI>
+ * <LI>If there is a
+ *     <CODE>public void setXXX(int,<type>)</CODE>
+ *     method, then it is a write-only indexed property of
+ *     type <type>.  There may also be a
+ *     <CODE>public <type>[] getXXX()</CODE> and a
+ *     <CODE>public void setXXX(<type>)</CODE>
+ *     method as well.</LI>
+ * <LI>If there is a
+ *     <CODE>public <type> getXXX()</CODE> method,
+ *     then XXX is a read-only property of type
+ *     <type>.  If there is a
+ *     <CODE>public void setXXX(<type>)</CODE>
+ *     method, then it will be used for the property and
+ *     the property will be considered read-write.</LI>
+ * <LI>If there is a
+ *     <CODE>public void setXXX(<type>)</CODE>
+ *     method, then as long as XXX is not already used as
+ *     the name of a property, XXX is assumed to be a
+ *     write-only property of type <type>.</LI>
+ * <LI>In all of the above cases, if the setXXX() method
+ *     throws <CODE>PropertyVetoException</CODE>, then the
+ *     property in question is assumed to be constrained.
+ *     No properties are ever assumed to be bound
+ *     (<STRONG>Spec Note:</STRONG> this is not in the
+ *     spec, it just makes sense).  See PropertyDescriptor
+ *     for a description of bound and constrained
+ *     properties.</LI>
+ * </OL>
+ *
+ * <STRONG>Events:</STRONG><P>
+ *
+ * If there is a pair of methods,
+ * <CODE>public void addXXX(<type>)</CODE> and
+ * <CODE>public void removeXXX(<type>)</CODE>, where
+ * <type> is a descendant of
+ * <CODE>java.util.EventListener</CODE>, then the pair of
+ * methods imply that this Bean will fire events to
+ * listeners of type <type>.<P>
+ *
+ * If the addXXX() method throws
+ * <CODE>java.util.TooManyListenersException</CODE>, then
+ * the event set is assumed to be <EM>unicast</EM>.  See
+ * EventSetDescriptor for a discussion of unicast event
+ * sets.<P>
+ *
+ * <STRONG>Spec Note:</STRONG> the spec seems to say that
+ * the listener type's classname must be equal to the XXX
+ * part of addXXX() and removeXXX(), but that is not the
+ * case in Sun's implementation, so I am assuming it is
+ * not the case in general.<P>
+ *
+ * <STRONG>Methods:</STRONG><P>
+ * 
+ * Any public methods (including those which were used
+ * for Properties or Events) are used as Methods.
+ *
+ * @author John Keiser
+ * @since JDK1.1
+ * @see java.beans.BeanInfo
+ */
+public class Introspector {
+  
+  public static final int USE_ALL_BEANINFO = 1;
+  public static final int IGNORE_IMMEDIATE_BEANINFO = 2;
+  public static final int IGNORE_ALL_BEANINFO = 3;
+
+  static String[] beanInfoSearchPath = {"gnu.java.beans.info"};
+  static Hashtable beanInfoCache = new Hashtable();
+  
+  private Introspector() {}
+  
+  /** 
+   * Get the BeanInfo for class <CODE>beanClass</CODE>,
+   * first by looking for explicit information, next by
+   * using standard design patterns to determine
+   * information about the class.
+   *
+   * @param beanClass the class to get BeanInfo about.
+   * @return the BeanInfo object representing the class.
+   */
+  public static BeanInfo getBeanInfo(Class beanClass) 
+    throws IntrospectionException 
+  {
+    BeanInfo cachedInfo;
+    synchronized(beanClass) 
+      {
+	cachedInfo = (BeanInfo)beanInfoCache.get(beanClass);
+	if(cachedInfo != null) 
+	  {
+	    return cachedInfo;
+	  }
+	cachedInfo = getBeanInfo(beanClass,null);
+	beanInfoCache.put(beanClass,cachedInfo);
+	return cachedInfo;
+      }
+  }
+  
+  /**
+   * Returns a {@BeanInfo} instance for the given Bean class where a flag
+   * controls the usage of explicit BeanInfo class to retrieve that
+   * information.
+   * 
+   * <p>You have three options:</p>
+   * <p>With {@link #USE_ALL_BEANINFO} the result is the same as
+   * {@link #getBeanInfo(Class)}.</p>
+   * 
+   * <p>Calling the method with <code>flag</code> set to
+   * {@link #IGNORE_IMMEDIATE_BEANINFO} will let it use all
+   * explicit BeanInfo classes for the beans superclasses
+   * but not for the bean class itself. Furthermore eventset,
+   * property and method information is retrieved by introspection
+   * if the explicit <code>BeanInfos</code> did not provide such data
+   * (ie. return <code>null</code> on {@link BeanInfo.getMethodDescriptors},
+   * {@link BeanInfo.getEventSetDescriptors} and
+   * {@link BeanInfo.getPropertyDescriptors}.)
+   * </p>
+   * 
+   * <p>When the method is called with <code>flag</code< set to
+   * {@link #IGNORE_ALL_BEANINFO} all the bean data is retrieved
+   * by inspecting the class.</p>
+   * 
+   * <p>Note: Any unknown value for <code>flag</code> is interpreted
+   * as {@link #IGNORE_ALL_BEANINFO}</p>.
+   * 
+   * @param beanClass The class whose BeanInfo should be returned.
+   * @param flag Controls the usage of explicit <code>BeanInfo</code> classes.
+   * @return A BeanInfo object describing the class. 
+   * @throws IntrospectionException If something goes wrong while retrieving
+   *    the bean data.
+   */
+  public static BeanInfo getBeanInfo(Class beanClass, int flag)
+    throws IntrospectionException
+  {
+    IntrospectionIncubator ii;
+    BeanInfoEmbryo infoEmbryo;
+    
+    switch(flag)
+    {
+      case USE_ALL_BEANINFO:
+        return getBeanInfo(beanClass);
+      case IGNORE_IMMEDIATE_BEANINFO:
+        Class superclass = beanClass.getSuperclass();
+        ExplicitInfo explicit = new ExplicitInfo(superclass, null);
+        
+        ii = new IntrospectionIncubator();
+        if (explicit.explicitEventSetDescriptors != null)
+          ii.setEventStopClass(superclass);
+        
+        if (explicit.explicitMethodDescriptors != null)
+          ii.setMethodStopClass(superclass);
+        
+        if (explicit.explicitPropertyDescriptors != null)
+          ii.setPropertyStopClass(superclass);
+        
+        ii.addMethods(beanClass.getMethods());
+
+        infoEmbryo = ii.getBeanInfoEmbryo();
+        merge(infoEmbryo, explicit);
+
+        infoEmbryo.setBeanDescriptor(new BeanDescriptor(beanClass, null));
+        
+        return infoEmbryo.getBeanInfo();
+      case IGNORE_ALL_BEANINFO:
+      default:
+        ii = new IntrospectionIncubator();
+        ii.addMethods(beanClass.getMethods());
+        infoEmbryo = ii.getBeanInfoEmbryo();
+        infoEmbryo.setBeanDescriptor(new BeanDescriptor(beanClass, null));
+        
+        return infoEmbryo.getBeanInfo();
+    }
+  }
+
+  /**
+   * Flush all of the Introspector's internal caches.
+   *
+   * @since 1.2
+   */
+  public static void flushCaches()
+  {
+    beanInfoCache.clear();
+
+	// Clears all the intermediate ExplicitInfo instances which
+	// have been created.
+	// This makes sure we have to retrieve stuff like BeanDescriptors
+	// again. (Remember that FeatureDescriptor can be modified by the user.)
+	ExplicitInfo.flushCaches();
+  }
+
+  /**
+   * Flush the Introspector's internal cached information for a given
+   * class.
+   *
+   * @param clz the class to be flushed.
+   * @throws NullPointerException if clz is null.
+   * @since 1.2
+   */
+  public static void flushFromCaches(Class clz)
+  {
+    synchronized (clz)
+      {
+	beanInfoCache.remove(clz);
+      }
+  }
+
+  /** Adds all explicity given bean info data to the introspected
+   * data.
+   * 
+   * @param infoEmbryo Bean info data retrieved by introspection.
+   * @param explicit Bean info data retrieved by BeanInfo classes.
+   */
+  private static void merge(BeanInfoEmbryo infoEmbryo, ExplicitInfo explicit)
+  {
+    PropertyDescriptor[] p = explicit.explicitPropertyDescriptors;
+    if(p!=null) 
+      {
+    for(int i=0;i<p.length;i++) 
+      {
+        if(!infoEmbryo.hasProperty(p[i])) 
+          {
+        infoEmbryo.addProperty(p[i]);
+          }
+      }
+    
+    // -1 should be used to denote a missing default property but
+    // for robustness reasons any value below zero is discarded.
+    // Not doing so would let Classpath fail where the JDK succeeds.
+    if(explicit.defaultProperty > -1) 
+      {
+        infoEmbryo.setDefaultPropertyName(p[explicit.defaultProperty].getName());
+      }
+      }
+    EventSetDescriptor[] e = explicit.explicitEventSetDescriptors;
+    if(e!=null) 
+      {
+    for(int i=0;i<e.length;i++) 
+      {
+        if(!infoEmbryo.hasEvent(e[i])) 
+          {
+        infoEmbryo.addEvent(e[i]);
+          }
+      }
+    
+    // -1 should be used to denote a missing default event but
+    // for robustness reasons any value below zero is discarded.
+    // Not doing so would let Classpath fail where the JDK succeeds.
+    if(explicit.defaultEvent > -1) 
+      {
+        infoEmbryo.setDefaultEventName(e[explicit.defaultEvent].getName());
+      }
+      }
+    MethodDescriptor[] m = explicit.explicitMethodDescriptors;
+    if(m!=null) 
+      {
+    for(int i=0;i<m.length;i++) 
+      {
+        if(!infoEmbryo.hasMethod(m[i])) 
+          {
+        infoEmbryo.addMethod(m[i]);
+          }
+      }
+      }
+
+    infoEmbryo.setAdditionalBeanInfo(explicit.explicitBeanInfo);
+    infoEmbryo.setIcons(explicit.im);
+    
+  }
+  
+  /** 
+   * Get the BeanInfo for class <CODE>beanClass</CODE>,
+   * first by looking for explicit information, next by
+   * using standard design patterns to determine
+   * information about the class.  It crawls up the
+   * inheritance tree until it hits <CODE>topClass</CODE>.
+   *
+   * @param beanClass the Bean class.
+   * @param stopClass the class to stop at.
+   * @return the BeanInfo object representing the class.
+   */
+  public static BeanInfo getBeanInfo(Class beanClass, Class stopClass) 
+    throws IntrospectionException 
+  {
+    ExplicitInfo explicit = new ExplicitInfo(beanClass, stopClass);
+
+    IntrospectionIncubator ii = new IntrospectionIncubator();
+    ii.setPropertyStopClass(explicit.propertyStopClass);
+    ii.setEventStopClass(explicit.eventStopClass);
+    ii.setMethodStopClass(explicit.methodStopClass);
+    ii.addMethods(beanClass.getMethods());
+    
+    BeanInfoEmbryo currentInfo = ii.getBeanInfoEmbryo();
+    
+    merge(currentInfo, explicit);
+    
+    //  Sets the info's BeanDescriptor to the one we extracted from the
+    // explicit BeanInfo instance(s) if they contained one. Otherwise we
+    // create the BeanDescriptor from scratch.
+    // Note: We do not create a copy the retrieved BeanDescriptor which will allow
+    // the user to modify the instance while it is cached. However this is how
+    // the RI does it.
+    currentInfo.setBeanDescriptor(
+        (explicit.explicitBeanDescriptor == null ? 
+            new BeanDescriptor(beanClass, null) :
+            explicit.explicitBeanDescriptor));    
+    return currentInfo.getBeanInfo();
+  }
+  
+  /** 
+   * Get the search path for BeanInfo classes.
+   *
+   * @return the BeanInfo search path.
+   */
+  public static String[] getBeanInfoSearchPath() 
+  {
+    return beanInfoSearchPath;
+  }
+  
+  /** 
+   * Set the search path for BeanInfo classes.
+   * @param beanInfoSearchPath the new BeanInfo search
+   *        path.
+   */
+  public static void setBeanInfoSearchPath(String[] beanInfoSearchPath) 
+  {
+    Introspector.beanInfoSearchPath = beanInfoSearchPath;
+  }
+  
+  /** 
+   * A helper method to convert a name to standard Java
+   * naming conventions: anything with two capitals as the
+   * first two letters remains the same, otherwise the
+   * first letter is decapitalized.  URL = URL, I = i,
+   * MyMethod = myMethod.
+   *
+   * @param name the name to decapitalize.
+   * @return the decapitalized name.
+   */
+  public static String decapitalize(String name) 
+  {
+    try 
+      {
+      if(!Character.isUpperCase(name.charAt(0))) 
+	{
+	  return name;
+	} 
+      else 
+	{
+	try 
+	  {
+	  if(Character.isUpperCase(name.charAt(1))) 
+	    {
+	      return name;
+	    } 
+	  else 
+	    {
+	      char[] c = name.toCharArray();
+	      c[0] = Character.toLowerCase(c[0]);
+	      return new String(c);
+	    }
+	  } 
+	catch(StringIndexOutOfBoundsException E) 
+	  {
+	    char[] c = new char[1];
+	    c[0] = Character.toLowerCase(name.charAt(0));
+	    return new String(c);
+	  }
+	}
+      } 
+    catch(StringIndexOutOfBoundsException E) 
+      {
+	return name;
+      } 
+    catch(NullPointerException E) 
+      {
+	return null;
+      }
+  }
+
+  static BeanInfo copyBeanInfo(BeanInfo b) 
+  {
+    java.awt.Image[] icons = new java.awt.Image[4];
+    for(int i=1;i<=4;i++) 
+      {
+	icons[i-1] = b.getIcon(i);
+      }
+
+    return new ExplicitBeanInfo(b.getBeanDescriptor(),
+				b.getAdditionalBeanInfo(),
+				b.getPropertyDescriptors(),
+				b.getDefaultPropertyIndex(),
+				b.getEventSetDescriptors(),
+				b.getDefaultEventIndex(),
+				b.getMethodDescriptors(),
+				icons);
+  }
+}
+
+class ExplicitInfo 
+{
+  BeanDescriptor explicitBeanDescriptor;
+  BeanInfo[] explicitBeanInfo;
+  
+  PropertyDescriptor[] explicitPropertyDescriptors;
+  EventSetDescriptor[] explicitEventSetDescriptors;
+  MethodDescriptor[] explicitMethodDescriptors;
+  
+  int defaultProperty;
+  int defaultEvent;
+  
+  java.awt.Image[] im = new java.awt.Image[4];
+  
+  Class propertyStopClass;
+  Class eventStopClass;
+  Class methodStopClass;
+
+  static Hashtable explicitBeanInfos = new Hashtable();
+  static Vector emptyBeanInfos = new Vector();
+
+  ExplicitInfo(Class beanClass, Class stopClass) 
+  {
+    while(beanClass != null && !beanClass.equals(stopClass)) 
+      {
+
+	BeanInfo explicit = findExplicitBeanInfo(beanClass);
+	
+
+	if(explicit != null) 
+	  {
+
+	    if(explicitBeanDescriptor == null) 
+	      {
+		explicitBeanDescriptor = explicit.getBeanDescriptor();
+	      }
+
+	    if(explicitBeanInfo == null) 
+	      {
+		explicitBeanInfo = explicit.getAdditionalBeanInfo();
+	      }
+
+	    if(explicitPropertyDescriptors == null) 
+	      {
+		if(explicit.getPropertyDescriptors() != null) 
+		  {
+		    explicitPropertyDescriptors = explicit.getPropertyDescriptors();
+		    defaultProperty = explicit.getDefaultPropertyIndex();
+		    propertyStopClass = beanClass;
+		  }
+	      }
+
+	    if(explicitEventSetDescriptors == null) 
+	      {
+		if(explicit.getEventSetDescriptors() != null) 
+		  {
+		    explicitEventSetDescriptors = explicit.getEventSetDescriptors();
+		    defaultEvent = explicit.getDefaultEventIndex();
+		    eventStopClass = beanClass;
+		  }
+	      }
+
+	    if(explicitMethodDescriptors == null) 
+	      {
+		if(explicit.getMethodDescriptors() != null) 
+		  {
+		    explicitMethodDescriptors = explicit.getMethodDescriptors();
+		    methodStopClass = beanClass;
+		  }
+	      }
+
+	    if(im[0] == null && im[1] == null 
+	       && im[2] == null && im[3] == null) 
+	      {
+		im[0] = explicit.getIcon(0);
+		im[1] = explicit.getIcon(1);
+		im[2] = explicit.getIcon(2);
+		im[3] = explicit.getIcon(3);
+	      }
+	  }
+	beanClass = beanClass.getSuperclass();
+      }
+
+    if(propertyStopClass == null) 
+      {
+	propertyStopClass = stopClass;
+      }
+
+    if(eventStopClass == null) 
+      {
+	eventStopClass = stopClass;
+      }
+
+    if(methodStopClass == null) 
+      {
+	methodStopClass = stopClass;
+      }
+  }
+  
+  /** Throws away all cached data and makes sure we re-instantiate things
+    * like BeanDescriptors again.
+    */
+  static void flushCaches() {
+	explicitBeanInfos.clear();
+	emptyBeanInfos.clear();
+  }
+  
+  static BeanInfo findExplicitBeanInfo(Class beanClass) 
+  {
+    BeanInfo retval = (BeanInfo)explicitBeanInfos.get(beanClass);
+    if(retval != null) 
+      {
+	return retval;
+      } 
+    else if(emptyBeanInfos.indexOf(beanClass) != -1) 
+      {
+	return null;
+      } 
+    else 
+      {
+	retval = reallyFindExplicitBeanInfo(beanClass);
+	if(retval != null) 
+	  {
+	    explicitBeanInfos.put(beanClass,retval);
+	  } 
+	else 
+	  {
+	    emptyBeanInfos.addElement(beanClass);
+	  }
+	return retval;
+      }
+  }
+  
+  static BeanInfo reallyFindExplicitBeanInfo(Class beanClass) 
+  {
+    ClassLoader beanClassLoader = beanClass.getClassLoader();
+    BeanInfo beanInfo;
+
+    beanInfo = getBeanInfo(beanClassLoader, beanClass.getName() + "BeanInfo");
+    if (beanInfo == null)
+      {
+	String newName;
+	newName = ClassHelper.getTruncatedClassName(beanClass) + "BeanInfo";
+
+	for(int i = 0; i < Introspector.beanInfoSearchPath.length; i++) 
+	  {
+	    if (Introspector.beanInfoSearchPath[i].equals("")) 
+	      beanInfo = getBeanInfo(beanClassLoader, newName);
+	    else 
+	      beanInfo = getBeanInfo(beanClassLoader,
+				     Introspector.beanInfoSearchPath[i] + "."
+				     + newName);
+
+		// Returns the beanInfo if it exists and the described class matches
+		// the one we searched.
+	    if (beanInfo != null && beanInfo.getBeanDescriptor() != null &&
+			beanInfo.getBeanDescriptor().getBeanClass() == beanClass)
+
+	      return beanInfo;
+	  }
+      }
+
+    return beanInfo;
+  }
+
+  /**
+   * Returns an instance of the given class name when it can be loaded
+   * through the given class loader, or null otherwise.
+   */
+  private static BeanInfo getBeanInfo(ClassLoader cl, String infoName)
+  {
+    try
+      {
+	return (BeanInfo) Class.forName(infoName, true, cl).newInstance();
+      }
+    catch (ClassNotFoundException cnfe)
+      {
+	return null;
+      }
+    catch (IllegalAccessException iae)
+      {
+	return null;
+      }
+    catch (InstantiationException ie)
+      {
+	return null;
+      }
+  }
+  
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/MethodDescriptor.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/MethodDescriptor.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/MethodDescriptor.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/MethodDescriptor.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,88 @@
+/* java.beans.MethodDescriptor
+   Copyright (C) 1998 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+import java.lang.reflect.Method;
+
+/** MethodDescriptor describes information about a JavaBeans method.
+ ** It's a fairly straightforward class (at least something in this
+ ** package is straightforward!).
+ **
+ ** @author John Keiser
+ ** @since JDK1.1
+ ** @version 1.1.0, 26 Jul 1998
+ **/
+public class MethodDescriptor extends FeatureDescriptor {
+	private Method m;
+	private ParameterDescriptor[] parameterDescriptors;
+
+	/** Create a new MethodDescriptor.
+	 ** This method sets the name to the name of the method (Method.getName()).
+	 ** @param m the method it will represent.
+	 **/
+	public MethodDescriptor(Method m) {
+		setName(m.getName());
+		this.m = m;
+	}
+
+	/** Create a new MethodDescriptor.
+	 ** This method sets the name to the name of the method (Method.getName()).
+	 ** @param m the method it will represent.
+	 ** @param parameterDescriptors descriptions of the parameters (especially names).
+	 **/
+	public MethodDescriptor(Method m, ParameterDescriptor[] parameterDescriptors) {
+		setName(m.getName());
+		this.m = m;
+		this.parameterDescriptors = parameterDescriptors;
+	}
+
+	/** Get the parameter descriptors from this method.
+	 ** Since MethodDescriptor has no way of determining what
+	 ** the parameter names were, this defaults to null.
+	 **/
+	public ParameterDescriptor[] getParameterDescriptors() {
+		return parameterDescriptors;
+	}
+
+	/** Get the method this MethodDescriptor represents. **/
+	public Method getMethod() {
+		return m;
+	}
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/ParameterDescriptor.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/ParameterDescriptor.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/ParameterDescriptor.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/ParameterDescriptor.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,52 @@
+/* java.beans.MethodDescriptor
+   Copyright (C) 1998 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+/** ParameterDescriptor represents a single parameter to a method.
+ ** As it turns out, FeatureDescriptor is sufficient to hold all
+ ** the information.  Use its constructor and methods to set
+ ** the appropriate values.
+ **
+ ** @author John Keiser
+ ** @since JDK1.1
+ ** @version 1.1.0, 26 Jul 1998
+ **/
+public class ParameterDescriptor extends FeatureDescriptor {
+	
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PersistenceDelegate.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PersistenceDelegate.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PersistenceDelegate.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PersistenceDelegate.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,90 @@
+/* java.beans.PersistenceDelegate
+   Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+/** <p>A <code>PersistenceDelegate</code> describes how a another object
+ * has to constructed and transformed in order to create a complete
+ * replicate.</p>
+ * 
+ * <p>For custom classes you will need to implement
+ * <code>PersistenceDelegate</code> in a way that is suitable for them.
+ * To make use of the implementation you have to register it with an
+ * {@link Encoder} using the {Encoder#setPersistenceDelegate} method.</p>
+ * 
+ * @author Robert Schuster (robertschuster at fsfe.org)
+ * @since 1.4
+ */
+public abstract class PersistenceDelegate
+{
+
+  protected void initialize(Class type, Object oldInstance, Object newInstance,
+                            Encoder out)
+  {
+    if (type != Object.class)
+      {
+        type = type.getSuperclass();
+
+        PersistenceDelegate pd = out.getPersistenceDelegate(type);
+        
+        pd.initialize(type, oldInstance, newInstance, out);
+      }
+  }
+
+  public void writeObject(Object oldInstance, Encoder out)
+  {
+    Object streamCandidate = out.get(oldInstance);
+
+    if (mutatesTo(oldInstance, streamCandidate))
+      {
+        initialize(oldInstance.getClass(), oldInstance, streamCandidate, out);
+      }
+    else
+      {
+        out.remove(oldInstance);
+        out.writeExpression(instantiate(oldInstance, out));
+      }
+  }
+
+  protected boolean mutatesTo(Object oldInstance, Object newInstance)
+  {
+    return (newInstance != null)
+           && oldInstance.getClass() == newInstance.getClass();
+  }
+
+  protected abstract Expression instantiate(Object oldInstance, Encoder out);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyChangeEvent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyChangeEvent.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyChangeEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyChangeEvent.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,189 @@
+/* PropertyChangeEvent.java -- describes a change in a property
+   Copyright (C) 1998, 2000, 2002, 2005  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+import java.util.EventObject;
+
+/**
+ * PropertyChangeEvents are fired in the PropertyChange and VetoableChange
+ * event classes.  They represent the old and new values as well as the
+ * source Bean. If the old or new value is a primitive type, it must be
+ * wrapped in the appropriate wrapper type (java.lang.Integer for int, etc.,
+ * etc.).
+ *
+ * <p>If the old or new values are unknown (although why that would be I do
+ * not know), they may be null. Also, if the set of properties itself has
+ * changed, the name should be null, and the old and new values may also be
+ * null. Right now Sun put in a propagationId, reserved for future use. Read
+ * the comments on the constructor and on setPropagationId for more
+ * information.
+ *
+ * @author John Keiser
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.1
+ * @status udpated to 1.4
+ */
+public class PropertyChangeEvent extends EventObject
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  private static final long serialVersionUID = 7042693688939648123L;
+
+  /**
+   * The name of the property that changed, may be null. Package visible for
+   * use by PropertyChangeSupport.
+   *
+   * @serial the changed property name
+   */
+  final String propertyName;
+
+  /**
+   * The new value of the property, may be null. Package visible for use by
+   * PropertyChangeSupport.
+   *
+   * @serial the new property value
+   */
+  final Object newValue;
+
+  /**
+   * The old value of the property, may be null. Package visible for use by
+   * PropertyChangeSupport.
+   *
+   * @serial the old property value
+   */
+  final Object oldValue;
+
+  /**
+   * The propagation ID, reserved for future use. May be null.
+   *
+   * @see #getPropagationId()
+   * @serial the Propagation ID
+   */
+  private Object propagationId;
+
+  /**
+   * Create a new PropertyChangeEvent. Remember that if you received a
+   * PropertyChangeEvent and are sending a new one, you should also set the
+   * propagation ID from the old PropertyChangeEvent.
+   *
+   * @param source the Bean containing the property
+   * @param propertyName the property's name
+   * @param oldVal the old value of the property
+   * @param newVal the new value of the property
+   * @throws IllegalArgumentException if source is null
+   */
+  public PropertyChangeEvent(Object source, String propertyName,
+                             Object oldVal, Object newVal)
+  {
+    super(source);
+    this.propertyName = propertyName;
+    oldValue = oldVal;
+    newValue = newVal;
+  }
+
+  /**
+   * Get the property name. May be null if multiple properties changed.
+   *
+   * @return the property name
+   */
+  public String getPropertyName()
+  {
+    return propertyName;
+  }
+
+  /**
+   * Get the property's new value. May be null if multiple properties changed.
+   *
+   * @return the property's new value
+   */
+  public Object getNewValue()
+  {
+    return newValue;
+  }
+
+  /**
+   * Get the property's old value. May be null if multiple properties changed.
+   *
+   * @return the property's old value
+   */
+  public Object getOldValue()
+  {
+    return oldValue;
+  }
+
+  /**
+   * Set the propagation ID.  This is a way for the event to be passed from
+   * hand to hand and retain a little extra state.  Right now it is unused,
+   * but it should be propagated anyway so that future versions of JavaBeans
+   * can use it, for God knows what.
+   *
+   * @param propagationId the propagation ID
+   * @see #getPropagationId()
+   */
+  public void setPropagationId(Object propagationId)
+  {
+    this.propagationId = propagationId;
+  }
+
+  /**
+   * Get the propagation ID. Right now, it is not used for anything.
+   *
+   * @return the propagation ID
+   * @see #setPropagationId(Object)
+   */
+  public Object getPropagationId()
+  {
+    return propagationId;
+  }
+
+  /**
+   * Utility method to rollback a change.
+   *
+   * @param event the event to rollback
+   * @return a new event with old and new swapped
+   */
+  PropertyChangeEvent rollback()
+  {
+    PropertyChangeEvent result
+      = new PropertyChangeEvent(source, propertyName, newValue, oldValue);
+    result.propagationId = propagationId;
+    return result;
+  }
+} // class PropertyChangeEvent

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyChangeListener.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyChangeListener.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyChangeListener.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyChangeListener.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,61 @@
+/* PropertyChangeListener.java -- listen for changes in a bound property
+   Copyright (C) 1998, 2000, 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+import java.util.EventListener;
+
+/**
+ * PropertyChangeListener allows a class to monitor properties of a Bean for
+ * changes. A propertyChange() event will only be fired <em>after</em> the
+ * property has changed.
+ *
+ * @author John Keiser
+ * @see PropertyChangeSupport
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public interface PropertyChangeListener extends EventListener
+{
+  /**
+   * Fired after a Bean's property has changed.
+   *
+   * @param e the change (containing the old and new values)
+   */
+  void propertyChange(PropertyChangeEvent e);
+} // interface PropertyChangeListener

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyChangeListenerProxy.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyChangeListenerProxy.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyChangeListenerProxy.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyChangeListenerProxy.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,102 @@
+/* PropertyChangeListenerProxy.java -- adds a name to a property listener
+   Copyright (C) 2002, 2005  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+import java.util.EventListenerProxy;
+
+/**
+ * This class provides an extension to <code>PropertyChangeListener</code> -
+ * associating a name with the listener. This can be used to filter the
+ * changes that one is interested in.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.4
+ * @status udpated to 1.4
+ */
+public class PropertyChangeListenerProxy extends EventListenerProxy
+  implements PropertyChangeListener
+{
+  /**
+   * The name of the property to listen for. Package visible for use by
+   * PropertyChangeSupport.
+   */
+  final String propertyName;
+
+  /**
+   * Create a new proxy which filters property change events and only passes
+   * changes to the named property on to the delegate. A null propertyName
+   * or listener does not fail now, but may cause a NullPointerException down
+   * the road.
+   *
+   * @param propertyName the property's name to filter on
+   * @param listener the delegate listener
+   */
+  public PropertyChangeListenerProxy(String propertyName,
+                                     PropertyChangeListener listener)
+  {
+    super(listener);
+    this.propertyName = propertyName;
+  }
+
+  /**
+   * Forwards the event on to the delegate if the property name matches.
+   *
+   * @param event the event to pass on, if it meets the filter
+   * @throws NullPointerException if the delegate this was created with is null
+   */
+  public void propertyChange(PropertyChangeEvent event)
+  {
+    // Note: Sun does not filter, under the assumption that since
+    // PropertyChangeSupport unwraps proxys, this method should never be
+    // called by normal use of listeners.
+    String name = event == null ? null : event.getPropertyName();
+    if (name == null ? propertyName == null : name.equals(propertyName))
+      ((PropertyChangeListener) getListener()).propertyChange(event);
+  }
+
+  /**
+   * Gets the name of the property this proxy is filtering on.
+   *
+   * @return the property name
+   */
+  public String getPropertyName()
+  {
+    return propertyName;
+  }
+} // class PropertyChangeListenerProxy

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyChangeSupport.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyChangeSupport.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyChangeSupport.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyChangeSupport.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,545 @@
+/* PropertyChangeSupport.java -- support to manage property change listeners
+   Copyright (C) 1998, 1999, 2000, 2002, 2005, 2006
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Vector;
+
+/**
+ * PropertyChangeSupport makes it easy to fire property change events and
+ * handle listeners. It allows chaining of listeners, as well as filtering
+ * by property name. In addition, it will serialize only those listeners
+ * which are serializable, ignoring the others without problem. This class
+ * is thread-safe.
+ *
+ * @author John Keiser
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class PropertyChangeSupport implements Serializable
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  private static final long serialVersionUID = 6401253773779951803L;
+
+  /**
+   * Maps property names (String) to named listeners (PropertyChangeSupport).
+   * If this is a child instance, this field will be null.
+   *
+   * @serial the map of property names to named listener managers
+   * @since 1.2
+   */
+  private Hashtable children;
+
+  /**
+   * The non-null source object for any generated events.
+   *
+   * @serial the event source
+   */
+  private final Object source;
+
+  /**
+   * A field to compare serialization versions - this class uses version 2.
+   *
+   * @serial the serialization format
+   */
+  private static final int propertyChangeSupportSerializedDataVersion = 2;
+
+  /**
+   * The list of all registered property listeners. If this instance was
+   * created by user code, this only holds the global listeners (ie. not tied
+   * to a name), and may be null. If it was created by this class, as a
+   * helper for named properties, then this vector will be non-null, and this
+   * instance appears as a value in the <code>children</code> hashtable of
+   * another instance, so that the listeners are tied to the key of that
+   * hashtable entry.
+   */
+  private transient Vector listeners;
+
+  /**
+   * Create a PropertyChangeSupport to work with a specific source bean.
+   *
+   * @param source the source bean to use
+   * @throws NullPointerException if source is null
+   */
+  public PropertyChangeSupport(Object source)
+  {
+    this.source = source;
+    if (source == null)
+      throw new NullPointerException();
+  }
+
+  /**
+   * Adds a PropertyChangeListener to the list of global listeners. All
+   * property change events will be sent to this listener. The listener add
+   * is not unique: that is, <em>n</em> adds with the same listener will
+   * result in <em>n</em> events being sent to that listener for every
+   * property change. Adding a null listener is silently ignored.
+   * This method will unwrap a PropertyChangeListenerProxy,
+   * registering the underlying delegate to the named property list.
+   *
+   * @param l the listener to add
+   */
+  public synchronized void addPropertyChangeListener(PropertyChangeListener l)
+  {
+    if (l == null)
+      return;
+
+    if (l instanceof PropertyChangeListenerProxy)
+      {
+        PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
+        addPropertyChangeListener(p.propertyName,
+                                  (PropertyChangeListener) p.getListener());
+      }
+    else
+      {
+        if (listeners == null)
+          listeners = new Vector();
+        listeners.add(l);
+      }
+  }
+
+  /**
+   * Removes a PropertyChangeListener from the list of global listeners. If
+   * any specific properties are being listened on, they must be deregistered
+   * by themselves; this will only remove the general listener to all
+   * properties. If <code>add()</code> has been called multiple times for a
+   * particular listener, <code>remove()</code> will have to be called the
+   * same number of times to deregister it. This method will unwrap a
+   * PropertyChangeListenerProxy, removing the underlying delegate from the
+   * named property list.
+   *
+   * @param l the listener to remove
+   */
+  public synchronized void
+    removePropertyChangeListener(PropertyChangeListener l)
+  {
+    if (l instanceof PropertyChangeListenerProxy)
+      {
+        PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
+        removePropertyChangeListener(p.propertyName,
+                                     (PropertyChangeListener) p.getListener());
+      }
+    else if (listeners != null)
+      {
+        listeners.remove(l);
+        if (listeners.isEmpty())
+          listeners = null;
+      }
+  }
+
+  /**
+   * Returns an array of all registered property change listeners. Those that
+   * were registered under a name will be wrapped in a
+   * <code>PropertyChangeListenerProxy</code>, so you must check whether the
+   * listener is an instance of the proxy class in order to see what name the
+   * real listener is registered under. If there are no registered listeners,
+   * this returns an empty array.
+   *
+   * @return the array of registered listeners
+   * @see PropertyChangeListenerProxy
+   * @since 1.4
+   */
+  public synchronized PropertyChangeListener[] getPropertyChangeListeners()
+  {
+    ArrayList list = new ArrayList();
+    if (listeners != null)
+      list.addAll(listeners);
+    if (children != null)
+      {
+        int i = children.size();
+        Iterator iter = children.entrySet().iterator();
+        while (--i >= 0)
+          {
+            Entry e = (Entry) iter.next();
+            String name = (String) e.getKey();
+            Vector v = ((PropertyChangeSupport) e.getValue()).listeners;
+            int j = v.size();
+            while (--j >= 0)
+              list.add(new PropertyChangeListenerProxy
+                (name, (PropertyChangeListener) v.get(j)));
+          }
+      }
+    return (PropertyChangeListener[])
+      list.toArray(new PropertyChangeListener[list.size()]);
+  }
+
+  /**
+   * Adds a PropertyChangeListener listening on the specified property. Events
+   * will be sent to the listener only if the property name matches. The
+   * listener add is not unique; that is, <em>n</em> adds on a particular
+   * property for a particular listener will result in <em>n</em> events
+   * being sent to that listener when that property is changed. The effect is
+   * cumulative, too; if you are registered to listen to receive events on
+   * all property changes, and then you register on a particular property,
+   * you will receive change events for that property twice. Adding a null
+   * listener is silently ignored. This method will unwrap a
+   * PropertyChangeListenerProxy, registering the underlying
+   * delegate to the named property list if the names match, and discarding
+   * it otherwise.
+   *
+   * @param propertyName the name of the property to listen on
+   * @param l the listener to add
+   * @throws NullPointerException if propertyName is null
+   */
+  public synchronized void addPropertyChangeListener(String propertyName,
+                                                     PropertyChangeListener l)
+  {
+    if (l == null)
+      return;
+
+    while (l instanceof PropertyChangeListenerProxy)
+      {
+        PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
+        if (propertyName == null ? p.propertyName != null
+            : ! propertyName.equals(p.propertyName))
+          return;
+        l = (PropertyChangeListener) p.getListener();
+      }
+    PropertyChangeSupport s = null;
+    if (children == null)
+      children = new Hashtable();
+    else
+      s = (PropertyChangeSupport) children.get(propertyName);
+    if (s == null)
+      {
+        s = new PropertyChangeSupport(source);
+        s.listeners = new Vector();
+        children.put(propertyName, s);
+      }
+    s.listeners.add(l);
+  }
+
+  /**
+   * Removes a PropertyChangeListener from listening to a specific property.
+   * If <code>add()</code> has been called multiple times for a particular
+   * listener on a property, <code>remove()</code> will have to be called the
+   * same number of times to deregister it. This method will unwrap a
+   * PropertyChangeListenerProxy, removing the underlying delegate from the
+   * named property list if the names match.
+   *
+   * @param propertyName the property to stop listening on
+   * @param l the listener to remove
+   * @throws NullPointerException if propertyName is null
+   */
+  public synchronized void
+    removePropertyChangeListener(String propertyName, PropertyChangeListener l)
+  {
+    if (children == null)
+      return;
+    PropertyChangeSupport s
+      = (PropertyChangeSupport) children.get(propertyName);
+    if (s == null)
+      return;
+    while (l instanceof PropertyChangeListenerProxy)
+      {
+        PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
+        if (propertyName == null ? p.propertyName != null
+            : ! propertyName.equals(p.propertyName))
+          return;
+        l = (PropertyChangeListener) p.getListener();
+      }
+    s.listeners.remove(l);
+    if (s.listeners.isEmpty())
+      {
+        children.remove(propertyName);
+        if (children.isEmpty())
+          children = null;
+      }
+  }
+
+  /**
+   * Returns an array of all property change listeners registered under the
+   * given property name. If there are no registered listeners, or
+   * propertyName is null, this returns an empty array.
+   *
+   * @return the array of registered listeners
+   * @since 1.4
+   */
+  public synchronized PropertyChangeListener[]
+    getPropertyChangeListeners(String propertyName)
+  {
+    if (children == null || propertyName == null)
+      return new PropertyChangeListener[0];
+    PropertyChangeSupport s
+      = (PropertyChangeSupport) children.get(propertyName);
+    if (s == null)
+      return new PropertyChangeListener[0];
+    return (PropertyChangeListener[])
+      s.listeners.toArray(new PropertyChangeListener[s.listeners.size()]);
+  }
+
+  /**
+   * Fire a PropertyChangeEvent containing the old and new values of the
+   * property to all the global listeners, and to all the listeners for the
+   * specified property name. This does nothing if old and new are non-null
+   * and equal.
+   *
+   * @param propertyName the name of the property that changed
+   * @param oldVal the old value
+   * @param newVal the new value
+   */
+  public void firePropertyChange(String propertyName,
+                                 Object oldVal, Object newVal)
+  {
+    firePropertyChange(new PropertyChangeEvent(source, propertyName,
+                                               oldVal, newVal));
+  }
+
+  /**
+   * Fire a PropertyChangeEvent containing the old and new values of the
+   * property to all the global listeners, and to all the listeners for the
+   * specified property name. This does nothing if old and new are equal.
+   *
+   * @param propertyName the name of the property that changed
+   * @param oldVal the old value
+   * @param newVal the new value
+   */
+  public void firePropertyChange(String propertyName, int oldVal, int newVal)
+  {
+    if (oldVal != newVal)
+      firePropertyChange(new PropertyChangeEvent(source, propertyName,
+                                                 new Integer(oldVal),
+                                                 new Integer(newVal)));
+  }
+
+  /**
+   * Fire a PropertyChangeEvent containing the old and new values of the
+   * property to all the global listeners, and to all the listeners for the
+   * specified property name. This does nothing if old and new are equal.
+   *
+   * @param propertyName the name of the property that changed
+   * @param oldVal the old value
+   * @param newVal the new value
+   */
+  public void firePropertyChange(String propertyName,
+                                 boolean oldVal, boolean newVal)
+  {
+    if (oldVal != newVal)
+      firePropertyChange(new PropertyChangeEvent(source, propertyName,
+                                                 Boolean.valueOf(oldVal),
+                                                 Boolean.valueOf(newVal)));
+  }
+
+  /**
+   * Fire a PropertyChangeEvent to all the global listeners, and to all the
+   * listeners for the specified property name. This does nothing if old and
+   * new values of the event are equal.
+   *
+   * @param event the event to fire
+   * @throws NullPointerException if event is null
+   */
+  public void firePropertyChange(PropertyChangeEvent event)
+  {
+    if (event.oldValue != null && event.oldValue.equals(event.newValue))
+      return;
+    Vector v = listeners; // Be thread-safe.
+    if (v != null)
+      {
+        int i = v.size();
+        while (--i >= 0)
+          ((PropertyChangeListener) v.get(i)).propertyChange(event);
+      }
+    Hashtable h = children; // Be thread-safe.
+    if (h != null && event.propertyName != null)
+      {
+        PropertyChangeSupport s
+          = (PropertyChangeSupport) h.get(event.propertyName);
+        if (s != null)
+          {
+            v = s.listeners; // Be thread-safe.
+            int i = v == null ? 0 : v.size();
+            while (--i >= 0)
+              ((PropertyChangeListener) v.get(i)).propertyChange(event);
+          }
+      }
+  }
+
+  /**
+   * Fire an indexed property change event.  This will only fire
+   * an event if the old and new values are not equal and not null. 
+   * @param name the name of the property which changed
+   * @param index the index of the property which changed
+   * @param oldValue the old value of the property
+   * @param newValue the new value of the property
+   * @since 1.5
+   */
+  public void fireIndexedPropertyChange(String name, int index,
+                                        Object oldValue, Object newValue)
+  {
+    // Argument checking is done in firePropertyChange(PropertyChangeEvent) .
+    firePropertyChange(new IndexedPropertyChangeEvent(source, name,
+                                                      oldValue, newValue,
+                                                      index));
+  }
+
+  /**
+   * Fire an indexed property change event.  This will only fire
+   * an event if the old and new values are not equal.
+   * @param name the name of the property which changed
+   * @param index the index of the property which changed
+   * @param oldValue the old value of the property
+   * @param newValue the new value of the property
+   * @since 1.5
+   */
+  public void fireIndexedPropertyChange(String name, int index,
+                                        int oldValue, int newValue)
+  {
+    if (oldValue != newValue)
+      fireIndexedPropertyChange(name, index, Integer.valueOf(oldValue),
+                                Integer.valueOf(newValue));
+  }
+
+  /**
+   * Fire an indexed property change event.  This will only fire
+   * an event if the old and new values are not equal.
+   * @param name the name of the property which changed
+   * @param index the index of the property which changed
+   * @param oldValue the old value of the property
+   * @param newValue the new value of the property
+   * @since 1.5
+   */
+  public void fireIndexedPropertyChange(String name, int index,
+                                        boolean oldValue, boolean newValue)
+  {
+    if (oldValue != newValue)
+      fireIndexedPropertyChange(name, index, Boolean.valueOf(oldValue),
+                                Boolean.valueOf(newValue));
+  }
+
+  /**
+   * Tell whether the specified property is being listened on or not. This
+   * will only return <code>true</code> if there are listeners on all
+   * properties or if there is a listener specifically on this property.
+   *
+   * @param propertyName the property that may be listened on
+   * @return whether the property is being listened on
+   */
+  public synchronized boolean hasListeners(String propertyName)
+  {
+    return listeners != null || (children != null
+                                 && children.get(propertyName) != null);
+  }
+
+  /**
+   * Saves the state of the object to the stream.
+   *
+   * @param s the stream to write to
+   * @throws IOException if anything goes wrong
+   * @serialData this writes out a null-terminated list of serializable
+   *             global property change listeners (the listeners for a named
+   *             property are written out as the global listeners of the
+   *             children, when the children hashtable is saved)
+   */
+  private synchronized void writeObject(ObjectOutputStream s)
+    throws IOException
+  {
+    s.defaultWriteObject();
+    if (listeners != null)
+      {
+        int i = listeners.size();
+        while (--i >= 0)
+          if (listeners.get(i) instanceof Serializable)
+            s.writeObject(listeners.get(i));
+      }
+    s.writeObject(null);
+  }
+
+  /**
+   * Reads the object back from stream (deserialization).
+   *
+   * XXX Since serialization for 1.1 streams was not documented, this may
+   * not work if propertyChangeSupportSerializedDataVersion is 1.
+   *
+   * @param s the stream to read from
+   * @throws IOException if reading the stream fails
+   * @throws ClassNotFoundException if deserialization fails
+   * @serialData this reads in a null-terminated list of serializable
+   *             global property change listeners (the listeners for a named
+   *             property are written out as the global listeners of the
+   *             children, when the children hashtable is saved)
+   */
+  private void readObject(ObjectInputStream s)
+    throws IOException, ClassNotFoundException
+  {
+    s.defaultReadObject();
+    PropertyChangeListener l = (PropertyChangeListener) s.readObject();
+    while (l != null)
+      {
+        addPropertyChangeListener(l);
+        l = (PropertyChangeListener) s.readObject();
+      }
+    // Sun is not as careful with children as we are, and lets some proxys
+    // in that can never receive events. So, we clean up anything that got
+    // serialized, to make sure our invariants hold.
+    if (children != null)
+      {
+        int i = children.size();
+        Iterator iter = children.entrySet().iterator();
+        while (--i >= 0)
+          {
+            Entry e = (Entry) iter.next();
+            String name = (String) e.getKey();
+            PropertyChangeSupport pcs = (PropertyChangeSupport) e.getValue();
+            if (pcs.listeners == null)
+              pcs.listeners = new Vector();
+            if (pcs.children != null)
+              pcs.listeners.addAll
+                (Arrays.asList(pcs.getPropertyChangeListeners(name)));
+            if (pcs.listeners.size() == 0)
+              iter.remove();
+            else
+              pcs.children = null;
+          }
+        if (children.size() == 0)
+          children = null;
+      }
+  }
+} // class PropertyChangeSupport

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyDescriptor.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyDescriptor.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyDescriptor.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyDescriptor.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,665 @@
+/* java.beans.PropertyDescriptor
+   Copyright (C) 1998, 2001, 2004, 2005  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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ ** PropertyDescriptor describes information about a JavaBean property,
+ ** by which we mean a property that has been exposed via a pair of
+ ** get and set methods.  (There may be no get method, which means
+ ** the property is write-only, or no set method, which means the
+ ** the property is read-only.)<P>
+ **
+ ** The constraints put on get and set methods are:<P>
+ ** <OL>
+ ** <LI>A get method must have signature
+ **     <CODE><propertyType> <getMethodName>()</CODE></LI>
+ ** <LI>A set method must have signature
+ **     <CODE>void <setMethodName>(<propertyType>)</CODE></LI>
+ ** <LI>Either method type may throw any exception.</LI>
+ ** <LI>Both methods must be public.</LI>
+ ** </OL>
+ **
+ ** @author John Keiser
+ ** @author Robert Schuster (thebohemian at gmx.net)
+ ** @since 1.1
+ ** @status updated to 1.4
+ **/
+public class PropertyDescriptor extends FeatureDescriptor
+{
+    Class propertyType;
+    Method getMethod;
+    Method setMethod;
+
+    Class propertyEditorClass;
+    boolean bound;
+    boolean constrained;
+
+    PropertyDescriptor(String name)
+    {
+        setName(name);
+    }
+
+    /** Create a new PropertyDescriptor by introspection.
+     ** This form of constructor creates the PropertyDescriptor by
+     ** looking for a getter method named <CODE>get<name>()</CODE>
+     ** (or, optionally, if the property is boolean,
+     ** <CODE>is<name>()</CODE>) and
+     ** <CODE>set<name>()</CODE> in class
+     ** <CODE><beanClass></CODE>, where <name> has its
+     ** first letter capitalized by the constructor.<P>
+     **
+     ** Note that using this constructor the given property must be read- <strong>and</strong>
+     ** writeable. If the implementation does not both, a read and a write method, an
+     ** <code>IntrospectionException</code> is thrown.
+     **
+     ** <B>Implementation note:</B> If there is both are both isXXX and
+     ** getXXX methods, the former is used in preference to the latter.
+     ** We do not check that an isXXX method returns a boolean. In both
+     ** cases, this matches the behaviour of JDK 1.4<P>
+     **
+     ** @param name the programmatic name of the property, usually
+     **             starting with a lowercase letter (e.g. fooManChu
+     **             instead of FooManChu).
+     ** @param beanClass the class the get and set methods live in.
+     ** @exception IntrospectionException if the methods are not found 
+     **            or invalid.
+     **/
+    public PropertyDescriptor(String name, Class beanClass)
+        throws IntrospectionException
+    {
+        setName(name);
+        if (name.length() == 0)
+        {
+            throw new IntrospectionException("empty property name");
+        }
+        String caps = Character.toUpperCase(name.charAt(0)) + name.substring(1);
+        findMethods(beanClass, "is" + caps, "get" + caps, "set" + caps);
+
+        if (getMethod == null)
+        {
+            throw new IntrospectionException(
+                "Cannot find a is" + caps + " or get" + caps + " method");
+        }
+
+        if (setMethod == null)
+        {
+            throw new IntrospectionException(
+                "Cannot find a " + caps + " method");
+        }
+
+        // finally check the methods compatibility        
+        propertyType = checkMethods(getMethod, setMethod);
+    }
+
+    /** Create a new PropertyDescriptor by introspection.
+     ** This form of constructor allows you to specify the
+     ** names of the get and set methods to search for.<P>
+     **
+     ** <B>Implementation note:</B> If there is a get method (or
+     ** boolean isXXX() method), then the return type of that method
+     ** is used to find the set method.  If there is no get method,
+     ** then the set method is searched for exhaustively.<P>
+     **
+     ** <B>Spec note:</B>
+     ** If there is no get method and multiple set methods with
+     ** the same name and a single parameter (different type of course),
+     ** then an IntrospectionException is thrown.  While Sun's spec
+     ** does not state this, it can make Bean behavior different on
+     ** different systems (since method order is not guaranteed) and as
+     ** such, can be treated as a bug in the spec.  I am not aware of
+     ** whether Sun's implementation catches this.
+     **
+     ** @param name the programmatic name of the property, usually
+     **             starting with a lowercase letter (e.g. fooManChu
+     **             instead of FooManChu).
+     ** @param beanClass the class the get and set methods live in.
+     ** @param getMethodName the name of the get method or <code>null</code> if the property is write-only.
+     ** @param setMethodName the name of the set method or <code>null</code> if the property is read-only.
+     ** @exception IntrospectionException if the methods are not found 
+     **            or invalid.
+     **/
+    public PropertyDescriptor(
+        String name,
+        Class beanClass,
+        String getMethodName,
+        String setMethodName)
+        throws IntrospectionException
+    {
+        setName(name);
+        findMethods(beanClass, getMethodName, null, setMethodName);
+
+        if (getMethod == null && getMethodName != null)
+        {
+            throw new IntrospectionException(
+                "Cannot find a getter method called " + getMethodName);
+        }
+
+        if (setMethod == null && setMethodName != null)
+        {
+            throw new IntrospectionException(
+                "Cannot find a setter method called " + setMethodName);
+        }
+
+        propertyType = checkMethods(getMethod, setMethod);
+    }
+
+    /** Create a new PropertyDescriptor using explicit Methods.
+     ** Note that the methods will be checked for conformance to standard
+     ** Property method rules, as described above at the top of this class.
+     **<br>
+     ** It is possible to call this method with both <code>Method</code> arguments
+     ** being <code>null</code>. In such a case the property type is <code>null</code>.
+     ** 
+     ** @param name the programmatic name of the property, usually
+     **             starting with a lowercase letter (e.g. fooManChu
+     **             instead of FooManChu).
+     ** @param readMethod the read method or <code>null</code> if the property is write-only.
+     ** @param writeMethod the write method or <code>null</code> if the property is read-only.
+     ** @exception IntrospectionException if the methods are not found 
+     **            or invalid.
+     **/
+    public PropertyDescriptor(
+        String name,
+        Method readMethod,
+        Method writeMethod)
+        throws IntrospectionException
+    {
+        setName(name);
+        getMethod = readMethod;
+        setMethod = writeMethod;
+        propertyType = checkMethods(getMethod, setMethod);
+    }
+
+    /** Get the property type.
+     ** This is the type the get method returns and the set method
+     ** takes in.
+     **/
+    public Class getPropertyType()
+    {
+        return propertyType;
+    }
+
+    /** Get the get method.  Why they call it readMethod here and
+     ** get everywhere else is beyond me.
+     **/
+    public Method getReadMethod()
+    {
+        return getMethod;
+    }
+
+    /** Sets the read method.<br/>
+     * The read method is used to retrieve the value of a property. A legal
+     * read method must have no arguments. Its return type must not be
+     * <code>void</code>. If this methods succeeds the property type
+     * is adjusted to the return type of the read method.<br/>
+     * <br/>
+     * It is legal to set the read and the write method to <code>null</code>
+     * or provide method which have been declared in distinct classes.
+     * 
+     * @param readMethod The new method to be used or <code>null</code>.
+     * @throws IntrospectionException If the given method is invalid.
+     * @since 1.2
+     */
+    public void setReadMethod(Method readMethod) throws IntrospectionException
+    {
+        propertyType = checkMethods(readMethod, setMethod);
+
+        getMethod = readMethod;
+    }
+
+    /** Get the set method.  Why they call it writeMethod here and
+     ** set everywhere else is beyond me.
+     **/
+    public Method getWriteMethod()
+    {
+        return setMethod;
+    }
+
+    /** Sets the write method.<br/>
+     * The write method is used to set the value of a property. A legal write method
+     * must have a single argument which can be assigned to the property. If no
+     * read method exists the property type changes to the argument type of the
+     * write method.<br/>
+     * <br/>
+     * It is legal to set the read and the write method to <code>null</code>
+     * or provide method which have been declared in distinct classes.
+     * 
+     * @param writeMethod The new method to be used or <code>null</code>.
+     * @throws IntrospectionException If the given method is invalid.
+     * @since 1.2
+     */
+    public void setWriteMethod(Method writeMethod)
+        throws IntrospectionException
+    {
+        propertyType = checkMethods(getMethod, writeMethod);
+
+        setMethod = writeMethod;
+    }
+
+    /** Get whether the property is bound.  Defaults to false. **/
+    public boolean isBound()
+    {
+        return bound;
+    }
+
+    /** Set whether the property is bound.
+     ** As long as the the bean implements addPropertyChangeListener() and
+     ** removePropertyChangeListener(), setBound(true) may safely be called.<P>
+     ** If these things are not true, then the behavior of the system
+     ** will be undefined.<P>
+     **
+     ** When a property is bound, its set method is required to fire the
+     ** <CODE>PropertyChangeListener.propertyChange())</CODE> event
+     ** after the value has changed.
+     ** @param bound whether the property is bound or not.
+     **/
+    public void setBound(boolean bound)
+    {
+        this.bound = bound;
+    }
+
+    /** Get whether the property is constrained.  Defaults to false. **/
+    public boolean isConstrained()
+    {
+        return constrained;
+    }
+
+    /** Set whether the property is constrained.
+     ** If the set method throws <CODE>java.beans.PropertyVetoException</CODE>
+     ** (or subclass thereof) and the bean implements addVetoableChangeListener()
+     ** and removeVetoableChangeListener(), then setConstrained(true) may safely
+     ** be called.  Otherwise, the system behavior is undefined.
+     ** <B>Spec note:</B> given those strict parameters, it would be nice if it
+     ** got set automatically by detection, but oh well.<P>
+     ** When a property is constrained, its set method is required to:<P>
+     ** <OL>
+     ** <LI>Fire the <CODE>VetoableChangeListener.vetoableChange()</CODE>
+     **     event notifying others of the change and allowing them a chance to
+     **     say it is a bad thing.</LI>
+     ** <LI>If any of the listeners throws a PropertyVetoException, then
+     **     it must fire another vetoableChange() event notifying the others
+     **     of a reversion to the old value (though, of course, the change
+     **     was never made).  Then it rethrows the PropertyVetoException and
+     **     exits.</LI>
+     ** <LI>If all has gone well to this point, the value may be changed.</LI>
+     ** </OL>
+     ** @param constrained whether the property is constrained or not.
+     **/
+    public void setConstrained(boolean constrained)
+    {
+        this.constrained = constrained;
+    }
+
+    /** Get the PropertyEditor class.  Defaults to null. **/
+    public Class getPropertyEditorClass()
+    {
+        return propertyEditorClass;
+    }
+
+    /** Set the PropertyEditor class.  If the class does not implement
+     ** the PropertyEditor interface, you will likely get an exception
+     ** late in the game.
+     ** @param propertyEditorClass the PropertyEditor class for this 
+     **        class to use.
+     **/
+    public void setPropertyEditorClass(Class propertyEditorClass)
+    {
+        this.propertyEditorClass = propertyEditorClass;
+    }
+
+    /**
+     * Instantiate a property editor using the property editor class.
+     * If no property editor class has been set, this will return null.
+     * If the editor class has a public constructor which takes a single
+     * argument, that will be used and the bean parameter will be passed
+     * to it.  Otherwise, a public no-argument constructor will be used,
+     * if available.  This method will return null if no constructor is
+     * found or if construction fails for any reason.
+     * @param bean the argument to the constructor
+     * @return a new PropertyEditor, or null on error
+     * @since 1.5
+     */
+    public PropertyEditor createPropertyEditor(Object bean)
+    {
+      if (propertyEditorClass == null)
+        return null;
+      Constructor c = findConstructor(propertyEditorClass,
+                                      new Class[] { Object.class });
+      if (c != null)
+        return instantiateClass(c, new Object[] { bean });
+      c = findConstructor(propertyEditorClass, null);
+      if (c != null)
+        return instantiateClass(c, null);
+      return null;
+    }
+
+    // Helper method to look up a constructor and return null if it is not
+    // found.
+    private Constructor findConstructor(Class k, Class[] argTypes)
+    {
+      try
+        {
+          return k.getConstructor(argTypes);
+        }
+      catch (NoSuchMethodException _)
+        {
+          return null;
+        }
+    }
+
+    // Helper method to instantiate an object but return null on error.
+    private PropertyEditor instantiateClass(Constructor c, Object[] args)
+    {
+      try
+        {
+          return (PropertyEditor) c.newInstance(args);
+        }
+      catch (InstantiationException _)
+        {
+          return null;
+        }
+      catch (InvocationTargetException _)
+        {
+          return null;
+        }
+      catch (IllegalAccessException _)
+        {
+          return null;
+        }
+      catch (ClassCastException _)
+        {
+          return null;
+        }
+    }
+
+    private void findMethods(
+        Class beanClass,
+        String getMethodName1,
+        String getMethodName2,
+        String setMethodName)
+        throws IntrospectionException
+    {
+        try
+        {
+            // Try the first get method name
+            if (getMethodName1 != null)
+            {
+                try
+                {
+                    getMethod =
+                        beanClass.getMethod(getMethodName1, new Class[0]);
+                }
+                catch (NoSuchMethodException e)
+                {}
+            }
+
+            // Fall back to the second get method name
+            if (getMethod == null && getMethodName2 != null)
+            {
+                try
+                {
+                    getMethod =
+                        beanClass.getMethod(getMethodName2, new Class[0]);
+                }
+                catch (NoSuchMethodException e)
+                {}
+            }
+
+            // Try the set method name
+            if (setMethodName != null)
+            {
+                if (getMethod != null)
+                {
+                    // If there is a get method, use its return type to help
+                    // select the corresponding set method.
+                    Class propertyType = getMethod.getReturnType();
+                    if (propertyType == Void.TYPE)
+                    {
+                        String msg =
+                            "The property's read method has return type 'void'";
+                        throw new IntrospectionException(msg);
+                    }
+
+                    Class[] setArgs = new Class[] { propertyType };
+                    try
+                    {
+                        setMethod = beanClass.getMethod(setMethodName, setArgs);
+                    }
+                    catch (NoSuchMethodException e)
+                    {}
+                }
+                else if (getMethodName1 == null && getMethodName2 == null)
+                {
+                    // If this is a write-only property, choose the first set method
+                    // with the required name, one parameter and return type 'void'
+                    Method[] methods = beanClass.getMethods();
+                    for (int i = 0; i < methods.length; i++)
+                    {
+                        if (methods[i].getName().equals(setMethodName)
+                            && methods[i].getParameterTypes().length == 1
+                            && methods[i].getReturnType() == Void.TYPE)
+                        {
+                            setMethod = methods[i];
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+        catch (SecurityException e)
+        {
+            // FIXME -- shouldn't we just allow SecurityException to propagate?
+            String msg =
+                "SecurityException thrown on attempt to access methods.";
+            throw new IntrospectionException(msg);
+        }
+    }
+
+    /** Checks whether the given <code>Method</code> instances are legal read and
+     * write methods. The following requirements must be met:<br/>
+     * <ul>
+     * <li>the read method must not have an argument</li>
+     * <li>the read method must have a non void return type</li>
+     * <li>the read method may not exist</li>
+     * <li>the write method must have a single argument</li>
+     * <li>the property type and the read method's return type must be assignable from the
+     * write method's argument type</li>
+     * <li>the write method may not exist</li>
+     * </ul>
+     * While checking the methods a common new property type is calculated. If the method
+     * succeeds this property type is returned.<br/>
+     * <br/>
+     * For compatibility this has to be noted:<br/>
+     * The two methods are allowed to be defined in two distinct classes and may both be null.
+     * 
+     * @param readMethod The new read method to check.
+     * @param writeMethod The new write method to check.
+     * @return The common property type of the two method.
+     * @throws IntrospectionException If any of the above requirements are not met.
+     */
+    private Class checkMethods(Method readMethod, Method writeMethod)
+        throws IntrospectionException
+    {
+        Class newPropertyType = propertyType;
+
+        // a valid read method has zero arguments and a non-void return type.
+        if (readMethod != null)
+        {
+            if (readMethod.getParameterTypes().length > 0)
+            {
+                throw new IntrospectionException("read method has unexpected parameters");
+            }
+
+            newPropertyType = readMethod.getReturnType();
+
+            if (newPropertyType == Void.TYPE)
+            {
+                throw new IntrospectionException("read method return type is void");
+            }
+        }
+
+        // a valid write method has one argument which can be assigned to the property
+        if (writeMethod != null)
+        {
+            if (writeMethod.getParameterTypes().length != 1)
+            {
+                String msg = "write method does not have exactly one parameter";
+                throw new IntrospectionException(msg);
+            }
+
+            if (readMethod == null)
+            {
+                // changes the property type if there is no read method
+                newPropertyType = writeMethod.getParameterTypes()[0];
+            }
+            else
+            {
+                // checks whether the write method can be assigned to the return type of the read
+                // method (if this is not the case, the methods are not compatible)
+                // note: newPropertyType may be null if no methods or method names have been
+                // delivered in the constructor.
+                if (newPropertyType != null
+                    && !newPropertyType.isAssignableFrom(
+                        writeMethod.getParameterTypes()[0]))
+                {
+                    // note: newPropertyType is the same as readMethod.getReturnType() at this point
+                    throw new IntrospectionException("read and write method are not compatible");
+                }
+
+                /* note: the check whether both method are defined in related classes makes sense but is not
+                 * done in the JDK. 
+                 * I leave this code here in case someone at Sun decides to add that functionality in later versions (rschuster)
+                if ((!readMethod
+                    .getDeclaringClass()
+                    .isAssignableFrom(writeMethod.getDeclaringClass()))
+                    && (!writeMethod
+                        .getDeclaringClass()
+                        .isAssignableFrom(readMethod.getDeclaringClass())))
+                {
+                    String msg =
+                        "set and get methods are not in the same class.";
+                    throw new IntrospectionException(msg);
+                }
+                */
+
+            }
+        }
+
+        return newPropertyType;
+    }
+
+    /**
+     * Return a hash code for this object, conforming to the contract described
+     * in {@link Object#hashCode()}.
+     * @return the hash code
+     * @since 1.5
+     */
+    public int hashCode()
+    {
+      return ((propertyType == null ? 0 : propertyType.hashCode())
+              | (propertyEditorClass == null ? 0 : propertyEditorClass.hashCode())
+              | (bound ? Boolean.TRUE : Boolean.FALSE).hashCode()
+              | (constrained ? Boolean.TRUE : Boolean.FALSE).hashCode()
+              | (getMethod == null ? 0 : getMethod.hashCode())
+              | (setMethod == null ? 0 : setMethod.hashCode()));
+    }
+
+    /** Compares this <code>PropertyDescriptor</code> against the
+     * given object.
+     * Two PropertyDescriptors are equals if
+     * <ul>
+     * <li>the read methods are equal</li>
+     * <li>the write methods are equal</li>
+     * <li>the property types are equals</li>
+     * <li>the property editor classes are equal</li>
+     * <li>the flags (constrained and bound) are equal</li>
+     * </ul>
+     * @return Whether both objects are equal according to the rules given above.
+     * @since 1.4
+    */
+    public boolean equals(Object o)
+    {
+        if (o instanceof PropertyDescriptor)
+        {
+            PropertyDescriptor that = (PropertyDescriptor) o;
+
+            // compares the property types and checks the case where both are null
+            boolean samePropertyType =
+                (propertyType == null)
+                    ? that.propertyType == null
+                    : propertyType.equals(that.propertyType);
+
+            // compares the property editor classes and checks the case where both are null
+            boolean samePropertyEditorClass =
+                (propertyEditorClass == null)
+                    ? that.propertyEditorClass == null
+                    : propertyEditorClass.equals(that.propertyEditorClass);
+
+            // compares the flags for equality
+            boolean sameFlags =
+                bound == that.bound && constrained == that.constrained;
+
+            // compares the read methods and checks the case where both are null
+            boolean sameReadMethod =
+                (getMethod == null)
+                    ? that.getMethod == null
+                    : getMethod.equals(that.getMethod);
+
+            boolean sameWriteMethod =
+                (setMethod == null)
+                    ? that.setMethod == null
+                    : setMethod.equals(that.setMethod);
+
+            return samePropertyType
+                && sameFlags
+                && sameReadMethod
+                && sameWriteMethod
+                && samePropertyEditorClass;
+        }
+        else
+        {
+            return false;
+        }
+        
+    }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyEditor.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyEditor.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyEditor.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyEditor.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,209 @@
+/* java.beans.PropertyEditor
+   Copyright (C) 1998 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+/**
+ ** PropertyEditors are custom GUI editors for specific types of values.
+ **
+ ** A PropertyEditor can be used, for example, if you are editing a type of value
+ ** that can be more easily represented graphically, such as a Point, or one that
+ ** can be more easily represented by a list, such as a boolean (true/false).<P>
+ **
+ ** A PropertyEditor must be able to display its contents when asked to and
+ ** be able to allow the user to change its underlying field value.  However, it
+ ** is not the PropertyEditor's responsibility to make the change to the
+ ** underlying Object; in fact, the PropertyEditor does not even know about the
+ ** Object it is actually editing--only about the property it is currently
+ ** editing.  When a change is made to the property, the PropertyEditor must
+ ** simply fire a PropertyChangeEvent and allow the RAD tool to actually set
+ ** the property in the underlying Bean.<P>
+ **
+ ** PropertyEditors should not change the Objects they are given by setValue().
+ ** These Objects may or may not be the actual Objects which are properties of
+ ** the Bean being edited.  Instead, PropertyEditors should create a new Object
+ ** and fire a PropertyChangeEvent with the old and new values.<P>
+ **
+ ** PropertyEditors also must support the ability to return a Java
+ ** initialization string.  See the getJavaInitializationString() method for
+ ** details.<P>
+ **
+ ** There are several different ways a PropertyEditor may display and control
+ ** editing of its value.  When multiple types of input and display are
+ ** given by a single PropertyEditor, the RAD tool may decide which of the call
+ ** to support.  Some RAD tools may even be text-only, so even if you support
+ ** a graphical set and get, it may choose the text set and get whenever it can.
+ ** <OL>
+ **   <LI>Every PropertyEditor must support getValue() and setValue().  For
+ **       setValue(), the component must only support it when the argument is
+ **       the same type that the PropertyEditor supports.</LI>
+ **   <LI>Every PropertyEditor must support getJavaInitializationString().</LI>
+ **   <LI>You may support painting the value yourself if you wish.  To do this,
+ **       have isPaintable() return true and implement the paintValue() method.
+ **       This method does not determine in any way how the value is edited;
+ **       merely how it is displayed.</LI>
+ **   <LI>Let the caller of the PropertyEditor give the user a text input.  Do
+ **       this by returning a non-null String from getAsText().  If you support
+ **       text input, you *must* support setAsText().</LI>
+ **   <LI>Give the caller a set of possible values, such as "true"/"false", that
+ **       the user must select from.  To do this, return the list of Strings
+ **       from the getTags() method.  The RAD tool may choose to implement the
+ **       user input any way it wishes, and only guarantees that setAsText() will
+ **       only be called with one of the Strings returned from getTags().</LI>
+ **   <LI>You may support a whole custom editing control by supporting
+ **       getCustomEditor().  To do this, return true from supportsCustomEditor()
+ **       and return a Component that does the job.  It is the component's job,
+ **       or the PropertyEditor's job, to make sure that when the editor changes
+ **       its value, the PropertyChangeEvent is thrown.</LI>
+ ** </OL>
+ **
+ ** The PropertyEditor for a particular Bean can be found using the
+ ** PropertyEditorManager class, which goes through a series of different
+ ** checks to find the appropriate class.<P>
+ **
+ ** A PropertyChangeEvent should be thrown from the PropertyEditor whenever a
+ ** bound  property (a property PropertyDescriptor.isBound() set to true)
+ ** changes.  When this happens, the editor itself should *not* change the value
+ ** itself, but rather allow the RAD tool to call setValue() or setAsText().
+ **
+ ** @author John Keiser
+ ** @since JDK1.1
+ ** @version 1.1.0, 30 June 1998
+ ** @see java.beans.PropertyEditorManager
+ ** @see java.beans.PropertyEditorSupport
+ **/
+
+public interface PropertyEditor {
+	/** Called by the RAD tool to set the value of this property for the PropertyEditor.
+	 ** If the property type is native, it should be wrapped in the appropriate
+	 ** wrapper type.
+	 ** @param value the value to set this property to.
+	 **/
+	void setValue(Object value);
+
+	/** Accessor method to get the current value the PropertyEditor is working with.
+	 ** If the property type is native, it will be wrapped in the appropriate
+	 ** wrapper type.
+	 ** @return the current value of the PropertyEditor.
+	 **/
+	Object getValue();
+
+
+	/** Set the value of this property using a String.
+	 ** Whether or not this PropertyEditor is editing a String type, this converts
+	 ** the String into the type of the PropertyEditor.
+	 ** @param text the text to set it to.
+	 ** @exception IllegalArgumentException if the String is in the wrong format or setAsText() is not supported.
+	 **/
+	void setAsText(String text) throws IllegalArgumentException;
+
+	/** Get the value of this property in String format.
+	 ** Many times this can simply use Object.toString().<P>
+	 ** Return null if you do not support getAsText()/setAsText().
+	 ** <code>setAsText(getAsText())</code> should be valid; i.e. the stuff you spit out in
+	 ** getAsText() should be able to go into setAsText().
+	 ** @return the value of this property in String format.
+	 **/
+	String getAsText();
+
+	/** Get a list of possible Strings which this property type can have.
+	 ** The value of these will be used by the RAD tool to construct some sort
+	 ** of list box or to check text box input, and the resulting String passed
+	 ** to setAsText() should be one of these.  Note, however, that like most things
+	 ** with this mammoth, unwieldy interface, this is not guaranteed.  Thus, you
+	 ** must check the value in setAsText() anyway.
+	 ** @return the list of possible String values for this property type.
+	 **/
+	String[] getTags();
+
+
+	/** The RAD tool calls this to find out whether the PropertyEditor can paint itself.
+	 ** @return true if it can paint itself graphically, false if it cannot.
+	 **/
+	boolean isPaintable();
+
+	/** The RAD tool calls this to paint the actual value of the property.
+	 ** The Graphics context will have the same current font, color, etc. as the
+	 ** parent Container.  You may safely change the font, color, etc. and not
+	 ** change them back.<P>
+	 ** This method should do a silent no-op if isPaintable() is false.
+	 ** @param g the Graphics context to paint on
+	 ** @param bounds the rectangle you have reserved to work in
+	 **/
+	void paintValue(java.awt.Graphics g, java.awt.Rectangle bounds);
+
+
+	/** The RAD tool calls this to find out whether the PropertyEditor supports a custom component to edit and display itself.
+	 ** @return true if getCustomEditor() will return a component, false if not.
+	 **/
+	boolean supportsCustomEditor();
+
+	/** The RAD tool calls this to grab the component that can edit this type.
+	 ** The component may be painted anywhere the RAD tool wants to paint it--
+	 ** even in its own window.<P>
+	 ** The component must hook up with the PropertyEditor and, whenever a
+	 ** change to the value is made, fire a PropertyChangeEvent to the source.<P>
+	 ** @return the custom editor for this property type.
+	 **/
+	java.awt.Component getCustomEditor();
+
+
+	/** Adds a property change listener to this PropertyEditor.
+	 ** @param listener the listener to add
+	 **/
+	void addPropertyChangeListener(PropertyChangeListener listener);
+
+	/** Removes a property change listener from this PropertyEditor.
+	 ** @param listener the listener to remove
+	 **/
+	void removePropertyChangeListener(PropertyChangeListener listener);
+
+	/** Get a Java language-specific String which could be used to create an Object
+	 ** of the specified type.  Every PropertyEditor must support this.<P>
+	 ** The reason for this is that while most RAD tools will serialize the Beans
+	 ** and deserialize them at runtime, some RAD tools will generate code that
+	 ** creates the Beans.  Examples of Java initialization strings would be:<P>
+	 ** <OL>
+	 **     <LI><CODE>2</CODE></LI>
+	 **     <LI><CODE>"I am a String"</CODE></LI>
+	 **     <LI><CODE>new MyObject(2, "String", new StringBuffer())</CODE></LI>
+	 ** </OL>
+	 ** @return the initialization string for this object in Java.
+	 **/
+	String getJavaInitializationString();
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyEditorManager.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyEditorManager.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyEditorManager.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyEditorManager.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,215 @@
+/* java.beans.PropertyEditorManager
+   Copyright (C) 1998 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+import gnu.java.beans.editors.ColorEditor;
+import gnu.java.beans.editors.FontEditor;
+import gnu.java.beans.editors.NativeBooleanEditor;
+import gnu.java.beans.editors.NativeByteEditor;
+import gnu.java.beans.editors.NativeDoubleEditor;
+import gnu.java.beans.editors.NativeFloatEditor;
+import gnu.java.beans.editors.NativeIntEditor;
+import gnu.java.beans.editors.NativeLongEditor;
+import gnu.java.beans.editors.NativeShortEditor;
+import gnu.java.beans.editors.StringEditor;
+import gnu.java.lang.ClassHelper;
+
+import java.awt.Color;
+import java.awt.Font;
+
+/**
+ * PropertyEditorManager is used to find property editors
+ * for various types (not necessarily Beans).<P>
+ *
+ * It first checks to see if the property editor is
+ * already registered; if it is, that property editor is
+ * used.  Next it takes the type's classname and appends
+ * "Editor" to it, and searches first in the class's
+ * package and then in the property editor search path.
+ *
+ * <p>Default property editors are provided for:</p>
+ * 
+ * <ol>
+ * <li>boolean, byte, short, int, long, float, and double</li>
+ * <li>java.lang.String</li>
+ * <li>java.awt.Color</li>
+ * <li>java.awt.Font</li>
+ * </ol>
+ *
+ * <p><strong>Spec Suggestion:</strong> Perhaps an editor for
+ * Filename or something like it should be provided.  As well
+ * as char.</p>
+ *
+ * @author John Keiser
+ * @since 1.1
+ * @version 1.1.0, 29 Jul 1998
+ */
+
+public class PropertyEditorManager
+{
+  static java.util.Hashtable editors = new java.util.Hashtable();
+  static String[] editorSearchPath = { "gnu.java.beans.editors",
+                                       "sun.beans.editors" };
+
+  static
+    {
+      registerEditor(Boolean.TYPE, NativeBooleanEditor.class);
+      registerEditor(Byte.TYPE,    NativeByteEditor.class);
+      registerEditor(Short.TYPE,   NativeShortEditor.class);
+      registerEditor(Integer.TYPE, NativeIntEditor.class);
+      registerEditor(Long.TYPE,    NativeLongEditor.class);
+      registerEditor(Float.TYPE,   NativeFloatEditor.class);
+      registerEditor(Double.TYPE,  NativeDoubleEditor.class);
+      registerEditor(String.class, StringEditor.class);
+      registerEditor(Color.class,  ColorEditor.class);
+      registerEditor(Font.class,   FontEditor.class);
+    }
+
+  /**
+   * Beats me why this class can be instantiated, but there
+   * you have it.
+   */
+  public PropertyEditorManager()
+  {
+    // Do nothing here
+  }
+
+  /**
+   * Register an editor for a class.  Replaces old editor
+   * if there was one registered before.
+   *
+   * @param editedClass the class that the property editor
+   *        will edit.
+   * @param editorClass the PropertyEditor class.
+   */
+  public static void registerEditor(Class editedClass, Class editorClass)
+  {
+    editors.put(editedClass, editorClass);
+  }
+
+  /**
+   * Returns a new instance of the property editor for the
+   * specified class.
+   *
+   * @param editedClass the class that the property editor
+   *        will edit.
+   * @return a PropertyEditor instance that can edit the
+   *         specified class.
+   */
+  public static PropertyEditor findEditor(Class editedClass)
+  {
+    try
+      {
+        Class found = (Class)editors.get(editedClass);
+        if(found != null)
+          {
+            return (PropertyEditor)found.newInstance();
+          }
+
+	ClassLoader contextClassLoader
+		= Thread.currentThread().getContextClassLoader();
+
+        try
+          {
+            found = Class.forName(editedClass.getName()+"Editor", true,
+				  contextClassLoader);
+            registerEditor(editedClass,found);
+            return (PropertyEditor)found.newInstance();
+          }
+        catch(ClassNotFoundException E)
+          {
+          }
+
+        String appendName
+		= "."
+		+ ClassHelper.getTruncatedClassName(editedClass)
+		+ "Editor";
+        synchronized(editorSearchPath)
+          {
+            for(int i=0;i<editorSearchPath.length;i++)
+              {
+                try
+                  {
+                    found = Class.forName(editorSearchPath[i] + appendName,
+					  true, contextClassLoader);
+                    registerEditor(editedClass,found);
+                    return (PropertyEditor)found.newInstance();
+                  }
+                catch(ClassNotFoundException E)
+                  {
+                  }
+              }
+          }
+      }
+    catch(InstantiationException E)
+      {
+      }
+    catch(IllegalAccessException E)
+      {
+      }
+    
+    return null;
+  }
+
+  /**
+   * Get the editor search path.
+   * As a minor departure from the spec, the default value
+   * for the editor search path is "gnu.java.beans.editors",
+   * "sun.beans.editors".
+   *
+   * @return the editor search path.
+   */
+  public static String[] getEditorSearchPath()
+  {
+    return editorSearchPath;
+  }
+
+  /**
+   * Set the editor search path.
+   *
+   * @param editorSearchPath the new value for the editor search path.
+   */
+  public static void setEditorSearchPath(String[] editorSearchPath)
+  {
+    synchronized(editorSearchPath)
+      {
+        PropertyEditorManager.editorSearchPath = editorSearchPath;
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyEditorSupport.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyEditorSupport.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyEditorSupport.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyEditorSupport.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,265 @@
+/* java.beans.PropertyEditorSupport
+   Copyright (C) 1998, 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+
+/**
+ * PropertyEditorSupport helps with PropertyEditors,
+ * implementing base functionality that they usually must
+ * have but which is a pain to implement.  You may extend
+ * from this class or use it as a standalone.<P>
+ *
+ * This class does not do any painting or actual editing.
+ * For that, you must use or extend it.  See the
+ * PropertyEditor class for better descriptions of what
+ * the various methods do.
+ *
+ * @author John Keiser
+ * @author Robert Schuster
+ * @since 1.1
+ * @status updated to 1.5
+ */
+public class PropertyEditorSupport implements PropertyEditor
+{
+  Object eventSource;
+  Object value;
+  PropertyChangeSupport pSupport;
+
+  /** Call this constructor when you are deriving from
+   * PropertyEditorSupport.
+   *
+   * Using this constructor the event source is this PropertyEditorSupport
+   * instance itself.
+   *
+   * @since 1.5
+   * @specnote this was <code>protected</code> prior to 1.5
+   */
+  public PropertyEditorSupport()
+  {
+    eventSource = this;
+    pSupport = new PropertyChangeSupport(this);
+  }
+
+  /** Call this constructor when you are using
+   * PropertyEditorSupport as a helper object.
+   *
+   * This constructor throws a NullPointerException when <code>source</code> is <code>null</code>,
+   * for compatibility reasons with J2SDK 1.5.0 .
+   *
+   * @param source The source to use when firing
+   * property change events.
+   * @since 1.5
+   * @specnote this was <code>protected</code> prior to 1.5
+   */
+  public PropertyEditorSupport(Object source)
+  {
+    // note: constructor rejects source being null for the sake of compatibility
+    // with official 1.5.0 implementation
+    if (source == null)
+      throw new NullPointerException("Event source must not be null.");
+
+    eventSource = source;
+    pSupport = new PropertyChangeSupport(eventSource);
+  }
+
+  /** Sets the current value of the property and a property change
+   * event is fired to all registered PropertyChangeListener instances.
+   *
+   * @param newValue The new value for the property.
+   */
+  public void setValue(Object newValue)
+  {
+    value = newValue;
+
+    // specification in java.beans.PropertyChangeEvent says
+    // that without a property name (first argument) the
+    // new and the old value should always be null
+    pSupport.firePropertyChange(null, null, null);
+  }
+
+  /** Gets the current value of the property.
+   *
+   * @return the current value of the property.
+   */
+  public Object getValue()
+  {
+    return value;
+  }
+
+  /** Gets whether this object is paintable or not.
+   *
+   * @return <CODE>false</CODE>
+   */
+  public boolean isPaintable()
+  {
+    return false;
+  }
+
+  /** Paints this object.  This class does nothing in
+   * this method.
+   */
+  public void paintValue(java.awt.Graphics g, java.awt.Rectangle r)
+  {
+  }
+
+  /** Gets the Java initialization String for the current
+   * value of the Object.  This class returns gibberish or
+   * null (though the spec does not say which).<P>
+   * <STRONG>Implementation Note:</STRONG> This class
+   * returns the string "@$#^" to make sure the code will
+   * be broken, so that you will know to override it when
+   * you create your own property editor.
+   *
+   * @return the Java initialization string.
+   */
+  public String getJavaInitializationString()
+  {
+    return "@$#^";
+  }
+
+  /** Gets the value as text.
+   * In this class, you cannot count on getAsText() doing
+   * anything useful, although in this implementation I
+   * do toString().
+   *
+   * @return the value as text.
+   */
+  public String getAsText()
+  {
+    return value != null ? value.toString() : "null";
+  }
+
+  /** Sets the value as text.
+   * In this class, you cannot count on setAsText() doing
+   * anything useful across implementations.
+   * <STRONG>Implementation Note:</STRONG> In this
+   * implementation it checks if the String is "null", and
+   * if it is, sets the value to null, otherwise it throws
+   * an IllegalArgumentException.
+   *
+   * @param s the text to convert to a new value.
+   * @exception IllegalArgumentException if the text is
+   * malformed.
+   */
+  public void setAsText(String s) throws IllegalArgumentException
+  {
+    if (s.equals("null"))
+      setValue(null);
+    else
+      throw new IllegalArgumentException();
+  }
+
+  /** Returns a list of possible choices for the value.
+   *
+   * @return <CODE>null</CODE>
+   */
+  public String[] getTags()
+  {
+    return null;
+  }
+
+  /** Returns a custom component to edit the value.
+   *
+   * @return <CODE>null</CODE> in this class.
+   */
+  public java.awt.Component getCustomEditor()
+  {
+    return null;
+  }
+
+  /** Finds out whether this property editor supports a
+   * custom component to edit its value.
+   *
+   * @return <CODE>false</CODE> in this class.
+   */
+  public boolean supportsCustomEditor()
+  {
+    return false;
+  }
+
+  /** Adds a property change listener to this property editor.
+   *
+   * @param l the listener to add.
+   */
+  public void addPropertyChangeListener(PropertyChangeListener l)
+  {
+    pSupport.addPropertyChangeListener(l);
+  }
+
+  /** Removes a property change listener from this property editor.
+   *
+   * @param l the listener to remove.
+   */
+  public void removePropertyChangeListener(PropertyChangeListener l)
+  {
+    pSupport.removePropertyChangeListener(l);
+  }
+
+  /** Notifies people that we've changed, although we don't
+   * tell them just how.
+   */
+  public void firePropertyChange()
+  {
+    pSupport.firePropertyChange(null, null, null);
+  }
+
+  /** Returns the bean that is used as the source of events.
+   *
+   * @return The event source object
+   * @since 1.5
+   */
+  public Object getSource()
+  {
+    return eventSource;
+  }
+
+  /** Sets the bean that is used as the source of events
+   * when property changes occur.
+   *
+   * The event source bean is for informational purposes only
+   * and should not be changed by the <code>PropertyEditor</code>.
+   *
+   * @param source
+   * @since 1.5
+   */
+  public void setSource(Object source)
+  {
+    eventSource = source;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyVetoException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyVetoException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyVetoException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/beans/PropertyVetoException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,85 @@
+/* PropertyVetoException.java -- thrown to veto a proposed property change
+   Copyright (C) 1998, 2000, 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.beans;
+
+/**
+ * PropertyVetoException is thrown when a VetoableChangeListener doesn't
+ * like the proposed change.
+ *
+ * @author John Keiser
+ * @see VetoableChangeListener
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class PropertyVetoException extends Exception
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  private static final long serialVersionUID = 129596057694162164L;
+
+  /**
+   * The vetoed change.
+   *
+   * @serial the event that was vetoed
+   */
+  private final PropertyChangeEvent evt;
+
+  /**
+   * Instantiate this exception with the given message and property change.
+   *
+   * @param msg the reason for the veto
+   * @param changeEvent the PropertyChangeEvent that was thrown
+   */
+  public PropertyVetoException(String msg, PropertyChangeEvent changeEvent)
+  {
+    super(msg);
+    evt = changeEvent;
+  }
+
+  /**
+   * Get the PropertyChange event that was vetoed.
+   *
+   * @return the vetoed change
+   */
+  public PropertyChangeEvent getPropertyChangeEvent()
+  {
+    return evt;
+  }
+}





More information about the llvm-commits mailing list