import jalview.api.AlignViewportI;
+import java.awt.Graphics;
+
public class OverviewDimensions
{
// Default width and height values
/**
* Check box dimensions and scroll positions and correct if necessary
*/
- public void checkValid()
+ public void setBoxPositionByMouse(int x, int y)
{
+ boxX = x;
+ boxY = y;
if (boxY < 0)
{
boxY = 0;
}
-
- if (boxY > (sequencesHeight - boxHeight))
+ else if (boxY > (sequencesHeight - boxHeight))
{
boxY = sequencesHeight - boxHeight + 1;
}
{
boxX = 0;
}
-
- if (boxX > (width - boxWidth))
+ else if (boxX > (width - boxWidth))
{
if (av.hasHiddenColumns())
{
endSeq = av.getAlignment().getHiddenSequences()
.adjustForHiddenSeqs(endSeq);
-
}
boxX = (int) (startRes * av.getCharWidth() * scalew);
boxY = (int) (startSeq * av.getCharHeight() * scaleh);
- if (av.hasHiddenColumns())
- {
- boxWidth = (int) ((endRes - startRes + 1) * av.getCharWidth() * scalew);
- }
- else
- {
- boxWidth = (int) ((endRes - startRes + 1) * av.getCharWidth() * scalew);
- }
-
+ boxWidth = (int) ((endRes - startRes + 1) * av.getCharWidth() * scalew);
boxHeight = (int) ((endSeq - startSeq) * av.getCharHeight() * scaleh);
}
scaleh = (float) sequencesHeight / fullsizeHeight;
}
+ /**
+ * Draw the overview panel's viewport box on a graphics object
+ *
+ * @param g
+ * the graphics object to draw on
+ */
+ public void drawBox(Graphics g)
+ {
+ g.drawRect(boxX, boxY, boxWidth, boxHeight);
+ g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2);
+ }
+
// don't like this, scroll vals are separate from setting code
public int getScrollCol()
{
return scrollRow;
}
+ // TODO should be removed, when unit test has mock Graphics object available
+ // to check boxX/boxY
public int getBoxX()
{
return boxX;
}
+ // TODO should be removed, when unit test has mock Graphics object available
+ // to check boxX/boxY
public int getBoxY()
{
return boxY;