git://source.jalview.org
/
jalview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b1beced
)
JAL-2778 tightened up use of resetAlignmentDims
author
kiramt
<k.mourao@dundee.ac.uk>
Fri, 26 Jan 2018 10:27:46 +0000
(10:27 +0000)
committer
kiramt
<k.mourao@dundee.ac.uk>
Fri, 26 Jan 2018 10:27:46 +0000
(10:27 +0000)
src/jalview/viewmodel/OverviewDimensions.java
patch
|
blob
|
history
src/jalview/viewmodel/OverviewDimensionsHideHidden.java
patch
|
blob
|
history
src/jalview/viewmodel/OverviewDimensionsShowHidden.java
patch
|
blob
|
history
diff --git
a/src/jalview/viewmodel/OverviewDimensions.java
b/src/jalview/viewmodel/OverviewDimensions.java
index
d7f2e61
..
0235081
100644
(file)
--- a/
src/jalview/viewmodel/OverviewDimensions.java
+++ b/
src/jalview/viewmodel/OverviewDimensions.java
@@
-161,23
+161,25
@@
public abstract class OverviewDimensions
public float getPixelsPerCol()
{
resetAlignmentDims();
public float getPixelsPerCol()
{
resetAlignmentDims();
- return (float) width / alwidth;
+ return 1 / widthRatio;
}
public float getPixelsPerSeq()
{
resetAlignmentDims();
}
public float getPixelsPerSeq()
{
resetAlignmentDims();
- return (float) sequencesHeight / alheight;
+ return 1 / heightRatio;
}
public void setWidth(int w)
{
width = w;
}
public void setWidth(int w)
{
width = w;
+ widthRatio = (float) alwidth / width;
}
public void setHeight(int h)
{
sequencesHeight = h - graphHeight;
}
public void setHeight(int h)
{
sequencesHeight = h - graphHeight;
+ heightRatio = (float) alheight / sequencesHeight;
}
/**
}
/**
@@
-277,14
+279,14
@@
public abstract class OverviewDimensions
// boxX, boxY is the x,y location equivalent to startRes, startSeq
int xPos = Math.min(startRes, alwidth - vpwidth + 1);
// boxX, boxY is the x,y location equivalent to startRes, startSeq
int xPos = Math.min(startRes, alwidth - vpwidth + 1);
- boxX = Math.round((float) xPos * width / alwidth);
- boxY = Math.round((float) startSeq * sequencesHeight / alheight);
+ boxX = Math.round(xPos / widthRatio);
+ boxY = Math.round(startSeq / heightRatio);
// boxWidth is the width in residues translated to pixels
// boxWidth is the width in residues translated to pixels
- boxWidth = Math.round((float) vpwidth * width / alwidth);
+ boxWidth = Math.round(vpwidth / widthRatio);
// boxHeight is the height in sequences translated to pixels
// boxHeight is the height in sequences translated to pixels
- boxHeight = Math.round((float) vpheight * sequencesHeight / alheight);
+ boxHeight = Math.round(vpheight / heightRatio);
}
/**
}
/**
diff --git
a/src/jalview/viewmodel/OverviewDimensionsHideHidden.java
b/src/jalview/viewmodel/OverviewDimensionsHideHidden.java
index
1cc42bb
..
f58e711
100644
(file)
--- a/
src/jalview/viewmodel/OverviewDimensionsHideHidden.java
+++ b/
src/jalview/viewmodel/OverviewDimensionsHideHidden.java
@@
-50,6
+50,8
@@
public class OverviewDimensionsHideHidden extends OverviewDimensions
public void updateViewportFromMouse(int mousex, int mousey,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
public void updateViewportFromMouse(int mousex, int mousey,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
+ resetAlignmentDims();
+
int xAsRes = getLeftXFromCentreX(mousex, hiddenCols);
int yAsSeq = getTopYFromCentreY(mousey, hiddenSeqs);
int xAsRes = getLeftXFromCentreX(mousex, hiddenCols);
int yAsSeq = getTopYFromCentreY(mousey, hiddenSeqs);
@@
-61,6
+63,8
@@
public class OverviewDimensionsHideHidden extends OverviewDimensions
public void adjustViewportFromMouse(int mousex, int mousey,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
public void adjustViewportFromMouse(int mousex, int mousey,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
+ resetAlignmentDims();
+
// calculate translation in pixel terms:
// get mouse location in viewport coords, add translation in viewport
// coords, and update viewport as usual
// calculate translation in pixel terms:
// get mouse location in viewport coords, add translation in viewport
// coords, and update viewport as usual
@@
-72,13
+76,16
@@
public class OverviewDimensionsHideHidden extends OverviewDimensions
}
}
+ /**
+ * {@inheritDoc} Callers should have already called resetAlignmentDims to
+ * refresh alwidth, alheight and width/height ratios
+ */
@Override
protected void updateViewportFromTopLeft(int leftx, int topy,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
int xAsRes = leftx;
int yAsSeq = topy;
@Override
protected void updateViewportFromTopLeft(int leftx, int topy,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
int xAsRes = leftx;
int yAsSeq = topy;
- resetAlignmentDims();
if (xAsRes < 0)
{
if (xAsRes < 0)
{
@@
-167,6
+174,10
@@
public class OverviewDimensionsHideHidden extends OverviewDimensions
heightRatio = (float) alheight / sequencesHeight;
}
heightRatio = (float) alheight / sequencesHeight;
}
+ /**
+ * {@inheritDoc} Callers should have already called resetAlignmentDims to
+ * refresh widthRatio
+ */
@Override
protected int getLeftXFromCentreX(int mousex, HiddenColumns hidden)
{
@Override
protected int getLeftXFromCentreX(int mousex, HiddenColumns hidden)
{
@@
-174,6
+185,10
@@
public class OverviewDimensionsHideHidden extends OverviewDimensions
return vpx - ranges.getViewportWidth() / 2;
}
return vpx - ranges.getViewportWidth() / 2;
}
+ /**
+ * {@inheritDoc} Callers should have already called resetAlignmentDims to
+ * refresh heightRatio
+ */
@Override
protected int getTopYFromCentreY(int mousey, HiddenSequences hidden)
{
@Override
protected int getTopYFromCentreY(int mousey, HiddenSequences hidden)
{
@@
-185,6
+200,8
@@
public class OverviewDimensionsHideHidden extends OverviewDimensions
public void setDragPoint(int x, int y, HiddenSequences hiddenSeqs,
HiddenColumns hiddenCols)
{
public void setDragPoint(int x, int y, HiddenSequences hiddenSeqs,
HiddenColumns hiddenCols)
{
+ resetAlignmentDims();
+
// get alignment position of x and box (can get directly from vpranges) and
// calculate difference between the positions
int vpx = Math.round(x * widthRatio);
// get alignment position of x and box (can get directly from vpranges) and
// calculate difference between the positions
int vpx = Math.round(x * widthRatio);
diff --git
a/src/jalview/viewmodel/OverviewDimensionsShowHidden.java
b/src/jalview/viewmodel/OverviewDimensionsShowHidden.java
index
ec2efa2
..
eaa3413
100644
(file)
--- a/
src/jalview/viewmodel/OverviewDimensionsShowHidden.java
+++ b/
src/jalview/viewmodel/OverviewDimensionsShowHidden.java
@@
-72,6
+72,8
@@
public class OverviewDimensionsShowHidden extends OverviewDimensions
public void updateViewportFromMouse(int mousex, int mousey,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
public void updateViewportFromMouse(int mousex, int mousey,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
+ resetAlignmentDims();
+
// convert mousex and mousey to alignment units as well as
// translating to top left corner of viewport - this is an absolute position
int xAsRes = getLeftXFromCentreX(mousex, hiddenCols);
// convert mousex and mousey to alignment units as well as
// translating to top left corner of viewport - this is an absolute position
int xAsRes = getLeftXFromCentreX(mousex, hiddenCols);
@@
-93,6
+95,8
@@
public class OverviewDimensionsShowHidden extends OverviewDimensions
public void adjustViewportFromMouse(int mousex, int mousey,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
public void adjustViewportFromMouse(int mousex, int mousey,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
+ resetAlignmentDims();
+
// calculate translation in pixel terms:
// get mouse location in viewport coords, add translation in viewport
// coords,
// calculate translation in pixel terms:
// get mouse location in viewport coords, add translation in viewport
// coords,
@@
-107,13
+111,16
@@
public class OverviewDimensionsShowHidden extends OverviewDimensions
updateViewportFromTopLeft(visXAsRes, visYAsRes, hiddenSeqs, hiddenCols);
}
updateViewportFromTopLeft(visXAsRes, visYAsRes, hiddenSeqs, hiddenCols);
}
+ /**
+ * {@inheritDoc} Callers should have already called resetAlignmentDims to
+ * refresh alwidth, alheight and width/height ratios
+ */
@Override
protected void updateViewportFromTopLeft(int leftx, int topy,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
int visXAsRes = leftx;
int visYAsSeq = topy;
@Override
protected void updateViewportFromTopLeft(int leftx, int topy,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
int visXAsRes = leftx;
int visYAsSeq = topy;
- resetAlignmentDims();
if (visXAsRes < 0)
{
if (visXAsRes < 0)
{
@@
-230,6
+237,11
@@
public class OverviewDimensionsShowHidden extends OverviewDimensions
heightRatio = (float) alheight / sequencesHeight;
}
heightRatio = (float) alheight / sequencesHeight;
}
+
+ /**
+ * {@inheritDoc} Callers should have already called resetAlignmentDims to
+ * refresh widthRatio
+ */
@Override
protected int getLeftXFromCentreX(int mousex, HiddenColumns hidden)
{
@Override
protected int getLeftXFromCentreX(int mousex, HiddenColumns hidden)
{
@@
-238,6
+250,10
@@
public class OverviewDimensionsShowHidden extends OverviewDimensions
vpx);
}
vpx);
}
+ /**
+ * {@inheritDoc} Callers should have already called resetAlignmentDims to
+ * refresh heightRatio
+ */
@Override
protected int getTopYFromCentreY(int mousey, HiddenSequences hidden)
{
@Override
protected int getTopYFromCentreY(int mousey, HiddenSequences hidden)
{
@@
-249,6
+265,8
@@
public class OverviewDimensionsShowHidden extends OverviewDimensions
public void setDragPoint(int x, int y, HiddenSequences hiddenSeqs,
HiddenColumns hiddenCols)
{
public void setDragPoint(int x, int y, HiddenSequences hiddenSeqs,
HiddenColumns hiddenCols)
{
+ resetAlignmentDims();
+
// get alignment position of x and box (can get directly from vpranges) and
// calculate difference between the positions
int vpx = Math.round(x * widthRatio);
// get alignment position of x and box (can get directly from vpranges) and
// calculate difference between the positions
int vpx = Math.round(x * widthRatio);