src/main/java/org/a05annex/util/geo2d/KochanekBartelsSpline.java
public boolean loadPath(String filename) {
        // The deal here is that we want to make sure we can read this file as a path before we
        // the existing path description.
        clearPath();
        try {
            // Load the path from the file.
            JSONObject path = readJsonFileAsJSONObject(filename);
            m_title = parseString(path, TITLE, DEFAULT_TITLE);
            m_description = parseString(path, DESCRIPTION, DEFAULT_DESCRIPTION);
            m_speedMultiplier = parseDouble(path, SPEED_MULTIPLIER, m_speedMultiplier);
            JSONArray controlPoints = getJSONArray(path, CONTROL_POINTS);
            for (Object cpObj : controlPoints) {
                JSONObject cpJson = (JSONObject) cpObj;
                ControlPoint newControlPoint = new ControlPoint(cpJson);
                if (null == m_first) {
                    m_first = newControlPoint;
                }
                if (null != m_last) {
                    m_last.m_next = newControlPoint;
                    newControlPoint.m_last = m_last;
                }
                m_last = newControlPoint;
            }
            // now that the points are reloaded, recompute the derivatives for any points that
            // have not been manually edited
            for (ControlPoint point : getControlPoints()) {
                point.updateLocationDerivatives();
                point.updateHeadingDerivative();
            }
            // and, the derivatives for the first point is dependent on the derivatives for
            // the later points in the spline, so recompute that now that we have the later points.
            if (null != m_first) {
                m_first.updateLocationDerivatives();
            }
            return true;

        } catch (IOException | ParseException | ClassCastException | NullPointerException e) {
            e.printStackTrace();
        }
        return false;
    }
/**
     * Load a path from a {@code .json} path file.
     *
     * @param filename (String, not null) The name of the file the path will be read from.
     * @return {@code true} if the path was successfully loaded, {@code false} otherwise. If the path was not
     * successfully loaded, the path will be empty.
     */
Load a path from a  .json path file.
@param filename (String, not null) The name of the file the path will be read from.
@return  true if the path was successfully loaded,  false otherwise. If the path was not
successfully loaded, the path will be empty.
Load a path from a . json path file . @param filename ( String not null ) The name of the file the path will be read from . @return true if the path was successfully loaded false otherwise . If the path was not successfully loaded the path will be empty .
public boolean loadPath(String filename) {
        clearPath();
        try {
            JSONObject path = readJsonFileAsJSONObject(filename);
            m_title = parseString(path, TITLE, DEFAULT_TITLE);
            m_description = parseString(path, DESCRIPTION, DEFAULT_DESCRIPTION);
            m_speedMultiplier = parseDouble(path, SPEED_MULTIPLIER, m_speedMultiplier);
            JSONArray controlPoints = getJSONArray(path, CONTROL_POINTS);
            for (Object cpObj : controlPoints) {
                JSONObject cpJson = (JSONObject) cpObj;
                ControlPoint newControlPoint = new ControlPoint(cpJson);
                if (null == m_first) {
                    m_first = newControlPoint;
                }
                if (null != m_last) {
                    m_last.m_next = newControlPoint;
                    newControlPoint.m_last = m_last;
                }
                m_last = newControlPoint;
            }
            for (ControlPoint point : getControlPoints()) {
                point.updateLocationDerivatives();
                point.updateHeadingDerivative();
            }
            if (null != m_first) {
                m_first.updateLocationDerivatives();
            }
            return true;
        } catch (IOException | ParseException | ClassCastException | NullPointerException e) {
            e.printStackTrace();
        }
        return false;
    }
public boolean loadPath ( String filename ) { clearPath ( ) ; try { JSONObject path = readJsonFileAsJSONObject ( filename ) ; m_title = parseString ( path , TITLE , DEFAULT_TITLE ) ; m_description = parseString ( path , DESCRIPTION , DEFAULT_DESCRIPTION ) ; m_speedMultiplier = parseDouble ( path , SPEED_MULTIPLIER , m_speedMultiplier ) ; JSONArray controlPoints = getJSONArray ( path , CONTROL_POINTS ) ; for ( Object cpObj : controlPoints ) { JSONObject cpJson = ( JSONObject ) cpObj ; ControlPoint newControlPoint = new ControlPoint ( cpJson ) ; if ( null == m_first ) { m_first = newControlPoint ; } if ( null != m_last ) { m_last . m_next = newControlPoint ; newControlPoint . m_last = m_last ; } m_last = newControlPoint ; } for ( ControlPoint point : getControlPoints ( ) ) { point . updateLocationDerivatives ( ) ; point . updateHeadingDerivative ( ) ; } if ( null != m_first ) { m_first . updateLocationDerivatives ( ) ; } return true ; } catch ( IOException | ParseException | ClassCastException | NullPointerException e ) { e . printStackTrace ( ) ; } return false ; }
Load a path from a {@code .json} path file.
Load a path from a { @code . json } path file .
// The deal here is that we want to make sure we can read this file as a path before we // the existing path description. // Load the path from the file. // now that the points are reloaded, recompute the derivatives for any points that // have not been manually edited // and, the derivatives for the first point is dependent on the derivatives for // the later points in the spline, so recompute that now that we have the later points.