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.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javafx.animation.RotateTransition;
import javafx.animation.Timeline; import javafx.animation.Timeline;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.beans.property.ReadOnlyBooleanProperty; import javafx.beans.property.ReadOnlyBooleanProperty;
@@ -47,6 +48,7 @@ import javafx.scene.shape.Polyline;
import javafx.scene.text.Text; import javafx.scene.text.Text;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.stage.StageStyle; import javafx.stage.StageStyle;
import javafx.util.Duration;
import seng302.model.ClientYacht; import seng302.model.ClientYacht;
import seng302.model.RaceState; import seng302.model.RaceState;
import seng302.model.mark.CompoundMark; 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 * Updates the wind direction arrow and text as from info from the StreamParser
* @param direction the from north angle of the wind. * @param direction the from north angle of the wind.
*/ */
private double preDir = 0;
private void updateWindDirection(double direction) { private void updateWindDirection(double direction) {
windDirectionLabel.setText(String.format("%.1f°", 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);
} }
/** /**
Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 27 KiB

+11 -10
View File
@@ -1,16 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?> <?import java.net.URL?>
<?import javafx.scene.text.*?> <?import javafx.geometry.Insets?>
<?import javafx.scene.image.*?> <?import javafx.scene.image.Image?>
<?import java.lang.*?> <?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.StackPane?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<StackPane id="background" fx:id="rootPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.SplashScreenController"> <StackPane id="background" fx:id="rootPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.SplashScreenController">
<stylesheets>
<String fx:value="/css/Master.css" />
<String fx:value="/css/SplashScreenView.css" />
</stylesheets>
<children> <children>
<ImageView fitHeight="296.0" fitWidth="295.0" pickOnBounds="true" preserveRatio="true" StackPane.alignment="TOP_CENTER"> <ImageView fitHeight="296.0" fitWidth="295.0" pickOnBounds="true" preserveRatio="true" StackPane.alignment="TOP_CENTER">
<image> <image>
@@ -29,4 +26,8 @@
</StackPane.margin> </StackPane.margin>
</Text> </Text>
</children> </children>
<stylesheets>
<URL value="@../css/Master.css"/>
<URL value="@../css/SplashScreenView.css"/>
</stylesheets>
</StackPane> </StackPane>