Class IconCache


  • public class IconCache
    extends Object
    Icon Cache of icon images
    Since:
    3.2.0
    Author:
    osbornb
    • Field Detail

      • DEFAULT_CACHE_SIZE

        public static final int DEFAULT_CACHE_SIZE
        Default max number of icon images to retain in cache
        See Also:
        Constant Field Values
    • Constructor Detail

      • IconCache

        public IconCache()
        Constructor, created with cache size of DEFAULT_CACHE_SIZE
      • IconCache

        public IconCache​(int size)
        Constructor
        Parameters:
        size - max icon images to retain in the cache
    • Method Detail

      • get

        public BufferedImage get​(IconRow iconRow)
        Get the cached image for the icon row or null if not cached
        Parameters:
        iconRow - icon row
        Returns:
        icon image or null
      • get

        public BufferedImage get​(long iconRowId)
        Get the cached image for the icon row id or null if not cached
        Parameters:
        iconRowId - icon row id
        Returns:
        icon image or null
      • put

        public BufferedImage put​(IconRow iconRow,
                                 BufferedImage image)
        Cache the icon image for the icon row
        Parameters:
        iconRow - icon row
        image - icon image
        Returns:
        previous cached icon image or null
      • put

        public BufferedImage put​(long iconRowId,
                                 BufferedImage image)
        Cache the icon image for the icon row id
        Parameters:
        iconRowId - icon row id
        image - icon image
        Returns:
        previous cached icon image or null
      • remove

        public BufferedImage remove​(IconRow iconRow)
        Remove the cached image for the icon row
        Parameters:
        iconRow - icon row
        Returns:
        removed icon image or null
      • remove

        public BufferedImage remove​(long iconRowId)
        Remove the cached image for the icon row id
        Parameters:
        iconRowId - icon row id
        Returns:
        removed icon image or null
      • clear

        public void clear()
        Clear the cache
      • resize

        public void resize​(int maxSize)
        Resize the cache
        Parameters:
        maxSize - max size
      • createIcon

        public BufferedImage createIcon​(IconRow icon)
        Create or retrieve from cache an icon image for the icon row
        Parameters:
        icon - icon row
        Returns:
        icon image
      • createIcon

        public BufferedImage createIcon​(IconRow icon,
                                        float scale)
        Create or retrieve from cache an icon image for the icon row
        Parameters:
        icon - icon row
        scale - scale factor
        Returns:
        icon image
      • createIconNoCache

        public static BufferedImage createIconNoCache​(IconRow icon)
        Create an icon image for the icon row without caching
        Parameters:
        icon - icon row
        Returns:
        icon image
      • createIconNoCache

        public static BufferedImage createIconNoCache​(IconRow icon,
                                                      float scale)
        Create an icon image for the icon row without caching
        Parameters:
        icon - icon row
        scale - scale factor
        Returns:
        icon image
      • createIcon

        public static BufferedImage createIcon​(IconRow icon,
                                               IconCache iconCache)
        Create or retrieve from cache an icon image for the icon row
        Parameters:
        icon - icon row
        iconCache - icon cache
        Returns:
        icon image
      • createIcon

        public static BufferedImage createIcon​(IconRow icon,
                                               float scale,
                                               IconCache iconCache)
        Create or retrieve from cache an icon image for the icon row
        Parameters:
        icon - icon row
        scale - scale factor
        iconCache - icon cache
        Returns:
        icon image