mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
changed the "sea" color of the canvas to be actually drawn on the canvas rather than the pane behind #story[377]
This commit is contained in:
@@ -3,8 +3,6 @@ package seng302.controllers;
|
|||||||
import javafx.animation.*;
|
import javafx.animation.*;
|
||||||
import javafx.beans.property.DoubleProperty;
|
import javafx.beans.property.DoubleProperty;
|
||||||
import javafx.beans.property.SimpleDoubleProperty;
|
import javafx.beans.property.SimpleDoubleProperty;
|
||||||
import javafx.event.ActionEvent;
|
|
||||||
import javafx.event.EventHandler;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.canvas.Canvas;
|
import javafx.scene.canvas.Canvas;
|
||||||
@@ -36,8 +34,6 @@ import java.util.List;
|
|||||||
public class CanvasController {
|
public class CanvasController {
|
||||||
@FXML
|
@FXML
|
||||||
private Canvas canvas;
|
private Canvas canvas;
|
||||||
@FXML
|
|
||||||
TextArea boatOrder;
|
|
||||||
|
|
||||||
private Race race;
|
private Race race;
|
||||||
private GraphicsContext gc;
|
private GraphicsContext gc;
|
||||||
@@ -140,6 +136,8 @@ public class CanvasController {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(long now) {
|
public void handle(long now) {
|
||||||
gc.clearRect(0, 0, 760, 360);
|
gc.clearRect(0, 0, 760, 360);
|
||||||
|
gc.setFill(Color.SKYBLUE);
|
||||||
|
gc.fillRect(0,0,canvas.getWidth(),canvas.getHeight());
|
||||||
drawCourse();
|
drawCourse();
|
||||||
drawBoats();
|
drawBoats();
|
||||||
|
|
||||||
@@ -156,10 +154,8 @@ public class CanvasController {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
generateTimeline();
|
generateTimelines();
|
||||||
|
|
||||||
timer.start();
|
timer.start();
|
||||||
|
|
||||||
loadTimerView();
|
loadTimerView();
|
||||||
|
|
||||||
Double maxDuration = 0.0;
|
Double maxDuration = 0.0;
|
||||||
@@ -168,8 +164,6 @@ public class CanvasController {
|
|||||||
for (TimelineInfo timelineInfo : timelineInfos.values()) {
|
for (TimelineInfo timelineInfo : timelineInfos.values()) {
|
||||||
|
|
||||||
Timeline timeline = timelineInfo.getTimeline();
|
Timeline timeline = timelineInfo.getTimeline();
|
||||||
System.out.println();
|
|
||||||
|
|
||||||
if (timeline.getTotalDuration().toMillis() >= maxDuration) {
|
if (timeline.getTotalDuration().toMillis() >= maxDuration) {
|
||||||
maxDuration = timeline.getTotalDuration().toMillis();
|
maxDuration = timeline.getTotalDuration().toMillis();
|
||||||
maxTimeline = timeline;
|
maxTimeline = timeline;
|
||||||
@@ -195,7 +189,7 @@ public class CanvasController {
|
|||||||
/**
|
/**
|
||||||
* Generates time line for each boat, and stores time time into timelineInfos hash map
|
* Generates time line for each boat, and stores time time into timelineInfos hash map
|
||||||
*/
|
*/
|
||||||
private void generateTimeline() {
|
private void generateTimelines() {
|
||||||
HashMap<Boat, List> boat_events = race.getEvents();
|
HashMap<Boat, List> boat_events = race.getEvents();
|
||||||
|
|
||||||
for (Boat boat : boat_events.keySet()) {
|
for (Boat boat : boat_events.keySet()) {
|
||||||
@@ -206,12 +200,6 @@ public class CanvasController {
|
|||||||
List<KeyFrame> keyFrames = new ArrayList<>();
|
List<KeyFrame> keyFrames = new ArrayList<>();
|
||||||
List<Event> events = boat_events.get(boat);
|
List<Event> events = boat_events.get(boat);
|
||||||
|
|
||||||
EventHandler onFinished = new EventHandler<ActionEvent>() {
|
|
||||||
public void handle(ActionEvent event) {
|
|
||||||
boat.getTeamName();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// iterates all events and convert each event to keyFrame, then add them into a list
|
// iterates all events and convert each event to keyFrame, then add them into a list
|
||||||
for (Event event : events) {
|
for (Event event : events) {
|
||||||
if (event.getIsFinishingEvent()) {
|
if (event.getIsFinishingEvent()) {
|
||||||
|
|||||||
@@ -11,34 +11,45 @@
|
|||||||
|
|
||||||
<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">
|
<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>
|
<children>
|
||||||
<AnchorPane fx:id="contentAnchorPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="960.0" prefWidth="1280.0" style="-fx-background-color: lightblue;" GridPane.columnIndex="1" GridPane.rowSpan="3">
|
<GridPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="632.0" minWidth="10.0" prefWidth="224.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1056.0" minWidth="10.0" prefWidth="1056.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<Canvas fx:id="canvas" height="960.0" style="-fx-background-color: Aqua;" width="1007.0" />
|
<AnchorPane prefHeight="200.0" prefWidth="200.0" GridPane.rowSpan="3">
|
||||||
|
<children>
|
||||||
|
<Label layoutX="11.0" layoutY="259.0" text="Team Position" />
|
||||||
|
<Label layoutX="11.0" layoutY="617.0" text="Race Log" />
|
||||||
|
<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" />
|
||||||
|
<Button layoutX="18.0" layoutY="468.0" mnemonicParsing="false" text="Button" />
|
||||||
|
<TextArea editable="false" layoutX="11.0" layoutY="640.0" prefHeight="306.0" prefWidth="200.0" />
|
||||||
|
<TextArea editable="false" layoutX="11.0" layoutY="280.0" prefHeight="141.0" prefWidth="200.0" />
|
||||||
|
<Circle fx:id="windBackgroundCircle" blendMode="DARKEN" fill="#76baf8" layoutX="110.0" layoutY="166.0" radius="35.0" stroke="#686868" strokeType="INSIDE" strokeWidth="3.0" />
|
||||||
|
<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>
|
||||||
|
</Text>
|
||||||
|
<Text fx:id="windDirectionText" fill="#a8a7a7" layoutX="171.0" layoutY="214.0" strokeType="OUTSIDE" strokeWidth="0.0" text="0.0°" textAlignment="RIGHT">
|
||||||
|
<font>
|
||||||
|
<Font name="System Bold" size="13.0" />
|
||||||
|
</font>
|
||||||
|
</Text>
|
||||||
|
<Pane fx:id="raceTimer" layoutX="11.0" layoutY="30.0" prefHeight="51.0" prefWidth="193.0" />
|
||||||
|
</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" />
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</GridPane>
|
||||||
<AnchorPane prefHeight="200.0" prefWidth="200.0" GridPane.rowSpan="3">
|
|
||||||
<children>
|
|
||||||
<Label layoutX="11.0" layoutY="259.0" text="Team Position" />
|
|
||||||
<Label layoutX="11.0" layoutY="617.0" text="Race Log" />
|
|
||||||
<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" />
|
|
||||||
<Button layoutX="18.0" layoutY="468.0" mnemonicParsing="false" text="Button" />
|
|
||||||
<TextArea editable="false" layoutX="11.0" layoutY="640.0" prefHeight="306.0" prefWidth="200.0" />
|
|
||||||
<TextArea editable="false" layoutX="11.0" layoutY="280.0" prefHeight="141.0" prefWidth="200.0" />
|
|
||||||
<Circle fx:id="windBackgroundCircle" blendMode="DARKEN" fill="#76baf8" layoutX="110.0" layoutY="166.0" radius="35.0" stroke="#686868" strokeType="INSIDE" strokeWidth="3.0" />
|
|
||||||
<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>
|
|
||||||
</Text>
|
|
||||||
<Text fx:id="windDirectionText" fill="#a8a7a7" layoutX="171.0" layoutY="214.0" strokeType="OUTSIDE" strokeWidth="0.0" text="0.0°" textAlignment="RIGHT">
|
|
||||||
<font>
|
|
||||||
<Font name="System Bold" size="13.0" />
|
|
||||||
</font>
|
|
||||||
</Text>
|
|
||||||
<Pane fx:id="raceTimer" layoutX="11.0" layoutY="30.0" prefHeight="51.0" prefWidth="193.0" />
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.scene.control.*?>
|
|
||||||
<?import java.lang.*?>
|
|
||||||
<?import javafx.scene.canvas.*?>
|
|
||||||
<?import javafx.scene.layout.*?>
|
|
||||||
<?import javafx.scene.canvas.Canvas?>
|
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
|
||||||
|
|
||||||
<GridPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.controllers.CanvasController">
|
|
||||||
<columnConstraints>
|
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="220.0" minWidth="220.0" prefWidth="273.0" />
|
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="1007.0" />
|
|
||||||
</columnConstraints>
|
|
||||||
<rowConstraints>
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="320.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="320.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="320.0" vgrow="SOMETIMES" />
|
|
||||||
</rowConstraints>
|
|
||||||
<children>
|
|
||||||
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="960.0" prefWidth="1280.0" style="-fx-background-color: lightblue;" GridPane.columnIndex="1" GridPane.rowSpan="3">
|
|
||||||
<children>
|
|
||||||
<Canvas fx:id="canvas" height="960.0" style="-fx-background-color: Aqua;" width="1007.0" />
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
|
||||||
<AnchorPane prefHeight="200.0" prefWidth="200.0" GridPane.rowSpan="3">
|
|
||||||
<children>
|
|
||||||
<Label layoutX="11.0" layoutY="259.0" text="Team Position" />
|
|
||||||
<Label layoutX="11.0" layoutY="617.0" text="Race Log" />
|
|
||||||
<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" />
|
|
||||||
<Button layoutX="18.0" layoutY="468.0" mnemonicParsing="false" text="Button" />
|
|
||||||
<TextArea editable="false" layoutX="11.0" layoutY="640.0" prefHeight="306.0" prefWidth="200.0" />
|
|
||||||
<TextArea editable="false" layoutX="11.0" layoutY="280.0" prefHeight="141.0" prefWidth="200.0" />
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
|
||||||
</children>
|
|
||||||
</GridPane>
|
|
||||||
Reference in New Issue
Block a user