Package ca.cgjennings.apps.arkham.sheet
Enum RenderTarget
- java.lang.Object
-
- java.lang.Enum<RenderTarget>
-
- ca.cgjennings.apps.arkham.sheet.RenderTarget
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<RenderTarget>
public enum RenderTarget extends java.lang.Enum<RenderTarget>
An enumeration of generic use cases for a requested rendering. When a caller wants to request that a sheet (or an item in a deck) be drawn, it must also provide this hint to describe how it intends to use the requested result. The hint will be used to choose the most appropriate combination of rendering algorithms.Note that if you are implementing a
Sheet
, you do not generally have to be concerned with this value as the framework will respond to the hint for you.- Since:
- 3.0
- Author:
- Chris Jennings
-
-
Enum Constant Summary
Enum Constants Enum Constant Description EXPORT
Indicates that the purpose of the rendering is to create a standalone image (typically at high resolution) suitable for use in other applications.FAST_PREVIEW
Indicates that the purpose of the rendering is to create a preview image, and furthermore that completing the rendering quickly is more important than image quality.PREVIEW
Indicates that the purpose of the rendering is to create a preview image.PRINT
Indicates that the purpose of the rendering is to render a printed image.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
applyTo(java.awt.Graphics2D g)
Applies suitable rendering hints to the graphics context for this target.int
getTransformInterpolationType()
Returns an appropriateAffineTransformOp
interpolation type for this target.java.awt.image.BufferedImage
resample(java.awt.image.BufferedImage source, float factor)
Returns a version of the image that is scaled up or down from the source image by the requested scaling factor.java.awt.image.BufferedImage
resample(java.awt.image.BufferedImage source, int width, int height)
Returns a scaled version of the source image.static RenderTarget
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static RenderTarget[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
FAST_PREVIEW
public static final RenderTarget FAST_PREVIEW
Indicates that the purpose of the rendering is to create a preview image, and furthermore that completing the rendering quickly is more important than image quality. This can be useful in specific situations, such as creating a thumbnail image. In more general contexts, it indicates that the user's system is not capable of adequate performance at the regularPREVIEW
target level. As a general guideline, you should aim for adequate performance on systems that are at least two years old when this target is active.
-
PREVIEW
public static final RenderTarget PREVIEW
Indicates that the purpose of the rendering is to create a preview image. This target strikes a balance between speed and quality. As a general guideline, you should aim for adequate performance on systems that are less than two years old when this target is active.
-
EXPORT
public static final RenderTarget EXPORT
Indicates that the purpose of the rendering is to create a standalone image (typically at high resolution) suitable for use in other applications. This target favours quality without regard to speed.
-
PRINT
public static final RenderTarget PRINT
Indicates that the purpose of the rendering is to render a printed image. This target favours quality without regard to speed.
-
-
Method Detail
-
values
public static RenderTarget[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (RenderTarget c : RenderTarget.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static RenderTarget valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
applyTo
public void applyTo(java.awt.Graphics2D g)
Applies suitable rendering hints to the graphics context for this target. This will apply a default set of hints that is suitable for most applications. Some renderers may choose to further customize the graphics context.- Parameters:
g
- the graphics context to modify- Throws:
java.lang.NullPointerException
- if the graphics context isnull
- See Also:
Sheet.applyContextHints(java.awt.Graphics2D)
-
getTransformInterpolationType
public int getTransformInterpolationType()
Returns an appropriateAffineTransformOp
interpolation type for this target.- Returns:
- an appropriate affine transform interpolation type
-
resample
public java.awt.image.BufferedImage resample(java.awt.image.BufferedImage source, int width, int height)
Returns a scaled version of the source image. The image will be scaled usingImageUtilities.resample(java.awt.image.BufferedImage, int, int, boolean, java.lang.Object, java.lang.Object)
using appropriate hint values for the target type. If either the width or height is less than 1, a value of 1 will be used for that dimension since images cannot have a 0 width or height.- Parameters:
source
- the image to scalewidth
- the desired image widthheight
- the desired image height- Returns:
- a scaled version of the image
- Throws:
java.lang.NullPointerException
- if the source image isnull
- See Also:
ScaleCache
-
resample
public final java.awt.image.BufferedImage resample(java.awt.image.BufferedImage source, float factor)
Returns a version of the image that is scaled up or down from the source image by the requested scaling factor. If the size of the scaled image matches a previously cached result, then the cached result will be returned. If the scale is 1, then the source image will be returned.- Parameters:
factor
- a scaling factor to apply to the image- Returns:
- a version of the source image whose dimensions are scaled by the requested amount
- Throws:
java.lang.NullPointerException
- if the source image isnull
- See Also:
ScaleCache
-
-