ReportMill 10 API

com.reportmill.graphics
Class RMColor

java.lang.Object
  extended by com.reportmill.base.RMObject
      extended by com.reportmill.graphics.RMColor
All Implemented Interfaces:
java.lang.Cloneable

public class RMColor
extends com.reportmill.base.RMObject

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
static RMColor black
           
static RMColor blue
           
static RMColor clear
           
static RMColor clearWhite
           
static RMColor cyan
           
static RMColor darkGray
           
static RMColor gray
           
static RMColor green
           
static RMColor lightBlue
           
static RMColor lightGray
           
static RMColor magenta
           
static RMColor orange
           
static RMColor pink
           
static RMColor red
           
static RMColor white
           
static RMColor yellow
           
 
Constructor Summary
RMColor()
          Creates a plain black opaque color.
RMColor(java.awt.Color awt)
          Creates an RMColor from the given AWT color.
RMColor(float g)
          Creates a color with the given gray value (0-1).
RMColor(float g, float a)
          Creates a color with the given gray and alpha values (0-1).
RMColor(float r, float g, float b)
          Creates a color with the given red, green blue values (0-1).
RMColor(float r, float g, float b, float a)
          Creates a color with the given red, green, blue values (0-1).
RMColor(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).
RMColor(java.lang.String aHexString)
          Creates a new color from the given hex string.
 
Method Summary
 java.awt.Color awt()
          Returns an AWT version of this color.
 java.awt.Color awt(float dissolve)
          Returns an AWT version of this color, with the alpha component scaled by the given dissolve factor.
 RMColor blend(RMColor aColor, float fraction)
          Returns a color darker than this color (by this given fraction).
 RMColor brighter()
          Returns a color 70% brighter than this color.
 RMColor brighter(float aFactor)
          Retures a color with the given percent brighter than this color.
static RMColor colorValue(java.lang.Object anObj)
          Returns a color value for a given object.
 RMColor darker()
          Returns a color darker than this color (70% of this color's brightness).
 boolean equals(java.lang.Object obj)
          Standar equals implementaiton.
 java.lang.Object fromXML(com.reportmill.archiver.RXArchiver anArchiver, com.reportmill.archiver.RXElement anElement)
          XML unarchival.
 int getAlpha()
          Returns the alpha component in the range 0-255.
 float getAlpha2D()
          Returns the alpha component in the range 0-1.
 int getBlue()
          Returns the blue component in the range 0-255.
 float getBlue2D()
          Returns the blue component in the range 0-1.
 int getGreen()
          Returns the green component in the range 0-255.
 float getGreen2D()
          Returns the green component in the range 0-1.
 int getRed()
          Returns the red component in the range 0-255.
 float getRed2D()
          Returns the red component in the range 0-1.
static float[] rgbToLab(float r, float g, float b)
          Converts an RGB triplet to a CIELab triplet
 java.lang.String toHexString()
          Returns a hex string representation of this color.
 float[] toLab()
          Converts an RMColor to a CIELab triplet
 java.lang.String toString()
          Returns a string representation of this color.
 com.reportmill.archiver.RXElement toXML(com.reportmill.archiver.RXArchiver anArchiver)
          XML archival.
 
Methods inherited from class com.reportmill.base.RMObject
clone, copy, didChange, didUndo, getAnimAttribute, getClassNameShort, undoClone, undoCopy, undoEquals
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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(float g)
Creates a color with the given gray value (0-1).


RMColor

public RMColor(float g,
               float a)
Creates a color with the given gray and alpha values (0-1).


RMColor

public RMColor(float r,
               float g,
               float b)
Creates a color with the given red, green blue values (0-1).


RMColor

public RMColor(float r,
               float g,
               float b,
               float a)
Creates a color with the given red, green, blue values (0-1).


RMColor

public RMColor(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).


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 int getRed()
Returns the red component in the range 0-255.


getGreen

public int getGreen()
Returns the green component in the range 0-255.


getBlue

public int getBlue()
Returns the blue component in the range 0-255.


getAlpha

public int getAlpha()
Returns the alpha component in the range 0-255.


getRed2D

public float getRed2D()
Returns the red component in the range 0-1.


getGreen2D

public float getGreen2D()
Returns the green component in the range 0-1.


getBlue2D

public float getBlue2D()
Returns the blue component in the range 0-1.


getAlpha2D

public float getAlpha2D()
Returns the alpha component in the range 0-1.


brighter

public RMColor brighter()
Returns a color 70% brighter than this color.


brighter

public RMColor brighter(float aFactor)
Retures a color with the given percent brighter than this color.


darker

public RMColor darker()
Returns a color darker than this color (70% of this color's brightness).


blend

public RMColor blend(RMColor aColor,
                     float fraction)
Returns a color darker than this color (by this given fraction).


equals

public boolean equals(java.lang.Object obj)
Standar equals implementaiton.

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Returns a string representation of this color.

Overrides:
toString in class java.lang.Object

toHexString

public java.lang.String toHexString()
Returns a hex string representation of this color.


awt

public java.awt.Color awt()
Returns an AWT version of this color.


awt

public java.awt.Color awt(float dissolve)
Returns an AWT version of this color, with the alpha component scaled by the given dissolve factor.


colorValue

public static RMColor colorValue(java.lang.Object anObj)
Returns a color value for a given object.


toXML

public com.reportmill.archiver.RXElement toXML(com.reportmill.archiver.RXArchiver anArchiver)
XML archival.


fromXML

public java.lang.Object fromXML(com.reportmill.archiver.RXArchiver anArchiver,
                                com.reportmill.archiver.RXElement anElement)
XML unarchival.


rgbToLab

public static float[] rgbToLab(float r,
                               float g,
                               float b)
Converts an RGB triplet to a CIELab triplet


toLab

public float[] toLab()
Converts an RMColor to a CIELab triplet


ReportMill 10 API