Back to index

moin  1.9.0~rc2
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
CH.ifa.draw.util.Iconkit Class Reference

The Iconkit class supports the sharing of images. More...

Collaboration diagram for CH.ifa.draw.util.Iconkit:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Iconkit (Component component)
 Constructs an Iconkit that uses the given editor to resolve image path names.
void loadRegisteredImages (Component component)
 Loads all registered images.
void registerImage (String fileName)
 Registers an image that is then loaded together with the other registered images by loadRegisteredImages.
Image registerAndLoadImage (Component component, String fileName)
 Registers and loads an image.
Image loadImage (String filename)
 Loads an image with the given name.
Image loadImageResource (String resourcename)
Image getImage (String filename)
 Gets the image with the given name.

Static Public Member Functions

static Iconkit instance ()
 Gets the single instance.

Private Member Functions

Image basicGetImage (String filename)

Private Attributes

Hashtable fMap
Vector fRegisteredImages
Component fComponent

Static Private Attributes

static final int ID = 123
static Iconkit fgIconkit = null
static boolean fgDebug = false

Detailed Description

The Iconkit class supports the sharing of images.

It maintains a map of image names and their corresponding images.

Iconkit also supports to load a collection of images in synchronized way. The resolution of a path name to an image is delegated to the DrawingEditor.


Design Patterns

 o

Singleton
The Iconkit is a singleton.


Definition at line 27 of file Iconkit.java.


Constructor & Destructor Documentation

CH.ifa.draw.util.Iconkit.Iconkit ( Component  component) [inline]

Constructs an Iconkit that uses the given editor to resolve image path names.

Definition at line 39 of file Iconkit.java.

                                        {
        fMap = new Hashtable(53);
        fRegisteredImages = new Vector(10);
        fComponent = component;
        fgIconkit = this;
    }

Member Function Documentation

Image CH.ifa.draw.util.Iconkit.basicGetImage ( String  filename) [inline, private]

Definition at line 137 of file Iconkit.java.

                                                 {
        if (fMap.containsKey(filename))
            return (Image) fMap.get(filename);
        return null;
    }

Here is the caller graph for this function:

Image CH.ifa.draw.util.Iconkit.getImage ( String  filename) [inline]

Gets the image with the given name.

If the image can't be found it tries it again after loading all the registered images.

Definition at line 127 of file Iconkit.java.

                                           {
        Image image = basicGetImage(filename);
        if (image != null)
            return image;
        // load registered images and try again
        loadRegisteredImages(fComponent);
        // try again
        return basicGetImage(filename);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static Iconkit CH.ifa.draw.util.Iconkit.instance ( ) [inline, static]

Gets the single instance.

Definition at line 49 of file Iconkit.java.

                                     {
        return fgIconkit;
    }
Image CH.ifa.draw.util.Iconkit.loadImage ( String  filename) [inline]

Loads an image with the given name.

Definition at line 100 of file Iconkit.java.

                                            {
        if (fMap.containsKey(filename))
            return (Image) fMap.get(filename);
        Image image = loadImageResource(filename);
        if (image != null)
            fMap.put(filename, image);
        return image;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Image CH.ifa.draw.util.Iconkit.loadImageResource ( String  resourcename) [inline]

Definition at line 109 of file Iconkit.java.

                                                        {
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        try {
            if (fgDebug)
                System.out.println(resourcename);
           byte[] image =
              CH.ifa.draw.images.StaticImages.getImage(resourcename);
           return toolkit.createImage(image);
        } catch (Exception ex) {
            return null;
        }
    }

Here is the caller graph for this function:

void CH.ifa.draw.util.Iconkit.loadRegisteredImages ( Component  component) [inline]

Loads all registered images.

See also:
registerImage

Definition at line 57 of file Iconkit.java.

                                                          {
        if (fRegisteredImages.size() == 0)
            return;

        MediaTracker tracker = new MediaTracker(component);

        // register images with MediaTracker
        Enumeration k = fRegisteredImages.elements();
        while (k.hasMoreElements()) {
            String fileName = (String) k.nextElement();
            if (basicGetImage(fileName) == null) {
                tracker.addImage(loadImage(fileName), ID);
            }
        }
        fRegisteredImages.removeAllElements();

        // block until all images are loaded
        try {
            tracker.waitForAll();
        } catch (Exception e) {  }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Image CH.ifa.draw.util.Iconkit.registerAndLoadImage ( Component  component,
String  fileName 
) [inline]

Registers and loads an image.

Definition at line 91 of file Iconkit.java.

                                                                            {
        registerImage(fileName);
        loadRegisteredImages(component);
        return getImage(fileName);
    }

Here is the call graph for this function:

void CH.ifa.draw.util.Iconkit.registerImage ( String  fileName) [inline]

Registers an image that is then loaded together with the other registered images by loadRegisteredImages.

See also:
loadRegisteredImages

Definition at line 84 of file Iconkit.java.

                                               {
        fRegisteredImages.addElement(fileName);
    }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 30 of file Iconkit.java.

boolean CH.ifa.draw.util.Iconkit.fgDebug = false [static, private]

Definition at line 33 of file Iconkit.java.

Iconkit CH.ifa.draw.util.Iconkit.fgIconkit = null [static, private]

Definition at line 32 of file Iconkit.java.

Hashtable CH.ifa.draw.util.Iconkit.fMap [private]

Definition at line 28 of file Iconkit.java.

Definition at line 29 of file Iconkit.java.

final int CH.ifa.draw.util.Iconkit.ID = 123 [static, private]

Definition at line 31 of file Iconkit.java.


The documentation for this class was generated from the following file: