kiwi.ui
Class ColorSwatch

java.lang.Object
  extended bykiwi.ui.ColorSwatch
All Implemented Interfaces:
javax.swing.Icon

public class ColorSwatch
extends java.lang.Object
implements javax.swing.Icon

A simple component that renders a color swatch--a filled rectangle with a thin black border.

Author:
Mark Lindner, PING Software Group

Field Summary
private  java.awt.Color color
           
static java.awt.Color DEFAULT_COLOR
          The default swatch color.
static int DEFAULT_HEIGHT
          The default swatch height.
static int DEFAULT_WIDTH
          The default swatch width.
private  int h
           
private  int w
           
 
Constructor Summary
ColorSwatch()
          Construct a new ColorSwatch with a default color, width, and height.
ColorSwatch(java.awt.Color color, int width, int height)
          Construct a new ColorSwatch with the specified color and geometry.
 
Method Summary
 java.awt.Color getColor()
          Get the color of this swatch.
 int getIconHeight()
          Get the height of the swatch.
 int getIconWidth()
          Get the width of the swatch.
 void paintIcon(java.awt.Component c, java.awt.Graphics gc, int x, int y)
          Paint the swatch (as an icon).
 void setColor(java.awt.Color color)
          Set the color of this swatch.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

color

private java.awt.Color color

w

private int w

h

private int h

DEFAULT_WIDTH

public static final int DEFAULT_WIDTH
The default swatch width.

See Also:
Constant Field Values

DEFAULT_HEIGHT

public static final int DEFAULT_HEIGHT
The default swatch height.

See Also:
Constant Field Values

DEFAULT_COLOR

public static final java.awt.Color DEFAULT_COLOR
The default swatch color.

Constructor Detail

ColorSwatch

public ColorSwatch()
Construct a new ColorSwatch with a default color, width, and height.


ColorSwatch

public ColorSwatch(java.awt.Color color,
                   int width,
                   int height)
Construct a new ColorSwatch with the specified color and geometry.

Parameters:
color - The color for the swatch.
width - The width, in pixels.
height - The height, in pixels.
Method Detail

getColor

public java.awt.Color getColor()
Get the color of this swatch.

Returns:
The current color of the swatch.

setColor

public void setColor(java.awt.Color color)
Set the color of this swatch.

Parameters:
color - The new color for the swatch.

getIconWidth

public int getIconWidth()
Get the width of the swatch.

Specified by:
getIconWidth in interface javax.swing.Icon
Returns:
The width, in pixels.

getIconHeight

public int getIconHeight()
Get the height of the swatch.

Specified by:
getIconHeight in interface javax.swing.Icon
Returns:
The height, in pixels.

paintIcon

public void paintIcon(java.awt.Component c,
                      java.awt.Graphics gc,
                      int x,
                      int y)
Paint the swatch (as an icon).

Specified by:
paintIcon in interface javax.swing.Icon
Parameters:
c - The component to paint the swatch in.
gc - The graphics context.
x - The x-coordinate.
y - The y-coordinate.