@BenchmarkMode({Mode.Throughput})
public int benchAdjustForHiddenColumns(HiddenColsAndStartState tstate)
{
- return tstate.h.adjustForHiddenColumns(tstate.visibleColumn);
+ return tstate.h.visibleToAbsoluteColumn(tstate.visibleColumn);
}
@Benchmark
@BenchmarkMode({Mode.Throughput})
public int benchFindColumnPosition(HiddenColsAndStartState tstate)
{
- return tstate.h.findColumnPosition(tstate.visibleColumn);
+ return tstate.h.absoluteToVisibleColumn(tstate.visibleColumn);
}
@Benchmark
if (av.hasHiddenColumns())
{
AlignmentI al = av.getAlignment();
- start = al.getHiddenColumns().findColumnPosition(ostart);
- end = al.getHiddenColumns().findColumnPosition(end);
+ start = al.getHiddenColumns().absoluteToVisibleColumn(ostart);
+ end = al.getHiddenColumns().absoluteToVisibleColumn(end);
if (start == end)
{
if (!scrollToNearest && !al.getHiddenColumns().isVisible(ostart))
if (av.hasHiddenColumns())
{
width = av.getAlignment().getHiddenColumns()
- .findColumnPosition(width);
+ .absoluteToVisibleColumn(width);
}
if (x < 0)
{
if (av.hasHiddenColumns())
{
column = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(column);
+ .visibleToAbsoluteColumn(column);
}
if (row > -1 && column < aa[row].annotations.length
if (av.hasHiddenColumns())
{
maxwidth = av.getAlignment().getHiddenColumns()
- .findColumnPosition(maxwidth) - 1;
+ .absoluteToVisibleColumn(maxwidth) - 1;
}
int annotationHeight = 0;
if (av.hasHiddenColumns())
{
- res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(x);
+ res = av.getAlignment().getHiddenColumns().visibleToAbsoluteColumn(x);
}
else
{
if (av.hasHiddenColumns())
{
res = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(res);
+ .visibleToAbsoluteColumn(res);
}
if (!stretchingGroup)
int res = (evt.getX() / av.getCharWidth())
+ av.getRanges().getStartRes();
res = Math.max(0, res);
- res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(res);
+ res = av.getAlignment().getHiddenColumns().visibleToAbsoluteColumn(res);
res = Math.min(res, av.getAlignment().getWidth() - 1);
min = Math.min(res, min);
max = Math.max(res, max);
{
if (hidden.isVisible(sel))
{
- sel = hidden.findColumnPosition(sel);
+ sel = hidden.absoluteToVisibleColumn(sel);
}
else
{
if (av.hasHiddenColumns())
{
startx = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(startx);
+ .visibleToAbsoluteColumn(startx);
endx = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(endx);
+ .visibleToAbsoluteColumn(endx);
}
int maxwidth = av.getAlignment().getWidth();
if (av.hasHiddenColumns())
{
maxwidth = av.getAlignment().getHiddenColumns()
- .findColumnPosition(maxwidth) - 1;
+ .absoluteToVisibleColumn(maxwidth) - 1;
}
// WEST SCALE
if (av.hasHiddenColumns())
{
endx = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(endx);
+ .visibleToAbsoluteColumn(endx);
}
SequenceI seq;
if (av.hasHiddenColumns())
{
maxwidth = av.getAlignment().getHiddenColumns()
- .findColumnPosition(maxwidth);
+ .absoluteToVisibleColumn(maxwidth);
}
while ((ypos <= canvasHeight) && (startRes < maxwidth))
if (av.hasHiddenColumns())
{
res = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(res);
+ .visibleToAbsoluteColumn(res);
}
return res;
* int column index in alignment view (count from zero)
* @return alignment column index for column
*/
- public int adjustForHiddenColumns(int column)
+ public int visibleToAbsoluteColumn(int column)
{
try
{
* the column index in the full alignment including hidden columns
* @return the position of the column in the visible alignment
*/
- public int findColumnPosition(int hiddenColumn)
+ public int absoluteToVisibleColumn(int hiddenColumn)
{
try
{
int distance = visibleDistance;
// in case startColumn is in a hidden region, move it to the left
- int start = adjustForHiddenColumns(findColumnPosition(startColumn));
+ int start = visibleToAbsoluteColumn(absoluteToVisibleColumn(startColumn));
Iterator<int[]> it = new ReverseRegionsIterator(0, start,
hiddenColumns);
if (foundStart)
{
- return findColumnPosition(start);
+ return absoluteToVisibleColumn(start);
}
// otherwise, sequence was completely hidden
return visPrev;
try
{
LOCK.readLock().lock();
- int adjres = adjustForHiddenColumns(res);
+ int adjres = visibleToAbsoluteColumn(res);
int[] reveal = null;
LOCK.readLock().lock();
// get absolute position of column in alignment
- int absoluteStart = adjustForHiddenColumns(start);
+ int absoluteStart = visibleToAbsoluteColumn(start);
// Get cursor position and supply it to the iterator:
// Since we want visible region start, we look for a cursor for the
int adjend = end;
if (useVisibleCoords)
{
- adjstart = adjustForHiddenColumns(start);
- adjend = adjustForHiddenColumns(end);
+ adjstart = visibleToAbsoluteColumn(start);
+ adjend = visibleToAbsoluteColumn(end);
}
try
if (av.hasHiddenColumns())
{
HiddenColumns hidden = av.getAlignment().getHiddenColumns();
- start = hidden.findColumnPosition(start);
- end = hidden.findColumnPosition(end);
+ start = hidden.absoluteToVisibleColumn(start);
+ end = hidden.absoluteToVisibleColumn(end);
if (start == end)
{
if (!hidden.isVisible(r[0]))
{
// reset the width to exclude hidden columns
width = av.getAlignment().getHiddenColumns()
- .findColumnPosition(width);
+ .absoluteToVisibleColumn(width);
}
hextent = getSeqPanel().seqCanvas.getWidth() / av.getCharWidth();
if (av.hasHiddenColumns())
{
maxwidth = av.getAlignment().getHiddenColumns()
- .findColumnPosition(maxwidth) - 1;
+ .absoluteToVisibleColumn(maxwidth) - 1;
}
int resWidth = getSeqPanel().seqCanvas
if (av.hasHiddenColumns())
{
maxwidth = av.getAlignment().getHiddenColumns()
- .findColumnPosition(maxwidth);
+ .absoluteToVisibleColumn(maxwidth);
}
int height = ((av.getAlignment().getHeight() + 1) * av.getCharHeight())
if (av.hasHiddenColumns())
{
maxwidth = av.getAlignment().getHiddenColumns()
- .findColumnPosition(maxwidth) - 1;
+ .absoluteToVisibleColumn(maxwidth) - 1;
}
int height = ((maxwidth / chunkWidth) + 1) * cHeight;
if (av.hasHiddenColumns())
{
column = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(column);
+ .visibleToAbsoluteColumn(column);
}
AlignmentAnnotation ann = aa[row];
if (av.hasHiddenColumns())
{
maxwidth = av.getAlignment().getHiddenColumns()
- .findColumnPosition(maxwidth) - 1;
+ .absoluteToVisibleColumn(maxwidth) - 1;
}
int annotationHeight = 0;
if (av.hasHiddenColumns())
{
- x = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(x);
+ x = av.getAlignment().getHiddenColumns().visibleToAbsoluteColumn(x);
}
if (x >= av.getAlignment().getWidth())
if (av.hasHiddenColumns())
{
res = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(res);
+ .visibleToAbsoluteColumn(res);
}
if (res >= av.getAlignment().getWidth())
int res = (evt.getX() / av.getCharWidth())
+ av.getRanges().getStartRes();
res = Math.max(0, res);
- res = hidden.adjustForHiddenColumns(res);
+ res = hidden.visibleToAbsoluteColumn(res);
res = Math.min(res, av.getAlignment().getWidth() - 1);
min = Math.min(res, min);
max = Math.max(res, max);
reveal = av.getAlignment().getHiddenColumns()
.getRegionWithEdgeAtRes(res);
- res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(res);
+ res = av.getAlignment().getHiddenColumns().visibleToAbsoluteColumn(res);
ToolTipManager.sharedInstance().registerComponent(this);
this.setToolTipText(
{
if (hidden.isVisible(sel))
{
- sel = hidden.findColumnPosition(sel);
+ sel = hidden.absoluteToVisibleColumn(sel);
}
else
{
if (av.hasHiddenColumns())
{
HiddenColumns hiddenColumns = av.getAlignment().getHiddenColumns();
- startX = hiddenColumns.adjustForHiddenColumns(startx);
- endX = hiddenColumns.adjustForHiddenColumns(endx);
+ startX = hiddenColumns.visibleToAbsoluteColumn(startx);
+ endX = hiddenColumns.visibleToAbsoluteColumn(endx);
}
FontMetrics fm = getFontMetrics(av.getFont());
if (av.hasHiddenColumns())
{
maxwidth = av.getAlignment().getHiddenColumns()
- .findColumnPosition(maxwidth);
+ .absoluteToVisibleColumn(maxwidth);
}
// chop the wrapped alignment extent up into panel-sized blocks and treat
// convert the cursorX into a position on the visible alignment
int cursor_xpos = av.getAlignment().getHiddenColumns()
- .findColumnPosition(cursorX);
+ .absoluteToVisibleColumn(cursorX);
if (av.getAlignment().getHiddenColumns().isVisible(cursorX))
{
if (av.hasHiddenColumns())
{
firstVisibleColumn = alignment.getHiddenColumns()
- .adjustForHiddenColumns(firstVisibleColumn);
+ .visibleToAbsoluteColumn(firstVisibleColumn);
lastVisibleColumn = alignment.getHiddenColumns()
- .adjustForHiddenColumns(lastVisibleColumn);
+ .visibleToAbsoluteColumn(lastVisibleColumn);
}
for (int seqNo = ranges.getStartSeq(); seqNo <= ranges
if (av.hasHiddenColumns())
{
firstCol = alignment.getHiddenColumns()
- .findColumnPosition(firstCol);
- lastCol = alignment.getHiddenColumns().findColumnPosition(lastCol);
+ .absoluteToVisibleColumn(firstCol);
+ lastCol = alignment.getHiddenColumns().absoluteToVisibleColumn(lastCol);
}
int transX = (firstCol - ranges.getStartRes()) * av.getCharWidth();
int transY = (firstSeq - ranges.getStartSeq()) * av.getCharHeight();
if (av.hasHiddenColumns())
{
firstVisibleColumn = alignment.getHiddenColumns()
- .adjustForHiddenColumns(firstVisibleColumn);
+ .visibleToAbsoluteColumn(firstVisibleColumn);
lastVisibleColumn = alignment.getHiddenColumns()
- .adjustForHiddenColumns(lastVisibleColumn);
+ .visibleToAbsoluteColumn(lastVisibleColumn);
}
int gapHeight = charHeight * (av.getScaleAboveWrapped() ? 2 : 1);
if (av.hasHiddenColumns())
{
displayColumn = alignment.getHiddenColumns()
- .findColumnPosition(displayColumn);
+ .absoluteToVisibleColumn(displayColumn);
}
/*
if (av.hasHiddenColumns())
{
res = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(res);
+ .visibleToAbsoluteColumn(res);
}
return res;
if (!hidden.isVisible(seqCanvas.cursorX))
{
- int visx = hidden.findColumnPosition(seqCanvas.cursorX - dx);
+ int visx = hidden.absoluteToVisibleColumn(seqCanvas.cursorX - dx);
int[] region = hidden.getRegionWithEdgeAtRes(visx);
if (region != null) // just in case
{
if (hasHiddenColumns)
{
- column = hiddenColumns.adjustForHiddenColumns(startRes + x);
+ column = hiddenColumns.visibleToAbsoluteColumn(startRes + x);
if (column > row_annotations.length - 1)
{
break;
column = sRes + x;
if (hasHiddenColumns)
{
- column = hiddenColumns.adjustForHiddenColumns(column);
+ column = hiddenColumns.visibleToAbsoluteColumn(column);
}
if (column > aaMax)
column = sRes + x;
if (hasHiddenColumns)
{
- column = hiddenColumns.adjustForHiddenColumns(column);
+ column = hiddenColumns.visibleToAbsoluteColumn(column);
}
if (column > aaMax)
if (refSeq == null)
{
iadj = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(i - 1) + 1;
+ .visibleToAbsoluteColumn(i - 1) + 1;
string = String.valueOf(iadj);
}
else
{
iadj = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(i - 1);
+ .visibleToAbsoluteColumn(i - 1);
refN = refSeq.findPosition(iadj);
// TODO show bounds if position is a gap
// - ie L--R -> "1L|2R" for
{
if (start == 0)
{
- start = hidden.adjustForHiddenColumns(start);
+ start = hidden.visibleToAbsoluteColumn(start);
}
end = hidden.getHiddenBoundaryRight(start);
if (hidden != null && hidden.hasHiddenColumns())
{
- start = hidden.adjustForHiddenColumns(end);
+ start = hidden.visibleToAbsoluteColumn(end);
start = hidden.getHiddenBoundaryLeft(start) + 1;
}
} while (end < max);
int yAsSeq = getTopYFromCentreY(mousey, hiddenSeqs);
// convert to visible positions
- int visXAsRes = hiddenCols.findColumnPosition(xAsRes);
+ int visXAsRes = hiddenCols.absoluteToVisibleColumn(xAsRes);
yAsSeq = hiddenSeqs.adjustForHiddenSeqs(
hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq));
yAsSeq = Math.max(yAsSeq, 0); // -1 if before first visible sequence
// coords,
// convert back to pixel coords
int vpx = Math.round((float) mousex * alwidth / width);
- int visXAsRes = hiddenCols.findColumnPosition(vpx) + xdiff;
+ int visXAsRes = hiddenCols.absoluteToVisibleColumn(vpx) + xdiff;
int vpy = Math.round((float) mousey * alheight / sequencesHeight);
int visYAsRes = hiddenSeqs.findIndexWithoutHiddenSeqs(vpy) + ydiff;
int vpwidth = ranges.getViewportWidth();
// check in case we went off the edge of the alignment
- int visAlignWidth = hiddenCols.findColumnPosition(alwidth - 1);
+ int visAlignWidth = hiddenCols.absoluteToVisibleColumn(alwidth - 1);
if (visXAsRes + vpwidth - 1 > visAlignWidth)
{
// went past the end of the alignment, adjust backwards
// if last position was before the end of the alignment, need to update
if (ranges.getEndRes() < visAlignWidth)
{
- visXAsRes = hiddenCols.findColumnPosition(hiddenCols
+ visXAsRes = hiddenCols.absoluteToVisibleColumn(hiddenCols
.subtractVisibleColumns(vpwidth - 1, alwidth - 1));
}
else
HiddenColumns hiddenCols)
{
// work with absolute values of startRes and endRes
- int startRes = hiddenCols.adjustForHiddenColumns(ranges.getStartRes());
- int endRes = hiddenCols.adjustForHiddenColumns(ranges.getEndRes());
+ int startRes = hiddenCols.visibleToAbsoluteColumn(ranges.getStartRes());
+ int endRes = hiddenCols.visibleToAbsoluteColumn(ranges.getEndRes());
// work with absolute values of startSeq and endSeq
int startSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.getStartSeq());
int vpx = Math.round((float) x * alwidth / width);
int vpy = Math.round((float) y * alheight / sequencesHeight);
- xdiff = ranges.getStartRes() - hiddenCols.findColumnPosition(vpx);
+ xdiff = ranges.getStartRes() - hiddenCols.absoluteToVisibleColumn(vpx);
ydiff = ranges.getStartSeq()
- hiddenSeqs.findIndexWithoutHiddenSeqs(vpy);
}
}
HiddenColumns hidden = al.getHiddenColumns();
- while (x < hidden.adjustForHiddenColumns(startRes))
+ while (x < hidden.visibleToAbsoluteColumn(startRes))
{
if (!scrollRight(false))
{
break;
}
}
- while (x > hidden.adjustForHiddenColumns(endRes))
+ while (x > hidden.visibleToAbsoluteColumn(endRes))
{
if (!scrollRight(true))
{
boolean changedLocation = false;
// convert the x,y location to visible coordinates
- int visX = al.getHiddenColumns().findColumnPosition(x);
+ int visX = al.getHiddenColumns().absoluteToVisibleColumn(x);
int visY = al.getHiddenSequences().findIndexWithoutHiddenSeqs(y);
// if (vis_x,vis_y) is already visible don't do anything
public void testFindColumnPosition()
{
HiddenColumns cs = new HiddenColumns();
- assertEquals(5, cs.findColumnPosition(5));
+ assertEquals(5, cs.absoluteToVisibleColumn(5));
// hiding column 6 makes no difference
cs.hideColumns(6, 6);
- assertEquals(5, cs.findColumnPosition(5));
+ assertEquals(5, cs.absoluteToVisibleColumn(5));
// hiding column 4 moves column 5 to column 4
cs.hideColumns(4, 4);
- assertEquals(4, cs.findColumnPosition(5));
+ assertEquals(4, cs.absoluteToVisibleColumn(5));
// hiding column 4 moves column 4 to position 3
- assertEquals(3, cs.findColumnPosition(4));
+ assertEquals(3, cs.absoluteToVisibleColumn(4));
// hiding columns 1 and 2 moves column 5 to column 2
cs.hideColumns(1, 2);
- assertEquals(2, cs.findColumnPosition(5));
+ assertEquals(2, cs.absoluteToVisibleColumn(5));
// check with > 1 hidden column regions
// where some columns are in the hidden regions
cs2.hideColumns(40, 44);
// hiding columns 5-10 and 20-27 moves column 8 to column 4
- assertEquals(4, cs2.findColumnPosition(8));
+ assertEquals(4, cs2.absoluteToVisibleColumn(8));
// and moves column 24 to 13
- assertEquals(13, cs2.findColumnPosition(24));
+ assertEquals(13, cs2.absoluteToVisibleColumn(24));
// and moves column 28 to 14
- assertEquals(14, cs2.findColumnPosition(28));
+ assertEquals(14, cs2.absoluteToVisibleColumn(28));
// and moves column 40 to 25
- assertEquals(25, cs2.findColumnPosition(40));
+ assertEquals(25, cs2.absoluteToVisibleColumn(40));
// check when hidden columns start at 0 that the visible column
// is returned as 0
HiddenColumns cs3 = new HiddenColumns();
cs3.hideColumns(0, 4);
- assertEquals(0, cs3.findColumnPosition(2));
+ assertEquals(0, cs3.absoluteToVisibleColumn(2));
// check that column after the last hidden region doesn't crash
- assertEquals(46, cs2.findColumnPosition(65));
+ assertEquals(46, cs2.absoluteToVisibleColumn(65));
}
@Test(groups = { "Functional" })
HiddenColumns cs = new HiddenColumns();
cs.hideInsertionsFor(al.getSequenceAt(0));
assertEquals("G", ""
- + al.getSequenceAt(0).getCharAt(cs.adjustForHiddenColumns(9)));
+ + al.getSequenceAt(0).getCharAt(cs.visibleToAbsoluteColumn(9)));
// KM: no idea what this is meant to be testing... seems to be an unfinished
// test
cs.hideMarkedBits(one);
assertEquals(2, cs.getNumberOfRegions());
- assertEquals(0, cs.adjustForHiddenColumns(0));
- assertEquals(2, cs.adjustForHiddenColumns(1));
- assertEquals(4, cs.adjustForHiddenColumns(2));
+ assertEquals(0, cs.visibleToAbsoluteColumn(0));
+ assertEquals(2, cs.visibleToAbsoluteColumn(1));
+ assertEquals(4, cs.visibleToAbsoluteColumn(2));
// one again
one.clear(1);
assertEquals(1, cs.getNumberOfRegions());
- assertEquals(0, cs.adjustForHiddenColumns(0));
- assertEquals(1, cs.adjustForHiddenColumns(1));
- assertEquals(2, cs.adjustForHiddenColumns(2));
- assertEquals(4, cs.adjustForHiddenColumns(3));
+ assertEquals(0, cs.visibleToAbsoluteColumn(0));
+ assertEquals(1, cs.visibleToAbsoluteColumn(1));
+ assertEquals(2, cs.visibleToAbsoluteColumn(2));
+ assertEquals(4, cs.visibleToAbsoluteColumn(3));
}
@Test(groups = { "Functional" })
{
HiddenColumns h = new HiddenColumns();
// returns input value when there are no hidden columns
- assertEquals(10, h.adjustForHiddenColumns(10));
+ assertEquals(10, h.visibleToAbsoluteColumn(10));
h.hideColumns(20, 30);
- assertEquals(10, h.adjustForHiddenColumns(10));
- assertEquals(20 + 11, h.adjustForHiddenColumns(20));
- assertEquals(35 + 11, h.adjustForHiddenColumns(35));
+ assertEquals(10, h.visibleToAbsoluteColumn(10));
+ assertEquals(20 + 11, h.visibleToAbsoluteColumn(20));
+ assertEquals(35 + 11, h.visibleToAbsoluteColumn(35));
h.hideColumns(5, 7);
- assertEquals(10 + 3, h.adjustForHiddenColumns(10));
- assertEquals(20 + 14, h.adjustForHiddenColumns(20));
- assertEquals(35 + 14, h.adjustForHiddenColumns(35));
+ assertEquals(10 + 3, h.visibleToAbsoluteColumn(10));
+ assertEquals(20 + 14, h.visibleToAbsoluteColumn(20));
+ assertEquals(35 + 14, h.visibleToAbsoluteColumn(35));
ColumnSelection sel = new ColumnSelection();
h.revealAllHiddenColumns(sel);
h.hideColumns(0, 1);
- assertEquals(4, h.adjustForHiddenColumns(2));
+ assertEquals(4, h.visibleToAbsoluteColumn(2));
}
@Test(groups = "Functional")