X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=315b14123b2b3f50a8adc352fcc15e8127ea3520;hb=237972562c84b83dbd287071cdd839d97aaf7d4b;hp=dbc1c926f8343cdbee711700eecdf9a9c87109b4;hpb=82cbe684b0afeb8a6a8c6014b9266cb90439dfe7;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index dbc1c92..315b141 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; @@ -107,7 +108,6 @@ public class AnnotationPanel extends JPanel implements MouseListener, public int adjustPanelHeight() { // setHeight of panels - image = null; AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); int height = 0; @@ -508,12 +508,17 @@ public class AnnotationPanel extends JPanel implements MouseListener, } } + if(row==-1) + return; + int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); if(av.hasHiddenColumns) res = av.getColumnSelection().adjustForHiddenColumns(res); - if (row > -1 && res -1 + && res < (int) aa[row].annotations.length) { if(aa[row].graphGroup>-1) { @@ -587,6 +592,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 +608,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 +656,49 @@ 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) + { + if(image==null) + { + return; + } + //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 +755,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; } @@ -1192,13 +1254,16 @@ public class AnnotationPanel extends JPanel implements MouseListener, for (int j = sRes; j < eRes; j++) { + if (aa.annotations[j] != null) + { g.setColor(aa.annotations[j].colour); - height = (int) ((aa.annotations[j].value / aa.graphMax) * y); - if(height>y) + height = (int) ( (aa.annotations[j].value / aa.graphMax) * y); + if (height > y) height = y; g.fillRect(x, y - height, av.charWidth, height); + } x += av.charWidth; } }