dsto.dfc.swing.controls
Class CompositeColorSwatchIcon

java.lang.Object
  extended by dsto.dfc.swing.controls.CompositeColorSwatchIcon
All Implemented Interfaces:
Copyable, Serializable, Cloneable, Icon

public class CompositeColorSwatchIcon
extends Object
implements Icon, Serializable, Copyable

An icon that displays a small rectangular coloured swatch under an icon. Can be used for icons like bucket fill that display the current fill colour at the bottom.

Version:
$Revision$
See Also:
Serialized Form

Field Summary
protected  Color color
           
protected static int ICON_HEIGHT
           
protected static int ICON_WIDTH
           
protected  Icon smallIcon
           
 
Constructor Summary
CompositeColorSwatchIcon(Icon smallIcon, Color color)
          Create a new icon from a smaller icon and a colour.
 
Method Summary
 Object clone()
          Create a completely separate copy of this object and any mutable objects owned by the object.
 int getIconHeight()
           
 int getIconWidth()
           
 Icon getSmallIcon()
           
 void paintIcon(Component c, Graphics g, int x, int y)
           
 void setColor(Color color)
          Set the color for the swatch.
 void setSmallIcon(Icon smallIcon)
          Set icon displayed at the top.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ICON_WIDTH

protected static final int ICON_WIDTH
See Also:
Constant Field Values

ICON_HEIGHT

protected static final int ICON_HEIGHT
See Also:
Constant Field Values

color

protected Color color

smallIcon

protected Icon smallIcon
Constructor Detail

CompositeColorSwatchIcon

public CompositeColorSwatchIcon(Icon smallIcon,
                                Color color)
Create a new icon from a smaller icon and a colour.

Parameters:
smallIcon - The icon to be displayed above the swatch. Must be 16x12 or smaller (swatch is 16x4 pixels).
color - The color to display in the swatch.
Method Detail

setColor

public void setColor(Color color)
Set the color for the swatch. May be null to indicate swatch is transparent.


setSmallIcon

public void setSmallIcon(Icon smallIcon)
Set icon displayed at the top. Should be 16x12 or smaller.


getSmallIcon

public Icon getSmallIcon()

paintIcon

public void paintIcon(Component c,
                      Graphics g,
                      int x,
                      int y)
Specified by:
paintIcon in interface Icon

getIconWidth

public int getIconWidth()
Specified by:
getIconWidth in interface Icon

getIconHeight

public int getIconHeight()
Specified by:
getIconHeight in interface Icon

clone

public Object clone()
             throws CloneNotSupportedException
Description copied from interface: Copyable
Create a completely separate copy of this object and any mutable objects owned by the object.

NOTE: subclasses should not remove the CloneNotSupportedException throws clause if they themselves support subclassing: removing the CloneNotSupportedException declaration stops subclasses from indicating that a clone was not possible.

Specified by:
clone in interface Copyable
Overrides:
clone in class Object
Throws:
CloneNotSupportedException - if the clone failed or is not possible.


Copyright © 2008 Commonwealth of Australia