Class LinePathConverter
- java.lang.Object
-
- ch.sahits.game.openpatrician.display.service.LinePathConverter
-
- All Implemented Interfaces:
IPathConverter
public class LinePathConverter extends java.lang.Object implements IPathConverter
Converts a list of point into a shape that can be used as path. This algorithm uses straight lines.- Author:
- Andi Hotz, (c) Sahits GmbH, 2016 Created on Jan 05, 2016
-
-
Field Summary
Fields Modifier and Type Field Description private TravellingVessels
vessels
-
Constructor Summary
Constructors Constructor Description LinePathConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
calculateDuration(INavigableVessel vessel, PathInterpolator interpolator, double fraction)
No real implementation here.java.util.Optional<javafx.scene.shape.Path>
createPath(INavigableVessel vessel, java.util.List<javafx.geometry.Point2D> pointedPath, double scale)
Create a path shape out of a list of points.java.util.List<javafx.geometry.Point2D>
reduceLinePoints(java.util.List<javafx.geometry.Point2D> initialPoints)
Reduce the number of points that are needed to describe the path.
-
-
-
Field Detail
-
vessels
@Autowired private TravellingVessels vessels
-
-
Method Detail
-
createPath
public java.util.Optional<javafx.scene.shape.Path> createPath(INavigableVessel vessel, java.util.List<javafx.geometry.Point2D> pointedPath, double scale)
Create a path shape out of a list of points. When the path is created the vessel will be added to the TravellingVessels container.- Specified by:
createPath
in interfaceIPathConverter
- Parameters:
vessel
- vessel that is traveling the path.pointedPath
- input points.scale
- scaling that is used on the path due to the sacle of the map.- Returns:
- shape representing a path.
-
reduceLinePoints
public java.util.List<javafx.geometry.Point2D> reduceLinePoints(java.util.List<javafx.geometry.Point2D> initialPoints)
Reduce the number of points that are needed to describe the path. No actual reduction of points happens.- Specified by:
reduceLinePoints
in interfaceIPathConverter
- Parameters:
initialPoints
- list of initial points- Returns:
- List of points
-
calculateDuration
public long calculateDuration(INavigableVessel vessel, PathInterpolator interpolator, double fraction)
No real implementation here.- Specified by:
calculateDuration
in interfaceIPathConverter
- Parameters:
vessel
- that is travelinginterpolator
- used to hold the path informationfraction
- value between [0,1]. 1 means that the whole distance is traveled.- Returns:
- calculated travel duration.
-
-