Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
7e45d710
Commit
7e45d710
authored
Mar 11, 2019
by
Julian Zobel
Browse files
Renamed function, removed sysout
parent
74c2e2f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/attraction/RandomDynamicAttractionGenerator.java
View file @
7e45d710
...
...
@@ -89,8 +89,7 @@ public class RandomDynamicAttractionGenerator implements IAttractionGenerator {
this
.
maxDynamicIntervall
=
maxDynamicIntervall
;
attractionPoints
.
clear
();
createAttractionPoints
();
updateAttractionPoints
();
}
@Override
...
...
@@ -113,14 +112,13 @@ public class RandomDynamicAttractionGenerator implements IAttractionGenerator {
// maybe was already removed...
if
(
attractionPoints
.
contains
(
attractionPoint
))
{
attractionPoints
.
remove
(
attractionPoint
);
cre
ateAttractionPoints
();
upd
ateAttractionPoints
();
}
}
},
null
,
0
);
}
protected
void
createAttractionPoints
()
{
protected
void
updateAttractionPoints
()
{
int
numberOfAttractionPoints
=
randomNumberOfAttractionPoints
();
// do nothing if this is the required amount of attraction points
...
...
@@ -129,34 +127,33 @@ public class RandomDynamicAttractionGenerator implements IAttractionGenerator {
}
// remove until this number fits
else
if
(
numberOfAttractionPoints
<
attractionPoints
.
size
())
{
else
if
(
numberOfAttractionPoints
<
attractionPoints
.
size
())
{
int
deltaAP
=
attractionPoints
.
size
()
-
numberOfAttractionPoints
;
int
deltaAP
=
attractionPoints
.
size
()
-
numberOfAttractionPoints
;
for
(
int
i
=
0
;
i
<
deltaAP
;
i
++)
{
for
(
int
i
=
0
;
i
<
deltaAP
;
i
++)
{
int
random
=
rand
.
nextInt
(
attractionPoints
.
size
());
attractionPoints
.
remove
(
random
);
}
}
return
;
}
// add more attraction points until it fits
else
{
int
deltaAP
=
numberOfAttractionPoints
-
attractionPoints
.
size
();
else
{
int
deltaAP
=
numberOfAttractionPoints
-
attractionPoints
.
size
();
for
(
int
i
=
0
;
i
<
deltaAP
;
i
++)
{
for
(
int
i
=
0
;
i
<
deltaAP
;
i
++)
{
AttractionPoint
newAP
=
createAttractionPoint
();
scheduleDynamicEvent
(
newAP
);
attractionPoints
.
add
(
newAP
);
}
}
}
}
/**
* Create an attraction point that is conform to all other currently saved attraction points.
*
* @return
*/
private
AttractionPoint
createAttractionPoint
()
{
// make a break counter to prevent more than 10 iterations and an infinity loop in general.
int
c
=
20
;
...
...
@@ -167,8 +164,7 @@ public class RandomDynamicAttractionGenerator implements IAttractionGenerator {
// set the radius of this attraction point
// minimum radius is 10 meters
double
radius
=
Math
.
max
(
minimumRadius
,
rand
.
nextDouble
()
*
maximumRadius
);
System
.
out
.
println
(
radius
);
if
(
i
<
c
)
{
// check if the attraction points would be completely within world dimensions (including radius!)
if
((
posVec
.
getX
()
+
radius
)
>=
worldDimension
.
getX
()
||
(
posVec
.
getY
()
+
radius
)
>=
worldDimension
.
getY
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment