add swing runnable to refresh panel on startup
authoramwaterhouse <Andrew Waterhouse>
Tue, 22 Mar 2005 12:17:56 +0000 (12:17 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 22 Mar 2005 12:17:56 +0000 (12:17 +0000)
src/jalview/gui/AlignmentPanel.java

index ac0862e..95a8e7c 100755 (executable)
@@ -52,7 +52,22 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
     scalePanelHolder.add(scalePanel, BorderLayout.CENTER);\r
     scorePanelHolder.add(scorePanel, BorderLayout.CENTER);\r
     seqPanelHolder.add(seqPanel, BorderLayout.CENTER);\r
-    setScrollValues(0,0);\r
+\r
+\r
+    if(seqPanel.seqCanvas.getWidth()==0)\r
+    javax.swing.SwingUtilities.invokeLater(new Runnable()\r
+     {\r
+       public void run()\r
+       {\r
+         setScrollValues(0,0);\r
+         Dimension d = calculateIdWidth();\r
+         d.setSize( d.width+4, d.height);\r
+         idPanel.idCanvas.setPreferredSize( d );\r
+         hscrollFillerPanel.setPreferredSize( d );\r
+         RefreshPanels();\r
+       }\r
+    });\r
+\r
 \r
     hscroll.addAdjustmentListener(this);\r
     vscroll.addAdjustmentListener(this);\r
@@ -61,16 +76,11 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
    {\r
      public void componentResized(ComponentEvent evt)\r
      {\r
-       if(seqPanel.getWidth()>0 && seqPanel.getHeight()>0)\r
           RefreshPanels();\r
      }\r
    });\r
 \r
-\r
-  // hscroll.setFocusable(false);\r
-  // vscroll.setFocusable(false);\r
    setFocusable(true);\r
-\r
    addKeyListener(new KeyAdapter()\r
    {\r
      public void keyPressed(KeyEvent evt)\r
@@ -224,6 +234,7 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
 \r
   public void RefreshPanels()\r
   {\r
+\r
               requestFocus();\r
               invalidate();\r
               idPanelHolder.setPreferredSize(idPanel.idCanvas.getPreferredSize());\r
@@ -244,12 +255,12 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
               }\r
               else\r
 \r
-                setScrollValues(av.getStartRes(), av.getStartSeq());\r
               av.getConsensus(true);\r
               if (overviewPanel != null)\r
                 overviewPanel.updateOverviewImage();\r
 \r
           validate();\r
+          setScrollValues(av.getStartRes(), av.getStartSeq());\r
           repaint();\r
   }\r
   int hextent = 0;\r
@@ -296,8 +307,13 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
 \r
   public void setScrollValues(int x, int y)\r
   {\r
-    hextent = seqPanel.seqCanvas.getWidth()/av.getCharWidth();\r
-    vextent = seqPanel.seqCanvas.getHeight()/av.getCharHeight();\r
+    hextent = seqPanel.seqCanvas.getWidth()/av.charWidth;\r
+    vextent = seqPanel.seqCanvas.getHeight()/av.charHeight;\r
+\r
+    if(hextent > av.alignment.getWidth())\r
+      hextent = av.alignment.getWidth();\r
+    if(vextent > av.alignment.getHeight())\r
+      vextent = av.alignment.getHeight();\r
 \r
     if(hextent+x  >  av.getAlignment().getWidth())\r
       x =  av.getAlignment().getWidth()- hextent;\r
@@ -314,7 +330,6 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
     hscroll.setValues(x,hextent,0,av.getAlignment().getWidth());\r
     vscroll.setValues(y,vextent,0,av.getAlignment().getHeight() );\r
 \r
-\r
     repaint();\r
 \r
   }\r