X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FSeqCanvas.java;h=618ec8a10a8b2b474e6cf36ed90161afc17755ef;hb=df1c58f9669c477db082016aa919d6c6cc9da071;hp=fe8122aece254fe8f63c8b908d4de66b8aefc5d3;hpb=5099540b9d747283036a752baa5ea246e8a5e855;p=jalview.git diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index fe8122a..618ec8a 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -35,8 +35,7 @@ public class SeqCanvas AlignViewport av; - boolean displaySearch = false; - int[] searchResults = null; + SearchResults searchResults = null; int chunkHeight; int chunkWidth; @@ -155,11 +154,13 @@ public class SeqCanvas public void fastPaint(int horizontal, int vertical) { - if (gg == null) + if (fastPaint || gg == null) { + repaint(); return; } + fastPaint = true; gg.copyArea(horizontal * av.charWidth, vertical * av.charHeight, imgWidth, @@ -169,6 +170,7 @@ public class SeqCanvas int sr = av.startRes, er = av.endRes, ss = av.startSeq, es = av.endSeq, transX = 0, transY = 0; + if (horizontal > 0) // scrollbar pulled right, image to the left { transX = (er - sr - horizontal) * av.charWidth; @@ -202,12 +204,9 @@ public class SeqCanvas gg.translate(transX, transY); - gg.setColor(Color.white); - gg.fillRect(0, 0, (er - sr + 1) * av.charWidth, (es - ss) * av.charHeight); drawPanel(gg, sr, er, ss, es, sr, ss, 0); gg.translate( -transX, -transY); - fastPaint = true; repaint(); } @@ -229,7 +228,6 @@ public class SeqCanvas public void paint(Graphics g) { - sr.renderGaps(av.renderGaps); if (fastPaint) { @@ -449,12 +447,27 @@ public class SeqCanvas if (av.showSequenceFeatures) { - fr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq), x1, x2, + fr.drawSequence(g, nextSeq, x1, x2, (x1 - startx) * av.charWidth, offset + (i - starty) * av.charHeight, av.charWidth, av.charHeight); } + /// Highlight search Results once all sequences have been drawn + ////////////////////////////////////////////////////////// + if (searchResults != null) + { + int[] visibleResults = searchResults.getResults(nextSeq, x1, x2); + if (visibleResults != null) + for (int r = 0; r < visibleResults.length; r += 2) + { + sr.drawHighlightedText(nextSeq, visibleResults[r], + visibleResults[r + 1], + (visibleResults[r] - startx) * av.charWidth, + offset + ( (i - starty) * av.charHeight), + av.charWidth, av.charHeight); + } + } } ///////////////////////////////////// @@ -614,58 +627,10 @@ public class SeqCanvas } while (groupIndex < groups.size()); } - - /// Highlight search Results once all sequences have been drawn - ////////////////////////////////////////////////////////// - if (displaySearch) - { - for (int r = 0; r < searchResults.length; r += 3) - { - int searchSeq = searchResults[r]; - - if (searchSeq >= y1 && searchSeq < y2) - { - SequenceI seq = av.getAlignment().getSequenceAt(searchSeq); - - int searchStart = seq.findIndex(searchResults[r + 1]) - 1; - int searchEnd = seq.findIndex(searchResults[r + 2]) - 1; - - SequenceRenderer ssr = (SequenceRenderer) sr; - if (searchStart < x1) - { - searchStart = x1; - } - if (searchEnd > x2) - { - searchEnd = x2; - } - - ssr.drawHighlightedText(seq, - searchStart, - searchEnd, - (searchStart - startx) * av.charWidth, - offset + - (searchSeq-starty)*av.charHeight, - av.charWidth, - av.charHeight); - } - } - } - } - public void highlightSearchResults(int[] results) + public void highlightSearchResults(SearchResults results) { - // results are in the order sequence, startRes, endRes - if (results == null) - { - displaySearch = false; - } - else - { - displaySearch = true; - } - searchResults = results; repaint();