mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Implemented zooming and clipping of race border. Implementation is still hackish.
#pair[ptg19, cir27] #story[1121]
This commit is contained in:
@@ -9,14 +9,10 @@ import java.util.Map;
|
|||||||
import javafx.animation.AnimationTimer;
|
import javafx.animation.AnimationTimer;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.event.EventHandler;
|
|
||||||
import javafx.geometry.Point2D;
|
import javafx.geometry.Point2D;
|
||||||
import javafx.scene.Group;
|
import javafx.scene.Group;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.input.KeyCode;
|
|
||||||
import javafx.scene.input.KeyEvent;
|
|
||||||
import javafx.scene.input.ScrollEvent;
|
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
@@ -93,18 +89,14 @@ public class GameView extends Pane {
|
|||||||
|
|
||||||
public void zoomOut() {
|
public void zoomOut() {
|
||||||
scaleFactor = 0.95;
|
scaleFactor = 0.95;
|
||||||
for (Node child : getChildren()) {
|
this.setScaleX(this.getScaleX() * scaleFactor);
|
||||||
child.setScaleX(child.getScaleX() * scaleFactor);
|
this.setScaleY(this.getScaleY() * scaleFactor);
|
||||||
child.setScaleY(child.getScaleY() * scaleFactor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void zoomIn() {
|
public void zoomIn() {
|
||||||
scaleFactor = 1.05;
|
scaleFactor = 1.05;
|
||||||
for (Node child : getChildren()) {
|
this.setScaleX(this.getScaleX() * scaleFactor);
|
||||||
child.setScaleX(child.getScaleX() * scaleFactor);
|
this.setScaleY(this.getScaleY() * scaleFactor);
|
||||||
child.setScaleY(child.getScaleY() * scaleFactor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum ScaleDirection {
|
private enum ScaleDirection {
|
||||||
@@ -122,45 +114,6 @@ public class GameView extends Pane {
|
|||||||
gameObjects.add(fpsDisplay);
|
gameObjects.add(fpsDisplay);
|
||||||
gameObjects.add(raceBorder);
|
gameObjects.add(raceBorder);
|
||||||
gameObjects.add(markers);
|
gameObjects.add(markers);
|
||||||
//
|
|
||||||
// this.setOnKeyPressed(new EventHandler<KeyEvent>() {
|
|
||||||
// @Override public void handle(KeyEvent event) {
|
|
||||||
// event.consume();
|
|
||||||
// switch (event.getCode()) {
|
|
||||||
// case Z:
|
|
||||||
// scaleFactor = scaleFactor * 1.2;
|
|
||||||
// break;
|
|
||||||
// case X:
|
|
||||||
// scaleFactor = scaleFactor * 0.8;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// if (event.getCode() == KeyCode.Z || event.getCode() == KeyCode.X) {
|
|
||||||
// for (Node child : getChildren()) {
|
|
||||||
// child.setScaleX(child.getScaleX() * scaleFactor);
|
|
||||||
// child.setScaleY(child.getScaleY() * scaleFactor);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// this.setOnScroll(new EventHandler<ScrollEvent>() {
|
|
||||||
// @Override public void handle(ScrollEvent event) {
|
|
||||||
// event.consume();
|
|
||||||
// if (event.getDeltaY() == 0) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// double scaleFactor =
|
|
||||||
// (event.getDeltaY() > 0)
|
|
||||||
// ? SCALE_DELTA
|
|
||||||
// : 1/SCALE_DELTA;
|
|
||||||
// for (Node child : getChildren()) {
|
|
||||||
// child.setScaleX(child.getScaleX() * scaleFactor);
|
|
||||||
// child.setScaleY(child.getScaleY() * scaleFactor);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
initializeTimer();
|
initializeTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,9 +346,6 @@ public class GameView extends Pane {
|
|||||||
BoatObject bo = boatObjects.get(boat);
|
BoatObject bo = boatObjects.get(boat);
|
||||||
Point2D p2d = findScaledXY(lat, lon);
|
Point2D p2d = findScaledXY(lat, lon);
|
||||||
bo.moveTo(p2d.getX(), p2d.getY(), heading, velocity, sailIn, windDir);
|
bo.moveTo(p2d.getX(), p2d.getY(), heading, velocity, sailIn, windDir);
|
||||||
// annotations.get(boat).setLayoutX(p2d.getX());
|
|
||||||
// annotations.get(boat).setLayoutY(p2d.getY());
|
|
||||||
// annotations.get(boat).setLocation(100d, 100d);
|
|
||||||
annotations.get(boat).setLocation(p2d.getX(), p2d.getY());
|
annotations.get(boat).setLocation(p2d.getX(), p2d.getY());
|
||||||
bo.setTrajectory(
|
bo.setTrajectory(
|
||||||
heading,
|
heading,
|
||||||
@@ -410,7 +360,6 @@ public class GameView extends Pane {
|
|||||||
gameObjects.addAll(wakes);
|
gameObjects.addAll(wakes);
|
||||||
gameObjects.addAll(annotationsGroup);
|
gameObjects.addAll(annotationsGroup);
|
||||||
gameObjects.addAll(boatObjectGroup);
|
gameObjects.addAll(boatObjectGroup);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,11 +115,11 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
initialiseSparkLine();
|
initialiseSparkLine();
|
||||||
|
|
||||||
gameView = new GameView();
|
gameView = new GameView();
|
||||||
Platform.runLater(() -> contentAnchorPane.getChildren().add(gameView));
|
Platform.runLater(() -> contentAnchorPane.getChildren().add(0, gameView));
|
||||||
gameView.setBoats(new ArrayList<>(participants.values()));
|
gameView.setBoats(new ArrayList<>(participants.values()));
|
||||||
gameView.updateBorder(raceData.getCourseLimit());
|
gameView.updateBorder(raceData.getCourseLimit());
|
||||||
gameView.updateCourse(
|
gameView.updateCourse(
|
||||||
new ArrayList<>(raceData.getCompoundMarks().values()), raceData.getMarkSequence()
|
new ArrayList<>(raceData.getCompoundMarks().values()), raceData.getMarkSequence()
|
||||||
);
|
);
|
||||||
gameView.setBoatAsPlayer(player);
|
gameView.setBoatAsPlayer(player);
|
||||||
gameView.startRace();
|
gameView.startRace();
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public class AnnotationBox extends Group {
|
|||||||
background.setStroke(theme);
|
background.setStroke(theme);
|
||||||
background.setStrokeWidth(2);
|
background.setStrokeWidth(2);
|
||||||
background.setCache(true);
|
background.setCache(true);
|
||||||
background.setCacheHint(CacheHint.SPEED);
|
background.setCacheHint(CacheHint.SCALE);
|
||||||
this.getChildren().add(background);
|
this.getChildren().add(background);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ public class AnnotationBox extends Group {
|
|||||||
Text text = new Text();
|
Text text = new Text();
|
||||||
text.setFill(theme);
|
text.setFill(theme);
|
||||||
text.setStrokeWidth(2);
|
text.setStrokeWidth(2);
|
||||||
text.setCacheHint(CacheHint.SPEED);
|
// text.setCacheHint(CacheHint.QUALITY);
|
||||||
text.setCache(true);
|
text.setCache(true);
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package seng302.visualiser.fxObjects;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.geometry.Point2D;
|
import javafx.geometry.Point2D;
|
||||||
import javafx.scene.CacheHint;
|
|
||||||
import javafx.scene.Group;
|
import javafx.scene.Group;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
@@ -85,7 +84,7 @@ public class BoatObject extends Group {
|
|||||||
});
|
});
|
||||||
boatPoly.setOnMouseClicked(event -> setIsSelected(!isSelected));
|
boatPoly.setOnMouseClicked(event -> setIsSelected(!isSelected));
|
||||||
boatPoly.setCache(true);
|
boatPoly.setCache(true);
|
||||||
boatPoly.setCacheHint(CacheHint.SPEED);
|
// boatPoly.setCacheHint(CacheHint.SPEED);
|
||||||
|
|
||||||
// annotationBox = new AnnotationBox();
|
// annotationBox = new AnnotationBox();
|
||||||
// annotationBox.setFill(colour);
|
// annotationBox.setFill(colour);
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import java.lang.*?>
|
||||||
|
<?import javafx.scene.chart.*?>
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
<?import javafx.scene.shape.*?>
|
||||||
|
<?import javafx.scene.text.*?>
|
||||||
<?import javafx.scene.chart.CategoryAxis?>
|
<?import javafx.scene.chart.CategoryAxis?>
|
||||||
<?import javafx.scene.chart.LineChart?>
|
<?import javafx.scene.chart.LineChart?>
|
||||||
<?import javafx.scene.chart.NumberAxis?>
|
<?import javafx.scene.chart.NumberAxis?>
|
||||||
@@ -17,40 +23,33 @@
|
|||||||
<?import javafx.scene.shape.Circle?>
|
<?import javafx.scene.shape.Circle?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
<?import javafx.scene.text.Text?>
|
<?import javafx.scene.text.Text?>
|
||||||
<GridPane prefHeight="960.0" prefWidth="1530.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.visualiser.controllers.RaceViewController">
|
|
||||||
<columnConstraints>
|
<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">
|
||||||
<ColumnConstraints maxWidth="246.0" minWidth="246.0" prefWidth="246.0" />
|
<children>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="1034.0" />
|
<AnchorPane fx:id="contentAnchorPane" layoutX="322.0" layoutY="130.0" prefHeight="998.0" prefWidth="1281.0" style="-fx-background-color: skyblue;" AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||||
</columnConstraints>
|
<AnchorPane prefHeight="960.0" prefWidth="250.0" style="-fx-background-color: #2C2c36;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<rowConstraints>
|
<children>
|
||||||
<RowConstraints minHeight="500.0" prefHeight="30.0" 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" />
|
||||||
<RowConstraints />
|
<Label layoutX="11.0" layoutY="41.0" text="Timer" textFill="WHITE" />
|
||||||
</rowConstraints>
|
<Label layoutX="11.0" layoutY="112.0" text="Wind direction" textFill="WHITE" />
|
||||||
<children>
|
<Circle fx:id="windBackgroundCircle" blendMode="DARKEN" fill="#3dcdc8" layoutX="110.0" layoutY="190.0" radius="35.0" stroke="#d7d7d7" strokeType="INSIDE" strokeWidth="3.0" />
|
||||||
<AnchorPane prefHeight="960.0" prefWidth="250.0" style="-fx-background-color: #2C2c36;" GridPane.rowSpan="3">
|
<Text fx:id="windArrowText" fill="#a8a8a8" layoutX="86.0" layoutY="210.0" strokeType="OUTSIDE" strokeWidth="0.0" text="↓">
|
||||||
<children>
|
<font>
|
||||||
<Label layoutX="11.0" layoutY="283.0" text="Team Position" textFill="WHITE" />
|
<Font name="AdobeArabic-Regular" size="55.0" />
|
||||||
<Label layoutX="13.0" layoutY="432.0" text="Settings" textFill="WHITE" />
|
</font>
|
||||||
<Label layoutX="11.0" layoutY="41.0" text="Timer" textFill="WHITE" />
|
</Text>
|
||||||
<Label layoutX="11.0" layoutY="112.0" text="Wind direction" textFill="WHITE" />
|
<Text fx:id="windDirectionText" fill="#d3d3d3" layoutX="171.0" layoutY="238.0" strokeType="OUTSIDE" strokeWidth="0.0" text="0.0°" textAlignment="RIGHT">
|
||||||
<Circle fx:id="windBackgroundCircle" blendMode="DARKEN" fill="#3dcdc8" layoutX="110.0" layoutY="190.0" radius="35.0" stroke="#d7d7d7" strokeType="INSIDE" strokeWidth="3.0" />
|
<font>
|
||||||
<Text fx:id="windArrowText" fill="#a8a8a8" layoutX="86.0" layoutY="210.0" strokeType="OUTSIDE" strokeWidth="0.0" text="↓">
|
<Font name="System Bold" size="13.0" />
|
||||||
<font>
|
</font>
|
||||||
<Font name="AdobeArabic-Regular" size="55.0" />
|
</Text>
|
||||||
</font>
|
|
||||||
</Text>
|
|
||||||
<Text fx:id="windDirectionText" fill="#d3d3d3" layoutX="171.0" layoutY="238.0" strokeType="OUTSIDE" strokeWidth="0.0" text="0.0°" textAlignment="RIGHT">
|
|
||||||
<font>
|
|
||||||
<Font name="System Bold" size="13.0" />
|
|
||||||
</font>
|
|
||||||
</Text>
|
|
||||||
<Text fx:id="windSpeedText" fill="#d3d3d3" layoutX="12.0" layoutY="237.0" strokeType="OUTSIDE" strokeWidth="0.0" text="0.0 Knot" textAlignment="RIGHT">
|
<Text fx:id="windSpeedText" fill="#d3d3d3" layoutX="12.0" layoutY="237.0" strokeType="OUTSIDE" strokeWidth="0.0" text="0.0 Knot" textAlignment="RIGHT">
|
||||||
<font>
|
<font>
|
||||||
<Font name="System Bold" size="13.0" />
|
<Font name="System Bold" size="13.0" />
|
||||||
</font>
|
</font>
|
||||||
</Text>
|
</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" />
|
<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" />
|
<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">
|
<Pane layoutX="11.0" layoutY="39.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="51.0" prefWidth="193.0">
|
||||||
<children>
|
<children>
|
||||||
@@ -67,17 +66,14 @@
|
|||||||
<Text fill="WHITE" layoutX="11.0" layoutY="649.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Boat Selection" />
|
<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" />
|
<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">
|
<LineChart fx:id="raceSparkLine" layoutX="-1.0" layoutY="719.0" legendVisible="false" prefHeight="277.0" prefWidth="246.0" title="Boat Positions">
|
||||||
<xAxis>
|
<xAxis>
|
||||||
<CategoryAxis label="Leg Number" side="BOTTOM" styleClass="spark-line-xaxis" />
|
<CategoryAxis label="Leg Number" side="BOTTOM" styleClass="spark-line-xaxis" />
|
||||||
</xAxis>
|
</xAxis>
|
||||||
<yAxis>
|
<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" />
|
<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>
|
</yAxis>
|
||||||
</LineChart>
|
</LineChart>
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
<AnchorPane fx:id="contentAnchorPane" style="-fx-background-color: skyblue;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" GridPane.columnIndex="1" GridPane.halignment="LEFT" GridPane.rowSpan="2147483647" GridPane.valignment="TOP">
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
</AnchorPane>
|
|
||||||
</children>
|
|
||||||
</GridPane>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user