moved painting routine
authoramwaterhouse <Andrew Waterhouse>
Tue, 30 Jan 2007 15:11:09 +0000 (15:11 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 30 Jan 2007 15:11:09 +0000 (15:11 +0000)
src/jalview/gui/WebserviceInfo.java

index b7d54d6..4b4e885 100755 (executable)
@@ -401,7 +401,6 @@ public class WebserviceInfo extends GWebserviceInfo
         public void run()
         {
             startTime = System.currentTimeMillis();
-            Graphics2D g = null;
 
             while (currentStatus < STATE_STOPPED_OK)
             {
@@ -415,80 +414,84 @@ public class WebserviceInfo extends GWebserviceInfo
                     angle %= 360;
                     startTime = System.currentTimeMillis();
 
-                    if (offscreen == null || offscreen.getWidth(this) != getWidth()
-                        || offscreen.getHeight(this) != getHeight())
-                    {
-                      offscreen = new BufferedImage(getWidth(), getHeight(),
-                                                    BufferedImage.TYPE_INT_ARGB);
-                      g = (Graphics2D) offscreen.getGraphics();
-                    }
-
-                    g.setColor(Color.white);
-                    g.fillRect(0, 0, getWidth(), getHeight());
+                    if (currentStatus >= STATE_STOPPED_OK)
+                      angle = 0;
 
-                    g.setFont(new Font("Arial", Font.BOLD, 12));
-                    g.setColor(Color.black);
+                    repaint();
+                }
+                catch (Exception ex)
+                {
+                }
+            }
 
-                    switch (currentStatus)
-                    {
-                      case STATE_QUEUING:
-                        g.drawString(title.concat(" - queuing"), 60, 30);
+            cancel.setEnabled(false);
+        }
 
-                        break;
+        void drawPanel()
+        {
+          if (offscreen == null || offscreen.getWidth(this) != getWidth()
+              || offscreen.getHeight(this) != getHeight())
+          {
+            offscreen = new BufferedImage(getWidth(), getHeight(),
+                                          BufferedImage.TYPE_INT_ARGB);
+         }
 
-                      case STATE_RUNNING:
-                        g.drawString(title.concat(" - running"), 60, 30);
+          Graphics2D g = (Graphics2D)offscreen.getGraphics();
 
-                        break;
+          g.setColor(Color.white);
+          g.fillRect(0, 0, getWidth(), getHeight());
 
-                      case STATE_STOPPED_OK:
-                        g.drawString(title.concat(" - complete"), 60, 30);
+          g.setFont(new Font("Arial", Font.BOLD, 12));
+          g.setColor(Color.black);
 
-                        break;
+          switch (currentStatus)
+          {
+            case STATE_QUEUING:
+              g.drawString(title.concat(" - queuing"), 60, 30);
 
-                      case STATE_CANCELLED_OK:
-                        g.drawString(title.concat(" - job cancelled!"), 60, 30);
+              break;
 
-                        break;
+            case STATE_RUNNING:
+              g.drawString(title.concat(" - running"), 60, 30);
 
-                      case STATE_STOPPED_ERROR:
-                        g.drawString(title.concat(" - job error!"), 60, 30);
+              break;
 
-                        break;
+            case STATE_STOPPED_OK:
+              g.drawString(title.concat(" - complete"), 60, 30);
 
-                      case STATE_STOPPED_SERVERERROR:
-                        g.drawString(title.concat(" - Server Error! (try later)"),
-                                     60,
-                                     30);
+              break;
 
-                        break;
-                    }
+            case STATE_CANCELLED_OK:
+              g.drawString(title.concat(" - job cancelled!"), 60, 30);
 
+              break;
 
-                    if (currentStatus >= STATE_STOPPED_OK)
-                      angle = 0;
+            case STATE_STOPPED_ERROR:
+              g.drawString(title.concat(" - job error!"), 60, 30);
 
-                    if (image != null)
-                    {
-                      g.rotate(Math.toRadians(angle), 28, 28);
-                      g.drawImage(image, 10, 10, this);
-                      g.rotate( -Math.toRadians(angle), 28, 28);
-                    }
+              break;
 
+            case STATE_STOPPED_SERVERERROR:
+              g.drawString(title.concat(" - Server Error! (try later)"),
+                           60,
+                           30);
 
-                    repaint();
-                }
-                catch (Exception ex)
-                {
-                }
-            }
+              break;
+          }
 
-            cancel.setEnabled(false);
+          if (image != null)
+          {
+            g.rotate(Math.toRadians(angle), 28, 28);
+            g.drawImage(image, 10, 10, this);
+            g.rotate( -Math.toRadians(angle), 28, 28);
+          }
         }
 
         public void paintComponent(Graphics g1)
         {
-            g1.drawImage(offscreen, 0,0,this);
+          drawPanel();
+
+          g1.drawImage(offscreen, 0,0,this);
         }
     }
 }