Starting to set the aspect to networkmap node.

This commit is contained in:
mdtrooper 2016-04-04 20:21:36 +02:00
parent fdfc46d827
commit e6fbb6d41d
3 changed files with 104 additions and 1 deletions

View File

@ -102,6 +102,10 @@ class Networkmap extends Map {
$id_agent = null;
$status = null;
$title = "";
$width = DEFAULT_NODE_WIDTH;
$height = DEFAULT_NODE_HEIGHT;
$shape = DEFAULT_NODE_SHAPE;
$color = DEFAULT_NODE_COLOR;
if (strstr($chunks[1], "&id_module=") !== false) {
// MODULE
preg_match("/id_module=([0-9]*)/", $chunks[1], $matches);
@ -125,7 +129,11 @@ class Networkmap extends Map {
'id_agent' => $id_agent,
'type' => $type,
'status' => $status,
'title' => $title);
'title' => $title,
'width' => $width,
'height' => $height,
'shape' => $shape,
'color' => $color);
if ($last_graph_id < $graphviz_id)
$last_graph_id = $graphviz_id;

View File

@ -503,4 +503,10 @@ define("ITEM_TYPE_AGENT_NETWORKMAP", 0);
define("ITEM_TYPE_MODULE_NETWORKMAP", 1);
define("ITEM_TYPE_EDGE_NETWORKMAP", 2);
define("ITEM_TYPE_FICTIONAL_NODE", 3);
/* Another constants new networkmap */
define("DEFAULT_NODE_WIDTH", 30);
define("DEFAULT_NODE_HEIGHT", 30);
define("DEFAULT_NODE_SHAPE", "circle");
define("DEFAULT_NODE_COLOR", COL_NOTINIT);
?>

View File

@ -371,6 +371,95 @@ NetworkmapController.prototype.exists_arrow = function(arrows, arrow) {
return var_return;
}
NetworkmapController.prototype.paint_node = function(g_node, node) {
var self = this;
var color;
switch (node['type']) {
case ITEM_TYPE_AGENT_NETWORKMAP:
//~ color =
break;
case ITEM_TYPE_FICTIONAL_NODE:
break;
}
var d3_node = d3.select(g_node)
.attr("transform", "translate(" + node['x'] + " " + node['y'] + ")")
.attr("class", "draggable node")
.attr("id", "node_" + node['graph_id'])
.attr("style", "fill: rgb(50, 50, 128);")
.attr("data-id", node['id'])
.attr("data-graph_id", node['graph_id'])
.attr("data-type", node['type']);
switch (node['shape']) {
case 'rect':
d3_node.append("rect")
.attr("height", node['height'])
.attr("width", node['width'])
.attr("x", 0)
.attr("y", 0);
break;
case 'circle':
d3_node.append("circle")
.attr("r", node['width'] / 2)
.attr("transform", "translate(" +
node['width'] / 2 + " " +
node['height'] / 2 + ")");
break;
case 'rhombus':
d3_node.append("rect")
.attr("transform", "rotate(45)")
.attr("height", node['height'])
.attr("width", node['width'])
.attr("x", 0)
.attr("y", 0)
break;
}
// Title
var d3_node_title = d3_node.append("text");
d3_node_title
.text(node['title'])
.style("fill", "#000000");
//Title position
var title_bbox = d3_node_title.node().getBBox();
console.log(node['title'], title_bbox);
var x = node['width'] / 2 - title_bbox.width / 2;
var y = node['height'] - title_bbox.y;
d3_node_title
.attr("transform", "translate(" + x + " " + y + ")");
d3_node
.style("fill", node['color']);
}
/**
* Function paint_nodes
* Return void
* This function paint the nodes
*/
NetworkmapController.prototype.paint_nodes = function() {
var self = this;
self._viewport.selectAll(".node")
.data(
nodes
.filter(function(d, i) {
return self.filter_only_agents(d);
}))
.enter()
.append("g")
.each(function(node) {self.paint_node(this, node);});
}
/**
* Function paint_arrows
* Return void