Remove unnecessary panel, also nullFrame created only once
authoramwaterhouse <Andrew Waterhouse>
Tue, 2 May 2006 12:23:28 +0000 (12:23 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 2 May 2006 12:23:28 +0000 (12:23 +0000)
src/jalview/appletgui/AlignmentPanel.java

index ed88418..b1a8b8b 100755 (executable)
@@ -63,13 +63,15 @@ public class AlignmentPanel extends Panel implements AdjustmentListener
     scalePanel = new ScalePanel(av, this);\r
     idwidthAdjuster = new IdwidthAdjuster(this);\r
     annotationPanel = new AnnotationPanel(this);\r
+\r
+    sequenceHolderPanel.add(annotationPanel, BorderLayout.SOUTH);\r
+\r
     alabels = new AnnotationLabels(this);\r
 \r
     setAnnotationVisible(av.showAnnotation);\r
 \r
     idPanelHolder.add(idPanel, BorderLayout.CENTER);\r
     idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER);\r
-    annotationScroller.add(annotationPanel);\r
     annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER);\r
     scalePanelHolder.add(scalePanel, BorderLayout.CENTER);\r
     seqPanelHolder.add(seqPanel, BorderLayout.CENTER);\r
@@ -93,7 +95,6 @@ public class AlignmentPanel extends Panel implements AdjustmentListener
     idPanel.idCanvas.setSize(d);\r
 \r
     hscrollFillerPanel.setSize(d.width, annotationPanel.getSize().height);\r
-    annotationScroller.setSize(annotationPanel.getSize());\r
 \r
     idPanel.idCanvas.setSize(d.width, seqPanel.seqCanvas.getSize().height);\r
     annotationSpaceFillerHolder.setSize(d.width,\r
@@ -107,13 +108,13 @@ public class AlignmentPanel extends Panel implements AdjustmentListener
   {\r
     // set idCanvas bufferedImage to null\r
     // to prevent drawing old image\r
-    idPanel.idCanvas.image =null;\r
+    idPanel.idCanvas.image = null;\r
     FontMetrics fm = getFontMetrics(av.getFont());\r
 \r
     scalePanel.setSize(new Dimension(10, av.charHeight + fm.getDescent()));\r
     idwidthAdjuster.setSize(new Dimension(10, av.charHeight + fm.getDescent()));\r
 \r
-annotationPanel.image = null;\r
+    annotationPanel.image = null;\r
     int ap = annotationPanel.adjustPanelHeight();\r
     annotationPanel.repaint();\r
     Dimension d = calculateIdWidth();\r
@@ -139,16 +140,14 @@ annotationPanel.image = null;
 \r
   Dimension calculateIdWidth()\r
   {\r
-    Frame frame = new Frame();\r
-    frame.addNotify();\r
-    Graphics g = frame.getGraphics();\r
-    if (g == null)\r
+    if (av.nullFrame == null)\r
     {\r
-      Frame f = new Frame();\r
-      f.addNotify();\r
-      g = f.getGraphics();\r
+      av.nullFrame = new Frame();\r
+      av.nullFrame.addNotify();\r
     }\r
 \r
+    Graphics g = av.nullFrame.getGraphics();\r
+\r
     FontMetrics fm = g.getFontMetrics(av.font);\r
     AlignmentI al = av.getAlignment();\r
 \r
@@ -171,7 +170,7 @@ annotationPanel.image = null;
     i = 0;\r
     if (al.getAlignmentAnnotation() != null)\r
     {\r
-      fm = g.getFontMetrics(frame.getFont());\r
+      fm = g.getFontMetrics(av.nullFrame.getFont());\r
       while (i < al.getAlignmentAnnotation().length)\r
       {\r
         String label = al.getAlignmentAnnotation()[i].label;\r
@@ -253,7 +252,7 @@ annotationPanel.image = null;
     if (!av.wrapAlignment)\r
     {\r
       annotationSpaceFillerHolder.setVisible(b);\r
-      annotationScroller.setVisible(b);\r
+      annotationPanel.setVisible(b);\r
     }\r
     validate();\r
     repaint();\r
@@ -270,12 +269,12 @@ annotationPanel.image = null;
 \r
     if (wrap)\r
     {\r
-      annotationScroller.setVisible(false);\r
+      annotationPanel.setVisible(false);\r
       annotationSpaceFillerHolder.setVisible(false);\r
     }\r
     else if (av.showAnnotation)\r
     {\r
-      annotationScroller.setVisible(true);\r
+      annotationPanel.setVisible(true);\r
       annotationSpaceFillerHolder.setVisible(true);\r
     }\r
 \r
@@ -522,7 +521,6 @@ annotationPanel.image = null;
   BorderLayout borderLayout10 = new BorderLayout();\r
   protected Panel hscrollFillerPanel = new Panel();\r
   BorderLayout borderLayout11 = new BorderLayout();\r
-  public Panel annotationScroller = new Panel();\r
   BorderLayout borderLayout4 = new BorderLayout();\r
   BorderLayout borderLayout2 = new BorderLayout();\r
 \r
@@ -557,11 +555,9 @@ annotationPanel.image = null;
       //  this.setPreferredSize(new Dimension(220, 166));\r
       seqPanelHolder.setBackground(Color.white);\r
       idPanelHolder.setBackground(Color.white);\r
-      annotationScroller.setLayout(borderLayout2);\r
       sequenceHolderPanel.add(scalePanelHolder, BorderLayout.NORTH);\r
       sequenceHolderPanel.add(seqPanelHolder, BorderLayout.CENTER);\r
       seqPanelHolder.add(vscroll, BorderLayout.EAST);\r
-      sequenceHolderPanel.add(annotationScroller, BorderLayout.SOUTH);\r
 \r
       //  Panel3.add(secondaryPanelHolder,  BorderLayout.SOUTH);\r
       this.add(idPanelHolder, BorderLayout.WEST);\r