Package org.openstreetmap.josm.tools
Enum Class ImageResizeMode
- All Implemented Interfaces:
Serializable,Comparable<ImageResizeMode>,Constable
Determines how the image is sized/resized in
ImageResource.getImageIcon(Dimension, boolean, ImageResizeMode).-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionCalculate proportional dimensions that best fit into the target width and height, retain aspect ratioCalculate dimensions for the largest image that fit within the bounding box, retain aspect ratioPosition an appropriately scaled image within the bounding box, retain aspect ratio -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) intReturns a cache key for this mode and the given dimension(package private) abstract DimensioncomputeDimension(Dimension dim, Dimension icon) Computes the dimension for the resulting image(package private) BufferedImagecreateBufferedImage(Dimension dim, Dimension icon, Consumer<Graphics2D> renderer, Image sourceIcon) Creates a new buffered image and applies the rendering function(package private) voidprepareGraphics(Dimension icon, BufferedImage image, Graphics2D g) Prepares the graphics object for rendering the given imagestatic ImageResizeModeReturns the enum constant of this class with the specified name.static ImageResizeMode[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
AUTO
Calculate proportional dimensions that best fit into the target width and height, retain aspect ratio -
BOUNDED
Calculate dimensions for the largest image that fit within the bounding box, retain aspect ratio -
PADDED
Position an appropriately scaled image within the bounding box, retain aspect ratio
-
-
Constructor Details
-
ImageResizeMode
private ImageResizeMode()
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
computeDimension
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
BufferedImage createBufferedImage(Dimension dim, Dimension icon, Consumer<Graphics2D> renderer, 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:
IllegalArgumentException- if renderer or sourceIcon is null
-
prepareGraphics
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
Returns a cache key for this mode and the given dimension- Parameters:
dim- the desired image dimension- Returns:
- a cache key
-