Enum ImageResizeMode

    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      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 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 image
      static 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.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • 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
    • 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 name
        java.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 dimension
        icon - 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 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:
        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 resize
        image - the image to render afterwards
        g - 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