public abstract class GraphicsUtils
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
GraphicsUtils()
Default constructor that prevents creation of class.
|
Modifier and Type | Method and Description |
---|---|
static java.awt.Color |
blend(java.awt.Color color1,
java.awt.Color color2,
double weight)
Linearly blends two colors with a defined weight.
|
static java.awt.Color |
deriveBrighter(java.awt.Color color)
Creates a new brighter version of a color by blending it with white.
|
static java.awt.Color |
deriveDarker(java.awt.Color color)
Creates a new darker version of a color by blending it with black.
|
static java.awt.Color |
deriveWithAlpha(java.awt.Color color,
int alpha)
Creates a new color with the same color components but a different
alpha value.
|
static void |
drawPaintedShape(java.awt.Graphics2D graphics,
java.awt.Shape shape,
java.awt.Paint paint,
java.awt.geom.Rectangle2D paintBounds,
java.awt.Stroke stroke)
Draws a filled Shape with the specified Paint object.
|
static void |
fillPaintedShape(java.awt.Graphics2D graphics,
java.awt.Shape shape,
java.awt.Paint paint,
java.awt.geom.Rectangle2D paintBounds)
Fills a Shape with the specified Paint object.
|
static java.awt.Shape |
getOutline(java.lang.String text,
java.awt.Font font,
float wrappingWidth,
double alignment)
Returns the outline for the specified text using the specified font and
line width.
|
static double[] |
luv2rgb(double[] luv,
double[] rgb)
Converts color components from the CIE L*u*v* to the sRGB color space.
|
static double[] |
luv2xyz(double[] luv,
double[] xyz)
Convert color components from the CIE L*u*v* to the CIE XYZ color space.
|
static double[] |
rgb2luv(double[] rgb,
double[] luv)
Converts color components from the CIE L*u*v* to the sRGB color space.
|
static double[] |
rgb2xyz(double[] rgb,
double[] xyz)
Converts color components from the sRGB to the CIE XYZ color space.
|
static double[] |
xyz2luv(double[] xyz,
double[] luv)
Converts color components from the CIE XYZ to the CIE L*u*v* color
space.
|
static double[] |
xyz2rgb(double[] xyz,
double[] rgb)
Converts color components from the sRGB to the CIE XYZ color space.
|
protected GraphicsUtils()
public static java.awt.Shape getOutline(java.lang.String text, java.awt.Font font, float wrappingWidth, double alignment)
text
- Text to be displayed.font
- Font of the Text.wrappingWidth
- Maximum width of linesalignment
- Alignment of the text when it spans multiple lines.public static void fillPaintedShape(java.awt.Graphics2D graphics, java.awt.Shape shape, java.awt.Paint paint, java.awt.geom.Rectangle2D paintBounds)
graphics
- Graphics to be painted into.shape
- Shape to be filled.paint
- Paint to be used.paintBounds
- Optional bounds describing the painted area.public static void drawPaintedShape(java.awt.Graphics2D graphics, java.awt.Shape shape, java.awt.Paint paint, java.awt.geom.Rectangle2D paintBounds, java.awt.Stroke stroke)
graphics
- Graphics to be painted into.shape
- Shape to be filled.paint
- Paint to be used.paintBounds
- Optional bounds describing the painted area.stroke
- Stroke to be used for outlines.public static double[] rgb2xyz(double[] rgb, double[] xyz)
null
, a new one will be created with the same
size as the rgb array.
See http://www.brucelindbloom.com/index.html?Eqn_RGB_to_XYZ.htmlrgb
- Color components in the sRGB color space.xyz
- Optional array to store color components in the CIE XYZ color space.public static double[] luv2xyz(double[] luv, double[] xyz)
null
, a new one will be created
with the same size as the luv array.
See http://www.brucelindbloom.com/index.html?Eqn_Luv_to_XYZ.htmlluv
- Color components in the CIE L*u*v* color spacexyz
- Optional array to store color components in the CIE XYZ color
space.public static double[] xyz2rgb(double[] xyz, double[] rgb)
null
, a new one will be created with the same
size as the xyz array.
See http://www.brucelindbloom.com/index.html?Eqn_XYZ_to_RGB.htmlxyz
- Color components in the CIE XYZ color space.rgb
- Optional array for storing color components in the sRGB color
space.public static double[] xyz2luv(double[] xyz, double[] luv)
null
, a new one will be
created with the same size as the xyz array.
http://www.brucelindbloom.com/index.html?Eqn_XYZ_to_Luv.htmlxyz
- Color components in the CIE XYZ color space.luv
- Optional array for storing color components in the CIE L*u*v*
color space.public static double[] rgb2luv(double[] rgb, double[] luv)
null
, a new one will be created with the same
size as the rgb array.rgb
- Color components in the sRGB color space.luv
- Optional array for storing color components in the CIE L*u*v*
color space.public static double[] luv2rgb(double[] luv, double[] rgb)
null
, a new one will be created with the same size
as the luv array.luv
- Color components in the CIE L*u*v* color space.rgb
- Optional array for storing color components in the sRGB color
space.public static java.awt.Color blend(java.awt.Color color1, java.awt.Color color2, double weight)
color1
- First color.color2
- Second color.weight
- Weighting factor in the range 0 to 1 (0 means color1, 1 means second color)public static java.awt.Color deriveWithAlpha(java.awt.Color color, int alpha)
color
- Original color.alpha
- Alpha value for new color.public static java.awt.Color deriveDarker(java.awt.Color color)
color
- Original color.public static java.awt.Color deriveBrighter(java.awt.Color color)
color
- Original color.