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
2fa7daee
Commit
2fa7daee
authored
Oct 28, 2015
by
Björn Richerzhagen
Browse files
Refactored Visualization of Underlay-Links
- re-enabled neighbors on hover & click - preparations for scaled visualizations
parent
20020ed4
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/views/RangedTopologyView.java
View file @
2fa7daee
...
...
@@ -123,7 +123,9 @@ public class RangedTopologyView extends AbstractTopologyView<RangedLink> {
determineLinkBandwidth
(
source
,
destination
),
determineLinkLatency
(
source
,
destination
),
getPhyType
()
.
getDefaultMTU
(),
getRange
());
linkList
.
add
(
link
);
synchronized
(
linkList
)
{
linkList
.
add
(
link
);
}
return
link
;
}
...
...
src/de/tud/kom/p2psim/impl/topology/views/VisualizationTopologyView.java
View file @
2fa7daee
...
...
@@ -77,6 +77,7 @@ import de.tud.kom.p2psim.impl.topology.views.visualization.world.StrongWaypointC
import
de.tud.kom.p2psim.impl.topology.views.visualization.world.TopologyComponentVis
;
import
de.tud.kom.p2psim.impl.topology.views.visualization.world.WeakWaypointComponentVis
;
import
de.tud.kom.p2psim.impl.util.NotSupportedException
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID
;
import
de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor
;
/**
...
...
@@ -101,7 +102,7 @@ public class VisualizationTopologyView extends JFrame implements TopologyView,
public
static
double
SCALE
;
protected
HashMap
<
Long
,
TopologyComponentVis
>
compVisPerHost
=
new
HashMap
<
Long
,
TopologyComponentVis
>();
protected
HashMap
<
INodeID
,
TopologyComponentVis
>
compVisPerHost
=
new
HashMap
<
INodeID
,
TopologyComponentVis
>();
protected
final
WorldPanel
worldPanel
;
...
...
@@ -213,9 +214,9 @@ public class VisualizationTopologyView extends JFrame implements TopologyView,
@Override
public
void
addedComponent
(
TopologyComponent
comp
)
{
if
(!
compVisPerHost
.
containsKey
(
comp
.
getHost
().
get
Host
Id
()))
{
if
(!
compVisPerHost
.
containsKey
(
comp
.
getHost
().
getId
()))
{
TopologyComponentVis
tVis
=
new
TopologyComponentVis
(
this
,
comp
);
compVisPerHost
.
put
(
comp
.
getHost
().
get
Host
Id
(),
tVis
);
compVisPerHost
.
put
(
comp
.
getHost
().
getId
(),
tVis
);
// this.visManager.addComponent("Topology", 0, new
// TopologyComponentVis(this, comp));
worldPanel
.
add
(
new
TopologyComponentVis
(
this
,
comp
));
...
...
@@ -338,6 +339,7 @@ public class VisualizationTopologyView extends JFrame implements TopologyView,
g2
.
setColor
(
Color
.
WHITE
);
g2
.
fillRect
(
0
,
0
,
(
int
)
(
WORLD_X
/
SCALE
),
(
int
)
(
WORLD_Y
/
SCALE
));
g2
.
setPaint
(
Color
.
BLACK
);
g2
.
drawLine
(
10
,
10
,
(
int
)
(
10
+
50
/
SCALE
),
10
);
}
}
...
...
@@ -397,8 +399,6 @@ public class VisualizationTopologyView extends JFrame implements TopologyView,
public
static
int
WORLD_Y
=
0
;
private
static
double
mapScale
=
1
;
protected
static
Map
<
String
,
PlottingView
>
plottingViews
=
Maps
.
newHashMap
();
...
...
@@ -452,6 +452,19 @@ public class VisualizationTopologyView extends JFrame implements TopologyView,
return
view
;
}
/**
* Returns the {@link TopologyComponentVis} corresponding to the
* provided host ID
*
* @param nodeID
* id of the host.
* @return
*/
public
static
TopologyComponentVis
getTopologyComponentVis
(
INodeID
nodeID
)
{
return
view
.
compVisPerHost
.
get
(
nodeID
);
}
private
static
void
setupAWTEventListener
()
{
Toolkit
tk
=
Toolkit
.
getDefaultToolkit
();
...
...
@@ -560,21 +573,6 @@ public class VisualizationTopologyView extends JFrame implements TopologyView,
return
WORLD_Y
;
}
public
static
double
getVisualScaleFactor
()
{
return
SCALE
;
}
/**
* Do not apply the scale factor to values that are cached for later
* use. If used in a constructor this factor can be wrong, as it might
* not have been initialized yet.
*
* @return
*/
public
static
double
getMapScale
()
{
return
mapScale
;
}
public
static
void
injectComponent
(
String
name
,
int
priority
,
JComponent
component
)
{
injectComponent
(
name
,
priority
,
component
,
true
);
...
...
src/de/tud/kom/p2psim/impl/topology/views/visualization/world/LinkComponentVis.java
View file @
2fa7daee
...
...
@@ -20,14 +20,19 @@
package
de.tud.kom.p2psim.impl.topology.views.visualization.world
;
import
java.awt.Color
;
import
java.awt.Graphics
;
import
java.awt.Graphics2D
;
import
java.util.HashSet
;
import
java.util.Set
;
import
javax.swing.JComponent
;
import
de.tud.kom.p2psim.api.linklayer.mac.Link
;
import
de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView
;
import
de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.VisualizationInjector
;
import
de.tud.kom.p2psim.impl.topology.views.visualization.ui.VisHelper
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.IEdge
;
import
de.tudarmstadt.maki.simonstrator.api.component.network.NetworkComponent.NetInterfaceName
;
import
de.tudarmstadt.maki.simonstrator.api.component.topology.TopologyID
;
/**
* Visualization of a Link
...
...
@@ -41,20 +46,23 @@ public class LinkComponentVis extends JComponent {
*
*/
private
final
VisualizationTopologyView
visualizationTopologyView
;
private
Link
link
;
private
TopologyComponentVis
src
;
private
TopologyComponentVis
dst
;
public
LinkComponentVis
(
VisualizationTopologyView
visualizationTopologyView
,
Link
link
,
TopologyComponentVis
src
,
TopologyComponentVis
dst
)
{
public
LinkComponentVis
(
VisualizationTopologyView
visualizationTopologyView
,
TopologyComponentVis
src
)
{
this
.
visualizationTopologyView
=
visualizationTopologyView
;
this
.
link
=
link
;
this
.
src
=
src
;
this
.
dst
=
dst
;
setBounds
(
0
,
0
,
(
int
)(
this
.
visualizationTopologyView
.
getWorldDimensions
().
getX
()
/
this
.
visualizationTopologyView
.
getScale
()),
(
int
)(
this
.
visualizationTopologyView
.
getWorldDimensions
().
getY
()
/
this
.
visualizationTopologyView
.
getScale
()));
setBounds
(
0
,
0
,
(
int
)
(
this
.
visualizationTopologyView
.
getWorldDimensions
().
getX
()
/
this
.
visualizationTopologyView
.
getScale
()),
(
int
)
(
this
.
visualizationTopologyView
.
getWorldDimensions
().
getY
()
/
this
.
visualizationTopologyView
.
getScale
()));
setBounds
(
0
,
0
,
(
int
)
(
this
.
visualizationTopologyView
.
getWorldDimensions
()
.
getX
()
/
this
.
visualizationTopologyView
.
getScale
()),
(
int
)
(
this
.
visualizationTopologyView
.
getWorldDimensions
()
.
getY
()
/
this
.
visualizationTopologyView
.
getScale
()));
setBounds
(
0
,
0
,
(
int
)
(
this
.
visualizationTopologyView
.
getWorldDimensions
()
.
getX
()
/
this
.
visualizationTopologyView
.
getScale
()),
(
int
)
(
this
.
visualizationTopologyView
.
getWorldDimensions
()
.
getY
()
/
this
.
visualizationTopologyView
.
getScale
()));
setOpaque
(
false
);
}
...
...
@@ -63,19 +71,16 @@ public class LinkComponentVis extends JComponent {
super
.
paintComponent
(
g
);
Graphics2D
g2
=
(
Graphics2D
)
g
;
if
(
link
.
isConnected
())
{
TopologyID
tId
=
src
.
getTopologyComp
().
getTopologyID
(
NetInterfaceName
.
WIFI
,
true
);
Set
<
IEdge
>
neighbors
=
new
HashSet
<
IEdge
>(
src
.
getTopologyComp
().
getNeighbors
(
tId
));
for
(
IEdge
mAddr
:
neighbors
)
{
TopologyComponentVis
dst
=
VisualizationInjector
.
getTopologyComponentVis
(
mAddr
.
toId
());
double
scale
=
this
.
visualizationTopologyView
.
getScale
();
g2
.
setColor
(
Color
.
BLUE
);
g2
.
drawLine
((
int
)
(
src
.
getPosition
().
getX
()
/
scale
),
(
int
)
(
src
.
getPosition
().
getY
()
/
scale
),
(
int
)
(
dst
.
getPosition
()
.
getX
()
/
scale
),
(
int
)
(
dst
.
getPosition
().
getY
()
/
scale
));
g2
.
drawLine
((
int
)
(
src
.
getPosition
().
getX
()
/
scale
),
(
int
)
(
src
.
getPosition
().
getY
()
/
scale
),
(
int
)
(
dst
.
getPosition
().
getX
()
/
scale
),
(
int
)
(
dst
.
getPosition
().
getY
()
/
scale
));
}
else
{
//
VisHelper
.
drawArrow
(
g2
,
src
.
getPosition
().
getX
()
/
scale
,
src
.
getPosition
().
getY
()
/
scale
,
dst
.
getPosition
().
getX
()
/
scale
,
dst
.
getPosition
().
getY
()
/
scale
,
2
);
}
}
...
...
src/de/tud/kom/p2psim/impl/topology/views/visualization/world/TopologyComponentVis.java
View file @
2fa7daee
...
...
@@ -27,8 +27,6 @@ import java.awt.Point;
import
java.awt.RenderingHints
;
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseEvent
;
import
java.util.List
;
import
java.util.Vector
;
import
javax.swing.JComponent
;
...
...
@@ -64,7 +62,7 @@ public class TopologyComponentVis extends JComponent {
protected
final
long
hostid
;
private
List
<
LinkComponentVis
>
myLinks
=
new
Vector
<
LinkComponentVis
>()
;
private
LinkComponentVis
lcVis
=
null
;
protected
boolean
active
=
false
;
...
...
@@ -117,10 +115,21 @@ public class TopologyComponentVis extends JComponent {
});
}
/**
* Access to the visualized {@link TopologyComponent}
*
* @return
*/
public
TopologyComponent
getTopologyComp
()
{
return
tComp
;
}
protected
void
paintComponent
(
Graphics
g
)
{
super
.
paintComponent
(
g
);
setLocation
((
int
)
((
posVec
.
getX
()
-
COMPONENT_PADDING
)
/
this
.
visualizationTopologyView
.
getScale
()),
(
int
)
((
posVec
.
getY
()
-
COMPONENT_PADDING
)
/
this
.
visualizationTopologyView
.
getScale
()));
setLocation
((
int
)
((
posVec
.
getX
()
/
this
.
visualizationTopologyView
.
getScale
()
-
COMPONENT_PADDING
)),
(
int
)
((
posVec
.
getY
()
/
this
.
visualizationTopologyView
.
getScale
()
-
COMPONENT_PADDING
)));
Graphics2D
g2
=
(
Graphics2D
)
g
;
g2
.
setRenderingHint
(
RenderingHints
.
KEY_ANTIALIASING
,
RenderingHints
.
VALUE_ANTIALIAS_ON
);
...
...
@@ -149,34 +158,15 @@ public class TopologyComponentVis extends JComponent {
}
protected
void
toggleActive
()
{
return
;
/*
active
=
!
active
;
if
(
active
)
{
TopologyView tView = tComp.getTopology().getTopologyView(this.visualizationTopologyView.PHY);
if (tView == null) {
active = !active;
return;
}
Simulator.getScheduler().pause();
List<MacAddress> neighbors = tView.getNeighbors(mac
.getMacAddress());
for (MacAddress mAddr : neighbors) {
Link l = tView.getLinkBetween(mac.getMacAddress(), mAddr);
LinkComponentVis lVis = new LinkComponentVis(this.visualizationTopologyView, l, this,
this.visualizationTopologyView.getComponentVis(mAddr));
myLinks.add(lVis);
VisualizationInjector.getWorldPanel().add(lVis);
}
Simulator.getScheduler().unpause();
} else {
for (LinkComponentVis lVis : myLinks) {
VisualizationInjector.getWorldPanel().remove(lVis);
}
lcVis
=
new
LinkComponentVis
(
this
.
visualizationTopologyView
,
TopologyComponentVis
.
this
);
VisualizationInjector
.
getWorldPanel
().
add
(
lcVis
);
}
else
if
(
lcVis
!=
null
)
{
VisualizationInjector
.
getWorldPanel
().
remove
(
lcVis
);
}
VisualizationInjector
.
getWorldPanel
().
invalidate
();
*/
}
protected
PositionVector
getPosition
()
{
...
...
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