added subclass MarkpassingManeuverImpl

This commit is contained in:
Axel Uhl committed 2012-12-06 16:07:57 +01:00
1 parent 60dc705652
commit aaa76026d1
3 files changed
+67 -3

No files matched your search

@@ -0,0 +1,10 @@
package com.sap.sailing.domain.tracking;
import com.sap.sailing.domain.base.Waypoint;
import com.sap.sailing.domain.common.Tack;
public interface MarkPassingManeuver extends Maneuver {
Waypoint getWaypointPassed();
Tack getSide();
}
@@ -0,0 +1,43 @@
package com.sap.sailing.domain.tracking.impl;
import com.sap.sailing.domain.base.SpeedWithBearing;
import com.sap.sailing.domain.base.Waypoint;
import com.sap.sailing.domain.common.Distance;
import com.sap.sailing.domain.common.ManeuverType;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.Tack;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.tracking.MarkPassingManeuver;
public class MarkpassingManeuverImpl extends ManeuverImpl implements MarkPassingManeuver {
private static final long serialVersionUID = 8935348908557191614L;
private final Waypoint waypointPassed;
private final Tack side;
public MarkpassingManeuverImpl(ManeuverType type, Tack newTack, Position position, TimePoint timePoint,
SpeedWithBearing speedWithBearingBefore, SpeedWithBearing speedWithBearingAfter,
double directionChangeInDegrees, Distance maneuverLoss, Waypoint waypointPassed, Tack side) {
super(type, newTack, position, timePoint, speedWithBearingBefore, speedWithBearingAfter,
directionChangeInDegrees, maneuverLoss);
this.waypointPassed = waypointPassed;
this.side = side;
}
@Override
public Waypoint getWaypointPassed() {
return waypointPassed;
}
@Override
public Tack getSide() {
return side;
}
@Override
public String toString() {
StringBuilder result = new StringBuilder(super.toString());
result.append(", passed waypoint "+getWaypointPassed()+" to "+getSide().name());
return result.toString();
}
}
@@ -1913,12 +1913,16 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
// the TrackedLegOfCompetitor variables may be null, e.g., in case the time points are before or after the race
TrackedLegOfCompetitor legBeforeManeuver = getTrackedLeg(competitor, timePointBeforeManeuver);
TrackedLegOfCompetitor legAfterManeuver = getTrackedLeg(competitor, timePointAfterManeuver);
Waypoint waypointPassed = null; // set for MARK_PASSING maneuvers only
Tack sideToWhichWaypointWasPassed = null; // set for MARK_PASSING maneuvers only
// check for mask passing first; a tacking / jibe-setting mark rounding thus takes precedence over being detected as a penalty circle
if (legBeforeManeuver != legAfterManeuver
// a maneuver at the start line is not to be considered a MARK_PASSING maneuver; show a tack as a tack
&& legAfterManeuver != null
&& legAfterManeuver.getLeg().getFrom() != getRace().getCourse().getFirstWaypoint()) {
maneuverType = ManeuverType.MARK_PASSING;
waypointPassed = legAfterManeuver.getLeg().getFrom();
sideToWhichWaypointWasPassed = totalCourseChangeInDegrees < 0 ? Tack.PORT : Tack.STARBOARD;
} else if (Math.abs(totalCourseChangeInDegrees) > PENALTY_CIRCLE_DEGREES_THRESHOLD) {
maneuverType = ManeuverType.PENALTY_CIRCLE;
if (legBeforeManeuver != null) {
@@ -1971,9 +1975,16 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
: ManeuverType.BEAR_AWAY;
}
}
Maneuver maneuver = new ManeuverImpl(maneuverType, tackAfterManeuver, maneuverPosition, maneuverTimePoint,
speedWithBearingOnApproximationAtBeginning, speedWithBearingOnApproximationAtEnd,
totalCourseChangeInDegrees, maneuverLoss);
final Maneuver maneuver;
if (maneuverType == ManeuverType.MARK_PASSING) {
maneuver = new MarkpassingManeuverImpl(maneuverType, tackAfterManeuver, maneuverPosition, maneuverTimePoint,
speedWithBearingOnApproximationAtBeginning, speedWithBearingOnApproximationAtEnd,
totalCourseChangeInDegrees, maneuverLoss, waypointPassed, sideToWhichWaypointWasPassed);
} else {
maneuver = new ManeuverImpl(maneuverType, tackAfterManeuver, maneuverPosition, maneuverTimePoint,
speedWithBearingOnApproximationAtBeginning, speedWithBearingOnApproximationAtEnd,
totalCourseChangeInDegrees, maneuverLoss);
}
return maneuver;
}