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;
AlignViewport av;
- SearchResults searchResults = null;
-
boolean fastPaint = false;
int LABEL_WEST;
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);
+ }
}
}
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;
{
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();
}
}
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);
av.setWrappedWidth(cWidth);
- av.endRes = av.startRes + cWidth;
+ av.getRanges().setEndRes(av.getRanges().getStartRes() + cWidth);
int endx;
int ypos = hgap;
(int) clip.getBounds().getHeight());
}
- drawPanel(g, startRes, endx, 0, al.getHeight(), ypos);
+ drawPanel(g, startRes, endx, 0, al.getHeight() - 1, ypos);
if (av.isShowAnnotation())
{
g1.drawLine((blockEnd - blockStart + 1) * charWidth - 1,
0 + offset, (blockEnd - blockStart + 1) * charWidth - 1,
- (endSeq - startSeq) * charHeight + offset);
+ (endSeq - startSeq + 1) * charHeight + offset);
}
g1.translate(-screenY * charWidth, 0);
// / 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)
if (av.isShowSequenceFeatures())
{
fr.drawSequence(g, nextSeq, startRes, endRes, offset
- + ((i - startSeq) * charHeight));
+ + ((i - startSeq) * charHeight), false);
}
// / 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)
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);
* @param results
* DOCUMENT ME!
*/
- public void highlightSearchResults(SearchResults results)
+ public void highlightSearchResults(SearchResultsI results)
{
img = null;
- searchResults = results;
+ av.setSearchResults(results);
repaint();
}