From: James Procter Date: Thu, 23 Mar 2023 14:51:32 +0000 (+0000) Subject: JAL-4155 Viewport holds a reference to its AlignmentViewPanel - getter on gui.AlignVi... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2bf8987532d51b3b7196aa87e65eb16924417f5b;p=jalview.git JAL-4155 Viewport holds a reference to its AlignmentViewPanel - getter on gui.AlignViewport casts interface to gui.AlignmentPanel --- diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 90f627e..944bb6b 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -525,6 +525,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. @@ -533,30 +543,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; - } - - public void setSortByTree(boolean sort) - { - sortByTree = sort; + return (AlignmentPanel) alignPanel; } - /** * Returns the (Desktop) instance of the StructureSelectionManager */ diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 2d057bb..b148859 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -126,6 +126,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 a42a2a4..4f68cb5 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -119,6 +119,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) @@ -954,6 +972,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;