Reimplemented wind. Wind arrow will rotate based on wind direction. Added labels for wind direction and wind speed.

#story[1245]
This commit is contained in:
Zhi You Tan
2017-09-12 16:52:44 +12:00
parent ec7ee34305
commit b25c3367a9
3 changed files with 60 additions and 69 deletions
@@ -735,4 +735,8 @@ public class GameView3D {
// });
// playerYacht.addMarkRoundingListener(this::updateMarkArrows);
}
public void setWindDir(double windDir) {
this.windDir = windDir;
}
}
@@ -88,8 +88,6 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
@FXML
private AnchorPane rvAnchorPane;
@FXML
private Text windDirectionText;
@FXML
private AnchorPane windArrowHolder;
@FXML
private Slider annotationSlider;
@@ -100,9 +98,11 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
@FXML
private Text fpsDisplay;
@FXML
private Text windSpeedText;
@FXML
private ImageView windImageView;
@FXML
private Label windDirectionLabel;
@FXML
private Label windSpeedLabel;
//Race Data
private Map<Integer, ClientYacht> participants;
@@ -216,12 +216,12 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
// raceState.addCollisionListener(gameView::drawCollision);
raceState.windDirectionProperty().addListener((obs, oldDirection, newDirection) -> {
// gameView.setWindDir(newDirection.doubleValue());
gameView.setWindDir(newDirection.doubleValue());
Platform.runLater(() -> updateWindDirection(newDirection.doubleValue()));
});
// raceState.windSpeedProperty().addListener((obs, oldSpeed, newSpeed) ->
// Platform.runLater(() -> updateWindSpeed(newSpeed.doubleValue()))
// );
raceState.windSpeedProperty().addListener((obs, oldSpeed, newSpeed) ->
Platform.runLater(() -> updateWindSpeed(newSpeed.doubleValue()))
);
Platform.runLater(() -> {
updateWindDirection(raceState.windDirectionProperty().doubleValue());
updateWindSpeed(raceState.getWindSpeed());
@@ -473,8 +473,8 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
* @param direction the from north angle of the wind.
*/
private void updateWindDirection(double direction) {
// windDirectionText.setText(String.format("%.1f°", direction));
// windArrowText.setRotate(direction);
windDirectionLabel.setText(String.format("%.1f°", direction));
windImageView.setRotate(direction);
}
/**
@@ -482,7 +482,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
* @param windSpeed Windspeed in knots.
*/
private void updateWindSpeed(double windSpeed) {
// windSpeedText.setText("Speed: " + String.format("%.1f", windSpeed) + " Knots");
windSpeedLabel.setText(String.format("%.1f", windSpeed) + " Knots");
}
+45 -58
View File
@@ -14,38 +14,28 @@
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.text.Font?>
<AnchorPane fx:id="rvAnchorPane" maxHeight="1.7976931348623157E308"
maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0"
prefWidth="1200.0" style="-fx-background-color: skyblue;" xmlns="http://javafx.com/javafx/8"
xmlns:fx="http://javafx.com/fxml/1"
fx:controller="seng302.visualiser.controllers.RaceViewController">
<AnchorPane fx:id="rvAnchorPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1200.0" style="-fx-background-color: skyblue;" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.RaceViewController">
<children>
<StackPane fx:id="contentAnchorPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="800.0" prefWidth="1200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
</StackPane>
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308"
prefHeight="800.0" prefWidth="1200.0" AnchorPane.bottomAnchor="0.0"
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="800.0" prefWidth="1200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="250.0" minWidth="250.0"
prefWidth="250.0"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="400.0"
prefWidth="400.0"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="250.0" minWidth="250.0" prefWidth="250.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="400.0" prefWidth="400.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="70.0" minHeight="70.0" prefHeight="70.0" vgrow="SOMETIMES"/>
<RowConstraints maxHeight="1.7976931348623157E308" vgrow="SOMETIMES"/>
<RowConstraints maxHeight="200.0" minHeight="200.0" prefHeight="200.0"
vgrow="SOMETIMES"/>
<RowConstraints maxHeight="70.0" minHeight="70.0" prefHeight="70.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="1.7976931348623157E308" vgrow="SOMETIMES" />
<RowConstraints maxHeight="200.0" minHeight="200.0" prefHeight="200.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<GridPane id="timerGrid" fx:id="timerGrid" prefWidth="192.0" styleClass=".timer">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="50.0" minWidth="50.0"
prefWidth="50.0"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="130.0" minWidth="130.0"
prefWidth="130.0"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="50.0" minWidth="50.0" prefWidth="50.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="130.0" minWidth="130.0" prefWidth="130.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
@@ -86,70 +76,67 @@
</GridPane>
<GridPane fx:id="chatGridPane" GridPane.columnIndex="2" GridPane.rowIndex="2">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308"
minWidth="300.0" prefWidth="300.0"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="100.0"
prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="300.0" prefWidth="300.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="100.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="1.7976931348623157E308" vgrow="SOMETIMES"/>
<RowConstraints maxHeight="50.0" minHeight="50.0" prefHeight="50.0"
vgrow="SOMETIMES"/>
<RowConstraints maxHeight="1.7976931348623157E308" vgrow="SOMETIMES" />
<RowConstraints maxHeight="50.0" minHeight="50.0" prefHeight="50.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Pane fx:id="chatHistoryHolder" prefHeight="200.0" prefWidth="200.0"
GridPane.columnSpan="2" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS">
<Pane fx:id="chatHistoryHolder" prefHeight="200.0" prefWidth="200.0" GridPane.columnSpan="2" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS">
<GridPane.margin>
<Insets/>
<Insets />
</GridPane.margin>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</Pane>
<JFXButton fx:id="chatSend" alignment="CENTER" buttonType="RAISED"
maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity"
minWidth="-Infinity" prefHeight="40.0" text="SEND" GridPane.columnIndex="1"
GridPane.halignment="CENTER" GridPane.rowIndex="1"
GridPane.valignment="CENTER">
<JFXButton fx:id="chatSend" alignment="CENTER" buttonType="RAISED" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="40.0" text="SEND" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER">
<GridPane.margin>
<Insets left="10.0" right="10.0"/>
<Insets left="10.0" right="10.0" />
</GridPane.margin>
</JFXButton>
<JFXTextField fx:id="chatInput" maxHeight="35.0" minHeight="-Infinity"
prefHeight="35.0" GridPane.rowIndex="1">
<JFXTextField fx:id="chatInput" maxHeight="35.0" minHeight="-Infinity" prefHeight="35.0" GridPane.rowIndex="1">
<GridPane.margin>
<Insets left="10.0"/>
<Insets left="10.0" />
</GridPane.margin>
</JFXTextField>
</children>
</GridPane>
<GridPane GridPane.halignment="CENTER" GridPane.rowIndex="2"
GridPane.valignment="BOTTOM">
<GridPane GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="BOTTOM">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="110.0" minWidth="110.0" prefWidth="110.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="132.0" minWidth="10.0" prefWidth="132.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="100.0" minHeight="100.0" prefHeight="100.0"
vgrow="SOMETIMES"/>
<RowConstraints maxHeight="100.0" minHeight="100.0" prefHeight="100.0"
vgrow="SOMETIMES"/>
<RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.0"
vgrow="SOMETIMES"/>
<RowConstraints maxHeight="100.0" minHeight="100.0" prefHeight="100.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="90.0" minHeight="90.0" prefHeight="90.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<ImageView fx:id="windImageView" fitHeight="92.0" fitWidth="109.0"
pickOnBounds="true" preserveRatio="true" GridPane.halignment="CENTER"
GridPane.rowIndex="1" GridPane.valignment="CENTER"/>
<Label fx:id="windLabel" text="112d 11.5knot" GridPane.halignment="CENTER"
GridPane.rowIndex="2" GridPane.valignment="CENTER"/>
<ImageView fx:id="windImageView" fitHeight="92.0" fitWidth="109.0" pickOnBounds="true" preserveRatio="true" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER" />
<Label fx:id="windDirectionLabel" text="180.0°" GridPane.halignment="LEFT" GridPane.rowIndex="2" GridPane.valignment="CENTER">
<GridPane.margin>
<Insets left="5.0" />
</GridPane.margin></Label>
<Label fx:id="windSpeedLabel" text="0.0 Knots" GridPane.halignment="RIGHT" GridPane.rowIndex="2" GridPane.valignment="CENTER">
<GridPane.margin>
<Insets right="5.0" />
</GridPane.margin></Label>
</children>
<opaqueInsets>
<Insets />
</opaqueInsets>
<GridPane.margin>
<Insets bottom="10.0" left="10.0" />
</GridPane.margin>
</GridPane>
</children>
</GridPane>
</children>
<stylesheets>
<String fx:value="/css/Master.css"/>
<String fx:value="/css/RaceView.css"/>
<String fx:value="/css/Master.css" />
<String fx:value="/css/RaceView.css" />
</stylesheets>
</AnchorPane>