File : core/mapIcon/ArrowAndTooltipFinder.js

1
/*
2
Copyright - 2017 2023 - wwwouaiebe - Contact: https://www.ouaie.be/
3
4
This  program is free software;
5
you can redistribute it and/or modify it under the terms of the
6
GNU General Public License as published by the Free Software Foundation;
7
either version 3 of the License, or any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
*/
18
/*
19
Changes:
20
    - v4.0.0:
21
        - created from v3.6.0
22
Doc reviewed 202208
23
 */
24
25
import theConfig from '../../data/Config.js';
26
import theTranslator from '../../core/uiLib/Translator.js';
27
28
import { ICON_POSITION } from '../../main/Constants.js';
29
30
/* ------------------------------------------------------------------------------------------------------------------------- */
31
/**
32
Search:
33
- the arrow to use for the direction to follow ( the arrow will be displayed in the address )
34
- the tooltip content
35
*/
36
/* ------------------------------------------------------------------------------------------------------------------------- */
37
38
class ArrowAndTooltipFinder {
39
40
    /**
41
    The constructor
42
    */
43
44
    constructor ( ) {
45
        Object.freeze ( this );
46
    }
47
48
    /**
49
    This method set the direction arrow and tooltip
50
    @param {ComputeDataForMapIcon} computeData The object with the data needed for the computations
51
    @param {NoteDataForMapIcon} noteData The object with the nota data
52
    */
53
54
    findData ( computeData, noteData ) {
55
56
        if ( null !== computeData.direction ) {
57
            if ( computeData.direction < theConfig.note.svgIcon.angleDirection.right ) {
58
                noteData.tooltipContent = theTranslator.getText ( 'ArrowAndTooltipFinder - Turn right' );
59
                computeData.directionArrow = '🢂';
60
            }
61
            else if ( computeData.direction < theConfig.note.svgIcon.angleDirection.slightRight ) {
62
                noteData.tooltipContent = theTranslator.getText ( 'ArrowAndTooltipFinder - Turn slight right' );
63
                computeData.directionArrow = '🢅';
64
            }
65
            else if ( computeData.direction < theConfig.note.svgIcon.angleDirection.continue ) {
66
                noteData.tooltipContent = theTranslator.getText ( 'ArrowAndTooltipFinder - Continue' );
67
                computeData.directionArrow = '🢁';
68
            }
69
            else if ( computeData.direction < theConfig.note.svgIcon.angleDirection.slightLeft ) {
70
                noteData.tooltipContent = theTranslator.getText ( 'ArrowAndTooltipFinder - Turn slight left' );
71
                computeData.directionArrow = '🢄';
72
            }
73
            else if ( computeData.direction < theConfig.note.svgIcon.angleDirection.left ) {
74
                noteData.tooltipContent = theTranslator.getText ( 'ArrowAndTooltipFinder - Turn left' );
75
                computeData.directionArrow = '🢀';
76
            }
77
            else if ( computeData.direction < theConfig.note.svgIcon.angleDirection.sharpLeft ) {
78
                noteData.tooltipContent = theTranslator.getText ( 'ArrowAndTooltipFinder - Turn sharp left' );
79
                computeData.directionArrow = '🢇';
80
            }
81
            else if ( computeData.direction < theConfig.note.svgIcon.angleDirection.sharpRight ) {
82
                noteData.tooltipContent = theTranslator.getText ( 'ArrowAndTooltipFinder - Turn sharp right' );
83
                computeData.directionArrow = '🢆';
84
            }
85
            else {
86
                noteData.tooltipContent = theTranslator.getText ( 'ArrowAndTooltipFinder - Turn right' );
87
                computeData.directionArrow = '🢂';
88
            }
89
        }
90
91
        if ( ICON_POSITION.atStart === computeData.positionOnRoute ) {
92
            noteData.tooltipContent = theTranslator.getText ( 'ArrowAndTooltipFinder - Start' );
93
        }
94
        else if ( ICON_POSITION.atEnd === computeData.positionOnRoute ) {
95
            noteData.tooltipContent = theTranslator.getText ( 'ArrowAndTooltipFinder - Stop' );
96
        }
97
    }
98
}
99
100
export default ArrowAndTooltipFinder;
101
102
/* --- End of file --------------------------------------------------------------------------------------------------------- */
103