Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
PeerfactSim.KOM
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Simonstrator
PeerfactSim.KOM
Commits
8853adf6
Commit
8853adf6
authored
8 years ago
by
Björn Richerzhagen
Browse files
Options
Downloads
Patches
Plain Diff
Updated NodeInfo Visualization
parent
9fab7de8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/de/tud/kom/p2psim/impl/topology/views/visualization/world/NodeInfoComponentVis.java
+77
-28
77 additions, 28 deletions
...ology/views/visualization/world/NodeInfoComponentVis.java
with
77 additions
and
28 deletions
src/de/tud/kom/p2psim/impl/topology/views/visualization/world/NodeInfoComponentVis.java
+
77
−
28
View file @
8853adf6
...
...
@@ -20,6 +20,8 @@
package
de.tud.kom.p2psim.impl.topology.views.visualization.world
;
import
java.awt.AlphaComposite
;
import
java.awt.BasicStroke
;
import
java.awt.Color
;
import
java.awt.Graphics
;
import
java.awt.Graphics2D
;
...
...
@@ -165,15 +167,56 @@ public class NodeInfoComponentVis extends JComponent
private
final
Color
activeGreen
=
new
Color
(
0
,
200
,
0
);
private
final
Color
[]
colors
=
{
Color
.
ORANGE
,
Color
.
BLUE
,
Color
.
RED
,
Color
.
MAGENTA
,
Color
.
GRAY
,
Color
.
GREEN
,
Color
.
CYAN
,
Color
.
PINK
};
private
final
Color
[]
baseColors
=
{
Color
.
ORANGE
,
Color
.
BLUE
,
Color
.
RED
,
Color
.
PINK
,
Color
.
GRAY
,
Color
.
GREEN
,
Color
.
CYAN
,
Color
.
WHITE
};
private
final
Color
[]
tuColors
=
{
new
Color
(
93
,
133
,
195
),
// 1a
new
Color
(
80
,
182
,
149
),
// 3a
// new Color(221,223,72), // 5a
new
Color
(
248
,
186
,
60
),
// 7a
new
Color
(
233
,
80
,
62
),
// 9a
new
Color
(
128
,
69
,
151
),
// 11a
new
Color
(
0
,
78
,
138
),
// 1c
new
Color
(
0
,
136
,
119
),
// 3c
// new Color(177, 189, 0), // 5c
new
Color
(
210
,
135
,
0
),
// 7c
new
Color
(
185
,
15
,
34
),
// 9c
new
Color
(
97
,
28
,
115
),
// 11c
};
private
Color
[][]
colors
=
null
;
public
NodeVis
(
Host
host
,
NodeInformation
nodeInfo
)
{
this
.
nodeInfo
=
nodeInfo
;
this
.
host
=
(
SimHost
)
host
;
this
.
loc
=
this
.
host
.
getTopologyComponent
().
getRealPosition
();
this
.
visNodeInfo
=
VisualizationInjector
.
getNodeInformation
(
host
.
getId
());
/*
* Create per-info-option colors by deriving the color from the base color
*/
colors
=
new
Color
[
nodeInfo
.
getNodeColorDimensions
()][];
for
(
int
dim
=
0
;
dim
<
colors
.
length
;
dim
++)
{
Color
baseColor
=
baseColors
[
dim
];
int
dimensionSize
=
nodeInfo
.
getNodeColorDescriptions
(
dim
).
length
;
colors
[
dim
]
=
new
Color
[
dimensionSize
];
/*
* http://stackoverflow.com/questions/2355157/dynamically-
* creating-colors-with-different-brightness
*/
// float hsbVals[] = Color.RGBtoHSB(baseColor.getRed(),
// baseColor.getGreen(), baseColor.getBlue(), null);
for
(
int
i
=
0
;
i
<
dimensionSize
;
i
++)
{
float
hue
=
i
/
(
float
)
dimensionSize
;
// colors[dim][i] = Color.getHSBColor(hue, hsbVals[1],
// hsbVals[2]);
colors
[
dim
][
i
]
=
tuColors
[
i
];
}
}
}
/**
...
...
@@ -184,24 +227,28 @@ public class NodeInfoComponentVis extends JComponent
*/
public
void
drawLegend
(
Graphics2D
g2
)
{
String
[]
dimensions
=
nodeInfo
.
getNodeColorDimensionDescriptions
();
int
radius
=
4
;
for
(
int
dim
=
0
;
dim
<
dimensions
.
length
;
dim
++)
{
radius
+=
2
;
if
(!
activeLayers
[
dim
])
{
int
segments
=
dimensions
.
length
;
int
segmentDegrees
=
(
int
)
(
360
/
(
double
)
segments
);
int
arcSize
=
8
;
g2
.
setStroke
(
new
BasicStroke
(
3
));
for
(
int
color
=
0
;
color
<
segments
;
color
++)
{
if
(!
activeLayers
[
color
])
{
continue
;
}
g2
.
setColor
(
Color
.
DARK_GRAY
);
g2
.
drawOval
(
10
,
20
*
(
dim
+
1
)
-
10
,
radius
*
2
,
radius
*
2
);
g2
.
drawString
(
dimensions
[
dim
],
30
,
20
*
(
dim
+
1
));
String
[]
colorDescs
=
nodeInfo
.
getNodeColorDescriptions
(
dim
);
g2
.
drawArc
(
10
,
20
*
(
color
+
1
)+
10
,
2
*
arcSize
,
2
*
arcSize
,
color
*
segmentDegrees
,
segmentDegrees
);
String
[]
colorDescs
=
nodeInfo
.
getNodeColorDescriptions
(
color
);
for
(
int
i
=
0
;
i
<
colorDescs
.
length
;
i
++)
{
g2
.
setColor
(
colors
[
i
]);
g2
.
fillRect
(
3
0
+
(
i
+
1
)
*
90
,
20
*
(
dim
+
1
)
-
10
,
8
,
8
);
g2
.
setColor
(
colors
[
color
][
i
]);
g2
.
fillRect
(
4
0
+
i
*
90
,
20
*
(
color
+
1
)
+
10
,
8
,
8
);
g2
.
setColor
(
Color
.
DARK_GRAY
);
g2
.
drawString
(
colorDescs
[
i
],
4
0
+
(
i
+
1
)
*
90
,
20
*
(
dim
+
1
));
g2
.
drawString
(
colorDescs
[
i
],
5
0
+
i
*
90
,
20
*
(
color
+
2
));
}
}
g2
.
setStroke
(
new
BasicStroke
(
1
));
}
public
void
draw
(
Graphics2D
g2
)
{
...
...
@@ -222,24 +269,26 @@ public class NodeInfoComponentVis extends JComponent
if
(!
nodeInfo
.
isActive
())
{
return
;
}
g2
.
setComposite
(
AlphaComposite
.
getInstance
(
AlphaComposite
.
SRC_OVER
,
1.0f
));
/*
* TODO add offline/online info here as well (removes the need for a
* custom object that visualizes the underlay!)
*/
int
numColors
=
nodeInfo
.
getNodeColorDimensions
();
radius
=
4
;
for
(
int
color
=
0
;
color
<
numColors
;
color
++)
{
int
value
=
nodeInfo
.
getNodeColor
(
color
);
radius
+=
2
;
if
(
value
<
0
||
!
activeLayers
[
color
])
{
int
segments
=
nodeInfo
.
getNodeColorDimensions
();
int
segmentDegrees
=
(
int
)
(
360
/
(
double
)
segments
);
int
arcSize
=
8
;
g2
.
setStroke
(
new
BasicStroke
(
8
,
BasicStroke
.
CAP_BUTT
,
BasicStroke
.
JOIN_BEVEL
));
for
(
int
dim
=
0
;
dim
<
segments
;
dim
++)
{
int
value
=
nodeInfo
.
getNodeColor
(
dim
);
if
(
value
<
0
||
!
activeLayers
[
dim
])
{
continue
;
}
g2
.
setColor
(
colors
[
value
]);
g2
.
drawOval
(
center
.
x
-
radius
,
center
.
y
-
radius
,
radius
*
2
,
radius
*
2
);
g2
.
setColor
(
colors
[
dim
][
value
]);
g2
.
drawArc
(
center
.
x
-
arcSize
,
center
.
y
-
arcSize
,
2
*
arcSize
,
2
*
arcSize
,
dim
*
segmentDegrees
,
segmentDegrees
);
}
g2
.
setStroke
(
new
BasicStroke
(
1
));
String
nodeDesc
=
nodeInfo
.
getNodeDescription
();
g2
.
drawString
(
nodeDesc
,
center
.
x
+
4
,
center
.
y
+
4
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment