Class BezierPathConverter

  • All Implemented Interfaces:
    ch.sahits.game.openpatrician.clientserverinterface.service.IPathConverter

    public class BezierPathConverter
    extends java.lang.Object
    implements ch.sahits.game.openpatrician.clientserverinterface.service.IPathConverter
    Create a Bezier path based on a set of points. The implementation is based on work described in http://devmag.org.za/2011/06/23/bzier-path-algorithms/
    Author:
    Andi Hotz, (c) Sahits GmbH, 2016 Created on Jan 05, 2016
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long calculateDuration​(ch.sahits.game.openpatrician.model.ship.INavigableVessel vessel, ch.sahits.game.openpatrician.clientserverinterface.service.PathInterpolator interpolator, double fraction)  
      java.util.Optional<javafx.scene.shape.Path> createPath​(ch.sahits.game.openpatrician.model.ship.INavigableVessel vessel, java.util.List<javafx.geometry.Point2D> pointedPath, double scale)  
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BezierPathConverter

        public BezierPathConverter()
    • Method Detail

      • createPath

        public java.util.Optional<javafx.scene.shape.Path> createPath​(ch.sahits.game.openpatrician.model.ship.INavigableVessel vessel,
                                                                      java.util.List<javafx.geometry.Point2D> pointedPath,
                                                                      double scale)
        Specified by:
        createPath in interface ch.sahits.game.openpatrician.clientserverinterface.service.IPathConverter
      • calculateDuration

        public long calculateDuration​(ch.sahits.game.openpatrician.model.ship.INavigableVessel vessel,
                                      ch.sahits.game.openpatrician.clientserverinterface.service.PathInterpolator interpolator,
                                      double fraction)
        Specified by:
        calculateDuration in interface ch.sahits.game.openpatrician.clientserverinterface.service.IPathConverter
      • 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. Points that do not change the direction of the path can be eliminated if:
        • The distance to the last point left is larger than the distance to the shore
        Specified by:
        reduceLinePoints in interface ch.sahits.game.openpatrician.clientserverinterface.service.IPathConverter
        Parameters:
        initialPoints - initial point of the line
        Returns:
        list of points making up the path