X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=d97c80f78a0c5f0714f119bf97a9f067932ab88a;hb=783520af519c958e10a2af29f1d4242e1ab890a3;hp=9c2aac0967129359020e0964cbeb5cd74bee03c9;hpb=481f2cbd12ab5527f2d86bf9a08736f3d962cf19;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 9c2aac0..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,7 +95,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, /** * DOCUMENT ME! */ - public void adjustPanelHeight() + public int adjustPanelHeight() { // setHeight of panels image = null; @@ -136,6 +142,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, } this.setPreferredSize(new Dimension(1, height)); + + return height; } /** @@ -148,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++) { @@ -178,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++) { @@ -526,7 +538,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, g.setColor(Color.white); g.fillRect(0, 0, getWidth(), getHeight()); - if (fastPaint) + if (fastPaint && image!=null) { g.drawImage(image, 0, 0, this); fastPaint = false; @@ -602,8 +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) { + g.setFont(av.getFont()); + + if (fm == null) + fm = g.getFontMetrics(); + + g.setColor(Color.white); g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getHeight()); @@ -852,13 +870,17 @@ public class AnnotationPanel extends JPanel implements MouseListener, g.fillRect(0, 0, width, y); g.setColor(new Color(0, 0, 180)); - int x = 0; + + 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; }