Changed line appearance and colour.

-Line displayed will no longer plot a point every update.
-Line colours are based on the colours displayed in the race.
-Race colours defined in ResizableRaceCanvas have been used for the lines.
-As boats change colour depending on placement (unintended), the lines will also do this.

#story[876]
main
zwu18 9 years ago
parent f999967cd5
commit f19a543b68

@ -7,14 +7,18 @@ import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.control.*;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import seng302.Mock.StreamedRace;
import seng302.Model.*;
import seng302.VisualiserInput;
import java.awt.Color;
import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;
import java.util.*;
import java.util.List;
/**
* Created by fwy13 on 15/03/2017.
@ -28,6 +32,7 @@ public class RaceController extends Controller {
private Integer sparkLineNumber = 0;
private ResizableRaceCanvas raceMap;
private ResizableRaceMap raceBoundaries;
private ArrayList colours;
@FXML SplitPane race;
@FXML CheckBox showFPS;
@FXML CheckBox showBoatPath;
@ -98,6 +103,8 @@ public class RaceController extends Controller {
// TODO replace for loop with boatsInRace
//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);
}
@ -114,6 +121,10 @@ public class RaceController extends Controller {
yAxis.setAutoRanging(false);
xAxis.setAutoRanging(false);
sparklineChart.setCreateSymbols(false);
sparklineChart.setStyle(".default-color0.chart-series-line { -fx-stroke: #e9967a; }");
// hide axis ticks and labels
sparklineChart.getXAxis().setTickLabelsVisible(false);
sparklineChart.getYAxis().setTickLabelsVisible(false);
@ -207,15 +218,16 @@ public class RaceController extends Controller {
// 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());
System.out.println(startBoats.get(0).toString());
sparkLineNumber++;
for (int i=0; i<boatsInRace.size(); i++){
for (int j=0; j<startBoats.size(); 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;
placingVal-=1;
}
}
@ -223,6 +235,20 @@ public class RaceController extends Controller {
xAxis.setUpperBound(sparkLineNumber);
}
private void makeColours() {
colours = new ArrayList<>(Arrays.asList(
"#8A2BE2",
"#000000",
"#FF0000",
"#FFA500",
"#556B2F",
"#32CD32",
"#800080",
"#A9A9A9",
"#FFFF00"
));
}
/**
* Set up boat annotations
*/

@ -190,7 +190,6 @@ public class StreamedRace implements Runnable {
public void handle(long arg0) {
if (boatsFinished < startingBoats.size()) {
boatsFinished = 0;
controller.updateSparkline(startingBoats);
totalTimeElapsed = System.currentTimeMillis() - timeRaceStarted;
for (Boat boat : startingBoats) {
@ -213,6 +212,9 @@ public class StreamedRace implements Runnable {
controller.finishRace(startingBoats);
stop();
}
controller.updateSparkline(startingBoats);
controller.updateMap(startingBoats, boatMarkers);
fps++;
if ((System.currentTimeMillis() - timeCurrent) > 1000) {

Loading…
Cancel
Save