From: Jim Procter Date: Fri, 28 Oct 2016 16:45:02 +0000 (+0100) Subject: JAL-966 SearchResultsI now on viewmodels.AlignmentViewport rather than on SeqCanvas X-Git-Tag: Release_2_10_1~10^2~6^2~1^2~22 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=d7361eaa08dc9af7d996851f39b7a2007d1b8832;p=jalview.git JAL-966 SearchResultsI now on viewmodels.AlignmentViewport rather than on SeqCanvas --- diff --git a/src/jalview/api/AlignViewportI.java b/src/jalview/api/AlignViewportI.java index bd7d53d..2bed605 100644 --- a/src/jalview/api/AlignViewportI.java +++ b/src/jalview/api/AlignViewportI.java @@ -26,6 +26,7 @@ import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentView; import jalview.datamodel.CigarArray; import jalview.datamodel.ColumnSelection; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; @@ -422,4 +423,25 @@ public interface AlignViewportI extends ViewStyleI * @return true if group is defined on the alignment */ boolean isSelectionDefinedGroup(); + + /** + * + * @return true if there are search results on the view + */ + boolean hasSearchResults(); + + /** + * set the search results for the view + * + * @param results + * - or null to clear current results + */ + void setSearchResults(SearchResultsI results); + + /** + * get search results for this view (if any) + * + * @return search results or null + */ + SearchResultsI getSearchResults(); } diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index 477f1d6..5d6bb07 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -50,8 +50,6 @@ public class SeqCanvas extends Panel AlignViewport av; - SearchResultsI searchResults = null; - boolean fastPaint = false; int cursorX = 0; @@ -632,9 +630,10 @@ public class SeqCanvas extends Panel // / Highlight search Results once all sequences have been drawn // //////////////////////////////////////////////////////// - if (searchResults != null) + if (av.hasSearchResults()) { - int[] visibleResults = searchResults.getResults(nextSeq, startRes, + int[] visibleResults = av.getSearchResults().getResults(nextSeq, + startRes, endRes); if (visibleResults != null) { @@ -845,8 +844,7 @@ public class SeqCanvas extends Panel public void highlightSearchResults(SearchResultsI results) { - searchResults = results; - + av.setSearchResults(results); repaint(); } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 63620e5..7dff2ac 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -2907,8 +2907,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, viewport.setFollowHighlight(state); if (state) { - alignPanel.scrollToPosition( - alignPanel.getSeqPanel().seqCanvas.searchResults, false); + alignPanel.scrollToPosition(viewport.getSearchResults(), false); } } diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index a621989..d015292 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -62,8 +62,6 @@ public class SeqCanvas extends JComponent AlignViewport av; - SearchResultsI searchResults = null; - boolean fastPaint = false; int LABEL_WEST; @@ -740,10 +738,10 @@ public class SeqCanvas extends JComponent // / Highlight search Results once all sequences have been drawn // //////////////////////////////////////////////////////// - if (searchResults != null) + if (av.hasSearchResults()) { - int[] visibleResults = searchResults.getResults(nextSeq, startRes, - endRes); + int[] visibleResults = av.getSearchResults().getResults(nextSeq, + startRes, endRes); if (visibleResults != null) { for (int r = 0; r < visibleResults.length; r += 2) @@ -969,7 +967,7 @@ public class SeqCanvas extends JComponent { img = null; - searchResults = results; + av.setSearchResults(results); repaint(); } diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 2f733ed..aa7cd12 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -2822,6 +2822,7 @@ public abstract class AlignmentViewport implements AlignViewportI, */ private boolean selectionIsDefinedGroup = false; + @Override public boolean isSelectionDefinedGroup() { @@ -2845,4 +2846,27 @@ public abstract class AlignmentViewport implements AlignViewportI, return selectionGroup.getContext() == alignment || selectionIsDefinedGroup; } + + /** + * null, or currently highlighted results on this view + */ + private SearchResultsI searchResults = null; + + @Override + public boolean hasSearchResults() + { + return searchResults != null; + } + + @Override + public void setSearchResults(SearchResultsI results) + { + searchResults = results; + } + + @Override + public SearchResultsI getSearchResults() + { + return searchResults; + } }