int alheight;
int alwidth;
- ViewportPositionProps posProps;
+ ViewportRanges vpranges;
Hashtable<SequenceI, SequenceCollectionI> hiddenRepSequences = new Hashtable<SequenceI, SequenceCollectionI>();
}
hiddenCols.revealAllHiddenColumns();
- posProps = new ViewportPositionProps(al);
- posProps.setStartRes(0);
- posProps.setEndRes(62);
- posProps.setStartSeq(0);
- posProps.setEndSeq(17);
+ vpranges = new ViewportRanges(al);
+ vpranges.setStartRes(0);
+ vpranges.setEndRes(62);
+ vpranges.setStartSeq(0);
+ vpranges.setEndSeq(17);
- viewHeight = posProps.getEndSeq() - posProps.getStartSeq() + 1;
- viewWidth = posProps.getEndRes() - posProps.getStartRes() + 1;
+ viewHeight = vpranges.getEndSeq() - vpranges.getStartSeq() + 1;
+ viewWidth = vpranges.getEndRes() - vpranges.getStartRes() + 1;
ColumnSelection hiddenCols = new ColumnSelection();
- od = new OverviewDimensions(posProps, true);
+ od = new OverviewDimensions(vpranges, true);
// Initial box sizing - default path through code
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
mouseClick(od, 0, 0);
moveViewport(0, 0);
// calculate before hidden columns so we get absolute values
- alheight = posProps.getAbsoluteAlignmentHeight();
- alwidth = posProps.getAbsoluteAlignmentWidth();
+ alheight = vpranges.getAbsoluteAlignmentHeight();
+ alwidth = vpranges.getAbsoluteAlignmentWidth();
- boxWidth = Math.round((float) (posProps.getEndRes()
- - posProps.getStartRes() + 1)
+ boxWidth = Math.round((float) (vpranges.getEndRes()
+ - vpranges.getStartRes() + 1)
* od.getWidth() / alwidth);
- boxHeight = Math.round((float) (posProps.getEndSeq()
- - posProps.getStartSeq() + 1)
+ boxHeight = Math.round((float) (vpranges.getEndSeq()
+ - vpranges.getStartSeq() + 1)
* od.getSequencesHeight() / alheight);
}
// test for alignment with width > height
SequenceI[] seqs1 = new SequenceI[] { seqa, seqb };
Alignment al1 = new Alignment(seqs1);
- ViewportPositionProps props = new ViewportPositionProps(al1);
+ ViewportRanges props = new ViewportRanges(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);
// test for alignment with width < height
SequenceI[] seqs2 = new SequenceI[] { seqa, seqb, seqc, seqd };
Alignment al2 = new Alignment(seqs2);
- props = new ViewportPositionProps(al2);
+ props = new ViewportRanges(al2);
od = new OverviewDimensions(props, true);
int scaledWidth = 300;
// min value
SequenceI[] seqs3 = new SequenceI[] { seqe };
Alignment al3 = new Alignment(seqs3);
- props = new ViewportPositionProps(al3);
+ props = new ViewportRanges(al3);
od = new OverviewDimensions(props, true);
assertEquals(od.getGraphHeight(), defaultGraphHeight);
SequenceI[] seqs4 = new SequenceI[] { seqa, seqb, seqc, seqd, seqa,
seqb, seqc, seqd, seqa, seqb, seqc, seqd, seqa, seqb, seqc, seqd };
Alignment al4 = new Alignment(seqs4);
- props = new ViewportPositionProps(al4);
+ props = new ViewportRanges(al4);
od = new OverviewDimensions(props, true);
assertEquals(od.getGraphHeight(), defaultGraphHeight);
assertEquals(od.getHeight(), maxSeqHeight + defaultGraphHeight);
Alignment al5 = new Alignment(seqs4);
- props = new ViewportPositionProps(al5);
+ props = new ViewportRanges(al5);
od = new OverviewDimensions(props, false);
assertEquals(od.getGraphHeight(), 0);
public void testSetBoxFromMouseClick()
{
od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
- posProps);
+ vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
// 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);
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(),
public void testFromMouseWithHiddenColsAtStart()
{
od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
- posProps);
+ vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
int lastHiddenCol = 30;
hiddenCols.hideColumns(0, lastHiddenCol);
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
assertEquals(od.getBoxX(),
Math.round((float) (lastHiddenCol + 1) * od.getWidth()
/ alwidth));
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(
// 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);
public void testFromMouseWithHiddenColsInMiddle()
{
od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
- posProps);
+ vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
int lastHidden = 73;
hiddenCols.hideColumns(firstHidden, lastHidden);
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
// 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);
public void testFromMouseWithHiddenColsAtEnd()
{
od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
- posProps);
+ vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
int firstHidden = 140;
int lastHidden = 164;
hiddenCols.hideColumns(firstHidden, lastHidden);
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
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);
}
/**
assertEquals(od.getBoxHeight(), boxHeight);
// move viewport to hidden columns
- moveViewport(102, 0);
+ // 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) 102 * od.getWidth() / alwidth));
+ Math.round((float) (firstHidden - viewWidth)
+ * od.getWidth() / alwidth));
assertEquals(od.getBoxY(), 0);
- assertEquals(od.getBoxWidth(), boxWidth
- + Math.round((float) (lastHidden - firstHidden)
- * od.getWidth() / alwidth));
+ assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
}
public void testFromMouseWithHiddenRowsAtStart()
{
od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
- posProps);
+ vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxHeight(), boxHeight);
int lastHiddenRow = 30;
hideSequences(0, lastHiddenRow);
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(),
Math.round((float) (lastHiddenRow + 1)
public void testFromMouseWithHiddenRowsInMiddle()
{
od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
- posProps);
+ vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
// 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);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
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));
}
/**
public void testFromMouseWithHiddenRowsAtEnd()
{
od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
- posProps);
+ vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
int lastHidden = 524;
hideSequences(firstHidden, lastHidden);
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
// 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);
}
/*
*/
private void moveViewportH(int startRes)
{
- posProps.setStartRes(startRes);
- posProps.setEndRes(startRes + viewWidth - 1);
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ vpranges.setStartRes(startRes);
+ vpranges.setEndRes(startRes + viewWidth - 1);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
}
/*
*/
private void moveViewportV(int startSeq)
{
- posProps.setStartSeq(startSeq);
- posProps.setEndSeq(startSeq + viewHeight - 1);
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ vpranges.setStartSeq(startSeq);
+ vpranges.setEndSeq(startSeq + viewHeight - 1);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
}
/*
*/
private void moveViewport(int startRes, int startSeq)
{
- posProps.setStartRes(startRes);
- posProps.setEndRes(startRes + viewWidth - 1);
- posProps.setStartSeq(startSeq);
- posProps.setEndSeq(startSeq + viewHeight - 1);
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ vpranges.setStartRes(startRes);
+ vpranges.setEndRes(startRes + viewWidth - 1);
+ vpranges.setStartSeq(startSeq);
+ vpranges.setEndSeq(startSeq + viewHeight - 1);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
}
/*
private void mouseClick(OverviewDimensions od, int x, int y)
{
od.updateViewportFromMouse(x, y, al.getHiddenSequences(), hiddenCols,
- posProps);
+ vpranges);
// updates require an OverviewPanel to exist which it doesn't here
// so call setBoxPosition() as it would be called by the AlignmentPanel
// normally
- posProps.setStartRes(od.getScrollCol());
- posProps.setEndRes(od.getScrollCol() + viewWidth - 1);
- posProps.setStartSeq(od.getScrollRow());
- posProps.setEndSeq(od.getScrollRow() + viewHeight - 1);
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ vpranges.setStartRes(od.getScrollCol());
+ vpranges.setEndRes(od.getScrollCol() + viewWidth - 1);
+ vpranges.setStartSeq(od.getScrollRow());
+ vpranges.setEndSeq(od.getScrollRow() + viewHeight - 1);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
}
/*