Renamed sharedModel module to racevisionGame - this is intended to be our single module program.
Moved Boat/MockBoat/VisualiserBoat into it. Moved Polars, polarParser, VMG, and polar exception. Moved the networking stuff into it. Moved angle, azimuth, bearing into it. Moved gpscoordinate into it. Moved mark/compoundMark into it. Moved leg into it. Moved trackpoint into it.
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package visualiser.model;
|
||||
|
||||
|
||||
import shared.model.GPSCoordinate;
|
||||
|
||||
/**
|
||||
* A TrackPoint is a point plotted to display the track a
|
||||
* {@link VisualiserBoat Boat} has travelled in a race. <br>
|
||||
* TrackPoints are displayed on a
|
||||
* {@link seng302.Model.ResizableRaceCanvas ResizableRaceCanvas}, via the
|
||||
* {@link seng302.Controllers.RaceController RaceController}. <br>
|
||||
* Track points can be made visible or hidden via the RaceController's
|
||||
* {@link seng302.Model.Annotations Annotations}.
|
||||
*/
|
||||
public class TrackPoint {
|
||||
private final GPSCoordinate coordinate;
|
||||
private final long timeAdded;
|
||||
private final long expiry;
|
||||
private final double minAlpha;
|
||||
|
||||
/**
|
||||
* Creates a new track point with fixed GPS coordinates and time, to reach minimum opacity on expiry.
|
||||
*
|
||||
* @param coordinate position of point on physical race map
|
||||
* @param timeAdded system clock at time of addition
|
||||
* @param expiry time to minimum opacity after added
|
||||
*/
|
||||
public TrackPoint(GPSCoordinate coordinate, long timeAdded, long expiry) {
|
||||
this.coordinate = coordinate;
|
||||
this.timeAdded = timeAdded;
|
||||
this.expiry = expiry;
|
||||
this.minAlpha = 0.1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the position of the point on physical race map.
|
||||
*
|
||||
* @return GPS coordinate of point
|
||||
*/
|
||||
public GPSCoordinate getCoordinate() {
|
||||
return coordinate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets opacity of point scaled by age in proportion to expiry, between 1 and minimum opacity inclusive.
|
||||
*
|
||||
* @return greater of minimum opacity and scaled opacity
|
||||
*/
|
||||
public double getAlpha() {
|
||||
return Double.max(minAlpha, 1.0 - (double) (System.currentTimeMillis() - timeAdded) / expiry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets time point was added to track.
|
||||
*
|
||||
* @return system clock at time of addition
|
||||
*/
|
||||
public long getTimeAdded() {
|
||||
return timeAdded;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user