JAL-3048 all image export (alignment, tree, PCA, Jmol) now via ImageExporter and...
[jalview.git] / src / jalview / gui / PCAPanel.java
index d2f789f..aea94f4 100644 (file)
@@ -27,11 +27,12 @@ import jalview.api.analysis.SimilarityParamsI;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentView;
-import jalview.datamodel.Annotation;
 import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.SequenceI;
+import jalview.gui.ImageExporter.ImageWriterI;
 import jalview.gui.JalviewColourChooser.ColourChooserListener;
 import jalview.jbgui.GPCAPanel;
+import jalview.util.ImageMaker;
 import jalview.util.MessageManager;
 import jalview.viewmodel.AlignmentViewport;
 import jalview.viewmodel.PCAModel;
@@ -49,8 +50,6 @@ import java.awt.print.PrinterJob;
 
 import javax.swing.ButtonGroup;
 import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JColorChooser;
-import javax.swing.JDialog;
 import javax.swing.JMenuItem;
 import javax.swing.JRadioButtonMenuItem;
 import javax.swing.event.InternalFrameAdapter;
@@ -519,67 +518,26 @@ public class PCAPanel extends GPCAPanel
     }
   }
 
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
-   */
-  @Override
-  public void eps_actionPerformed(ActionEvent e)
-  {
-    makePCAImage(jalview.util.ImageMaker.TYPE.EPS);
-  }
-
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
-   */
-  @Override
-  public void png_actionPerformed(ActionEvent e)
-  {
-    makePCAImage(jalview.util.ImageMaker.TYPE.PNG);
-  }
-
-  void makePCAImage(jalview.util.ImageMaker.TYPE type)
+  public void makePCAImage(ImageMaker.TYPE type)
   {
     int width = rc.getWidth();
     int height = rc.getHeight();
-
-    jalview.util.ImageMaker im;
-
-    if (type == jalview.util.ImageMaker.TYPE.PNG)
-    {
-      im = new jalview.util.ImageMaker(this,
-              jalview.util.ImageMaker.TYPE.PNG, "Make PNG image from PCA",
-              width, height, null, null, null, 0, false);
-    }
-    else if (type == jalview.util.ImageMaker.TYPE.EPS)
-    {
-      im = new jalview.util.ImageMaker(this,
-              jalview.util.ImageMaker.TYPE.EPS, "Make EPS file from PCA",
-              width, height, null, this.getTitle(), null, 0, false);
-    }
-    else
-    {
-      im = new jalview.util.ImageMaker(this,
-              jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA",
-              width, height, null, this.getTitle(), null, 0, false);
-
-    }
-
-    if (im.getGraphics() != null)
+    ImageWriterI writer = new ImageWriterI()
     {
-      rc.drawBackground(im.getGraphics(), Color.black);
-      rc.drawScene(im.getGraphics());
-      if (rc.drawAxes == true)
+      @Override
+      public void exportImage(Graphics g) throws Exception
       {
-        rc.drawAxes(im.getGraphics());
+        rc.drawBackground(g, Color.black);
+        rc.drawScene(g);
+        if (rc.drawAxes)
+        {
+          rc.drawAxes(g);
+        }
       }
-      im.writeImage();
-    }
+    };
+    String pca = MessageManager.getString("label.pca");
+    ImageExporter exporter = new ImageExporter(writer, null, type, pca);
+    exporter.doExport(null, this, width, height, pca);
   }
 
   @Override