From 571d15a897c11bdc2dda76ce03686604596f220d Mon Sep 17 00:00:00 2001 From: kiramt Date: Fri, 3 Mar 2017 09:46:08 +0000 Subject: [PATCH] JAL-2388 Initial removal of hidden cols/seqs out of overview --- src/jalview/appletgui/OverviewPanel.java | 51 +--- src/jalview/datamodel/Alignment.java | 54 ++-- src/jalview/datamodel/AlignmentI.java | 31 +- src/jalview/gui/AlignViewport.java | 2 +- src/jalview/gui/OverviewPanel.java | 35 +-- src/jalview/viewmodel/OverviewDimensions.java | 94 ++---- src/jalview/viewmodel/ViewportPositionProps.java | 123 ++++---- test/jalview/viewmodel/OverviewDimensionsTest.java | 312 +++++++++++--------- 8 files changed, 333 insertions(+), 369 deletions(-) diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index 0d3f058..0e22af9 100755 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.java @@ -123,22 +123,23 @@ public class OverviewPanel extends Panel implements Runnable, @Override public void mousePressed(MouseEvent evt) { - od.setBoxPositionByMouse(evt.getX(), evt.getY()); - ap.setScrollValues(od.getScrollCol(), od.getScrollRow()); - ap.paintAlignment(false); + mouseAction(evt); } @Override public void mouseReleased(MouseEvent evt) { - od.setBoxPositionByMouse(evt.getX(), evt.getY()); - ap.setScrollValues(od.getScrollCol(), od.getScrollRow()); - ap.paintAlignment(false); + mouseAction(evt); } @Override public void mouseDragged(MouseEvent evt) { + mouseAction(evt); + } + + private void mouseAction(MouseEvent evt) + { od.setBoxPositionByMouse(evt.getX(), evt.getY()); ap.setScrollValues(od.getScrollCol(), od.getScrollRow()); ap.paintAlignment(false); @@ -197,11 +198,10 @@ public class OverviewPanel extends Panel implements Runnable, Graphics mg = miniMe.getGraphics(); - od.updateScales(); + // od.updateScales(); int alwidth = av.getAlignment().getWidth(); - int alheight = av.getAlignment().getHeight() - + av.getAlignment().getHiddenSequences().getSize(); + int alheight = av.getAlignment().getAbsoluteHeight(); float sampleCol = alwidth / (float) od.getWidth(); float sampleRow = alheight / (float) od.getSequencesHeight(); @@ -244,7 +244,7 @@ public class OverviewPanel extends Panel implements Runnable, int sameCol = 0; jalview.datamodel.SequenceI seq = null; - final boolean hasHiddenRows = av.hasHiddenRows(); + final boolean hasHiddenCols = av.hasHiddenColumns(); boolean hiddenRow = false; @@ -256,33 +256,10 @@ public class OverviewPanel extends Panel implements Runnable, } else { - // this should largely be a method in Alignment - hiddenRow = false; - if (hasHiddenRows) - { - // look for sequence in hidden rows - seq = av.getAlignment().getHiddenSequences() - .getHiddenSequence(lastrow); - if (seq == null) - { - // didn't find in hidden rows, adjust the index and retrieve from - // full row set - int index = av.getAlignment().getHiddenSequences() - .findIndexWithoutHiddenSeqs(lastrow); - - seq = av.getAlignment().getSequenceAt(index); - } - else - { - // found in hidden rows, ergo this row is hidden - hiddenRow = true; - } - } - else - { - seq = av.getAlignment().getSequenceAt(lastrow); - } - // end of Alignment method + // get the sequence which would be at alignment index 'lastrow' if no + // columns were hidden, and determine whether it is hidden or not + hiddenRow = av.getAlignment().isHidden(lastrow); + seq = av.getAlignment().getSequenceAtAbsoluteIndex(lastrow); for (int col = 0; col < od.getWidth(); col++) { diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index a6f2bf4..2546d41 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -185,14 +185,7 @@ public class Alignment implements AlignmentI return AlignmentUtils.getSequencesByName(this); } - /** - * DOCUMENT ME! - * - * @param i - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ + @Override public SequenceI getSequenceAt(int i) { @@ -206,6 +199,28 @@ public class Alignment implements AlignmentI return null; } + @Override + public SequenceI getSequenceAtAbsoluteIndex(int i) + { + SequenceI seq = null; + if (getHiddenSequences().getSize() > 0) + { + seq = getHiddenSequences().getHiddenSequence(i); + if (seq == null) + { + // didn't find the sequence in the hidden sequences, get it from the + // alignment + int index = getHiddenSequences().findIndexWithoutHiddenSeqs(i); + seq = getSequenceAt(index); + } + } + else + { + seq = getSequenceAt(i); + } + return seq; + } + /** * Adds a sequence to the alignment. Recalculates maxLength and size. Note * this currently does not recalculate whether or not the alignment is @@ -668,22 +683,19 @@ public class Alignment implements AlignmentI return -1; } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ + @Override public int getHeight() { return sequences.size(); } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ + @Override + public int getAbsoluteHeight() + { + return sequences.size() + getHiddenSequences().getSize(); + } + @Override public int getWidth() { @@ -769,6 +781,12 @@ public class Alignment implements AlignmentI return true; } + @Override + public boolean isHidden(int alignmentIndex) + { + return (getHiddenSequences().getHiddenSequence(alignmentIndex) == null); + } + /** * Delete all annotations, including auto-calculated if the flag is set true. * Returns true if at least one annotation was deleted, else false. diff --git a/src/jalview/datamodel/AlignmentI.java b/src/jalview/datamodel/AlignmentI.java index 5d185cd..1ecff9a 100755 --- a/src/jalview/datamodel/AlignmentI.java +++ b/src/jalview/datamodel/AlignmentI.java @@ -31,13 +31,22 @@ import java.util.Set; public interface AlignmentI extends AnnotatedCollectionI { /** - * Calculates the number of sequences in an alignment + * Calculates the number of sequences in an alignment, excluding hidden + * sequences * * @return Number of sequences in alignment */ int getHeight(); /** + * Calculates the number of sequences in an alignment, including hidden + * sequences + * + * @return Number of sequences in alignment + */ + int getAbsoluteHeight(); + + /** * * Calculates the maximum width of the alignment, including gaps. * @@ -65,6 +74,15 @@ public interface AlignmentI extends AnnotatedCollectionI boolean isAligned(boolean includeHidden); /** + * Answers if the sequence at alignmentIndex is hidden + * + * @param alignmentIndex + * the index to check + * @return true if the sequence is hidden + */ + boolean isHidden(int alignmentIndex); + + /** * Gets sequences as a Synchronized collection * * @return All sequences in alignment. @@ -90,6 +108,17 @@ public interface AlignmentI extends AnnotatedCollectionI SequenceI getSequenceAt(int i); /** + * Find a specific sequence in this alignment. + * + * @param i + * Index of required sequence in full alignment, i.e. if all columns + * were visible + * + * @return SequenceI at given index. + */ + SequenceI getSequenceAtAbsoluteIndex(int i); + + /** * Returns a map of lists of sequences keyed by sequence name. * * @return diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 7bebfa9..5c264c0 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -310,7 +310,7 @@ public class AlignViewport extends AlignmentViewport implements residueShading.setConsensus(hconsensus); } - posProps = new ViewportPositionProps(this.alignment, this.viewStyle); + posProps = new ViewportPositionProps(this.alignment, this); } /** diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index d87285c..e553657 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -181,15 +181,11 @@ public class OverviewPanel extends JPanel implements Runnable mg.setColor(Color.orange); mg.fillRect(0, 0, od.getWidth(), miniMe.getHeight()); - // calculate scale based on current alignment width and height - od.updateScales(); - // calculate sampleCol and sampleRow // alignment width is max number of residues/bases // alignment height is number of sequences int alwidth = av.getAlignment().getWidth(); - int alheight = av.getAlignment().getHeight() - + av.getAlignment().getHiddenSequences().getSize(); + int alheight = av.getAlignment().getAbsoluteHeight(); // sampleCol or sampleRow is the width/height allocated to each residue // in particular, sometimes we may need more than one row/col of the @@ -239,7 +235,7 @@ public class OverviewPanel extends JPanel implements Runnable int color = Color.white.getRGB(); jalview.datamodel.SequenceI seq = null; - final boolean hasHiddenRows = av.hasHiddenRows(); + final boolean hasHiddenCols = av.hasHiddenColumns(); boolean hiddenRow = false; // get hidden row and hidden column map once at beginning. @@ -255,29 +251,10 @@ public class OverviewPanel extends JPanel implements Runnable lastrow = currentrow; - hiddenRow = false; - // should be method(s) in Alignment - if (hasHiddenRows) - { - seq = av.getAlignment().getHiddenSequences() - .getHiddenSequence(lastrow); - if (seq == null) - { - int index = av.getAlignment().getHiddenSequences() - .findIndexWithoutHiddenSeqs(lastrow); - - seq = av.getAlignment().getSequenceAt(index); - } - else - { - hiddenRow = true; - } - } - else - { - seq = av.getAlignment().getSequenceAt(lastrow); - } - // end of Alignment method(s) + // get the sequence which would be at alignment index 'lastrow' if no + // columns were hidden, and determine whether it is hidden or not + hiddenRow = av.getAlignment().isHidden(lastrow); + seq = av.getAlignment().getSequenceAtAbsoluteIndex(lastrow); } if (seq == null) diff --git a/src/jalview/viewmodel/OverviewDimensions.java b/src/jalview/viewmodel/OverviewDimensions.java index b4c7c6d..fe9f4db 100644 --- a/src/jalview/viewmodel/OverviewDimensions.java +++ b/src/jalview/viewmodel/OverviewDimensions.java @@ -77,8 +77,8 @@ public class OverviewDimensions this.posProps = av.getPosProps(); // scale the initial size of overviewpanel to shape of alignment - float initialScale = (float) av.getAlignment().getWidth() - / (float) av.getAlignment().getHeight(); + float initialScale = (float) posProps.getAlignmentWidthInCols() + / (float) posProps.getAlignmentHeightInRows(); // TODO: in applet this was getSequenceConsensusHash() // check if it makes any functional difference @@ -116,6 +116,9 @@ public class OverviewDimensions */ public void setBoxPositionByMouse(int x, int y) { + int alwidth = av.getAlignment().getWidth(); + int alheight = av.getAlignment().getAbsoluteHeight(); + boxX = x; boxY = y; if (boxY < 0) @@ -124,7 +127,7 @@ public class OverviewDimensions } else if (boxY > (sequencesHeight - boxHeight)) { - boxY = sequencesHeight - boxHeight + 1; + boxY = sequencesHeight - boxHeight; } if (boxX < 0) @@ -136,28 +139,23 @@ public class OverviewDimensions if (av.hasHiddenColumns()) { // Try smallest possible box - boxWidth = (int) (posProps.convertResiduesToPixels(posProps - .getEndRes() - posProps.getStartRes() + 1) * scalew); - - // boxWidth = (int) ((av.getEndRes() - av.getStartRes() + 1) - // * av.getCharWidth() * scalew); + boxWidth = Math.round((float) (posProps.getEndRes() + - posProps.getStartRes() + 1) + * width / alwidth); } boxX = width - boxWidth; } - scrollCol = posProps.convertPixelsToResidues(Math.round(boxX / scalew)); - scrollRow = posProps - .convertPixelsToSequences(Math.round(boxY / scaleh)); - - // scrollCol = (int) (boxX / scalew / av.getCharWidth()); - // scrollRow = (int) (boxY / scaleh / av.getCharHeight()); + scrollCol = Math.round((float) boxX * alwidth / width); + scrollRow = Math.round((float) boxY * alheight / sequencesHeight); if (av.hasHiddenColumns()) { - if (!av.getColumnSelection().isVisible(scrollCol)) + // doesn't seem to do anything useful + /*if (!av.getColumnSelection().isVisible(scrollCol)) { return; - } + }*/ scrollCol = av.getColumnSelection().findColumnPosition(scrollCol); } @@ -176,60 +174,22 @@ public class OverviewDimensions */ public void setBoxPosition() { - updateScales(); - - int startRes = av.getStartRes(); - int endRes = av.getEndRes(); - - if (av.hasHiddenColumns()) - { - startRes = av.getColumnSelection().adjustForHiddenColumns(startRes); - endRes = av.getColumnSelection().adjustForHiddenColumns(endRes); - } - - int startSeq = av.getStartSeq(); - int endSeq = av.getEndSeq(); - - if (av.hasHiddenRows()) - { - startSeq = av.getAlignment().getHiddenSequences() - .adjustForHiddenSeqs(startSeq); - - endSeq = av.getAlignment().getHiddenSequences() - .adjustForHiddenSeqs(endSeq); - } + int alwidth = av.getAlignment().getWidth(); + int alheight = av.getAlignment().getAbsoluteHeight(); - boxX = Math.round(posProps.convertResiduesToPixels(startRes) * scalew); - boxY = Math.round(posProps.convertSequencesToPixels(startSeq) * scaleh); + int startRes = av.getPosProps().getAbsoluteStartRes(); + int endRes = av.getPosProps().getAbsoluteEndRes(); - // boxX = (int) (startRes * av.getCharWidth() * scalew); - // boxY = (int) (startSeq * av.getCharHeight() * scaleh); + int startSeq = av.getPosProps().getAbsoluteStartSeq(); + int endSeq = av.getPosProps().getAbsoluteEndSeq(); - boxWidth = Math.round(posProps.convertResiduesToPixels(endRes - - startRes - + 1) * scalew); - boxHeight = Math.round(posProps.convertSequencesToPixels(endSeq - - startSeq) - * scaleh); + boxX = Math.round((float) startRes * width / alwidth); + boxY = Math.round((float) startSeq * sequencesHeight / alheight); - // boxWidth = (int) ((endRes - startRes + 1) * av.getCharWidth() * scalew); - // boxHeight = (int) ((endSeq - startSeq) * av.getCharHeight() * scaleh); - } - - /** - * Update width and height scales in terms of the alignment width and height - */ - public void updateScales() - { - int alwidth = av.getAlignment().getWidth(); - int alheight = av.getAlignment().getHeight() - + av.getAlignment().getHiddenSequences().getSize(); - - int fullsizeWidth = alwidth * av.getCharWidth(); - int fullsizeHeight = alheight * av.getCharHeight(); - - scalew = (float) width / fullsizeWidth; - scaleh = (float) sequencesHeight / fullsizeHeight; + boxWidth = Math + .round((float) (endRes - startRes + 1) * width / alwidth); + boxHeight = Math.round((float) (endSeq - startSeq) * sequencesHeight + / alheight); } /** @@ -269,11 +229,13 @@ public class OverviewDimensions return boxY; } + // TODO should be removed, when unit test has mock Graphics object available public int getBoxWidth() { return boxWidth; } + // TODO should be removed, when unit test has mock Graphics object available public int getBoxHeight() { return boxHeight; diff --git a/src/jalview/viewmodel/ViewportPositionProps.java b/src/jalview/viewmodel/ViewportPositionProps.java index 1bb49af..f00d69f 100644 --- a/src/jalview/viewmodel/ViewportPositionProps.java +++ b/src/jalview/viewmodel/ViewportPositionProps.java @@ -20,7 +20,7 @@ */ package jalview.viewmodel; -import jalview.api.ViewStyleI; +import jalview.api.AlignViewportI; import jalview.datamodel.AlignmentI; /** @@ -42,23 +42,18 @@ public class ViewportPositionProps extends ViewportProperties // end sequence of viewport private int endSeq; - // character height - private int charHeight; - - // character width - private int charWidth; - // alignment private AlignmentI al; - // viewstyle - private ViewStyleI viewstyle; + // viewport + private AlignViewportI av; // this is a bad dependency, viewmodel should not + // depend on api /** * Constructor * @param alignment TODO */ - public ViewportPositionProps(AlignmentI alignment, ViewStyleI vstyle) + public ViewportPositionProps(AlignmentI alignment, AlignViewportI viewport) { // initial values of viewport settings this.startRes = 0; @@ -66,17 +61,7 @@ public class ViewportPositionProps extends ViewportProperties this.startSeq = 0; this.endSeq = alignment.getHeight() - 1; this.al = alignment; - this.viewstyle = vstyle; - } - - public void setCharHeight(int h) - { - viewstyle.setCharHeight(h); - } - - public void setCharWidth(int w) - { - viewstyle.setCharWidth(w); + this.av = viewport; } // ways to update values @@ -116,22 +101,22 @@ public class ViewportPositionProps extends ViewportProperties public void setEndRes(int res) { - if (res > al.getWidth() - 1) + if (res > al.getWidth()) { - res = al.getWidth() - 1; + res = al.getWidth(); } - else if (res < 0) + else if (res < 1) { - res = 0; + res = 1; } this.endRes = res; } public void setStartSeq(int seq) { - if (seq > al.getHeight()) + if (seq > al.getHeight() - 1) { - seq = al.getHeight(); + seq = al.getHeight() - 1; } else if (seq < 0) { @@ -146,9 +131,9 @@ public class ViewportPositionProps extends ViewportProperties { seq = al.getHeight(); } - else if (seq < 0) + else if (seq < 1) { - seq = 0; + seq = 1; } this.endSeq = seq; } @@ -184,68 +169,62 @@ public class ViewportPositionProps extends ViewportProperties { return endSeq; } + /** - * Get start residue of viewport + * Get absolute start residue of viewport */ - public int getStartRes(boolean countHidden) + public int getAbsoluteStartRes() { - if (countHidden) - { - return 0; // av.getColumnSelection().adjustForHiddenColumns(startRes); - } - else + int start = startRes; + + if (av.hasHiddenColumns()) { - return startRes; + start = av.getColumnSelection().adjustForHiddenColumns(start); } + return start; } /** - * Convert distance x in viewport pixels to a distance in number of residues - * - * @param x - * number of pixels - * @return number of residues + * Get absolute start residue of viewport */ - public int convertPixelsToResidues(int x) + public int getAbsoluteEndRes() { - return Math.round((float) x / viewstyle.getCharWidth()); - // return (int) ((float) x / viewstyle.getCharWidth()); - } + int end = endRes; - /** - * Convert distance y in viewport pixels to a distance in number of sequences - * - * @param y - * number of pixels - * @return number of sequences - */ - public int convertPixelsToSequences(int y) - { - return Math.round((float) y / viewstyle.getCharHeight()); - // return (int) ((float) y / viewstyle.getCharHeight()); + if (av.hasHiddenColumns()) + { + end = av.getColumnSelection().adjustForHiddenColumns(end); + } + return end; } - + /** - * Convert number of sequences s to a height in viewport pixels - * - * @param s - * number of sequences - * @return number of pixels + * Get absolute start sequence of viewport */ - public int convertSequencesToPixels(int s) + public int getAbsoluteStartSeq() { - return (s * viewstyle.getCharHeight()); + int start = startSeq; + + if (av.hasHiddenRows()) + { + start = av.getAlignment().getHiddenSequences() + .adjustForHiddenSeqs(start); + } + return start; } /** - * Convert number of residues r to a width in viewport pixels - * - * @param r - * number of residues - * @return number of pixels + * Get absolute end sequence of viewport */ - public int convertResiduesToPixels(int r) + public int getAbsoluteEndSeq() { - return (r * viewstyle.getCharWidth()); + int end = endSeq; + + if (av.hasHiddenRows()) + { + end = av.getAlignment().getHiddenSequences().adjustForHiddenSeqs(end); + } + return end; } + } diff --git a/test/jalview/viewmodel/OverviewDimensionsTest.java b/test/jalview/viewmodel/OverviewDimensionsTest.java index 94fb83f..cc808d6 100644 --- a/test/jalview/viewmodel/OverviewDimensionsTest.java +++ b/test/jalview/viewmodel/OverviewDimensionsTest.java @@ -78,6 +78,12 @@ public class OverviewDimensionsTest { int viewHeight; + int viewWidth; + + int alheight; + + int alwidth; + @BeforeClass(alwaysRun = true) public void setUpJvOptionPane() { @@ -135,11 +141,6 @@ public class OverviewDimensionsTest { av = af.getViewport(); - if (av.isCalcInProgress()) - { - - } - od = new OverviewDimensions(av); while (av.isCalcInProgress()) @@ -149,24 +150,13 @@ public class OverviewDimensionsTest { Thread.sleep(50); } catch (InterruptedException e) { - System.out.println("Hiding cols interruption"); + } } // Initial box sizing - default path through code od.setBoxPosition(); - scalew = (float) od.getWidth() - / (av.getAlignment().getWidth() * av.getCharWidth()); - scaleh = (float) od.getSequencesHeight() - / (av.getAlignment().getHeight() * av.getCharHeight()); - boxWidth = Math.round((av.getEndRes() - av.getStartRes() + 1) - * av.getCharWidth() * scalew); - boxHeight = Math.round((av.getEndSeq() - av.getStartSeq()) - * av.getCharHeight() * scaleh); - - viewHeight = av.getEndSeq() - av.getStartSeq(); - init(); } @@ -192,6 +182,34 @@ public class OverviewDimensionsTest { mouseClick(od, 0, 0); moveViewport(0, 0); + + viewHeight = av.getEndSeq() - av.getStartSeq(); + viewWidth = av.getEndRes() - av.getStartRes(); + + // wait for gui to get set up + while (viewHeight != 17 || viewWidth != 59) + { + try + { + Thread.sleep(50); + viewHeight = av.getEndSeq() - av.getStartSeq(); + viewWidth = av.getEndRes() - av.getStartRes(); + } catch (InterruptedException e) + { + + } + } + + // calculate before hidden columns so we get absolute values + alheight = av.getAlignment().getHeight(); + alwidth = av.getAlignment().getWidth(); + + boxWidth = Math.round((float) (av.getEndRes() - av.getStartRes() + 1) + / alwidth * od.getWidth()); + boxHeight = Math.round((float) (av.getEndSeq() - av.getStartSeq()) + / alheight * od.getHeight()); + System.out.println(boxHeight); + } @AfterMethod(alwaysRun = true) @@ -318,7 +336,7 @@ public class OverviewDimensionsTest { assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollRow(), - Math.round(10 / scaleh / av.getCharHeight())); + Math.round((float) 10 * alheight / od.getSequencesHeight())); assertEquals(od.getScrollCol(), 0); // negative boxY value reset to 0 @@ -327,41 +345,43 @@ public class OverviewDimensionsTest { assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), - Math.round(6 / scalew / av.getCharWidth())); + Math.round((float) 6 * alwidth / od.getWidth())); assertEquals(od.getScrollRow(), 0); // overly large boxX value reset to width-boxWidth mouseClick(od, 100, 6); - assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth(), 1.5); - assertEquals(od.getBoxY(), 6, 1.5); + assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth()); + assertEquals(od.getBoxY(), 6); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), - (od.getBoxX() / scalew / av.getCharWidth()), 1.5); + Math.round((float) od.getBoxX() * alwidth / od.getWidth())); assertEquals(od.getScrollRow(), - (od.getBoxY() / scaleh / av.getCharHeight()), 1.5); + Math.round((float) od.getBoxY() * alheight + / od.getSequencesHeight())); // overly large boxY value reset to sequenceHeight - boxHeight mouseClick(od, 10, 520); - assertEquals(od.getBoxX(), 10, 1.5); - assertEquals(od.getBoxY(), od.getSequencesHeight() - od.getBoxHeight(), - 1.5); + assertEquals(od.getBoxX(), 10); + assertEquals(od.getBoxY(), od.getSequencesHeight() - od.getBoxHeight()); assertEquals(od.getBoxWidth(), boxWidth); - assertEquals(od.getBoxHeight(), boxHeight, 1.5); + assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), - (od.getBoxX() / scalew / av.getCharWidth()), 1.5); + Math.round((float) od.getBoxX() * alwidth / od.getWidth())); assertEquals(od.getScrollRow(), - (od.getBoxY() / scaleh / av.getCharHeight()), 1.5); + Math.round((float) od.getBoxY() * alheight + / od.getSequencesHeight())); // click past end of alignment, as above mouseClick(od, 3000, 5); - assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth(), 1.5); + assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth()); assertEquals(od.getBoxWidth(), boxWidth); - assertEquals(od.getBoxHeight(), boxHeight, 1.5); + assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), - (od.getBoxX() / scalew / av.getCharWidth()), 1.5); + Math.round((float) od.getBoxX() * alwidth / od.getWidth())); assertEquals(od.getScrollRow(), - (od.getBoxY() / scaleh / av.getCharHeight()), 1.5); + Math.round((float) od.getBoxY() * alheight + / od.getSequencesHeight())); // move viewport so startRes non-zero and then mouseclick moveViewportH(50); @@ -370,14 +390,15 @@ public class OverviewDimensionsTest { int oldboxx = od.getBoxX(); int oldboxy = od.getBoxY(); mouseClick(od, od.getBoxX() + 5, od.getBoxY() + 2); - assertEquals(od.getBoxX(), oldboxx + 5, 1.5); + assertEquals(od.getBoxX(), oldboxx + 5); assertEquals(od.getBoxWidth(), boxWidth); - assertEquals(od.getBoxHeight(), boxHeight, 1.5); + assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), - (od.getBoxX() / scalew / av.getCharWidth()), 1.5); - assertEquals(od.getBoxY(), oldboxy + 2, 1.5); + Math.round((float) od.getBoxX() * alwidth / od.getWidth())); + assertEquals(od.getBoxY(), oldboxy + 2); assertEquals(od.getScrollRow(), - (od.getBoxY() / scaleh / av.getCharHeight()), 1.5); + Math.round((float) od.getBoxY() * alheight + / od.getSequencesHeight())); // click at top corner mouseClick(od, 0, 0); @@ -386,7 +407,7 @@ public class OverviewDimensionsTest { assertEquals(od.getBoxY(), 0); assertEquals(od.getScrollRow(), 0); assertEquals(od.getBoxWidth(), boxWidth); - assertEquals(od.getBoxHeight(), boxHeight, 1.5); + assertEquals(od.getBoxHeight(), boxHeight); } /** @@ -410,7 +431,8 @@ public class OverviewDimensionsTest { od.setBoxPosition(); assertEquals(od.getBoxX(), - Math.round((lastHiddenCol + 1) * scalew * av.getCharWidth())); + Math.round((float) (lastHiddenCol + 1) * od.getWidth() + / alwidth)); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); @@ -419,21 +441,20 @@ public class OverviewDimensionsTest { /* int xpos = 10; mouseClick(od, xpos, 0); assertEquals(od.getBoxX(), - Math.round ((lastHiddenCol + 1) * scalew * av.getCharWidth())); + Math.round ((lastHiddenCol + 1) * od.getWidth() / alwidth)); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollRow(), 0); assertEquals(od.getScrollCol(), - Math.round (xpos / scalew / av.getCharWidth())); + Math.round (xpos * alwidth / od.getWidth())); */ // click to right of hidden columns, box moves to click point testBoxIsAtClickPoint(40, 0); assertEquals(od.getScrollRow(), 0); assertEquals(od.getScrollCol(), - Math.round(40 / scalew / av.getCharWidth()) - - lastHiddenCol, - 1.5); + Math.round((float) 40 * alwidth / od.getWidth()) + - (lastHiddenCol + 1)); // click to right of hidden columns such that box runs over right hand side // of alignment @@ -441,16 +462,16 @@ public class OverviewDimensionsTest { // overly large boxX value reset to width-boxWidth int xpos = 100; mouseClick(od, xpos, 5); - assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth(), 1.5); + assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth()); assertEquals(od.getBoxY(), 5); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), - Math.round(od.getBoxX() / scalew / av.getCharWidth()) - - lastHiddenCol, 1.5); + Math.round((float) od.getBoxX() * alwidth / od.getWidth()) + - (lastHiddenCol + 1)); assertEquals(od.getScrollRow(), - Math.round(od.getBoxY() / scaleh / av.getCharHeight())); - + Math.round((float) od.getBoxY() * alheight + / od.getSequencesHeight())); } /** @@ -478,7 +499,7 @@ public class OverviewDimensionsTest { assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getScrollCol(), 0); assertEquals(od.getScrollRow(), 0); - + // move box so that it overlaps with hidden cols on one side // box width changes, boxX and scrollCol as for unhidden case int xpos = 50 - boxWidth; // 50 is position in overview halfway between cols @@ -488,11 +509,11 @@ public class OverviewDimensionsTest { assertEquals(od.getBoxY(), 0); assertEquals( od.getBoxWidth(), - Math.round(boxWidth + (lastHidden - firstHidden + 1) * scalew - * av.getCharWidth())); + Math.round(boxWidth + (float) (lastHidden - firstHidden + 1) + * od.getWidth() / alwidth)); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), - Math.round(xpos / scalew / av.getCharWidth())); + Math.round(xpos * alwidth / od.getWidth())); assertEquals(od.getScrollRow(), 0); // move box so that it completely covers hidden cols @@ -503,11 +524,11 @@ public class OverviewDimensionsTest { assertEquals(od.getBoxY(), 0); assertEquals( od.getBoxWidth(), - Math.round(boxWidth + (lastHidden - firstHidden + 1) * scalew - * av.getCharWidth())); + Math.round(boxWidth + (float) (lastHidden - firstHidden + 1) + * od.getWidth() / alwidth)); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), - Math.round(xpos / scalew / av.getCharWidth()), 1.5); + Math.round(xpos * alwidth / od.getWidth())); assertEquals(od.getScrollRow(), 0); // move box so boxX is in hidden cols, box overhangs at right @@ -517,12 +538,12 @@ public class OverviewDimensionsTest { /* xpos = 50; mouseClick(od, xpos, 0); assertEquals(od.getBoxX(), - (lastHidden + 1) * scalew * av.getCharWidth(), 1.5); + (lastHidden + 1) * scalew * av.getCharWidth()); assertEquals(od.getBoxY(), 0); - assertEquals(od.getBoxWidth(), boxWidth, 1.5); + assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), - Math.round(xpos / scalew / av.getCharWidth()), 1.5); + Math.round(xpos * alwidth / od.getWidth())); assertEquals(od.getScrollRow(), 0);*/ // move box so boxX is to right of hidden cols, but does not go beyond full @@ -538,22 +559,23 @@ public class OverviewDimensionsTest { testBoxIsAtClickPoint(xpos, 0); assertEquals(od.getScrollRow(), 0); assertEquals(od.getScrollCol(), - Math.round(xpos / scalew / av.getCharWidth()) - - lastHidden, 1.5);*/ + Math.round(xpos * alwidth / od.getWidth()) + - lastHidden);*/ // move box so it goes beyond full width of alignment // boxX, scrollCol adjusted back, box width normal xpos = 3000; mouseClick(od, xpos, 5); - assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth(), 1.5); + assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth()); assertEquals(od.getBoxY(), 5); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), - Math.round((od.getBoxX() / scalew / av.getCharWidth()) + Math.round(((float) od.getBoxX() * alwidth / od.getWidth()) - (lastHidden - firstHidden + 1))); assertEquals(od.getScrollRow(), - Math.round(od.getBoxY() / scaleh / av.getCharHeight())); + Math.round((float) od.getBoxY() * alheight + / od.getSequencesHeight())); } @@ -588,7 +610,7 @@ public class OverviewDimensionsTest { testBoxIsAtClickPoint(xpos, 0); assertEquals(od.getScrollRow(), 0); assertEquals(od.getScrollCol(), - Math.round(xpos / scalew / av.getCharWidth()), 1.5); + Math.round((float) xpos * alwidth / od.getWidth())); // click to left of hidden cols, with overlap // boxX and scrollCol adjusted for hidden cols, width normal @@ -599,12 +621,12 @@ public class OverviewDimensionsTest { assertEquals( od.getBoxX(), Math.round((firstHidden - 1) * scalew * av.getCharWidth()) - - od.getBoxWidth(), 1.5); + - od.getBoxWidth()); assertEquals(od.getBoxY(), 0); - assertEquals(od.getBoxWidth(), boxWidth, 1.5); + assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), - Math.round(od.getBoxX() / scalew / av.getCharWidth()), 1.5); + Math.round(od.getBoxX() * alwidth / od.getWidth())); assertEquals(od.getScrollRow(), 0);*/ // click in hidden cols @@ -614,12 +636,12 @@ public class OverviewDimensionsTest { assertEquals( od.getBoxX(), Math.round((firstHidden - 1) * scalew * av.getCharWidth()) - - od.getBoxWidth(), 1.5); + - od.getBoxWidth()); assertEquals(od.getBoxY(), 0); - assertEquals(od.getBoxWidth(), boxWidth, 1.5); + assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), - Math.round(od.getBoxX() / scalew / av.getCharWidth()), 1.5); + Math.round(od.getBoxX() * alwidth / od.getWidth())); assertEquals(od.getScrollRow(), 0);*/ // click off end of alignment @@ -629,12 +651,12 @@ public class OverviewDimensionsTest { assertEquals( od.getBoxX(), Math.round((firstHidden - 1) * scalew * av.getCharWidth()) - - od.getBoxWidth(), 1.5); + - od.getBoxWidth()); assertEquals(od.getBoxY(), 0); - assertEquals(od.getBoxWidth(), boxWidth, 1.5); + assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), - Math.round(od.getBoxX() / scalew / av.getCharWidth()), 1.5); + Math.round(od.getBoxX() * alwidth / od.getWidth())); assertEquals(od.getScrollRow(), 0);*/ } @@ -654,25 +676,28 @@ public class OverviewDimensionsTest { // move viewport to right moveViewportH(70); - assertEquals(od.getBoxX(), Math.round(70 * scalew * av.getCharWidth())); + assertEquals(od.getBoxX(), + Math.round((float) 70 * od.getWidth() / alwidth)); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); // move viewport down moveViewportV(100); - assertEquals(od.getBoxX(), Math.round(70 * scalew * av.getCharWidth())); + assertEquals(od.getBoxX(), + Math.round((float) 70 * od.getWidth() / alwidth)); assertEquals(od.getBoxY(), - Math.round(100 * scaleh * av.getCharHeight())); + Math.round(100 * od.getSequencesHeight() / alheight)); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); // move viewport to bottom right moveViewport(98, 508); - assertEquals(od.getBoxX(), Math.round(98 * scalew * av.getCharWidth())); + assertEquals(od.getBoxX(), + Math.round((float) 98 * od.getWidth() / alwidth)); assertEquals(od.getBoxY(), - Math.round(508 * scaleh * av.getCharHeight())); - assertEquals(od.getBoxWidth(), boxWidth, 1.5); + Math.round((float) 508 * od.getSequencesHeight() / alheight)); + assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); } @@ -690,7 +715,7 @@ public class OverviewDimensionsTest { // move viewport to start of alignment moveViewport(0, 0); assertEquals(od.getBoxX(), - Math.round((lastHidden + 1) * scalew * av.getCharWidth())); + Math.round((float) (lastHidden + 1) * od.getWidth() / alwidth)); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); @@ -698,7 +723,8 @@ public class OverviewDimensionsTest { // move viewport to end of alignment - need to make startRes by removing // hidden cols because of how viewport/overview are implemented moveViewport(98 - lastHidden - 1, 0); - assertEquals(od.getBoxX(), Math.round(98 * scalew * av.getCharWidth())); + assertEquals(od.getBoxX(), + Math.round((float) 98 * od.getWidth() / alwidth)); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); @@ -718,7 +744,8 @@ public class OverviewDimensionsTest { // move viewport before hidden columns moveViewport(3, 0); - assertEquals(od.getBoxX(), Math.round(3 * scalew * av.getCharWidth())); + assertEquals(od.getBoxX(), + Math.round((float) 3 * od.getWidth() / alwidth)); assertEquals(od.getBoxY(), 0); System.out.println(od.getBoxWidth()); assertEquals(od.getBoxWidth(), boxWidth); @@ -727,30 +754,32 @@ public class OverviewDimensionsTest { // move viewport to left of hidden columns with overlap moveViewport(10, 0); - assertEquals(od.getBoxX(), Math.round(10 * scalew * av.getCharWidth())); + assertEquals(od.getBoxX(), + Math.round((float) 10 * od.getWidth() / alwidth)); assertEquals(od.getBoxY(), 0); assertEquals( od.getBoxWidth(), boxWidth - + Math.round((lastHidden - firstHidden + 1) * scalew - * av.getCharWidth())); + + Math.round((float) (lastHidden - firstHidden + 1) + * od.getWidth() / alwidth)); assertEquals(od.getBoxHeight(), boxHeight); // move viewport to straddle hidden columns moveViewport(60, 0); - assertEquals(od.getBoxX(), Math.round(60 * scalew * av.getCharWidth())); + assertEquals(od.getBoxX(), + Math.round((float) 60 * od.getWidth() / alwidth)); assertEquals(od.getBoxY(), 0); assertEquals( od.getBoxWidth(), boxWidth - + Math.round((lastHidden - firstHidden + 1) * scalew - * av -.getCharWidth())); + + Math.round((lastHidden - firstHidden + 1) + * od.getWidth() / alwidth)); assertEquals(od.getBoxHeight(), boxHeight); // move viewport to right of hidden columns, no overlap moveViewport(80 - (lastHidden - firstHidden + 1), 0); - assertEquals(od.getBoxX(), Math.round(80 * scalew * av.getCharWidth())); + assertEquals(od.getBoxX(), + Math.round((float) 80 * od.getWidth() / alwidth)); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); @@ -770,8 +799,8 @@ public class OverviewDimensionsTest { // move viewport before hidden columns moveViewport(3, 0); - assertEquals(od.getBoxX(), Math.round(3 * scalew * av.getCharWidth()), - 1.5); + assertEquals(od.getBoxX(), + Math.round((float) 3 * od.getWidth() / alwidth)); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); @@ -779,14 +808,14 @@ public class OverviewDimensionsTest { // move viewport to hidden columns // TODO boxwidth includes hidden in overview panel (why?) moveViewport(98, 0); - assertEquals(od.getBoxX(), Math.round(98 * scalew * av.getCharWidth()), - 1.5); + assertEquals(od.getBoxX(), + Math.round((float) 98 * od.getWidth() / alwidth)); assertEquals(od.getBoxY(), 0); assertEquals( od.getBoxWidth(), boxWidth - + Math.round((lastHidden - firstHidden + 1) * scalew - * av.getCharWidth()), 1.5); + + Math.round((float) (lastHidden - firstHidden + 1) + * od.getWidth() / alwidth)); assertEquals(od.getBoxHeight(), boxHeight); } @@ -806,7 +835,8 @@ public class OverviewDimensionsTest { moveViewport(0, 0); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), - Math.round((lastHidden + 1) * scaleh * av.getCharHeight())); + Math.round((float) (lastHidden + 1) * od.getSequencesHeight() + / alheight)); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); @@ -823,9 +853,9 @@ public class OverviewDimensionsTest { assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), (525 - viewHeight) * scaleh - * av.getCharHeight(), 1.5); - assertEquals(od.getBoxWidth(), boxWidth, 1.5); - assertEquals(od.getBoxHeight(), boxHeight, 1.5);*/ + * av.getCharHeight()); + assertEquals(od.getBoxWidth(), boxWidth); + assertEquals(od.getBoxHeight(), boxHeight);*/ } /** @@ -845,8 +875,8 @@ public class OverviewDimensionsTest { /*moveViewport(0, 0); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); - assertEquals(od.getBoxWidth(), boxWidth, 1.5); - assertEquals(od.getBoxHeight(), boxHeight, 1.5);*/ + assertEquals(od.getBoxWidth(), boxWidth); + assertEquals(od.getBoxHeight(), boxHeight);*/ // move viewport to straddle hidden rows // TODO also fails with boxY out by 12 @@ -854,7 +884,7 @@ public class OverviewDimensionsTest { assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), Math.round (198 * scaleh * av.getCharHeight()), 1.5); - assertEquals(od.getBoxWidth(), boxWidth, 1.5); + assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight + ((lastHidden - firstHidden) * scaleh * av.getCharHeight()), 1.5);*/ @@ -885,13 +915,13 @@ public class OverviewDimensionsTest { assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), Math.round ((firstHidden - viewHeight - 1) - * scaleh * av.getCharHeight()), 1.5); - assertEquals(od.getBoxWidth(), boxWidth, 1.5); + * scaleh * av.getCharHeight())); + assertEquals(od.getBoxWidth(), boxWidth); assertEquals( od.getBoxHeight(), boxHeight + Math.round ((lastHidden - firstHidden + 1) * scaleh * av - .getCharHeight()), 1.5);*/ + .getCharHeight()));*/ } @@ -918,7 +948,8 @@ public class OverviewDimensionsTest { od.setBoxPosition(); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), - Math.round((lastHiddenRow + 1) * scaleh * av.getCharHeight())); + Math.round((float) (lastHiddenRow + 1) + * od.getSequencesHeight() / alheight)); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); @@ -927,7 +958,7 @@ public class OverviewDimensionsTest { /* mouseClick(od, 0, 0); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); - assertEquals(od.getBoxWidth(), boxWidth, 1.5); + assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight + Math.round ((lastHiddenRow + 1) * scaleh * av.getCharHeight()), 1.5);*/ @@ -935,7 +966,7 @@ public class OverviewDimensionsTest { // click below hidden rows mouseClick(od, 0, 150); assertEquals(od.getBoxX(), 0); - assertEquals(od.getBoxY(), 150, 1.5); + assertEquals(od.getBoxY(), 150); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); } @@ -947,12 +978,8 @@ public class OverviewDimensionsTest { @Test(groups = { "Functional" }) public void testFromMouseWithHiddenRowsInMiddle() { - assertEquals(od.getBoxHeight(), 10); - od.setBoxPositionByMouse(0, 0); - assertEquals(od.getBoxHeight(), 10); - assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); @@ -964,12 +991,9 @@ public class OverviewDimensionsTest { // no changes int firstHiddenRow = 50; int lastHiddenRow = 60; - assertEquals(od.getBoxHeight(), 10); hideSequences(firstHiddenRow, lastHiddenRow + 1, lastHiddenRow + 1); - assertEquals(od.getBoxHeight(), 10); od.setBoxPosition(); - assertEquals(od.getBoxHeight(), 10); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); @@ -980,31 +1004,31 @@ public class OverviewDimensionsTest { int ypos = 40; // TODO test fails because box does not change height - dealt with by scroll // values - /* mouseClick(od, 0, Math.round (ypos / scaleh / av.getCharHeight())); + /* mouseClick(od, 0, Math.round (ypos * alheight / od.getSequencesHeight())); assertEquals(od.getBoxX(), 0); - assertEquals(od.getBoxY(), Math.round (ypos / scaleh / av.getCharHeight()), + assertEquals(od.getBoxY(), Math.round (ypos * alheight / od.getSequencesHeight()), 1.5); - assertEquals(od.getBoxWidth(), boxWidth, 1.5); + assertEquals(od.getBoxWidth(), boxWidth); assertEquals( od.getBoxHeight(), boxHeight + Math.round ((lastHiddenRow - firstHiddenRow + 1) / scaleh / av - .getCharHeight()), 1.5); + .getCharHeight())); */ // 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 / scaleh / av.getCharHeight())); + /*mouseClick(od, 0, Math.round (ypos * alheight / od.getSequencesHeight())); assertEquals(od.getBoxX(), 0); - assertEquals(od.getBoxY(), Math.round (ypos / scaleh / av.getCharHeight()), + assertEquals(od.getBoxY(), Math.round (ypos * alheight / od.getSequencesHeight()), 1.5); - assertEquals(od.getBoxWidth(), boxWidth, 1.5); + assertEquals(od.getBoxWidth(), boxWidth); assertEquals( od.getBoxHeight(), boxHeight + Math.round ((lastHiddenRow - firstHiddenRow + 1) / scaleh / av - .getCharHeight()), 1.5);*/ + .getCharHeight()));*/ } /** @@ -1036,10 +1060,11 @@ public class OverviewDimensionsTest { // click above hidden rows int ypos = 40; // row 40 - 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(ypos * scaleh * av.getCharHeight())); + Math.round((float) ypos * od.getSequencesHeight() / alheight)); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); @@ -1054,8 +1079,8 @@ public class OverviewDimensionsTest { od.getBoxY(), Math.round ((firstHidden - viewHeight) * scaleh * av.getCharHeight()), 1.5); - assertEquals(od.getBoxWidth(), boxWidth, 1.5); - assertEquals(od.getBoxHeight(), boxHeight, 1.5);*/ + assertEquals(od.getBoxWidth(), boxWidth); + assertEquals(od.getBoxHeight(), boxHeight);*/ // click within hidden rows ypos = 505; @@ -1066,8 +1091,8 @@ public class OverviewDimensionsTest { od.getBoxY(), Math.round ((firstHidden - viewHeight) * scaleh * av.getCharHeight()), 1.5); - assertEquals(od.getBoxWidth(), boxWidth, 1.5); - assertEquals(od.getBoxHeight(), boxHeight, 1.5);*/ + assertEquals(od.getBoxWidth(), boxWidth); + assertEquals(od.getBoxHeight(), boxHeight);*/ } /* @@ -1075,9 +1100,8 @@ public class OverviewDimensionsTest { */ private void moveViewportH(int startRes) { - int width = av.getEndRes() - av.getStartRes(); av.setStartRes(startRes); - av.setEndRes(startRes + width); + av.setEndRes(startRes + viewWidth); od.setBoxPosition(); } @@ -1096,10 +1120,8 @@ public class OverviewDimensionsTest { */ private void moveViewport(int startRes, int startSeq) { - int width = av.getEndRes() - av.getStartRes(); - av.setStartRes(startRes); - av.setEndRes(startRes + width); + av.setEndRes(startRes + viewWidth); av.setStartSeq(startSeq); av.setEndSeq(startSeq + viewHeight); od.setBoxPosition(); @@ -1114,22 +1136,22 @@ public class OverviewDimensionsTest { // updates require an OverviewPanel to exist which it doesn't here // so call setBoxPosition() as it would be called by the AlignmentPanel // normally - int width = av.getEndRes() - av.getStartRes(); - int height = av.getEndSeq() - av.getStartSeq(); + // int width = av.getEndRes() - av.getStartRes(); + // int height = av.getEndSeq() - av.getStartSeq(); av.setStartRes(od.getScrollCol()); - av.setEndRes(od.getScrollCol() + width); + av.setEndRes(od.getScrollCol() + viewWidth); av.setStartSeq(od.getScrollRow()); - av.setEndSeq(od.getScrollRow() + height); + av.setEndSeq(od.getScrollRow() + viewHeight); od.setBoxPosition(); } private void testBoxIsAtClickPoint(int xpos, int ypos) { mouseClick(od, xpos, ypos); - assertEquals(od.getBoxX(), xpos, 1.5); - assertEquals(od.getBoxY(), ypos, 1.5); - assertEquals(od.getBoxWidth(), boxWidth, 1.5); - assertEquals(od.getBoxHeight(), boxHeight, 1.5); + assertEquals(od.getBoxX(), xpos); + assertEquals(od.getBoxY(), ypos); + assertEquals(od.getBoxWidth(), boxWidth); + assertEquals(od.getBoxHeight(), boxHeight); } -- 1.7.10.2