Merge branch 'master' of /home/cosc/student/zyt10/Documents/[SENG302]/team-13 with conflicts.

This commit is contained in:
Zhi You Tan
2017-03-27 16:52:31 +13:00
parent b50ac62a4b
commit 48f7e41905
2 changed files with 82 additions and 49 deletions
@@ -7,6 +7,7 @@ import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.geometry.NodeOrientation;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.control.CheckBox;
@@ -34,8 +35,6 @@ import java.util.*;
* Modified by Haoming Yin (hyi25) on 20/3/2017.
*/
public class CanvasController {
@FXML
private Canvas canvas;
@FXML
private AnchorPane contentAnchorPane;
@FXML
@@ -47,13 +46,15 @@ public class CanvasController {
@FXML
private CheckBox toggleAnnotation, toggleFps;
private ResizableCanvas canvas;
private Race race;
private GraphicsContext gc;
private HashMap<Boat, TimelineInfo> timelineInfos;
private AnchorPane raceResults;
private final double ORIGIN_LAT = 32.320504;
private final double ORIGIN_LAT = 32.321504;
private final double ORIGIN_LON = -64.857063;
private Animation.Status raceStatus = Animation.Status.PAUSED;
@@ -70,6 +71,15 @@ public class CanvasController {
* Initialize the controller
*/
public void initialize() {
canvas = new ResizableCanvas();
contentAnchorPane.getChildren().add(canvas);
// Bind canvas size to stack pane size.
canvas.widthProperty().bind(
contentAnchorPane.widthProperty());
canvas.heightProperty().bind(
contentAnchorPane.heightProperty());
gc = canvas.getGraphicsContext2D();
RaceController raceController = new RaceController();
raceController.initializeRace();
@@ -163,6 +173,38 @@ public class CanvasController {
windArrowText.setRotate(windDirection);
}
class ResizableCanvas extends Canvas {
public ResizableCanvas() {
// Redraw canvas when size changes.
widthProperty().addListener(evt -> draw());
heightProperty().addListener(evt -> draw());
}
private void draw() {
double width = getWidth();
double height = getHeight();
GraphicsContext gc = getGraphicsContext2D();
gc.clearRect(0, 0, width, height);
}
@Override
public boolean isResizable() {
return true;
}
@Override
public double prefWidth(double height) {
return getWidth();
}
@Override
public double prefHeight(double width) {
return getHeight();
}
}
/**
* Display the list of boats in the order they finished the race
*/
+7 -16
View File
@@ -9,15 +9,13 @@
<?import javafx.scene.canvas.Canvas?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane prefHeight="960.0" prefWidth="1280.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.controllers.CanvasController">
<children>
<GridPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<GridPane prefHeight="960.0" prefWidth="1280.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.controllers.CanvasController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="632.0" minWidth="10.0" prefWidth="246.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1056.0" minWidth="10.0" prefWidth="1034.0" />
<ColumnConstraints maxWidth="246.0" minWidth="246.0" prefWidth="246.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="1034.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="500.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints />
<RowConstraints />
</rowConstraints>
@@ -25,7 +23,7 @@
<AnchorPane prefHeight="200.0" prefWidth="200.0" GridPane.rowSpan="3">
<children>
<Label layoutX="11.0" layoutY="259.0" text="Team Position" />
<Label layoutX="13.0" layoutY="432.0" text="Settings" />
<Label layoutX="13.0" layoutY="432.0" text="Annotation toggle" />
<Label layoutX="11.0" layoutY="14.0" text="Timer" />
<Label layoutX="11.0" layoutY="88.0" text="Wind direction" />
<Circle fx:id="windBackgroundCircle" blendMode="DARKEN" fill="#76baf8" layoutX="110.0" layoutY="166.0" radius="35.0" stroke="#686868" strokeType="INSIDE" strokeWidth="3.0" />
@@ -45,16 +43,9 @@
<fx:include fx:id="teamPositions" source="TeamPositions.fxml" />
</children>
</AnchorPane>
<CheckBox fx:id="toggleAnnotation" layoutX="27.0" layoutY="462.0" mnemonicParsing="false" selected="true" text="Show annotations" />
<CheckBox fx:id="toggleFps" layoutX="27.0" layoutY="488.0" mnemonicParsing="false" prefHeight="18.0" prefWidth="143.0" selected="true" text="Show FPS" />
</children>
</AnchorPane>
<AnchorPane fx:id="contentAnchorPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="960.0" prefWidth="1280.0" GridPane.columnIndex="1" GridPane.rowSpan="3">
<children>
<Canvas fx:id="canvas" height="960.0" width="1056.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
<CheckBox fx:id="toggleAnnotation" layoutX="27.0" layoutY="462.0" mnemonicParsing="false" selected="true" text="Show annotation" />
</children>
</AnchorPane>
<AnchorPane fx:id="contentAnchorPane" nodeOrientation="LEFT_TO_RIGHT" prefHeight="960.0" prefWidth="1280.0" GridPane.columnIndex="1" GridPane.rowSpan="3" />
</children>
</GridPane>
</children>
</AnchorPane>