Package com.inductiveautomation.snap.gfx
Class SnapColor
- java.lang.Object
- 
- com.inductiveautomation.snap.gfx.SnapColor
 
- 
 public class SnapColor extends java.lang.ObjectThis class represents an RGBA color, just like Java.awt.Color. It was originally needed when running without AWT. It still has some convenience, but maybe one day should be replaced by, or just subclass, Java.awt.Color.
- 
- 
Field SummaryFields Modifier and Type Field Description static SnapColorBLACKstatic SnapColorBLUEstatic SnapColorCLEARstatic SnapColorCLEARWHITEstatic SnapColorCYANstatic SnapColorDARKGRAYstatic SnapColorGRAYstatic SnapColorGREENstatic SnapColorLIGHTBLUEstatic SnapColorLIGHTGRAYstatic SnapColorMAGENTAstatic SnapColorORANGEstatic SnapColorPINKstatic SnapColorREDstatic SnapColorWHITEstatic SnapColorYELLOW
 - 
Constructor SummaryConstructors Constructor Description SnapColor()Creates a plain black opaque color.SnapColor(double g)Creates a color with the given gray value (0-1).SnapColor(double g, double a)Creates a color with the given gray and alpha values (0-1).SnapColor(double r, double g, double b)Creates a color with the given red, green blue values (0-1).SnapColor(double r, double g, double b, double a)Creates a color with the given red, green, blue values (0-1).SnapColor(float c, float m, float y, float k, float a)Creates a color with the given cyan, magenta, yellow, black and alpha values (0-1).SnapColor(int r, int g, int b)Creates a color with the given red, green blue values (0-1).SnapColor(java.lang.String aHexString)Creates a new color from the given hex string.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.Colorawt()Returns an AWT version of this color.SnapColorblend(SnapColor aColor, double aFraction)Returns a color darker than this color (by this given fraction).SnapColorbrighter()Returns a color brighter than this color (blended with white).static SnapColorcolorValue(java.lang.Object anObj)Returns a color value for a given object.SnapColordarker()Returns a color darker than this color (blended with black).booleanequals(java.lang.Object anObj)Standard equals implementation.doublegetAlpha2D()Returns the alpha component in the range 0-1.intgetAlphaInt()Returns the alpha component in the range 0-255.doublegetBlue2D()Returns the blue component in the range 0-1.intgetBlueInt()Returns the blue component in the range 0-255.doublegetGreen2D()Returns the green component in the range 0-1.intgetGreenInt()Returns the green component in the range 0-255.static SnapColorgetRandom()Returns a random color.doublegetRed2D()Returns the red component in the range 0-1.intgetRedInt()Returns the red component in the range 0-255.intgetRGBA()Returns the color as an int.inthashCode()Standard Hashcode implementation.java.lang.StringtoHexString()Returns a hex string representation of this color.java.lang.StringtoString()Returns a string representation of this color.
 
- 
- 
- 
Field Detail- 
BLACKpublic static SnapColor BLACK 
 - 
BLUEpublic static SnapColor BLUE 
 - 
CYANpublic static SnapColor CYAN 
 - 
DARKGRAYpublic static SnapColor DARKGRAY 
 - 
GRAYpublic static SnapColor GRAY 
 - 
GREENpublic static SnapColor GREEN 
 - 
LIGHTGRAYpublic static SnapColor LIGHTGRAY 
 - 
MAGENTApublic static SnapColor MAGENTA 
 - 
ORANGEpublic static SnapColor ORANGE 
 - 
PINKpublic static SnapColor PINK 
 - 
REDpublic static SnapColor RED 
 - 
WHITEpublic static SnapColor WHITE 
 - 
YELLOWpublic static SnapColor YELLOW 
 - 
CLEARpublic static SnapColor CLEAR 
 - 
LIGHTBLUEpublic static SnapColor LIGHTBLUE 
 - 
CLEARWHITEpublic static SnapColor CLEARWHITE 
 
- 
 - 
Constructor Detail- 
SnapColorpublic SnapColor() Creates a plain black opaque color.
 - 
SnapColorpublic SnapColor(double g) Creates a color with the given gray value (0-1).
 - 
SnapColorpublic SnapColor(double g, double a)Creates a color with the given gray and alpha values (0-1).
 - 
SnapColorpublic SnapColor(double r, double g, double b)Creates a color with the given red, green blue values (0-1).
 - 
SnapColorpublic SnapColor(int r, int g, int b)Creates a color with the given red, green blue values (0-1).
 - 
SnapColorpublic SnapColor(double r, double g, double b, double a)Creates a color with the given red, green, blue values (0-1).
 - 
SnapColorpublic SnapColor(float c, float m, float y, float k, float a)Creates a color with the given cyan, magenta, yellow, black and alpha values (0-1). Bogus right now.
 - 
SnapColorpublic SnapColor(java.lang.String aHexString) Creates a new color from the given hex string.
 
- 
 - 
Method Detail- 
getRed2Dpublic double getRed2D() Returns the red component in the range 0-1.
 - 
getGreen2Dpublic double getGreen2D() Returns the green component in the range 0-1.
 - 
getBlue2Dpublic double getBlue2D() Returns the blue component in the range 0-1.
 - 
getAlpha2Dpublic double getAlpha2D() Returns the alpha component in the range 0-1.
 - 
getRedIntpublic int getRedInt() Returns the red component in the range 0-255.
 - 
getGreenIntpublic int getGreenInt() Returns the green component in the range 0-255.
 - 
getBlueIntpublic int getBlueInt() Returns the blue component in the range 0-255.
 - 
getAlphaIntpublic int getAlphaInt() Returns the alpha component in the range 0-255.
 - 
getRGBApublic int getRGBA() Returns the color as an int.
 - 
brighterpublic SnapColor brighter() Returns a color brighter than this color (blended with white).
 - 
darkerpublic SnapColor darker() Returns a color darker than this color (blended with black).
 - 
blendpublic SnapColor blend(SnapColor aColor, double aFraction) Returns a color darker than this color (by this given fraction).
 - 
equalspublic boolean equals(java.lang.Object anObj) Standard equals implementation.- Overrides:
- equalsin class- java.lang.Object
 
 - 
hashCodepublic int hashCode() Standard Hashcode implementation.- Overrides:
- hashCodein class- java.lang.Object
 
 - 
toStringpublic java.lang.String toString() Returns a string representation of this color.- Overrides:
- toStringin class- java.lang.Object
 
 - 
toHexStringpublic java.lang.String toHexString() Returns a hex string representation of this color.
 - 
colorValuepublic static SnapColor colorValue(java.lang.Object anObj) Returns a color value for a given object.
 - 
getRandompublic static SnapColor getRandom() Returns a random color.
 - 
awtpublic java.awt.Color awt() Returns an AWT version of this color.
 
- 
 
-