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
db3d7740
Commit
db3d7740
authored
Mar 08, 2017
by
Simon Luser
Browse files
adapted Vis
parent
2ac40564
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/common/DefaultMonitor.java
View file @
db3d7740
...
...
@@ -215,7 +215,7 @@ public class DefaultMonitor implements MonitorComponent, EventHandler,
analyzer
.
stop
(
output
);
}
output
.
write
(
"*******************************************************\n"
);
//
output.close();
output
.
close
();
}
catch
(
IOException
e
)
{
throw
new
AssertionError
();
}
...
...
src/de/tud/kom/p2psim/impl/topology/views/RangedTopologyView.java
View file @
db3d7740
...
...
@@ -141,7 +141,7 @@ public class RangedTopologyView extends AbstractTopologyView<RangedLink> {
* @return max distance between hosts to still be able to communicate (ie.
* wireless range)
*/
p
rotected
double
getRange
()
{
p
ublic
double
getRange
()
{
return
range
;
}
...
...
src/de/tud/kom/p2psim/impl/topology/views/VisualizationTopologyView.java
View file @
db3d7740
...
...
@@ -40,9 +40,9 @@ import java.awt.event.MouseAdapter;
import
java.awt.event.MouseEvent
;
import
java.awt.geom.Point2D
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentLinkedQueue
;
import
java.util.concurrent.CopyOnWriteArrayList
;
...
...
@@ -385,64 +385,64 @@ public class VisualizationTopologyView extends JFrame
* @author Bjoern Richerzhagen
* @version 1.0, 19.03.2012
*/
p
rotected
class
WorldPanel
extends
JLayeredPane
{
p
ublic
class
WorldPanel
extends
JLayeredPane
{
protected
HashMap
<
INodeID
,
VisNodeInformation
>
nodeInformation
=
new
HashMap
<
INodeID
,
VisNodeInformation
>();
protected
Concurrent
HashMap
<
INodeID
,
VisNodeInformation
>
nodeInformation
=
new
Concurrent
HashMap
<
INodeID
,
VisNodeInformation
>();
p
rotected
final
static
int
PADDING
=
16
;
p
ublic
final
static
int
PADDING
=
16
;
p
rotected
final
static
int
NODE_PAD
=
2
;
p
ublic
final
static
int
NODE_PAD
=
2
;
private
static
final
long
serialVersionUID
=
-
3023020559483652110L
;
public
WorldPanel
()
{
this
.
setLayout
(
null
);
this
.
setDoubleBuffered
(
true
);
this
.
addMouseListener
(
new
MouseAdapter
()
{
/**
* Stores the mouse position, if the mouse button is pressed
*/
@Override
public
void
mousePressed
(
MouseEvent
e
)
{
boolean
turnedSomeoneOff
=
false
;
for
(
VisNodeInformation
node
:
nodeInformation
.
values
())
{
// Make it easier to turn things off.
if
(
node
.
clicked
&&
node
.
position
.
distance
(
e
.
getPoint
())
<
PADDING
+
2
)
{
node
.
clicked
=
!
node
.
clicked
;
VisualizationInjector
.
notifyInteractionListenersOnClick
(
node
.
hostId
,
node
.
clicked
);
turnedSomeoneOff
=
true
;
}
}
if
(!
turnedSomeoneOff
)
{
// Turn sth on (limit to one node)
for
(
VisNodeInformation
node
:
nodeInformation
.
values
())
{
if
(
node
.
disableClickListener
)
{
continue
;
}
if
(!
node
.
clicked
&&
node
.
position
.
distance
(
e
.
getPoint
())
<
PADDING
)
{
node
.
clicked
=
!
node
.
clicked
;
VisualizationInjector
.
notifyInteractionListenersOnClick
(
node
.
hostId
,
node
.
clicked
);
break
;
}
}
}
}
});
//
this.addMouseListener(new MouseAdapter() {
//
//
/**
//
* Stores the mouse position, if the mouse button is pressed
//
*/
//
@Override
//
public void mousePressed(MouseEvent e) {
//
boolean turnedSomeoneOff = false;
//
for (VisNodeInformation node : nodeInformation.values()) {
//
// Make it easier to turn things off.
//
if (node.clicked && node.position
//
.distance(e.getPoint()) < PADDING + 2) {
//
node.clicked = !node.clicked;
//
VisualizationInjector
//
.notifyInteractionListenersOnClick(
//
node.hostId, node.clicked);
//
turnedSomeoneOff = true;
//
}
//
}
//
if (!turnedSomeoneOff) {
//
// Turn sth on (limit to one node)
//
for (VisNodeInformation node : nodeInformation.values()) {
//
if (node.disableClickListener) {
//
continue;
//
}
//
if (!node.clicked && node.position
//
.distance(e.getPoint()) < PADDING) {
//
node.clicked = !node.clicked;
//
VisualizationInjector
//
.notifyInteractionListenersOnClick(
//
node.hostId, node.clicked);
//
break;
//
}
//
}
//
}
//
}
//
//
});
}
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
);
nodeInformation
.
put
IfAbsent
(
comp
.
getHost
().
getId
(),
tVis
);
}
}
...
...
@@ -454,32 +454,31 @@ public class VisualizationTopologyView extends JFrame
@Override
protected
void
paintComponent
(
Graphics
g
)
{
Graphics2D
g2
=
(
Graphics2D
)
g
;
g2
.
setRenderingHint
(
RenderingHints
.
KEY_ANTIALIASING
,
RenderingHints
.
VALUE_ANTIALIAS_ON
);
paintNodes
(
g2
);
//
Graphics2D g2 = (Graphics2D) g;
//
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
//
RenderingHints.VALUE_ANTIALIAS_ON);
//
paintNodes(g2);
super
.
paintComponent
(
g
);
}
private
void
paintNodes
(
Graphics2D
g2
)
{
for
(
VisNodeInformation
node
:
nodeInformation
.
values
())
{
if
(
node
.
clicked
)
{
g2
.
setColor
(
Color
.
MAGENTA
);
g2
.
fillOval
((
int
)
node
.
position
.
getX
()
-
PADDING
,
(
int
)
node
.
position
.
getY
()
-
PADDING
,
PADDING
*
2
+
1
,
PADDING
*
2
+
1
);
}
else
{
if
(
showNodes
)
{
// Draw nodes
g2
.
setColor
(
Color
.
DARK_GRAY
);
g2
.
fillOval
((
int
)
node
.
position
.
getX
()
-
NODE_PAD
,
(
int
)
node
.
position
.
getY
()
-
NODE_PAD
,
NODE_PAD
*
2
+
1
,
NODE_PAD
*
2
+
1
);
}
}
}
}
// private void paintNodes(Graphics2D g2) {
// for (VisNodeInformation node : nodeInformation.values()) {
// if (node.clicked) {
// g2.setColor(Color.MAGENTA);
// g2.fillOval((int) node.position.getX() - PADDING,
// (int) node.position.getY() - PADDING,
// PADDING * 2 + 1, PADDING * 2 + 1);
// } else {
// if (showNodes) {
// // Draw nodes
// g2.setColor(Color.DARK_GRAY);
// g2.fillOval((int) node.position.getX() - NODE_PAD,
// (int) node.position.getY() - NODE_PAD,
// NODE_PAD * 2 + 1, NODE_PAD * 2 + 1);
// }
// }
// }
// }
}
public
void
notifyInteractionListenersOnClick
(
long
hostid
,
...
...
src/de/tud/kom/p2psim/impl/topology/views/visualization/ui/VisHelper.java
View file @
db3d7740
...
...
@@ -26,6 +26,9 @@ import java.awt.Point;
import
java.awt.Polygon
;
import
java.awt.geom.Point2D
;
import
de.tud.kom.p2psim.impl.topology.PositionVector
;
import
de.tud.kom.p2psim.impl.util.Triple
;
/**
* Helpers for your own visualization components
*
...
...
@@ -76,4 +79,24 @@ public class VisHelper {
drawArrow
(
g2
,
from
.
getX
(),
from
.
getY
(),
to
.
getX
(),
to
.
getY
(),
thickness
);
}
/**
* uses the start-/end position and the percentage and determines with
* vector addition the new position on the line between start and end
* according to the percentage of already traveled distance.
*
* @param messageBall
* @return the current position of the message.
*/
public
static
PositionVector
determineNewMessageBallPosition
(
Triple
<
PositionVector
,
PositionVector
,
Integer
>
messageBall
)
{
double
distance
=
messageBall
.
getA
().
distanceTo
(
messageBall
.
getB
());
PositionVector
differenceVector
=
messageBall
.
getB
()
.
minus
(
messageBall
.
getA
());
differenceVector
.
normalize
();
differenceVector
.
multiplyScalar
(
messageBall
.
getC
().
doubleValue
()
/
100
d
*
distance
);
PositionVector
pos
=
messageBall
.
getA
().
clone
();
pos
.
add
(
differenceVector
);
return
pos
;
}
}
src/de/tud/kom/p2psim/impl/topology/views/visualization/ui/XYChart.java
View file @
db3d7740
...
...
@@ -64,7 +64,7 @@ public class XYChart {
dataset
=
new
YIntervalSeriesCollection
();
dataset
.
addSeries
(
new
YIntervalSeries
(
seriesName
));
chart
=
ChartFactory
.
createXYLineChart
(
null
,
"Time [
h:m:
s]"
,
null
,
dataset
,
PlotOrientation
.
VERTICAL
,
true
,
true
,
false
);
chart
=
ChartFactory
.
createXYLineChart
(
null
,
"Time [s]"
,
null
,
dataset
,
PlotOrientation
.
VERTICAL
,
true
,
true
,
false
);
chart
.
setBackgroundPaint
(
plotBackgroundColor
);
XYPlot
plot
=
(
XYPlot
)
chart
.
getPlot
();
...
...
@@ -93,15 +93,24 @@ public class XYChart {
//plot.setFixedLegendItems(new LegendItemCollection());
DeviationRenderer
errorRenderer
=
new
DeviationRenderer
(
true
,
true
);
errorRenderer
.
setSeriesStroke
(
0
,
new
BasicStroke
(
3
F
,
1
,
1
));
errorRenderer
.
setSeriesStroke
(
1
,
new
BasicStroke
(
3
F
,
1
,
1
));
errorRenderer
.
setSeriesStroke
(
2
,
new
BasicStroke
(
3
F
,
1
,
1
));
errorRenderer
.
setSeriesFillPaint
(
0
,
new
Color
(
255
,
200
,
200
));
errorRenderer
.
setSeriesFillPaint
(
1
,
new
Color
(
200
,
200
,
255
));
errorRenderer
.
setSeriesFillPaint
(
2
,
new
Color
(
200
,
255
,
200
));
errorRenderer
.
setSeriesStroke
(
0
,
new
BasicStroke
(
2
F
,
1
,
1
));
errorRenderer
.
setSeriesStroke
(
1
,
new
BasicStroke
(
1
F
,
1
,
1
));
errorRenderer
.
setSeriesStroke
(
2
,
new
BasicStroke
(
1
F
,
1
,
1
));
errorRenderer
.
setSeriesStroke
(
3
,
new
BasicStroke
(
1
F
,
1
,
1
));
errorRenderer
.
setSeriesStroke
(
4
,
new
BasicStroke
(
1
F
,
1
,
1
));
errorRenderer
.
setSeriesStroke
(
5
,
new
BasicStroke
(
1
F
,
1
,
1
));
errorRenderer
.
setSeriesFillPaint
(
0
,
new
Color
(
255
,
0
,
0
));
errorRenderer
.
setSeriesFillPaint
(
1
,
new
Color
(
0
,
0
,
255
));
errorRenderer
.
setSeriesFillPaint
(
2
,
new
Color
(
0
,
255
,
0
));
errorRenderer
.
setSeriesFillPaint
(
3
,
new
Color
(
255
,
255
,
0
));
errorRenderer
.
setSeriesFillPaint
(
4
,
new
Color
(
128
,
0
,
0
));
errorRenderer
.
setSeriesFillPaint
(
5
,
new
Color
(
0
,
255
,
255
));
errorRenderer
.
setSeriesPaint
(
0
,
new
Color
(
255
,
0
,
0
));
errorRenderer
.
setSeriesPaint
(
1
,
new
Color
(
0
,
0
,
255
));
errorRenderer
.
setSeriesPaint
(
2
,
new
Color
(
0
,
255
,
0
));
errorRenderer
.
setSeriesPaint
(
3
,
new
Color
(
255
,
255
,
0
));
errorRenderer
.
setSeriesPaint
(
4
,
new
Color
(
128
,
0
,
0
));
errorRenderer
.
setSeriesPaint
(
5
,
new
Color
(
0
,
255
,
255
));
//errorRenderer.setShapesVisible(false);
//errorRenderer.setLinesVisible(true);
//errorRenderer.setAlpha(0.0f);
...
...
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