/**  FlipModePanel Class
   * @version 1.0  21 jan 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 flip modes.
    * @version 1.0  21 Jan 2000
    * @author Lawrence Rodrigues
    **/
public class FlipModePanel extends JPanel implements TabPanel {
   GeomManipController viewer;
   public FlipModePanel(GeomManipController viewer){
      this.viewer = viewer;
      createUI();
   }
   public void openPanel() { }
   public void closePanel(){ }

   protected void createUI() {
      ButtonGroup bg = new ButtonGroup();
      JRadioButton normal = new JRadioButton("Normal");
      JRadioButton lr = new JRadioButton("Left to Right");
      JRadioButton tb = new JRadioButton("Top to Bottom");
      JRadioButton tblr = new JRadioButton("T B and L R");
      FlipModeAdapter flnormal = new FlipModeAdapter(FlipMode.NORMAL);
      FlipModeAdapter fllr = new FlipModeAdapter(FlipMode.LEFT_RIGHT);
      FlipModeAdapter fltp = new FlipModeAdapter(FlipMode.TOP_BOTTOM);
      FlipModeAdapter fltblr = new FlipModeAdapter(FlipMode.TOP_BOTTOM_LEFT_RIGHT);
      normal.setSelected(true);

      normal.addActionListener(flnormal);
      lr.addActionListener(fllr);
      tb.addActionListener(fltp);
      tblr.addActionListener(fltblr);

      bg.add(normal);
      bg.add(lr);
      bg.add(tb);
      bg.add(tblr);

      add(lr);
      add(tb);
      add(tblr);
   }
   class FlipModeAdapter implements ActionListener {
      int mode;
      public FlipModeAdapter( int type) {mode = type;}
      public void actionPerformed(ActionEvent e) {
         viewer.flip(mode);
      }
   }
}