classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] ImageIcon fix


From: Mark Wielaard
Subject: Re: [cp-patches] ImageIcon fix
Date: Mon, 22 Aug 2005 21:19:24 +0200

Hi,

On Sun, 2005-08-21 at 14:25 -0400, Thomas Fitzsimmons wrote:
> 2005-08-21  Thomas Fitzsimmons  <address@hidden>
> 
>       * javax/swing/ImageIcon.java (getIconHeight): Return -1 if image
>       is null.
>       (getIconWidth): Likewise.

>    public int getIconHeight()
>    {
> +    // Sun returns -1 if the image is not loaded.
> +    if (image == null)
> +      return -1;

This is also what the Java Swing book describes:

        The iconHeight and iconWidth properties default to -1 if no
        image is loaded.
        
So it isn't Sun (or GNU) specific.

I installed the following documentation patch:

2005-08-22  Mark Wielaard  <address@hidden>

        * javax/swing/ImageIcon.java: Add documentation.

Cheers,

Mark
Index: javax/swing/ImageIcon.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/ImageIcon.java,v
retrieving revision 1.19
diff -u -r1.19 ImageIcon.java
--- javax/swing/ImageIcon.java  21 Aug 2005 18:20:07 -0000      1.19
+++ javax/swing/ImageIcon.java  22 Aug 2005 19:17:32 -0000
@@ -55,8 +55,6 @@
 
 /**
  * An address@hidden Icon} implementation that is backed by an address@hidden 
Image}.
- *
- * @author original author unknown
  */
 public class ImageIcon
   implements Icon, Serializable, Accessible
@@ -224,100 +222,174 @@
   /** The AccessibleContext of this ImageIcon. */
   private AccessibleContext accessibleContext;
 
+  /**
+   * Creates an ImageIcon without any properties set.
+   */
   public ImageIcon()
   {
   }
-  
+ 
+  /**
+   * Creates an ImageIcon from the given file with as initial
+   * description the file name.
+   */
   public ImageIcon(String file)
   {
     this(file, file);
   }
 
+  /**
+   * Creates an ImageIcon from the given file and sets the given
+   * description.
+   */
   public ImageIcon(String file, String description)
   {
     this(Toolkit.getDefaultToolkit().getImage(file), description);
   }
 
+  /**
+   * Creates an ImageIcon from the given byte array without any
+   * description set.
+   */
   public ImageIcon(byte[] imageData)
   {
     this(imageData, null);
   }
   
+  /**
+   * Creates an ImageIcon from the given byte array and sets the given
+   * description.
+   */
   public ImageIcon(byte[] imageData, String description)
   {
     this(Toolkit.getDefaultToolkit().createImage(imageData), description);
   }
 
+  /**
+   * Creates an ImageIcon from the given URL without any description
+   * set.
+   */
   public ImageIcon(URL url)
   {
     this(url, null);
   }
 
+  /**
+   * Creates an ImageIcon from the given URL and sets the given
+   * description.
+   */
   public ImageIcon(URL url, String description)
   {
     this(Toolkit.getDefaultToolkit().getImage(url), description);
   }
 
+  /**
+   * Creates an ImageIcon from the given Image without any description
+   * set.
+   */
   public ImageIcon(Image image)
   {
     this(image, null);
   }
 
+  /**
+   * Creates an ImageIcon from the given Image and sets the given
+   * description.
+   */
   public ImageIcon(Image image, String description)
   {
     setImage(image);
     setDescription(description);
   }
-    
+
+  /**
+   * Returns the ImageObserver that is used for all Image
+   * operations. Defaults to null when not explicitly set.
+   */
   public ImageObserver getImageObserver()
   {
     return observer;
   }
   
+  /**
+   * Sets the ImageObserver that will be used for all Image
+   * operations. Can be set to null (the default) when no observer is
+   * needed.
+   */
   public void setImageObserver(ImageObserver newObserver)
   {
     observer = newObserver;
   }
 
+  /**
+   * Returns the backing Image for this ImageIcon. Might be set to
+   * null in which case no image is shown.
+   */
   public Image getImage()
   {
     return image;
   }
 
+  /**
+   * Explicitly sets the backing Image for this ImageIcon. Will call
+   * loadImage() to make sure that the Image is completely loaded
+   * before returning.
+   */
   public void setImage(Image image)
   {
     loadImage(image);
     this.image = image;
   }
 
+  /**
+   * Returns a human readable description for this ImageIcon or null
+   * when no description is set or available.
+   */
   public String getDescription()
   {
     return description;
   }
 
+  /**
+   * Sets a human readable description for this ImageIcon. Can be set
+   * to null when no description is available.
+   */
   public void setDescription(String description)
   {
     this.description = description;
   }
 
+  /**
+   * Returns the the height of the backing Image, or -1 if the backing
+   * Image is null. The getHeight() method of the Image will be called
+   * with the set observer of this ImageIcon.
+   */
   public int getIconHeight()
   {
-    // Sun returns -1 if the image is not loaded.
     if (image == null)
       return -1;
 
     return image.getHeight(observer);
   }
 
+  /**
+   * Returns the the width of the backing Image, or -1 if the backing
+   * Image is null. The getWidth() method of the Image will be called
+   * with the set observer of this ImageIcon.
+   */
   public int getIconWidth()
   {
-    // Sun returns -1 if the image is not loaded.
     if (image == null)
       return -1;
 
     return image.getWidth(observer);
   }
 
+  /**
+   * Calls <code>g.drawImage()</code> on the backing Image using the
+   * set observer of this ImageIcon. If the set observer is null, the
+   * given Component is used as observer.
+   */
   public void paintIcon(Component c, Graphics g, int x, int y)
   {
     g.drawImage(image, x, y, observer != null ? observer : c);

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]