* Set first residue visible in the viewport, and retain the current width.
* Fires a property change event.
*
- * @param res
+ * @param res
* residue position
*/
public void setStartRes(int res)
private int[] updateStartEndSeq(int start, int end)
{
- if (end == 3 && this.endSeq == 14 || end == 13 && this.endSeq == 3) {
- new NullPointerException().printStackTrace(System.out);
- System.out.println("ViewportRange updateStartEndSeq " + start + " " + end + " " + Thread.currentThread());
- }
+// if (end == 3 && this.endSeq == 14 || end == 13 && this.endSeq == 3) {
+// new NullPointerException().printStackTrace(System.out);
+// System.out.println("ViewportRange updateStartEndSeq " + start + " " + end + " " + Thread.currentThread());
+// }
int oldstartseq = this.startSeq;
- int visibleHeight = getVisibleAlignmentHeight();
- if (start > visibleHeight - 1)
- {
- startSeq = Math.max(visibleHeight - 1, 0);
- }
- else if (start < 0)
- {
- startSeq = 0;
- }
- else
- {
- startSeq = start;
- }
-
int oldendseq = this.endSeq;
- if (end >= visibleHeight)
- {
- endSeq = Math.max(visibleHeight - 1, 0);
- }
- else if (end < 0)
- {
- endSeq = 0;
- }
- else
- {
- endSeq = end;
- }
+ int max = getVisibleAlignmentHeight() - 1;
+ startSeq = Math.max(0, Math.min(start, max));
+ endSeq = Math.max(0, Math.min(end, max));
return new int[] { oldstartseq, oldendseq };
}
*/
public void setViewportStartAndWidth(int start, int w)
{
- int vpstart = start;
- if (vpstart < 0)
- {
- vpstart = 0;
- }
-
- /*
- * if not wrapped, don't leave white space at the right margin
- */
+ int vpstart = Math.max(0, start);
+
if (!wrappedMode)
{
- if ((w <= getVisibleAlignmentWidth())
- && (vpstart + w - 1 > getVisibleAlignmentWidth() - 1))
+ // if not wrapped, don't leave white space at the right margin
+ int maxStart = getVisibleAlignmentWidth() - w;
+ if (maxStart >= 0)
{
- vpstart = getVisibleAlignmentWidth() - w;
+ vpstart = Math.min(vpstart, maxStart);
}
}
*/
public void setViewportStartAndHeight(int start, int h)
{
- int vpstart = start;
-
- int visHeight = getVisibleAlignmentHeight();
- if (vpstart < 0)
+ int vpstart = Math.max(0, start);
+ int maxStart = getVisibleAlignmentHeight() - h;
+ if (maxStart > 0)
{
- vpstart = 0;
+ // can't start higher than vertical extent will allow
+ // (viewport height is less than the full alignment
+ // and we are running off the bottom)
+ vpstart = Math.min(vpstart, maxStart);
}
- else if (h <= visHeight && vpstart + h > visHeight)
- // viewport height is less than the full alignment and we are running off
- // the bottom
- {
- vpstart = visHeight - h;
- }
- // System.out.println("ViewportRanges setviewportStartAndHeight " + vpstart
- // + " " + start + " " + h + " " + getVisibleAlignmentHeight());
-
setStartEndSeq(vpstart, vpstart + h - 1);
}