X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FSeqCanvas.java;h=fd74c4a459cfea6a961849aa51f64f761d18a0c0;hb=d559b47886de6427219011e6e355320a0babd757;hp=024fdc7f8b9fb07a7b60409d6dc8b447326bb4dd;hpb=8e828522d5642db3c70c0909e0b44244f9ec2605;p=jalview.git diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index 024fdc7..fd74c4a 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -21,9 +21,11 @@ package jalview.appletgui; 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.AlignmentViewport; import java.awt.Color; @@ -48,8 +50,6 @@ public class SeqCanvas extends Panel AlignViewport av; - SearchResults searchResults = null; - boolean fastPaint = false; int cursorX = 0; @@ -90,26 +90,29 @@ public class SeqCanvas extends Panel private void drawNorthScale(Graphics g, int startx, int endx, int ypos) { - int scalestartx = startx - startx % 10 + 10; - + updateViewport(); 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) * avcharWidth, - ypos - (avcharHeight / 2)); - - g.drawLine(((i - startx - 1) * avcharWidth) + (avcharWidth / 2), - (ypos + 2) - (avcharHeight / 2), - ((i - startx - 1) * avcharWidth) + (avcharWidth / 2), - ypos - 2); + if (mark.major) + { + if (mstring != null) + { + g.drawString(mstring, mpos * avcharWidth, ypos + - (avcharHeight / 2)); + } + g.drawLine((mpos * avcharWidth) + (avcharWidth / 2), (ypos + 2) + - (avcharHeight / 2), (mpos * avcharWidth) + + (avcharWidth / 2), ypos - 2); + } } } @@ -213,12 +216,12 @@ public class SeqCanvas extends Panel // Its possible on certain browsers that the call to fastpaint // is faster than it can paint, so this check here catches // this possibility - if (lastsr + horizontal != av.startRes) + if (lastsr + horizontal != av.getStartRes()) { - horizontal = av.startRes - lastsr; + horizontal = av.getStartRes() - lastsr; } - lastsr = av.startRes; + lastsr = av.getStartRes(); fastPaint = true; gg.copyArea(horizontal * avcharWidth, vertical * avcharHeight, imgWidth @@ -226,7 +229,8 @@ public class SeqCanvas extends Panel imgHeight - vertical * avcharHeight, -horizontal * avcharWidth, -vertical * avcharHeight); - int sr = av.startRes, er = av.endRes, ss = av.startSeq, es = av.endSeq, transX = 0, transY = 0; + int sr = av.getStartRes(), er = av.getEndRes(), ss = av.getStartSeq(), es = av + .getEndSeq(), transX = 0, transY = 0; if (horizontal > 0) // scrollbar pulled right, image to the left { @@ -241,9 +245,10 @@ public class SeqCanvas extends Panel else if (vertical > 0) // scroll down { ss = es - vertical; - if (ss < av.startSeq) // ie scrolling too fast, more than a page at a time + if (ss < av.getStartSeq()) // ie scrolling too fast, more than a page at a + // time { - ss = av.startSeq; + ss = av.getStartSeq(); } else { @@ -253,9 +258,9 @@ public class SeqCanvas extends Panel else if (vertical < 0) { es = ss - vertical; - if (es > av.endSeq) + if (es > av.getEndSeq()) { - es = av.endSeq; + es = av.getEndSeq(); } } @@ -328,11 +333,12 @@ public class SeqCanvas extends Panel if (av.getWrapAlignment()) { - drawWrappedPanel(gg, imgWidth, imgHeight, av.startRes); + drawWrappedPanel(gg, imgWidth, imgHeight, av.getStartRes()); } else { - drawPanel(gg, av.startRes, av.endRes, av.startSeq, av.endSeq, 0); + drawPanel(gg, av.getStartRes(), av.getEndRes(), av.getStartSeq(), + av.getEndSeq(), 0); } g.drawImage(img, 0, 0, this); @@ -418,7 +424,7 @@ public class SeqCanvas extends Panel av.setWrappedWidth(cWidth); - av.endRes = av.startRes + cWidth; + av.setEndRes(av.getStartRes() + cWidth); int endx; int ypos = hgap; @@ -627,9 +633,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) { @@ -838,10 +845,9 @@ public class SeqCanvas extends Panel } } - public void highlightSearchResults(SearchResults results) + public void highlightSearchResults(SearchResultsI results) { - searchResults = results; - + av.setSearchResults(results); repaint(); }