|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.neu.ccs.gui.SwatchNameRenderer
Class SwatchNameRenderer is designed to implement
ListCellRenderer by providing pairs each with a
paint swatch and its name.
| Field Summary | |
private Dimension |
maxDimension
The maximum dimension of all swatch-name pairs. |
private StringObjectMap |
nameCellMap
The hash table of color names and swatch-name pairs. |
| Constructor Summary | |
SwatchNameRenderer()
This constructor provides a renderer for swatch-name pairs generated from the color names obtained via Colors.getColorNamesAsArray. |
|
| Method Summary | |
private SwatchNamePair |
getListCellFromMap(String name)
Returns the list cell corresponding to the given color name. |
Component |
getListCellRendererComponent(JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus)
Returns the swatch name pair component associated with the given String value in the given list; sets the
foreground and background of the swatch name pair depending
on the given isSelected parameter. |
Dimension |
getMaximumPreferredSize()
Returns the maximum preferred size of all swatch-name pairs in this renderer. |
String[] |
getStrings()
Returns the array of color name strings installed in this renderer. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private StringObjectMap nameCellMap
private Dimension maxDimension
| Constructor Detail |
public SwatchNameRenderer()
| Method Detail |
private SwatchNamePair getListCellFromMap(String name)
Returns the list cell corresponding to the given color name.
name - the color namepublic String[] getStrings()
Returns the array of color name strings installed in this renderer. This returns the strings installed at construction and avoids problems if additional color name pairs are later installed globally.
public Dimension getMaximumPreferredSize()
Returns the maximum preferred size of all swatch-name pairs in this renderer.
public Component getListCellRendererComponent(JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus)
Returns the swatch name pair component associated with the
given String value in the given list; sets the
foreground and background of the swatch name pair depending
on the given isSelected parameter.
This method implements the ListCellRenderer
interface.
Returns null if an unexpected error occurs.
getListCellRendererComponent in interface ListCellRendererlist - the JList to paintvalue - the value returned by list.getModel().getElementAt(index)index - the index of the cellisSelected - true if the specified cell was selectedcellHasFocus - true if the specified cell has the focus
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||