Class GraphicsUtils
- java.lang.Object
-
- de.erichseifert.vectorgraphics2d.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classGraphicsUtils.FontExpressivenessComparator
-
Field Summary
Fields Modifier and Type Field Description private static GraphicsUtils.FontExpressivenessComparatorFONT_EXPRESSIVENESS_COMPARATORprivate static java.awt.font.FontRenderContextFONT_RENDER_CONTEXTprivate static java.lang.StringFONT_TEST_STRING
-
Constructor Summary
Constructors Constructor Description GraphicsUtils()Default constructor that prevents creation of class.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.awt.Shapeclone(java.awt.Shape shape)static booleanequals(java.awt.Shape shapeA, java.awt.Shape shapeB)static java.awt.image.BufferedImagegetAlphaImage(java.awt.image.BufferedImage image)static java.awt.FontgetPhysicalFont(java.awt.Font logicalFont)static java.awt.FontgetPhysicalFont(java.awt.Font logicalFont, java.lang.String testText)Try to guess physical font from the properties of a logical font, like "Dialog", "Serif", "Monospaced" etc.static booleanhasAlpha(java.awt.Image image)This method returnstrueif the specified image has the possibility to store transparent pixels.private static booleanisLogicalFontFamily(java.lang.String family)static java.awt.image.BufferedImagetoBufferedImage(java.awt.Image image)This method returns a buffered image with the contents of an image.static java.awt.image.BufferedImagetoBufferedImage(java.awt.image.RenderedImage image)Converts a rendered image instance to aBufferedImage.static booleanusesAlpha(java.awt.Image image)This method returnstrueif the specified image has at least one pixel that is not fully opaque.
-
-
-
Field Detail
-
FONT_RENDER_CONTEXT
private static final java.awt.font.FontRenderContext FONT_RENDER_CONTEXT
-
FONT_TEST_STRING
private static final java.lang.String FONT_TEST_STRING
- See Also:
- Constant Field Values
-
FONT_EXPRESSIVENESS_COMPARATOR
private static final GraphicsUtils.FontExpressivenessComparator FONT_EXPRESSIVENESS_COMPARATOR
-
-
Method Detail
-
hasAlpha
public static boolean hasAlpha(java.awt.Image image)
This method returnstrueif the specified image has the possibility to store transparent pixels. Inspired by http://www.exampledepot.com/egs/java.awt.image/HasAlpha.html- Parameters:
image- Image that should be checked for alpha channel.- Returns:
trueif the specified image can have transparent pixels,falseotherwise
-
usesAlpha
public static boolean usesAlpha(java.awt.Image image)
This method returnstrueif the specified image has at least one pixel that is not fully opaque.- Parameters:
image- Image that should be checked for non-opaque pixels.- Returns:
trueif the specified image has transparent pixels,falseotherwise
-
toBufferedImage
public static java.awt.image.BufferedImage toBufferedImage(java.awt.image.RenderedImage image)
Converts a rendered image instance to aBufferedImage.- Parameters:
image- Rendered image that should be converted.- Returns:
- a buffered image containing the image pixels, or the original
instance if the image already was of type
BufferedImage.
-
toBufferedImage
public static java.awt.image.BufferedImage toBufferedImage(java.awt.Image image)
This method returns a buffered image with the contents of an image. Taken from http://www.exampledepot.com/egs/java.awt.image/Image2Buf.html- Parameters:
image- Image to be converted- Returns:
- a buffered image with the contents of the specified image
-
clone
public static java.awt.Shape clone(java.awt.Shape shape)
-
isLogicalFontFamily
private static boolean isLogicalFontFamily(java.lang.String family)
-
getPhysicalFont
public static java.awt.Font getPhysicalFont(java.awt.Font logicalFont, java.lang.String testText)Try to guess physical font from the properties of a logical font, like "Dialog", "Serif", "Monospaced" etc.- Parameters:
logicalFont- Logical font object.testText- Text used to determine font properties.- Returns:
- An object of the first matching physical font. The original font object is returned if it was a physical font or no font matched.
-
getPhysicalFont
public static java.awt.Font getPhysicalFont(java.awt.Font logicalFont)
-
getAlphaImage
public static java.awt.image.BufferedImage getAlphaImage(java.awt.image.BufferedImage image)
-
equals
public static boolean equals(java.awt.Shape shapeA, java.awt.Shape shapeB)
-
-