this.posProps = av.getPosProps();
// scale the initial size of overviewpanel to shape of alignment
- float initialScale = (float) av.getAlignment().getWidth()
- / (float) av.getAlignment().getHeight();
+ float initialScale = (float) posProps.getAlignmentWidthInCols()
+ / (float) posProps.getAlignmentHeightInRows();
// TODO: in applet this was getSequenceConsensusHash()
// check if it makes any functional difference
*/
public void setBoxPositionByMouse(int x, int y)
{
+ int alwidth = av.getAlignment().getWidth();
+ int alheight = av.getAlignment().getAbsoluteHeight();
+
boxX = x;
boxY = y;
if (boxY < 0)
}
else if (boxY > (sequencesHeight - boxHeight))
{
- boxY = sequencesHeight - boxHeight + 1;
+ boxY = sequencesHeight - boxHeight;
}
if (boxX < 0)
if (av.hasHiddenColumns())
{
// Try smallest possible box
- boxWidth = (int) (posProps.convertResiduesToPixels(posProps
- .getEndRes() - posProps.getStartRes() + 1) * scalew);
-
- // boxWidth = (int) ((av.getEndRes() - av.getStartRes() + 1)
- // * av.getCharWidth() * scalew);
+ boxWidth = Math.round((float) (posProps.getEndRes()
+ - posProps.getStartRes() + 1)
+ * width / alwidth);
}
boxX = width - boxWidth;
}
- scrollCol = posProps.convertPixelsToResidues(Math.round(boxX / scalew));
- scrollRow = posProps
- .convertPixelsToSequences(Math.round(boxY / scaleh));
-
- // scrollCol = (int) (boxX / scalew / av.getCharWidth());
- // scrollRow = (int) (boxY / scaleh / av.getCharHeight());
+ scrollCol = Math.round((float) boxX * alwidth / width);
+ scrollRow = Math.round((float) boxY * alheight / sequencesHeight);
if (av.hasHiddenColumns())
{
- if (!av.getColumnSelection().isVisible(scrollCol))
+ // doesn't seem to do anything useful
+ /*if (!av.getColumnSelection().isVisible(scrollCol))
{
return;
- }
+ }*/
scrollCol = av.getColumnSelection().findColumnPosition(scrollCol);
}
*/
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);
- }
+ int alwidth = av.getAlignment().getWidth();
+ int alheight = av.getAlignment().getAbsoluteHeight();
- boxX = Math.round(posProps.convertResiduesToPixels(startRes) * scalew);
- boxY = Math.round(posProps.convertSequencesToPixels(startSeq) * scaleh);
+ int startRes = av.getPosProps().getAbsoluteStartRes();
+ int endRes = av.getPosProps().getAbsoluteEndRes();
- // boxX = (int) (startRes * av.getCharWidth() * scalew);
- // boxY = (int) (startSeq * av.getCharHeight() * scaleh);
+ int startSeq = av.getPosProps().getAbsoluteStartSeq();
+ int endSeq = av.getPosProps().getAbsoluteEndSeq();
- boxWidth = Math.round(posProps.convertResiduesToPixels(endRes
- - startRes
- + 1) * scalew);
- boxHeight = Math.round(posProps.convertSequencesToPixels(endSeq
- - startSeq)
- * scaleh);
+ boxX = Math.round((float) startRes * width / alwidth);
+ boxY = Math.round((float) startSeq * sequencesHeight / alheight);
- // 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;
+ boxWidth = Math
+ .round((float) (endRes - startRes + 1) * width / alwidth);
+ boxHeight = Math.round((float) (endSeq - startSeq) * sequencesHeight
+ / alheight);
}
/**
return boxY;
}
+ // TODO should be removed, when unit test has mock Graphics object available
public int getBoxWidth()
{
return boxWidth;
}
+ // TODO should be removed, when unit test has mock Graphics object available
public int getBoxHeight()
{
return boxHeight;