import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
import jalview.util.Platform;
+import jalview.viewmodel.ViewportListenerI;
import jalview.viewmodel.ViewportRanges;
import java.awt.BorderLayout;
* @version $Revision: 1.161 $
*/
public class AlignmentPanel extends GAlignmentPanel implements
- AdjustmentListener, Printable, AlignmentViewPanel
+ AdjustmentListener, Printable, AlignmentViewPanel,
+ ViewportListenerI
{
public AlignViewport av;
}
};
av.addPropertyChangeListener(propertyChangeListener);
+
+ av.getRanges().addPropertyChangeListener(this);
fontChanged();
adjustAnnotationHeight();
updateLayout();
|| res >= (vpRanges.getStartRes() + cwidth))
{
vscroll.setValue((res / cwidth));
- vpRanges.setStartRes(vscroll.getValue() * cwidth);
+ // vpRanges.setStartRes(vscroll.getValue() * cwidth);
}
}
* 'do not scroll complement' flag; ensure it is the same for both
* operations
*/
- boolean flag = isDontScrollComplement();
+ // boolean flag = isDontScrollComplement();
hscroll.setValues(x, hextent, 0, width);
- setDontScrollComplement(flag);
+ // setDontScrollComplement(flag);
vscroll.setValues(y, vextent, 0, height);
}
if (evt.getSource() == hscroll)
{
int x = hscroll.getValue();
- vpRanges.setStartRes(x);
- vpRanges.setEndRes((x + (getSeqPanel().seqCanvas.getWidth() / av
+ if (x == oldX)
+ {
+ return;
+ }
+ // vpRanges.setStartRes(x);
+ // vpRanges.setEndRes((x + (getSeqPanel().seqCanvas.getWidth() / av
+ // .getCharWidth())) - 1);
+ vpRanges.setStartEndRes(
+ x,
+ (x + (getSeqPanel().seqCanvas.getWidth() / av
.getCharWidth())) - 1);
}
if (av.getWrapAlignment())
{
+ if (offy == oldX)
+ {
+ return;
+ }
if (offy > -1)
{
int rowSize = getSeqPanel().seqCanvas
.getWrappedCanvasWidth(getSeqPanel().seqCanvas.getWidth());
- vpRanges.setStartRes(offy * rowSize);
- vpRanges.setEndRes((offy + 1) * rowSize);
+ vpRanges.setStartEndRes(offy * rowSize, (offy + 1) * rowSize);
+ // vpRanges.setStartRes(offy * rowSize);
+ // vpRanges.setEndRes((offy + 1) * rowSize);
+
}
else
{
}
else
{
- vpRanges.setStartSeq(offy);
- vpRanges.setEndSeq(offy
- + (getSeqPanel().seqCanvas.getHeight() / av.getCharHeight())
- - 1);
+ if (offy == oldY)
+ {
+ return;
+ }
+ // vpRanges.setStartSeq(offy);
+ // vpRanges.setEndSeq(offy
+ // + (getSeqPanel().seqCanvas.getHeight() / av.getCharHeight())
+ // - 1);
+ vpRanges.setStartEndSeq(
+ offy,
+ offy
+ + (getSeqPanel().seqCanvas.getHeight() / av
+ .getCharHeight()) - 1);
}
}
- if (overviewPanel != null)
+ /*if (overviewPanel != null)
{
overviewPanel.setBoxPosition();
- }
+ }*/
- int scrollX = vpRanges.getStartRes() - oldX;
- int scrollY = vpRanges.getStartSeq() - oldY;
+ // int scrollX = vpRanges.getStartRes() - oldX;
+ // int scrollY = vpRanges.getStartSeq() - oldY;
if (av.getWrapAlignment() || !fastPaint)
{
repaint();
}
- else
- {
- // Make sure we're not trying to draw a panel
- // larger than the visible window
- if (scrollX > vpRanges.getEndRes() - vpRanges.getStartRes())
- {
- scrollX = vpRanges.getEndRes() - vpRanges.getStartRes();
- }
- else if (scrollX < vpRanges.getStartRes() - vpRanges.getEndRes())
- {
- scrollX = vpRanges.getStartRes() - vpRanges.getEndRes();
- }
-
- if (scrollX != 0 || scrollY != 0)
- {
- getIdPanel().getIdCanvas().fastPaint(scrollY);
- getSeqPanel().seqCanvas.fastPaint(scrollX, scrollY);
- getScalePanel().repaint();
-
- if (av.isShowAnnotation() && scrollX != 0)
- {
- getAnnotationPanel().fastPaint(scrollX);
- }
- }
- }
- /*
- * If there is one, scroll the (Protein/cDNA) complementary alignment to
- * match, unless we are ourselves doing that.
- */
- if (isDontScrollComplement())
- {
- setDontScrollComplement(false);
- }
- else
- {
- av.scrollComplementaryAlignment();
- }
+ /* else
+ {
+ // Make sure we're not trying to draw a panel
+ // larger than the visible window
+ if (scrollX > vpRanges.getEndRes() - vpRanges.getStartRes())
+ {
+ scrollX = vpRanges.getEndRes() - vpRanges.getStartRes();
+ }
+ else if (scrollX < vpRanges.getStartRes() - vpRanges.getEndRes())
+ {
+ scrollX = vpRanges.getStartRes() - vpRanges.getEndRes();
+ }
+
+ if (scrollX != 0 || scrollY != 0)
+ {
+ getIdPanel().getIdCanvas().fastPaint(scrollY);
+ getSeqPanel().seqCanvas.fastPaint(scrollX, scrollY);
+ getScalePanel().repaint();
+
+ if (av.isShowAnnotation() && scrollX != 0)
+ {
+ getAnnotationPanel().fastPaint(scrollX);
+ }
+ }
+ }
+ /*
+ * If there is one, scroll the (Protein/cDNA) complementary alignment to
+ * match, unless we are ourselves doing that.
+ */
+ /* if (isDontScrollComplement())
+ {
+ setDontScrollComplement(false);
+ }
+ else
+ {
+ av.scrollComplementaryAlignment();
+ }*/
}
/**
repaint();
}
}
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ int x = vpRanges.getStartRes();
+ int y = vpRanges.getStartSeq();
+ setScrollValues(x, y);
+
+ }
}
import jalview.schemes.ResidueProperties;
import jalview.util.Comparison;
import jalview.util.MessageManager;
+import jalview.viewmodel.ViewportListenerI;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.image.BufferedImage;
+import java.beans.PropertyChangeEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
*/
public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
MouseListener, MouseWheelListener, MouseMotionListener,
- ActionListener, AdjustmentListener, Scrollable
+ ActionListener, AdjustmentListener, Scrollable, ViewportListenerI
{
String HELIX = MessageManager.getString("label.helix");
// and then set our own listener to consume all mousewheel events
ap.annotationScroller.addMouseWheelListener(this);
renderer = new AnnotationRenderer();
+
+ av.getRanges().addPropertyChangeListener(this);
}
public AnnotationPanel(AlignViewport av)
renderer.dispose();
}
}
+
+ @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.gui;
import jalview.datamodel.SequenceI;
+import jalview.viewmodel.ViewportListenerI;
import jalview.viewmodel.ViewportRanges;
import java.awt.BorderLayout;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
+import java.beans.PropertyChangeEvent;
import java.util.List;
import javax.swing.JPanel;
* @author $author$
* @version $Revision$
*/
-public class IdCanvas extends JPanel
+public class IdCanvas extends JPanel implements ViewportListenerI
{
protected AlignViewport av;
setLayout(new BorderLayout());
this.av = av;
PaintRefresher.Register(this, av.getSequenceSetId());
+ av.getRanges().addPropertyChangeListener(this);
}
/**
{
this.idfont = idfont;
}
+
+ @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());
+ }
+ }
}
af.viewport.setShowUnconserved(view.hasShowUnconserved() ? view
.isShowUnconserved() : false);
af.viewport.getRanges().setStartRes(view.getStartRes());
- af.viewport.getRanges().setStartSeq(view.getStartSeq());
+ // startSeq set in af.alignPanel.updateLayout below
af.alignPanel.updateLayout();
ColourSchemeI cs = null;
// apply colourschemes
af.setBounds(view.getXpos(), view.getYpos(), view.getWidth(),
view.getHeight());
af.viewport.getRanges().setStartRes(view.getStartRes());
- af.viewport.getRanges().setStartSeq(view.getStartSeq());
+ // startSeq set in af.alignPanel.updateLayout below
af.viewport.setShowAnnotation(view.getShowAnnotation());
af.viewport.setAbovePIDThreshold(view.getPidSelected());
af.viewport.setColourText(view.getShowColourText());
import jalview.renderer.AnnotationRenderer;
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.MouseMotionAdapter;
import java.awt.image.BufferedImage;
+import java.beans.PropertyChangeEvent;
import javax.swing.JPanel;
* @author $author$
* @version $Revision$
*/
-public class OverviewPanel extends JPanel implements Runnable
+public class OverviewPanel extends JPanel implements Runnable,
+ ViewportListenerI
{
private static final Color TRANS_GREY = new Color(100, 100, 100, 25);
(av.isShowAnnotation() && av
.getAlignmentConservationAnnotation() != null));
+ av.getRanges().addPropertyChangeListener(this);
+
addComponentListener(new ComponentAdapter()
{
@Override
g.setColor(Color.red);
od.drawBox(g);
}
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ setBoxPosition();
+ }
}
import jalview.renderer.ScaleRenderer.ScaleMark;
import jalview.util.MessageManager;
import jalview.util.Platform;
+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;
import javax.swing.JMenuItem;
* supports a range of mouse operations to select, hide or reveal columns.
*/
public class ScalePanel extends JPanel implements MouseMotionListener,
- MouseListener
+ MouseListener, ViewportListenerI
{
protected int offy = 4;
addMouseListener(this);
addMouseMotionListener(this);
+
+ av.getRanges().addPropertyChangeListener(this);
}
/**
}
}
+ @Override
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ // Respond to viewport change events (e.g. alignment panel was scrolled)
+ repaint();
+ }
+
}
import jalview.datamodel.SequenceI;
import jalview.renderer.ScaleRenderer;
import jalview.renderer.ScaleRenderer.ScaleMark;
+import jalview.viewmodel.ViewportListenerI;
import jalview.viewmodel.ViewportRanges;
import java.awt.BasicStroke;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.image.BufferedImage;
+import java.beans.PropertyChangeEvent;
import java.util.List;
import javax.swing.JComponent;
* @author $author$
* @version $Revision$
*/
-public class SeqCanvas extends JComponent
+public class SeqCanvas extends JComponent implements ViewportListenerI
{
final FeatureRenderer fr;
setLayout(new BorderLayout());
PaintRefresher.Register(this, av.getSequenceSetId());
setBackground(Color.white);
+
+ av.getRanges().addPropertyChangeListener(this);
}
public SequenceRenderer getSequenceRenderer()
repaint();
}
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+
+ 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());
+ }
+
+ }
}
--- /dev/null
+package jalview.viewmodel;
+
+import java.beans.PropertyChangeListener;
+
+public interface ViewportListenerI extends PropertyChangeListener
+{
+
+}
*/
package jalview.viewmodel;
+import java.beans.PropertyChangeSupport;
+
public abstract class ViewportProperties
{
+ protected PropertyChangeSupport changeSupport = new PropertyChangeSupport(
+ this);
+
+ public void addPropertyChangeListener(ViewportListenerI listener)
+ {
+ changeSupport.addPropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(ViewportListenerI listener)
+ {
+ changeSupport.removePropertyChangeListener(listener);
+ }
}
}
/**
- * Set first residue visible in the viewport
+ * Set first residue visible in the viewport, and retain the current width.
*
* @param res
* residue position
{
res = 0;
}
+
+ int oldres = this.startRes;
this.startRes = res;
+ // changeSupport.firePropertyChange("startres", oldres, res);
+ }
+
+ public void setStartEndRes(int startres, int endres)
+ {
+ int oldres = this.startRes;
+ setStartRes(startres);
+ setEndRes(endres);
+ changeSupport.firePropertyChange("startres", oldres, startres);
}
/**
{
res = 0;
}
+ int oldres = this.endRes;
this.endRes = res;
+
+ // changeSupport.firePropertyChange("endres", oldres, res);
}
/**
{
seq = 0;
}
+
+ int oldseq = this.startSeq;
this.startSeq = seq;
+ // changeSupport.firePropertyChange("startseq", oldseq, seq);
+ }
+
+ public void setStartEndSeq(int startseq, int endseq)
+ {
+ int oldseq = this.startSeq;
+ setStartSeq(startseq);
+ setEndSeq(endseq);
+ changeSupport.firePropertyChange("startseq", oldseq, startseq);
}
/**
{
seq = 0;
}
+ int oldseq = this.endSeq;
this.endSeq = seq;
+
+ // changeSupport.firePropertyChange("endseq", oldseq, seq);
}
/**