Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -25,7 +25,7 @@ public class Constants {
|
||||
{new BoatInRace("Oracle Team USA", 30.0, Color.BLUEVIOLET, "Oracle"),
|
||||
new BoatInRace("Land Rover BAR", 23.0, Color.BLACK, "BAR"),
|
||||
new BoatInRace("SoftBank Team Japan", 27.0, Color.RED, "JAP"),
|
||||
new BoatInRace("Groupama Team France", 25.0, Color.ORANGE, "FRN"),
|
||||
new BoatInRace("Groupama Team France", 25.0, Color.ORANGE, "FRA"),
|
||||
new BoatInRace("Artemis Racing", 22.5, Color.DARKOLIVEGREEN, "ART"),
|
||||
new BoatInRace("Emirates Team New Zealand", 62, Color.LIMEGREEN, "ETNZ")};
|
||||
|
||||
|
||||
@@ -52,7 +52,6 @@ public class RaceController extends Controller{
|
||||
@FXML
|
||||
Label FPS;
|
||||
|
||||
|
||||
@FXML
|
||||
TableView<BoatInRace> boatInfoTable;
|
||||
@FXML
|
||||
@@ -119,7 +118,17 @@ public class RaceController extends Controller{
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
|
||||
//listener for fps
|
||||
showFPS.selectedProperty().addListener(new ChangeListener<Boolean>() {
|
||||
public void changed(ObservableValue<? extends Boolean> ov,
|
||||
Boolean old_val, Boolean new_val) {
|
||||
if (showFPS.isSelected()){
|
||||
FPS.setVisible(true);
|
||||
} else {
|
||||
FPS.setVisible(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -160,20 +169,9 @@ public class RaceController extends Controller{
|
||||
ArrayList<Leg> legs = raceXMLReader.getLegs();
|
||||
ConstantVelocityRace race = new ConstantVelocityRace(boats, legs, this, scaleFactor);
|
||||
|
||||
//start race
|
||||
new Thread((race)).start();
|
||||
|
||||
//listener for fps
|
||||
showFPS.selectedProperty().addListener(new ChangeListener<Boolean>() {
|
||||
public void changed(ObservableValue<? extends Boolean> ov,
|
||||
Boolean old_val, Boolean new_val) {
|
||||
if (showFPS.isSelected()){
|
||||
FPS.setVisible(true);
|
||||
} else {
|
||||
FPS.setVisible(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//listener for annotation
|
||||
showAnno.selectedProperty().addListener(new ChangeListener<Boolean>() {
|
||||
public void changed(ObservableValue<? extends Boolean> ov,
|
||||
|
||||
@@ -28,8 +28,8 @@ public abstract class Race implements Runnable {
|
||||
protected int scaleFactor;
|
||||
|
||||
private int SLEEP_TIME = 100; //time in milliseconds to pause in a paced loop
|
||||
protected int PRERACE_TIME = 10000;//Integer.MAX_VALUE; //time in milliseconds to pause during pre-race
|
||||
private boolean timerEnabled = true;
|
||||
protected int PRERACE_TIME = 5000; //time in milliseconds to pause during pre-race
|
||||
private boolean timerEnabled = true; //boolean to determine if timer is ran
|
||||
|
||||
/**
|
||||
* Initailiser for Race
|
||||
@@ -148,7 +148,7 @@ public abstract class Race implements Runnable {
|
||||
long remainingSeconds;
|
||||
long hours;
|
||||
|
||||
currentTimeInSeconds = (totalTimeElapsed / 1000) * scaleFactor;
|
||||
currentTimeInSeconds = (totalTimeElapsed * scaleFactor)/ 1000;
|
||||
minutes = currentTimeInSeconds / 60;
|
||||
remainingSeconds = currentTimeInSeconds % 60;
|
||||
hours = minutes / 60;
|
||||
@@ -183,13 +183,11 @@ public abstract class Race implements Runnable {
|
||||
*/
|
||||
private void simulateRace() {
|
||||
|
||||
System.setProperty("javafx.animation.fullspeed", "true");
|
||||
|
||||
new AnimationTimer() {
|
||||
|
||||
long timeRaceStarted = System.currentTimeMillis();
|
||||
int fps = 0;
|
||||
long timeCurrent = System.currentTimeMillis();
|
||||
long timeRaceStarted = System.currentTimeMillis(); //start time of loop
|
||||
int fps = 0; //init fps value
|
||||
long timeCurrent = System.currentTimeMillis(); //current time
|
||||
|
||||
@Override
|
||||
public void handle(long arg0) {
|
||||
@@ -211,6 +209,11 @@ public abstract class Race implements Runnable {
|
||||
if (controller != null) controller.updateMap(startingBoats);
|
||||
if (timerEnabled)
|
||||
updateTime(calcTimer());
|
||||
} else {
|
||||
//Exit animation timer
|
||||
updateTime(calcTimer());
|
||||
updateFPS(0); //race ended so fps = 0
|
||||
stop(); //exit animation timer
|
||||
}
|
||||
fps++;
|
||||
if ((System.currentTimeMillis()-timeCurrent) > 1000){
|
||||
|
||||
@@ -2,6 +2,7 @@ package seng302.Model;
|
||||
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.scene.canvas.Canvas;
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.paint.Color;
|
||||
@@ -17,6 +18,7 @@ import java.awt.*;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
/**
|
||||
* This creates a JavaFX Canvas that is fills it's parent.
|
||||
@@ -200,8 +202,8 @@ public class ResizableRaceCanvas extends Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
//display wind direction arrow - specify origin point and angle
|
||||
displayArrow(new GraphCoordinate(500, 20), 100);
|
||||
//display wind direction arrow - specify origin point and angle - angle now set to random angle
|
||||
displayArrow(new GraphCoordinate((int)getWidth()-40, 40), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user