DESY ACOP Beans Home

com.cosylab.gui.components.util
Class IconHelper

java.lang.Object
  extended by com.cosylab.gui.components.util.IconHelper

public final class IconHelper
extends java.lang.Object

IconHelper acts as an interface to the all icons currently in classpath. IconHelper is a singleton class that maintains internal cache to all accessed icons. This class may be used to minimize the memory consumption where application uses static icons. If icons are changed independently, this class should not be used.

Version:
$id$
Author:
Ales Pucelj

Field Summary
static java.lang.String ICONS_GENERAL_DELETE16
           
static java.lang.String ICONS_GENERAL_DELETE24
           
static java.lang.String ICONS_GENERAL_REMOVE16
           
static java.lang.String ICONS_GENERAL_REMOVE24
           
static java.lang.String ICONS_NAVIGATION_DOWN16
           
static java.lang.String ICONS_NAVIGATION_DOWN24
           
static java.lang.String ICONS_NAVIGATION_MINUS16
           
static java.lang.String ICONS_NAVIGATION_PLUS16
           
static java.lang.String ICONS_NAVIGATION_UP16
           
static java.lang.String ICONS_NAVIGATION_UP24
           
 
Method Summary
static javax.swing.Icon createIcon(java.io.File file)
          Creates an Icon by reading the image stored in the given file.
static javax.swing.Icon createIcon(java.lang.String name)
          Returns instance of the icon.
static javax.swing.Icon createIcon(java.lang.String name, java.lang.ClassLoader cl)
          Returns instance of the icon by loading it using the ClassLoader instance provided.
static java.awt.Image createImage(java.lang.String name)
          Creates a new image loaded from the provided image file name.
static java.awt.Image createImage(java.lang.String name, java.lang.ClassLoader cl)
          Creates a new image loaded from the provided image file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ICONS_NAVIGATION_DOWN16

public static java.lang.String ICONS_NAVIGATION_DOWN16

ICONS_NAVIGATION_DOWN24

public static java.lang.String ICONS_NAVIGATION_DOWN24

ICONS_NAVIGATION_MINUS16

public static java.lang.String ICONS_NAVIGATION_MINUS16

ICONS_NAVIGATION_PLUS16

public static java.lang.String ICONS_NAVIGATION_PLUS16

ICONS_NAVIGATION_UP16

public static java.lang.String ICONS_NAVIGATION_UP16

ICONS_NAVIGATION_UP24

public static java.lang.String ICONS_NAVIGATION_UP24

ICONS_GENERAL_DELETE16

public static java.lang.String ICONS_GENERAL_DELETE16

ICONS_GENERAL_DELETE24

public static java.lang.String ICONS_GENERAL_DELETE24

ICONS_GENERAL_REMOVE16

public static java.lang.String ICONS_GENERAL_REMOVE16

ICONS_GENERAL_REMOVE24

public static java.lang.String ICONS_GENERAL_REMOVE24
Method Detail

createIcon

public static javax.swing.Icon createIcon(java.lang.String name,
                                          java.lang.ClassLoader cl)
Returns instance of the icon by loading it using the ClassLoader instance provided. Icons are cached. If an icon with the same name is requested several times, createIcon will return the same instance each time. If icons will be manipulated individually, do not use this method to load icons. If icon is not found in the classpath, return value will be null.

Parameters:
name - String
cl - ClassLoader Instance of class loader to use
Returns:
Icon Instance of Icon or null if icon could not be found.

createIcon

public static javax.swing.Icon createIcon(java.lang.String name)
Returns instance of the icon. Icons are cached. If an icon with the same name is requested several times, createIcon will return the same instance each time. If icons will be manipulated individually, do not use this method to load icons. If icon is not found in the classpath, or the file with that name does not exist on the disk return value will be null.

Parameters:
name - String
Returns:
Icon Instance of Icon or null if icon could not be found.

createImage

public static java.awt.Image createImage(java.lang.String name)
Creates a new image loaded from the provided image file name. This class' class loader is used to access resources.

Parameters:
name - the filename of the image
Returns:
Image

createImage

public static java.awt.Image createImage(java.lang.String name,
                                         java.lang.ClassLoader cl)
Creates a new image loaded from the provided image file. The image is loaded using the given class loader.

Parameters:
name - the filename of the image
cl - classloader to be used for accessing resources
Returns:
Image

createIcon

public static javax.swing.Icon createIcon(java.io.File file)
Creates an Icon by reading the image stored in the given file. This file can be anywhere on the computer as long as it is accessible by the current user rights (the icon file does not need to be added to classpath).

Parameters:
file - the image file
Returns:
icon


Copyright © 2010. All Rights Reserved.