|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jfig.gui.ColorCache
singleton to manage colors and FIG color-indices.
This class tries to achieve a more or less transparent mapping between color names (Strings), rgb-values, and the curios color numbers used in the XFIG3.1 file format.
Typically, this class is used only by the attribute editor to set new line and fill colors, and during import of xfig-files into jfig. This is a singleton class. Use getColorCache() to retrieve the one and only ColorCache.
Once the mapping from names or rgb-values to a Java java.awt.Color object has been done, all other editor functions and classes should use these Color objects only.
Note: user colors, once allocated, are preserved when loading a new FIG file. Naturally, all user colors specified in that file override the current settings. This algorithm can lead to an 'inflation' of (unused) user colors. Also note that requesting the same color with different user color indices will result in multiple assignments of the same color. Beware!
Field Summary | |
static int |
BLACK
|
static int |
BLUE
|
static int |
BLUE2
|
static int |
BLUE3
|
static int |
BLUE4
|
static int |
BROWN2
|
static int |
BROWN3
|
static int |
BROWN4
|
static int |
CYAN
|
static int |
CYAN2
|
static int |
CYAN3
|
static int |
CYAN4
|
static int |
GOLD
|
static int |
GREEN
|
static int |
GREEN2
|
static int |
GREEN3
|
static int |
GREEN4
|
static int |
LTBLUE
|
static int |
MAGENTA
|
static int |
MAGENTA2
|
static int |
MAGENTA3
|
static int |
MAGENTA4
|
static int |
PINK
|
static int |
PINK2
|
static int |
PINK3
|
static int |
PINK4
|
static int |
RED
|
static int |
RED2
|
static int |
RED3
|
static int |
RED4
|
static int |
WHITE
|
static int |
YELLOW
|
Method Summary | |
void |
clearUserColors()
|
java.awt.Color |
get(int i)
|
java.awt.Color |
get(int index,
int area_fill)
get(): get a Color for given index and xfig 'area_fill' attribute |
java.awt.Color |
get(java.lang.String s)
Return the Color corresponding to String s. |
java.awt.Color |
get(java.lang.String s,
int area_fill)
get(): get a Color for given name and xfig 'area_fill' attribute |
java.awt.Color |
getColorAt(int index)
|
static ColorCache |
getColorCache()
getColorCache(): retrieve a reference to our global color cache |
java.util.Vector |
getColorIndices()
getColorIndices(): Construct and return a Vector with the indices of all currently defined colors. |
java.util.Vector |
getColorNames()
getColorNames(): Construct and return a Vector with the names of all currently defined colors. |
int |
getColorNumber(java.awt.Color c)
|
java.awt.Color |
getFIG21Gray(int area_fill)
get the FIG 2.1 gray value corresponding to the 'area_fill' attribute |
int |
getFigColorIndex(int index)
|
int |
getIndex(java.awt.Color c)
|
long |
getTimestamp()
|
boolean |
hasUserColors()
|
int |
numberOfColors()
|
void |
put(java.lang.String s,
int i,
java.awt.Color c)
Add a new Color c with Index i and Name s into our Hashtables. |
void |
putUserColor(int index,
int rgb)
|
int |
registerUserColor(java.awt.Color c)
register Color c with this cache: return the Color index, if already in the cache, else add the Color to the cache and return the new index. |
void |
removeUserColor(int i)
|
void |
setDebug(boolean b)
|
java.awt.Color |
xfig_area_fill(java.awt.Color c,
int area_fill)
xfig_area_fill(): calculate the new Color corresponding to a given xfig 'area_fill' attribute. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static int BLACK
public static int BLUE
public static int GREEN
public static int CYAN
public static int RED
public static int MAGENTA
public static int YELLOW
public static int WHITE
public static int BLUE4
public static int BLUE3
public static int BLUE2
public static int LTBLUE
public static int GREEN4
public static int GREEN3
public static int GREEN2
public static int CYAN4
public static int CYAN3
public static int CYAN2
public static int RED4
public static int RED3
public static int RED2
public static int MAGENTA4
public static int MAGENTA3
public static int MAGENTA2
public static int BROWN4
public static int BROWN3
public static int BROWN2
public static int PINK4
public static int PINK3
public static int PINK2
public static int PINK
public static int GOLD
Method Detail |
public static ColorCache getColorCache()
public long getTimestamp()
public void setDebug(boolean b)
public void put(java.lang.String s, int i, java.awt.Color c)
public java.awt.Color get(java.lang.String s)
public java.awt.Color get(int i)
public int getIndex(java.awt.Color c)
public int getFigColorIndex(int index)
public java.awt.Color getColorAt(int index)
public int numberOfColors()
public java.util.Vector getColorNames()
public java.util.Vector getColorIndices()
public int getColorNumber(java.awt.Color c)
public java.awt.Color get(java.lang.String s, int area_fill)
public java.awt.Color get(int index, int area_fill)
public java.awt.Color xfig_area_fill(java.awt.Color c, int area_fill)
jfig does not support XFIG pattern fills (specified by area_fill values >= 20 / 40) and will use orange color as a warning.
public java.awt.Color getFIG21Gray(int area_fill)
public void putUserColor(int index, int rgb)
public boolean hasUserColors()
public int registerUserColor(java.awt.Color c)
public void clearUserColors()
public void removeUserColor(int i)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |