package jalview.viewmodel; import jalview.api.AlignmentColsCollectionI; import jalview.api.AlignmentRowsCollectionI; import jalview.datamodel.AlignmentI; import jalview.datamodel.HiddenColumns; import jalview.datamodel.HiddenSequences; import jalview.datamodel.VisibleColsCollection; import jalview.datamodel.VisibleRowsCollection; public class OverviewDimensionsHideHidden extends OverviewDimensions { private ViewportRanges ranges; public OverviewDimensionsHideHidden(ViewportRanges vpranges, boolean showAnnotationPanel) { super(vpranges, showAnnotationPanel); ranges = vpranges; resetAlignmentDims(); } @Override public void updateViewportFromMouse(int mousex, int mousey, HiddenSequences hiddenSeqs, HiddenColumns hiddenCols) { resetAlignmentDims(); int xAsRes = getLeftXFromCentreX(mousex, hiddenCols); int yAsSeq = getTopYFromCentreY(mousey, hiddenSeqs); if (xAsRes < 0) { xAsRes = 0; } if (yAsSeq < 0) { yAsSeq = 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.getViewportWidth(); 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 (ranges.getStartRes() < alwidth) { xAsRes = alwidth - vpwidth; } else { xAsRes = ranges.getStartRes(); } } // // Convert y value to sequence position // // get viewport height in sequences // add 1 because height includes both endSeq and startSeq int vpheight = ranges.getViewportHeight(); if (yAsSeq + vpheight > alheight) { // went past the end of the alignment, adjust backwards if (ranges.getEndSeq() < alheight) { yAsSeq = alheight - vpheight; } else { yAsSeq = ranges.getStartSeq(); } } // update viewport ranges.setStartRes(xAsRes); ranges.setStartSeq(yAsSeq); } @Override public void setBoxPosition(HiddenSequences hiddenSeqs, HiddenColumns hiddenCols) { setBoxPosition(ranges.getStartRes(), ranges.getStartSeq(), ranges.getViewportWidth(), ranges.getViewportHeight()); } @Override public AlignmentColsCollectionI getColumns(AlignmentI al) { return new VisibleColsCollection(0, ranges.getAbsoluteAlignmentWidth() - 1, al); } @Override public AlignmentRowsCollectionI getRows(AlignmentI al) { return new VisibleRowsCollection(0, ranges.getAbsoluteAlignmentHeight() - 1, al); } @Override protected void resetAlignmentDims() { alwidth = ranges.getVisibleAlignmentWidth(); alheight = ranges.getVisibleAlignmentHeight(); } @Override protected int getLeftXFromCentreX(int mousex, HiddenColumns hidden) { int vpx = Math.round((float) mousex * alwidth / width); return vpx - ranges.getViewportWidth() / 2; } @Override protected int getTopYFromCentreY(int mousey, HiddenSequences hidden) { int vpy = Math.round((float) mousey * alheight / sequencesHeight); return vpy - ranges.getViewportHeight() / 2; } }