mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-03 10:53:49 +00:00
Refactored arrays of the CompetitorInRaceDTO to lists
This commit is contained in:
1 parent
26df01bd1c
commit
86266d7c8b
3 files changed
+36
-18
No files matched your search
+6
-6
@@ -289,10 +289,10 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener, TimeL
|
||||
long starttime = System.currentTimeMillis();
|
||||
List<Pair<String, Long>> markPassingTimes = getCompetitorsAndTimePointsDTO().getMarkPassings(competitor);
|
||||
List<Point> markPassingPoints = new ArrayList<Point>();
|
||||
Double[] markPassingValues = chartData.getMarkPassings(competitor);
|
||||
List<Double> markPassingValues = chartData.getMarkPassings(competitor);
|
||||
for (int j = 0; j < markPassingTimes.size(); j++) {
|
||||
if (markPassingValues[j] != null && markPassingTimes.get(j).getB() != null) {
|
||||
Point markPassingPoint = new Point(markPassingTimes.get(j).getB(), markPassingValues[j]);
|
||||
if (markPassingValues.get(j) != null && markPassingTimes.get(j).getB() != null) {
|
||||
Point markPassingPoint = new Point(markPassingTimes.get(j).getB(), markPassingValues.get(j));
|
||||
markPassingPoint.setName(markPassingTimes.get(j).getA());
|
||||
markPassingPoints.add(markPassingPoint);
|
||||
}
|
||||
@@ -301,12 +301,12 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener, TimeL
|
||||
GWT.log("Update mark passings time for " + competitor.name + ": "
|
||||
+ (System.currentTimeMillis() - starttime));
|
||||
starttime = System.currentTimeMillis();
|
||||
Double[] data = chartData.getRaceData(competitor);
|
||||
List<Double> data = chartData.getRaceData(competitor);
|
||||
List<Long> timepoints = getCompetitorsAndTimePointsDTO().getTimePoints();
|
||||
List<Point> competitorPoints = new ArrayList<Point>();
|
||||
for (int j = 0; j < timepoints.size(); j++) {
|
||||
if (data[j] != null) {
|
||||
Point competitorPoint = new Point(timepoints.get(j), data[j]);
|
||||
if (data.get(j) != null) {
|
||||
Point competitorPoint = new Point(timepoints.get(j), data.get(j));
|
||||
competitorPoints.add(competitorPoint);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -1351,17 +1351,17 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
for (CompetitorDTO competitorDTO : competitorAndTimePointsDTO.getCompetitors()) {
|
||||
Competitor competitor = getCompetitorById(trackedRace.getRace().getCompetitors(), competitorDTO.id);
|
||||
List<Long> timePoints = competitorAndTimePointsDTO.getTimePoints();
|
||||
Double[] entries = new Double[timePoints.size()];
|
||||
List<Double> entries = new ArrayList<Double>();
|
||||
for (int i = 0; i < timePoints.size(); i++) {
|
||||
MillisecondsTimePoint time = new MillisecondsTimePoint(timePoints.get(i));
|
||||
entries[i] = getCompetitorRaceDataEntry(dataType, trackedRace, competitor, time);
|
||||
entries.add(getCompetitorRaceDataEntry(dataType, trackedRace, competitor, time));
|
||||
}
|
||||
competitorData.setRaceData(competitorDTO, entries);
|
||||
entries = new Double[competitorAndTimePointsDTO.getMarkPassings(competitorDTO).size()];
|
||||
entries = new ArrayList<Double>();
|
||||
for (int i = 0; i < competitorAndTimePointsDTO.getMarkPassings(competitorDTO).size(); i++) {
|
||||
MillisecondsTimePoint time = new MillisecondsTimePoint(
|
||||
competitorAndTimePointsDTO.getMarkPassings(competitorDTO).get(i).getB());
|
||||
entries[i] = getCompetitorRaceDataEntry(dataType, trackedRace, competitor, time);
|
||||
entries.add(getCompetitorRaceDataEntry(dataType, trackedRace, competitor, time));
|
||||
}
|
||||
competitorData.setMarkPassingData(competitorDTO, entries);
|
||||
}
|
||||
|
||||
+26
-8
@@ -1,30 +1,48 @@
|
||||
package com.sap.sailing.gwt.ui.shared;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
public class CompetitorInRaceDTO implements IsSerializable {
|
||||
private HashMap<CompetitorDTO, Double[]> raceData;
|
||||
private HashMap<CompetitorDTO, Double[]> markPassings;
|
||||
private HashMap<CompetitorDTO, List<Double>> raceData;
|
||||
private HashMap<CompetitorDTO, List<Double>> markPassings;
|
||||
|
||||
public CompetitorInRaceDTO(){
|
||||
raceData = new HashMap<CompetitorDTO, Double[]>();
|
||||
markPassings = new HashMap<CompetitorDTO, Double[]>();
|
||||
raceData = new HashMap<CompetitorDTO, List<Double>>();
|
||||
markPassings = new HashMap<CompetitorDTO, List<Double>>();
|
||||
}
|
||||
|
||||
public void setRaceData(CompetitorDTO competitor, Double[] data){
|
||||
public void setRaceData(CompetitorDTO competitor, List<Double> data){
|
||||
raceData.put(competitor, data);
|
||||
}
|
||||
|
||||
public void setMarkPassingData(CompetitorDTO competitor, Double[] data){
|
||||
public void setMarkPassingData(CompetitorDTO competitor, List<Double> data){
|
||||
markPassings.put(competitor, data);
|
||||
}
|
||||
|
||||
public Double[] getRaceData(CompetitorDTO competitor){
|
||||
public List<Double> getRaceData(CompetitorDTO competitor){
|
||||
return raceData.get(competitor);
|
||||
}
|
||||
|
||||
public Double[] getMarkPassings(CompetitorDTO competitor){
|
||||
public List<Double> getMarkPassings(CompetitorDTO competitor){
|
||||
return markPassings.get(competitor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds <code>dataToAdd</code> to the race data.<br />
|
||||
* Doesn't check, if the new data is already contained.
|
||||
*/
|
||||
public void addRaceData(CompetitorDTO competitor, List<Double> dataToAdd) {
|
||||
getRaceData(competitor).addAll(dataToAdd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds <code>markPassingsToAdd</code> to the mark passings.
|
||||
* Doesn't check, if the new mark passings are already contained.
|
||||
*/
|
||||
public void addMarkPassings(CompetitorDTO competitor, List<Double> markPassingsToAdd) {
|
||||
getMarkPassings(competitor).addAll(markPassingsToAdd);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user