*/
package jalview.viewmodel;
-import jalview.api.AlignViewportI;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.HiddenColumns;
*/
public class ViewportRanges extends ViewportProperties
{
+ public static final String STARTRES = "startres";
+
+ public static final String ENDRES = "endres";
+
+ public static final String STARTSEQ = "startseq";
+
+ public static final String ENDSEQ = "endseq";
+
// start residue of viewport
private int startRes;
public void setStartEndRes(int start, int end)
{
int oldstartres = this.startRes;
- if (start > al.getWidth() - 1)
+ if (start > getVisibleAlignmentWidth() - 1)
{
- startRes = al.getWidth() - 1;
+ startRes = Math.max(getVisibleAlignmentWidth() - 1, 0);
}
else if (start < 0)
{
{
endRes = 0;
}
+ else if (end > getVisibleAlignmentWidth() - 1)
+ {
+ endRes = Math.max(getVisibleAlignmentWidth() - 1, 0);
+ }
else
{
endRes = end;
}
- changeSupport.firePropertyChange("startres", oldstartres, startRes);
+ changeSupport.firePropertyChange(STARTRES, oldstartres, startRes);
if (oldstartres == startRes)
{
// event won't be fired if start positions are same
// fire an event for the end positions in case they changed
- changeSupport.firePropertyChange("endres", oldendres, endRes);
+ changeSupport.firePropertyChange(ENDRES, oldendres, endRes);
}
}
{
int startres = res;
int width = getViewportWidth();
- if (startres + width - 1 > al.getWidth() - 1)
+ if (startres + width - 1 > getVisibleAlignmentWidth() - 1)
{
- startres = al.getWidth() - width;
+ startres = getVisibleAlignmentWidth() - width;
}
setStartEndRes(startres - width + 1, startres);
}
{
int startseq = seq;
int height = getViewportHeight();
- if (startseq + height - 1 > al.getHeight() - 1)
+ if (startseq + height - 1 > getVisibleAlignmentHeight() - 1)
{
- startseq = al.getHeight() - height;
+ startseq = getVisibleAlignmentHeight() - height;
}
setStartEndSeq(startseq, startseq + height - 1);
}
public void setStartEndSeq(int start, int end)
{
int oldstartseq = this.startSeq;
- if (start > al.getHeight() - 1)
+ if (start > getVisibleAlignmentHeight() - 1)
{
- startSeq = al.getHeight() - 1;
+ startSeq = Math.max(getVisibleAlignmentHeight() - 1, 0);
}
else if (start < 0)
{
}
int oldendseq = this.endSeq;
- if (end >= al.getHeight())
+ if (end >= getVisibleAlignmentHeight())
{
- endSeq = al.getHeight() - 1;
+ endSeq = Math.max(getVisibleAlignmentHeight() - 1, 0);
}
else if (end < 0)
{
endSeq = end;
}
- changeSupport.firePropertyChange("startseq", oldstartseq, startSeq);
+ changeSupport.firePropertyChange(STARTSEQ, oldstartseq, startSeq);
if (oldstartseq == startSeq)
{
// event won't be fired if start positions are the same
// fire in case the end positions changed
- changeSupport.firePropertyChange("endseq", oldendseq, endSeq);
+ changeSupport.firePropertyChange(ENDSEQ, oldendseq, endSeq);
}
}
{
vpstart = 0;
}
- else if (vpstart + w - 1 > al.getWidth() - 1)
+ else if ((w <= getVisibleAlignmentWidth())
+ && (vpstart + w - 1 > getVisibleAlignmentWidth() - 1))
+ // viewport width is less than the full alignment and we are running off the
+ // RHS edge
{
- vpstart = al.getWidth() - 1;
+ vpstart = getVisibleAlignmentWidth() - w;
}
setStartEndRes(vpstart, vpstart + w - 1);
}
{
vpstart = 0;
}
- else if (vpstart + h - 1 > al.getHeight() - 1)
+ else if ((h <= getVisibleAlignmentHeight())
+ && (vpstart + h - 1 > getVisibleAlignmentHeight() - 1))
+ // viewport height is less than the full alignment and we are running off
+ // the bottom
{
- vpstart = al.getHeight() - h;
+ vpstart = getVisibleAlignmentHeight() - h;
}
setStartEndSeq(vpstart, vpstart + h - 1);
}
}
else
{
- if (endSeq >= al.getHeight() - 1)
+ if (endSeq >= getVisibleAlignmentHeight() - 1)
{
return false;
}
}
else
{
- if (endRes > al.getWidth() - 1)
+ if (endRes >= getVisibleAlignmentWidth() - 1)
{
return false;
}
* x position in alignment
* @param y
* y position in alignment
- * @param av
- * viewport to be visible in. Here until hidden columns JAL-2388
- * merged, then use alignment to get hidden cols
*/
- public void scrollToVisible(int x, int y, AlignViewportI av)
+ public void scrollToVisible(int x, int y)
{
while (y < startSeq)
{