X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=9aa8733e36920b13d36d5fe58c6e533b1cee57d1;hb=HEAD;hp=711d224fcf4c35cd7c556ccaad5e6a74bc70f57a;hpb=147c5664cb8ca080623e9c7c786b8dbfb567bae8;p=jalview.git diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 711d224..9aa8733 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -95,6 +95,7 @@ import jalview.api.analysis.SimilarityParamsI; import jalview.bin.Cache; import jalview.bin.Console; import jalview.bin.Jalview; +import jalview.bin.groovy.JalviewObjectI; import jalview.commands.CommandI; import jalview.commands.EditCommand; import jalview.commands.EditCommand.Action; @@ -503,7 +504,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void focusGained(FocusEvent e) { - Jalview.setCurrentAlignFrame(AlignFrame.this); + Jalview.getInstance().setCurrentAlignFrame(AlignFrame.this); } }); @@ -624,12 +625,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, // if (viewport.cursorMode) // { // alignPanel.seqPanel.insertNucAtCursor(false,"A"); - // //System.out.println("A"); + // //jalview.bin.Console.outPrintln("A"); // } // break; /* * case KeyEvent.VK_CLOSE_BRACKET: if (viewport.cursorMode) { - * System.out.println("closing bracket"); } break; + * jalview.bin.Console.outPrintln("closing bracket"); } break; */ case KeyEvent.VK_DELETE: case KeyEvent.VK_BACK_SPACE: @@ -830,7 +831,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void propertyChange(PropertyChangeEvent evt) { - // // System.out.println("Discoverer property change."); + // // jalview.bin.Console.outPrintln("Discoverer property + // change."); // if (evt.getPropertyName().equals("services")) { SwingUtilities.invokeLater(new Runnable() @@ -839,7 +841,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void run() { - System.err.println( + jalview.bin.Console.errPrintln( "Rebuild WS Menu for service change"); BuildWebServiceMenu(); } @@ -854,7 +856,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, public void internalFrameClosed( javax.swing.event.InternalFrameEvent evt) { - // System.out.println("deregistering discoverer listener"); + // jalview.bin.Console.outPrintln("deregistering discoverer listener"); Desktop.instance.removeJalviewPropertyChangeListener("services", thisListener); closeMenuItem_actionPerformed(true); @@ -1251,10 +1253,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, */ public void saveAlignment(String file, FileFormatI format) { - saveAlignment(file, format, false); + saveAlignment(file, format, false, false); } - public void saveAlignment(String file, FileFormatI format, boolean stdout) + public void saveAlignment(String file, FileFormatI format, boolean stdout, + boolean forceBackup) { lastSaveSuccessful = true; if (!stdout) @@ -1307,7 +1310,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, else { // create backupfiles object and get new temp filename destination - boolean doBackup = BackupFiles.getEnabled() && !stdout; + boolean doBackup = forceBackup + || (BackupFiles.getEnabled() && !stdout); BackupFiles backupfiles = null; if (doBackup) { @@ -1331,9 +1335,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, out.print(output); out.flush(); - Console.trace("ALIGNFRAME about to close file"); - out.close(); - Console.trace("ALIGNFRAME closed file"); + if (!stdout) + { + Console.trace("ALIGNFRAME about to close file"); + out.close(); + Console.trace("ALIGNFRAME closed file"); + } AlignFrame.this.setTitle(stdout ? "STDOUT" : file); if (stdout) { @@ -1558,7 +1565,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, */ public void createPNG(File f) throws ImageOutputException { - createPNG(f, null, BitmapImageSizing.nullBitmapImageSizing()); + createPNG(f, null, BitmapImageSizing.defaultBitmapImageSizing()); } public void createPNG(File f, String renderer, BitmapImageSizing userBis) @@ -1665,6 +1672,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, closeAllTabs = true; } + Desktop.closeModal(this); + try { if (alignPanels != null) @@ -1694,6 +1703,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 @@ -1787,7 +1797,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, * * @return alignment objects for all views */ - AlignmentI[] getViewAlignments() + public AlignmentI[] getViewAlignments() { if (alignPanels != null) { @@ -2495,7 +2505,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } catch (Exception ex) { ex.printStackTrace(); - System.out.println("Exception whilst pasting: " + ex); + jalview.bin.Console.outPrintln("Exception whilst pasting: " + ex); // could be anything being pasted in here } @@ -2543,7 +2553,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } catch (Exception ex) { ex.printStackTrace(); - System.out.println("Exception whilst pasting: " + ex); + jalview.bin.Console.outPrintln("Exception whilst pasting: " + ex); // could be anything being pasted in here } catch (OutOfMemoryError oom) { @@ -3179,11 +3189,20 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void wrapMenuItem_actionPerformed(ActionEvent e) { - scaleAbove.setVisible(wrapMenuItem.isSelected()); - scaleLeft.setVisible(wrapMenuItem.isSelected()); - scaleRight.setVisible(wrapMenuItem.isSelected()); - viewport.setWrapAlignment(wrapMenuItem.isSelected()); + setWrapFormat(wrapMenuItem.isSelected(), false); + } + + public void setWrapFormat(boolean b, boolean setMenuItem) + { + scaleAbove.setVisible(b); + scaleLeft.setVisible(b); + scaleRight.setVisible(b); + viewport.setWrapAlignment(b); alignPanel.updateLayout(); + if (setMenuItem) + { + wrapMenuItem.setSelected(b); + } } @Override @@ -3521,7 +3540,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } JInternalFrame frame = new JInternalFrame(); - + frame.setFrameIcon(null); frame.getContentPane().add(new JScrollPane(pane)); Desktop.addInternalFrame(frame, MessageManager @@ -3549,12 +3568,16 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, return alignPanel.overviewPanel; } JInternalFrame frame = new JInternalFrame(); + frame.setFrameIcon(null); final OverviewPanel overview = new OverviewPanel(alignPanel, frame, showHidden); frame.setContentPane(overview); - Desktop.addInternalFrame(frame, "", true, frame.getWidth(), - frame.getHeight(), true, true); - frame.setFrameIcon(null); + + alignPanel.setOverviewPanel(overview); + alignPanel.setOverviewTitle(this); + + Desktop.addInternalFrame(frame, overview.getTitle(), true, + frame.getWidth(), frame.getHeight(), true, true); frame.pack(); frame.setLayer(JLayeredPane.PALETTE_LAYER); final AlignmentPanel thePanel = this.alignPanel; @@ -3574,9 +3597,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, frame.addKeyListener(getKeyListeners()[0]); } - alignPanel.setOverviewPanel(overview); - alignPanel.setOverviewTitle(this); - return overview; } @@ -3828,6 +3848,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, else { JInternalFrame frame = new JInternalFrame(); + frame.setFrameIcon(null); frame.setContentPane(new PairwiseAlignPanel(viewport)); Desktop.addInternalFrame(frame, MessageManager.getString("action.pairwise_alignment"), 600, @@ -4343,7 +4364,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { try { - System.err.println("Waiting for building menu to finish."); + jalview.bin.Console + .errPrintln("Waiting for building menu to finish."); Thread.sleep(10); } catch (Exception e) { @@ -4359,7 +4381,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, final List legacyItems = new ArrayList<>(); try { - // System.err.println("Building ws menu again " + // jalview.bin.Console.errPrintln("Building ws menu again " // + Thread.currentThread()); // TODO: add support for context dependent disabling of services based // on @@ -4797,7 +4819,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, * Object[] { String,SequenceI} */ ArrayList filesmatched = new ArrayList<>(); - ArrayList filesnotmatched = new ArrayList<>(); + ArrayList filesnotmatched = new ArrayList<>(); for (int i = 0; i < files.size(); i++) { // BH 2018 @@ -4843,9 +4865,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } mtch = idm.findAllIdMatches(pdbfn); } + FileFormatI type = null; if (mtch != null) { - FileFormatI type; try { type = new IdentifyFile().identify(file, protocol); @@ -4861,7 +4883,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } // File wasn't named like one of the sequences or wasn't a PDB // file. - filesnotmatched.add(file); + filesnotmatched.add(new Object[] { file, protocol, type }); } } int assocfiles = 0; @@ -4897,7 +4919,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, Desktop.instance); if (pe != null) { - System.err.println("Associated file : " + jalview.bin.Console.errPrintln("Associated file : " + (fm[0].toString()) + " with " + toassoc.getDisplayId(true)); assocfiles++; @@ -4915,7 +4937,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, */ for (Object[] o : filesmatched) { - filesnotmatched.add(o[0]); + filesnotmatched.add(new Object[] { o[0], o[1] }); } } } @@ -4937,9 +4959,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { return; } - for (Object fn : filesnotmatched) + for (Object[] fn : filesnotmatched) { - loadJalviewDataFile(fn, null, null, null); + loadJalviewDataFile(fn[0], (DataSourceType) fn[1], + (FileFormatI) fn[2], null); } } @@ -5035,7 +5058,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { format = new IdentifyFile().identify(file, sourceType); } - if (FileFormat.ScoreMatrix == format) + if (FileFormat.FeatureSettings == format) + { + if (featureSettings != null) + { + featureSettings.load(file, sourceType); + } + else + { + FeatureSettings.loadFeatureSettingsFile(getFeatureRenderer(), + fileObject, sourceType); + } + } + else if (FileFormat.ScoreMatrix == format) { ScoreMatrixFile sm = new ScoreMatrixFile( new FileParse(file, sourceType)); @@ -5603,9 +5638,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override protected void justifyLeftMenuItem_actionPerformed(ActionEvent e) { - AlignmentI al = viewport.getAlignment(); - al.justify(false); - viewport.firePropertyChange("alignment", null, al); + avc.justify_Region(true); } /** @@ -5614,9 +5647,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override protected void justifyRightMenuItem_actionPerformed(ActionEvent e) { - AlignmentI al = viewport.getAlignment(); - al.justify(true); - viewport.firePropertyChange("alignment", null, al); + avc.justify_Region(false); } @Override @@ -5821,6 +5852,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } } alignPanel.validateAnnotationDimensions(true); + // TODO this triggers relayout of annotation panel - otherwise annotation + // label height is different to panel height + alignPanel.fontChanged(); alignPanel.alignmentChanged(); } @@ -5930,7 +5964,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, viewport.getAlignment())); } catch (Exception ex) { - System.err.println(ex.getMessage()); + jalview.bin.Console.errPrintln(ex.getMessage()); return; } } @@ -5943,16 +5977,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override protected void runGroovy_actionPerformed() { - Jalview.setCurrentAlignFrame(this); - groovy.ui.Console console = Desktop.getGroovyConsole(); + Jalview.getInstance().setCurrentAlignFrame(this); + groovy.console.ui.Console console = Desktop.getGroovyConsole(); if (console != null) { try { + console.setVariable(JalviewObjectI.currentAlFrameName, this); console.runScript(); } catch (Exception ex) { - System.err.println((ex.toString())); + jalview.bin.Console.errPrintln((ex.toString())); JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager.getString("label.couldnt_run_groovy_script"), MessageManager.getString("label.groovy_support_failed"), @@ -5961,7 +5996,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } else { - System.err.println("Can't run Groovy script as console not found"); + jalview.bin.Console + .errPrintln("Can't run Groovy script as console not found"); } }