Package com.inductiveautomation.snap.gfx
Class SnapColor
java.lang.Object
com.inductiveautomation.snap.gfx.SnapColor
This 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 SummaryFieldsModifier and TypeFieldDescriptionstatic SnapColorstatic SnapColorstatic SnapColorstatic SnapColorstatic SnapColorstatic SnapColorstatic SnapColorstatic SnapColorstatic SnapColorstatic SnapColorstatic SnapColorstatic SnapColorstatic SnapColorstatic SnapColorstatic SnapColorstatic SnapColor
- 
Constructor SummaryConstructorsConstructorDescriptionCreates 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).Creates a new color from the given hex string.
- 
Method SummaryModifier and TypeMethodDescriptionawt()Returns an AWT version of this color.Returns a color darker than this color (by this given fraction).brighter()Returns a color brighter than this color (blended with white).static SnapColorcolorValue(Object anObj) Returns a color value for a given object.darker()Returns a color darker than this color (blended with black).booleanStandard equals implementation.doubleReturns the alpha component in the range 0-1.intReturns the alpha component in the range 0-255.doubleReturns the blue component in the range 0-1.intReturns the blue component in the range 0-255.doubleReturns the green component in the range 0-1.intReturns the green component in the range 0-255.static SnapColorReturns a random color.doublegetRed2D()Returns the red component in the range 0-1.intReturns the red component in the range 0-255.intgetRGBA()Returns the color as an int.inthashCode()Standard Hashcode implementation.Returns a hex string representation of this color.toString()Returns a string representation of this color.
- 
Field Details- 
BLACK
- 
BLUE
- 
CYAN
- 
DARKGRAY
- 
GRAY
- 
GREEN
- 
LIGHTGRAY
- 
MAGENTA
- 
ORANGE
- 
PINK
- 
RED
- 
WHITE
- 
YELLOW
- 
CLEAR
- 
LIGHTBLUE
- 
CLEARWHITE
 
- 
- 
Constructor Details- 
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.
- 
SnapColorCreates a new color from the given hex string.
 
- 
- 
Method Details- 
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.
- 
brighterReturns a color brighter than this color (blended with white).
- 
darkerReturns a color darker than this color (blended with black).
- 
blendReturns a color darker than this color (by this given fraction).
- 
equalsStandard equals implementation.
- 
hashCodepublic int hashCode()Standard Hashcode implementation.
- 
toStringReturns a string representation of this color.
- 
toHexStringReturns a hex string representation of this color.
- 
colorValueReturns a color value for a given object.
- 
getRandomReturns a random color.
- 
awtReturns an AWT version of this color.
 
-