mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-26 15:54:55 +01:00
Set position integrated !
This commit is contained in:
parent
8cf9e6d18e
commit
d9cdcc5160
@ -209,7 +209,11 @@
|
|||||||
<filelist dir="${basedir}/src/main/javascript/"
|
<filelist dir="${basedir}/src/main/javascript/"
|
||||||
files="nlayout/ChildrenSorterStrategy.js"/>
|
files="nlayout/ChildrenSorterStrategy.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/"
|
<filelist dir="${basedir}/src/main/javascript/"
|
||||||
files="nlayout/SymetricSorter.js"/>
|
files="nlayout/AbstractBasicSorter.js"/>
|
||||||
|
<filelist dir="${basedir}/src/main/javascript/"
|
||||||
|
files="nlayout/BalancedSorter.js"/>
|
||||||
|
<filelist dir="${basedir}/src/main/javascript/"
|
||||||
|
files="nlayout/SymmetricSorter.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/"
|
<filelist dir="${basedir}/src/main/javascript/"
|
||||||
files="nlayout/GridSorter.js"/>
|
files="nlayout/GridSorter.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/"
|
<filelist dir="${basedir}/src/main/javascript/"
|
||||||
|
@ -1044,7 +1044,7 @@ mindplot.Topic = new Class({
|
|||||||
// Update the figure position(ej: central topic must be centered) and children position.
|
// Update the figure position(ej: central topic must be centered) and children position.
|
||||||
this._updatePositionOnChangeSize(oldSize, size);
|
this._updatePositionOnChangeSize(oldSize, size);
|
||||||
|
|
||||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeResizeEvent, [this]);
|
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeResizeEvent, {node:this.getModel(),size:size});
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -26,7 +26,7 @@ mindplot.layout.BaseLayoutManager = new Class({
|
|||||||
this.setOptions(options);
|
this.setOptions(options);
|
||||||
this._createBoard();
|
this._createBoard();
|
||||||
this._designer = designer;
|
this._designer = designer;
|
||||||
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeResizeEvent, this._nodeResizeEvent.bind(this));
|
// mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeResizeEvent, this._nodeResizeEvent.bind(this));
|
||||||
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeMoveEvent, this._nodeMoveEvent.bind(this));
|
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeMoveEvent, this._nodeMoveEvent.bind(this));
|
||||||
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.ONodeDisconnectEvent, this._nodeDisconnectEvent.bind(this));
|
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.ONodeDisconnectEvent, this._nodeDisconnectEvent.bind(this));
|
||||||
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.ONodeConnectEvent, this._nodeConnectEvent.bind(this));
|
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.ONodeConnectEvent, this._nodeConnectEvent.bind(this));
|
||||||
|
@ -53,14 +53,5 @@ mindplot.nlayout.AbstractBasicSorter = new Class({
|
|||||||
return a.getOrder() - b.getOrder()
|
return a.getOrder() - b.getOrder()
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
},
|
|
||||||
|
|
||||||
verify:function(treeSet, node) {
|
|
||||||
// Check that all is consistent ...
|
|
||||||
var children = this._getSortedChildren(treeSet, node);
|
|
||||||
|
|
||||||
for (var i = 0; i < children.length; i++) {
|
|
||||||
$assert(children[i].getOrder() == i, "missing order elements");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2011] [wisemapping]
|
||||||
|
*
|
||||||
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||||
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||||
|
* "powered by wisemapping" text requirement on every single page;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the license at
|
||||||
|
*
|
||||||
|
* http://www.wisemapping.org/license
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
mindplot.nlayout.BalancedSorter = new Class({
|
mindplot.nlayout.BalancedSorter = new Class({
|
||||||
Extends: mindplot.nlayout.AbstractBasicSorter,
|
Extends: mindplot.nlayout.AbstractBasicSorter,
|
||||||
|
|
||||||
@ -66,13 +83,17 @@ mindplot.nlayout.BalancedSorter = new Class({
|
|||||||
|
|
||||||
insert: function(treeSet, parent, child, order) {
|
insert: function(treeSet, parent, child, order) {
|
||||||
var children = this._getSortedChildren(treeSet, parent);
|
var children = this._getSortedChildren(treeSet, parent);
|
||||||
$assert(order <= children.length, "Order must be continues and can not have holes. Order:" + order);
|
|
||||||
$assert(order <= children.length, "Order must be continues and can not have holes. Order:" + order);
|
|
||||||
|
|
||||||
// Shift all the elements in one .
|
// Shift all the elements in one. In case of balanced sorter, order don't need to be continues ...
|
||||||
|
var collision = order;
|
||||||
for (var i = order; i < children.length; i++) {
|
for (var i = order; i < children.length; i++) {
|
||||||
var node = children[i];
|
var node = children[i];
|
||||||
node.setOrder(i + 1);
|
|
||||||
|
// @Todo: This must be review. Order balance need to be defined ...
|
||||||
|
if (node.getOrder() == collision) {
|
||||||
|
collision = collision + 1;
|
||||||
|
node.setOrder(collision);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
child.setOrder(order);
|
child.setOrder(order);
|
||||||
},
|
},
|
||||||
@ -98,7 +119,8 @@ mindplot.nlayout.BalancedSorter = new Class({
|
|||||||
var children = this._getSortedChildren(treeSet, node);
|
var children = this._getSortedChildren(treeSet, node);
|
||||||
|
|
||||||
// Compute heights ...
|
// Compute heights ...
|
||||||
var heights = children.map(function(child) {
|
var heights = children.map(
|
||||||
|
function(child) {
|
||||||
return {id:child.getId(), order:child.getOrder(), height:this._computeChildrenHeight(treeSet, child)};
|
return {id:child.getId(), order:child.getOrder(), height:this._computeChildrenHeight(treeSet, child)};
|
||||||
}, this).reverse();
|
}, this).reverse();
|
||||||
|
|
||||||
@ -114,8 +136,8 @@ mindplot.nlayout.BalancedSorter = new Class({
|
|||||||
totalNHeight += elem.height;
|
totalNHeight += elem.height;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var psum = totalPHeight/2;
|
var psum = totalPHeight / 2;
|
||||||
var nsum = totalNHeight/2;
|
var nsum = totalNHeight / 2;
|
||||||
var ysum = 0;
|
var ysum = 0;
|
||||||
|
|
||||||
// Calculate the offsets ...
|
// Calculate the offsets ...
|
||||||
@ -131,7 +153,7 @@ mindplot.nlayout.BalancedSorter = new Class({
|
|||||||
ysum = nsum;
|
ysum = nsum;
|
||||||
}
|
}
|
||||||
|
|
||||||
var yOffset = ysum + heights[i].height/2;
|
var yOffset = ysum + heights[i].height / 2;
|
||||||
var xOffset = direction * (node.getSize().width + mindplot.nlayout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
|
var xOffset = direction * (node.getSize().width + mindplot.nlayout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
|
||||||
|
|
||||||
$assert(!isNaN(xOffset), "xOffset can not be null");
|
$assert(!isNaN(xOffset), "xOffset can not be null");
|
||||||
@ -144,6 +166,10 @@ mindplot.nlayout.BalancedSorter = new Class({
|
|||||||
|
|
||||||
toString:function() {
|
toString:function() {
|
||||||
return "Balanced Sorter";
|
return "Balanced Sorter";
|
||||||
|
},
|
||||||
|
|
||||||
|
verify:function(treeSet, node) {
|
||||||
|
// @todo...
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -27,7 +27,10 @@ mindplot.nlayout.EventBusDispatcher = new Class({
|
|||||||
this._layoutManager.addEvent('change', function(event) {
|
this._layoutManager.addEvent('change', function(event) {
|
||||||
var id = event.getId();
|
var id = event.getId();
|
||||||
var topic = designerModel.findTopicById(id);
|
var topic = designerModel.findTopicById(id);
|
||||||
console.log("Modifing position to:" + id);
|
console.log("Modify position to:" + id);
|
||||||
|
|
||||||
|
topic.setPosition(event.getPosition());
|
||||||
|
topic.setOrder(event.getOrder());
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -43,8 +46,8 @@ mindplot.nlayout.EventBusDispatcher = new Class({
|
|||||||
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.DoLayout, this._doLayout.bind(this));
|
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.DoLayout, this._doLayout.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
_nodeResizeEvent: function(node) {
|
_nodeResizeEvent: function(args) {
|
||||||
console.log("mindplot.nlayout.EventBusDispatcher._nodeResizeEvent: Not Implemented yet");
|
this._layoutManager.updateNodeSize(args.node.getId(), args.size);
|
||||||
},
|
},
|
||||||
|
|
||||||
_nodeMoveEvent: function(node) {
|
_nodeMoveEvent: function(node) {
|
||||||
@ -82,11 +85,12 @@ mindplot.nlayout.EventBusDispatcher = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_doLayout: function() {
|
_doLayout: function() {
|
||||||
|
(function() {
|
||||||
this._layoutManager.layout(true);
|
this._layoutManager.layout(true);
|
||||||
console.log("---------");
|
console.log("---------");
|
||||||
this._layoutManager.dump();
|
this._layoutManager.dump();
|
||||||
console.log("---------");
|
console.log("---------");
|
||||||
|
}).delay(0, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
@ -32,7 +32,9 @@ mindplot.nlayout.LayoutManager = new Class({
|
|||||||
updateNodeSize: function(id, size) {
|
updateNodeSize: function(id, size) {
|
||||||
var node = this._treeSet.find(id);
|
var node = this._treeSet.find(id);
|
||||||
node.setSize(size);
|
node.setSize(size);
|
||||||
// @Todo: finish...
|
console.log("Size:"+size.width);
|
||||||
|
|
||||||
|
// Todo: This must be completed ...
|
||||||
},
|
},
|
||||||
|
|
||||||
updateShirkState: function(id, isShrink) {
|
updateShirkState: function(id, isShrink) {
|
||||||
|
@ -121,7 +121,6 @@ mindplot.nlayout.OriginalLayout = new Class({
|
|||||||
});
|
});
|
||||||
|
|
||||||
mindplot.nlayout.OriginalLayout.SYMMETRIC_SORTER = new mindplot.nlayout.SymmetricSorter();
|
mindplot.nlayout.OriginalLayout.SYMMETRIC_SORTER = new mindplot.nlayout.SymmetricSorter();
|
||||||
mindplot.nlayout.OriginalLayout.GRID_SORTER = new mindplot.nlayout.GridSorter();
|
|
||||||
mindplot.nlayout.OriginalLayout.BALANCED_SORTER = new mindplot.nlayout.BalancedSorter();
|
mindplot.nlayout.OriginalLayout.BALANCED_SORTER = new mindplot.nlayout.BalancedSorter();
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,7 +54,6 @@ mindplot.nlayout.SymmetricSorter = new Class({
|
|||||||
insert: function(treeSet, parent, child, order) {
|
insert: function(treeSet, parent, child, order) {
|
||||||
var children = this._getSortedChildren(treeSet, parent);
|
var children = this._getSortedChildren(treeSet, parent);
|
||||||
$assert(order <= children.length, "Order must be continues and can not have holes. Order:" + order);
|
$assert(order <= children.length, "Order must be continues and can not have holes. Order:" + order);
|
||||||
$assert(order <= children.length, "Order must be continues and can not have holes. Order:" + order);
|
|
||||||
|
|
||||||
// Shift all the elements in one .
|
// Shift all the elements in one .
|
||||||
for (var i = order; i < children.length; i++) {
|
for (var i = order; i < children.length; i++) {
|
||||||
@ -85,7 +84,8 @@ mindplot.nlayout.SymmetricSorter = new Class({
|
|||||||
var children = this._getSortedChildren(treeSet, node);
|
var children = this._getSortedChildren(treeSet, node);
|
||||||
|
|
||||||
// Compute heights ...
|
// Compute heights ...
|
||||||
var heights = children.map(function(child) {
|
var heights = children.map(
|
||||||
|
function(child) {
|
||||||
return {id:child.getId(), order:child.getOrder(), position: child.getPosition(), height: this._computeChildrenHeight(treeSet, child)};
|
return {id:child.getId(), order:child.getOrder(), position: child.getPosition(), height: this._computeChildrenHeight(treeSet, child)};
|
||||||
}, this).reverse();
|
}, this).reverse();
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ mindplot.nlayout.SymmetricSorter = new Class({
|
|||||||
var parent = treeSet.getParent(treeSet.find(heights[i].id));
|
var parent = treeSet.getParent(treeSet.find(heights[i].id));
|
||||||
var direction = parent.getPosition().x > 0 ? 1 : -1;
|
var direction = parent.getPosition().x > 0 ? 1 : -1;
|
||||||
|
|
||||||
var yOffset = ysum + heights[i].height/2;
|
var yOffset = ysum + heights[i].height / 2;
|
||||||
var xOffset = direction * (node.getSize().width + mindplot.nlayout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
|
var xOffset = direction * (node.getSize().width + mindplot.nlayout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
|
||||||
|
|
||||||
$assert(!isNaN(xOffset), "xOffset can not be null");
|
$assert(!isNaN(xOffset), "xOffset can not be null");
|
||||||
@ -115,6 +115,15 @@ mindplot.nlayout.SymmetricSorter = new Class({
|
|||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
verify:function(treeSet, node) {
|
||||||
|
// Check that all is consistent ...
|
||||||
|
var children = this._getSortedChildren(treeSet, node);
|
||||||
|
|
||||||
|
for (var i = 0; i < children.length; i++) {
|
||||||
|
$assert(children[i].getOrder() == i, "missing order elements");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
toString:function() {
|
toString:function() {
|
||||||
return "Symmetric Sorter";
|
return "Symmetric Sorter";
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
<script type='text/javascript' src='../../../main/javascript/nlayout/OriginalLayout.js'></script>
|
<script type='text/javascript' src='../../../main/javascript/nlayout/OriginalLayout.js'></script>
|
||||||
<script type='text/javascript' src='../../../main/javascript/nlayout/ChangeEvent.js'></script>
|
<script type='text/javascript' src='../../../main/javascript/nlayout/ChangeEvent.js'></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="../../../main/javascript/nlayout/raphael-min.js"></script>
|
<script type="text/javascript" src="raphael-min.js"></script>
|
||||||
<script type="text/javascript" src="../../../main/javascript/nlayout/raphael-plugins.js"></script>
|
<script type="text/javascript" src="raphael-plugins.js"></script>
|
||||||
|
|
||||||
<script type='text/javascript' src='../../../main/javascript/nlayout/TestSuite.js'></script>
|
<script type='text/javascript' src='TestSuite.js'></script>
|
||||||
|
|
||||||
|
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
|
7
mindplot/src/test/javascript/static/sample.xml
Normal file
7
mindplot/src/test/javascript/static/sample.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<map name="mapId" version="pela">
|
||||||
|
<topic central="true" id="0">
|
||||||
|
<topic position="-268,50" order="2" id="1">
|
||||||
|
<topic position="-387,51" order="0" id="2"/>
|
||||||
|
</topic>
|
||||||
|
</topic>
|
||||||
|
</map>
|
Loading…
Reference in New Issue
Block a user