ru.novosoft.dc.rtf.dom.objects
Class RTFColor

java.lang.Object
  |
  +--ru.novosoft.dc.rtf.dom.objects.RTFColor

public final class RTFColor
extends java.lang.Object

The RTF color class.


Constructor Summary
RTFColor(int red, int green, int blue)
          Construct an RTF color from red, green, and blue components.
 
Method Summary
 int blue()
          Return the blue component of the color.
 double brightness()
          Return the brightnees of the color as a double value at the segment [0,1].
 boolean equals(java.lang.Object obj)
          Compare this color with another color and return true if colors coinside.
 int green()
          Return the green component of the color.
 double hue()
          Return the hue of the color as a double value at the segment [0,1].
 RTFColor mixedColor(RTFColor color, double r)
          Mix this color with another color in the specified ratio and return the mixed color.
 boolean needInvertAutoColor()
          Return true if this color is too dark as a background color (the additive lightness of RGB components less than 155).
 int red()
          Return the red component of the color.
 double saturation()
          Return the saturation of the color as a double value at the segment [0,1].
 java.lang.String toString()
          Convert a color to the hexadecimal number in the form "#XXXXXX".
static java.lang.String toString(int colorValue)
          Convert an integer color value to the hexadecimal number of the form "#XXXXXX", where pairs of digits correspond to RED, GREEN, and BLUE intensities from the left to the right.
static java.lang.String toTwoHexDigits(int value)
          Convert the low byte of an integer value to the upper-case hexadecimal string of two digits.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RTFColor

public RTFColor(int red,
                int green,
                int blue)
Construct an RTF color from red, green, and blue components. Every value is a number in the range [0..255].
Method Detail

red

public final int red()
Return the red component of the color.

green

public final int green()
Return the green component of the color.

blue

public final int blue()
Return the blue component of the color.

brightness

public double brightness()
Return the brightnees of the color as a double value at the segment [0,1].

saturation

public double saturation()
Return the saturation of the color as a double value at the segment [0,1].

hue

public double hue()
Return the hue of the color as a double value at the segment [0,1].

equals

public boolean equals(java.lang.Object obj)
Compare this color with another color and return true if colors coinside.
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Convert a color to the hexadecimal number in the form "#XXXXXX".
Overrides:
toString in class java.lang.Object

toString

public static java.lang.String toString(int colorValue)
Convert an integer color value to the hexadecimal number of the form "#XXXXXX", where pairs of digits correspond to RED, GREEN, and BLUE intensities from the left to the right. The integer color value contains 3 bytes in the back order: RED is the low byte, GREEN is the middle byte, and BLUE is the high byte. A value of color must be a valid integer in the range from 0 to 0xFFFFFF. Otherwise, the result is unexpected.

toTwoHexDigits

public static java.lang.String toTwoHexDigits(int value)
Convert the low byte of an integer value to the upper-case hexadecimal string of two digits.

mixedColor

public RTFColor mixedColor(RTFColor color,
                           double r)
Mix this color with another color in the specified ratio and return the mixed color. The formula for mixing colors is the following: mixed.component()=this.component()*(1-r)+color.component()*r, where component() means red(), green(), and blue(). If r is out of segment [0,1], inpredictable color is returned.
Parameters:
color - another color to mix with
r - a ratio of mixing (a value from the segment [0,1])

needInvertAutoColor

public final boolean needInvertAutoColor()
Return true if this color is too dark as a background color (the additive lightness of RGB components less than 155).