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
176ded37
Commit
176ded37
authored
Apr 17, 2017
by
Christian
Browse files
Visualization for surf project
parent
d529c723
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/views/VisualizationTopologyView.java
View file @
176ded37
...
...
@@ -388,10 +388,16 @@ public class VisualizationTopologyView extends JFrame
protected
class
WorldPanel
extends
JLayeredPane
{
protected
HashMap
<
INodeID
,
VisNodeInformation
>
nodeInformation
=
new
HashMap
<
INodeID
,
VisNodeInformation
>();
protected
HashMap
<
INodeID
,
VisNodeInformation
>
staticGwNodeInformation
=
new
HashMap
<
INodeID
,
VisNodeInformation
>();
protected
HashMap
<
INodeID
,
VisNodeInformation
>
mobileGwNodeInformation
=
new
HashMap
<
INodeID
,
VisNodeInformation
>();
protected
HashMap
<
INodeID
,
VisNodeInformation
>
citizenNodeInformation
=
new
HashMap
<
INodeID
,
VisNodeInformation
>();
protected
final
static
int
PADDING
=
16
;
protected
final
static
int
NODE_PAD
=
2
;
protected
final
static
int
STATIC_GW_NODE_PAD
=
3
;
protected
final
static
int
MOBILE_GW_NODE_PAD
=
2
;
protected
final
static
int
CITIZEN_NODE_PAD
=
2
;
private
static
final
long
serialVersionUID
=
-
3023020559483652110L
;
...
...
@@ -439,10 +445,39 @@ public class VisualizationTopologyView extends JFrame
}
public
void
addTopologyComponent
(
TopologyComponent
comp
)
{
if
(!
nodeInformation
.
containsKey
(
comp
.
getHost
().
getId
()))
{
VisNodeInformation
tVis
=
new
VisNodeInformation
(
comp
);
comp
.
requestLocationUpdates
(
null
,
tVis
);
nodeInformation
.
put
(
comp
.
getHost
().
getId
(),
tVis
);
if
(
comp
.
getHost
().
toString
().
contains
(
"StaticGateways"
)){
if
(!
staticGwNodeInformation
.
containsKey
(
comp
.
getHost
().
getId
()))
{
VisNodeInformation
tVis
=
new
VisNodeInformation
(
comp
);
comp
.
requestLocationUpdates
(
null
,
tVis
);
staticGwNodeInformation
.
put
(
comp
.
getHost
().
getId
(),
tVis
);
}
}
else
{
if
(
comp
.
getHost
().
toString
().
contains
(
"MobileGateways"
)){
if
(!
mobileGwNodeInformation
.
containsKey
(
comp
.
getHost
().
getId
()))
{
VisNodeInformation
tVis
=
new
VisNodeInformation
(
comp
);
comp
.
requestLocationUpdates
(
null
,
tVis
);
mobileGwNodeInformation
.
put
(
comp
.
getHost
().
getId
(),
tVis
);
}
}
else
{
if
(
comp
.
getHost
().
toString
().
contains
(
"Citizens"
)){
if
(!
citizenNodeInformation
.
containsKey
(
comp
.
getHost
().
getId
()))
{
VisNodeInformation
tVis
=
new
VisNodeInformation
(
comp
);
comp
.
requestLocationUpdates
(
null
,
tVis
);
citizenNodeInformation
.
put
(
comp
.
getHost
().
getId
(),
tVis
);
}
}
else
{
if
(!
nodeInformation
.
containsKey
(
comp
.
getHost
().
getId
()))
{
VisNodeInformation
tVis
=
new
VisNodeInformation
(
comp
);
comp
.
requestLocationUpdates
(
null
,
tVis
);
System
.
out
.
println
(
"HERE: "
+
comp
.
getHost
().
toString
());
nodeInformation
.
put
(
comp
.
getHost
().
getId
(),
tVis
);
}
}
}
}
}
...
...
@@ -478,6 +513,79 @@ public class VisualizationTopologyView extends JFrame
}
}
}
for
(
VisNodeInformation
node
:
staticGwNodeInformation
.
values
())
{
if
(
node
.
clicked
)
{
g2
.
setColor
(
Color
.
MAGENTA
);
g2
.
fillRect
((
int
)
node
.
position
.
getX
()
-
STATIC_GW_NODE_PAD
,
(
int
)
node
.
position
.
getY
()
-
STATIC_GW_NODE_PAD
,
STATIC_GW_NODE_PAD
*
2
+
1
,
STATIC_GW_NODE_PAD
*
2
+
1
);
g2
.
setColor
(
Color
.
BLACK
);
Font
font
=
new
Font
(
"Helvetica"
,
Font
.
BOLD
,
10
);
g2
.
setFont
(
font
);
g2
.
drawString
(
"SGw"
+
node
.
hostId
,
(
int
)
node
.
position
.
getX
()-
STATIC_GW_NODE_PAD
,(
int
)
node
.
position
.
getY
()-
STATIC_GW_NODE_PAD
);
}
else
{
if
(
showNodes
)
{
Color
col
=
new
Color
(
153
,
0
,
0
);
g2
.
setColor
(
col
);
g2
.
fillRect
((
int
)
node
.
position
.
getX
()
-
STATIC_GW_NODE_PAD
,
(
int
)
node
.
position
.
getY
()
-
STATIC_GW_NODE_PAD
,
STATIC_GW_NODE_PAD
*
2
+
1
,
STATIC_GW_NODE_PAD
*
2
+
1
);
g2
.
setColor
(
Color
.
BLACK
);
Font
font
=
new
Font
(
"Helvetica"
,
Font
.
BOLD
,
10
);
g2
.
setFont
(
font
);
g2
.
drawString
(
"SGw"
+
node
.
hostId
,
(
int
)
node
.
position
.
getX
()-
STATIC_GW_NODE_PAD
,(
int
)
node
.
position
.
getY
()-
STATIC_GW_NODE_PAD
);
}
}
}
for
(
VisNodeInformation
node
:
mobileGwNodeInformation
.
values
())
{
if
(
node
.
clicked
)
{
g2
.
setColor
(
Color
.
MAGENTA
);
g2
.
fillRect
((
int
)
node
.
position
.
getX
()
-
MOBILE_GW_NODE_PAD
,
(
int
)
node
.
position
.
getY
()
-
MOBILE_GW_NODE_PAD
,
MOBILE_GW_NODE_PAD
*
2
+
5
,
MOBILE_GW_NODE_PAD
*
2
);
g2
.
setColor
(
Color
.
BLACK
);
Font
font
=
new
Font
(
"Helvetica"
,
Font
.
BOLD
,
10
);
g2
.
setFont
(
font
);
g2
.
drawString
(
"MGw"
+
node
.
hostId
,
(
int
)
node
.
position
.
getX
()-
MOBILE_GW_NODE_PAD
,(
int
)
node
.
position
.
getY
()-
MOBILE_GW_NODE_PAD
);
}
else
{
if
(
showNodes
)
{
// Draw nodes
Color
col
=
new
Color
(
0
,
76
,
153
);
g2
.
setColor
(
col
);
g2
.
fillRect
((
int
)
node
.
position
.
getX
()
-
MOBILE_GW_NODE_PAD
,
(
int
)
node
.
position
.
getY
()
-
MOBILE_GW_NODE_PAD
,
MOBILE_GW_NODE_PAD
*
2
+
5
,
MOBILE_GW_NODE_PAD
*
2
);
g2
.
setColor
(
Color
.
BLACK
);
Font
font
=
new
Font
(
"Helvetica"
,
Font
.
BOLD
,
10
);
g2
.
setFont
(
font
);
g2
.
drawString
(
"MGw"
+
node
.
hostId
,
(
int
)
node
.
position
.
getX
()-
MOBILE_GW_NODE_PAD
,(
int
)
node
.
position
.
getY
()-
MOBILE_GW_NODE_PAD
);
}
}
}
for
(
VisNodeInformation
node
:
citizenNodeInformation
.
values
())
{
if
(
node
.
clicked
)
{
g2
.
setColor
(
Color
.
MAGENTA
);
g2
.
fillOval
((
int
)
node
.
position
.
getX
()
-
CITIZEN_NODE_PAD
,
(
int
)
node
.
position
.
getY
()
-
CITIZEN_NODE_PAD
,
CITIZEN_NODE_PAD
*
2
+
1
,
CITIZEN_NODE_PAD
*
2
+
1
);
/*g2.setColor(Color.BLACK);
Font font = new Font("Helvetica", Font.BOLD, 12);
g2.setFont(font);
g2.drawString("Cit"+node.hostId, (int) node.position.getX()- CITIZEN_NODE_PAD,(int) node.position.getY()- CITIZEN_NODE_PAD);*/
}
else
{
if
(
showNodes
)
{
// Draw nodes
g2
.
setColor
(
Color
.
GREEN
);
g2
.
fillOval
((
int
)
node
.
position
.
getX
()
-
CITIZEN_NODE_PAD
,
(
int
)
node
.
position
.
getY
()
-
CITIZEN_NODE_PAD
,
CITIZEN_NODE_PAD
*
2
+
1
,
CITIZEN_NODE_PAD
*
2
+
1
);
/*g2.setColor(Color.BLACK);
Font font = new Font("Helvetica", Font.BOLD, 12);
g2.setFont(font);
g2.drawString("Cit"+node.hostId, (int) node.position.getX()- CITIZEN_NODE_PAD,(int) node.position.getY()- CITIZEN_NODE_PAD);*/
}
}
}
}
}
...
...
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