*/
public void setEndRes(int res)
{
+ int startres = res;
int width = getViewportWidth();
- setStartEndRes(res - width + 1, res);
+ if (startres + width - 1 > al.getWidth() - 1)
+ {
+ startres = al.getWidth() - width;
+ }
+ setStartEndRes(startres - width + 1, startres);
}
/**
- * Set the first sequence visible in the viewport. Fires a property change
- * event.
+ * Set the first sequence visible in the viewport, maintaining the height. If
+ * the viewport would extend past the last sequence, sets the viewport so it
+ * sits at the bottom of the alignment. Fires a property change event.
*
* @param seq
* sequence position
*/
public void setStartSeq(int seq)
{
+ int startseq = seq;
int height = getViewportHeight();
- setStartEndSeq(seq, seq + height - 1);
+ if (startseq + height - 1 > al.getHeight() - 1)
+ {
+ startseq = al.getHeight() - height;
+ }
+ setStartEndSeq(startseq, startseq + height - 1);
}
/**
- * Set start and end sequences at the same time. This method only fires one
- * event for the two changes, and should be used in preference to separate
- * calls to setStartSeq and setEndSeq.
+ * Set start and end sequences at the same time. The viewport height may
+ * change. This method only fires one event for the two changes, and should be
+ * used in preference to separate calls to setStartSeq and setEndSeq.
*
* @param start
* the start sequence