Fix: smoothing wind rotation

- added animation for wind rotation
- enlarged wind image's background to centre the compass

#story[1273]
This commit is contained in:
Haoming Yin
2017-09-27 22:45:56 +13:00
parent 22e1e57c24
commit 287cfd77d0
3 changed files with 21 additions and 11 deletions
@@ -9,6 +9,7 @@ import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;
import javafx.animation.RotateTransition;
import javafx.animation.Timeline;
import javafx.application.Platform;
import javafx.beans.property.ReadOnlyBooleanProperty;
@@ -47,6 +48,7 @@ import javafx.scene.shape.Polyline;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.util.Duration;
import seng302.model.ClientYacht;
import seng302.model.RaceState;
import seng302.model.mark.CompoundMark;
@@ -608,9 +610,16 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
* Updates the wind direction arrow and text as from info from the StreamParser
* @param direction the from north angle of the wind.
*/
private double preDir = 0;
private void updateWindDirection(double direction) {
windDirectionLabel.setText(String.format("%.1f°", direction));
windImageView.setRotate(direction);
RotateTransition rt = new RotateTransition(Duration.millis(300), windImageView);
rt.setByAngle(direction - preDir);
rt.setCycleCount(5);
rt.setAutoReverse(true);
rt.play();
preDir = direction;
// windImageView.setRotate(direction);
}
/**