X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=d97c80f78a0c5f0714f119bf97a9f067932ab88a;hb=0705a85fe0a3d391e5aba360340a0c342c898366;hp=4d3fc0f98dfa2f9c096139ca496f301360156c87;hpb=50101c6da4cd0c6cd3d0438fa66905aae30b58b7;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 4d3fc0f..d97c80f 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -76,6 +76,12 @@ public class AnnotationPanel extends JPanel implements MouseListener, ap.annotationScroller.getVerticalScrollBar().addAdjustmentListener(this); } + public AnnotationPanel(AlignViewport av) + { + this.av = av; + } + + /** * DOCUMENT ME! * @@ -89,9 +95,10 @@ public class AnnotationPanel extends JPanel implements MouseListener, /** * DOCUMENT ME! */ - public void adjustPanelHeight() + public int adjustPanelHeight() { // setHeight of panels + image = null; AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); int height = 0; @@ -135,6 +142,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, } this.setPreferredSize(new Dimension(1, height)); + + return height; } /** @@ -147,6 +156,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 +188,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 +345,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) { @@ -519,29 +535,32 @@ public class AnnotationPanel extends JPanel implements MouseListener, */ public void paintComponent(Graphics g) { - g.setColor(Color.white); - g.fillRect(0, 0, getWidth(), getHeight()); + g.setColor(Color.white); + g.fillRect(0, 0, getWidth(), getHeight()); - if (fastPaint) - { - g.drawImage(image, 0, 0, this); - fastPaint = false; - - return; - } + if (fastPaint && image!=null) + { + g.drawImage(image, 0, 0, this); + fastPaint = false; + return; + } - imgWidth = (av.endRes - av.startRes + 1) * av.charWidth; + imgWidth = (av.endRes - av.startRes + 1) * av.charWidth; + if (image == null || imgWidth != image.getWidth()) + { image = new BufferedImage(imgWidth, ap.annotationPanel.getHeight(), - BufferedImage.TYPE_INT_RGB); + BufferedImage.TYPE_INT_RGB); gg = (Graphics2D) image.getGraphics(); gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); + RenderingHints.VALUE_ANTIALIAS_ON); gg.setFont(av.getFont()); + fm = gg.getFontMetrics(); + } - drawComponent(gg, av.startRes, av.endRes + 1); - g.drawImage(image, 0, 0, this); + drawComponent(gg, av.startRes, av.endRes + 1); + g.drawImage(image, 0, 0, this); } /** @@ -583,7 +602,9 @@ public class AnnotationPanel extends JPanel implements MouseListener, gg.translate(-transX, 0); fastPaint = true; + repaint(); + } /** @@ -593,11 +614,14 @@ public class AnnotationPanel extends JPanel implements MouseListener, * @param startRes DOCUMENT ME! * @param endRes DOCUMENT ME! */ - public void drawComponent(Graphics2D g, int startRes, int endRes) + public void drawComponent(Graphics g, int startRes, int endRes) { - if(fm==null) + g.setFont(av.getFont()); + + if (fm == null) fm = g.getFontMetrics(); + g.setColor(Color.white); g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getHeight()); @@ -632,6 +656,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, continue; } + if (row.isGraph) { // this is so that we draw the characters below the graph @@ -839,19 +864,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; }