X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=9e4b18081139d5c27d4dd15775dabe8892fd1e90;hb=c764fbfdffe3a52349038c957d7a73b8e22e9985;hp=160ee1ae5c84bed42babcd11c59359a733a2a71e;hpb=1d1edb58c9ee8baec12686a512eb18d97b9bdba1;p=jalview.git diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 160ee1a..9e4b180 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; @@ -112,6 +111,7 @@ import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentOrder; import jalview.datamodel.AlignmentView; import jalview.datamodel.ColumnSelection; +import jalview.datamodel.ContactMatrixI; import jalview.datamodel.HiddenColumns; import jalview.datamodel.PDBEntry; import jalview.datamodel.SeqCigar; @@ -140,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; @@ -156,7 +157,6 @@ import jalview.viewmodel.AlignmentViewport; import jalview.viewmodel.ViewportRanges; import jalview.ws.DBRefFetcher; import jalview.ws.DBRefFetcher.FetchFinishedListenerI; -import jalview.ws.datamodel.alphafold.PAEContactMatrix; import jalview.ws.jws1.Discoverer; import jalview.ws.jws2.Jws2Discoverer; import jalview.ws.jws2.jabaws2.Jws2Instance; @@ -1279,11 +1279,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) @@ -1361,7 +1360,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, AlignFrame.this.getViewport().setSavedUpToDate(true); } } - return null; }; /* @@ -1379,7 +1377,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { try { - outputAction.call(); + outputAction.run(); } catch (Exception e) { // TODO Auto-generated catch block @@ -1401,7 +1399,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(); @@ -1423,7 +1421,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, oom); cap.dispose(); } - return null; }; /* @@ -1440,7 +1437,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { try { - outputAction.call(); + outputAction.run(); } catch (Exception e) { e.printStackTrace(); @@ -1458,19 +1455,75 @@ 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); - bjs.exportHTML(null); + try + { + bjs.exportHTML(null); + } catch (ImageOutputException x) + { + // report problem to console and raise dialog + } } public void createImageMap(File file, String image) { - alignPanel.makePNGImageMap(file, 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 + } + } /** @@ -1479,13 +1532,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, * * @param f */ - @Override - public void createPNG(File f) + public void createPNG(File f) throws ImageOutputException { createPNG(f, null, BitmapImageSizing.nullBitmapImageSizing()); } public void createPNG(File f, String renderer, BitmapImageSizing userBis) + throws ImageOutputException { alignPanel.makeAlignmentImage(TYPE.PNG, f, renderer, userBis); } @@ -1496,13 +1549,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); } @@ -1513,13 +1565,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); } @@ -1571,7 +1622,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); @@ -1591,6 +1641,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, closeAllTabs = true; } + Desktop.closeModal(this); + try { if (alignPanels != null) @@ -1620,6 +1672,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, featureSettings.close(); featureSettings = null; } + /* * this will raise an INTERNAL_FRAME_CLOSED event and this method will * be called recursively, with the frame now in 'closed' state @@ -2303,10 +2356,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, .intValue(); } } - alignment.addAnnotation(sequences[i].getAnnotation()[a]); // annotation - // was - // duplicated - // earlier + // annotation was duplicated earlier + alignment.addAnnotation(sequences[i].getAnnotation()[a]); + // take care of contact matrix too + ContactMatrixI cm = sequences[i] + .getContactMatrixFor(sequences[i].getAnnotation()[a]); + if (cm != null) + { + alignment.addContactListFor(sequences[i].getAnnotation()[a], + cm); + } + alignment.setAnnotationIndex(sequences[i].getAnnotation()[a], a); } @@ -2493,7 +2553,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, return; } - Callable okAction = () -> { + Runnable okAction = () -> { SequenceI[] cut = sg.getSequences() .toArray(new SequenceI[sg.getSize()]); @@ -2517,7 +2577,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { } } - return null; }; /* @@ -2543,7 +2602,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { try { - okAction.call(); + okAction.run(); } catch (Exception e) { e.printStackTrace(); @@ -4135,7 +4194,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, .getString("label.possible_problem_with_tree_file"), JvOptionPane.WARNING_MESSAGE); } - return null; }); chooser.showOpenDialog(this); } @@ -4201,8 +4259,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, return tp; } - public void showContactMapTree(AlignmentAnnotation aa, - PAEContactMatrix cm) + public void showContactMapTree(AlignmentAnnotation aa, ContactMatrixI cm) { int x = 4, y = 5; int w = 400, h = 500; @@ -4211,8 +4268,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { NewickFile fin = new NewickFile( new FileParse(cm.getNewick(), DataSourceType.PASTE)); - String title = "PAE Matrix Tree for " - + cm.getReferenceSeq().getDisplayId(false); + String title = cm.getAnnotLabel() + " " + cm.getTreeMethod() + " tree" + + aa.sequenceRef != null + ? (" for " + aa.sequenceRef.getDisplayId(false)) + : ""; showColumnWiseTree(fin, aa, title, w, h, x, y); } catch (Throwable xx) @@ -5981,7 +6040,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);