Merge remote-tracking branch 'server/master'

This commit is contained in:
Axel Uhl committed 2012-06-15 17:29:23 +02:00
commit 3c30ed9433
7 files changed
+47 -25

No files matched your search

@@ -127,12 +127,11 @@ public class TimePanel<T extends TimePanelSettings> extends FormPanel implements
timeSlider = new TimeSlider();
timeSlider.setEnabled(true);
timeSlider.setLabelFormatter(new SliderBar.LabelFormatter() {
final DateTimeFormat formatter = DateTimeFormat.getFormat("HH:mm");
final DateTimeFormat timeWithMinutesFormatter = DateTimeFormat.getFormat("HH:mm");
@Override
public String formatLabel(SliderBar slider, double value) {
Date date = new Date();
date.setTime((long) value);
return formatter.format(date);
public String formatLabel(SliderBar slider, Double value, Double previousValue) {
Date date = new Date(value.longValue());
return timeWithMinutesFormatter.format(date);
}
});
@@ -826,16 +826,27 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
windTrackInfoDTO.dampeningIntervalInMilliseconds = windTrack
.getMillisecondsOverWhichToAverageWind();
TimePoint timePoint = fromTimePoint;
Double minWindConfidence = 2.0;
Double maxWindConfidence = -1.0;
for (int i = 0; i < numberOfFixes; i++) {
WindWithConfidence<Pair<Position, TimePoint>> averagedWindWithConfidence = windTrack.getAveragedWindWithConfidence(position, timePoint);
if (averagedWindWithConfidence != null) {
WindDTO windDTO = createWindDTOFromAlreadyAveraged(averagedWindWithConfidence.getObject(), windTrack, timePoint);
windDTO.confidence = averagedWindWithConfidence.getConfidence();
double confidence = averagedWindWithConfidence.getConfidence();
windDTO.confidence = confidence;
windTrackInfoDTO.windFixes.add(windDTO);
if(confidence < minWindConfidence) {
minWindConfidence = confidence;
}
if(confidence > maxWindConfidence) {
maxWindConfidence = confidence;
}
}
timePoint = new MillisecondsTimePoint(timePoint.asMillis() + millisecondsStepWidth);
}
windTrackInfoDTO.minWindConfidence = minWindConfidence;
windTrackInfoDTO.maxWindConfidence = maxWindConfidence;
}
}
}
@@ -875,27 +886,38 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
// TODO consider parallelizing
if (windSourceTypeNames == null || windSourceTypeNames.contains(windSource.getType().name())) {
WindTrackInfoDTO windTrackInfoDTO = new WindTrackInfoDTO();
windTrackInfoDTOs.put(windSource, windTrackInfoDTO);
windTrackInfoDTO.windFixes = new ArrayList<WindDTO>();
WindTrack windTrack = trackedRace.getOrCreateWindTrack(windSource);
windTrackInfoDTOs.put(windSource, windTrackInfoDTO);
windTrackInfoDTO.dampeningIntervalInMilliseconds = windTrack
.getMillisecondsOverWhichToAverageWind();
TimePoint timePoint = from;
Double minWindConfidence = 2.0;
Double maxWindConfidence = -1.0;
for (int i = 0; i < numberOfFixes && newestEvent != null && timePoint.compareTo(newestEvent) < 0; i++) {
WindWithConfidence<Pair<Position, TimePoint>> averagedWindWithConfidence = windTrack.getAveragedWindWithConfidence(null, timePoint);
if (averagedWindWithConfidence != null) {
double confidence = averagedWindWithConfidence.getConfidence();
WindDTO windDTO = createWindDTOFromAlreadyAveraged(averagedWindWithConfidence.getObject(), windTrack, timePoint);
windDTO.confidence = averagedWindWithConfidence.getConfidence();
windDTO.confidence = confidence;
windTrackInfoDTO.windFixes.add(windDTO);
if(confidence < minWindConfidence) {
minWindConfidence = confidence;
}
if(confidence > maxWindConfidence) {
maxWindConfidence = confidence;
}
}
timePoint = new MillisecondsTimePoint(timePoint.asMillis() + millisecondsStepWidth);
}
windTrackInfoDTO.minWindConfidence = minWindConfidence;
windTrackInfoDTO.maxWindConfidence = maxWindConfidence;
}
}
}
return result;
}
@Override
public WindInfoForRaceDTO getAveragedWindInfo(RaceIdentifier raceIdentifier, Date from, Date to,
long resolutionInMilliseconds, Collection<String> windSourceTypeNames) {
@@ -7,6 +7,8 @@ import com.google.gwt.user.client.rpc.IsSerializable;
public class WindTrackInfoDTO implements IsSerializable {
public List<WindDTO> windFixes;
public long dampeningIntervalInMilliseconds;
public double minWindConfidence;
public double maxWindConfidence;
public WindTrackInfoDTO() {}
}
@@ -89,7 +89,7 @@ public class SliderBar extends FocusPanel implements RequiresResize, HasValue<Do
* the value the label displays
* @return the text to display for the label
*/
String formatLabel(SliderBar slider, double value);
String formatLabel(SliderBar slider, Double value, Double previousValue);
}
/**
@@ -810,9 +810,9 @@ public class SliderBar extends FocusPanel implements RequiresResize, HasValue<Do
* the value at the label
* @return the text to put in the label
*/
protected String formatTickLabel(double value) {
protected String formatTickLabel(Double value, Double previousValue) {
if (tickLabelFormatter != null) {
return tickLabelFormatter.formatLabel(this, value);
return tickLabelFormatter.formatLabel(this, value, previousValue);
} else {
return (int) (10 * value) / 10.0 + "";
}
@@ -871,6 +871,7 @@ public class SliderBar extends FocusPanel implements RequiresResize, HasValue<Do
int lineWidth = lineElement.getOffsetWidth();
if (numTickLabels > 0) {
// Create the labels or make them visible
Double previousValue = null;
for (int i = 0; i <= numTickLabels; i++) {
Element label = null;
if (i < tickLabelElements.size()) {
@@ -892,7 +893,7 @@ public class SliderBar extends FocusPanel implements RequiresResize, HasValue<Do
double value = minValue + (getTotalRange() * i / numTickLabels);
DOM.setStyleAttribute(label, "visibility", "hidden");
DOM.setStyleAttribute(label, "display", "");
DOM.setElementProperty(label, "innerHTML", formatTickLabel(value));
DOM.setElementProperty(label, "innerHTML", formatTickLabel(value, previousValue));
// Move to the left so the label width is not clipped by the
// shell
@@ -905,6 +906,8 @@ public class SliderBar extends FocusPanel implements RequiresResize, HasValue<Do
labelLeftOffset = Math.max(labelLeftOffset, lineLeftOffset);
DOM.setStyleAttribute(label, "left", labelLeftOffset + "px");
DOM.setStyleAttribute(label, "visibility", "visible");
previousValue = value;
}
// Hide unused labels
@@ -91,6 +91,7 @@ public class TimeSlider extends SliderBar {
// Draw the tick labels
int lineWidth = lineElement.getOffsetWidth();
// Create the labels or make them visible
Double previousValue = null;
for (int i = 0; i < calculatedTimeTicks.size(); i++) {
TickPosition tickPosition = calculatedTimeTicks.get(i);
Element label = null;
@@ -113,7 +114,7 @@ public class TimeSlider extends SliderBar {
double value = tickPosition.getPosition().getTime();
DOM.setStyleAttribute(label, "visibility", "hidden");
DOM.setStyleAttribute(label, "display", "");
DOM.setElementProperty(label, "innerHTML", formatTickLabel(value));
DOM.setElementProperty(label, "innerHTML", formatTickLabel(value, previousValue));
// Move to the left so the label width is not clipped by the
// shell
@@ -127,6 +128,8 @@ public class TimeSlider extends SliderBar {
labelLeftOffset = Math.max(labelLeftOffset, lineLeftOffset);
DOM.setStyleAttribute(label, "left", labelLeftOffset + "px");
DOM.setStyleAttribute(label, "visibility", "visible");
previousValue = value;
}
// Hide unused labels
@@ -69,11 +69,6 @@ public class TimeTicksCalculator {
// round to a tenfold of 1, 2, 2.5 or 5
normalized = interval / magnitude;
// multiples for a linear scale
if (magnitude == 1) {
multiples = new int[] { 1, 2, 5, 10 };
}
// normalize the interval to the nearest multiple
for (int i = 0; i < multiples.length; i++) {
interval = multiples[i];
@@ -197,11 +192,6 @@ public class TimeTicksCalculator {
if(time <= max)
tickPositions.add(new TickPosition(time));
// record information on the chosen unit - for dynamic label formatter
// tickPositions.info = extend(normalizedInterval, {
// totalRange: interval * count
// });
return tickPositions;
}
@@ -417,7 +417,10 @@ public class RaceMap extends AbsolutePanel implements TimeListener, CompetitorSe
WindTrackInfoDTO windTrackInfoDTO = windInfo.windTrackInfoByWindSource.get(windSource);
switch (windSource.getType()) {
case EXPEDITION:
windSourcesToShow.add(new Pair<WindSource, WindTrackInfoDTO>(windSource, windTrackInfoDTO));
// we filter out measured wind sources with a very little confidence
if(windTrackInfoDTO.minWindConfidence > 0.01) {
windSourcesToShow.add(new Pair<WindSource, WindTrackInfoDTO>(windSource, windTrackInfoDTO));
}
break;
case COMBINED:
showCombinedWindOnMap(windSource, windTrackInfoDTO);