package jalview.viewmodel; import jalview.api.AlignmentColsCollectionI; import jalview.api.AlignmentRowsCollectionI; import jalview.datamodel.AlignmentI; import jalview.datamodel.ColumnSelection; import jalview.datamodel.HiddenSequences; import jalview.datamodel.VisibleColsCollection; import jalview.datamodel.VisibleRowsCollection; public class OverviewDimensionsAllVisible extends OverviewDimensions { public OverviewDimensionsAllVisible(ViewportRanges ranges, boolean showAnnotationPanel) { super(ranges, showAnnotationPanel); alwidth = ranges.getVisibleAlignmentWidth(); alheight = ranges.getVisibleAlignmentHeight(); } @Override public void updateViewportFromMouse(int mousex, int mousey, HiddenSequences hiddenSeqs, ColumnSelection hiddenCols, ViewportRanges ranges) { int x = mousex; int y = mousey; alwidth = ranges.getVisibleAlignmentWidth(); alheight = ranges.getVisibleAlignmentHeight(); if (x < 0) { x = 0; } if (y < 0) { y = 0; } // // Convert x value to residue position // // need to determine where scrollCol should be, given x // to do this also need to know width of viewport, and some hidden column // correction // convert x to residues - this is an absolute position int xAsRes = Math.round((float) x * alwidth / width); // get viewport width in residues int vpwidth = ranges.getEndRes() - ranges.getStartRes() + 1; if (xAsRes + vpwidth > alwidth) { // went past the end of the alignment, adjust backwards // if last position was before the end of the alignment, need to update if ((scrollCol + vpwidth - 1) < alwidth) { xAsRes = alwidth - vpwidth; } else { xAsRes = scrollCol; } } // // Convert y value to sequence position // // convert y to residues int yAsSeq = Math.round((float) y * alheight / sequencesHeight); // get viewport height in sequences // add 1 because height includes both endSeq and startSeq int vpheight = ranges.getEndSeq() - ranges.getStartSeq() + 1; if (yAsSeq + vpheight > alheight) { // went past the end of the alignment, adjust backwards if ((scrollRow + vpheight - 1) < alheight) { yAsSeq = alheight - vpheight; } else { yAsSeq = scrollRow; } } // update scroll values scrollCol = xAsRes; scrollRow = yAsSeq; } @Override public void setBoxPosition(HiddenSequences hiddenSeqs, ColumnSelection hiddenCols, ViewportRanges ranges) { alwidth = ranges.getVisibleAlignmentWidth(); alheight = ranges.getVisibleAlignmentHeight(); // work with visible values of startRes and endRes int startRes = ranges.getStartRes(); int endRes = ranges.getEndRes(); // work with visible values of startSeq and endSeq int startSeq = ranges.getStartSeq(); int endSeq = ranges.getEndSeq(); // boxX, boxY is the x,y location equivalent to startRes, startSeq boxX = Math.round((float) startRes * width / alwidth); boxY = Math.round((float) startSeq * sequencesHeight / alheight); // boxWidth is the width in residues translated to pixels // since the box includes both the start and end residues, add 1 to the // difference boxWidth = Math .round((float) (endRes - startRes + 1) * width / alwidth); // boxHeight is the height in sequences translated to pixels boxHeight = Math.round((float) (endSeq - startSeq + 1) * sequencesHeight / alheight); } @Override public AlignmentColsCollectionI getColumns(ViewportRanges ranges, ColumnSelection hiddenCols) { return new VisibleColsCollection(0, ranges.getVisibleAlignmentWidth() - 1, hiddenCols); } @Override public AlignmentRowsCollectionI getRows(ViewportRanges ranges, AlignmentI al) { return new VisibleRowsCollection(0, ranges.getVisibleAlignmentHeight() - 1, al); } }