case KeyEvent.VK_PAGE_UP:
if (viewport.getWrapAlignment())
{
- alignPanel.scrollUp(true);
+ vpRanges.scrollUp(true);
}
else
{
- alignPanel.setScrollValues(vpRanges.getStartRes(),
- 2 * vpRanges.getStartSeq() - vpRanges.getEndSeq());
+ vpRanges.setStartSeq(2 * vpRanges.getStartSeq()
+ - vpRanges.getEndSeq());
}
break;
case KeyEvent.VK_PAGE_DOWN:
if (viewport.getWrapAlignment())
{
- alignPanel.scrollUp(false);
+ vpRanges.scrollUp(false);
}
else
{
- alignPanel.setScrollValues(vpRanges.getStartRes(),
- vpRanges.getEndSeq());
+ vpRanges.setStartSeq(vpRanges.getEndSeq());
}
break;
}
// reset the viewport ranges when the alignment panel is resized
// in particular, this initialises the end residue value when Jalview
// is initialised
- int widthInRes = (getSeqPanel().seqCanvas.getWidth() / av
- .getCharWidth()) - 1;
- int currentStartRes = vpRanges.getStartRes();
+
+
if (av.getWrapAlignment())
{
- widthInRes = getSeqPanel().seqCanvas
+ int widthInRes = getSeqPanel().seqCanvas
.getWrappedCanvasWidth(getSeqPanel().seqCanvas.getWidth());
+ vpRanges.setStartEndRes(vpRanges.getStartRes(), widthInRes);
+ }
+ else
+ {
+ int widthInRes = (getSeqPanel().seqCanvas.getWidth() / av
+ .getCharWidth()) - 1;
+ int heightInSeq = (getSeqPanel().seqCanvas.getHeight() / av.getCharHeight()) - 1;
+
+ vpRanges.setStartEndRes(vpRanges.getStartRes(), widthInRes);
+ vpRanges.setStartEndSeq(vpRanges.getStartSeq(), heightInSeq);
}
- vpRanges.setStartEndRes(currentStartRes, widthInRes);
+
}
});
getIdPanel().getIdCanvas().setPreferredSize(d);
hscrollFillerPanel.setPreferredSize(d);
- if (overviewPanel != null)
- {
- overviewPanel.setBoxPosition();
- }
if (this.alignFrame.getSplitViewContainer() != null)
{
((SplitFrame) this.alignFrame.getSplitViewContainer()).adjustLayout();
}
else
{
- scrollToWrappedVisible(start);
+ vpRanges.scrollToWrappedVisible(start);
+ // scrollToWrappedVisible(start);
}
}
- if (redrawOverview && overviewPanel != null)
- {
- overviewPanel.setBoxPosition();
- }
+
paintAlignment(redrawOverview);
return true;
}
- void scrollToWrappedVisible(int res)
- {
- int cwidth = getSeqPanel().seqCanvas
- .getWrappedCanvasWidth(getSeqPanel().seqCanvas.getWidth());
- if (res < vpRanges.getStartRes()
- || res >= (vpRanges.getStartRes() + cwidth))
- {
- vscroll.setValue((res / cwidth));
- }
-
- }
-
/**
* DOCUMENT ME!
*
annotationSpaceFillerHolder.setVisible(true);
}
- idSpaceFillerPanel1.setVisible(!wrap);
-
- repaint();
- }
-
- // return value is true if the scroll is valid
- public boolean scrollUp(boolean up)
- {
- if (up)
+ if (wrap)
{
- if (vscroll.getValue() < 1)
- {
- return false;
- }
-
- fastPaint = false;
- vscroll.setValue(vscroll.getValue() - 1);
+ int widthInRes = getSeqPanel().seqCanvas
+ .getWrappedCanvasWidth(getSeqPanel().seqCanvas.getWidth());
+ vpRanges.setStartEndRes(vpRanges.getStartRes(), widthInRes);
}
else
{
- if ((vextent + vscroll.getValue()) >= av.getAlignment().getHeight())
- {
- return false;
- }
+ int widthInRes = (getSeqPanel().seqCanvas.getWidth() / av
+ .getCharWidth()) - 1;
+ int heightInSeq = (getSeqPanel().seqCanvas.getHeight() / av
+ .getCharHeight()) - 1;
- fastPaint = false;
- vscroll.setValue(vscroll.getValue() + 1);
+ vpRanges.setStartEndRes(vpRanges.getStartRes(), widthInRes);
+ vpRanges.setStartEndSeq(vpRanges.getStartSeq(), heightInSeq);
}
- fastPaint = true;
+ idSpaceFillerPanel1.setVisible(!wrap);
- return true;
+ repaint();
}
- /**
- * DOCUMENT ME!
- *
- * @param right
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public boolean scrollRight(boolean right)
- {
- if (!right)
- {
- if (hscroll.getValue() < 1)
- {
- return false;
- }
-
- fastPaint = false;
- hscroll.setValue(hscroll.getValue() - 1);
- }
- else
- {
- if ((hextent + hscroll.getValue()) >= av.getAlignment().getWidth())
- {
- return false;
- }
-
- fastPaint = false;
- hscroll.setValue(hscroll.getValue() + 1);
- }
-
- fastPaint = true;
-
- return true;
- }
/**
* Adjust row/column scrollers to show a visible position in the alignment.
public void adjustmentValueChanged(AdjustmentEvent evt)
{
int oldX = vpRanges.getStartRes();
+ int oldwidth = vpRanges.getViewportWidth();
int oldY = vpRanges.getStartSeq();
+ int oldheight = vpRanges.getViewportHeight();
if (av.getWrapAlignment())
{
// if we're scrolling to the position we're already at, stop
// this prevents infinite recursion of events when the scroll/viewport
// ranges values are the same
- if (offy * rowSize == oldX)
+ if ((offy * rowSize == oldX) && (oldwidth == rowSize))
{
return;
}
if (evt.getSource() == hscroll)
{
int x = hscroll.getValue();
+ int width = (getSeqPanel().seqCanvas.getWidth() / av.getCharWidth()) - 1;
// if we're scrolling to the position we're already at, stop
// this prevents infinite recursion of events when the scroll/viewport
// ranges values are the same
- if (x == oldX)
+ if ((x == oldX) && (width == oldwidth))
{
return;
}
- vpRanges.setStartEndRes(x,
- (x + (getSeqPanel().seqCanvas.getWidth() / av
- .getCharWidth())) - 1);
+ vpRanges.setStartEndRes(x, x + width);
}
else if (evt.getSource() == vscroll)
{
- int offy = vscroll.getValue();
+ int y = vscroll.getValue();
+ int height = (getSeqPanel().seqCanvas.getHeight() / av
+ .getCharHeight()) - 1;
// if we're scrolling to the position we're already at, stop
// this prevents infinite recursion of events when the scroll/viewport
// ranges values are the same
- if (offy == oldY)
+ if ((y == oldY) && (height == oldheight))
{
return;
}
- vpRanges.setStartEndSeq(
- offy,
- offy
- + (getSeqPanel().seqCanvas.getHeight() / av
- .getCharHeight()) - 1);
+ vpRanges.setStartEndSeq(y, y + height);
}
if (!fastPaint)
{
e.consume();
if (e.getWheelRotation() > 0)
{
- ap.scrollRight(true);
+ av.getRanges().scrollRight(true);
}
else
{
- ap.scrollRight(false);
+ av.getRanges().scrollRight(false);
}
}
else
{
if (e.isShiftDown())
{
- alignPanel.scrollRight(true);
+ av.getRanges().scrollRight(true);
}
else
{
- alignPanel.scrollUp(false);
+ av.getRanges().scrollUp(false);
}
}
else
{
if (e.isShiftDown())
{
- alignPanel.scrollRight(false);
+ av.getRanges().scrollRight(false);
}
else
{
- alignPanel.scrollUp(true);
+ av.getRanges().scrollUp(true);
}
}
}
if ((av.getRanges().getStartSeq() > index)
|| (av.getRanges().getEndSeq() < index))
{
- alignPanel.setScrollValues(av.getRanges().getStartRes(), index);
+ av.getRanges().setStartSeq(index);
}
}
while (running)
{
- if (alignPanel.scrollUp(up))
+ if (av.getRanges().scrollUp(up))
{
// scroll was ok, so add new sequence to selection
int seq = av.getRanges().getStartSeq();
od.updateViewportFromMouse(evt.getX(), evt.getY(), av
.getAlignment().getHiddenSequences(), av
.getColumnSelection(), av.getRanges());
+ // TODO set via ViewportRanges in overview dimensions once JAL-2388 is
+ // merged
ap.setScrollValues(od.getScrollCol(), od.getScrollRow());
}
}
od.updateViewportFromMouse(evt.getX(), evt.getY(), av
.getAlignment().getHiddenSequences(), av
.getColumnSelection(), av.getRanges());
+ // TODO set via ViewportRanges in overview dimensions once JAL-2388 is
+ // merged
ap.setScrollValues(od.getScrollCol(), od.getScrollRow());
}
}
* changed
*
*/
- public void setBoxPosition()
+ private void setBoxPosition()
{
od.setBoxPosition(av.getAlignment()
.getHiddenSequences(), av.getColumnSelection(), av.getRanges());
endEditing();
if (av.getWrapAlignment())
{
- ap.scrollToWrappedVisible(seqCanvas.cursorX);
+ av.getRanges().scrollToWrappedVisible(seqCanvas.cursorX);
+ // ap.scrollToWrappedVisible(seqCanvas.cursorX);
}
else
{
while (seqCanvas.cursorY < av.getRanges().getStartSeq())
{
- ap.scrollUp(true);
+ av.getRanges().scrollUp(true);
}
while (seqCanvas.cursorY + 1 > av.getRanges().getEndSeq())
{
- ap.scrollUp(false);
+ av.getRanges().scrollUp(false);
}
- if (!av.getWrapAlignment())
+
+ while (seqCanvas.cursorX < av.getColumnSelection()
+ .adjustForHiddenColumns(av.getRanges().getStartRes()))
{
- while (seqCanvas.cursorX < av.getColumnSelection()
- .adjustForHiddenColumns(av.getRanges().getStartRes()))
+ if (!av.getRanges().scrollRight(false))
{
- if (!ap.scrollRight(false))
- {
- break;
- }
+ break;
}
- while (seqCanvas.cursorX > av.getColumnSelection()
- .adjustForHiddenColumns(av.getRanges().getEndRes()))
+ }
+ while (seqCanvas.cursorX > av.getColumnSelection()
+ .adjustForHiddenColumns(av.getRanges().getEndRes()))
+ {
+ if (!av.getRanges().scrollRight(true))
{
- if (!ap.scrollRight(true))
- {
- break;
- }
+ break;
}
}
+
}
setStatusMessage(av.getAlignment().getSequenceAt(seqCanvas.cursorY),
seqCanvas.cursorX, seqCanvas.cursorY);
{
if (e.isShiftDown())
{
- ap.scrollRight(true);
+ av.getRanges().scrollRight(true);
}
else
{
- ap.scrollUp(false);
+ av.getRanges().scrollUp(false);
}
}
else
{
if (e.isShiftDown())
{
- ap.scrollRight(false);
+ av.getRanges().scrollRight(false);
}
else
{
- ap.scrollUp(true);
+ av.getRanges().scrollUp(true);
}
}
// TODO Update tooltip for new position.
if (mouseDragging && (evt.getY() < 0)
&& (av.getRanges().getStartSeq() > 0))
{
- running = ap.scrollUp(true);
+ running = av.getRanges().scrollUp(true);
}
if (mouseDragging && (evt.getY() >= getHeight())
&& (av.getAlignment().getHeight() > av.getRanges()
.getEndSeq()))
{
- running = ap.scrollUp(false);
+ running = av.getRanges().scrollUp(false);
}
if (mouseDragging && (evt.getX() < 0))
{
- running = ap.scrollRight(false);
+ running = av.getRanges().scrollRight(false);
}
else if (mouseDragging && (evt.getX() >= getWidth()))
{
- running = ap.scrollRight(true);
+ running = av.getRanges().scrollRight(true);
}
}
*/
public void setStartRes(int res)
{
- int oldres = this.startRes;
- setStartResInternal(res);
- changeSupport.firePropertyChange("startres", oldres, res);
+ int width = getViewportWidth();
+ setStartEndRes(res, res + width - 1);
}
- private void setStartResInternal(int res)
+ public void setStartEndRes(int startres, int endres)
{
- if (res > al.getWidth() - 1)
+ int oldres = this.startRes;
+ if (startres > al.getWidth() - 1)
{
- res = al.getWidth() - 1;
+ startres = al.getWidth() - 1;
}
- else if (res < 0)
+ else if (startres < 0)
{
- res = 0;
+ startres = 0;
}
- this.startRes = res;
- }
+ this.startRes = startres;
+
+ if (endres >= al.getWidth())
+ {
+ endres = al.getWidth() - 1;
+ }
+ else if (endres < 0)
+ {
+ endres = 0;
+ }
+ this.endRes = endres;
- public void setStartEndRes(int startres, int endres)
- {
- int oldres = this.startRes;
- setStartResInternal(startres);
- setEndResInternal(endres);
changeSupport.firePropertyChange("startres", oldres, startres);
}
*/
public void setEndRes(int res)
{
- int oldres = this.endRes;
- setEndResInternal(res);
-
- changeSupport.firePropertyChange("endres", oldres, res);
- }
-
- private void setEndResInternal(int res)
- {
- if (res >= al.getWidth())
- {
- res = al.getWidth() - 1;
- }
- else if (res < 0)
- {
- res = 0;
- }
- this.endRes = res;
+ int width = getViewportWidth();
+ setStartEndRes(res - width + 1, res);
}
/**
*/
public void setStartSeq(int seq)
{
- int oldseq = this.startSeq;
- setStartSeqInternal(seq);
- changeSupport.firePropertyChange("startseq", oldseq, seq);
+ int height = getViewportHeight();
+ setStartEndSeq(seq, seq + height - 1);
}
- private void setStartSeqInternal(int seq)
+ public void setStartEndSeq(int startseq, int endseq)
{
- if (seq > al.getHeight() - 1)
+ int oldseq = this.startSeq;
+ if (startseq > al.getHeight() - 1)
{
- seq = al.getHeight() - 1;
+ startseq = al.getHeight() - 1;
}
- else if (seq < 0)
+ else if (startseq < 0)
{
- seq = 0;
+ startseq = 0;
}
- this.startSeq = seq;
- }
+ this.startSeq = startseq;
- public void setStartEndSeq(int startseq, int endseq)
- {
- int oldseq = this.startSeq;
- setStartSeqInternal(startseq);
- setEndSeqInternal(endseq);
+ if (endseq >= al.getHeight())
+ {
+ endseq = al.getHeight() - 1;
+ }
+ else if (endseq < 0)
+ {
+ endseq = 0;
+ }
+ this.endSeq = endseq;
changeSupport.firePropertyChange("startseq", oldseq, startseq);
}
*/
public void setEndSeq(int seq)
{
- int oldseq = this.endSeq;
- setEndSeqInternal(seq);
- changeSupport.firePropertyChange("endseq", oldseq, seq);
- }
-
- private void setEndSeqInternal(int seq)
- {
- if (seq >= al.getHeight())
- {
- seq = al.getHeight() - 1;
- }
- else if (seq < 0)
- {
- seq = 0;
- }
- this.endSeq = seq;
+ int height = getViewportHeight();
+ setStartEndSeq(seq - height + 1, seq);
}
/**
{
return endSeq;
}
+
+ /**
+ * Get width of viewport in residues
+ *
+ * @return width of viewport
+ */
+ public int getViewportWidth()
+ {
+ return (endRes - startRes + 1); // TODO get for wrapped alignments too
+ }
+
+ /**
+ * Get height of viewport in residues
+ *
+ * @return height of viewport
+ */
+ public int getViewportHeight()
+ {
+ return (endSeq - startSeq + 1);
+ }
+
+ // return value is true if the scroll is valid
+ public boolean scrollUp(boolean up)
+ {
+ if (up)
+ {
+ if (startSeq < 1)
+ {
+ return false;
+ }
+
+ setStartSeq(startSeq - 1);
+ }
+ else
+ {
+ if (endSeq >= al.getHeight() - 1)
+ {
+ return false;
+ }
+
+ setStartSeq(startSeq + 1);
+ }
+ return true;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param right
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean scrollRight(boolean right)
+ {
+ if (!right)
+ {
+ if (startRes < 1)
+ {
+ return false;
+ }
+
+ setStartRes(startRes - 1);
+ }
+ else
+ {
+ if (endRes > al.getWidth() - 1)
+ {
+ return false;
+ }
+
+ setStartRes(startRes + 1);
+ }
+
+ return true;
+ }
+
+ public void scrollToWrappedVisible(int res)
+ {
+ if (res < startRes || res > endRes)
+ {
+ setEndSeq(res / getViewportWidth());
+ }
+
+ }
+
}