{
this.viewName = viewName;
}
+
+ /**
+ * Answers the absolute column position (0..) (allowing for any hidden
+ * columns) for the given x position in the viewport. The position is
+ * restricted to the currently visible range, and to the width of the
+ * alignment. This method is not applicable, and throws an exception if
+ * called, if the view is in wrapped mode.<br>
+ * Example
+ * <ul>
+ * <li>alignment width 157 (uniref50.fa example)</li>
+ * <li>panel width 70</li>
+ * <li>columns 0-59 and 69-119 hidden (111 columns)</li>
+ * <li>leaves 56 columns visible, hidden columns left of and within the
+ * alignment</li>
+ * <li>getAbsoluteColumn(0) answers 60 (first visible column)</li>
+ * <li>getAbsoluteColumn(-20) answers 60</li>
+ * <li>getAbsoluteColumn(8*charWidth) answers 68 (just before hidden column
+ * marker)</li>
+ * <li>getAbsoluteColumn(9*charWidth) answers 120 (just after hidden column
+ * marker)</li>
+ * <li>getAbsoluteColumn(123456) answers 156 (last column of alignment)</li>
+ * </ul>
+ *
+ * @param xPos
+ * @return
+ * @throw IllegalStateException
+ */
+ public int getAbsoluteColumn(int xPos)
+ {
+ if (getWrapAlignment())
+ {
+ throw new IllegalStateException("Not valid in wrapped mode");
+ }
+ int xCords = Math.max(0, xPos); // treat negative X as zero
+ int res = (xCords / getCharWidth()) + ranges.getStartRes();
+ res = Math.min(res, ranges.getEndRes());
+ if (hasHiddenColumns())
+ {
+ res = getAlignment().getHiddenColumns().visibleToAbsoluteColumn(res);
+ }
+ res = Math.max(0, res);
+ return res;
+ }
}
mouseDragging = false;
ap.getSeqPanel().stopScrolling();
- int xCords = Math.max(0, evt.getX()); // prevent negative X coordinates
- ViewportRanges ranges = av.getRanges();
- int res = (xCords / av.getCharWidth())
- + ranges.getStartRes();
- res = Math.min(res, ranges.getEndRes());
- if (av.hasHiddenColumns())
- {
- res = av.getAlignment().getHiddenColumns()
- .visibleToAbsoluteColumn(res);
- }
- res = Math.max(0, res);
+ int xPos = evt.getX();
+ int res = av.getAbsoluteColumn(xPos);
if (!stretchingGroup)
{