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.FontExpressivenessComparator
private static final FontRenderContext
private static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Shape
static boolean
static BufferedImage
getAlphaImage
(BufferedImage image) static Font
getPhysicalFont
(Font logicalFont) static Font
getPhysicalFont
(Font logicalFont, String testText) Try to guess physical font from the properties of a logical font, like "Dialog", "Serif", "Monospaced" etc.static boolean
This method returnstrue
if the specified image has the possibility to store transparent pixels.private static boolean
isLogicalFontFamily
(String family) static BufferedImage
toBufferedImage
(Image image) This method returns a buffered image with the contents of an image.static BufferedImage
toBufferedImage
(RenderedImage image) Converts a rendered image instance to aBufferedImage
.static boolean
This method returnstrue
if 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 returnstrue
if 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:
true
if the specified image can have transparent pixels,false
otherwise
-
usesAlpha
This method returnstrue
if 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:
true
if the specified image has transparent pixels,false
otherwise
-
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
-