}\r
\r
/**\r
- * Use this method to find out where a visible column is in the alignment when\r
- * hidden columns exist\r
+ * Use this method to find out where a column will appear in the visible alignment when\r
+ * hidden columns exist. If the column is not visible, then the left-most visible column will always be returned.\r
* \r
* @param hiddenColumn\r
* int\r
if (hiddenColumns != null)\r
{\r
int index = 0;\r
- int gaps = 0;\r
+ int[] region;\r
do\r
{\r
- int[] region = (int[]) hiddenColumns.elementAt(index);\r
+ region = (int[]) hiddenColumns.elementAt(index++);\r
if (hiddenColumn > region[1])\r
{\r
result -= region[1] + 1 - region[0];\r
}\r
- index++;\r
- } while (index < hiddenColumns.size());\r
-\r
- result -= gaps;\r
+ } while ((hiddenColumn > region[1]) && (index < hiddenColumns.size()));\r
+ if (hiddenColumn>region[0] && hiddenColumn<region[1])\r
+ {\r
+ return region[0]+hiddenColumn-result;\r
+ }\r
}\r
-\r
- return result;\r
+ return result; // return the shifted position after removing hidden columns.\r
}\r
\r
/**\r
if (av.hasHiddenColumns)
{
- res = av.getColumnSelection().adjustForHiddenColumns(x);
+ x = av.getColumnSelection().adjustForHiddenColumns(x);
}
- else
+
+ if (x >= av.alignment.getWidth())
{
+ res = av.alignment.getWidth() - 1;
+ } else {
res = x;
}
iVec = null;
sg.setStartRes(res);
sg.setEndRes(res);
- av.setSelectionGroup(sg);
if (evt.isShiftDown())
{
sg.setStartRes(min);
sg.setEndRes(max);
}
-
+ av.setSelectionGroup(sg);
}
ap.paintAlignment(false);
int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
- if (res > av.alignment.getWidth())
+ if (av.hasHiddenColumns)
{
- res = av.alignment.getWidth() - 1;
+ res = av.getColumnSelection().adjustForHiddenColumns(res);
}
- if (av.hasHiddenColumns)
+ if (res >= av.alignment.getWidth())
{
- res = av.getColumnSelection().adjustForHiddenColumns(res);
+ res = av.alignment.getWidth() - 1;
}
if (!stretchingGroup)
res = av.getColumnSelection().adjustForHiddenColumns(res);
}
- if (res > av.alignment.getWidth())
+ if (res >= av.alignment.getWidth())
{
res = av.alignment.getWidth() - 1;
}
int col;
for (int i = min; i <= max; i++)
{
- col = av.getColumnSelection().adjustForHiddenColumns(i);
+ col = i; // av.getColumnSelection().adjustForHiddenColumns(i);
if ((col < sg.getStartRes()) || (col > sg.getEndRes()))
{
// Fill the selected columns
ColumnSelection cs = av.getColumnSelection();
+ int s;
if (cs != null)
{
gg.setColor(new Color(220, 0, 0));
int sel = cs.columnAt(i);
if (av.hasHiddenColumns)
{
- sel = cs.findColumnPosition(sel);
+ if (cs.isVisible(sel))
+ {
+ sel = cs.findColumnPosition(sel);
+ }
+ else
+ {
+ continue;
+ }
}
if ((sel >= startx) && (sel <= endx))