Back to index

wims  3.65+svn20090927
Public Member Functions | Static Public Member Functions | Static Private Member Functions | Static Private Attributes
fr.ove.openmath.jome.ctrlview.bidim.images.ImageLoader Class Reference

This class is a little tool to load images. More...

Inheritance diagram for fr.ove.openmath.jome.ctrlview.bidim.images.ImageLoader:
Inheritance graph
[legend]
Collaboration diagram for fr.ove.openmath.jome.ctrlview.bidim.images.ImageLoader:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ImageLoader (Component component)
 The Constructor.

Static Public Member Functions

static Image getImage (String name)
 Returns the image with the specified name.
static float getHeightFactor (String idImage)
 Returns the height factor to apply to the orignal size of the wanted image.
static float getBaseline (String idImage)
 Returns the baseline of the wanted image.
static float getTopInset (String idImage)
static float getBottomInset (String idImage)
static float getLeftInset (String idImage)
static float getRightInset (String idImage)
static boolean exists (String idImage)
 Checks if there exist an image with the specified identifier.

Static Private Member Functions

static Image loadImage (String name, String key) throws Exception
 Loads the image with the specified name and put it in the hashtable with the specified key.
static Image setImage (String name)

Static Private Attributes

static Hashtable allImages
 The hashtable which contains all the images loaded.
static MediaTracker tracker
static Toolkit toolkit
static Class theClass
static ImagesResourcesManager imagesResourcesManager = new ImagesResourcesManager("fr.ove.openmath.jome.ctrlview.bidim.images.ImagesResources")
 The image resources manager.

Detailed Description

This class is a little tool to load images.

Author:
© 1998 DIRAT Laurent
Version:
1.0 17/02/99

Definition at line 44 of file ImageLoader.java.


Constructor & Destructor Documentation

The Constructor.


This constructor is used in the case of an application, and not an applet such as the precedent does.

Parameters:
componentthe component which needs the images to load.

Definition at line 67 of file ImageLoader.java.

                                            {
              theClass = getClass();

        // On utilise un mediatracker pour pouvoir attendre que toutes les
        // images soient chargées avant de rendre la main.
              tracker = new MediaTracker(component);
        allImages = new Hashtable(10);  // On crée la table de Hashcode
        
        // On récupère la toolkit par défaut pour créer les images.
        toolkit = Toolkit.getDefaultToolkit();
        
        // On charge les parenthèses pour que ce soit un peu plus rapide (c'est a priori
        // les images les plus suceptibles d'être chargées)
        getImage("LeftTopPar");
        getImage("LeftMiddlePar");
        getImage("LeftBottomPar");
        getImage("RightTopPar");
        getImage("RightMiddlePar");
        getImage("RightBottomPar");
    }

Here is the call graph for this function:


Member Function Documentation

static boolean fr.ove.openmath.jome.ctrlview.bidim.images.ImageLoader.exists ( String  idImage) [inline, static]

Checks if there exist an image with the specified identifier.

Parameters:
idImagethe identifier of the wanted image

Definition at line 236 of file ImageLoader.java.

                                                 {
        return (imagesResourcesManager.getImageName(idImage) == null);
    }

Here is the call graph for this function:

static float fr.ove.openmath.jome.ctrlview.bidim.images.ImageLoader.getBaseline ( String  idImage) [inline, static]

Returns the baseline of the wanted image.

If the returned value equals -1n the baseline corresponds the one of the current font.

Parameters:
idImagethe identifier of the wanted image

Definition at line 130 of file ImageLoader.java.

                                                    {
        float baseline = -1.0f; // Si -1, alors la baseline est celle de la police courante.
        
        try {
            String base = imagesResourcesManager.getBaseline(idImage);
            if (base != null)
                baseline = Float.valueOf(base).floatValue();
        }
        catch (NumberFormatException fne) {
            System.out.println("baseline has not a valid number.");
        }
        catch (Exception e) {
            System.out.println("baseline has not a valid number."); // erreur d'un autre type
        }
        
        return baseline;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static float fr.ove.openmath.jome.ctrlview.bidim.images.ImageLoader.getBottomInset ( String  idImage) [inline, static]
Parameters:
idImagethe identifier of the wanted image

Definition at line 172 of file ImageLoader.java.

                                                       {
        float inset = 0.0f;
        
        try {
            String srtInset = imagesResourcesManager.getBottomInset(idImage);
            if (srtInset != null)
                inset = Float.valueOf(srtInset).floatValue();
        }
        catch (NumberFormatException fne) {
            System.out.println("bottom inset has not a valid number.");
        }
        catch (Exception e) {
            System.out.println("bottom inset has not a valid number."); // erreur d'un autre type
        }
        
        return inset;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static float fr.ove.openmath.jome.ctrlview.bidim.images.ImageLoader.getHeightFactor ( String  idImage) [inline, static]

Returns the height factor to apply to the orignal size of the wanted image.

Parameters:
idImagethe identifier of the wanted image

Definition at line 107 of file ImageLoader.java.

                                                        {
        float heightFactor = 1.0f;
        
        try {
            String height = imagesResourcesManager.getHeightFactor(idImage);
            if (height != null)
                heightFactor = Float.valueOf(height).floatValue();
        }
        catch (NumberFormatException fne) {
            System.out.println("height factor is not a valid number.");
        }
        catch (Exception e) {
            System.out.println("height factor is not a valid number."); // erreur d'un autre type
        }
        
        return heightFactor;
    }    

Here is the call graph for this function:

Here is the caller graph for this function:

static Image fr.ove.openmath.jome.ctrlview.bidim.images.ImageLoader.getImage ( String  name) [inline, static]

Returns the image with the specified name.

Parameters:
namethe name of the desired image.
Returns:
the desired image.

Definition at line 93 of file ImageLoader.java.

                                              {
        Image image = (Image) allImages.get(name);

        if (image == null)
            image = setImage(name);

        return image;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static float fr.ove.openmath.jome.ctrlview.bidim.images.ImageLoader.getLeftInset ( String  idImage) [inline, static]
Parameters:
idImagethe identifier of the wanted image

Definition at line 193 of file ImageLoader.java.

                                                     {
        float inset = 0.0f;
        
        try {
            String srtInset = imagesResourcesManager.getLeftInset(idImage);
            if (srtInset != null)
                inset = Float.valueOf(srtInset).floatValue();
        }
        catch (NumberFormatException fne) {
            System.out.println("left inset has not a valid number.");
        }
        catch (Exception e) {
            System.out.println("left inset has not a valid number."); // erreur d'un autre type
        }
        
        return inset;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static float fr.ove.openmath.jome.ctrlview.bidim.images.ImageLoader.getRightInset ( String  idImage) [inline, static]
Parameters:
idImagethe identifier of the wanted image

Definition at line 214 of file ImageLoader.java.

                                                      {
        float inset = 0.0f;
        
        try {
            String srtInset = imagesResourcesManager.getRightInset(idImage);
            if (srtInset != null)
                inset = Float.valueOf(srtInset).floatValue();
        }
        catch (NumberFormatException fne) {
            System.out.println("right inset has not a valid number.");
        }
        catch (Exception e) {
            System.out.println("right inset has not a valid number."); // erreur d'un autre type
        }
        
        return inset;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static float fr.ove.openmath.jome.ctrlview.bidim.images.ImageLoader.getTopInset ( String  idImage) [inline, static]
Parameters:
idImagethe identifier of the wanted image

Definition at line 151 of file ImageLoader.java.

                                                    {
        float inset = 0.0f;
        
        try {
            String srtInset = imagesResourcesManager.getTopInset(idImage);
            if (srtInset != null)
                inset = Float.valueOf(srtInset).floatValue();
        }
        catch (NumberFormatException fne) {
            System.out.println("top inset has not a valid number.");
        }
        catch (Exception e) {
            System.out.println("top inset has not a valid number."); // erreur d'un autre type
        }
        
        return inset;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static Image fr.ove.openmath.jome.ctrlview.bidim.images.ImageLoader.loadImage ( String  name,
String  key 
) throws Exception [inline, static, private]

Loads the image with the specified name and put it in the hashtable with the specified key.

Parameters:
namethe name of theimage to load
keythe key of the image in the hastable
Returns:
the desired image

Definition at line 248 of file ImageLoader.java.

                                                                             {
        Image image = null;
              java.io.InputStream iStream = theClass.getResourceAsStream(name);
        try {
            int read;
            ByteVector byteImage = new ByteVector();
                  while ((read = iStream.read()) != -1) {
                      byteImage.addElement((byte) read);
                      if (iStream.available() == 0)
                          break;
                  }
            
            image = toolkit.createImage(byteImage.getBytes());
            iStream.close();
        }
        catch (IOException e){
            System.out.println("Impossible to read image : IO problems");
            e.printStackTrace();
        }
        catch (Exception e){
            System.out.println("Impossible to create image");
            e.printStackTrace();
        }
        
        if (image != null) {
            allImages.put(key, image);
            tracker.addImage(image, 0);
        
            // On attend que toutes les images soient chargées.
              try { 
                  tracker.waitForAll();
              }
              catch (InterruptedException e) {
                  System.out.print(e.toString());
              }
              
              if (tracker.isErrorAny())
                  throw new Exception("Impossible to load image");
        }
        return image;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static Image fr.ove.openmath.jome.ctrlview.bidim.images.ImageLoader.setImage ( String  name) [inline, static, private]

Definition at line 290 of file ImageLoader.java.

                                               {
        Image image = null;
        try {
            String imgName = imagesResourcesManager.getImageName(name);
            
            if (imgName == null)
                image = getImage("undef");
            else
                image = loadImage(imgName, name);
                        
            return image;
        }
        catch (Exception e) {
            e.printStackTrace();
            return image;
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

The hashtable which contains all the images loaded.

Definition at line 48 of file ImageLoader.java.

ImagesResourcesManager fr.ove.openmath.jome.ctrlview.bidim.images.ImageLoader.imagesResourcesManager = new ImagesResourcesManager("fr.ove.openmath.jome.ctrlview.bidim.images.ImagesResources") [static, private]

The image resources manager.

Definition at line 59 of file ImageLoader.java.

Definition at line 54 of file ImageLoader.java.

Definition at line 53 of file ImageLoader.java.

Definition at line 51 of file ImageLoader.java.


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