|| res >= (vpRanges.getStartRes() + cwidth))
{
vscroll.setValue((res / cwidth));
- // vpRanges.setStartRes(vscroll.getValue() * cwidth);
}
}
if (av.getWrapAlignment())
{
- setScrollingForWrappedPanel(x, y);
+ setScrollingForWrappedPanel(x);
}
else
{
x = 0;
}
- /*
- * each scroll adjustment triggers adjustmentValueChanged, which resets the
- * 'do not scroll complement' flag; ensure it is the same for both
- * operations
- */
- // boolean flag = isDontScrollComplement();
+ // update the scroll values
hscroll.setValues(x, hextent, 0, width);
- // setDontScrollComplement(flag);
vscroll.setValues(y, vextent, 0, height);
}
}
int offy = vscroll.getValue();
int rowSize = getSeqPanel().seqCanvas
.getWrappedCanvasWidth(getSeqPanel().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 (offy * rowSize == oldX)
{
return;
if (evt.getSource() == hscroll)
{
int x = hscroll.getValue();
+
+ // 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)
{
return;
else if (evt.getSource() == vscroll)
{
int offy = vscroll.getValue();
+
+ // 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)
{
return;
validate();
/*
- * set scroll bar positions; first suppress this being 'followed' in any
- * complementary split pane
+ * set scroll bar positions
*/
-
- // setDontScrollComplement(true);
setScrollValues(vpRanges.getStartRes(), vpRanges.getStartSeq());
}
/*
* Set vertical scroll bar parameters for wrapped panel
+ * @param res
+ * the residue to scroll to
*/
- private void setScrollingForWrappedPanel(int x, int y)
+ private void setScrollingForWrappedPanel(int res)
{
+ // get the width of the alignment in residues
int maxwidth = av.getAlignment().getWidth();
-
if (av.hasHiddenColumns())
{
maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
}
+ // get the width of the canvas in residues
int canvasWidth = getSeqPanel().seqCanvas
.getWrappedCanvasWidth(getSeqPanel().seqCanvas.getWidth());
if (canvasWidth > 0)
{
- int current = x / canvasWidth;
+ // position we want to scroll to is number of canvasWidth's to get there
+ int current = res / canvasWidth;
+
+ // max scroll position: add one because extent is 1 and scrollbar value
+ // can only be set to at most max - extent
int max = maxwidth / canvasWidth + 1;
- vscroll.setMaximum(max);
vscroll.setUnitIncrement(1);
- vscroll.setVisibleAmount(1);
vscroll.setValues(current, 1, 0, max);
}
}
}
@Override
+ /**
+ * Property change event fired when a change is made to the viewport ranges
+ * object associated with this alignment panel's viewport
+ */
public void propertyChange(PropertyChangeEvent evt)
{
+ // update this panel's scroll values based on the new viewport ranges values
int x = vpRanges.getStartRes();
int y = vpRanges.getStartSeq();
setScrollValues(x, y);
+
+ // now update any complementary alignment (its viewport ranges object
+ // is different so does not get automatically updated)
av.scrollComplementaryAlignment();
}
}