View Javadoc

1   // Copyright 2004, FreeHEP.
2   package hep.wired.heprep.image;
3   
4   import java.awt.Cursor;
5   import java.awt.Image;
6   import javax.swing.Icon;
7   
8   import org.freehep.util.images.ImageHandler;
9   
10  /***
11   * Facility class to load Images, Icons and Cursors.
12   *
13   * @author Mark Donszelmann
14   * @version $Id: WiredImage.java 443 2004-09-01 04:18:18Z duns $
15   */
16  public class WiredImage extends ImageHandler {
17  
18      // only static methods
19      private WiredImage() {
20      }
21  
22      /***
23       * Returns an image for given name, relative to this class.
24       */
25      public static Image getImage(String name) {
26          return getImage(name, WiredImage.class);
27      }
28  
29      /***
30       * Returns the best cursor for given name, relative to this class. The cursor
31       * is created with given width and height.
32       */
33      public static Cursor getBestCursor(String name, int width, int height) {
34          return getBestCursor(name, width, height, 0, 0);
35      }
36  
37      /***
38       * Returns the best cursor for given name, relative to this class. The cursor
39       * is created with given width and height and hotspot x, y.
40       */
41      public static Cursor getBestCursor(String name, int width, int height, int x, int y) {
42          return getBestCursor(name, WiredImage.class, width, height, x, y);
43      }
44  
45      /***
46       * Returns an icon for given name, relative to this class.
47       */
48      public static Icon getIcon(String name) {
49          return getIcon(name, WiredImage.class);
50      }
51  
52      /***
53       * Returns an icon for given name, relative to this class.
54       */
55      public static Icon getIcon(String name, int size) {
56          name = name.replaceAll("%w", Integer.toString(size));
57          return getIcon(name);
58      }
59  }