|
|
|
|
@ -23,6 +23,7 @@ public class ResizableRaceCanvas extends Canvas {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the boats that are to be displayed in this race.
|
|
|
|
|
*
|
|
|
|
|
* @param boats
|
|
|
|
|
*/
|
|
|
|
|
public void setBoats(BoatInRace[] boats) {
|
|
|
|
|
@ -40,33 +41,36 @@ public class ResizableRaceCanvas extends Canvas {
|
|
|
|
|
/**
|
|
|
|
|
* Constructor
|
|
|
|
|
*/
|
|
|
|
|
public ResizableRaceCanvas(){
|
|
|
|
|
public ResizableRaceCanvas() {
|
|
|
|
|
this(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the RaceMap that the RaceCanvas is to be displaying for.
|
|
|
|
|
*
|
|
|
|
|
* @param map
|
|
|
|
|
*/
|
|
|
|
|
public void setMap (RaceMap map) {
|
|
|
|
|
public void setMap(RaceMap map) {
|
|
|
|
|
this.map = map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Displays the mark of a race as a circle.
|
|
|
|
|
*
|
|
|
|
|
* @param graphCoordinate Latitude and Logintude in GraphCoordinate that it is to be displayed as.
|
|
|
|
|
* @param paint Colour the mark is to be coloured.
|
|
|
|
|
* @see GraphCoordinate
|
|
|
|
|
* @see Color
|
|
|
|
|
* @see Paint
|
|
|
|
|
*/
|
|
|
|
|
public void displayMark(GraphCoordinate graphCoordinate, Paint paint){
|
|
|
|
|
public void displayMark(GraphCoordinate graphCoordinate, Paint paint) {
|
|
|
|
|
gc.setFill(paint);
|
|
|
|
|
gc.fillOval(graphCoordinate.getX(), graphCoordinate.getY(), 15, 15);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Displays a line on the map with rectangles on the starting and ending point of the line.
|
|
|
|
|
*
|
|
|
|
|
* @param graphCoordinateA Starting Point of the line in GraphCoordinate.
|
|
|
|
|
* @param graphCoordinateB End Point of the line in GraphCoordinate.
|
|
|
|
|
* @param paint Colour the line is to coloured.
|
|
|
|
|
@ -74,7 +78,7 @@ public class ResizableRaceCanvas extends Canvas {
|
|
|
|
|
* @see Color
|
|
|
|
|
* @see Paint
|
|
|
|
|
*/
|
|
|
|
|
public void displayLine(GraphCoordinate graphCoordinateA, GraphCoordinate graphCoordinateB, Paint paint){
|
|
|
|
|
public void displayLine(GraphCoordinate graphCoordinateA, GraphCoordinate graphCoordinateB, Paint paint) {
|
|
|
|
|
gc.setStroke(paint);
|
|
|
|
|
gc.setFill(paint);
|
|
|
|
|
gc.fillOval(graphCoordinateA.getX() - 3, graphCoordinateA.getY() - 3, 6, 6);
|
|
|
|
|
@ -84,34 +88,37 @@ public class ResizableRaceCanvas extends Canvas {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Display a point on the Canvas
|
|
|
|
|
*
|
|
|
|
|
* @param graphCoordinate Coordinate that the point is to be displayed at.
|
|
|
|
|
* @param paint Colour that the boat is to be coloured.
|
|
|
|
|
* @see GraphCoordinate
|
|
|
|
|
* @see Paint
|
|
|
|
|
* @see Color
|
|
|
|
|
*/
|
|
|
|
|
public void displayPoint(GraphCoordinate graphCoordinate, Paint paint){
|
|
|
|
|
public void displayPoint(GraphCoordinate graphCoordinate, Paint paint) {
|
|
|
|
|
gc.setFill(paint);
|
|
|
|
|
gc.fillOval(graphCoordinate.getX(), graphCoordinate.getY(), 10, 10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Displays an arrow on the Canvas
|
|
|
|
|
*
|
|
|
|
|
* @param coordinate Coordinate that the arrow is to be displayed at.
|
|
|
|
|
* @param angle Angle that the arrow is to be facing in degrees 0 degrees = North (Up).
|
|
|
|
|
* @see GraphCoordinate
|
|
|
|
|
*/
|
|
|
|
|
public void displayArrow(GraphCoordinate coordinate, int angle){
|
|
|
|
|
public void displayArrow(GraphCoordinate coordinate, int angle) {
|
|
|
|
|
gc.save();
|
|
|
|
|
rotate(angle, coordinate.getX(),coordinate.getY());
|
|
|
|
|
gc.fillPolygon(new double[]{coordinate.getX()-12, coordinate.getX()-6, coordinate.getX(), coordinate.getX()-4, coordinate.getX()-4, coordinate.getX()-8, coordinate.getX()-8},
|
|
|
|
|
new double[]{coordinate.getY()-5, coordinate.getY()-20, coordinate.getY()-5, coordinate.getY()-5, coordinate.getY()+20, coordinate.getY()+20, coordinate.getY()-5},
|
|
|
|
|
rotate(angle, coordinate.getX(), coordinate.getY());
|
|
|
|
|
gc.fillPolygon(new double[]{coordinate.getX() - 12, coordinate.getX() - 6, coordinate.getX(), coordinate.getX() - 4, coordinate.getX() - 4, coordinate.getX() - 8, coordinate.getX() - 8},
|
|
|
|
|
new double[]{coordinate.getY() - 5, coordinate.getY() - 20, coordinate.getY() - 5, coordinate.getY() - 5, coordinate.getY() + 20, coordinate.getY() + 20, coordinate.getY() - 5},
|
|
|
|
|
7);
|
|
|
|
|
gc.restore();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Rotates things on the canvas Note: this must be called in between gc.save() and gc.restore() else they will rotate everything
|
|
|
|
|
*
|
|
|
|
|
* @param angle Bearing angle to rotate at in degrees
|
|
|
|
|
* @param px Pivot point x of rotation.
|
|
|
|
|
* @param py Pivot point y of rotation.
|
|
|
|
|
@ -123,13 +130,14 @@ public class ResizableRaceCanvas extends Canvas {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Display given name and speed of boat at a graph coordinate
|
|
|
|
|
*
|
|
|
|
|
* @param name name of the boat
|
|
|
|
|
* @param speed speed of the boat
|
|
|
|
|
* @param coordinate coordinate the text appears
|
|
|
|
|
*/
|
|
|
|
|
public void displayText(String name, double speed, GraphCoordinate coordinate){
|
|
|
|
|
public void displayText(String name, double speed, GraphCoordinate coordinate) {
|
|
|
|
|
String text = name + ", " + speed + " knots";
|
|
|
|
|
gc.fillText(text, coordinate.getX()+20, coordinate.getY());
|
|
|
|
|
gc.fillText(text, coordinate.getX() + 20, coordinate.getY());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -142,9 +150,9 @@ public class ResizableRaceCanvas extends Canvas {
|
|
|
|
|
|
|
|
|
|
gc.clearRect(0, 0, width, height);
|
|
|
|
|
//System.out.println("Race Map Canvas Width: "+ width + ", Height:" + height);
|
|
|
|
|
this.map = new RaceMap(32.278, -64.863, 32.320989, -64.821, (int)width, (int)height);
|
|
|
|
|
this.map = new RaceMap(32.278, -64.863, 32.320989, -64.821, (int) width, (int) height);
|
|
|
|
|
|
|
|
|
|
if (map == null){
|
|
|
|
|
if (map == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -185,6 +193,7 @@ public class ResizableRaceCanvas extends Canvas {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Draws a boat at a certain GPSCoordinate
|
|
|
|
|
*
|
|
|
|
|
* @param colour Colour to colour boat.
|
|
|
|
|
* @param gpsCoordinates GPScoordinate that the boat is to be drawn at.
|
|
|
|
|
* @see GPSCoordinate
|
|
|
|
|
@ -198,6 +207,7 @@ public class ResizableRaceCanvas extends Canvas {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the Canvas to resizable.
|
|
|
|
|
*
|
|
|
|
|
* @return That the Canvas is resizable.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@ -207,6 +217,7 @@ public class ResizableRaceCanvas extends Canvas {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the preferred width of the Canvas
|
|
|
|
|
*
|
|
|
|
|
* @param width
|
|
|
|
|
* @return Returns the width of the Canvas
|
|
|
|
|
*/
|
|
|
|
|
@ -217,6 +228,7 @@ public class ResizableRaceCanvas extends Canvas {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the preferred height of the Canvas
|
|
|
|
|
*
|
|
|
|
|
* @param height
|
|
|
|
|
* @return Returns the height of the Canvas
|
|
|
|
|
*/
|
|
|
|
|
|