Class RMColor
- java.lang.Object
-
- com.inductiveautomation.rm.graphics.RMColor
-
- All Implemented Interfaces:
Archivable
public class RMColor extends java.lang.Object implements Archivable
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 Summary
Fields Modifier and Type Field Description static RMColorblackstatic RMColorbluestatic RMColorclearstatic RMColorclearWhitestatic RMColorcyanstatic RMColordarkGraystatic RMColorgraystatic RMColorgreenstatic RMColorlightBluestatic RMColorlightGraystatic RMColormagentastatic RMColororangestatic RMColorpinkstatic RMColorredstatic RMColorwhitestatic RMColoryellow
-
Constructor Summary
Constructors Constructor Description RMColor()Creates a plain black opaque color.RMColor(double g)Creates a color with the given gray value (0-1).RMColor(double g, double a)Creates a color with the given gray and alpha values (0-1).RMColor(double r, double g, double b)Creates a color with the given red, green blue values (0-1).RMColor(double r, double g, double b, double a)Creates a color with the given red, green, blue values (0-1).RMColor(double c, double m, double y, double k, double a)Creates a color with the given cyan, magenta, yellow, black and alpha values (0-1).RMColor(int r, int g, int b)Creates a color with the given red, green blue values (0-1).RMColor(java.awt.Color awt)Creates an RMColor from the given AWT color.RMColor(java.lang.String aHexString)Creates a new color from the given hex string.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.Colorawt()Returns an AWT version of this color.RMColorblend(RMColor aColor, double aFraction)Returns a color darker than this color (by this given fraction).RMColorbrighter()Returns a color brighter than this color (blended with white).static RMColorcolorValue(java.lang.Object anObj)Returns a color value for a given object.RMColordarker()Returns a color darker than this color (blended with black).booleanequals(java.lang.Object anObj)Standard equals implementation.java.lang.ObjectfromXML(RXArchiver anArchiver, RXElement anElement)XML unarchival.doublegetAlpha()Returns the alpha component in the range 0-1.intgetAlphaInt()Returns the alpha component in the range 0-255.doublegetBlue()Returns the blue component in the range 0-1.intgetBlueInt()Returns the blue component in the range 0-255.doublegetGreen()Returns the green component in the range 0-1.intgetGreenInt()Returns the green component in the range 0-255.static RMColorgetRandom()Returns a random color.doublegetRed()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.static float[]rgbToLab(double r, double g, double b)Converts an RGB triplet to a CIELab tripletjava.lang.StringtoHexString()Returns a hex string representation of this color.float[]toLab()Converts an RMColor to a CIELab tripletjava.lang.StringtoString()Returns a string representation of this color.RXElementtoXML(RXArchiver anArchiver)XML archival.
-
-
-
Field Detail
-
black
public static RMColor black
-
blue
public static RMColor blue
-
cyan
public static RMColor cyan
-
darkGray
public static RMColor darkGray
-
gray
public static RMColor gray
-
green
public static RMColor green
-
lightGray
public static RMColor lightGray
-
magenta
public static RMColor magenta
-
orange
public static RMColor orange
-
pink
public static RMColor pink
-
red
public static RMColor red
-
white
public static RMColor white
-
yellow
public static RMColor yellow
-
clear
public static RMColor clear
-
lightBlue
public static RMColor lightBlue
-
clearWhite
public static RMColor clearWhite
-
-
Constructor Detail
-
RMColor
public RMColor()
Creates a plain black opaque color.
-
RMColor
public RMColor(double g)
Creates a color with the given gray value (0-1).
-
RMColor
public RMColor(double g, double a)Creates a color with the given gray and alpha values (0-1).
-
RMColor
public RMColor(double r, double g, double b)Creates a color with the given red, green blue values (0-1).
-
RMColor
public RMColor(int r, int g, int b)Creates a color with the given red, green blue values (0-1).
-
RMColor
public RMColor(double r, double g, double b, double a)Creates a color with the given red, green, blue values (0-1).
-
RMColor
public RMColor(double c, double m, double y, double k, double a)Creates a color with the given cyan, magenta, yellow, black and alpha values (0-1). Bogus right now.
-
RMColor
public RMColor(java.awt.Color awt)
Creates an RMColor from the given AWT color.
-
RMColor
public RMColor(java.lang.String aHexString)
Creates a new color from the given hex string.
-
-
Method Detail
-
getRed
public double getRed()
Returns the red component in the range 0-1.
-
getGreen
public double getGreen()
Returns the green component in the range 0-1.
-
getBlue
public double getBlue()
Returns the blue component in the range 0-1.
-
getAlpha
public double getAlpha()
Returns the alpha component in the range 0-1.
-
getRedInt
public int getRedInt()
Returns the red component in the range 0-255.
-
getGreenInt
public int getGreenInt()
Returns the green component in the range 0-255.
-
getBlueInt
public int getBlueInt()
Returns the blue component in the range 0-255.
-
getAlphaInt
public int getAlphaInt()
Returns the alpha component in the range 0-255.
-
getRGBA
public int getRGBA()
Returns the color as an int.
-
brighter
public RMColor brighter()
Returns a color brighter than this color (blended with white).
-
darker
public RMColor darker()
Returns a color darker than this color (blended with black).
-
blend
public RMColor blend(RMColor aColor, double aFraction)
Returns a color darker than this color (by this given fraction).
-
equals
public boolean equals(java.lang.Object anObj)
Standard equals implementation.- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
Returns a string representation of this color.- Overrides:
toStringin classjava.lang.Object
-
toHexString
public java.lang.String toHexString()
Returns a hex string representation of this color.
-
colorValue
@Nullable public static RMColor colorValue(java.lang.Object anObj)
Returns a color value for a given object. If we can't guess what color the object represents, returns null.
-
toLab
public float[] toLab()
Converts an RMColor to a CIELab triplet
-
rgbToLab
public static float[] rgbToLab(double r, double g, double b)Converts an RGB triplet to a CIELab triplet
-
getRandom
public static RMColor getRandom()
Returns a random color.
-
toXML
public RXElement toXML(RXArchiver anArchiver)
XML archival.- Specified by:
toXMLin interfaceArchivable
-
fromXML
public java.lang.Object fromXML(RXArchiver anArchiver, RXElement anElement)
XML unarchival.- Specified by:
fromXMLin interfaceArchivable
-
awt
public java.awt.Color awt()
Returns an AWT version of this color.
-
-