From 7a5cac232c59bba9964ec32ecdd787b8028cde48 Mon Sep 17 00:00:00 2001 From: hansonr Date: Mon, 29 Jul 2019 15:09:16 -0500 Subject: [PATCH] JAL-3387 no-annotation too early --- src/jalview/bin/Jalview.java | 40 ++++++++++++++++++++++++++++------- src/jalview/gui/AlignFrame.java | 37 ++++++++++++++++++++------------ src/jalview/gui/AlignmentPanel.java | 7 +++++- 3 files changed, 62 insertions(+), 22 deletions(-) diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 6f902af..060d6ad 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -145,6 +145,8 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi private boolean noCalculation, noMenuBar, noStatus; + private boolean noAnnotation; + public boolean getStartCalculations() { return !noCalculation; @@ -160,6 +162,10 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi return !noStatus; } + public boolean getShowAnnotation() + { + return !noAnnotation; + } public static AlignFrame getCurrentAlignFrame() { @@ -654,6 +660,12 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi System.out.println("CMD [nostatus] executed successfully!"); } + if (aparser.contains(ArgsParser.NOANNOTATION) + || aparser.contains(ArgsParser.NOANNOTATION2)) + { + noAnnotation = true; + System.out.println("CMD no-annotation executed successfully!"); + } if (aparser.contains(ArgsParser.NOCALCULATION)) { noCalculation = true; @@ -754,18 +766,30 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi System.out.println("CMD [-sortbytree] executed successfully!"); } } - + boolean doUpdateAnnotation = false; - - if (aparser.contains(ArgsParser.NOANNOTATION) - || aparser.contains(ArgsParser.NOANNOTATION2)) + /** + * we do this earlier in JalviewJS because of a complication with + * SHOWOVERVIEW + * + * For now, just fixing this in JalviewJS. + * + * + * @j2sIgnore + * + */ { - af.getViewport().setShowAnnotation(false); - if (!af.getViewport().isShowAnnotation()) + if (aparser.contains(ArgsParser.NOANNOTATION) + || aparser.contains(ArgsParser.NOANNOTATION2)) { - doUpdateAnnotation = true; - System.out.println("CMD no-annotation executed successfully!"); + af.getViewport().setShowAnnotation(false); + if (!af.getViewport().isShowAnnotation()) + { + doUpdateAnnotation = true; + System.out + .println("CMD no-annotation executed successfully!"); + } } } if (aparser.contains(ArgsParser.NOSORTBYTREE)) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index d87f0f0..01aa9b0 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -107,6 +107,7 @@ import jalview.ws.seqfetcher.DbSourceProxy; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; +import java.awt.Dimension; import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.datatransfer.Clipboard; @@ -299,9 +300,6 @@ public class AlignFrame extends GAlignFrame viewport = new AlignViewport(al, hiddenColumns, sequenceSetId, viewId); - alignPanel = new AlignmentPanel(this, viewport); - - addAlignmentPanel(alignPanel, true); init(); } @@ -321,8 +319,6 @@ public class AlignFrame extends GAlignFrame { viewport.hideSequence(hiddenSeqs); } - alignPanel = new AlignmentPanel(this, viewport); - addAlignmentPanel(alignPanel, true); init(); } @@ -338,7 +334,6 @@ public class AlignFrame extends GAlignFrame { viewport = ap.av; alignPanel = ap; - addAlignmentPanel(ap, false); init(); } @@ -348,7 +343,28 @@ public class AlignFrame extends GAlignFrame */ void init() { -// setBackground(Color.white); // BH 2019 + boolean newPanel = (alignPanel == null); + viewport.setShowAutocalculatedAbove(isShowAutoCalculatedAbove()); + if (newPanel) + { + if (Platform.isJS()) + { + // need to set this up front if NOANNOTATION is + // used in conjunction with SHOWOVERVIEW. + + // I have not determined if this is appropriate for + // Jalview/Java, as it means we are setting this flag + // for all subsequent AlignFrames. For now, at least, + // I am setting it to be JalviewJS-only. + + boolean showAnnotation = Jalview.getInstance().getShowAnnotation(); + viewport.setShowAnnotation(showAnnotation); + } + alignPanel = new AlignmentPanel(this, viewport); + } + addAlignmentPanel(alignPanel, newPanel); + + // setBackground(Color.white); // BH 2019 if (!Jalview.isHeadlessMode()) { @@ -381,9 +397,6 @@ public class AlignFrame extends GAlignFrame sortPairwiseMenuItem_actionPerformed(null); } - this.alignPanel.av - .setShowAutocalculatedAbove(isShowAutoCalculatedAbove()); - setMenusFromViewport(viewport); buildSortByAnnotationScoresMenu(); calculateTree.addActionListener(new ActionListener() @@ -556,7 +569,7 @@ public class AlignFrame extends GAlignFrame switch (evt.getKeyCode()) { - case 27: // escape key + case KeyEvent.VK_ESCAPE: // escape key deselectAllSequenceMenuItem_actionPerformed(null); break; @@ -829,8 +842,6 @@ public class AlignFrame extends GAlignFrame @Override public void propertyChange(PropertyChangeEvent evt) { - // // System.out.println("Discoverer property change."); - // if (evt.getPropertyName().equals("services")) { SwingUtilities.invokeLater(new Runnable() { diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index f723794..5fa8fdf 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -56,6 +56,7 @@ import java.awt.event.AdjustmentEvent; import java.awt.event.AdjustmentListener; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; +import java.awt.image.BufferedImage; import java.awt.print.PageFormat; import java.awt.print.Printable; import java.awt.print.PrinterException; @@ -136,7 +137,11 @@ public class AlignmentPanel extends GAlignmentPanel implements annotationScroller.setViewportView(getAnnotationPanel()); annotationSpaceFillerHolder.add(getAlabels(), BorderLayout.CENTER); - + if (!av.isShowAnnotation()) + { + annotationScroller.setVisible(false); + annotationSpaceFillerHolder.setVisible(false); + } scalePanelHolder.add(getScalePanel(), BorderLayout.CENTER); seqPanelHolder.add(getSeqPanel(), BorderLayout.CENTER); -- 1.7.10.2