X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationLabels.java;h=560c9839d4f9bf19d921fb727a53405235d444f7;hb=627834dc46a79d74dec14c3d7a64a529f2337f6f;hp=099d1d1cf2641bd2d20d7fe06be5ffec9e3acbfc;hpb=9fff97021c2c637e426f6971d54dcf3fd4191985;p=jalview.git diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index 099d1d1..560c983 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -44,11 +44,14 @@ public class AnnotationLabels extends JPanel implements MouseListener, boolean active = false; Image image; AlignmentPanel ap; + AlignViewport av; boolean resizing = false; int oldY; int mouseX; int selectedRow = 0; int scrollOffset = 0; + Font font = new Font("Arial", Font.PLAIN, 11); + /** * Creates a new AnnotationLabels object. @@ -58,6 +61,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, public AnnotationLabels(AlignmentPanel ap) { this.ap = ap; + av = ap.av; java.net.URL url = getClass().getResource("/images/idwidth.gif"); Image temp = null; @@ -88,6 +92,11 @@ public class AnnotationLabels extends JPanel implements MouseListener, addMouseMotionListener(this); } + public AnnotationLabels(AlignViewport av) + { + this.av = av; + } + /** * DOCUMENT ME! * @@ -325,7 +334,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, { pop.addSeparator(); final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem( - "Ignore gaps in calculation", + "Ignore Gaps In Consensus", ap.av.getIgnoreGapsConsensus()); cbmi.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) @@ -346,13 +355,19 @@ public class AnnotationLabels extends JPanel implements MouseListener, * * @param g1 DOCUMENT ME! */ - public void paintComponent(Graphics g1) + public void paintComponent(Graphics g) { - Graphics2D g = (Graphics2D) g1; - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + + int width = getWidth(); + if(width==0) + width = ap.calculateIdWidth().width + 4; + + Graphics2D g2 = (Graphics2D) g; + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - drawComponent(g); + drawComponent(g2, width); + } /** @@ -360,8 +375,13 @@ public class AnnotationLabels extends JPanel implements MouseListener, * * @param g DOCUMENT ME! */ - public void drawComponent(Graphics2D g) + public void drawComponent(Graphics g, int width) { + if(av.getFont().getSize()<10) + g.setFont(new Font("Arial", Font.PLAIN, av.getFont().getSize()-1)); + else + g.setFont(font); + FontMetrics fm = g.getFontMetrics(g.getFont()); g.setColor(Color.white); g.fillRect(0, 0, getWidth(), getHeight()); @@ -369,12 +389,10 @@ public class AnnotationLabels extends JPanel implements MouseListener, 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; - int width = getWidth(); - if(width==0) - width = ap.calculateIdWidth().width + 4; + if (aa != null) { @@ -387,14 +405,14 @@ public class AnnotationLabels extends JPanel implements MouseListener, 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); }