Back to index

wims  3.65+svn20090927
Public Member Functions | Private Attributes
fr.ove.errordialog.PanelImage Class Reference

A simple panel that contains an image to display. More...

Inheritance diagram for fr.ove.errordialog.PanelImage:
Inheritance graph
[legend]
Collaboration diagram for fr.ove.errordialog.PanelImage:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PanelImage (String imageName) throws Exception
 The constructor.
Dimension getPreferredSize ()
 Returns the preferred size of the instance.
void paint (Graphics g)
 Paints the instance.

Private Attributes

Image image

Detailed Description

A simple panel that contains an image to display.


The image to display must be in the same package of the instance. (possibly the subpackages with the correct path specified in the constructo)

Author:
© 1998 DIRAT Laurent
Version:
1.0 13/04/99

Definition at line 53 of file PanelImage.java.


Constructor & Destructor Documentation

fr.ove.errordialog.PanelImage.PanelImage ( String  imageName) throws Exception [inline]

The constructor.

Parameters:
imageNamethe name of the image the instance displays.

Definition at line 60 of file PanelImage.java.

                                                         {
              java.io.InputStream iStream = getClass().getResourceAsStream(imageName);
              
        try {
            /*
            int avaliable = iStream.available();
            byte imageBytes[] = new byte[avaliable];
            int bytesRead = iStream.read(imageBytes);
            bytesRead = iStream.read(imageBytes);
            image = (Toolkit.getDefaultToolkit()).createImage(imageBytes);
            iStream.close();
            */
            
            int read;
            ByteVector byteImage = new ByteVector();
                  while ((read = iStream.read()) != -1) {
                      byteImage.addElement((byte) read);
                      if (iStream.available() == 0)
                          break;
                  }
            
            image = (Toolkit.getDefaultToolkit()).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) {
              MediaTracker tracker = new MediaTracker(this);
            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");
        }
    }

Here is the call graph for this function:


Member Function Documentation

Returns the preferred size of the instance.

Definition at line 113 of file PanelImage.java.

                                        {
        return new Dimension(image.getWidth(this), image.getHeight(this));
    }
void fr.ove.errordialog.PanelImage.paint ( Graphics  g) [inline]

Paints the instance.

Parameters:
gthe graphics where to paint.

Definition at line 121 of file PanelImage.java.

                                  {
        g.drawImage(image, 0, 0, this);
    }

Member Data Documentation

Definition at line 54 of file PanelImage.java.


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