Vous êtes sur la page 1sur 34

SoItware DeIects Prevention Techniques Example Project

MapsMIDlet.jaa
lxxxi
All classes and interfaces must belong to a named package 17 PMD Marker
Avoid really long classes. 17 PMD Marker
Efferent Couplings is 36 17 Metrics Marker
Lack of Cohesion in Methods (Henderson-Sellers) is 90% 17 Metrics Marker
Lack of Cohesion in Methods (Total Correlation) is 7,735% 17 Metrics Marker
Number of Fields is 121 17 Metrics Marker
The class 'MapsMDlet' has a Cyclomatic Complexity of 22 (Highest = 202). 17 PMD Marker
To be compliant to J2EE, a webapp should not use any thread. 17 PMD Marker
Too many fields 17 PMD Marker
Weighted Methods per Class is 150 17 Metrics Marker
Found non-transient, non-static member. Please mark as transient or provide accessors. 20 PMD Marker
Use explicit scoping instead of the default package private level 20 PMD Marker
Avoid variables with short names like mb 24 PMD Marker
Found non-transient, non-static member. Please mark as transient or provide accessors. 24 PMD Marker
Use explicit scoping instead of the default package private level 24 PMD Marker
Found non-transient, non-static member. Please mark as transient or provide accessors. 25 PMD Marker
Use explicit scoping instead of the default package private level 25 PMD Marker
Found non-transient, non-static member. Please mark as transient or provide accessors. 26 PMD Marker
Use explicit scoping instead of the default package private level 26 PMD Marker
Found non-transient, non-static member. Please mark as transient or provide accessors. 27 PMD Marker
Use explicit scoping instead of the default package private level 27 PMD Marker
Avoid variables with short names like ic 30 PMD Marker
Avoid variables with short names like cc 31 PMD Marker
The field name indicates a constant but its modifiers do not 75 PMD Marker
The field name indicates a constant but its modifiers do not 76 PMD Marker
The field name indicates a constant but its modifiers do not 77 PMD Marker
Avoid variables with short names like d 79 PMD Marker
Avoid variables with short names like t1 100 PMD Marker
To be compliant to J2EE, a webapp should not use any thread. 100 PMD Marker
To be compliant to J2EE, a webapp should not use any thread. 101 PMD Marker
Unused field: MapsMDlet.t2 101 FindBugs
Unread field: MapsMDlet.first 106 FindBugs
Unread field: MapsMDlet.gpsHash 112 FindBugs
Unread field: MapsMDlet.gpsThr 114 FindBugs
Unread field: MapsMDlet.frndThr 115 FindBugs
Zarko Acimovic
MapsMIDlet.jaa
lxxxii
Avoid using implementation types like 'Vector'; use the interface instead 129 PMD Marker
Avoid using implementation types like 'Vector'; use the interface instead 129 PMD Marker
Consider replacing this Vector with the newer java.util.List 129 PMD Marker
Avoid excessively long variable names like synchronizationDone 134 PMD Marker
Unread field: MapsMDlet.synchronizationDone 134 FindBugs
Unused field: MapsMDlet.setLine 142 FindBugs
Unused field: MapsMDlet.resetLine 143 FindBugs
The field name indicates a constant but its modifiers do not 158 PMD Marker
The field name indicates a constant but its modifiers do not 159 PMD Marker
Unused field: MapsMDlet.routeList 186 FindBugs
Unused field: MapsMDlet.allRoutes 188 FindBugs
Unused field: MapsMDlet.hideRoutes 189 FindBugs
Unused field: MapsMDlet.delRouteList 191 FindBugs
Unused field: MapsMDlet.delAllRoutes 192 FindBugs
Unused field: MapsMDlet.categories 197 FindBugs
Lines of Code in Method is 165 201 Metrics Marker
Number of Statements is 121 201 Metrics Marker
Avoid really long methods. 204 PMD Marker
The method startApp() has an NCSS count of 113 204 PMD Marker
The String literal "Categories" appears 8 times in this file; the first occurrence is on 332 332 PMD Marker
Use ArrayList instead of Vector 362 PMD Marker
Avoid really long methods. 368 PMD Marker
Cyclomatic Complexity is 121 368 Metrics Marker
Lines of Code in Method is 819 368 Metrics Marker
Number of Levels is 6 368 Metrics Marker
Number of Locals in Scope is 30 368 Metrics Marker
Number of Statements is 716 368 Metrics Marker
Parameter 'c' is not assigned and could be declared final 368 PMD Marker
Parameter 's' is not assigned and could be declared final 368 PMD Marker
The method 'commandAction' has a Cyclomatic Complexity of 202. 368 PMD Marker
The method commandAction() has an NCSS count of 539 368 PMD Marker
Avoid using if statements without curly braces 370 PMD Marker
Use equals() to compare object references. 370 PMD Marker
Use equals() to compare object references. 371 PMD Marker
Use equals() to compare object references. 371 PMD Marker
Use equals() to compare object references. 374 PMD Marker
Use equals() to compare object references. 374 PMD Marker
Avoid empty catch blocks 399 PMD Marker
MapsMDlet.commandAction(Command, Displayable) might ignore java.lang.Exception 399 FindBugs
Avoid unnecessary comparisons in boolean expressions 413 PMD Marker
SoItware DeIects Prevention Techniques Example Project
MapsMIDLet.jaa
lxxxiii
Avoid unnecessary comparisons in boolean expressions 422 PMD Marker
Avoid using if statements without curly braces 422 PMD Marker
Local variable 'wp' could be declared final 428 PMD Marker
Local variable 'wp' could be declared final 434 PMD Marker
Local variable 'name' could be declared final 450 PMD Marker
Local variable 'sel' could be declared final 451 PMD Marker
Local variable 'category' could be declared final 456 PMD Marker
The local variable category is never read 456 Java Problem
Do not add empty strings 468 PMD Marker
Do not add empty strings 468 PMD Marker
Avoid empty catch blocks 479 PMD Marker
MapsMDlet.commandAction(Command, Displayable) might ignore java.lang.Exception 479 FindBugs
The local variable category is never read 551 Java Problem
Do not add empty strings 563 PMD Marker
Do not add empty strings 563 PMD Marker
Avoid empty catch blocks 574 PMD Marker
MapsMDlet.commandAction(Command, Displayable) might ignore java.lang.Exception 574 FindBugs
Deeply nested if..then statements are hard to read 599 PMD Marker
Avoid using if statements without curly braces 643 PMD Marker
Avoid using if statements without curly braces 644 PMD Marker
Avoid unnecessary comparisons in boolean expressions 670 PMD Marker
Avoid unnecessary comparisons in boolean expressions 695 PMD Marker
Avoid instantiating new objects inside loops 700 PMD Marker
Avoid instantiating new objects inside loops 735 PMD Marker
Consider replacing this Vector with the newer java.util.List 766 PMD Marker
Avoid instantiating new objects inside loops 775 PMD Marker
Avoid instantiating new objects inside loops 786 PMD Marker
Avoid instantiating new objects inside loops 828 PMD Marker
Consider replacing this Vector with the newer java.util.List 881 PMD Marker
Consider replacing this Vector with the newer java.util.List 881 PMD Marker
1023 FindBugs
To be compliant to J2EE, a webapp should not use any thread. 1028 PMD Marker
Substitute calls to size() == 0 (or size() != 0) with calls to isEmpty() 1049 PMD Marker
Substitute calls to size() == 0 (or size() != 0) with calls to isEmpty() 1105 PMD Marker
Cyclomatic Complexity is 11 1190 Metrics Marker
Lines of Code in Method is 87 1190 Metrics Marker
Number of Levels is 7 1190 Metrics Marker
Number of Locals in Scope is 16 1190 Metrics Marker
Number of Statements is 73 1190 Metrics Marker
The method 'run' has a Cyclomatic Complexity of 17. 1190 PMD Marker
Write to static field MapsMDlet.resource from instance method
MapsMDlet.commandAction(Command, Displayable)
Zarko Acimovic
MapsMIDlet.jaa
1 /**
2 *
3 * NapsNI1e1 crea1es con1ro1 menus due 1o user`s ac1ons and hand1es CP5
ssues
4 *
5 */
6 mpor1 avax.m1cJoed111oh.cdu1.*,
7
8 mpor1 avax.m1cJoed111oh.m1de1.*,
9
10 mpor1 ava.u11.*,
11 mpor1 ava.1o.*,
12
13
14
15
16
17 pub1c c1ass hapshT0e1 ex1ends hT0e1 mp1emen1s CommahdL1s1eheJ,unnab1e
{
18
19
lxxxiv
Parameter 'flag' is not assigned and could be declared final 1287 PMD Marker
Lines of Code in Method is 16 1291 Metrics Marker
Parameter 's' is not assigned and could be declared final 1296 PMD Marker
Avoid unused local variables such as 'k'. 1297 PMD Marker
Dead store to k in MapsMDlet.compact(String) 1297 FindBugs
The local variable k is never read 1297 Java Problem
MapsMDlet.compact(String) concatenates strings using + in a loop 1302 FindBugs
Prefer StringBuffer over += for concatenating strings 1302 PMD Marker
Avoid unused local variables such as 'kk'. 1304 PMD Marker
Dead store to kk in MapsMDlet.compact(String) 1304 FindBugs
The local variable kk is never read 1304 Java Problem
Parameter 's' is not assigned and could be declared final 1308 PMD Marker
Avoid unused local variables such as 'k'. 1309 PMD Marker
Dead store to k in MapsMDlet.compactFine(String) 1309 FindBugs
The local variable k is never read 1309 Java Problem
MapsMDlet.compactFine(String) concatenates strings using + in a loop 1314 FindBugs
Prefer StringBuffer over += for concatenating strings 1314 PMD Marker
Avoid unused local variables such as 'kk'. 1316 PMD Marker
Dead store to kk in MapsMDlet.compactFine(String) 1316 FindBugs
The local variable kk is never read 1316 Java Problem
Cyclomatic Complexity is 6 1320 Metrics Marker
Lines of Code in Method is 31 1320 Metrics Marker
Number of Statements is 26 1320 Metrics Marker
Avoid empty catch blocks 1335 PMD Marker
SoItware DeIects Prevention Techniques Example Project
20 hapBackgJouhdFac1oJy mb1 = neW hapBackgJouhdFac1oJy{"/ha12.phg",
"/SJedh1.phg","/ve1k1.phg",
21 "44.83049905", "20.44570857", "44.79241639",
"20.48713523"),
22
23
24 hapBackgJouhd mb,
25 hap0bec1s mob,
26 Seec1oJPo1h1 seP,
27 0u1ook ou,
28
29 Pvec1oJ vwpF = neW Pvec1oJ{"1Jee",1a1se),
30 TmageCahvas3 1c,
31 CompassCahvas cc,
32
33 //PoIn1 |p3 = ne|
PoIn1]"44.8JJJ83","20.454J7J5","|1ub`4kadenI]a`","]","/Cu11uIa1_oI_TouIIs1/Even1
.png",1Iue);
34 Pon1 wp2 = neW Pon1{"44.82990854","20.45661377","25.
ma","","/SpoJ1/Sw1mm1hg.phg",1rue),
35 Pon1 wp1 = neW Pon1{"44.81573706","20.45998215","Sp. Khezu
h1ha1u","","/Cu1uJa_oJ_TouJ1s1/hohumeh1.phg",1rue),
36
37 Pon1 wp4 = neW Pon1{"44.8178034","20.45177167","SaboJha
cJkva","","/Cu1uJa_oJ_TouJ1s1/ChuJch.phg",1rue),
38 Pon1 wp5 = neW Pon1{"44.82577520","20.45459270","Zooosk1
vJ1","","/Cu1uJa_oJ_TouJ1s1/Zoo.phg",1rue),
39
40 Pon1 wp6 = neW Pon1{"44.81293225","20.46132951","CJ1he1
ka1e","","/SeJv1ce_oJ_b1111y/Ca1e.phg",1rue),
41 Pon1 wp7 = neW Pon1{"44.81426084","20.45943480","TJzh1 ceh1aJ
`SJemska`","","/SeJv1ce_oJ_b1111y/Shop.phg",1rue),
42 Pon1 wp8 = neW Pon1{"44.81248939","20.46006637","B1oskop
20.ok1obaJ","","/SeJv1ce_oJ_b1111y/C1hema.phg",1rue),
43 Pon1 wp9 = neW
Pon1{"44.81293225","20.46743470","Po1c1a","","/SeJv1ce_oJ_b1111y/Po1ce.phg",1
rue),
44 Pon1 wp10 = neW Pon1{"44.81854182","20.45711898","F1oosk1
1aku1e1","","/SeJv1ce_oJ_b1111y/Schoo.phg",1rue),
45 Pon1 wp11 = neW Pon1{"44.82518476","20.45737165","B1oskop
REX","","/SeJv1ce_oJ_b1111y/C1hema.phg",1rue),
46 Pon1 wp12 = neW Pon1{"44.80496078","20.47652941","Eek1Jo1ehh1ck1
1aku1e1","","/SeJv1ce_oJ_b1111y/Schoo.phg",1rue),
47 Pon1 wp13 = neW
Pon1{"44.80466556","20.47337150","RCbB","","/SeJv1ce_oJ_b1111y/Schoo.phg",1rue)
,
48 Pon1 wp14 = neW
Pon1{"44.80865126","20.46368736","Apo1eka","","/SeJv1ce_oJ_b1111y/PhaJmacy.phg",
1rue),
49 Pon1 wp15 = neW Pon1{"44.80067980","20.45737165","bJgeh1h1
ceh1aJ","","/SeJv1ce_oJ_b1111y/RedcJoss.phg",1rue),
lxxxv
Zarko Acimovic
50
51
52
53
54 /** Pon1 Wp3 = neW Pon1{45,2 , 1,`N`,22,26, 5,`E`,"c1","]")
55 Pon1 Wp4 = neW Pon1{45,13, 2,`N`,21,58, 5,`E`,"d1","]")
56 Pon1 Wp5 = neW Pon1{46,45, 1,`N`,21,26, 5,`E`,"e1","]")
57 Pon1 Wp6 = neW Pon1{46,48,23,`N`,21,23, 9,`E`,"11","]")
58 Pon1 Wp7 = neW Pon1{46,36,56,`N`,22,25,56,`E`,"g1","]")
59 Pon1 Wp8 = neW Pon1{46,48,59,`N`,26,27,17,`E`,"a","]")
66 Pon1 Wp9 = neW Pon1{46,45, 6,`N`,26,26,15,`E`,"b","]")
61 Pon1 Wp16 = neW Pon1{46,42, 6,`N`,26,29,15,`E`,"c","]")
62 Pon1 Wp11 = neW Pon1{46,39, 6,`N`,26,29,15,`E`,"d","]")
63 Pon1 Wp12 = neW Pon1{46,16,23,`N`,26,36, 9,`E`,"e","]")
64 Pon1 Wp13 = neW Pon1{45,56,23,`N`,26,33, 9,`E`,"1","]")
65 Pon1 Wp14 = neW Pon1{46,36,23,`N`,26,52, 9,`E`,"g","]")
66 Pon1 Wp15 = neW Pon1{46,25,23,`N`,26,54, 6,`E`,"h","]")
67 Pon1 Wp16 = neW Pon1{46,26,23,`N`,26,46, 6,`E`,"","]")
68 Pon1 Wp17 = neW Pon1{46,16,23,`N`,26,48, 6,`E`,"]","]")
69 Pon1 Wp18 = neW Pon1{45,56,23,`N`,26,35, 6,`E`,"k","]") */
70
71 Pon1 seec1edWP,
72
73
74
///////////////////////C0||4|9S,|E|dS,8dTT0|S\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
75 Commahd 0bhhY,
76 Commahd 0ELTh,
77 Commahd hAP_Ch0,
78
79 01spay d = 01spay.ge101spay{1hs),
80
81 Ls1 modes,
82 Commahd seec1Cmd,
83 Commahd mapv1ewCmd,
84 Commahd compassCmd,
85
86
87
88 Commahd op1,
89 Commahd mod,
90
91 Ls1 hvL1s1,
92 Commahd Po1h1s,
93 Commahd Jou1es,
94 Commahd gps,
95 Commahd 1J1ehds,
96 Commahd ZoomTh,
97 Commahd Zoom0u1,
98 Commahd ex11Cmd,
99 S1mpeTex1FoJm gpsT1,
lxxxvi
SoItware DeIects Prevention Techniques Example Project
100 Thread 11,
101 Thread 12,
102
103 s1a11c 51rng JesouJce="",
104 booeah gps0h = 1a1se,
105 s1a11c 51rng show = "",
106 booeah 11Js1 = 1a1se,
107 Ls1 1J1ehdL1s1,
108 Commahd addhewFJ1ehd ,
109 Commahd ohCPSc,
110 Commahd o11CPSc,
111 Ls1 gpsL1s1,
112 1h1 gpshash = 0,
113
114 1h1 gpsThJ = 0,
115 1h1 1JhdThJ = 0,
116 1h1 cuJJeh1yShowed = 0,
117 hash1ab1e 1hJhash = neW hash1ab1e{),
118 vec1or 1s101FJ1ehds = neW vec1or{),
119 S1mpeTex1FoJm 1J1ehdFoJm,
120 Commahd s1opFoow,
121 Commahd dee1eFJ1ehds,
122 booeah 1oowFJ1ehds = 1a1se,
123
124 Ls1 oheFJ1ehd,
125 Commahd s1opFoow0he,
126 Commahd dee1eFJ1ehd,
127
128 ThJead4FJ1ehd 111,
129 vec1or wh11eL1s1,
130 51rng 1J1ehd,
131
132 booeah syhcFoow = 1a1se,
133 ohg gobaT1meS1amp = 0,
134 booeah syhchJoh1za11oh0ohe = 1a1se,
135
136 Ls1 WPseec1ed,
137 Commahd se1AsCuJJeh1,
138 Commahd se10es11,
139 Commahd ed11,
140 Commahd dee1e,
141 Commahd meas01s1,
142 Commahd se1L1he,
143 Commahd Jese1L1he,
144
145
146 Ls1 WPho1Se,
147 Commahd se1CuJJeh1,
148 Commahd se10es12,
149 Commahd addWP,
150
lxxxvii
Zarko Acimovic
151 CommahyphehS1J1hg chs = neW CommahyphehS1J1hg{),
152 Tex1FoJm 111, // 1oIn 1oI addIng ne| PoIn1 on se1ec1ed spo1
153 Tex1FoJm 112, // 1oIn 1oI edI1Ing o1 se1ec1ed PoIn1
154 Tex1FoJm 1133, // 1oIn 1oI addIng |aypoIn1 |I1h useI en1eIed da1a
1oI ]1a1,1on)
155 Tex1FoJm pJev1ous,
156 Tex1FoJmTmage 1111, //1oIn 1oI addIng ne| PoIn1 |I1h Inages 1oI
se1ec1ed ca1egoIIes
157 Tex1FoJmTmage 1122,
158 Commahd SAvE_Ch0,
159 Commahd C0hT_Ch0,
160 Commahd BACK_Ch0,
161 AeJ1 a = neW AeJ1{"WaJh1hg","Pease Seec1
Po1h1!",nu11,AeJ1Type.ThF0),
162
163 Ls1 WPL1s1, //LIs1 o1 PoIn1s
164 Commahd addhewWP,
165 Commahd soJ1WP,
166 Commahd soJ1hameWP,
167 booeah showT0 = 1a1se,
168 Commahd showT0com,
169 Ls1 pJev1ousL1s1,
170
171
172 Tex1FoJm 11Add, //1oIn 1oI addIng PoIn1 |I1h conp1e1e In1o abou1
cooIdIna1es
173
174 Ls1 soJ1ed,
175
176
177 Ls1 Jou1eha1h,
178 Commahd cJea1ehewRou1e,
179 Commahd showRou1es,
180 Commahd deRou1e,
181
182 Ls1 Jou1ehew,
183 Commahd addPo1h1,
184 Commahd Jou1eF1h,
185
186 Ls1 Jou1eL1s1,
187 Ls1 Jou1e0p11ohs,
188 Commahd aRou1es,
189 Commahd h1deRou1es,
190
191 Ls1 deRou1eL1s1,
192 Commahd deARou1es,
193 51rng hameR = "",
194
195 Pvec1oJ hewRou1evec1oJ,
196 S1mpeTex1FoJm 113, ///1oIn 1oI de1InIng nane o1 Iou1e
197 51rng|] ca1egoJ1es,
lxxxviii
SoItware DeIects Prevention Techniques Example Project
198 booeah Jou1eSe111hg = 1a1se,
199
200 51rng|] pa1hToTmage,
201 /**
262 * Qsee NI1e1#s1ar1App{)
263 */
204 pro1ec1ed vo1d s1aJ1App{) 1hroWs hT0e1S1a1eChahgeExcep11oh {
205
206 mb = mb1.ge1hapBackgJouhd{),
207 mob = neW hap0bec1s{mb),
208
209 vwpF.addEemeh1{wp1),
210 vwpF.addEemeh1{wp2),
211 //v|pF.addE1enen1]|p3);
212 vwpF.addEemeh1{wp4),
213 vwpF.addEemeh1{wp5),
214 vwpF.addEemeh1{wp6),
215 vwpF.addEemeh1{wp7),
216 vwpF.addEemeh1{wp8),
217 vwpF.addEemeh1{wp9),
218 vwpF.addEemeh1{wp10),
219 vwpF.addEemeh1{wp11),
220 vwpF.addEemeh1{wp12),
221 vwpF.addEemeh1{wp13),
222 vwpF.addEemeh1{wp14),
223 vwpF.addEemeh1{wp15),
224
225
226
227 mob.se1FJeeWaypo1h1sv{vwpF),
228
229 seP = neW Seec1oJPo1h1{mb,mob),
230
231 ou = neW 0u1ook{mb,mob,seP),
232
233 1c = neW TmageCahvas3{ou),
234
235
236
//////////////////////////C0||4|9S,|E|dS,8dTT0|S\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
237
238 0bhhY = neW Commahd{" ",Commahd.SCREEh,1),
239 0ELTh = neW Commahd{"------------------",Commahd.SCREEh,1),
240 hAP_Ch0 = neW Commahd{"v1ew oh hap",Commahd.BACK,1),
241 BACK_Ch0 = neW Commahd{"Back 1o PJev1ous
ScJeeh",Commahd.BACK,1),
242
243 mod = neW Commahd{"hode",Commahd.SCREEh,1),
244 modes = neW Ls1{"",Ls1.ThPLTCTT),
245 seec1Cmd = neW Commahd{"Seec11oh",Commahd.SCREEh,1),
246 mapv1ewCmd = neW Commahd{"hapv1ew",Commahd.SCREEh,1),
lxxxix
Zarko Acimovic
247 compassCmd = neW Commahd{"Compass",Commahd.SCREEh,1),
248 ex11Cmd = neW Commahd{"Ex11",Commahd.SCREEh,1),
249 modes.appehd{"PLEASE SELECT hEW h00E FR0h hEhb...",nu11),
250 modes.addCommahd{0bhhY),
251 modes.addCommahd{mapv1ewCmd),
252 modes.addCommahd{seec1Cmd),
253 modes.addCommahd{compassCmd),
254 modes.addCommahd{ex11Cmd),
255 modes.se1CommahdL1s1eheJ{1hs),
256
257 op1 = neW Commahd{"0p11oh",Commahd.SCREEh,1),
258
259
260
261 // |ap vIe| op1Ions
262 hvL1s1 = neW Ls1{"",Ls1.ThPLTCTT),
263 Po1h1s = neW Commahd{"Waypo1h1s",Commahd.SCREEh,1),
264 Jou1es = neW Commahd{"Rou1es",Commahd.SCREEh,1),
265 gps = neW Commahd{"CPS",Commahd.SCREEh,1),
266
267 1J1ehds = neW Commahd{"FJ1ehds",Commahd.SCREEh,1),
268 ZoomTh = neW Commahd{"Zoom Th",Commahd.SCREEh,1),
269 Zoom0u1 = neW Commahd{"Zoom 0u1",Commahd.SCREEh,1),
270 //ExI1 = ne| Connand]"ExI1",Connand.EXJT,J);
271
272 hvL1s1.addCommahd{0bhhY),
273 hvL1s1.addCommahd{Po1h1s),
274 hvL1s1.addCommahd{Jou1es),
275 hvL1s1.addCommahd{gps),
276 hvL1s1.addCommahd{1J1ehds),
277 hvL1s1.addCommahd{ZoomTh),
278 hvL1s1.addCommahd{Zoom0u1),
279 hvL1s1.addCommahd{BACK_Ch0),
280 hvL1s1.se1CommahdL1s1eheJ{1hs),
281
282 C0hT_Ch0 = neW Commahd{"Coh11hue",Commahd.SCREEh,1),
283 gpsT1 = neW S1mpeTex1FoJm{1a1se),
284 gpsT1.addCommahd{C0hT_Ch0),
285 gpsT1.se1CommahdL1s1eheJ{1hs),
286
287
288
289
290 // J1 PoIn1 Is se1ec1ed
291 WPseec1ed = neW Ls1{"",Ls1.ThPLTCTT),
292 se1AsCuJJeh1 = neW Commahd{"Se1 as
CuJJeh1",Commahd.SCREEh,1),
293 se10es11 = neW Commahd{"Se1 as
0es11ha11oh",Commahd.SCREEh,1),
294 ed11 = neW Commahd{"Ed11",Commahd.SCREEh,1),
295 dee1e = neW Commahd{"0ee1e",Commahd.SCREEh,1),
xc
SoItware DeIects Prevention Techniques Example Project
296 meas01s1 = neW Commahd{"heasuJe
01s1ahce",Commahd.SCREEh,1),
297
298
299 WPseec1ed.addCommahd{0bhhY),
300 WPseec1ed.addCommahd{hAP_Ch0),
301 WPseec1ed.addCommahd{se1AsCuJJeh1),
302 WPseec1ed.addCommahd{se10es11),
303 WPseec1ed.addCommahd{ed11),
304 WPseec1ed.addCommahd{dee1e),
305 WPseec1ed.addCommahd{meas01s1),
306 WPseec1ed.addCommahd{BACK_Ch0),
307 WPseec1ed.se1CommahdL1s1eheJ{1hs),
308
309
310
311 // J1 PoIn1 Is no1 se1ec1ed
312 WPho1Se = neW Ls1{"",Ls1.ThPLTCTT),
313 se1CuJJeh1 = neW Commahd{"Se1 CuJJeh1",Commahd.SCREEh,1),
314 se10es12 = neW Commahd{"Se1
0es11ha11oh",Commahd.SCREEh,1),
315 addWP = neW Commahd{"Add Waypo1h1",Commahd.SCREEh,1),
316
317 WPho1Se.addCommahd{0bhhY),
318 WPho1Se.addCommahd{se1CuJJeh1),
319 WPho1Se.addCommahd{se10es12),
320 WPho1Se.addCommahd{addWP),
321 WPho1Se.addCommahd{meas01s1),
322 //kPno1Se1.addConnand]|4P_C|9);
323 WPho1Se.addCommahd{BACK_Ch0),
324 WPho1Se.se1CommahdL1s1eheJ{1hs),
325
326 WPL1s1 = neW Ls1{"",Ls1.ThPLTCTT),
327 addhewWP = neW Commahd{"Add Waypo1h1",Commahd.SCREEh,1),
328 soJ1WP = neW Commahd{"SoJ1 Waypo1h1s by
01s1ahce",Commahd.SCREEh,1),
329 soJ1hameWP = neW Commahd{"SoJ1 Waypo1h1s by
hame",Commahd.SCREEh,1),
330 showT0com = neW Commahd{"Show/h1de T0",Commahd.SCREEh,1),
331
332 11Add = neW
Tex1FoJm{chs.ge1Ca1egoJ1es{1hs.ge1AppPJopeJ1y{"Ca1egoJ1es")),1a1se),
333
334 11Add.addCommahd{C0hT_Ch0),
335 11Add.se1CommahdL1s1eheJ{1hs),
336
337 soJ1ed = neW Ls1{"",Ls1.ThPLTCTT),
338 soJ1ed.se1CommahdL1s1eheJ{1hs),
339
340
341 1c.addCommahd{op1),
xci
Zarko Acimovic
342 1c.addCommahd{mod),
343 1c.se1CommahdL1s1eheJ{1hs),
344
345
346 111 = neW
Tex1FoJm{chs.ge1Ca1egoJ1es{1hs.ge1AppPJopeJ1y{"Ca1egoJ1es")),1a1se),///1oIn 1oI
addIng ne| PoIn1 on se1ec1ed spo1
347 112 = neW
Tex1FoJm{chs.ge1Ca1egoJ1es{1hs.ge1AppPJopeJ1y{"Ca1egoJ1es")),1a1se),/// 1oIn 1oI
edI1Ing o1 se1ec1ed PoIn1
348 1133 = neW
Tex1FoJm{chs.ge1Ca1egoJ1es{1hs.ge1AppPJopeJ1y{"Ca1egoJ1es")),1rue),/// 1oIn 1oI
edI1Ing o1 se1ec1ed PoIn1
349
350 SAvE_Ch0 = neW Commahd{"Save",Commahd.SCREEh,1),
351
352 111.addCommahd{C0hT_Ch0),
353 111.addCommahd{BACK_Ch0),
354 111.se1CommahdL1s1eheJ{1hs),
355 112.addCommahd{C0hT_Ch0),
356 112.addCommahd{BACK_Ch0),
357 112.se1CommahdL1s1eheJ{1hs),
358 1133.addCommahd{C0hT_Ch0),
359 1133.addCommahd{BACK_Ch0),
360 1133.se1CommahdL1s1eheJ{1hs),
361
362 wh11eL1s1 = neW vec1or{),
363
364 d.se1CuJJeh1{1c),
365 }
366
367
368 pub1c vo1d commahdAc11oh{Commahd c, 01spayabe s){
369
370 1 {c==hAP_Ch0) d.se1CuJJeh1{1c),
371 1 {s==1c && c==mod){
372 d.se1CuJJeh1{modes),
373 }
374 1 {s==modes && c==seec1Cmd){
375 ou.se1Seec1{),
376 1c.Jepa1h1{),
377 d.se1CuJJeh1{1c),
378 seP.Jese1B1g{),
379 seP.Jese1CooJ{),
380 }
381 1 {s==modes && c==mapv1ewCmd){
382 seP.Jese1CooJ{),
383 seP.Jese1B1g{),
384 ou.Jese1Seec1{),
385 d.se1CuJJeh1{1c),
386 }
xcii
SoItware DeIects Prevention Techniques Example Project
387
388 1 {s==modes && c==compassCmd){
389 ou.Jese1Seec1{),
390 cc = neW CompassCahvas{mob),
391 cc.addCommahd{hAP_Ch0),
392 cc.se1CommahdL1s1eheJ{1hs),
393 d.se1CuJJeh1{cc),
394 }
395
396 1 {s==modes && c==ex11Cmd){
397 1ry{
398 des1JoyApp{1a1se),
399 }ca1ch{Excep1on e){}
400 ho111y0es1Joyed{),
401 re1urn,
402 }
403
404 1{s==cc && c==hAP_Ch0){
405 cc.se1Ehd{),
406 1c = neW TmageCahvas3{ou),
407 1c.addCommahd{op1),
408 1c.addCommahd{mod),
409 1c.se1CommahdL1s1eheJ{1hs),
410 d.se1CuJJeh1{1c),
411 }
412
413 1 {s==1c && c==op1 && Jou1eSe111hg==1a1se){
414 1{ou.ge1Seec1{)==1rue) {
415 seec1edWP = seP.ge1Seec1edWP{),
416 1{seec1edWP.ge1hame{)=="seec1oJ")
d.se1CuJJeh1{WPho1Se),
417 1{seec1edWP.ge1hame{)!="seec1oJ") {
418 d.se1CuJJeh1{WPseec1ed),
419 pJev1ousL1s1=nu11,
420 }
421 }
422 1{ou.ge1Seec1{)==1a1se) d.se1CuJJeh1{hvL1s1),
423 }
424
425
426 // JF PoIn1 |0T SELECTE9
427 1{s==WPho1Se && c==se1CuJJeh1){
428 Pon1 wp = seP.ge1Seec1oJ{),
429 wp.se1hame{"cuJJeh1"),
430 mob.se1CuJJeh1Pos111oh{wp),
431 d.se1CuJJeh1{1c),
432 }
433 1{s==WPho1Se && c==se10es12){
434 Pon1 wp = seP.ge1Seec1oJ{),
435 wp.se1hame{"des1"),
436 mob.se10es11ha11ohPos111oh{wp),
xciii
Zarko Acimovic
437 d.se1CuJJeh1{1c),
438 }
439
440 // 499 PoIn1 0| SELECTE9 SP0T
441 1{s==WPho1Se && c==addWP){
442 111.se1hame{"de1au1"), //1oIn 1oI addIng ne|
PoIn1 on se1ec1ed spo1
443 //11J.se1Type]"Type |I11 be se1 accoIdIng 1o
ca1egoIy");
444 111.se1La1{seP.ge1Seec1oJ{).ge1La1{)),
445 111.se1Loh{seP.ge1Seec1oJ{).ge1Loh{)),
446 d.se1CuJJeh1{111),
447 }
448
449 1 {s.equas{111) && c == C0hT_Ch0){
450 51rng hame = 111.ge1hame{),
451 1h1 se = 111.ge1Seec1ed{),
452
453 // chs Is Ins1ance o1 Conna|ypenS1IIng c1ass
454 // |hIch he1ps us pIocess hyphens and connas In
455 //.pIopeI1Ies 1I1e
456 51rng|] ca1egoJy =
chs.ge1Ca1egoJ1es{1hs.ge1AppPJopeJ1y{"Ca1egoJ1es")),
457 51rng|] ca1egoJyhypheh =
chs.ge1Ca1egoJ1eshypheh{1hs.ge1AppPJopeJ1y{"Ca1egoJ1es")),
458
459 // e1enen1s o1 a se1ec1ed ca1egoIy. as sIn1e
s1IIngs and as hyphen-s1IIngs
460 51rng ca1ha1ches =
1hs.ge1AppPJopeJ1y{ca1egoJyhypheh|se]),
461 51rng|] aJCa1ha1ches =
chs.ge1S1J1hgs0hy{ca1ha1ches),
462 51rng|] aJCa1hyphha1ches =
chs.ge1W11hLowL1he{ca1ha1ches),
463
464 // Inages 1ha1 coIIespond 1o ca1egoIy e1enen1s
465 51rng|] 1mageS1J = neW
51rng|aJCa1ha1ches.ehg1h],
466 Image|] 1mg = neW Image|aJCa1ha1ches.ehg1h],
467 1or{1h1 1=0, 1<aJCa1ha1ches.ehg1h, 1++){
468 1mageS1J|1] =
1hs.ge1AppPJopeJ1y{""+aJCa1hyphha1ches|1]+""),
469 1mageS1J|1] = 1hs.compac1{1mageS1J|1]),
470 }
471
472 pa1hToTmage = neW 51rng|aJCa1ha1ches.ehg1h],
473 1or {1h1 1=0, 1<aJCa1ha1ches.ehg1h, 1++){
474 1ry{
475 51rng s1J = ca1egoJyhypheh|se]
+"/"+1mageS1J|1],
xciv
SoItware DeIects Prevention Techniques Example Project
476 s1J = compac1{s1J), //ge11Ing IId
o11 b1anco spo1s
477 pa1hToTmage|1] = s1J,
478 1mg|1] = Image.cJea1eTmage{s1J),
479 } ca1ch{Excep1on e){}
480 }
481
482 1111 = neW Tex1FoJmTmage{"",aJCa1ha1ches,1mg),
483 1111.se1hameChCR{"Pease seec1 1ype"),
484 1111.se1hame{hame),
485 //11JJ.se1Type]"P1ease se1ec1 1ype");
486 1111.addCommahd{BACK_Ch0),
487 1111.addCommahd{SAvE_Ch0),
488 1111.se1CommahdL1s1eheJ{1hs),
489 d.se1CuJJeh1{1111),
490 }
491
492 1{s==111 && c==BACK_Ch0){
493 d.se1CuJJeh1{WPho1Se),
494 }
495
496 1{s==1111 && c==BACK_Ch0){
497 d.se1CuJJeh1{111),
498 }
499
500 1{s==1111 && c==SAvE_Ch0){
501 Pon1 wp = seP.ge1Seec1oJ{),
502 wp.se1hame{1111.ge1hame{)),
503 1h1 se = 1111.ge1Seec1ed{),
504 51rng cmpc1 = compac1{pa1hToTmage|se]),
505 wp.se1Tmage{cmpc1),
506 mob.addFJeeWaypo1h1{wp),
507 d.se1CuJJeh1{1c),
508 }
509
510 1{s==WPseec1ed && c==se1AsCuJJeh1){
511 mob.se1CuJJeh1Pos111oh{seec1edWP),
512 d.se1CuJJeh1{1c),
513 }
514
515 1{s==WPseec1ed && c==se10es11){
516 mob.se10es11ha11ohPos111oh{seec1edWP),
517 d.se1CuJJeh1{1c),
518 }
519
520 //EdI1 o1 PoIn1
521 1{s==WPseec1ed && c==ed11){
522 112.se1hame{seec1edWP.ge1hame{)),
523 112.se1Type{seec1edWP.ge1Type{)),
524 112.se1La1{seec1edWP.ge1La1{)),
525 112.se1Loh{seec1edWP.ge1Loh{)),
xcv
Zarko Acimovic
526 d.se1CuJJeh1{112),
527 }
528
529
530 //EdI1Ing o1 |aypoIn1 0R InseI1Ing |aypoIn1 1Ion 1ex1 1oIn
531 1 { {s.equas{112)]]s.equas{1133)) && c == C0hT_Ch0){
532 51rng hame ="",
533 1h1 se = 0,
534
535 1{s.equas{112)){
536 hame = 112.ge1hame{),
537 se = 112.ge1Seec1ed{),
538 pJev1ous = 112,
539 }
540
541 1{s.equas{1133)){
542 hame = 1133.ge1hame{),
543 se = 1133.ge1Seec1ed{),
544 pJev1ous = 1133,
545 }
546
547
548 // chs Is Ins1ance o1 Conna|ypenS1IIng c1ass
549 // |hIch he1ps us pIocess hyphens and connas In
550 //.pIopeI1Ies 1I1e
551 51rng|] ca1egoJy =
chs.ge1Ca1egoJ1es{1hs.ge1AppPJopeJ1y{"Ca1egoJ1es")),
552 51rng|] ca1egoJyhypheh =
chs.ge1Ca1egoJ1eshypheh{1hs.ge1AppPJopeJ1y{"Ca1egoJ1es")),
553
554 // e1enen1s o1 a se1ec1ed ca1egoIy. as sIn1e
s1IIngs and as hyphen-s1IIngs
555 51rng ca1ha1ches =
1hs.ge1AppPJopeJ1y{ca1egoJyhypheh|se]),
556 51rng|] aJCa1ha1ches =
chs.ge1S1J1hgs0hy{ca1ha1ches),
557 51rng|] aJCa1hyphha1ches =
chs.ge1W11hLowL1he{ca1ha1ches),
558
559 // Inages 1ha1 coIIespond 1o ca1egoIy e1enen1s
560 51rng|] 1mageS1J = neW
51rng|aJCa1ha1ches.ehg1h],
561 Image|] 1mg = neW Image|aJCa1ha1ches.ehg1h],
562 1or{1h1 1=0, 1<aJCa1ha1ches.ehg1h, 1++){
563 1mageS1J|1] =
1hs.ge1AppPJopeJ1y{""+aJCa1hyphha1ches|1]+""),
564 1mageS1J|1] = 1hs.compac1{1mageS1J|1]),
565 }
566
567 pa1hToTmage = neW 51rng|aJCa1ha1ches.ehg1h],
568 1or {1h1 1=0, 1<aJCa1ha1ches.ehg1h, 1++){
xcvi
SoItware DeIects Prevention Techniques Example Project
569 1ry{
570 51rng s1J = ca1egoJyhypheh|se]
+"/"+1mageS1J|1],
571 s1J = compac1{s1J), //ge11Ing IId
o11 b1anco spo1s
572 pa1hToTmage|1] = s1J,
573 1mg|1] = Image.cJea1eTmage{s1J),
574 } ca1ch{Excep1on e){}
575 }
576
577 1122 = neW Tex1FoJmTmage{"",aJCa1ha1ches,1mg),
578 1122.se1hameChCR{"Pease seec1 1ype"),
579 1122.se1hame{hame),
580 1122.addCommahd{BACK_Ch0),
581 1122.addCommahd{SAvE_Ch0),
582 1122.se1CommahdL1s1eheJ{1hs),
583 d.se1CuJJeh1{1122),
584 }
585
586 1{s==112 && c==BACK_Ch0){
587 d.se1CuJJeh1{WPseec1ed),
588 }
589
590 1{s==1122 && c==BACK_Ch0){
591 d.se1CuJJeh1{pJev1ous),
592 }
593
594 1{s==1122 && c==SAvE_Ch0){
595
596 //EdI1Ing o1 |aypoIn1
597 1{pJev1ous == 112){
598 Pon1 wp = seP.ge1Seec1edWP{),
599 1{wp.ge1La1{)==0){
600 wp = neW
Pon1{112.ge1La1{),112.ge1Loh{),1122.ge1hame{),"","bahco",1a1se),
601 }
602 wp.se1hame{1122.ge1hame{)),
603 1h1 se = 1122.ge1Seec1ed{),
604 51rng cmpc1 = compac1{pa1hToTmage|se]),
605 wp.se1Tmage{cmpc1),
606 wp.se1La1{112.ge1La1{)),
607 wp.se1Loh{112.ge1Loh{)),
608 seP.dee1eWP{),
609 mob.addFJeeWaypo1h1{wp),
610 seP.se1CooJ{),
611 d.se1CuJJeh1{1c),
612 }
613
614 // |e| |aypoIn1 1Ion 1ex1 1oIn
615 1{pJev1ous==1133){
xcvii
Zarko Acimovic
616 Pon1 wp = neW
Pon1{1133.ge1La1{),1133.ge1Loh{),1122.ge1hame{),"","bahco",1a1se),
617 wp.se1hame{1122.ge1hame{)),
618 1h1 se = 1122.ge1Seec1ed{),
619 51rng cmpc1 = compac1{pa1hToTmage|se]),
620 wp.se1Tmage{cmpc1),
621 wp.se1La1{1133.ge1La1{)),
622 wp.se1Loh{1133.ge1Loh{)),
623 mob.addFJeeWaypo1h1{wp),
624 d.se1CuJJeh1{1c),
625 }
626 }
627
628
629 // 9e1e1e PoIn1
630 1{s==WPseec1ed && c==dee1e){
631 1h1 k = seP.dee1eWP{),
632 1{k==-1){
633 a.se1T1meou1{3000),
634 a.se1S1J1hg{"hoJe 1hah ohe Po1h1
seec1ed"),
635 d.se1CuJJeh1{a),
636 } e1se {
637 seP.Jese1B1g{),
638 d.se1CuJJeh1{1c),
639 }
640 }
641
642 1{s==WPseec1ed && c==BACK_Ch0){
643 1{pJev1ousL1s1==nu11) d.se1CuJJeh1{1c),
644 1{pJev1ousL1s1!=nu11) d.se1CuJJeh1{pJev1ousL1s1),
645 }
646
647
648 // |easuIIng dIs1ance be1|een cuIIen1 posI1Ion and se1ec1ed
k4YP0J|T
649 1{s==WPseec1ed && c==meas01s1){
650
1{mob.ge1CuJJeh1Pos111oh{).ge1hame{).equas{"dummy")){
651 a.se1T1meou1{3000),
652 a.se1S1J1hg{"CuJJeh1 pos111oh 1s ho1 se1"),
653 d.se1CuJJeh1{a),
654
655 } e1se {
656 a.se1T1meou1{3000),
657 seec1edWP = seP.ge1Seec1edWP{),
658 ohg k = mob.measuJe01s1ahce{seec1edWP),
659 a.se1S1J1hg{"01s1ahce 1s "+k+" m"),
660 d.se1CuJJeh1{a),
661 }
662
xcviii
SoItware DeIects Prevention Techniques Example Project
663 }
664
665
666 // |easuIIng dIs1ance be1|een cuIIen1 posI1Ion and se1ec1ed
L0C4TJ0|
667 1{s==WPho1Se && c==meas01s1){
668 seec1edWP = seP.ge1Seec1oJ{),
669 ohg k = mob.measuJe01s1ahce{seec1edWP),
670 1{mob.cuJJeh1Se1{)==1a1se){
671 a.se1T1meou1{3000),
672 a.se1S1J1hg{"CuJJeh1 pos111oh 1s ho1 se1"),
673 d.se1CuJJeh1{a),
674
675 } e1se {
676 a.se1T1meou1{3000),
677 a.se1S1J1hg{"01s1ahce 1s "+k+" m"),
678 d.se1CuJJeh1{a),
679 }
680 }
681
682 1{s==WPho1Se && c==BACK_Ch0) d.se1CuJJeh1{1c),
683
684
685
686
687
688 // -----------------Sho|Ing up a11 PoIn1s and sone
opeIa1Ions---------------
689 1{s==hvL1s1 && c==Po1h1s){
690 se1WPL1s1{),
691
692 1or{1h1 1=0, 1<mob.1JeeWaypo1h1s.s1ze{), 1++){
693 Pon1 wp =
{Pon1)mob.1JeeWaypo1h1s.eemeh1A1{1),
694 51rng hame = "",
695 1{showT0==1rue){
696 hame = wp.ge1hame{)
+"_"+wp.ge1T0{),
697 } e1se {
698 hame = wp.ge1hame{),
699 }
700 Commahd cc = neW
Commahd{hame,Commahd.SCREEh,1),
701 WPL1s1.addCommahd{cc),
702 }
703 d.se1CuJJeh1{WPL1s1),
704 }
705
706 1{s==hvL1s1 && c==BACK_Ch0){
707 d.se1CuJJeh1{1c),
708 }
xcix
Zarko Acimovic
709
710 1{s==hvL1s1 && c==ZoomTh){
711 ou.ZoomTh{),
712 d.se1CuJJeh1{1c),
713 }
714
715 1{s==hvL1s1 && c==Zoom0u1){
716 ou.Zoom0u1{),
717 d.se1CuJJeh1{1c),
718 }
719
720
721 // dIsp1ayIng o1 J9s o1 Icons
722 1{s==WPL1s1 && c==showT0com){
723 1{showT0==1rue) {showT0=1a1se, } e1se
{showT0=1rue,}
724
725 se1WPL1s1{),
726
727 1or{1h1 1=0, 1<mob.1JeeWaypo1h1s.s1ze{), 1++){
728 Pon1 wp =
{Pon1)mob.1JeeWaypo1h1s.eemeh1A1{1),
729 51rng hame = "",
730 1{showT0==1rue){
731 hame = wp.ge1hame{)
+"_"+wp.ge1T0{),
732 } e1se {
733 hame = wp.ge1hame{),
734 }
735 Commahd cc = neW
Commahd{hame,Commahd.SCREEh,1),
736 WPL1s1.addCommahd{cc),
737 }
738 d.se1CuJJeh1{WPL1s1),
739 }
740
741
742 // 4ddIng ne| PoIn1 |I1h a11 a11IIbu1es such as
743 // L4TJTd9E and L0|JTd9E
744 // ke dea1 |I1h 1133 sane as |I1h 112 ]112 Is used 1oI
745 // InseI1Ing ne| da1a 1oI se1ec1ed 1oca1Ion
746 // |eIe de1au11 va1ues 1oI cooIdIna1es aIe 1hose o1 cen1eI
o1 1he nap
747
748 1{s==WPL1s1 && c==addhewWP){
749 1133.se1hame{"Ceh1eJ o1
hap"),//44.803455JJ,20.42482J
750 1133.se1Type{""),
751 1133.se1La1{"44.80345511"),
752 1133.se1Loh{"20.42949821"),
753 d.se1CuJJeh1{1133),
c
SoItware DeIects Prevention Techniques Example Project
754 }
755
756
757
758 1{s==1133 && c==BACK_Ch0){
759 d.se1CuJJeh1{WPL1s1),
760 }
761
762 //soI1Ing |aypoIn1s by dIs1ance
763 1{s==WPL1s1 && c==soJ1WP){
764 se1WPL1s1{),
765
766 vec1or soJ =
mob.1JeeWaypo1h1s.soJ1Ascehd1hg{mob.ge1CuJJeh1Pos111oh{)),
767 1or{1h1 1=0, 1<soJ.s1ze{), 1++){
768 Pon1 wp = {Pon1)soJ.eemeh1A1{1),
769 51rng hame = "",
770 1{showT0==1rue){
771 hame = wp.ge1hame{)+" "+wp.ge1T0{),
772 } e1se {
773 hame = wp.ge1hame{),
774 }
775 Commahd cc = neW
Commahd{hame,Commahd.SCREEh,1),
776 WPL1s1.addCommahd{cc),
777 }
778 d.se1CuJJeh1{WPL1s1),
779 }
780
781 //soI1Ing |aypoIn1s by nane
782 1{s==WPL1s1 && c==soJ1hameWP){
783 se1WPL1s1{),
784 51rng|] soJ = mob.1JeeWaypo1h1s.soJ1Byhame{),
785 1or{1h1 1=0, 1<soJ.ehg1h, 1++){
786 Commahd cc = neW
Commahd{soJ|1],Commahd.SCREEh,1),
787 WPL1s1.addCommahd{cc),
788 }
789 d.se1CuJJeh1{WPL1s1),
790 }
791
792
793 1{s==WPL1s1 && c==hAP_Ch0){
794 d.se1CuJJeh1{1c),
795 }
796
797 1{s==WPL1s1 && c==BACK_Ch0){
798 d.se1CuJJeh1{hvL1s1),
799 }
800
801 //9Isp1ayIng se1ec1ed |aypoIn1
ci
Zarko Acimovic
802 1{s==WPL1s1 && c!=soJ1WP && c!=addhewWP && c!=hAP_Ch0 &&
c!=soJ1hameWP && c!=0bhhY && c!=BACK_Ch0){
803 51rng hame = c.ge1Labe{),
804 mb.paJam=1rue,
805 seP.seec1WP{hame),
806 ou.se1Seec1{),
807 ou.se1WPseec11oh{),
808 d.se1CuJJeh1{WPseec1ed),
809 pJev1ousL1s1 = WPL1s1,
810 }
811
812
813
814 // -------------- R0dTES --------------------------------
815
816 // |aIn |enu 1oI Rou1es
817 1{s==hvL1s1 && c==Jou1es){
818 Jou1eha1h = neW Ls1{"",Ls1.ThPLTCTT),
819 cJea1ehewRou1e = neW Commahd{"hew
Rou1e",Commahd.SCREEh,1),
820 Jou1eha1h.addCommahd{0bhhY),
821 Jou1eha1h.addCommahd{cJea1ehewRou1e),
822 Jou1eha1h.addCommahd{BACK_Ch0),
823 Jou1eha1h.addCommahd{0ELTh),
824 Jou1eha1h.se1CommahdL1s1eheJ{1hs),
825 1or{1h1 1=0, 1<mob.ge1Rou1es{).s1ze{), 1++){
826 Pvec1oJ Jou1e =
{Pvec1oJ)mob.ge1Rou1es{).eemeh1A1{1),
827 51rng hame = Jou1e.ge1hame{),
828 Commahd cJ = neW
Commahd{hame,Commahd.SCREEh,1),
829 Jou1eha1h.addCommahd{cJ),
830 }
831 d.se1CuJJeh1{Jou1eha1h),
832 }
833
834 1{s==Jou1eha1h && c==BACK_Ch0){
835 d.se1CuJJeh1{hvL1s1),
836 }
837
838 //CIea1Ing a |e| Rou1e
839 1{s==Jou1eha1h && c==cJea1ehewRou1e){
840 113 = neW S1mpeTex1FoJm{1a1se),
841 113.addCommahd{SAvE_Ch0),
842 113.se1CommahdL1s1eheJ{1hs),
843 d.se1CuJJeh1{113),
844 }
845
846
847 1{s==113 && c==SAvE_Ch0){
848 hewRou1evec1oJ = neW Pvec1oJ{"",1rue),
cii
SoItware DeIects Prevention Techniques Example Project
849 hewRou1evec1oJ.se1hame{113.ge1hame{)),
850 hewRou1evec1oJ.se1v1s1be{),
851 mob.addRou1e{hewRou1evec1oJ),
852
853 Jou1ehew = neW Ls1{"",Ls1.ThPLTCTT),
854 addPo1h1 = neW Commahd{"Add
Waypo1h1",Commahd.SCREEh,1),
855 Jou1eF1h = neW Commahd{"Rou1e
F1h1shed",Commahd.SCREEh,1),
856 Jou1ehew.addCommahd{addPo1h1),
857 Jou1ehew.addCommahd{Jou1eF1h),
858 Jou1ehew.se1CommahdL1s1eheJ{1hs),
859
860 d.se1CuJJeh1{Jou1ehew),
861 }
862
863
864 // Se1ec1Ion o1 specI1Ic Iou1e
865 1{s==Jou1eha1h && c!=cJea1ehewRou1e && c!=0bhhY && c!
=BACK_Ch0 && c!=0ELTh){
866 hameR = c.ge1Labe{),
867 Jou1e0p11ohs = neW Ls1{"",Ls1.ThPLTCTT),
868 showRou1es = neW Commahd{"Show/h1de
Rou1e",Commahd.SCREEh,1),
869 deRou1e = neW Commahd{"0ee1e
Rou1e",Commahd.SCREEh,1),
870 Jou1e0p11ohs.addCommahd{0bhhY),
871 Jou1e0p11ohs.addCommahd{hAP_Ch0),
872 Jou1e0p11ohs.addCommahd{showRou1es),
873 Jou1e0p11ohs.addCommahd{deRou1e),
874 Jou1e0p11ohs.addCommahd{BACK_Ch0),
875 Jou1e0p11ohs.se1CommahdL1s1eheJ{1hs),
876 d.se1CuJJeh1{Jou1e0p11ohs),
877 }
878
879 //vIe|Ing se1ec1ed Iou1e
880 1{s==Jou1e0p11ohs && c==showRou1es){
881 vec1or aR = {vec1or) mob.ge1Rou1es{),
882 1or{1h1 1=0, 1<aR.s1ze{), 1++){
883 Pvec1oJ J1 = {Pvec1oJ)aR.eemeh1A1{1),
884 1{J1.ge1hame{)==hameR) {
885 1{J1.s1ze{)!=0){
886 1{J1.ge1v1s1be{)==1rue){
887 J1.Jese1v1s1be{),
888 d.se1CuJJeh1{1c),
889 }e1se{
890 J1.se1v1s1be{),
891 Pon1 wp = {Pon1)
J1.eemeh1A1{0),
892 51rng hame =
wp.ge1hame{),
ciii
Zarko Acimovic
893
seP.seec1WP{hame),
894 ou.se1Seec1{),
895 seP.Jese1CooJ{),
896 seP.Jese1B1g{),
897 d.se1CuJJeh1{1c),
898 }
899 }
900 1{J1.s1ze{)==0){
901 a.se1T11e{"WaJh1hg"),
902 a.se1S1J1hg{"Rou1e has ho
po1h1s 1o show"),
903 a.se1T1meou1{5000),
904 d.se1CuJJeh1{a),
905 }
906
907 }
908 1{J1.ge1hame{)!=hameR) J1.Jese1v1s1be{),
909 }
910 }
911
912
913 //9e1e1Ion o1 se1ec1ed Iou1e
914 1{s==Jou1e0p11ohs && c==deRou1e){
915 vec1or v = mob.ge1Rou1es{),
916 1or{1h1 1=0, 1<v.s1ze{), 1++){
917 Pvec1oJ wpv = {Pvec1oJ)v.eemeh1A1{1),
918 1{wpv.ge1hame{)==hameR){
919 mob.JemoveRou1e{hameR),
920 1=1000,
921 }
922 }
923 d.se1CuJJeh1{1c),
924 }
925
926
927 //|apvIe|
928 1{s==Jou1e0p11ohs && c==hAP_Ch0){
929 vec1or v = mob.ge1Rou1es{),
930 1or{1h1 1=0, 1<v.s1ze{), 1++){
931 Pvec1oJ wpv = {Pvec1oJ)v.eemeh1A1{1),
932 1{wpv.ge1hame{)==hameR){
933 Pon1 p = {Pon1) wpv.eemeh1A1{0),
934 seP.seec1WP{p.ge1hame{)),
935 ou.se1Seec1{),
936 ou.se1WPseec11oh{),
937 1=1000,
938 }
939 }
940 d.se1CuJJeh1{1c),
941 }
civ
SoItware DeIects Prevention Techniques Example Project
942
943 //8ack on Iou1e|aIn
944 1{s==Jou1e0p11ohs && c==BACK_Ch0){
945 d.se1CuJJeh1{Jou1eha1h),
946 }
947
948
949
950
951
952 //4ddIng ne| poIn1 In cuIIen1 Iou1e
953 1{s==Jou1ehew && c==addPo1h1){
954 1{ou.ge1Seec1{)==1rue){
955 mob.JemoveRou1e{hewRou1evec1oJ),
956 Pon1 wp = seP.ge1Seec1oJ{),
957 wp.se1TypeT0{hewRou1evec1oJ.ge1T0{)),
958 wp.se1hame{hewRou1evec1oJ.ge1hame{)),
959 wp.se1Tmage{"Jou1e"),
960 hewRou1evec1oJ.addEemeh1{wp),
961 mob.addRou1e{hewRou1evec1oJ),
962 d.se1CuJJeh1{1c),
963 }
964
965 1{ou.ge1Seec1{)==1a1se){
966 ou.se1Seec1{),
967 ou.se1Rou1e{),
968 Jou1eSe111hg = 1rue,
969 d.se1CuJJeh1{1c),
970 }
971
972 }
973
974 1{s==1c && Jou1eSe111hg==1rue && c==op1){
975 d.se1CuJJeh1{Jou1ehew),
976 }
977
978 1{s==Jou1ehew && c==Jou1eF1h){
979 ou.Jese1Seec1{),
980 Jou1eSe111hg = 1a1se,
981 d.se1CuJJeh1{1c),
982 }
983
984
985
986
987
988
989 //--------------------------------PS
0|/0FF------------------------------
990
991 1{s==hvL1s1 && c==gps){
cv
Zarko Acimovic
992 gpsL1s1 = neW Ls1{"",Ls1.ThPLTCTT),
993 ohCPSc = neW Commahd{"0h",Commahd.SCREEh,1),
994 o11CPSc = neW Commahd{"011",Commahd.SCREEh,1),
995 gpsL1s1.addCommahd{ohCPSc),
996 gpsL1s1.addCommahd{o11CPSc),
997 gpsL1s1.se1CommahdL1s1eheJ{1hs),
998 d.se1CuJJeh1{gpsL1s1),
999 }
1000
1001 1{s==gpsL1s1 && c==ohCPSc){
1002 1{gps0h==1a1se){
1003 gps0h=1rue,
1004 1oowFJ1ehds = 1a1se,
1005 //SpecI1yIng PS cooIdIna1es IesouIce
1006 gpsT1.se1Labe{"Pease seec1 souJce o1 CPS
cooJd1ha1es, usuay 11`s CPS.1x1"),
1007 gpsT1.se1hame{"CPS.1x1"),
1008 gpsT1.se1Type{"CPS.1x1"),
1009 d.se1CuJJeh1{gpsT1), //PS 1ex11oIn
1010 } e1se {
1011 d.se1CuJJeh1{1c),
1012 }
1013 }
1014
1015 1{s==gpsL1s1 && c==o11CPSc){
1016 gps0h=1a1se,
1017 d.se1CuJJeh1{1c),
1018 }
1019
1020
1021
1022 1{s==gpsT1 && c==C0hT_Ch0){
1023 JesouJce = gpsT1.ge1hame{),
1024
1025 syhcFoow = 1rue,
1026 syhchJoh1za11oh0ohe=1a1se,
1027
1028 11=neW Thread{1hs),
1029 cuJJeh1yShowed = 11.hashCode{),
1030 gpshash = 11.hashCode{),
1031 11.s1aJ1{),
1032 d.se1CuJJeh1{1c),
1033
1034 }
1035
1036 // --------------------------- |4|9LJ| FRJE|9S` JSSdES
-------------------
1037
1038 1{s==hvL1s1 && c==1J1ehds){
1039 1J1ehdL1s1 = neW Ls1{"",Ls1.ThPLTCTT),
cvi
SoItware DeIects Prevention Techniques Example Project
1040 addhewFJ1ehd = neW Commahd{"Add hew FJ1ehd",
Commahd.SCREEh,1),
1041 s1opFoow = neW Commahd{"S1op Foow FJ1ehds",
Commahd.SCREEh,1),
1042 dee1eFJ1ehds = neW Commahd{"0ee1e FJ1ehds",
Commahd.SCREEh,1),
1043 1J1ehdL1s1.addCommahd{0bhhY),
1044 1J1ehdL1s1.addCommahd{addhewFJ1ehd),
1045 1J1ehdL1s1.addCommahd{s1opFoow),
1046 1J1ehdL1s1.addCommahd{dee1eFJ1ehds),
1047 1J1ehdL1s1.addCommahd{BACK_Ch0),
1048 1J1ehdL1s1.addCommahd{0ELTh),
1049 1{1s101FJ1ehds.s1ze{)>0){
1050 1or {1h1 1=0, 1<1s101FJ1ehds.s1ze{), 1++){
1051 FJ1ehd 1 =
{FJ1ehd)1s101FJ1ehds.eemeh1A1{1),
1052 Commahd cc = neW
Commahd{1.ge1hame{),Commahd.SCREEh,1),
1053 1J1ehdL1s1.addCommahd{cc),
1054 }
1055 }
1056 1J1ehdL1s1.se1CommahdL1s1eheJ{1hs),
1057 d.se1CuJJeh1{1J1ehdL1s1),
1058 }
1059
1060 1{s==1J1ehdL1s1 && c==addhewFJ1ehd){
1061 1J1ehdFoJm = neW S1mpeTex1FoJm{1a1se),
1062 1J1ehdFoJm.se1Labe{"FJ1ehd"),
1063 1J1ehdFoJm.se1Labe2{"SouJce o1 cooJd1ha1es"),
1064 1J1ehdFoJm.se1hame{"h1ka"),
1065 1J1ehdFoJm.se1Type{"h1ka.1x1"),
1066
1067 1J1ehdFoJm.addCommahd{C0hT_Ch0),
1068 1J1ehdFoJm.se1CommahdL1s1eheJ{1hs),
1069
1070 d.se1CuJJeh1{1J1ehdFoJm),
1071 }
1072
1073 1{s==1J1ehdFoJm && c==C0hT_Ch0){
1074 111 = neW
ThJead4FJ1ehd{wh11eL1s1,1J1ehdFoJm.ge1hame{),mob,1c,mb,ou),
1075 In1eger hT0 = neW In1eger{111.ge1T0{)),
1076 wh11eL1s1.addEemeh1{hT0),
1077
1078 111.s1aJ1{),
1079 FJ1ehd 1 = neW
FJ1ehd{1J1ehdFoJm.ge1hame{),1J1ehdFoJm.ge1Type{),111.ge1T0{),111),
1080 1s101FJ1ehds.addEemeh1{1),
1081 d.se1CuJJeh1{1c),
1082 }
1083
cvii
Zarko Acimovic
1084 1{s==1J1ehdL1s1 && c==s1opFoow){
1085 wh11eL1s1.JemoveAEemeh1s{),
1086 mob.dee1eAFJ1ehds{),
1087 1c.Jepa1h1{),
1088 d.se1CuJJeh1{1c),
1089 }
1090
1091 1{s==1J1ehdL1s1 && c==dee1eFJ1ehds){
1092 mob.dee1eAFJ1ehds{),
1093 1s101FJ1ehds.JemoveAEemeh1s{),
1094 1J1ehdL1s1 = neW Ls1{"",Ls1.ThPLTCTT),
1095 addhewFJ1ehd = neW Commahd{"Add hew FJ1ehd",
Commahd.SCREEh,1),
1096 s1opFoow = neW Commahd{"S1op Foow FJ1ehds",
Commahd.SCREEh,1),
1097 dee1eFJ1ehds = neW Commahd{"0ee1e FJ1ehds",
Commahd.SCREEh,1),
1098 1J1ehdL1s1.addCommahd{0bhhY),
1099 1J1ehdL1s1.addCommahd{addhewFJ1ehd),
1100 1J1ehdL1s1.addCommahd{s1opFoow),
1101 1J1ehdL1s1.addCommahd{dee1eFJ1ehds),
1102 //1IIendLIs1.addConnand]|4P_C|9);
1103 1J1ehdL1s1.addCommahd{BACK_Ch0),
1104 1J1ehdL1s1.addCommahd{0ELTh),
1105 1{1s101FJ1ehds.s1ze{)>0){
1106 1or {1h1 1=0, 1<1s101FJ1ehds.s1ze{), 1++){
1107 FJ1ehd 1 =
{FJ1ehd)1s101FJ1ehds.eemeh1A1{1),
1108 Commahd cc = neW
Commahd{1.ge1hame{),Commahd.SCREEh,1),
1109 1J1ehdL1s1.addCommahd{cc),
1110 }
1111 }
1112 1J1ehdL1s1.se1CommahdL1s1eheJ{1hs),
1113 d.se1CuJJeh1{1J1ehdL1s1),
1114 d.se1CuJJeh1{1J1ehdL1s1),
1115 }
1116
1117 1{s==1J1ehdL1s1 && c!=addhewFJ1ehd && c!=s1opFoow && c!
=dee1eFJ1ehds && c!=hAP_Ch0 && c!=BACK_Ch0 && c!=0ELTh){
1118 1J1ehd = c.ge1Labe{),
1119 1J1ehd = compac1{1J1ehd),
1120 oheFJ1ehd = neW Ls1{"",Ls1.ThPLTCTT),
1121 s1opFoow0he = neW Commahd{"S1op Foow",
Commahd.SCREEh,1),
1122 dee1eFJ1ehd = neW Commahd{"0ee1e",
Commahd.SCREEh,1),
1123 oheFJ1ehd.addCommahd{0bhhY),
1124 oheFJ1ehd.addCommahd{hAP_Ch0),
1125 oheFJ1ehd.addCommahd{s1opFoow0he),
1126 oheFJ1ehd.addCommahd{dee1eFJ1ehd),
cviii
SoItware DeIects Prevention Techniques Example Project
1127 oheFJ1ehd.addCommahd{BACK_Ch0),
1128 oheFJ1ehd.se1CommahdL1s1eheJ{1hs),
1129
1130 d.se1CuJJeh1{oheFJ1ehd),
1131 }
1132
1133 1{s==1J1ehdL1s1 && c==BACK_Ch0){
1134 d.se1CuJJeh1{hvL1s1),
1135 }
1136
1137 1{s==oheFJ1ehd && c==hAP_Ch0){
1138 1or{1h1 1=0, 1<1s101FJ1ehds.s1ze{), 1++){
1139 FJ1ehd 1 =
{FJ1ehd)1s101FJ1ehds.eemeh1A1{1),
1140 1{1.ge1hame{).equas{1J1ehd)) {
1141
1142 1{1.ge1ThJead{)==1a1se){
1143 111 = neW
ThJead4FJ1ehd{wh11eL1s1,1.ge1hame{),mob,1c,mb,ou),
1144 In1eger hT0 = neW
In1eger{111.ge1T0{)),
1145 wh11eL1s1.addEemeh1{hT0),
1146 1.se1T0{111.ge1T0{)),
1147 1.se1ThJead{111),
1148 111.se1F1Js1{),
1149 111.s1aJ1{),
1150 } e1se {
1151 1.se1F1Js1{),
1152 }
1153 }
1154 }
1155 d.se1CuJJeh1{1c),
1156 }
1157
1158 1{s==oheFJ1ehd && c==BACK_Ch0){
1159 d.se1CuJJeh1{1J1ehdL1s1),
1160 }
1161
1162 1{s==oheFJ1ehd && c==s1opFoow0he){
1163 1or{1h1 1=0, 1<1s101FJ1ehds.s1ze{), 1++){
1164 FJ1ehd 1 =
{FJ1ehd)1s101FJ1ehds.eemeh1A1{1),
1165 1{1.ge1hame{).equas{1J1ehd)) {
1166 wh11eL1s1.JemoveEemeh1{neW
In1eger{1.ge1hash{))),
1167 mob.dee1eFJ1ehd{1.ge1hash{)),
1168 1.se1ThJead{nu11),
1169 }
1170 }
1171 d.se1CuJJeh1{1c),
1172 }
cix
Zarko Acimovic
1173
1174 1{s==oheFJ1ehd && c==dee1eFJ1ehd){
1175 1or{1h1 1=0, 1<1s101FJ1ehds.s1ze{), 1++){
1176 FJ1ehd 1 =
{FJ1ehd)1s101FJ1ehds.eemeh1A1{1),
1177 1{1.ge1hame{).equas{1J1ehd)) {
1178 wh11eL1s1.JemoveEemeh1{neW
In1eger{1.ge1hash{))),
1179 mob.dee1eFJ1ehd{1.ge1hash{)),
1180 1s101FJ1ehds.JemoveEemeh1A1{1),
1181 }
1182 }
1183 d.se1CuJJeh1{1c),
1184 }
1185
1186 }
1187
1188
1189 //----------------------ThIs paI1 o1 code dea1s |I1h
PS---------------------
1190 pub1c vo1d Juh{){
1191 Wh1e{1oowFJ1ehds==1rue ]] gps0h==1rue){
1192 51rng s = 1hs.ge1ResouJceAsS1J1hg{JesouJce),
1193 1h1 hex1Thdex = 6,
1194 1h1 1hdex = s.1hdex01{`\h`),
1195
1196 hex1Thdex = s.1hdex01{`\h`,1hdex+1),
1197
1198 1h1 as1Thdex = s.as1Thdex01{`\h`),
1199
1200 1h1 beg1h = -2,
1201 1h1 ehd = 1hdex,
1202
1203 51rng c1 = "",
1204 51rng c2 = "",
1205 51rng 11meS1amp = "",
1206 ohg cuJJeh1TS = 0,
1207
1208 Wh1e{1hdex<as1Thdex && gps0h==1rue){
1209 Thread 1 = Thread.cuJJeh1ThJead{),
1210 1{1.hashCode{)==cuJJeh1yShowed){
1211 /**
1212 1{synchronza1onone==1a1se &&
syncFo11oW==1rue){
1213 do{ //5ynchronza1on
1214 51rng 1emp =
s.subs1rng{begn+2,end)
1215 1emp =
compac1{1emp)
1216 n1 comma =
1emp.ndex1{`,`)
cx
SoItware DeIects Prevention Techniques Example Project
1217 c1 =
1emp.subs1rng{6,comma)
1218 n1 nex1Comma =
1emp.ndex1{`,`,comma+1)
1219 c2 =
1emp.subs1rng{comma+1,nex1Comma)
1226 1me51amp =
1emp.subs1rng{nex1Comma+1,1emp.1eng1h{))
1221 curren1T5 =
Long.parseLong{1me51amp)
1222 begn = ndex-1
1223 end = nex1Index
1224 ndex = nex1Index
1225 nex1Index =
s.ndex1{`\n`,nex1Index+1)
1226 )
Wh1e{curren1T5<1hs.ge1Tme51amp{)),
1227 syhchJoh1za11oh0ohe = 1Jue,
1228 }*/
1229
1230 Po1h1 wp = hu,
1231 11{!c1.equas{"")){
1232 wp = hew
Po1h1{c2,c1,JesouJce,"","bahco",1Jue),
1233 }
1234 11{syhcFoow==1Jue) {
1235
1h1s.se1T1meS1amp{cuJJeh1TS),
1236 }
1237
1238 S1J1hg 1emp =
s.subs1J1hg{beg1h+2,ehd),
1239 1emp = compac1{1emp),
1240 11{1emp.equas{"")){ //ha kJau ce
1emp da bude pJazho
1241 1hdex = as1Thdex+1,
1242 } ese {
1243 1emp = compac1{1emp),
1244 1h1 comma =
1emp.1hdex01{`,`),
1245 c1 =
1emp.subs1J1hg{0,comma),
1246 1h1 hex1Comma =
1emp.1hdex01{`,`,comma+1),
1247 c2 =
1emp.subs1J1hg{comma+1,hex1Comma),
1248 11meS1amp =
1emp.subs1J1hg{hex1Comma+1,1emp.ehg1h{)),
1249 cuJJeh1TS =
Lohg.paJseLohg{11meS1amp),
1250
cxi
Zarko Acimovic
1251 beg1h = 1hdex-1,
1252 ehd = hex1Thdex,
1253 1hdex = hex1Thdex,
1254 hex1Thdex =
s.1hdex01{`\h`,hex1Thdex+1),
1255 }
1256
1257 1Jy{
1258 ThJead.seep{1000),
1259 }ca1ch{Excep11oh e){}
1260
1261 11{wp!=hu){
1262 mob.se10JawabePo1h1s{),
1263 11{gps0h==1Jue){
1264
mob.se1CuJJeh1Pos111oh{wp),
1265
11{{mob.ge1CuJJeh1Pos111oh{).ge1X{)>176 || mob.ge1Curren1Pos1on{).ge1Y{)>166 ||
1266
mob.ge1Curren1Pos1on{).ge1X{)<16 || mob.ge1Curren1Pos1on{).ge1Y{)<16) &&
ou1.ge15e1ec1{)==1a1se )
1267
mb.se1ackground{Wp)
1268
c.repan1{)
1269
1276 )
1271 )
1272 )
1273 )
1274 )
1275
1276 )
1277
1278 /**
1279 * Qsee NI1e1#pauseApp{)
1286 */
1281 pro1ec1ed vo1d pauseApp{) {
1282 }
1283
1284 /**
1285 * Qsee NI1e1#des1royApp{boo1ean)
1286 */
1287 pro1ec1ed vo1d des1JoyApp{booeah 1ag) 1hroWs
hT0e1S1a1eChahgeExcep11oh {
1288 }
1289
1290
1291 /** 1anco charac1ers are possb1e 1o occur n names o1 pc1ures
1292 * In1eger represen1a1ons o1 b1anko charac1ers are 9 and 32
1293 * A1so, charac1ers W1h n1eger represen1a1on be1Ween 6 and 33
cxii
SoItware DeIects Prevention Techniques Example Project
1294 * can no1 be prn1ed ou1 n W5 conso1e, so I exc1uded 1hem 1oo
1295 */
1296 pub1c 51rng compac1{51rng s){
1297 1h1 k = s.ehg1h{),
1298 chaJ|] d = s.1oChaJAJJay{),
1299 51rng Je1 = "",
1300 1or{1h1 1=0, 1<d.ehg1h, 1++){
1301 1h1 1emp = {1h1)d|1],
1302 1{1emp>32) Je1+=d|1],
1303 }
1304 1h1 kk = Je1.ehg1h{),
1305 re1urn Je1,
1306 }
1307
1308 pub1c 51rng compac1F1he{51rng s){
1309 1h1 k = s.ehg1h{),
1310 chaJ|] d = s.1oChaJAJJay{),
1311 51rng Je1 = "",
1312 1or{1h1 1=0, 1<d.ehg1h, 1++){
1313 1h1 1emp = {1h1)d|1],
1314 1{1emp!=32 && 1emp!=9) Je1+=d|1],
1315 }
1316 1h1 kk = Je1.ehg1h{),
1317 re1urn Je1,
1318 }
1319
1320 pub1c 51rng ge1ResouJceAsS1J1hg{51rng JesouJce){
1321 Inpu151ream 1s = nu11,
1322 1ry{
1323 1s = 1hs.ge1Cass{).ge1ResouJceAsS1Jeam{JesouJce),
1324 }ca1ch{Excep1on e) {
1325 a.se1S1J1hg{"TheJe 1s ho such JesouJce"),
1326 d.se1CuJJeh1{a),
1327 }
1328
1329 //conveIsIon o1 IesouIce In1o s1IIng
1330 51rng s = "",
1331 chaJ m =` `,
1332
1333 1ry{
1334 m = {chaJ)1s.Jead{),
1335 }ca1ch{Excep1on e){}
1336
1337 Wh1e{m!=65535){
1338 s+=m,
1339 1ry{
1340 m = {chaJ)1s.Jead{),
1341 }ca1ch{Excep1on e){}
1342 }
1343 1ry{
1344 1s.cose{),
cxiii
Zarko Acimovic
1345 }ca1ch{Excep1on e){}
1346
1347
1348 s=compac1F1he{s),
1349 re1urn s,
1350 }
1351
1352 pub1c ohg ge1T1meS1amp{){
1353 re1urn gobaT1meS1amp,
1354 }
1355
1356 pub1c vo1d se1T1meS1amp{ohg 1ms){
1357 gobaT1meS1amp = 1ms,
1358 }
1359
1360 pub1c vo1d se1WPL1s1{){
1361 WPL1s1 = neW Ls1{"",Ls1.ThPLTCTT),
1362 WPL1s1.addCommahd{0bhhY),
1363 WPL1s1.addCommahd{addhewWP),
1364 WPL1s1.addCommahd{soJ1WP),
1365 WPL1s1.addCommahd{soJ1hameWP),
1366 WPL1s1.addCommahd{showT0com),
1367 WPL1s1.addCommahd{BACK_Ch0),
1368 WPL1s1.addCommahd{0ELTh),
1369 WPL1s1.se1CommahdL1s1eheJ{1hs),
1370
1371 }
1372 }
1373
1374
1375
cxiv

Vous aimerez peut-être aussi