Disconnect node in layout

This commit is contained in:
Gonzalo Bellver
2012-01-12 15:51:50 -03:00
parent eca97f6a72
commit cf9bdee1c4
4 changed files with 43 additions and 30 deletions

View File

@@ -81,6 +81,7 @@ mindplot.nlayout.OriginalLayout = new Class({
var nodeId = node.getId();
var children = this._treeSet.getChildren(node);
var parent = this._treeSet.getParent(node);
var childrenOrderMoved = children.some(function(child) {
return child.hasOrderChanged();
});
@@ -88,9 +89,12 @@ mindplot.nlayout.OriginalLayout = new Class({
// If ether any of the nodes has been changed of position or the height of the children is not
// the same, children nodes must be repositioned ....
var newBranchHeight = heightById[nodeId];
var heightChanged = node._branchHeight != newBranchHeight;
if (childrenOrderMoved || heightChanged) {
var parentHeightChanged = $defined(parent) ? parent._heightChanged : false;
var heightChanged = node._branchHeight != newBranchHeight;
node._heightChanged = heightChanged || parentHeightChanged;
if (childrenOrderMoved || heightChanged || parentHeightChanged) {
var sorter = node.getSorter();
var offsetById = sorter.computeOffsets(this._treeSet, node);
var parentPosition = node.getPosition();

View File

@@ -158,10 +158,10 @@ mindplot.nlayout.RootedTreeSet = new Class({
rect.attr('fill', fillColor);
rect.click(function() {
console.log("[id:" + node.getId() + ", order:" + node.getOrder() + ", position: {" + node.getPosition().x + "," + node.getPosition().y + "}, size: {" + node.getSize().width + "," + node.getSize().height + "}");
console.log("[id:" + node.getId() + ", order:" + node.getOrder() + ", position:(" + node.getPosition().x + "," + node.getPosition().y + "), size:" + node.getSize().width + "x" + node.getSize().height + ", sorter:" + node.getSorter() +"]");
});
text.click(function() {
console.log("[id:" + node.getId() + ", order:" + node.getOrder() + ", position: {" + node.getPosition().x + "," + node.getPosition().y + "}, size: {" + node.getSize().width + "," + node.getSize().height + "}");
console.log("[id:" + node.getId() + ", order:" + node.getOrder() + ", position:(" + node.getPosition().x + "," + node.getPosition().y + "), size:" + node.getSize().width + "x" + node.getSize().height + ", sorter:" + node.getSorter() +"]");
});
for (var i = 0; i < children.length; i++) {

View File

@@ -48,6 +48,8 @@ mindplot.nlayout.SymmetricSorter = new Class({
result = [last.getOrder() + 1,{x:cpos.x,y:cpos.y - (mindplot.nlayout.SymmetricSorter.INTERNODE_VERTICAL_PADDING * 4)}];
}
//TODO(gb): also return order!
return result;
},
@@ -100,8 +102,9 @@ mindplot.nlayout.SymmetricSorter = new Class({
var result = {};
for (var i = 0; i < heights.length; i++) {
ysum = ysum - heights[i].height;
var parent = treeSet.getParent(treeSet.find(heights[i].id));
//TODO(gb): actually compare to branch's root node position
var direction = parent.getPosition().x > 0 ? 1 : -1;
var yOffset = ysum + heights[i].height / 2;