2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.viewmodel;
23 import jalview.api.AlignViewportI;
24 import jalview.datamodel.AlignmentI;
27 * Supplies and updates viewport properties relating to position such as: start
28 * and end residues and sequences, hidden column/row adjustments, ratio of
29 * viewport to alignment etc
31 public class ViewportPositionProps extends ViewportProperties
33 // start residue of viewport
36 // end residue of viewport
39 // start sequence of viewport
42 // end sequence of viewport
46 private AlignmentI al;
49 private AlignViewportI av; // this is a bad dependency, viewmodel should not
54 * @param alignment TODO
56 public ViewportPositionProps(AlignmentI alignment, AlignViewportI viewport)
58 // initial values of viewport settings
60 this.endRes = alignment.getWidth() - 1;
62 this.endSeq = alignment.getHeight() - 1;
67 // ways to update values
69 // ways to notify of changes
71 // ways to supply positional information
76 public int getAlignmentWidthInCols()
82 * Get alignment height
84 public int getAlignmentHeightInRows()
86 return al.getHeight();
89 public void setStartRes(int res)
91 if (res > al.getWidth() - 1)
93 res = al.getWidth() - 1;
102 public void setEndRes(int res)
104 if (res > al.getWidth())
115 public void setStartSeq(int seq)
117 if (seq > al.getHeight() - 1)
119 seq = al.getHeight() - 1;
128 public void setEndSeq(int seq)
130 if (seq > al.getHeight())
132 seq = al.getHeight();
142 * Get start residue of viewport
144 public int getStartRes()
150 * Get end residue of viewport
152 public int getEndRes()
158 * Get start sequence of viewport
160 public int getStartSeq()
166 * Get end sequence of viewport
168 public int getEndSeq()
174 * Get absolute start residue of viewport
176 public int getAbsoluteStartRes()
178 int start = startRes;
180 if (av.hasHiddenColumns())
182 start = av.getColumnSelection().adjustForHiddenColumns(start);
188 * Get absolute start residue of viewport
190 public int getAbsoluteEndRes()
194 if (av.hasHiddenColumns())
196 end = av.getColumnSelection().adjustForHiddenColumns(end);
202 * Get absolute start sequence of viewport
204 public int getAbsoluteStartSeq()
206 int start = startSeq;
208 if (av.hasHiddenRows())
210 start = av.getAlignment().getHiddenSequences()
211 .adjustForHiddenSeqs(start);
217 * Get absolute end sequence of viewport
219 public int getAbsoluteEndSeq()
223 if (av.hasHiddenRows())
225 end = av.getAlignment().getHiddenSequences().adjustForHiddenSeqs(end);