com.jgoodies.uif.util
Class CompoundIcon

java.lang.Object
  extended by com.jgoodies.uif.util.CompoundIcon
All Implemented Interfaces:
Icon

public final class CompoundIcon
extends Object
implements Icon

An Icon implementation that paints two icons as compound or overlaid icon using a specified alignment.

Version:
$Revision: 1.5 $
Author:
Karsten Lentzsch
See Also:
ImageIcon

Field Summary
static int CENTER
          Put the foreground icon at the top of its display area, centered horizontally.
static int EAST
          Put the foreground icon on the right side of its display area, centered vertically.
static int NORTH
          Put the foreground icon at the top of its display area, centered horizontally.
static int NORTHEAST
          Put the foreground icon at the top-right corner of its display area.
static int NORTHWEST
          Put the foreground icon at the top-left corner of its display area.
static int SOUTH
          Put the foreground icon at the bottom of its display area, centered horizontally.
static int SOUTHEAST
          Put the foreground icon at the bottom-right corner of its display area.
static int SOUTHWEST
          Put the foreground icon at the bottom-left corner of its display area.
static int WEST
          Put the foreground icon on the left side of its display area, centered vertically.
 
Constructor Summary
CompoundIcon(Icon backgroundIcon, Icon foregroundIcon)
          Constructs a compound icon for the given foreground and background icons, using a default anchor.
CompoundIcon(Icon backgroundIcon, Icon foregroundIcon, int anchor)
          Constructs a compound icon for the given foreground and background icons, using the specified anchor.
 
Method Summary
 int getIconHeight()
          Returns this icon's height, which is the maximum of the heights of the background and foreground icons.
 int getIconWidth()
          Returns this icon's width, which is the maximum of the widths of the background and foreground icons.
 void paintIcon(Component c, Graphics g, int x, int y)
          Draws this icon at the specified location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CENTER

public static final int CENTER
Put the foreground icon at the top of its display area, centered horizontally.

See Also:
Constant Field Values

NORTH

public static final int NORTH
Put the foreground icon at the top of its display area, centered horizontally.

See Also:
Constant Field Values

NORTHEAST

public static final int NORTHEAST
Put the foreground icon at the top-right corner of its display area.

See Also:
Constant Field Values

EAST

public static final int EAST
Put the foreground icon on the right side of its display area, centered vertically.

See Also:
Constant Field Values

SOUTHEAST

public static final int SOUTHEAST
Put the foreground icon at the bottom-right corner of its display area.

See Also:
Constant Field Values

SOUTH

public static final int SOUTH
Put the foreground icon at the bottom of its display area, centered horizontally.

See Also:
Constant Field Values

SOUTHWEST

public static final int SOUTHWEST
Put the foreground icon at the bottom-left corner of its display area.

See Also:
Constant Field Values

WEST

public static final int WEST
Put the foreground icon on the left side of its display area, centered vertically.

See Also:
Constant Field Values

NORTHWEST

public static final int NORTHWEST
Put the foreground icon at the top-left corner of its display area.

See Also:
Constant Field Values
Constructor Detail

CompoundIcon

public CompoundIcon(Icon backgroundIcon,
                    Icon foregroundIcon)
Constructs a compound icon for the given foreground and background icons, using a default anchor.

Parameters:
backgroundIcon - the icon in the centered background
foregroundIcon - the icon that overlays the background icon

CompoundIcon

public CompoundIcon(Icon backgroundIcon,
                    Icon foregroundIcon,
                    int anchor)
Constructs a compound icon for the given foreground and background icons, using the specified anchor.

Parameters:
backgroundIcon - the icon in the centered background
foregroundIcon - the icon that overlays the background icon
anchor - the position of the foreground icon relative to the background icon
Method Detail

getIconWidth

public int getIconWidth()
Returns this icon's width, which is the maximum of the widths of the background and foreground icons.

Specified by:
getIconWidth in interface Icon
Returns:
an int specifying the fixed width of this icon.

getIconHeight

public int getIconHeight()
Returns this icon's height, which is the maximum of the heights of the background and foreground icons.

Specified by:
getIconHeight in interface Icon
Returns:
an int specifying the fixed height of this icon.

paintIcon

public void paintIcon(Component c,
                      Graphics g,
                      int x,
                      int y)
Draws this icon at the specified location. First paints the background icon at the specified location, then paints the foreground icon using the offsets computed in #setAnchor.

Specified by:
paintIcon in interface Icon


Copyright © 2000-2008 JGoodies Karsten Lentzsch. All Rights Reserved.