org.freehep.util.images
Class ImageHandler
- java.lang.Object
-
- org.freehep.util.images.ImageHandler
-
public class ImageHandler extends java.lang.ObjectA convenience class for handling images. Maintains a cache of images suitable for small icons which may be reused often.
-
-
Field Summary
Fields Modifier and Type Field and Description static java.awt.CursorbrokenCursorstatic javax.swing.IconbrokenIconstatic java.awt.ImagebrokenImage
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static java.awt.CursorgetBestCursor(java.lang.String name, java.lang.Class clazz, int width, int height)Create the best cursor by reading from a URL, with hotspot (0,0).static java.awt.CursorgetBestCursor(java.lang.String name, java.lang.Class clazz, int width, int height, int x, int y)Create the best cursor by reading from a URL, with hotspot (x, y).static java.awt.CursorgetCursor(java.lang.String name, java.lang.Class clazz)Convenience routine, equivalent to getCursor(clazz.getResource(name)); As an additional convenience, if the name does not contain an extension (eg .gif) then a list of common extensions will be tried.static java.awt.CursorgetCursor(java.lang.String name, java.lang.Class clazz, int x, int y)Convenience routine, equivalent to getCursor(clazz.getResource(name)); As an additional convenience, if the name does not contain an extension (eg .gif) then a list of common extensions will be tried.static java.awt.CursorgetCursor(java.net.URL url)Create a cursor by reading from a URL, with hotspot (0,0).static java.awt.CursorgetCursor(java.net.URL url, int x, int y)Create a cursor by reading from a URLstatic javax.swing.IcongetIcon(java.lang.String name, java.lang.Class clazz)Convenience routine, equivalent to getIcon(clazz.getResource(name)); As an additional convenience, if the name does not contain an extension (eg .gif) then a list of common extensions will be tried.static javax.swing.IcongetIcon(java.net.URL url)Create an Icon by reading from a URLstatic java.awt.ImagegetImage(java.lang.String name, java.lang.Class clazz)Convenience routine, equivalent to getImage(clazz.getResource(name)); As an additional convenience, if the name does not contain an extension (eg .gif) then a list of common extensions will be tried.static java.awt.ImagegetImage(java.net.URL url)Load an image from a URL.
-
-
-
Field Detail
-
brokenImage
public static final java.awt.Image brokenImage
-
brokenCursor
public static final java.awt.Cursor brokenCursor
-
brokenIcon
public static final javax.swing.Icon brokenIcon
-
-
Method Detail
-
getImage
public static java.awt.Image getImage(java.net.URL url)
Load an image from a URL. Images are cached for efficiency. If the image cannot be found will return a brokenImage. No exceptions are thrown.- Parameters:
url- The url of the image to load.- Returns:
- The image
-
getBestCursor
public static java.awt.Cursor getBestCursor(java.lang.String name, java.lang.Class clazz, int width, int height)Create the best cursor by reading from a URL, with hotspot (0,0).
-
getBestCursor
public static java.awt.Cursor getBestCursor(java.lang.String name, java.lang.Class clazz, int width, int height, int x, int y)Create the best cursor by reading from a URL, with hotspot (x, y). The best width and height are inserted into the URL in the spots with %width and %height. Example: getBestCursor("/org/freehep/swing/images/MyIcon%wx%h.png", 32 32);- Parameters:
name- URL of the cursorclazz- Class to be used for getting resourcewidth- suggested widthheight- suggested heightx- hotspoty- hotspot- Returns:
- The cursor, the default cursor if custom cursors are not supported or brokenCursor if the cursor cannot be found
-
getCursor
public static java.awt.Cursor getCursor(java.net.URL url)
Create a cursor by reading from a URL, with hotspot (0,0).- Parameters:
url- The URL to read- Returns:
- The cursor, or brokenCursor if the cursor cannot be found
-
getCursor
public static java.awt.Cursor getCursor(java.net.URL url, int x, int y)Create a cursor by reading from a URL- Parameters:
url- The URL to readx- x position of hotspoty- y position of hotspot- Returns:
- The cursor, or brokenCursor if the cursor cannot be found
-
getIcon
public static javax.swing.Icon getIcon(java.net.URL url)
Create an Icon by reading from a URL- Parameters:
url- The URL to read- Returns:
- The icon, or brokenIcon if it cannot be loaded
-
getImage
public static java.awt.Image getImage(java.lang.String name, java.lang.Class clazz)Convenience routine, equivalent to getImage(clazz.getResource(name)); As an additional convenience, if the name does not contain an extension (eg .gif) then a list of common extensions will be tried.- Parameters:
name- The relative address of the image to loadclazz- The class from which the address is based- Returns:
- The image, or brokenImage if no image is found.
-
getCursor
public static java.awt.Cursor getCursor(java.lang.String name, java.lang.Class clazz)Convenience routine, equivalent to getCursor(clazz.getResource(name)); As an additional convenience, if the name does not contain an extension (eg .gif) then a list of common extensions will be tried.- Parameters:
name- The relative address of the cursor to loadclazz- The class from which the address is based- Returns:
- The cursor, or brokenCursor if no cursor is found.
-
getCursor
public static java.awt.Cursor getCursor(java.lang.String name, java.lang.Class clazz, int x, int y)Convenience routine, equivalent to getCursor(clazz.getResource(name)); As an additional convenience, if the name does not contain an extension (eg .gif) then a list of common extensions will be tried.- Parameters:
name- The relative address of the cursor to loadclazz- The class from which the address is basedx- hotspoty- hotspot- Returns:
- The cursor, or brokenCursor if no cursor is found.
-
getIcon
public static javax.swing.Icon getIcon(java.lang.String name, java.lang.Class clazz)Convenience routine, equivalent to getIcon(clazz.getResource(name)); As an additional convenience, if the name does not contain an extension (eg .gif) then a list of common extensions will be tried.- Parameters:
name- The relative address of the icon to loadclazz- The class from which the address is based- Returns:
- The icon, or brokenIcon if no icon is found.
-
-
DMelt 3.0 © DataMelt by jWork.ORG