mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Removing dead code in race view controller and fixed mark rounding bug
This commit is contained in:
@@ -382,8 +382,8 @@ public class GameClient {
|
|||||||
if (raceFinished) {
|
if (raceFinished) {
|
||||||
raceViewController.showFinishDialog(finishedBoats);
|
raceViewController.showFinishDialog(finishedBoats);
|
||||||
Sounds.playFinishSound();
|
Sounds.playFinishSound();
|
||||||
close();
|
// close();
|
||||||
ViewManager.getInstance().getGameClient().stopGame();
|
// ViewManager.getInstance().getGameClient().stopGame();
|
||||||
//loadFinishScreenView();
|
//loadFinishScreenView();
|
||||||
}
|
}
|
||||||
raceState.setRaceFinished();
|
raceState.setRaceFinished();
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ public class GameView3D extends GameView{
|
|||||||
for (ObservableValue o : Arrays
|
for (ObservableValue o : Arrays
|
||||||
.asList(playerBoat.layoutXProperty(), playerBoat.layoutXProperty())) {
|
.asList(playerBoat.layoutXProperty(), playerBoat.layoutXProperty())) {
|
||||||
o.addListener((obs, oldVal, newVal) -> {
|
o.addListener((obs, oldVal, newVal) -> {
|
||||||
|
if (playerYacht.getLegNumber() < course.size()) {
|
||||||
List<Mark> marks = course.get(playerYacht.getLegNumber()).getMarks();
|
List<Mark> marks = course.get(playerYacht.getLegNumber()).getMarks();
|
||||||
Point2D midPoint = new Point2D(0, 0);
|
Point2D midPoint = new Point2D(0, 0);
|
||||||
if (marks.size() == 1) {
|
if (marks.size() == 1) {
|
||||||
@@ -363,6 +363,7 @@ public class GameView3D extends GameView{
|
|||||||
if (midPoint != null) {
|
if (midPoint != null) {
|
||||||
playerBoat.updateMarkIndicator(midPoint);
|
playerBoat.updateMarkIndicator(midPoint);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class FinishScreenViewController implements Initializable {
|
|||||||
|
|
||||||
public void switchToStartScreenView() {
|
public void switchToStartScreenView() {
|
||||||
Sounds.playButtonClick();
|
Sounds.playButtonClick();
|
||||||
setContentPane("/views/StartScreenView.fxml");
|
ViewManager.getInstance().goToStartView();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playButtonHoverSound(MouseEvent mouseEvent) {
|
public void playButtonHoverSound(MouseEvent mouseEvent) {
|
||||||
|
|||||||
@@ -4,62 +4,34 @@ import com.jfoenix.controls.JFXButton;
|
|||||||
import com.jfoenix.controls.JFXDialog;
|
import com.jfoenix.controls.JFXDialog;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import javafx.animation.RotateTransition;
|
import javafx.animation.RotateTransition;
|
||||||
import javafx.animation.Timeline;
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.beans.property.ReadOnlyBooleanProperty;
|
import javafx.beans.property.ReadOnlyBooleanProperty;
|
||||||
import javafx.collections.FXCollections;
|
|
||||||
import javafx.collections.ListChangeListener;
|
|
||||||
import javafx.collections.ObservableList;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.geometry.Point2D;
|
|
||||||
import javafx.scene.Scene;
|
|
||||||
import javafx.scene.SubScene;
|
import javafx.scene.SubScene;
|
||||||
import javafx.scene.chart.LineChart;
|
|
||||||
import javafx.scene.chart.NumberAxis;
|
|
||||||
import javafx.scene.chart.XYChart.Series;
|
|
||||||
import javafx.scene.control.Button;
|
|
||||||
import javafx.scene.control.CheckBox;
|
|
||||||
import javafx.scene.control.ComboBox;
|
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.Slider;
|
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.GridPane;
|
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
import javafx.scene.layout.VBox;
|
|
||||||
import javafx.scene.paint.Color;
|
|
||||||
import javafx.scene.paint.Paint;
|
import javafx.scene.paint.Paint;
|
||||||
import javafx.scene.shape.Line;
|
|
||||||
import javafx.scene.shape.Polyline;
|
|
||||||
import javafx.scene.text.Text;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
import javafx.stage.StageStyle;
|
|
||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
import seng302.model.ClientYacht;
|
import seng302.model.ClientYacht;
|
||||||
import seng302.model.RaceState;
|
import seng302.model.RaceState;
|
||||||
import seng302.model.mark.CompoundMark;
|
|
||||||
import seng302.model.mark.Mark;
|
|
||||||
import seng302.model.stream.xml.parser.RaceXMLData;
|
import seng302.model.stream.xml.parser.RaceXMLData;
|
||||||
import seng302.model.token.TokenType;
|
import seng302.model.token.TokenType;
|
||||||
import seng302.utilities.Sounds;
|
import seng302.utilities.Sounds;
|
||||||
import seng302.visualiser.GameView3D;
|
import seng302.visualiser.GameView3D;
|
||||||
import seng302.visualiser.controllers.annotations.ImportantAnnotationController;
|
|
||||||
import seng302.visualiser.controllers.annotations.ImportantAnnotationDelegate;
|
import seng302.visualiser.controllers.annotations.ImportantAnnotationDelegate;
|
||||||
import seng302.visualiser.controllers.annotations.ImportantAnnotationsState;
|
import seng302.visualiser.controllers.annotations.ImportantAnnotationsState;
|
||||||
import seng302.visualiser.controllers.dialogs.FinishDialogController;
|
import seng302.visualiser.controllers.dialogs.FinishDialogController;
|
||||||
import seng302.visualiser.fxObjects.ChatHistory;
|
import seng302.visualiser.fxObjects.ChatHistory;
|
||||||
import seng302.visualiser.fxObjects.assets_2D.WindArrow;
|
|
||||||
import seng302.visualiser.fxObjects.assets_3D.BoatObject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller class that manages the display of a race
|
* Controller class that manages the display of a race
|
||||||
@@ -74,8 +46,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
private AnchorPane loadingScreenPane;
|
private AnchorPane loadingScreenPane;
|
||||||
@FXML
|
@FXML
|
||||||
private ImageView loadingScreen;
|
private ImageView loadingScreen;
|
||||||
@FXML
|
|
||||||
private Pane basePane;
|
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton chatSend;
|
private JFXButton chatSend;
|
||||||
@FXML
|
@FXML
|
||||||
@@ -83,31 +54,11 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
@FXML
|
@FXML
|
||||||
private TextField chatInput;
|
private TextField chatInput;
|
||||||
@FXML
|
@FXML
|
||||||
private LineChart<String, Double> raceSparkLine;
|
|
||||||
@FXML
|
|
||||||
private NumberAxis sparklineYAxis;
|
|
||||||
@FXML
|
|
||||||
private VBox positionVbox;
|
|
||||||
@FXML
|
|
||||||
private CheckBox toggleFps;
|
|
||||||
@FXML
|
|
||||||
private Label timerLabel;
|
private Label timerLabel;
|
||||||
@FXML
|
@FXML
|
||||||
private StackPane contentStackPane;
|
private StackPane contentStackPane;
|
||||||
|
|
||||||
private GridPane contentGridPane;
|
|
||||||
@FXML
|
|
||||||
private AnchorPane rvAnchorPane;
|
|
||||||
@FXML
|
|
||||||
private AnchorPane windArrowHolder;
|
|
||||||
@FXML
|
|
||||||
private Slider annotationSlider;
|
|
||||||
@FXML
|
|
||||||
private Button selectAnnotationBtn;
|
|
||||||
@FXML
|
|
||||||
private ComboBox<ClientYacht> yachtSelectionComboBox;
|
|
||||||
@FXML
|
|
||||||
private Text fpsDisplay;
|
|
||||||
@FXML
|
@FXML
|
||||||
private ImageView windImageView;
|
private ImageView windImageView;
|
||||||
@FXML
|
@FXML
|
||||||
@@ -119,21 +70,12 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
@FXML
|
@FXML
|
||||||
private ImageView velocityIcon, handlingIcon, windWalkerIcon, bumperIcon, badRandomIcon;
|
private ImageView velocityIcon, handlingIcon, windWalkerIcon, bumperIcon, badRandomIcon;
|
||||||
|
|
||||||
//Race Data
|
|
||||||
private Map<Integer, ClientYacht> participants;
|
|
||||||
private Map<Integer, CompoundMark> markers;
|
|
||||||
private RaceXMLData courseData;
|
|
||||||
private GameView3D gameView;
|
private GameView3D gameView;
|
||||||
private RaceState raceState;
|
private RaceState raceState;
|
||||||
|
|
||||||
private ChatHistory chatHistory;
|
private ChatHistory chatHistory;
|
||||||
|
|
||||||
private Timeline timerTimeline;
|
|
||||||
private Timer timer = new Timer();
|
private Timer timer = new Timer();
|
||||||
private List<Series<String, Double>> sparkLineData = new ArrayList<>();
|
|
||||||
private ImportantAnnotationsState importantAnnotations;
|
|
||||||
private Polyline windArrow = new WindArrow(Color.LIGHTGRAY);
|
|
||||||
private ObservableList<ClientYacht> selectionComboBoxList = FXCollections.observableArrayList();
|
|
||||||
private ClientYacht player;
|
private ClientYacht player;
|
||||||
private JFXDialog finishScreenDialog;
|
private JFXDialog finishScreenDialog;
|
||||||
private FinishDialogController finishDialogController;
|
private FinishDialogController finishDialogController;
|
||||||
@@ -149,11 +91,11 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
Image loadingImage = new Image("PP.png");
|
Image loadingImage = new Image("PP.png");
|
||||||
loadingScreen.setImage(loadingImage);
|
loadingScreen.setImage(loadingImage);
|
||||||
//Centers the Image within the image view
|
//Centers the Image within the image view
|
||||||
double w = 0;
|
double w;
|
||||||
double h = 0;
|
double h;
|
||||||
double ratioX = loadingScreen.getFitWidth() / loadingImage.getWidth();
|
double ratioX = loadingScreen.getFitWidth() / loadingImage.getWidth();
|
||||||
double ratioY = loadingScreen.getFitHeight() / loadingImage.getHeight();
|
double ratioY = loadingScreen.getFitHeight() / loadingImage.getHeight();
|
||||||
double reduceRatio = 0;
|
double reduceRatio;
|
||||||
if(ratioX >= ratioY) {
|
if(ratioX >= ratioY) {
|
||||||
reduceRatio = ratioY;
|
reduceRatio = ratioY;
|
||||||
} else {
|
} else {
|
||||||
@@ -180,9 +122,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
chatHistoryHolder.heightProperty()
|
chatHistoryHolder.heightProperty()
|
||||||
);
|
);
|
||||||
|
|
||||||
contentStackPane.setOnMouseClicked(event -> {
|
contentStackPane.setOnMouseClicked(event -> contentStackPane.requestFocus());
|
||||||
contentStackPane.requestFocus();
|
|
||||||
});
|
|
||||||
Platform.runLater(contentStackPane::requestFocus);
|
Platform.runLater(contentStackPane::requestFocus);
|
||||||
//Makes the chat history non transparent when clicked on
|
//Makes the chat history non transparent when clicked on
|
||||||
chatInput.focusedProperty().addListener((observable, oldValue, newValue) -> {
|
chatInput.focusedProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
@@ -205,12 +145,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
loadingScreenPane.setVisible(false);
|
loadingScreenPane.setVisible(false);
|
||||||
contentStackPane.setVisible(true);
|
contentStackPane.setVisible(true);
|
||||||
|
|
||||||
Platform.runLater(new Runnable() {
|
Platform.runLater(() -> contentStackPane.requestFocus());
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
contentStackPane.requestFocus();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -238,24 +173,13 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
Map<Integer, ClientYacht> participants, RaceXMLData raceData, RaceState raceState,
|
Map<Integer, ClientYacht> participants, RaceXMLData raceData, RaceState raceState,
|
||||||
ClientYacht player) {
|
ClientYacht player) {
|
||||||
|
|
||||||
this.participants = participants;
|
|
||||||
this.courseData = raceData;
|
|
||||||
this.markers = raceData.getCompoundMarks();
|
|
||||||
this.raceState = raceState;
|
this.raceState = raceState;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
||||||
raceState.getPlayerPositions().addListener((ListChangeListener<ClientYacht>) c -> {
|
|
||||||
while (c.next()) {
|
|
||||||
if (c.wasPermutated()) {
|
|
||||||
updateOrder(raceState.getPlayerPositions());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
player.addPowerUpListener(this::displayPowerUpIcon);
|
player.addPowerUpListener(this::displayPowerUpIcon);
|
||||||
player.addPowerDownListener(this::removeIcon);
|
player.addPowerDownListener(this::removeIcon);
|
||||||
|
|
||||||
updateOrder(raceState.getPlayerPositions());
|
|
||||||
gameView = new GameView3D();
|
gameView = new GameView3D();
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
contentStackPane.getChildren().add(0, gameView.getAssets());
|
contentStackPane.getChildren().add(0, gameView.getAssets());
|
||||||
@@ -342,7 +266,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeIcon(ClientYacht yacht) {
|
private void removeIcon(ClientYacht yacht) {
|
||||||
if (yacht == player) {
|
if (yacht == player) {
|
||||||
blinkingTimer.cancel();
|
blinkingTimer.cancel();
|
||||||
iconToDisplay.setVisible(false);
|
iconToDisplay.setVisible(false);
|
||||||
@@ -357,37 +281,10 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
* @param importantAnnotationsState The current state of the selected annotations
|
* @param importantAnnotationsState The current state of the selected annotations
|
||||||
*/
|
*/
|
||||||
public void importantAnnotationsChanged(ImportantAnnotationsState importantAnnotationsState) {
|
public void importantAnnotationsChanged(ImportantAnnotationsState importantAnnotationsState) {
|
||||||
this.importantAnnotations = importantAnnotationsState;
|
// setAnnotations((int) annotationSlider.getValue()); // Refresh the displayed annotations
|
||||||
setAnnotations((int) annotationSlider.getValue()); // Refresh the displayed annotations
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the "select annotations" view in a new window
|
|
||||||
*/
|
|
||||||
private void loadSelectAnnotationView() {
|
|
||||||
try {
|
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader();
|
|
||||||
Stage stage = new Stage();
|
|
||||||
// Set controller
|
|
||||||
ImportantAnnotationController controller = new ImportantAnnotationController(
|
|
||||||
this, stage
|
|
||||||
);
|
|
||||||
fxmlLoader.setController(controller);
|
|
||||||
// Load FXML and set CSS
|
|
||||||
fxmlLoader.setLocation(
|
|
||||||
getClass().getResource("/views/importantAnnotationSelectView.fxml")
|
|
||||||
);
|
|
||||||
Scene scene = new Scene(fxmlLoader.load(), 469, 298);
|
|
||||||
scene.getStylesheets().add(getClass().getResource("/css/master.css").toString());
|
|
||||||
stage.initStyle(StageStyle.UNDECORATED);
|
|
||||||
stage.setScene(scene);
|
|
||||||
stage.show();
|
|
||||||
controller.loadState(importantAnnotations);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialises a timer which updates elements of the RaceView such as wind direction, yacht
|
* Initialises a timer which updates elements of the RaceView such as wind direction, yacht
|
||||||
@@ -406,34 +303,6 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
}, 0, 1000);
|
}, 0, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Iterates over all corners until ones SeqID matches with the yachts current leg number.
|
|
||||||
* Then it gets the compoundMarkID of that corner and uses it to fetch the appropriate mark
|
|
||||||
* Returns null if no next mark found.
|
|
||||||
* @param bg The BoatGroup to find the next mark of
|
|
||||||
* @return The next Mark or null if none found
|
|
||||||
*/
|
|
||||||
private Mark getNextMark(BoatObject bg) {
|
|
||||||
// TODO: 1/08/17 Move to GameView
|
|
||||||
//
|
|
||||||
// Integer legNumber = bg.getClientYacht().getLegNumber();
|
|
||||||
// List<Corner> markSequence = courseData.getMarkSequence();
|
|
||||||
//
|
|
||||||
// if (legNumber == 0) {
|
|
||||||
// return null;
|
|
||||||
// } else if (legNumber == markSequence.size() - 1) {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for (Corner corner : markSequence) {
|
|
||||||
// if (legNumber + 2 == corner.getSeqID()) {
|
|
||||||
// return courseData.getCompoundMarks().get(corner.getCompoundMarkID());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the wind direction arrow and text as from info from the StreamParser
|
* Updates the wind direction arrow and text as from info from the StreamParser
|
||||||
@@ -516,226 +385,6 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
boatHeadingLabel.setText(String.format("Boat Heading:\n%.1f°", player.getHeading()));
|
boatHeadingLabel.setText(String.format("Boat Heading:\n%.1f°", player.getHeading()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the order of the yachts as from the StreamParser and sets them in the yacht order
|
|
||||||
* section
|
|
||||||
*/
|
|
||||||
private void updateOrder(ObservableList<ClientYacht> yachts) {
|
|
||||||
// List<Text> vboxEntries = new ArrayList<>();
|
|
||||||
//
|
|
||||||
// for (int i = 0; i < yachts.size(); i++) {
|
|
||||||
//// System.out.println("yacht == null " + String.valueOf(yacht == null));
|
|
||||||
// if (yachts.get(i).getBoatStatus() == BoatStatus.FINISHED
|
|
||||||
// .getCode()) { // 3 is finish status
|
|
||||||
// Text textToAdd = new Text(i + 1 + ". " +
|
|
||||||
// yachts.get(i).getShortName() + " (Finished)");
|
|
||||||
// textToAdd.setFill(Paint.valueOf("#d3d3d3"));
|
|
||||||
// vboxEntries.add(textToAdd);
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
// Text textToAdd = new Text(i + 1 + ". " +
|
|
||||||
// yachts.get(i).getShortName() + " ");
|
|
||||||
// textToAdd.setFill(Paint.valueOf("#d3d3d3"));
|
|
||||||
// textToAdd.setStyle("");
|
|
||||||
// vboxEntries.add(textToAdd);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// Platform.runLater(() ->
|
|
||||||
// positionVbox.getChildren().setAll(vboxEntries)
|
|
||||||
// );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void updateLaylines(BoatObject bg) {
|
|
||||||
// TODO: 1/08/17 move to GameView
|
|
||||||
//
|
|
||||||
// Mark nextMark = getNextMark(bg);
|
|
||||||
// Boolean isUpwind = null;
|
|
||||||
// // Can only calc leg direction if there is a next mark and it is a gate mark
|
|
||||||
// if (nextMark != null) {
|
|
||||||
// if (nextMark instanceof GateMark) {
|
|
||||||
// if (bg.isUpwindLeg(gameViewController, nextMark)) {
|
|
||||||
// isUpwind = true;
|
|
||||||
// } else {
|
|
||||||
// isUpwind = false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for(MarkObject mg : gameViewController.getMarkGroups()) {
|
|
||||||
//
|
|
||||||
// mg.removeLaylines();
|
|
||||||
//
|
|
||||||
// if (mg.getMainMark().getId() == nextMark.getId()) {
|
|
||||||
//
|
|
||||||
// SingleMark singleMark1 = ((GateMark) nextMark).getSingleMark1();
|
|
||||||
// SingleMark singleMark2 = ((GateMark) nextMark).getSingleMark2();
|
|
||||||
// Point2D markPoint1 = gameViewController
|
|
||||||
// .findScaledXY(singleMark1.getLatitude(), singleMark1.getLongitude());
|
|
||||||
// Point2D markPoint2 = gameViewController
|
|
||||||
// .findScaledXY(singleMark2.getLatitude(), singleMark2.getLongitude());
|
|
||||||
// HashMap<Double, Double> angleAndSpeed;
|
|
||||||
// if (isUpwind) {
|
|
||||||
// angleAndSpeed = PolarTable.getOptimalUpwindVMG(StreamParser.getWindSpeed());
|
|
||||||
// } else {
|
|
||||||
// angleAndSpeed = PolarTable.getOptimalDownwindVMG(StreamParser.getWindSpeed());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Double resultingAngle = angleAndSpeed.keySet().iterator().next();
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Point2D yachtCurrentPos = new Point2D(bg.getBoatLayoutX(), bg.getBoatLayoutY());
|
|
||||||
// Point2D gateMidPoint = markPoint1.midpoint(markPoint2);
|
|
||||||
// Integer lineFuncResult = GeoUtility.lineFunction(yachtCurrentPos, gateMidPoint, markPoint2);
|
|
||||||
// Line rightLayline = new Line();
|
|
||||||
// Line leftLayline = new Line();
|
|
||||||
// if (lineFuncResult == 1) {
|
|
||||||
// rightLayline = makeRightLayline(markPoint2, 180 - resultingAngle, StreamParser.getWindDirection());
|
|
||||||
// leftLayline = makeLeftLayline(markPoint1, 180 - resultingAngle, StreamParser.getWindDirection());
|
|
||||||
// } else if (lineFuncResult == -1) {
|
|
||||||
// rightLayline = makeRightLayline(markPoint1, 180 - resultingAngle, StreamParser.getWindDirection());
|
|
||||||
// leftLayline = makeLeftLayline(markPoint2, 180 - resultingAngle, StreamParser.getWindDirection());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// leftLayline.setStrokeWidth(0.5);
|
|
||||||
// leftLayline.setStroke(bg.getBoat().getColour());
|
|
||||||
//
|
|
||||||
// rightLayline.setStrokeWidth(0.5);
|
|
||||||
// rightLayline.setStroke(bg.getBoat().getColour());
|
|
||||||
//
|
|
||||||
// bg.setLaylines(leftLayline, rightLayline);
|
|
||||||
// mg.addLaylines(leftLayline, rightLayline);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private Point2D getPointRotation(Point2D ref, Double distance, Double angle) {
|
|
||||||
Double newX = ref.getX() + (ref.getX() + distance - ref.getX()) * Math.cos(angle)
|
|
||||||
- (ref.getY() + distance - ref.getY()) * Math.sin(angle);
|
|
||||||
Double newY = ref.getY() + (ref.getX() + distance - ref.getX()) * Math.sin(angle)
|
|
||||||
+ (ref.getY() + distance - ref.getY()) * Math.cos(angle);
|
|
||||||
|
|
||||||
return new Point2D(newX, newY);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Line makeLeftLayline(Point2D startPoint, Double layLineAngle, Double baseAngle) {
|
|
||||||
Point2D ep = getPointRotation(startPoint, 50.0, baseAngle + layLineAngle);
|
|
||||||
Line line = new Line(startPoint.getX(), startPoint.getY(), ep.getX(), ep.getY());
|
|
||||||
return line;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Line makeRightLayline(Point2D startPoint, Double layLineAngle, Double baseAngle) {
|
|
||||||
|
|
||||||
Point2D ep = getPointRotation(startPoint, 50.0, baseAngle - layLineAngle);
|
|
||||||
Line line = new Line(startPoint.getX(), startPoint.getY(), ep.getX(), ep.getY());
|
|
||||||
return line;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialised the combo box with any yachts currently in the race and adds the required listener
|
|
||||||
* for the combobox to take action upon selection
|
|
||||||
*/
|
|
||||||
private void initialiseBoatSelectionComboBox() {
|
|
||||||
// yachtSelectionComboBox.setItems(
|
|
||||||
// FXCollections.observableArrayList(participants.values())
|
|
||||||
// );
|
|
||||||
// //Null check is if the listener is fired but nothing selected
|
|
||||||
// yachtSelectionComboBox.valueProperty().addListener((obs, lastSelection, selectedBoat) -> {
|
|
||||||
// if (selectedBoat != null) {
|
|
||||||
// gameView.selectBoat(selectedBoat);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
//TODO uncomment out
|
|
||||||
// selectionComboBoxList.setAll(participants.values());
|
|
||||||
// yachtSelectionComboBox.setItems(selectionComboBoxList);
|
|
||||||
// yachtSelectionComboBox.valueProperty().addListener((obs, lastSelection, selectedBoat) -> {
|
|
||||||
// if (selectedBoat != null) {
|
|
||||||
// gameView.selectBoat(selectedBoat);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display the list of yachts in the order they finished the race
|
|
||||||
*/
|
|
||||||
private void loadRaceResultView() {
|
|
||||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("/views/FinishView.fxml"));
|
|
||||||
|
|
||||||
try {
|
|
||||||
contentGridPane.getChildren().removeAll();
|
|
||||||
contentGridPane.getChildren().clear();
|
|
||||||
contentGridPane.getChildren().addAll((Pane) loader.load());
|
|
||||||
|
|
||||||
} catch (javafx.fxml.LoadException e) {
|
|
||||||
System.err.println(e.getCause().toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
System.err.println(e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getMillisToFormattedTime(long milliseconds) {
|
|
||||||
return String.format("%02d:%02d:%02d",
|
|
||||||
TimeUnit.MILLISECONDS.toHours(milliseconds),
|
|
||||||
TimeUnit.MILLISECONDS.toMinutes(milliseconds) % 60, //Modulus 60 minutes per hour
|
|
||||||
TimeUnit.MILLISECONDS.toSeconds(milliseconds) % 60 //Modulus 60 seconds per minute
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setAnnotations(Integer annotationLevel) {
|
|
||||||
// switch (annotationLevel) {
|
|
||||||
// // No Annotations
|
|
||||||
// case 0:
|
|
||||||
// gameView.setAnnotationVisibilities(
|
|
||||||
// false, false, false, false, false, false
|
|
||||||
// );
|
|
||||||
// break;
|
|
||||||
// // Important Annotations
|
|
||||||
// case 1:
|
|
||||||
// gameView.setAnnotationVisibilities(
|
|
||||||
// importantAnnotations.getAnnotationState(Annotation.NAME),
|
|
||||||
// importantAnnotations.getAnnotationState(Annotation.SPEED),
|
|
||||||
// importantAnnotations.getAnnotationState(Annotation.ESTTIMETONEXTMARK),
|
|
||||||
// importantAnnotations.getAnnotationState(Annotation.LEGTIME),
|
|
||||||
// importantAnnotations.getAnnotationState(Annotation.TRACK),
|
|
||||||
// importantAnnotations.getAnnotationState(Annotation.WAKE)
|
|
||||||
// );
|
|
||||||
// break;
|
|
||||||
// // All Annotations
|
|
||||||
// case 2:
|
|
||||||
// gameView.setAnnotationVisibilities(
|
|
||||||
// true, true, true, true, true, true
|
|
||||||
// );
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets all the annotations of the selected yacht to be visible and all others to be hidden
|
|
||||||
*
|
|
||||||
* @param yacht The yacht for which we want to view all annotations
|
|
||||||
*/
|
|
||||||
private void setSelectedBoat(ClientYacht yacht) {
|
|
||||||
// for (BoatObject bg : gameViewController.getBoatGroups()) {
|
|
||||||
// //We need to iterate over all race groups to get the matching yacht group belonging to this yacht if we
|
|
||||||
// //are to toggle its annotations, there is no other backwards knowledge of a yacht to its yachtgroup.
|
|
||||||
// if (bg.getBoat().getHullID().equals(yacht.getHullID())) {
|
|
||||||
//// updateLaylines(bg);
|
|
||||||
// bg.setIsSelected(true);
|
|
||||||
//// selectedBoat = yacht;
|
|
||||||
// } else {
|
|
||||||
// bg.setIsSelected(false);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateTokens(RaceXMLData raceData) {
|
public void updateTokens(RaceXMLData raceData) {
|
||||||
gameView.updateTokens(raceData.getTokens());
|
gameView.updateTokens(raceData.getTokens());
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
</CompoundMark>
|
</CompoundMark>
|
||||||
<CompoundMark CompoundMarkID="2">
|
<CompoundMark CompoundMarkID="2">
|
||||||
<Mark Lat="57.670914" Lng="11.835263"/>
|
<Mark Lat="57.670914" Lng="11.835263"/>
|
||||||
<Mark Lat="57.6699024" Lng="11.8353195"/>
|
|
||||||
</CompoundMark>
|
</CompoundMark>
|
||||||
<CompoundMark CompoundMarkID="3">
|
<CompoundMark CompoundMarkID="3">
|
||||||
<Mark Lat="57.6674596" Lng="11.8417500"/>
|
<Mark Lat="57.6674596" Lng="11.8417500"/>
|
||||||
@@ -29,21 +28,27 @@
|
|||||||
<Mark Lat="57.667311" Lng="11.828857"/>
|
<Mark Lat="57.667311" Lng="11.828857"/>
|
||||||
<Mark Lat="57.667334" Lng="11.825853"/>
|
<Mark Lat="57.667334" Lng="11.825853"/>
|
||||||
</CompoundMark>
|
</CompoundMark>
|
||||||
|
<CompoundMark CompoundMarkID="6">
|
||||||
|
<Mark Lat="57.6675700" Lng="11.8359880"/>
|
||||||
|
<Mark Lat="57.667610" Lng="11.833473"/>
|
||||||
|
</CompoundMark>
|
||||||
</Marks>
|
</Marks>
|
||||||
|
|
||||||
<Course>
|
<Course>
|
||||||
<OpeningSegment>
|
<OpeningSegment>
|
||||||
<Corner CompoundMarkID="1" Rounding="PS"/>
|
<Corner CompoundMarkID="1" Rounding="PS"/>
|
||||||
<Corner CompoundMarkID="2" Rounding="P"/>
|
<Corner CompoundMarkID="2" Rounding="S"/>
|
||||||
</OpeningSegment>
|
</OpeningSegment>
|
||||||
|
|
||||||
<RepeatingSegment>
|
<RepeatingSegment>
|
||||||
<Corner CompoundMarkID="3" Rounding="SP"/>
|
<Corner CompoundMarkID="3" Rounding="SP"/>
|
||||||
<Corner CompoundMarkID="4" Rounding="PS"/>
|
<Corner CompoundMarkID="4" Rounding="PS"/>
|
||||||
|
<Corner CompoundMarkID="5" Rounding="PS"/>
|
||||||
|
<Corner CompoundMarkID="2" Rounding="S"/>
|
||||||
</RepeatingSegment>
|
</RepeatingSegment>
|
||||||
|
|
||||||
<ClosingSegment>
|
<ClosingSegment>
|
||||||
<Corner CompoundMarkID="5" Rounding="PS"/>
|
<Corner CompoundMarkID="6" Rounding="PS"/>
|
||||||
</ClosingSegment>
|
</ClosingSegment>
|
||||||
</Course>
|
</Course>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user