|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.woven_media.util.color.ColorUtil
public class ColorUtil
ColorUtil is a static class for calculating color conversions and color models.
Constructor Summary | |
---|---|
ColorUtil()
|
Method Summary | |
---|---|
static int[] |
buildRGBarray(java.lang.String hex)
Builds an array of RGB values based on a hexadecimal triplet. |
static double[] |
cmykAsPercent(int c,
int m,
int y,
int k)
Converts CMYK values between 0 - 255 to values between 0 - 100 that can be expressed as percentages. |
static int[] |
cmykToRGB(int c,
int m,
int y,
int k)
Converts CMYK values to RGB. |
static int |
getBlue(java.lang.String blue)
Converts strings representing Blue RGB values to integers. |
static int |
getGreen(java.lang.String green)
Converts strings representing Green RGB values to integers. |
static java.lang.String[] |
getHSBvalues(int r,
int g,
int b)
Get HSB values from RGB color model. |
static java.awt.Color |
getNearestSafeColor(int[] rgbArray)
Returns a java.awt.Color object representing the nearest safe color. |
static int |
getRed(java.lang.String red)
Converts strings representing Red RGB values to integers. |
static java.awt.Color |
getRGBColor(java.lang.String hex)
Returns a RGB java.awt.Color object by parsing the hex string
parameter. |
static java.awt.Color |
getRGBColor(java.lang.String red,
java.lang.String grn,
java.lang.String blu)
Returns a java.awt.Color object from RGB strings. |
static int |
HEXtoRGB(java.lang.String hex)
Convenience routine that converts individual triplet values of a hexadecimal string to an integer. |
static float[] |
HSVtoRGB(float r,
float g,
float b,
float h,
float s,
float v)
Converts to RGB color model from HSV model. |
static boolean |
isColorSafe(java.lang.String hex)
Determines whether a hexadecimal string is a safe color equivalent. |
static boolean |
isValidHex(java.lang.String hex)
Tests whether a string is a valid hexadecimal value. |
static boolean |
isValidString(java.lang.String inString,
java.lang.String filterString)
Tests whether a string contains the required characters. |
int |
luminance(float r,
float g,
float b)
Grab the luminance the same way GIMP does. |
static int[] |
nearestSafeColor(int[] rgbArray)
Algorithm for determining the nearest safe color based on the values of a valid RGB array of unsigned integer values. |
static int[] |
parseAWTColor(java.awt.Color c)
Parses a java.awt.Color object and returns an array of RGB integers. |
static java.lang.String[] |
parseHex(java.lang.String hex)
Returns a java.lang.String array of the seperate red, green
and blue hexadecimal values and checks for the abbreviated form. |
static int[] |
rgbToCMYK(int red,
int grn,
int blu)
Approximation algorithm only for CMYK color! Converts RGB values to CMYK array of values. |
static java.lang.String |
RGBtoHEX(int red,
int green,
int blue)
Converts RGB integer values to a hexadecimal triplet and return as java.lang.String . |
static float[] |
RGBtoHSV(float r,
float g,
float b,
float h,
float s,
float v)
Converts to HSV color model from RGB model. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ColorUtil()
Method Detail |
---|
public static java.lang.String RGBtoHEX(int red, int green, int blue)
java.lang.String
.
red
- int
value representing red.green
- int
value representing green.blue
- int
value representing blue.public static boolean isValidHex(java.lang.String hex)
hex
- string representing a hexadecimal triplet number.
boolean
value indicating a valid or invalid hexadecimal string.public static boolean isValidString(java.lang.String inString, java.lang.String filterString)
inString
- string to check.filterString
- string of required characters.
boolean
value indicating a valid or invalid string.public static java.awt.Color getRGBColor(java.lang.String hex)
java.awt.Color
object by parsing the hex
string
parameter. An abbreviated, three (hexadecimal) digit form can be used, as well as the
standard six-digit form.
hex
- string representing a hexadecimal triplet or abbreviated triplet.
java.awt.Color
object created from the hex
string equivalent.parseHex(java.lang.String)
public static java.lang.String[] parseHex(java.lang.String hex)
java.lang.String
array of the seperate red, green
and blue hexadecimal values and checks for the abbreviated form. If the
hex
parameter is an abbreviated form, a six-digit standard form
hexadecimal triplet is created and returned as an array of strings.
hex
- hexadecimal triplet string, either six-digit or three-digit form.
getRGBColor(java.lang.String)
public static java.awt.Color getRGBColor(java.lang.String red, java.lang.String grn, java.lang.String blu)
java.awt.Color
object from RGB strings.
red
- string representing red.grn
- string representing green.blu
- string representing blue.
java.awt.Color
object created from RGB string values.NumberFormatException
,
Integer
public static boolean isColorSafe(java.lang.String hex)
hex
- string representing a hexadecimal triplet number.
boolean
value indicating whether a color is a safe color or not.public static int[] buildRGBarray(java.lang.String hex)
hex
- string representing a hexadecimal triplet number.
int
array of RGB values.public static int[] nearestSafeColor(int[] rgbArray)
rgbArray
- int
array of representing RGB values.
int
array of RGB values converted to a safe color equivalent.public static int[] rgbToCMYK(int red, int grn, int blu)
red
- int
value between (0-255) representing red.grn
- int
value between (0-255) representing green.blu
- int
value between (0-255) representing blue.
int
array of CMYK values converted from RGB.public static int[] parseAWTColor(java.awt.Color c)
java.awt.Color
object and returns an array of RGB integers.
c
- java.awt.Color
object.
int
array of RGB values converted from a java.awt.Color
object.StringTokenizer
,
StringBuffer
public static double[] cmykAsPercent(int c, int m, int y, int k)
c
- int
representing cyan.m
- int
representing magenta.y
- int
representing yellow.k
- int
representing black.
double
array of CMYK percentages.NumberFormat
public static int[] cmykToRGB(int c, int m, int y, int k)
c
- int
representing cyan.m
- int
representing magenta.y
- int
representing yellow.k
- int
representing black.
int
array of RGB values converted from CMYK.public static java.lang.String[] getHSBvalues(int r, int g, int b)
r
- int
representing red.g
- int
representing green.b
- int
representing blue.
public static java.awt.Color getNearestSafeColor(int[] rgbArray)
java.awt.Color
object representing the nearest safe color.
rgbArray
- array of valid RGB values.
java.awt.Color
objectpublic static int HEXtoRGB(java.lang.String hex)
hex
- string representing a single hexadecimal triplet number.
int
value of either red, green or blue.public static int getRed(java.lang.String red)
red
- string representing red
int
value representing red converted from a string.public static int getGreen(java.lang.String green)
green
- string representing green.
int
value representing green converted from a string.public static int getBlue(java.lang.String blue)
blue
- string representing blue.
int
value representing blue converted from a string.public int luminance(float r, float g, float b)
i.e. Math.round(0.3 * r + 0.59 * g + 0.11 * b)
int
value representing the luminance.public static float[] RGBtoHSV(float r, float g, float b, float h, float s, float v)
r
- represents red as a float value [0 - 1]g
- represents green as a float value [0 - 1]b
- represents blue as a float value [0 - 1]h
- represents hue as a float value [0,360]s
- represents saturation as a float value [0,1]v
- represents value as a float value [0,1]
float
array of HSV values converted from RGB.public static float[] HSVtoRGB(float r, float g, float b, float h, float s, float v)
r
- represents red as a float value [0 - 1]g
- represents green as a float value [0 - 1]b
- represents blue as a float value [0 - 1]h
- represents hue as a float value [0,360]s
- represents saturation as a float value [0,1]v
- represents value as a float value [0,1]
float
array of RGB values converted from HSV.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |