mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-26 07:44:56 +01:00
Integrate predict ...
This commit is contained in:
parent
b9e5469907
commit
89060af08b
@ -330,13 +330,30 @@ mindplot.Designer = new Class({
|
||||
// Add new node ...
|
||||
var parentTopic = nodes[0];
|
||||
var parentTopicId = parentTopic.getId();
|
||||
var childModel = parentTopic.createChildModel();
|
||||
var childModel = this._createChildModel(parentTopic);
|
||||
|
||||
// Execute event ...
|
||||
this._actionDispatcher.addTopic(childModel, parentTopicId, true);
|
||||
|
||||
},
|
||||
|
||||
_createChildModel : function(topic) {
|
||||
// Create a new node ...
|
||||
var model = topic.getModel();
|
||||
var mindmap = model.getMindmap();
|
||||
var childModel = mindmap.createNode(mindplot.model.INodeModel.MAIN_TOPIC_TYPE);
|
||||
|
||||
// Create a new node ...
|
||||
var layoutManager = this._eventBussDispatcher.getLayoutManager();
|
||||
var result = layoutManager.predict(topic.getId());
|
||||
childModel.setOrder(result.order);
|
||||
|
||||
var position = result.position;
|
||||
childModel.setPosition(position.x, position.y);
|
||||
|
||||
return childModel;
|
||||
},
|
||||
|
||||
createSiblingForSelectedNode : function() {
|
||||
var nodes = this.getModel().filterSelectedTopics();
|
||||
if (nodes.length <= 0) {
|
||||
@ -358,13 +375,31 @@ mindplot.Designer = new Class({
|
||||
|
||||
} else {
|
||||
var parentTopic = topic.getOutgoingConnectedTopic();
|
||||
var siblingModel = topic.createSiblingModel();
|
||||
var siblingModel = this._createSiblingModel(topic);
|
||||
var parentTopicId = parentTopic.getId();
|
||||
|
||||
this._actionDispatcher.addTopic(siblingModel, parentTopicId, true);
|
||||
}
|
||||
},
|
||||
|
||||
_createSiblingModel : function(topic) {
|
||||
var result = null;
|
||||
var parentTopic = topic.getOutgoingConnectedTopic();
|
||||
if (parentTopic != null) {
|
||||
|
||||
// Create a new node ...
|
||||
var model = topic.getModel();
|
||||
var mindmap = model.getMindmap();
|
||||
result = mindmap.createNode(mindplot.model.INodeModel.MAIN_TOPIC_TYPE);
|
||||
|
||||
// Create a new node ...
|
||||
var order = topic.getOrder() + 1;
|
||||
result.setOrder(order);
|
||||
result.setPosition(10, 10); // Set a dummy pisition ...
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
showRelPivot : function(event) {
|
||||
// Current mouse position ....
|
||||
var screen = this._workspace.getScreenManager();
|
||||
|
@ -227,24 +227,6 @@ mindplot.MainTopic = new Class({
|
||||
|
||||
_defaultBorderColor : function() {
|
||||
return '#023BB9';
|
||||
},
|
||||
|
||||
// @todo: Removed !!!
|
||||
createSiblingModel : function() {
|
||||
var result = null;
|
||||
var parentTopic = this.getOutgoingConnectedTopic();
|
||||
if (parentTopic != null) {
|
||||
// Create a new node ...
|
||||
var model = this.getModel();
|
||||
var mindmap = model.getMindmap();
|
||||
result = mindmap.createNode(mindplot.model.INodeModel.MAIN_TOPIC_TYPE);
|
||||
|
||||
// Create a new node ...
|
||||
var order = this.getOrder() + 1;
|
||||
result.setOrder(order);
|
||||
result.setPosition(10,10);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -1242,30 +1242,8 @@ mindplot.Topic = new Class({
|
||||
// Position node ...
|
||||
textShape.setPosition(topicPadding + iconsWidth, topicPadding);
|
||||
}
|
||||
},
|
||||
|
||||
// @Todo: this don't seems to be a nice way... Order should be infered automatically ...
|
||||
createChildModel : function() {
|
||||
// Create a new node ...
|
||||
var model = this.getModel();
|
||||
var mindmap = model.getMindmap();
|
||||
var childModel = mindmap.createNode(mindplot.model.INodeModel.MAIN_TOPIC_TYPE);
|
||||
|
||||
// Get the hights model order position ...
|
||||
var children = this._getChildren();
|
||||
var order = -1;
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var child = children[i];
|
||||
if (child.getOrder() > order) {
|
||||
order = child.getOrder();
|
||||
}
|
||||
}
|
||||
// Create a new node ...
|
||||
childModel.setOrder(order + 1);
|
||||
childModel.setPosition(10, 10);
|
||||
|
||||
return childModel;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
@ -87,11 +87,15 @@ mindplot.nlayout.EventBusDispatcher = new Class({
|
||||
|
||||
_doLayout: function() {
|
||||
// (function() {
|
||||
this._layoutManager.layout(true);
|
||||
console.log("---------");
|
||||
this._layoutManager.dump();
|
||||
console.log("---------");
|
||||
this._layoutManager.layout(true);
|
||||
console.log("---------");
|
||||
this._layoutManager.dump();
|
||||
console.log("---------");
|
||||
// }).delay(0, this);
|
||||
},
|
||||
|
||||
getLayoutManager: function() {
|
||||
return this._layoutManager;
|
||||
}
|
||||
|
||||
});
|
@ -94,7 +94,8 @@ mindplot.nlayout.LayoutManager = new Class({
|
||||
|
||||
var parent = this._treeSet.find(parentId);
|
||||
var sorter = parent.getSorter();
|
||||
return sorter.predict(parent, this._treeSet, position);
|
||||
var result = sorter.predict(parent, this._treeSet, position);
|
||||
return {order:result[0],position:result[1]};
|
||||
},
|
||||
|
||||
dump: function() {
|
||||
|
Loading…
Reference in New Issue
Block a user