mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +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.application.Platform;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.geometry.Point2D;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.Node;
|
||||
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.Pane;
|
||||
import javafx.scene.paint.Color;
|
||||
@@ -93,18 +89,14 @@ public class GameView extends Pane {
|
||||
|
||||
public void zoomOut() {
|
||||
scaleFactor = 0.95;
|
||||
for (Node child : getChildren()) {
|
||||
child.setScaleX(child.getScaleX() * scaleFactor);
|
||||
child.setScaleY(child.getScaleY() * scaleFactor);
|
||||
}
|
||||
this.setScaleX(this.getScaleX() * scaleFactor);
|
||||
this.setScaleY(this.getScaleY() * scaleFactor);
|
||||
}
|
||||
|
||||
public void zoomIn() {
|
||||
scaleFactor = 1.05;
|
||||
for (Node child : getChildren()) {
|
||||
child.setScaleX(child.getScaleX() * scaleFactor);
|
||||
child.setScaleY(child.getScaleY() * scaleFactor);
|
||||
}
|
||||
this.setScaleX(this.getScaleX() * scaleFactor);
|
||||
this.setScaleY(this.getScaleY() * scaleFactor);
|
||||
}
|
||||
|
||||
private enum ScaleDirection {
|
||||
@@ -122,45 +114,6 @@ public class GameView extends Pane {
|
||||
gameObjects.add(fpsDisplay);
|
||||
gameObjects.add(raceBorder);
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -393,9 +346,6 @@ public class GameView extends Pane {
|
||||
BoatObject bo = boatObjects.get(boat);
|
||||
Point2D p2d = findScaledXY(lat, lon);
|
||||
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());
|
||||
bo.setTrajectory(
|
||||
heading,
|
||||
@@ -410,7 +360,6 @@ public class GameView extends Pane {
|
||||
gameObjects.addAll(wakes);
|
||||
gameObjects.addAll(annotationsGroup);
|
||||
gameObjects.addAll(boatObjectGroup);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -115,11 +115,11 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
initialiseSparkLine();
|
||||
|
||||
gameView = new GameView();
|
||||
Platform.runLater(() -> contentAnchorPane.getChildren().add(gameView));
|
||||
gameView.setBoats(new ArrayList<>(participants.values()));
|
||||
gameView.updateBorder(raceData.getCourseLimit());
|
||||
gameView.updateCourse(
|
||||
new ArrayList<>(raceData.getCompoundMarks().values()), raceData.getMarkSequence()
|
||||
Platform.runLater(() -> contentAnchorPane.getChildren().add(0, gameView));
|
||||
gameView.setBoats(new ArrayList<>(participants.values()));
|
||||
gameView.updateBorder(raceData.getCourseLimit());
|
||||
gameView.updateCourse(
|
||||
new ArrayList<>(raceData.getCompoundMarks().values()), raceData.getMarkSequence()
|
||||
);
|
||||
gameView.setBoatAsPlayer(player);
|
||||
gameView.startRace();
|
||||
|
||||
@@ -95,7 +95,7 @@ public class AnnotationBox extends Group {
|
||||
background.setStroke(theme);
|
||||
background.setStrokeWidth(2);
|
||||
background.setCache(true);
|
||||
background.setCacheHint(CacheHint.SPEED);
|
||||
background.setCacheHint(CacheHint.SCALE);
|
||||
this.getChildren().add(background);
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ public class AnnotationBox extends Group {
|
||||
Text text = new Text();
|
||||
text.setFill(theme);
|
||||
text.setStrokeWidth(2);
|
||||
text.setCacheHint(CacheHint.SPEED);
|
||||
// text.setCacheHint(CacheHint.QUALITY);
|
||||
text.setCache(true);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package seng302.visualiser.fxObjects;
|
||||
import java.util.ArrayList;
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.Point2D;
|
||||
import javafx.scene.CacheHint;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.paint.Color;
|
||||
@@ -85,7 +84,7 @@ public class BoatObject extends Group {
|
||||
});
|
||||
boatPoly.setOnMouseClicked(event -> setIsSelected(!isSelected));
|
||||
boatPoly.setCache(true);
|
||||
boatPoly.setCacheHint(CacheHint.SPEED);
|
||||
// boatPoly.setCacheHint(CacheHint.SPEED);
|
||||
|
||||
// annotationBox = new AnnotationBox();
|
||||
// annotationBox.setFill(colour);
|
||||
|
||||
Reference in New Issue
Block a user