Enum Class ImageResizeMode

java.lang.Object
java.lang.Enum<ImageResizeMode>
org.openstreetmap.josm.tools.ImageResizeMode
All Implemented Interfaces:
Serializable, Comparable<ImageResizeMode>, Constable

Determines how the image is sized/resized in ImageResource.getImageIcon(Dimension, boolean, ImageResizeMode).
  • Enum Constant Details

    • 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 Details

  • Method Details

    • values

      public static ImageResizeMode[] 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

      public static ImageResizeMode valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • computeDimension

      Computes the dimension for the resulting image
      Parameters:
      dim - the desired image dimension
      icon - the dimensions of the image to resize
      Returns:
      the dimension for the resulting image
    • createBufferedImage

      Creates a new buffered image and applies the rendering function
      Parameters:
      dim - the desired image dimension
      icon - the dimensions of the image to resize
      renderer - the rendering function
      sourceIcon - 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 resize
      image - the image to render afterwards
      g - graphics
    • cacheKey

      int cacheKey(Dimension dim)
      Returns a cache key for this mode and the given dimension
      Parameters:
      dim - the desired image dimension
      Returns:
      a cache key