X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPCAPanel.java;h=aea94f4b03312c2a7bb066029dba17cdb2e090fa;hb=8de672a19aa66c59e84511da1961dd35397c02cb;hp=9f52d26bc76ed8e1b68709fce057b33d97b24d55;hpb=14193747f3831242bc7dfac12394eb20eb0ba480;p=jalview.git diff --git a/src/jalview/gui/PCAPanel.java b/src/jalview/gui/PCAPanel.java index 9f52d26..aea94f4 100644 --- a/src/jalview/gui/PCAPanel.java +++ b/src/jalview/gui/PCAPanel.java @@ -29,7 +29,10 @@ import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentView; 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; @@ -47,7 +50,6 @@ import java.awt.print.PrinterJob; import javax.swing.ButtonGroup; import javax.swing.JCheckBoxMenuItem; -import javax.swing.JColorChooser; import javax.swing.JMenuItem; import javax.swing.JRadioButtonMenuItem; import javax.swing.event.InternalFrameAdapter; @@ -210,15 +212,18 @@ public class PCAPanel extends GPCAPanel @Override public void bgcolour_actionPerformed(ActionEvent e) { - Color col = JColorChooser.showDialog(this, - MessageManager.getString("label.select_background_colour"), - rc.bgColour); - - if (col != null) + String ttl = MessageManager.getString("label.select_background_colour"); + ColourChooserListener listener = new ColourChooserListener() { - rc.bgColour = col; - } - rc.repaint(); + @Override + public void colourSelected(Color c) + { + rc.bgColour = c; + rc.repaint(); + } + }; + JalviewColourChooser.showColourChooser(this, ttl, rc.bgColour, + listener); } /** @@ -464,7 +469,16 @@ public class PCAPanel extends GPCAPanel public void run() { PrinterJob printJob = PrinterJob.getPrinterJob(); - PageFormat pf = printJob.pageDialog(printJob.defaultPage()); + PageFormat defaultPage = printJob.defaultPage(); + PageFormat pf = printJob.pageDialog(defaultPage); + + if (defaultPage == pf) + { + /* + * user cancelled + */ + return; + } printJob.setPrintable(this, pf); @@ -504,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