/**
* Set first residue visible in the viewport, and retain the current width.
+ * Fires a property change event.
*
* @param res
* residue position
*/
public void setStartEndRes(int start, int end)
{
- int oldres = this.startRes;
+ int oldstartres = this.startRes;
if (start > al.getWidth() - 1)
{
startRes = al.getWidth() - 1;
startRes = start;
}
+ int oldendres = this.endRes;
if (end < 0)
{
endRes = 0;
endRes = end;
}
- changeSupport.firePropertyChange("startres", oldres, start);
+ changeSupport.firePropertyChange("startres", oldstartres, start);
+ if (oldstartres == start)
+ {
+ // 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, end);
+ }
}
/**
- * Set last residue visible in the viewport
+ * Set last residue visible in the viewport. Fires a property change event.
*
* @param res
* residue position
}
/**
- * Set the first sequence visible in the viewport
+ * Set the first sequence visible in the viewport. Fires a property change
+ * event.
*
* @param seq
* sequence position
*/
public void setStartEndSeq(int start, int end)
{
- int oldseq = this.startSeq;
+ int oldstartseq = this.startSeq;
if (start > al.getHeight() - 1)
{
startSeq = al.getHeight() - 1;
startSeq = start;
}
+ int oldendseq = this.endSeq;
if (end >= al.getHeight())
{
endSeq = al.getHeight() - 1;
endSeq = end;
}
- changeSupport.firePropertyChange("startseq", oldseq, start);
+ changeSupport.firePropertyChange("startseq", oldstartseq, start);
+ if (oldstartseq == start)
+ {
+ // event won't be fired if start positions are the same
+ // fire in case the end positions changed
+ changeSupport.firePropertyChange("endseq", oldendseq, end);
+ }
}
/**
- * Set the last sequence visible in the viewport
+ * Set the last sequence visible in the viewport. Fires a property change
+ * event.
*
* @param seq
* sequence position
/**
* Set viewport width in residues, without changing startRes. Use in
* preference to calculating endRes from the width, to avoid out by one
- * errors!
+ * errors! Fires a property change event.
*
* @param w
* width in residues
/**
* Set viewport height in residues, without changing startSeq. Use in
* preference to calculating endSeq from the height, to avoid out by one
- * errors!
+ * errors! Fires a property change event.
*
* @param h
* height in sequences
/**
* Set viewport horizontal start position and width. Use in preference to
- * calculating endRes from the width, to avoid out by one errors!
+ * calculating endRes from the width, to avoid out by one errors! Fires a
+ * property change event.
*
* @param start
* start residue
*/
public void setViewportStartAndWidth(int start, int w)
{
- setStartEndRes(start, start + w - 1);
+ int vpstart = start;
+ if (vpstart < 0)
+ {
+ vpstart = 0;
+ }
+ else if (vpstart + w - 1 > al.getWidth() - 1)
+ {
+ vpstart = al.getWidth() - 1;
+ }
+ setStartEndRes(vpstart, vpstart + w - 1);
}
/**
* Set viewport vertical start position and height. Use in preference to
- * calculating endSeq from the height, to avoid out by one errors!
+ * calculating endSeq from the height, to avoid out by one errors! Fires a
+ * property change event.
*
* @param start
* start sequence
*/
public void setViewportStartAndHeight(int start, int h)
{
- setStartEndSeq(start, start + h - 1);
+ int vpstart = start;
+ if (vpstart < 0)
+ {
+ vpstart = 0;
+ }
+ else if (vpstart + h - 1 > al.getHeight() - 1)
+ {
+ vpstart = al.getHeight() - h;
+ }
+ setStartEndSeq(vpstart, vpstart + h - 1);
}
/**
}
/**
- * Scroll the viewport range vertically
+ * Scroll the viewport range vertically. Fires a property change event.
*
* @param up
* true if scrolling up, false if down
}
/**
- * Scroll the viewport range horizontally
+ * Scroll the viewport range horizontally. Fires a property change event.
*
* @param right
* true if scrolling right, false if left
}
/**
- * Scroll a wrapped alignment so that the specified residue is visible
+ * Scroll a wrapped alignment so that the specified residue is visible. Fires
+ * a property change event.
*
* @param res
* residue position to scroll to
}
/**
- * Scroll so that (x,y) is visible
+ * Scroll so that (x,y) is visible. Fires a property change event.
*
* @param x
* x position in alignment
}
}
}
-
+
+ /**
+ * Adjust sequence position for page up. Fires a property change event.
+ */
+ public void pageUp()
+ {
+ setViewportStartAndHeight(2 * startSeq - endSeq, getViewportHeight());
+ }
+
+ /**
+ * Adjust sequence position for page down. Fires a property change event.
+ */
+ public void pageDown()
+ {
+ setViewportStartAndHeight(endSeq, getViewportHeight());
+ }
}