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 jalview.viewmodel.ViewportRanges;
import java.awt.Color;
import java.awt.FontMetrics;
AlignViewport av;
- SearchResults searchResults = null;
-
boolean fastPaint = false;
int cursorX = 0;
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);
+ }
}
}
return;
}
+ ViewportRanges ranges = av.getRanges();
+
updateViewport();
// 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 != ranges.getStartRes())
{
- horizontal = av.startRes - lastsr;
+ horizontal = ranges.getStartRes() - lastsr;
}
- lastsr = av.startRes;
+ lastsr = ranges.getStartRes();
fastPaint = true;
gg.copyArea(horizontal * avcharWidth, vertical * avcharHeight, imgWidth
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 = ranges.getStartRes(), er = ranges.getEndRes(), ss = ranges
+ .getStartSeq(), es = ranges
+ .getEndSeq(), transX = 0, transY = 0;
if (horizontal > 0) // scrollbar pulled right, image to the left
{
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 < ranges.getStartSeq()) // ie scrolling too fast, more than a page
+ // at a
+ // time
{
- ss = av.startSeq;
+ ss = ranges.getStartSeq();
}
else
{
- transY = imgHeight - vertical * avcharHeight;
+ transY = imgHeight - ((vertical + 1) * avcharHeight);
}
}
else if (vertical < 0)
{
es = ss - vertical;
- if (es > av.endSeq)
+ if (es > ranges.getEndSeq())
{
- es = av.endSeq;
+ es = ranges.getEndSeq();
}
}
* at 0). NOTE 1: The av limits are set in setFont in this class and in the
* adjustment listener in SeqPanel when the scrollbars move.
*/
+ @Override
public void update(Graphics g)
{
paint(g);
gg.setColor(Color.white);
gg.fillRect(0, 0, imgWidth, imgHeight);
+ ViewportRanges ranges = av.getRanges();
+
if (av.getWrapAlignment())
{
- drawWrappedPanel(gg, imgWidth, imgHeight, av.startRes);
+ drawWrappedPanel(gg, imgWidth, imgHeight, 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(img, 0, 0, this);
av.setWrappedWidth(cWidth);
- av.endRes = av.startRes + cWidth;
+ av.getRanges().setEndRes(av.getRanges().getStartRes() + cWidth);
int endx;
int ypos = hgap;
continue;
}
- gg.fillPolygon(new int[]
- { res * avcharWidth - avcharHeight / 4,
+ gg.fillPolygon(new int[] { res * avcharWidth - avcharHeight / 4,
res * avcharWidth + avcharHeight / 4, res * avcharWidth },
- new int[]
- { ypos - (avcharHeight / 2), ypos - (avcharHeight / 2),
+ new int[] { ypos - (avcharHeight / 2),
+ ypos - (avcharHeight / 2),
ypos - (avcharHeight / 2) + 8 }, 3);
}
g.setClip(0, 0, cWidth * avcharWidth, canvasHeight);
}
- drawPanel(g, startRes, endx, 0, al.getHeight(), ypos);
+ drawPanel(g, startRes, endx, 0, al.getHeight() - 1, ypos);
g.setClip(null);
if (av.isShowAnnotation())
}
private void drawPanel(Graphics g1, int startRes, int endRes,
- int startSeq,
- int endSeq, int offset)
+ int startSeq, int endSeq, int offset)
{
-
if (!av.hasHiddenColumns())
{
draw(g1, startRes, endRes, startSeq, endSeq, offset);
g1.setColor(Color.blue);
g1.drawLine((blockEnd - blockStart + 1) * avcharWidth - 1,
0 + offset, (blockEnd - blockStart + 1) * avcharWidth
- - 1, (endSeq - startSeq) * avcharHeight
+ - 1, (endSeq - startSeq + 1) * avcharHeight
+ offset);
}
g1.translate(-screenY * avcharWidth, 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 * avcharWidth, 0);
draw(g1, blockStart, blockEnd, startSeq, endSeq, offset);
// / First draw the sequences
// ///////////////////////////
- for (int i = startSeq; i < endSeq; i++)
+ for (int i = startSeq; i <= endSeq; i++)
{
nextSeq = av.getAlignment().getSequenceAt(i);
if (av.isShowSequenceFeatures())
{
fr.drawSequence(g, nextSeq, startRes, endRes, offset
- + ((i - startSeq) * avcharHeight));
+ + ((i - startSeq) * avcharHeight), false);
}
// / 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)
{
int bottom = -1;
int alHeight = av.getAlignment().getHeight() - 1;
- for (i = startSeq; i < endSeq; i++)
+ for (i = startSeq; i <= endSeq; i++)
{
sx = (group.getStartRes() - startRes) * avcharWidth;
sy = offset + ((i - startSeq) * avcharHeight);
break;
}
- group = av.getAlignment().getGroups()
- .get(groupIndex);
+ group = av.getAlignment().getGroups().get(groupIndex);
} while (groupIndex < av.getAlignment().getGroups().size());
}
}
- public void highlightSearchResults(SearchResults results)
+ public void highlightSearchResults(SearchResultsI results)
{
- searchResults = results;
-
+ av.setSearchResults(results);
repaint();
}