mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
[WIP]
- changed contentAnchorPane to Grid Pane temporarily so added child will be able to resize natively - implemented zooming when resizing Bugs: - horizontal resizing works as intended, but vertical resizing will result in canvas moving far too left - need to solve the right and bottom empty space when resizing #story[1248]
This commit is contained in:
@@ -11,6 +11,8 @@ import javafx.animation.KeyFrame;
|
|||||||
import javafx.animation.KeyValue;
|
import javafx.animation.KeyValue;
|
||||||
import javafx.animation.Timeline;
|
import javafx.animation.Timeline;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
|
import javafx.beans.value.ChangeListener;
|
||||||
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.geometry.Point2D;
|
import javafx.geometry.Point2D;
|
||||||
import javafx.scene.Group;
|
import javafx.scene.Group;
|
||||||
@@ -26,10 +28,8 @@ import javafx.scene.shape.Circle;
|
|||||||
import javafx.scene.shape.Polygon;
|
import javafx.scene.shape.Polygon;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
import seng302.model.ClientYacht;
|
|
||||||
import seng302.gameServer.messages.RoundingSide;
|
import seng302.gameServer.messages.RoundingSide;
|
||||||
import seng302.model.ClientYacht;
|
import seng302.model.ClientYacht;
|
||||||
import seng302.model.Colors;
|
|
||||||
import seng302.model.GeoPoint;
|
import seng302.model.GeoPoint;
|
||||||
import seng302.model.Limit;
|
import seng302.model.Limit;
|
||||||
import seng302.model.mark.CompoundMark;
|
import seng302.model.mark.CompoundMark;
|
||||||
@@ -142,6 +142,55 @@ public class GameView extends Pane {
|
|||||||
gameObjects.add(raceBorder);
|
gameObjects.add(raceBorder);
|
||||||
gameObjects.add(markers);
|
gameObjects.add(markers);
|
||||||
initializeTimer();
|
initializeTimer();
|
||||||
|
|
||||||
|
// DEBUG USE
|
||||||
|
gameObjects.add(new Circle(0, 0, 10, Color.RED));
|
||||||
|
gameObjects.add(new Circle(0, 960, 10, Color.RED));
|
||||||
|
gameObjects.add(new Circle(1280, 960, 10, Color.RED));
|
||||||
|
gameObjects.add(new Circle(1280, 0, 10, Color.RED));
|
||||||
|
// --------
|
||||||
|
|
||||||
|
this.widthProperty().addListener(new ChangeListener<Number>() {
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends Number> observable, Number oldValue,
|
||||||
|
Number newValue) {
|
||||||
|
scaleFactor = (newValue.doubleValue() - 180) / canvasWidth;
|
||||||
|
double maxVertical = 960 * scaleFactor;
|
||||||
|
|
||||||
|
if (oldValue.doubleValue() != 0.0 && maxVertical < getScene().getHeight()) {
|
||||||
|
setScaleX(scaleFactor);
|
||||||
|
setScaleY(scaleFactor);
|
||||||
|
setTranslateX(0 - ((1 - scaleFactor) * oldValue.doubleValue() / 2));
|
||||||
|
setTranslateY(0 - ((1 - scaleFactor) * getScene().getHeight() / 2));
|
||||||
|
System.out.println("Width: " + newValue);
|
||||||
|
System.out.println("Scale X: " + getScaleX());
|
||||||
|
System.out.println("Transition X: " + getTranslateX());
|
||||||
|
System.out.println("Get Height: " + getScene().getHeight());
|
||||||
|
System.out.println("Get Width: " + getScene().getWidth());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.heightProperty().addListener(new ChangeListener<Number>() {
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends Number> observable, Number oldValue,
|
||||||
|
Number newValue) {
|
||||||
|
scaleFactor = (newValue.doubleValue() - 40) / canvasHeight;
|
||||||
|
double maxHorizontal = 1530 * scaleFactor;
|
||||||
|
|
||||||
|
if (oldValue.doubleValue() != 0.0 && maxHorizontal < getScene().getWidth()) {
|
||||||
|
setScaleX(scaleFactor);
|
||||||
|
setScaleY(scaleFactor);
|
||||||
|
setTranslateX(0 - ((1 - scaleFactor) * getScene().getWidth() / 2));
|
||||||
|
setTranslateY(0 - ((1 - scaleFactor) * oldValue.doubleValue() / 2));
|
||||||
|
System.out.println("Height: " + newValue);
|
||||||
|
System.out.println("Scale Y: " + getScaleY());
|
||||||
|
System.out.println("Transition Y: " + getTranslateY());
|
||||||
|
System.out.println("Get Height: " + getScene().getHeight());
|
||||||
|
System.out.println("Get Width: " + getScene().getWidth());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeTimer() {
|
private void initializeTimer() {
|
||||||
@@ -440,7 +489,9 @@ public class GameView extends Pane {
|
|||||||
* Enables zoom. Has to be called after this is added to a scene.
|
* Enables zoom. Has to be called after this is added to a scene.
|
||||||
*/
|
*/
|
||||||
public void enableZoom () {
|
public void enableZoom () {
|
||||||
|
System.out.println("enable zoom");
|
||||||
if (this.getScene() != null) {
|
if (this.getScene() != null) {
|
||||||
|
System.out.println("can zoom");
|
||||||
this.getScene().addEventHandler(KeyEvent.KEY_PRESSED, (event) -> {
|
this.getScene().addEventHandler(KeyEvent.KEY_PRESSED, (event) -> {
|
||||||
if (event.getCode() == KeyCode.Z) {
|
if (event.getCode() == KeyCode.Z) {
|
||||||
zoomIn();
|
zoomIn();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import javafx.scene.control.Button;
|
|||||||
import javafx.scene.control.CheckBox;
|
import javafx.scene.control.CheckBox;
|
||||||
import javafx.scene.control.ComboBox;
|
import javafx.scene.control.ComboBox;
|
||||||
import javafx.scene.control.Slider;
|
import javafx.scene.control.Slider;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.GridPane;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
@@ -64,7 +64,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
@FXML
|
@FXML
|
||||||
private Text timerLabel;
|
private Text timerLabel;
|
||||||
@FXML
|
@FXML
|
||||||
private AnchorPane contentAnchorPane;
|
private GridPane contentAnchorPane;
|
||||||
@FXML
|
@FXML
|
||||||
private Text windArrowText, windDirectionText;
|
private Text windArrowText, windDirectionText;
|
||||||
@FXML
|
@FXML
|
||||||
|
|||||||
@@ -24,83 +24,137 @@
|
|||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
<?import javafx.scene.text.Text?>
|
<?import javafx.scene.text.Text?>
|
||||||
|
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="998.0" prefWidth="1530.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.RaceViewController">
|
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
|
||||||
<children>
|
prefHeight="998.0" prefWidth="1530.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||||
<AnchorPane layoutX="322.0" layoutY="130.0" prefHeight="998.0" prefWidth="1281.0"
|
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8"
|
||||||
style="-fx-background-color: skyblue;" AnchorPane.bottomAnchor="0.0"
|
xmlns:fx="http://javafx.com/fxml/1"
|
||||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
fx:controller="seng302.visualiser.controllers.RaceViewController">
|
||||||
<children>
|
<children>
|
||||||
<GridPane prefHeight="998.0" prefWidth="1281.0" AnchorPane.bottomAnchor="0.0"
|
<GridPane prefHeight="998.0" prefWidth="1530.0" AnchorPane.bottomAnchor="0.0"
|
||||||
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
|
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
AnchorPane.topAnchor="0.0">
|
<columnConstraints>
|
||||||
<columnConstraints>
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="250.0" minWidth="250.0"
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="630.0" minWidth="10.0"
|
prefWidth="250.0"/>
|
||||||
prefWidth="68.0"/>
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="1283.0"/>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1213.0" minWidth="10.0"
|
</columnConstraints>
|
||||||
prefWidth="1213.0"/>
|
<rowConstraints>
|
||||||
</columnConstraints>
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||||
<rowConstraints>
|
</rowConstraints>
|
||||||
<RowConstraints maxHeight="489.0" minHeight="1.0" prefHeight="24.0"
|
<children>
|
||||||
vgrow="SOMETIMES"/>
|
<AnchorPane prefHeight="998.0" prefWidth="1281.0"
|
||||||
<RowConstraints maxHeight="997.0" minHeight="10.0" prefHeight="974.0"
|
style="-fx-background-color: skyblue;" GridPane.columnIndex="1">
|
||||||
vgrow="SOMETIMES"/>
|
<children>
|
||||||
</rowConstraints>
|
<GridPane minHeight="10.0" prefHeight="998.0" prefWidth="1281.0"
|
||||||
<children>
|
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||||
<AnchorPane fx:id="contentAnchorPane" prefHeight="200.0" prefWidth="200.0"
|
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
GridPane.columnSpan="2" GridPane.rowSpan="2"/>
|
<columnConstraints>
|
||||||
<Text fx:id="fpsDisplay" strokeType="OUTSIDE" strokeWidth="0.0" text="60 FPS"
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="68.0" minWidth="68.0"
|
||||||
GridPane.halignment="CENTER" GridPane.valignment="CENTER"/>
|
prefWidth="68.0"/>
|
||||||
</children>
|
<ColumnConstraints hgrow="SOMETIMES"/>
|
||||||
</GridPane>
|
</columnConstraints>
|
||||||
</children>
|
<rowConstraints>
|
||||||
</AnchorPane>
|
<RowConstraints maxHeight="24.0" minHeight="24.0" prefHeight="24.0"
|
||||||
<AnchorPane prefHeight="960.0" prefWidth="250.0" style="-fx-background-color: #2C2c36;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
|
vgrow="SOMETIMES"/>
|
||||||
<children>
|
<RowConstraints vgrow="SOMETIMES"/>
|
||||||
<Label layoutX="11.0" layoutY="283.0" text="Team Position" textFill="WHITE" />
|
</rowConstraints>
|
||||||
<Label layoutX="13.0" layoutY="432.0" text="Settings" textFill="WHITE" />
|
<children>
|
||||||
<Label layoutX="11.0" layoutY="41.0" text="Timer" textFill="WHITE" />
|
<GridPane fx:id="contentAnchorPane" GridPane.columnSpan="2"
|
||||||
<Label layoutX="11.0" layoutY="112.0" text="Wind direction" textFill="WHITE" />
|
GridPane.rowSpan="2">
|
||||||
<Circle fx:id="windBackgroundCircle" blendMode="DARKEN" fill="#3dcdc8" layoutX="110.0" layoutY="190.0" radius="35.0" stroke="#d7d7d7" strokeType="INSIDE" strokeWidth="3.0" />
|
<columnConstraints>
|
||||||
<Text fx:id="windArrowText" fill="#a8a8a8" layoutX="86.0" layoutY="210.0" strokeType="OUTSIDE" strokeWidth="0.0" text="↓">
|
<ColumnConstraints hgrow="SOMETIMES"/>
|
||||||
<font>
|
</columnConstraints>
|
||||||
<Font name="AdobeArabic-Regular" size="55.0" />
|
<rowConstraints>
|
||||||
</font>
|
<RowConstraints vgrow="SOMETIMES"/>
|
||||||
</Text>
|
</rowConstraints>
|
||||||
<Text fx:id="windDirectionText" fill="#d3d3d3" layoutX="171.0" layoutY="238.0" strokeType="OUTSIDE" strokeWidth="0.0" text="0.0°" textAlignment="RIGHT">
|
</GridPane>
|
||||||
<font>
|
<Text fx:id="fpsDisplay" strokeType="OUTSIDE" strokeWidth="0.0"
|
||||||
<Font name="System Bold" size="13.0" />
|
text="60 FPS" GridPane.halignment="CENTER"
|
||||||
</font>
|
GridPane.valignment="CENTER"/>
|
||||||
</Text>
|
</children>
|
||||||
<Text fx:id="windSpeedText" fill="#d3d3d3" layoutX="12.0" layoutY="237.0" strokeType="OUTSIDE" strokeWidth="0.0" text="0.0 Knot" textAlignment="RIGHT">
|
</GridPane>
|
||||||
<font>
|
</children>
|
||||||
<Font name="System Bold" size="13.0" />
|
</AnchorPane>
|
||||||
</font>
|
<AnchorPane minHeight="10.0" minWidth="250.0" prefHeight="960.0" prefWidth="250.0"
|
||||||
</Text>
|
style="-fx-background-color: #2C2c36;">
|
||||||
<CheckBox fx:id="toggleFps" focusTraversable="false" graphicTextGap="0.0" layoutX="21.0" layoutY="453.0" mnemonicParsing="false" prefHeight="18.0" prefWidth="143.0" selected="true" styleClass="ui-checkbox" text="Show FPS" textFill="WHITE" />
|
<children>
|
||||||
<VBox fx:id="positionVbox" layoutX="12.0" layoutY="304.0" prefHeight="116.0" prefWidth="200.0" styleClass="text-white" />
|
<Label layoutX="11.0" layoutY="283.0" text="Team Position"
|
||||||
<Pane layoutX="11.0" layoutY="39.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="51.0" prefWidth="193.0">
|
textFill="WHITE"/>
|
||||||
<children>
|
<Label layoutX="13.0" layoutY="432.0" text="Settings" textFill="WHITE"/>
|
||||||
<Text fx:id="timerLabel" fill="#f8f8f8" layoutX="-26.0" layoutY="51.0" strokeType="OUTSIDE" strokeWidth="0.0" text="00:00" textAlignment="CENTER" wrappingWidth="246.0">
|
<Label layoutX="11.0" layoutY="41.0" text="Timer" textFill="WHITE"/>
|
||||||
<font>
|
<Label layoutX="11.0" layoutY="112.0" text="Wind direction"
|
||||||
<Font size="25.0" />
|
textFill="WHITE"/>
|
||||||
</font>
|
<Circle fx:id="windBackgroundCircle" blendMode="DARKEN" fill="#3dcdc8"
|
||||||
</Text>
|
layoutX="110.0" layoutY="190.0" radius="35.0" stroke="#d7d7d7"
|
||||||
</children>
|
strokeType="INSIDE" strokeWidth="3.0"/>
|
||||||
</Pane>
|
<Text fx:id="windArrowText" fill="#a8a8a8" layoutX="86.0" layoutY="210.0"
|
||||||
<Slider fx:id="annotationSlider" blockIncrement="1.0" layoutX="38.0" layoutY="527.0" majorTickUnit="1.0" max="2.0" minorTickCount="0" prefHeight="51.0" prefWidth="170.0" showTickLabels="true" showTickMarks="true" snapToTicks="true" styleClass="ui-slider" />
|
strokeType="OUTSIDE" strokeWidth="0.0" text="↓">
|
||||||
<Label layoutX="10.0" layoutY="499.0" text="Annotations" textFill="WHITE" />
|
<font>
|
||||||
<Button fx:id="selectAnnotationBtn" focusTraversable="false" layoutX="35.0" layoutY="578.0" mnemonicParsing="false" prefHeight="18.0" prefWidth="170.0" styleClass="blue-ui-btn" text="Select Annotations" textFill="WHITE" />
|
<Font name="AdobeArabic-Regular" size="55.0"/>
|
||||||
<Text fill="WHITE" layoutX="11.0" layoutY="649.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Boat Selection" />
|
</font>
|
||||||
<ComboBox fx:id="yachtSelectionComboBox" focusTraversable="false" layoutX="37.0" layoutY="664.0" prefHeight="25.0" prefWidth="170.0" promptText="Select Yacht" styleClass="combo-box-base" />
|
</Text>
|
||||||
<LineChart fx:id="raceSparkLine" layoutX="-1.0" layoutY="719.0" legendVisible="false" prefHeight="277.0" prefWidth="246.0" title="Boat Positions">
|
<Text fx:id="windDirectionText" fill="#d3d3d3" layoutX="171.0"
|
||||||
<xAxis>
|
layoutY="238.0" strokeType="OUTSIDE" strokeWidth="0.0" text="0.0°"
|
||||||
<CategoryAxis label="Leg Number" side="BOTTOM" styleClass="spark-line-xaxis" />
|
textAlignment="RIGHT">
|
||||||
</xAxis>
|
<font>
|
||||||
<yAxis>
|
<Font name="System Bold" size="13.0"/>
|
||||||
<NumberAxis fx:id="sparklineYAxis" minorTickCount="1" minorTickLength="1.0" side="LEFT" styleClass="spark-line-yaxis" tickLabelGap="1.0" tickUnit="1.0" upperBound="7.0" />
|
</font>
|
||||||
</yAxis>
|
</Text>
|
||||||
</LineChart>
|
<Text fx:id="windSpeedText" fill="#d3d3d3" layoutX="12.0" layoutY="237.0"
|
||||||
</children>
|
strokeType="OUTSIDE" strokeWidth="0.0" text="0.0 Knot"
|
||||||
</AnchorPane>
|
textAlignment="RIGHT">
|
||||||
</children>
|
<font>
|
||||||
|
<Font name="System Bold" size="13.0"/>
|
||||||
|
</font>
|
||||||
|
</Text>
|
||||||
|
<CheckBox fx:id="toggleFps" focusTraversable="false" graphicTextGap="0.0"
|
||||||
|
layoutX="21.0" layoutY="453.0" mnemonicParsing="false" prefHeight="18.0"
|
||||||
|
prefWidth="143.0" selected="true" styleClass="ui-checkbox" text="Show FPS"
|
||||||
|
textFill="WHITE"/>
|
||||||
|
<VBox fx:id="positionVbox" layoutX="12.0" layoutY="304.0" prefHeight="116.0"
|
||||||
|
prefWidth="200.0" styleClass="text-white"/>
|
||||||
|
<Pane layoutX="11.0" layoutY="39.0" maxHeight="-Infinity"
|
||||||
|
maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
|
||||||
|
prefHeight="51.0" prefWidth="193.0">
|
||||||
|
<children>
|
||||||
|
<Text fx:id="timerLabel" fill="#f8f8f8" layoutX="-26.0"
|
||||||
|
layoutY="51.0" strokeType="OUTSIDE" strokeWidth="0.0" text="00:00"
|
||||||
|
textAlignment="CENTER" wrappingWidth="246.0">
|
||||||
|
<font>
|
||||||
|
<Font size="25.0"/>
|
||||||
|
</font>
|
||||||
|
</Text>
|
||||||
|
</children>
|
||||||
|
</Pane>
|
||||||
|
<Slider fx:id="annotationSlider" blockIncrement="1.0" layoutX="38.0"
|
||||||
|
layoutY="527.0" majorTickUnit="1.0" max="2.0" minorTickCount="0"
|
||||||
|
prefHeight="51.0" prefWidth="170.0" showTickLabels="true"
|
||||||
|
showTickMarks="true" snapToTicks="true" styleClass="ui-slider"/>
|
||||||
|
<Label layoutX="10.0" layoutY="499.0" text="Annotations" textFill="WHITE"/>
|
||||||
|
<Button fx:id="selectAnnotationBtn" focusTraversable="false" layoutX="35.0"
|
||||||
|
layoutY="578.0" mnemonicParsing="false" prefHeight="18.0"
|
||||||
|
prefWidth="170.0" styleClass="blue-ui-btn" text="Select Annotations"
|
||||||
|
textFill="WHITE"/>
|
||||||
|
<Text fill="WHITE" layoutX="11.0" layoutY="649.0" strokeType="OUTSIDE"
|
||||||
|
strokeWidth="0.0" text="Boat Selection"/>
|
||||||
|
<ComboBox fx:id="yachtSelectionComboBox" focusTraversable="false"
|
||||||
|
layoutX="37.0" layoutY="664.0" prefHeight="25.0" prefWidth="170.0"
|
||||||
|
promptText="Select Yacht" styleClass="combo-box-base"/>
|
||||||
|
<LineChart fx:id="raceSparkLine" layoutX="-1.0" layoutY="719.0"
|
||||||
|
legendVisible="false" prefHeight="277.0" prefWidth="246.0"
|
||||||
|
title="Boat Positions">
|
||||||
|
<xAxis>
|
||||||
|
<CategoryAxis label="Leg Number" side="BOTTOM"
|
||||||
|
styleClass="spark-line-xaxis"/>
|
||||||
|
</xAxis>
|
||||||
|
<yAxis>
|
||||||
|
<NumberAxis fx:id="sparklineYAxis" minorTickCount="1"
|
||||||
|
minorTickLength="1.0" side="LEFT" styleClass="spark-line-yaxis"
|
||||||
|
tickLabelGap="1.0" tickUnit="1.0" upperBound="7.0"/>
|
||||||
|
</yAxis>
|
||||||
|
</LineChart>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
|||||||
Reference in New Issue
Block a user