+ /*
+ * Set vertical scroll bar parameters for wrapped panel
+ * @param res
+ * the residue to scroll to
+ */
+ private void setScrollingForWrappedPanel(int res)
+ {
+ // get the width of the alignment in residues
+ int maxwidth = av.getAlignment().getWidth();
+ if (av.hasHiddenColumns())
+ {
+ maxwidth = av.getAlignment().getHiddenColumns()
+ .findColumnPosition(maxwidth) - 1;
+ }
+
+ // get the width of the canvas in residues
+ int canvasWidth = seqPanel.seqCanvas
+ .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
+ if (canvasWidth > 0)
+ {
+ // 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.setUnitIncrement(1);
+ vscroll.setValues(current, 1, 0, max);
+ }
+ }
+