From 6f0b432ac19ed1d0d5e01a834586dc81b8a6a72d Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 9 Jul 2018 15:11:40 +0100 Subject: [PATCH] JAL-1858 separate method highlightSearchResults with fastPaint --- src/jalview/gui/AlignmentPanel.java | 4 ++-- src/jalview/gui/FeatureEditor.java | 12 ++++------- src/jalview/gui/SeqCanvas.java | 38 +++++++++++++++++++++++++++-------- src/jalview/gui/SeqPanel.java | 6 +++--- 4 files changed, 39 insertions(+), 21 deletions(-) diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 2c5684a..065d0c3 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -335,9 +335,9 @@ public class AlignmentPanel extends GAlignmentPanel implements { boolean scrolled = scrollToPosition(results, 0, true, false); - boolean noFastPaint = scrolled && av.getWrapAlignment(); + boolean fastPaint = !(scrolled && av.getWrapAlignment()); - getSeqPanel().seqCanvas.highlightSearchResults(results, noFastPaint); + getSeqPanel().seqCanvas.highlightSearchResults(results, fastPaint); } /** diff --git a/src/jalview/gui/FeatureEditor.java b/src/jalview/gui/FeatureEditor.java index 6165152..b34e104 100644 --- a/src/jalview/gui/FeatureEditor.java +++ b/src/jalview/gui/FeatureEditor.java @@ -270,8 +270,7 @@ public class FeatureEditor highlight.addResult(sequences.get(0), sf.getBegin(), sf.getEnd()); - ap.getSeqPanel().seqCanvas.highlightSearchResults(highlight, - true); + ap.getSeqPanel().seqCanvas.highlightSearchResults(highlight); } FeatureColourI col = fr.getFeatureStyle(name.getText()); if (col == null) @@ -477,8 +476,7 @@ public class FeatureEditor * suppress fastPaint here - if feature colour changed, * we need to repaint the whole alignment */ - ap.getSeqPanel().seqCanvas.highlightSearchResults(null, - true); + ap.getSeqPanel().seqCanvas.highlightSearchResults(null); ap.paintAlignment(true, true); } }).response(new RunResponse(JvOptionPane.NO_OPTION) @@ -492,16 +490,14 @@ public class FeatureEditor sequences.get(0).getDatasetSequence().deleteFeature(sf); // update Feature Settings for removal of feature / group fr.featuresAdded(); - ap.getSeqPanel().seqCanvas.highlightSearchResults(null, - true); + ap.getSeqPanel().seqCanvas.highlightSearchResults(null); ap.paintAlignment(true, true); } }).defaultResponse(new Runnable() { public void run() { - ap.getSeqPanel().seqCanvas.highlightSearchResults(null, - true); + ap.getSeqPanel().seqCanvas.highlightSearchResults(null); ap.paintAlignment(true, true); } }).showInternalDialog(mainPanel, title, diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 4861bd5..7ecedf4 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -1567,20 +1567,42 @@ public class SeqCanvas extends JPanel implements ViewportListenerI * Highlights search results in the visible region by rendering as white text * on a black background. Any previous highlighting is removed. Answers true * if any highlight was left on the visible alignment (so status bar should be + * set to match), else false. This method does _not_ set the 'fastPaint' flag, + * so allows the next repaint to update the whole display. + * + * @param results + * @return + */ + public boolean highlightSearchResults(SearchResultsI results) + { + return highlightSearchResults(results, false); + + } + + /** + * Highlights search results in the visible region by rendering as white text + * on a black background. Any previous highlighting is removed. Answers true + * if any highlight was left on the visible alignment (so status bar should be * set to match), else false. *

- * Currently fastPaint is not implemented for wrapped alignments. If a wrapped - * alignment had to be scrolled to show the highlighted region, then it should - * be fully redrawn, otherwise a fast paint can be performed. This argument - * could be removed if fast paint of scrolled wrapped alignment is coded in - * future (JAL-2609). + * Optionally, set the 'fastPaint' flag for a faster redraw if only the + * highlighted regions are modified. This speeds up highlighting across linked + * alignments. + *

+ * Currently fastPaint is not implemented for scrolled wrapped alignments. If + * a wrapped alignment had to be scrolled to show the highlighted region, then + * it should be fully redrawn, otherwise a fast paint can be performed. This + * argument could be removed if fast paint of scrolled wrapped alignment is + * coded in future (JAL-2609). * * @param results - * @param noFastPaint + * @param doFastPaint + * if true, sets a flag so the next repaint only redraws the modified + * image * @return */ public boolean highlightSearchResults(SearchResultsI results, - boolean noFastPaint) + boolean doFastPaint) { if (fastpainting) { @@ -1589,7 +1611,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI boolean wrapped = av.getWrapAlignment(); try { - fastPaint = !noFastPaint; + fastPaint = doFastPaint; fastpainting = fastPaint; /* diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 5ae4a0e..eff4985 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -745,8 +745,8 @@ public class SeqPanel extends JPanel ap.setToScrollComplementPanel(true); } - boolean noFastPaint = wasScrolled && av.getWrapAlignment(); - if (seqCanvas.highlightSearchResults(results, noFastPaint)) + boolean fastPaint = !(wasScrolled && av.getWrapAlignment()); + if (seqCanvas.highlightSearchResults(results, fastPaint)) { setStatusMessage(results); } @@ -1673,7 +1673,7 @@ public class SeqPanel extends JPanel SearchResultsI highlight = new SearchResults(); highlight.addResult(sequence, features.get(0).getBegin(), features .get(0).getEnd()); - seqCanvas.highlightSearchResults(highlight, false); + seqCanvas.highlightSearchResults(highlight, true); /* * open the Amend Features dialog; clear highlighting afterwards, -- 1.7.10.2