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, etc
30 public class ViewportPositionProps extends ViewportProperties
32 // start residue of viewport
35 // end residue of viewport
38 // start sequence of viewport
41 // end sequence of viewport
45 private AlignmentI al;
48 private AlignViewportI av; // this is a bad dependency, viewmodel should not
53 * @param alignment TODO
55 public ViewportPositionProps(AlignmentI alignment, AlignViewportI viewport)
57 // initial values of viewport settings
59 this.endRes = alignment.getWidth() - 1;
61 this.endSeq = alignment.getHeight() - 1;
66 // ways to update values
68 // ways to notify of changes
70 // ways to supply positional information
75 public int getAlignmentWidthInCols()
81 * Get alignment height
83 public int getAlignmentHeightInRows()
85 return al.getHeight();
88 public void setStartRes(int res)
90 if (res > al.getWidth() - 1)
92 res = al.getWidth() - 1;
101 public void setEndRes(int res)
103 if (res > al.getWidth())
114 public void setStartSeq(int seq)
116 if (seq > al.getHeight() - 1)
118 seq = al.getHeight() - 1;
127 public void setEndSeq(int seq)
129 if (seq > al.getHeight())
131 seq = al.getHeight();
141 * Get start residue of viewport
143 public int getStartRes()
149 * Get end residue of viewport
151 public int getEndRes()
157 * Get start sequence of viewport
159 public int getStartSeq()
165 * Get end sequence of viewport
167 public int getEndSeq()
173 * Get absolute start residue of viewport
175 public int getAbsoluteStartRes()
177 int start = startRes;
179 if (av.hasHiddenColumns())
181 start = av.getColumnSelection().adjustForHiddenColumns(start);
187 * Get absolute start residue of viewport
189 public int getAbsoluteEndRes()
193 if (av.hasHiddenColumns())
195 end = av.getColumnSelection().adjustForHiddenColumns(end);
201 * Get absolute start sequence of viewport
203 public int getAbsoluteStartSeq()
205 int start = startSeq;
207 if (av.hasHiddenRows())
209 start = av.getAlignment().getHiddenSequences()
210 .adjustForHiddenSeqs(start);
216 * Get absolute end sequence of viewport
218 public int getAbsoluteEndSeq()
222 if (av.hasHiddenRows())
224 end = av.getAlignment().getHiddenSequences().adjustForHiddenSeqs(end);