// cached widths and heights
int boxWidth;
+
int boxHeight;
+
int viewHeight;
+
int viewWidth;
+
int alheight;
+
int alwidth;
ViewportRanges vpranges;
}
ColumnSelection colsel = new ColumnSelection();
hiddenCols.revealAllHiddenColumns(colsel);
-
+
vpranges = new ViewportRanges(al);
vpranges.setViewportStartAndHeight(0, 18);
vpranges.setViewportStartAndWidth(0, 63);
alheight = vpranges.getVisibleAlignmentHeight();
alwidth = vpranges.getVisibleAlignmentWidth();
- boxWidth = Math.round((float) (vpranges.getEndRes()
- - vpranges.getStartRes() + 1)
- * od.getWidth() / alwidth);
- boxHeight = Math.round((float) (vpranges.getEndSeq()
- - vpranges.getStartSeq() + 1)
- * od.getSequencesHeight() / alheight);
+ boxWidth = Math.round(
+ (float) (vpranges.getEndRes() - vpranges.getStartRes() + 1)
+ * od.getWidth() / alwidth);
+ boxHeight = Math.round(
+ (float) (vpranges.getEndSeq() - vpranges.getStartSeq() + 1)
+ * od.getSequencesHeight() / alheight);
}
@AfterClass(alwaysRun = true)
assertEquals(od.getBoxHeight(), boxHeight);
assertEquals(vpranges.getStartRes(),
Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
- assertEquals(
- vpranges.getStartSeq(),
- Math.round((float) od.getBoxY() * alheight
- / od.getSequencesHeight()));
+ assertEquals(vpranges.getStartSeq(), Math.round(
+ (float) od.getBoxY() * alheight / od.getSequencesHeight()));
// overly large boxY value reset to sequenceHeight - boxHeight
mouseClick(od, 10, 520);
// 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(
- vpranges.getStartSeq(),
- Math.round((float) od.getBoxY() * alheight
- / od.getSequencesHeight()) - 1);
+ assertEquals(vpranges.getStartSeq(), Math.round(
+ (float) od.getBoxY() * alheight / od.getSequencesHeight()) - 1);
// click past end of alignment, as above
mouseClick(od, 3000, 5);
assertEquals(od.getBoxHeight(), boxHeight);
assertEquals(vpranges.getStartRes(),
Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
- assertEquals(
- vpranges.getStartSeq(),
- Math.round((float) od.getBoxY() * alheight
- / od.getSequencesHeight()));
+ assertEquals(vpranges.getStartSeq(), Math.round(
+ (float) od.getBoxY() * alheight / od.getSequencesHeight()));
// move viewport so startRes non-zero and then mouseclick
moveViewportH(20);
assertEquals(vpranges.getStartRes(),
Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
assertEquals(od.getBoxY(), oldboxy + 3);
- assertEquals(
- vpranges.getStartSeq(),
- Math.round((float) od.getBoxY() * alheight
- / od.getSequencesHeight()));
+ assertEquals(vpranges.getStartSeq(), Math.round(
+ (float) od.getBoxY() * alheight / od.getSequencesHeight()));
// click at top corner
mouseClick(od, 0, 0);
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(vpranges.getStartRes(), 0);
assertEquals(vpranges.getStartSeq(), 0);
-
+
// hide columns 63-73, no change to box position or dimensions
int firstHidden = 63;
int lastHidden = 73;
// move box so that it overlaps with hidden cols on one side
// box width, boxX and scrollCol as for unhidden case
int xpos = 54 - boxWidth / 2; // 54 is position in overview approx halfway
- // between cols 60 and 70
+ // between cols 60 and 70
mouseClick(od, xpos, boxHeight / 2);
testBoxIsAtClickPoint(xpos, boxHeight / 2);
assertEquals(vpranges.getStartRes(), 1 + // rounding
xpos = 33;
mouseClick(od, xpos, boxHeight / 2);
testBoxIsAtClickPoint(xpos, boxHeight / 2);
- assertEquals(vpranges.getStartRes(),
- Math.round((float) (xpos - boxWidth / 2) * alwidth
- / od.getWidth()));
+ assertEquals(vpranges.getStartRes(), Math.round(
+ (float) (xpos - boxWidth / 2) * alwidth / od.getWidth()));
assertEquals(vpranges.getStartSeq(), 0);
// move box so boxX is in hidden cols, box overhangs at right
assertEquals(od.getBoxHeight(), boxHeight);
assertEquals(vpranges.getStartSeq(), 0);
assertEquals(vpranges.getStartRes(), 75);
-
+
// move box so it goes beyond full width of alignment
// boxX, scrollCol adjusted back, box width normal
xpos = 3000;
xpos = Math.round((float) 144 * od.getWidth() / alwidth) - boxWidth;
mouseClick(od, xpos, boxHeight / 2);
testBoxIsAtClickPoint(xpos, boxHeight / 2);
- assertEquals(vpranges.getStartRes(),
- Math.round((float) (xpos - boxWidth / 2) * alwidth
- / od.getWidth()));
+ assertEquals(vpranges.getStartRes(), Math.round(
+ (float) (xpos - boxWidth / 2) * alwidth / od.getWidth()));
assertEquals(vpranges.getStartSeq(), 0);
// click off end of alignment
// 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((float) (98 - lastHidden - 1) * od.getWidth()
- / alwidth));
+ assertEquals(od.getBoxX(), Math.round(
+ (float) (98 - lastHidden - 1) * od.getWidth() / alwidth));
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
// viewport can't actually extend into hidden cols,
// so move to the far right edge of the viewport
moveViewport(firstHidden - viewWidth, 0);
- assertEquals(od.getBoxX(),
- Math.round((float) (firstHidden - viewWidth)
- * od.getWidth() / alwidth));
+ assertEquals(od.getBoxX(), Math.round(
+ (float) (firstHidden - viewWidth) * od.getWidth() / alwidth));
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
alheight = vpranges.getVisibleAlignmentHeight();
alwidth = vpranges.getVisibleAlignmentWidth();
- boxWidth = Math.round((float) (vpranges.getEndRes()
- - vpranges.getStartRes() + 1)
- * od.getWidth() / alwidth);
- boxHeight = Math.round((float) (vpranges.getEndSeq()
- - vpranges.getStartSeq() + 1)
- * od.getSequencesHeight() / alheight);
+ boxWidth = Math.round(
+ (float) (vpranges.getEndRes() - vpranges.getStartRes() + 1)
+ * od.getWidth() / alwidth);
+ boxHeight = Math.round(
+ (float) (vpranges.getEndSeq() - vpranges.getStartSeq() + 1)
+ * od.getSequencesHeight() / alheight);
// move viewport to start of alignment:
// box moves to below hidden rows, height remains same
// move viewport to end of alignment
moveViewport(0, 525 - viewHeight - lastHidden - 1);
assertEquals(od.getBoxX(), 0);
- assertEquals(
- od.getBoxY(),
+ assertEquals(od.getBoxY(),
Math.round((float) (525 - viewHeight - lastHidden - 1)
- * od.getSequencesHeight()
- / alheight));
+ * od.getSequencesHeight() / alheight));
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
}
alheight = vpranges.getVisibleAlignmentHeight();
alwidth = vpranges.getVisibleAlignmentWidth();
- boxWidth = Math.round((float) (vpranges.getEndRes()
- - vpranges.getStartRes() + 1)
- * od.getWidth() / alwidth);
- boxHeight = Math.round((float) (vpranges.getEndSeq()
- - vpranges.getStartSeq() + 1)
- * od.getSequencesHeight() / alheight);
+ boxWidth = Math.round(
+ (float) (vpranges.getEndRes() - vpranges.getStartRes() + 1)
+ * od.getWidth() / alwidth);
+ boxHeight = Math.round(
+ (float) (vpranges.getEndSeq() - vpranges.getStartSeq() + 1)
+ * od.getSequencesHeight() / alheight);
// move viewport to start of alignment:
// box, height etc as in non-hidden case
// move viewport to straddle hidden rows
moveViewport(0, 198);
assertEquals(od.getBoxX(), 0);
- assertEquals(od.getBoxY(), Math.round ((float)198 * od.getSequencesHeight()
- / alheight));
+ assertEquals(od.getBoxY(),
+ Math.round((float) 198 * od.getSequencesHeight() / alheight));
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
}
alheight = vpranges.getVisibleAlignmentHeight();
alwidth = vpranges.getVisibleAlignmentWidth();
- boxWidth = Math.round((float) (vpranges.getEndRes()
- - vpranges.getStartRes() + 1)
- * od.getWidth() / alwidth);
- boxHeight = Math.round((float) (vpranges.getEndSeq()
- - vpranges.getStartSeq() + 1)
- * od.getSequencesHeight() / alheight);
+ boxWidth = Math.round(
+ (float) (vpranges.getEndRes() - vpranges.getStartRes() + 1)
+ * od.getWidth() / alwidth);
+ boxHeight = Math.round(
+ (float) (vpranges.getEndSeq() - vpranges.getStartSeq() + 1)
+ * od.getSequencesHeight() / alheight);
// move viewport to start of alignment:
// box, height etc as in non-hidden case
// viewport sits above hidden rows and does not include them
moveViewport(0, firstHidden - viewHeight - 1);
assertEquals(od.getBoxX(), 0);
- assertEquals(
- od.getBoxY(),
+ assertEquals(od.getBoxY(),
Math.round((float) (firstHidden - viewHeight - 1)
* od.getSequencesHeight() / alheight));
assertEquals(od.getBoxWidth(), boxWidth);
alheight = vpranges.getVisibleAlignmentHeight();
alwidth = vpranges.getVisibleAlignmentWidth();
- boxWidth = Math.round((float) (vpranges.getEndRes()
- - vpranges.getStartRes() + 1)
- * od.getWidth() / alwidth);
- boxHeight = Math.round((float) (vpranges.getEndSeq()
- - vpranges.getStartSeq() + 1)
- * od.getSequencesHeight() / alheight);
+ boxWidth = Math.round(
+ (float) (vpranges.getEndRes() - vpranges.getStartRes() + 1)
+ * od.getWidth() / alwidth);
+ boxHeight = Math.round(
+ (float) (vpranges.getEndSeq() - vpranges.getStartSeq() + 1)
+ * od.getSequencesHeight() / alheight);
od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
assertEquals(od.getBoxX(), 0);
alheight = vpranges.getVisibleAlignmentHeight();
alwidth = vpranges.getVisibleAlignmentWidth();
- boxWidth = Math.round((float) (vpranges.getEndRes()
- - vpranges.getStartRes() + 1)
- * od.getWidth() / alwidth);
- boxHeight = Math.round((float) (vpranges.getEndSeq()
- - vpranges.getStartSeq() + 1)
- * od.getSequencesHeight() / alheight);
+ boxWidth = Math.round(
+ (float) (vpranges.getEndRes() - vpranges.getStartRes() + 1)
+ * od.getWidth() / alwidth);
+ boxHeight = Math.round(
+ (float) (vpranges.getEndSeq() - vpranges.getStartSeq() + 1)
+ * od.getSequencesHeight() / alheight);
od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
alheight = vpranges.getVisibleAlignmentHeight();
alwidth = vpranges.getVisibleAlignmentWidth();
- boxWidth = Math.round((float) (vpranges.getEndRes()
- - vpranges.getStartRes() + 1)
- * od.getWidth() / alwidth);
- boxHeight = Math.round((float) (vpranges.getEndSeq()
- - vpranges.getStartSeq() + 1)
- * od.getSequencesHeight() / alheight);
+ boxWidth = Math.round(
+ (float) (vpranges.getEndRes() - vpranges.getStartRes() + 1)
+ * od.getWidth() / alwidth);
+ boxHeight = Math.round(
+ (float) (vpranges.getEndSeq() - vpranges.getStartSeq() + 1)
+ * od.getSequencesHeight() / alheight);
od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
assertEquals(od.getBoxX(), 0);
mouseClick(od, 0,
Math.round((float) ypos * od.getSequencesHeight() / alheight));
assertEquals(od.getBoxX(), 0);
- assertEquals(
- od.getBoxY(),
- Math.round((float) firstHidden * od.getSequencesHeight()
- / alheight)
- - boxHeight);
+ assertEquals(od.getBoxY(), Math
+ .round((float) firstHidden * od.getSequencesHeight() / alheight)
+ - boxHeight);
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
}
public void testDragging()
{
od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
- od.setDragPoint(4, 16, al.getHiddenSequences(),
- hiddenCols);
- od.adjustViewportFromMouse(20, 22,
- al.getHiddenSequences(), hiddenCols);
+ od.setDragPoint(4, 16, al.getHiddenSequences(), hiddenCols);
+ od.adjustViewportFromMouse(20, 22, al.getHiddenSequences(), hiddenCols);
// updates require an OverviewPanel to exist which it doesn't here
// so call setBoxPosition() as it would be called by the AlignmentPanel
// corner moves 16 (20-4) right and 6 (22-16) up
assertEquals(od.getBoxX(), 16);
assertEquals(od.getBoxY(), 6);
+
+ // hide columns - makes no difference
+ hiddenCols.hideColumns(1, 4);
+ od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
+ od.setDragPoint(4, 16, al.getHiddenSequences(), hiddenCols);
+ od.adjustViewportFromMouse(20, 22, al.getHiddenSequences(), hiddenCols);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
+
+ // corner moves 16 (20-4) right and 6 (22-16) up
+ assertEquals(od.getBoxX(), 16);
+ assertEquals(od.getBoxY(), 6);
+
+ // hide sequences in box area
+ // makes absolutely no difference
+ hideSequences(1, 3);
+ od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
+ od.setDragPoint(4, 16, al.getHiddenSequences(), hiddenCols);
+ od.adjustViewportFromMouse(20, 22, al.getHiddenSequences(), hiddenCols);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
+
+ // corner moves 16 (20-4) right and 6 (22-16) up
+ assertEquals(od.getBoxX(), 16);
+ assertEquals(od.getBoxY(), 6);
}
/*
// normally
od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
}
-
+
/*
* Test that the box is positioned with the top left corner at xpos, ypos
* and with the original width and height
{
SequenceI[] allseqs = al.getSequencesArray();
SequenceGroup theseSeqs = new SequenceGroup();
-
+
for (int i = start; i <= end; i++)
{
theseSeqs.addSequence(allseqs[i], false);