*/
public void updateLayout()
{
+ if (getTopLevelAncestor() == null)
+ return;
ViewportRanges ranges = av.getRanges();
fontChanged();
setAnnotationVisible(av.isShowAnnotation());
idSpaceFillerPanel1.setVisible(!wrap);
- repaint();
+
+// BH not added to anything yet! repaint();
}
/**
* visible row to scroll to
*
*/
- public void setScrollValues(int xpos, int ypos)
+ public void setScrollValues(int x, int y)
{
- System.out.println("AlignmentPanel.setScrollValues " + xpos + "_" + ypos);
- int x = xpos;
- int y = ypos;
+ System.out.println("AlignmentPanel.setScrollValues " + x + "_" + y);
if (av == null || av.getAlignment() == null)
{
{
int width = av.getAlignment().getVisibleWidth();
int height = av.getAlignment().getHeight();
+
+ hextent = Math.min(getSeqPanel().seqCanvas.getWidth() / av.getCharWidth(), width);
+ vextent = Math.min(getSeqPanel().seqCanvas.getHeight() / av.getCharHeight(), height);
- hextent = getSeqPanel().seqCanvas.getWidth() / av.getCharWidth();
- vextent = getSeqPanel().seqCanvas.getHeight() / av.getCharHeight();
-
+ if (hextent < 0)
System.out.println("AlignmentPanel.setScrollValues found hext=" + hextent + " vext=" + vextent + " width=" + width + " height=" + height
);
+
+ x = Math.max(0, Math.min(x, width - hextent));
+ y = Math.max(0, Math.min(y, height - vextent));
- if (hextent > width)
- {
- hextent = width;
- }
-
- if (vextent > height)
- {
- vextent = height;
- }
-
-
-
- if ((hextent + x) > width)
- {
- x = width - hextent;
- }
-
- if ((vextent + y) > height)
- {
- y = height - vextent;
- }
-
System.out.println("AlignmentPanel.setScrollValues resetting these to " + x + "_" + y
+ " based on hext=" + hextent + " vext=" + vextent + " width=" + width + " height=" + height
);
-
- if (y < 0)
- {
- y = 0;
- }
-
- if (x < 0)
- {
- x = 0;
- }
updateRanges(x, y);
updateScrollBars(x, y, width, height);
* 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);
}
* Test the method that computes wrapped width in residues, height of wrapped
* widths in pixels, and the number of widths visible
*/
- @Test(groups = "Functional", priority = 0)
+ @Test(groups = "Functional")
public void testCalculateWrappedGeometry_noAnnotations()
{
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
* Test the method that computes wrapped width in residues, height of wrapped
* widths in pixels, and the number of widths visible
*/
- @Test(groups = "Functional", priority = 1)
+ @Test(groups = "Functional")
public void testCalculateWrappedGeometry_withAnnotations()
{
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
* endSeq should be unchanged, but the vertical repeat height should include
* all sequences.
*/
- @Test(groups = "Functional", priority = 2)
+ @Test(groups = "Functional")
public void testCalculateWrappedGeometry_fromScrolled()
{
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
assertEquals(al.getHeight(), 15);
ViewportRanges ranges = av.getRanges();
- System.out.println(av.getRanges() + " just before setting end to 3");
ranges.setStartEndSeq(0, 3);
- System.out.println(av.getRanges() + " just after setting end to 3");
+ System.out.println(ranges);
av.setShowAnnotation(false);
av.setScaleAboveWrapped(true);
+ System.out.println(ranges);
SeqCanvas testee = af.alignPanel.getSeqPanel().seqCanvas;
av.setWrapAlignment(true);
+ System.out.println(ranges);
av.setFont(new Font("SansSerif", Font.PLAIN, 14), true);
int charHeight = av.getCharHeight();
int charWidth = av.getCharWidth();
+ System.out.println(ranges);
// Windows h=19, w=11.
assertEquals(charHeight, !Platform.isWin() ? 17 : 19);
assertEquals(charWidth, !Platform.isWin() ? 12 : 11);
+ System.out.println(ranges);
int canvasWidth = 400;
int canvasHeight = 300;
testee.calculateWrappedGeometry(canvasWidth, canvasHeight);
- System.out.println(ranges + " just before assert");
+ System.out.println(ranges);
assertEquals(ranges.getEndSeq(), 3); // unchanged
int repeatingHeight = (int) PA.getValue(testee,
"wrappedRepeatHeightPx");