gov.noaa.pmel.sgt.swing
Class ColorSwatchIcon

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

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: 1.4 $, $Date: 2001/02/06 20:05:52 $
Author:
Donald Denbo
See Also:
Icon

Constructor Summary
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.
 int getSize()
          Get the size of the icon.
 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()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
equals, 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
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.

getSize

public int getSize()
Get the size of the icon.

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
Following copied from interface: javax.swing.Icon
Returns:
an int specifying the fixed width of the icon.

getIconHeight

public int getIconHeight()
Get the icon heigth.
Specified by:
getIconHeight in interface javax.swing.Icon
Following copied from interface: javax.swing.Icon
Returns:
an int specifying the fixed height of the icon.

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 
Overrides:
toString in class java.lang.Object
Following copied from class: java.lang.Object
Returns:
a string representation of the 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
Following copied from interface: java.beans.PropertyChangeListener
Parameters:
evt - A PropertyChangeEvent object describing the event source and the property that has changed.


Send comments about the Scientific Graphics toolkit to dwd@pmel.noaa.gov. For more information about Java Development in the EPIC Group see the EPIC Software Page
Generated on December 13 2001