de.erichseifert.gral.util
Class GraphicsUtils
- java.lang.Object
-
- de.erichseifert.gral.util.GraphicsUtils
-
public abstract class GraphicsUtils extends java.lang.ObjectAbstract class that contains utility functions for working with graphics. For example, this includes font handling or color space conversion.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static java.awt.Colorblend(java.awt.Color color1, java.awt.Color color2, double weight)Linearly blends two colors with a defined weight.static java.awt.ColorderiveBrighter(java.awt.Color color)Creates a new brighter version of a color by blending it with white.static java.awt.ColorderiveDarker(java.awt.Color color)Creates a new darker version of a color by blending it with black.static java.awt.ColorderiveWithAlpha(java.awt.Color color, int alpha)Creates a new color with the same color components but a different alpha value.static voiddrawPaintedShape(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 voidfillPaintedShape(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.ShapegetOutline(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.
-
-
-
Method Detail
-
getOutline
public 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. The text may also contain line breaks ('\n').- Parameters:
text- Text to be displayed.font- Font of the Text.wrappingWidth- Maximum width of linesalignment- Alignment of the text when it spans multiple lines.- Returns:
- Shape of the text outline in the specified font.
-
fillPaintedShape
public 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.- Parameters:
graphics- Graphics to be painted into.shape- Shape to be filled.paint- Paint to be used.paintBounds- Optional bounds describing the painted area.
-
drawPaintedShape
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)Draws a filled Shape with the specified Paint object.- Parameters:
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.
-
rgb2xyz
public static double[] rgb2xyz(double[] rgb, double[] xyz)Converts color components from the sRGB to the CIE XYZ color space. A D50 white point is assumed for the sRGB conversion. If the xyz array isnull, 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.html- Parameters:
rgb- Color components in the sRGB color space.xyz- Optional array to store color components in the CIE XYZ color space.- Returns:
- Color components in the CIE XYZ color space.
-
luv2xyz
public static double[] luv2xyz(double[] luv, double[] xyz)Convert color components from the CIE L*u*v* to the CIE XYZ color space. If the xyz array isnull, 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.html- Parameters:
luv- Color components in the CIE L*u*v* color spacexyz- Optional array to store color components in the CIE XYZ color space.- Returns:
- Color components in the CIE XYZ color space.
-
xyz2rgb
public static double[] xyz2rgb(double[] xyz, double[] rgb)Converts color components from the sRGB to the CIE XYZ color space. A D50 white point is assumed for the sRGB conversion. If the rgb array isnull, 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.html- Parameters:
xyz- Color components in the CIE XYZ color space.rgb- Optional array for storing color components in the sRGB color space.- Returns:
- Color components in the sRGB color space.
-
xyz2luv
public static double[] xyz2luv(double[] xyz, double[] luv)Converts color components from the CIE XYZ to the CIE L*u*v* color space. If the luv array isnull, a new one will be created with the same size as the xyz array. http://www.brucelindbloom.com/index.html?Eqn_XYZ_to_Luv.html- Parameters:
xyz- Color components in the CIE XYZ color space.luv- Optional array for storing color components in the CIE L*u*v* color space.- Returns:
- Color components in the CIE L*u*v* color space.
-
rgb2luv
public static double[] rgb2luv(double[] rgb, double[] luv)Converts color components from the CIE L*u*v* to the sRGB color space. A D50 white point is assumed for the sRGB conversion. If the luv array isnull, a new one will be created with the same size as the rgb array.- Parameters:
rgb- Color components in the sRGB color space.luv- Optional array for storing color components in the CIE L*u*v* color space.- Returns:
- Color components in the CIE L*u*v* color space.
-
luv2rgb
public static double[] luv2rgb(double[] luv, double[] rgb)Converts color components from the CIE L*u*v* to the sRGB color space. A D50 white point is assumed for the sRGB conversion. If the rgb array isnull, a new one will be created with the same size as the luv array.- Parameters:
luv- Color components in the CIE L*u*v* color space.rgb- Optional array for storing color components in the sRGB color space.- Returns:
- Color components in sRGB color space.
-
blend
public static java.awt.Color blend(java.awt.Color color1, java.awt.Color color2, double weight)Linearly blends two colors with a defined weight.- Parameters:
color1- First color.color2- Second color.weight- Weighting factor in the range 0 to 1 (0 means color1, 1 means second color)- Returns:
- New blended color
-
deriveWithAlpha
public 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.- Parameters:
color- Original color.alpha- Alpha value for new color.- Returns:
- New color with specified alpha value.
-
deriveDarker
public static java.awt.Color deriveDarker(java.awt.Color color)
Creates a new darker version of a color by blending it with black. The derived color has the same alpha value as the original color.- Parameters:
color- Original color.- Returns:
- Darker color with same alpha value.
-
deriveBrighter
public static java.awt.Color deriveBrighter(java.awt.Color color)
Creates a new brighter version of a color by blending it with white. The derived color has the same alpha value as the original color.- Parameters:
color- Original color.- Returns:
- Brighter color with same alpha value.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG