JAL-3333 Title text now appears instantly. Altering speed of rotating logo depending...
[jalview.git] / src / jalview / gui / WebserviceInfo.java
index d6ca836..2b85141 100644 (file)
@@ -32,6 +32,7 @@ import java.awt.Graphics2D;
 import java.awt.GridLayout;
 import java.awt.Image;
 import java.awt.MediaTracker;
+import java.awt.RenderingHints;
 import java.awt.event.ActionEvent;
 import java.awt.image.BufferedImage;
 import java.util.Vector;
@@ -328,7 +329,7 @@ public class WebserviceInfo extends GWebserviceInfo
     setInfoText(info);
 
     java.net.URL url = getClass()
-            .getResource("/images/Jalview_Logo_small.png");
+            .getResource("/images/Jalview_Logo_small_with_border.png");
     image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
 
     MediaTracker mt = new MediaTracker(this);
@@ -345,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();
@@ -791,24 +793,34 @@ protected void cancel_actionPerformed(ActionEvent e)
     BufferedImage offscreen;
 
     @Override
-       public void run()
+    public void run()
     {
       startTime = System.currentTimeMillis();
 
+      float invSpeed = 30f;
       while (currentStatus < STATE_STOPPED_OK)
       {
+        if (currentStatus == STATE_QUEUING)
+        {
+          invSpeed = 25f;
+        }
+        else if (currentStatus == STATE_RUNNING)
+        {
+          invSpeed = 10f;
+        }
         try
         {
           Thread.sleep(50);
 
           int units = (int) ((System.currentTimeMillis() - startTime)
-                  / 10f);
+                  / invSpeed);
           angle += units;
           angle %= 360;
           startTime = System.currentTimeMillis();
 
           if (currentStatus >= STATE_STOPPED_OK)
           {
+            park();
             angle = 0;
           }
 
@@ -821,26 +833,61 @@ protected void cancel_actionPerformed(ActionEvent e)
       cancel.setEnabled(false);
     }
 
+    public void park()
+    {
+      startTime = System.currentTimeMillis();
+
+      while (angle < 360)
+      {
+        try
+        {
+          Thread.sleep(25);
+
+          int units = (int) ((System.currentTimeMillis() - startTime)
+                  / 5f);
+          angle += units;
+          startTime = System.currentTimeMillis();
+
+          if (angle >= 360)
+          {
+            angle = 360;
+          }
+
+          repaint();
+        } catch (Exception ex)
+        {
+        }
+      }
+
+    }
+
     void drawPanel()
     {
       if (offscreen == null || offscreen.getWidth(this) != getWidth()
               || offscreen.getHeight(this) != getHeight())
       {
         offscreen = new BufferedImage(getWidth(), getHeight(),
-                BufferedImage.TYPE_INT_ARGB);
+                BufferedImage.TYPE_INT_RGB);
       }
 
       Graphics2D g = (Graphics2D) offscreen.getGraphics();
 
+      g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+              RenderingHints.VALUE_ANTIALIAS_ON);
+      g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
+              RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+      g.setRenderingHint(RenderingHints.KEY_RENDERING,
+              RenderingHints.VALUE_RENDER_QUALITY);
+
       g.setColor(Color.white);
       g.fillRect(0, 0, getWidth(), getHeight());
 
       if (image != null)
       {
         int x = image.getWidth(this) / 2, y = image.getHeight(this) / 2;
-        g.rotate(Math.toRadians(angle), 10 + x, 10 + y);
-        g.drawImage(image, 10, 10, this);
-        g.rotate(-Math.toRadians(angle), 10 + x, 10 + y);
+        g.rotate(Math.toRadians(angle), x, y);
+        g.drawImage(image, 0, 0, this);
+        g.rotate(-Math.toRadians(angle), x, y);
       }
     }