Package cnuphys.splot.plot
Class ImageManager
java.lang.Object
cnuphys.splot.plot.ImageManager
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionclone()
Singleton objects cannot be cloned, so we override clone to throw a CloneNotSupportedException.Try to obtain an ImageIcon from the cache.static ImageManager
Access to the image manager singletonLoad an image from file or the jar file.loadImageFromFile
(String fileName, Component component) Load an image from a local file.loadImageFromURL
(URL url, Component c) Load an image from a URLloadImageIcon
(BufferedImage bufferedImage, String hashKey) Load an image icon from a buffered image.loadImageIcon
(String imageFileName) Load an image icon from file or the jar file.void
Place an ImageIcon into the cache.
-
Field Details
-
cnuIcon
-
-
Method Details
-
getInstance
Access to the image manager singleton- Returns:
- the image manager singleton.
-
loadImage
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
Load an image icon from a buffered image.- Parameters:
bufferedImage
- the buffered image.hashKey
- the hashtable key.- Returns:
- the image icon.
-
loadImageIcon
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
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
Load an image from a URL- Parameters:
url
- The url of the imagec
- A component to use as an observer- Returns:
- the image found at the url
-
get
Try to obtain an ImageIcon from the cache.- Parameters:
key
- the has key.- Returns:
- an ImageIcom from the key, or null.
-
put
Place an ImageIcon into the cache.- Parameters:
key
- the hask key to use.imageIcon
- the ImageIcon to cache.
-
clone
Singleton objects cannot be cloned, so we override clone to throw a CloneNotSupportedException.- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-