+ public void fontChanged()\r
+ {\r
+ // set idCanvas bufferedImage to null\r
+ // to prevent drawing old image\r
+ FontMetrics fm = getFontMetrics(av.getFont());\r
+\r
+ scalePanelHolder.setPreferredSize(new Dimension(10, av.charHeight+fm.getDescent()));\r
+ idSpaceFillerPanel1.setPreferredSize(new Dimension(10, av.charHeight+fm.getDescent()));\r
+\r
+ idPanel.idCanvas.gg = null;\r
+ annotationPanel.adjustPanelHeight();\r
+ Dimension d = calculateIdWidth();\r
+ d.setSize(d.width + 4, d.height);\r
+ idPanel.idCanvas.setPreferredSize(d);\r
+ hscrollFillerPanel.setPreferredSize(d);\r
+ repaint();\r
+ }\r
+\r
+\r
+ Dimension calculateIdWidth()\r
+ {\r
+ Graphics g = this.getGraphics();\r
+ if(g==null)\r
+ {\r
+ javax.swing.JFrame f = new javax.swing.JFrame();\r
+ f.addNotify();\r
+ g = f.getGraphics();\r
+ }\r
+\r
+ FontMetrics fm = g.getFontMetrics(av.font);\r
+ AlignmentI al = av.getAlignment();\r
+\r
+ int i = 0;\r
+ int idWidth = 0;\r
+ String id;\r
+ while (i < al.getHeight() && al.getSequenceAt(i) != null)\r
+ {\r
+ SequenceI s = al.getSequenceAt(i);\r
+ if(av.getShowFullId())\r
+ id = s.getDisplayId();\r
+ else\r
+ id = s.getName();\r
+\r
+ if (fm.stringWidth(id) > idWidth)\r
+ idWidth = fm.stringWidth(id);\r
+ i++;\r
+ }\r
+\r
+ // Also check annotation label widths\r
+ i=0;\r
+ if(al.getAlignmentAnnotation()!=null)\r
+ {\r
+ fm = g.getFontMetrics(alabels.getFont());\r
+ while (i < al.getAlignmentAnnotation().length)\r
+ {\r
+ String label = al.getAlignmentAnnotation()[i].label;\r
+ if (fm.stringWidth(label) > idWidth)\r
+ idWidth = fm.stringWidth(label);\r
+ i++;\r
+ }\r
+ }\r
+\r
+ return new Dimension(idWidth, 12);\r
+ }\r
+\r