gov.noaa.pmel.sgt.swing
Class ColorSwatchIcon

java.lang.Object
  extended by gov.noaa.pmel.sgt.swing.ColorSwatchIcon
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener, javax.swing.Icon

public class ColorSwatchIcon
extends java.lang.Object
implements javax.swing.Icon, java.beans.PropertyChangeListener

ColorSwatchIcon implements Icon to create a icon that displays a small square of color. ColorSwatchIcon is used with property dialogs to display/edit colors from an IndexedColor map.

Since:
2.0
Version:
$Revision$, $Date$
Author:
Donald Denbo
See Also:
Icon

Constructor Summary
ColorSwatchIcon(java.awt.Color color, int width, int height)
           
ColorSwatchIcon(IndexedColor cmap, int index, int size)
          Construct a ColorSwatchIcon.
 
Method Summary
 java.awt.Color getColor()
          Get icon color.
 int getIconHeight()
          Get the icon heigth.
 int getIconWidth()
          Get the icon width.
 int getIndex()
          Get color index.
 void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
          Paint the icon at the specified location
 void propertyChange(java.beans.PropertyChangeEvent event)
          ColorSwatchIcon listens for changes to the IndexedColor color map.
 void setSize(int size)
          Change the size of the swatch.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ColorSwatchIcon

public ColorSwatchIcon(IndexedColor cmap,
                       int index,
                       int size)
Construct a ColorSwatchIcon.

Parameters:
cmap - indexed color map
index - color index
size - swatch size in pixels

ColorSwatchIcon

public ColorSwatchIcon(java.awt.Color color,
                       int width,
                       int height)
Parameters:
color -
size -
Since:
version 1.3
Method Detail

getIndex

public int getIndex()
Get color index.


getColor

public java.awt.Color getColor()
Get icon color.


setSize

public void setSize(int size)
Change the size of the swatch.


paintIcon

public void paintIcon(java.awt.Component c,
                      java.awt.Graphics g,
                      int x,
                      int y)
Paint the icon at the specified location

Specified by:
paintIcon in interface javax.swing.Icon

getIconWidth

public int getIconWidth()
Get the icon width.

Specified by:
getIconWidth in interface javax.swing.Icon

getIconHeight

public int getIconHeight()
Get the icon heigth.

Specified by:
getIconHeight in interface javax.swing.Icon

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
ColorSwatchIcon listens for changes to the IndexedColor color map. If changes occur the swatch is updated.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener