Class RadianceCommonCortex
- java.lang.Object
-
- org.pushingpixels.radiance.common.api.RadianceCommonCortex
-
public class RadianceCommonCortex extends java.lang.Object
Provides the public API surface for working with platform-consistent fonts, text rendering and offscreen bitmap rendering.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
RadianceCommonCortex.PainterScale1X
static class
RadianceCommonCortex.Platform
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.lang.String,java.util.Map>
desktopHintsCache
private static RadianceCommonCortex.Platform
platform
private static java.lang.String
PROP_DESKTOPHINTS
-
Constructor Summary
Constructors Modifier Constructor Description private
RadianceCommonCortex()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
clearDesktopHints(java.awt.Graphics2D g2, java.awt.Font font)
static java.awt.image.BufferedImage
createThumbnail(double scale, java.awt.image.BufferedImage image, int requestedThumbWidth)
Creates a thumbnail of the specified width.private static java.util.Map
desktopHints(java.awt.Graphics2D g2)
static void
drawImageWithScale(java.awt.Graphics g, double scaleFactor, java.awt.Image img, int x, int y)
static void
drawImageWithScale(java.awt.Graphics g, double scaleFactor, java.awt.Image img, int x, int y, int width, int height, int offsetX, int offsetY)
static java.awt.image.BufferedImage
getBlankScaledImage(double scale, int width, int height)
Gets a scaled, high-DPI aware image of specified dimensions.static java.awt.image.BufferedImage
getBlankUnscaledImage(int width, int height)
Gets an unscaled, high-DPI aware image of specified dimensions.static FontPolicy
getDefaultFontPolicy()
Returns the default platform-specific font policy.static RadianceCommonCortex.Platform
getPlatform()
static FontPolicy
getScaledFontPolicy(float scaleFactor)
Returns scaled platform-specific font policy.static double
getScaleFactor(java.awt.Component component)
static void
installDesktopHints(java.awt.Graphics2D g2, java.awt.Font font)
private static boolean
isPrinting(java.awt.Graphics g)
static void
paintAtScale1x(java.awt.Graphics2D g, int x, int y, int width, int height, RadianceCommonCortex.PainterScale1X painterScale1X)
-
-
-
Field Detail
-
PROP_DESKTOPHINTS
private static final java.lang.String PROP_DESKTOPHINTS
- See Also:
- Constant Field Values
-
platform
private static RadianceCommonCortex.Platform platform
-
desktopHintsCache
private static java.util.Map<java.lang.String,java.util.Map> desktopHintsCache
-
-
Method Detail
-
getPlatform
public static RadianceCommonCortex.Platform getPlatform()
-
getDefaultFontPolicy
public static FontPolicy getDefaultFontPolicy()
Returns the default platform-specific font policy.- Returns:
- Default platform-specific font policy.
-
getScaledFontPolicy
public static FontPolicy getScaledFontPolicy(float scaleFactor)
Returns scaled platform-specific font policy.- Parameters:
scaleFactor
- Scale factor. Should be positive.- Returns:
- Scaled platform-specific font policy.
-
createThumbnail
public static java.awt.image.BufferedImage createThumbnail(double scale, java.awt.image.BufferedImage image, int requestedThumbWidth)
Creates a thumbnail of the specified width.- Parameters:
image
- The original image.requestedThumbWidth
- The width of the resulting thumbnail.- Returns:
- Thumbnail of the specified width.
-
installDesktopHints
public static void installDesktopHints(java.awt.Graphics2D g2, java.awt.Font font)
-
clearDesktopHints
public static void clearDesktopHints(java.awt.Graphics2D g2, java.awt.Font font)
-
desktopHints
private static java.util.Map desktopHints(java.awt.Graphics2D g2)
-
isPrinting
private static boolean isPrinting(java.awt.Graphics g)
-
getScaleFactor
public static double getScaleFactor(java.awt.Component component)
-
getBlankScaledImage
public static java.awt.image.BufferedImage getBlankScaledImage(double scale, int width, int height)
Gets a scaled, high-DPI aware image of specified dimensions.Use
drawImageWithScale(Graphics, double, Image, int, int)
ordrawImageWithScale(Graphics, double, Image, int, int, int, int, int, int)
to draw the image obtained with this method. Note that applying an extension ofRadianceAbstractFilter
is a "safe" operation as far as preserving the scale-aware configuration. If you are using a customBufferedImageOp
that is not aRadianceAbstractFilter
, the resulting image will be a regularBufferedImage
that will not be drawn correctly using one of thedrawImageWithScale
methods above. In such a case, usegetScaleFactor(Component)
to divide the image width and height for the purposes of drawing.- Parameters:
width
- Width of the target imageheight
- Width of the target image- Returns:
- A scaled, high-DPI aware image of specified dimensions.
-
getBlankUnscaledImage
public static java.awt.image.BufferedImage getBlankUnscaledImage(int width, int height)
Gets an unscaled, high-DPI aware image of specified dimensions.- Parameters:
width
- Width of the target imageheight
- Width of the target image- Returns:
- An unscaled, high-DPI aware image of specified dimensions.
-
drawImageWithScale
public static void drawImageWithScale(java.awt.Graphics g, double scaleFactor, java.awt.Image img, int x, int y)
-
drawImageWithScale
public static void drawImageWithScale(java.awt.Graphics g, double scaleFactor, java.awt.Image img, int x, int y, int width, int height, int offsetX, int offsetY)
-
paintAtScale1x
public static void paintAtScale1x(java.awt.Graphics2D g, int x, int y, int width, int height, RadianceCommonCortex.PainterScale1X painterScale1X)
-
-