Groovy Documentation

com.wordpress.tipsforjava.swing
[Java] Class AlphaIcon

java.lang.Object
  com.wordpress.tipsforjava.swing.AlphaIcon
All Implemented Interfaces:
Icon

public class AlphaIcon
extends Object

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. To show an animated ImageIcon with transparency, use the companion class AlphaImageIcon.

Authors:
Rob Camick
Darryl Burke
Version:
1.0 08/16/10


Field Summary
private float alpha

private Icon icon

 
Constructor Summary
AlphaIcon(Icon icon, float alpha)

Creates an AlphaIcon with the specified icon and opacity.

 
Method Summary
float getAlpha()

Gets this AlphaIcon's opacity

Icon getIcon()

Gets the icon wrapped by this AlphaIcon

int getIconHeight()

Gets the height of the bounding rectangle of this AlphaIcon

int getIconWidth()

Gets the width of the bounding rectangle of this AlphaIcon.

void paintIcon(Component c, Graphics g, int x, int y)

Paints the wrapped icon with this AlphaIcon's transparency.

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

alpha

private float alpha


icon

private Icon icon


 
Constructor Detail

AlphaIcon

public AlphaIcon(Icon icon, float alpha)
Creates an AlphaIcon with the specified icon and opacity. The opacity alpha should be in the range 0.0F (fully transparent) to 1.0F (fully opaque).
Parameters:
icon - the Icon to wrap
alpha - the opacity


 
Method Detail

getAlpha

public float getAlpha()
Gets this AlphaIcon's opacity
Returns:
the opacity, in the range 0.0 to 1.0


getIcon

public Icon getIcon()
Gets the icon wrapped by this AlphaIcon
Returns:
the wrapped icon


getIconHeight

@Override
public int getIconHeight()
Gets the height of the bounding rectangle of this AlphaIcon. * Returns the height of the wrapped icon.
Returns:
the height in pixels


getIconWidth

@Override
public int getIconWidth()
Gets the width of the bounding rectangle of this AlphaIcon. Returns the width of the wrapped icon.
Returns:
the width in pixels


paintIcon

@Override
public void paintIcon(Component c, Graphics g, int x, int y)
Paints the wrapped icon with this AlphaIcon's transparency.
Parameters:
c - The component to which the icon is painted
g - the graphics context
x - the X coordinate of the icon's top-left corner
y - the Y coordinate of the icon's top-left corner


 

Groovy Documentation