@ -6,13 +6,11 @@ import javafx.scene.paint.Color;
import javafx.scene.paint.Paint ;
import javafx.scene.text.Font ;
import javafx.scene.transform.Rotate ;
import network.Messages.Enums.BoatStatusEnum ;
import shared.dataInput.RaceDataSource ;
import shared.enums.RoundingType ;
import shared.model.* ;
import java.util.ArrayList ;
import java.util.Comparator ;
import java.util.List ;
/ * *
@ -44,13 +42,15 @@ public class ResizableRaceCanvas extends ResizableCanvas {
private VisualiserRaceState raceState ;
private boolean annoName = tru e;
private boolean annoName = fals e;
private boolean annoAbbrev = true ;
private boolean annoSpeed = tru e;
private boolean annoSpeed = fals e;
private boolean annoPath = true ;
private boolean annoEstTime = true ;
private boolean annoTimeSinceLastMark = true ;
private boolean annoGuideLine = false ;
private boolean annoEstTime = false ;
private boolean annoTimeSinceLastMark = false ;
private boolean annoGuideLine = true ;
private boolean isFullScreen = false ;
@ -293,7 +293,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
List < VisualiserBoat > boats = new ArrayList < > ( raceState . getBoats ( ) ) ;
//Sort to ensure we draw boats in consistent order.
boats . sort ( Comparator . comparingInt ( Boat : : getSourceID ) ) ;
// boats.sort(Comparator.comparingInt(Boat::getSourceID));
//Current draw order:
// track points
@ -302,29 +302,29 @@ public class ResizableRaceCanvas extends ResizableCanvas {
// text
//Track points.
for ( VisualiserBoat boat : boats ) {
drawTrack ( boat ) ;
}
if ( isFullScreen ) {
for ( VisualiserBoat boat : boats ) {
drawTrack ( boat ) ;
}
//Wake.
for ( VisualiserBoat boat : boats ) {
//Only draw wake if they are currently racing.
if ( boat . getStatus ( ) = = BoatStatusEnum . RACING ) {
drawWake ( boat ) ;
//Text.
for ( VisualiserBoat boat : boats ) {
drawBoatText ( boat ) ;
}
}
//Wake.
// for (VisualiserBoat boat : boats) {
// //Only draw wake if they are currently racing.
// if (boat.getStatus() == BoatStatusEnum.RACING) {
// drawWake(boat);
// }
// }
//Boat.
for ( VisualiserBoat boat : boats ) {
drawBoat ( boat ) ;
}
//Text.
for ( VisualiserBoat boat : boats ) {
drawBoatText ( boat ) ;
}
}
/ * *
@ -364,9 +364,9 @@ public class ResizableRaceCanvas extends ResizableCanvas {
gc . fillPolygon ( x , y , x . length ) ;
gc . restore ( ) ;
if ( boat . getSourceID ( ) = = ThisBoat . getInstance ( ) . getSourceID ( ) ) {
drawSails ( boat ) ;
}
// if (boat.getSourceID() == ThisBoat.getInstance().getSourceID()) {
// drawSails(boat);
// }
}
/ * *
@ -605,7 +605,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
//Prepare to draw.
gc . setLineWidth ( 1 ) ;
gc . setFill ( Color . AQUA ) ;
gc . setFill ( Color . DEEPSKYBLUE ) ;
//Calculate the screen coordinates of the boundary.
@ -645,19 +645,23 @@ public class ResizableRaceCanvas extends ResizableCanvas {
//Race boundary.
drawBoundary ( ) ;
//Guiding Line
if ( annoGuideLine ) {
//rounding lines
if ( isFullScreen ) {
drawRoundingLines ( ) ;
drawRaceLine ( ) ;
}
//Guiding Line
// if (annoGuideLine){
// drawRaceLine();
// }
//Boats.
drawBoats ( ) ;
//Marks.
drawMarks ( ) ;
//TEMP
drawRoundingLines ( ) ;
}
@ -752,7 +756,8 @@ public class ResizableRaceCanvas extends ResizableCanvas {
gc . save ( ) ;
gc . setLineWidth ( 2 ) ;
gc . setStroke ( Color . MEDIUMAQUAMARINE ) ;
gc . setStroke ( getLineColor ( legs . get ( index ) ) ) ;
gc . beginPath ( ) ;
gc . moveTo ( startPath . getX ( ) , startPath . getY ( ) ) ;
@ -772,7 +777,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
gc . save ( ) ;
gc . setLineWidth ( 2 ) ;
gc . setStroke ( Color. MEDIUMAQUAMARINE ) ;
gc . setStroke ( getLineColor( legs . get ( index ) ) ) ;
gc . beginPath ( ) ;
gc . moveTo ( startPath . getX ( ) , startPath . getY ( ) ) ;
@ -788,6 +793,21 @@ public class ResizableRaceCanvas extends ResizableCanvas {
}
}
private Color getLineColor ( Leg leg ) {
for ( VisualiserBoat boat : raceState . getBoats ( ) ) {
if ( boat . isClientBoat ( ) ) {
if ( boat . getCurrentLeg ( ) = = leg ) {
return Color . ORANGE ;
} else {
return Color . MEDIUMAQUAMARINE ;
}
} else {
return Color . MEDIUMAQUAMARINE ;
}
}
return Color . MEDIUMAQUAMARINE ;
}
private void drawArrowHead ( GPSCoordinate start , GPSCoordinate end ) {
GraphCoordinate lineStart = this . map . convertGPS ( start ) ;
@ -862,6 +882,11 @@ public class ResizableRaceCanvas extends ResizableCanvas {
}
public boolean isFullScreen ( ) {
return isFullScreen ;
}
public void setFullScreen ( boolean fullScreen ) {
isFullScreen = fullScreen ;
}
}