}
fastpainting = true;
fastPaint = true;
- updateViewport();
- ViewportRanges ranges = av.getRanges();
- int startRes = ranges.getStartRes();
- int endRes = ranges.getEndRes();
- int startSeq = ranges.getStartSeq();
- int endSeq = ranges.getEndSeq();
- int transX = 0;
- int transY = 0;
+ try
+ {
+ updateViewport();
- gg.copyArea(horizontal * charWidth, vertical * charHeight, imgWidth,
- imgHeight, -horizontal * charWidth, -vertical * charHeight);
+ ViewportRanges ranges = av.getRanges();
+ int startRes = ranges.getStartRes();
+ int endRes = ranges.getEndRes();
+ int startSeq = ranges.getStartSeq();
+ int endSeq = ranges.getEndSeq();
+ int transX = 0;
+ int transY = 0;
- if (horizontal > 0) // scrollbar pulled right, image to the left
- {
- transX = (endRes - startRes - horizontal) * charWidth;
- startRes = endRes - horizontal;
- }
- else if (horizontal < 0)
- {
- endRes = startRes - horizontal;
- }
- else if (vertical > 0) // scroll down
- {
- startSeq = endSeq - vertical;
+ gg.copyArea(horizontal * charWidth, vertical * charHeight, imgWidth,
+ imgHeight, -horizontal * charWidth, -vertical * charHeight);
- if (startSeq < ranges.getStartSeq())
- { // ie scrolling too fast, more than a page at a time
- startSeq = ranges.getStartSeq();
+ if (horizontal > 0) // scrollbar pulled right, image to the left
+ {
+ transX = (endRes - startRes - horizontal) * charWidth;
+ startRes = endRes - horizontal;
}
- else
+ else if (horizontal < 0)
{
- transY = imgHeight - ((vertical + 1) * charHeight);
+ endRes = startRes - horizontal;
}
- }
- else if (vertical < 0)
- {
- endSeq = startSeq - vertical;
+ else if (vertical > 0) // scroll down
+ {
+ startSeq = endSeq - vertical;
- if (endSeq > ranges.getEndSeq())
+ if (startSeq < ranges.getStartSeq())
+ { // ie scrolling too fast, more than a page at a time
+ startSeq = ranges.getStartSeq();
+ }
+ else
+ {
+ transY = imgHeight - ((vertical + 1) * charHeight);
+ }
+ }
+ else if (vertical < 0)
{
- endSeq = ranges.getEndSeq();
+ endSeq = startSeq - vertical;
+
+ if (endSeq > ranges.getEndSeq())
+ {
+ endSeq = ranges.getEndSeq();
+ }
}
- }
- gg.translate(transX, transY);
- drawPanel(gg, startRes, endRes, startSeq, endSeq, 0);
- gg.translate(-transX, -transY);
+ gg.translate(transX, transY);
+ drawPanel(gg, startRes, endRes, startSeq, endSeq, 0);
+ gg.translate(-transX, -transY);
- repaint();
- fastpainting = false;
+ repaint();
+ } finally
+ {
+ fastpainting = false;
+ }
}
@Override
{
String eventName = evt.getPropertyName();
- // if (av.getWrapAlignment())
- // {
- // if (eventName.equals(ViewportRanges.STARTRES))
- // {
- // repaint();
- // }
- // }
- // else
- {
- int scrollX = 0;
- if (eventName.equals(ViewportRanges.STARTRES))
+ int scrollX = 0;
+ if (eventName.equals(ViewportRanges.STARTRES))
+ {
+ // Make sure we're not trying to draw a panel
+ // larger than the visible window
+ ViewportRanges vpRanges = av.getRanges();
+ scrollX = (int) evt.getNewValue() - (int) evt.getOldValue();
+ int range = vpRanges.getEndRes() - vpRanges.getStartRes();
+ if (scrollX > range)
{
- // Make sure we're not trying to draw a panel
- // larger than the visible window
- ViewportRanges vpRanges = av.getRanges();
- scrollX = (int) evt.getNewValue() - (int) evt.getOldValue();
- int range = vpRanges.getEndRes() - vpRanges.getStartRes();
- if (scrollX > range)
- {
- scrollX = range;
- }
- else if (scrollX < -range)
- {
- scrollX = -range;
- }
+ scrollX = range;
}
+ else if (scrollX < -range)
+ {
+ scrollX = -range;
+ }
+ }
- // Both scrolling and resizing change viewport ranges: scrolling changes
- // both start and end points, but resize only changes end values.
- // Here we only want to fastpaint on a scroll, with resize using a normal
- // paint, so scroll events are identified as changes to the horizontal or
- // vertical start value.
- if (eventName.equals(ViewportRanges.STARTRES))
+ // Both scrolling and resizing change viewport ranges: scrolling changes
+ // both start and end points, but resize only changes end values.
+ // Here we only want to fastpaint on a scroll, with resize using a normal
+ // paint, so scroll events are identified as changes to the horizontal or
+ // vertical start value.
+ if (eventName.equals(ViewportRanges.STARTRES))
+ {
+ // scroll - startres and endres both change
+ if (av.getWrapAlignment())
{
- // scroll - startres and endres both change
- if (av.getWrapAlignment())
- {
- fastPaintWrapped(scrollX);
- // fastPaintWrapped(scrollX > 0 ? 1 : -1); // to debug: 1 at a time
- }
- else
- {
- fastPaint(scrollX, 0);
- }
+ fastPaintWrapped(scrollX);
}
- else if (eventName.equals(ViewportRanges.STARTSEQ))
+ else
{
- fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue());
+ fastPaint(scrollX, 0);
}
}
+ else if (eventName.equals(ViewportRanges.STARTSEQ))
+ {
+ fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue());
+ }
}
/**
{
/*
* shift of more than one view width is
- * too complicated to handle in this method
+ * overcomplicated to handle in this method
*/
fastPaint = false;
repaint();
return;
}
- fastPaint = true;
+ if (fastpainting || gg == null)
+ {
+ return;
+ }
- /*
- * relocate the regions of the alignment that are still visible
- */
- shiftWrappedAlignment(-scrollX);
+ fastPaint = true;
+ fastpainting = true;
- /*
- * add new columns (scale above, sequence, annotation)
- * - at top left if scrollX < 0
- * - at right of last two widths if scrollX > 0
- * also West scale top left or East scale bottom right if shown
- */
- if (scrollX < 0)
+ try
{
- fastPaintWrappedAddLeft(-scrollX);
- }
- else
+ /*
+ * relocate the regions of the alignment that are still visible
+ */
+ shiftWrappedAlignment(-scrollX);
+
+ /*
+ * add new columns (scale above, sequence, annotation)
+ * - at top left if scrollX < 0
+ * - at right of last two widths if scrollX > 0
+ * also West scale top left or East scale bottom right if shown
+ */
+ if (scrollX < 0)
+ {
+ fastPaintWrappedAddLeft(-scrollX);
+ }
+ else
+ {
+ fastPaintWrappedAddRight(scrollX);
+ }
+
+ repaint();
+ } finally
{
- fastPaintWrappedAddRight(scrollX);
+ fastpainting = false;
}
-
- repaint();
}
/**
}
/*
- * limit visible widths to max widths of alignment
+ * limit visible widths to max widths of alignment, from the
+ * current start residue (we may be scrolled down)
*/
ViewportRanges ranges = av.getRanges();
- int visibleAlignmentWidth = ranges.getVisibleAlignmentWidth();
+ int availableAlignmentWidth = ranges.getVisibleAlignmentWidth()
+ - ranges.getStartRes();
int viewportWidth = ranges.getViewportWidth();
- int maxWidths = visibleAlignmentWidth / viewportWidth;
- if (visibleAlignmentWidth % viewportWidth > 0)
+ int maxWidths = availableAlignmentWidth / viewportWidth;
+ if (availableAlignmentWidth % viewportWidth > 0)
{
maxWidths++;
}
visibleWidths = Math.min(visibleWidths, maxWidths);
- int widthInColumns = (getWidth() - labelWidthEast - labelWidthWest)
+ int canvasWidth = getWidth();
+ int widthInColumns = (canvasWidth - labelWidthEast - labelWidthWest)
/ charWidth;
/**
* scrolling right beyond end of alignment
*/
gg.setColor(Color.white);
- int width = getWidth() - labelWidthWest - xOffset;
+ int width = canvasWidth - labelWidthWest - xOffset;
gg.fillRect(labelWidthWest, ypos - hgap, width, repeatHeight);
gg.setFont(av.getFont());
{
drawVerticalScale(gg, leftEndColumn, endRes, ypos, false);
}
+
+ /*
+ * and finally, white fill any space below the visible alignment
+ * (in case it has wrapped to just the top part of the panel)
+ */
+ int heightBelow = canvasHeight - visibleWidths * repeatHeight;
+ if (heightBelow > 0)
+ {
+ gg.setColor(Color.white);
+ gg.fillRect(0, canvasHeight - heightBelow, canvasWidth, heightBelow);
+ }
}
/**
{
visibleWidths++;
}
+ // todo limit visibleWidths to not exceed width of alignment
+ // (don't process white space below)
if (positions > 0)
{