nlayout refactor.

This commit is contained in:
Paulo Veiga
2012-01-14 14:20:59 -03:00
parent 90644c201a
commit c7ddfd6135
16 changed files with 195 additions and 195 deletions

View File

@@ -56,7 +56,7 @@ mindplot.Designer = new Class({
this._relPivot = new mindplot.RelationshipPivot(this._workspace, this);
// Init layout manager ...
this._eventBussDispatcher = new mindplot.nlayout.EventBusDispatcher(this.getModel());
this._eventBussDispatcher = new mindplot.layout.EventBusDispatcher(this.getModel());
},
_registerEvents : function() {

View File

@@ -29,4 +29,4 @@ mindplot.collaboration.framework = {};
mindplot.collaboration.framework.brix = {};
mindplot.collaboration.framework.brix.model = {};
mindplot.nlayout = {};
mindplot.layout = {};

View File

@@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.nlayout.AbstractBasicSorter = new Class({
Extends: mindplot.nlayout.ChildrenSorterStrategy,
mindplot.layout.AbstractBasicSorter = new Class({
Extends: mindplot.layout.ChildrenSorterStrategy,
computeChildrenIdByHeights: function(treeSet, node) {
var result = {};
@@ -25,7 +25,7 @@ mindplot.nlayout.AbstractBasicSorter = new Class({
},
_computeChildrenHeight : function(treeSet, node, heightCache) {
var height = node.getSize().height + (mindplot.nlayout.AbstractBasicSorter.INTERNODE_VERTICAL_PADDING * 2); // 2* Top and down padding;
var height = node.getSize().height + (mindplot.layout.AbstractBasicSorter.INTERNODE_VERTICAL_PADDING * 2); // 2* Top and down padding;
var result;
var children = treeSet.getChildren(node);
@@ -56,5 +56,5 @@ mindplot.nlayout.AbstractBasicSorter = new Class({
}
});
mindplot.nlayout.AbstractBasicSorter.INTERNODE_VERTICAL_PADDING = 5;
mindplot.nlayout.AbstractBasicSorter.INTERNODE_HORIZONTAL_PADDING = 30;
mindplot.layout.AbstractBasicSorter.INTERNODE_VERTICAL_PADDING = 5;
mindplot.layout.AbstractBasicSorter.INTERNODE_HORIZONTAL_PADDING = 30;

View File

@@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.nlayout.BalancedSorter = new Class({
Extends: mindplot.nlayout.AbstractBasicSorter,
mindplot.layout.BalancedSorter = new Class({
Extends: mindplot.layout.AbstractBasicSorter,
initialize: function() {
@@ -29,7 +29,7 @@ mindplot.nlayout.BalancedSorter = new Class({
},
_computeChildrenHeight : function(treeSet, node, heightCache) {
var height = node.getSize().height + (mindplot.nlayout.BalancedSorter.INTERNODE_VERTICAL_PADDING * 2); // 2* Top and down padding;
var height = node.getSize().height + (mindplot.layout.BalancedSorter.INTERNODE_VERTICAL_PADDING * 2); // 2* Top and down padding;
var result;
var children = treeSet.getChildren(node);
@@ -63,7 +63,7 @@ mindplot.nlayout.BalancedSorter = new Class({
// No children?
if (children.length == 0) {
return [0, {x:parent.getPosition().x + parent.getSize().width + mindplot.nlayout.BalancedSorter.INTERNODE_HORIZONTAL_PADDING * 2, y:parent.getPosition().y}];
return [0, {x:parent.getPosition().x + parent.getSize().width + mindplot.layout.BalancedSorter.INTERNODE_HORIZONTAL_PADDING * 2, y:parent.getPosition().y}];
}
@@ -75,7 +75,7 @@ mindplot.nlayout.BalancedSorter = new Class({
var cpos = child.getPosition();
if (position.y > cpos.y) {
yOffset = child == last ?
child.getSize().height + mindplot.nlayout.BalancedSorter.INTERNODE_VERTICAL_PADDING * 2 :
child.getSize().height + mindplot.layout.BalancedSorter.INTERNODE_VERTICAL_PADDING * 2 :
(children[index + 1].getPosition().y - child.getPosition().y)/2;
result = [child.getOrder() + 2,{x:cpos.x, y:cpos.y + yOffset}];
}
@@ -86,7 +86,7 @@ mindplot.nlayout.BalancedSorter = new Class({
var first = children[0];
result = [position.x > 0 ? 0 : 1, {
x:first.getPosition().x,
y:first.getPosition().y - first.getSize().height - mindplot.nlayout.BalancedSorter.INTERNODE_VERTICAL_PADDING * 2
y:first.getPosition().y - first.getSize().height - mindplot.layout.BalancedSorter.INTERNODE_VERTICAL_PADDING * 2
}];
}
@@ -167,7 +167,7 @@ mindplot.nlayout.BalancedSorter = new Class({
}
var yOffset = ysum + heights[i].height / 2;
var xOffset = direction * (node.getSize().width/2 + heights[i].width/2 + + mindplot.nlayout.BalancedSorter.INTERNODE_HORIZONTAL_PADDING);
var xOffset = direction * (node.getSize().width/2 + heights[i].width/2 + + mindplot.layout.BalancedSorter.INTERNODE_HORIZONTAL_PADDING);
$assert(!isNaN(xOffset), "xOffset can not be null");
$assert(!isNaN(yOffset), "yOffset can not be null");
@@ -208,5 +208,5 @@ mindplot.nlayout.BalancedSorter = new Class({
}
});
mindplot.nlayout.BalancedSorter.INTERNODE_VERTICAL_PADDING = 5;
mindplot.nlayout.BalancedSorter.INTERNODE_HORIZONTAL_PADDING = 30;
mindplot.layout.BalancedSorter.INTERNODE_VERTICAL_PADDING = 5;
mindplot.layout.BalancedSorter.INTERNODE_HORIZONTAL_PADDING = 30;

View File

@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.nlayout.ChangeEvent = new Class({
mindplot.layout.ChangeEvent = new Class({
initialize:function(id) {
$assert(!isNaN(id), "id can not be null");
this._id = id;

View File

@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.nlayout.ChildrenSorterStrategy = new Class({
mindplot.layout.ChildrenSorterStrategy = new Class({
initialize:function() {
},

View File

@@ -15,14 +15,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.nlayout.EventBusDispatcher = new Class({
mindplot.layout.EventBusDispatcher = new Class({
initialize:function(designerModel) {
$assert(designerModel, "designerModel cannot be null");
this.registerBusEvents();
var size = {width:25,height:25};
this._layoutManager = new mindplot.nlayout.LayoutManager(0, size);
this._layoutManager = new mindplot.layout.LayoutManager(0, size);
this._layoutManager.addEvent('change', function(event) {
var id = event.getId();
@@ -51,7 +51,7 @@ mindplot.nlayout.EventBusDispatcher = new Class({
},
_nodeMoveEvent: function(node) {
console.log("mindplot.nlayout.EventBusDispatcher._nodeMoveEvent: Not Implemented yet");
console.log("mindplot.layout.EventBusDispatcher._nodeMoveEvent: Not Implemented yet");
},
@@ -65,7 +65,7 @@ mindplot.nlayout.EventBusDispatcher = new Class({
},
_nodeRepositionateEvent: function(node) {
console.log("mindplot.nlayout.EventBusDispatcher._nodeRepositionateEvent: Not Implemented yet");
console.log("mindplot.layout.EventBusDispatcher._nodeRepositionateEvent: Not Implemented yet");
},

View File

@@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.nlayout.GridSorter = new Class({
Extends: mindplot.nlayout.AbstractBasicSorter,
mindplot.layout.GridSorter = new Class({
Extends: mindplot.layout.AbstractBasicSorter,
computeOffsets: function(treeSet, node) {
$assert(treeSet, "treeSet can no be null.");
@@ -43,7 +43,7 @@ mindplot.nlayout.GridSorter = new Class({
var finalHeight = i == 0 ? 0 : heights[i].height/2 * even;
var yOffset = zeroHeight + middleHeight +finalHeight;
var xOffset = node.getSize().width + mindplot.nlayout.GridSorter.GRID_HORIZONTAR_SIZE;
var xOffset = node.getSize().width + mindplot.layout.GridSorter.GRID_HORIZONTAR_SIZE;
$assert(!isNaN(xOffset), "xOffset can not be null");
$assert(!isNaN(yOffset), "yOffset can not be null");
@@ -60,6 +60,6 @@ mindplot.nlayout.GridSorter = new Class({
});
mindplot.nlayout.GridSorter.GRID_HORIZONTAR_SIZE = 20;
mindplot.nlayout.GridSorter.INTER_NODE_VERTICAL_DISTANCE = 50;
mindplot.layout.GridSorter.GRID_HORIZONTAR_SIZE = 20;
mindplot.layout.GridSorter.INTER_NODE_VERTICAL_DISTANCE = 50;

View File

@@ -15,14 +15,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.nlayout.LayoutManager = new Class({
mindplot.layout.LayoutManager = new Class({
Extends: Events,
initialize: function(rootNodeId, rootSize) {
$assert($defined(rootNodeId), "rootNodeId can not be null");
$assert(rootSize, "rootSize can not be null");
this._treeSet = new mindplot.nlayout.RootedTreeSet();
this._layout = new mindplot.nlayout.OriginalLayout(this._treeSet);
this._treeSet = new mindplot.layout.RootedTreeSet();
this._layout = new mindplot.layout.OriginalLayout(this._treeSet);
var rootNode = this._layout.createNode(rootNodeId, rootSize, {x:0,y:0}, 'root');
this._treeSet.setRoot(rootNode);
@@ -145,7 +145,7 @@ mindplot.nlayout.LayoutManager = new Class({
return event.id == id;
});
if (!event) {
event = new mindplot.nlayout.ChangeEvent(id);
event = new mindplot.layout.ChangeEvent(id);
}
// Update nodes ...

View File

@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.nlayout.Node = new Class({
mindplot.layout.Node = new Class({
initialize:function(id, size, position, sorter) {
$assert(typeof id === 'number' && isFinite(id), "id can not be null");
$assert(size, "size can not be null");

View File

@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.nlayout.OriginalLayout = new Class({
mindplot.layout.OriginalLayout = new Class({
initialize: function(treeSet) {
this._treeSet = treeSet;
},
@@ -27,9 +27,9 @@ mindplot.nlayout.OriginalLayout = new Class({
$assert(type, "type can not be null");
var strategy = type === 'root' ?
mindplot.nlayout.OriginalLayout.BALANCED_SORTER :
mindplot.nlayout.OriginalLayout.SYMMETRIC_SORTER;
return new mindplot.nlayout.Node(id, size, position, strategy);
mindplot.layout.OriginalLayout.BALANCED_SORTER :
mindplot.layout.OriginalLayout.SYMMETRIC_SORTER;
return new mindplot.layout.Node(id, size, position, strategy);
},
connectNode: function(parentId, childId, order) {
@@ -121,8 +121,8 @@ mindplot.nlayout.OriginalLayout = new Class({
});
mindplot.nlayout.OriginalLayout.SYMMETRIC_SORTER = new mindplot.nlayout.SymmetricSorter();
mindplot.nlayout.OriginalLayout.BALANCED_SORTER = new mindplot.nlayout.BalancedSorter();
mindplot.layout.OriginalLayout.SYMMETRIC_SORTER = new mindplot.layout.SymmetricSorter();
mindplot.layout.OriginalLayout.BALANCED_SORTER = new mindplot.layout.BalancedSorter();

View File

@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.nlayout.RootedTreeSet = new Class({
mindplot.layout.RootedTreeSet = new Class({
initialize:function() {
this._rootNodes = [];
},

View File

@@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.nlayout.SymmetricSorter = new Class({
Extends: mindplot.nlayout.AbstractBasicSorter,
mindplot.layout.SymmetricSorter = new Class({
Extends: mindplot.layout.AbstractBasicSorter,
initialize:function() {
},
@@ -29,7 +29,7 @@ mindplot.nlayout.SymmetricSorter = new Class({
if (children.length == 0) {
position = position || {x:parent.getPosition().x + direction, y:parent.getPosition().y};
var position = {
x: parent.getPosition().x + direction * (parent.getSize().width + mindplot.nlayout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
x: parent.getPosition().x + direction * (parent.getSize().width + mindplot.layout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
y:parent.getPosition().y
}
return [0, position];
@@ -43,7 +43,7 @@ mindplot.nlayout.SymmetricSorter = new Class({
var cpos = child.getPosition();
if (position.y > cpos.y) {
yOffset = child == last ?
child.getSize().height + mindplot.nlayout.SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2 :
child.getSize().height + mindplot.layout.SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2 :
(children[index + 1].getPosition().y + children[index + 1].getSize().height/2 - child.getPosition().y)/2;
result = [child.getOrder() + 1,{x:cpos.x, y:cpos.y + yOffset}];
}
@@ -54,7 +54,7 @@ mindplot.nlayout.SymmetricSorter = new Class({
var first = children[0];
result = [0, {
x:first.getPosition().x,
y:first.getPosition().y - first.getSize().height - mindplot.nlayout.SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2
y:first.getPosition().y - first.getSize().height - mindplot.layout.SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2
}];
}
@@ -116,7 +116,7 @@ mindplot.nlayout.SymmetricSorter = new Class({
var direction = parent.getPosition().x > 0 ? 1 : -1;
var yOffset = ysum + heights[i].height / 2;
var xOffset = direction * (heights[i].width/2 + node.getSize().width/2 + mindplot.nlayout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
var xOffset = direction * (heights[i].width/2 + node.getSize().width/2 + mindplot.layout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
$assert(!isNaN(xOffset), "xOffset can not be null");
$assert(!isNaN(yOffset), "yOffset can not be null");
@@ -140,7 +140,7 @@ mindplot.nlayout.SymmetricSorter = new Class({
}
});
mindplot.nlayout.SymmetricSorter.INTERNODE_VERTICAL_PADDING = 5;
mindplot.nlayout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING = 30;
mindplot.layout.SymmetricSorter.INTERNODE_VERTICAL_PADDING = 5;
mindplot.layout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING = 30;