mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Started to implement the group over the canvas in the code. Removed basic boat redrawing and timeline and replaced with boats being placed into a group and given coordinates.
This commit is contained in:
@@ -42,6 +42,7 @@ public class RaceViewController {
|
||||
@FXML
|
||||
private CanvasController includedCanvasController;
|
||||
|
||||
private ArrayList<Boat> startingBoats = new ArrayList<>();
|
||||
private boolean displayAnnotations;
|
||||
private boolean displayFps;
|
||||
private Timeline timerTimeline;
|
||||
@@ -50,24 +51,29 @@ public class RaceViewController {
|
||||
private Race race;
|
||||
|
||||
public void initialize() {
|
||||
includedCanvasController.setup(this);
|
||||
RaceController raceController = new RaceController();
|
||||
raceController.initializeRace();
|
||||
race = raceController.getRace();
|
||||
for (Boat boat : race.getBoats()) {
|
||||
startingBoats.add(boat);
|
||||
}
|
||||
// try{
|
||||
// initializeTimelines();
|
||||
// }
|
||||
// catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
includedCanvasController.setup(this);
|
||||
includedCanvasController.setUpBoats();
|
||||
initializeTimer();
|
||||
initializeSettings();
|
||||
try{
|
||||
initializeTimelines();
|
||||
}
|
||||
catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//set wind direction!!!!!!! can't find another place to put my code --haoming
|
||||
double windDirection = new ConfigParser("/config/config.xml").getWindDirection();
|
||||
windDirectionText.setText(String.format("%.1f°", windDirection));
|
||||
windArrowText.setRotate(windDirection);
|
||||
|
||||
}
|
||||
|
||||
private void initializeSettings(){
|
||||
@@ -114,39 +120,39 @@ public class RaceViewController {
|
||||
*/
|
||||
private void initializeTimelines() {
|
||||
HashMap<Boat, List> boat_events = race.getEvents();
|
||||
|
||||
for (Boat boat : boat_events.keySet()) {
|
||||
// x, y are the real time coordinates
|
||||
DoubleProperty x = new SimpleDoubleProperty();
|
||||
DoubleProperty y = new SimpleDoubleProperty();
|
||||
|
||||
List<KeyFrame> keyFrames = new ArrayList<>();
|
||||
List<Event> events = boat_events.get(boat);
|
||||
|
||||
// iterates all events and convert each event to keyFrame, then add them into a list
|
||||
for (Event event : events) {
|
||||
if (event.getIsFinishingEvent()) {
|
||||
keyFrames.add(
|
||||
new KeyFrame(Duration.seconds(event.getTime()),
|
||||
onFinished -> {race.setBoatFinished(boat); handleEvent(event);},
|
||||
new KeyValue(x, event.getThisMark().getLatitude()),
|
||||
new KeyValue(y, event.getThisMark().getLongitude())
|
||||
)
|
||||
);
|
||||
} else {
|
||||
keyFrames.add(
|
||||
new KeyFrame(Duration.seconds(event.getTime()),
|
||||
onFinished ->{
|
||||
handleEvent(event);
|
||||
boat.setHeading(event.getBoatHeading());
|
||||
},
|
||||
new KeyValue(x, event.getThisMark().getLatitude()),
|
||||
new KeyValue(y, event.getThisMark().getLongitude())
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
timelineInfos.put(boat, new TimelineInfo(new Timeline(keyFrames.toArray(new KeyFrame[keyFrames.size()])), x, y));
|
||||
startingBoats.add(boat);
|
||||
// // x, y are the real time coordinates
|
||||
// DoubleProperty x = new SimpleDoubleProperty();
|
||||
// DoubleProperty y = new SimpleDoubleProperty();
|
||||
//
|
||||
// List<KeyFrame> keyFrames = new ArrayList<>();
|
||||
// List<Event> events = boat_events.get(boat);
|
||||
//
|
||||
// // iterates all events and convert each event to keyFrame, then add them into a list
|
||||
// for (Event event : events) {
|
||||
// if (event.getIsFinishingEvent()) {
|
||||
// keyFrames.add(
|
||||
// new KeyFrame(Duration.seconds(event.getTime()),
|
||||
// onFinished -> {race.setBoatFinished(boat); handleEvent(event);},
|
||||
// new KeyValue(x, event.getThisMark().getLatitude()),
|
||||
// new KeyValue(y, event.getThisMark().getLongitude())
|
||||
// )
|
||||
// );
|
||||
// } else {
|
||||
// keyFrames.add(
|
||||
// new KeyFrame(Duration.seconds(event.getTime()),
|
||||
// onFinished ->{
|
||||
// handleEvent(event);
|
||||
// boat.setHeading(event.getBoatHeading());
|
||||
// },
|
||||
// new KeyValue(x, event.getThisMark().getLatitude()),
|
||||
// new KeyValue(y, event.getThisMark().getLongitude())
|
||||
// )
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// timelineInfos.put(boat, new TimelineInfo(new Timeline(keyFrames.toArray(new KeyFrame[keyFrames.size()])), x, y));
|
||||
}
|
||||
setRaceDuration();
|
||||
}
|
||||
@@ -277,4 +283,8 @@ public class RaceViewController {
|
||||
public Map<Boat, TimelineInfo> getTimelineInfos() {
|
||||
return timelineInfos;
|
||||
}
|
||||
|
||||
public ArrayList<Boat> getStartingBoats(){
|
||||
return startingBoats;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user