import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.viewmodel.ViewportListenerI;
+import jalview.viewmodel.ViewportRanges;
import java.awt.Color;
import java.awt.Dimension;
// ap.annotationScroller.getVAdjustable().addAdjustmentListener( this );
renderer = new AnnotationRenderer();
+
+ av.getRanges().addPropertyChangeListener(this);
}
public AnnotationPanel(AlignViewport av)
{
this.av = av;
renderer = new AnnotationRenderer();
- av.getRanges().addPropertyChangeListener(this);
+
}
@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"))
+ // Both scrolling and resizing change viewport ranges: scrolling changes
+ // both start and end points, but resize only changes end values.
+ // Here we only want to fastpaint on a scroll, with resize using a normal
+ // paint, so scroll events are identified as changes to the horizontal or
+ // vertical start value.
+ if (evt.getPropertyName().equals(ViewportRanges.STARTRES))
{
fastPaint((int) evt.getNewValue() - (int) evt.getOldValue());
}
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"))
+ // Both scrolling and resizing change viewport ranges: scrolling changes
+ // both start and end points, but resize only changes end values.
+ // Here we only want to fastpaint on a scroll, with resize using a normal
+ // paint, so scroll events are identified as changes to the horizontal or
+ // vertical start value.
+ if (evt.getPropertyName().equals(ViewportRanges.STARTSEQ))
{
fastPaint((int) evt.getNewValue() - (int) evt.getOldValue());
}
import jalview.renderer.ScaleRenderer.ScaleMark;
import jalview.util.MessageManager;
import jalview.viewmodel.ViewportListenerI;
+import jalview.viewmodel.ViewportRanges;
import java.awt.Color;
import java.awt.FontMetrics;
public void propertyChange(PropertyChangeEvent evt)
{
// Respond to viewport change events (e.g. alignment panel was scrolled)
- repaint();
+ // Both scrolling and resizing change viewport ranges: scrolling changes
+ // both start and end points, but resize only changes end values.
+ // Here we only want to fastpaint on a scroll, with resize using a normal
+ // paint, so scroll events are identified as changes to the horizontal or
+ // vertical start value.
+ if (evt.getPropertyName().equals(ViewportRanges.STARTRES))
+ {
+ // scroll event, repaint panel
+ repaint();
+ }
}
}
@Override
public void propertyChange(PropertyChangeEvent evt)
{
+ String eventName = evt.getPropertyName();
+
if (!av.getWrapAlignment())
{
- if (evt.getPropertyName().equals("startres")
- || evt.getPropertyName().equals("endres"))
+ int scrollX = 0;
+ if (eventName.equals(ViewportRanges.STARTRES))
{
// 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();
+ scrollX = (int) evt.getNewValue() - (int) evt.getOldValue();
if (scrollX > vpRanges.getEndRes() - vpRanges.getStartRes())
{
scrollX = vpRanges.getEndRes() - vpRanges.getStartRes();
{
scrollX = vpRanges.getStartRes() - vpRanges.getEndRes();
}
+ }
+
+ // Both scrolling and resizing change viewport ranges: scrolling changes
+ // both start and end points, but resize only changes end values.
+ // Here we only want to fastpaint on a scroll, with resize using a normal
+ // paint, so scroll events are identified as changes to the horizontal or
+ // vertical start value.
+ if (eventName.equals(ViewportRanges.STARTRES))
+ {
+ // scroll - startres and endres both change
fastPaint(scrollX, 0);
}
- else if (evt.getPropertyName().equals("startseq")
- || evt.getPropertyName().equals("endseq"))
+ else if (eventName.equals(ViewportRanges.STARTSEQ))
{
+ // scroll
fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue());
}
}
-
}
}
import jalview.util.Comparison;
import jalview.util.MessageManager;
import jalview.viewmodel.ViewportListenerI;
+import jalview.viewmodel.ViewportRanges;
import java.awt.AlphaComposite;
import java.awt.Color;
public void propertyChange(PropertyChangeEvent evt)
{
// Respond to viewport range changes (e.g. alignment panel was scrolled)
- if (evt.getPropertyName().equals("startres"))
+ // Both scrolling and resizing change viewport ranges: scrolling changes
+ // both start and end points, but resize only changes end values.
+ // Here we only want to fastpaint on a scroll, with resize using a normal
+ // paint, so scroll events are identified as changes to the horizontal or
+ // vertical start value.
+ if (evt.getPropertyName().equals(ViewportRanges.STARTRES))
{
fastPaint((int) evt.getNewValue() - (int) evt.getOldValue());
}
- else if (evt.getPropertyName().equals("endres"))
- {
- // resize - do nothing
- }
}
}
public void propertyChange(PropertyChangeEvent evt)
{
// Respond to viewport range changes (e.g. alignment panel was scrolled)
- if (evt.getPropertyName().equals("startseq"))
+ // Both scrolling and resizing change viewport ranges: scrolling changes
+ // both start and end points, but resize only changes end values.
+ // Here we only want to fastpaint on a scroll, with resize using a normal
+ // paint, so scroll events are identified as changes to the horizontal or
+ // vertical start value.
+ if (evt.getPropertyName().equals(ViewportRanges.STARTSEQ))
{
fastPaint((int) evt.getNewValue() - (int) evt.getOldValue());
}
- else if (evt.getPropertyName().equals("endseq"))
- {
- // resize - do nothing
- }
}
}
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.viewmodel.ViewportListenerI;
+import jalview.viewmodel.ViewportRanges;
import java.awt.Color;
import java.awt.FontMetrics;
public void propertyChange(PropertyChangeEvent evt)
{
// Respond to viewport change events (e.g. alignment panel was scrolled)
- if (evt.getPropertyName().equals("startres"))
+ // Both scrolling and resizing change viewport ranges: scrolling changes
+ // both start and end points, but resize only changes end values.
+ // Here we only want to fastpaint on a scroll, with resize using a normal
+ // paint, so scroll events are identified as changes to the horizontal or
+ // vertical start value.
+ if (evt.getPropertyName().equals(ViewportRanges.STARTRES))
{
// scroll event, repaint panel
repaint();
@Override
public void propertyChange(PropertyChangeEvent evt)
{
+ String eventName = evt.getPropertyName();
+
if (!av.getWrapAlignment())
{
int scrollX = 0;
- if ((evt.getPropertyName().equals("startres"))
- || (evt.getPropertyName().equals("endres")))
+ if (eventName.equals(ViewportRanges.STARTRES))
{
// Make sure we're not trying to draw a panel
// larger than the visible window
}
}
- if (evt.getPropertyName().equals("startres"))
+ // Both scrolling and resizing change viewport ranges: scrolling changes
+ // both start and end points, but resize only changes end values.
+ // Here we only want to fastpaint on a scroll, with resize using a normal
+ // paint, so scroll events are identified as changes to the horizontal or
+ // vertical start value.
+ if (eventName.equals(ViewportRanges.STARTRES))
{
// scroll - startres and endres both change
fastPaint(scrollX, 0);
}
- else if (evt.getPropertyName().equals("endres"))
- {
- // resize - only endres changes - do nothing
- }
- else if (evt.getPropertyName().equals("startseq"))
+ else if (eventName.equals(ViewportRanges.STARTSEQ))
{
// scroll
fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue());
}
- else if (evt.getPropertyName().equals("endseq"))
- {
- // resize - do nothing
- }
}
}
}
*/
public class ViewportRanges extends ViewportProperties
{
+ public static final String STARTRES = "startres";
+
+ public static final String ENDRES = "endres";
+
+ public static final String STARTSEQ = "startseq";
+
+ public static final String ENDSEQ = "endseq";
+
// start residue of viewport
private int startRes;
endRes = end;
}
- changeSupport.firePropertyChange("startres", oldstartres, startRes);
+ changeSupport.firePropertyChange(STARTRES, oldstartres, startRes);
if (oldstartres == startRes)
{
// event won't be fired if start positions are same
// fire an event for the end positions in case they changed
- changeSupport.firePropertyChange("endres", oldendres, endRes);
+ changeSupport.firePropertyChange(ENDRES, oldendres, endRes);
}
}
endSeq = end;
}
- changeSupport.firePropertyChange("startseq", oldstartseq, startSeq);
+ changeSupport.firePropertyChange(STARTSEQ, oldstartseq, startSeq);
if (oldstartseq == startSeq)
{
// event won't be fired if start positions are the same
// fire in case the end positions changed
- changeSupport.firePropertyChange("endseq", oldendseq, endSeq);
+ changeSupport.firePropertyChange(ENDSEQ, oldendseq, endSeq);
}
}