Merge branch 'documentation/JAL-3111_release_211' into develop
[jalview.git] / src / jalview / gui / WebserviceInfo.java
index 801e3da..8158718 100644 (file)
@@ -82,7 +82,7 @@ public class WebserviceInfo extends GWebserviceInfo
 
   Image image;
 
-  int angle = 0;
+  float angle = 0f;
 
   String title = "";
 
@@ -346,6 +346,7 @@ public class WebserviceInfo extends GWebserviceInfo
     ap.setPreferredSize(new Dimension(60, 60));
     titlePanel.add(ap, BorderLayout.WEST);
     titlePanel.add(titleText, BorderLayout.CENTER);
+    setStatus(currentStatus);
 
     Thread thread = new Thread(ap);
     thread.start();
@@ -792,24 +793,37 @@ protected void cancel_actionPerformed(ActionEvent e)
     BufferedImage offscreen;
 
     @Override
-       public void run()
+    public void run()
     {
       startTime = System.currentTimeMillis();
 
+      float invSpeed = 15f;
+      float factor = 1f;
       while (currentStatus < STATE_STOPPED_OK)
       {
+        if (currentStatus == STATE_QUEUING)
+        {
+          invSpeed = 25f;
+          factor = 1f;
+        }
+        else if (currentStatus == STATE_RUNNING)
+        {
+          invSpeed = 10f;
+          factor = (float) (0.5 + 1.5
+                  * (0.5 - (0.5 * Math.sin(3.14159 / 180 * (angle + 45)))));
+        }
         try
         {
           Thread.sleep(50);
 
-          int units = (int) ((System.currentTimeMillis() - startTime)
-                  / 10f);
-          angle += units;
+          float delta = (System.currentTimeMillis() - startTime) / invSpeed;
+          angle += delta * factor;
           angle %= 360;
           startTime = System.currentTimeMillis();
 
           if (currentStatus >= STATE_STOPPED_OK)
           {
+            park();
             angle = 0;
           }
 
@@ -822,6 +836,35 @@ protected void cancel_actionPerformed(ActionEvent e)
       cancel.setEnabled(false);
     }
 
+    public void park()
+    {
+      startTime = System.currentTimeMillis();
+
+      while (angle < 360)
+      {
+        float invSpeed = 5f;
+        float factor = 1f;
+        try
+        {
+          Thread.sleep(25);
+
+          float delta = (System.currentTimeMillis() - startTime) / invSpeed;
+          angle += delta * factor;
+          startTime = System.currentTimeMillis();
+
+          if (angle >= 360)
+          {
+            angle = 360;
+          }
+
+          repaint();
+        } catch (Exception ex)
+        {
+        }
+      }
+
+    }
+
     void drawPanel()
     {
       if (offscreen == null || offscreen.getWidth(this) != getWidth()
@@ -846,9 +889,9 @@ protected void cancel_actionPerformed(ActionEvent e)
       if (image != null)
       {
         int x = image.getWidth(this) / 2, y = image.getHeight(this) / 2;
-        g.rotate(Math.toRadians(angle), x, y);
+        g.rotate(3.14159 / 180 * (angle), x, y);
         g.drawImage(image, 0, 0, this);
-        g.rotate(-Math.toRadians(angle), x, y);
+        g.rotate(-3.14159 / 180 * (angle), x, y);
       }
     }