JAL-3333 Smooth rotation of image now too
authorBen Soares <bsoares@dundee.ac.uk>
Fri, 28 Jun 2019 14:54:01 +0000 (15:54 +0100)
committerBen Soares <bsoares@dundee.ac.uk>
Fri, 28 Jun 2019 14:54:01 +0000 (15:54 +0100)
resources/images/Jalview_Logo_small_with_border.png [new file with mode: 0644]
src/jalview/gui/WebserviceInfo.java

diff --git a/resources/images/Jalview_Logo_small_with_border.png b/resources/images/Jalview_Logo_small_with_border.png
new file mode 100644 (file)
index 0000000..b91e2bb
Binary files /dev/null and b/resources/images/Jalview_Logo_small_with_border.png differ
index d6ca836..f97f808 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);
@@ -832,15 +833,22 @@ protected void cancel_actionPerformed(ActionEvent e)
 
       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);
       }
     }