/* @(#) ImageBrowser.java 1.1 99/11/18
 * Copyright (c) 1999 Lawrence Rodrigues
 */
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import com.vistech.util.*;
import com.vistech.events.*;
import com.vistech.imageloader.*;

/** An application class that displays multiple images in a grid fashion.
 * @version 1.0  18 Nov 1999
 * @author Lawrence Rodrigues
 **/
public class ImageBrowser extends com.vistech.util.ApplicationFrame{
   protected MultiImageLoader il;
   protected String saveFileName = null;
   protected ViewerPanel viewer;
   public ImageBrowser() {
      createUI();
      saveFileName = "ImageLoaderGUI.jpg";
   }

   protected void setAboutStrings() {
      setAboutString(" Java Image Browser \n Version 1.0 \n"+
                        "Author: Lawrence Rodrigues\n");
      setAboutTitle(" Image Browser");
   }

   private void createUI() {
      setAboutStrings();
      il = new MultiImageLoader();
      il.setLoadButtonLabel("Launch Image Browser");
      il.addImageLoadedListener(
          new ImageLoadedListener() {
             public void imageLoaded(ImageLoadedEvent e) {
                Image[] imset = e.getImages();
                displayImage(imset);
                il.setLoadButtonLabel("Load Images");
             }
          });
      this.getContentPane().add(il);
      this.setSize(il.getPreferredSize().width+30, il.getPreferredSize().height+50);
   }

   public void displayImage(Image[] imset) {
      if(viewer == null) {
         viewer = new ViewerPanel();
         viewer.setTitle("Image Browser");
         viewer.addWindowListener(
           new WindowAdapter() {
           public void windowClosing(WindowEvent e){
             System.exit(0);
          }
         });
      }
      viewer.setImageSet(imset);
      viewer.show();
      viewer.repaint();
   }

   public static void  main(String[] args){
      ImageBrowser ib = new ImageBrowser();
      ib.setTitle("Java Image Browser");
      ib.show();
   }
}