import jalview.util.Comparison;
import jalview.util.MessageManager;
import jalview.viewmodel.ViewportListenerI;
+import jalview.viewmodel.ViewportRanges;
import java.awt.AlphaComposite;
import java.awt.Color;
* @param horizontal
* repaint with horizontal shift in alignment
*/
- public void fastPaint(int horizontal, boolean isresize)
+ public void fastPaint(int horizontal)
{
if ((horizontal == 0) || gg == null
|| av.getAlignment().getAlignmentAnnotation() == null
int sr = av.getRanges().getStartRes();
int er = av.getRanges().getEndRes() + 1;
int transX = 0;
- long stime;
- long mtime;
- if (isresize)
- {
- imgWidth = (av.getRanges().getEndRes() - av.getRanges().getStartRes()
- + 1) * av.getCharWidth();
-
- if (imgWidth > 0)
- {
- BufferedImage newimage = new BufferedImage(imgWidth,
- ap.getAnnotationPanel().getHeight(),
- BufferedImage.TYPE_INT_ARGB);
-
- gg = (Graphics2D) newimage.getGraphics();
- gg.setFont(av.getFont());
- gg.drawImage(image, null, 0, 0);
- image = newimage;
+ long stime = System.currentTimeMillis();
+ gg.copyArea(0, 0, imgWidth, getHeight(),
+ -horizontal * av.getCharWidth(), 0);
+ long mtime = System.currentTimeMillis();
- transX = (er - horizontal - sr) * av.getCharWidth();
- sr = er - horizontal - sr;
- }
+ if (horizontal > 0) // scrollbar pulled right, image to the left
+ {
+ transX = (er - sr - horizontal) * av.getCharWidth();
+ sr = er - horizontal;
}
- else
+ else if (horizontal < 0)
{
- stime = System.currentTimeMillis();
- gg.copyArea(0, 0, imgWidth, getHeight(),
- -horizontal * av.getCharWidth(), 0);
- mtime = System.currentTimeMillis();
-
- if (horizontal > 0) // scrollbar pulled right, image to the left
- {
- transX = (er - sr - horizontal) * av.getCharWidth();
- sr = er - horizontal;
- }
- else if (horizontal < 0)
- {
- er = sr - horizontal;
- }
+ er = sr - horizontal;
}
gg.translate(transX, 0);
public void propertyChange(PropertyChangeEvent evt)
{
// Respond to viewport range changes (e.g. alignment panel was scrolled)
- if (evt.getPropertyName().equals("startres"))
- {
- fastPaint((int) evt.getNewValue() - (int) evt.getOldValue(), false);
- }
- else if (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))
{
- // resize
- fastPaint((int) evt.getNewValue() - (int) evt.getOldValue(), true);
+ fastPaint((int) evt.getNewValue() - (int) evt.getOldValue());
}
}
}