git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'features/JAL-2388OverviewWindow' into develop
[jalview.git]
/
src
/
jalview
/
viewmodel
/
OverviewDimensions.java
diff --git
a/src/jalview/viewmodel/OverviewDimensions.java
b/src/jalview/viewmodel/OverviewDimensions.java
index
4af4175
..
43680b5
100644
(file)
--- a/
src/jalview/viewmodel/OverviewDimensions.java
+++ b/
src/jalview/viewmodel/OverviewDimensions.java
@@
-69,29
+69,29
@@
public class OverviewDimensions
/**
* Create an OverviewDimensions object
*
/**
* Create an OverviewDimensions object
*
- * @param props
+ * @param ranges
* positional properties of the viewport
* @param showAnnotationPanel
* true if the annotation panel is to be shown, false otherwise
*/
* positional properties of the viewport
* @param showAnnotationPanel
* true if the annotation panel is to be shown, false otherwise
*/
- public OverviewDimensions(ViewportPositionProps props,
+ public OverviewDimensions(ViewportRanges ranges,
boolean showAnnotationPanel)
{
// scale the initial size of overviewpanel to shape of alignment
boolean showAnnotationPanel)
{
// scale the initial size of overviewpanel to shape of alignment
- float initialScale = (float) props.getAbsoluteAlignmentWidth()
- / (float) props.getAbsoluteAlignmentHeight();
+ float initialScale = (float) ranges.getAbsoluteAlignmentWidth()
+ / (float) ranges.getAbsoluteAlignmentHeight();
if (!showAnnotationPanel)
{
graphHeight = 0;
}
if (!showAnnotationPanel)
{
graphHeight = 0;
}
- if (props.getAbsoluteAlignmentWidth() > props
+ if (ranges.getAbsoluteAlignmentWidth() > ranges
.getAbsoluteAlignmentHeight())
{
// wider
width = MAX_WIDTH;
.getAbsoluteAlignmentHeight())
{
// wider
width = MAX_WIDTH;
- sequencesHeight = (int) (MAX_WIDTH / initialScale);
+ sequencesHeight = Math.round(MAX_WIDTH / initialScale);
if (sequencesHeight < MIN_SEQ_HEIGHT)
{
sequencesHeight = MIN_SEQ_HEIGHT;
if (sequencesHeight < MIN_SEQ_HEIGHT)
{
sequencesHeight = MIN_SEQ_HEIGHT;
@@
-100,7
+100,7
@@
public class OverviewDimensions
else
{
// taller
else
{
// taller
- width = (int) (MAX_WIDTH * initialScale);
+ width = Math.round(MAX_WIDTH * initialScale);
sequencesHeight = MAX_SEQ_HEIGHT;
if (width < MIN_WIDTH)
sequencesHeight = MAX_SEQ_HEIGHT;
if (width < MIN_WIDTH)
@@
-121,18
+121,18
@@
public class OverviewDimensions
* hidden sequences
* @param hiddenCols
* hidden columns
* hidden sequences
* @param hiddenCols
* hidden columns
- * @param props
+ * @param ranges
* viewport position properties
*/
public void updateViewportFromMouse(int mousex, int mousey,
HiddenSequences hiddenSeqs, ColumnSelection hiddenCols,
* viewport position properties
*/
public void updateViewportFromMouse(int mousex, int mousey,
HiddenSequences hiddenSeqs, ColumnSelection hiddenCols,
- ViewportPositionProps props)
+ ViewportRanges ranges)
{
int x = mousex;
int y = mousey;
{
int x = mousex;
int y = mousey;
- int alwidth = props.getAbsoluteAlignmentWidth();
- int alheight = props.getAbsoluteAlignmentHeight();
+ int alwidth = ranges.getAbsoluteAlignmentWidth();
+ int alheight = ranges.getAbsoluteAlignmentHeight();
if (x < 0)
{
if (x < 0)
{
@@
-156,28
+156,30
@@
public class OverviewDimensions
int xAsRes = Math.round((float) x * alwidth / width);
// get viewport width in residues
int xAsRes = Math.round((float) x * alwidth / width);
// get viewport width in residues
- int vpwidth = props.getEndRes() - props.getStartRes() + 1;
+ int vpwidth = ranges.getEndRes() - ranges.getStartRes() + 1;
// get where x should be when accounting for hidden cols
// if x is in a hidden col region, shift to left - but we still need
// absolute position
// so convert back after getting visible region position
// get where x should be when accounting for hidden cols
// if x is in a hidden col region, shift to left - but we still need
// absolute position
// so convert back after getting visible region position
- xAsRes = hiddenCols.adjustForHiddenColumns(hiddenCols
- .findColumnPosition(xAsRes));
-
- // get where end res should be by adding the viewport width on
- // subtract 1 because the width includes endRes
- int endRes = xAsRes + vpwidth - 1;
+ int visXAsRes = hiddenCols.findColumnPosition(xAsRes);
// check in case we went off the edge of the alignment
// check in case we went off the edge of the alignment
- int visAlignWidth = hiddenCols.findColumnPosition(alwidth);
- if (endRes > visAlignWidth - 1)
+ int visAlignWidth = hiddenCols.findColumnPosition(alwidth - 1);
+ if (visXAsRes + vpwidth - 1 > visAlignWidth)
{
// went past the end of the alignment, adjust backwards
{
// went past the end of the alignment, adjust backwards
- endRes = visAlignWidth - 1;
- // recalc xAsRes backwards from endRes
- // add 1 because width includes xAsRes
- xAsRes = hiddenCols.adjustForHiddenColumns(endRes - vpwidth + 1);
+
+ // if last position was before the end of the alignment, need to update
+ if ((scrollCol + vpwidth - 1) < visAlignWidth)
+ {
+ visXAsRes = hiddenCols.findColumnPosition(hiddenCols
+ .subtractVisibleColumns(vpwidth - 1, alwidth - 1));
+ }
+ else
+ {
+ visXAsRes = scrollCol;
+ }
}
//
}
//
@@
-189,7
+191,7
@@
public class OverviewDimensions
// get viewport height in sequences
// add 1 because height includes both endSeq and startSeq
// get viewport height in sequences
// add 1 because height includes both endSeq and startSeq
- int vpheight = props.getEndSeq() - props.getStartSeq() + 1;
+ int vpheight = ranges.getEndSeq() - ranges.getStartSeq() + 1;
// get where y should be when accounting for hidden rows
// if y is in a hidden row region, shift up - but we still need absolute
// get where y should be when accounting for hidden rows
// if y is in a hidden row region, shift up - but we still need absolute
@@
-198,23
+200,27
@@
public class OverviewDimensions
yAsSeq = hiddenSeqs.adjustForHiddenSeqs(hiddenSeqs
.findIndexWithoutHiddenSeqs(yAsSeq));
yAsSeq = hiddenSeqs.adjustForHiddenSeqs(hiddenSeqs
.findIndexWithoutHiddenSeqs(yAsSeq));
- // get where end seq should be by adding the viewport height on
- int endSeq = yAsSeq + vpheight - 1;
-
// check in case we went off the edge of the alignment
int visAlignHeight = hiddenSeqs.findIndexWithoutHiddenSeqs(alheight);
// check in case we went off the edge of the alignment
int visAlignHeight = hiddenSeqs.findIndexWithoutHiddenSeqs(alheight);
- if (hiddenSeqs.findIndexWithoutHiddenSeqs(endSeq) > visAlignHeight - 1)
+ int visYAsRes = hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq);
+ if (visYAsRes + vpheight - 1 > visAlignHeight)
{
// went past the end of the alignment, adjust backwards
{
// went past the end of the alignment, adjust backwards
- endSeq = visAlignHeight - 1;
- // recalc yAsSeq backwards from endSeq
- yAsSeq = endSeq - vpheight + 1;
+ if ((scrollRow + vpheight - 1) < visAlignHeight)
+ {
+ visYAsRes = hiddenSeqs.findIndexWithoutHiddenSeqs(hiddenSeqs
+ .subtractVisibleRows(vpheight - 1, alheight - 1));
+ }
+ else
+ {
+ visYAsRes = scrollRow;
+ }
}
}
- // convert absolute positions back to visible alignment positions for
- // viewport scrolling
- scrollCol = hiddenCols.findColumnPosition(xAsRes);
- scrollRow = hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq);
+ // update scroll values
+ scrollCol = visXAsRes;
+ scrollRow = visYAsRes;
+
}
/**
}
/**
@@
-225,22
+231,22
@@
public class OverviewDimensions
* hidden sequences
* @param hiddenCols
* hidden columns
* hidden sequences
* @param hiddenCols
* hidden columns
- * @param props
+ * @param ranges
* viewport position properties
*/
public void setBoxPosition(HiddenSequences hiddenSeqs,
* viewport position properties
*/
public void setBoxPosition(HiddenSequences hiddenSeqs,
- ColumnSelection hiddenCols, ViewportPositionProps props)
+ ColumnSelection hiddenCols, ViewportRanges ranges)
{
{
- int alwidth = props.getAbsoluteAlignmentWidth();
- int alheight = props.getAbsoluteAlignmentHeight();
+ int alwidth = ranges.getAbsoluteAlignmentWidth();
+ int alheight = ranges.getAbsoluteAlignmentHeight();
// work with absolute values of startRes and endRes
// work with absolute values of startRes and endRes
- int startRes = hiddenCols.adjustForHiddenColumns(props.getStartRes());
- int endRes = hiddenCols.adjustForHiddenColumns(props.getEndRes());
+ int startRes = hiddenCols.adjustForHiddenColumns(ranges.getStartRes());
+ int endRes = hiddenCols.adjustForHiddenColumns(ranges.getEndRes());
// work with absolute values of startSeq and endSeq
// work with absolute values of startSeq and endSeq
- int startSeq = hiddenSeqs.adjustForHiddenSeqs(props.getStartSeq());
- int endSeq = hiddenSeqs.adjustForHiddenSeqs(props.getEndSeq());
+ int startSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.getStartSeq());
+ int endSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.getEndSeq());
// boxX, boxY is the x,y location equivalent to startRes, startSeq
boxX = Math.round((float) startRes * width / alwidth);
// boxX, boxY is the x,y location equivalent to startRes, startSeq
boxX = Math.round((float) startRes * width / alwidth);
@@
-252,8
+258,6
@@
public class OverviewDimensions
boxWidth = Math
.round((float) (endRes - startRes + 1) * width / alwidth);
// boxHeight is the height in sequences translated to pixels
boxWidth = Math
.round((float) (endRes - startRes + 1) * width / alwidth);
// boxHeight is the height in sequences translated to pixels
- // since the box includes both the start and end sequences, add 1 to the
- // difference
boxHeight = Math.round((float) (endSeq - startSeq + 1)
* sequencesHeight
/ alheight);
boxHeight = Math.round((float) (endSeq - startSeq + 1)
* sequencesHeight
/ alheight);
@@
-271,7
+275,6
@@
public class OverviewDimensions
g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2);
}
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 scrollCol;
public int getScrollCol()
{
return scrollCol;