- * Check box dimensions and scroll positions and correct if necessary
- */
- public void setBoxPositionByMouse(int x, int y)
- {
- boxX = x;
- boxY = y;
- if (boxY < 0)
- {
- boxY = 0;
- }
- else if (boxY > (sequencesHeight - boxHeight))
- {
- boxY = sequencesHeight - boxHeight + 1;
- }
-
- if (boxX < 0)
- {
- boxX = 0;
- }
- else if (boxX > (width - boxWidth))
- {
- if (av.hasHiddenColumns())
- {
- // Try smallest possible box
- boxWidth = (int) ((av.getEndRes() - av.getStartRes() + 1)
- * av.getCharWidth() * scalew);
- }
- boxX = width - boxWidth;
- }
-
- scrollCol = (int) (boxX / scalew / av.getCharWidth());
- scrollRow = (int) (boxY / scaleh / av.getCharHeight());
-
- if (av.hasHiddenColumns())
- {
- if (!av.getColumnSelection().isVisible(scrollCol))
- {
- return;
- }
-
- scrollCol = av.getColumnSelection().findColumnPosition(scrollCol);
- }
-
- if (av.hasHiddenRows())
- {
- scrollRow = av.getAlignment().getHiddenSequences()
- .findIndexWithoutHiddenSeqs(scrollRow);
- }
- }
-
- /**
- * Update the overview panel box when the associated alignment panel is
- * changed
- *
- */
- public void setBoxPosition()
- {
- updateScales();
-
- int startRes = av.getStartRes();
- int endRes = av.getEndRes();
-
- if (av.hasHiddenColumns())
- {
- startRes = av.getColumnSelection().adjustForHiddenColumns(startRes);
- endRes = av.getColumnSelection().adjustForHiddenColumns(endRes);
- }
-
- int startSeq = av.getStartSeq();
- int endSeq = av.getEndSeq();
-
- if (av.hasHiddenRows())
- {
- startSeq = av.getAlignment().getHiddenSequences()
- .adjustForHiddenSeqs(startSeq);
-
- endSeq = av.getAlignment().getHiddenSequences()
- .adjustForHiddenSeqs(endSeq);
- }
-
- boxX = (int) (startRes * av.getCharWidth() * scalew);
- boxY = (int) (startSeq * av.getCharHeight() * scaleh);
-
- boxWidth = (int) ((endRes - startRes + 1) * av.getCharWidth() * scalew);
- boxHeight = (int) ((endSeq - startSeq) * av.getCharHeight() * scaleh);
- }
-
- /**
- * Update width and height scales in terms of the alignment width and height
- */
- public void updateScales()
- {
- int alwidth = av.getAlignment().getWidth();
- int alheight = av.getAlignment().getHeight()
- + av.getAlignment().getHiddenSequences().getSize();
-
- int fullsizeWidth = alwidth * av.getCharWidth();
- int fullsizeHeight = alheight * av.getCharHeight();
-
- scalew = (float) width / fullsizeWidth;
- scaleh = (float) sequencesHeight / fullsizeHeight;
- }
-
- /**