X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=5f0d3c88798bd7d80aa60d6dd0cda7d7cacbe87c;hb=246746e55bd02c66746d5cd872f49890cbae206a;hp=4f984fd1e6a7ea091ceedb36ea5b201f6137a5d3;hpb=6df80899bb3100cd38064c62cda5a2bb85b4528d;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 4f984fd..5f0d3c8 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -92,6 +92,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, public void adjustPanelHeight() { // setHeight of panels + image = null; AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); int height = 0; @@ -147,6 +148,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, if (activeRow == -1) { AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); + if(aa==null) + return; for (int j = 0; j < aa.length; j++) { @@ -177,6 +180,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, if (activeRow == -1) { AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); + if(aa==null) + return; for (int j = 0; j < aa.length; j++) { @@ -332,7 +337,10 @@ public class AnnotationPanel extends JPanel implements MouseListener, for (int i = 0; i < aa.length; i++) { - height += aa[i].height; + if (aa[i].visible) + { + height += aa[i].height; + } if (evt.getY() < height) { @@ -531,24 +539,18 @@ public class AnnotationPanel extends JPanel implements MouseListener, imgWidth = (av.endRes - av.startRes + 1) * av.charWidth; - if (image != null && imgWidth == image.getWidth()) + if (image == null || imgWidth != image.getWidth()) { - //This will be called by a mouse over, tool tip etc - // no need to redraw whole image - g.drawImage(image, 0, 0, this); - fastPaint = false; - return; + image = new BufferedImage(imgWidth, ap.annotationPanel.getHeight(), + BufferedImage.TYPE_INT_RGB); + gg = (Graphics2D) image.getGraphics(); + gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + + gg.setFont(av.getFont()); + fm = gg.getFontMetrics(); } - image = new BufferedImage(imgWidth, ap.annotationPanel.getHeight(), - BufferedImage.TYPE_INT_RGB); - gg = (Graphics2D) image.getGraphics(); - gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - - gg.setFont(av.getFont()); - fm = gg.getFontMetrics(); - drawComponent(gg, av.startRes, av.endRes + 1); g.drawImage(image, 0, 0, this); } @@ -640,6 +642,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, continue; } + if (row.isGraph) { // this is so that we draw the characters below the graph @@ -847,19 +850,23 @@ public class AnnotationPanel extends JPanel implements MouseListener, } // used by overview window - public void drawGraph(Graphics g, AlignmentAnnotation aa, int width, int y) + public void drawGraph(Graphics g, AlignmentAnnotation aa, int width, int y, int sRes, int eRes) { g.setColor(Color.white); g.fillRect(0, 0, width, y); g.setColor(new Color(0, 0, 180)); - int x = 0; - for (int j = 0; j < aa.annotations.length; j++) + int x = 0, height; + + for (int j = sRes; j < eRes; j++) { g.setColor(new Color(0, 0, 180)); - int height = (int) ((aa.annotations[j].value / aa.graphMax) * GRAPH_HEIGHT); + height = (int) ((aa.annotations[j].value / aa.graphMax) * GRAPH_HEIGHT); + if(height>y) + height = y; + g.fillRect(x, y - height, av.charWidth, height); x += av.charWidth; }