Package org.openstreetmap.josm.tools
Enum ImageResizeMode
- java.lang.Object
-
- java.lang.Enum<ImageResizeMode>
-
- org.openstreetmap.josm.tools.ImageResizeMode
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<ImageResizeMode>
enum ImageResizeMode extends java.lang.Enum<ImageResizeMode>
Determines how the image is sized/resized inImageResource.getImageIcon(Dimension, boolean, ImageResizeMode)
.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description AUTO
Calculate proportional dimensions that best fit into the target width and height, retain aspect ratioBOUNDED
Calculate dimensions for the largest image that fit within the bounding box, retain aspect ratioPADDED
Position an appropriately scaled image within the bounding box, retain aspect ratio
-
Constructor Summary
Constructors Modifier Constructor Description private
ImageResizeMode()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) int
cacheKey(java.awt.Dimension dim)
Returns a cache key for this mode and the given dimension(package private) abstract java.awt.Dimension
computeDimension(java.awt.Dimension dim, java.awt.Dimension icon)
Computes the dimension for the resulting image(package private) java.awt.image.BufferedImage
createBufferedImage(java.awt.Dimension dim, java.awt.Dimension icon, java.util.function.Consumer<java.awt.Graphics2D> renderer, java.awt.Image sourceIcon)
Creates a new buffered image and applies the rendering function(package private) void
prepareGraphics(java.awt.Dimension icon, java.awt.image.BufferedImage image, java.awt.Graphics2D g)
Prepares the graphics object for rendering the given imagestatic ImageResizeMode
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static ImageResizeMode[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
AUTO
public static final ImageResizeMode AUTO
Calculate proportional dimensions that best fit into the target width and height, retain aspect ratio
-
BOUNDED
public static final ImageResizeMode BOUNDED
Calculate dimensions for the largest image that fit within the bounding box, retain aspect ratio
-
PADDED
public static final ImageResizeMode PADDED
Position an appropriately scaled image within the bounding box, retain aspect ratio
-
-
Constructor Detail
-
ImageResizeMode
private ImageResizeMode()
-
-
Method Detail
-
values
public static ImageResizeMode[] 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 (ImageResizeMode c : ImageResizeMode.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ImageResizeMode 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
-
computeDimension
abstract java.awt.Dimension computeDimension(java.awt.Dimension dim, java.awt.Dimension icon)
Computes the dimension for the resulting image- Parameters:
dim
- the desired image dimensionicon
- the dimensions of the image to resize- Returns:
- the dimension for the resulting image
-
createBufferedImage
java.awt.image.BufferedImage createBufferedImage(java.awt.Dimension dim, java.awt.Dimension icon, java.util.function.Consumer<java.awt.Graphics2D> renderer, java.awt.Image sourceIcon)
Creates a new buffered image and applies the rendering function- Parameters:
dim
- the desired image dimensionicon
- the dimensions of the image to resizerenderer
- the rendering functionsourceIcon
- the source icon to draw- Returns:
- a new buffered image
- Throws:
java.lang.IllegalArgumentException
- if renderer or sourceIcon is null
-
prepareGraphics
void prepareGraphics(java.awt.Dimension icon, java.awt.image.BufferedImage image, java.awt.Graphics2D g)
Prepares the graphics object for rendering the given image- Parameters:
icon
- the dimensions of the image to resizeimage
- the image to render afterwardsg
- graphics
-
cacheKey
int cacheKey(java.awt.Dimension dim)
Returns a cache key for this mode and the given dimension- Parameters:
dim
- the desired image dimension- Returns:
- a cache key
-
-