int seqOffset = findComplementScrollTarget(sr);
if (!sr.isEmpty())
{
- complementPanel.setFollowingComplementScroll(true);
+ complementPanel.setFollowingComplementScroll(false);
complementPanel.scrollToCentre(sr, seqOffset);
+ complementPanel.setFollowingComplementScroll(true);
}
}
import jalview.util.Comparison;
import jalview.util.MessageManager;
import jalview.util.Platform;
+import jalview.viewmodel.ViewportListenerI;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
+import java.beans.PropertyChangeEvent;
public class AnnotationPanel extends Panel implements AwtRenderPanelI,
AdjustmentListener, ActionListener, MouseListener,
- MouseMotionListener
+ MouseMotionListener, ViewportListenerI
{
AlignViewport av;
{
this.av = av;
renderer = new AnnotationRenderer();
+ av.getRanges().addPropertyChangeListener(this);
}
@Override
return null;
}
}
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ // Respond to viewport range changes (e.g. alignment panel was scrolled)
+ if (evt.getPropertyName().equals("startres")
+ || evt.getPropertyName().equals("endres"))
+ {
+ fastPaint((int) evt.getNewValue() - (int) evt.getOldValue());
+ }
+ }
}
package jalview.appletgui;
import jalview.datamodel.SequenceI;
+import jalview.viewmodel.ViewportListenerI;
import jalview.viewmodel.ViewportRanges;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Panel;
+import java.beans.PropertyChangeEvent;
import java.util.List;
-public class IdCanvas extends Panel
+public class IdCanvas extends Panel implements ViewportListenerI
{
protected AlignViewport av;
setLayout(null);
this.av = av;
PaintRefresher.Register(this, av.getSequenceSetId());
+ av.getRanges().addPropertyChangeListener(this);
}
public void drawIdString(Graphics gg, boolean hiddenRows, SequenceI s,
}
return false;
}
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ // Respond to viewport range changes (e.g. alignment panel was scrolled)
+ if (evt.getPropertyName().equals("startseq")
+ || evt.getPropertyName().equals("endseq"))
+ {
+ fastPaint((int) evt.getNewValue() - (int) evt.getOldValue());
+ }
+ }
}
if (av.getRanges().getStartSeq() > index
|| av.getRanges().getEndSeq() < index)
{
- alignPanel.setScrollValues(av.getRanges().getStartRes(), index);
+ av.getRanges().setStartSeq(index);
}
}
running = true;
while (running)
{
- if (alignPanel.scrollUp(up))
+ if (av.getRanges().scrollUp(up))
{
// scroll was ok, so add new sequence to selection
int seq = av.getRanges().getStartSeq();
import jalview.datamodel.SequenceI;
import jalview.renderer.seqfeatures.FeatureColourFinder;
import jalview.viewmodel.OverviewDimensions;
+import jalview.viewmodel.ViewportListenerI;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
+import java.beans.PropertyChangeEvent;
public class OverviewPanel extends Panel implements Runnable,
- MouseMotionListener, MouseListener
+ MouseMotionListener, MouseListener, ViewportListenerI
{
private OverviewDimensions od;
(av.isShowAnnotation() && av.getSequenceConsensusHash() != null));
setSize(new Dimension(od.getWidth(), od.getHeight()));
+
+ av.getRanges().addPropertyChangeListener(this);
+
addComponentListener(new ComponentAdapter()
{
* changed
*
*/
- public void setBoxPosition()
+ private void setBoxPosition()
{
od.setBoxPosition(av.getAlignment()
.getHiddenSequences(), av.getColumnSelection(), av.getRanges());
}
}
+ @Override
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ setBoxPosition();
+ }
+
}
import jalview.renderer.ScaleRenderer;
import jalview.renderer.ScaleRenderer.ScaleMark;
import jalview.util.MessageManager;
+import jalview.viewmodel.ViewportListenerI;
import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
+import java.beans.PropertyChangeEvent;
import java.util.List;
public class ScalePanel extends Panel implements MouseMotionListener,
- MouseListener
+ MouseListener, ViewportListenerI
{
protected int offy = 4;
addMouseListener(this);
addMouseMotionListener(this);
+ av.getRanges().addPropertyChangeListener(this);
}
@Override
}
}
+ @Override
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ // Respond to viewport change events (e.g. alignment panel was scrolled)
+ repaint();
+ }
+
}
import jalview.renderer.ScaleRenderer;
import jalview.renderer.ScaleRenderer.ScaleMark;
import jalview.viewmodel.AlignmentViewport;
+import jalview.viewmodel.ViewportListenerI;
import jalview.viewmodel.ViewportRanges;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Panel;
+import java.beans.PropertyChangeEvent;
-public class SeqCanvas extends Panel
+public class SeqCanvas extends Panel implements ViewportListenerI
{
FeatureRenderer fr;
sr = new SequenceRenderer(av);
PaintRefresher.Register(this, av.getSequenceSetId());
updateViewport();
+
+ av.getRanges().addPropertyChangeListener(this);
}
int avcharHeight = 0, avcharWidth = 0;
av.setWrappedWidth(cWidth);
- av.getRanges().setEndRes(av.getRanges().getStartRes() + cWidth);
+ av.getRanges().setEndRes(av.getRanges().getStartRes() + cWidth - 1);
int endx;
int ypos = hgap;
repaint();
}
+ @Override
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ if (!av.getWrapAlignment())
+ {
+ if (evt.getPropertyName().equals("startres")
+ || evt.getPropertyName().equals("endres"))
+ {
+ // Make sure we're not trying to draw a panel
+ // larger than the visible window
+ ViewportRanges vpRanges = av.getRanges();
+ int scrollX = (int) evt.getNewValue() - (int) evt.getOldValue();
+ if (scrollX > vpRanges.getEndRes() - vpRanges.getStartRes())
+ {
+ scrollX = vpRanges.getEndRes() - vpRanges.getStartRes();
+ }
+ else if (scrollX < vpRanges.getStartRes() - vpRanges.getEndRes())
+ {
+ scrollX = vpRanges.getStartRes() - vpRanges.getEndRes();
+ }
+ fastPaint(scrollX, 0);
+ }
+ else if (evt.getPropertyName() == "startseq"
+ || evt.getPropertyName() == "endseq")
+ {
+ fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue());
+ }
+ }
+
+ }
+
}
endEditing();
if (av.getWrapAlignment())
{
- ap.scrollToWrappedVisible(seqCanvas.cursorX);
+ av.getRanges().scrollToWrappedVisible(seqCanvas.cursorX);
}
else
{
ViewportRanges ranges = av.getRanges();
while (seqCanvas.cursorY < ranges.getStartSeq())
{
- ap.scrollUp(true);
+ ranges.scrollUp(true);
}
while (seqCanvas.cursorY + 1 > ranges.getEndSeq())
{
- ap.scrollUp(false);
+ ranges.scrollUp(false);
}
while (seqCanvas.cursorX < av.getColumnSelection()
.adjustForHiddenColumns(ranges.getStartRes()))
{
- if (!ap.scrollRight(false))
+ if (!ranges.scrollRight(false))
{
break;
}
while (seqCanvas.cursorX > av.getColumnSelection()
.adjustForHiddenColumns(ranges.getEndRes()))
{
- if (!ap.scrollRight(true))
+ if (!ranges.scrollRight(true))
{
break;
}
{
if (av.isFollowHighlight())
{
+ // don't allow highlight of protein/cDNA to also scroll a complementary
+ // panel,as this sets up a feedback loop (scrolling panel 1 causes moused
+ // over residue to change abruptly, causing highlighted residue in panel 2
+ // to change, causing a scroll in panel 1 etc)
+ ap.setFollowingComplementScroll(false);
if (ap.scrollToPosition(results, true))
{
ap.alignFrame.repaint();
}
+ ap.setFollowingComplementScroll(true);
}
setStatusMessage(results);
seqCanvas.highlightSearchResults(results);
if (mouseDragging && evt.getY() < 0
&& av.getRanges().getStartSeq() > 0)
{
- running = ap.scrollUp(true);
+ running = av.getRanges().scrollUp(true);
}
if (mouseDragging && evt.getY() >= getSize().height
&& av.getAlignment().getHeight() > av.getRanges()
.getEndSeq())
{
- running = ap.scrollUp(false);
+ running = av.getRanges().scrollUp(false);
}
if (mouseDragging && evt.getX() < 0)
{
- running = ap.scrollRight(false);
+ running = av.getRanges().scrollRight(false);
}
else if (mouseDragging && evt.getX() >= getSize().width)
{
- running = ap.scrollRight(true);
+ running = av.getRanges().scrollRight(true);
}
}
{
if (av.getWrapAlignment())
{
-
- }
- else
- {
if (evt.getPropertyName().equals("startres")
|| evt.getPropertyName().equals("endres"))
{