src/java/com/mammen/main/MainUIModel.java
/**************************************************************************
     *  updateVarUnits
     *      Converts the waypoints list from one Unit to another.
     *
     * @param old_unit The current Unit.
     * @param new_unit The Unit to convert to.
     **************************************************************************/
updateVarUnits
Converts the waypoints list from one Unit to another.

@param old_unit The current Unit.
@param new_unit The Unit to convert to.
updateVarUnits Converts the waypoints list from one Unit to another . @param old_unit The current Unit . @param new_unit The Unit to convert to .
private void updateVarUnits( Units old_unit, Units new_unit )
    {
        List<Waypoint> tmpList = new ArrayList<>();
        for( Waypoint wp : waypointList )
        {
            double tmp_x = 0, tmp_y = 0;
            switch( old_unit )
            {
                case FEET:
                    tmp_x = wp.getX();
                    tmp_y = wp.getY();
                    break;
                case INCHES:
                    tmp_x = Mathf.inchesToFeet( wp.getX() );
                    tmp_y = Mathf.inchesToFeet( wp.getY() );
                    break;
                case METERS:
                    tmp_x = Mathf.meterToFeet( wp.getX() );
                    tmp_y = Mathf.meterToFeet( wp.getY() );
                    break;
            }
            switch( new_unit )
            {
                case FEET:
                    tmpList.add( new Waypoint( tmp_x, tmp_y, wp.getAngle() ) );
                    break;
                case INCHES:
                    tmpList.add( new Waypoint( Mathf.feetToInches( tmp_x ),
                                               Mathf.feetToInches( tmp_y ),
                                               wp.getAngle() ) );
                    break;
                case METERS:
                    tmpList.add( new Waypoint( Mathf.feetToMeter( tmp_x ),
                                               Mathf.feetToMeter( tmp_y ),
                                               wp.getAngle() ) );
                    break;
            }
        }
        waypointList.clear();
        waypointList.addAll( tmpList );
    }
private void updateVarUnits ( Units old_unit , Units new_unit ) { List < Waypoint > tmpList = new ArrayList < > ( ) ; for ( Waypoint wp : waypointList ) { double tmp_x = 0 , tmp_y = 0 ; switch ( old_unit ) { case FEET : tmp_x = wp . getX ( ) ; tmp_y = wp . getY ( ) ; break ; case INCHES : tmp_x = Mathf . inchesToFeet ( wp . getX ( ) ) ; tmp_y = Mathf . inchesToFeet ( wp . getY ( ) ) ; break ; case METERS : tmp_x = Mathf . meterToFeet ( wp . getX ( ) ) ; tmp_y = Mathf . meterToFeet ( wp . getY ( ) ) ; break ; } switch ( new_unit ) { case FEET : tmpList . add ( new Waypoint ( tmp_x , tmp_y , wp . getAngle ( ) ) ) ; break ; case INCHES : tmpList . add ( new Waypoint ( Mathf . feetToInches ( tmp_x ) , Mathf . feetToInches ( tmp_y ) , wp . getAngle ( ) ) ) ; break ; case METERS : tmpList . add ( new Waypoint ( Mathf . feetToMeter ( tmp_x ) , Mathf . feetToMeter ( tmp_y ) , wp . getAngle ( ) ) ) ; break ; } } waypointList . clear ( ) ; waypointList . addAll ( tmpList ) ; }
updateVarUnits
      Converts the waypoints list from one Unit to another.
updateVarUnits Converts the waypoints list from one Unit to another .
// TODO: Find a better way of doing this!!! //          Maybe storing the values in the backend in feet //          and only convert it for display. // Convert each point in the waypoints list // convert to intermediate unit of feet // convert from intermediate unit of feet