import static org.testng.Assert.assertEquals;
import jalview.analysis.AlignmentGenerator;
-import jalview.bin.Cache;
import jalview.bin.Jalview;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
AlignFrame af;
AlignViewport av;
-
AlignmentI al;
OverviewDimensions od;
+ // cached widths and heights
int boxWidth;
int boxHeight;
int viewHeight;
Jalview.main(new String[] { "-nonews", "-props",
"test/jalview/testProps.jvprops" });
- Cache.applicationProperties.setProperty("SHOW_IDENTITY",
- Boolean.TRUE.toString());
af = new FileLoader().LoadFileWaitTillLoaded(al.toString(),
DataSourceType.PASTE);
od.setBoxPosition(av.getAlignment()
.getHiddenSequences(), av.getColumnSelection(), av.getPosProps());
- init();
- }
-
- private void init()
- {
av.showAllHiddenColumns();
av.showAllHiddenSeqs();
av.setSelectionGroup(null);
try
{
Thread.sleep(50);
+ av.getAlignPanel().setScrollValues(0, 0);
viewHeight = av.getEndSeq() - av.getStartSeq();
viewWidth = av.getEndRes() - av.getStartRes();
} catch (InterruptedException e)
// 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(od.getBoxX(),
- 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 * alwidth / od.getWidth()));
- */
+ int xpos = 10;
+ mouseClick(od, xpos, 0);
+ assertEquals(
+ od.getBoxX(),
+ Math.round((float) (lastHiddenCol + 1) * od.getWidth()
+ / alwidth));
+ assertEquals(od.getBoxY(), 0);
+ assertEquals(od.getBoxWidth(), boxWidth);
+ assertEquals(od.getBoxHeight(), boxHeight);
+ assertEquals(od.getScrollRow(), 0);
+ assertEquals(od.getScrollCol(), 0);
+
// click to right of hidden columns, box moves to click point
testBoxIsAtClickPoint(40, 0);
assertEquals(od.getScrollRow(), 0);
// of alignment
// box position is adjusted away from the edge
// overly large boxX value reset to width-boxWidth
- int xpos = 100;
+ xpos = 100;
mouseClick(od, xpos, 5);
assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth());
assertEquals(od.getBoxY(), 5);
assertEquals(od.getScrollCol(), 0);
assertEquals(od.getScrollRow(), 0);
- // hide columns 60-68, no change to box position or dimensions
+ // hide columns 63-73, no change to box position or dimensions
int firstHidden = 63;
int lastHidden = 73;
hideColumns(firstHidden, lastHidden);
assertEquals(od.getScrollRow(), 0);
// move box so boxX is in hidden cols, box overhangs at right
- // box width back to normal, boxX and scrollCol move to right of hidden area
- // TODO currently this test fails in the Jalview GUI, there is a gap between
- // the rhs of the hidden area and the box
- /* xpos = 50;
- mouseClick(od, xpos, 0);
- assertEquals(od.getBoxX(),
- (lastHidden + 1) * scalew * av.getCharWidth());
- assertEquals(od.getBoxY(), 0);
- assertEquals(od.getBoxWidth(), boxWidth);
- assertEquals(od.getBoxHeight(), boxHeight);
- assertEquals(od.getScrollCol(),
- Math.round(xpos * alwidth / od.getWidth()));
- assertEquals(od.getScrollRow(), 0);*/
+ // boxX and scrollCol at left of hidden area, box width extends across
+ // hidden region
+ xpos = 50;
+ mouseClick(od, xpos, 0);
+ assertEquals(od.getBoxX(),
+ Math.round((float) (firstHidden - 1) * od.getWidth() / alwidth));
+ assertEquals(od.getBoxY(), 0);
+ assertEquals(
+ od.getBoxWidth(),
+ boxWidth
+ + Math.round((float) (lastHidden - firstHidden + 1)
+ * od.getWidth() / alwidth));
+ assertEquals(od.getBoxHeight(), boxHeight);
+ assertEquals(od.getScrollCol(), firstHidden - 1);
+ assertEquals(od.getScrollRow(), 0);
// move box so boxX is to right of hidden cols, but does not go beyond full
// width of alignment
// box width, boxX and scrollCol all as for non-hidden case
- // TODO currently this test fails in the Jalview GUI because boxX is
- // calculated
- // based on the current boxWidth, which includes hidden columns, thereby
- // pushing
- // the box off the end of the alignment. So boxX is adjusted backwards
- // unnecessarily.
- /* xpos = 72;
- testBoxIsAtClickPoint(xpos, 0);
- assertEquals(od.getScrollRow(), 0);
- assertEquals(od.getScrollCol(),
- Math.round(xpos * alwidth / od.getWidth())
- - lastHidden);*/
+ xpos = 75;
+ testBoxIsAtClickPoint(xpos, 0);
+ assertEquals(od.getScrollRow(), 0);
+ assertEquals(od.getScrollCol(),
+ Math.round(xpos * alwidth / od.getWidth())
+ - (lastHidden - firstHidden + 1));
// move box so it goes beyond full width of alignment
// boxX, scrollCol adjusted back, box width normal
assertEquals(od.getScrollCol(), 0);
assertEquals(od.getScrollRow(), 0);
- // hide columns 140-157, no change to box position or dimensions
+ // hide columns 140-164, no change to box position or dimensions
int firstHidden = 140;
- int lastHidden = 157;
+ int lastHidden = 164;
hideColumns(firstHidden, lastHidden);
od.setBoxPosition(av.getAlignment()
.getHiddenSequences(), av.getColumnSelection(), av.getPosProps());
// click to left of hidden cols, with overlap
// boxX and scrollCol adjusted for hidden cols, width normal
- // TODO this fails because setBoxPosition screws up the hidden cols calc
- // only works in GUI because of AlignmentPanel::setScrollValues
- /*xpos = 115 - boxWidth;
- mouseClick(od, xpos, 0);
- 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 = Math.round((float) 145 * od.getWidth() / alwidth) - boxWidth;
+ mouseClick(od, xpos, 0);
+ assertEquals(
+ od.getBoxX(),
+ Math.round((firstHidden - 1) * od.getWidth() / alwidth)
+ - boxWidth);
+ 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);
+ */
// click in hidden cols
// boxX and scrollCol adjusted for hidden cols, width normal
// TODO breaks as above test
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
- // move viewport to end of alignment, need to account for hidden rows
- // because of how alignment panel/overview panel are implemented
-
- // AlignViewport adjusts endSeq using Alignment height which excludes hidden
- // rows if we happen to be at the bottom of the alignment
- // od.setBoxPosition adjusts endSeq to include hidden rows
- // od.checkValid adjusts scroll position to exclude hidden rows
- // TODO this test fails because of the above!
-
- /* moveViewport(0, 525 - viewHeight - lastHidden - 1);
- assertEquals(od.getBoxX(), 0);
- assertEquals(od.getBoxY(),
- (525 - viewHeight) * scaleh
- * av.getCharHeight());
- assertEquals(od.getBoxWidth(), boxWidth);
- assertEquals(od.getBoxHeight(), boxHeight);*/
+ // move viewport to end of alignment
+ moveViewport(0, 525 - viewHeight - lastHidden - 1);
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(
+ od.getBoxY(),
+ Math.round((float) (525 - viewHeight) * od.getSequencesHeight()
+ / alheight));
+ assertEquals(od.getBoxWidth(), boxWidth);
+ assertEquals(od.getBoxHeight(), boxHeight);
}
/**
// move viewport to start of alignment:
// box, height etc as in non-hidden case
- // TODO fails with boxy=12 because that's what setBoxPosition sets it to!
- /*moveViewport(0, 0);
+ moveViewport(0, 0);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
- assertEquals(od.getBoxHeight(), boxHeight);*/
+ assertEquals(od.getBoxHeight(), boxHeight);
// move viewport to straddle hidden rows
- // TODO also fails with boxY out by 12
- /*moveViewport(0, 198);
+ moveViewport(0, 198);
assertEquals(od.getBoxX(), 0);
- assertEquals(od.getBoxY(), Math.round (198 * scaleh * av.getCharHeight()),
- 1.5);
+ assertEquals(od.getBoxY(), Math.round ((float)198 * od.getSequencesHeight()
+ / alheight));
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight
- + ((lastHidden - firstHidden) * scaleh * av.getCharHeight()),
- 1.5);*/
+ + Math.round((float) (lastHidden - firstHidden + 1)
+ * od.getSequencesHeight()
+ / alheight));
}
/**
assertEquals(od.getBoxHeight(), boxHeight);
// move viewport to end of alignment
- // TODO fails with wrong boxHeight who knows why
- /*moveViewport(0, firstHidden - viewHeight - 1);
- assertEquals(od.getBoxX(), 0);
- assertEquals(od.getBoxY(),
- Math.round ((firstHidden - viewHeight - 1)
- * scaleh * av.getCharHeight()));
- assertEquals(od.getBoxWidth(), boxWidth);
- assertEquals(
- od.getBoxHeight(),
- boxHeight
- + Math.round ((lastHidden - firstHidden + 1) * scaleh * av
- .getCharHeight()));*/
+ // viewport sits above hidden rows and does not include them
+ moveViewport(0, firstHidden - viewHeight - 1);
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(
+ od.getBoxY(),
+ Math.round((float) (firstHidden - viewHeight - 1)
+ * od.getSequencesHeight() / alheight));
+ assertEquals(od.getBoxWidth(), boxWidth);
+ assertEquals(od.getBoxHeight(), boxHeight);
}
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
- // click in hidden rows
- // TODO fails because boxHeight is 27 not 25 (possible rounding issue)
- /* mouseClick(od, 0, 0);
- assertEquals(od.getBoxX(), 0);
- assertEquals(od.getBoxY(), 0);
- assertEquals(od.getBoxWidth(), boxWidth);
- assertEquals(od.getBoxHeight(), boxHeight
- + Math.round ((lastHiddenRow + 1) * scaleh * av.getCharHeight()),
- 1.5);*/
+ // click in hidden rows - same result
+ mouseClick(od, 0, 0);
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(
+ od.getBoxY(),
+ Math.round((float) (lastHiddenRow + 1)
+ * od.getSequencesHeight() / alheight));
+ assertEquals(od.getBoxWidth(), boxWidth);
+ assertEquals(od.getBoxHeight(), boxHeight);
// click below hidden rows
mouseClick(od, 0, 150);