From: amwaterhouse Date: Wed, 18 Oct 2006 13:02:58 +0000 (+0000) Subject: Faded anntotations when recalculating X-Git-Tag: Release_2_2~265 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c5443fe79c3846608bdaad1e548ba80ca65317ac;p=jalview.git Faded anntotations when recalculating --- diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 9fee829..844c1ab 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -49,6 +49,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, AlignmentPanel ap; int activeRow = -1; BufferedImage image; + BufferedImage fadedImage; Graphics2D gg; FontMetrics fm; int imgWidth = 0; @@ -587,6 +588,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, gg.setFont(av.getFont()); fm = gg.getFontMetrics(); + gg.setColor(Color.white); + gg.fillRect(0, 0, imgWidth, image.getHeight()); } @@ -601,9 +604,12 @@ public class AnnotationPanel extends JPanel implements MouseListener, */ public void fastPaint(int horizontal) { - if ((horizontal == 0) || gg==null || - (av.alignment.getAlignmentAnnotation() == null) || - (av.alignment.getAlignmentAnnotation().length < 1)) + if ((horizontal == 0) + || gg==null + || av.alignment.getAlignmentAnnotation()==null + || av.alignment.getAlignmentAnnotation().length < 1 + || av.updatingConsensus + || av.updatingConservation) { repaint(); return; @@ -646,14 +652,45 @@ public class AnnotationPanel extends JPanel implements MouseListener, */ public void drawComponent(Graphics g, int startRes, int endRes) { - g.setFont(av.getFont()); + if(av.updatingConsensus || av.updatingConservation) + { + //We'll keep a record of the old image, + //and draw a faded image until the calculation + //has completed + if(fadedImage==null + || fadedImage.getWidth()!=imgWidth + || fadedImage.getHeight()!=image.getHeight()) + { + fadedImage = new BufferedImage( + imgWidth, image.getHeight(), + BufferedImage.TYPE_INT_RGB); + + Graphics2D fadedG = (Graphics2D) fadedImage.getGraphics(); + + fadedG.setColor(Color.white); + fadedG.fillRect(0, 0, imgWidth, image.getHeight()); + + fadedG.setComposite( + AlphaComposite.getInstance( + AlphaComposite.SRC_OVER, .3f)); + fadedG.drawImage(image, 0, 0, this); + + } + + } + else + fadedImage = null; + + g.setColor(Color.white); + g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getHeight()); + + g.setFont(av.getFont()); if (fm == null) fm = g.getFontMetrics(); - g.setColor(Color.white); - g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getHeight()); + if ( (av.alignment.getAlignmentAnnotation() == null) || (av.alignment.getAlignmentAnnotation().length < 1)) @@ -710,22 +747,39 @@ public class AnnotationPanel extends JPanel implements MouseListener, if (av.updatingConsensus && aa[i].label.equals("Consensus")) { - g.setColor(Color.darkGray); - g.drawString("Recalculating Consensus....", 20, y - 5); y += av.charHeight; + + g.drawImage(fadedImage, + 0,y-row.height,imgWidth, y, + 0,y-row.height,imgWidth, y, this); + g.setColor(Color.black); + // g.drawString("Calculating Consensus....",20, y-row.height/2); + continue; } else if (av.updatingConservation && aa[i].label.equals("Conservation")) { - g.setColor(Color.darkGray); - g.drawString("Recalculating Conservation.....", 20, y - 5); + y += av.charHeight; + g.drawImage(fadedImage, + 0, y - row.height, imgWidth, y, + 0, y - row.height, imgWidth, y, this); + + g.setColor(Color.black); + // g.drawString("Calculating Conservation.....",20, y-row.height/2); + continue; } else if (av.updatingConservation && aa[i].label.equals("Quality")) { - g.setColor(Color.darkGray); - g.drawString("Recalculating Quality....", 20, y - 5); + + y += av.charHeight; + g.drawImage(fadedImage, + 0, y - row.height, imgWidth, y, + 0, y - row.height, imgWidth, y, this); + g.setColor(Color.black); + /// g.drawString("Calculating Quality....",20, y-row.height/2); + continue; }