Class ImageManager

java.lang.Object
cnuphys.splot.plot.ImageManager

public class ImageManager extends Object
  • Field Details

  • Method Details

    • getInstance

      public static ImageManager getInstance()
      Access to the image manager singleton
      Returns:
      the image manager singleton.
    • loadImage

      public Image loadImage(String imageFileName, Component component)
      Load an image from file or the jar file.
      Parameters:
      imageFileName - the image files name.
      component - a component to serve as an ImageObserver(any component should do).
      Returns:
      the image
    • loadImageIcon

      public ImageIcon loadImageIcon(BufferedImage bufferedImage, String hashKey)
      Load an image icon from a buffered image.
      Parameters:
      bufferedImage - the buffered image.
      hashKey - the hashtable key.
      Returns:
      the image icon.
    • loadImageIcon

      public ImageIcon loadImageIcon(String imageFileName)
      Load an image icon from file or the jar file.
      Parameters:
      imageFileName - the image file name, relative to class path.
      Returns:
      the loaded ImageIcon, or null.
    • loadImageFromFile

      public Image loadImageFromFile(String fileName, Component component)
      Load an image from a local file.
      Parameters:
      fileName - the name of the file holding the image. It will first treat this as an absolute path. If that fails, it will try to uses it relative to the current working directory. If that fails, relative to the home directory. If that fails, we cave.
      component - a component to use as an observer. Any component should do.
      Returns:
      the loaded image, or null.
    • loadImageFromURL

      public Image loadImageFromURL(URL url, Component c)
      Load an image from a URL
      Parameters:
      url - The url of the image
      c - A component to use as an observer
      Returns:
      the image found at the url
    • get

      public ImageIcon get(String key)
      Try to obtain an ImageIcon from the cache.
      Parameters:
      key - the has key.
      Returns:
      an ImageIcom from the key, or null.
    • put

      public void put(String key, ImageIcon imageIcon)
      Place an ImageIcon into the cache.
      Parameters:
      key - the hask key to use.
      imageIcon - the ImageIcon to cache.
    • clone

      public Object clone() throws CloneNotSupportedException
      Singleton objects cannot be cloned, so we override clone to throw a CloneNotSupportedException.
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException