enhanced reivision grph rendering a little

This commit is contained in:
hyung-hwan 2017-01-04 06:56:52 +00:00
parent a1f3400990
commit 38d11d3564
3 changed files with 67 additions and 22 deletions

View File

@ -1638,18 +1638,25 @@ class SubversionModel extends Model
return $cloc; return $cloc;
} }
private function _add_rg_node (&$nodeids, &$nodes, $name) private function _add_rg_node (&$nodeids, &$nodes, $name, $type = '')
{ {
if (array_key_exists($name, $nodeids)) return $nodeids[$name]; if (array_key_exists($name, $nodeids))
{
$nid = $nodeids[$name];
if ($type != '') $nodes[$nid]['_type'] .= $type;
return $nid;
}
$nid = count($nodeids); $nid = count($nodeids);
array_push ($nodes, array ('id' => $nid, 'label' => $name)); array_push ($nodes, array ('id' => $nid, 'label' => $name, '_type' => $type));
$nodeids[$name] = $nid; $nodeids[$name] = $nid;
return $nid; return $nid;
} }
private function _add_rg_edge (&$edges, $from, $to, $label) private function _add_rg_edge (&$edges, $from, $to, $label)
{ {
array_push ($edges, array ('from' => $from, 'to' => $to, 'label' => $label)); $edge = array ('from' => $from, 'to' => $to, 'label' => $label);
if (!in_array($edge, $edges)) array_push ($edges, $edge);
} }
function __revisionGraph ($projectid, $path, $rev) function __revisionGraph ($projectid, $path, $rev)
@ -2059,12 +2066,12 @@ class SubversionModel extends Model
if ($br >= 0) if ($br >= 0)
{ {
$id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$br}"); $id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$br}");
$id2 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}"); $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}", 'X');
$this->_add_rg_edge ($edges, $id1, $id2, ''); $this->_add_rg_edge ($edges, $id1, $id2, '');
} }
$id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}"); $id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}");
$id2 = $this->_add_rg_node ($nodeids, $nodes, "{$topath}:{$torev}"); $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$topath}:{$torev}", 'X');
$this->_add_rg_edge ($edges, $id1, $id2, 'copied'); $this->_add_rg_edge ($edges, $id1, $id2, 'copied');
break; break;
case 'MV': case 'MV':
@ -2072,12 +2079,12 @@ class SubversionModel extends Model
if ($br >= 0) if ($br >= 0)
{ {
$id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$br}"); $id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$br}");
$id2 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}"); $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}", 'X');
$this->_add_rg_edge ($edges, $id1, $id2, ''); $this->_add_rg_edge ($edges, $id1, $id2, '');
} }
$id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}"); $id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}");
$id2 = $this->_add_rg_node ($nodeids, $nodes, "{$topath}:{$torev}"); $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$topath}:{$torev}", 'X');
$this->_add_rg_edge ($edges, $id1, $id2, 'moved'); $this->_add_rg_edge ($edges, $id1, $id2, 'moved');
break; break;
case 'RM': case 'RM':
@ -2085,18 +2092,18 @@ class SubversionModel extends Model
if ($br >= 0) if ($br >= 0)
{ {
$id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$br}"); $id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$br}");
$id2 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}"); $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}", 'X');
$this->_add_rg_edge ($edges, $id1, $id2, ''); $this->_add_rg_edge ($edges, $id1, $id2, '');
} }
$id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}"); $id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}", 'D');
$id2 = $this->_add_rg_node ($nodeids, $nodes, $topath); //$id2 = $this->_add_rg_node ($nodeids, $nodes, $topath);
$this->_add_rg_edge ($edges, $id1, $id2, 'deleted'); //$this->_add_rg_edge ($edges, $id1, $id2, 'deleted');
break; break;
case 'AD': case 'AD':
$id1 = $this->_add_rg_node ($nodeids, $nodes, $frompath); //$id1 = $this->_add_rg_node ($nodeids, $nodes, $frompath);
$id2 = $this->_add_rg_node ($nodeids, $nodes, "{$topath}:{$torev}"); $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$topath}:{$torev}", 'A');
$this->_add_rg_edge ($edges, $id1, $id2, ''); //$this->_add_rg_edge ($edges, $id1, $id2, '');
break; break;
case 'MF': case 'MF':
/* /*
@ -2128,7 +2135,7 @@ class SubversionModel extends Model
$torev = $ti[2]; $torev = $ti[2];
$num_changes = $ti[3]; $num_changes = $ti[3];
$id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}"); $id1 = $this->_add_rg_node ($nodeids, $nodes, "{$frompath}:{$fromrev}");
$id2 = $this->_add_rg_node ($nodeids, $nodes, "{$topath}:{$torev}"); $id2 = $this->_add_rg_node ($nodeids, $nodes, "{$topath}:{$torev}", 'X');
$this->_add_rg_edge ($edges, $id1, $id2, "{$num_changes} change(s)"); $this->_add_rg_edge ($edges, $id1, $id2, "{$num_changes} change(s)");
} }

View File

@ -447,7 +447,26 @@ var RevGraphApp = (function ()
j = data.nodes.length; j = data.nodes.length;
for (i = 0; i < j; i++) for (i = 0; i < j; i++)
{ {
data.nodes[i].labelHighlightBold = false;
data.nodes[i].shape = 'box'; data.nodes[i].shape = 'box';
if (data.nodes[i]._type == '')
{
// no other nodes reache this node
data.nodes[i].color = '#553322';
data.nodes[i].font = { color: 'white' };
}
else if (data.nodes[i]._type.indexOf('D') >= 0)
{
data.nodes[i].color = '#AA3344';
data.nodes[i].font = { color: 'white' };
data.nodes[i].label += '\n<<DELETED>>';
}
else if (data.nodes[i]._type.indexOf('A') >= 0)
{
data.nodes[i].color = '#227722';
data.nodes[i].font = { color: 'white' };
data.nodes[i].label += '\n<<NEW>>';
}
} }
j = data.edges.length; j = data.edges.length;

View File

@ -268,7 +268,7 @@ var RevGraphApp = (function ()
autoResize: false, autoResize: false,
height: '400px', height: '400px',
width: '90%', width: '90%',
clickToUse: false, clickToUse: false /*,
layout: { layout: {
hierarchical: { hierarchical: {
enabled: true, enabled: true,
@ -276,8 +276,8 @@ var RevGraphApp = (function ()
//levelSeparation: 150, //levelSeparation: 150,
//nodeSpacing: 200, //nodeSpacing: 200,
//treeSpacing: 300, //treeSpacing: 300,
direction: 'LR', //'LR' 'UD', 'DU', 'RL' //direction: 'LR' //'LR' 'UD', 'DU', 'RL'
sortMethod: 'directed' // 'hubsize'*/ //sortMethod: 'directed' // 'hubsize'
} }
}, },
@ -289,17 +289,36 @@ var RevGraphApp = (function ()
} }
}, },
physics: { physics: {
//enabled: true enabled: true
enabled: false }*/
}
}; };
var i, j; var i, j;
j = data.nodes.length; j = data.nodes.length;
for (i = 0; i < j; i++) for (i = 0; i < j; i++)
{ {
data.nodes[i].labelHighlightBold = false;
data.nodes[i].shape = 'box'; data.nodes[i].shape = 'box';
if (data.nodes[i]._type == '')
{
// no other nodes reache this node
data.nodes[i].color = '#553322';
data.nodes[i].font = { color: 'white' };
}
else if (data.nodes[i]._type.indexOf('D') >= 0)
{
data.nodes[i].color = '#AA3344';
data.nodes[i].font = { color: 'white' };
data.nodes[i].label += '\n<<DELETED>>';
}
else if (data.nodes[i]._type.indexOf('A') >= 0)
{
data.nodes[i].color = '#227722';
data.nodes[i].font = { color: 'white' };
data.nodes[i].label += '\n<<NEW>>';
}
} }
j = data.edges.length; j = data.edges.length;