mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Fixed est time to next mark and time from last mark annotation update after commit e0750f53 in BoatGroup.java
#story[924] #story[927]
This commit is contained in:
@@ -18,11 +18,12 @@ import java.text.DateFormat;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BoatGroup is a javafx group that by default contains a graphical objects for representing a 2 dimensional boat.
|
* BoatGroup is a javafx group that by default contains a graphical objects for representing a 2
|
||||||
* It contains a single polygon for the boat, a group of lines to show it's path, a wake object and two text labels to
|
* dimensional boat. It contains a single polygon for the boat, a group of lines to show it's path,
|
||||||
* annotate the boat teams name and the boats velocity. The boat will update it's position onscreen everytime
|
* a wake object and two text labels to annotate the boat teams name and the boats velocity. The
|
||||||
* UpdatePosition is called unless the window is minimized in which case it attempts to store animations and apply them
|
* boat will update it's position onscreen everytime UpdatePosition is called unless the window is
|
||||||
* when the window is maximised.
|
* minimized in which case it attempts to store animations and apply them when the window is
|
||||||
|
* maximised.
|
||||||
*/
|
*/
|
||||||
public class BoatGroup extends Group {
|
public class BoatGroup extends Group {
|
||||||
|
|
||||||
@@ -62,8 +63,9 @@ public class BoatGroup extends Group{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a BoatGroup with the default triangular boat polygon.
|
* Creates a BoatGroup with the default triangular boat polygon.
|
||||||
* @param boat The boat that the BoatGroup will represent. Must contain an ID which will be used to tell which
|
*
|
||||||
* BoatGroup to update.
|
* @param boat The boat that the BoatGroup will represent. Must contain an ID which will be used
|
||||||
|
* to tell which BoatGroup to update.
|
||||||
* @param color The colour of the boat polygon and the trailing line.
|
* @param color The colour of the boat polygon and the trailing line.
|
||||||
*/
|
*/
|
||||||
public BoatGroup(Yacht boat, Color color) {
|
public BoatGroup(Yacht boat, Color color) {
|
||||||
@@ -73,20 +75,23 @@ public class BoatGroup extends Group{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a BoatGroup with the boat being the default polygon. The head of the boat should be at point (0,0).
|
* Creates a BoatGroup with the boat being the default polygon. The head of the boat should be
|
||||||
* @param boat The boat that the BoatGroup will represent. Must contain an ID which will be used to tell which
|
* at point (0,0).
|
||||||
* BoatGroup to update.
|
*
|
||||||
|
* @param boat The boat that the BoatGroup will represent. Must contain an ID which will be used
|
||||||
|
* to tell which BoatGroup to update.
|
||||||
* @param color The colour of the boat polygon and the trailing line.
|
* @param color The colour of the boat polygon and the trailing line.
|
||||||
* @param points An array of co-ordinates x1,y1,x2,y2,x3,y3... that will make up the boat polygon.
|
* @param points An array of co-ordinates x1,y1,x2,y2,x3,y3... that will make up the boat
|
||||||
|
* polygon.
|
||||||
*/
|
*/
|
||||||
public BoatGroup (Yacht boat, Color color, double... points)
|
public BoatGroup(Yacht boat, Color color, double... points) {
|
||||||
{
|
|
||||||
this.boat = boat;
|
this.boat = boat;
|
||||||
initChildren(color, points);
|
initChildren(color, points);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a text object with caching and a color applied
|
* Return a text object with caching and a color applied
|
||||||
|
*
|
||||||
* @param defaultText The default text to display
|
* @param defaultText The default text to display
|
||||||
* @param fill The text fill color
|
* @param fill The text fill color
|
||||||
* @return The text object
|
* @return The text object
|
||||||
@@ -103,8 +108,10 @@ public class BoatGroup extends Group{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the javafx objects that will be the in the group by default.
|
* Creates the javafx objects that will be the in the group by default.
|
||||||
|
*
|
||||||
* @param color The colour of the boat polygon and the trailing line.
|
* @param color The colour of the boat polygon and the trailing line.
|
||||||
* @param points An array of co-ordinates x1,y1,x2,y2,x3,y3... that will make up the boat polygon.
|
* @param points An array of co-ordinates x1,y1,x2,y2,x3,y3... that will make up the boat
|
||||||
|
* polygon.
|
||||||
*/
|
*/
|
||||||
private void initChildren(Color color, double... points) {
|
private void initChildren(Color color, double... points) {
|
||||||
textColor = color;
|
textColor = color;
|
||||||
@@ -154,6 +161,7 @@ public class BoatGroup extends Group{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the javafx objects that will be the in the group by default.
|
* Creates the javafx objects that will be the in the group by default.
|
||||||
|
*
|
||||||
* @param color The colour of the boat polygon and the trailing line.
|
* @param color The colour of the boat polygon and the trailing line.
|
||||||
*/
|
*/
|
||||||
private void initChildren(Color color) {
|
private void initChildren(Color color) {
|
||||||
@@ -164,7 +172,9 @@ public class BoatGroup extends Group{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the boat and its children annotations from its current coordinates by specified amounts.
|
* Moves the boat and its children annotations from its current coordinates by specified
|
||||||
|
* amounts.
|
||||||
|
*
|
||||||
* @param dx The amount to move the X coordinate by
|
* @param dx The amount to move the X coordinate by
|
||||||
* @param dy The amount to move the Y coordinate by
|
* @param dy The amount to move the Y coordinate by
|
||||||
*/
|
*/
|
||||||
@@ -186,6 +196,7 @@ public class BoatGroup extends Group{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the boat and its children annotations to coordinates specified
|
* Moves the boat and its children annotations to coordinates specified
|
||||||
|
*
|
||||||
* @param x The X coordinate to move the boat to
|
* @param x The X coordinate to move the boat to
|
||||||
* @param y The Y coordinate to move the boat to
|
* @param y The Y coordinate to move the boat to
|
||||||
*/
|
*/
|
||||||
@@ -215,7 +226,7 @@ public class BoatGroup extends Group{
|
|||||||
*/
|
*/
|
||||||
private void updateTimeTillNextMark() {
|
private void updateTimeTillNextMark() {
|
||||||
if (estTimeToNextMarkObject == null) {
|
if (estTimeToNextMarkObject == null) {
|
||||||
estTimeToNextMarkObject = getTextObject("", textColor);
|
estTimeToNextMarkObject = getTextObject("Next mark: -", textColor);
|
||||||
}
|
}
|
||||||
if (boat.getEstimateTimeAtNextMark() != null) {
|
if (boat.getEstimateTimeAtNextMark() != null) {
|
||||||
DateFormat format = new SimpleDateFormat("mm:ss");
|
DateFormat format = new SimpleDateFormat("mm:ss");
|
||||||
@@ -232,7 +243,7 @@ public class BoatGroup extends Group{
|
|||||||
*/
|
*/
|
||||||
private void updateLastMarkRoundingTime() {
|
private void updateLastMarkRoundingTime() {
|
||||||
if (legTimeObject == null) {
|
if (legTimeObject == null) {
|
||||||
legTimeObject = getTextObject("", textColor);
|
legTimeObject = getTextObject("Last mark: -", textColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boat.getMarkRoundingTime() != null) {
|
if (boat.getMarkRoundingTime() != null) {
|
||||||
@@ -240,8 +251,7 @@ public class BoatGroup extends Group{
|
|||||||
String elapsedTime = format
|
String elapsedTime = format
|
||||||
.format(StreamParser.getCurrentTimeLong() - boat.getMarkRoundingTime());
|
.format(StreamParser.getCurrentTimeLong() - boat.getMarkRoundingTime());
|
||||||
legTimeObject.setText("Last mark: " + elapsedTime);
|
legTimeObject.setText("Last mark: " + elapsedTime);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
legTimeObject.setText("Last mark: -");
|
legTimeObject.setText("Last mark: -");
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -285,7 +295,8 @@ public class BoatGroup extends Group{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the rotational velocity required to reach the rotationalGoal from the currentRotation.
|
* Calculates the rotational velocity required to reach the rotationalGoal from the
|
||||||
|
* currentRotation.
|
||||||
*/
|
*/
|
||||||
protected Double calculateRotationalVelocity(Double rotationalGoal) {
|
protected Double calculateRotationalVelocity(Double rotationalGoal) {
|
||||||
Double rotationalVelocity = 0.0;
|
Double rotationalVelocity = 0.0;
|
||||||
@@ -310,12 +321,14 @@ public class BoatGroup extends Group{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the destination of the boat and the headng it should have once it reaches
|
* Sets the destination of the boat and the headng it should have once it reaches
|
||||||
|
*
|
||||||
* @param newXValue The X co-ordinate the boat needs to move to.
|
* @param newXValue The X co-ordinate the boat needs to move to.
|
||||||
* @param newYValue The Y co-ordinate the boat needs to move to.
|
* @param newYValue The Y co-ordinate the boat needs to move to.
|
||||||
* @param rotation Rotation to move graphics to.
|
* @param rotation Rotation to move graphics to.
|
||||||
* @param timeValid the time the position values are valid for
|
* @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) {
|
public void setDestination(double newXValue, double newYValue, double rotation,
|
||||||
|
double groundSpeed, long timeValid, double frameRate, long id) {
|
||||||
if (lastTimeValid == 0) {
|
if (lastTimeValid == 0) {
|
||||||
lastTimeValid = timeValid - 200;
|
lastTimeValid = timeValid - 200;
|
||||||
moveTo(newXValue, newYValue, rotation);
|
moveTo(newXValue, newYValue, rotation);
|
||||||
@@ -361,7 +374,6 @@ public class BoatGroup extends Group{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void setTeamNameObjectVisible(Boolean visible) {
|
public void setTeamNameObjectVisible(Boolean visible) {
|
||||||
teamNameObject.setVisible(visible);
|
teamNameObject.setVisible(visible);
|
||||||
}
|
}
|
||||||
@@ -400,9 +412,9 @@ public class BoatGroup extends Group{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Due to javaFX limitations annotations associated with a boat that you want to appear below all boats in the
|
* Due to javaFX limitations annotations associated with a boat that you want to appear below
|
||||||
* Z-axis need to be pulled out of the BoatGroup and added to the parent group of the BoatGroups. This function
|
* all boats in the Z-axis need to be pulled out of the BoatGroup and added to the parent group
|
||||||
* returns these annotations as a group.
|
* of the BoatGroups. This function returns these annotations as a group.
|
||||||
*
|
*
|
||||||
* @return A group containing low priority annotations.
|
* @return A group containing low priority annotations.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user