/* * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 * of the License, or (at your option) any later version. * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.viewmodel; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import jalview.bin.Cache; import jalview.bin.Jalview; import jalview.datamodel.Alignment; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; import jalview.gui.AlignViewport; import jalview.io.DataSourceType; import jalview.io.FileLoader; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; public class OverviewDimensionsTest { boolean showConservationSetting; SequenceI seq1 = new Sequence( "Seq1", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq2 = new Sequence( "Seq2", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq3 = new Sequence( "Seq3", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq4 = new Sequence( "Seq4", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq5 = new Sequence( "Seq5", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq6 = new Sequence( "Seq6", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq7 = new Sequence( "Seq7", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq8 = new Sequence( "Seq8", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq9 = new Sequence( "Seq9", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq10 = new Sequence( "Seq10", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq11 = new Sequence( "Seq11", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq12 = new Sequence( "Seq12", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq13 = new Sequence( "Seq13", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq14 = new Sequence( "Seq14", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq15 = new Sequence( "Seq15", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq16 = new Sequence( "Seq16", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq17 = new Sequence( "Seq17", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq18 = new Sequence( "Seq18", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq19 = new Sequence( "Seq19", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq20 = new Sequence( "Seq20", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq21 = new Sequence( "Seq21", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq22 = new Sequence( "Seq22", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC" + "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC" + "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC" + "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC" + "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); SequenceI seq23 = new Sequence( "Seq23", "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); AlignFrame af; @BeforeMethod(alwaysRun = true) public void setUp() { Jalview.main(new String[] { "-nonews", "-props", "test/jalview/testProps.jvprops" }); Cache.applicationProperties.setProperty("SHOW_IDENTITY", Boolean.TRUE.toString()); af = new FileLoader().LoadFileWaitTillLoaded( "examples/testdata/bigal.fa", DataSourceType.FILE); /* * wait for Consensus thread to complete */ synchronized (this) { while (af.getViewport().getConsensusSeq() == null) { try { wait(50); } catch (InterruptedException e) { } } } // get cached setting for showConservation // reset it in AfterClass! showConservationSetting = Cache.getDefault("SHOW_CONSERVATION", true); } @AfterClass(alwaysRun = true) public void tearDown() { Cache.applicationProperties.setProperty("SHOW_CONSERVATION", Boolean.toString(showConservationSetting)); } /** * Test that the OverviewDimensions constructor sets width and height * correctly */ @Test(groups = { "Functional" }) public void testConstructor() { SequenceI seqa = new Sequence("Seq1", "ABC"); SequenceI seqb = new Sequence("Seq2", "ABC"); SequenceI seqc = new Sequence("Seq3", "ABC"); SequenceI seqd = new Sequence("Seq4", "ABC"); SequenceI seqe = new Sequence("Seq5", "ABCABCABCABCABCABCABCABCBACBACBACBAC"); int defaultGraphHeight = 20; int maxWidth = 400; int minWidth = 120; int maxSeqHeight = 300; int minSeqHeight = 40; Cache.applicationProperties.setProperty("SHOW_CONSERVATION", Boolean.toString(true)); // test for alignment with width > height SequenceI[] seqs1 = new SequenceI[] { seqa, seqb }; Alignment al1 = new Alignment(seqs1); al1.setDataset(null); AlignViewport av1 = new AlignViewport(al1); OverviewDimensions od = new OverviewDimensions(av1); int scaledHeight = 266; assertEquals(od.getGraphHeight(), defaultGraphHeight); assertEquals(od.getSequencesHeight(), scaledHeight); assertEquals(od.getWidth(), maxWidth); assertEquals(od.getHeight(), scaledHeight + defaultGraphHeight); // test for alignment with width < height SequenceI[] seqs2 = new SequenceI[] { seqa, seqb, seqc, seqd }; Alignment al2 = new Alignment(seqs2); al2.setDataset(null); AlignViewport av2 = new AlignViewport(al2); od = new OverviewDimensions(av2); int scaledWidth = 300; assertEquals(od.getGraphHeight(), defaultGraphHeight); assertEquals(od.getSequencesHeight(), maxSeqHeight); assertEquals(od.getWidth(), scaledWidth); assertEquals(od.getHeight(), scaledWidth + defaultGraphHeight); // test for alignment with width > height and sequence height scaled below // min value SequenceI[] seqs3 = new SequenceI[] { seqe }; Alignment al3 = new Alignment(seqs3); al3.setDataset(null); AlignViewport av3 = new AlignViewport(al3); od = new OverviewDimensions(av3); assertEquals(od.getGraphHeight(), defaultGraphHeight); assertEquals(od.getSequencesHeight(), minSeqHeight); assertEquals(od.getWidth(), maxWidth); assertEquals(od.getHeight(), minSeqHeight + defaultGraphHeight); // test for alignment with width < height and width scaled below min value SequenceI[] seqs4 = new SequenceI[] { seqa, seqb, seqc, seqd, seqa, seqb, seqc, seqd, seqa, seqb, seqc, seqd, seqa, seqb, seqc, seqd }; Alignment al4 = new Alignment(seqs4); al4.setDataset(null); AlignViewport av4 = new AlignViewport(al4); od = new OverviewDimensions(av4); assertEquals(od.getGraphHeight(), defaultGraphHeight); assertEquals(od.getSequencesHeight(), maxSeqHeight); assertEquals(od.getWidth(), minWidth); assertEquals(od.getHeight(), maxSeqHeight + defaultGraphHeight); // test for alignment where no conservation annotation is shown Cache.applicationProperties.setProperty("SHOW_CONSERVATION", Boolean.toString(false)); Alignment al5 = new Alignment(seqs4); al5.setDataset(null); AlignViewport av5 = new AlignViewport(al5); od = new OverviewDimensions(av5); assertEquals(od.getGraphHeight(), 0); assertEquals(od.getSequencesHeight(), maxSeqHeight); assertEquals(od.getWidth(), minWidth); assertEquals(od.getHeight(), maxSeqHeight); } /** * Test that validation after mouse adjustments to boxX and boxY sets box * dimensions and scroll values correctly, when there are no hidden rows or * columns. * * The current implementation uses multiple transformations between coordinate * systems which often involve casting to int, which causes values to be * truncated. As a result we can lose accuracy. The tests below use * approximate test values where appropriate. */ @Test(groups = { "Functional" }) public void testSetBoxFromMouseClick() { AlignViewport av = af.getViewport(); OverviewDimensions od = new OverviewDimensions(av); // Initial box sizing - default path through code od.setBoxPosition(); float scalew = (float) od.getWidth() / (av.getAlignment().getWidth() * av.getCharWidth()); float scaleh = (float) od.getSequencesHeight() / (av.getAlignment().getHeight() * av.getCharHeight()); int boxWidth = (int) ((av.getEndRes() - av.getStartRes() + 1) * av.getCharWidth() * scalew); int boxHeight = (int) ((av.getEndSeq() - av.getStartSeq()) * av.getCharHeight() * scaleh); od.checkValid(); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getScrollCol(), 0); assertEquals(od.getScrollRow(), 0); // negative boxX value reset to 0 mouseClick(od, -5, 10); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollRow(), (int) (10 / scaleh / av.getCharHeight())); assertEquals(od.getScrollCol(), 0); // negative boxY value reset to 0 mouseClick(od, 6, -2); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), (int) (6 / scalew / av.getCharWidth())); assertEquals(od.getScrollRow(), 0); // overly large boxX value reset to width-boxWidth mouseClick(od, 100, 6); assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth(), 1.5); assertEquals(od.getBoxY(), 6, 1.5); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), (od.getBoxX() / scalew / av.getCharWidth()), 1.5); assertEquals(od.getScrollRow(), (od.getBoxY() / scaleh / av.getCharHeight()), 1.5); // overly large boxY value reset to sequenceHeight - boxHeight mouseClick(od, 10, 520); assertEquals(od.getBoxX(), 10, 1.5); assertEquals(od.getBoxY(), od.getSequencesHeight() - od.getBoxHeight(), 1.5); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight, 1.5); assertEquals(od.getScrollCol(), (od.getBoxX() / scalew / av.getCharWidth()), 1.5); assertEquals(od.getScrollRow(), (od.getBoxY() / scaleh / av.getCharHeight()), 1.5); // click past end of alignment, as above mouseClick(od, 3000, 5); assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth(), 1.5); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight, 1.5); assertEquals(od.getScrollCol(), (od.getBoxX() / scalew / av.getCharWidth()), 1.5); assertEquals(od.getScrollRow(), (od.getBoxY() / scaleh / av.getCharHeight()), 1.5); // move viewport so startRes non-zero and then mouseclick moveViewportH(av, od, 50); // click at viewport position int oldboxx = od.getBoxX(); int oldboxy = od.getBoxY(); mouseClick(od, od.getBoxX() + 5, od.getBoxY() + 2); assertEquals(od.getBoxX(), oldboxx + 5, 1.5); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight, 1.5); assertEquals(od.getScrollCol(), (od.getBoxX() / scalew / av.getCharWidth()), 1.5); assertEquals(od.getBoxY(), oldboxy + 2, 1.5); assertEquals(od.getScrollRow(), (od.getBoxY() / scaleh / av.getCharHeight()), 1.5); // click at top corner mouseClick(od, 0, 0); assertEquals(od.getBoxX(), 0); assertEquals(od.getScrollCol(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getScrollRow(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight, 1.5); } /** * Test setting of the box position, when there are hidden cols at the start * of the alignment */ @Test(groups = { "Functional" }) public void testFromMouseWithHiddenColsAtStart() { AlignViewport av = af.getViewport(); OverviewDimensions od = new OverviewDimensions(av); // Initial box sizing - default path through code od.setBoxPosition(); float scalew = (float) od.getWidth() / (av.getAlignment().getWidth() * av.getCharWidth()); float scaleh = (float) od.getSequencesHeight() / (av.getAlignment().getHeight() * av.getCharHeight()); int boxWidth = (int) ((av.getEndRes() - av.getStartRes() + 1) * av.getCharWidth() * scalew); int boxHeight = (int) ((av.getEndSeq() - av.getStartSeq()) * av.getCharHeight() * scaleh); od.checkValid(); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getScrollCol(), 0); assertEquals(od.getScrollRow(), 0); // hide cols at start and check updated box position is correct // changes boxX but not boxwidth int lastHiddenCol = 30; av.hideColumns(0, lastHiddenCol); od.setBoxPosition(); assertEquals(od.getBoxX(), (int) ((lastHiddenCol + 1) * scalew * av.getCharWidth())); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); // try to click in hidden cols, check box does not move int xpos = 10; mouseClick(od, xpos, 0); assertEquals(od.getBoxX(), (int) ((lastHiddenCol + 1) * scalew * av.getCharWidth())); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollRow(), 0); assertEquals(od.getScrollCol(), (int) (xpos / scalew / av.getCharWidth())); // click to right of hidden columns, box moves to click point xpos = 40; mouseClick(od, xpos, 0); assertEquals(od.getBoxX(), (int) ((xpos - lastHiddenCol) * scalew * av.getCharWidth())); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollRow(), 0); assertEquals(od.getScrollCol(), (int) (xpos / scalew / av.getCharWidth())); // click to right of hidden columns such that box runs over right hand side // of alignment // box position is adjusted away from the edge // overly large boxX value reset to width-boxWidth xpos = 100; mouseClick(od, xpos, 5); assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth() - ((int) (lastHiddenCol * scalew * av.getCharWidth()))); assertEquals(od.getBoxY(), 5); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), (int) (xpos / scalew / av.getCharWidth())); assertEquals(od.getScrollRow(), (int) (od.getBoxY() / scaleh / av.getCharHeight())); } @Test(groups = { "Functional" }) public void testSetBoxPosWithHiddenColsAtEnd() { } @Test(groups = { "Functional" }) public void testSetBoxPosWithHiddenColsMiddle() { AlignViewport av = af.getViewport(); OverviewDimensions od = new OverviewDimensions(av); av.setStartRes(50); // hiding columns before current position: changes boxX but not boxwidth od.setBoxPosition(); int prevBoxX = od.getBoxX(); int prevWidth = od.getBoxWidth(); av.hideColumns(10, 20); od.setBoxPosition(); assertEquals(od.getBoxX(), 75); assertTrue(prevBoxX < od.getBoxX()); assertEquals(od.getBoxWidth(), prevWidth); // hiding columns after current position: changes end position but not start // so scrollCol and boxX do not change but boxWidth does prevWidth = od.getBoxWidth(); av.hideColumns(108, 110); od.setBoxPosition(); assertEquals(od.getBoxX(), prevBoxX); assertEquals(od.getScrollCol(), 49); // assertEquals(od2.getBoxWidth(), prevWidth + ((int) 2 * av.getCharWidth() // / scalew)); } @Test(groups = { "Functional" }) public void testSetBoxPosWithHiddenRowsAtStart() { AlignViewport av = af.getViewport(); OverviewDimensions od = new OverviewDimensions(av); av.setStartRes(50); // account for hidden rows SequenceI[] hidden = { seq2, seq3, seq4, seq5, seq6, seq7 }; av.showAllHiddenColumns(); av.hideSequence(hidden); od.checkValid(); assertEquals(od.getBoxY(), 0); assertEquals(od.getScrollRow(), 0); } /** * Test that the box position is set correctly when set from the viewport, * with no hidden rows or columns */ @Test(groups = { "Functional" }) public void testSetBoxFromViewport() { AlignViewport av = af.getViewport(); OverviewDimensions od = new OverviewDimensions(av); od.setBoxPosition(); float scalew = (float) od.getWidth() / (av.getAlignment().getWidth() * av.getCharWidth()); float scaleh = (float) od.getSequencesHeight() / (av.getAlignment().getHeight() * av.getCharHeight()); int boxWidth = (int) ((av.getEndRes() - av.getStartRes() + 1) * av.getCharWidth() * scalew); int boxHeight = (int) ((av.getEndSeq() - av.getStartSeq()) * av.getCharHeight() * scaleh); // move viewport to start of alignment moveViewport(av, od, 0, 0); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); // move viewport to right moveViewportH(av, od, 70); assertEquals(od.getBoxX(), (int) (70 * scalew * av.getCharWidth())); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); // move viewport down moveViewportV(av, od, 100); assertEquals(od.getBoxX(), (int) (70 * scalew * av.getCharWidth())); assertEquals(od.getBoxY(), (int) (100 * scaleh * av.getCharHeight())); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); // move viewport to bottom right moveViewport(av, od, 98, 508); assertEquals(od.getBoxX(), (int) (98 * scalew * av.getCharWidth())); assertEquals(od.getBoxY(), (int) (508 * scaleh * av.getCharHeight())); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); } /* * Move viewport horizontally: startRes + previous width gives new horizontal extent. Vertical extent stays the same. */ private void moveViewportH(AlignViewport av, OverviewDimensions od, int startRes) { int width = av.getEndRes() - av.getStartRes(); av.setStartRes(startRes); av.setEndRes(startRes + width); od.setBoxPosition(); } /* * Move viewport vertically: startSeq and endSeq give new vertical extent. Horizontal extent stays the same. */ private void moveViewportV(AlignViewport av, OverviewDimensions od, int startSeq) { int height = av.getEndSeq() - av.getStartSeq(); av.setStartSeq(startSeq); av.setEndSeq(startSeq + height); od.setBoxPosition(); } /* * Move viewport horizontally and vertically. */ private void moveViewport(AlignViewport av, OverviewDimensions od, int startRes, int startSeq) { int width = av.getEndRes() - av.getStartRes(); int height = av.getEndSeq() - av.getStartSeq(); av.setStartRes(startRes); av.setEndRes(startRes + width); av.setStartSeq(startSeq); av.setEndSeq(startSeq + height); od.setBoxPosition(); } /* * Mouse click as position x,y in overview window */ private void mouseClick(OverviewDimensions od, int x, int y) { od.setBoxX(x); od.setBoxY(y); od.checkValid(); // updates require an OverviewPanel to exist which it doesn't here // so call setBoxPosition() as it would be called by the AlignmentPanel // normally AlignViewport av = af.getViewport(); int width = av.getEndRes() - av.getStartRes(); int height = av.getEndSeq() - av.getStartSeq(); av.setStartRes(od.getScrollCol()); av.setEndRes(od.getScrollCol() + width); av.setStartSeq(od.getScrollRow()); av.setEndSeq(od.getScrollRow() + height); od.setBoxPosition(); } }