mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
shifted annotation layers. Merged with dev.
This commit is contained in:
@@ -29,9 +29,6 @@ public class App extends Application {
|
||||
StreamReceiver.noMoreBytes();
|
||||
System.exit(0);
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -12,7 +12,9 @@ import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Polygon;
|
||||
import javafx.scene.text.Text;
|
||||
import seng302.fxObjects.BoatAnnotations;
|
||||
import seng302.fxObjects.BoatGroup;
|
||||
import seng302.fxObjects.Wake;
|
||||
import seng302.models.Colors;
|
||||
import seng302.models.Yacht;
|
||||
import seng302.models.mark.GateMark;
|
||||
@@ -120,13 +122,12 @@ public class CanvasController {
|
||||
FPSdisplay.setStrokeWidth(2);
|
||||
group.getChildren().add(FPSdisplay);
|
||||
group.getChildren().add(raceBorder);
|
||||
|
||||
|
||||
// TODO: 1/05/17 wmu16 - Change this call to now draw the marks as from the xml
|
||||
initializeBoats();
|
||||
initializeMarks();
|
||||
initializeBoats();
|
||||
|
||||
timer = new AnimationTimer() {
|
||||
private long lastTime = 0;
|
||||
private int FPSCount = 30;
|
||||
|
||||
@Override
|
||||
public void handle(long now) {
|
||||
@@ -145,7 +146,11 @@ public class CanvasController {
|
||||
elapsedNanos = now - oldFrameTime;
|
||||
long elapsedNanosPerFrame = elapsedNanos / frameTimes.length;
|
||||
frameRate = 1_000_000_000.0 / elapsedNanosPerFrame;
|
||||
drawFps(frameRate.intValue());
|
||||
if (FPSCount-- == 0) {
|
||||
FPSCount = 30;
|
||||
drawFps(frameRate.intValue());
|
||||
}
|
||||
raceViewController.updateSparkLine();
|
||||
}
|
||||
updateGroups();
|
||||
if (StreamParser.isRaceFinished()) {
|
||||
@@ -243,7 +248,9 @@ public class CanvasController {
|
||||
BoatPositionPacket positionPacket = movementQueue.take();
|
||||
Point2D p2d = findScaledXY(positionPacket.getLat(), positionPacket.getLon());
|
||||
double heading = 360.0 / 0xffff * positionPacket.getHeading();
|
||||
boatGroup.setDestination(p2d.getX(), p2d.getY(), heading, positionPacket.getGroundSpeed(), positionPacket.getTimeValid(), frameRate, boatGroup.getRaceId());
|
||||
boatGroup.setDestination(
|
||||
p2d.getX(), p2d.getY(), heading, positionPacket.getGroundSpeed(),
|
||||
positionPacket.getTimeValid(), frameRate);
|
||||
} catch (InterruptedException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -269,7 +276,9 @@ public class CanvasController {
|
||||
*/
|
||||
private void initializeBoats() {
|
||||
Map<Integer, Yacht> boats = StreamParser.getBoats();
|
||||
Group boatAnnotations = new Group();
|
||||
Group wakes = new Group();
|
||||
Group trails = new Group();
|
||||
Group annotations = new Group();
|
||||
|
||||
ArrayList<Participant> participants = StreamParser.getXmlObject().getRaceXML().getParticipants();
|
||||
ArrayList<Integer> participantIDs = new ArrayList<>();
|
||||
@@ -282,10 +291,14 @@ public class CanvasController {
|
||||
boat.setColour(Colors.getColor());
|
||||
BoatGroup boatGroup = new BoatGroup(boat, boat.getColour());
|
||||
boatGroups.add(boatGroup);
|
||||
boatAnnotations.getChildren().add(boatGroup.getLowPriorityAnnotations());
|
||||
trails.getChildren().add(boatGroup.getTrail());
|
||||
wakes.getChildren().add(boatGroup.getWake());
|
||||
annotations.getChildren().add(boatGroup.getAnnotations());
|
||||
}
|
||||
}
|
||||
group.getChildren().add(boatAnnotations);
|
||||
group.getChildren().addAll(trails);
|
||||
group.getChildren().addAll(wakes);
|
||||
group.getChildren().addAll(annotations);
|
||||
group.getChildren().addAll(boatGroups);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.geometry.Point2D;
|
||||
import javafx.geometry.Side;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.chart.LineChart;
|
||||
import javafx.scene.chart.NumberAxis;
|
||||
@@ -34,10 +33,10 @@ import seng302.controllers.annotations.ImportantAnnotationController;
|
||||
import seng302.controllers.annotations.ImportantAnnotationDelegate;
|
||||
import seng302.controllers.annotations.ImportantAnnotationsState;
|
||||
import seng302.fxObjects.BoatGroup;
|
||||
import seng302.fxObjects.MarkGroup;
|
||||
import seng302.models.*;
|
||||
import seng302.models.mark.GateMark;
|
||||
import seng302.models.mark.Mark;
|
||||
import seng302.models.mark.MarkGroup;
|
||||
import seng302.models.mark.SingleMark;
|
||||
import seng302.models.stream.StreamParser;
|
||||
import seng302.models.stream.XMLParser;
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.text.SimpleDateFormat;
|
||||
/**
|
||||
* Collection of annotations for boats.
|
||||
*/
|
||||
class BoatAnnotations extends Group{
|
||||
public class BoatAnnotations extends Group{
|
||||
|
||||
//Text offset constants
|
||||
private static final double X_OFFSET_TEXT = 18d;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class BoatGroup extends Group {
|
||||
private Double distanceTravelled = 0.0;
|
||||
private Point2D lastPoint;
|
||||
private boolean destinationSet;
|
||||
private BoatAnnotations boatAnnotations;;
|
||||
private BoatAnnotations boatAnnotations;
|
||||
|
||||
private Boolean isSelected = true; //All boats are initialised as selected
|
||||
|
||||
@@ -106,6 +106,10 @@ public class BoatGroup extends Group {
|
||||
boatPoly.setCache(true);
|
||||
boatPoly.setCacheHint(CacheHint.SPEED);
|
||||
boatAnnotations = new BoatAnnotations(boat, color);
|
||||
|
||||
leftLayLine = new Line();
|
||||
rightLayline = new Line();
|
||||
|
||||
wake = new Wake(0, -BOAT_HEIGHT);
|
||||
super.getChildren().addAll(boatPoly, boatAnnotations);
|
||||
}
|
||||
@@ -196,25 +200,6 @@ public class BoatGroup extends Group {
|
||||
wake.updatePosition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the rotational velocity required to reach the rotationalGoal from the
|
||||
* currentRotation.
|
||||
*/
|
||||
private Double calculateRotationalVelocity(Double rotationalGoal) {
|
||||
Double rotationalVelocity;
|
||||
|
||||
if (Math.abs(rotationalGoal - lastRotation) > 180) {
|
||||
if (rotationalGoal - lastRotation >= 0.0) {
|
||||
rotationalVelocity = ((rotationalGoal - lastRotation) - 360) / 200;
|
||||
} else {
|
||||
rotationalVelocity = (360 + (rotationalGoal - lastRotation)) / 200;
|
||||
}
|
||||
} else {
|
||||
rotationalVelocity = (rotationalGoal - lastRotation) / 200;
|
||||
}
|
||||
return rotationalVelocity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the destination of the boat and the headng it should have once it reaches
|
||||
*
|
||||
@@ -224,7 +209,7 @@ public class BoatGroup extends Group {
|
||||
* @param timeValid the time the position values are valid for
|
||||
*/
|
||||
public void setDestination(double newXValue, double newYValue, double rotation,
|
||||
double groundSpeed, long timeValid, double frameRate, long id) {
|
||||
double groundSpeed, long timeValid, double frameRate) {
|
||||
if (lastTimeValid == 0) {
|
||||
lastTimeValid = timeValid - 200;
|
||||
moveTo(newXValue, newYValue, rotation);
|
||||
@@ -338,19 +323,17 @@ public class BoatGroup extends Group {
|
||||
return boat.getSourceID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Due to javaFX limitations annotations associated with a boat that you want to appear below
|
||||
* all boats in the Z-axis need to be pulled out of the BoatGroup and added to the parent group
|
||||
* of the BoatGroups. This function returns these annotations as a group.
|
||||
*
|
||||
* @return A group containing low priority annotations.
|
||||
*/
|
||||
public Group getLowPriorityAnnotations() {
|
||||
Group group = new Group();
|
||||
group.getChildren().addAll(wake, lineGroup);
|
||||
return group;
|
||||
public Wake getWake () {
|
||||
return wake;
|
||||
}
|
||||
|
||||
public Group getTrail() {
|
||||
return lineGroup;
|
||||
}
|
||||
|
||||
public BoatAnnotations getAnnotations() {
|
||||
return boatAnnotations;
|
||||
}
|
||||
|
||||
public Double getBoatLayoutX() {
|
||||
return boatPoly.getLayoutX();
|
||||
@@ -369,4 +352,5 @@ public class BoatGroup extends Group {
|
||||
public String toString() {
|
||||
return boat.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import javafx.scene.transform.Scale;
|
||||
/**
|
||||
* A group containing objects used to represent wakes onscreen. Contains functionality for their animation.
|
||||
*/
|
||||
class Wake extends Group {
|
||||
public class Wake extends Group {
|
||||
|
||||
//The number of wakes
|
||||
private int numWakes = 8;
|
||||
@@ -79,11 +79,11 @@ class Wake extends Group {
|
||||
}
|
||||
}
|
||||
|
||||
double rad = (12 / numWakes) + velocity;
|
||||
double rad = (14 / numWakes) + velocity;
|
||||
for (Arc arc : arcs) {
|
||||
arc.setRadiusX(rad);
|
||||
arc.setRadiusY(rad);
|
||||
rad += (12 / numWakes) + (velocity / 2);
|
||||
rad += (14 / numWakes) + (velocity / 2.5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@ import seng302.controllers.RaceViewController;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import seng302.models.stream.StreamParser;
|
||||
import seng302.models.stream.XMLParser.RaceXMLObject.Corner;
|
||||
|
||||
/**
|
||||
* Yacht class for the racing boat.
|
||||
@@ -38,7 +36,6 @@ public class Yacht {
|
||||
private Long markRoundTime;
|
||||
|
||||
// Mark rounding
|
||||
private Long markRoundingTime;
|
||||
private Mark lastMarkRounded;
|
||||
private Mark nextMark;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user