X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAnnotationLabels.java;h=8b3a503ce83f644b2ce8e3a599743f023e093a9b;hb=3045b37e365018c7fe5a97fec36994eb22c379a4;hp=ca5fe23edce4dd9334775ef6f9bd8dabec62cf3c;hpb=218ff56e061f1329f53b2fa4cb353b0348a87bc0;p=jalview.git diff --git a/src/jalview/appletgui/AnnotationLabels.java b/src/jalview/appletgui/AnnotationLabels.java index ca5fe23..8b3a503 100755 --- a/src/jalview/appletgui/AnnotationLabels.java +++ b/src/jalview/appletgui/AnnotationLabels.java @@ -29,6 +29,7 @@ public class AnnotationLabels { boolean active = false; AlignmentPanel ap; + AlignViewport av; boolean resizing = false; int oldY, mouseX; static String ADDNEW = "Add new row"; @@ -42,6 +43,7 @@ public class AnnotationLabels public AnnotationLabels(AlignmentPanel ap) { this.ap = ap; + this.av = ap.av; setLayout(null); addMouseListener(new MouseAdapter() { @@ -52,6 +54,12 @@ public class AnnotationLabels }); } + public AnnotationLabels(AlignViewport av) +{ + this.av = av; +} + + public void setScrollOffset(int y) { scrollOffset = y; @@ -60,7 +68,7 @@ public class AnnotationLabels public void actionPerformed(ActionEvent evt) { - AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); + AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); if (evt.getActionCommand().equals(HIDE)) { @@ -75,7 +83,7 @@ public class AnnotationLabels } else if (evt.getActionCommand().equals(OUTPUT_TEXT)) { - CutAndPasteTransfer cap = new CutAndPasteTransfer(false); + CutAndPasteTransfer cap = new CutAndPasteTransfer(false, ap.alignFrame); Frame frame = new Frame(); frame.add(cap); jalview.bin.JalviewLite.addFrame(frame, @@ -146,19 +154,20 @@ public class AnnotationLabels public void paint(Graphics g) { - drawComponent(g); + drawComponent(g, getSize().width); } - public void drawComponent(Graphics g) + public void drawComponent(Graphics g, int width) { - FontMetrics fm = g.getFontMetrics(g.getFont()); + g.setFont(av.getFont()); + FontMetrics fm = g.getFontMetrics(av.getFont()); g.setColor(Color.white); g.fillRect(0, 0, getSize().width, getSize().height); g.translate(0, scrollOffset); g.setColor(Color.black); - AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); + AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); int y = g.getFont().getSize(); int x = 0; @@ -171,16 +180,16 @@ public class AnnotationLabels continue; } - x = getSize().width - fm.stringWidth(aa[i].label) - 3; + x = width - fm.stringWidth(aa[i].label) - 3; - if (aa[i].isGraph) + if (aa[i].graph>0) { y += (aa[i].height / 3); } g.drawString(aa[i].label, x, y); - if (aa[i].isGraph) + if (aa[i].graph>0) { y += (2 * aa[i].height / 3); }