mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
The line chart now has series which display on it.
Need to get the right data to display on the linechart when it updates. #story[952]
This commit is contained in:
@@ -22,10 +22,7 @@ import seng302.models.parsers.XMLParser.RaceXMLObject.Limit;
|
|||||||
import seng302.models.parsers.packets.BoatPositionPacket;
|
import seng302.models.parsers.packets.BoatPositionPacket;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.PriorityBlockingQueue;
|
import java.util.concurrent.PriorityBlockingQueue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,7 +101,13 @@ public class CanvasController {
|
|||||||
gc.restore();
|
gc.restore();
|
||||||
fitMarksToCanvas();
|
fitMarksToCanvas();
|
||||||
|
|
||||||
|
Timer t = new Timer();
|
||||||
|
t.schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
}
|
||||||
|
},1000);
|
||||||
// TODO: 1/05/17 wmu16 - Change this call to now draw the marks as from the xml
|
// TODO: 1/05/17 wmu16 - Change this call to now draw the marks as from the xml
|
||||||
drawBoats();
|
drawBoats();
|
||||||
timer = new AnimationTimer() {
|
timer = new AnimationTimer() {
|
||||||
@@ -125,6 +128,10 @@ public class CanvasController {
|
|||||||
long elapsedNanosPerFrame = elapsedNanos / frameTimes.length ;
|
long elapsedNanosPerFrame = elapsedNanos / frameTimes.length ;
|
||||||
Double frameRate = 1_000_000_000.0 / elapsedNanosPerFrame ;
|
Double frameRate = 1_000_000_000.0 / elapsedNanosPerFrame ;
|
||||||
drawFps(frameRate.intValue());
|
drawFps(frameRate.intValue());
|
||||||
|
System.out.println(elapsedNanos);
|
||||||
|
if (elapsedNanos % 10 == 0) {
|
||||||
|
raceViewController.updateSparkLine();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: 1/05/17 cir27 - Make the RaceObjects update on the actual delay.
|
// TODO: 1/05/17 cir27 - Make the RaceObjects update on the actual delay.
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
private Timeline timerTimeline;
|
private Timeline timerTimeline;
|
||||||
private Race race;
|
private Race race;
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
|
private ArrayList<XYChart.Series<String, Double>> sparklineData = new ArrayList<>();
|
||||||
|
private int time;
|
||||||
|
|
||||||
private int index = 0;
|
private int index = 0;
|
||||||
|
|
||||||
@@ -95,6 +97,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
selectAnnotationBtn.setOnAction(event -> {
|
selectAnnotationBtn.setOnAction(event -> {
|
||||||
loadSelectAnnotationView();
|
loadSelectAnnotationView();
|
||||||
});
|
});
|
||||||
|
time = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -185,12 +188,24 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
private void initializeSparkline(){
|
private void initializeSparkline(){
|
||||||
raceSparkLine.setTitle("Boat Positions");
|
raceSparkLine.setTitle("Boat Positions");
|
||||||
for (Yacht yacht: startingBoats){
|
for (Yacht yacht: startingBoats){
|
||||||
if (raceSparkLine.getData().contains(yacht.getSparklinePosition())) {
|
XYChart.Series<String, Double> yachtData = new XYChart.Series<>();
|
||||||
raceSparkLine.getData().remove(yacht.getSparklinePosition());
|
yachtData.getData().add(new XYChart.Data<>(Integer.toString(time), Double.parseDouble(yacht.getPosition())));
|
||||||
}
|
sparklineData.add(yachtData);
|
||||||
raceSparkLine.getData().add(yacht.getSparklinePosition());
|
|
||||||
System.out.println("Here");
|
System.out.println("Here");
|
||||||
}
|
}
|
||||||
|
for (Series<String, Double> spark:
|
||||||
|
sparklineData){
|
||||||
|
raceSparkLine.getData().add(spark);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateSparkLine(){
|
||||||
|
for (int i = 0; i < startingBoats.size();i++){
|
||||||
|
sparklineData.get(i).getData().add(new XYChart.Data<>(Integer.toString(time),Double.parseDouble(startingBoats.get(i).getPosition())));
|
||||||
|
System.out.println("Here");
|
||||||
|
}
|
||||||
|
time++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package seng302.models;
|
|||||||
|
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import javafx.scene.chart.XYChart;
|
import javafx.scene.chart.XYChart;
|
||||||
import javafx.scene.chart.XYChart.Data;
|
|
||||||
import javafx.scene.chart.XYChart.Series;
|
import javafx.scene.chart.XYChart.Series;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
|
|
||||||
@@ -40,8 +39,6 @@ public class Yacht {
|
|||||||
// Mark rounding
|
// Mark rounding
|
||||||
private Long markRoundingTime;
|
private Long markRoundingTime;
|
||||||
|
|
||||||
// Used for sparkline
|
|
||||||
private XYChart.Series<Number, Number> sparklinePosition;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used in EventTest and RaceTest.
|
* Used in EventTest and RaceTest.
|
||||||
@@ -64,8 +61,6 @@ public class Yacht {
|
|||||||
this.velocity = boatVelocity;
|
this.velocity = boatVelocity;
|
||||||
this.shortName = shortName;
|
this.shortName = shortName;
|
||||||
this.sourceID = id;
|
this.sourceID = id;
|
||||||
this.sparklinePosition = new XYChart.Series<>();
|
|
||||||
this.sparklinePosition.setName(boatName);
|
|
||||||
index = 0;
|
index = 0;
|
||||||
dataQ1 = new ConcurrentLinkedQueue<>();
|
dataQ1 = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
@@ -78,8 +73,6 @@ public class Yacht {
|
|||||||
this.shortName = shortName;
|
this.shortName = shortName;
|
||||||
this.boatName = boatName;
|
this.boatName = boatName;
|
||||||
this.country = country;
|
this.country = country;
|
||||||
this.sparklinePosition = new XYChart.Series<>();
|
|
||||||
this.sparklinePosition.setName(boatName);
|
|
||||||
index = 0;
|
index = 0;
|
||||||
dataQ1 = new ConcurrentLinkedQueue<>();
|
dataQ1 = new ConcurrentLinkedQueue<>();
|
||||||
}
|
}
|
||||||
@@ -162,7 +155,6 @@ public class Yacht {
|
|||||||
try {
|
try {
|
||||||
if (Integer.parseInt(position) != Integer.parseInt(this.position)){
|
if (Integer.parseInt(position) != Integer.parseInt(this.position)){
|
||||||
dataQ1.add(Integer.parseInt(position));
|
dataQ1.add(Integer.parseInt(position));
|
||||||
sparklinePosition.getData().add(new XYChart.Data<>(index++, dataQ1.remove()));
|
|
||||||
System.out.println("new position found for " + boatName + " in position " + position + " old(" + this.position + ")");
|
System.out.println("new position found for " + boatName + " in position " + position + " old(" + this.position + ")");
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
@@ -195,10 +187,6 @@ public class Yacht {
|
|||||||
this.markRoundingTime = markRoundingTime;
|
this.markRoundingTime = markRoundingTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Series<Number, Number> getSparklinePosition() {
|
|
||||||
return sparklinePosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return boatName;
|
return boatName;
|
||||||
|
|||||||
Reference in New Issue
Block a user