From: Ben Soares Date: Mon, 1 Jul 2019 11:27:01 +0000 (+0100) Subject: JAL-3333 using floats for smoother weighting X-Git-Tag: Release_2_11_0~2^2~19 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=441f6e97f601ab3b0ee1dbfa62e9a6fbb2fe3c3a;p=jalview.git JAL-3333 using floats for smoother weighting --- 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); } }