|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.ceryle.util.VectorMap
org.ceryle.ui.ColorLookupTable
public class ColorLookupTable
Extends HashMap, creating a color lookup table that can be loaded from a text or XTM document. The text format is simple: '#' at start of line is a comment, otherwise first token is ID followed by whitespace, followed by a color spec. For XTM files, the order of the <topic> elements in the file is significant, and determines the iteration order of the table (e.g., when used to create menus). As a lookup table, of course, order is insignificant.
The lookup() method is a synonym for HashMap's get() method, and includes a bit of a trick: if the lookup key begins with a "#", the key is interpreted as a hex color specification (e.g., "#df7e82") and processed accordingly. If it contains a comma, it is interpreted as an RGB or RGBA color (e.g., "223,126,130" or "223,126,130,90") with values between 0-255.
This class also includes import and export methods from the XTM syntax. The syntax for the .xtm file is shown in the example below:
<topicMap id="basic" xmlns="http://www.topicmaps.org/xtm/1.0/">
<topic id="orange">
<occurrence><resourceData>#ff6300</resourceData></occurrence>
</topic>
<topic id="red">
<occurrence><resourceData>#de0800</resourceData></occurrence>
</topic>
<topic id="fuchsia">
<occurrence><resourceData>#f70884</resourceData></occurrence>
</topic>
</topicMap>
Noting that both the ColorLookupTable and each color have individual identifiers, provided by the IDs of the <topic> elements.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Field Summary | |
|---|---|
static String |
DEFAULT_CLUT_NAME
The default CLUT name. |
| Fields inherited from class org.ceryle.util.VectorMap |
|---|
m_map, m_vector |
| Constructor Summary | |
|---|---|
ColorLookupTable(String id)
Constructor provided an identifier for this ColorLookupTable. |
|
| Method Summary | |
|---|---|
Color |
get(String name)
Returns the Color to which this ColorLookupTable maps the specified color name. |
String |
getColorName(int n)
Returns the name of the Color as according to the order of the table. |
Color |
getColorNumber(int n)
Returns the numbered Color as according to the order of the table. |
Color |
getFirstColor()
Returns the first Color (in table order). |
String[] |
getHexColorSpecifications()
Returns a String array containing the the hex color specifications in the same order as the originating list. |
String |
getID()
Returns the ID of this ColorLookupTable. |
Color |
getLastColor()
Returns the last Color (in table order). |
Iterator |
getNames()
Returns the color names in the same order as the originating list. |
void |
load(String filename)
Imports the text or XTM document at filename as a color lookup table. |
Color |
lookup(String name,
Color failColor)
Looks up a color (by name) from this ColorLookupTable, returning null if a value cannot be found. |
Object |
put(String id,
Color color)
Associates the specified ID with the specified Color in this CLUT. |
| Methods inherited from class org.ceryle.util.VectorMap |
|---|
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, remove, size, values |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_CLUT_NAME
| Constructor Detail |
|---|
public ColorLookupTable(String id)
| Method Detail |
|---|
public String getID()
public Object put(String id,
Color color)
public Iterator getNames()
public String[] getHexColorSpecifications()
public Color get(String name)
lookup(String,Color), with no frills, returning null on failure.
public Color getFirstColor()
public Color getLastColor()
public Color getColorNumber(int n)
public String getColorName(int n)
public Color lookup(String name,
Color failColor)
public void load(String filename)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||