fontChanged method added, componentListener removed
authoramwaterhouse <Andrew Waterhouse>
Mon, 18 Apr 2005 08:03:41 +0000 (08:03 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 18 Apr 2005 08:03:41 +0000 (08:03 +0000)
src/jalview/gui/AlignmentPanel.java

index 9b57ae1..02330a5 100755 (executable)
@@ -51,10 +51,7 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
     annotationScroller.setViewportView(annotationPanel);\r
     annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER);\r
 \r
-    Dimension d = calculateIdWidth();\r
-    d.setSize( d.width+4, d.height);\r
-    idPanel.idCanvas.setPreferredSize( d );\r
-    hscrollFillerPanel.setPreferredSize( d );\r
+    fontChanged();\r
 \r
     scalePanelHolder.add(scalePanel, BorderLayout.CENTER);\r
     seqPanelHolder.add(seqPanel, BorderLayout.CENTER);\r
@@ -64,14 +61,6 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
     hscroll.addAdjustmentListener(this);\r
     vscroll.addAdjustmentListener(this);\r
 \r
-    addComponentListener(new ComponentAdapter()\r
-   {\r
-     public void componentResized(ComponentEvent evt)\r
-     {\r
-          repaint();\r
-     }\r
-   });\r
-\r
    setFocusable(true);\r
    addKeyListener(new KeyAdapter()\r
    {\r
@@ -114,6 +103,20 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
    });\r
   }\r
 \r
+  public void fontChanged()\r
+  {\r
+    // set idCanvas bufferedImage to null\r
+    // to prevent drawing old image\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
@@ -344,9 +347,10 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
       repaint();\r
     else\r
     {\r
+      idPanel.idCanvas.fastPaint(av.getStartSeq() - oldY);\r
       seqPanel.seqCanvas.fastPaint(av.getStartRes() - oldX,\r
                                    av.getStartSeq() - oldY);\r
-      idPanel.idCanvas.fastPaint(av.getStartSeq() - oldY);\r
+\r
       scalePanel.repaint();\r
       if (av.getShowAnnotation())\r
         annotationPanel.fastPaint(av.getStartRes() - oldX);\r
@@ -354,13 +358,14 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
 \r
   }\r
 \r
+\r
   public void paintComponent(Graphics g)\r
   {\r
     invalidate();\r
-\r
     Dimension d = idPanel.idCanvas.getPreferredSize();\r
     idPanelHolder.setPreferredSize(d);\r
     hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12));\r
+    validate();\r
 \r
     if (av.getWrapAlignment())\r
     {\r
@@ -376,7 +381,7 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
       setScrollValues(av.getStartRes(), av.getStartSeq());\r
     }\r
 \r
-    validate();\r
+\r
 \r
   }\r
 \r