Package smile.swing
Class AlphaIcon
java.lang.Object
smile.swing.AlphaIcon
- All Implemented Interfaces:
Icon
An Icon wrapper that paints the contained icon with a specified transparency.
Note: This class is not suitable for wrapping an
ImageIcon
that holds an animated image.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfloat
getAlpha()
Gets thisAlphaIcon
's opacitygetIcon()
Gets the icon wrapped by thisAlphaIcon
int
Gets the height of the bounding rectangle of thisAlphaIcon
.int
Gets the width of the bounding rectangle of thisAlphaIcon
.void
Paints the wrapped icon with thisAlphaIcon
's transparency.
-
Constructor Details
-
AlphaIcon
Creates anAlphaIcon
with the specified icon and opacity. The opacityalpha
should be in the range 0.0F (fully transparent) to 1.0F (fully opaque).- Parameters:
icon
- the Icon to wrapalpha
- the opacity
-
-
Method Details
-
getAlpha
public float getAlpha()Gets thisAlphaIcon
's opacity- Returns:
- the opacity, in the range 0.0 to 1.0
-
getIcon
Gets the icon wrapped by thisAlphaIcon
- Returns:
- the wrapped icon
-
paintIcon
Paints the wrapped icon with thisAlphaIcon
's transparency. -
getIconWidth
public int getIconWidth()Gets the width of the bounding rectangle of thisAlphaIcon
. Returns the width of the wrapped icon.- Specified by:
getIconWidth
in interfaceIcon
- Returns:
- the width in pixels
-
getIconHeight
public int getIconHeight()Gets the height of the bounding rectangle of thisAlphaIcon
. * Returns the height of the wrapped icon.- Specified by:
getIconHeight
in interfaceIcon
- Returns:
- the height in pixels
-