import jalview.util.Comparison;
import jalview.util.MessageManager;
import jalview.viewmodel.ViewportListenerI;
+import jalview.viewmodel.ViewportRanges;
import java.awt.AlphaComposite;
import java.awt.Color;
if (anot.length < av.getColumnSelection().getMax())
{
- Annotation[] temp = new Annotation[av.getColumnSelection().getMax() + 2];
+ Annotation[] temp = new Annotation[av.getColumnSelection().getMax()
+ + 2];
System.arraycopy(anot, 0, temp, 0, anot.length);
anot = temp;
aa[activeRow].annotations = anot;
anot[index] = new Annotation(label, "", type, 0);
}
- anot[index].secondaryStructure = type != 'S' ? type : label
- .length() == 0 ? ' ' : label.charAt(0);
+ anot[index].secondaryStructure = type != 'S' ? type
+ : label.length() == 0 ? ' ' : label.charAt(0);
anot[index].displayCharacter = label;
}
{
if (graphStretch > -1)
{
- av.getAlignment().getAlignmentAnnotation()[graphStretch].graphHeight += graphStretchY
- - evt.getY();
- if (av.getAlignment().getAlignmentAnnotation()[graphStretch].graphHeight < 0)
+ av.getAlignment()
+ .getAlignmentAnnotation()[graphStretch].graphHeight += graphStretchY
+ - evt.getY();
+ if (av.getAlignment()
+ .getAlignmentAnnotation()[graphStretch].graphHeight < 0)
{
- av.getAlignment().getAlignmentAnnotation()[graphStretch].graphHeight = 0;
+ av.getAlignment()
+ .getAlignmentAnnotation()[graphStretch].graphHeight = 0;
}
graphStretchY = evt.getY();
adjustPanelHeight();
- ap.paintAlignment(true);
+ ap.paintAlignment(false, false);
}
else
{
if (av.hasHiddenColumns())
{
column = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(column);
+ .visibleToAbsoluteColumn(column);
}
AlignmentAnnotation ann = aa[row];
int seqIndex = av.getAlignment().findIndex(seqref);
if (seqIndex != -1)
{
- text.append(", ")
- .append(MessageManager.getString("label.sequence"))
+ text.append(", ").append(MessageManager.getString("label.sequence"))
.append(" ").append(seqIndex + 1);
char residue = seqref.getCharAt(column);
if (!Comparison.isGap(residue))
String name;
if (av.getAlignment().isNucleotide())
{
- name = ResidueProperties.nucleotideName.get(String
- .valueOf(residue));
- text.append(" Nucleotide: ").append(
- name != null ? name : residue);
+ name = ResidueProperties.nucleotideName
+ .get(String.valueOf(residue));
+ text.append(" Nucleotide: ")
+ .append(name != null ? name : residue);
}
else
{
- name = 'X' == residue ? "X" : ('*' == residue ? "STOP"
- : ResidueProperties.aa2Triplet.get(String
- .valueOf(residue)));
+ name = 'X' == residue ? "X"
+ : ('*' == residue ? "STOP"
+ : ResidueProperties.aa2Triplet
+ .get(String.valueOf(residue)));
text.append(" Residue: ").append(name != null ? name : residue);
}
int residuePos = seqref.findPosition(column);
@Override
public void paintComponent(Graphics g)
{
+ super.paintComponent(g);
+
g.setColor(Color.white);
g.fillRect(0, 0, getWidth(), getHeight());
return;
}
}
- imgWidth = (av.getRanges().getEndRes() - av.getRanges().getStartRes() + 1)
- * av.getCharWidth();
+ imgWidth = (av.getRanges().getEndRes() - av.getRanges().getStartRes()
+ + 1) * av.getCharWidth();
if (imgWidth < 1)
{
return;
{
try
{
- image = new BufferedImage(imgWidth, ap.getAnnotationPanel()
- .getHeight(), BufferedImage.TYPE_INT_RGB);
+ image = new BufferedImage(imgWidth,
+ ap.getAnnotationPanel().getHeight(),
+ BufferedImage.TYPE_INT_RGB);
} catch (OutOfMemoryError oom)
{
try
gg.fillRect(0, 0, imgWidth, image.getHeight());
imageFresh = true;
}
-
- drawComponent(gg, av.getRanges().getStartRes(), av.getRanges()
- .getEndRes() + 1);
+
+ drawComponent(gg, av.getRanges().getStartRes(),
+ av.getRanges().getEndRes() + 1);
imageFresh = false;
g.drawImage(image, 0, 0, this);
}
repaint();
return;
}
- long stime = System.currentTimeMillis();
- gg.copyArea(0, 0, imgWidth, getHeight(),
- -horizontal * av.getCharWidth(), 0);
- long mtime = System.currentTimeMillis();
+
int sr = av.getRanges().getStartRes();
int er = av.getRanges().getEndRes() + 1;
int transX = 0;
+ gg.copyArea(0, 0, imgWidth, getHeight(),
+ -horizontal * av.getCharWidth(), 0);
+
if (horizontal > 0) // scrollbar pulled right, image to the left
{
transX = (er - sr - horizontal) * av.getCharWidth();
drawComponent(gg, sr, er);
gg.translate(-transX, 0);
- long dtime = System.currentTimeMillis();
+
fastPaint = true;
- repaint();
- long rtime = System.currentTimeMillis();
- if (debugRedraw)
- {
- System.err.println("Scroll:\t" + horizontal + "\tCopyArea:\t"
- + (mtime - stime) + "\tDraw component:\t" + (dtime - mtime)
- + "\tRepaint call:\t" + (rtime - dtime));
- }
+ // Call repaint on alignment panel so that repaints from other alignment
+ // panel components can be aggregated. Otherwise performance of the overview
+ // window and others may be adversely affected.
+ av.getAlignPanel().repaint();
}
private volatile boolean lastImageGood = false;
// and draw a faded image until the calculation
// has completed
if (lastImageGood
- && (fadedImage == null || fadedImage.getWidth() != imgWidth || fadedImage
- .getHeight() != image.getHeight()))
+ && (fadedImage == null || fadedImage.getWidth() != imgWidth
+ || fadedImage.getHeight() != image.getHeight()))
{
// System.err.println("redraw faded image ("+(fadedImage==null ?
// "null image" : "") + " lastGood="+lastImageGood+")");
fadedG.setColor(Color.white);
fadedG.fillRect(0, 0, imgWidth, image.getHeight());
- fadedG.setComposite(AlphaComposite.getInstance(
- AlphaComposite.SRC_OVER, .3f));
+ fadedG.setComposite(
+ AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .3f));
fadedG.drawImage(image, 0, 0, this);
}
return;
}
- lastImageGood = renderer.drawComponent(this, av, g, activeRow,
- startRes, endRes);
+ lastImageGood = renderer.drawComponent(this, av, g, activeRow, startRes,
+ endRes);
if (!lastImageGood && fadedImage == null)
{
fadedImage = oldFaded;
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"))
+ else if (evt.getPropertyName().equals(ViewportRanges.STARTRESANDSEQ))
+ {
+ fastPaint(((int[]) evt.getNewValue())[0]
+ - ((int[]) evt.getOldValue())[0]);
+ }
+ else if (evt.getPropertyName().equals(ViewportRanges.MOVE_VIEWPORT))
{
- // resize
+ repaint();
}
}
}