Documentation of 'org.freehep.util.images.ImageHandler' Java class
ImageHandler
org.freehep.util.images

Class ImageHandler



  • public class ImageHandler
    extends java.lang.Object
    A 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.Cursor brokenCursor 
      static javax.swing.Icon brokenIcon 
      static java.awt.Image brokenImage 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      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).
      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).
      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.
      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.
      static java.awt.Cursor getCursor(java.net.URL url)
      Create a cursor by reading from a URL, with hotspot (0,0).
      static java.awt.Cursor getCursor(java.net.URL url, int x, int y)
      Create a cursor by reading from a URL
      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.
      static javax.swing.Icon getIcon(java.net.URL url)
      Create an Icon by reading from a URL
      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.
      static java.awt.Image getImage(java.net.URL url)
      Load an image from a URL.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 cursor
        clazz - Class to be used for getting resource
        width - suggested width
        height - suggested height
        x - hotspot
        y - 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 read
        x - x position of hotspot
        y - 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 load
        clazz - 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 load
        clazz - 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 load
        clazz - The class from which the address is based
        x - hotspot
        y - 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 load
        clazz - 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

You see the box below because you did not login.