Renamed DetailColumnType to DetailType and added precision.

This commit is contained in:
Benjamin Ebling committed 2011-12-06 10:31:39 +01:00
1 parent b5045d27e9
commit f4bc517850
13 files changed
+118 -118

No files matched your search

@@ -37,7 +37,7 @@ import com.sap.sailing.gwt.ui.shared.CompetitorAndTimePointsDAO;
import com.sap.sailing.gwt.ui.shared.Pair;
import com.sap.sailing.gwt.ui.shared.RaceIdentifier;
public class CompareCompetitorsPanel extends FormPanel {
public class ChartsPanel extends FormPanel {
private List<Pair<CompetitorDAO, Double[]>> chartData = null;
private CompetitorAndTimePointsDAO competitorAndTimePointsDAO = null;
private LineChart chart;
@@ -59,15 +59,10 @@ public class CompareCompetitorsPanel extends FormPanel {
public static final int DECK_PANEL_INDEX_LOADING = 0;
public static final int DECK_PANEL_INDEX_CHART = 1;
public static final int SHOW_CURRENT_SPEED_OVER_GROUND = 0;
public static final int SHOW_VELOCITY_MADE_GOOD = 1;
public static final int SHOW_GAP_TO_LEADER = 2;
public static final int SHOW_WINDWARD_DISTANCE_TO_LEADER = 3;
public static final int SHOW_DISTANCE_TRAVELED = 4;
private int dataToShow = SHOW_CURRENT_SPEED_OVER_GROUND;
private DetailType dataToShow = DetailType.WINDWARD_DISTANCE_TO_OVERALL_LEADER;
private AbsolutePanel loadingPanel;
public CompareCompetitorsPanel(SailingServiceAsync sailingService, final List<CompetitorDAO> competitors,
public ChartsPanel(SailingServiceAsync sailingService, final List<CompetitorDAO> competitors,
RaceIdentifier[] races, StringConstants stringConstants, int chartWidth, int chartHeight) {
this.sailingService = sailingService;
this.races = races;
@@ -123,16 +118,21 @@ public class CompareCompetitorsPanel extends FormPanel {
Label lblChart = new Label(stringConstants.chooseChart());
configPanel.add(lblChart);
final ListBox dataSelection = new ListBox();
dataSelection.addItem(stringConstants.speedOverGroundLong(), "" + SHOW_CURRENT_SPEED_OVER_GROUND);
dataSelection.addItem(stringConstants.distanceTraveled(), "" + SHOW_DISTANCE_TRAVELED);
dataSelection.addItem(stringConstants.velocityMadeGoodLong(), "" + SHOW_VELOCITY_MADE_GOOD);
dataSelection.addItem(stringConstants.gapToLeaderLong(), "" + SHOW_GAP_TO_LEADER);
dataSelection.addItem(stringConstants.windwardDistanceToLeaderInMeters(), "" + SHOW_WINDWARD_DISTANCE_TO_LEADER);
dataSelection.addItem(DetailType.WINDWARD_DISTANCE_TO_OVERALL_LEADER.toString());
dataSelection.addItem(DetailType.DISTANCE_TRAVELED.toString());
dataSelection.addItem(DetailType.VELOCITY_MADE_GOOD_IN_KNOTS.toString());
dataSelection.addItem(DetailType.GAP_TO_LEADER_IN_SECONDS.toString());
dataSelection.addItem(DetailType.CURRENT_SPEED_OVER_GROUND_IN_KNOTS.toString());
dataSelection.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
dataToShow = Integer.parseInt(dataSelection.getValue(dataSelection.getSelectedIndex()));
for (DetailType dt : DetailType.values()){
if (dt.toString().equals(dataSelection.getItemText(dataSelection.getSelectedIndex()))){
dataToShow = dt;
}
}
loadData();
}
});
@@ -193,41 +193,26 @@ public class CompareCompetitorsPanel extends FormPanel {
Options opt = Options.create();
opt.setWidth(chartWidth);
opt.setHeight(chartHeight);
switch (dataToShow) {
case SHOW_VELOCITY_MADE_GOOD:
opt.setTitle(stringConstants.velocityMadeGoodLong());
break;
case SHOW_GAP_TO_LEADER:
opt.setTitle(stringConstants.gapToLeaderLong());
break;
case SHOW_WINDWARD_DISTANCE_TO_LEADER:
opt.setTitle(stringConstants.windwardDistanceToLeaderInMeters());
break;
case SHOW_DISTANCE_TRAVELED:
opt.setTitle(stringConstants.distanceTraveled());
break;
default:
opt.setTitle(stringConstants.speedOverGroundLong());
}
opt.setTitle(dataToShow.toString());
AxisOptions hAxisOptions = AxisOptions.create();
hAxisOptions.setTitle("time");
opt.setHAxisOptions(hAxisOptions);
AxisOptions vAxisOptions = AxisOptions.create();
switch (dataToShow) {
case SHOW_VELOCITY_MADE_GOOD:
case VELOCITY_MADE_GOOD_IN_KNOTS:
vAxisOptions.setTitle(stringConstants.speed() + " " + stringConstants.in() + " " + stringConstants.velocityMadeGoodInKnotsUnit());
break;
case SHOW_GAP_TO_LEADER:
case GAP_TO_LEADER_IN_SECONDS:
vAxisOptions.setTitle(stringConstants.time() + " " + stringConstants.in() + " " + stringConstants.secondsUnit());
break;
case SHOW_WINDWARD_DISTANCE_TO_LEADER:
case WINDWARD_DISTANCE_TO_OVERALL_LEADER:
vAxisOptions.setTitle(stringConstants.distance() + " " + stringConstants.in() + " " + stringConstants.metersUnit());
break;
case SHOW_DISTANCE_TRAVELED:
case DISTANCE_TRAVELED:
vAxisOptions.setTitle(stringConstants.distance() + " " + stringConstants.in() + " " + stringConstants.metersUnit());
break;
default:
case CURRENT_SPEED_OVER_GROUND_IN_KNOTS:
vAxisOptions.setTitle(stringConstants.speed() + " " + stringConstants.in() + " " + stringConstants.currentSpeedOverGroundInKnotsUnit());
break;
}
@@ -242,7 +227,7 @@ public class CompareCompetitorsPanel extends FormPanel {
@Override
public void run() {
CompareCompetitorsPanel.this.sailingService.getCompetitorRaceData(races[selectedRace], competitorAndTimePointsDAO, dataToShow,
ChartsPanel.this.sailingService.getCompetitorRaceData(races[selectedRace], competitorAndTimePointsDAO, dataToShow,
new AsyncCallback<List<Pair<CompetitorDAO, Double[]>>>() {
@Override
@@ -12,8 +12,8 @@ import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.sap.sailing.gwt.ui.client.CompareCompetitorsPanel.DataLoadedEvent;
import com.sap.sailing.gwt.ui.client.CompareCompetitorsPanel.DataLoadedHandler;
import com.sap.sailing.gwt.ui.client.ChartsPanel.DataLoadedEvent;
import com.sap.sailing.gwt.ui.client.ChartsPanel.DataLoadedHandler;
import com.sap.sailing.gwt.ui.shared.CompetitorDAO;
import com.sap.sailing.gwt.ui.shared.RaceIdentifier;
@@ -22,7 +22,7 @@ public class CompareCompetitorsChartDialog extends DialogBox {
public CompareCompetitorsChartDialog(SailingServiceAsync sailingService, List<CompetitorDAO> competitors, RaceIdentifier[] races, StringConstants stringConstants){
super(true);
CompareCompetitorsPanel ccp = new CompareCompetitorsPanel(sailingService, competitors, races, stringConstants, (int) (Window.getClientWidth()-300), (int) (Window.getClientHeight()-200));
ChartsPanel ccp = new ChartsPanel(sailingService, competitors, races, stringConstants, (int) (Window.getClientWidth()-300), (int) (Window.getClientHeight()-200));
ccp.addDataLoadedHandler(new DataLoadedHandler() {
@Override
@@ -1,10 +1,20 @@
package com.sap.sailing.gwt.ui.client;
public enum DetailColumnType {
DISTANCE_TRAVELED, AVERAGE_SPEED_OVER_GROUND_IN_KNOTS, RANK_GAIN, NUMBER_OF_MANEUVERS, CURRENT_SPEED_OVER_GROUND_IN_KNOTS,
ESTIMATED_TIME_TO_NEXT_WAYPOINT_IN_SECONDS, VELOCITY_MADE_GOOD_IN_KNOTS, GAP_TO_LEADER_IN_SECONDS,
WINDWARD_DISTANCE_TO_GO_IN_METERS, RACE_DISTANCE_TRAVELED, RACE_AVERAGE_SPEED_OVER_GROUND_IN_KNOTS, RACE_GAP_TO_LEADER_IN_SECONDS,
RACE_MANEUVERS;
public enum DetailType {
DISTANCE_TRAVELED(0), AVERAGE_SPEED_OVER_GROUND_IN_KNOTS(2), RANK_GAIN(0), NUMBER_OF_MANEUVERS(0), CURRENT_SPEED_OVER_GROUND_IN_KNOTS(2),
ESTIMATED_TIME_TO_NEXT_WAYPOINT_IN_SECONDS(1), VELOCITY_MADE_GOOD_IN_KNOTS(2), GAP_TO_LEADER_IN_SECONDS(0),
WINDWARD_DISTANCE_TO_GO_IN_METERS(0), RACE_DISTANCE_TRAVELED(0), RACE_AVERAGE_SPEED_OVER_GROUND_IN_KNOTS(2), RACE_GAP_TO_LEADER_IN_SECONDS(0),
RACE_MANEUVERS(0), WINDWARD_DISTANCE_TO_OVERALL_LEADER(0);
private int precision;
DetailType(int precision){
this.precision = precision;
}
public int getPrecision(){
return precision;
}
public String toString(StringConstants stringConstants) {
switch (this) {
@@ -34,6 +44,8 @@ public enum DetailColumnType {
return stringConstants.gapToLeaderInSeconds();
case RACE_MANEUVERS:
return stringConstants.numberOfManeuvers();
case WINDWARD_DISTANCE_TO_OVERALL_LEADER:
return stringConstants.windwardDistanceToOverallLeader();
}
return null;
}
@@ -24,8 +24,8 @@ public abstract class ExpandableSortableColumn<C> extends SortableColumn<Leaderb
private boolean enableExpansion;
private boolean suppressSortingOnce;
private final LeaderboardPanel leaderboardPanel;
private final Map<DetailColumnType, SortableColumn<LeaderboardRowDAO, ?>> detailColumnsMap;
private final List<DetailColumnType> detailSelection;
private final Map<DetailType, SortableColumn<LeaderboardRowDAO, ?>> detailColumnsMap;
private final List<DetailType> detailSelection;
/**
* Holds the child columns that represent expanded information for this column. If <code>null</code>,
@@ -44,7 +44,7 @@ public abstract class ExpandableSortableColumn<C> extends SortableColumn<Leaderb
public ExpandableSortableColumn(LeaderboardPanel leaderboardPanel, boolean enableExpansion, Cell<C> cell,
StringConstants stringConstants, String detailHeaderStyle, String detailColumnStyle,
List<DetailColumnType> detailSelection) {
List<DetailType> detailSelection) {
super(cell);
this.enableExpansion = enableExpansion;
this.leaderboardPanel = leaderboardPanel;
@@ -56,7 +56,7 @@ public abstract class ExpandableSortableColumn<C> extends SortableColumn<Leaderb
* By default, an expandable sortable column has no detail columns. Subclasses that want to offer detail columns must
* override this method.
*/
protected Map<DetailColumnType, SortableColumn<LeaderboardRowDAO, ?>> getDetailColumnMap(
protected Map<DetailType, SortableColumn<LeaderboardRowDAO, ?>> getDetailColumnMap(
LeaderboardPanel leaderboardPanel, StringConstants stringConstants, String detailHeaderStyle,
String detailColumnStyle) {
return Collections.emptyMap();
@@ -86,7 +86,7 @@ public abstract class ExpandableSortableColumn<C> extends SortableColumn<Leaderb
List<SortableColumn<LeaderboardRowDAO, ?>> result;
if (isExpanded()) {
result = new ArrayList<SortableColumn<LeaderboardRowDAO,?>>();
for (DetailColumnType detailColumnType : detailSelection) {
for (DetailType detailColumnType : detailSelection) {
SortableColumn<LeaderboardRowDAO, ?> selectedColumn = detailColumnsMap.get(detailColumnType);
if (selectedColumn != null) {
result.add(selectedColumn);
@@ -98,14 +98,14 @@ public abstract class ExpandableSortableColumn<C> extends SortableColumn<Leaderb
return result;
}
protected SortableColumn<LeaderboardRowDAO, ?> createExpansionColumn(DetailColumnType detailColumnType) {
protected SortableColumn<LeaderboardRowDAO, ?> createExpansionColumn(DetailType detailColumnType) {
throw new RuntimeException("Detail column type "+detailColumnType+" not supported by column of type "+getClass().getName());
}
/**
* @return the list of details supported by {@link #createExpansionColumn}
*/
protected List<DetailColumnType> getSupportedDetails() {
protected List<DetailType> getSupportedDetails() {
return Collections.emptyList();
}
@@ -84,9 +84,9 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
private final RankColumn rankColumn;
private final List<DetailColumnType> selectedLegDetails;
private final List<DetailType> selectedLegDetails;
private final List<DetailColumnType> selectedRaceDetails;
private final List<DetailType> selectedRaceDetails;
private List<String> selectedRaceColumns;
@@ -418,9 +418,9 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
}
public static DetailColumnType[] getAvailableRaceDetailColumnTypes() {
return new DetailColumnType[] { DetailColumnType.RACE_AVERAGE_SPEED_OVER_GROUND_IN_KNOTS,
DetailColumnType.RACE_DISTANCE_TRAVELED, DetailColumnType.RACE_GAP_TO_LEADER_IN_SECONDS, DetailColumnType.RACE_MANEUVERS };
public static DetailType[] getAvailableRaceDetailColumnTypes() {
return new DetailType[] { DetailType.RACE_AVERAGE_SPEED_OVER_GROUND_IN_KNOTS,
DetailType.RACE_DISTANCE_TRAVELED, DetailType.RACE_GAP_TO_LEADER_IN_SECONDS, DetailType.RACE_MANEUVERS };
}
private class TextRaceColumn extends RaceColumn<String> implements RaceNameProvider {
@@ -465,21 +465,21 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
}
@Override
protected Map<DetailColumnType, SortableColumn<LeaderboardRowDAO, ?>> getDetailColumnMap(
protected Map<DetailType, SortableColumn<LeaderboardRowDAO, ?>> getDetailColumnMap(
LeaderboardPanel leaderboardPanel, StringConstants stringConstants, String detailHeaderStyle,
String detailColumnStyle) {
Map<DetailColumnType, SortableColumn<LeaderboardRowDAO, ?>> result = new HashMap<DetailColumnType, SortableColumn<LeaderboardRowDAO, ?>>();
result.put(DetailColumnType.RACE_DISTANCE_TRAVELED,
Map<DetailType, SortableColumn<LeaderboardRowDAO, ?>> result = new HashMap<DetailType, SortableColumn<LeaderboardRowDAO, ?>>();
result.put(DetailType.RACE_DISTANCE_TRAVELED,
new FormattedDoubleLegDetailColumn(stringConstants.distanceInMeters(), stringConstants.distanceInMetersUnit(),
new RaceDistanceTraveledInMeters(), 0, getLeaderboardPanel().getLeaderboardTable(),
LEG_COLUMN_HEADER_STYLE, LEG_COLUMN_STYLE));
result.put(DetailColumnType.RACE_AVERAGE_SPEED_OVER_GROUND_IN_KNOTS, new FormattedDoubleLegDetailColumn(
result.put(DetailType.RACE_AVERAGE_SPEED_OVER_GROUND_IN_KNOTS, new FormattedDoubleLegDetailColumn(
stringConstants.averageSpeedInKnots(), stringConstants.averageSpeedInKnotsUnit(), new RaceAverageSpeedInKnots(), 2, getLeaderboardPanel()
.getLeaderboardTable(), LEG_COLUMN_HEADER_STYLE, LEG_COLUMN_STYLE));
result.put(DetailColumnType.RACE_GAP_TO_LEADER_IN_SECONDS, new FormattedDoubleLegDetailColumn(
result.put(DetailType.RACE_GAP_TO_LEADER_IN_SECONDS, new FormattedDoubleLegDetailColumn(
stringConstants.gapToLeaderInSeconds(), stringConstants.gapToLeaderInSecondsUnit(), new RaceGapToLeaderInSeconds(), 0, getLeaderboardPanel()
.getLeaderboardTable(), LEG_COLUMN_HEADER_STYLE, LEG_COLUMN_STYLE));
result.put(DetailColumnType.RACE_MANEUVERS, new ManeuverCountRaceColumn(
result.put(DetailType.RACE_MANEUVERS, new ManeuverCountRaceColumn(
stringConstants.numberOfManeuvers(), getLeaderboardPanel()
.getLeaderboardTable(), this, LEG_COLUMN_HEADER_STYLE, LEG_COLUMN_STYLE, stringConstants));
return result;
@@ -714,11 +714,11 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
this.setLeaderboardName(leaderboardName);
this.errorReporter = errorReporter;
this.stringConstants = stringConstants;
this.selectedLegDetails = new ArrayList<DetailColumnType>();
this.selectedLegDetails.add(DetailColumnType.DISTANCE_TRAVELED);
this.selectedLegDetails.add(DetailColumnType.AVERAGE_SPEED_OVER_GROUND_IN_KNOTS);
this.selectedLegDetails.add(DetailColumnType.RANK_GAIN);
this.selectedRaceDetails = new ArrayList<DetailColumnType>();
this.selectedLegDetails = new ArrayList<DetailType>();
this.selectedLegDetails.add(DetailType.DISTANCE_TRAVELED);
this.selectedLegDetails.add(DetailType.AVERAGE_SPEED_OVER_GROUND_IN_KNOTS);
this.selectedLegDetails.add(DetailType.RANK_GAIN);
this.selectedRaceDetails = new ArrayList<DetailType>();
this.selectedRaceColumns = new ArrayList<String>();
delayInMilliseconds = 0l;
timer = new Timer(/* delayBetweenAutoAdvancesInMilliseconds */ 3000l);
@@ -17,23 +17,23 @@ import com.sap.sailing.gwt.ui.client.LeaderboardSettingsPanel.Result;
public class LeaderboardSettingsPanel extends DataEntryDialog<Result> {
private final List<String> raceColumnSelection;
private final List<String> raceAllRaceColumns;
private final List<DetailColumnType> legDetailSelection;
private final List<DetailColumnType> raceDetailSelection;
private final List<DetailType> legDetailSelection;
private final List<DetailType> raceDetailSelection;
private final Map<String, CheckBox> raceColumnCheckboxes;
private final Map<DetailColumnType, CheckBox> legDetailCheckboxes;
private final Map<DetailColumnType, CheckBox> raceDetailCheckboxes;
private final Map<DetailType, CheckBox> legDetailCheckboxes;
private final Map<DetailType, CheckBox> raceDetailCheckboxes;
private final StringConstants stringConstants;
private final IntegerBox delayBetweenAutoAdvancesInSecondsBox;
private final IntegerBox delayInSecondsBox;
public static class Result {
private final List<String> raceColumnsToShow;
private final List<DetailColumnType> legDetailsToShow;
private final List<DetailColumnType> raceDetailsToShow;
private final List<DetailType> legDetailsToShow;
private final List<DetailType> raceDetailsToShow;
private final long delayBetweenAutoAdvancesInMilliseconds;
private final long delayInMilliseconds;
public Result(List<DetailColumnType> legDetailsToShow, List<DetailColumnType> raceDetailsToShow, List<String> raceColumnsToShow, long delayBetweenAutoAdvancesInMilliseconds, long delayInMilliseconds) {
public Result(List<DetailType> legDetailsToShow, List<DetailType> raceDetailsToShow, List<String> raceColumnsToShow, long delayBetweenAutoAdvancesInMilliseconds, long delayInMilliseconds) {
this.legDetailsToShow = legDetailsToShow;
this.raceDetailsToShow = raceDetailsToShow;
this.raceColumnsToShow = raceColumnsToShow;
@@ -41,11 +41,11 @@ public class LeaderboardSettingsPanel extends DataEntryDialog<Result> {
this.delayInMilliseconds = delayInMilliseconds;
}
public List<DetailColumnType> getLegDetailsToShow() {
public List<DetailType> getLegDetailsToShow() {
return legDetailsToShow;
}
public List<DetailColumnType> getRaceDetailsToShow() {
public List<DetailType> getRaceDetailsToShow() {
return raceDetailsToShow;
}
@@ -62,7 +62,7 @@ public class LeaderboardSettingsPanel extends DataEntryDialog<Result> {
}
}
public LeaderboardSettingsPanel(List<DetailColumnType> legDetailSelection, List<DetailColumnType> raceDetailSelection, List<String> raceAllRaceColumns, List<String> raceColumnSelection,
public LeaderboardSettingsPanel(List<DetailType> legDetailSelection, List<DetailType> raceDetailSelection, List<String> raceAllRaceColumns, List<String> raceColumnSelection,
long delayBetweenAutoAdvancesInMilliseconds, String title, String message,
String okButtonName,
String cancelButtonName, com.sap.sailing.gwt.ui.client.DataEntryDialog.Validator<Result> validator, AsyncCallback<Result> callback, StringConstants stringConstants, long delayInMilliseconds) {
@@ -73,8 +73,8 @@ public class LeaderboardSettingsPanel extends DataEntryDialog<Result> {
this.raceDetailSelection = raceDetailSelection;
this.stringConstants = stringConstants;
raceColumnCheckboxes = new LinkedHashMap<String, CheckBox>();
legDetailCheckboxes = new LinkedHashMap<DetailColumnType, CheckBox>();
raceDetailCheckboxes = new LinkedHashMap<DetailColumnType, CheckBox>();
legDetailCheckboxes = new LinkedHashMap<DetailType, CheckBox>();
raceDetailCheckboxes = new LinkedHashMap<DetailType, CheckBox>();
delayBetweenAutoAdvancesInSecondsBox = createIntegerBox((int) delayBetweenAutoAdvancesInMilliseconds/1000, 4);
delayInSecondsBox = createIntegerBox((int) delayInMilliseconds/1000, 4);
}
@@ -94,16 +94,16 @@ public class LeaderboardSettingsPanel extends DataEntryDialog<Result> {
vpLeft.add(delayBetweenAutoAdvancesLabel);
vpLeft.add(delayBetweenAutoAdvancesInSecondsBox);
vpLeft.add(new Label(stringConstants.raceDetailsToShow()));
List<DetailColumnType> currentRaceDetailSelection = raceDetailSelection;
for (DetailColumnType type : LeaderboardPanel.getAvailableRaceDetailColumnTypes()) {
List<DetailType> currentRaceDetailSelection = raceDetailSelection;
for (DetailType type : LeaderboardPanel.getAvailableRaceDetailColumnTypes()) {
CheckBox checkbox = createCheckbox(type.toString(stringConstants));
checkbox.setValue(currentRaceDetailSelection.contains(type));
raceDetailCheckboxes.put(type, checkbox);
vpLeft.add(checkbox);
}
vpLeft.add(new Label(stringConstants.legDetailsToShow()));
List<DetailColumnType> currentLegDetailSelection = legDetailSelection;
for (DetailColumnType type : LegColumn.getAvailableLegDetailColumnTypes()) {
List<DetailType> currentLegDetailSelection = legDetailSelection;
for (DetailType type : LegColumn.getAvailableLegDetailColumnTypes()) {
CheckBox checkbox = createCheckbox(type.toString(stringConstants));
checkbox.setValue(currentLegDetailSelection.contains(type));
legDetailCheckboxes.put(type, checkbox);
@@ -125,14 +125,14 @@ public class LeaderboardSettingsPanel extends DataEntryDialog<Result> {
@Override
protected Result getResult() {
List<DetailColumnType> raceDetailsToShow = new ArrayList<DetailColumnType>();
for (Map.Entry<DetailColumnType, CheckBox> entry : raceDetailCheckboxes.entrySet()) {
List<DetailType> raceDetailsToShow = new ArrayList<DetailType>();
for (Map.Entry<DetailType, CheckBox> entry : raceDetailCheckboxes.entrySet()) {
if (entry.getValue().getValue()) {
raceDetailsToShow.add(entry.getKey());
}
}
List<DetailColumnType> legDetailsToShow = new ArrayList<DetailColumnType>();
for (Map.Entry<DetailColumnType, CheckBox> entry : legDetailCheckboxes.entrySet()) {
List<DetailType> legDetailsToShow = new ArrayList<DetailType>();
for (Map.Entry<DetailType, CheckBox> entry : legDetailCheckboxes.entrySet()) {
if (entry.getValue().getValue()) {
legDetailsToShow.add(entry.getKey());
}
@@ -186,7 +186,7 @@ public class LegColumn extends ExpandableSortableColumn<String> {
}
public LegColumn(LeaderboardPanel leaderboardPanel, String raceName, int legIndex, StringConstants stringConstants,
List<DetailColumnType> legDetailSelection, String headerStyle, String columnStyle,
List<DetailType> legDetailSelection, String headerStyle, String columnStyle,
String detailHeaderStyle, String detailColumnStyle) {
super(leaderboardPanel, /* expandable */true /* all legs have details */, new TextCell(), stringConstants,
detailHeaderStyle, detailColumnStyle, legDetailSelection);
@@ -198,49 +198,49 @@ public class LegColumn extends ExpandableSortableColumn<String> {
this.columnStyle = columnStyle;
}
public static DetailColumnType[] getAvailableLegDetailColumnTypes() {
return new DetailColumnType[] { DetailColumnType.AVERAGE_SPEED_OVER_GROUND_IN_KNOTS,
DetailColumnType.DISTANCE_TRAVELED, DetailColumnType.RANK_GAIN,
DetailColumnType.CURRENT_SPEED_OVER_GROUND_IN_KNOTS,
DetailColumnType.ESTIMATED_TIME_TO_NEXT_WAYPOINT_IN_SECONDS,
DetailColumnType.VELOCITY_MADE_GOOD_IN_KNOTS, DetailColumnType.GAP_TO_LEADER_IN_SECONDS,
DetailColumnType.WINDWARD_DISTANCE_TO_GO_IN_METERS,
DetailColumnType.NUMBER_OF_MANEUVERS };
public static DetailType[] getAvailableLegDetailColumnTypes() {
return new DetailType[] { DetailType.AVERAGE_SPEED_OVER_GROUND_IN_KNOTS,
DetailType.DISTANCE_TRAVELED, DetailType.RANK_GAIN,
DetailType.CURRENT_SPEED_OVER_GROUND_IN_KNOTS,
DetailType.ESTIMATED_TIME_TO_NEXT_WAYPOINT_IN_SECONDS,
DetailType.VELOCITY_MADE_GOOD_IN_KNOTS, DetailType.GAP_TO_LEADER_IN_SECONDS,
DetailType.WINDWARD_DISTANCE_TO_GO_IN_METERS,
DetailType.NUMBER_OF_MANEUVERS };
}
@Override
protected Map<DetailColumnType, SortableColumn<LeaderboardRowDAO, ?>> getDetailColumnMap(
protected Map<DetailType, SortableColumn<LeaderboardRowDAO, ?>> getDetailColumnMap(
LeaderboardPanel leaderboardPanel, StringConstants stringConstants, String detailHeaderStyle,
String detailColumnStyle) {
Map<DetailColumnType, SortableColumn<LeaderboardRowDAO, ?>> result = new HashMap<DetailColumnType, SortableColumn<LeaderboardRowDAO, ?>>();
result.put(DetailColumnType.DISTANCE_TRAVELED,
Map<DetailType, SortableColumn<LeaderboardRowDAO, ?>> result = new HashMap<DetailType, SortableColumn<LeaderboardRowDAO, ?>>();
result.put(DetailType.DISTANCE_TRAVELED,
new FormattedDoubleLegDetailColumn(stringConstants.distanceInMeters(), stringConstants.distanceInMetersUnit(),
new DistanceTraveledInMeters(), 0, getLeaderboardPanel().getLeaderboardTable(), detailHeaderStyle, detailColumnStyle));
result.put(DetailColumnType.AVERAGE_SPEED_OVER_GROUND_IN_KNOTS, new FormattedDoubleLegDetailColumn(
result.put(DetailType.AVERAGE_SPEED_OVER_GROUND_IN_KNOTS, new FormattedDoubleLegDetailColumn(
stringConstants.averageSpeedInKnots(), stringConstants.averageSpeedInKnotsUnit(), new AverageSpeedOverGroundInKnots(), 2, leaderboardPanel
.getLeaderboardTable(), detailHeaderStyle, detailColumnStyle));
result.put(DetailColumnType.CURRENT_SPEED_OVER_GROUND_IN_KNOTS, new FormattedDoubleLegDetailColumn(
result.put(DetailType.CURRENT_SPEED_OVER_GROUND_IN_KNOTS, new FormattedDoubleLegDetailColumn(
stringConstants.currentSpeedOverGroundInKnots(), stringConstants.currentSpeedOverGroundInKnotsUnit(), new CurrentSpeedOverGroundInKnots(),
2, getLeaderboardPanel().getLeaderboardTable(), detailHeaderStyle, detailColumnStyle));
result.put(DetailColumnType.ESTIMATED_TIME_TO_NEXT_WAYPOINT_IN_SECONDS,
result.put(DetailType.ESTIMATED_TIME_TO_NEXT_WAYPOINT_IN_SECONDS,
new FormattedDoubleLegDetailColumn(stringConstants.estimatedTimeToNextWaypointInSeconds(),
stringConstants.estimatedTimeToNextWaypointInSecondsUnit(),
new EstimatedTimeToNextWaypointInSeconds(), 1, getLeaderboardPanel().getLeaderboardTable(),
detailHeaderStyle, detailColumnStyle));
result.put(
DetailColumnType.GAP_TO_LEADER_IN_SECONDS,
DetailType.GAP_TO_LEADER_IN_SECONDS,
new FormattedDoubleLegDetailColumn(stringConstants.gapToLeaderInSeconds(), stringConstants.gapToLeaderInSecondsUnit(),
new GapToLeaderInSeconds(), 0, getLeaderboardPanel().getLeaderboardTable(), detailHeaderStyle, detailColumnStyle));
result.put(DetailColumnType.VELOCITY_MADE_GOOD_IN_KNOTS,
result.put(DetailType.VELOCITY_MADE_GOOD_IN_KNOTS,
new FormattedDoubleLegDetailColumn(stringConstants.velocityMadeGoodInKnots(),
stringConstants.velocityMadeGoodInKnotsUnit(), new VelocityMadeGoodInKnots(), 2,
getLeaderboardPanel().getLeaderboardTable(), detailHeaderStyle, detailColumnStyle));
result.put(DetailColumnType.WINDWARD_DISTANCE_TO_GO_IN_METERS, new FormattedDoubleLegDetailColumn(
result.put(DetailType.WINDWARD_DISTANCE_TO_GO_IN_METERS, new FormattedDoubleLegDetailColumn(
stringConstants.windwardDistanceToGoInMeters(), stringConstants.windwardDistanceToGoInMetersUnit(), new WindwardDistanceToGoInMeters(),
0, getLeaderboardPanel().getLeaderboardTable(), detailHeaderStyle, detailColumnStyle));
result.put(DetailColumnType.RANK_GAIN, new RankGainColumn(stringConstants.rankGain(), new RankGain(),
result.put(DetailType.RANK_GAIN, new RankGainColumn(stringConstants.rankGain(), new RankGain(),
getLeaderboardPanel().getLeaderboardTable(), detailHeaderStyle, detailColumnStyle));
result.put(DetailColumnType.NUMBER_OF_MANEUVERS, new ManeuverCountLegDetailsColumn(
result.put(DetailType.NUMBER_OF_MANEUVERS, new ManeuverCountLegDetailsColumn(
stringConstants.numberOfManeuvers(), getLeaderboardPanel()
.getLeaderboardTable(), detailHeaderStyle, detailColumnStyle));
return result;
@@ -132,7 +132,7 @@ public interface SailingService extends RemoteService {
String[] getCountryCodes();
List<Pair<CompetitorDAO, Double[]>> getCompetitorRaceData(RaceIdentifier race, CompetitorAndTimePointsDAO competitorAndTimePointsDAO, int dataType) throws Exception;
List<Pair<CompetitorDAO, Double[]>> getCompetitorRaceData(RaceIdentifier race, CompetitorAndTimePointsDAO competitorAndTimePointsDAO, DetailType dataType) throws Exception;
CompetitorAndTimePointsDAO getCompetitorAndTimePoints(RaceIdentifier race, int steps);
@@ -180,7 +180,7 @@ public interface SailingServiceAsync {
void getCountryCodes(AsyncCallback<String[]> callback);
void getCompetitorRaceData(RaceIdentifier race, CompetitorAndTimePointsDAO competitorAndTimePointsDAO,
int dataType, AsyncCallback<List<Pair<CompetitorDAO, Double[]>>> callback);
DetailType dataType, AsyncCallback<List<Pair<CompetitorDAO, Double[]>>> callback);
void getDouglasPoints(RaceIdentifier raceIdentifier, Map<CompetitorDAO, Date> from, Map<CompetitorDAO, Date> to,
double meters, AsyncCallback<Map<CompetitorDAO, List<GPSFixDAO>>> callback);
@@ -169,4 +169,5 @@ public interface StringConstants extends Constants {
String actionRaceUnlink();
String actionRaceRemove();
String filterLeaderboardsByName();
String windwardDistanceToOverallLeader();
}
@@ -163,4 +163,5 @@ actionRemove=Remove leaderboard
actionRaceEdit=Edit or rename race
actionRaceUnlink=Unlink race
actionRaceRemove=Remove race
filterLeaderboardsByName=Filter leaderboards by name
filterLeaderboardsByName=Filter leaderboards by name
windwardDistanceToOverallLeader=Windward distance to overall leader
@@ -164,4 +164,5 @@ actionRemove=Leaderboard entfernen
actionRaceEdit=Rennen ändern oder umbenennen
actionRaceUnlink=Rennverknüpfung entfernen
actionRaceRemove=Rennen entfernen
filterLeaderboardsByName=Leaderboards nach Name filtern
filterLeaderboardsByName=Leaderboards nach Name filtern
windwardDistanceToOverallLeader=Windward distance to overall leader
@@ -74,7 +74,7 @@ import com.sap.sailing.domain.tracking.impl.WindTrackImpl;
import com.sap.sailing.domain.tractracadapter.DomainFactory;
import com.sap.sailing.domain.tractracadapter.RaceRecord;
import com.sap.sailing.domain.tractracadapter.TracTracConfiguration;
import com.sap.sailing.gwt.ui.client.CompareCompetitorsPanel;
import com.sap.sailing.gwt.ui.client.DetailType;
import com.sap.sailing.gwt.ui.client.SailingService;
import com.sap.sailing.gwt.ui.shared.BoatClassDAO;
import com.sap.sailing.gwt.ui.shared.CompetitorDAO;
@@ -1177,7 +1177,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
}
@Override
public List<Pair<CompetitorDAO, Double[]>> getCompetitorRaceData(RaceIdentifier race, CompetitorAndTimePointsDAO competitorAndTimePointsDAO, int dataType) throws NoWindException {
public List<Pair<CompetitorDAO, Double[]>> getCompetitorRaceData(RaceIdentifier race, CompetitorAndTimePointsDAO competitorAndTimePointsDAO, DetailType dataType) throws NoWindException {
List<Pair<CompetitorDAO, Double[]>> competitorData = new ArrayList<Pair<CompetitorDAO, Double[]>>();
TrackedRace trackedRace = getTrackedRace(race);
Iterable<Competitor> competitors = trackedRace.getRace().getCompetitors();
@@ -1191,7 +1191,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
}
switch (dataType){
case CompareCompetitorsPanel.SHOW_CURRENT_SPEED_OVER_GROUND:
case CURRENT_SPEED_OVER_GROUND_IN_KNOTS:
for (int c = 0; c < selectedCompetitor.size(); c++){
Double[] entries = new Double[competitorAndTimePointsDAO.getTimePoints().length];
for (int i = 0; i < competitorAndTimePointsDAO.getTimePoints().length; i++){
@@ -1205,7 +1205,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
competitorData.add(new Pair<CompetitorDAO, Double[]>(competitorAndTimePointsDAO.getCompetitor()[c], entries));
}
break;
case CompareCompetitorsPanel.SHOW_VELOCITY_MADE_GOOD:
case VELOCITY_MADE_GOOD_IN_KNOTS:
for (int c = 0; c < selectedCompetitor.size(); c++){
Double[] entries = new Double[competitorAndTimePointsDAO.getTimePoints().length];
for (int i = 0; i < competitorAndTimePointsDAO.getTimePoints().length; i++){
@@ -1219,7 +1219,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
competitorData.add(new Pair<CompetitorDAO, Double[]>(competitorAndTimePointsDAO.getCompetitor()[c], entries));
}
break;
case CompareCompetitorsPanel.SHOW_DISTANCE_TRAVELED:
case DISTANCE_TRAVELED:
for (int c = 0; c < selectedCompetitor.size(); c++){
Double[] entries = new Double[competitorAndTimePointsDAO.getTimePoints().length];
double distanceOfPreviousLegs = 0;
@@ -1242,7 +1242,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
competitorData.add(new Pair<CompetitorDAO, Double[]>(competitorAndTimePointsDAO.getCompetitor()[c], entries));
}
break;
case CompareCompetitorsPanel.SHOW_GAP_TO_LEADER:
case GAP_TO_LEADER_IN_SECONDS:
for (int c = 0; c < selectedCompetitor.size(); c++){
Double[] entries = new Double[competitorAndTimePointsDAO.getTimePoints().length];
for (int i = 0; i < competitorAndTimePointsDAO.getTimePoints().length; i++){
@@ -1255,7 +1255,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
competitorData.add(new Pair<CompetitorDAO, Double[]>(competitorAndTimePointsDAO.getCompetitor()[c], entries));
}
break;
case CompareCompetitorsPanel.SHOW_WINDWARD_DISTANCE_TO_LEADER:
case WINDWARD_DISTANCE_TO_OVERALL_LEADER:
for (int c = 0; c < selectedCompetitor.size(); c++){
Double[] entries = new Double[competitorAndTimePointsDAO.getTimePoints().length];
try {