Implemented displayText to display boat name and speed with mark
-method takes in boat name, boat speed and coordinates #story [18, 19]
This commit is contained in:
@@ -25,7 +25,7 @@ public abstract class Race implements Runnable {
|
|||||||
|
|
||||||
|
|
||||||
private int SLEEP_TIME = 25; //time in milliseconds to pause in a paced loop
|
private int SLEEP_TIME = 25; //time in milliseconds to pause in a paced loop
|
||||||
private int PRERACE_TIME = Integer.MAX_VALUE; //time in milliseconds to pause during pre-race
|
private int PRERACE_TIME = 10000;//Integer.MAX_VALUE; //time in milliseconds to pause during pre-race
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initailiser for Race
|
* Initailiser for Race
|
||||||
|
|||||||
@@ -124,6 +124,16 @@ public class ResizableRaceCanvas extends Canvas {
|
|||||||
gc.setTransform(r.getMxx(), r.getMyx(), r.getMxy(), r.getMyy(), r.getTx(), r.getTy());
|
gc.setTransform(r.getMxx(), r.getMyx(), r.getMxy(), r.getMyy(), r.getTx(), r.getTy());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display given name and speed of boat at a graph coordinate
|
||||||
|
* @param name name of boat
|
||||||
|
* @param coordinate coordinate the text appears
|
||||||
|
*/
|
||||||
|
public void displayText(String name, double speed, GraphCoordinate coordinate){
|
||||||
|
String text = name + ", " + speed + " knots";
|
||||||
|
gc.fillText(text, coordinate.getX()+20, coordinate.getY());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the Race Map
|
* Draws the Race Map
|
||||||
*/
|
*/
|
||||||
@@ -166,6 +176,7 @@ public class ResizableRaceCanvas extends Canvas {
|
|||||||
if (boat != null) {
|
if (boat != null) {
|
||||||
// System.out.print("Drawing Boat At: " + boat.getCurrentPosition());
|
// System.out.print("Drawing Boat At: " + boat.getCurrentPosition());
|
||||||
displayMark(this.map.convertGPS(boat.getCurrentPosition()), boat.getColour());
|
displayMark(this.map.convertGPS(boat.getCurrentPosition()), boat.getColour());
|
||||||
|
displayText(boat.getName(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user