public interface AlignViewportI extends ViewStyleI
{
- ViewportRanges getRanges();
-
- int getEndRes();
-
- int getStartRes();
+ /**
+ * Get the ranges object containing details of the start and end sequences and
+ * residues
+ *
+ * @return
+ */
+ public ViewportRanges getRanges();
/**
* calculate the height for visible annotation, revalidating bounds where
* @return search results or null
*/
SearchResultsI getSearchResults();
-
- int getStartSeq();
-
- int getEndSeq();
}
import jalview.util.MappingUtils;
import jalview.util.MessageManager;
import jalview.viewmodel.AlignmentViewport;
+import jalview.viewmodel.ViewportRanges;
import java.awt.BorderLayout;
import java.awt.Canvas;
@Override
public void keyPressed(KeyEvent evt)
{
+ ViewportRanges ranges = viewport.getRanges();
+
if (viewport.cursorMode
&& ((evt.getKeyCode() >= KeyEvent.VK_0 && evt.getKeyCode() <= KeyEvent.VK_9) || (evt
.getKeyCode() >= KeyEvent.VK_NUMPAD0 && evt
new String[] { (viewport.cursorMode ? "on" : "off") }));
if (viewport.cursorMode)
{
- alignPanel.seqPanel.seqCanvas.cursorX = viewport.getStartRes();
- alignPanel.seqPanel.seqCanvas.cursorY = viewport.getStartSeq();
+ alignPanel.seqPanel.seqCanvas.cursorX = ranges.getStartRes();
+ alignPanel.seqPanel.seqCanvas.cursorY = ranges.getStartSeq();
}
break;
}
else
{
- alignPanel.setScrollValues(viewport.getStartRes(),
- 2 * viewport.getStartSeq() - viewport.getEndSeq());
+ alignPanel.setScrollValues(ranges.getStartRes(),
+ 2 * ranges.getStartSeq() - ranges.getEndSeq());
}
break;
}
else
{
- alignPanel.setScrollValues(viewport.getStartRes(),
- viewport.getEndSeq());
+ alignPanel
+ .setScrollValues(ranges.getStartRes(), ranges.getEndSeq());
}
break;
seqs, 0, viewport.getAlignment().getWidth(),
viewport.getAlignment()));
- viewport.setEndSeq(viewport.getAlignment().getHeight());
+ viewport.getRanges().setEndSeq(viewport.getAlignment().getHeight());
viewport.getAlignment().getWidth();
viewport.firePropertyChange("alignment", null, viewport.getAlignment()
.getSequences());
void trimAlignment(boolean trimLeft)
{
+ AlignmentI al = viewport.getAlignment();
+ ViewportRanges ranges = viewport.getRanges();
ColumnSelection colSel = viewport.getColumnSelection();
int column;
}
else
{
- seqs = viewport.getAlignment().getSequencesArray();
+ seqs = al.getSequencesArray();
}
TrimRegionCommand trimRegion;
if (trimLeft)
{
trimRegion = new TrimRegionCommand("Remove Left", true, seqs,
- column, viewport.getAlignment());
- viewport.setStartRes(0);
+ column, al);
+ ranges.setStartRes(0);
}
else
{
trimRegion = new TrimRegionCommand("Remove Right", false, seqs,
- column, viewport.getAlignment());
+ column, al);
}
statusBar.setText(MessageManager.formatMessage(
.toString() }));
addHistoryItem(trimRegion);
- for (SequenceGroup sg : viewport.getAlignment().getGroups())
+ for (SequenceGroup sg : al.getGroups())
{
if ((trimLeft && !sg.adjustForRemoveLeft(column))
|| (!trimLeft && !sg.adjustForRemoveRight(column)))
{
- viewport.getAlignment().deleteGroup(sg);
+ al.deleteGroup(sg);
}
}
- viewport.firePropertyChange("alignment", null, viewport
- .getAlignment().getSequences());
+ viewport.firePropertyChange("alignment", null, al.getSequences());
}
}
public void removeGappedColumnMenuItem_actionPerformed()
{
- int start = 0, end = viewport.getAlignment().getWidth() - 1;
+ AlignmentI al = viewport.getAlignment();
+ ViewportRanges ranges = viewport.getRanges();
+ int start = 0;
+ int end = ranges.getAbsoluteAlignmentWidth() - 1;
SequenceI[] seqs;
if (viewport.getSelectionGroup() != null)
// This is to maintain viewport position on first residue
// of first sequence
- SequenceI seq = viewport.getAlignment().getSequenceAt(0);
- int startRes = seq.findPosition(viewport.getStartRes());
+ SequenceI seq = al.getSequenceAt(0);
+ int startRes = seq.findPosition(ranges.getStartRes());
// ShiftList shifts;
// viewport.getAlignment().removeGaps(shifts=new ShiftList());
// edit.alColumnChanges=shifts.getInverse();
// if (viewport.hasHiddenColumns)
// viewport.getColumnSelection().compensateForEdits(shifts);
- viewport.setStartRes(seq.findIndex(startRes) - 1);
- viewport.firePropertyChange("alignment", null, viewport.getAlignment()
- .getSequences());
+ ranges.setStartRes(seq.findIndex(startRes) - 1);
+ viewport.firePropertyChange("alignment", null, al.getSequences());
}
public void removeAllGapsMenuItem_actionPerformed()
{
- int start = 0, end = viewport.getAlignment().getWidth() - 1;
+ AlignmentI al = viewport.getAlignment();
+ ViewportRanges ranges = viewport.getRanges();
+ int start = 0;
+ int end = ranges.getAbsoluteAlignmentWidth() - 1;
SequenceI[] seqs;
if (viewport.getSelectionGroup() != null)
// This is to maintain viewport position on first residue
// of first sequence
- SequenceI seq = viewport.getAlignment().getSequenceAt(0);
- int startRes = seq.findPosition(viewport.getStartRes());
+ SequenceI seq = al.getSequenceAt(0);
+ int startRes = seq.findPosition(ranges.getStartRes());
addHistoryItem(new RemoveGapsCommand("Remove Gaps", seqs, start, end,
- viewport.getAlignment()));
+ al));
- viewport.setStartRes(seq.findIndex(startRes) - 1);
+ ranges.setStartRes(seq.findIndex(startRes) - 1);
- viewport.firePropertyChange("alignment", null, viewport.getAlignment()
- .getSequences());
+ viewport.firePropertyChange("alignment", null, al.getSequences());
}
public void resetSeqLimits(int height)
{
- setEndSeq(height / getCharHeight());
+ ranges.setEndSeq(height / getCharHeight());
}
public void setCurrentTree(NJTree tree)
import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceI;
import jalview.structure.StructureSelectionManager;
+import jalview.viewmodel.ViewportRanges;
import java.awt.BorderLayout;
import java.awt.Color;
AnnotationLabels alabels;
+ ViewportRanges vpRanges;
+
// this value is set false when selection area being dragged
boolean fastPaint = true;
{
alignFrame = null;
av = null;
+ vpRanges = null;
seqPanel = null;
seqPanelHolder = null;
sequenceHolderPanel = null;
alignFrame = af;
this.av = av;
+ vpRanges = av.getRanges();
seqPanel = new SeqPanel(av, this);
idPanel = new IdPanel(av, this);
scalePanel = new ScalePanel(av, this);
@Override
public void componentResized(ComponentEvent evt)
{
- setScrollValues(av.getStartRes(), av.getStartSeq());
+ setScrollValues(vpRanges.getStartRes(), vpRanges.getStartSeq());
if (getSize().height > 0
&& annotationPanelHolder.getSize().height > 0)
{
*/
if (centre)
{
- int offset = (av.getEndRes() - av.getStartRes() + 1) / 2 - 1;
+ int offset = (vpRanges.getEndRes() - vpRanges.getStartRes() + 1) / 2 - 1;
start = Math.max(start - offset, 0);
end = Math.min(end + offset, seq.getEnd() - 1);
}
// setScrollValues(start, seqIndex);
// }
// logic copied from jalview.gui.AlignmentPanel:
- if ((startv = av.getStartRes()) >= start)
+ if ((startv = vpRanges.getStartRes()) >= start)
{
/*
* Scroll left to make start of search results visible
*/
setScrollValues(start - 1, seqIndex);
}
- else if ((endv = av.getEndRes()) <= end)
+ else if ((endv = vpRanges.getEndRes()) <= end)
{
/*
* Scroll right to make end of search results visible
*/
setScrollValues(startv + 1 + end - endv, seqIndex);
}
- else if ((starts = av.getStartSeq()) > seqIndex)
+ else if ((starts = vpRanges.getStartSeq()) > seqIndex)
{
/*
* Scroll up to make start of search results visible
*/
- setScrollValues(av.getStartRes(), seqIndex);
+ setScrollValues(vpRanges.getStartRes(), seqIndex);
}
- else if ((ends = av.getEndSeq()) <= seqIndex)
+ else if ((ends = vpRanges.getEndSeq()) <= seqIndex)
{
/*
* Scroll down to make end of search results visible
*/
- setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1);
+ setScrollValues(vpRanges.getStartRes(), starts + seqIndex - ends
+ + 1);
}
/*
* Else results are already visible - no need to scroll
{
int cwidth = seqPanel.seqCanvas
.getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
- if (res <= av.getStartRes() || res >= (av.getStartRes() + cwidth))
+ if (res <= vpRanges.getStartRes()
+ || res >= (vpRanges.getStartRes() + cwidth))
{
vscroll.setValue(res / cwidth);
- av.setStartRes(vscroll.getValue() * cwidth);
+ vpRanges.setStartRes(vscroll.getValue() * cwidth);
}
}
public void setWrapAlignment(boolean wrap)
{
- av.setStartSeq(0);
- av.setStartRes(0);
+ vpRanges.setStartSeq(0);
+ vpRanges.setStartRes(0);
scalePanelHolder.setVisible(!wrap);
hscroll.setVisible(!wrap);
x = 0;
}
- av.setStartSeq(y);
- av.setEndSeq(y + vextent);
- av.setStartRes(x);
- av.setEndRes((x + (seqPanel.seqCanvas.getSize().width / av
+ vpRanges.setStartSeq(y);
+ vpRanges.setEndSeq(y + vextent);
+ vpRanges.setStartRes(x);
+ vpRanges.setEndRes((x + (seqPanel.seqCanvas.getSize().width / av
.getCharWidth())) - 1);
hscroll.setValues(x, hextent, 0, width);
@Override
public void adjustmentValueChanged(AdjustmentEvent evt)
{
- int oldX = av.getStartRes();
- int oldY = av.getStartSeq();
+ int oldX = vpRanges.getStartRes();
+ int oldY = vpRanges.getStartSeq();
if (evt == null || evt.getSource() == apvscroll)
{
if (evt == null || evt.getSource() == hscroll)
{
int x = hscroll.getValue();
- av.setStartRes(x);
- av.setEndRes(x + seqPanel.seqCanvas.getSize().width
+ vpRanges.setStartRes(x);
+ vpRanges.setEndRes(x + seqPanel.seqCanvas.getSize().width
/ av.getCharWidth() - 1);
}
{
int rowSize = seqPanel.seqCanvas
.getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
- av.setStartRes(vscroll.getValue() * rowSize);
- av.setEndRes((vscroll.getValue() + 1) * rowSize);
+ vpRanges.setStartRes(vscroll.getValue() * rowSize);
+ vpRanges.setEndRes((vscroll.getValue() + 1) * rowSize);
}
else
{
- av.setStartSeq(offy);
- av.setEndSeq(offy + seqPanel.seqCanvas.getSize().height
+ vpRanges.setStartSeq(offy);
+ vpRanges.setEndSeq(offy + seqPanel.seqCanvas.getSize().height
/ av.getCharHeight() - 1);
}
}
overviewPanel.setBoxPosition();
}
- int scrollX = av.getStartRes() - oldX;
- int scrollY = av.getStartSeq() - oldY;
+ int scrollX = vpRanges.getStartRes() - oldX;
+ int scrollY = vpRanges.getStartSeq() - oldY;
if (av.getWrapAlignment() || !fastPaint || av.MAC)
{
{
// Make sure we're not trying to draw a panel
// larger than the visible window
- if (scrollX > av.getEndRes() - av.getStartRes())
+ if (scrollX > vpRanges.getEndRes() - vpRanges.getStartRes())
{
- scrollX = av.getEndRes() - av.getStartRes();
+ scrollX = vpRanges.getEndRes() - vpRanges.getStartRes();
}
- else if (scrollX < av.getStartRes() - av.getEndRes())
+ else if (scrollX < vpRanges.getStartRes() - vpRanges.getEndRes())
{
- scrollX = av.getStartRes() - av.getEndRes();
+ scrollX = vpRanges.getStartRes() - vpRanges.getEndRes();
}
idPanel.idCanvas.fastPaint(scrollY);
scalePanel.repaint();
if (av.isShowAnnotation())
{
- annotationPanel.fastPaint(av.getStartRes() - oldX);
+ annotationPanel.fastPaint(vpRanges.getStartRes() - oldX);
}
}
sendViewPosition();
private void sendViewPosition()
{
StructureSelectionManager.getStructureSelectionManager(av.applet)
- .sendViewPosition(this, av.getStartRes(), av.getEndRes(),
- av.getStartSeq(), av.getEndSeq());
+ .sendViewPosition(this, vpRanges.getStartRes(),
+ vpRanges.getEndRes(), vpRanges.getStartSeq(),
+ vpRanges.getEndSeq());
}
/**
}
else
{
- setScrollValues(av.getStartRes(), av.getStartSeq());
+ setScrollValues(vpRanges.getStartRes(), vpRanges.getStartSeq());
}
seqPanel.seqCanvas.repaint();
av.calcPanelHeight());
f.height += dif;
ap.seqPanelHolder.setPreferredSize(f);
- ap.setScrollValues(av.getStartRes(), av.getStartSeq());
+ ap.setScrollValues(av.getRanges().getStartRes(), av.getRanges()
+ .getStartSeq());
ap.validate();
// ap.paintAlignment(true);
ap.addNotify();
}
}
- int column = evt.getX() / av.getCharWidth() + av.getStartRes();
+ int column = evt.getX() / av.getCharWidth()
+ + av.getRanges().getStartRes();
if (av.hasHiddenColumns())
{
gg.setColor(Color.white);
gg.fillRect(0, 0, getSize().width, getSize().height);
- drawComponent(gg, av.getStartRes(), av.getEndRes() + 1);
+ drawComponent(gg, av.getRanges().getStartRes(), av.getRanges()
+ .getEndRes() + 1);
g.drawImage(image, 0, 0, this);
}
gg.copyArea(0, 0, imgWidth, getSize().height,
-horizontal * av.getCharWidth(), 0);
- int sr = av.getStartRes(), er = av.getEndRes() + 1, transX = 0;
+ int sr = av.getRanges().getStartRes(), er = av.getRanges().getEndRes() + 1, transX = 0;
if (horizontal > 0) // scrollbar pulled right, image to the left
{
package jalview.appletgui;
import jalview.datamodel.SequenceI;
+import jalview.viewmodel.ViewportRanges;
import java.awt.Color;
import java.awt.Font;
return;
}
+ ViewportRanges ranges = av.getRanges();
+
gg.copyArea(0, 0, getSize().width, imgHeight, 0,
-vertical * av.getCharHeight());
- int ss = av.getStartSeq(), es = av.getEndSeq(), transY = 0;
+ int ss = ranges.getStartSeq(), es = ranges.getEndSeq(), transY = 0;
if (vertical > 0) // scroll down
{
ss = es - vertical;
- if (ss < av.getStartSeq()) // ie scrolling too fast, more than a page at a
+ if (ss < ranges.getStartSeq()) // ie scrolling too fast, more than a page
+ // at a
// time
{
- ss = av.getStartSeq();
+ ss = ranges.getStartSeq();
}
else
{
else if (vertical < 0)
{
es = ss - vertical;
- if (es > av.getEndSeq())
+ if (es > ranges.getEndSeq())
{
- es = av.getEndSeq();
+ es = ranges.getEndSeq();
}
}
gg.setFont(italic);
gg.fillRect(0, 0, getSize().width, getSize().height);
- drawIds(av.getStartSeq(), av.getEndSeq());
+ drawIds(av.getRanges().getStartSeq(), av.getRanges().getEndSeq());
g.drawImage(image, 0, 0, this);
}
int cHeight = alheight * avcharHeight + hgap + annotationHeight;
- int rowSize = av.getEndRes() - av.getStartRes();
+ int rowSize = av.getRanges().getEndRes()
+ - av.getRanges().getStartRes();
// Draw the rest of the panels
- for (int ypos = hgap, row = av.getStartRes(); (ypos <= getSize().height)
+ for (int ypos = hgap, row = av.getRanges().getStartRes(); (ypos <= getSize().height)
&& (row < maxwidth); ypos += cHeight, row += rowSize)
{
for (int i = starty; i < alheight; i++)
return;
}
- if (mouseDragging && e.getY() < 0 && av.getStartSeq() > 0)
+ if (mouseDragging && e.getY() < 0 && av.getRanges().getStartSeq() > 0)
{
scrollThread = new ScrollThread(true);
}
if (mouseDragging && e.getY() >= getSize().height
- && av.getAlignment().getHeight() > av.getEndSeq())
+ && av.getAlignment().getHeight() > av.getRanges().getEndSeq())
{
scrollThread = new ScrollThread(false);
}
int index = av.getAlignment().findIndex(list.get(0));
// do we need to scroll the panel?
- if (av.getStartSeq() > index || av.getEndSeq() < index)
+ if (av.getRanges().getStartSeq() > index
+ || av.getRanges().getEndSeq() < index)
{
- alignPanel.setScrollValues(av.getStartRes(), index);
+ alignPanel.setScrollValues(av.getRanges().getStartRes(), index);
}
}
if (alignPanel.scrollUp(up))
{
// scroll was ok, so add new sequence to selection
- int seq = av.getStartSeq();
+ int seq = av.getRanges().getStartSeq();
if (!up)
{
- seq = av.getEndSeq();
+ seq = av.getRanges().getEndSeq();
}
if (seq < lastid)
@Override
public void mousePressed(MouseEvent evt)
{
- int x = (evt.getX() / av.getCharWidth()) + av.getStartRes();
+ int x = (evt.getX() / av.getCharWidth()) + av.getRanges().getStartRes();
final int res;
if (av.hasHiddenColumns())
{
mouseDragging = false;
- int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
+ int res = (evt.getX() / av.getCharWidth())
+ + av.getRanges().getStartRes();
if (res > av.getAlignment().getWidth())
{
mouseDragging = true;
ColumnSelection cs = av.getColumnSelection();
- int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
+ int res = (evt.getX() / av.getCharWidth())
+ + av.getRanges().getStartRes();
res = Math.max(0, res);
res = cs.adjustForHiddenColumns(res);
res = Math.min(res, av.getAlignment().getWidth() - 1);
return;
}
- int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
+ int res = (evt.getX() / av.getCharWidth())
+ + av.getRanges().getStartRes();
res = av.getColumnSelection().adjustForHiddenColumns(res);
@Override
public void paint(Graphics g)
{
- drawScale(g, av.getStartRes(), av.getEndRes(), getSize().width,
+ drawScale(g, av.getRanges().getStartRes(), av.getRanges().getEndRes(),
+ getSize().width,
getSize().height);
}
import jalview.renderer.ScaleRenderer;
import jalview.renderer.ScaleRenderer.ScaleMark;
import jalview.viewmodel.AlignmentViewport;
+import jalview.viewmodel.ViewportRanges;
import java.awt.Color;
import java.awt.FontMetrics;
return;
}
+ ViewportRanges ranges = av.getRanges();
+
updateViewport();
// Its possible on certain browsers that the call to fastpaint
// is faster than it can paint, so this check here catches
// this possibility
- if (lastsr + horizontal != av.getStartRes())
+ if (lastsr + horizontal != ranges.getStartRes())
{
- horizontal = av.getStartRes() - lastsr;
+ horizontal = ranges.getStartRes() - lastsr;
}
- lastsr = av.getStartRes();
+ lastsr = ranges.getStartRes();
fastPaint = true;
gg.copyArea(horizontal * avcharWidth, vertical * avcharHeight, imgWidth
imgHeight - vertical * avcharHeight, -horizontal * avcharWidth,
-vertical * avcharHeight);
- int sr = av.getStartRes(), er = av.getEndRes(), ss = av.getStartSeq(), es = av
+ int sr = ranges.getStartRes(), er = ranges.getEndRes(), ss = ranges
+ .getStartSeq(), es = ranges
.getEndSeq(), transX = 0, transY = 0;
if (horizontal > 0) // scrollbar pulled right, image to the left
else if (vertical > 0) // scroll down
{
ss = es - vertical;
- if (ss < av.getStartSeq()) // ie scrolling too fast, more than a page at a
+ if (ss < ranges.getStartSeq()) // ie scrolling too fast, more than a page
+ // at a
// time
{
- ss = av.getStartSeq();
+ ss = ranges.getStartSeq();
}
else
{
else if (vertical < 0)
{
es = ss - vertical;
- if (es > av.getEndSeq())
+ if (es > ranges.getEndSeq())
{
- es = av.getEndSeq();
+ es = ranges.getEndSeq();
}
}
gg.setColor(Color.white);
gg.fillRect(0, 0, imgWidth, imgHeight);
+ ViewportRanges ranges = av.getRanges();
+
if (av.getWrapAlignment())
{
- drawWrappedPanel(gg, imgWidth, imgHeight, av.getStartRes());
+ drawWrappedPanel(gg, imgWidth, imgHeight, ranges.getStartRes());
}
else
{
- drawPanel(gg, av.getStartRes(), av.getEndRes(), av.getStartSeq(),
- av.getEndSeq(), 0);
+ drawPanel(gg, ranges.getStartRes(), ranges.getEndRes(),
+ ranges.getStartSeq(), ranges.getEndSeq(), 0);
}
g.drawImage(img, 0, 0, this);
av.setWrappedWidth(cWidth);
- av.setEndRes(av.getStartRes() + cWidth);
+ av.getRanges().setEndRes(av.getRanges().getStartRes() + cWidth);
int endx;
int ypos = hgap;
import jalview.util.MappingUtils;
import jalview.util.MessageManager;
import jalview.viewmodel.AlignmentViewport;
+import jalview.viewmodel.ViewportRanges;
import java.awt.BorderLayout;
import java.awt.Font;
}
else
{
- while (seqCanvas.cursorY < av.getStartSeq())
+ ViewportRanges ranges = av.getRanges();
+ while (seqCanvas.cursorY < ranges.getStartSeq())
{
ap.scrollUp(true);
}
- while (seqCanvas.cursorY + 1 > av.getEndSeq())
+ while (seqCanvas.cursorY + 1 > ranges.getEndSeq())
{
ap.scrollUp(false);
}
while (seqCanvas.cursorX < av.getColumnSelection()
- .adjustForHiddenColumns(av.getStartRes()))
+ .adjustForHiddenColumns(ranges.getStartRes()))
{
if (!ap.scrollRight(false))
}
}
while (seqCanvas.cursorX > av.getColumnSelection()
- .adjustForHiddenColumns(av.getEndRes()))
+ .adjustForHiddenColumns(ranges.getEndRes()))
{
if (!ap.scrollRight(true))
{
}
wrappedBlock = y / cHeight;
- wrappedBlock += av.getStartRes() / cwidth;
+ wrappedBlock += av.getRanges().getStartRes() / cwidth;
res = wrappedBlock * cwidth + x / av.getCharWidth();
}
else
{
- res = (x / av.getCharWidth()) + av.getStartRes();
+ res = (x / av.getCharWidth()) + av.getRanges().getStartRes();
}
if (av.hasHiddenColumns())
}
else
{
- seq = Math.min((y / av.getCharHeight()) + av.getStartSeq(), av
+ seq = Math.min((y / av.getCharHeight())
+ + av.getRanges().getStartSeq(),
+ av
.getAlignment().getHeight() - 1);
if (seq < 0)
{
oldSeq = -1;
}
- if (res > av.getEndRes() || res < av.getStartRes()
- || y < av.getStartSeq() || y > av.getEndSeq())
+ if (res > av.getRanges().getEndRes()
+ || res < av.getRanges().getStartRes()
+ || y < av.getRanges().getStartSeq()
+ || y > av.getRanges().getEndSeq())
{
mouseExited(evt);
}
if (evt != null)
{
- if (mouseDragging && evt.getY() < 0 && av.getStartSeq() > 0)
+ if (mouseDragging && evt.getY() < 0
+ && av.getRanges().getStartSeq() > 0)
{
running = ap.scrollUp(true);
}
if (mouseDragging && evt.getY() >= getSize().height
- && av.getAlignment().getHeight() > av.getEndSeq())
+ && av.getAlignment().getHeight() > av.getRanges()
+ .getEndSeq())
{
running = ap.scrollUp(false);
}
public void scrollTo(int row, int column)
{
- row = row < 0 ? ap.av.getStartSeq() : row;
- column = column < 0 ? ap.av.getStartRes() : column;
+ row = row < 0 ? ap.av.getRanges().getStartSeq() : row;
+ column = column < 0 ? ap.av.getRanges().getStartRes() : column;
ap.scrollTo(column, column, row, true, true);
}
public void scrollToRow(int row)
{
- row = row < 0 ? ap.av.getStartSeq() : row;
- ap.scrollTo(ap.av.getStartRes(), ap.av.getStartRes(), row, true, true);
+ row = row < 0 ? ap.av.getRanges().getStartSeq() : row;
+ ap.scrollTo(ap.av.getRanges().getStartRes(), ap.av.getRanges()
+ .getStartRes(), row, true, true);
}
/**
public void scrollToColumn(int column)
{
- column = column < 0 ? ap.av.getStartRes() : column;
- ap.scrollTo(column, column, ap.av.getStartSeq(), true, true);
+ column = column < 0 ? ap.av.getRanges().getStartRes() : column;
+ ap.scrollTo(column, column, ap.av.getRanges().getStartSeq(), true, true);
}
/**
import jalview.schemes.TCoffeeColourScheme;
import jalview.util.MessageManager;
import jalview.viewmodel.AlignmentViewport;
+import jalview.viewmodel.ViewportRanges;
import jalview.ws.DBRefFetcher;
import jalview.ws.DBRefFetcher.FetchFinishedListenerI;
import jalview.ws.jws1.Discoverer;
AlignViewport viewport;
+ ViewportRanges vpRanges;
+
public AlignViewControllerI avc;
List<AlignmentPanel> alignPanels = new ArrayList<AlignmentPanel>();
progressBar = new ProgressBar(this.statusPanel, this.statusBar);
}
+ vpRanges = viewport.getRanges();
avc = new jalview.controller.AlignViewController(this, viewport,
alignPanel);
if (viewport.getAlignmentConservationAnnotation() == null)
new String[] { (viewport.cursorMode ? "on" : "off") }));
if (viewport.cursorMode)
{
- alignPanel.getSeqPanel().seqCanvas.cursorX = viewport
+ alignPanel.getSeqPanel().seqCanvas.cursorX = vpRanges
.getStartRes();
- alignPanel.getSeqPanel().seqCanvas.cursorY = viewport
+ alignPanel.getSeqPanel().seqCanvas.cursorY = vpRanges
.getStartSeq();
}
alignPanel.getSeqPanel().seqCanvas.repaint();
}
else
{
- alignPanel.setScrollValues(viewport.getStartRes(),
- 2 * viewport.getStartSeq() - viewport.getEndSeq());
+ alignPanel.setScrollValues(vpRanges.getStartRes(),
+ 2 * vpRanges.getStartSeq() - vpRanges.getEndSeq());
}
break;
case KeyEvent.VK_PAGE_DOWN:
}
else
{
- alignPanel.setScrollValues(viewport.getStartRes(),
- viewport.getEndSeq());
+ alignPanel.setScrollValues(vpRanges.getStartRes(),
+ vpRanges.getEndSeq());
}
break;
}
{
// propagate alignment changed.
- viewport.setEndSeq(alignment.getHeight());
+ vpRanges.setEndSeq(alignment.getHeight());
if (annotationAdded)
{
// Duplicate sequence annotation in all views.
{
trimRegion = new TrimRegionCommand("Remove Left", true, seqs,
column, viewport.getAlignment());
- viewport.setStartRes(0);
+ vpRanges.setStartRes(0);
}
else
{
// This is to maintain viewport position on first residue
// of first sequence
SequenceI seq = viewport.getAlignment().getSequenceAt(0);
- int startRes = seq.findPosition(viewport.getStartRes());
+ int startRes = seq.findPosition(vpRanges.getStartRes());
// ShiftList shifts;
// viewport.getAlignment().removeGaps(shifts=new ShiftList());
// edit.alColumnChanges=shifts.getInverse();
// if (viewport.hasHiddenColumns)
// viewport.getColumnSelection().compensateForEdits(shifts);
- viewport.setStartRes(seq.findIndex(startRes) - 1);
+ vpRanges.setStartRes(seq.findIndex(startRes) - 1);
viewport.firePropertyChange("alignment", null, viewport.getAlignment()
.getSequences());
// This is to maintain viewport position on first residue
// of first sequence
SequenceI seq = viewport.getAlignment().getSequenceAt(0);
- int startRes = seq.findPosition(viewport.getStartRes());
+ int startRes = seq.findPosition(vpRanges.getStartRes());
addHistoryItem(new RemoveGapsCommand("Remove Gaps", seqs, start, end,
viewport.getAlignment()));
- viewport.setStartRes(seq.findIndex(startRes) - 1);
+ vpRanges.setStartRes(seq.findIndex(startRes) - 1);
viewport.firePropertyChange("alignment", null, viewport.getAlignment()
.getSequences());
}
}
- setEndSeq(getAlignment().getHeight());
+ ranges.setEndSeq(getAlignment().getHeight());
firePropertyChange("alignment", null, getAlignment().getSequences());
}
import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
import jalview.util.Platform;
+import jalview.viewmodel.ViewportRanges;
import java.awt.BorderLayout;
import java.awt.Color;
{
public AlignViewport av;
+ ViewportRanges vpRanges;
+
OverviewPanel overviewPanel;
private SeqPanel seqPanel;
{
alignFrame = af;
this.av = av;
+ vpRanges = av.getRanges();
setSeqPanel(new SeqPanel(av, this));
setIdPanel(new IdPanel(av, this));
*/
if (centre)
{
- int offset = (av.getEndRes() - av.getStartRes() + 1) / 2 - 1;
+ int offset = (vpRanges.getEndRes() - vpRanges.getStartRes() + 1) / 2 - 1;
start = Math.max(start - offset, 0);
end = end + offset - 1;
}
// + av.getStartSeq() + ", ends=" + av.getEndSeq());
if (!av.getWrapAlignment())
{
- if ((startv = av.getStartRes()) >= start)
+ if ((startv = vpRanges.getStartRes()) >= start)
{
/*
* Scroll left to make start of search results visible
// setScrollValues(start - 1, seqIndex); // plus one residue
setScrollValues(start, seqIndex);
}
- else if ((endv = av.getEndRes()) <= end)
+ else if ((endv = vpRanges.getEndRes()) <= end)
{
/*
* Scroll right to make end of search results visible
// setScrollValues(startv + 1 + end - endv, seqIndex); // plus one
setScrollValues(startv + end - endv, seqIndex);
}
- else if ((starts = av.getStartSeq()) > seqIndex)
+ else if ((starts = vpRanges.getStartSeq()) > seqIndex)
{
/*
* Scroll up to make start of search results visible
*/
- setScrollValues(av.getStartRes(), seqIndex);
+ setScrollValues(vpRanges.getStartRes(), seqIndex);
}
- else if ((ends = av.getEndSeq()) <= seqIndex)
+ else if ((ends = vpRanges.getEndSeq()) <= seqIndex)
{
/*
* Scroll down to make end of search results visible
*/
- setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1);
+ setScrollValues(vpRanges.getStartRes(), starts + seqIndex - ends
+ + 1);
}
/*
* Else results are already visible - no need to scroll
{
int cwidth = getSeqPanel().seqCanvas
.getWrappedCanvasWidth(getSeqPanel().seqCanvas.getWidth());
- if (res < av.getStartRes() || res >= (av.getStartRes() + cwidth))
+ if (res < vpRanges.getStartRes()
+ || res >= (vpRanges.getStartRes() + cwidth))
{
vscroll.setValue((res / cwidth));
- av.setStartRes(vscroll.getValue() * cwidth);
+ vpRanges.setStartRes(vscroll.getValue() * cwidth);
}
}
fontChanged();
setAnnotationVisible(av.isShowAnnotation());
boolean wrap = av.getWrapAlignment();
- av.setStartSeq(0);
+ vpRanges.setStartSeq(0);
scalePanelHolder.setVisible(!wrap);
hscroll.setVisible(!wrap);
idwidthAdjuster.setVisible(!wrap);
}
// update endRes after x has (possibly) been adjusted
- av.setEndRes((x + (getSeqPanel().seqCanvas.getWidth() / av
+ vpRanges.setEndRes((x + (getSeqPanel().seqCanvas.getWidth() / av
.getCharWidth())) - 1);
/*
@Override
public void adjustmentValueChanged(AdjustmentEvent evt)
{
- int oldX = av.getStartRes();
- int oldY = av.getStartSeq();
+ int oldX = vpRanges.getStartRes();
+ int oldY = vpRanges.getStartSeq();
if (evt.getSource() == hscroll)
{
int x = hscroll.getValue();
- av.setStartRes(x);
- av.setEndRes((x + (getSeqPanel().seqCanvas.getWidth() / av
+ vpRanges.setStartRes(x);
+ vpRanges.setEndRes((x + (getSeqPanel().seqCanvas.getWidth() / av
.getCharWidth())) - 1);
}
{
int rowSize = getSeqPanel().seqCanvas
.getWrappedCanvasWidth(getSeqPanel().seqCanvas.getWidth());
- av.setStartRes(offy * rowSize);
- av.setEndRes((offy + 1) * rowSize);
+ vpRanges.setStartRes(offy * rowSize);
+ vpRanges.setEndRes((offy + 1) * rowSize);
}
else
{
@Override
public void run()
{
- setScrollValues(av.getStartRes(), av.getStartSeq());
+ setScrollValues(vpRanges.getStartRes(),
+ vpRanges.getStartSeq());
}
});
}
}
else
{
- av.setStartSeq(offy);
- av.setEndSeq(offy
+ vpRanges.setStartSeq(offy);
+ vpRanges.setEndSeq(offy
+ (getSeqPanel().seqCanvas.getHeight() / av.getCharHeight())
- 1);
}
overviewPanel.setBoxPosition();
}
- int scrollX = av.getStartRes() - oldX;
- int scrollY = av.getStartSeq() - oldY;
+ int scrollX = vpRanges.getStartRes() - oldX;
+ int scrollY = vpRanges.getStartSeq() - oldY;
if (av.getWrapAlignment() || !fastPaint)
{
{
// Make sure we're not trying to draw a panel
// larger than the visible window
- if (scrollX > av.getEndRes() - av.getStartRes())
+ if (scrollX > vpRanges.getEndRes() - vpRanges.getStartRes())
{
- scrollX = av.getEndRes() - av.getStartRes();
+ scrollX = vpRanges.getEndRes() - vpRanges.getStartRes();
}
- else if (scrollX < av.getStartRes() - av.getEndRes())
+ else if (scrollX < vpRanges.getStartRes() - vpRanges.getEndRes())
{
- scrollX = av.getStartRes() - av.getEndRes();
+ scrollX = vpRanges.getStartRes() - vpRanges.getEndRes();
}
if (scrollX != 0 || scrollY != 0)
}
else
{
- setScrollValues(av.getStartRes(), av.getStartSeq());
+ setScrollValues(vpRanges.getStartRes(), vpRanges.getStartSeq());
}
}
return;
}
- int column = (evt.getX() / av.getCharWidth()) + av.getStartRes();
+ int column = (evt.getX() / av.getCharWidth())
+ + av.getRanges().getStartRes();
if (av.hasHiddenColumns())
{
return;
}
}
- imgWidth = (av.getEndRes() - av.getStartRes() + 1) * av.getCharWidth();
+ imgWidth = (av.getRanges().getEndRes() - av.getRanges().getStartRes() + 1)
+ * av.getCharWidth();
if (imgWidth < 1)
{
return;
imageFresh = true;
}
- drawComponent(gg, av.getStartRes(), av.getEndRes() + 1);
+ drawComponent(gg, av.getRanges().getStartRes(), av.getRanges()
+ .getEndRes() + 1);
imageFresh = false;
g.drawImage(image, 0, 0, this);
}
gg.copyArea(0, 0, imgWidth, getHeight(),
-horizontal * av.getCharWidth(), 0);
long mtime = System.currentTimeMillis();
- int sr = av.getStartRes();
- int er = av.getEndRes() + 1;
+ int sr = av.getRanges().getStartRes();
+ int er = av.getRanges().getEndRes() + 1;
int transX = 0;
if (horizontal > 0) // scrollbar pulled right, image to the left
package jalview.gui;
import jalview.datamodel.SequenceI;
+import jalview.viewmodel.ViewportRanges;
import java.awt.BorderLayout;
import java.awt.Color;
return;
}
+ ViewportRanges ranges = av.getRanges();
+
gg.copyArea(0, 0, getWidth(), imgHeight, 0,
-vertical * av.getCharHeight());
- int ss = av.getStartSeq();
- int es = av.getEndSeq();
+ int ss = ranges.getStartSeq();
+ int es = ranges.getEndSeq();
int transY = 0;
if (vertical > 0) // scroll down
{
ss = es - vertical;
- if (ss < av.getStartSeq())
+ if (ss < ranges.getStartSeq())
{ // ie scrolling too fast, more than a page at a time
- ss = av.getStartSeq();
+ ss = ranges.getStartSeq();
}
else
{
{
es = ss - vertical;
- if (es > av.getEndSeq())
+ if (es > ranges.getEndSeq())
{
- es = av.getEndSeq();
+ es = ranges.getEndSeq();
}
}
gg.setColor(Color.white);
gg.fillRect(0, 0, getWidth(), imgHeight);
- drawIds(av.getStartSeq(), av.getEndSeq());
+ drawIds(av.getRanges().getStartSeq(), av.getRanges().getEndSeq());
g.drawImage(image, 0, 0, this);
}
int cHeight = alheight * av.getCharHeight() + hgap + annotationHeight;
- int rowSize = av.getEndRes() - av.getStartRes();
+ int rowSize = av.getRanges().getEndRes()
+ - av.getRanges().getStartRes();
// Draw the rest of the panels
- for (int ypos = hgap, row = av.getStartRes(); (ypos <= getHeight())
+ for (int ypos = hgap, row = av.getRanges().getStartRes(); (ypos <= getHeight())
&& (row < maxwidth); ypos += cHeight, row += rowSize)
{
for (int i = starty; i < alheight; i++)
return;
}
- if (mouseDragging && (e.getY() < 0) && (av.getStartSeq() > 0))
+ if (mouseDragging && (e.getY() < 0)
+ && (av.getRanges().getStartSeq() > 0))
{
scrollThread = new ScrollThread(true);
}
if (mouseDragging && (e.getY() >= getHeight())
- && (av.getAlignment().getHeight() > av.getEndSeq()))
+ && (av.getAlignment().getHeight() > av.getRanges().getEndSeq()))
{
scrollThread = new ScrollThread(false);
}
int index = av.getAlignment().findIndex(list.get(0));
// do we need to scroll the panel?
- if ((av.getStartSeq() > index) || (av.getEndSeq() < index))
+ if ((av.getRanges().getStartSeq() > index)
+ || (av.getRanges().getEndSeq() < index))
{
- alignPanel.setScrollValues(av.getStartRes(), index);
+ alignPanel.setScrollValues(av.getRanges().getStartRes(), index);
}
}
if (alignPanel.scrollUp(up))
{
// scroll was ok, so add new sequence to selection
- int seq = av.getStartSeq();
+ int seq = av.getRanges().getStartSeq();
if (!up)
{
- seq = av.getEndSeq();
+ seq = av.getRanges().getEndSeq();
}
if (seq < lastid)
import jalview.util.StringUtils;
import jalview.util.jarInputStreamProvider;
import jalview.viewmodel.AlignmentViewport;
+import jalview.viewmodel.ViewportRanges;
import jalview.viewmodel.seqfeatures.FeatureRendererSettings;
import jalview.viewmodel.seqfeatures.FeaturesDisplayed;
import jalview.ws.jws2.Jws2Discoverer;
List<UserColourScheme> userColours = new ArrayList<UserColourScheme>();
AlignViewport av = ap.av;
+ ViewportRanges vpRanges = av.getRanges();
JalviewModel object = new JalviewModel();
object.setVamsasModel(new jalview.schemabinding.version2.VamsasModel());
view.setWidth(size.width);
view.setHeight(size.height);
- view.setStartRes(av.getStartRes());
- view.setStartSeq(av.getStartSeq());
+ view.setStartRes(vpRanges.getStartRes());
+ view.setStartSeq(vpRanges.getStartSeq());
if (av.getGlobalColourScheme() instanceof jalview.schemes.UserColourScheme)
{
af.viewport.setThresholdTextColour(view.getTextColThreshold());
af.viewport.setShowUnconserved(view.hasShowUnconserved() ? view
.isShowUnconserved() : false);
- af.viewport.setStartRes(view.getStartRes());
- af.viewport.setStartSeq(view.getStartSeq());
+ af.viewport.getRanges().setStartRes(view.getStartRes());
+ af.viewport.getRanges().setStartSeq(view.getStartSeq());
af.alignPanel.updateLayout();
ColourSchemeI cs = null;
// apply colourschemes
af.setBounds(view.getXpos(), view.getYpos(), view.getWidth(),
view.getHeight());
- af.viewport.setStartRes(view.getStartRes());
- af.viewport.setStartSeq(view.getStartSeq());
+ af.viewport.getRanges().setStartRes(view.getStartRes());
+ af.viewport.getRanges().setStartSeq(view.getStartSeq());
af.viewport.setShowAnnotation(view.getShowAnnotation());
af.viewport.setAbovePIDThreshold(view.getPidSelected());
af.viewport.setColourText(view.getShowColourText());
@Override
public void mousePressed(MouseEvent evt)
{
- int x = (evt.getX() / av.getCharWidth()) + av.getStartRes();
+ int x = (evt.getX() / av.getCharWidth()) + av.getRanges().getStartRes();
final int res;
if (av.hasHiddenColumns())
{
mouseDragging = false;
- int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
+ int res = (evt.getX() / av.getCharWidth())
+ + av.getRanges().getStartRes();
if (av.hasHiddenColumns())
{
mouseDragging = true;
ColumnSelection cs = av.getColumnSelection();
- int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
+ int res = (evt.getX() / av.getCharWidth())
+ + av.getRanges().getStartRes();
res = Math.max(0, res);
res = cs.adjustForHiddenColumns(res);
res = Math.min(res, av.getAlignment().getWidth() - 1);
return;
}
- int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
+ int res = (evt.getX() / av.getCharWidth())
+ + av.getRanges().getStartRes();
res = av.getColumnSelection().adjustForHiddenColumns(res);
@Override
public void paintComponent(Graphics g)
{
- drawScale(g, av.getStartRes(), av.getEndRes(), getWidth(), getHeight());
+ drawScale(g, av.getRanges().getStartRes(), av.getRanges().getEndRes(),
+ getWidth(), getHeight());
}
// scalewidth will normally be screenwidth,
import jalview.datamodel.SequenceI;
import jalview.renderer.ScaleRenderer;
import jalview.renderer.ScaleRenderer.ScaleMark;
+import jalview.viewmodel.ViewportRanges;
import java.awt.BasicStroke;
import java.awt.BorderLayout;
gg.copyArea(horizontal * charWidth, vertical * charHeight, imgWidth,
imgHeight, -horizontal * charWidth, -vertical * charHeight);
- int sr = av.getStartRes();
- int er = av.getEndRes();
- int ss = av.getStartSeq();
- int es = av.getEndSeq();
+ ViewportRanges ranges = av.getRanges();
+ int sr = ranges.getStartRes();
+ int er = ranges.getEndRes();
+ int ss = ranges.getStartSeq();
+ int es = ranges.getEndSeq();
int transX = 0;
int transY = 0;
{
ss = es - vertical;
- if (ss < av.getStartSeq())
+ if (ss < ranges.getStartSeq())
{ // ie scrolling too fast, more than a page at a time
- ss = av.getStartSeq();
+ ss = ranges.getStartSeq();
}
else
{
{
es = ss - vertical;
- if (es > av.getEndSeq())
+ if (es > ranges.getEndSeq())
{
- es = av.getEndSeq();
+ es = ranges.getEndSeq();
}
}
gg.setColor(Color.white);
gg.fillRect(0, 0, imgWidth, imgHeight);
+ ViewportRanges ranges = av.getRanges();
if (av.getWrapAlignment())
{
- drawWrappedPanel(gg, getWidth(), getHeight(), av.getStartRes());
+ drawWrappedPanel(gg, getWidth(), getHeight(), ranges.getStartRes());
}
else
{
- drawPanel(gg, av.getStartRes(), av.getEndRes(), av.getStartSeq(),
- av.getEndSeq(), 0);
+ drawPanel(gg, ranges.getStartRes(), ranges.getEndRes(),
+ ranges.getStartSeq(), ranges.getEndSeq(), 0);
}
g.drawImage(lcimg, 0, 0, this);
av.setWrappedWidth(cWidth);
- av.setEndRes(av.getStartRes() + cWidth);
+ av.getRanges().setEndRes(av.getRanges().getStartRes() + cWidth);
int endx;
int ypos = hgap;
}
wrappedBlock = y / cHeight;
- wrappedBlock += av.getStartRes() / cwidth;
+ wrappedBlock += av.getRanges().getStartRes() / cwidth;
res = wrappedBlock * cwidth + x / av.getCharWidth();
// right-hand gutter
x = seqCanvas.getX() + seqCanvas.getWidth();
}
- res = (x / av.getCharWidth()) + av.getStartRes();
- if (res > av.getEndRes())
+ res = (x / av.getCharWidth()) + av.getRanges().getStartRes();
+ if (res > av.getRanges().getEndRes())
{
// moused off right
- res = av.getEndRes();
+ res = av.getRanges().getEndRes();
}
}
}
else
{
- seq = Math.min((y / av.getCharHeight()) + av.getStartSeq(), av
+ seq = Math.min((y / av.getCharHeight())
+ + av.getRanges().getStartSeq(),
+ av
.getAlignment().getHeight() - 1);
}
}
else
{
- while (seqCanvas.cursorY < av.getStartSeq())
+ while (seqCanvas.cursorY < av.getRanges().getStartSeq())
{
ap.scrollUp(true);
}
- while (seqCanvas.cursorY + 1 > av.getEndSeq())
+ while (seqCanvas.cursorY + 1 > av.getRanges().getEndSeq())
{
ap.scrollUp(false);
}
if (!av.getWrapAlignment())
{
while (seqCanvas.cursorX < av.getColumnSelection()
- .adjustForHiddenColumns(av.getStartRes()))
+ .adjustForHiddenColumns(av.getRanges().getStartRes()))
{
if (!ap.scrollRight(false))
{
}
}
while (seqCanvas.cursorX > av.getColumnSelection()
- .adjustForHiddenColumns(av.getEndRes()))
+ .adjustForHiddenColumns(av.getRanges().getEndRes()))
{
if (!ap.scrollRight(true))
{
changeStartRes = true;
}
- if (res < av.getStartRes())
+ if (res < av.getRanges().getStartRes())
{
- res = av.getStartRes();
+ res = av.getRanges().getStartRes();
}
if (changeEndRes)
{
if (evt != null)
{
- if (mouseDragging && (evt.getY() < 0) && (av.getStartSeq() > 0))
+ if (mouseDragging && (evt.getY() < 0)
+ && (av.getRanges().getStartSeq() > 0))
{
running = ap.scrollUp(true);
}
if (mouseDragging && (evt.getY() >= getHeight())
- && (av.getAlignment().getHeight() > av.getEndSeq()))
+ && (av.getAlignment().getHeight() > av.getRanges()
+ .getEndSeq()))
{
running = ap.scrollUp(false);
}
public void updateFromAlignViewport(AlignViewportI av)
{
charWidth = av.getCharWidth();
- endRes = av.getEndRes();
+ endRes = av.getRanges().getEndRes();
charHeight = av.getCharHeight();
hasHiddenColumns = av.hasHiddenColumns();
validCharWidth = av.isValidCharWidth();
*/
private boolean followHighlight = true;
- /*private int startRes;
-
- private int endRes;
-
- private int startSeq;
-
- private int endSeq;*/
-
/**
* Property change listener for changes in alignment
*
return ranges;
}
- @Override
- public int getStartRes()
- {
- return ranges.getStartRes();
- }
-
- @Override
- public int getEndRes()
- {
- return ranges.getEndRes();
- }
-
- @Override
- public int getStartSeq()
- {
- return ranges.getStartSeq();
- }
-
- public void setStartRes(int res)
- {
- ranges.setStartRes(res);
- }
-
- public void setStartSeq(int seq)
- {
- ranges.setStartSeq(seq);
- }
-
- public void setEndRes(int res)
- {
- ranges.setEndRes(res);
- }
-
- public void setEndSeq(int seq)
- {
- ranges.setEndSeq(seq);
- }
-
- @Override
- public int getEndSeq()
- {
- return ranges.getEndSeq();
- }
-
/**
* Helper method to populate the SearchResults with the location in the
* complementary alignment to scroll to, in order to match this one.
* locate 'middle' column (true middle if an odd number visible, left of
* middle if an even number visible)
*/
- int middleColumn = getStartRes() + (getEndRes() - getStartRes()) / 2;
+ int middleColumn = ranges.getStartRes()
+ + (ranges.getEndRes() - ranges.getStartRes()) / 2;
final HiddenSequences hiddenSequences = getAlignment()
.getHiddenSequences();
*/
int lastSeq = alignment.getHeight() - 1;
List<AlignedCodonFrame> seqMappings = null;
- for (int seqNo = getStartSeq(); seqNo < lastSeq; seqNo++, seqOffset++)
+ for (int seqNo = ranges.getStartSeq(); seqNo < lastSeq; seqNo++, seqOffset++)
{
sequence = getAlignment().getSequenceAt(seqNo);
if (hiddenSequences != null && hiddenSequences.isHidden(sequence))
/**
* Embryonic class which: Supplies and updates viewport properties relating to
* position such as: start and end residues and sequences; ideally will serve
- * hidden columns/rows too
+ * hidden columns/rows too. Intention also to support calculations for
+ * positioning, scrolling etc. such as finding the middle of the viewport,
+ * checking for scrolls off screen
*/
public class ViewportRanges extends ViewportProperties
{
}
af.getFeatureRenderer().featuresAdded();
- int start = af.getViewport().getStartSeq();
- int end = af.getViewport().getEndSeq();
+ int start = af.getViewport().getRanges().getStartSeq();
+ int end = af.getViewport().getRanges().getEndSeq();
int index;
for (index = start; index < end; index++)
{
import jalview.datamodel.SequenceI;
import jalview.io.DataSourceType;
import jalview.io.FileLoader;
+import jalview.viewmodel.ViewportRanges;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@Test(groups = "Functional")
public void TestSetScrollValues()
{
- int oldres = af.getViewport().getEndRes();
+ ViewportRanges ranges = af.getViewport().getRanges();
+
+ int oldres = ranges.getEndRes();
af.alignPanel.setScrollValues(-1, 5);
// setting -ve x value does not change residue
- assertEquals(af.getViewport().getEndRes(), oldres);
+ assertEquals(ranges.getEndRes(), oldres);
af.alignPanel.setScrollValues(0, 5);
// setting 0 as x value does not change residue
- assertEquals(af.getViewport().getEndRes(), oldres);
+ assertEquals(ranges.getEndRes(), oldres);
af.alignPanel.setScrollValues(5, 5);
// setting x value to 5 extends endRes by 5 residues
- assertEquals(af.getViewport().getEndRes(), oldres + 5);
+ assertEquals(ranges.getEndRes(), oldres + 5);
// scroll to position after hidden columns sets endres to oldres (width) +
// position
int scrollpos = 60;
af.getViewport().hideColumns(30, 50);
af.alignPanel.setScrollValues(scrollpos, 5);
- assertEquals(af.getViewport().getEndRes(), oldres + scrollpos);
+ assertEquals(ranges.getEndRes(), oldres + scrollpos);
// scroll to position within hidden columns, still sets endres to oldres +
// position
af.getViewport().showAllHiddenColumns();
af.getViewport().hideColumns(30, 50);
af.alignPanel.setScrollValues(scrollpos, 5);
- assertEquals(af.getViewport().getEndRes(), oldres + scrollpos);
+ assertEquals(ranges.getEndRes(), oldres + scrollpos);
// scroll to position within <width> distance of the end of the alignment
// endRes should be set to width of alignment - 1
scrollpos = 130;
af.getViewport().showAllHiddenColumns();
af.alignPanel.setScrollValues(scrollpos, 5);
- assertEquals(af.getViewport().getEndRes(), af.getViewport()
+ assertEquals(ranges.getEndRes(), af.getViewport()
.getAlignment().getWidth() - 1);
// now hide some columns, and scroll to position within <width>
// columns
af.getViewport().hideColumns(30, 50);
af.alignPanel.setScrollValues(scrollpos, 5);
- assertEquals(af.getViewport().getEndRes(), af.getViewport()
+ assertEquals(ranges.getEndRes(), af.getViewport()
.getAlignment().getWidth() - 1 - 21); // 21 is the number of hidden
// columns
}