From 98c5c4656979411a618e9af5268c0364ee77ba74 Mon Sep 17 00:00:00 2001 From: David Wu Date: Mon, 20 Mar 2017 16:46:59 +1300 Subject: [PATCH] Implemented displayText to display boat name and speed with mark -method takes in boat name, boat speed and coordinates #story [18, 19] --- src/main/java/seng302/Model/Race.java | 2 +- src/main/java/seng302/Model/ResizableRaceCanvas.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/seng302/Model/Race.java b/src/main/java/seng302/Model/Race.java index 96fb96cc..dbaa64de 100644 --- a/src/main/java/seng302/Model/Race.java +++ b/src/main/java/seng302/Model/Race.java @@ -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 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 diff --git a/src/main/java/seng302/Model/ResizableRaceCanvas.java b/src/main/java/seng302/Model/ResizableRaceCanvas.java index 9cbd403f..06682736 100644 --- a/src/main/java/seng302/Model/ResizableRaceCanvas.java +++ b/src/main/java/seng302/Model/ResizableRaceCanvas.java @@ -124,6 +124,16 @@ public class ResizableRaceCanvas extends Canvas { 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 */ @@ -166,6 +176,7 @@ public class ResizableRaceCanvas extends Canvas { if (boat != null) { // System.out.print("Drawing Boat At: " + boat.getCurrentPosition()); displayMark(this.map.convertGPS(boat.getCurrentPosition()), boat.getColour()); + displayText(boat.getName(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition())); } } }