{
resetAlignmentDims();
- int x = mousex;
- int y = mousey;
+ int xAsRes = getLeftXFromCentreX(mousex, hiddenCols);
+ int yAsSeq = getTopYFromCentreY(mousey, hiddenSeqs);
- if (x < 0)
+ if (xAsRes < 0)
{
- x = 0;
+ xAsRes = 0;
}
- if (y < 0)
+ if (yAsSeq < 0)
{
- y = 0;
+ yAsSeq = 0;
}
//
// correction
// convert x to residues - this is an absolute position
- int xAsRes = Math.round((float) x * alwidth / width);
+ // int xAsRes = Math.round((float) x * alwidth / width);
// get viewport width in residues
int vpwidth = ranges.getViewportWidth();
//
// convert y to residues
- int yAsSeq = Math.round((float) y * alheight / sequencesHeight);
+ // int yAsSeq = Math.round((float) y * alheight / sequencesHeight);
// get viewport height in sequences
// add 1 because height includes both endSeq and startSeq
alwidth = ranges.getVisibleAlignmentWidth();
alheight = ranges.getVisibleAlignmentHeight();
}
+
+ @Override
+ protected int getLeftXFromCentreX(int mousex, HiddenColumns hidden)
+ {
+ int vpx = Math.round((float) mousex * alwidth / width);
+ return vpx - ranges.getViewportWidth() / 2;
+ }
+
+ @Override
+ protected int getTopYFromCentreY(int mousey, HiddenSequences hidden)
+ {
+ int vpy = Math.round((float) mousey * alheight / sequencesHeight);
+ return vpy - ranges.getViewportHeight() / 2;
+ }
}
public void updateViewportFromMouse(int mousex, int mousey,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
- int x = mousex;
- int y = mousey;
+ int xAsRes = getLeftXFromCentreX(mousex, hiddenCols);
+ int yAsSeq = getTopYFromCentreY(mousey, hiddenSeqs);
resetAlignmentDims();
- if (x < 0)
+ if (xAsRes < 0)
{
- x = 0;
+ xAsRes = 0;
}
- if (y < 0)
+ if (yAsSeq < 0)
{
- y = 0;
+ yAsSeq = 0;
}
//
// correction
// convert x to residues - this is an absolute position
- int xAsRes = Math.round((float) x * alwidth / width);
+ // int xAsRes = Math.round((float) x * alwidth / width);
// get viewport width in residues
int vpwidth = ranges.getViewportWidth();
//
// convert y to residues
- int yAsSeq = Math.round((float) y * alheight / sequencesHeight);
+ // int yAsSeq = Math.round((float) y * alheight / sequencesHeight);
// get viewport height in sequences
int vpheight = ranges.getViewportHeight();
alwidth = ranges.getAbsoluteAlignmentWidth();
alheight = ranges.getAbsoluteAlignmentHeight();
}
+
+ @Override
+ protected int getLeftXFromCentreX(int mousex, HiddenColumns hidden)
+ {
+ int vpx = Math.round((float) mousex * alwidth / width);
+ return hidden.findColumnPosition(hidden.subtractVisibleColumns(
+ ranges.getViewportWidth() / 2, vpx));
+ }
+
+ @Override
+ protected int getTopYFromCentreY(int mousey, HiddenSequences hidden)
+ {
+ int vpy = Math.round((float) mousey * alheight / sequencesHeight);
+ return hidden.findIndexWithoutHiddenSeqs(hidden.subtractVisibleRows(
+ ranges.getViewportHeight() / 2, vpy));
+ }
}
ViewportRanges vpranges;
- Hashtable<SequenceI, SequenceCollectionI> hiddenRepSequences = new Hashtable<SequenceI, SequenceCollectionI>();
+ Hashtable<SequenceI, SequenceCollectionI> hiddenRepSequences = new Hashtable<>();
HiddenColumns hiddenCols = new HiddenColumns();
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
- assertEquals(vpranges.getStartSeq(),
+ assertEquals(vpranges.getStartSeq() + vpranges.getViewportHeight() / 2,
Math.round((float) 10 * alheight / od.getSequencesHeight()));
assertEquals(vpranges.getStartRes(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
- assertEquals(vpranges.getStartRes(),
- Math.round((float) 6 * alwidth / od.getWidth()));
+ assertEquals(vpranges.getStartRes(), 0);
assertEquals(vpranges.getStartSeq(), 0);
// overly large boxX value reset to width-boxWidth
- mouseClick(od, 100, 6);
+ mouseClick(od, 101, 6);
assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth());
- assertEquals(od.getBoxY(), 6);
+ assertEquals(od.getBoxY(), 1);
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
assertEquals(vpranges.getStartRes(),
assertEquals(od.getBoxY(), od.getSequencesHeight() - od.getBoxHeight());
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
- assertEquals(vpranges.getStartRes(),
+ assertEquals(vpranges.getStartRes() + vpranges.getViewportWidth() / 2,
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(
- vpranges.getStartSeq(),
+ vpranges.getStartSeq() + vpranges.getViewportWidth() / 2,
Math.round((float) od.getBoxY() * alheight
/ od.getSequencesHeight()) - 1);
assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth());
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
- assertEquals(vpranges.getStartRes(),
+ assertEquals(vpranges.getStartRes() + vpranges.getViewportWidth() / 2,
Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
assertEquals(
- vpranges.getStartSeq(),
+ vpranges.getStartSeq() + vpranges.getViewportHeight() / 2,
Math.round((float) od.getBoxY() * alheight
/ od.getSequencesHeight()));
assertEquals(od.getBoxX(), oldboxx + 5);
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
- assertEquals(vpranges.getStartRes(),
+ assertEquals(vpranges.getStartRes() + vpranges.getViewportWidth() / 2,
Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
assertEquals(od.getBoxY(), oldboxy + 2);
assertEquals(
- vpranges.getStartSeq(),
+ vpranges.getStartSeq() + vpranges.getViewportHeight() / 2,
Math.round((float) od.getBoxY() * alheight
/ od.getSequencesHeight()));