Package com.iizix.prop
Class GColor
java.lang.Object
com.iizix.prop.GColor
- All Implemented Interfaces:
- Cloneable
This is a data holder class for color, typically an RGB(A) color for a component.
- Author:
- Christopher Mindus
- Field SummaryFields
- Constructor SummaryConstructorsConstructorDescription- GColor- (int rgb) Creates an opaque RGB color object.- GColor- (int argb, boolean hasAlpha) Creates an opaque [A]RGB color object.- GColor- (int r, int g, int b) Creates an opaque RGB color object.- GColor- (int r, int g, int b, double a) Creates an ARGB color object.- GColor- (int r, int g, int b, int a) Creates an ARGB color object.
- Method SummaryModifier and TypeMethodDescription- void- appendColor- (SendTransaction trans) Appends the color to a transaction.- static GColor- createGColor- (String string) Creates a GColor from a String.- booleanChecks if two color objects are equal.- booleanChecks if two color objects are equal.- static GColor- from- (ReadTransaction trans) Creates a color from a transaction.- int- getColor()Gets the color value as ARGB.- static String[]Returns a list of all the color names sorted in alphabetical order.Gets the shortest CSS color string for this color.- getName()Returns the color name.- static intGets a color RGB value from a CSS3 color name.Gets the color as a String in the form described below.- int- hashCode()Hash code.- booleanReturns whether the color is inherited or not.- boolean- isOpaque()Checks if this color is (100%) opaque and not a color by name or not a system color, i.e.- booleanReturns the theme color flag.- booleanChecks if this color is transparent, or no color is set.- protected StringReturns the parameter string representing the state of this event.- static GColor- parseGColor- (String string) Parses an HTML color String, such as "#nnn", "#123456", "rgb(r,g,b)", "rgba(r,g,b,a)" or a named color.- toString()Returns a string representation of this class instance and its values.
- Field Details- NONEThe no-color, i.e. full transparent.
- INHERITThe inherited color, used for CSS.
- namesForColorsThe map of colors to name where only the first entry is taken.
 
- Constructor Details- GColorpublic GColor- (int r, int g, int b) Creates an opaque RGB color object.- Parameters:
- r- The red color (0-255).
- g- The green color (0-255).
- b- The build color (0-255).
- Throws:
- IllegalArgumentException- if any r,g,b color is not 0-255.
 
- GColorpublic GColor- (int r, int g, int b, int a) Creates an ARGB color object.- Parameters:
- r- The red color (0-255).
- g- The green color (0-255).
- b- The build color (0-255).
- a- The alpha (0-255), 0=transparent, 255=opaque.
- Throws:
- IllegalArgumentException- if any r,g,b color is not 0-255.
 
- GColorpublic GColor- (int r, int g, int b, double a) Creates an ARGB color object.- Parameters:
- r- The red color (0-255).
- g- The green color (0-255).
- b- The build color (0-255).
- a- The alpha (0.0-1.0), 0.0=transparent, 1.0=opaque.
- Throws:
- IllegalArgumentException- if any r,g,b color is not 0-255.
 
- GColorpublic GColor- (int rgb) Creates an opaque RGB color object.- Parameters:
- rgb- The integer red, green and blue colors.
- Throws:
- IllegalArgumentException- if- rgb< 0 or- rgb> 0xFFFFFF.
 
- GColorpublic GColor- (int argb, boolean hasAlpha) Creates an opaque [A]RGB color object.- Parameters:
- argb- The alpha-blended integer red, green and blue colors.
- hasAlpha- If false, sets alpha-blend part to 255.
- Throws:
- IllegalArgumentException- if any r,g,b color is not 0-255.
 
 
- Method Details- getColorNamesReturns a list of all the color names sorted in alphabetical order.- Returns:
- The color names array.
 
- getRGBColorFromCSS3NameGets a color RGB value from a CSS3 color name.- Parameters:
- name- The color name.
- Returns:
- The color value matching, or -1 for none.
 
- createGColorCreates a GColor from a String. If the string is null or empty, GColor.NONE is returned, otherwise a new GColor as if- new GColor(string)was called.- Parameters:
- string- The string as 0xnnnnnnnn or decimal. It can be null or empty string for GColor.NONE, or "inherit" for GColor.INHERIT.
- Throws:
- IllegalArgumentException- for errors in the string specification.
- NumberFormatException- for invalid number formats.
 
- parseGColorParses an HTML color String, such as "#nnn", "#123456", "rgb(r,g,b)", "rgba(r,g,b,a)" or a named color. Named colors are CSS3 names or IIZI defined names starting with "%".- Throws:
- ParseException- If parsing failed.
 
- fromCreates a color from a transaction.- Parameters:
- trans- The transaction.
- Returns:
- The color.
 
- getNameReturns the color name.- Returns:
- The color name is either a CSS3 color name matching the value or a predefined color name, or null if the color is not mapped to a named color.
 
- isThemeColorpublic boolean isThemeColor()Returns the theme color flag.- Returns:
- true if the color is a themed color without color if no theme is selected, false for well-defined color.
 
- appendColorAppends the color to a transaction.- Parameters:
- trans- The transaction.
 
- equalsChecks if two color objects are equal.
- equalsChecks if two color objects are equal.- Parameters:
- color- another color object. If null, the colors are not equal.
- Returns:
- true if equal, false otherwise.
 
- hashCodepublic int hashCode()Hash code.
- isInheritedpublic boolean isInherited()Returns whether the color is inherited or not.- Returns:
- true for CSS "inherit" color, false otherwise.
 
- isTransparentpublic boolean isTransparent()Checks if this color is transparent, or no color is set.- Returns:
- true if transparent, false otherwise (also false when inherited).
 
- isOpaquepublic boolean isOpaque()Checks if this color is (100%) opaque and not a color by name or not a system color, i.e. is a color of RGB type or ARGB with A=0x00.- Returns:
- true if fully opaque, false otherwise (also false when inherited).
 
- getColorpublic int getColor()Gets the color value as ARGB.- Returns:
- The color value, -1 if inherited.
 
- getStringGets the color as a String in the form described below.- Returns:
- the String as described below.
 
- paramStringReturns the parameter string representing the state of this event. This string is useful for debugging. Subclasses adds extra information to the string by preceding it with a comma followed by the extra information.- Returns:
- the parameter string of this event.
 
- toStringReturns a string representation of this class instance and its values.
- getCSSValueGets the shortest CSS color string for this color.- Returns:
- E.g. #123456 for opaque colors, rgba(r,g,b,a) for (semi-)transparency colors, or "inherit" if inherited.