public class AlphaImageIcon
extends javax.swing.ImageIcon
This class is suitable for wrapping an ImageIcon
that holds an animated image. To show a non-animated Icon with transparency,
the companion class AlphaIcon
is a lighter alternative.
Constructor and Description |
---|
AlphaImageIcon(javax.swing.Icon icon,
float alpha)
Creates an
AlphaImageIcon with the specified icon and opacity. |
Modifier and Type | Method and Description |
---|---|
float |
getAlpha()
Gets this
AlphaIcon 's opacity |
javax.swing.Icon |
getIcon()
Gets the icon wrapped by this
AlphaIcon |
int |
getIconHeight()
Gets the height of the bounding rectangle of this
AlphaImageIcon . |
int |
getIconWidth()
Gets the width of the bounding rectangle of this
AlphaImageIcon . |
java.awt.Image |
getImage()
Overridden to return the image of a wrapped ImageIcon, or null if the wrapped icon
is not an ImageIcon.
|
int |
getImageLoadStatus()
Overridden to return the status of the image loading operation of a wrapped ImageIcon,
or 0 if the contained icon is not an ImageIcon.
|
java.awt.image.ImageObserver |
getImageObserver()
Overridden to return the ImageObserver of the image of a wrapped ImageIcon, or null if
the contained icon is not an ImageIcon.
|
void |
paintIcon(java.awt.Component c,
java.awt.Graphics g,
int x,
int y)
Paints the wrapped icon with this
AlphaImageIcon 's transparency. |
void |
setImage(java.awt.Image image)
Overridden to forward to a wrapped ImageIcon.
|
void |
setImageObserver(java.awt.image.ImageObserver observer)
Overridden to forward to a wrapped ImageIcon.
|
public AlphaImageIcon(javax.swing.Icon icon, float alpha)
AlphaImageIcon
with the specified icon and opacity.
The opacity alpha
should be in the range 0.0F (fully transparent)
to 1.0F (fully opaque).icon
- the Icon to wrapalpha
- the opacitypublic java.awt.Image getImage()
getImage
in class javax.swing.ImageIcon
public void setImage(java.awt.Image image)
In common with ImageIcom
, the newly set image will only be shown when the
concerned component(s) are repainted.
setImage
in class javax.swing.ImageIcon
image
- Sets the image displayed by a wrapped ImageIconpublic int getImageLoadStatus()
getImageLoadStatus
in class javax.swing.ImageIcon
public java.awt.image.ImageObserver getImageObserver()
getImageObserver
in class javax.swing.ImageIcon
public void setImageObserver(java.awt.image.ImageObserver observer)
setImageObserver
in class javax.swing.ImageIcon
observer
- the image observerpublic float getAlpha()
AlphaIcon
's opacitypublic javax.swing.Icon getIcon()
AlphaIcon
public void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
AlphaImageIcon
's transparency.paintIcon
in interface javax.swing.Icon
paintIcon
in class javax.swing.ImageIcon
c
- The component to which the icon is paintedg
- the graphics contextx
- the X coordinate of the icon's top-left cornery
- the Y coordinate of the icon's top-left cornerpublic int getIconWidth()
AlphaImageIcon
.
Overridden to return the width of the wrapped icom.getIconWidth
in interface javax.swing.Icon
getIconWidth
in class javax.swing.ImageIcon
public int getIconHeight()
AlphaImageIcon
.
Overridden to return the height of the wrapped icon.getIconHeight
in interface javax.swing.Icon
getIconHeight
in class javax.swing.ImageIcon