hscroll.setValues(x, hextent, 0, width);
vscroll.setValues(y, vextent, 0, height);
+ // AWT scrollbar does not fire adjustmentValueChanged for setValues
+ // so also call adjustment code!
+ adjustHorizontal(x);
+ adjustVertical(y);
+
sendViewPosition();
}
}
@Override
public void adjustmentValueChanged(AdjustmentEvent evt)
{
- int oldX = vpRanges.getStartRes();
- int oldwidth = vpRanges.getViewportWidth();
- int oldY = vpRanges.getStartSeq();
- int oldheight = vpRanges.getViewportHeight();
-
if (evt == null || evt.getSource() == apvscroll)
{
annotationPanel.setScrollOffset(apvscroll.getValue(), false);
alabels.setScrollOffset(apvscroll.getValue(), false);
- // annotationPanel.image=null;
- // alabels.image=null;
- // alabels.repaint();
- // annotationPanel.repaint();
}
if (evt == null || evt.getSource() == hscroll)
{
int x = hscroll.getValue();
- int width = seqPanel.seqCanvas.getWidth() / av.getCharWidth();
+ adjustHorizontal(x);
+ }
+
+ if (evt == null || evt.getSource() == vscroll)
+ {
+ int offy = vscroll.getValue();
+ adjustVertical(offy);
+ }
+
+ }
+
+ private void adjustHorizontal(int x)
+ {
+ int oldX = vpRanges.getStartRes();
+ int oldwidth = vpRanges.getViewportWidth();
+ int width = seqPanel.seqCanvas.getWidth() / av.getCharWidth();
+
+ // if we're scrolling to the position we're already at, stop
+ // this prevents infinite recursion of events when the scroll/viewport
+ // ranges values are the same
+ if ((x == oldX) && (width == oldwidth))
+ {
+ return;
+ }
+ vpRanges.setViewportStartAndWidth(x, width);
+
+ if (av.getWrapAlignment() || !fastPaint || av.MAC)
+ {
+ repaint();
+ }
+ sendViewPosition();
+ }
+
+ private void adjustVertical(int offy)
+ {
+ int oldX = vpRanges.getStartRes();
+ int oldwidth = vpRanges.getViewportWidth();
+ int oldY = vpRanges.getStartSeq();
+ int oldheight = vpRanges.getViewportHeight();
+
+ if (av.getWrapAlignment())
+ {
+ int rowSize = seqPanel.seqCanvas
+ .getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());
// if we're scrolling to the position we're already at, stop
// this prevents infinite recursion of events when the scroll/viewport
// ranges values are the same
- if ((x == oldX) && (width == oldwidth))
+ if ((offy * rowSize == oldX) && (oldwidth == rowSize))
{
return;
}
- vpRanges.setViewportStartAndWidth(x, width);
+ else if (offy > -1)
+ {
+ vpRanges.setViewportStartAndWidth(offy * rowSize, rowSize);
+ }
}
-
- if (evt == null || evt.getSource() == vscroll)
+ else
{
- int offy = vscroll.getValue();
- if (av.getWrapAlignment())
- {
- int rowSize = seqPanel.seqCanvas
- .getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());
+ int height = seqPanel.seqCanvas.getHeight() / av.getCharHeight();
- // if we're scrolling to the position we're already at, stop
- // this prevents infinite recursion of events when the scroll/viewport
- // ranges values are the same
- if ((offy * rowSize == oldX) && (oldwidth == rowSize))
- {
- return;
- }
- else if (offy > -1)
- {
- vpRanges.setViewportStartAndWidth(offy * rowSize, rowSize);
- }
- }
- else
+ // if we're scrolling to the position we're already at, stop
+ // this prevents infinite recursion of events when the scroll/viewport
+ // ranges values are the same
+ if ((offy == oldY) && (height == oldheight))
{
- int height = seqPanel.seqCanvas.getHeight() / av.getCharHeight();
-
- // if we're scrolling to the position we're already at, stop
- // this prevents infinite recursion of events when the scroll/viewport
- // ranges values are the same
- if ((offy == oldY) && (height == oldheight))
- {
- return;
- }
- vpRanges.setViewportStartAndHeight(offy, height);
+ return;
}
+ vpRanges.setViewportStartAndHeight(offy, height);
}
-
- /* if (overviewPanel != null)
- {
- overviewPanel.setBoxPosition();
- }
-
- int scrollX = vpRanges.getStartRes() - oldX;
- int scrollY = vpRanges.getStartSeq() - oldY;
- */
if (av.getWrapAlignment() || !fastPaint || av.MAC)
{
repaint();
}
- /* else
- {
- // Make sure we're not trying to draw a panel
- // larger than the visible window
- if (scrollX > vpRanges.getEndRes() - vpRanges.getStartRes())
- {
- scrollX = vpRanges.getEndRes() - vpRanges.getStartRes();
- }
- else if (scrollX < vpRanges.getStartRes() - vpRanges.getEndRes())
- {
- scrollX = vpRanges.getStartRes() - vpRanges.getEndRes();
- }
-
- idPanel.idCanvas.fastPaint(scrollY);
- seqPanel.seqCanvas.fastPaint(scrollX, scrollY);
-
- scalePanel.repaint();
- if (av.isShowAnnotation())
- {
- annotationPanel.fastPaint(vpRanges.getStartRes() - oldX);
- }
- }*/
sendViewPosition();
-
- /*
- * If there is one, scroll the (Protein/cDNA) complementary alignment to
- * match, unless we are ourselves doing that.
- */
- /* if (isFollowingComplementScroll())
- {
- setFollowingComplementScroll(false);
- }
- else
- {
- AlignmentPanel ap = getComplementPanel();
- av.scrollComplementaryAlignment(ap);
- }*/
-
}
/**