Fix error when press enter over a isolated node

Fix prediction error when the node is a isolated node.
This commit is contained in:
Paulo Gustavo Veiga 2012-08-20 11:22:19 -03:00
parent da6859313b
commit 28bbc4c846
2 changed files with 10 additions and 10 deletions

View File

@ -473,7 +473,7 @@ mindplot.Designer = new Class({
} }
var topic = nodes[0]; var topic = nodes[0];
if (topic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) { if (!topic.getOutgoingConnectedTopic()) { // Central topic and isolated topics ....
// Central topic doesn't have siblings ... // Central topic doesn't have siblings ...
this.createChildForSelectedNode(); this.createChildForSelectedNode();

View File

@ -86,31 +86,31 @@ mindplot.layout.SymmetricSorter = new Class({
// Try to fit within ... // Try to fit within ...
var result = null; var result = null;
var last = parentChildren.getLast(); var last = parentChildren.getLast();
for (var i=0; i<parentChildren.length; i++) { for (var i = 0; i < parentChildren.length; i++) {
var parentChild = parentChildren[i]; var parentChild = parentChildren[i];
var nodeAfter = (i + 1) == parentChild.length ? null : parentChildren[i+1]; var nodeAfter = (i + 1) == parentChild.length ? null : parentChildren[i + 1];
// Fit at the bottom // Fit at the bottom
if (!nodeAfter && position.y > parentChild.getPosition().y) { if (!nodeAfter && position.y > parentChild.getPosition().y) {
var order = graph.getParent(node).getId() == parent.getId() ? var order = (graph.getParent(node) && graph.getParent(node).getId() == parent.getId()) ?
last.getOrder() : last.getOrder() + 1; last.getOrder() : last.getOrder() + 1;
var position = { var position = {
x: parentChild.getPosition().x, x:parentChild.getPosition().x,
y: parentChild.getPosition().y + parentChild.getSize().height + mindplot.layout.SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2 y:parentChild.getPosition().y + parentChild.getSize().height + mindplot.layout.SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2
}; };
return [order, position]; return [order, position];
} }
// Fit after this node // Fit after this node
if (nodeAfter && position.y > parentChild.getPosition().y && position.y < nodeAfter.getPosition().y) { if (nodeAfter && position.y > parentChild.getPosition().y && position.y < nodeAfter.getPosition().y) {
if(nodeAfter.getId() == node.getId() || parentChild.getId() == node.getId()) { if (nodeAfter.getId() == node.getId() || parentChild.getId() == node.getId()) {
return [node.getOrder(), node.getPosition()]; return [node.getOrder(), node.getPosition()];
} else { } else {
var order = position.y > node.getPosition().y ? var order = position.y > node.getPosition().y ?
nodeAfter.getOrder() - 1 : parentChild.getOrder() + 1; nodeAfter.getOrder() - 1 : parentChild.getOrder() + 1;
var position = { var position = {
x: parentChild.getPosition().x, x:parentChild.getPosition().x,
y: parentChild.getPosition().y + (nodeAfter.getPosition().y - parentChild.getPosition().y) / 2 y:parentChild.getPosition().y + (nodeAfter.getPosition().y - parentChild.getPosition().y) / 2
}; };
return [order, position]; return [order, position];