X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSeqCanvas.java;h=7d953989280b719458107acbddd20ed0802e899d;hb=refs%2Fheads%2Ffeatures%2FJAL-653_JAL-1766_htslib_refseqsupport;hp=5706fe76c9c7f7f6ac01db1c891cb5e8299123c8;hpb=4d7f98a6dd54d9863ba449ec79dcd95d25ed863d;p=jalview.git diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 5706fe7..7d95398 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -21,9 +21,12 @@ package jalview.gui; import jalview.datamodel.AlignmentI; -import jalview.datamodel.SearchResults; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; +import jalview.renderer.ScaleRenderer; +import jalview.renderer.ScaleRenderer.ScaleMark; +import jalview.viewmodel.ViewportRanges; import java.awt.BasicStroke; import java.awt.BorderLayout; @@ -60,8 +63,6 @@ public class SeqCanvas extends JComponent AlignViewport av; - SearchResults searchResults = null; - boolean fastPaint = false; int LABEL_WEST; @@ -122,24 +123,26 @@ public class SeqCanvas extends JComponent private void drawNorthScale(Graphics g, int startx, int endx, int ypos) { updateViewport(); - int scalestartx = startx - (startx % 10) + 10; - - g.setColor(Color.black); - // NORTH SCALE - for (int i = scalestartx; i < endx; i += 10) + for (ScaleMark mark : new ScaleRenderer().calculateMarks(av, startx, + endx)) { - int value = i; - if (av.hasHiddenColumns()) + int mpos = mark.column; // (i - startx - 1) + if (mpos < 0) { - value = av.getColumnSelection().adjustForHiddenColumns(value); + continue; } + String mstring = mark.text; - g.drawString(String.valueOf(value), (i - startx - 1) * charWidth, - ypos - (charHeight / 2)); - - g.drawLine(((i - startx - 1) * charWidth) + (charWidth / 2), - (ypos + 2) - (charHeight / 2), ((i - startx - 1) * charWidth) - + (charWidth / 2), ypos - 2); + if (mark.major) + { + if (mstring != null) + { + g.drawString(mstring, mpos * charWidth, ypos - (charHeight / 2)); + } + g.drawLine((mpos * charWidth) + (charWidth / 2), (ypos + 2) + - (charHeight / 2), (mpos * charWidth) + (charWidth / 2), + ypos - 2); + } } } @@ -277,10 +280,11 @@ public class SeqCanvas extends JComponent gg.copyArea(horizontal * charWidth, vertical * charHeight, imgWidth, imgHeight, -horizontal * charWidth, -vertical * charHeight); - int sr = av.startRes; - int er = av.endRes; - int ss = av.startSeq; - int es = av.endSeq; + ViewportRanges ranges = av.getRanges(); + int sr = ranges.getStartRes(); + int er = ranges.getEndRes(); + int ss = ranges.getStartSeq(); + int es = ranges.getEndSeq(); int transX = 0; int transY = 0; @@ -298,22 +302,22 @@ public class SeqCanvas extends JComponent { ss = es - vertical; - if (ss < av.startSeq) + if (ss < ranges.getStartSeq()) { // ie scrolling too fast, more than a page at a time - ss = av.startSeq; + ss = ranges.getStartSeq(); } else { - transY = imgHeight - (vertical * charHeight); + transY = imgHeight - ((vertical + 1) * charHeight); } } else if (vertical < 0) { es = ss - vertical; - if (es > av.endSeq) + if (es > ranges.getEndSeq()) { - es = av.endSeq; + es = ranges.getEndSeq(); } } @@ -335,6 +339,7 @@ public class SeqCanvas extends JComponent */ // Set this to false to force a full panel paint + @Override public void paintComponent(Graphics g) { updateViewport(); @@ -392,13 +397,15 @@ public class SeqCanvas extends JComponent gg.setColor(Color.white); gg.fillRect(0, 0, imgWidth, imgHeight); + ViewportRanges ranges = av.getRanges(); if (av.getWrapAlignment()) { - drawWrappedPanel(gg, getWidth(), getHeight(), av.startRes); + drawWrappedPanel(gg, getWidth(), getHeight(), ranges.getStartRes()); } else { - drawPanel(gg, av.startRes, av.endRes, av.startSeq, av.endSeq, 0); + drawPanel(gg, ranges.getStartRes(), ranges.getEndRes(), + ranges.getStartSeq(), ranges.getEndSeq(), 0); } g.drawImage(lcimg, 0, 0, this); @@ -500,7 +507,7 @@ public class SeqCanvas extends JComponent av.setWrappedWidth(cWidth); - av.endRes = av.startRes + cWidth; + av.getRanges().setEndRes(av.getRanges().getStartRes() + cWidth); int endx; int ypos = hgap; @@ -682,10 +689,17 @@ public class SeqCanvas extends JComponent g1.translate(-screenY * charWidth, 0); screenY += blockEnd - blockStart + 1; blockStart = hideEnd + 1; + + if (screenY > (endRes - startRes)) + { + // already rendered last block + return; + } } if (screenY <= (endRes - startRes)) { + // remaining visible region to render blockEnd = blockStart + (endRes - startRes) - screenY; g1.translate(screenY * charWidth, 0); draw(g1, blockStart, blockEnd, startSeq, endSeq, offset); @@ -708,7 +722,7 @@ public class SeqCanvas extends JComponent // / First draw the sequences // /////////////////////////// - for (int i = startSeq; i < endSeq; i++) + for (int i = startSeq; i <= endSeq; i++) { nextSeq = av.getAlignment().getSequenceAt(i); if (nextSeq == null) @@ -722,16 +736,17 @@ public class SeqCanvas extends JComponent if (av.isShowSequenceFeatures()) { - fr.drawSequence(g, nextSeq, startRes, endRes, offset + fr.drawSequence(g, nextSeq, startRes, + endRes, offset + ((i - startSeq) * charHeight)); } // / 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) @@ -792,7 +807,7 @@ public class SeqCanvas extends JComponent int top = -1; int bottom = -1; - for (i = startSeq; i < endSeq; i++) + for (i = startSeq; i <= endSeq; i++) { sx = (group.getStartRes() - startRes) * charWidth; sy = offset + ((i - startSeq) * charHeight); @@ -953,11 +968,11 @@ public class SeqCanvas extends JComponent * @param results * DOCUMENT ME! */ - public void highlightSearchResults(SearchResults results) + public void highlightSearchResults(SearchResultsI results) { img = null; - searchResults = results; + av.setSearchResults(results); repaint(); }