Merge branch 'gwt' into maneuverdetectiontest

This commit is contained in:
Fabian Schwarz-Fritz committed 2011-12-16 10:41:11 +01:00
commit a7c374471a
12 files changed
+148 -98

No files matched your search

@@ -36,7 +36,6 @@ import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Anchor;
@@ -58,6 +57,7 @@ import com.google.gwt.user.client.ui.Widget;
import com.sap.sailing.gwt.ui.shared.CompetitorDAO;
import com.sap.sailing.gwt.ui.shared.CompetitorInRaceDAO;
import com.sap.sailing.gwt.ui.shared.CompetitorsAndTimePointsDAO;
import com.sap.sailing.gwt.ui.shared.Pair;
import com.sap.sailing.server.api.DetailType;
import com.sap.sailing.server.api.RaceIdentifier;
@@ -65,6 +65,7 @@ public class ChartsPanel extends FormPanel {
private CompetitorInRaceDAO chartData;
private CompetitorsAndTimePointsDAO competitorsAndTimePointsDAO = null;
private final SailingServiceAsync sailingService;
private final ErrorReporter errorReporter;
private DateTimeFormat dateFormat;
private HorizontalPanel mainPanel;
private VerticalPanel chartPanel;
@@ -87,6 +88,7 @@ public class ChartsPanel extends FormPanel {
private HashMap<CompetitorDAO, Integer> competitorID;
private HashMap<Integer, SeriesHandler> markSeriesID;
private HashMap<CompetitorDAO, Widget> competitorLabels;
private HashMap<String, String> markPassingBuoyName;
private int width = 800, height = 600;
private int competitorNr = 0;
@@ -94,9 +96,10 @@ public class ChartsPanel extends FormPanel {
private AbsolutePanel loadingPanel;
public ChartsPanel(SailingServiceAsync sailingService, final List<CompetitorDAO> competitors,
RaceIdentifier[] races, StringConstants stringConstants, int chartWidth, int chartHeight) {
RaceIdentifier[] races, StringConstants stringConstants, int chartWidth, int chartHeight, ErrorReporter errorReporter) {
width = chartWidth;
height = chartHeight;
this.errorReporter = errorReporter;
chartData = new CompetitorInRaceDAO();
seriesID = new HashMap<Integer, SeriesHandler>();
competitorID = new HashMap<CompetitorDAO, Integer>();
@@ -104,6 +107,7 @@ public class ChartsPanel extends FormPanel {
idColor = new HashMap<Integer, String>();
competitorVisible = new HashMap<CompetitorDAO, Boolean>();
competitorLabels = new HashMap<CompetitorDAO, Widget>();
markPassingBuoyName = new HashMap<String, String>();
this.sailingService = sailingService;
this.races = races;
this.stringConstants = stringConstants;
@@ -143,7 +147,7 @@ public class ChartsPanel extends FormPanel {
chartPanel.add(raceChooserPanel);
loadingPanel = new AbsolutePanel();
loadingPanel.setSize(width + "px", height - 60 + "px");
loadingPanel.setSize(width + "px", height + "px");
Anchor a = new Anchor(new SafeHtmlBuilder().appendHtmlConstant("<img src=\"/images/ajax-loader.gif\"/>")
.toSafeHtml());
@@ -251,7 +255,7 @@ public class ChartsPanel extends FormPanel {
dataToShow, new AsyncCallback<CompetitorInRaceDAO>() {
@Override
public void onFailure(Throwable caught) {
Window.alert(stringConstants.failedToLoadRaceData() + ": " + caught.toString());
errorReporter.reportError(stringConstants.failedToLoadRaceData() + ": " + caught.toString());
}
@Override
@@ -274,7 +278,7 @@ public class ChartsPanel extends FormPanel {
new AsyncCallback<CompetitorsAndTimePointsDAO>() {
@Override
public void onFailure(Throwable caught) {
Window.alert("Failed to load race information: " + caught.toString());
errorReporter.reportError("Failed to load race information: " + caught.toString());
}
@Override
@@ -325,11 +329,12 @@ public class ChartsPanel extends FormPanel {
markSeries.clear();
if (isCompetitorVisible(competitor) && chartData.getRaceData(competitor) != null){
long starttime = System.currentTimeMillis();
long[] markPassingTimes = competitorsAndTimePointsDAO.getMarkPassings(competitor);
Pair<String,Long>[] markPassingTimes = competitorsAndTimePointsDAO.getMarkPassings(competitor);
Double[] markPassingValues = chartData.getMarkPassings(competitor);
for (int j = 0; j < markPassingTimes.length; j++){
if (markPassingValues[j] != null && markPassingTimes != null) {
markSeries.add(new DataPoint(markPassingTimes[j],markPassingValues[j]));
if (markPassingValues[j] != null && markPassingTimes[j].getB() != null) {
markPassingBuoyName.put(competitor.id + markPassingTimes[j].getB(), markPassingTimes[j].getA());
markSeries.add(new DataPoint(markPassingTimes[j].getB(),markPassingValues[j]));
}
}
GWT.log("Update mark passings time for " + competitor.name + ": " + (System.currentTimeMillis() - starttime));
@@ -444,7 +449,7 @@ public class ChartsPanel extends FormPanel {
}
if (item != null && competitor != null) {
if (item.getSeries().getLabel().toLowerCase().contains("mark")){
selectedPointLabel.setText(competitor.name + " passed mark at " + dateFormat.format(new Date((long) item.getDataPoint().getX())));
selectedPointLabel.setText(competitor.name + " passed " + markPassingBuoyName.get(competitor.id + (long) item.getDataPoint().getX()) +" at " + dateFormat.format(new Date((long) item.getDataPoint().getX())));
}
else {
String unit = "";
@@ -503,7 +508,7 @@ public class ChartsPanel extends FormPanel {
plot.setLinearSelection(x1, x2);
}
});
plot.setHeight(height- 60);
plot.setHeight(height);
plot.setWidth(width);
plot.setOverviewHeight(60);
FlowPanel panel = new FlowPanel() {
@@ -22,9 +22,9 @@ import com.sap.sailing.server.api.RaceIdentifier;
public class CompareCompetitorsChartDialog extends DialogBox {
private Anchor closeAnchor;
public CompareCompetitorsChartDialog(SailingServiceAsync sailingService, List<CompetitorDAO> competitors, RaceIdentifier[] races, StringConstants stringConstants){
public CompareCompetitorsChartDialog(SailingServiceAsync sailingService, List<CompetitorDAO> competitors, RaceIdentifier[] races, StringConstants stringConstants, ErrorReporter errorReporter){
super(false);
final ChartsPanel ccp = new ChartsPanel(sailingService, competitors, races, stringConstants, (int) (Window.getClientWidth()-320), (int) (Window.getClientHeight()-90));
final ChartsPanel ccp = new ChartsPanel(sailingService, competitors, races, stringConstants, (int) (Window.getClientWidth()-350), (int) (Window.getClientHeight()-170),errorReporter);
ccp.addDataLoadedHandler(new DataLoadedHandler() {
@Override
@@ -5,10 +5,12 @@ import com.google.gwt.cell.client.TextCell;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.cellview.client.CellTable;
import com.sap.sailing.gwt.ui.shared.LeaderboardDAO;
import com.sap.sailing.gwt.ui.shared.LeaderboardRowDAO;
public class FormattedDoubleLegDetailColumn extends LegDetailColumn<Double, String> implements HasStringValue {
public class FormattedDoubleLegDetailColumn extends LegDetailColumn<Double, String> implements HasStringAndDoubleValue {
private final NumberFormat formatter;
private final MinMaxRenderer minMaxRenderer;
public FormattedDoubleLegDetailColumn(String title, String unit,
com.sap.sailing.gwt.ui.client.LegDetailColumn.LegDetailField<Double> field, int decimals,
@@ -22,6 +24,16 @@ public class FormattedDoubleLegDetailColumn extends LegDetailColumn<Double, Stri
patternBuilder.append('0');
}
formatter = NumberFormat.getFormat(patternBuilder.toString());
this.minMaxRenderer = new MinMaxRenderer(this, getComparator());
}
protected MinMaxRenderer getMinMaxRenderer() {
return minMaxRenderer;
}
@Override
protected void updateMinMax(LeaderboardDAO leaderboard) {
getMinMaxRenderer().updateMinMax(leaderboard.rows.values());
}
protected NumberFormat getFormatter() {
@@ -42,10 +54,15 @@ public class FormattedDoubleLegDetailColumn extends LegDetailColumn<Double, Stri
}
return result;
}
@Override
public Double getDoubleValue(LeaderboardRowDAO row) {
return getFieldValue(row);
}
@Override
public void render(Context context, LeaderboardRowDAO row, SafeHtmlBuilder sb) {
getMinMaxRenderer().render(context, row, sb);
getMinMaxRenderer().render(context, row, getTitle(row), sb);
}
/**
@@ -2,13 +2,17 @@ package com.sap.sailing.gwt.ui.client;
import com.sap.sailing.gwt.ui.shared.LeaderboardRowDAO;
public interface HasStringValue {
/**
* This interface helps to get the String or the Double values of a {@link LeaderboardRowDAO}.
*/
public interface HasStringAndDoubleValue {
/**
* This method returns the value of a column to render in MinMaxRenderer. If the value does not exist or is empty
* for <code>null</code> is returned.
*
* @param object
* @return the value of the Column
*/
String getStringValueToRender(LeaderboardRowDAO object);
String getStringValueToRender(LeaderboardRowDAO row);
Double getDoubleValue(LeaderboardRowDAO row);
}
@@ -1348,7 +1348,7 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
competitors.add(leaderboardRowDAO.competitor);
}
}
CompareCompetitorsChartDialog chartDialog = new CompareCompetitorsChartDialog(sailingService, competitors, races.toArray(new LeaderboardNameAndRaceColumnName[0]), stringConstants);
CompareCompetitorsChartDialog chartDialog = new CompareCompetitorsChartDialog(sailingService, competitors, races.toArray(new LeaderboardNameAndRaceColumnName[0]), stringConstants, errorReporter);
chartDialog.show();
}
}
@@ -7,18 +7,16 @@ import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.Header;
import com.google.gwt.user.cellview.client.SafeHtmlHeader;
import com.sap.sailing.gwt.ui.shared.LeaderboardDAO;
import com.sap.sailing.gwt.ui.shared.LeaderboardRowDAO;
public abstract class LegDetailColumn<FieldType extends Comparable<?>, RenderingType> extends
SortableColumn<LeaderboardRowDAO, RenderingType> implements HasStringValue {
SortableColumn<LeaderboardRowDAO, RenderingType> {
private final String title;
private final LegDetailField<FieldType> field;
private final CellTable<LeaderboardRowDAO> leaderboardTable;
private final String headerStyle;
private final String columnStyle;
private final String unit;
private final MinMaxRenderer minMaxRenderer;
public interface LegDetailField<T extends Comparable<?>> {
T get(LeaderboardRowDAO row);
@@ -34,11 +32,6 @@ public abstract class LegDetailColumn<FieldType extends Comparable<?>, Rendering
this.leaderboardTable = leaderboardTable;
this.headerStyle = headerStyle;
this.columnStyle = columnStyle;
minMaxRenderer = new MinMaxRenderer(this, getComparator());
}
protected MinMaxRenderer getMinMaxRenderer() {
return minMaxRenderer;
}
protected String getTitle() {
@@ -99,8 +92,4 @@ public abstract class LegDetailColumn<FieldType extends Comparable<?>, Rendering
return getField().get(row);
}
@Override
protected void updateMinMax(LeaderboardDAO leaderboard) {
getMinMaxRenderer().updateMinMax(leaderboard.rows.values());
}
}
@@ -18,7 +18,7 @@ import com.sap.sailing.gwt.ui.shared.LegEntryDAO;
import com.sap.sailing.gwt.ui.shared.Triple;
import com.sap.sailing.server.api.DetailType;
public class ManeuverCountRaceColumn extends ExpandableSortableColumn<String> implements HasStringValue {
public class ManeuverCountRaceColumn extends ExpandableSortableColumn<String> implements HasStringAndDoubleValue {
private final StringConstants stringConstants;
private final RaceNameProvider raceNameProvider;
@@ -207,7 +207,7 @@ public class ManeuverCountRaceColumn extends ExpandableSortableColumn<String> im
@Override
public void render(Context context, LeaderboardRowDAO row, SafeHtmlBuilder sb) {
minmaxRenderer.render(context, row, sb);
minmaxRenderer.render(context, row, getTitle(row), sb);
}
/**
@@ -7,8 +7,15 @@ import com.google.gwt.cell.client.Cell.Context;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.sap.sailing.gwt.ui.shared.LeaderboardRowDAO;
/**
* Renders the values and the percentage bar of the {@link LegDetailColumn} and {@link ManeuverCountRaceColumn}.
* It is used to update the minimum and maximum values of the columns, and to render the column content.
*
* @author Fabian Schwarz-Fritz
*
*/
public class MinMaxRenderer {
private HasStringValue valueProvider;
private HasStringAndDoubleValue valueProvider;
private Comparator<LeaderboardRowDAO> comparator;
private Double minimumValue;
private Double maximumValue;
@@ -22,17 +29,19 @@ public class MinMaxRenderer {
* @param comparator
* The comparator to update the minimum and maximum values.
*/
public MinMaxRenderer(HasStringValue valueProvider, Comparator<LeaderboardRowDAO> comparator) {
public MinMaxRenderer(HasStringAndDoubleValue valueProvider, Comparator<LeaderboardRowDAO> comparator) {
this.valueProvider = valueProvider;
this.comparator = comparator;
}
/**
* Renders the value of a {@link LeaderboardRowDAO}.
*
* @param title
* tool tip title to display; if <code>null</code>, no tool tip will be rendered
*/
public void render(Context context, LeaderboardRowDAO row, SafeHtmlBuilder sb) {
public void render(Context context, LeaderboardRowDAO row, String title, SafeHtmlBuilder sb) {
int percent = getPercentage(row);
String title = null;
String stringValue = valueProvider.getStringValueToRender(row);
stringValue = stringValue == null ? "" : stringValue;
sb.appendHtmlConstant(
@@ -51,7 +60,7 @@ public class MinMaxRenderer {
*/
private int getPercentage(LeaderboardRowDAO row) {
int percentage = 0;
Double value = getDoubleFromString(valueProvider.getStringValueToRender(row));
Double value = valueProvider.getDoubleValue(row);
if (value != null) {
if (value != null && getMinimumDouble() != null && getMaximumDouble() != null) {
int minBarLength = Math.abs(getMinimumDouble()) < 0.01 ? 0 : 10;
@@ -72,25 +81,6 @@ public class MinMaxRenderer {
return maximumValue;
}
/**
* Parses a <code>String</code> into a <code>Double</code>.
*
* @param string
* The <code>String</code> to be parsed.
* @return The <code>Double</code> result of the given <code>String</code>.
*/
private Double getDoubleFromString(String string) {
Double result = null;
if (string != null) {
try {
result = Double.parseDouble(string);
} catch (NumberFormatException numberFormatException) {
}
}
return result;
}
/**
* Updates the {@link MinMaxRenderer#minimumValue} and {@link MinMaxRenderer#maximumValue}.
*
@@ -101,20 +91,20 @@ public class MinMaxRenderer {
LeaderboardRowDAO minimumRow = null;
LeaderboardRowDAO maximumRow = null;
for (LeaderboardRowDAO row : values) {
if (getDoubleFromString(valueProvider.getStringValueToRender(row)) != null
if (valueProvider.getDoubleValue(row) != null
&& (minimumRow == null || comparator.compare(minimumRow, row) > 0)) {
minimumRow = row;
}
if (getDoubleFromString(valueProvider.getStringValueToRender(row)) != null
if (valueProvider.getDoubleValue(row) != null
&& (maximumRow == null || comparator.compare(maximumRow, row) < 0)) {
maximumRow = row;
}
}
if (minimumRow != null) {
minimumValue = getDoubleFromString(valueProvider.getStringValueToRender(minimumRow));
minimumValue = valueProvider.getDoubleValue(minimumRow);
}
if (maximumRow != null) {
maximumValue = getDoubleFromString(valueProvider.getStringValueToRender(maximumRow));
maximumValue = valueProvider.getDoubleValue(maximumRow);
}
}
}
@@ -76,7 +76,7 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
private final ListBox quickRanksBox;
private final List<CompetitorDAO> quickRanksList;
private final TimePanel timePanel;
/**
* Two sails on downwind leg, wind from port (sails on starboard); no highlighting
*/
@@ -86,7 +86,7 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
* Two sails on downwind leg, wind from port (sails on starboard); with highlighting
*/
private ImageRotator boatIconHighlightedDownwindPortRotator;
/**
* Two sails on downwind leg, wind from starboard (sails on port); no highlighting
*/
@@ -96,7 +96,7 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
* Two sails on downwind leg, wind from starboard (sails on port); with highlighting
*/
private ImageRotator boatIconHighlightedDownwindStarboardRotator;
/**
* One sail, wind from port (sails on starboard); no highlighting
*/
@@ -106,7 +106,7 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
* One sail, wind from port (sails on starboard); with highlighting
*/
private ImageRotator boatIconHighlightedPortRotator;
/**
* One sail, wind from starboard (sails on port); no highlighting
*/
@@ -116,7 +116,7 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
* One sail, wind from starboard (sails on port); with highlighting
*/
private ImageRotator boatIconHighlightedStarboardRotator;
private Icon buoyIcon;
private Icon tackToStarboardIcon;
private Icon tackToPortIcon;
@@ -144,6 +144,11 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
*/
private boolean mapZoomedOrPannedSinceLastRaceSelectionChange = false;
/**
* Used to check if the first initial zoom to the buoy markers was already done.
*/
private boolean mapFirstZoomDone = false;
/**
* Tails of competitors currently displayed as overlays on the map.
*/
@@ -238,10 +243,9 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
CheckBox checkBoxJibe = new CheckBox(stringConstants.jibe());
checkBoxJibe.setValue(true);
checkboxAndType.add(new Pair<CheckBox, String>(checkBoxJibe, "JIBE"));
CheckBox checkBoxPenalty= new CheckBox(stringConstants.penaltyCircle());
CheckBox checkBoxPenalty = new CheckBox(stringConstants.penaltyCircle());
checkBoxPenalty.setValue(true);
checkboxAndType
.add(new Pair<CheckBox, String>(checkBoxPenalty, "PENALTY_CIRCLE"));
checkboxAndType.add(new Pair<CheckBox, String>(checkBoxPenalty, "PENALTY_CIRCLE"));
CheckBox checkBoxMarkPassing = new CheckBox(stringConstants.markPassing());
checkBoxMarkPassing.setValue(true);
checkboxAndType.add(new Pair<CheckBox, String>(checkBoxMarkPassing, "MARK_PASSING"));
@@ -266,7 +270,7 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
if (!timer.isPlaying() && lastDouglasPeuckerResult != null && event.getValue()) {
removeAllMarkDouglasPeuckerpoints();
showMarkDouglasPeuckerPoints(lastDouglasPeuckerResult);
} else if(!event.getValue()){
} else if (!event.getValue()) {
removeAllMarkDouglasPeuckerpoints();
}
}
@@ -424,7 +428,8 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
boatIconDownwindPortRotator = new ImageRotator(resources.lowlightedBoatIconDW_Port());
boatIconHighlightedDownwindPortRotator = new ImageRotator(resources.highlightedBoatIconDW_Port());
boatIconDownwindStarboardRotator = new ImageRotator(resources.lowlightedBoatIconDW_Starboard());
boatIconHighlightedDownwindStarboardRotator = new ImageRotator(resources.highlightedBoatIconDW_Starboard());
boatIconHighlightedDownwindStarboardRotator = new ImageRotator(resources
.highlightedBoatIconDW_Starboard());
boatIconPortRotator = new ImageRotator(resources.lowlightedBoatIcon_Port());
boatIconHighlightedPortRotator = new ImageRotator(resources.highlightedBoatIcon_Port());
boatIconStarboardRotator = new ImageRotator(resources.lowlightedBoatIcon_Starboard());
@@ -481,9 +486,14 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
@Override
public void onRaceSelectionChange(List<Triple<EventDAO, RegattaDAO, RaceDAO>> selectedRaces) {
mapFirstZoomDone = false;
mapZoomedOrPannedSinceLastRaceSelectionChange = false;
if (!selectedRaces.isEmpty() && selectedRaces.get(selectedRaces.size() - 1) != null) {
RaceDAO raceDAO = selectedRaces.get(selectedRaces.size() - 1).getC();
if (raceDAO.startOfRace != null) {
timePanel.timeChanged(raceDAO.startOfRace);
timer.setTime(raceDAO.startOfRace.getTime());
}
updateSlider(raceDAO);
}
// force display of currently selected race
@@ -753,6 +763,44 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
Marker marker = buoyMarkers.remove(toRemoveMarkDAO);
map.removeOverlay(marker);
}
zoomMapFirstTimeToMarks(buoyMarkers.keySet());
}
}
/**
* Zooms the map to the given marks if the map was not zoomed yet. If the map zoom to the marks was successful one
* time, the initial zoom to these marks can not be done again except the race selection is changed via {@link RaceMapPanel#onRaceSelectionChange(List).
*
* @param marksToZoomAt
* the marks to zoom at
*/
private void zoomMapFirstTimeToMarks(Set<MarkDAO> marksToZoomAt) {
if (!mapZoomedOrPannedSinceLastRaceSelectionChange && !mapFirstZoomDone) {
LatLngBounds newBounds = null;
if (marksToZoomAt != null && !marksToZoomAt.isEmpty()) {
for (MarkDAO markDAO : marksToZoomAt) {
LatLng latLngZoomFirstTime = LatLng.newInstance(markDAO.position.latDeg, markDAO.position.lngDeg);
LatLngBounds bounds = LatLngBounds.newInstance(latLngZoomFirstTime, latLngZoomFirstTime);
if (newBounds == null) {
newBounds = bounds;
} else {
newBounds.extend(bounds.getNorthEast());
newBounds.extend(bounds.getSouthWest());
}
}
}
if (newBounds != null) {
map.setZoomLevel(map.getBoundsZoomLevel(newBounds));
map.setCenter(newBounds.getCenter());
mapFirstZoomDone = true;
/*
* Reset the mapZoomedOrPannedSinceLastRaceSelection: In spite of the fact that the map was just zoomed
* to the bounds of the buoys, it was not a zoom or pan triggered by the user. As a consequence the
* mapZoomedOrPannedSinceLastRaceSelection option has to reset again.
*/
mapZoomedOrPannedSinceLastRaceSelectionChange = false;
}
}
}
@@ -767,7 +815,8 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
LatLngBounds newMapBounds = null;
Set<CompetitorDAO> competitorDAOsOfUnusedTails = new HashSet<CompetitorDAO>(tails.keySet());
Set<CompetitorDAO> competitorDAOsOfUnusedMarkers = new HashSet<CompetitorDAO>(boatMarkers.keySet());
for (CompetitorDAO competitorDAO : getCompetitorsToShow()) {
Collection<CompetitorDAO> competitorsToShow = getCompetitorsToShow();
for (CompetitorDAO competitorDAO : competitorsToShow) {
if (fixes.containsKey(competitorDAO)) {
Polyline tail = tails.get(competitorDAO);
if (tail == null) {
@@ -794,7 +843,8 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
} else {
competitorDAOsOfUnusedMarkers.remove(competitorDAO);
boatMarker.setLatLng(LatLng.newInstance(lastPos.position.latDeg, lastPos.position.lngDeg));
boatMarker.setImage(getBoatImageURL(lastPos, competitorsSelectedInMap.contains(competitorDAO)));
boatMarker.setImage(getBoatImageURL(lastPos,
competitorsSelectedInMap.contains(competitorDAO)));
}
}
}
@@ -802,6 +852,7 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
if (!mapZoomedOrPannedSinceLastRaceSelectionChange && newMapBounds != null) {
map.setZoomLevel(map.getBoundsZoomLevel(newMapBounds));
map.setCenter(newMapBounds.getCenter());
mapFirstZoomDone = true;
}
for (CompetitorDAO unusedMarkerCompetitorDAO : competitorDAOsOfUnusedMarkers) {
map.removeOverlay(boatMarkers.remove(unusedMarkerCompetitorDAO));
@@ -815,11 +866,11 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
private String getBoatImageURL(GPSFixDAO boatFix, boolean highlighted) {
return getBoatImageURL(getBoatImageRotator(boatFix, highlighted), boatFix);
}
private String getBoatImageURL(ImageRotator boatImageRotator, GPSFixDAO boatFix) {
return boatImageRotator.getRotatedImageURL(boatFix.speedWithBearing.bearingInDegrees);
}
private Icon getBoatImageIcon(GPSFixDAO boatFix, boolean highlighted) {
ImageRotator boatImageRotator = getBoatImageRotator(boatFix, highlighted);
Icon icon = Icon.newInstance(getBoatImageURL(boatImageRotator, boatFix));
@@ -867,6 +918,7 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
if (showOnlySelected.getValue()) {
return competitorsSelectedInMap;
} else {
// here the quickrankslist is emtpy, because of that te map is not zoomed correctly
return quickRanksList;
}
}
@@ -1024,7 +1076,7 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
removeAllMarkDouglasPeuckerpoints();
}
if (!timer.isPlaying()) {
if(checkBoxDouglasPeuckerPoints.getValue()){
if (checkBoxDouglasPeuckerPoints.getValue()) {
showMarkDouglasPeuckerPoints(result);
}
}
@@ -52,13 +52,4 @@ public class RankGainColumn extends LegDetailColumn<Integer, Integer> {
}
}
}
@Override
public String getStringValueToRender(LeaderboardRowDAO object) {
Integer intValue = getValue(object);
if (intValue != null) {
return intValue.toString();
}
return null;
}
}
@@ -1208,7 +1208,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
competitorData.setRaceData(competitor, entries);
entries = new Double[competitorAndTimePointsDAO.getMarkPassings(competitor).length];
for (int i = 0; i < competitorAndTimePointsDAO.getMarkPassings(competitor).length; i++){
MillisecondsTimePoint time = new MillisecondsTimePoint(competitorAndTimePointsDAO.getMarkPassings(competitor)[i]);
MillisecondsTimePoint time = new MillisecondsTimePoint(competitorAndTimePointsDAO.getMarkPassings(competitor)[i].getB());
TrackedLegOfCompetitor trackedLeg = trackedRace.getTrackedLeg(selectedCompetitor.get(c), time);
if (trackedLeg != null){
SpeedWithBearing speedOverGround = trackedLeg.getSpeedOverGround(time);
@@ -1233,7 +1233,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
CompetitorDAO competitor = competitorAndTimePointsDAO.getCompetitor()[c];
entries = new Double[competitorAndTimePointsDAO.getMarkPassings(competitor).length];
for (int i = 0; i < competitorAndTimePointsDAO.getMarkPassings(competitor).length; i++){
MillisecondsTimePoint time = new MillisecondsTimePoint(competitorAndTimePointsDAO.getMarkPassings(competitor)[i]);
MillisecondsTimePoint time = new MillisecondsTimePoint(competitorAndTimePointsDAO.getMarkPassings(competitor)[i].getB());
TrackedLegOfCompetitor trackedLeg = trackedRace.getTrackedLeg(selectedCompetitor.get(c), time);
if (trackedLeg != null){
Speed velocityMadeGood = trackedLeg.getVelocityMadeGood(time);
@@ -1267,7 +1267,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
CompetitorDAO competitor = competitorAndTimePointsDAO.getCompetitor()[c];
entries = new Double[competitorAndTimePointsDAO.getMarkPassings(competitor).length];
for (int i = 0; i < competitorAndTimePointsDAO.getMarkPassings(competitor).length; i++){
MillisecondsTimePoint time = new MillisecondsTimePoint(competitorAndTimePointsDAO.getMarkPassings(competitor)[i]);
MillisecondsTimePoint time = new MillisecondsTimePoint(competitorAndTimePointsDAO.getMarkPassings(competitor)[i].getB());
TrackedLegOfCompetitor trackedLeg = trackedRace.getTrackedLeg(selectedCompetitor.get(c), time);
if (trackedLeg != null){
Distance distanceTraveled = trackedLeg.getDistanceTraveled(time);
@@ -1298,7 +1298,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
CompetitorDAO competitor = competitorAndTimePointsDAO.getCompetitor()[c];
entries = new Double[competitorAndTimePointsDAO.getMarkPassings(competitor).length];
for (int i = 0; i < competitorAndTimePointsDAO.getMarkPassings(competitor).length; i++){
MillisecondsTimePoint time = new MillisecondsTimePoint(competitorAndTimePointsDAO.getMarkPassings(competitor)[i]);
MillisecondsTimePoint time = new MillisecondsTimePoint(competitorAndTimePointsDAO.getMarkPassings(competitor)[i].getB());
TrackedLegOfCompetitor trackedLeg = trackedRace.getTrackedLeg(selectedCompetitor.get(c), time);
if (trackedLeg != null){
entries[i] = trackedLeg.getGapToLeaderInSeconds(time);
@@ -1322,7 +1322,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
CompetitorDAO competitor = competitorAndTimePointsDAO.getCompetitor()[c];
entries = new Double[competitorAndTimePointsDAO.getMarkPassings(competitor).length];
for (int i = 0; i < competitorAndTimePointsDAO.getMarkPassings(competitor).length; i++){
MillisecondsTimePoint time = new MillisecondsTimePoint(competitorAndTimePointsDAO.getMarkPassings(competitor)[i]);
MillisecondsTimePoint time = new MillisecondsTimePoint(competitorAndTimePointsDAO.getMarkPassings(competitor)[i].getB());
TrackedLegOfCompetitor trackedLeg = trackedRace.getTrackedLeg(selectedCompetitor.get(c), time);
if (trackedLeg != null){
Distance distanceToLeader = trackedLeg.getWindwardDistanceToOverallLeader(time);
@@ -1490,20 +1490,22 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
return (Event) eventIdentifier.getEvent(this);
}
@Override
@SuppressWarnings("unchecked")
@Override
public CompetitorsAndTimePointsDAO getCompetitorsAndTimePoints(RaceIdentifier race, int steps) {
CompetitorsAndTimePointsDAO competitorAndTimePointsDAO = new CompetitorsAndTimePointsDAO(steps);
TrackedRace trackedRace = getTrackedRace(race);
List<CompetitorDAO> competitors = new ArrayList<CompetitorDAO>();
for (Competitor competitor : trackedRace.getRace().getCompetitors()) {
NavigableSet<MarkPassing> markPassings = trackedRace.getMarkPassings(competitor);
long[] markPassingTimes = new long[markPassings.size()];
int i=0;
List<Pair<String, Long>> markPassingTimes = new ArrayList<Pair<String,Long>>();
for (MarkPassing markPassing : markPassings){
markPassingTimes[i++] = markPassing.getTimePoint().asMillis();
markPassingTimes.add(new Pair<String, Long>(markPassing.getWaypoint().getName(), markPassing.getTimePoint().asMillis()));
}
competitors.add(getCompetitorDAO(competitor));
competitorAndTimePointsDAO.setMarkPassings(getCompetitorDAO(competitor), markPassingTimes);
//The following line will create a "Unchecked type safety warning".
//There is no way to solve this, so it is okay to suppress this warning.
competitorAndTimePointsDAO.setMarkPassings(getCompetitorDAO(competitor), markPassingTimes.toArray(new Pair[0]));
}
competitorAndTimePointsDAO.setCompetitor(competitors.toArray(new CompetitorDAO[0]));
competitorAndTimePointsDAO.setStartTime(trackedRace.getStart().asMillis());
@@ -8,7 +8,7 @@ public class CompetitorsAndTimePointsDAO implements IsSerializable {
private static final long MILLISECONDS_BEFORE_RACE_TO_INCLUDE = 20000;
private CompetitorDAO[] competitors;
private HashMap<String, long[]> markPassings;
private HashMap<String, Pair<String, Long>[]> markPassings;
private long startTime;
private long timePointOfNewestEvent;
private int steps;
@@ -16,7 +16,7 @@ public class CompetitorsAndTimePointsDAO implements IsSerializable {
CompetitorsAndTimePointsDAO() {}
public CompetitorsAndTimePointsDAO(int steps) {
markPassings = new HashMap<String, long[]>();
markPassings = new HashMap<String, Pair<String, Long>[]>();
this.steps = steps;
}
@@ -46,11 +46,11 @@ public class CompetitorsAndTimePointsDAO implements IsSerializable {
this.startTime = startTime;
}
public long[] getMarkPassings(CompetitorDAO competitor) {
public Pair<String, Long>[] getMarkPassings(CompetitorDAO competitor) {
return markPassings.get(competitor.id);
}
public void setMarkPassings(CompetitorDAO competitor, long[] markPassings) {
public void setMarkPassings(CompetitorDAO competitor, Pair<String, Long>[] markPassings) {
this.markPassings.put(competitor.id, markPassings);
}