// boxHeight is the height in sequences translated to pixels
boxHeight = Math.round((float) vpheight * sequencesHeight / alheight);
}
+
+ /**
+ * Answers if a mouse position is in the overview's red box
+ *
+ * @param x
+ * mouse x position
+ * @param y
+ * mouse y position
+ * @return true if (x,y) is inside the box
+ */
+ protected boolean isPositionInBox(int x, int y)
+ {
+ return (x > boxX && y > boxY && boxX + x < boxWidth
+ && boxY + y < boxHeight);
+ }
}
\ No newline at end of file
package jalview.viewmodel;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
import jalview.analysis.AlignmentGenerator;
import jalview.datamodel.Alignment;
ViewportRanges vpranges;
- Hashtable<SequenceI, SequenceCollectionI> hiddenRepSequences = new Hashtable<SequenceI, SequenceCollectionI>();
+ Hashtable<SequenceI, SequenceCollectionI> hiddenRepSequences = new Hashtable<>();
HiddenColumns hiddenCols = new HiddenColumns();
assertEquals(od.getBoxHeight(), boxHeight);
}
+ /**
+ * Test the function to determine if a point is in the overview's box or not
+ */
+ @Test(groups = { "Functional" })
+ public void testPositionInBox()
+ {
+ assertFalse(od.isPositionInBox(0, 0));
+ assertTrue(od.isPositionInBox(10, 9));
+ assertFalse(od.isPositionInBox(0, 9));
+ assertFalse(od.isPositionInBox(9, 0));
+ assertFalse(od.isPositionInBox(75, 20));
+ }
+
/*
* Move viewport horizontally: startRes + previous width gives new horizontal extent. Vertical extent stays the same.
*/
package jalview.viewmodel;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
import jalview.analysis.AlignmentGenerator;
import jalview.datamodel.Alignment;
ViewportRanges vpranges;
- Hashtable<SequenceI, SequenceCollectionI> hiddenRepSequences = new Hashtable<SequenceI, SequenceCollectionI>();
+ Hashtable<SequenceI, SequenceCollectionI> hiddenRepSequences = new Hashtable<>();
HiddenColumns hiddenCols = new HiddenColumns();
assertEquals(od.getBoxHeight(), boxHeight);
}
+ /**
+ * Test the function to determine if a point is in the overview's box or not
+ */
+ @Test(groups = { "Functional" })
+ public void testPositionInBox()
+ {
+ assertFalse(od.isPositionInBox(0, 0));
+ assertTrue(od.isPositionInBox(10, 9));
+ assertFalse(od.isPositionInBox(0, 9));
+ assertFalse(od.isPositionInBox(9, 0));
+ assertFalse(od.isPositionInBox(75, 20));
+ }
+
/*
* Move viewport horizontally: startRes + previous width gives new horizontal extent. Vertical extent stays the same.
*/