// Path: src/main/java/com/swingsane/gui/panel/ITransformSettingsPanel.java
// public interface ITransformSettingsPanel {
// 
//   IImageTransform getTransform();
// 
//   void restoreSettings();
// 
//   void setTransform(IImageTransform transform);
// 
// }
// 
// Path: src/main/java/com/swingsane/gui/panel/RotateTransformSettingsPanel.java
// @SuppressWarnings("serial")
// public class RotateTransformSettingsPanel extends JPanel implements ITransformSettingsPanel {
// 
//   private JComboBox<Rotation> rotationComboBox;
// 
//   private RotateTransform transform;
// 
//   public RotateTransformSettingsPanel() {
//     initComponents();
//   }
// 
//   @Override
//   public final IImageTransform getTransform() {
//     return transform;
//   }
// 
//   private void initComponents() {
//     GridBagLayout gridBagLayout = new GridBagLayout();
//     gridBagLayout.columnWidths = new int[] { 32, 0 };
//     gridBagLayout.rowHeights = new int[] { 24, 0 };
//     gridBagLayout.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
//     gridBagLayout.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
//     setLayout(gridBagLayout);
// 
//     JPanel containerPanel = new JPanel();
//     containerPanel.setBorder(new CompoundBorder(new TitledBorder(Localizer
//         .localize("RotationSettingsBorderTitle")), new EmptyBorder(5, 5, 5, 5)));
//     GridBagConstraints gbc_containerPanel = new GridBagConstraints();
//     gbc_containerPanel.fill = GridBagConstraints.HORIZONTAL;
//     gbc_containerPanel.anchor = GridBagConstraints.NORTH;
//     gbc_containerPanel.gridx = 0;
//     gbc_containerPanel.gridy = 0;
//     add(containerPanel, gbc_containerPanel);
//     GridBagLayout gbl_containerPanel = new GridBagLayout();
//     gbl_containerPanel.columnWidths = new int[] { 0, 0 };
//     gbl_containerPanel.rowHeights = new int[] { 24, 0 };
//     gbl_containerPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
//     gbl_containerPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
//     containerPanel.setLayout(gbl_containerPanel);
// 
//     rotationComboBox = new JComboBox<Rotation>();
//     rotationComboBox.addActionListener(new ActionListener() {
//       @Override
//       public void actionPerformed(ActionEvent e) {
//         rotationSelectionActionPerformed(e);
//       }
//     });
//     rotationComboBox.setFont(UIManager.getFont("ComboBox.font"));
//     rotationComboBox.setModel(new DefaultComboBoxModel<Rotation>(new Rotation[] { Rotation.CW_90,
//         Rotation.CW_180, Rotation.CW_270 }));
//     GridBagConstraints gbc_rotationComboBox = new GridBagConstraints();
//     gbc_rotationComboBox.anchor = GridBagConstraints.NORTH;
//     gbc_rotationComboBox.gridx = 0;
//     gbc_rotationComboBox.gridy = 0;
//     containerPanel.add(rotationComboBox, gbc_rotationComboBox);
//   }
// 
//   @Override
//   public final void restoreSettings() {
//     rotationComboBox.setSelectedItem(transform.getRotation());
//   }
// 
//   private void rotationSelectionActionPerformed(ActionEvent e) {
//     transform.setRotation((Rotation) rotationComboBox.getSelectedItem());
//   }
// 
//   @Override
//   public final void setTransform(IImageTransform transform) {
//     this.transform = (RotateTransform) transform;
//     restoreSettings();
//   }
// 
// }
// 
// Path: src/main/java/com/swingsane/preferences/IPreferredDefaults.java
// public interface IPreferredDefaults {
// 
//   public enum ColorMode {
//     BLACK_AND_WHITE, COLOR, GRAYSCALE
//   }
// 
//   public enum Source {
//     AUTOMATIC_DOCUMENT_FEEDER, FLATBED
//   }
// 
//   int DEFAULT_RESOLUTION = 300;
// 
//   Rotation DEFAULT_ROTATION = Rotation.CW_90;
// 
//   int DEFAULT_LUMINANCE_THRESHOLD = 165;
// 
//   double DEFAULT_DESKEW_THRESHOLD = 2.0d;
// 
//   ColorMode getColor();
// 
//   double getDefaultDeskewThreshold();
// 
//   int getDefaultLuminanceThreshold();
// 
//   Rotation getDefaultRotation();
// 
//   int getResolution();
// 
//   void setColor(ColorMode color);
// 
//   void setResolution(int resolution);
// 
//   void update(Scanner scanner);
// 
// }


import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.imgscalr.Scalr;
import org.imgscalr.Scalr.Rotation;
import com.swingsane.gui.panel.ITransformSettingsPanel;
import com.swingsane.gui.panel.RotateTransformSettingsPanel;
import com.swingsane.preferences.IPreferredDefaults;
package com.swingsane.business.image.transform;





/**
 * @author Roland Quast (roland@formreturn.com)
 *
 */
public class RotateTransform implements IImageTransform {

  private Rotation rotation;
// Path: src/main/java/com/swingsane/gui/panel/ITransformSettingsPanel.java
// public interface ITransformSettingsPanel {
// 
//   IImageTransform getTransform();
// 
//   void restoreSettings();
// 
//   void setTransform(IImageTransform transform);
// 
// }
// 
// Path: src/main/java/com/swingsane/gui/panel/RotateTransformSettingsPanel.java
// @SuppressWarnings("serial")
// public class RotateTransformSettingsPanel extends JPanel implements ITransformSettingsPanel {
// 
//   private JComboBox<Rotation> rotationComboBox;
// 
//   private RotateTransform transform;
// 
//   public RotateTransformSettingsPanel() {
//     initComponents();
//   }
// 
//   @Override
//   public final IImageTransform getTransform() {
//     return transform;
//   }
// 
//   private void initComponents() {
//     GridBagLayout gridBagLayout = new GridBagLayout();
//     gridBagLayout.columnWidths = new int[] { 32, 0 };
//     gridBagLayout.rowHeights = new int[] { 24, 0 };
//     gridBagLayout.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
//     gridBagLayout.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
//     setLayout(gridBagLayout);
// 
//     JPanel containerPanel = new JPanel();
//     containerPanel.setBorder(new CompoundBorder(new TitledBorder(Localizer
//         .localize("RotationSettingsBorderTitle")), new EmptyBorder(5, 5, 5, 5)));
//     GridBagConstraints gbc_containerPanel = new GridBagConstraints();
//     gbc_containerPanel.fill = GridBagConstraints.HORIZONTAL;
//     gbc_containerPanel.anchor = GridBagConstraints.NORTH;
//     gbc_containerPanel.gridx = 0;
//     gbc_containerPanel.gridy = 0;
//     add(containerPanel, gbc_containerPanel);
//     GridBagLayout gbl_containerPanel = new GridBagLayout();
//     gbl_containerPanel.columnWidths = new int[] { 0, 0 };
//     gbl_containerPanel.rowHeights = new int[] { 24, 0 };
//     gbl_containerPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
//     gbl_containerPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
//     containerPanel.setLayout(gbl_containerPanel);
// 
//     rotationComboBox = new JComboBox<Rotation>();
//     rotationComboBox.addActionListener(new ActionListener() {
//       @Override
//       public void actionPerformed(ActionEvent e) {
//         rotationSelectionActionPerformed(e);
//       }
//     });
//     rotationComboBox.setFont(UIManager.getFont("ComboBox.font"));
//     rotationComboBox.setModel(new DefaultComboBoxModel<Rotation>(new Rotation[] { Rotation.CW_90,
//         Rotation.CW_180, Rotation.CW_270 }));
//     GridBagConstraints gbc_rotationComboBox = new GridBagConstraints();
//     gbc_rotationComboBox.anchor = GridBagConstraints.NORTH;
//     gbc_rotationComboBox.gridx = 0;
//     gbc_rotationComboBox.gridy = 0;
//     containerPanel.add(rotationComboBox, gbc_rotationComboBox);
//   }
// 
//   @Override
//   public final void restoreSettings() {
//     rotationComboBox.setSelectedItem(transform.getRotation());
//   }
// 
//   private void rotationSelectionActionPerformed(ActionEvent e) {
//     transform.setRotation((Rotation) rotationComboBox.getSelectedItem());
//   }
// 
//   @Override
//   public final void setTransform(IImageTransform transform) {
//     this.transform = (RotateTransform) transform;
//     restoreSettings();
//   }
// 
// }
// 
// Path: src/main/java/com/swingsane/preferences/IPreferredDefaults.java
// public interface IPreferredDefaults {
// 
//   public enum ColorMode {
//     BLACK_AND_WHITE, COLOR, GRAYSCALE
//   }
// 
//   public enum Source {
//     AUTOMATIC_DOCUMENT_FEEDER, FLATBED
//   }
// 
//   int DEFAULT_RESOLUTION = 300;
// 
//   Rotation DEFAULT_ROTATION = Rotation.CW_90;
// 
//   int DEFAULT_LUMINANCE_THRESHOLD = 165;
// 
//   double DEFAULT_DESKEW_THRESHOLD = 2.0d;
// 
//   ColorMode getColor();
// 
//   double getDefaultDeskewThreshold();
// 
//   int getDefaultLuminanceThreshold();
// 
//   Rotation getDefaultRotation();
// 
//   int getResolution();
// 
//   void setColor(ColorMode color);
// 
//   void setResolution(int resolution);
// 
//   void update(Scanner scanner);
// 
// }


// Path: src/main/java/com/swingsane/business/image/transform/RotateTransform.java
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.imgscalr.Scalr;
import org.imgscalr.Scalr.Rotation;
import com.swingsane.gui.panel.ITransformSettingsPanel;
import com.swingsane.gui.panel.RotateTransformSettingsPanel;
import com.swingsane.preferences.IPreferredDefaults;

package com.swingsane.business.image.transform;





/**
 * @author Roland Quast (roland@formreturn.com)
 *
 */
public class RotateTransform implements IImageTransform {

  private Rotation rotation;
  private File sourceImageFile;