From 441f6e97f601ab3b0ee1dbfa62e9a6fbb2fe3c3a Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Mon, 1 Jul 2019 12:27:01 +0100 Subject: [PATCH] JAL-3333 using floats for smoother weighting --- src/jalview/gui/WebserviceInfo.java | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/jalview/gui/WebserviceInfo.java b/src/jalview/gui/WebserviceInfo.java index 0a46600..5240eea 100644 --- a/src/jalview/gui/WebserviceInfo.java +++ b/src/jalview/gui/WebserviceInfo.java @@ -82,7 +82,7 @@ public class WebserviceInfo extends GWebserviceInfo Image image; - int angle = 0; + float angle = 0f; String title = ""; @@ -797,27 +797,27 @@ protected void cancel_actionPerformed(ActionEvent e) { startTime = System.currentTimeMillis(); - float invSpeed = 30f; + 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) - / invSpeed); - double factor = 0.5 - + 1.5 * (0.5 - - (0.5 * Math.sin(Math.toRadians(angle + 45)))); - angle += units * factor; + float delta = (System.currentTimeMillis() - startTime) / invSpeed; + angle += delta * factor; angle %= 360; startTime = System.currentTimeMillis(); @@ -842,13 +842,16 @@ protected void cancel_actionPerformed(ActionEvent e) while (angle < 360) { + float invSpeed = 5f; + float factor = 1f; try { Thread.sleep(25); int units = (int) ((System.currentTimeMillis() - startTime) / 5f); - angle += units; + float delta = (System.currentTimeMillis() - startTime) / invSpeed; + angle += delta * factor; startTime = System.currentTimeMillis(); if (angle >= 360) @@ -888,9 +891,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); } } -- 1.7.10.2