Merge branch 'master' into updatable-chart_2

Conflicts:
	java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/shared/controls/slider/SliderBar.java
This commit is contained in:
Axel Uhl committed 2012-02-28 20:58:56 +01:00
commit 20b9c3b88c
8 files changed
+59 -30

No files matched your search

@@ -261,7 +261,7 @@ public class SwissTimingRaceTrackerImpl extends AbstractRaceTrackerImpl implemen
* {@link #trackedRace} with data received from the trackers.
*/
private boolean isTrackedRaceStillReachable() {
return Util.contains(getEvent().getAllRaces(), trackedRace.getRace()) &&
return trackedRace != null && Util.contains(getEvent().getAllRaces(), trackedRace.getRace()) &&
getTrackedEvent().getExistingTrackedRace(trackedRace.getRace()) == trackedRace;
}
@@ -194,6 +194,13 @@ public interface TrackedRace {
*/
TimePoint getTimePointOfNewestEvent();
/**
* @return the mark passings for <code>competitor</code> in this race received so far; the mark passing objects are
* returned such that their {@link MarkPassing#getWaypoint() waypoints} are ordered in the same way they are ordered
* in the race's {@link Course}. Note, that this doesn't necessarily guarantee ascending time points, particularly
* if premature mark passings have been detected accidentally as can be the case with some tracking providers such
* as TracTrac.
*/
NavigableSet<MarkPassing> getMarkPassings(Competitor competitor);
void removeWind(Wind wind, WindSource windSource);
@@ -100,10 +100,15 @@ public class DynamicGPSFixMovingTrackImpl<ItemType> extends DynamicTrackImpl<Ite
NavigableSet<GPSFixMoving> fixesToUseForSpeedEstimation) {
// TODO factor out the obtaining of relevant fixes which should be the same in super.getEstimatedSpeed(at)
DummyGPSFixMoving atTimed = new DummyGPSFixMoving(at);
NavigableSet<GPSFixMoving> beforeSet = fixesToUseForSpeedEstimation.headSet(atTimed, /* inclusive */ false);
NavigableSet<GPSFixMoving> afterSet = fixesToUseForSpeedEstimation.tailSet(atTimed, /* inclusive */ true);
List<GPSFixMoving> relevantFixes = new LinkedList<GPSFixMoving>();
boolean beforeSetEmpty;
GPSFixMoving beforeSetLast = null;
synchronized (this) {
NavigableSet<GPSFixMoving> beforeSet = fixesToUseForSpeedEstimation.headSet(atTimed, /* inclusive */ false);
beforeSetEmpty = beforeSet.isEmpty(); // ask this while holding the lock
if (!beforeSetEmpty) {
beforeSetLast = beforeSet.last();
}
for (GPSFixMoving beforeFix : beforeSet.descendingSet()) {
if (at.asMillis() - beforeFix.getTimePoint().asMillis() > getMillisecondsOverWhichToAverage() / 2) {
break;
@@ -111,7 +116,14 @@ public class DynamicGPSFixMovingTrackImpl<ItemType> extends DynamicTrackImpl<Ite
relevantFixes.add(0, beforeFix);
}
}
boolean afterSetEmpty;
GPSFixMoving afterSetFirst = null;
synchronized (this) {
NavigableSet<GPSFixMoving> afterSet = fixesToUseForSpeedEstimation.tailSet(atTimed, /* inclusive */ true);
afterSetEmpty = afterSet.isEmpty(); // ask this while holding the lock
if (!afterSetEmpty) {
afterSetFirst = afterSet.first();
}
for (GPSFixMoving afterFix : afterSet) {
if (afterFix.getTimePoint().asMillis() - at.asMillis() > getMillisecondsOverWhichToAverage() / 2) {
break;
@@ -121,16 +133,16 @@ public class DynamicGPSFixMovingTrackImpl<ItemType> extends DynamicTrackImpl<Ite
}
if (relevantFixes.isEmpty()) {
// find the fix closest to "at":
if (beforeSet.isEmpty()) {
if (!afterSet.isEmpty()) {
relevantFixes.add(afterSet.first());
if (beforeSetEmpty) {
if (!afterSetEmpty) {
relevantFixes.add(afterSetFirst);
}
} else {
if (afterSet.isEmpty()) {
relevantFixes.add(beforeSet.last());
if (afterSetEmpty) {
relevantFixes.add(beforeSetLast);
} else {
GPSFixMoving beforeFix = beforeSet.last();
GPSFixMoving afterFix = afterSet.first();
GPSFixMoving beforeFix = beforeSetLast;
GPSFixMoving afterFix = afterSetFirst;
relevantFixes.add(at.asMillis() - beforeFix.getTimePoint().asMillis() <= afterFix.getTimePoint()
.asMillis() - at.asMillis() ? beforeFix : afterFix);
}
@@ -43,6 +43,7 @@ public class RaceRankComparator implements Comparator<Competitor> {
if (o1 == o2) {
result = 0;
} else {
// TODO see also bug 340/342; need to synchronize on TrackedRace to avoid concurrent updates to MarkPassings, although this is course-grained
NavigableSet<MarkPassing> o1MarkPassings = trackedRace.getMarkPassings(o1).headSet(
markPassingWithTimePoint, /* inclusive */true);
NavigableSet<MarkPassing> o2MarkPassings = trackedRace.getMarkPassings(o2).headSet(
@@ -1,5 +1,6 @@
package com.sap.sailing.domain.tracking.impl;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.NavigableSet;
@@ -39,6 +40,10 @@ public abstract class TrackImpl<FixType extends Timed> implements Track<FixType>
this.fixes = fixes;
}
/**
* Callers that want to iterate over the collection returned need to synchronize on <code>this</code> object to avoid
* {@link ConcurrentModificationException}s.
*/
protected NavigableSet<FixType> getInternalRawFixes() {
@SuppressWarnings("unchecked")
NavigableSet<FixType> result = (NavigableSet<FixType>) fixes;
@@ -46,8 +51,11 @@ public abstract class TrackImpl<FixType extends Timed> implements Track<FixType>
}
/**
* @return the smoothened fixes; this implementation simply delegates to {@link #getInternalRawFixes()} because for only
* {@link Timed} fixes we can't know how to remove outliers. Subclasses that constrain the
* Callers that want to iterate over the collection returned need to synchronize on <code>this</code> object to
* avoid {@link ConcurrentModificationException}s.
*
* @return the smoothened fixes; this implementation simply delegates to {@link #getInternalRawFixes()} because for
* only {@link Timed} fixes we can't know how to remove outliers. Subclasses that constrain the
* <code>FixType</code> may provide smoothening implementations.
*/
protected NavigableSet<FixType> getInternalFixes() {
@@ -174,7 +174,7 @@ public class RaceTimePanel extends TimePanel<RaceTimePanelSettings> implements R
}
// never reduce max if it was already set
if (min != null && max != null && (getMax() == null || getMax().before(max))) {
setMinMax(min, max);
setMinMax(min, max, /* fireEvent */ false); // no event because we guarantee time to be between min and max
}
}
@@ -36,14 +36,14 @@ public class TimePanel<T extends TimePanelSettings> extends FormPanel implements
/**
* The start time point of the time interval visualized by this time panel. May be <code>null</code> if not yet initialized.
*
* @see #setMinMax(Date, Date)
* @see #setMinMax(Date, Date, boolean)
*/
private Date min;
/**
* The end time point of the time interval visualized by this time panel. May be <code>null</code> if not yet initialized.
*
* @see #setMinMax(Date, Date)
* @see #setMinMax(Date, Date, boolean)
*/
private Date max;
@@ -271,7 +271,7 @@ public class TimePanel<T extends TimePanelSettings> extends FormPanel implements
// Handle it equally for replay and live mode for robustness reasons. This at least allows a user
// to watch on even if the time panel was off in its assumptions about race end and end of tracking.
if (time.after(getMax())) {
setMinMax(getMin(), time);
setMinMax(getMin(), time, /* fireEvent */ false); // no event because we guarantee that time is between min/max
}
long t = time.getTime();
sliderBar.setCurrentValue(new Double(t), false);
@@ -295,22 +295,23 @@ public class TimePanel<T extends TimePanelSettings> extends FormPanel implements
/**
* @param min must not be <code>null</code>
* @param max must not be <code>null</code>
* @param fireEvent TODO
*/
public void setMinMax(Date min, Date max) {
public void setMinMax(Date min, Date max, boolean fireEvent) {
assert min != null && max != null;
boolean changed = false;
int numTicks = 8;
if (!max.equals(this.max)) {
changed = true;
this.max = max;
sliderBar.setMaxValue(new Double(max.getTime()));
sliderBar.setMaxValue(new Double(max.getTime()), fireEvent);
}
if (!min.equals(this.min)) {
changed = true;
this.min = min;
sliderBar.setMinValue(new Double(min.getTime()));
sliderBar.setMinValue(new Double(min.getTime()), fireEvent);
if (sliderBar.getCurrentValue() == null) {
sliderBar.setCurrentValue(new Double(min.getTime()));
sliderBar.setCurrentValue(new Double(min.getTime()), fireEvent);
}
}
if (changed) {
@@ -318,9 +319,9 @@ public class TimePanel<T extends TimePanelSettings> extends FormPanel implements
sliderBar.setNumTicks(numTicks);
int numSteps = sliderBar.getElement().getClientWidth();
if (numSteps > 0) {
sliderBar.setStepSize(numSteps);
sliderBar.setStepSize(numSteps, fireEvent);
} else {
sliderBar.setStepSize(1000);
sliderBar.setStepSize(1000, fireEvent);
}
}
}
@@ -702,10 +702,10 @@ public class SliderBar extends FocusPanel implements RequiresResize, HasValue<Do
* @param maxValue
* the current value
*/
public void setMaxValue(Double maxValue) {
public void setMaxValue(Double maxValue, boolean fireEvent) {
this.maxValue = maxValue;
drawTickLabels();
resetCurrentValue();
resetCurrentValue(fireEvent);
}
/**
@@ -714,10 +714,10 @@ public class SliderBar extends FocusPanel implements RequiresResize, HasValue<Do
* @param minValue
* the current value
*/
public void setMinValue(Double minValue) {
public void setMinValue(Double minValue, boolean fireEvent) {
this.minValue = minValue;
drawTickLabels();
resetCurrentValue();
resetCurrentValue(fireEvent);
}
/**
@@ -767,9 +767,9 @@ public class SliderBar extends FocusPanel implements RequiresResize, HasValue<Do
* @param stepSize
* the current value
*/
public void setStepSize(double stepSize) {
public void setStepSize(double stepSize, boolean fireEvent) {
this.stepSize = stepSize;
resetCurrentValue();
resetCurrentValue(fireEvent);
}
public void setValue(Double value) {
@@ -1088,8 +1088,8 @@ public class SliderBar extends FocusPanel implements RequiresResize, HasValue<Do
/**
* Reset the progress to constrain the progress to the current range and redraw the knob as needed.
*/
private synchronized void resetCurrentValue() {
setCurrentValue(getCurrentValue());
private synchronized void resetCurrentValue(boolean fireEvent) {
setCurrentValue(getCurrentValue(), fireEvent);
}
/**