int[] pixels = image != null? new int[w * h] : null; if (image != null) { try { PixelGrabber pg = new PixelGrabber(image, 0, 0, w, h, pixels, 0, w); pg.grabPixels(); if ((pg.getStatus() & ImageObserver.ABORT) != 0) { throw new IOException("failed to load image contents"); } } catch (InterruptedException e) { throw new IOException("image load interrupted"); } } s.writeInt(w); s.writeInt(h); s.writeObject(pixels); } /** * --- Accessibility Support --- */ private AccessibleImageIcon accessibleContext = null; /** * Gets the AccessibleContext associated with this ImageIcon. * For image icons, the AccessibleContext takes the form of an * AccessibleImageIcon. * A new AccessibleImageIcon instance is created if necessary. * * @return an AccessibleImageIcon that serves as the * AccessibleContext of this ImageIcon * @beaninfo * expert: true * description: The AccessibleContext associated with this ImageIcon. * @since 1.3 */ public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new AccessibleImageIcon(); } return accessibleContext; } /** * This class implements accessibility support for the * <code>ImageIcon</code> class. It provides an implementation of the * Java Accessibility API appropriate to image icon user-interface * elements. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans<sup><font size="-2">TM</font></sup> * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. * @since 1.3 */ protected class AccessibleImageIcon extends AccessibleContext implements AccessibleIcon, Serializable { /* * AccessibleContest implementation ----------------- */ /** * Gets the role of this object. * * @return an instance of AccessibleRole describing the role of the * object * @see AccessibleRole */ public AccessibleRole getAccessibleRole() { return AccessibleRole.ICON; } /** * Gets the state of this object. * * @return an instance of AccessibleStateSet containing the current * state set of the object * @see AccessibleState */ public AccessibleStateSet getAccessibleStateSet() { return null; } /** * Gets the Accessible parent of this object. If the parent of this * object implements Accessible, this method should simply return * getParent(). * * @return the Accessible parent of this object -- can be null if this * object does not have an Accessible parent */ public Accessible getAccessibleParent() { return null; } /** * Gets the index of this object in its accessible parent. * * @return the index of this object in its parent; -1 if this * object does not have an accessible parent. * @see #getAccessibleParent */ public int getAccessibleIndexInParent() { return -1; } /** * Returns the number of accessible children in the object. If all * of the children of this object implement Accessible, than this * method should return the number of children of this object. * * @return the number of accessible children in the object. */ public int getAccessibleChildrenCount() { return 0; } /** * Returns the nth Accessible child of the object. * * @param i zero-based index of child * @return the nth Accessible child of the object */ public Accessible getAccessibleChild(int i) { return null; } /** * Returns the locale of this object. * * @return the locale of this object */ public Locale getLocale() throws IllegalComponentStateException { return null; } /* * AccessibleIcon implementation ----------------- */ /** * Gets the description of the icon. This is meant to be a brief * textual description of the object. For example, it might be * presented to a blind user to give an indication of the purpose * of the icon. * * @return the description of the icon */ public String getAccessibleIconDescription() { return ImageIcon.this.getDescription(); } /** * Sets the description of the icon. This is meant to be a brief * textual description of the object. For example, it might be * presented to a blind user to give an indication of the purpose * of the icon. * * @param description the description of the icon */ public void setAccessibleIconDescription(String description) { ImageIcon.this.setDescription(description); } /** * Gets the height of the icon. * * @return the height of the icon */ public int getAccessibleIconHeight() { return ImageIcon.this.height; } /** * Gets the width of the icon. * * @return the width of the icon */ public int getAccessibleIconWidth() { return ImageIcon.this.width; } private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { s.defaultReadObject(); } private void writeObject(ObjectOutputStream s) throws IOException { s.defaultWriteObject(); } } // AccessibleImageIcon}Lines 501–703 of 703. Previous lines
int[] pixels = image != null? new int[w * h] : null; if (image != null) { try { PixelGrabber pg = new PixelGrabber(image, 0, 0, w, h, pixels, 0, w); pg.grabPixels(); if ((pg.getStatus() & ImageObserver.ABORT) != 0) { throw new IOException("failed to load image contents"); } } catch (InterruptedException e) { throw new IOException("image load interrupted"); } } s.writeInt(w); s.writeInt(h); s.writeObject(pixels); } /** * --- Accessibility Support --- */ private AccessibleImageIcon accessibleContext = null; /** * Gets the AccessibleContext associated with this ImageIcon. * For image icons, the AccessibleContext takes the form of an * AccessibleImageIcon. * A new AccessibleImageIcon instance is created if necessary. * * @return an AccessibleImageIcon that serves as the * AccessibleContext of this ImageIcon * @beaninfo * expert: true * description: The AccessibleContext associated with this ImageIcon. * @since 1.3 */ public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new AccessibleImageIcon(); } return accessibleContext; } /** * This class implements accessibility support for the * <code>ImageIcon</code> class. It provides an implementation of the * Java Accessibility API appropriate to image icon user-interface * elements. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans<sup><font size="-2">TM</font></sup> * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. * @since 1.3 */ protected class AccessibleImageIcon extends AccessibleContext implements AccessibleIcon, Serializable { /* * AccessibleContest implementation ----------------- */ /** * Gets the role of this object. * * @return an instance of AccessibleRole describing the role of the * object * @see AccessibleRole */ public AccessibleRole getAccessibleRole() { return AccessibleRole.ICON; } /** * Gets the state of this object. * * @return an instance of AccessibleStateSet containing the current * state set of the object * @see AccessibleState */ public AccessibleStateSet getAccessibleStateSet() { return null; } /** * Gets the Accessible parent of this object. If the parent of this * object implements Accessible, this method should simply return * getParent(). * * @return the Accessible parent of this object -- can be null if this * object does not have an Accessible parent */ public Accessible getAccessibleParent() { return null; } /** * Gets the index of this object in its accessible parent. * * @return the index of this object in its parent; -1 if this * object does not have an accessible parent. * @see #getAccessibleParent */ public int getAccessibleIndexInParent() { return -1; } /** * Returns the number of accessible children in the object. If all * of the children of this object implement Accessible, than this * method should return the number of children of this object. * * @return the number of accessible children in the object. */ public int getAccessibleChildrenCount() { return 0; } /** * Returns the nth Accessible child of the object. * * @param i zero-based index of child * @return the nth Accessible child of the object */ public Accessible getAccessibleChild(int i) { return null; } /** * Returns the locale of this object. * * @return the locale of this object */ public Locale getLocale() throws IllegalComponentStateException { return null; } /* * AccessibleIcon implementation ----------------- */ /** * Gets the description of the icon. This is meant to be a brief * textual description of the object. For example, it might be * presented to a blind user to give an indication of the purpose * of the icon. * * @return the description of the icon */ public String getAccessibleIconDescription() { return ImageIcon.this.getDescription(); } /** * Sets the description of the icon. This is meant to be a brief * textual description of the object. For example, it might be * presented to a blind user to give an indication of the purpose * of the icon. * * @param description the description of the icon */ public void setAccessibleIconDescription(String description) { ImageIcon.this.setDescription(description); } /** * Gets the height of the icon. * * @return the height of the icon */ public int getAccessibleIconHeight() { return ImageIcon.this.height; } /** * Gets the width of the icon. * * @return the width of the icon */ public int getAccessibleIconWidth() { return ImageIcon.this.width; } private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { s.defaultReadObject(); } private void writeObject(ObjectOutputStream s) throws IOException { s.defaultWriteObject(); } } // AccessibleImageIcon }