package app;
import java.io.*;
import java.beans.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.lang.reflect.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.util.*;
import com.vistech.events.*;
import com.vistech.util.*;
import com.vistech.imageloader.*;
import com.vistech.imageviewer.*;
import com.sun.image.codec.jpeg.*;

public class CineViewer extends ApplicationFrame{
   protected MultiImageLoader il;
   private JTabbedPane jtp;
   protected ImageCanvas imageViewer;
   protected CineController cine;
   protected MovieUI cineUI;

   public SlideShow() { createUI();}

   private void createUI() {
      il = new MultiImageLoader();
      cine = new Movie();
      il.setLoadButtonLabel("Transfer Images");
      imageViewer = new ImageCanvas();
      cine.setImageDisplay(imageViewer);
      cineUI = new MovieUI(cine);

      il.addListSelectListener(cineUI);
      il.addImageLoadedListener(
            new ImageLoadedListener() {
               public void imageLoaded(ImageLoadedEvent e) {
                  Image[] imset = e.getImages();
                  imageViewer.setAWTImage(imset[0]);
                  cine.setCineImageSet(imset);
                  //il.setLoadButtonLabel("Transfer Images");
               }
            }
      );


      JPanel companel = new JPanel();
      JSplitPane hsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, il,cineUI);
      Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
      int width = (int)(dim.width *9/10.0);
      int height = (int)(dim.height*3/4);
      JSplitPane vsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, hsp,imageViewer);
      getContentPane().setLayout(new GridLayout(1,1));
      getContentPane().add(vsp);
      pack();
      setSize(new Dimension(dim.width, height));
      show();
      hsp.setDividerLocation(0.6);
      vsp.setDividerLocation(0.4);
      imageViewer.repaint();
   }

   public static void  main(String[] args){
      SlideShow iv = new SlideShow();
      iv.setTitle("Cine' Viewer");
      iv.show();
   }
}
