/**
* Create an OverviewDimensions object
*
- * @param props
+ * @param ranges
* positional properties of the viewport
* @param showAnnotationPanel
* true if the annotation panel is to be shown, false otherwise
*/
- public OverviewDimensions(ViewportPositionProps props,
+ public OverviewDimensions(ViewportRanges ranges,
boolean showAnnotationPanel)
{
// scale the initial size of overviewpanel to shape of alignment
- float initialScale = (float) props.getAbsoluteAlignmentWidth()
- / (float) props.getAbsoluteAlignmentHeight();
+ float initialScale = (float) ranges.getAbsoluteAlignmentWidth()
+ / (float) ranges.getAbsoluteAlignmentHeight();
if (!showAnnotationPanel)
{
graphHeight = 0;
}
- if (props.getAbsoluteAlignmentWidth() > props
+ if (ranges.getAbsoluteAlignmentWidth() > ranges
.getAbsoluteAlignmentHeight())
{
// wider
* hidden sequences
* @param hiddenCols
* hidden columns
- * @param props
+ * @param ranges
* viewport position properties
*/
public void updateViewportFromMouse(int mousex, int mousey,
HiddenSequences hiddenSeqs, ColumnSelection hiddenCols,
- ViewportPositionProps props)
+ ViewportRanges ranges)
{
int x = mousex;
int y = mousey;
- int alwidth = props.getAbsoluteAlignmentWidth();
- int alheight = props.getAbsoluteAlignmentHeight();
+ int alwidth = ranges.getAbsoluteAlignmentWidth();
+ int alheight = ranges.getAbsoluteAlignmentHeight();
if (x < 0)
{
int xAsRes = Math.round((float) x * alwidth / width);
// get viewport width in residues
- int vpwidth = props.getEndRes() - props.getStartRes() + 1;
+ int vpwidth = ranges.getEndRes() - ranges.getStartRes() + 1;
// get where x should be when accounting for hidden cols
// if x is in a hidden col region, shift to left - but we still need
// get viewport height in sequences
// add 1 because height includes both endSeq and startSeq
- int vpheight = props.getEndSeq() - props.getStartSeq() + 1;
+ int vpheight = ranges.getEndSeq() - ranges.getStartSeq() + 1;
// get where y should be when accounting for hidden rows
// if y is in a hidden row region, shift up - but we still need absolute
* hidden sequences
* @param hiddenCols
* hidden columns
- * @param props
+ * @param ranges
* viewport position properties
*/
public void setBoxPosition(HiddenSequences hiddenSeqs,
- ColumnSelection hiddenCols, ViewportPositionProps props)
+ ColumnSelection hiddenCols, ViewportRanges ranges)
{
- int alwidth = props.getAbsoluteAlignmentWidth();
- int alheight = props.getAbsoluteAlignmentHeight();
+ int alwidth = ranges.getAbsoluteAlignmentWidth();
+ int alheight = ranges.getAbsoluteAlignmentHeight();
// work with absolute values of startRes and endRes
- int startRes = hiddenCols.adjustForHiddenColumns(props.getStartRes());
- int endRes = hiddenCols.adjustForHiddenColumns(props.getEndRes());
+ int startRes = hiddenCols.adjustForHiddenColumns(ranges.getStartRes());
+ int endRes = hiddenCols.adjustForHiddenColumns(ranges.getEndRes());
// work with absolute values of startSeq and endSeq
- int startSeq = hiddenSeqs.adjustForHiddenSeqs(props.getStartSeq());
- int endSeq = hiddenSeqs.adjustForHiddenSeqs(props.getEndSeq());
+ int startSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.getStartSeq());
+ int endSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.getEndSeq());
// boxX, boxY is the x,y location equivalent to startRes, startSeq
boxX = Math.round((float) startRes * width / alwidth);
int alheight;
int alwidth;
- ViewportPositionProps posProps;
+ ViewportRanges vpranges;
Hashtable<SequenceI, SequenceCollectionI> hiddenRepSequences = new Hashtable<SequenceI, SequenceCollectionI>();
}
hiddenCols.revealAllHiddenColumns();
- posProps = new ViewportPositionProps(al);
- posProps.setStartRes(0);
- posProps.setEndRes(62);
- posProps.setStartSeq(0);
- posProps.setEndSeq(17);
+ vpranges = new ViewportRanges(al);
+ vpranges.setStartRes(0);
+ vpranges.setEndRes(62);
+ vpranges.setStartSeq(0);
+ vpranges.setEndSeq(17);
- viewHeight = posProps.getEndSeq() - posProps.getStartSeq() + 1;
- viewWidth = posProps.getEndRes() - posProps.getStartRes() + 1;
+ viewHeight = vpranges.getEndSeq() - vpranges.getStartSeq() + 1;
+ viewWidth = vpranges.getEndRes() - vpranges.getStartRes() + 1;
ColumnSelection hiddenCols = new ColumnSelection();
- od = new OverviewDimensions(posProps, true);
+ od = new OverviewDimensions(vpranges, true);
// Initial box sizing - default path through code
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
mouseClick(od, 0, 0);
moveViewport(0, 0);
// calculate before hidden columns so we get absolute values
- alheight = posProps.getAbsoluteAlignmentHeight();
- alwidth = posProps.getAbsoluteAlignmentWidth();
+ alheight = vpranges.getAbsoluteAlignmentHeight();
+ alwidth = vpranges.getAbsoluteAlignmentWidth();
- boxWidth = Math.round((float) (posProps.getEndRes()
- - posProps.getStartRes() + 1)
+ boxWidth = Math.round((float) (vpranges.getEndRes()
+ - vpranges.getStartRes() + 1)
* od.getWidth() / alwidth);
- boxHeight = Math.round((float) (posProps.getEndSeq()
- - posProps.getStartSeq() + 1)
+ boxHeight = Math.round((float) (vpranges.getEndSeq()
+ - vpranges.getStartSeq() + 1)
* od.getSequencesHeight() / alheight);
}
// test for alignment with width > height
SequenceI[] seqs1 = new SequenceI[] { seqa, seqb };
Alignment al1 = new Alignment(seqs1);
- ViewportPositionProps props = new ViewportPositionProps(al1);
+ ViewportRanges props = new ViewportRanges(al1);
OverviewDimensions od = new OverviewDimensions(props, true);
int scaledHeight = 267;
// test for alignment with width < height
SequenceI[] seqs2 = new SequenceI[] { seqa, seqb, seqc, seqd };
Alignment al2 = new Alignment(seqs2);
- props = new ViewportPositionProps(al2);
+ props = new ViewportRanges(al2);
od = new OverviewDimensions(props, true);
int scaledWidth = 300;
// min value
SequenceI[] seqs3 = new SequenceI[] { seqe };
Alignment al3 = new Alignment(seqs3);
- props = new ViewportPositionProps(al3);
+ props = new ViewportRanges(al3);
od = new OverviewDimensions(props, true);
assertEquals(od.getGraphHeight(), defaultGraphHeight);
SequenceI[] seqs4 = new SequenceI[] { seqa, seqb, seqc, seqd, seqa,
seqb, seqc, seqd, seqa, seqb, seqc, seqd, seqa, seqb, seqc, seqd };
Alignment al4 = new Alignment(seqs4);
- props = new ViewportPositionProps(al4);
+ props = new ViewportRanges(al4);
od = new OverviewDimensions(props, true);
assertEquals(od.getGraphHeight(), defaultGraphHeight);
assertEquals(od.getHeight(), maxSeqHeight + defaultGraphHeight);
Alignment al5 = new Alignment(seqs4);
- props = new ViewportPositionProps(al5);
+ props = new ViewportRanges(al5);
od = new OverviewDimensions(props, false);
assertEquals(od.getGraphHeight(), 0);
public void testSetBoxFromMouseClick()
{
od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
- posProps);
+ vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
public void testFromMouseWithHiddenColsAtStart()
{
od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
- posProps);
+ vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
int lastHiddenCol = 30;
hiddenCols.hideColumns(0, lastHiddenCol);
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
assertEquals(od.getBoxX(),
Math.round((float) (lastHiddenCol + 1) * od.getWidth()
/ alwidth));
public void testFromMouseWithHiddenColsInMiddle()
{
od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
- posProps);
+ vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
int lastHidden = 73;
hiddenCols.hideColumns(firstHidden, lastHidden);
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
public void testFromMouseWithHiddenColsAtEnd()
{
od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
- posProps);
+ vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
int firstHidden = 140;
int lastHidden = 164;
hiddenCols.hideColumns(firstHidden, lastHidden);
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
public void testFromMouseWithHiddenRowsAtStart()
{
od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
- posProps);
+ vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxHeight(), boxHeight);
int lastHiddenRow = 30;
hideSequences(0, lastHiddenRow);
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(),
Math.round((float) (lastHiddenRow + 1)
public void testFromMouseWithHiddenRowsInMiddle()
{
od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
- posProps);
+ vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
int lastHiddenRow = 54;
hideSequences(firstHiddenRow, lastHiddenRow);
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
public void testFromMouseWithHiddenRowsAtEnd()
{
od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
- posProps);
+ vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
int lastHidden = 524;
hideSequences(firstHidden, lastHidden);
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
assertEquals(od.getBoxX(), 0);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
*/
private void moveViewportH(int startRes)
{
- posProps.setStartRes(startRes);
- posProps.setEndRes(startRes + viewWidth - 1);
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ vpranges.setStartRes(startRes);
+ vpranges.setEndRes(startRes + viewWidth - 1);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
}
/*
*/
private void moveViewportV(int startSeq)
{
- posProps.setStartSeq(startSeq);
- posProps.setEndSeq(startSeq + viewHeight - 1);
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ vpranges.setStartSeq(startSeq);
+ vpranges.setEndSeq(startSeq + viewHeight - 1);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
}
/*
*/
private void moveViewport(int startRes, int startSeq)
{
- posProps.setStartRes(startRes);
- posProps.setEndRes(startRes + viewWidth - 1);
- posProps.setStartSeq(startSeq);
- posProps.setEndSeq(startSeq + viewHeight - 1);
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ vpranges.setStartRes(startRes);
+ vpranges.setEndRes(startRes + viewWidth - 1);
+ vpranges.setStartSeq(startSeq);
+ vpranges.setEndSeq(startSeq + viewHeight - 1);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
}
/*
private void mouseClick(OverviewDimensions od, int x, int y)
{
od.updateViewportFromMouse(x, y, al.getHiddenSequences(), hiddenCols,
- posProps);
+ vpranges);
// updates require an OverviewPanel to exist which it doesn't here
// so call setBoxPosition() as it would be called by the AlignmentPanel
// normally
- posProps.setStartRes(od.getScrollCol());
- posProps.setEndRes(od.getScrollCol() + viewWidth - 1);
- posProps.setStartSeq(od.getScrollRow());
- posProps.setEndSeq(od.getScrollRow() + viewHeight - 1);
- od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+ vpranges.setStartRes(od.getScrollCol());
+ vpranges.setEndRes(od.getScrollCol() + viewWidth - 1);
+ vpranges.setStartSeq(od.getScrollRow());
+ vpranges.setEndSeq(od.getScrollRow() + viewHeight - 1);
+ od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
}
/*