*/
package jalview.viewmodel;
-import jalview.api.AlignViewportI;
import jalview.datamodel.AlignmentI;
/**
* Supplies and updates viewport properties relating to position such as: start
- * and end residues and sequences, hidden column/row adjustments, etc
+ * and end residues and sequences
*/
public class ViewportPositionProps extends ViewportProperties
{
// alignment
private AlignmentI al;
- // viewport
- private AlignViewportI av; // this is a bad dependency, viewmodel should not
- // depend on api
-
/**
* Constructor
- * @param alignment TODO
+ *
+ * @param alignment
+ * the viewport's alignment
*/
- public ViewportPositionProps(AlignmentI alignment, AlignViewportI viewport)
+ public ViewportPositionProps(AlignmentI alignment)
{
// initial values of viewport settings
this.startRes = 0;
this.startSeq = 0;
this.endSeq = alignment.getHeight() - 1;
this.al = alignment;
- this.av = viewport;
}
// ways to update values
// ways to supply positional information
/**
- * Get alignment width
+ * Get alignment width in cols, including hidden cols
*/
- public int getAlignmentWidthInCols()
+ public int getAbsoluteAlignmentWidth()
{
return al.getWidth();
}
/**
- * Get alignment height
+ * Get alignment height in rows, including hidden rows
*/
- public int getAlignmentHeightInRows()
+ public int getAbsoluteAlignmentHeight()
{
- return al.getHeight();
+ return al.getHeight() + al.getHiddenSequences().getSize();
}
+ /**
+ * Set first residue visible in the viewport
+ *
+ * @param res
+ * residue position
+ */
public void setStartRes(int res)
{
if (res > al.getWidth() - 1)
this.startRes = res;
}
+ /**
+ * Set last residue visible in the viewport
+ *
+ * @param res
+ * residue position
+ */
public void setEndRes(int res)
{
- if (res > al.getWidth())
+ if (res >= al.getWidth())
{
- res = al.getWidth();
+ res = al.getWidth() - 1;
}
else if (res < 1)
{
this.endRes = res;
}
+ /**
+ * Set the first sequence visible in the viewport
+ *
+ * @param seq
+ * sequence position
+ */
public void setStartSeq(int seq)
{
if (seq > al.getHeight() - 1)
this.startSeq = seq;
}
+ /**
+ * Set the last sequence visible in the viewport
+ *
+ * @param seq
+ * sequence position
+ */
public void setEndSeq(int seq)
{
- if (seq > al.getHeight())
+ if (seq >= al.getHeight())
{
- seq = al.getHeight();
+ seq = al.getHeight() - 1;
}
else if (seq < 1)
{
{
return endSeq;
}
-
- /**
- * Get absolute start residue of viewport
- */
- public int getAbsoluteStartRes()
- {
- int start = startRes;
-
- if (av.hasHiddenColumns())
- {
- start = av.getColumnSelection().adjustForHiddenColumns(start);
- }
- return start;
- }
-
- /**
- * Get absolute start residue of viewport
- */
- public int getAbsoluteEndRes()
- {
- int end = endRes;
-
- if (av.hasHiddenColumns())
- {
- end = av.getColumnSelection().adjustForHiddenColumns(end);
- }
- return end;
- }
-
- /**
- * Get absolute start sequence of viewport
- */
- public int getAbsoluteStartSeq()
- {
- int start = startSeq;
-
- if (av.hasHiddenRows())
- {
- start = av.getAlignment().getHiddenSequences()
- .adjustForHiddenSeqs(start);
- }
- return start;
- }
-
- /**
- * Get absolute end sequence of viewport
- */
- public int getAbsoluteEndSeq()
- {
- int end = endSeq;
-
- if (av.hasHiddenRows())
- {
- end = av.getAlignment().getHiddenSequences().adjustForHiddenSeqs(end);
- }
- return end;
- }
-
}