Академический Документы
Профессиональный Документы
Культура Документы
MapsMIDlet
MapBackground
Outlook
DelRoute
MapObjects
CompassCanvas
PVector
Point
MathFP
ImageCanvas3
TextFormFriend
TextFormWP
TextForm
Thread4Friend
MapsMIDlet
SelectorPoint
Friend
SimpleTextForm
MapBackgroundFactory
HeapSorter
TextFormImage
Coordinates
CommaHyphenString
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
Zarko Acimovic
Copyright 2013 Zarko Acimovic
All rights reserved.
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
DEDICATION
I dedicate this book to my parents, Ivana and Goran
CONTENTS
1
Introduction
METRICS
170
Zarko Acimovic
1 INTRODUCTION
I present 5000 lines of Java source code mostly written by using trial-error, code-test, design-at-keyboard
techniques without using VizzMaintenance defect prevention tool. After the project was written,
VizzMaintenace tool was run against it and delivered report for it. Each class is preceded with VizzMaintenace
report and comment about class design issue based on VizzMaintenance judgment.
The code was written for prototype project in three months. I wrote the code in 2004 and ever since had several
business offers to commercialize it which I resisted due to complexity of the code.
I recommend readers to switch to formal software development, such as B, Event-B, VDM or Z.
Static analysis of source code defect prevention method has efficiency 44%. Defect potential per 1 FP was
5, after implementing this method is 2.8.
Tool: Coverity
Mathematical test case design defect prevention efficiency was 34%. Defect potential per 1 FP is 5, after
is 3.3.
Tool: Bullseye
Bonus: Root cause analysis 1044-1993 - IEEE Standard Classification for Software Anomalies. Efficiency
41% - Before 5 After 2.95
Source: Chapter 3. Estimating and Measuring Software Quality. The Economics of Software Quality, ISBN:
9780132564762 , Capers Jones, Olivier Bonsignour
iv
http://www.amazon.com/Economics-Software-Quality-Capers-Jones/dp/0132582201
http://www.informit.com/store/product.aspx?isbn=0132582201
Tools used: Sun J2ME Wireless Toolkit, Eclipse, IBM WebSphere Device Developer 5.5, CVS, Motorola and
Nokia phone emulators and SDKs. Technology: J2ME, MIDP 2.0, CLDC 1.1.
Device-independent Java 2 Micro Edition (J2ME) midlet, executable in any emulator or mobile device, for
displaying map with scale, following moving objects, zoom in-out and pan, selection of location , measuring
distance, following individual or vehicle on map with route presentation, presentation of waypoints on map,
presentation of list of existing waypoints (sorted by name, type, distance) for selecting destination or editing and
deletion, creating, editing and deletion of waypoint points with coordinates, name, type, icon; coordinates are
defined by current position, selected location on map or inserted in textual form, selection of waypoint as
destination and navigation towards that destination. Some classes implemented: MapBackground, MapObject,
v
Zarko Acimovic
Complexity
Size
Lines of Code (LOC)
Interface Complexity
Number of Attributes and Methods (SIZE2)
Number Of local Methods (NOM)
Structural Complexity
McCabe Cyclomatic Complexity (CC)
Weighted Method Count (WMC)
Response For a Class (RFC)
vi
vii
Zarko Acimovic
Class Name
MapsMIDlet
MapBackground
Outlook
DelRoute
MapObjects
CompassCanvas
PVector
Point
MathFP
ImageCanvas3
TextFormFriend
TextFormWP
TextForm
Thread4Friend
MapsMIDlet
SelectorPoint
Friend
SimpleTextForm
MapBackgroundFactory
HeapSorter
TextFormImage
Coordinates
CommaHyphenString
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
6 SOURCE CODE
As you can see in the above table the problem with below CommaHyphenString class is that LD metric is zero.
From http://www.arisa.se/compendium/node112.html we learn more about Loclity of Data metric:
The Locality of Data metric relates the amount of data being local the class to the total amount of data used by the
class. This relates to the quality of abstraction embodied by the class and allows conclusions on the reuse potential
of the class and testability. To find out precisely how this metric is calculated and how it affects software quality
attributes such as testability or maintainability please check http://www.arisa.se/compendium/node112.html
Also there is problem with Tight Class Cohesion. The Tight Class Cohesion metric measures the cohesion
between the public methods of a class. That is the relative number of directly connected public methods in the
class. Classes having a low cohesion indicate errors in the design. http://www.arisa.se/compendium/node118.html
/**
*
* CommaHyphenString parses .properties file. It eliminates commas or low
lines
4
* from .properties file so items in it( such as categories) could be
properly
5
* showed on screen
6
*/
7 import java.util.*;
8
9 public class CommaHyphenString {
10
11
//String s;
12
int lastIndex;
viii
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
CommaHyphenString(){}
Zarko Acimovic
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
Class Name
MapsMIDlet
MapBackground
Outlook
DelRoute
MapObjects
CompassCanvas
PVector
Point
MathFP
ImageCanvas3
TextFormFriend
TextFormWP
TextForm
Thread4Friend
MapsMIDlet
SelectorPoint
Friend
SimpleTextForm
MapBackgroundFactory
HeapSorter
TextFormImage
Coordinates
CommaHyphenString
*/
String[] getCategoriesHyphen(String s){
return this.getWithLowLine(s);
}
/** Returns categories
* @return String[]
*/
String[] getCategories(String s){
return this.getStringsOnly(s);
}
/** Defines index of last comma in string
* @return integer
*/
public int defineLast(String s){
int lastIndex = 0;
char c[] = s.toCharArray();
for (int i=0; i<c.length; i++){
if(c[i]==',') lastIndex=i;
}
return lastIndex;
}
}
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
Complexity
Size
Lines of Code (LOC)
Interface Complexity
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
xi
Zarko Acimovic
Documentation
Lack Of Documentation (LOD)
Code Conventions
As you can see on the above table the problem with below class CompassCanvas is that LOD metric is zero. Lack
Of Documentation description: How many comments are lacking in a class, considering one class comment and a
comment per method as optimum. Structure and content of the comments are ignored. To find out how this metric
is calculated please check http://www.arisa.se/compendium/node121.html .
/**
*
* ComapssCanvas draws compass on screen
*/
import javax.microedition.lcdui.*;
//import javax.microedition.midlet.*;
=
=
=
=
0;
0;
0;
0;
Image imgDest;
long destUp;
long destDown;
long gama;
xii
Zarko Acimovic
81
sy = sy.substring(0,iy);
82
83
int x = Integer.parseInt(sx);
84
int y = Integer.parseInt(sy);
85
86
String s9 =
MathFP.toString(MathFP.add(MathFP.toFP(93),MathFP.mul(MathFP.toFP(smallestRadius),M
athFP.sin(MathFP.sub(north,delta)))));
87
ix = s9.indexOf('.');
88
s9 = s9.substring(0,ix);
89
int NX = Integer.parseInt(s9);
90
String s10 =
MathFP.toString(MathFP.sub(MathFP.toFP(85),MathFP.mul(MathFP.toFP(smallestRadius),M
athFP.cos(MathFP.sub(north,delta)))));
91
iy = s10.indexOf('.');
92
s10 = s10.substring(0,iy);
93
int NY = Integer.parseInt(s10);
94
95
g.drawString("N",x,y,0);
96
97
sx =
MathFP.toString(MathFP.add(MathFP.toFP(93),MathFP.mul(MathFP.toFP(75),MathFP.sin(Ma
thFP.sub(south,delta)))));
98
sy =
MathFP.toString(MathFP.sub(MathFP.toFP(85),MathFP.mul(MathFP.toFP(75),MathFP.cos(Ma
thFP.sub(south,delta)))));
99
ix = sx.indexOf('.');
100
sx = sx.substring(0,ix);
101
iy = sy.indexOf('.');
102
sy = sy.substring(0,iy);
103
104
x = Integer.parseInt(sx);
105
y = Integer.parseInt(sy);
106
107
String s11 =
MathFP.toString(MathFP.add(MathFP.toFP(93),MathFP.mul(MathFP.toFP(smallestRadius),M
athFP.sin(MathFP.sub(south,delta)))));
108
ix = s11.indexOf('.');
109
s11 = s11.substring(0,ix);
110
int SX = Integer.parseInt(s11);
111
String s12 =
MathFP.toString(MathFP.sub(MathFP.toFP(85),MathFP.mul(MathFP.toFP(smallestRadius),M
athFP.cos(MathFP.sub(south,delta)))));
112
iy = s12.indexOf('.');
113
s12 = s12.substring(0,iy);
114
int SY = Integer.parseInt(s12);
115
116
117
118
g.drawString("S",x,y,0);
119
int del = 0;
xiv
Zarko Acimovic
159
x = Integer.parseInt(sx);
160
y = Integer.parseInt(sy);
161
162
g.drawString("E",x,y,0);
163
164
sx =
MathFP.toString(MathFP.add(MathFP.toFP(93),MathFP.mul(MathFP.toFP(75),MathFP.sin(Ma
thFP.sub(west,delta)))));
165
sy =
MathFP.toString(MathFP.sub(MathFP.toFP(85),MathFP.mul(MathFP.toFP(75),MathFP.cos(Ma
thFP.sub(west,delta)))));
166
ix = sx.indexOf('.');
167
sx = sx.substring(0,ix);
168
iy = sy.indexOf('.');
169
sy = sy.substring(0,iy);
170
171
x = Integer.parseInt(sx);
172
y = Integer.parseInt(sy);
173
174
g.drawString("W",x,y,0);
175
176
177
178
179
gama = MathFP.sub(delta,gama);
180
//gama = MathFP.toFP("314");
181
long gamaDegrees =
Coordinates.radiansToDegrees(gama);
182
//long gamaDegrees = gama;
183
//System.out.println("gama="+MathFP.toString(gamaDegrees));
184
//gama = Coordinates.degreesToRadians(gama);
185
186
long corrX =
MathFP.add(MathFP.toFP(93),MathFP.mul(MathFP.toFP(smallestRadius),MathFP.sin(MathFP
.sub(destUp,gama))));
187
long corrY =
MathFP.sub(MathFP.toFP(85),MathFP.mul(MathFP.toFP(smallestRadius),MathFP.cos(MathFP
.sub(destUp,gama))));
188
189
long dx = 0;
190
long dy = 0;
191
192
if(gamaDegrees<=0) {
193
gama =
MathFP.add(gama,Coordinates.MathFP_2PI);
194
gamaDegrees =
MathFP.add(gamaDegrees,MathFP.toFP("360"));
195
}
196
197
// Correction of position for imgDest
xvi
xvii
Zarko Acimovic
230
if(MathFP.toFP("275")<=gamaDegrees &&
gamaDegrees<=MathFP.toFP("360")){
231
dx = 0MathFP.mul(MathFP.toFP("8"),MathFP.cos(gama));
232
dy = 0MathFP.mul(MathFP.toFP("25"),MathFP.cos(gama));
233
234
}
235
236
237
238
239
long prevCorrX=corrX;
240
long prevCorrY=corrY;
241
242
corrX = MathFP.add(corrX,dx);
243
corrY = MathFP.add(corrY,dy);
244
245
246
247
sx = MathFP.toString(corrX);
248
sy = MathFP.toString(corrY);
249
ix = sx.indexOf('.');
250
sx = sx.substring(0,ix);
251
iy = sy.indexOf('.');
252
sy = sy.substring(0,iy);
253
int xbear1 = Integer.parseInt(sx);
254
int ybear1 = Integer.parseInt(sy);
255
256
257
sx = MathFP.toString(prevCorrX);
258
sy = MathFP.toString(prevCorrY);
259
ix = sx.indexOf('.');
260
sx = sx.substring(0,ix);
261
iy = sy.indexOf('.');
262
sy = sy.substring(0,iy);
263
int xbear3 = Integer.parseInt(sx);
264
int ybear3 = Integer.parseInt(sy);
265
266
267
268
sx =
MathFP.toString(MathFP.add(MathFP.toFP(93),MathFP.mul(MathFP.toFP(smallestRadius),M
athFP.sin(MathFP.sub(destDown,gama)))));
269
sy =
MathFP.toString(MathFP.sub(MathFP.toFP(85),MathFP.mul(MathFP.toFP(smallestRadius),M
athFP.cos(MathFP.sub(destDown,gama)))));
270
271
272
ix = sx.indexOf('.');
273
sx = sx.substring(0,ix);
xviii
iy = sy.indexOf('.');
sy = sy.substring(0,iy);
int xbear2 = Integer.parseInt(sx);
int ybear2 = Integer.parseInt(sy);
g.drawLine(xbear2,ybear2,xbear3,ybear3);
g.drawImage(imgDest,xbear1,ybear1,0);
}
}
public void run(){
while(end == false){
delta = mob.getDirection();
gama = mob.getBearing();
repaint();
try{
Thread.sleep(100);
}catch(Exception e){}
}
}
public void setEnd(){
end = true;
}
}
xix
Zarko Acimovic
Class Name
MapsMIDlet
MapBackground
Outlook
DelRoute
MapObjects
CompassCanvas
PVector
Point
MathFP
ImageCanvas3
TextFormFriend
TextFormWP
TextForm
Thread4Friend
MapsMIDlet
SelectorPoint
Friend
SimpleTextForm
MapBackgroundFactory
HeapSorter
TextFormImage
Coordinates
CommaHyphenString
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
Complexity
Size
Lines of Code (LOC)
Interface Complexity
Number of Attributes and Methods (SIZE2)
Number Of local Methods (NOM)
Structural Complexity
McCabe Cyclomatic Complexity (CC)
Weighted Method Count (WMC)
Response For a Class (RFC)
xx
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
As you can see on above table, Coordinates class has problem with metrics LD and TCC. TCC or Tight Class
Cohesion Description: The Tight Class Cohesion metric measures the cohesion between the public methods of a
class. That is the relative number of directly connected public methods in the class. Classes having a low cohesion
indicate errors in the design. http://www.arisa.se/compendium/node118.html
Locality of Data. Description. The Locality of Data metric relates the amount of data being local the class to the
total amount of data used by the class. This relates to the quality of abstraction embodied by the class and allows
conclusions on the reuse potential of the class and testability. http://www.arisa.se/compendium/node112.html
1
2
3
4
5
6
7
8
/**
*
* Coordinates class different performs geographical calculations
*/
//import net.jscience.math.MathFP;
xxi
Zarko Acimovic
Zarko Acimovic
100
* @param lonTo longitude of the second point
101
* @return long representing angle in degrees [0,360) between
corresponding meridian in first point and line on the Great Circle between those
points
102
*/
103
protected static long bearing(long latFrom, long lonFrom, long latTo,
long lonTo){
104
//BMa: Some numeric with MathFP still happen - but error is mostly
below 16 degrees
105
// This should be fixed only if the final target device stays without
not have floats or doubles (e.g. it is not CLDC 1.1)
106
long bearing;
107
long deltaLat=latTo-latFrom;
108
long deltaLon=lonTo-lonFrom;
109
if (MathFP.abs(deltaLat)<MathFP_1 && MathFP.abs(deltaLon)<MathFP_1) {
110
// longiude and latitude distance within one deegre, could invent
better condition
111
//This approximation works better for smaller distances
112
latFrom = degreesToRadians(latFrom);
113
deltaLon=MathFP.mul(deltaLon, MathFP.cos(latFrom));
114
bearing = MathFP.atan2(deltaLat,deltaLon);
115
}else{
116
latFrom = degreesToRadians(latFrom);
117
latTo = degreesToRadians(latTo);
118
lonFrom = degreesToRadians(lonFrom);
119
lonTo = degreesToRadians(lonTo);
120
121
122
if (latFrom==latTo && lonFrom==lonTo)
123
return 0;
124
//if (MathFP.cos(latFrom) < Double.MIN_VALUE)
// Double.MIN_VALUE a
small number ~ machine precision, so here we check for +/-0
125
if (MathFP.cos(latFrom) == 0 )
// Double.MIN_VALUE a small number ~
machine precision, so here we check for +/-0
126
if (latFrom > 0)
127
return MathFP.PI;
// starting from N pole
128
else
129
return MathFP_2PI;
// starting from S pole
130
//double bearing = radiansToDegrees(Math.atan2(Math.sin(lon2lon1)*Math.cos(lat2),Math.cos(lat1)*Math.sin(lat2)Math.sin(lat1)*Math.cos(lat2)*Math.cos(lon2-lon1))%(2*Math.PI));
131
132
bearing = MathFP.atan2(
133
MathFP.mul(MathFP.sin(deltaLon),MathFP.cos(latTo)),
134
MathFP.mul(MathFP.cos(latFrom),MathFP.sin(latTo))135
MathFP.mul(MathFP.mul(MathFP.sin(latFrom),MathFP.cos(latTo)),MathFP.cos(deltaLon)))
;
136
}
137
bearing = MathFP.mod(radiansToDegrees(bearing), MathFP_360);
138
xxiv
Zarko Acimovic
179
Math.sqrt(
180
Math.pow(Math.sin((lat1-lat2)/2), 2)
181
+
182
Math.cos(lat1)*Math.cos(lat2)*Math.pow(Math.sin((lon2-lon1)/2), 2)
183
)
184
);
185
*/
186
187 /*
188
System.out.print("latFrom: "+MathFP.toString(latFrom));
189
System.out.println(" lonFrom: "+MathFP.toString(lonFrom));
190
System.out.print("latTo: "+MathFP.toString(latTo));
191
System.out.println(" lonTo: "+MathFP.toString(lonTo));
192
*/
193
194
long p1=MathFP.sin(MathFP.div((latFrom-latTo), MathFP_2));
195
p1 = MathFP.mul(p1, MathFP.toFP(1000000));
196
//System.out.println(" p1: "+MathFP.toString(p1));
197
p1 = MathFP.mul(p1, p1);
198
//System.out.println(" p1: "+MathFP.toString(p1));
199
200
long p2=MathFP.sin(MathFP.div((lonTo-lonFrom), MathFP_2));
201
p2 = MathFP.mul(p2, MathFP.toFP(1000000));
202
//System.out.println(" p2: "+MathFP.toString(p2));
203
p2 = MathFP.mul(p2, p2);
204
//System.out.println(" p2: "+MathFP.toString(p2));
205
206
long sqrtarg=p1
+MathFP.mul(MathFP.mul(MathFP.cos(latFrom),MathFP.cos(latTo)),p2);
207
//System.out.println(" sqrtarg: "+MathFP.toString(sqrtarg));
208
209
sqrtarg=MathFP.sqrt(sqrtarg);
210
//System.out.println(" sqrtarg: "+MathFP.toString(sqrtarg));
211
212
long distance;
213
if (sqrtarg>MathFP.toFP(19000)) { //toFP("0.019")*1000000 - boundary
for MathFP.asin approximation by X
214
// calculation is erroneus for small angles
215
long asinarg=MathFP.div(sqrtarg, MathFP.toFP(1000000));
216
//System.out.println(" > asinarg: "+MathFP.toString(asinarg));
217
asinarg=MathFP.asin(asinarg);
218
//System.out.println(" > asinarg: "+MathFP.toString(asinarg));
219
distance = MathFP.mul(EARTH_RADIUS2, asinarg);
220
//System.out.println(" distance asin: "+MathFP.toString(distance));
221
} else {
222
//asin(X) is aproximately equall to X,
223
//This approximation allow us to change the order of multiplication
and division in order to reduce loss of significant digits
224
225
distance = MathFP.mul(EARTH_RADIUS2, sqrtarg);
xxvi
xxvii
Zarko Acimovic
Class Name
MapsMIDlet
MapBackground
Outlook
DelRoute
MapObjects
CompassCanvas
PVector
Point
MathFP
ImageCanvas3
TextFormFriend
TextFormWP
TextForm
Thread4Friend
MapsMIDlet
SelectorPoint
Friend
SimpleTextForm
MapBackgroundFactory
HeapSorter
TextFormImage
Coordinates
CommaHyphenString
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
Complexity
Size
Lines of Code (LOC)
Interface Complexity
Number of Attributes and Methods (SIZE2)
Number Of local Methods (NOM)
Structural Complexity
xxviii
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
xxix
Zarko Acimovic
xxx
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
Complexity
Size
Lines of Code (LOC)
Interface Complexity
Number of Attributes and Methods (SIZE2)
Number Of local Methods (NOM)
Structural Complexity
McCabe Cyclomatic Complexity (CC)
Weighted Method Count (WMC)
Response For a Class (RFC)
xxxi
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
Zarko Acimovic
Friend class has problem with Lack of Documentation. Lack Of Documentation Description. How many
comments are lacking in a class, considering one class comment and a comment per method as optimum.
Structure and content of the comments are ignored. http://www.arisa.se/compendium/node121.html
1
2
3
4
5
6
7
8
9
10
/**
*
* Friend class holds all important data for a friend
*/
public class Friend {
String name;
String resource;
int hashThread;
Thread4Friend t;
xxxii
t){
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
this.name = name;
this.resource = resource;
this.hashThread = hashThread;
this.t = t;
}
public String getName(){
return name;
}
public String getResource(){
return resource;
}
public int getHash(){
return hashThread;
}
public void setID(int hash){
hashThread = hash;
}
public String toString(){
return "Friend is "+name+"\n"+"Hash is "+hashThread;
}
public void setFirst(){
t.setFirst();
}
public boolean getThread(){
if (t==null){ return false; }
else {return true; }
}
public void setThread(Thread4Friend t){
this.t = t;
}
}
xxxiii
Zarko Acimovic
Class Name
MapsMIDlet
MapBackground
Outlook
DelRoute
MapObjects
CompassCanvas
PVector
Point
MathFP
ImageCanvas3
TextFormFriend
TextFormWP
TextForm
Thread4Friend
MapsMIDlet
SelectorPoint
Friend
SimpleTextForm
MapBackgroundFactory
HeapSorter
TextFormImage
Coordinates
CommaHyphenString
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
Complexity
Size
Lines of Code (LOC)
Interface Complexity
Number of Attributes and Methods (SIZE2)
Number Of local Methods (NOM)
Structural Complexity
McCabe Cyclomatic Complexity (CC)
xxxiv
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
xxxv
Zarko Acimovic
HeapSorter class has problem with LD, TCC and LOD: Lack Of Documentation Description. How many
comments are lacking in a class, considering one class comment and a comment per method as optimum.
Structure and content of the comments are ignored. http://www.arisa.se/compendium/node121.html
Tight Class Cohesion Description
The Tight Class Cohesion metric measures the cohesion between the public methods of a class. That is the
relative number of directly connected public methods in the class. Classes having a low cohesion indicate errors
in the design. http://www.arisa.se/compendium/node118.html
HeapSorter.java source code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
*
* HeapSorter class sorts points by distance or by name
*/
public class HeapSorter{
HeapSorter(){}
public void heapsort(long[] a){
long[]A = setHeapWithSize(a,a.length);
buildHeap(A);
for(int i=0; i<A.length; i++){
System.out.println(A[i]);
}
for(int i=a.length; i>1; i--){
a[i-1]=A[0]; A[0]=A[i-1];
A=setHeapWithSize(A,A.length-1);
heapify(A,1);
}
a[0]=A[0];
}
public void heapsort(String[] as){
String[] AS = setHeapWithSize(as,as.length);
buildHeap(AS);
for(int i=0; i<AS.length; i++){
System.out.println(AS[i]);
}
for(int i=as.length; i>1; i--){
as[i-1]=AS[0]; AS[0]=AS[i-1];
AS=setHeapWithSize(AS,AS.length-1);
heapify(AS,1);
}
as[0]=AS[0];
xxxvi
}
public void buildHeap(long[] a){
for(int i=a.length/2; i>0; i--) heapify(a,i);
}
public void buildHeap(String[] as){
for(int i=as.length/2; i>0; i--) heapify(as,i);
}
public void
int
int
int
Zarko Acimovic
84
as[largest-1]=tmpS;
85
86
87
}
88
89
90
public
91
92
}
93
94
public
95
96
}
97
98
public
99
100
}
101
102
public
103
104
}
105
106
public
107
108
}
109
110
public
111
112
113
114
115
116
}
117
118
public
119
120
121
122
123
124
}
125 };
xxxviii
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
Complexity
Size
Lines of Code (LOC)
Interface Complexity
Number of Attributes and Methods (SIZE2)
Number Of local Methods (NOM)
Structural Complexity
McCabe Cyclomatic Complexity (CC)
Weighted Method Count (WMC)
Response For a Class (RFC)
xxxix
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
Zarko Acimovic
ImageCnavas3 lacks documentation. Lack Of Documentation Description. How many comments are lacking in a
class, considering one class comment and a comment per method as optimum. Structure and content of the
comments are ignored. http://www.arisa.se/compendium/node121.html
ImageCanvas3.java source code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/**
*
* ImageCanvas3 draws elements on screen and captures events on canvas
*/
//import java.io.IOException;
import javax.microedition.lcdui.*;
//import java.util.*;
public class ImageCanvas3 extends Canvas {
Outlook ol;
ImageCanvas3(Outlook ol){
xl
this.ol =ol;
ol.setCanvasWH(this.getWidth(),this.getHeight());
}
public void paint(Graphics g) {
ol.drawOutlook(g);
}
public void keyPressed (int keyCode){
//keyCode+=disabler;
if(keyCode==49){
ol.ZoomIn();
repaint();
}
if(keyCode==50){
ol.ZoomOut();
repaint();
}
if(keyCode==51){
repaint();
}
switch (getGameAction(keyCode)) {
case Canvas.UP:
ol.setMap('u');
repaint();
break;
case Canvas.DOWN:
ol.setMap('d');
repaint();
break;
case Canvas.LEFT:
ol.setMap('l');
repaint();
break;
case Canvas.RIGHT:
ol.setMap('r');
repaint();
break;
}
}
}
xli
Zarko Acimovic
Class Name
MapsMIDlet
MapBackground
Outlook
DelRoute
MapObjects
CompassCanvas
PVector
Point
MathFP
ImageCanvas3
TextFormFriend
TextFormWP
TextForm
Thread4Friend
MapsMIDlet
SelectorPoint
Friend
SimpleTextForm
MapBackgroundFactory
HeapSorter
TextFormImage
Coordinates
CommaHyphenString
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
Complexity
Size
Lines of Code (LOC)
Interface Complexity
Number of Attributes and Methods (SIZE2)
Number Of local Methods (NOM)
Structural Complexity
McCabe Cyclomatic Complexity (CC)
xlii
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
xliii
Zarko Acimovic
1 /**
2
*
3
* MapBackground transforms map according to user actions, zoom In, zoom
out or pan
4
*/
5 import java.util.*;
6 import java.io.*;
7 import javax.microedition.lcdui.*;
8
9
10 public class MapBackground {
11
12
/** Current JPEG Background of map
13
*/
14
private Image img;
15
16
/** Images for Different Zoom Levels;
17
*/
18
private Image[] zoomImg = new Image[3];
19
20
private int zoomLevel = 0;
21
22
/** Width of current background image
23
*/
24
private long sizeX;
25
26
/** Height of current background image
27
*/
28
private long sizeY;
29
30
31
/** Float-point value of upper limit
32
*/
33
private long upLat;
34
35
/** Float-point value of lower limit
36
*/
37
private long downLat;
38
39
/** Side of upper limit
40
*/
41
//private char upNS;
42
43
/** Side of lower limit
44
*/
xliv
xlv
Zarko Acimovic
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
Point downEnd;
/** Character that represents side of Pan
*/
char sidePan;
/** x-coordinate of begining of image
*/
long x = 0;
/** y-coordinate of begining of image
*/
long y = 0;
/** Indicates beginning of pan range verticaly
*/
boolean reachBeginV = true;
/** Indicates end of pan range verticaly
*/
boolean reachEndV = false;
/** Indicates beginning of pan range horizontaly
*/
boolean reachBeginH = true;
/** Indicates end of pan range horizontaly
*/
boolean reachEndH = false;
/** Step of panning
*/
long step = 30;
/** Counter of shifts vertically
*/
long movV=0;
/** Counter of shifts horizontally
*/
long movH=0;
/** Name of smallest image
*/
String[] imgArray = new String[3];
/** Canvas Height
*/
private long canvasHeight;
/** Canvas Width
xlvii
Zarko Acimovic
198
*/
199
private long canvasWidth;
200
201
202
long previousPixLat;
203
long previousPixLon;
204
205
long minX;
206
long minY;
207
208
boolean param = false;
209
210
211
MapBackground( String name0, String name1, String name2,
212
String latStr1,
213
String lonStr1,
214
String latStr2,
215
String lonStr2 ) {
216
if(MathFP.toFP(latStr1)>MathFP.toFP(latStr2)){
217
this.upLat
= MathFP.toFP(latStr1);
218
this.downLat = MathFP.toFP(latStr2);
219
} else {
220
this.upLat
= MathFP.toFP(latStr2);
221
this.downLat = MathFP.toFP(latStr1);
222
}
223
224
if(MathFP.toFP(lonStr1)>MathFP.toFP(lonStr2)){
225
this.leftLon = MathFP.toFP(lonStr2);
226
this.rightLon = MathFP.toFP(lonStr1);
227
} else {
228
this.leftLon
= MathFP.toFP(lonStr1);
229
this.rightLon = MathFP.toFP(lonStr2);
230
}
231
232
233
imgArray[0] = name0;
234
imgArray[1] = name1;
235
imgArray[2] = name2;
236
237
try {
238
zoomImg[0] = Image.createImage(imgArray[0]);
239
} catch (IOException e) {}
240
241
img = zoomImg[0];
242
sizeX = img.getWidth();
243
sizeY = img.getHeight();
244
245
newEdge = new
Point(MathFP.toString(upLat),MathFP.toString(leftLon),"newEdge","","blanco",false);
246
xlviii
Zarko Acimovic
292
293
/** Returns total number of seconds for LEFT LONGITUDE
294
* @return int
295
*/
296
public long getLonSec() {
297
return this.totLonSec;
298
}
299
300
/** Returns total number of seconds for UPPER LATITUDE
301
* @return int
302
*/
303
public long getLatSec() {
304
return this.totLatSec;
305
}
306
307
308
/** Returns Canvas height
309
*
310
* @return int
311
*/
312
public long getCanvasHeight(){
313
return canvasHeight;
314
}
315
316
/** Returns Canvas width
317
*
318
* @return int
319
*/
320
public long getCanvasWidth(){
321
return canvasWidth;
322
}
323
324
/** Sets newEdge; new Edge is created every time when user pans or zooms
map ;
325
* newEdge represents Point of upper left corner of visible screen (x=0
and
326
* y=0 for newEdge)
327
*
328
* @return Point
329
*/
330
public void setNewEdge(){
331
previousEdge = newEdge;
332
333
long tt1 =
MathFP.mul(this.getPixLat(),MathFP.toFP(Math.abs(this.getY())));
334
long tt2 =
MathFP.mul(this.getPixLon(),MathFP.toFP(Math.abs(this.getX())));
335
336
newEdge = new Point(MathFP.sub(this.getLatSec(),tt1),
337
MathFP.add(this.getLonSec(),tt2),"","",false);
l
}
/** Returns new edge
*/
public Point getNewEdge(){
return newEdge;
}
/** Returns down End
*/
public Point getDownEnd(){
return downEnd;
}
/** Returns new Edge as String
*
* @return String
*/
public String getNEdgeStr(){
return newEdge.toString();
}
Zarko Acimovic
389
x+=((this.img.getWidth()-canvasWidth)/step);
390
if(x>0) x=0;
391
movH--;
392
reachEndH=false;
393
if(movH==0) reachBeginH=true;
394
}
395
396
}
397
398
if (side=='r'){
399
if(reachEndH==false) {
400
x-=((this.img.getWidth()-canvasWidth)/step);
401
movH++;
402
reachBeginH=false;
403
if(movH==step) reachEndH=true;
404
405
}
406
}
407
408
this.setNewEdge();
409
410
}
411
412
413
/** returns x-coordinate of begining of Image
414
*/
415
public long getX(){
416
return x;
417
}
418
419
/** returns y-coordinate of begining of Image
420
*/
421
public long getY(){
422
return y;
423
}
424
425
/** Zoom In
426
*/
427
public boolean ZoomIn(){
428
boolean zoom = false;
429
if(zoomLevel<2){
430
zoom = true;
431
this.setPreviousEdge();
432
433
zoomLevel++;
434
if (zoomImg[zoomLevel]==null){
435
try{
436
zoomImg[zoomLevel] =
Image.createImage(imgArray[zoomLevel]);
437
} catch(Exception e){}
438
}
lii
this.img = zoomImg[zoomLevel];
this.sizeX = this.img.getWidth();
this.sizeY = this.img.getHeight();
this.setPixels();
x=0-(((this.img.getWidth()-canvasWidth)/step)*movH);
y=0-(((this.img.getHeight()-canvasHeight)/step)*movV);
this.setNewEdge();
}
return zoom;
}
/** Zoom Out
*/
public boolean ZoomOut(){
boolean zoom = false;
if(zoomLevel>0){
zoom = true;
this.setPreviousEdge();
zoomLevel--;
this.img = zoomImg[zoomLevel];
this.sizeX = this.img.getWidth();
this.sizeY = this.img.getHeight();
this.setPixels();
x=0-(((this.img.getWidth()-canvasWidth)/step)*movH);
y=0-(((this.img.getHeight()-canvasHeight)/step)*movV);
this.setNewEdge();
}
return zoom;
}
Zarko Acimovic
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
liv
Zarko Acimovic
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
movH=step;
}
if(y<minY){
y=minY;
movV=step;
}
if(x>0) x=0;
if(y>0) y=0;
if(movV<0) movV=0;
if(movH<0) movH=0;
if
if
if
if
this.setNewEdge();
}
/**
public void stela(long p1,long p2){
p1 -=((this.img.getHeight()-canvasHeight)/step);
p2+=((this.img.getWidth()-canvasWidth)/step);
p1 -=((this.img.getHeight()-canvasHeight)/step);
p2+=((this.img.getWidth()-canvasWidth)/step);
p2+=((this.img.getWidth()-canvasWidth)/step);
p2+=((this.img.getWidth()-canvasWidth)/step);
}*/
lvi
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
Complexity
Size
Lines of Code (LOC)
Interface Complexity
Number of Attributes and Methods (SIZE2)
Number Of local Methods (NOM)
Structural Complexity
McCabe Cyclomatic Complexity (CC)
Weighted Method Count (WMC)
Response For a Class (RFC)
lvii
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
Zarko Acimovic
1 /**
2
*
3
* Different map formats could be implemented and dealt with with
MapBackgroundFactory
4
*/
5 public class MapBackgroundFactory {
6
7
MapBackground m;
8
9
/**
10
MapBackgroundFactory(String name0, String name1, String name2,
lviii
Class Name
MapsMIDlet
MapBackground
Outlook
DelRoute
MapObjects
CompassCanvas
PVector
Point
MathFP
ImageCanvas3
TextFormFriend
TextFormWP
TextForm
Thread4Friend
MapsMIDlet
SelectorPoint
Friend
SimpleTextForm
MapBackgroundFactory
HeapSorter
TextFormImage
Coordinates
CommaHyphenString
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
Complexity
Size
lix
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
Zarko Acimovic
lx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
*
* MapObjects controls appearance of all map objects on current screen
*/
import java.util.*;
//import java.io.*;
import javax.microedition.lcdui.*;
public class MapObjects {
MapBackground mb;
Point currentPosition;
Point previousPosition;
Point destinationPosition;
PVector freeWaypoints;
Vector routes;
PVector currentRoute;
Vector drawablePoints;
Hashtable friends;
boolean drawLine = false;
boolean destSet = false;
boolean currentSet = false;
MapObjects(MapBackground mb){
this.mb = mb;
currentPosition = mb.getNewEdge();
destinationPosition = mb.getNewEdge();
currentPosition.setName("dummy");
destinationPosition.setName("dummy");
routes = new Vector();
friends = new Hashtable();
lxi
Zarko Acimovic
34
}
35
36
/** Sets drawable Points for current Screen
37
*
38
*/
39
public void setDrawablePoints(){
40
Vector temp1 = new Vector();
41
Vector temp2;
42
43
//check if current and destination are visible
44
if(this.currentPosition.check(mb.getNewEdge(), mb.getDownEnd())) {
45
currentPosition.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat());
46
temp1.addElement(currentPosition);
47
}
48
if(this.destinationPosition.check(mb.getNewEdge(),
mb.getDownEnd())) {
49
destinationPosition.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat());
50
temp1.addElement(destinationPosition);
51
}
52
53
//check which free waypoints are visible
54
temp2 = freeWaypoints.getPoints(mb.getNewEdge(),mb.getDownEnd());
55
for (int j=0; j<temp2.size(); j++){
56
Point wp = (Point)temp2.elementAt(j);
57
wp.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat());
58
temp1.addElement(wp);
59
}
60
61
62
//check which route points are visible
63
for (int i=0; i<routes.size(); i++){
64
PVector v = (PVector)routes.elementAt(i);
65
if (v.getVisible()==true){
66
temp2 =
v.getPoints(mb.getNewEdge(),mb.getDownEnd());
67
68
for (int j=0; j<temp2.size(); j++){
69
Point wp = (Point)temp2.elementAt(j);
70
wp.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat());
71
temp1.addElement(wp);
72
}
73
}
74
}
75
drawablePoints = temp1;
76
}
77
78
/** Returns drawable Points for current Screen
79
* @return Vector
lxii
Zarko Acimovic
130
/** Returns destination position
131
* @return Point
132
*/
133
public Point getDestinationPosition(){
134
return destinationPosition;
135
}
136
137
/** Returns all routes
138
*/
139
public Vector getRoutes(){
140
return routes;
141
}
142
143
/** Returns free Vector of free Points
144
*/
145
public PVector getFreeWaypoints(){
146
return freeWaypoints;
147
}
148
149
/** Draws MapObjects --- OBSOLETED!!!
150
*/
151
public void drawMOBold(Graphics g, boolean route){
152
long zl = mb.getZoomLevel()+1;
153
Long zzl = new Long(zl);
154
int zoomL = Integer.parseInt(zzl.toString());
155
this.setDrawablePoints();
156
157
// Drawing of line beetwen destination and current position
158
if(drawLine==true){
159
currentPosition.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat());
160
destinationPosition.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat());
161
g.drawLine(currentPosition.getXX(),currentPosition.getYY(),destinationPosition.getX
X(),destinationPosition.getYY());
162
}
163
164
// Drawing of free Points, current position and destination
position
165
for(int i=0; i<drawablePoints.size(); i++){
166
Point wp = (Point)drawablePoints.elementAt(i);
167
if(wp.getImage().equals("blanco")){
168
g.fillRect(wp.getXX(),wp.getYY(),5*zoomL,5*zoomL);
169
g.drawString(wp.getName(),wp.getXX()+5,wp.getYY()
+5,0);
170
} else {
171
Image img = null;
172
try{
173
img =
Image.createImage(wp.getImage());
lxiv
Zarko Acimovic
214
currentPosition.drawPoint(g,mb.getNewEdge(),mb.getPixLat(),mb.getPixLon(),mb.getZoo
mLevel());
215
216
}
217
if(destSet)
destinationPosition.drawPoint(g,mb.getNewEdge(),mb.getPixLat(),mb.getPixLon(),mb.ge
tZoomLevel());
218
if(currentSet && destSet)
g.drawLine(currentPosition.getXX(),currentPosition.getYY(),destinationPosition.getX
X(),destinationPosition.getYY());
219
}
220
221
222
223
224
/** Adds free Point
225
*/
226
public void addFreeWaypoint(Point wp){
227
this.freeWaypoints.addElement(wp);
228
}
229
230
/** Adds new route
231
*/
232
public void addRoute(PVector v){
233
this.routes.addElement(v);
234
}
235
236
/** Adds new Point to route with routeID on position pos
237
*/
238
public void addWP2Route(Point wp, int routeID, int pos) {
239
PVector route;
240
for (int i=0; i<routes.size(); i++){
241
route = (PVector)routes.elementAt(i);
242
if(route.getID()==routeID){
243
route.insertElementAt(wp,pos);
244
i=1000;
245
}
246
}
247
}
248
249
/** Sets free waypoints vector
250
*/
251
public void setFreeWaypointsV(PVector wpv){
252
this.freeWaypoints = wpv;
253
}
254
255
/** Measure distance
256
*/
257
public long measureDistance(Point wp){
258
if (currentPosition.equals(mb.getNewEdge())) {
lxvi
return -1;
} else {
return currentPosition.measureDistance(wp);
}
}
public boolean currentSet(){
return currentSet;
}
public boolean destSet(){
return destSet;
}
direction = 0;
latP = previousPosition.getLat();
lonP = previousPosition.getLon();
latC = currentPosition.getLat();
lonC = currentPosition.getLon();
Zarko Acimovic
310
*/
311
public long getBearing(){
312
313
long bearing = 0;
314
long latP = previousPosition.getLat();
315
long lonP = previousPosition.getLon();
316
long latD = destinationPosition.getLat();
317
long lonD = destinationPosition.getLon();
318
319
320
//if(latD>latP && lonD==lonP) bearing = MathFP.toFP("0");
321
if( latD>latP && MathFP.abs(MathFP.sub(lonD,lonP))<MathFP.toFP("5")
) bearing = MathFP.toFP("0");
322
if(latD>latP && lonD>lonP) bearing = MathFP.toFP("45");
323
//if(latD==latP && lonD>lonP) bearing = MathFP.toFP("90");
324
if(MathFP.abs(MathFP.sub(latD,latP))<MathFP.toFP("5") && lonD>lonP)
bearing = MathFP.toFP("90");
325
if(latD<latP && lonD>lonP) bearing = MathFP.toFP("135");
326
//if(latD<latP && lonP==lonD) bearing = MathFP.toFP("180");
327
if(latD<latP &&
MathFP.abs(MathFP.sub(lonD,lonP))<MathFP.toFP("5") ) bearing = MathFP.toFP("180");
328
if(latD<latP && lonD<lonP) bearing = MathFP.toFP("225");
329
//if(latP==latD && lonD<lonP) bearing = MathFP.toFP("270");
330
if(MathFP.abs(MathFP.sub(latD,latP))<MathFP.toFP("5") && lonD<lonP)
bearing = MathFP.toFP("270");
331
if(latD>latP && lonD<lonP) bearing = MathFP.toFP("315");
332
333
334
bearing = Coordinates.degreesToRadians(bearing);
335
return bearing;
336
337
}
338
339
340
public void addNewFriend(int friendID){
341
Point dummy = new Point(currentPosition,false);
342
Integer frID = new Integer(friendID);
343
friends.put(frID,dummy);
344
}
345
346
public void updateFriend(Integer friendID,Point p){
347
friends.put(friendID,p);
348
}
349
350
public void deleteFriend(int friendID){
351
Integer frID = new Integer(friendID);
352
friends.remove(frID);
353
System.out.println(friends);
354
}
355
356
public void deleteAllFriends(){
lxviii
lxix
Zarko Acimovic
Class Name
MapsMIDlet
MapBackground
Outlook
DelRoute
MapObjects
CompassCanvas
PVector
Point
MathFP
ImageCanvas3
TextFormFriend
TextFormWP
TextForm
Thread4Friend
MapsMIDlet
SelectorPoint
Friend
SimpleTextForm
MapBackgroundFactory
HeapSorter
TextFormImage
Coordinates
CommaHyphenString
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
Complexity
Size
Lines of Code (LOC)
Interface Complexity
Number of Attributes and Methods (SIZE2)
Number Of local Methods (NOM)
Structural Complexity
McCabe Cyclomatic Complexity (CC)
Weighted Method Count (WMC)
Response For a Class (RFC)
lxx
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
lxxi
Zarko Acimovic
MapsMIDlet.java
1 /**
2
*
3
* MapsMIDlet creates control menus due to user's actions and handles GPS
issues
4
*
5
*/
6 import javax.microedition.lcdui.*;
7
8 import javax.microedition.midlet.*;
9
10 import java.util.*;
11 import java.io.*;
12
13
14
15
16
17 public class MapsMIDlet extends MIDlet implements CommandListener,Runnable
{
18
19
20
MapBackgroundFactory mbf = new MapBackgroundFactory("/Mali2.png",
"/Srednji.png","/Veliki.png",
21
"44.83049905", "20.44570857", "44.79241639",
"20.48713523");
22
23
24
MapBackground mb;
25
MapObjects mob;
26
SelectorPoint selP;
27
Outlook oul;
28
29
PVector vwpF = new PVector("free",false);
30
ImageCanvas3 ic;
31
CompassCanvas cc;
32
lxxii
Zarko Acimovic
65
Point wp14 = new Point(46,30,23,'N',20,52, 9,'E',"g","j");
66
Point wp15 = new Point(46,25,23,'N',20,54, 0,'E',"h","j");
67
Point wp16 = new Point(46,20,23,'N',20,46, 0,'E',"i","j");
68
Point wp17 = new Point(46,10,23,'N',20,48, 0,'E',"j","j");
69
Point wp18 = new Point(45,50,23,'N',20,35, 0,'E',"k","j"); */
70
71
Point selectedWP;
72
73
74
///////////////////////COMMANDS,MENUS,BUTTONS\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
75
Command DUMMY;
76
Command DELIM;
77
Command MAP_CMD;
78
79
Display d = Display.getDisplay(this);
80
81
List modes;
82
Command selectCmd;
83
Command mapviewCmd;
84
Command compassCmd;
85
86
87
88
Command opt;
89
Command mod;
90
91
List MVList;
92
Command Points;
93
Command routes;
94
Command gps;
95
Command friends;
96
Command ZoomIn;
97
Command ZoomOut;
98
Command exitCmd;
99
SimpleTextForm gpsTf;
100
Thread t1;
101
Thread t2;
102
103
static String resource="";
104
boolean gpsON = false;
105
static String show = "";
106
boolean first = false;
107
List friendList;
108
Command addNewFriend ;
109
Command onGPSc;
110
Command offGPSc;
111
List gpsList;
112
int gpsHash = 0;
113
114
int gpsThr = 0;
lxxiv
Zarko Acimovic
163
164
165
166
167
168
169
170
171
172
coordinates
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
TextForm tfAdd; //form for adding Point with complete info about
List sorted;
List routeMain;
Command createNewRoute;
Command showRoutes;
Command delRoute;
List routeNew;
Command addPoint;
Command routeFin;
List routeList;
List routeOptions;
Command allRoutes;
Command hideRoutes;
List delRouteList;
Command delAllRoutes;
String nameR = "";
PVector newRouteVector;
SimpleTextForm tf3; ///form for defining name of route
String[] categories;
boolean routeSetting = false;
String[] pathToImage;
/**
* @see MIDlet#startApp()
*/
protected void startApp() throws MIDletStateChangeException {
mb = mbf.getMapBackground();
mob = new MapObjects(mb);
vwpF.addElement(wp1);
vwpF.addElement(wp2);
//vwpF.addElement(wp3);
vwpF.addElement(wp4);
lxxvi
Zarko Acimovic
262
MVList = new List("",List.IMPLICIT);
263
Points = new Command("Waypoints",Command.SCREEN,1);
264
routes
= new Command("Routes",Command.SCREEN,1);
265
gps
= new Command("GPS",Command.SCREEN,1);
266
267
friends
= new Command("Friends",Command.SCREEN,1);
268
ZoomIn
= new Command("Zoom In",Command.SCREEN,1);
269
ZoomOut
= new Command("Zoom Out",Command.SCREEN,1);
270
//Exit
= new Command("Exit",Command.EXIT,1);
271
272
MVList.addCommand(DUMMY);
273
MVList.addCommand(Points);
274
MVList.addCommand(routes);
275
MVList.addCommand(gps);
276
MVList.addCommand(friends);
277
MVList.addCommand(ZoomIn);
278
MVList.addCommand(ZoomOut);
279
MVList.addCommand(BACK_CMD);
280
MVList.setCommandListener(this);
281
282
CONT_CMD = new Command("Continue",Command.SCREEN,1);
283
gpsTf = new SimpleTextForm(false);
284
gpsTf.addCommand(CONT_CMD);
285
gpsTf.setCommandListener(this);
286
287
288
289
290
// If Point is selected
291
WPselected
= new List("",List.IMPLICIT);
292
setAsCurrent = new Command("Set as
Current",Command.SCREEN,1);
293
setDest1
= new Command("Set as
Destination",Command.SCREEN,1);
294
edit
= new Command("Edit",Command.SCREEN,1);
295
delete
= new Command("Delete",Command.SCREEN,1);
296
measDist
= new Command("Measure
Distance",Command.SCREEN,1);
297
298
299
WPselected.addCommand(DUMMY);
300
WPselected.addCommand(MAP_CMD);
301
WPselected.addCommand(setAsCurrent);
302
WPselected.addCommand(setDest1);
303
WPselected.addCommand(edit);
304
WPselected.addCommand(delete);
305
WPselected.addCommand(measDist);
306
WPselected.addCommand(BACK_CMD);
307
WPselected.setCommandListener(this);
308
309
lxxviii
Zarko Acimovic
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
tf1.addCommand(CONT_CMD);
tf1.addCommand(BACK_CMD);
tf1.setCommandListener(this);
tf2.addCommand(CONT_CMD);
tf2.addCommand(BACK_CMD);
tf2.setCommandListener(this);
tf33.addCommand(CONT_CMD);
tf33.addCommand(BACK_CMD);
tf33.setCommandListener(this);
whiteList = new Vector();
d.setCurrent(ic);
}
}
if(s==cc && c==MAP_CMD){
cc.setEnd();
ic = new ImageCanvas3(oul);
ic.addCommand(opt);
ic.addCommand(mod);
ic.setCommandListener(this);
d.setCurrent(ic);
}
if (s==ic && c==opt && routeSetting==false){
if(oul.getSelect()==true) {
selectedWP = selP.getSelectedWP();
if(selectedWP.getName()=="selector")
if(selectedWP.getName()!="selector") {
d.setCurrent(WPselected);
previousList=null;
}
}
if(oul.getSelect()==false) d.setCurrent(MVList);
}
Zarko Acimovic
450
String name = tf1.getName();
451
int sel = tf1.getSelected();
452
453
// chs is instance of CommaHypenString class
454
// which helps us process hyphens and commas in
455
//.properties file
456
String[] category =
chs.getCategories(this.getAppProperty("Categories"));
457
String[] categoryHyphen =
chs.getCategoriesHyphen(this.getAppProperty("Categories"));
458
459
// elements of a selected category: as simle
strings and as hyphen-strings
460
String catMatches =
this.getAppProperty(categoryHyphen[sel]);
461
String[] arCatMatches =
chs.getStringsOnly(catMatches);
462
String[] arCatHyphMatches =
chs.getWithLowLine(catMatches);
463
464
// images that correspond to category elements
465
String[] imageStr = new
String[arCatMatches.length];
466
Image[] img = new Image[arCatMatches.length];
467
for(int i=0; i<arCatMatches.length; i++){
468
imageStr[i] =
this.getAppProperty(""+arCatHyphMatches[i]+"");
469
imageStr[i] = this.compact(imageStr[i]);
470
}
471
472
pathToImage = new String[arCatMatches.length];
473
for (int i=0; i<arCatMatches.length; i++){
474
try{
475
String str = categoryHyphen[sel]
+"/"+imageStr[i];
476
str = compact(str); //getting rid
off blanco spots
477
pathToImage[i] = str;
478
img[i] = Image.createImage(str);
479
} catch(Exception e){}
480
}
481
482
tf11 = new TextFormImage("",arCatMatches,img);
483
tf11.setNameCHGR("Please select type");
484
tf11.setName(name);
485
//tf11.setType("Please select type");
486
tf11.addCommand(BACK_CMD);
487
tf11.addCommand(SAVE_CMD);
488
tf11.setCommandListener(this);
489
d.setCurrent(tf11);
490
}
lxxxii
Zarko Acimovic
542
name = tf33.getName();
543
sel = tf33.getSelected();
544
previous = tf33;
545
}
546
547
548
// chs is instance of CommaHypenString class
549
// which helps us process hyphens and commas in
550
//.properties file
551
String[] category =
chs.getCategories(this.getAppProperty("Categories"));
552
String[] categoryHyphen =
chs.getCategoriesHyphen(this.getAppProperty("Categories"));
553
554
// elements of a selected category: as simle
strings and as hyphen-strings
555
String catMatches =
this.getAppProperty(categoryHyphen[sel]);
556
String[] arCatMatches =
chs.getStringsOnly(catMatches);
557
String[] arCatHyphMatches =
chs.getWithLowLine(catMatches);
558
559
// images that correspond to category elements
560
String[] imageStr = new
String[arCatMatches.length];
561
Image[] img = new Image[arCatMatches.length];
562
for(int i=0; i<arCatMatches.length; i++){
563
imageStr[i] =
this.getAppProperty(""+arCatHyphMatches[i]+"");
564
imageStr[i] = this.compact(imageStr[i]);
565
}
566
567
pathToImage = new String[arCatMatches.length];
568
for (int i=0; i<arCatMatches.length; i++){
569
try{
570
String str = categoryHyphen[sel]
+"/"+imageStr[i];
571
str = compact(str); //getting rid
off blanco spots
572
pathToImage[i] = str;
573
img[i] = Image.createImage(str);
574
} catch(Exception e){}
575
}
576
577
tf22 = new TextFormImage("",arCatMatches,img);
578
tf22.setNameCHGR("Please select type");
579
tf22.setName(name);
580
tf22.addCommand(BACK_CMD);
581
tf22.addCommand(SAVE_CMD);
582
tf22.setCommandListener(this);
lxxxiv
Zarko Acimovic
632
if(k==-1){
633
a.setTimeout(3000);
634
a.setString("More than one Point
selected");
635
d.setCurrent(a);
636
} else {
637
selP.resetBig();
638
d.setCurrent(ic);
639
}
640
}
641
642
if(s==WPselected && c==BACK_CMD){
643
if(previousList==null) d.setCurrent(ic);
644
if(previousList!=null) d.setCurrent(previousList);
645
}
646
647
648
// Measuring distance between current position and selected
WAYPOINT
649
if(s==WPselected && c==measDist){
650
if(mob.getCurrentPosition().getName().equals("dummy")){
651
a.setTimeout(3000);
652
a.setString("Current position is not set");
653
d.setCurrent(a);
654
655
} else {
656
a.setTimeout(3000);
657
selectedWP = selP.getSelectedWP();
658
long k = mob.measureDistance(selectedWP);
659
a.setString("Distance is "+k+" m");
660
d.setCurrent(a);
661
}
662
663
}
664
665
666
// Measuring distance between current position and selected
LOCATION
667
if(s==WPnotSel && c==measDist){
668
selectedWP = selP.getSelector();
669
long k = mob.measureDistance(selectedWP);
670
if(mob.currentSet()==false){
671
a.setTimeout(3000);
672
a.setString("Current position is not set");
673
d.setCurrent(a);
674
675
} else {
676
a.setTimeout(3000);
677
a.setString("Distance is "+k+" m");
678
d.setCurrent(a);
lxxxvi
Zarko Acimovic
725
setWPList();
726
727
for(int i=0; i<mob.freeWaypoints.size(); i++){
728
Point wp =
(Point)mob.freeWaypoints.elementAt(i);
729
String name = "";
730
if(showID==true){
731
name = wp.getName()
+"_"+wp.getID();
732
} else {
733
name = wp.getName();
734
}
735
Command cc = new
Command(name,Command.SCREEN,1);
736
WPList.addCommand(cc);
737
}
738
d.setCurrent(WPList);
739
}
740
741
742
// Adding new Point with all attributes such as
743
// LATITUDE and LONGITUDE
744
// We deal with tf33 same as with tf2 (tf2 is used for
745
// inserting new data for selected location
746
// Here default values for coordinates are those of center
of the map
747
748
if(s==WPList && c==addNewWP){
749
tf33.setName("Center of
Map");//44.80345511,20.42949821
750
tf33.setType("");
751
tf33.setLat("44.80345511");
752
tf33.setLon("20.42949821");
753
d.setCurrent(tf33);
754
}
755
756
757
758
if(s==tf33 && c==BACK_CMD){
759
d.setCurrent(WPList);
760
}
761
762
//sorting waypoints by distance
763
if(s==WPList && c==sortWP){
764
setWPList();
765
766
Vector sor =
mob.freeWaypoints.sortAscending(mob.getCurrentPosition());
767
for(int i=0; i<sor.size(); i++){
768
Point wp = (Point)sor.elementAt(i);
769
String name = "";
lxxxviii
Zarko Acimovic
818
routeMain = new List("",List.IMPLICIT);
819
createNewRoute = new Command("New
Route",Command.SCREEN,1);
820
routeMain.addCommand(DUMMY);
821
routeMain.addCommand(createNewRoute);
822
routeMain.addCommand(BACK_CMD);
823
routeMain.addCommand(DELIM);
824
routeMain.setCommandListener(this);
825
for(int i=0; i<mob.getRoutes().size(); i++){
826
PVector route =
(PVector)mob.getRoutes().elementAt(i);
827
String name = route.getName();
828
Command cr = new
Command(name,Command.SCREEN,1);
829
routeMain.addCommand(cr);
830
}
831
d.setCurrent(routeMain);
832
}
833
834
if(s==routeMain && c==BACK_CMD){
835
d.setCurrent(MVList);
836
}
837
838
//Creating a New Route
839
if(s==routeMain && c==createNewRoute){
840
tf3 = new SimpleTextForm(false);
841
tf3.addCommand(SAVE_CMD);
842
tf3.setCommandListener(this);
843
d.setCurrent(tf3);
844
}
845
846
847
if(s==tf3 && c==SAVE_CMD){
848
newRouteVector = new PVector("",true);
849
newRouteVector.setName(tf3.getName());
850
newRouteVector.setVisible();
851
mob.addRoute(newRouteVector);
852
853
routeNew = new List("",List.IMPLICIT);
854
addPoint = new Command("Add
Waypoint",Command.SCREEN,1);
855
routeFin = new Command("Route
Finished",Command.SCREEN,1);
856
routeNew.addCommand(addPoint);
857
routeNew.addCommand(routeFin);
858
routeNew.setCommandListener(this);
859
860
d.setCurrent(routeNew);
861
}
862
863
xc
Zarko Acimovic
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
if(rt.getName()!=nameR) rt.resetVisible();
}
}
//Mapview
if(s==routeOptions && c==MAP_CMD){
Vector v = mob.getRoutes();
for(int i=0; i<v.size(); i++){
PVector wpv = (PVector)v.elementAt(i);
if(wpv.getName()==nameR){
Point p = (Point) wpv.elementAt(0);
selP.selectWP(p.getName());
oul.setSelect();
oul.setWPselection();
i=1000;
}
}
d.setCurrent(ic);
}
//Back on routeMain
if(s==routeOptions && c==BACK_CMD){
d.setCurrent(routeMain);
}
Zarko Acimovic
1008
gpsTf.setType("GPS.txt");
1009
d.setCurrent(gpsTf); //GPS textform
1010
} else {
1011
d.setCurrent(ic);
1012
}
1013
}
1014
1015
if(s==gpsList && c==offGPSc){
1016
gpsON=false;
1017
d.setCurrent(ic);
1018
}
1019
1020
1021
1022
if(s==gpsTf && c==CONT_CMD){
1023
resource = gpsTf.getName();
1024
1025
syncFollow = true;
1026
synchronizationDone=false;
1027
1028
t1=new Thread(this);
1029
currentlyShowed = t1.hashCode();
1030
gpsHash = t1.hashCode();
1031
t1.start();
1032
d.setCurrent(ic);
1033
1034
}
1035
1036
// --------------------------- HANDLING FRIENDS' ISSUES
------------------1037
1038
if(s==MVList && c==friends){
1039
friendList = new List("",List.IMPLICIT);
1040
addNewFriend = new Command("Add New Friend",
Command.SCREEN,1);
1041
stopFollow = new Command("Stop Follow Friends",
Command.SCREEN,1);
1042
deleteFriends = new Command("Delete Friends",
Command.SCREEN,1);
1043
friendList.addCommand(DUMMY);
1044
friendList.addCommand(addNewFriend);
1045
friendList.addCommand(stopFollow);
1046
friendList.addCommand(deleteFriends);
1047
friendList.addCommand(BACK_CMD);
1048
friendList.addCommand(DELIM);
1049
if(listOfFriends.size()>0){
1050
for (int i=0; i<listOfFriends.size(); i++){
1051
Friend f =
(Friend)listOfFriends.elementAt(i);
1052
Command cc = new
Command(f.getName(),Command.SCREEN,1);
xciv
Zarko Acimovic
1099
friendList.addCommand(addNewFriend);
1100
friendList.addCommand(stopFollow);
1101
friendList.addCommand(deleteFriends);
1102
//friendList.addCommand(MAP_CMD);
1103
friendList.addCommand(BACK_CMD);
1104
friendList.addCommand(DELIM);
1105
if(listOfFriends.size()>0){
1106
for (int i=0; i<listOfFriends.size(); i++){
1107
Friend f =
(Friend)listOfFriends.elementAt(i);
1108
Command cc = new
Command(f.getName(),Command.SCREEN,1);
1109
friendList.addCommand(cc);
1110
}
1111
}
1112
friendList.setCommandListener(this);
1113
d.setCurrent(friendList);
1114
d.setCurrent(friendList);
1115
}
1116
1117
if(s==friendList && c!=addNewFriend && c!=stopFollow && c!
=deleteFriends && c!=MAP_CMD && c!=BACK_CMD && c!=DELIM){
1118
friend = c.getLabel();
1119
friend = compact(friend);
1120
oneFriend = new List("",List.IMPLICIT);
1121
stopFollowOne = new Command("Stop Follow",
Command.SCREEN,1);
1122
deleteFriend = new Command("Delete",
Command.SCREEN,1);
1123
oneFriend.addCommand(DUMMY);
1124
oneFriend.addCommand(MAP_CMD);
1125
oneFriend.addCommand(stopFollowOne);
1126
oneFriend.addCommand(deleteFriend);
1127
oneFriend.addCommand(BACK_CMD);
1128
oneFriend.setCommandListener(this);
1129
1130
d.setCurrent(oneFriend);
1131
}
1132
1133
if(s==friendList && c==BACK_CMD){
1134
d.setCurrent(MVList);
1135
}
1136
1137
if(s==oneFriend && c==MAP_CMD){
1138
for(int i=0; i<listOfFriends.size(); i++){
1139
Friend f =
(Friend)listOfFriends.elementAt(i);
1140
if(f.getName().equals(friend)) {
1141
1142
if(f.getThread()==false){
xcvi
Zarko Acimovic
1188
1189
//----------------------This part of code deals with
GPS--------------------1190
public void run(){
1191
while(followFriends==true || gpsON==true){
1192
String s = this.getResourceAsString(resource);
1193
int nextIndex = 6;
1194
int index = s.indexOf('\n');
1195
1196
nextIndex = s.indexOf('\n',index+1);
1197
1198
int lastIndex = s.lastIndexOf('\n');
1199
1200
int begin = -2;
1201
int end = index;
1202
1203
String c1 = "";
1204
String c2 = "";
1205
String timeStamp = "";
1206
long currentTS = 0;
1207
1208
while(index<lastIndex && gpsON==true){
1209
Thread t = Thread.currentThread();
1210
if(t.hashCode()==currentlyShowed){
1211
/**
1212
if(synchronizationDone==false &&
syncFollow==true){
1213
do{ //Synchronization
1214
String temp =
s.substring(begin+2,end);
1215
temp =
compact(temp);
1216
int comma =
temp.indexOf(',');
1217
c1 =
temp.substring(0,comma);
1218
int nextComma =
temp.indexOf(',',comma+1);
1219
c2 =
temp.substring(comma+1,nextComma);
1220
timeStamp =
temp.substring(nextComma+1,temp.length());
1221
currentTS =
Long.parseLong(timeStamp);
1222
begin = index-1;
1223
end = nextIndex;
1224
index = nextIndex;
1225
nextIndex =
s.indexOf('\n',nextIndex+1);
1226
}
while(currentTS<this.getTimeStamp());
xcviii
xcix
synchronizationDone = true;
}*/
Point wp = null;
if(!c1.equals("")){
wp = new
}
if(syncFollow==true)
}
String temp =
temp = compact(temp);
if(temp.equals("")){ //na kraju ce
index = lastIndex+1;
} else {
temp = compact(temp);
int comma =
c1 =
int nextComma =
c2 =
timeStamp =
currentTS =
begin = index-1;
end = nextIndex;
index = nextIndex;
nextIndex =
}
try{
Thread.sleep(1000);
}catch(Exception e){}
if(wp!=null){
mob.setDrawablePoints();
if(gpsON==true){
Zarko Acimovic
1265
if((mob.getCurrentPosition().getX()>170 || mob.getCurrentPosition().getY()>160 ||
1266
mob.getCurrentPosition().getX()<10 || mob.getCurrentPosition().getY()<10) &&
oul.getSelect()==false )
1267
mb.setBackground(wp);
1268
ic.repaint();
1269
1270
}
1271
}
1272
}
1273
}
1274
}
1275
1276
}
1277
1278
/**
1279
* @see MIDlet#pauseApp()
1280
*/
1281
protected void pauseApp() {
1282
}
1283
1284
/**
1285
* @see MIDlet#destroyApp(boolean)
1286
*/
1287
protected void destroyApp(boolean flag) throws
MIDletStateChangeException {
1288
}
1289
1290
1291
/** Blanco characters are possible to occur in names of pictures;
1292
* Integer representations of blanko characters are 9 and 32
1293
* Also, characters with integer representation between 0 and 33
1294
* can not be printed out in WSDD console, so I excluded them too
1295
*/
1296
public String compact(String s){
1297
int k = s.length();
1298
char[] d = s.toCharArray();
1299
String ret = "";
1300
for(int i=0; i<d.length; i++){
1301
int temp = (int)d[i];
1302
if(temp>32) ret+=d[i];
1303
}
1304
int kk = ret.length();
1305
return ret;
1306
}
1307
1308
public String compactFine(String s){
1309
int k = s.length();
c
char[] d = s.toCharArray();
String ret = "";
for(int i=0; i<d.length; i++){
int temp = (int)d[i];
if(temp!=32 && temp!=9) ret+=d[i];
}
int kk = ret.length();
return ret;
}
public String getResourceAsString(String resource){
InputStream is = null;
try{
is = this.getClass().getResourceAsStream(resource);
}catch(Exception e) {
a.setString("There is no such resource");
d.setCurrent(a);
}
//conversion of resource into string
String s = "";
char m =' ';
try{
m = (char)is.read();
}catch(Exception e){}
while(m!=65535){
s+=m;
try{
m = (char)is.read();
}catch(Exception e){}
}
try{
is.close();
}catch(Exception e){}
s=compactFine(s);
return s;
}
public long getTimeStamp(){
return globalTimeStamp;
}
public void setTimeStamp(long tms){
globalTimeStamp = tms;
}
public void setWPList(){
ci
Zarko Acimovic
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
cii
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
Complexity
Size
Lines of Code (LOC)
Interface Complexity
Number of Attributes and Methods (SIZE2)
Number Of local Methods (NOM)
Structural Complexity
McCabe Cyclomatic Complexity (CC)
Weighted Method Count (WMC)
Response For a Class (RFC)
ciii
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
Zarko Acimovic
MathFP.java
1
2
3
4
5
6
7
8
9
10
11
/**
* MathFP implements fix point as a replacement for floating point
*/
Zarko Acimovic
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
Zarko Acimovic
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
Zarko Acimovic
258
259
public static long abs(long l) {
260
if(l < 0L)
261
return -l;
262
else
263
return l;
264
}
265
266
public static long sqrt(long l, int i) {
267
if(l < 0L)
268
throw new ArithmeticException("Bad Input");
269
if(l == 0L)
270
return 0L;
271
long l1 = l + _one >> 1;
272
for(int j = 0; j < i; j++)
273
l1 = l1 + div(l, l1) >> 1;
274
275
if(l1 < 0L)
276
throw new ArithmeticException("Overflow");
277
else
278
return l1;
279
}
280
281
public static long sqrt(long l) {
282
return sqrt(l, 24);
283
}
284
285
//public static long sin(long l) {
286
private static long sinBad(long l) {
287
long l1 = mul(l, div(toFP(180L), PI));
288
l1 %= toFP(360L);
289
if(l1 < 0L)
290
l1 = toFP(360L) + l1;
291
long l2 = l1;
292
if(l1 >= toFP(90L) && l1 < toFP(270L))
293
l2 = toFP(180L) - l1;
294
else
295
if(l1 >= toFP(270L) && l1 < toFP(360L))
296
l2 = -(toFP(360L) - l1);
297
long l3 = l2 / 90L;
298
long l4 = mul(l3, l3);
299
long l5 = mul(mul(mul(mul(0xfffffffffffee21aL >> (int)_flt, l4) +
(0x14594dL >> (int)_flt), l4) - (0xa55b13L >> (int)_flt), l4) + (long)(0x1921f9c >>
(int)_flt), l3);
300
return l5;
301
}
302
303
//public static long asin(long l) {
304
private static long asinBad(long l) {
305
if(abs(l) > _one) {
306
throw new ArithmeticException("Bad Input");
cx
Zarko Acimovic
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
l4 *= k + 1;
if(l4 > l2 || l2 <= 0L || l4 <= 0L)
break;
}
l1 = mul(l1, l3);
}
if(flag)
l1 = div(_one, l1);
return l1;
}
public static long log(long l) {
if(l <= 0L)
throw new ArithmeticException("Bad Input");
long l1 = 0L;
long l2 = 0L;
int i;
for(i = 0; l >= _one << 1; i++)
l >>= 1;
long l4 = (long)i * (long)(0xb17218 >> (int)_flt);
long l5 = 0L;
if(l < _one)
return -log(div(_one, l));
l -= _one;
for(int j = 1; j < 20; j++) {
long l3;
if(l1 == 0L)
l3 = l;
else
l3 = mul(l1, l);
if(l3 == 0L)
break;
l5 += ((j % 2 != 0 ? 1L : -1L) * l3) / (long)j;
l1 = l3;
}
return l4 + l5;
}
public static long pow(long l, long l1) {
boolean flag = l1 < 0L;
long l2 = _one;
l1 = abs(l1);
for(int i = (int)l1 >> _fbits; i-- > 0;)
l2 = mul(l2, l);
if(l2 < 0L)
throw new ArithmeticException("Overflow");
if(l != 0L)
cxii
cxiii
Zarko Acimovic
Class Name
MapsMIDlet
MapBackground
Outlook
DelRoute
MapObjects
CompassCanvas
PVector
Point
MathFP
ImageCanvas3
TextFormFriend
TextFormWP
TextForm
Thread4Friend
MapsMIDlet
SelectorPoint
Friend
SimpleTextForm
MapBackgroundFactory
HeapSorter
TextFormImage
Coordinates
CommaHyphenString
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
Complexity
Size
Lines of Code (LOC)
Interface Complexity
Number of Attributes and Methods (SIZE2)
Number Of local Methods (NOM)
Structural Complexity
McCabe Cyclomatic Complexity (CC)
Weighted Method Count (WMC)
Response For a Class (RFC)
cxiv
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
Outlook.java
1
2
3
4
5
6
7
8
9
10
11
12
13
/**
*
* Outlook coordinates work MapBackground, MapObjects and SelectorPoint
*
*/
//import java.util.*;
//import java.io.*;
import javax.microedition.lcdui.*;
public class Outlook {
MapBackground mb;
MapObjects mob;
MapBackgroundFactory mbf;
cxv
Zarko Acimovic
14
SelectorPoint selP;
15
boolean select = false;
16
boolean route = false;
17
boolean startup = false;
18
boolean first = false;
19
Point center = new Point("44.83168","20.445","","","blanco",false);
20
boolean WPselection = false;
21
22
Outlook(MapBackground mb, MapObjects mob, SelectorPoint sp) {
23
24
this.mb = mb;
25
this.mob = mob;
26
this.selP = sp;
27
}
28
29
public void drawOutlook(Graphics g){
30
if(startup==false) {
31
mb.setBackground(center);
32
startup = true;
33
}
34
35
mb.drawMapBackground(g);
36
37
if(first==true && mob.currentSet()==false &&
WPselection==false){
38
selP.selP = new Point(mb.getNewEdge(),false);
39
first=false;
40
}
41
42
if(first==true && mob.currentSet()==true &&
WPselection==false){
43
selP.selectWP(mob.getCurrentPosition().getName());
44
mb.drawMapBackground(g);
45
first=false;
46
}
47
48
/**
49
if(route==false){
50
mob.drawMOB(g,route);
51
if(select==true) selP.drawSelP(g);
52
} else {
53
if(select==true) selP.drawSelP(g);
54
mob.drawMOB(g,route);
55
}*/
56
57
if(select==true) selP.drawSelP(g);
58
mob.drawMOB(g,route);
59
if(select==true) selP.drawCaption(g);
60
61
}
62
cxvi
cxvii
Zarko Acimovic
Class Name
MapsMIDlet
MapBackground
Outlook
DelRoute
MapObjects
CompassCanvas
PVector
Point
MathFP
ImageCanvas3
TextFormFriend
TextFormWP
TextForm
Thread4Friend
MapsMIDlet
SelectorPoint
Friend
SimpleTextForm
MapBackgroundFactory
HeapSorter
TextFormImage
Coordinates
CommaHyphenString
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
Complexity
Size
Lines of Code (LOC)
Interface Complexity
Number of Attributes and Methods (SIZE2)
Number Of local Methods (NOM)
Structural Complexity
McCabe Cyclomatic Complexity (CC)
cxviii
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
cxix
Zarko Acimovic
The Improvement of LCOM (cf. Lack of Cohesion in Methods 3.2.3) metric is a measure for the number of connected
components in a class. A component are methods of a class sharing (being connected by) instance variables of the class. The
less separate components there are the higher is the cohesion of the methods in the class.
http://www.arisa.se/compendium/node117.html
Lack of Cohesion in Methods Description
The Lack of Cohesion in Methods metric is a measure for the number of not connected method pairs in a class representing
independent parts having no cohesion. It represents the difference between the number of method pairs not having instance
variables in common, and the number of method pairs having common instance variables.
http://www.arisa.se/compendium/node116.html
Number Of local Methods Description
Number of local Methods measures the number of methods locally declared in a class. Inherited methods are not considered.
It is the size of the interface of a class and allows conclusions on its complexity.
http://www.arisa.se/compendium/node94.html
Tight Class Cohesion Description
The Tight Class Cohesion metric measures the cohesion between the public methods of a class. That is the relative number of
directly connected public methods in the class. Classes having a low cohesion indicate errors in the design.
http://www.arisa.se/compendium/node118.html
Point.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* Class Point represents geographical object
*/
//import java.util.*;
//import java.io.*;
import javax.microedition.lcdui.*;
public class Point {
/** Point ID
*
*/
private int ID = 0;
cxx
/** Counter
*/
private static int cnt = 0;
Zarko Acimovic
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
long totLatSec;
/** Total number of longitude seconds
*/
long totLonSec;
/** Name of the Point
*/
String name = "default";
/** Type of the Point
*/
String type = "default";
/** Distance between this point and point which asks sorting
*/
private long distance;
/** x coordinate of Point on Canvas
*/
private long x = 5;
/** y coordinate of Point on Canvas
*/
private long y = 5;
cxxii
Zarko Acimovic
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
temp = MathFP.mul(temp,MathFP.toFP("60"));
this.minLat = MathFP.getWholePart(MathFP.toString(temp));
temp = MathFP.sub(this.lat,this.degLat);
temp = MathFP.mul(temp,MathFP.toFP("60"));
temp = MathFP.sub(temp,minLat);
this.secLat = MathFP.mul(temp,MathFP.toFP("60"));
this.degLon = MathFP.getWholePart(lonS);
temp = MathFP.sub(this.lon,this.degLon);
temp = MathFP.mul(temp,MathFP.toFP("60"));
this.minLon = MathFP.getWholePart(MathFP.toString(temp));
temp = MathFP.sub(this.lon,this.degLon);
temp = MathFP.mul(temp,MathFP.toFP("60"));
temp = MathFP.sub(temp,minLon);
this.secLon = MathFP.mul(temp,MathFP.toFP("60"));
this.totLatSec = totLatSec;
this.totLonSec = totLonSec;
if(setNewID==true){
ID = cnt;
cnt++;
}
typeID = 0; //default type
//System.out.println("cnt="+cnt);
}
degLon=wp.degLon;
minLon=wp.minLon;
secLon=wp.secLon;
//sideWE=wp.sideWE;
name=wp.name;
type=wp.type;
this.lat = wp.lat;
this.lon = wp.lon;
this.totLatSec = wp.totLatSec;
this.totLonSec = wp.totLonSec;
cxxiv
if (setNewID==true){
ID = cnt;
cnt++;
}
typeID = 0; //default type
//System.out.println("cnt="+cnt);
imgString = wp.getImage();
}
Point (String lat,
//char sideNS,
String lon,
//char sideWE,
String name, String type, String img, boolean setNewID){
//this.sideNS = sideNS;
//this.sideWE = sideWE;
this.name = name;
this.type = type;
this.lat = MathFP.toFP(lat);
this.lon = MathFP.toFP(lon);
this.degLat = MathFP.getWholePart(lat);
long temp = MathFP.sub(this.lat,this.degLat);
temp = MathFP.mul(temp,MathFP.toFP("60"));
this.minLat = MathFP.getWholePart(MathFP.toString(temp));
temp = MathFP.sub(this.lat,this.degLat);
temp = MathFP.mul(temp,MathFP.toFP("60"));
temp = MathFP.sub(temp,minLat);
this.secLat = MathFP.mul(temp,MathFP.toFP("60"));
this.degLon = MathFP.getWholePart(lon);
temp = MathFP.sub(this.lon,this.degLon);
temp = MathFP.mul(temp,MathFP.toFP("60"));
this.minLon = MathFP.getWholePart(MathFP.toString(temp));
temp = MathFP.sub(this.lon,this.degLon);
temp = MathFP.mul(temp,MathFP.toFP("60"));
temp = MathFP.sub(temp,minLon);
this.secLon = MathFP.mul(temp,MathFP.toFP("60"));
this.totLatSec = MathFP.mul(this.lat,MathFP.toFP("3600"));
this.totLonSec = MathFP.mul(this.lon,MathFP.toFP("3600"));
if (setNewID==true) {
ID = cnt;
cnt++;
}
cxxv
Zarko Acimovic
281
typeID = 0; //default type
282
//System.out.println("cnt="+cnt);
283
imgString = img;
284
285
}
286
287
288
289
/**
290
Point(String lat, String lon, String name, String type, String
image, boolean setNewID){
291
this.name = name;
292
this.type = type;
293
this.lat = MathFP.toFP(lat);
294
this.lon = MathFP.toFP(lon);
295
296
this.degLat = MathFP.getWholePart(lat);
297
long temp = MathFP.sub(this.lat,this.degLat);
298
temp = MathFP.mul(temp,MathFP.toFP("60"));
299
this.minLat = MathFP.getWholePart(MathFP.toString(temp));
300
301
temp = MathFP.sub(this.lat,this.degLat);
302
temp = MathFP.mul(temp,MathFP.toFP("60"));
303
temp = MathFP.sub(temp,minLat);
304
this.secLat = MathFP.mul(temp,MathFP.toFP("60"));
305
306
this.degLon = MathFP.getWholePart(lon);
307
temp = MathFP.sub(this.lon,this.degLon);
308
temp = MathFP.mul(temp,MathFP.toFP("60"));
309
this.minLon = MathFP.getWholePart(MathFP.toString(temp));
310
311
temp = MathFP.sub(this.lon,this.degLon);
312
temp = MathFP.mul(temp,MathFP.toFP("60"));
313
temp = MathFP.sub(temp,minLon);
314
this.secLon = MathFP.mul(temp,MathFP.toFP("60"));
315
316
this.totLatSec = MathFP.mul(this.lat,MathFP.toFP("3600"));
317
this.totLonSec = MathFP.mul(this.lon,MathFP.toFP("3600"));
318
319
320
if (setNewID==true) {
321
ID = cnt;
322
cnt++;
323
}
324
typeID = 0; //default type
325
326
}*/
327
328
/** Calculates distance between two Points;
329
*
330
* @version advanced
cxxvi
* @return long
*/
public long measureDistance(Point wp){
Coordinates c1 = new Coordinates(this.lat,this.lon);
Coordinates c2 = new Coordinates(wp.lat, wp.lon);
return MathFP.toLong(c1.distance(c2));
}
/** Sets distance
*/
public void setDistance (long dist){
distance = dist;
}
/** Gets distance
* @return long
*/
public long getDistance (){
return distance;
}
/** Returns type of Point
* @return String
*/
public String getType() { return type; }
/** Sets type of Point
* @return String
*/
public void setType(String type) { this.type = type; }
/** Returns name of Point
* @return String
*/
public String getName() { return name; }
/** Sets type of Point
* @return String
*/
public void setName(String name) { this.name = name; }
/** Returns side of the world as String
* @return String
*
*/
//public char getNS(){
//
return sideNS;
//}
/** Returns side of
* @return String
cxxvii
Zarko Acimovic
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
*
*/
//public char getWE(){
//
return sideWE;
//}
/** Returns degrees of latitiude
*
* @author Zarko Acimovic
* @version initial
*/
public long getDLat(){
return degLat;
}
/** Returns minutes of latitiude
*
* @author Zarko Acimovic
* @version initial
*/
public long getMLat(){
return minLat;
}
/** Returns seconds of latitiude
*
* @author Zarko Acimovic
* @version initial
*/
public long getSLat(){
return secLat;
}
/** Returns degrees of longitude
*
* @author Zarko Acimovic
* @version initial
*/
public long getDLon(){
return degLon;
}
/** Returns minutes of longitude
*
* @author Zarko Acimovic
* @version initial
*/
public long getMLon(){
return minLon;
}
cxxviii
Zarko Acimovic
479
public void setXY (Point wp, long pixLon, long pixLat){
480
//System.out.println("----this------------------"+this);
481
//System.out.println("-------newEdge---------------"+wp);
482
///System.out.println("this.getLat()="+MathFP.toString(this.getLat()));
483
//System.out.println("this.getLon()="+MathFP.toString(this.getLon()));
484
///System.out.println("wp.getLat()="+MathFP.toString(wp.getLat()));
485
///System.out.println("wp.getLon()="+MathFP.toString(wp.getLon()));
486
//System.out.println("pixLat="+MathFP.toString(pixLat));
487
///System.out.println("pixLon="+MathFP.toString(pixLon));
488
489
y =
MathFP.div(MathFP.mul(MathFP.sub(wp.getLat(),this.getLat()),MathFP.toFP("3600")),pi
xLat);
490
y = MathFP.toLong(y);
491
492
x =
MathFP.div(MathFP.mul(MathFP.sub(this.getLon(),wp.getLon()),MathFP.toFP("3600")),pi
xLon);
493
x = MathFP.toLong(x);
494
}
495
496
/** Checks if this Point is beetwen wp1 and wp2
497
*
498
* @version initial
499
* @return boolean
500
*/
501
public boolean check(Point wp1, Point wp2){
502
503
long lim1Lat = wp1.getLat();
504
long lim1Lon = wp1.getLon();
505
long lim2Lat = wp2.getLat();
506
long lim2Lon = wp2.getLon();
507
508
long bigLat;
509
long miniLat;
510
long bigLon;
511
long miniLon;
512
513
if (lim1Lat>lim2Lat){
514
bigLat=lim1Lat;
515
miniLat=lim2Lat;
516
} else {
517
bigLat=lim2Lat;
518
miniLat=lim1Lat;
519
}
520
521
if (lim1Lon>lim2Lon){
cxxx
bigLon=lim1Lon;
miniLon=lim2Lon;
} else {
bigLon=lim2Lon;
miniLon=lim1Lon;
}
if (miniLat<this.getLat() && this.getLat()<bigLat &&
miniLon<this.getLon() && this.getLon()<bigLon){
return true;
} else {
return false;
}
}
Zarko Acimovic
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
cxxxiii
Zarko Acimovic
672
g.drawString(this.getName(),this.getXX()-18,this.getYY()
+11,0);
673
674
if (this.getName().equals("GPS.txt"))
675
g.drawString(this.getName(),this.getXX()-18,this.getYY()
+11,0);
676
677
if (this.getName().equals("Mika.txt"))
678
g.drawString(this.getName(),this.getXX()-18,this.getYY()
+11,0);
679
680
if (this.getName().equals("GPS"))
681
g.drawString(this.getName(),this.getXX()-18,this.getYY()
+11,0);
682
683
if (this.getName().equals("Mika"))
684
g.drawString(this.getName(),this.getXX()-18,this.getYY()
+11,0);
685
686
if (this.getName().equals("Str8"))
687
g.drawString(this.getName(),this.getXX()-18,this.getYY()
+11,0);
688
}
689
690
if(!this.getImage().equals("blanco") && !
this.getImage().equals("route")){
691
Image img = null;
692
try{
693
img = Image.createImage(this.getImage());
694
}catch(Exception e){}
695
g.drawImage(img,this.getXX()-3,this.getYY()-3,0);
696
//g.drawString(this.getName(),this.getXX()15,this.getYY()+11,0);
697
}
698
}
699
700
public void setLat(String s){
701
lat = MathFP.toFP(s);
702
}
703
704
public void setLon(String s){
705
lon = MathFP.toFP(s);
706
}
707
708 }
cxxxiv
Class Name
MapsMIDlet
MapBackground
Outlook
DelRoute
MapObjects
CompassCanvas
PVector
Point
MathFP
ImageCanvas3
TextFormFriend
TextFormWP
TextForm
Thread4Friend
MapsMIDlet
SelectorPoint
Friend
SimpleTextForm
MapBackgroundFactory
HeapSorter
TextFormImage
Coordinates
CommaHyphenString
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
Complexity
Size
Lines of Code (LOC)
Interface Complexity
Number of Attributes and Methods (SIZE2)
Number Of local Methods (NOM)
Structural Complexity
McCabe Cyclomatic Complexity (CC)
Weighted Method Count (WMC)
Response For a Class (RFC)
cxxxv
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
Zarko Acimovic
PVector is OK.
PVector.java
1
2
3
4
5
6
7
8
/**
*
* PVector enables drawing and sorting of points by name and distance
*/
import java.util.*;
//import java.io.*;
cxxxvi
import javax.microedition.lcdui.*;
public class PVector extends Vector {
/** ID of WP Vector
* 0 - simple Vector
* 1 - route
*/
private int ID = 0;
private static int cnt = 0;
private String name ="";
boolean visible = false;
cxxxvii
Zarko Acimovic
60
public Vector sortAscending(Point wp){
61
int size = this.size();
62
long[] distances = new long [size];
63
for (int i=0; i<size; i++) {
64
Point whs = (Point)this.elementAt(i); //from
warehouse
65
distances[i]=whs.measureDistance(wp);
66
whs.setDistance(distances[i]);
67
}
68
Hashtable ht = new Hashtable();
69
for (int i=0; i<size; i++){
70
ht.put(new Long(distances[i]),this.elementAt(i));
71
}
72
HeapSorter hp = new HeapSorter();
73
hp.heapsort(distances);
74
Vector sorted = new Vector();
75
for (int i=0;i<size;i++) sorted.addElement(ht.get(new
Long(distances[i])));
76
return sorted;
77
}
78
79
public String[] sortByName(){
80
//System.out.println("wwwwww");
81
//int size = this.size();
82
//long[] firstChars = new long[size];
83
//Hashtable ht = new Hashtable();
84
String names[] = new String[this.size()];
85
for(int i=0; i<this.size(); i++){
86
Point whs = (Point) this.elementAt(i);
87
//firstChars[i] = (long) whs.getName().charAt(0);
88
//ht.put(new
Long(firstChars[i]),this.elementAt(i));
89
names[i]=whs.getName();
90
}
91
HeapSorter hp = new HeapSorter();
92
hp.heapsort(names);
93
//Vector sorted = new Vector();
94
//for (int i=0;i<size;i++) sorted.addElement(ht.get(new
Long(firstChars[i])));
95
//System.out.println("wwwwww\n"+sorted);
96
return names;
97
}
98
99
/** Returns vector of Points sorted by distance
100
* from WayPint wp in descending order
101
*
102
* @version initial
103
* @return Vector
104
*/
105
public Vector sortDescending(Point wp){
106
int size = this.size();
cxxxviii
Zarko Acimovic
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
lim1Lat
lim1Lon
lim2Lat
lim2Lon
long
long
long
long
bigLat;
miniLat;
bigLon;
miniLon;
=
=
=
=
wp1.getLat();
wp1.getLon();
wp2.getLat();
wp2.getLon();
if (lim1Lat>lim2Lat){
bigLat=lim1Lat;
miniLat=lim2Lat;
} else {
bigLat=lim2Lat;
miniLat=lim1Lat;
}
if (lim1Lon>lim2Lon){
bigLon=lim1Lon;
miniLon=lim2Lon;
} else {
bigLon=lim2Lon;
miniLon=lim1Lon;
}
for (int i=0; i<this.size();i++){
Point wp = (Point)this.elementAt(i);
if (miniLat<wp.getLat() && wp.getLat()<bigLat &&
miniLon<wp.getLon() && wp.getLon()<bigLon){
v.addElement(wp);
}
}
//System.out.println("Vektor je\n"+v);
return v;
}
/** Merges two vectors
*
* @version initial
*/
cxl
Zarko Acimovic
255
*
256
*/
257
public void setID(int i){
258
ID = i;
259
}
260
261
/** Returns ID of WPVector
262
* 0 - simple WPVector
263
* 1 - route
264
*/
265
public int getID(){
266
return ID;
267
}
268
269
/** Returns name WPVector
270
*/
271
public String getName(){
272
return name;
273
}
274
275
/** Returns name WPVector
276
*/
277
public void setName(String s){
278
name = s;
279
}
280
281
public void setVisible(){
282
visible = true;
283
}
284
285
public void resetVisible(){
286
visible = false;
287
}
288
289
public boolean getVisible(){
290
return visible;
291
}
292
293
public void drawVector(Graphics g, boolean route, Point newEdge, long
pixLon, long pixLat, long zoomL){
294
/////System.out.println("route="+route);
295
/////System.out.println("routeVisible="+this.getVisible());
296
if(route==true){
297
if(this.getVisible()==true){
298
if(this.size()==1){
299
Point wp1 = (Point) this.elementAt(0);
300
wp1.drawPoint(g,newEdge,pixLat,pixLon,zoomL);
301
} else {
302
for(int j=0; j<this.size()-1; j++){
cxlii
Class Name
MapsMIDlet
MapBackground
Outlook
DelRoute
MapObjects
CompassCanvas
PVector
Point
MathFP
ImageCanvas3
TextFormFriend
TextFormWP
TextForm
Thread4Friend
MapsMIDlet
SelectorPoint
Friend
SimpleTextForm
MapBackgroundFactory
HeapSorter
TextFormImage
Coordinates
CommaHyphenString
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
Complexity
cxliii
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
Zarko Acimovic
Size
Lines of Code (LOC)
Interface Complexity
Number of Attributes and Methods (SIZE2)
Number Of local Methods (NOM)
Structural Complexity
McCabe Cyclomatic Complexity (CC)
Weighted Method Count (WMC)
Response For a Class (RFC)
SelectorPoint is OK.
SelectorPoint.java
1 /**
2
* SelectorPoint controls selection and identification of geographical
object
3
*/
4 import java.util.*;
5 //import java.io.*;
6 import javax.microedition.lcdui.*;
7
8 public class SelectorPoint{
9
MapBackground mb;
10
MapObjects mob;
11
Point selP;
12
int m = 255;
13
int n = 200;
14
int s = 0;
15
boolean colorSet=false;
16
boolean big = false;
17
18
SelectorPoint(MapBackground mb, MapObjects mob){
19
20
this.selP = mob.getCurrentPosition();
21
this.mb = mb;
22
this.mob = mob;
23
}
24
25
/** Sets selector point on Screen due to user's left/right , up/down
commands
26
*/
27
public void setSelectorScreen(char s){
28
29
30
if(s=='r'){
cxlv
Zarko Acimovic
31
if (selP.getX()>0 && selP.getX()<mb.getCanvasWidth())
selP.addX(5);
32
if (selP.getX()>mb.getCanvasWidth()-5) {
33
// calculation of (deg,min,sec) for Selector before
panning
34
//dakle ja pre panovanja izracunam svetske
koordinate selektora,
35
//da bi znao gde je on stvarno, pa kad panujem mapu
(a samim
36
//tim i promenim njen newEdge onda odredjujem i
relativni polozaj
37
//selektorske tacke u odnosu na taj newEdge (jasno
je da pri panovanju mape
38
//nije doslo do promene svetskih koordinata
selektora)
39
this.setSelectorWorld(mb.getNewEdge(),
mb.getPixLon(),mb.getPixLat());
40
//Paning
41
mb.setMap(s);
42
mob.setDrawablePoints();
43
//calculation of new Selector position on panned
map
44
selP.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat());
45
46
}
47
}
48
if(s=='l'){
49
if (selP.getX()>6) selP.subX(5);
50
if (selP.getX()<=6) {
51
// calculation of (deg,min,sec) for Selector before
panning
52
this.setSelectorWorld(mb.getNewEdge(),
mb.getPixLon(),mb.getPixLat());
53
//Paning
54
mb.setMap(s);
55
mob.setDrawablePoints();
56
//calculation of new Selector position on panned
map
57
selP.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat());
58
}
59
}
60
if(s=='d'){
61
if (selP.getY()>0 && selP.getY()<mb.getCanvasHeight()-5)
selP.addY(5);
62
if (selP.getY()>=(mb.getCanvasHeight()-5)) {
63
//calculation of (deg,min,sec) for Selector before
panning
64
this.setSelectorWorld(mb.getNewEdge(),
mb.getPixLon(),mb.getPixLat());
cxlvi
//Paning
mb.setMap(s);
mob.setDrawablePoints();
//calculation of new Selector position on panned
map
69
selP.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat());
70
71
}
72
}
73
if(s=='u'){
74
if (selP.getY()>6) selP.subY(5);
75
if (selP.getY()<=6) {
76
//calculation of (deg,min,sec) for Selector before
panning
77
this.setSelectorWorld(mb.getNewEdge(),
mb.getPixLon(),mb.getPixLat());
78
//Paning
79
mb.setMap(s);
80
mob.setDrawablePoints();
81
//calculation of new Selector position on panned
map
82
selP.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat());
83
84
}
85
}
86
87
Point WP = this.getSelectedWP();
88
89
if (!WP.getName().equals("selector") && colorSet==false) {
90
setColor();
91
setBig();
92
}
93
if (WP.getName().equals("selector") && colorSet==true) {
94
resetColor();
95
resetBig();
96
}
97
//if (!WP.getImage().equals("blanco") && !
WP.getImage().equals("route") && big==false) setBig();
98
//if ((WP.getImage().equals("blanco")||
WP.getImage().equals("route")) && big==true) resetBig();
99
}
100
101
102
103
/** When selector is moved we only update its (x,y) 'descriptors',
104
* so when map has to be panned we need to find out (lat,lon) pair
105
* for selector on old screen and adjust its position (x',y') on new
screen
106
* in a way that (lat,lon) is unchanged
cxlvii
Zarko Acimovic
107
*/
108
public void setSelectorWorld(Point edge, long pixLon, long pixLat){
109
110
// pamtim trenutno x i y
111
long tx = selP.getX();
112
long ty = selP.getY();
113
114
// azuriram svetske kordinate
115
long dLatSec = MathFP.mul(pixLat,MathFP.toFP(selP.getY()));
116
long dLonSec = MathFP.mul(pixLon,MathFP.toFP(selP.getX()));
117
118
selP = new Point(MathFP.sub(edge.getLatSec(),dLatSec),
119
MathFP.add(edge.getLonSec(),dLonSec),"","",false);
120
121
// vracam trenutno x i y
122
selP.setX(tx);
123
selP.setY(ty);
124
}
125
126
/** Returns copy of SELECTOR Point
127
* @return Point
128
*/
129
public Point getSelector(){
130
this.setSelectorWorld(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat());
131
Point copy = new Point(selP,true);
132
133
copy.setName("");
134
return copy;
135
}
136
137
/** Returns x-coordinate of selector
138
* @return long
139
*/
140
long getSelX(){
141
return selP.getX();
142
}
143
144
/** Returns y-coordinate of selector
145
* @return long
146
*/
147
long getSelY(){
148
return selP.getY();
149
}
150
151
/** Returns user selected Point
152
* @return Point
153
*/
154
public Point getSelectedWP(){
155
Vector v = mob.getDrawablePoints();
cxlviii
Zarko Acimovic
206
Point dP = mob.getDestinationPosition();
207
if(s.equals(dP.getName())) {
208
look4=dP;
209
k=-4;
210
}
211
}
212
213
if(k==-2){
214
Vector routes = mob.getRoutes();
215
for(int i=0; i<routes.size(); i++){
216
PVector rt = (PVector) routes.elementAt(i);
217
for(int j=0; j<rt.size(); j++){
218
Point wp = (Point)rt.elementAt(j);
219
System.out.println(wp);
220
if(wp.getName().equals(s)){
221
k=j;
222
look4=(Point)rt.elementAt(j);
223
i=1000;
224
j=1000;
225
}
226
}
227
}
228
}
229
230
this.selP = new Point(look4,false);
231
232
mb.setBackground(look4);
233
234
mob.setDrawablePoints();
235
selP.setXY(mb.getNewEdge(),mb.getPixLon(), mb.getPixLat());
236
237
if (!selP.getImage().equals("blanco") && big==false) setBig();
238
if (selP.getImage().equals("blanco") && big==true) resetBig();
239
240
this.setColor();
241
}
242
243
/** Deletes selected Point
244
* Returns -4 if current Point is deleted
245
* Returns -3 if destination Point is deleted
246
* Returns -2 if free Point deleted
247
* Returns -1 if more then one Point is selected
248
* Returns 0 if none Point is selected
249
* Returns n if n-th Point in route deleted
250
*/
251
public int deleteWP(){
252
int ret = 0;
253
254
this.setSelectorWorld(mb.getNewEdge(),
mb.getPixLon(),mb.getPixLat());
255
cl
Zarko Acimovic
304
Point dp = mob.getDestinationPosition();
305
306
if( Math.abs(selP.getX()-dp.getX())<5 &&
307
Math.abs(selP.getY()-dp.getY())<5 ) {
308
mob.resetDestinationPosition();
309
ret= -3;
310
}
311
312
resetColor();
313
314
return ret;
315
}
316
317
318
/** Action that must be taken with Selector when Zoom In/Out
319
*/
320
public void Zoom(){
321
this.setSelectorWorld(mb.getPreviousEdge(),
mb.getPreviousPixLon(),mb.getPreviousPixLat());
322
selP.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat());
323
while (selP.getX()>mb.getCanvasWidth()) {
324
this.setSelectorWorld(mb.getNewEdge(),
mb.getPixLon(),mb.getPixLat());
325
mb.setMap('r');
326
selP.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat());
327
}
328
while (selP.getY()>mb.getCanvasHeight()) {
329
this.setSelectorWorld(mb.getNewEdge(),
mb.getPixLon(),mb.getPixLat());
330
mb.setMap('d');
331
selP.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat());
332
}
333
while (selP.getX()<0){
334
this.setSelectorWorld(mb.getNewEdge(),
mb.getPixLon(),mb.getPixLat());
335
mb.setMap('l');
336
selP.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat());
337
}
338
while (selP.getY()<0) {
339
this.setSelectorWorld(mb.getNewEdge(),
mb.getPixLon(),mb.getPixLat());
340
mb.setMap('u');
341
selP.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat());
342
}
343
}
344
345
346
/** Draws selector point
347
*
348
public void drawSelPOld(Graphics g){
349
long zl = mb.getZoomLevel()+1;
clii
Zarko Acimovic
400
g.setColor(0,0,0);
401
g.drawRect(selP.getXX()-13,selP.getYY()-5,33,16);
402
g.drawRect(selP.getXX()-5,selP.getYY()-13,16,22);///umesto
16,32 sad je 16,25
403
g.setColor(m,n,s);
404
g.fillRect(selP.getXX()-12,selP.getYY()-4,32,15);
405
g.fillRect(selP.getXX()-4,selP.getYY()-12,15,22);
406
407
//g.drawString(selP.getName(),selP.getXX()-15,selP.getYY()
+11,0);
408
}
409
g.setColor(0,0,0);
410
if (!this.getSelectedWP().getName().equals("selector"))
g.drawString(this.getSelectedWP().getName(),this.getSelectedWP().getXX()15,this.getSelectedWP().getYY()+11,0);
411
}*/
412
413
public void drawSelP(Graphics g){
414
int length=0;
415
416
//g.setColor(m,n,s);
417
g.setColor(255,180,0);
418
g.fillRect(selP.getXX()-8,selP.getYY()-4,15,7);
419
g.fillRect(selP.getXX()-4,selP.getYY()-8,7,5);
420
g.setColor(0,0,0);
421
g.drawRect(selP.getXX()-8,selP.getYY()-4,15,7);
422
g.drawRect(selP.getXX()-4,selP.getYY()-8,7,15);
423
//g.setColor(m,n,s);
424
g.setColor(255,180,0);
425
g.fillRect(selP.getXX()-7,selP.getYY()-3,14,6);
426
g.fillRect(selP.getXX()-3,selP.getYY()-7,6,14);
427
/**
428
if(big==true){
429
g.setColor(m,n,s);
430
//g.drawRect(selP.getXX()-4,selP.getYY()-4,15,15);
431
//g.drawRect(selP.getXX()-5,selP.getYY()-5,17,17);
432
//g.drawRect(selP.getXX()-6,selP.getYY()-6,19,19);
433
String name = this.getSelectedWP().getName();
434
length = name.length();
435
g.fillRect(selP.getXX()-4*length-2,selP.getYY()
+12,8*length+2,14);
436
}
437
g.setColor(0,0,0);
438
if (!this.getSelectedWP().getName().equals("selector"))
g.drawString(this.getSelectedWP().getName(),selP.getXX()-4*length,selP.getYY()
+13,0);
439
*/
440
}
441
442
public void drawCaption(Graphics g){
443
int length=0;
cliv
Zarko Acimovic
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
}
public void resetColor(){
m=255;
n=180;
s=0;
colorSet=false;
}
public void setBig(){
big=true;
}
public void resetBig(){
big=false;
}
/**
*
*
*
*/
clvi
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
Complexity
Size
Lines of Code (LOC)
Interface Complexity
Number of Attributes and Methods (SIZE2)
Number Of local Methods (NOM)
Structural Complexity
McCabe Cyclomatic Complexity (CC)
Weighted Method Count (WMC)
Response For a Class (RFC)
clvii
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
Zarko Acimovic
SimpleTextForm.java
1
2
3
4
5
6
7
8
9
10
11
/**
* Simple text form
*/
import javax.microedition.lcdui.*;
//import javax.microedition.midlet.*;
//import java.io.*;
clviii
//import java.util.*;
Zarko Acimovic
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
Class Name
MapsMIDlet
MapBackground
Outlook
DelRoute
MapObjects
CompassCanvas
PVector
Point
MathFP
ImageCanvas3
TextFormFriend
TextFormWP
TextForm
Thread4Friend
MapsMIDlet
SelectorPoint
Friend
SimpleTextForm
MapBackgroundFactory
HeapSorter
TextFormImage
Coordinates
CommaHyphenString
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
Complexity
Size
Lines of Code (LOC)
Interface Complexity
Number of Attributes and Methods (SIZE2)
clx
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
clxi
Zarko Acimovic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* Text form
*/
import javax.microedition.lcdui.*;
//import javax.microedition.midlet.*;
//import java.io.*;
//import java.util.*;
clxii
*/
TextForm(String[] s, boolean first){
super("Data Input");
nameWP = new TextField("Name","",50,0);
typeWP = new TextField("Type","",50,0);
this.append(nameWP);
if(first = false){
//this.append(typeWP);
this.append("");
chgr = new ChoiceGroup("Category",1,s,null);
this.append(chgr);
lat = new TextField("Latitude","",50,0);
lon = new TextField("Longitude","",50,0);
this.append(lat);
this.append(lon);
}else{
lat = new TextField("Latitude","",50,0);
lon = new TextField("Longitude","",50,0);
this.append(lat);
this.append(lon);
this.append("");
chgr = new ChoiceGroup("Category:",1,s,null);
this.append(chgr);
}
}
/** Returns the name of waypoint
* @return String
*/
public String getName(){
return nameWP.getString();
}
/** Returns the type of waypoint
* @return String
*/
public String getType(){
return typeWP.getString();
}
/** Sets the name of waypoint
*/
public void setName(String s){
nameWP.setString(s);
}
/** Sets the type of waypoint
clxiii
Zarko Acimovic
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
*/
public void setType(String s){
typeWP.setString(s);
}
public int getSelected(){
return chgr.getSelectedIndex();
}
public void setLat(long s){
lat.setString(MathFP.toString(s));
}
public void setLon(long s){
lon.setString(MathFP.toString(s));
}
public void setLat(String s){
lat.setString(s);
}
public void setLon(String s){
lon.setString(s);
}
public String getLat(){
return lat.getString();
}
public String getLon(){
return lon.getString();
}
}
clxiv
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
Complexity
Size
Lines of Code (LOC)
Interface Complexity
Number of Attributes and Methods (SIZE2)
Number Of local Methods (NOM)
Structural Complexity
McCabe Cyclomatic Complexity (CC)
Weighted Method Count (WMC)
Response For a Class (RFC)
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
Zarko Acimovic
/**
* Text form
*/
import javax.microedition.lcdui.*;
//import javax.microedition.midlet.*;
clxvi
//import java.io.*;
//import java.util.*;
Zarko Acimovic
60
61
62
63
64
65
66
Class Name
MapsMIDlet
MapBackground
Outlook
DelRoute
MapObjects
CompassCanvas
PVector
Point
MathFP
ImageCanvas3
TextFormFriend
TextFormWP
TextForm
Thread4Friend
MapsMIDlet
SelectorPoint
Friend
SimpleTextForm
MapBackgroundFactory
HeapSorter
TextFormImage
Coordinates
CommaHyphenString
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
Complexity
Size
Lines of Code (LOC)
Interface Complexity
clxviii
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
clxix
Zarko Acimovic
Documentation
Lack Of Documentation (LOD)
Code Conventions
/**
* Text form for ChoicGroup with images
*/
import javax.microedition.lcdui.*;
//import javax.microedition.midlet.*;
//import java.io.*;
//import java.util.*;
clxx
// TextField lon;
ChoiceGroup chgr;
Zarko Acimovic
84
85
86
87
88
89
Class Name
MapsMIDlet
MapBackground
Outlook
DelRoute
MapObjects
CompassCanvas
PVector
Point
MathFP
ImageCanvas3
TextFormFriend
TextFormWP
TextForm
Thread4Friend
MapsMIDlet
SelectorPoint
Friend
SimpleTextForm
MapBackgroundFactory
HeapSorter
TextFormImage
Coordinates
CommaHyphenString
}
public void setLon(long s){
//lon.setString(MathFP.toString(s));
}
}
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
Complexity
Size
Lines of Code (LOC)
Interface Complexity
Number of Attributes and Methods (SIZE2)
Number Of local Methods (NOM)
Structural Complexity
McCabe Cyclomatic Complexity (CC)
Weighted Method Count (WMC)
Response For a Class (RFC)
clxxii
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
Zarko Acimovic
connected components in a class. A component are methods of a class sharing (being connected by) instance
variables of the class. The less separate components there are the higher is the cohesion of the methods in the
class.
http://www.arisa.se/compendium/node117.html
TextFormWP.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* Text form for insertion of waypoint
*/
import javax.microedition.lcdui.*;
//import javax.microedition.midlet.*;
//import java.io.*;
//import java.util.*;
clxxiv
clxxv
Zarko Acimovic
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
clxxvi
clxxvii
Zarko Acimovic
Class Name
MapsMIDlet
MapBackground
Outlook
DelRoute
MapObjects
CompassCanvas
PVector
Point
MathFP
ImageCanvas3
TextFormFriend
TextFormWP
TextForm
Thread4Friend
MapsMIDlet
SelectorPoint
Friend
SimpleTextForm
MapBackgroundFactory
HeapSorter
TextFormImage
Coordinates
CommaHyphenString
Maintainability
0.4696
0
0.0490881667
0.068318936
0
0.0490881667
0.068318936
0.2540449746
0.0981763335
0.0490881667
0.068318936
0.2049568079
0.1366378719
0.1174071027
0.4696284108
0
0.0490881667
0.068318936
0.2049568079
0.1857260387
0.1366378719
0.1366378719
0.1366378719
CBO
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
CYC_Classes
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
DAC
15
2
5
0
5
3
3
2
0
1
0
0
1
5
15
6
1
0
1
0
0
1
0
Complexity
Size
Lines of Code (LOC)
Interface Complexity
Number of Attributes and Methods (SIZE2)
Number Of local Methods (NOM)
Structural Complexity
McCabe Cyclomatic Complexity (CC)
Weighted Method Count (WMC)
Response For a Class (RFC)
LD
0.9909
1.923
0.9
1
1
0.864
1
1.3
0.875
1
0
0
0
1
0.991
1
1
0
0
0
0
0.285
0
LEN
10
13
7
8
10
13
7
5
6
12
14
10
8
13
10
13
6
14
20
10
13
11
17
LOC
1356
616
103
23
370
291
313
699
440
52
52
175
103
173
1356
520
50
70
32
125
75
266
80
LOD_Class MPC
0.667
152
0.29
27
0.917
19
0.75
0
0.4
54
1
78
0.334
25
0.18
33
0.86
0
1
5
0.33
0
0.077
0
0.67
2
0.875
5
0.67
152
0.381
90
0.889
1
0.5
0
0.5
1
0.929
0
0.556
0
0
31
0.167
0
NAM
134
77
21
5
41
26
21
60
46
3
7
23
16
16
134
28
12
11
2
13
11
21
6
NOC
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NOM
11
30
11
3
29
3
17
38
34
2
5
12
11
7
11
20
8
7
1
13
8
10
5
RFC
95
40
27
3
53
14
32
45
34
6
5
12
12
11
95
63
9
7
1
13
8
20
5
TCC
0.1429
0.207
0.436
0
0.29
1
0.037
0.074
0.16
1
0.4
0.03
0.145
0.048
0.143
0.36
0.25
0.29
0
0
0.107
0.083
0
WMC
142
59
20
3
70
13
40
51
95
6
5
12
11
18
142
71
9
7
1
27
8
16
13
Lack Of Documentation Description. How many comments are lacking in a class, considering one class comment
and a comment per method as optimum. Structure and content of the comments are ignored.
http://www.arisa.se/compendium/node121.html
Tight Class Cohesion Description
The Tight Class Cohesion metric measures the cohesion between the public methods of a class. That is the
relative number of directly connected public methods in the class. Classes having a low cohesion indicate errors
in the design. http://www.arisa.se/compendium/node118.html
Thread4Friend.java
1
2
3
4
5
6
/**
*
* Thread4Friend controls apperance of friend's position on screen
*/
//import javax.microedition.lcdui.*;
clxxix
Zarko Acimovic
7 //import javax.microedition.midlet.*;
8
9 import java.util.*;
10 import java.io.*;
11
12
13 public class Thread4Friend implements Runnable{
14
Thread t;
15
Vector whiteList;
16
String resource;
17
MapObjects mob;
18
ImageCanvas3 ic;
19
MapBackground mb;
20
Outlook oul;
21
int hashID;
22
boolean first = false;
23
24
Thread4Friend(Vector whiteList, String resource, MapObjects mob,
ImageCanvas3 ic, MapBackground mb, Outlook oul){
25
this.oul = oul;
26
this.mob = mob;
27
this.mb = mb;
28
this.ic = ic;
29
this.resource = resource;
30
this.whiteList = whiteList;
31
t = new Thread(this);
32
//t.start();
33
hashID = t.hashCode();
34
}
35
36
public void start(){
37
38
t.start();
39
}
40
41
public int getID(){
42
return hashID;
43
}
44
45
public void run(){
46
47
Thread current = Thread.currentThread();
48
//System.out.println*
49
Integer friendID = new Integer(current.hashCode());
50
while(whiteList.contains(friendID)){
51
current = Thread.currentThread();
52
friendID = new Integer(current.hashCode());
53
String s = this.getResourceAsString(resource);
54
int nextIndex = 6;
55
int index = s.indexOf('\n');
56
clxxx
clxxxi
Zarko Acimovic
99
if(wp!=null &&
whiteList.contains(friendID)){
100
mob.setDrawablePoints();
101
mob.updateFriend(friendID,wp);
102
if(first==false) {
103
mb.setBackground(wp);
104
first=true;
105
}
106
ic.repaint();
107
}
108
}
109
}
110
}
111
112
113
114
/** Blanco characters are possible to occur in names of pictures;
115
* Integer representations of blanko characters are 9 and 32
116
* Also, characters with integer representation between 0 and 33
117
* can not be printed out in WSDD console, so I excluded them too
118
*/
119
public String compact(String s){
120
int k = s.length();
121
//System.out.println("Length of s is "+s.length());
122
char[] d = s.toCharArray();
123
String ret = "";
124
for(int i=0; i<d.length; i++){
125
int temp = (int)d[i];
126
if(temp>32) ret+=d[i];
127
}
128
//System.out.println("Length of ret is "+ret.length());
129
int kk = ret.length();
130
//if (kk!=k) System.out.println("Bugger is: "+s);
131
return ret;
132
}
133
134
public String compactFine(String s){
135
int k = s.length();
136
//System.out.println("Length of s is "+s.length());
137
char[] d = s.toCharArray();
138
String ret = "";
139
for(int i=0; i<d.length; i++){
140
int temp = (int)d[i];
141
if(temp!=32 && temp!=9) ret+=d[i];
142
}
143
//System.out.println("Length of ret is "+ret.length());
144
int kk = ret.length();
145
//if (kk!=k) System.out.println("Bugger is: "+s);
146
return ret;
147
}
148
clxxxii
s=compactFine(s);
return s;
}
public void setFirst(){
first = false;
}
}
clxxxiii
Zarko Acimovic
Follow me on
https://www.facebook.com/AutomatedTesting
clxxxiv