public class ColorHelper
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
contains(RColor ref,
java.util.ArrayList<RColor> colors)
Checks if ref is member of colors.
|
static boolean |
contains(RColor ref,
RColor[] colors)
Checks if ref is member of colors.
|
static void |
convert(java.util.ArrayList<RColor> colors,
ColorSpace target)
Converts the input colors c into the given color space.
|
static void |
convert(RColor[] colors,
ColorSpace target)
Converts the input colors c into the given color space.
|
static RColor |
convert(RColor c,
ColorDifferenceMeasure m)
Converts the input color c into a appropriate color model defined by the
ColorDifferenceMeasure.
|
static RColor |
convert(RColor c,
ColorSpace target)
Converts the input color c into the given target color space.
|
static java.util.ArrayList<RColor> |
copy(java.util.ArrayList<RColor> colors)
Creates a copy array of the given input.
|
static RColor[] |
copy(RColor[] colors)
Creates a copy array of the given input.
|
static int |
getColor(float... paramters)
Converts input values to a color.
|
static int |
getColor(java.lang.String hex)
Converts a String, containing a hexadecimal number, to a color.
|
static java.lang.Float |
getLoss(RColor rvMean,
java.util.ArrayList<RColor> colors,
ColorDifferenceMeasure m)
Calculates the loss - the mean distance of all members of colors to
rvMean.
|
static java.lang.Float |
getLoss(RColor rvMean,
java.util.ArrayList<RColor> colors,
ColorDifferenceMeasure m,
int start,
int end)
Calculates the loss - the mean distance of all members of colors to
rvMean.
|
static java.lang.Float |
getLoss(RColor rvMean,
RColor[] colors,
ColorDifferenceMeasure m)
Calculates the loss - the mean distance of all members of colors to
rvMean.
|
static java.lang.Float |
getLoss(RColor rvMean,
RColor[] colors,
ColorDifferenceMeasure m,
int start,
int end)
Calculates the loss - the mean distance of all members of colors to
rvMean.
|
static RColor |
getMeanColor(java.util.ArrayList<RColor> colors,
ColorDifferenceMeasure m)
Returns the mean color of the given set colors using the color
space defined by the ColorDifferenceMeasure m, e.g RGBEuclidean is
mapped to RGBColor.
|
static RColor |
getMeanColor(java.util.ArrayList<RColor> colors,
ColorSpace space)
Returns the mean color of the given set colors using the color
space defined by space.
|
static RColor |
getMeanColor(ColorDifferenceMeasure m,
RColor... colors)
Returns the mean color of the given set colors using the color
space defined by the ColorDifferenceMeasure m, e.g RGBEuclidean is
mapped to RGBColor.
|
static RColor |
getMeanColor(RColor[] colors,
ColorDifferenceMeasure m)
Returns the mean color of the given set colors using the color
space defined by the ColorDifferenceMeasure m, e.g RGBEuclidean is
mapped to RGBColor.
|
static RColor |
getMeanColor(RColor[] colors,
ColorSpace space)
Returns the mean color of the given set colors using the color
space defined by space.
|
static int |
getRandomColor()
Creates a random opaque color.
|
static RColor |
lerpColors(RColor c1,
RColor c2,
float amt)
Lerps the two input colors and creates a new color.
|
public static RColor[] copy(RColor[] colors)
colors - A set of colors.public static java.util.ArrayList<RColor> copy(java.util.ArrayList<RColor> colors)
colors - A set of colors.public static java.lang.Float getLoss(RColor rvMean, RColor[] colors, ColorDifferenceMeasure m)
rvMean - A base color which will be used to calculate the distance to.colors - Colors.m - The measure which defines how the loss is calculated and which
color model will be used.public static java.lang.Float getLoss(RColor rvMean, RColor[] colors, ColorDifferenceMeasure m, int start, int end)
rvMean - A base color which will be used to calculate the distance to.colors - Colors.m - The measure which defines how the loss is calculated and which
color model will be used.start - Start index of the subset of the input colors (start < end).
start will be member of the subset.end - End index of the subset of the input colors (start < end). end
will not be member of the subset.public static java.lang.Float getLoss(RColor rvMean, java.util.ArrayList<RColor> colors, ColorDifferenceMeasure m)
rvMean - A base color which will be used to calculate the distance to.colors - Colors.m - The measure which defines how the loss is calculated and which
color model will be used.public static java.lang.Float getLoss(RColor rvMean, java.util.ArrayList<RColor> colors, ColorDifferenceMeasure m, int start, int end)
rvMean - A base color which will be used to calculate the distance to.colors - Colors.m - The measure which defines how the loss is calculated and which
color model will be used.start - Start index of the subset of the input colors (start < end).
start will be member of the subset.end - End index of the subset of the input colors (start < end). end
will not be member of the subset.public static RColor getMeanColor(ColorDifferenceMeasure m, RColor... colors)
m - A ColorDifferenceMeasure.colors - A set of colors (not null, one or more colors).public static RColor getMeanColor(RColor[] colors, ColorDifferenceMeasure m)
colors - A set of colors (not null, one or more colors).m - A ColorDifferenceMeasure.public static RColor getMeanColor(java.util.ArrayList<RColor> colors, ColorDifferenceMeasure m)
colors - A set of colors (not null, one or more colors).m - A ColorDifferenceMeasure.public static RColor getMeanColor(RColor[] colors, ColorSpace space)
colors - A set of colors (not null, one or more colors).space - A color space.public static RColor getMeanColor(java.util.ArrayList<RColor> colors, ColorSpace space)
colors - A set of colors (not null, one or more colors).space - A color space.public static RColor lerpColors(RColor c1, RColor c2, float amt)
c1 - The first color.c2 - The second color.amt - The lerping value [0, 1].public static RColor convert(RColor c, ColorSpace target)
c - The color which should be converted.target - The color space to convert to.public static RColor convert(RColor c, ColorDifferenceMeasure m)
c - The color which should be converted.m - The color difference measure.public static void convert(RColor[] colors, ColorSpace target)
colors - The colors which should be converted.target - The target color space.public static void convert(java.util.ArrayList<RColor> colors, ColorSpace target)
colors - The colors which should be converted.target - The target color space.public static boolean contains(RColor ref, RColor[] colors)
ref - A color or null.colors - Colors (Not null, members might be null)public static boolean contains(RColor ref, java.util.ArrayList<RColor> colors)
ref - A color or null.colors - Colors (Not null, members might be null)public static int getRandomColor()
public static int getColor(java.lang.String hex)
hex - A string containing a hexadecimal number.public static int getColor(float... paramters)
paramters - Either [gray], [gray, alpha] or [r, g, b] or [r, g, b, alpha].