From 7f4da0a2b0c10f158a03dbfce8878e67e90c4a68 Mon Sep 17 00:00:00 2001 From: kiramt Date: Wed, 15 Mar 2017 14:58:36 +0000 Subject: [PATCH] JAL-2388 Unit tests and tidies --- src/jalview/appletgui/AlignViewport.java | 2 + src/jalview/appletgui/OverviewPanel.java | 35 ++--- src/jalview/datamodel/HiddenSequences.java | 8 +- src/jalview/gui/OverviewPanel.java | 43 +++---- src/jalview/viewmodel/AlignmentViewport.java | 22 ---- src/jalview/viewmodel/OverviewDimensions.java | 22 ++-- src/jalview/viewmodel/ViewportPositionProps.java | 30 ++++- test/jalview/viewmodel/OverviewDimensionsTest.java | 136 ++++++++++---------- 8 files changed, 143 insertions(+), 155 deletions(-) diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index f927e63..f5d6ce7 100644 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -39,6 +39,7 @@ import jalview.structure.SelectionSource; import jalview.structure.StructureSelectionManager; import jalview.structure.VamsasSource; import jalview.viewmodel.AlignmentViewport; +import jalview.viewmodel.ViewportPositionProps; import java.awt.Font; @@ -74,6 +75,7 @@ public class AlignViewport extends AlignmentViewport implements calculator = new jalview.workers.AlignCalcManager(); this.applet = applet; alignment = al; + posProps = new ViewportPositionProps(this.alignment); // we always pad gaps this.setPadGaps(true); this.setStartRes(0); diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index 836a800..f0dd524 100755 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.java @@ -20,6 +20,7 @@ */ package jalview.appletgui; +import jalview.datamodel.SequenceI; import jalview.viewmodel.OverviewDimensions; import java.awt.Color; @@ -61,10 +62,10 @@ public class OverviewPanel extends Panel implements Runnable, private Frame nullFrame; - public OverviewPanel(AlignmentPanel ap) + public OverviewPanel(AlignmentPanel alPanel) { - this.av = ap.av; - this.ap = ap; + this.av = alPanel.av; + this.ap = alPanel; setLayout(null); nullFrame = new Frame(); nullFrame.addNotify(); @@ -75,15 +76,7 @@ public class OverviewPanel extends Panel implements Runnable, sr.forOverview = true; fr = new FeatureRenderer(av); - boolean showAnnotation = true; - // TODO: in applet this was getSequenceConsensusHash() - // check if it makes any functional difference: hconsensus or conservation - if (av.getAlignmentConservationAnnotation() == null) - { - showAnnotation = false; - } - - od = new OverviewDimensions(av.getPosProps(), showAnnotation); + od = new OverviewDimensions(av.getPosProps(), av.isShowAnnotation()); setSize(new Dimension(od.getWidth(), od.getHeight())); addComponentListener(new ComponentAdapter() @@ -156,7 +149,7 @@ public class OverviewPanel extends Panel implements Runnable, } /** - * DOCUMENT ME! + * Updates the overview image when the related alignment panel is updated */ public void updateOverviewImage() { @@ -175,8 +168,8 @@ public class OverviewPanel extends Panel implements Runnable, if ((getWidth() > 0) && (getHeight() > 0)) { - od.setWidth(getWidth()); // width = getWidth(); - od.setHeight(getHeight()); // sequencesHeight = getHeight() - graphHeight; + od.setWidth(getWidth()); + od.setHeight(getHeight()); } setSize(new Dimension(od.getWidth(), od.getHeight())); @@ -208,8 +201,6 @@ public class OverviewPanel extends Panel implements Runnable, Graphics mg = miniMe.getGraphics(); - // od.updateScales(); - int alwidth = av.getAlignment().getWidth(); int alheight = av.getAlignment().getAbsoluteHeight(); float sampleCol = alwidth / (float) od.getWidth(); @@ -217,7 +208,7 @@ public class OverviewPanel extends Panel implements Runnable, buildImage(sampleRow, sampleCol, mg); - if (av.getAlignmentConservationAnnotation() != null) + if (av.isShowAnnotation()) { for (int col = 0; col < od.getWidth() && !resizeAgain; col++) { @@ -243,6 +234,9 @@ public class OverviewPanel extends Panel implements Runnable, } } + /* + * Build the overview panel image + */ private void buildImage(float sampleRow, float sampleCol, Graphics mg) { int lastcol = 0; @@ -253,7 +247,7 @@ public class OverviewPanel extends Panel implements Runnable, int sameRow = 0; int sameCol = 0; - jalview.datamodel.SequenceI seq = null; + SequenceI seq = null; final boolean hasHiddenCols = av.hasHiddenColumns(); boolean hiddenRow = false; @@ -304,7 +298,6 @@ public class OverviewPanel extends Panel implements Runnable, sameRow = 1; } } - } /* @@ -326,7 +319,7 @@ public class OverviewPanel extends Panel implements Runnable, } else { - color = Color.white; // White + color = Color.white; } if (hiddenRow diff --git a/src/jalview/datamodel/HiddenSequences.java b/src/jalview/datamodel/HiddenSequences.java index 9c02f29..d3aa01a 100755 --- a/src/jalview/datamodel/HiddenSequences.java +++ b/src/jalview/datamodel/HiddenSequences.java @@ -260,8 +260,14 @@ public class HiddenSequences } int index = 0; int hiddenSeqs = 0; + int diff = 0; if (hiddenSequences.length <= alignmentIndex) { + // if the alignmentIndex runs past the end of hidden sequences + // and therefore actually past the end of the alignment + // store the difference to add back on at the end, so that behaviour + // is consistent with hidden columns behaviour (used by overview panel) + diff = alignmentIndex - hiddenSequences.length + 1; alignmentIndex = hiddenSequences.length - 1; } @@ -274,7 +280,7 @@ public class HiddenSequences index++; } - return (alignmentIndex - hiddenSeqs); + return (alignmentIndex - hiddenSeqs + diff); } /** diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index 923616f..2c77942 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -20,6 +20,7 @@ */ package jalview.gui; +import jalview.datamodel.SequenceI; import jalview.renderer.AnnotationRenderer; import jalview.viewmodel.OverviewDimensions; @@ -88,14 +89,7 @@ public class OverviewPanel extends JPanel implements Runnable sr.forOverview = true; fr = new FeatureRenderer(alPanel); - boolean showAnnotation = true; - // TODO: in applet this was getSequenceConsensusHash() - // check if it makes any functional difference: hconsensus or conservation - if (av.getAlignmentConservationAnnotation() == null) - { - showAnnotation = false; - } - od = new OverviewDimensions(av.getPosProps(), showAnnotation); + od = new OverviewDimensions(av.getPosProps(), av.isShowAnnotation()); addComponentListener(new ComponentAdapter() { @@ -117,8 +111,6 @@ public class OverviewPanel extends JPanel implements Runnable { if (!av.getWrapAlignment()) { - // TODO: feature: jv2.5 detect shift drag and update selection from - // it. od.updateViewportFromMouse(evt.getX(), evt.getY(), av .getAlignment().getHiddenSequences(), av .getColumnSelection(), av.getPosProps()); @@ -160,8 +152,8 @@ public class OverviewPanel extends JPanel implements Runnable if ((getWidth() > 0) && (getHeight() > 0)) { - od.setWidth(getWidth()); // width = getWidth(); - od.setHeight(getHeight()); // sequencesHeight = getHeight() - graphHeight; + od.setWidth(getWidth()); + od.setHeight(getHeight()); } setPreferredSize(new Dimension(od.getWidth(), od.getHeight())); @@ -208,7 +200,7 @@ public class OverviewPanel extends JPanel implements Runnable buildImage(sampleRow, sampleCol); - if (av.getAlignmentConservationAnnotation() != null) + if (av.isShowAnnotation()) { renderer.updateFromAlignViewport(av); for (int col = 0; col < od.getWidth() && !resizeAgain; col++) @@ -239,13 +231,16 @@ public class OverviewPanel extends JPanel implements Runnable setBoxPosition(); } + /* + * Build the overview panel image + */ private void buildImage(float sampleRow, float sampleCol) { int lastcol = -1; int lastrow = -1; int color = Color.white.getRGB(); - jalview.datamodel.SequenceI seq = null; + SequenceI seq = null; final boolean hasHiddenCols = av.hasHiddenColumns(); boolean hiddenRow = false; @@ -268,12 +263,6 @@ public class OverviewPanel extends JPanel implements Runnable seq = av.getAlignment().getSequenceAtAbsoluteIndex(lastrow); } - if (seq == null) - { - System.out.println(lastrow + " null"); - continue; - } - for (int col = 0; col < od.getWidth() && !resizeAgain; col++) { if (doCopy) @@ -287,9 +276,7 @@ public class OverviewPanel extends JPanel implements Runnable color = getColumnColourFromSequence(seq, hiddenRow, hasHiddenCols, lastcol); } - // else if ((int) (col * sampleCol) == lastcol && (int) (row * - // sampleRow) == lastrow)) - // we just use the color we already have , so don't need to set it + // else we just use the color we already have , so don't need to set it miniMe.setRGB(col, row, color); } @@ -304,7 +291,11 @@ public class OverviewPanel extends JPanel implements Runnable { int color; - if (seq.getLength() > lastcol) + if (seq == null) + { + color = Color.white.getRGB(); + } + else if (seq.getLength() > lastcol) { color = sr.getResidueBoxColour(seq, lastcol).getRGB(); @@ -315,7 +306,7 @@ public class OverviewPanel extends JPanel implements Runnable } else { - color = Color.white.getRGB(); // White + color = Color.white.getRGB(); } if (hiddenRow @@ -367,7 +358,7 @@ public class OverviewPanel extends JPanel implements Runnable g.fillRect(0, 0, getWidth(), getHeight()); } } - // TODO: render selected regions + g.setColor(Color.red); od.drawBox(g); } diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 41248b1..47f7d9d 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -2679,44 +2679,22 @@ public abstract class AlignmentViewport implements AlignViewportI, public void setStartSeq(int seq) { posProps.setStartSeq(seq); - // this.startSeq = seq; } public void setEndRes(int res) { posProps.setEndRes(res); - /*if (res > alignment.getWidth() - 1) - { - // log.System.out.println(" Corrected res from " + res + " to maximum " + - // (alignment.getWidth()-1)); - res = alignment.getWidth() - 1; - } - if (res < 0) - { - res = 0; - } - this.endRes = res;*/ } public void setEndSeq(int seq) { posProps.setEndSeq(seq); - /*if (seq > alignment.getHeight()) - { - seq = alignment.getHeight(); - } - if (seq < 0) - { - seq = 0; - } - this.endSeq = seq;*/ } @Override public int getEndSeq() { return posProps.getEndSeq(); - // return endSeq; } /** diff --git a/src/jalview/viewmodel/OverviewDimensions.java b/src/jalview/viewmodel/OverviewDimensions.java index 60b4ee9..b34c85d 100644 --- a/src/jalview/viewmodel/OverviewDimensions.java +++ b/src/jalview/viewmodel/OverviewDimensions.java @@ -91,7 +91,7 @@ public class OverviewDimensions { // wider width = MAX_WIDTH; - sequencesHeight = (int) (MAX_WIDTH / initialScale); + sequencesHeight = Math.round(MAX_WIDTH / initialScale); if (sequencesHeight < MIN_SEQ_HEIGHT) { sequencesHeight = MIN_SEQ_HEIGHT; @@ -100,7 +100,7 @@ public class OverviewDimensions else { // taller - width = (int) (MAX_WIDTH * initialScale); + width = Math.round(MAX_WIDTH * initialScale); sequencesHeight = MAX_SEQ_HEIGHT; if (width < MIN_WIDTH) @@ -173,7 +173,8 @@ public class OverviewDimensions // if last position was before the end of the alignment, need to update if ((scrollCol + vpwidth - 1) < visAlignWidth) { - visXAsRes = hiddenCols.findColumnNToLeft(vpwidth - 1, alwidth - 1); + visXAsRes = hiddenCols.findColumnPosition(hiddenCols + .findColumnNToLeft(vpwidth - 1, alwidth - 1)); } else { @@ -199,19 +200,16 @@ public class OverviewDimensions yAsSeq = hiddenSeqs.adjustForHiddenSeqs(hiddenSeqs .findIndexWithoutHiddenSeqs(yAsSeq)); - // get where end seq should be by adding the viewport height on - int endSeq = yAsSeq + vpheight - 1; - // check in case we went off the edge of the alignment int visAlignHeight = hiddenSeqs.findIndexWithoutHiddenSeqs(alheight); int visYAsRes = hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq); - if (hiddenSeqs.findIndexWithoutHiddenSeqs(endSeq) > visAlignHeight) + if (visYAsRes + vpheight - 1 > visAlignHeight) { // went past the end of the alignment, adjust backwards if ((scrollRow + vpheight - 1) < visAlignHeight) { - visYAsRes = hiddenSeqs - .findIndexNAboveRow(vpheight - 1, alheight - 1); + visYAsRes = hiddenSeqs.findIndexWithoutHiddenSeqs(hiddenSeqs + .findIndexNAboveRow(vpheight - 1, alheight - 1)); } else { @@ -219,10 +217,9 @@ public class OverviewDimensions } } - // convert absolute positions back to visible alignment positions for - // viewport scrolling + // update scroll values scrollCol = visXAsRes; - scrollRow = visYAsRes; // hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq); + scrollRow = visYAsRes; } @@ -278,7 +275,6 @@ public class OverviewDimensions g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2); } - // don't like this, scroll vals are separate from setting code public int getScrollCol() { return scrollCol; diff --git a/src/jalview/viewmodel/ViewportPositionProps.java b/src/jalview/viewmodel/ViewportPositionProps.java index 69a60f5..d143130 100644 --- a/src/jalview/viewmodel/ViewportPositionProps.java +++ b/src/jalview/viewmodel/ViewportPositionProps.java @@ -24,7 +24,7 @@ import jalview.datamodel.AlignmentI; /** * Supplies and updates viewport properties relating to position such as: start - * and end residues and sequences, hidden column/row adjustments, etc + * and end residues and sequences */ public class ViewportPositionProps extends ViewportProperties { @@ -45,7 +45,9 @@ public class ViewportPositionProps extends ViewportProperties /** * Constructor - * @param alignment TODO + * + * @param alignment + * the viewport's alignment */ public ViewportPositionProps(AlignmentI alignment) { @@ -79,6 +81,12 @@ public class ViewportPositionProps extends ViewportProperties return al.getHeight() + al.getHiddenSequences().getSize(); } + /** + * Set first residue visible in the viewport + * + * @param res + * residue position + */ public void setStartRes(int res) { if (res > al.getWidth() - 1) @@ -92,6 +100,12 @@ public class ViewportPositionProps extends ViewportProperties this.startRes = res; } + /** + * Set last residue visible in the viewport + * + * @param res + * residue position + */ public void setEndRes(int res) { if (res > al.getWidth()) @@ -105,6 +119,12 @@ public class ViewportPositionProps extends ViewportProperties this.endRes = res; } + /** + * Set the first sequence visible in the viewport + * + * @param seq + * sequence position + */ public void setStartSeq(int seq) { if (seq > al.getHeight() - 1) @@ -118,6 +138,12 @@ public class ViewportPositionProps extends ViewportProperties this.startSeq = seq; } + /** + * Set the last sequence visible in the viewport + * + * @param seq + * sequence position + */ public void setEndSeq(int seq) { if (seq > al.getHeight()) diff --git a/test/jalview/viewmodel/OverviewDimensionsTest.java b/test/jalview/viewmodel/OverviewDimensionsTest.java index 8ceadba..1ea07ea 100644 --- a/test/jalview/viewmodel/OverviewDimensionsTest.java +++ b/test/jalview/viewmodel/OverviewDimensionsTest.java @@ -137,7 +137,7 @@ public class OverviewDimensionsTest ViewportPositionProps props = new ViewportPositionProps(al1); OverviewDimensions od = new OverviewDimensions(props, true); - int scaledHeight = 266; + int scaledHeight = 267; assertEquals(od.getGraphHeight(), defaultGraphHeight); assertEquals(od.getSequencesHeight(), scaledHeight); assertEquals(od.getWidth(), maxWidth); @@ -225,7 +225,7 @@ public class OverviewDimensionsTest // overly large boxX value reset to width-boxWidth mouseClick(od, 100, 6); - assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth() + 1); + assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth()); assertEquals(od.getBoxY(), 6); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); @@ -243,13 +243,17 @@ public class OverviewDimensionsTest assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), Math.round((float) od.getBoxX() * alwidth / od.getWidth())); + + // here (float) od.getBoxY() * alheight / od.getSequencesHeight() = 507.5 + // and round rounds to 508; however we get 507 working with row values + // hence the subtraction of 1 assertEquals(od.getScrollRow(), Math.round((float) od.getBoxY() * alheight - / od.getSequencesHeight())); + / od.getSequencesHeight()) - 1); // click past end of alignment, as above mouseClick(od, 3000, 5); - assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth() + 1); + assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth()); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), @@ -313,7 +317,6 @@ public class OverviewDimensionsTest assertEquals(od.getBoxHeight(), boxHeight); // try to click in hidden cols, check box does not move - // this test currently fails as the overview box does not behave like this! int xpos = 10; mouseClick(od, xpos, 0); assertEquals( @@ -339,7 +342,7 @@ public class OverviewDimensionsTest // overly large boxX value reset to width-boxWidth xpos = 100; mouseClick(od, xpos, 5); - assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth() + 1); + assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth()); assertEquals(od.getBoxY(), 5); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); @@ -440,7 +443,7 @@ public class OverviewDimensionsTest // boxX, scrollCol adjusted back, box width normal xpos = 3000; mouseClick(od, xpos, 5); - assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth() + 1); + assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth()); assertEquals(od.getBoxY(), 5); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); @@ -492,44 +495,40 @@ public class OverviewDimensionsTest xpos = Math.round((float) 145 * od.getWidth() / alwidth) - boxWidth; mouseClick(od, xpos, 0); assertEquals(od.getBoxX(), - Math.round((firstHidden - 1) * od.getWidth() / alwidth) - - boxWidth); + Math.round((float) (firstHidden - 1) * od.getWidth() / alwidth) + - boxWidth + 1); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), - Math.round(od.getBoxX() * alwidth / od.getWidth())); + Math.round((float) od.getBoxX() * alwidth / od.getWidth())); assertEquals(od.getScrollRow(), 0); // click in hidden cols // boxX and scrollCol adjusted for hidden cols, width normal - // TODO breaks as above test - /*xpos = 115; - assertEquals( - od.getBoxX(), - Math.round((firstHidden - 1) * scalew * av.getCharWidth()) - - od.getBoxWidth()); + xpos = 115; + assertEquals(od.getBoxX(), + Math.round((float) (firstHidden - 1) * od.getWidth() / alwidth) + - boxWidth + 1); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), - Math.round(od.getBoxX() * alwidth / od.getWidth())); - assertEquals(od.getScrollRow(), 0);*/ + Math.round((float) od.getBoxX() * alwidth / od.getWidth())); + assertEquals(od.getScrollRow(), 0); // click off end of alignment // boxX and scrollCol adjusted for hidden cols, width normal - // TODO breaks as above test - /* xpos = 3000; - assertEquals( - od.getBoxX(), - Math.round((firstHidden - 1) * scalew * av.getCharWidth()) - - od.getBoxWidth()); - assertEquals(od.getBoxY(), 0); - assertEquals(od.getBoxWidth(), boxWidth); - assertEquals(od.getBoxHeight(), boxHeight); - assertEquals(od.getScrollCol(), - Math.round(od.getBoxX() * alwidth / od.getWidth())); - assertEquals(od.getScrollRow(), 0);*/ + xpos = 3000; + assertEquals(od.getBoxX(), + Math.round((float) (firstHidden - 1) * od.getWidth() / alwidth) + - boxWidth + 1); + assertEquals(od.getBoxY(), 0); + assertEquals(od.getBoxWidth(), boxWidth); + assertEquals(od.getBoxHeight(), boxHeight); + assertEquals(od.getScrollCol(), + Math.round((float) od.getBoxX() * alwidth / od.getWidth())); + assertEquals(od.getScrollRow(), 0); } /** @@ -683,7 +682,7 @@ public class OverviewDimensionsTest Math.round((float) 102 * od.getWidth() / alwidth)); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth - + Math.round((float) (lastHidden - firstHidden) + + Math.round((float) (lastHidden - firstHidden + 1) * od.getWidth() / alwidth)); assertEquals(od.getBoxHeight(), boxHeight); } @@ -850,7 +849,7 @@ public class OverviewDimensionsTest // hide rows in middle and check updated box position is correct // no changes int firstHiddenRow = 50; - int lastHiddenRow = 60; + int lastHiddenRow = 54; hideSequences(firstHiddenRow, lastHiddenRow); od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps); @@ -861,34 +860,32 @@ public class OverviewDimensionsTest assertEquals(od.getBoxHeight(), boxHeight); // click above hidden rows, so that box overlaps - int ypos = 40; - // TODO test fails because box does not change height - dealt with by scroll - // values - /* mouseClick(od, 0, Math.round (ypos * alheight / od.getSequencesHeight())); - assertEquals(od.getBoxX(), 0); - assertEquals(od.getBoxY(), Math.round (ypos * alheight / od.getSequencesHeight()), - 1.5); - assertEquals(od.getBoxWidth(), boxWidth); - assertEquals( - od.getBoxHeight(), - boxHeight - + Math.round ((lastHiddenRow - firstHiddenRow + 1) / scaleh / av - .getCharHeight())); - */ + int ypos = 35; // column value in residues + mouseClick(od, 0, + Math.round((float) ypos * od.getSequencesHeight() / alheight)); + assertEquals(od.getBoxX(), 0); + assertEquals(od.getBoxY(), + Math.round((float) ypos * od.getSequencesHeight() / alheight)); + assertEquals(od.getBoxWidth(), boxWidth); + assertEquals( + od.getBoxHeight(), + boxHeight + + Math.round((float) (lastHiddenRow - firstHiddenRow + 1) + * od.getSequencesHeight() / alheight)); + // click so that box straddles hidden rows - ypos = 48; - // TODO test fails because box does not change height - dealt with by scroll - // values - /*mouseClick(od, 0, Math.round (ypos * alheight / od.getSequencesHeight())); + ypos = 44; // column value in residues + mouseClick(od, 0, + Math.round((float) ypos * od.getSequencesHeight() / alheight)); assertEquals(od.getBoxX(), 0); - assertEquals(od.getBoxY(), Math.round (ypos * alheight / od.getSequencesHeight()), - 1.5); + assertEquals(od.getBoxY(), + Math.round((float) ypos * od.getSequencesHeight() / alheight)); assertEquals(od.getBoxWidth(), boxWidth); assertEquals( od.getBoxHeight(), boxHeight - + Math.round ((lastHiddenRow - firstHiddenRow + 1) / scaleh / av - .getCharHeight()));*/ + + Math.round((float) (lastHiddenRow - firstHiddenRow + 1) + * od.getSequencesHeight() / alheight)); } /** @@ -931,29 +928,28 @@ public class OverviewDimensionsTest // click above hidden rows so box overlaps // boxY moved upwards, boxHeight remains same - // TODO fails with boxY located at row 497 - correction done by - // setScrollValues - /* ypos = 497; // row 497 - mouseClick(od, 0, Math.round (ypos * scaleh * av.getCharHeight())); - assertEquals(od.getBoxX(), 0); - assertEquals( - od.getBoxY(), - Math.round ((firstHidden - viewHeight) * scaleh * av.getCharHeight()), - 1.5); - assertEquals(od.getBoxWidth(), boxWidth); - assertEquals(od.getBoxHeight(), boxHeight);*/ + ypos = 497; // row 497 + mouseClick(od, 0, + Math.round((float) ypos * od.getSequencesHeight() / alheight)); + assertEquals(od.getBoxX(), 0); + assertEquals( + od.getBoxY(), + Math.round((float) (firstHidden - viewHeight) + * od.getSequencesHeight() / alheight)); + assertEquals(od.getBoxWidth(), boxWidth); + assertEquals(od.getBoxHeight(), boxHeight); // click within hidden rows ypos = 505; - // TODO: fails with wrong boxHeight - correction done by setScrollValues(?) - /*mouseClick(od, 0, Math.round (ypos * scaleh * av.getCharHeight())); + mouseClick(od, 0, + Math.round((float) ypos * od.getSequencesHeight() / alheight)); assertEquals(od.getBoxX(), 0); assertEquals( od.getBoxY(), - Math.round ((firstHidden - viewHeight) * scaleh * av.getCharHeight()), - 1.5); + Math.round((firstHidden - viewHeight) * od.getSequencesHeight() + / alheight)); assertEquals(od.getBoxWidth(), boxWidth); - assertEquals(od.getBoxHeight(), boxHeight);*/ + assertEquals(od.getBoxHeight(), boxHeight); } /* -- 1.7.10.2