sgtplot.swing
Class ColorSwatchIcon
- java.lang.Object
-
- sgtplot.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.PropertyChangeListenerColorSwatchIconimplementsIconto create a icon that displays a small square of color.ColorSwatchIconis used with property dialogs to display/edit colors from anIndexedColormap.- Since:
- 2.0
- See Also:
Icon
-
-
Constructor Summary
Constructors Constructor and Description ColorSwatchIcon(java.awt.Color color, int width, int height)ColorSwatchIcon(IndexedColor cmap, int index, int size)Construct aColorSwatchIcon.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.awt.ColorgetColor()Get icon color.intgetIconHeight()Get the icon heigth.intgetIconWidth()Get the icon width.intgetIndex()Get color index.voidpaintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)Paint the icon at the specified locationvoidpropertyChange(java.beans.PropertyChangeEvent event)ColorSwatchIconlistens for changes to theIndexedColorcolor map.voidsetSize(int size)Change the size of the swatch.java.lang.StringtoString()
-
-
-
Constructor Detail
-
ColorSwatchIcon
public ColorSwatchIcon(IndexedColor cmap, int index, int size)
Construct aColorSwatchIcon.- Parameters:
cmap- indexed color mapindex- color indexsize- 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:
paintIconin interfacejavax.swing.Icon
-
getIconWidth
public int getIconWidth()
Get the icon width.- Specified by:
getIconWidthin interfacejavax.swing.Icon
-
getIconHeight
public int getIconHeight()
Get the icon heigth.- Specified by:
getIconHeightin interfacejavax.swing.Icon
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent event)
ColorSwatchIconlistens for changes to theIndexedColorcolor map. If changes occur the swatch is updated.- Specified by:
propertyChangein interfacejava.beans.PropertyChangeListener
-
-
DMelt 3.0 © DataMelt by jWork.ORG