Baseline alignment
This commit is contained in:
@@ -320,7 +320,6 @@ mindplot.Designer = new Class({
|
||||
},
|
||||
|
||||
createChildForSelectedNode : function() {
|
||||
console.log("createChildForSelectedNode"); //TODO(gb): Remove trace!!!
|
||||
var nodes = this.getModel().filterSelectedTopics();
|
||||
if (nodes.length <= 0) {
|
||||
// If there are more than one node selected,
|
||||
|
@@ -174,12 +174,6 @@ mindplot.layout.Node = new Class({
|
||||
return this._sorter;
|
||||
},
|
||||
|
||||
getVertex: function() {
|
||||
var a = {x: this.getPosition().x - this.getSize().width / 2, y:this.getPosition().y - this.getSize().height / 2};
|
||||
var b = {x: this.getPosition().x + this.getSize().width / 2, y:this.getPosition().y + this.getSize().height / 2};
|
||||
return {a:a, b:b};
|
||||
},
|
||||
|
||||
toString: function() {
|
||||
return "[id:" + this.getId() + ", order:" + this.getOrder() + ", position: {" + this.getPosition().x + "," + this.getPosition().y + "}, size: {" + this.getSize().width + "," + this.getSize().height + "}, shrink:" + this.areChildrenShrunken() + "]";
|
||||
}
|
||||
|
@@ -144,28 +144,34 @@ mindplot.layout.OriginalLayout = new Class({
|
||||
var nodeHeight = node.getSize().height;
|
||||
var childHeight = child.getSize().height;
|
||||
|
||||
var children = this._treeSet.getChildren(child);
|
||||
|
||||
if (children.length == 1 && children[0].getSize().height > childHeight) { // A
|
||||
offset = children[0].getSize().height/2 - childHeight/2;
|
||||
} else if (children.length == 1 && childHeight > children[0].getSize().height) { // B
|
||||
offset = 0;
|
||||
} else if (children.length == 1 && nodeHeight > childHeight) {
|
||||
offset = nodeHeight/2 - childHeight/2;
|
||||
if (this._treeSet.isStartOfSubBranch(child) && this._branchIsTaller(child, heightById)) {
|
||||
if (this._treeSet.hasSinglePathToSingleLeaf(child)) {
|
||||
offset = heightById[child.getId()]/2 - (childHeight + child.getSorter()._getVerticalPadding()*2)/2;
|
||||
} else {
|
||||
offset = this._treeSet.isLeaf(child) ? 0 : -(childHeight - nodeHeight)/2;
|
||||
}
|
||||
} else if (nodeHeight > childHeight) {
|
||||
if (this._treeSet.getSiblings(child).length > 0) {
|
||||
offset = 0;
|
||||
} else {
|
||||
offset = nodeHeight/2 - childHeight/2;
|
||||
}
|
||||
}
|
||||
else if (children.length == 0 && childHeight <= nodeHeight) {
|
||||
offset = nodeHeight/2 - childHeight/2;
|
||||
}
|
||||
else if (childHeight > nodeHeight && children.length > 0) {
|
||||
offset = nodeHeight/2 - childHeight/2;
|
||||
}
|
||||
else {
|
||||
offset = 0;
|
||||
else if (childHeight > nodeHeight) {
|
||||
if (this._treeSet.getSiblings(child).length > 0) {
|
||||
offset = 0;
|
||||
} else {
|
||||
offset = -(childHeight / 2 - nodeHeight / 2);
|
||||
}
|
||||
}
|
||||
|
||||
return offset;
|
||||
},
|
||||
|
||||
_branchIsTaller: function(node, heightById) {
|
||||
return heightById[node.getId()] > (node.getSize().height + node.getSorter()._getVerticalPadding()*2);
|
||||
},
|
||||
|
||||
_fixOverlapping: function(node, heightById) {
|
||||
var children = this._treeSet.getChildren(node);
|
||||
|
||||
|
@@ -147,6 +147,30 @@ mindplot.layout.RootedTreeSet = new Class({
|
||||
return siblings;
|
||||
},
|
||||
|
||||
hasSinglePathToSingleLeaf: function(node) {
|
||||
$assert(node, 'node cannot be null');
|
||||
return this._hasSinglePathToSingleLeaf(node);
|
||||
},
|
||||
|
||||
_hasSinglePathToSingleLeaf: function(node) {
|
||||
var children = this.getChildren(node);
|
||||
|
||||
if (children.length == 1) {
|
||||
return this._hasSinglePathToSingleLeaf(children[0]);
|
||||
}
|
||||
|
||||
return children.length == 0;
|
||||
},
|
||||
|
||||
isStartOfSubBranch: function(node) {
|
||||
return this.getSiblings(node).length > 0 && this.getChildren(node).length == 1;
|
||||
},
|
||||
|
||||
isLeaf: function(node) {
|
||||
$assert(node, 'node cannot be null');
|
||||
return this.getChildren(node).length == 0;
|
||||
},
|
||||
|
||||
getParent:function(node) {
|
||||
$assert(node, 'node cannot be null');
|
||||
return node._parent;
|
||||
|
Reference in New Issue
Block a user