Class GraphicsUtils
java.lang.Object
de.erichseifert.vectorgraphics2d.util.GraphicsUtils
Abstract class that contains utility functions for working with graphics.
For example, this includes font handling.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final GraphicsUtils.FontExpressivenessComparatorprivate static final FontRenderContextprivate static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Shapestatic booleanstatic BufferedImagegetAlphaImage(BufferedImage image) static FontgetPhysicalFont(Font logicalFont) static FontgetPhysicalFont(Font logicalFont, String testText) Try to guess physical font from the properties of a logical font, like "Dialog", "Serif", "Monospaced" etc.static booleanThis method returnstrueif the specified image has the possibility to store transparent pixels.private static booleanisLogicalFontFamily(String family) static BufferedImagetoBufferedImage(Image image) This method returns a buffered image with the contents of an image.static BufferedImagetoBufferedImage(RenderedImage image) Converts a rendered image instance to aBufferedImage.static booleanThis method returnstrueif the specified image has at least one pixel that is not fully opaque.
-
Field Details
-
FONT_RENDER_CONTEXT
-
FONT_TEST_STRING
- See Also:
-
FONT_EXPRESSIVENESS_COMPARATOR
-
-
Constructor Details
-
GraphicsUtils
GraphicsUtils()Default constructor that prevents creation of class.
-
-
Method Details
-
hasAlpha
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
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
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
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
-
isLogicalFontFamily
-
getPhysicalFont
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
-
getAlphaImage
-
equals
-