Class ImageLoader


  • public class ImageLoader
    extends java.lang.Object
    The ImageLoader is the main interface for the images stored in the Gateway. While they're accessible via a URL, this class will maintain a cache system (both in-memory using soft references and a disk-backed cach) of images and resized versions of them.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void clearCache()
      Clears the in-memory image cache
      static ImageLoader getInstance()
      Get the shared instance of the ImageLoader
      byte[] loadBytes​(java.lang.String name)
      Loads the named image, and returns its raw bytes.
      java.awt.Image loadImage​(java.lang.String name)
      Loads the named image.
      java.awt.Image loadImage​(java.lang.String name, int width, int height)
      Deprecated.
      java.awt.Image loadImage​(java.lang.String name, java.awt.Dimension size)
      Loads the named image and resizes it to the given size.
      java.awt.Image loadImageNoCache​(java.lang.String name, java.awt.Dimension size)
      Loads the named image at the given size, but skips any caching mechanism.
      static void setCacheDir​(java.io.File cacheDir)
      Set the directory used to cache images and their resized versions
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInstance

        public static ImageLoader getInstance()
        Get the shared instance of the ImageLoader
      • setCacheDir

        public static void setCacheDir​(java.io.File cacheDir)
        Set the directory used to cache images and their resized versions
      • loadImage

        @Deprecated
        public java.awt.Image loadImage​(java.lang.String name,
                                        int width,
                                        int height)
        Deprecated.
      • loadImage

        public java.awt.Image loadImage​(java.lang.String name)
        Loads the named image. If possible, the image is retrieved from an in-memory image cache.
      • loadImage

        public java.awt.Image loadImage​(java.lang.String name,
                                        java.awt.Dimension size)
        Loads the named image and resizes it to the given size.
        Parameters:
        name - The path to the image. May be a path to a gateway image or a URL
        size - The size to resize the image to. May be null, which means to use the natural size.
      • loadImageNoCache

        public java.awt.Image loadImageNoCache​(java.lang.String name,
                                               java.awt.Dimension size)
        Loads the named image at the given size, but skips any caching mechanism. This will download the image and resize it fresh, each time it is called.
        Parameters:
        name - The path to the image or the URL to an image.
        size - The size to resize the image to, or null meaning return the image at its natural size.
      • loadBytes

        public byte[] loadBytes​(java.lang.String name)
        Loads the named image, and returns its raw bytes.
      • clearCache

        public void clearCache()
        Clears the in-memory image cache