/**  FlipModePanel Class
   * @version 1.0  18 apr 2000
   * @author Lawrence Rodrigues
   **/
package com.vistech.imageviewer;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.geom.*;
import com.vistech.util.*;

/** Creates a panel with Radio buttons for selecting display modes.
  * @version 1.0  21 Jan 2000
  * @author Lawrence Rodrigues
  **/
public class DisplayModePanel extends JPanel implements TabPanel {
   ImageManipulator viewer;
   public DisplayModePanel( ImageManipulator viewer){
      this.viewer = viewer;
      createUI();
   }
   public void openPanel() { }
   public void closePanel(){ }

   protected void createUI() {
      ButtonGroup bg = new ButtonGroup();
      JRadioButton normal = new JRadioButton("Scaled");
      JRadioButton tofit = new JRadioButton("To Fit");
      JRadioButton orig = new JRadioButton("Original");
      DisplayModeAdapter danormal = new DisplayModeAdapter(DisplayMode.SCALED);
      DisplayModeAdapter datofit = new DisplayModeAdapter(DisplayMode.TO_FIT);
      DisplayModeAdapter daorig = new DisplayModeAdapter(DisplayMode.ORIG_SIZE);
      normal.setSelected(true);

      normal.addActionListener(danormal);
      tofit.addActionListener(datofit);
      orig.addActionListener(daorig);

      bg.add(normal);
      bg.add(tofit);
      bg.add(orig);
      add(normal);
      add(tofit);
      add(orig);
    }
     class DisplayModeAdapter implements ActionListener {
      int mode;
      public DisplayModeAdapter( int type) { mode = type;}
      public void actionPerformed(ActionEvent e) {
         viewer.setDisplayMode(mode);
      }
   }
}
