mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Merge branch 'master' of /home/cosc/student/zyt10/Documents/[SENG302]/team-13 with conflicts.
This commit is contained in:
@@ -7,6 +7,7 @@ import javafx.beans.value.ChangeListener;
|
|||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.geometry.NodeOrientation;
|
||||||
import javafx.scene.canvas.Canvas;
|
import javafx.scene.canvas.Canvas;
|
||||||
import javafx.scene.canvas.GraphicsContext;
|
import javafx.scene.canvas.GraphicsContext;
|
||||||
import javafx.scene.control.CheckBox;
|
import javafx.scene.control.CheckBox;
|
||||||
@@ -34,8 +35,6 @@ import java.util.*;
|
|||||||
* Modified by Haoming Yin (hyi25) on 20/3/2017.
|
* Modified by Haoming Yin (hyi25) on 20/3/2017.
|
||||||
*/
|
*/
|
||||||
public class CanvasController {
|
public class CanvasController {
|
||||||
@FXML
|
|
||||||
private Canvas canvas;
|
|
||||||
@FXML
|
@FXML
|
||||||
private AnchorPane contentAnchorPane;
|
private AnchorPane contentAnchorPane;
|
||||||
@FXML
|
@FXML
|
||||||
@@ -47,13 +46,15 @@ public class CanvasController {
|
|||||||
@FXML
|
@FXML
|
||||||
private CheckBox toggleAnnotation, toggleFps;
|
private CheckBox toggleAnnotation, toggleFps;
|
||||||
|
|
||||||
|
private ResizableCanvas canvas;
|
||||||
|
|
||||||
private Race race;
|
private Race race;
|
||||||
private GraphicsContext gc;
|
private GraphicsContext gc;
|
||||||
private HashMap<Boat, TimelineInfo> timelineInfos;
|
private HashMap<Boat, TimelineInfo> timelineInfos;
|
||||||
|
|
||||||
private AnchorPane raceResults;
|
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 final double ORIGIN_LON = -64.857063;
|
||||||
|
|
||||||
private Animation.Status raceStatus = Animation.Status.PAUSED;
|
private Animation.Status raceStatus = Animation.Status.PAUSED;
|
||||||
@@ -70,6 +71,15 @@ public class CanvasController {
|
|||||||
* Initialize the controller
|
* Initialize the controller
|
||||||
*/
|
*/
|
||||||
public void initialize() {
|
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();
|
gc = canvas.getGraphicsContext2D();
|
||||||
RaceController raceController = new RaceController();
|
RaceController raceController = new RaceController();
|
||||||
raceController.initializeRace();
|
raceController.initializeRace();
|
||||||
@@ -163,6 +173,38 @@ public class CanvasController {
|
|||||||
windArrowText.setRotate(windDirection);
|
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
|
* Display the list of boats in the order they finished the race
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -9,52 +9,43 @@
|
|||||||
<?import javafx.scene.canvas.Canvas?>
|
<?import javafx.scene.canvas.Canvas?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?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">
|
<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">
|
||||||
<children>
|
<columnConstraints>
|
||||||
<GridPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<ColumnConstraints maxWidth="246.0" minWidth="246.0" prefWidth="246.0" />
|
||||||
<columnConstraints>
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="1034.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="632.0" minWidth="10.0" prefWidth="246.0" />
|
</columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1056.0" minWidth="10.0" prefWidth="1034.0" />
|
<rowConstraints>
|
||||||
</columnConstraints>
|
<RowConstraints minHeight="500.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
<rowConstraints>
|
<RowConstraints />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints />
|
||||||
<RowConstraints />
|
</rowConstraints>
|
||||||
<RowConstraints />
|
<children>
|
||||||
</rowConstraints>
|
<AnchorPane prefHeight="200.0" prefWidth="200.0" GridPane.rowSpan="3">
|
||||||
<children>
|
<children>
|
||||||
<AnchorPane prefHeight="200.0" prefWidth="200.0" GridPane.rowSpan="3">
|
<Label layoutX="11.0" layoutY="259.0" text="Team Position" />
|
||||||
<children>
|
<Label layoutX="13.0" layoutY="432.0" text="Annotation toggle" />
|
||||||
<Label layoutX="11.0" layoutY="259.0" text="Team Position" />
|
<Label layoutX="11.0" layoutY="14.0" text="Timer" />
|
||||||
<Label layoutX="13.0" layoutY="432.0" text="Settings" />
|
<Label layoutX="11.0" layoutY="88.0" text="Wind direction" />
|
||||||
<Label layoutX="11.0" layoutY="14.0" text="Timer" />
|
<Circle fx:id="windBackgroundCircle" blendMode="DARKEN" fill="#76baf8" layoutX="110.0" layoutY="166.0" radius="35.0" stroke="#686868" strokeType="INSIDE" strokeWidth="3.0" />
|
||||||
<Label layoutX="11.0" layoutY="88.0" text="Wind direction" />
|
<Text fx:id="windArrowText" fill="#686868" layoutX="86.0" layoutY="186.0" strokeType="OUTSIDE" strokeWidth="0.0" text="↑">
|
||||||
<Circle fx:id="windBackgroundCircle" blendMode="DARKEN" fill="#76baf8" layoutX="110.0" layoutY="166.0" radius="35.0" stroke="#686868" strokeType="INSIDE" strokeWidth="3.0" />
|
<font>
|
||||||
<Text fx:id="windArrowText" fill="#686868" layoutX="86.0" layoutY="186.0" strokeType="OUTSIDE" strokeWidth="0.0" text="↑">
|
|
||||||
<font>
|
|
||||||
<Font name="AdobeArabic-Regular" size="55.0" />
|
<Font name="AdobeArabic-Regular" size="55.0" />
|
||||||
</font>
|
</font>
|
||||||
</Text>
|
</Text>
|
||||||
<Text fx:id="windDirectionText" fill="#a8a7a7" layoutX="171.0" layoutY="214.0" strokeType="OUTSIDE" strokeWidth="0.0" text="0.0°" textAlignment="RIGHT">
|
<Text fx:id="windDirectionText" fill="#a8a7a7" layoutX="171.0" layoutY="214.0" strokeType="OUTSIDE" strokeWidth="0.0" text="0.0°" textAlignment="RIGHT">
|
||||||
<font>
|
<font>
|
||||||
<Font name="System Bold" size="13.0" />
|
<Font name="System Bold" size="13.0" />
|
||||||
</font>
|
</font>
|
||||||
</Text>
|
</Text>
|
||||||
<Pane fx:id="raceTimer" layoutX="11.0" layoutY="30.0" prefHeight="51.0" prefWidth="193.0" />
|
<Pane fx:id="raceTimer" layoutX="11.0" layoutY="30.0" prefHeight="51.0" prefWidth="193.0" />
|
||||||
<AnchorPane layoutX="12.0" layoutY="280.0" prefHeight="140.0" prefWidth="200.0">
|
<AnchorPane layoutX="12.0" layoutY="280.0" prefHeight="140.0" prefWidth="200.0">
|
||||||
<children>
|
<children>
|
||||||
<fx:include fx:id="teamPositions" source="TeamPositions.fxml" />
|
<fx:include fx:id="teamPositions" source="TeamPositions.fxml" />
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
<CheckBox fx:id="toggleAnnotation" layoutX="27.0" layoutY="462.0" mnemonicParsing="false" selected="true" text="Show annotations" />
|
<CheckBox fx:id="toggleAnnotation" layoutX="27.0" layoutY="462.0" mnemonicParsing="false" selected="true" text="Show annotation" />
|
||||||
<CheckBox fx:id="toggleFps" layoutX="27.0" layoutY="488.0" mnemonicParsing="false" prefHeight="18.0" prefWidth="143.0" selected="true" text="Show FPS" />
|
</children>
|
||||||
</children>
|
</AnchorPane>
|
||||||
</AnchorPane>
|
<AnchorPane fx:id="contentAnchorPane" nodeOrientation="LEFT_TO_RIGHT" prefHeight="960.0" prefWidth="1280.0" GridPane.columnIndex="1" GridPane.rowSpan="3" />
|
||||||
<AnchorPane fx:id="contentAnchorPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="960.0" prefWidth="1280.0" GridPane.columnIndex="1" GridPane.rowSpan="3">
|
</children>
|
||||||
<children>
|
</GridPane>
|
||||||
<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" />
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
|
||||||
</children>
|
|
||||||
</GridPane>
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user