X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=abe92bbabb4f691f41ce4c7ee3ba8aba5a466c8a;hb=90ff735f876d7064f1f24925874fd7f41f94c7ac;hp=452f0027adf0935925dfa5a3e7d1a0947a4d11a1;hpb=c2e5d3d1ebe3b283bdde15637c590721cd6c5637;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 452f002..abe92bb 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -31,6 +31,7 @@ import jalview.schemes.ResidueProperties; import jalview.util.Comparison; import jalview.util.MessageManager; import jalview.viewmodel.ViewportListenerI; +import jalview.viewmodel.ViewportRanges; import java.awt.AlphaComposite; import java.awt.Color; @@ -284,7 +285,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, 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; @@ -412,8 +414,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, 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; } @@ -451,7 +453,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, * the selection list (read-only view) is in selection order, not * column order; make a copy so we can sort it */ - List selected = new ArrayList(viscols.getSelected()); + List selected = new ArrayList<>(viscols.getSelected()); Collections.sort(selected); for (int index : selected) { @@ -657,15 +659,18 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, { 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 { @@ -819,8 +824,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, 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)) @@ -829,16 +833,17 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, 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); @@ -899,6 +904,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, @Override public void paintComponent(Graphics g) { + super.paintComponent(g); + g.setColor(Color.white); g.fillRect(0, 0, getWidth(), getHeight()); @@ -912,8 +919,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, 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; @@ -923,8 +930,9 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, { 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 @@ -954,8 +962,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, 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); } @@ -981,14 +989,14 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, 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(); @@ -1004,17 +1012,9 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, 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)); - } - } private volatile boolean lastImageGood = false; @@ -1043,8 +1043,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, // 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+")"); @@ -1056,8 +1056,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, 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); } @@ -1098,8 +1098,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, 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; @@ -1168,10 +1168,19 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, 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()); } + else if (evt.getPropertyName().equals(ViewportRanges.STARTRESANDSEQ)) + { + fastPaint(((int[]) evt.getNewValue())[0] + - ((int[]) evt.getOldValue())[0]); + } } }