Package generic.theme
Class GColor
java.lang.Object
java.awt.Color
generic.theme.GColor
- All Implemented Interfaces:
Paint,Transparency,Serializable
- Direct Known Subclasses:
GColorUIResource
A
Color whose value is dynamically determined by looking up its id into a global
color table that is determined by the active GTheme.
The idea is for developers to not use specific colors in their code, but to instead use a GColor with an id that hints at its use. For example, instead of hard coding a component's background color to white by coding "component.setBackground(Color.white)", you would do something like "component.setBackground(new GColor("color.mywidget.bg"). Then in a "[module name].theme.properties" file (located in the module's data directory), you would set the default value by adding this line "color.mywidget.bg = white".
- See Also:
-
Field Summary
Fields inherited from class java.awt.Color
black, BLACK, blue, BLUE, cyan, CYAN, DARK_GRAY, darkGray, gray, GRAY, green, GREEN, LIGHT_GRAY, lightGray, magenta, MAGENTA, orange, ORANGE, pink, PINK, red, RED, white, WHITE, yellow, YELLOWFields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbrighter()createContext(ColorModel cm, Rectangle r, Rectangle2D r2d, AffineTransform xform, RenderingHints hints) darker()booleanintgetAlpha()intgetBlue()float[]getColorComponents(float[] compArray) float[]getColorComponents(ColorSpace cspace, float[] compArray) float[]getComponents(float[] compArray) float[]getComponents(ColorSpace cspace, float[] compArray) intgetGreen()getId()Returns the id for this GColor.intgetRed()intgetRGB()float[]getRGBColorComponents(float[] compArray) float[]getRGBComponents(float[] compArray) intinthashCode()booleanReturns true if this GColor could not find a value for its color id in the current theme and is using the default color as its delegatevoidrefresh(GThemeValueMap currentValues) Reloads the delegate.static voidrefreshAll(GThemeValueMap currentValues) Static method for notifying all the existing GColors that colors have changed and they should reload their cached indirect color.Generates a more verbose toString()Returns this color as a hex string that starts with '#'toString()withAlpha(int newAlpha) Creates a transparent version of this GColor.
-
Constructor Details
-
GColor
Construct a GColor with an id that will be used to look up the current color associated with that id, which can be changed at runtime.- Parameters:
id- the id used to lookup the current value for this color
-
GColor
Copy constructor. Used primarily to convert a GColorUiResource to a GColor without having to lookup the color which can cause errors during theme transitions.- Parameters:
gColor- the gColor to copy
-
-
Method Details
-
withAlpha
Creates a transparent version of this GColor. If the underlying value of this GColor changes, the transparent version will also change.- Parameters:
newAlpha- the transparency level for the new color- Returns:
- a transparent version of this GColor
-
getId
Returns the id for this GColor.- Returns:
- the id for this GColor.
-
getRed
public int getRed() -
getGreen
public int getGreen() -
getBlue
public int getBlue() -
getAlpha
public int getAlpha() -
getRGB
public int getRGB() -
brighter
-
darker
-
isUnresolved
public boolean isUnresolved()Returns true if this GColor could not find a value for its color id in the current theme and is using the default color as its delegate- Returns:
- true if this GColor could not find a value for its color id in the current theme
-
toString
-
toHexString
Returns this color as a hex string that starts with '#'- Returns:
- the hex string
-
toDebugString
Generates a more verbose toString()- Returns:
- a more verbose toString()
-
hashCode
public int hashCode() -
equals
-
getRGBComponents
public float[] getRGBComponents(float[] compArray) - Overrides:
getRGBComponentsin classColor
-
getRGBColorComponents
public float[] getRGBColorComponents(float[] compArray) - Overrides:
getRGBColorComponentsin classColor
-
getComponents
public float[] getComponents(float[] compArray) - Overrides:
getComponentsin classColor
-
getColorComponents
public float[] getColorComponents(float[] compArray) - Overrides:
getColorComponentsin classColor
-
getComponents
- Overrides:
getComponentsin classColor
-
getColorComponents
- Overrides:
getColorComponentsin classColor
-
getColorSpace
- Overrides:
getColorSpacein classColor
-
createContext
public PaintContext createContext(ColorModel cm, Rectangle r, Rectangle2D r2d, AffineTransform xform, RenderingHints hints) - Specified by:
createContextin interfacePaint- Overrides:
createContextin classColor
-
getTransparency
public int getTransparency()- Specified by:
getTransparencyin interfaceTransparency- Overrides:
getTransparencyin classColor
-
refresh
Reloads the delegate.- Parameters:
currentValues- the map of current theme values
-
refreshAll
Static method for notifying all the existing GColors that colors have changed and they should reload their cached indirect color.- Parameters:
currentValues- the map of current theme values
-