X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=ab705c2e152fdb71e8997fbd395678c862f8fd97;hb=bab8878fb12f99051cdc622fe6a9767b3109bc70;hp=48927bb5702c9351a978b8b5313b4fa0c3426b92;hpb=19c22459dca6c69d6f1fd0eed029c01e21c99854;p=jalview.git diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 48927bb..ab705c2 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -59,7 +59,6 @@ import java.util.Hashtable; import java.util.List; import java.util.Locale; import java.util.Vector; -import java.util.concurrent.Callable; import javax.swing.ButtonGroup; import javax.swing.JCheckBoxMenuItem; @@ -141,6 +140,7 @@ import jalview.io.JnetAnnotationMaker; import jalview.io.NewickFile; import jalview.io.ScoreMatrixFile; import jalview.io.TCoffeeScoreFile; +import jalview.io.exceptions.ImageOutputException; import jalview.io.vcf.VCFLoader; import jalview.jbgui.GAlignFrame; import jalview.project.Jalview2XML; @@ -152,6 +152,7 @@ import jalview.util.HttpUtils; import jalview.util.ImageMaker.TYPE; import jalview.util.MessageManager; import jalview.util.Platform; +import jalview.util.imagemaker.BitmapImageSizing; import jalview.viewmodel.AlignmentViewport; import jalview.viewmodel.ViewportRanges; import jalview.ws.DBRefFetcher; @@ -982,7 +983,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void setProgressBar(String message, long id) { - if (!Platform.isHeadless()) + if (!Platform.isHeadless() && progressBar != null) progressBar.setProgressBar(message, id); } @@ -990,7 +991,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, public void registerHandler(final long id, final IProgressIndicatorHandler handler) { - progressBar.registerHandler(id, handler); + if (progressBar != null) + progressBar.registerHandler(id, handler); } /** @@ -1000,7 +1002,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public boolean operationInProgress() { - return progressBar.operationInProgress(); + return progressBar == null ? false : progressBar.operationInProgress(); } /** @@ -1278,11 +1280,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } AlignExportSettingsI options = new AlignExportSettingsAdapter(false); - Callable cancelAction = () -> { + Runnable cancelAction = () -> { lastSaveSuccessful = false; - return null; }; - Callable outputAction = () -> { + Runnable outputAction = () -> { // todo defer this to inside formatSequences (or later) AlignmentExportData exportData = viewport.getAlignExportData(options); String output = new FormatAdapter(alignPanel, options) @@ -1360,7 +1361,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, AlignFrame.this.getViewport().setSavedUpToDate(true); } } - return null; }; /* @@ -1378,7 +1378,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { try { - outputAction.call(); + outputAction.run(); } catch (Exception e) { // TODO Auto-generated catch block @@ -1400,7 +1400,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, FileFormatI fileFormat = FileFormats.getInstance() .forName(fileFormatName); AlignExportSettingsI options = new AlignExportSettingsAdapter(false); - Callable outputAction = () -> { + Runnable outputAction = () -> { // todo defer this to inside formatSequences (or later) AlignmentExportData exportData = viewport.getAlignExportData(options); CutAndPasteTransfer cap = new CutAndPasteTransfer(); @@ -1422,7 +1422,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, oom); cap.dispose(); } - return null; }; /* @@ -1439,7 +1438,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { try { - outputAction.call(); + outputAction.run(); } catch (Exception e) { e.printStackTrace(); @@ -1457,38 +1456,76 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, protected void htmlMenuItem_actionPerformed(ActionEvent e) { HtmlSvgOutput htmlSVG = new HtmlSvgOutput(alignPanel); - htmlSVG.exportHTML(null); + try { + htmlSVG.exportHTML(null); + } catch (ImageOutputException x) { + // report problem to console and raise dialog + } } @Override public void bioJSMenuItem_actionPerformed(ActionEvent e) { BioJsHTMLOutput bjs = new BioJsHTMLOutput(alignPanel); + try { bjs.exportHTML(null); + } catch (ImageOutputException x) { + // report problem to console and raise dialog + } } public void createImageMap(File file, String image) { + try { alignPanel.makePNGImageMap(file, image); + } catch (ImageOutputException x) { + // report problem to console and raise dialog + } } + @Override + public void createPNG_actionPerformed(ActionEvent e) { + try{ + createPNG(null); + } catch (ImageOutputException ioex) + { + // raise dialog, and report via console + } + } + @Override + public void createEPS_actionPerformed(ActionEvent e) { + try{ + createEPS(null); + } catch (ImageOutputException ioex) + { + // raise dialog, and report via console + } + + } + @Override + public void createSVG_actionPerformed(ActionEvent e) { + try{ + createSVG(null); + } catch (ImageOutputException ioex) + { + // raise dialog, and report via console + } + + } /** * Creates a PNG image of the alignment and writes it to the given file. If * the file is null, the user is prompted to choose a file. * * @param f */ - @Override - public void createPNG(File f) + public void createPNG(File f) throws ImageOutputException { - createPNG(f, null, 0.0f, 0, 0); + createPNG(f, null, BitmapImageSizing.nullBitmapImageSizing()); } - public void createPNG(File f, String renderer, float bitmapscale, - int bitmapwidth, int bitmapheight) + public void createPNG(File f, String renderer, BitmapImageSizing userBis) throws ImageOutputException { - alignPanel.makeAlignmentImage(TYPE.PNG, f, renderer, bitmapscale, - bitmapwidth, bitmapheight); + alignPanel.makeAlignmentImage(TYPE.PNG, f, renderer, userBis); } /** @@ -1497,13 +1534,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, * * @param f */ - @Override - public void createEPS(File f) + public void createEPS(File f) throws ImageOutputException { createEPS(f, null); } - public void createEPS(File f, String renderer) + public void createEPS(File f, String renderer) throws ImageOutputException { alignPanel.makeAlignmentImage(TYPE.EPS, f, renderer); } @@ -1514,13 +1550,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, * * @param f */ - @Override - public void createSVG(File f) + public void createSVG(File f) throws ImageOutputException { createSVG(f, null); } - public void createSVG(File f, String renderer) + public void createSVG(File f, String renderer) throws ImageOutputException { alignPanel.makeAlignmentImage(TYPE.SVG, f, renderer); } @@ -1572,7 +1607,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, String choice = chooser.getSelectedFile().getPath(); Cache.setProperty("LAST_DIRECTORY", choice); loadJalviewDataFile(chooser.getSelectedFile(), null, null, null); - return null; }); chooser.showOpenDialog(this); @@ -2499,7 +2533,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, return; } - Callable okAction = () -> { + Runnable okAction = () -> { SequenceI[] cut = sg.getSequences() .toArray(new SequenceI[sg.getSize()]); @@ -2523,7 +2557,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { } } - return null; }; /* @@ -2549,7 +2582,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { try { - okAction.call(); + okAction.run(); } catch (Exception e) { e.printStackTrace(); @@ -4141,7 +4174,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, .getString("label.possible_problem_with_tree_file"), JvOptionPane.WARNING_MESSAGE); } - return null; }); chooser.showOpenDialog(this); } @@ -5989,7 +6021,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, Cache.setProperty("LAST_DIRECTORY", choice); SequenceI[] seqs = viewport.getAlignment().getSequencesArray(); new VCFLoader(choice).loadVCF(seqs, us); - return null; }); chooser.showOpenDialog(null);