From a53974449027202e8f6985f5191f0efbecd5342c Mon Sep 17 00:00:00 2001 From: James Procter Date: Thu, 23 Mar 2023 14:51:32 +0000 Subject: [PATCH] JAL-4155 Viewport holds a reference to its AlignmentViewPanel - getter on gui.AlignViewport casts interface to gui.AlignmentPanel --- src/jalview/gui/AlignViewport.java | 33 ++++++++++---------------- src/jalview/gui/AlignmentPanel.java | 1 + src/jalview/viewmodel/AlignmentViewport.java | 19 +++++++++++++++ 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 2d82579..79a16ba 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -529,6 +529,16 @@ public class AlignViewport extends AlignmentViewport this); } + + public boolean getSortByTree() + { + return sortByTree; + } + + public void setSortByTree(boolean sort) + { + sortByTree = sort; + } /** * return the alignPanel containing the given viewport. Use this to get the * components currently handling the given viewport. @@ -537,30 +547,11 @@ public class AlignViewport extends AlignmentViewport * @return null or an alignPanel guaranteed to have non-null alignFrame * reference */ + public AlignmentPanel getAlignPanel() { - AlignmentPanel[] aps = PaintRefresher - .getAssociatedPanels(this.getSequenceSetId()); - for (int p = 0; aps != null && p < aps.length; p++) - { - if (aps[p].av == this) - { - return aps[p]; - } - } - return null; - } - - public boolean getSortByTree() - { - return sortByTree; + return (AlignmentPanel) alignPanel; } - - public void setSortByTree(boolean sort) - { - sortByTree = sort; - } - /** * Returns the (Desktop) instance of the StructureSelectionManager */ diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index fd53faf..d90164f 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -128,6 +128,7 @@ public class AlignmentPanel extends GAlignmentPanel implements // setBackground(Color.white); // BH 2019 alignFrame = af; this.av = av; + av.setAlignPanel(this); setSeqPanel(new SeqPanel(av, this)); setIdPanel(new IdPanel(av, this)); diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 0e3bb9e..2b4074e 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -138,6 +138,24 @@ public abstract class AlignmentViewport ranges = new ViewportRanges(al); } + protected AlignmentViewPanel alignPanel=null; + public void setAlignPanel(AlignmentViewPanel ap) + { + alignPanel = ap; + } + /** + * return the AlignmentViewPanel containing the given viewport. Use this to get the + * components currently handling the given viewport. + * + * @param av + * @return null or an alignPanel guaranteed to have non-null alignFrame + * reference + */ + + public AlignmentViewPanel getAlignPanel() + { + return alignPanel; + } /** * @param name * @see jalview.api.ViewStyleI#setFontName(java.lang.String) @@ -1027,6 +1045,7 @@ public abstract class AlignmentViewport * defensively null out references to large objects in case * this object is not garbage collected (as if!) */ + alignPanel=null; consensus = null; complementConsensus = null; strucConsensus = null; -- 1.7.10.2