From b24a7070977bdbb780ec0a0e218935966af94b65 Mon Sep 17 00:00:00 2001 From: kiramt Date: Mon, 15 Jan 2018 10:38:29 +0000 Subject: [PATCH] JAL-2759 Rename findColumnPosition and adjustForHiddenColumns (yay!) --- .../java/org/jalview/HiddenColumnsBenchmark.java | 4 +- src/jalview/appletgui/AlignmentPanel.java | 6 +-- src/jalview/appletgui/AnnotationPanel.java | 2 +- src/jalview/appletgui/IdCanvas.java | 2 +- src/jalview/appletgui/ScalePanel.java | 8 +-- src/jalview/appletgui/SeqCanvas.java | 10 ++-- src/jalview/appletgui/SeqPanel.java | 2 +- src/jalview/datamodel/HiddenColumns.java | 16 +++--- src/jalview/gui/AlignmentPanel.java | 12 ++--- src/jalview/gui/AnnotationPanel.java | 2 +- src/jalview/gui/IdCanvas.java | 2 +- src/jalview/gui/ScalePanel.java | 10 ++-- src/jalview/gui/SeqCanvas.java | 22 ++++---- src/jalview/gui/SeqPanel.java | 4 +- src/jalview/renderer/AnnotationRenderer.java | 6 +-- src/jalview/renderer/ScaleRenderer.java | 4 +- src/jalview/viewmodel/AlignmentViewport.java | 4 +- .../viewmodel/OverviewDimensionsShowHidden.java | 14 ++--- src/jalview/viewmodel/ViewportRanges.java | 6 +-- test/jalview/datamodel/HiddenColumnsTest.java | 54 ++++++++++---------- 20 files changed, 95 insertions(+), 95 deletions(-) diff --git a/benchmarking/src/main/java/org/jalview/HiddenColumnsBenchmark.java b/benchmarking/src/main/java/org/jalview/HiddenColumnsBenchmark.java index c0b4d4b..07b76f9 100644 --- a/benchmarking/src/main/java/org/jalview/HiddenColumnsBenchmark.java +++ b/benchmarking/src/main/java/org/jalview/HiddenColumnsBenchmark.java @@ -102,14 +102,14 @@ public class HiddenColumnsBenchmark @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 diff --git a/src/jalview/appletgui/AlignmentPanel.java b/src/jalview/appletgui/AlignmentPanel.java index 270b2f7..83d8ade 100644 --- a/src/jalview/appletgui/AlignmentPanel.java +++ b/src/jalview/appletgui/AlignmentPanel.java @@ -421,8 +421,8 @@ public class AlignmentPanel extends Panel 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)) @@ -675,7 +675,7 @@ public class AlignmentPanel extends Panel if (av.hasHiddenColumns()) { width = av.getAlignment().getHiddenColumns() - .findColumnPosition(width); + .absoluteToVisibleColumn(width); } if (x < 0) { diff --git a/src/jalview/appletgui/AnnotationPanel.java b/src/jalview/appletgui/AnnotationPanel.java index 50a9e33..50bc184 100755 --- a/src/jalview/appletgui/AnnotationPanel.java +++ b/src/jalview/appletgui/AnnotationPanel.java @@ -480,7 +480,7 @@ public class AnnotationPanel extends Panel if (av.hasHiddenColumns()) { column = av.getAlignment().getHiddenColumns() - .adjustForHiddenColumns(column); + .visibleToAbsoluteColumn(column); } if (row > -1 && column < aa[row].annotations.length diff --git a/src/jalview/appletgui/IdCanvas.java b/src/jalview/appletgui/IdCanvas.java index f5ea12e..296f898 100755 --- a/src/jalview/appletgui/IdCanvas.java +++ b/src/jalview/appletgui/IdCanvas.java @@ -286,7 +286,7 @@ public class IdCanvas extends Panel implements ViewportListenerI if (av.hasHiddenColumns()) { maxwidth = av.getAlignment().getHiddenColumns() - .findColumnPosition(maxwidth) - 1; + .absoluteToVisibleColumn(maxwidth) - 1; } int annotationHeight = 0; diff --git a/src/jalview/appletgui/ScalePanel.java b/src/jalview/appletgui/ScalePanel.java index 4e44888..d240d86 100755 --- a/src/jalview/appletgui/ScalePanel.java +++ b/src/jalview/appletgui/ScalePanel.java @@ -87,7 +87,7 @@ public class ScalePanel extends Panel if (av.hasHiddenColumns()) { - res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(x); + res = av.getAlignment().getHiddenColumns().visibleToAbsoluteColumn(x); } else { @@ -235,7 +235,7 @@ public class ScalePanel extends Panel if (av.hasHiddenColumns()) { res = av.getAlignment().getHiddenColumns() - .adjustForHiddenColumns(res); + .visibleToAbsoluteColumn(res); } if (!stretchingGroup) @@ -276,7 +276,7 @@ public class ScalePanel extends Panel 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); @@ -378,7 +378,7 @@ public class ScalePanel extends Panel { if (hidden.isVisible(sel)) { - sel = hidden.findColumnPosition(sel); + sel = hidden.absoluteToVisibleColumn(sel); } else { diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index 9d9ee2c..6f078ea 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -131,16 +131,16 @@ public class SeqCanvas extends Panel implements ViewportListenerI 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 @@ -181,7 +181,7 @@ public class SeqCanvas extends Panel implements ViewportListenerI if (av.hasHiddenColumns()) { endx = av.getAlignment().getHiddenColumns() - .adjustForHiddenColumns(endx); + .visibleToAbsoluteColumn(endx); } SequenceI seq; @@ -455,7 +455,7 @@ public class SeqCanvas extends Panel implements ViewportListenerI if (av.hasHiddenColumns()) { maxwidth = av.getAlignment().getHiddenColumns() - .findColumnPosition(maxwidth); + .absoluteToVisibleColumn(maxwidth); } while ((ypos <= canvasHeight) && (startRes < maxwidth)) diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index d74bbb7..d6ed3f3 100644 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -647,7 +647,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, if (av.hasHiddenColumns()) { res = av.getAlignment().getHiddenColumns() - .adjustForHiddenColumns(res); + .visibleToAbsoluteColumn(res); } return res; diff --git a/src/jalview/datamodel/HiddenColumns.java b/src/jalview/datamodel/HiddenColumns.java index ef80b32..f9ee46c 100644 --- a/src/jalview/datamodel/HiddenColumns.java +++ b/src/jalview/datamodel/HiddenColumns.java @@ -735,7 +735,7 @@ public class HiddenColumns * 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 { @@ -763,7 +763,7 @@ public class HiddenColumns * 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 { @@ -829,7 +829,7 @@ public class HiddenColumns 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 it = new ReverseRegionsIterator(0, start, hiddenColumns); @@ -1086,7 +1086,7 @@ public class HiddenColumns if (foundStart) { - return findColumnPosition(start); + return absoluteToVisibleColumn(start); } // otherwise, sequence was completely hidden return visPrev; @@ -1390,7 +1390,7 @@ public class HiddenColumns try { LOCK.readLock().lock(); - int adjres = adjustForHiddenColumns(res); + int adjres = visibleToAbsoluteColumn(res); int[] reveal = null; @@ -1471,7 +1471,7 @@ public class HiddenColumns 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 @@ -1529,8 +1529,8 @@ public class HiddenColumns int adjend = end; if (useVisibleCoords) { - adjstart = adjustForHiddenColumns(start); - adjend = adjustForHiddenColumns(end); + adjstart = visibleToAbsoluteColumn(start); + adjend = visibleToAbsoluteColumn(end); } try diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 3a1dbe8..60ca80a 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -419,8 +419,8 @@ public class AlignmentPanel extends GAlignmentPanel implements 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])) @@ -678,7 +678,7 @@ public class AlignmentPanel extends GAlignmentPanel implements { // reset the width to exclude hidden columns width = av.getAlignment().getHiddenColumns() - .findColumnPosition(width); + .absoluteToVisibleColumn(width); } hextent = getSeqPanel().seqCanvas.getWidth() / av.getCharWidth(); @@ -1174,7 +1174,7 @@ public class AlignmentPanel extends GAlignmentPanel implements if (av.hasHiddenColumns()) { maxwidth = av.getAlignment().getHiddenColumns() - .findColumnPosition(maxwidth) - 1; + .absoluteToVisibleColumn(maxwidth) - 1; } int resWidth = getSeqPanel().seqCanvas @@ -1366,7 +1366,7 @@ public class AlignmentPanel extends GAlignmentPanel implements if (av.hasHiddenColumns()) { maxwidth = av.getAlignment().getHiddenColumns() - .findColumnPosition(maxwidth); + .absoluteToVisibleColumn(maxwidth); } int height = ((av.getAlignment().getHeight() + 1) * av.getCharHeight()) @@ -1584,7 +1584,7 @@ public class AlignmentPanel extends GAlignmentPanel implements if (av.hasHiddenColumns()) { maxwidth = av.getAlignment().getHiddenColumns() - .findColumnPosition(maxwidth) - 1; + .absoluteToVisibleColumn(maxwidth) - 1; } int height = ((maxwidth / chunkWidth) + 1) * cHeight; diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 438e81b..f8e8a78 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -724,7 +724,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, if (av.hasHiddenColumns()) { column = av.getAlignment().getHiddenColumns() - .adjustForHiddenColumns(column); + .visibleToAbsoluteColumn(column); } AlignmentAnnotation ann = aa[row]; diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index 085b259..ab96d80 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -374,7 +374,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI if (av.hasHiddenColumns()) { maxwidth = av.getAlignment().getHiddenColumns() - .findColumnPosition(maxwidth) - 1; + .absoluteToVisibleColumn(maxwidth) - 1; } int annotationHeight = 0; diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 799eac2..c8040de 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -113,7 +113,7 @@ public class ScalePanel extends JPanel if (av.hasHiddenColumns()) { - x = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(x); + x = av.getAlignment().getHiddenColumns().visibleToAbsoluteColumn(x); } if (x >= av.getAlignment().getWidth()) @@ -282,7 +282,7 @@ public class ScalePanel extends JPanel if (av.hasHiddenColumns()) { res = av.getAlignment().getHiddenColumns() - .adjustForHiddenColumns(res); + .visibleToAbsoluteColumn(res); } if (res >= av.getAlignment().getWidth()) @@ -337,7 +337,7 @@ public class ScalePanel extends JPanel 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); @@ -393,7 +393,7 @@ public class ScalePanel extends JPanel reveal = av.getAlignment().getHiddenColumns() .getRegionWithEdgeAtRes(res); - res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(res); + res = av.getAlignment().getHiddenColumns().visibleToAbsoluteColumn(res); ToolTipManager.sharedInstance().registerComponent(this); this.setToolTipText( @@ -458,7 +458,7 @@ public class ScalePanel extends JPanel { if (hidden.isVisible(sel)) { - sel = hidden.findColumnPosition(sel); + sel = hidden.absoluteToVisibleColumn(sel); } else { diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 2a43e85..dcc548d 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -200,8 +200,8 @@ public class SeqCanvas extends JComponent implements ViewportListenerI 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()); @@ -948,7 +948,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI if (av.hasHiddenColumns()) { maxwidth = av.getAlignment().getHiddenColumns() - .findColumnPosition(maxwidth); + .absoluteToVisibleColumn(maxwidth); } // chop the wrapped alignment extent up into panel-sized blocks and treat @@ -1261,7 +1261,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI // 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)) { @@ -1641,9 +1641,9 @@ public class SeqCanvas extends JComponent implements ViewportListenerI if (av.hasHiddenColumns()) { firstVisibleColumn = alignment.getHiddenColumns() - .adjustForHiddenColumns(firstVisibleColumn); + .visibleToAbsoluteColumn(firstVisibleColumn); lastVisibleColumn = alignment.getHiddenColumns() - .adjustForHiddenColumns(lastVisibleColumn); + .visibleToAbsoluteColumn(lastVisibleColumn); } for (int seqNo = ranges.getStartSeq(); seqNo <= ranges @@ -1686,8 +1686,8 @@ public class SeqCanvas extends JComponent implements ViewportListenerI 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(); @@ -2076,9 +2076,9 @@ public class SeqCanvas extends JComponent implements ViewportListenerI if (av.hasHiddenColumns()) { firstVisibleColumn = alignment.getHiddenColumns() - .adjustForHiddenColumns(firstVisibleColumn); + .visibleToAbsoluteColumn(firstVisibleColumn); lastVisibleColumn = alignment.getHiddenColumns() - .adjustForHiddenColumns(lastVisibleColumn); + .visibleToAbsoluteColumn(lastVisibleColumn); } int gapHeight = charHeight * (av.getScaleAboveWrapped() ? 2 : 1); @@ -2117,7 +2117,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI if (av.hasHiddenColumns()) { displayColumn = alignment.getHiddenColumns() - .findColumnPosition(displayColumn); + .absoluteToVisibleColumn(displayColumn); } /* diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 8b80ffd..57d0e35 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -250,7 +250,7 @@ public class SeqPanel extends JPanel if (av.hasHiddenColumns()) { res = av.getAlignment().getHiddenColumns() - .adjustForHiddenColumns(res); + .visibleToAbsoluteColumn(res); } return res; @@ -365,7 +365,7 @@ public class SeqPanel extends JPanel 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 diff --git a/src/jalview/renderer/AnnotationRenderer.java b/src/jalview/renderer/AnnotationRenderer.java index 41772d4..25a81f9 100644 --- a/src/jalview/renderer/AnnotationRenderer.java +++ b/src/jalview/renderer/AnnotationRenderer.java @@ -600,7 +600,7 @@ public class AnnotationRenderer { if (hasHiddenColumns) { - column = hiddenColumns.adjustForHiddenColumns(startRes + x); + column = hiddenColumns.visibleToAbsoluteColumn(startRes + x); if (column > row_annotations.length - 1) { break; @@ -1247,7 +1247,7 @@ public class AnnotationRenderer column = sRes + x; if (hasHiddenColumns) { - column = hiddenColumns.adjustForHiddenColumns(column); + column = hiddenColumns.visibleToAbsoluteColumn(column); } if (column > aaMax) @@ -1327,7 +1327,7 @@ public class AnnotationRenderer column = sRes + x; if (hasHiddenColumns) { - column = hiddenColumns.adjustForHiddenColumns(column); + column = hiddenColumns.visibleToAbsoluteColumn(column); } if (column > aaMax) diff --git a/src/jalview/renderer/ScaleRenderer.java b/src/jalview/renderer/ScaleRenderer.java index 830a840..c7406a5 100644 --- a/src/jalview/renderer/ScaleRenderer.java +++ b/src/jalview/renderer/ScaleRenderer.java @@ -115,13 +115,13 @@ public class ScaleRenderer 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 diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index a0cbff4..946c8e6 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -1768,7 +1768,7 @@ public abstract class AlignmentViewport { if (start == 0) { - start = hidden.adjustForHiddenColumns(start); + start = hidden.visibleToAbsoluteColumn(start); } end = hidden.getHiddenBoundaryRight(start); @@ -1786,7 +1786,7 @@ public abstract class AlignmentViewport if (hidden != null && hidden.hasHiddenColumns()) { - start = hidden.adjustForHiddenColumns(end); + start = hidden.visibleToAbsoluteColumn(end); start = hidden.getHiddenBoundaryLeft(start) + 1; } } while (end < max); diff --git a/src/jalview/viewmodel/OverviewDimensionsShowHidden.java b/src/jalview/viewmodel/OverviewDimensionsShowHidden.java index 9dde16e..9a8c2a8 100644 --- a/src/jalview/viewmodel/OverviewDimensionsShowHidden.java +++ b/src/jalview/viewmodel/OverviewDimensionsShowHidden.java @@ -78,7 +78,7 @@ public class OverviewDimensionsShowHidden extends OverviewDimensions 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 @@ -98,7 +98,7 @@ public class OverviewDimensionsShowHidden extends OverviewDimensions // 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; @@ -136,7 +136,7 @@ public class OverviewDimensionsShowHidden extends OverviewDimensions 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 @@ -144,7 +144,7 @@ public class OverviewDimensionsShowHidden extends OverviewDimensions // 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 @@ -195,8 +195,8 @@ public class OverviewDimensionsShowHidden extends OverviewDimensions 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()); @@ -251,7 +251,7 @@ public class OverviewDimensionsShowHidden extends OverviewDimensions 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); } diff --git a/src/jalview/viewmodel/ViewportRanges.java b/src/jalview/viewmodel/ViewportRanges.java index 0cc8d7c..b06ae59 100644 --- a/src/jalview/viewmodel/ViewportRanges.java +++ b/src/jalview/viewmodel/ViewportRanges.java @@ -608,14 +608,14 @@ public class ViewportRanges extends ViewportProperties } 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)) { @@ -637,7 +637,7 @@ public class ViewportRanges extends ViewportProperties 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 diff --git a/test/jalview/datamodel/HiddenColumnsTest.java b/test/jalview/datamodel/HiddenColumnsTest.java index edd68b2..133f06e 100644 --- a/test/jalview/datamodel/HiddenColumnsTest.java +++ b/test/jalview/datamodel/HiddenColumnsTest.java @@ -68,22 +68,22 @@ public class HiddenColumnsTest 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 @@ -93,25 +93,25 @@ public class HiddenColumnsTest 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" }) @@ -422,7 +422,7 @@ public class HiddenColumnsTest 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 @@ -708,9 +708,9 @@ public class HiddenColumnsTest 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); @@ -719,10 +719,10 @@ public class HiddenColumnsTest 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" }) @@ -1009,22 +1009,22 @@ public class HiddenColumnsTest { 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") -- 1.7.10.2