mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-02 02:13:55 +00:00
further TimePanel und RaceTimePanel adjustments, new setting for automated calculation of delay for live mode simulation
This commit is contained in:
1 parent
2e3ee39fff
commit
3d2b04ed4e
8 files changed
+156
-59
No files matched your search
+27
-9
@@ -11,8 +11,9 @@ import com.sap.sailing.gwt.ui.client.Timer.PlayModes;
|
||||
import com.sap.sailing.gwt.ui.client.Timer.PlayStates;
|
||||
import com.sap.sailing.gwt.ui.shared.LegTimesInfoDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.RaceTimesInfoDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.components.SettingsDialogComponent;
|
||||
|
||||
public class RaceTimePanel extends TimePanel implements RaceSelectionChangeListener {
|
||||
public class RaceTimePanel extends TimePanel<RaceTimePanelSettings> implements RaceSelectionChangeListener {
|
||||
private final SailingServiceAsync sailingService;
|
||||
private final ErrorReporter errorReporter;
|
||||
|
||||
@@ -24,6 +25,8 @@ public class RaceTimePanel extends TimePanel implements RaceSelectionChangeListe
|
||||
|
||||
private boolean isTimerInitialized = false;
|
||||
|
||||
private RaceTimesInfoDTO lastRaceTimesInfo;
|
||||
|
||||
public RaceTimePanel(final SailingServiceAsync sailingService, Timer timer, ErrorReporter errorReporter, StringMessages stringMessages) {
|
||||
super(timer, stringMessages);
|
||||
|
||||
@@ -65,7 +68,7 @@ public class RaceTimePanel extends TimePanel implements RaceSelectionChangeListe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSettings(TimePanelSettings newSettings) {
|
||||
public void updateSettings(RaceTimePanelSettings newSettings) {
|
||||
super.updateSettings(newSettings);
|
||||
|
||||
isTimerInitialized = false;
|
||||
@@ -74,23 +77,38 @@ public class RaceTimePanel extends TimePanel implements RaceSelectionChangeListe
|
||||
readRaceTimesInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RaceTimePanelSettings getSettings() {
|
||||
RaceTimePanelSettings result = new RaceTimePanelSettings();
|
||||
result.setDelayToLivePlayInSeconds(timer.getLivePlayDelayInMillis()/1000);
|
||||
result.setRefreshInterval(timer.getRefreshInterval());
|
||||
result.setRaceTimesInfo(lastRaceTimesInfo);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SettingsDialogComponent<RaceTimePanelSettings> getSettingsDialogComponent() {
|
||||
return new RaceTimePanelSettingsDialogComponent(getSettings(), stringMessages);
|
||||
}
|
||||
|
||||
private void updateTimeInfos(RaceTimesInfoDTO raceTimesInfo) {
|
||||
if(raceTimesInfo == null || raceTimesInfo.timePointOfNewestEvent == null) {
|
||||
lastRaceTimesInfo = raceTimesInfo;
|
||||
|
||||
if(raceTimesInfo == null || raceTimesInfo.timePointOfNewestEvent == null || raceTimesInfo.startOfTracking == null) {
|
||||
reset();
|
||||
} else {
|
||||
// we set here the min and max of the time slider, the start and end of the race as well as the knows leg markers
|
||||
if(!isTimerInitialized)
|
||||
{
|
||||
// manipulation of delay to make the event 'live'
|
||||
// long lastEventTimeDelay = System.currentTimeMillis() - raceTimesInfo.timePointOfNewestEvent.getTime() + 1000;
|
||||
// timer.setDelay(lastEventTimeDelay);
|
||||
|
||||
long livePlayDelayInMillis = timer.getLivePlayDelayInMillis();
|
||||
long liveTimePointInMillis = System.currentTimeMillis() - livePlayDelayInMillis;
|
||||
|
||||
if(raceTimesInfo.timePointOfNewestEvent.getTime() > System.currentTimeMillis() - livePlayDelayInMillis)
|
||||
if(liveTimePointInMillis < raceTimesInfo.timePointOfNewestEvent.getTime() &&
|
||||
liveTimePointInMillis > raceTimesInfo.startOfTracking.getTime()) {
|
||||
timer.setPlayMode(PlayModes.Live);
|
||||
else
|
||||
} else {
|
||||
timer.setPlayMode(PlayModes.Replay);
|
||||
}
|
||||
|
||||
initMinMax(raceTimesInfo);
|
||||
initTimerPosition(raceTimesInfo);
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.sap.sailing.gwt.ui.client;
|
||||
|
||||
import com.sap.sailing.gwt.ui.shared.RaceTimesInfoDTO;
|
||||
|
||||
public class RaceTimePanelSettings extends TimePanelSettings {
|
||||
private RaceTimesInfoDTO raceTimesInfo;
|
||||
|
||||
public RaceTimePanelSettings() {
|
||||
super();
|
||||
}
|
||||
|
||||
public RaceTimesInfoDTO getRaceTimesInfo() {
|
||||
return raceTimesInfo;
|
||||
}
|
||||
|
||||
public void setRaceTimesInfo(RaceTimesInfoDTO raceTimesInfo) {
|
||||
this.raceTimesInfo = raceTimesInfo;
|
||||
}
|
||||
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.sap.sailing.gwt.ui.client;
|
||||
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.gwt.ui.shared.RaceTimesInfoDTO;
|
||||
|
||||
public class RaceTimePanelSettingsDialogComponent extends TimePanelSettingsDialogComponent<RaceTimePanelSettings> {
|
||||
|
||||
public RaceTimePanelSettingsDialogComponent(RaceTimePanelSettings settings, StringMessages stringMessages) {
|
||||
super(settings, stringMessages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Widget getAdditionalWidget(DataEntryDialog<RaceTimePanelSettings> dialog) {
|
||||
Widget widget = super.getAdditionalWidget(dialog);
|
||||
|
||||
HorizontalPanel labelAndTDelayForLiveBoxPanel = new HorizontalPanel();
|
||||
labelAndTDelayForLiveBoxPanel.setSpacing(5);
|
||||
labelAndTDelayForLiveBoxPanel.add(new Label("Delay for live mode:"));
|
||||
RaceTimesInfoDTO raceTimesInfo = initialSettings.getRaceTimesInfo();
|
||||
if(raceTimesInfo != null && raceTimesInfo.startOfTracking != null) {
|
||||
long delayforLiveModeInMs = System.currentTimeMillis() - raceTimesInfo.getStartOfTracking().getTime();
|
||||
labelAndTDelayForLiveBoxPanel.add(new Label(delayforLiveModeInMs / 1000 + " s"));
|
||||
}
|
||||
mainContentPanel.add(labelAndTDelayForLiveBoxPanel);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RaceTimePanelSettings getResult() {
|
||||
RaceTimePanelSettings result = new RaceTimePanelSettings();
|
||||
result.setDelayToLivePlayInSeconds(timeDelayBox.getValue() == null ? -1 : timeDelayBox.getValue());
|
||||
result.setRefreshInterval(refreshIntervalBox.getValue() == null ? -1 : (long) (refreshIntervalBox.getValue() * 1000));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+36
-23
@@ -30,7 +30,7 @@ import com.sap.sailing.gwt.ui.shared.components.SettingsDialog;
|
||||
import com.sap.sailing.gwt.ui.shared.components.SettingsDialogComponent;
|
||||
import com.sap.sailing.gwt.ui.shared.controls.slider.SliderBar;
|
||||
|
||||
public class TimePanel extends FormPanel implements Component<TimePanelSettings>, TimeListener, PlayStateListener, RequiresResize {
|
||||
public class TimePanel<T extends TimePanelSettings> extends FormPanel implements Component<T>, TimeListener, PlayStateListener, RequiresResize {
|
||||
protected final Timer timer;
|
||||
private final IntegerBox playSpeedBox;
|
||||
private final Label timeDelayLabel;
|
||||
@@ -39,9 +39,9 @@ public class TimePanel extends FormPanel implements Component<TimePanelSettings>
|
||||
private final Label playModeLabel;
|
||||
protected final SliderBar sliderBar;
|
||||
private final Button backToLivePlayButton;
|
||||
private final StringMessages stringMessages;
|
||||
private final DateTimeFormat dateFormatter = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_FULL);
|
||||
private final DateTimeFormat timeFormatter = DateTimeFormat.getFormat("HH:mm:ss");
|
||||
protected final StringMessages stringMessages;
|
||||
protected final DateTimeFormat dateFormatter = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_FULL);
|
||||
protected final DateTimeFormat timeFormatter = DateTimeFormat.getFormat("HH:mm:ss");
|
||||
private final ImageResource playButtonImg;
|
||||
private final ImageResource pauseButtonImg;
|
||||
private final ImageResource playSpeedImg;
|
||||
@@ -50,7 +50,9 @@ public class TimePanel extends FormPanel implements Component<TimePanelSettings>
|
||||
private final ImageResource playModeInactiveImg;
|
||||
private final Image playPauseImage;
|
||||
private final Image playModeImage;
|
||||
private Date lastReceivedDataTimepoint;
|
||||
protected Date lastReceivedDataTimepoint;
|
||||
private final Button slowDownButton;
|
||||
private final Button speedUpButton;
|
||||
|
||||
private static ClientResources resources = GWT.create(ClientResources.class);
|
||||
|
||||
@@ -63,7 +65,7 @@ public class TimePanel extends FormPanel implements Component<TimePanelSettings>
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
new SettingsDialog<TimePanelSettings>(TimePanel.this, stringConstants).show();
|
||||
new SettingsDialog<T>(TimePanel.this, stringConstants).show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,8 +138,21 @@ public class TimePanel extends FormPanel implements Component<TimePanelSettings>
|
||||
}
|
||||
}
|
||||
});
|
||||
playPauseImage.getElement().getStyle().setFloat(Style.Float.LEFT);
|
||||
playPauseImage.getElement().getStyle().setPadding(3, Style.Unit.PX);
|
||||
playControlPanel.add(playPauseImage);
|
||||
|
||||
|
||||
backToLivePlayButton = new Button("Live");
|
||||
backToLivePlayButton.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
TimePanel.this.timer.resume();
|
||||
}
|
||||
});
|
||||
backToLivePlayButton.getElement().getStyle().setFloat(Style.Float.LEFT);
|
||||
backToLivePlayButton.getElement().getStyle().setPadding(3, Style.Unit.PX);
|
||||
playControlPanel.add(backToLivePlayButton);
|
||||
|
||||
// current date and time control
|
||||
FlowPanel timeControlPanel = new FlowPanel();
|
||||
timeControlPanel.setStyleName("timePanel-controls-time");
|
||||
@@ -166,15 +181,6 @@ public class TimePanel extends FormPanel implements Component<TimePanelSettings>
|
||||
playModeLabel.getElement().getStyle().setFloat(Style.Float.LEFT);
|
||||
playModeLabel.getElement().getStyle().setPadding(5, Style.Unit.PX);
|
||||
|
||||
backToLivePlayButton = new Button("> Live");
|
||||
backToLivePlayButton.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
TimePanel.this.timer.play();
|
||||
}
|
||||
});
|
||||
controlsPanel.add(backToLivePlayButton);
|
||||
|
||||
// play speed controls
|
||||
FlowPanel playSpeedControlPanel = new FlowPanel();
|
||||
playSpeedControlPanel.setStyleName("timePanel-controls-playSpeed");
|
||||
@@ -189,7 +195,7 @@ public class TimePanel extends FormPanel implements Component<TimePanelSettings>
|
||||
playSpeedControlPanel.add(playSpeedImage);
|
||||
playSpeedControlPanel.add(playSpeedBox);
|
||||
|
||||
Button slowDownButton = new Button("-1");
|
||||
slowDownButton = new Button("-1");
|
||||
slowDownButton.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
@@ -199,7 +205,7 @@ public class TimePanel extends FormPanel implements Component<TimePanelSettings>
|
||||
});
|
||||
playSpeedControlPanel.add(slowDownButton);
|
||||
|
||||
Button speedUpButton = new Button("+1");
|
||||
speedUpButton = new Button("+1");
|
||||
speedUpButton.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
@@ -333,6 +339,9 @@ public class TimePanel extends FormPanel implements Component<TimePanelSettings>
|
||||
timeDelayLabel.setVisible(true);
|
||||
sliderBar.setEnabled(true);
|
||||
backToLivePlayButton.setVisible(true);
|
||||
playSpeedBox.setEnabled(false);
|
||||
slowDownButton.setEnabled(false);
|
||||
speedUpButton.setEnabled(false);
|
||||
break;
|
||||
case Replay:
|
||||
timeDelayLabel.setVisible(false);
|
||||
@@ -340,15 +349,19 @@ public class TimePanel extends FormPanel implements Component<TimePanelSettings>
|
||||
playModeLabel.setText(stringMessages.playModeReplay());
|
||||
sliderBar.setEnabled(true);
|
||||
backToLivePlayButton.setVisible(false);
|
||||
playSpeedBox.setEnabled(true);
|
||||
slowDownButton.setEnabled(true);
|
||||
speedUpButton.setEnabled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public TimePanelSettings getSettings() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public T getSettings() {
|
||||
TimePanelSettings result = new TimePanelSettings();
|
||||
result.setDelayToLivePlayInSeconds(timer.getLivePlayDelayInMillis()/1000);
|
||||
result.setRefreshInterval(timer.getRefreshInterval());
|
||||
return result;
|
||||
return (T) result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -362,12 +375,12 @@ public class TimePanel extends FormPanel implements Component<TimePanelSettings>
|
||||
}
|
||||
|
||||
@Override
|
||||
public SettingsDialogComponent<TimePanelSettings> getSettingsDialogComponent() {
|
||||
return new TimePanelSettingsDialogComponent(getSettings(), stringMessages);
|
||||
public SettingsDialogComponent<T> getSettingsDialogComponent() {
|
||||
return new TimePanelSettingsDialogComponent<T>(getSettings(), stringMessages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSettings(TimePanelSettings newSettings) {
|
||||
public void updateSettings(T newSettings) {
|
||||
boolean delayChanged = newSettings.getDelayToLivePlayInSeconds() != getSettings().getDelayToLivePlayInSeconds();
|
||||
if (delayChanged) {
|
||||
timer.setDelay(1000l * newSettings.getDelayToLivePlayInSeconds());
|
||||
|
||||
+26
-22
@@ -10,47 +10,51 @@ import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.gwt.ui.client.DataEntryDialog.Validator;
|
||||
import com.sap.sailing.gwt.ui.shared.components.SettingsDialogComponent;
|
||||
|
||||
public class TimePanelSettingsDialogComponent implements SettingsDialogComponent<TimePanelSettings> {
|
||||
private LongBox timeDelayBox;
|
||||
private DoubleBox refreshIntervalBox;
|
||||
private final StringMessages stringMessages;
|
||||
private final TimePanelSettings initialSettings;
|
||||
public class TimePanelSettingsDialogComponent<T extends TimePanelSettings> implements SettingsDialogComponent<T> {
|
||||
protected LongBox timeDelayBox;
|
||||
protected DoubleBox refreshIntervalBox;
|
||||
protected final StringMessages stringMessages;
|
||||
protected final T initialSettings;
|
||||
protected VerticalPanel mainContentPanel;
|
||||
|
||||
public TimePanelSettingsDialogComponent(TimePanelSettings settings, StringMessages stringMessages) {
|
||||
public TimePanelSettingsDialogComponent(T settings, StringMessages stringMessages) {
|
||||
this.stringMessages = stringMessages;
|
||||
initialSettings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Widget getAdditionalWidget(DataEntryDialog<TimePanelSettings> dialog) {
|
||||
VerticalPanel vp = new VerticalPanel();
|
||||
|
||||
HorizontalPanel labelAndTimeDelayBoxPanel = new HorizontalPanel();
|
||||
labelAndTimeDelayBoxPanel.add(new Label(stringMessages.timeDelay()));
|
||||
timeDelayBox = dialog.createLongBox(initialSettings.getDelayToLivePlayInSeconds(), 4);
|
||||
labelAndTimeDelayBoxPanel.add(timeDelayBox);
|
||||
vp.add(labelAndTimeDelayBoxPanel);
|
||||
|
||||
public Widget getAdditionalWidget(DataEntryDialog<T> dialog) {
|
||||
mainContentPanel = new VerticalPanel();
|
||||
|
||||
HorizontalPanel labelAndRefreshIntervalBoxPanel = new HorizontalPanel();
|
||||
labelAndRefreshIntervalBoxPanel.add(new Label(stringMessages.refreshInterval()));
|
||||
labelAndRefreshIntervalBoxPanel.setSpacing(5);
|
||||
labelAndRefreshIntervalBoxPanel.add(new Label(stringMessages.refreshInterval() + ":"));
|
||||
refreshIntervalBox = dialog.createDoubleBox(((double) initialSettings.getRefreshInterval()) / 1000, 4);
|
||||
labelAndRefreshIntervalBoxPanel.add(refreshIntervalBox);
|
||||
vp.add(labelAndRefreshIntervalBoxPanel);
|
||||
mainContentPanel.add(labelAndRefreshIntervalBoxPanel);
|
||||
|
||||
return vp;
|
||||
HorizontalPanel labelAndTimeDelayBoxPanel = new HorizontalPanel();
|
||||
labelAndTimeDelayBoxPanel.setSpacing(5);
|
||||
labelAndTimeDelayBoxPanel.add(new Label(stringMessages.timeDelay() + ":"));
|
||||
timeDelayBox = dialog.createLongBox(initialSettings.getDelayToLivePlayInSeconds(), 10);
|
||||
labelAndTimeDelayBoxPanel.add(timeDelayBox);
|
||||
mainContentPanel.add(labelAndTimeDelayBoxPanel);
|
||||
|
||||
return mainContentPanel;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public TimePanelSettings getResult() {
|
||||
TimePanelSettings result = new TimePanelSettings();
|
||||
public T getResult() {
|
||||
T result = (T) new TimePanelSettings();
|
||||
result.setDelayToLivePlayInSeconds(timeDelayBox.getValue() == null ? -1 : timeDelayBox.getValue());
|
||||
result.setRefreshInterval(refreshIntervalBox.getValue() == null ? -1 : (long) (refreshIntervalBox.getValue() * 1000));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Validator<TimePanelSettings> getValidator() {
|
||||
return new Validator<TimePanelSettings>() {
|
||||
public Validator<T> getValidator() {
|
||||
return new Validator<T>() {
|
||||
@Override
|
||||
public String getErrorMessage(TimePanelSettings valueToValidate) {
|
||||
String errorMessage = null;
|
||||
|
||||
+3
-3
@@ -112,9 +112,9 @@ public class RaceBoardPanel extends FormPanel implements EventDisplayer, RaceSel
|
||||
componentsNavigationPanel.addStyleName("raceBoardNavigation");
|
||||
|
||||
boolean showLeaderboard = true;
|
||||
boolean showMap = true;
|
||||
boolean showWindCharts = true;
|
||||
boolean showCompetitorCharts = true;
|
||||
boolean showMap = false;
|
||||
boolean showWindCharts = false;
|
||||
boolean showCompetitorCharts = false;
|
||||
|
||||
if (user == null) {
|
||||
// anonymous user
|
||||
|
||||
+1
-1
@@ -754,7 +754,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
|
||||
TrackedRace trackedRace = getExistingTrackedRace(raceIdentifier);
|
||||
if (trackedRace != null) {
|
||||
raceTimesInfo = new RaceTimesInfoDTO();
|
||||
raceTimesInfo = new RaceTimesInfoDTO(raceIdentifier);
|
||||
|
||||
raceTimesInfo.startOfRace = trackedRace.getStart() == null ? null : trackedRace.getStart().asDate();
|
||||
raceTimesInfo.startOfTracking = trackedRace.getStartOfTracking() == null ? null : trackedRace.getStartOfTracking().asDate();
|
||||
|
||||
+5
-1
@@ -10,7 +10,7 @@ import com.sap.sailing.domain.common.RaceIdentifier;
|
||||
public class RaceTimesInfoDTO implements IsSerializable {
|
||||
private RaceIdentifier raceIdentifier;
|
||||
|
||||
private List<LegTimesInfoDTO> legTimes;
|
||||
public List<LegTimesInfoDTO> legTimes;
|
||||
|
||||
public Date startOfRace;
|
||||
public Date startOfTracking;
|
||||
@@ -20,6 +20,10 @@ public class RaceTimesInfoDTO implements IsSerializable {
|
||||
public Date timePointOfLastEvent;
|
||||
public Date timePointOfNewestEvent;
|
||||
|
||||
public RaceTimesInfoDTO(RaceIdentifier raceIdentifier) {
|
||||
this.raceIdentifier = raceIdentifier;
|
||||
}
|
||||
|
||||
public RaceTimesInfoDTO() {}
|
||||
|
||||
public RaceIdentifier getRaceIdentifier() {
|
||||
|
||||
Reference in new issue
Block a user