JAL-2388 Dependency tidy
[jalview.git] / src / jalview / viewmodel / ViewportPositionProps.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
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.
11  *  
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.
16  * 
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.
20  */
21 package jalview.viewmodel;
22
23 import jalview.datamodel.AlignmentI;
24
25 /**
26  * Supplies and updates viewport properties relating to position such as: start
27  * and end residues and sequences, hidden column/row adjustments, etc
28  */
29 public class ViewportPositionProps extends ViewportProperties
30 {
31   // start residue of viewport
32   private int startRes;
33
34   // end residue of viewport
35   private int endRes;
36
37   // start sequence of viewport
38   private int startSeq;
39
40   // end sequence of viewport
41   private int endSeq;
42
43   // alignment
44   private AlignmentI al;
45
46   /**
47    * Constructor
48    * @param alignment TODO
49    */
50   public ViewportPositionProps(AlignmentI alignment)
51   {
52     // initial values of viewport settings
53     this.startRes = 0;
54     this.endRes = alignment.getWidth() - 1;
55     this.startSeq = 0;
56     this.endSeq = alignment.getHeight() - 1;
57     this.al = alignment;
58   }
59
60   // ways to update values
61
62   // ways to notify of changes
63
64   // ways to supply positional information
65
66   /**
67    * Get alignment width in cols, including hidden cols
68    */
69   public int getAbsoluteAlignmentWidth()
70   {
71     return al.getWidth();
72   }
73
74   /**
75    * Get alignment height in rows, including hidden rows
76    */
77   public int getAbsoluteAlignmentHeight()
78   {
79     return al.getHeight() + al.getHiddenSequences().getSize();
80   }
81
82   public void setStartRes(int res)
83   {
84     if (res > al.getWidth() - 1)
85     {
86       res = al.getWidth() - 1;
87     }
88     else if (res < 0)
89     {
90       res = 0;
91     }
92     this.startRes = res;
93   }
94
95   public void setEndRes(int res)
96   {
97     if (res > al.getWidth())
98     {
99       res = al.getWidth();
100     }
101     else if (res < 1)
102     {
103       res = 1;
104     }
105     this.endRes = res;
106   }
107
108   public void setStartSeq(int seq)
109   {
110     if (seq > al.getHeight() - 1)
111     {
112       seq = al.getHeight() - 1;
113     }
114     else if (seq < 0)
115     {
116       seq = 0;
117     }
118     this.startSeq = seq;
119   }
120
121   public void setEndSeq(int seq)
122   {
123     if (seq > al.getHeight())
124     {
125       seq = al.getHeight();
126     }
127     else if (seq < 1)
128     {
129       seq = 1;
130     }
131     this.endSeq = seq;
132   }
133
134   /**
135    * Get start residue of viewport
136    */
137   public int getStartRes()
138   {
139     return startRes;
140   }
141
142   /**
143    * Get end residue of viewport
144    */
145   public int getEndRes()
146   {
147     return endRes;
148   }
149
150   /**
151    * Get start sequence of viewport
152    */
153   public int getStartSeq()
154   {
155     return startSeq;
156   }
157
158   /**
159    * Get end sequence of viewport
160    */
161   public int getEndSeq()
162   {
163     return endSeq;
164   }
165 }