Image image;
- int angle = 0;
+ float angle = 0f;
String title = "";
{
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();
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)
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);
}
}