|
|
|
|
@ -10,12 +10,12 @@ import javafx.scene.control.*;
|
|
|
|
|
import javafx.scene.control.Button;
|
|
|
|
|
import javafx.scene.control.Label;
|
|
|
|
|
import javafx.scene.layout.GridPane;
|
|
|
|
|
import javafx.scene.paint.Color;
|
|
|
|
|
import seng302.Mock.StreamedRace;
|
|
|
|
|
import seng302.Model.*;
|
|
|
|
|
import seng302.VisualiserInput;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.awt.Color;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
@ -32,7 +32,8 @@ public class RaceController extends Controller {
|
|
|
|
|
private Integer sparkLineNumber = 0;
|
|
|
|
|
private ResizableRaceCanvas raceMap;
|
|
|
|
|
private ResizableRaceMap raceBoundaries;
|
|
|
|
|
private ArrayList colours;
|
|
|
|
|
private ArrayList<String> colours;
|
|
|
|
|
private Map<Integer, String> boatColours = new HashMap<>();
|
|
|
|
|
@FXML SplitPane race;
|
|
|
|
|
@FXML CheckBox showFPS;
|
|
|
|
|
@FXML CheckBox showBoatPath;
|
|
|
|
|
@ -104,14 +105,12 @@ public class RaceController extends Controller {
|
|
|
|
|
//int [] boats = {1, 2, 3, 4, 5, 6};
|
|
|
|
|
// set a line for each boat
|
|
|
|
|
makeColours();
|
|
|
|
|
System.out.println(colours.get(0));
|
|
|
|
|
for (Boat boat : boats){
|
|
|
|
|
startBoats.add(boat);
|
|
|
|
|
}
|
|
|
|
|
startBoats.addAll(boats);
|
|
|
|
|
mapBoatColours();
|
|
|
|
|
for (int i=0; i<startBoats.size(); i++){
|
|
|
|
|
Float startPos = ((float)startBoats.size()+1)/2;
|
|
|
|
|
XYChart.Series<Number, Number> series = new XYChart.Series();
|
|
|
|
|
series.getData().add(new XYChart.Data(0, startPos));
|
|
|
|
|
series.getData().add(new XYChart.Data(0, i + 1));
|
|
|
|
|
sparklineChart.getData().add(series);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -133,6 +132,8 @@ public class RaceController extends Controller {
|
|
|
|
|
lookup(".axis-minor-tick-mark").setVisible(false);
|
|
|
|
|
sparklineChart.getYAxis().
|
|
|
|
|
lookup(".axis-minor-tick-mark").setVisible(false);
|
|
|
|
|
|
|
|
|
|
updateSparkline(boats);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -214,20 +215,19 @@ public class RaceController extends Controller {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateSparkline(ObservableList<Boat> boatsInRace){
|
|
|
|
|
System.out.println(sparklineChart.getData().size());
|
|
|
|
|
// TODO replace for loops with correct boats - Done
|
|
|
|
|
//int [] startingBoats = {1, 2, 3, 4, 5, 6};
|
|
|
|
|
//int [] boatsInRace = {1, 2, 3, 4, 5, 6};
|
|
|
|
|
int colourIndex = 0;
|
|
|
|
|
int placingVal = boatsInRace.size();
|
|
|
|
|
//System.out.println(boatsInRace.get(0).toString());
|
|
|
|
|
sparkLineNumber++;
|
|
|
|
|
for (int i=0; i<boatsInRace.size(); i++){
|
|
|
|
|
for (int j=0; j<startBoats.size(); j++){
|
|
|
|
|
for (int i = boatsInRace.size() - 1; i >= 0; i--){
|
|
|
|
|
for (int j = startBoats.size() - 1; j >= 0; j--){
|
|
|
|
|
if (boatsInRace.get(i)==startBoats.get(j)){
|
|
|
|
|
sparklineChart.getData().get(j).getData().add(new XYChart.Data<>
|
|
|
|
|
(sparkLineNumber, placingVal));
|
|
|
|
|
sparklineChart.getData().get(j).getNode().setStyle("-fx-stroke: "+colours.get(colourIndex)+";");
|
|
|
|
|
colourIndex+=1;
|
|
|
|
|
sparklineChart.getData().get(j).getNode().setStyle("-fx-stroke: "+boatColours.get(boatsInRace.get(i).getSourceID())+";");
|
|
|
|
|
placingVal-=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -237,18 +237,28 @@ public class RaceController extends Controller {
|
|
|
|
|
|
|
|
|
|
private void makeColours() {
|
|
|
|
|
colours = new ArrayList<>(Arrays.asList(
|
|
|
|
|
"#8A2BE2",
|
|
|
|
|
"#000000",
|
|
|
|
|
"#FF0000",
|
|
|
|
|
"#FFA500",
|
|
|
|
|
"#556B2F",
|
|
|
|
|
"#32CD32",
|
|
|
|
|
"#800080",
|
|
|
|
|
"#A9A9A9",
|
|
|
|
|
"#FFFF00"
|
|
|
|
|
colourToHex(Color.BLUEVIOLET),
|
|
|
|
|
colourToHex(Color.BLACK),
|
|
|
|
|
colourToHex(Color.RED),
|
|
|
|
|
colourToHex(Color.ORANGE),
|
|
|
|
|
colourToHex(Color.DARKOLIVEGREEN),
|
|
|
|
|
colourToHex(Color.LIMEGREEN),
|
|
|
|
|
colourToHex(Color.PURPLE),
|
|
|
|
|
colourToHex(Color.DARKGRAY),
|
|
|
|
|
colourToHex(Color.YELLOW)
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mapBoatColours() {
|
|
|
|
|
int currentColour = 0;
|
|
|
|
|
for (Boat boat : startBoats) {
|
|
|
|
|
if (!boatColours.containsKey(boat.getSourceID())) {
|
|
|
|
|
boatColours.put(boat.getSourceID(), colours.get(currentColour));
|
|
|
|
|
}
|
|
|
|
|
currentColour = (currentColour + 1) % colours.size();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set up boat annotations
|
|
|
|
|
*/
|
|
|
|
|
@ -299,4 +309,11 @@ public class RaceController extends Controller {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String colourToHex(Color color) {
|
|
|
|
|
return String.format( "#%02X%02X%02X",
|
|
|
|
|
(int)( color.getRed() * 255 ),
|
|
|
|
|
(int)( color.getGreen() * 255 ),
|
|
|
|
|
(int)( color.getBlue() * 255 ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|