diff --git a/mindplot/pom.xml b/mindplot/pom.xml
index c8c9a490..154dbf1f 100644
--- a/mindplot/pom.xml
+++ b/mindplot/pom.xml
@@ -82,28 +82,14 @@
-
-
-
-
-
-
-
-
+
-
@@ -159,17 +145,7 @@
files="commands/AddRelationshipCommand.js"/>
-
-
-
-
-
-
-
diff --git a/mindplot/src/main/javascript/Designer.js b/mindplot/src/main/javascript/Designer.js
index 61611999..cb162051 100644
--- a/mindplot/src/main/javascript/Designer.js
+++ b/mindplot/src/main/javascript/Designer.js
@@ -48,7 +48,7 @@ mindplot.Designer = new Class({
this._registerEvents();
// Init drag related classes ...
- this._dragTopicPositioner = new mindplot.DragTopicPositioner(this.getModel(), this._workspace);
+ this._dragConnector = new mindplot.DragConnector(this.getModel(), this._workspace);
this._dragger = this._buildDragManager(this._workspace);
mindplot.DragTopic.init(this._workspace);
}
@@ -91,22 +91,11 @@ mindplot.Designer = new Class({
}.bind(this));
// Create nodes on double click...
- screenManager.addEvent('dblclick', function(event) {
+ screenManager.addEvent('dblclick', function() {
if (workspace.isWorkspaceEventsEnabled()) {
- // Get mouse position
- var pos = screenManager.getWorkspaceMousePosition(event);
-
- // Create a new topic model ...
- var mindmap = this.getMindmap();
- var model = mindmap.createNode(mindplot.model.INodeModel.MAIN_TOPIC_TYPE);
- model.setPosition(pos.x, pos.y);
-
- // Get central topic ...
var centralTopic = this.getModel().getCentralTopic();
- var centralTopicId = centralTopic.getId();
-
- // Execute action ...
- this._actionDispatcher.addTopic(model, centralTopicId, true);
+ var model = this._createChildModel(centralTopic);
+ this._actionDispatcher.addTopic(model, centralTopic.getId());
}
}.bind(this));
@@ -127,7 +116,7 @@ mindplot.Designer = new Class({
var dragger = new mindplot.DragManager(workspace);
var topics = this.getModel().getTopics();
- var dragTopicPositioner = this._dragTopicPositioner;
+ var dragConnector = this._dragConnector;
dragger.addEvent('startdragging', function(event, node) {
// Enable all mouse events.
@@ -138,7 +127,7 @@ mindplot.Designer = new Class({
dragger.addEvent('dragging', function(event, dragTopic) {
// Update the state and connections of the topic ...
- dragTopicPositioner.positionateDragTopic(dragTopic);
+ dragConnector.update(dragTopic);
});
dragger.addEvent('enddragging', function(event, dragTopic) {
diff --git a/mindplot/src/main/javascript/DragTopicPositioner.js b/mindplot/src/main/javascript/DragConnector.js
similarity index 77%
rename from mindplot/src/main/javascript/DragTopicPositioner.js
rename to mindplot/src/main/javascript/DragConnector.js
index f5716c6f..47e879ea 100644
--- a/mindplot/src/main/javascript/DragTopicPositioner.js
+++ b/mindplot/src/main/javascript/DragConnector.js
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-mindplot.DragTopicPositioner = new Class({
+mindplot.DragConnector = new Class({
initialize:function(designerModel, workspace) {
$assert(designerModel, 'designerModel can not be null');
$assert(workspace, 'workspace can not be null');
@@ -26,24 +26,12 @@ mindplot.DragTopicPositioner = new Class({
this._workspace = workspace;
},
- positionateDragTopic : function(dragTopic) {
- // Workout the real position of the element on the board.
- var dragTopicPosition = dragTopic.getPosition();
- var draggedTopic = dragTopic.getDraggedTopic();
-
+ update : function(dragTopic) {
// Topic can be connected ?
- this._checkDragTopicConnection(dragTopic);
-
- // Position topic in the board
- if (dragTopic.isConnected()) {
- var targetTopic = dragTopic.getConnectedToTopic();
- // @todo: Hack ...
- var position = designer._eventBussDispatcher._layoutManager.predict(targetTopic.getId(),dragTopicPosition);
- console.log(position);
- }
+ this._checkConnection(dragTopic);
},
- _checkDragTopicConnection : function(dragTopic) {
+ _checkConnection : function(dragTopic) {
var topics = this._designerModel.getTopics();
// Must be disconnected from their current connection ?.
@@ -65,7 +53,7 @@ mindplot.DragTopicPositioner = new Class({
// I have to change the current connection to a main topic.
dragTopic.disconnect(this._workspace);
} else
- if (Math.abs(dragXPosition - currentXPosition) > mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE) {
+ if (Math.abs(dragXPosition - currentXPosition) > mindplot.DragConnector.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE) {
dragTopic.disconnect(this._workspace);
}
}
@@ -73,11 +61,11 @@ mindplot.DragTopicPositioner = new Class({
// Finally, connect nodes ...
if (!dragTopic.isConnected()) {
- var centalTopic = topics[0];
+ var centralTopic = topics[0];
if ($defined(mainTopicToMainTopicConnection)) {
dragTopic.connectTo(mainTopicToMainTopicConnection);
- } else if (Math.abs(dragTopic.getPosition().x - centalTopic.getPosition().x) <= mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE) {
- dragTopic.connectTo(centalTopic);
+ } else if (Math.abs(dragTopic.getPosition().x - centralTopic.getPosition().x) <= mindplot.DragConnector.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE) {
+ dragTopic.connectTo(centralTopic);
}
}
},
@@ -114,4 +102,4 @@ mindplot.DragTopicPositioner = new Class({
}
});
-mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE = 400;
+mindplot.DragConnector.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE = 400;
diff --git a/mindplot/src/main/javascript/DragManager.js b/mindplot/src/main/javascript/DragManager.js
index 3af8d80d..f3b81809 100644
--- a/mindplot/src/main/javascript/DragManager.js
+++ b/mindplot/src/main/javascript/DragManager.js
@@ -72,10 +72,6 @@ mindplot.DragManager.prototype.remove = function(node)
index = i;
}
}
- if (contained)
- {
- elem = new Array();
- }
};
mindplot.DragManager.prototype._buildMouseMoveListener = function(workspace, dragNode, dragManager)
diff --git a/mindplot/src/main/javascript/DragPivot.js b/mindplot/src/main/javascript/DragPivot.js
index d52726f8..28d438f6 100644
--- a/mindplot/src/main/javascript/DragPivot.js
+++ b/mindplot/src/main/javascript/DragPivot.js
@@ -51,58 +51,45 @@ mindplot.DragPivot = new Class({
return line;
},
- _redraw : function(pivotPosition) {
+
+ _redrawLine : function() {
// Update line position.
$assert(this.getTargetTopic(), 'Illegal invocation. Target node can not be null');
var pivotRect = this._getPivotRect();
- var currentPivotPosition = pivotRect.getPosition();
// Pivot position has not changed. In this case, position change is not required.
var targetTopic = this.getTargetTopic();
- if (currentPivotPosition.x != pivotPosition.x || currentPivotPosition.y != pivotPosition.y) {
- var position = this._position;
- var fromPoint = targetTopic.workoutIncomingConnectionPoint(position);
+ var position = this._position;
- // Calculate pivot connection point ...
- var size = this._size;
- var targetPosition = targetTopic.getPosition();
- var line = this._line;
+ // Calculate pivot connection point ...
+ var size = this._size;
+ var targetPosition = targetTopic.getPosition();
+ var line = this._line;
- // Update Line position.
- var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, position);
- var pivotPoint = mindplot.util.Shape.calculateRectConnectionPoint(position, size, isAtRight);
- line.setFrom(pivotPoint.x, pivotPoint.y);
+ // Update Line position.
+ var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, position);
+ var pivotPoint = mindplot.util.Shape.calculateRectConnectionPoint(position, size, isAtRight);
+ line.setFrom(pivotPoint.x, pivotPoint.y);
- // Update rect position
- pivotRect.setPosition(pivotPosition.x, pivotPosition.y);
+ // Update rect position
+ var cx = position.x - (parseInt(size.width) / 2);
+ var cy = position.y - (parseInt(size.height) / 2);
+ pivotRect.setPosition(cx, cy);
- // Display elements if it's required...
- if (!pivotRect.isVisible()) {
- // Make line visible only when the position has been already changed.
- // This solve several strange effects ;)
- var targetPoint = targetTopic.workoutIncomingConnectionPoint(pivotPoint);
- line.setTo(targetPoint.x, targetPoint.y);
-
- this.setVisibility(true);
- }
+ // Display elements if it's required...
+ if (!pivotRect.isVisible()) {
+ // Make line visible only when the position has been already changed.
+ // This solve several strange effects ;)
+ var targetPoint = targetTopic.workoutIncomingConnectionPoint(pivotPoint);
+ line.setTo(targetPoint.x, targetPoint.y);
+ this.setVisibility(true);
}
},
setPosition : function(point) {
this._position = point;
-
- // Update visual position.
- var size = this.getSize();
-
- var cx = point.x - (parseInt(size.width) / 2);
- var cy = point.y - (parseInt(size.height) / 2);
-
- // Update line ...
- if (this.getTargetTopic()) {
- var pivotPosition = {x:cx,y:cy};
- this._redraw(pivotPosition);
- }
+ this._redrawLine();
},
getPosition : function() {
@@ -117,13 +104,6 @@ mindplot.DragPivot = new Class({
return rect;
},
- _buildConnectRect : function() {
- var size = this._size;
- var rectAttributes = {fillColor:'#CC0033',opacity:0.4,width:size.width,height:size.height,strokeColor:'#FF9933'};
- var result = new web2d.Rect(0, rectAttributes);
- return result;
- },
-
_getPivotRect : function() {
return this._dragPivot;
},
@@ -139,9 +119,7 @@ mindplot.DragPivot = new Class({
var connectRect = this._connectRect;
connectRect.setVisibility(value);
- if ($defined(this._line)) {
- this._line.setVisibility(value);
- }
+ this._line.setVisibility(value);
},
addToWorkspace : function(workspace) {
@@ -186,11 +164,14 @@ mindplot.DragPivot = new Class({
}
},
- connectTo : function(targetTopic) {
+ connectTo : function(targetTopic, position) {
$assert(!this._outgoingLine, 'Could not connect an already connected node');
- $assert(targetTopic != this, 'Cilcular connection are not allowed');
+ $assert(targetTopic != this, 'Circular connection are not allowed');
+ $assert(position, 'position can not be null');
$assert(targetTopic, 'parent can not be null');
+ this._position = position;
+
this._targetTopic = targetTopic;
if (targetTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
this._line = this._straightLine;
@@ -216,7 +197,9 @@ mindplot.DragPivot = new Class({
// Change elements position ...
var pivotRect = this._getPivotRect();
pivotRect.moveToFront();
+ pivotRect.setPosition(position.x, position.y);
+ this._redrawLine();
},
disconnect : function(workspace) {
diff --git a/mindplot/src/main/javascript/DragTopic.js b/mindplot/src/main/javascript/DragTopic.js
index 8b4906a4..348c1312 100644
--- a/mindplot/src/main/javascript/DragTopic.js
+++ b/mindplot/src/main/javascript/DragTopic.js
@@ -44,6 +44,17 @@ mindplot.DragTopic = new Class({
// Update visual position.
this._elem2d.setPosition(cx, cy);
+
+ if (this.isConnected()) {
+ var parent = this.getConnectedToTopic();
+ var predict = designer._eventBussDispatcher._layoutManager.predict(parent.getId(), this.getPosition());
+ if (this._order != predict.order) {
+ var dragPivot = this._getDragPivot();
+ var position = predict.position;
+ dragPivot.connectTo(parent, position);
+ this.setOrder(predict.order);
+ }
+ }
},
getInnerShape : function() {
@@ -82,15 +93,21 @@ mindplot.DragTopic = new Class({
connectTo : function(parent) {
$assert(parent, 'Parent connection node can not be null.');
+ // Where it should be connected ?
+ var predict = designer._eventBussDispatcher._layoutManager.predict(parent.getId(), this.getPosition());
+
+ // Connect pivot ...
var dragPivot = this._getDragPivot();
- dragPivot.connectTo(parent);
+ var position = predict.position;
+ dragPivot.connectTo(parent, position);
+
+ this.setOrder(predict.order);
},
getDraggedTopic : function() {
return this._draggedNode;
},
-
removeFromWorkspace : function(workspace) {
// Remove drag shadow.
workspace.removeChild(this._elem2d);
@@ -114,8 +131,7 @@ mindplot.DragTopic = new Class({
getPosition:function() {
return this._position;
- }
- ,
+ },
isDragTopic : function() {
return true;
@@ -124,52 +140,24 @@ mindplot.DragTopic = new Class({
applyChanges : function(workspace) {
$assert(workspace, 'workspace can not be null');
- var dragPivot = this._getDragPivot();
var draggedTopic = this.getDraggedTopic();
var isDragConnected = this.isConnected();
- // @Todo: Remove this static ...
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
var topicId = draggedTopic.getId();
+ var dragPosition = this.getPosition();
+ var order = null;
+ var parent = null;
if (isDragConnected) {
-
var targetTopic = this.getConnectedToTopic();
- if (targetTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
- // Update topic position ...
- var dragPivotPosition = dragPivot.getPosition();
-
- // Must position the dragged topic taking into account the current node size.
- var pivotSize = dragPivot.getSize();
- var draggedTopicSize = draggedTopic.getSize();
- var xOffset = draggedTopicSize.width - pivotSize.width;
- xOffset = Math.round(xOffset / 2);
-
- if (dragPivotPosition.x > 0) {
- dragPivotPosition.x = parseInt(dragPivotPosition.x) + xOffset;
- }
- else {
- dragPivotPosition.x = parseInt(dragPivotPosition.x) - xOffset;
- }
- // Set new position ...
- actionDispatcher.dragTopic(topicId, dragPivotPosition, null, targetTopic);
-
- } else {
- // Main topic connections can be positioned only with the order ...
- actionDispatcher.dragTopic(topicId, null, this._order, targetTopic);
- }
- } else {
-
- // If the node is not connected, positionate based on the original drag topic position.
- var dragPosition = this.getPosition();
- actionDispatcher.dragTopic(topicId, dragPosition);
+ order = this._order;
+ parent = targetTopic;
}
- },
- setBoardPosition : function(point) {
- $assert(point, 'point can not be null');
- var dragPivot = this._getDragPivot();
- dragPivot.setPosition(point);
+ // If the node is not connected, position based on the original drag topic position.
+ actionDispatcher.dragTopic(topicId, dragPosition, order, parent);
+
},
getConnectedToTopic : function() {
@@ -181,9 +169,10 @@ mindplot.DragTopic = new Class({
return this.getConnectedToTopic() != null;
}
-});
+})
+ ;
-mindplot.DragTopic.PIVOT_SIZE = {width:50,height:10};
+mindplot.DragTopic.PIVOT_SIZE = {width:50,height:6};
mindplot.DragTopic.init = function(workspace) {
diff --git a/mindplot/src/main/javascript/nlayout/AbstractBasicSorter.js b/mindplot/src/main/javascript/layout/AbstractBasicSorter.js
similarity index 100%
rename from mindplot/src/main/javascript/nlayout/AbstractBasicSorter.js
rename to mindplot/src/main/javascript/layout/AbstractBasicSorter.js
diff --git a/mindplot/src/main/javascript/nlayout/BalancedSorter.js b/mindplot/src/main/javascript/layout/BalancedSorter.js
similarity index 100%
rename from mindplot/src/main/javascript/nlayout/BalancedSorter.js
rename to mindplot/src/main/javascript/layout/BalancedSorter.js
diff --git a/mindplot/src/main/javascript/layout/BaseLayoutManager.js b/mindplot/src/main/javascript/layout/BaseLayoutManager.js
deleted file mode 100644
index 7f0b7f2a..00000000
--- a/mindplot/src/main/javascript/layout/BaseLayoutManager.js
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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.layout.BaseLayoutManager = new Class({
-
- options: {
-
- },
-
- initialize: function(designer, options) {
- this.setOptions(options);
- this._createBoard();
- this._designer = designer;
-// 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.ONodeDisconnectEvent, this._nodeDisconnectEvent.bind(this));
-// mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.ONodeConnectEvent, this._nodeConnectEvent.bind(this));
-// mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeRepositionateEvent, this._nodeRepositionateEvent.bind(this));
-// mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeShrinkEvent, this._nodeShrinkEvent.bind(this));
- },
-
- _nodeResizeEvent:function(node) {
- },
-
- _nodeMoveEvent:function(node) {
- var modifiedTopics = [];
- this.getTopicBoardForTopic(node).updateChildrenPosition(node, modifiedTopics);
- },
-
- _nodeDisconnectEvent:function(targetNode, node) {
- var modifiedTopics = [];
- this.getTopicBoardForTopic(targetNode).removeTopicFromBoard(node, modifiedTopics);
- },
-
- _nodeConnectEvent:function(targetNode, node) {
- var modifiedTopics = [];
- this.getTopicBoardForTopic(targetNode).addBranch(node, modifiedTopics);
- },
-
- _nodeRepositionateEvent:function(node) {
- var modifiedTopics = [];
- this.getTopicBoardForTopic(node).updateChildrenPosition(node, modifiedTopics);
- },
-
- _nodeShrinkEvent:function(node) {
- },
-
- _createBoard:function() {
- this._boards = new Hash();
- },
- getTopicBoardForTopic:function(node) {
- var id = node.getId();
- var result = this._boards[id];
- if (!$defined(result)) {
- result = this._addNode(node);
- }
- return result;
- },
- _addNode:function(node) {
- var board = null;
- if (this._isCentralTopic(node))
- board = this._createCentralTopicBoard(node);
- else
- board = this._createMainTopicBoard(node);
- var id = node.getId();
- this._boards[id] = board;
- return board;
- },
- _createMainTopicBoard:function(node) {
- return new mindplot.layout.boards.Board(node, this);
- },
- _createCentralTopicBoard:function(node) {
- return new mindplot.layout.boards.Board(node, this);
- },
- prepareNode:function(node, children) {
-
- },
- addHelpers:function(node) {
-
- },
- needsPrepositioning:function() {
- return true;
- },
- getDesigner:function() {
- return this._designer;
- },
- _isCentralTopic:function(node) {
- var type = node.getModel().getType();
- return type == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE;
- },
-
- getClassName:function() {
- return mindplot.layout.BaseLayoutManager.NAME;
- }
-});
-
-mindplot.layout.BaseLayoutManager.NAME = "BaseLayoutManager";
-
-mindplot.layout.BaseLayoutManager.implement(new Events);
-mindplot.layout.BaseLayoutManager.implement(new Options);
\ No newline at end of file
diff --git a/mindplot/src/main/javascript/nlayout/ChangeEvent.js b/mindplot/src/main/javascript/layout/ChangeEvent.js
similarity index 100%
rename from mindplot/src/main/javascript/nlayout/ChangeEvent.js
rename to mindplot/src/main/javascript/layout/ChangeEvent.js
diff --git a/mindplot/src/main/javascript/nlayout/ChildrenSorterStrategy.js b/mindplot/src/main/javascript/layout/ChildrenSorterStrategy.js
similarity index 100%
rename from mindplot/src/main/javascript/nlayout/ChildrenSorterStrategy.js
rename to mindplot/src/main/javascript/layout/ChildrenSorterStrategy.js
diff --git a/mindplot/src/main/javascript/nlayout/EventBus.js b/mindplot/src/main/javascript/layout/EventBus.js
similarity index 100%
rename from mindplot/src/main/javascript/nlayout/EventBus.js
rename to mindplot/src/main/javascript/layout/EventBus.js
diff --git a/mindplot/src/main/javascript/nlayout/EventBusDispatcher.js b/mindplot/src/main/javascript/layout/EventBusDispatcher.js
similarity index 100%
rename from mindplot/src/main/javascript/nlayout/EventBusDispatcher.js
rename to mindplot/src/main/javascript/layout/EventBusDispatcher.js
diff --git a/mindplot/src/main/javascript/nlayout/GridSorter.js b/mindplot/src/main/javascript/layout/GridSorter.js
similarity index 100%
rename from mindplot/src/main/javascript/nlayout/GridSorter.js
rename to mindplot/src/main/javascript/layout/GridSorter.js
diff --git a/mindplot/src/main/javascript/nlayout/LayoutManager.js b/mindplot/src/main/javascript/layout/LayoutManager.js
similarity index 100%
rename from mindplot/src/main/javascript/nlayout/LayoutManager.js
rename to mindplot/src/main/javascript/layout/LayoutManager.js
diff --git a/mindplot/src/main/javascript/layout/LayoutManagerFactory.js b/mindplot/src/main/javascript/layout/LayoutManagerFactory.js
deleted file mode 100644
index 2bd16473..00000000
--- a/mindplot/src/main/javascript/layout/LayoutManagerFactory.js
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.layout.LayoutManagerFactory = {};
-mindplot.layout.LayoutManagerFactory.managers = {
- OriginalLayoutManager:mindplot.layout.OriginalLayoutManager,
- FreeMindLayoutManager:mindplot.layout.FreeMindLayoutManager
-};
-mindplot.layout.LayoutManagerFactory.getManagerByName = function(name) {
- var manager = mindplot.layout.LayoutManagerFactory.managers[name + "Manager"];
- if ($defined(manager)) {
- return manager;
- }
- else {
- return mindplot.layout.LayoutManagerFactory.managers["OriginalLayoutManager"];
- }
-};
-
-
diff --git a/mindplot/src/main/javascript/nlayout/Node.js b/mindplot/src/main/javascript/layout/Node.js
similarity index 100%
rename from mindplot/src/main/javascript/nlayout/Node.js
rename to mindplot/src/main/javascript/layout/Node.js
diff --git a/mindplot/src/main/javascript/nlayout/OriginalLayout.js b/mindplot/src/main/javascript/layout/OriginalLayout.js
similarity index 100%
rename from mindplot/src/main/javascript/nlayout/OriginalLayout.js
rename to mindplot/src/main/javascript/layout/OriginalLayout.js
diff --git a/mindplot/src/main/javascript/layout/OriginalLayoutManager.js b/mindplot/src/main/javascript/layout/OriginalLayoutManager.js
deleted file mode 100644
index b7041f9d..00000000
--- a/mindplot/src/main/javascript/layout/OriginalLayoutManager.js
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.layout.OriginalLayoutManager = new Class({
- Extends:mindplot.layout.BaseLayoutManager,
- options:{
-
- },
- initialize:function(designer, options) {
- this.parent(designer, options);
-
- },
-
- prepareNode:function(node, children) {
- // Sort children by order to solve adding order in for OriginalLayoutManager...
- var nodesByOrder = new Hash();
- var maxOrder = 0;
- var result = [];
- if (children.length > 0) {
- for (var i = 0; i < children.length; i++) {
- var child = children[i];
- var order = child.getOrder();
- if (!$defined(order)) {
- order = ++maxOrder;
- child.setOrder(order);
- }
-
- if (nodesByOrder.has(order)) {
- if (Math.sign(child.getPosition().x) == Math.sign(nodesByOrder.get(order).getPosition().x)) {
- //duplicated order. Change order to next available.
- order = ++maxOrder;
- child.setOrder(order);
- }
- } else {
- nodesByOrder.set(order, child);
- if (order > maxOrder)
- maxOrder = order;
- }
- result[order] = child;
- }
- }
- nodesByOrder = null;
- return node.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE ? result : children;
- },
-
- _nodeResizeEvent:function(node) {
-
- },
-
- _nodeRepositionateEvent:function(node) {
- this.getTopicBoardForTopic(node).repositionate();
- },
-
- getDragTopicPositioner : function() {
- return this._dragTopicPositioner;
- },
-
-
-
- _createMainTopicBoard:function(node) {
- return new mindplot.layout.boards.original.MainTopicBoard(node, this);
- },
-
- _createCentralTopicBoard:function(node) {
- return new mindplot.layout.boards.original.CentralTopicBoard(node, this);
- },
-
- getClassName:function() {
- return mindplot.layout.OriginalLayoutManager.NAME;
- }
-});
-
-mindplot.layout.OriginalLayoutManager.NAME = "OriginalLayoutManager";
\ No newline at end of file
diff --git a/mindplot/src/main/javascript/nlayout/RootedTreeSet.js b/mindplot/src/main/javascript/layout/RootedTreeSet.js
similarity index 100%
rename from mindplot/src/main/javascript/nlayout/RootedTreeSet.js
rename to mindplot/src/main/javascript/layout/RootedTreeSet.js
diff --git a/mindplot/src/main/javascript/nlayout/SymmetricSorter.js b/mindplot/src/main/javascript/layout/SymmetricSorter.js
similarity index 100%
rename from mindplot/src/main/javascript/nlayout/SymmetricSorter.js
rename to mindplot/src/main/javascript/layout/SymmetricSorter.js
diff --git a/mindplot/src/main/javascript/layout/boards/Board.js b/mindplot/src/main/javascript/layout/boards/Board.js
deleted file mode 100644
index 34d40b8d..00000000
--- a/mindplot/src/main/javascript/layout/boards/Board.js
+++ /dev/null
@@ -1,31 +0,0 @@
-mindplot.layout.boards.Board = new Class({
- Implements: [Events,Options],
- options: {
-
- },
- initialize: function(node, layoutManager, options) {
- this.setOptions(options);
- this._node = node;
- this._layoutManager = layoutManager;
- },
- getClassName:function() {
- return mindplot.layout.boards.Board.NAME;
- },
- removeTopicFromBoard:function(node, modifiedTopics) {
- $assert(false, "no Board implementation found!");
- },
- addBranch:function(node, modifiedTopics) {
- $assert(false, "no Board implementation found!");
- },
- updateChildrenPosition:function(node, modifiedTopics) {
- $assert(false, "no Board implementation found!");
- },
- setNodeMarginTop:function(node, delta) {
- $assert(false, "no Board implementation found!");
- },
- getNode:function() {
- return this._node;
- }
-});
-
-mindplot.layout.boards.Board.NAME = "Board";
diff --git a/mindplot/src/main/javascript/layout/boards/original/Board.js b/mindplot/src/main/javascript/layout/boards/original/Board.js
deleted file mode 100644
index 1db93471..00000000
--- a/mindplot/src/main/javascript/layout/boards/original/Board.js
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * 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.layout.boards.original.Board = new Class({
- initialize : function(defaultHeight, referencePoint) {
- $assert(referencePoint, "referencePoint can not be null");
- this._defaultWidth = defaultHeight;
- this._entries = new mindplot.layout.boards.original.BidirectionalArray();
- this._referencePoint = referencePoint;
- },
-
- getReferencePoint : function() {
- return this._referencePoint;
- },
-
- _removeEntryByOrder : function(order, position) {
- var board = this._getBoard(position);
- var entry = board.lookupEntryByOrder(order);
-
- $assert(!entry.isAvailable(), 'Entry must not be available in order to be removed.Entry Order:' + order);
- entry.removeTopic();
- board.update(entry);
- },
-
- removeTopicFromBoard : function(topic) {
- var position = topic.getPosition();
- var order = topic.getOrder();
-
- this._removeEntryByOrder(order, position);
- topic.setOrder(null);
- },
-
- positionateDragTopic :function(dragTopic) {
- throw "this method must be overrided";
- },
-
- getHeight: function() {
- var board = this._getBoard();
- return board.getHeight();
- }
-});
-
-/**
- * ---------------------------------------
- */
-mindplot.layout.boards.original.BidirectionalArray = new Class({
-
- initialize: function() {
- this._leftElem = [];
- this._rightElem = [];
- },
-
- get :function(index, sign) {
- $assert($defined(index), 'Illegal argument, index must be passed.');
- if ($defined(sign)) {
- $assert(index >= 0, 'Illegal absIndex value');
- index = index * sign;
- }
-
- var result = null;
- if (index >= 0 && index < this._rightElem.length) {
- result = this._rightElem[index];
- } else if (index < 0 && Math.abs(index) < this._leftElem.length) {
- result = this._leftElem[Math.abs(index)];
- }
- return result;
- },
-
- set : function(index, elem) {
- $assert($defined(index), 'Illegal index value');
-
- var array = (index >= 0) ? this._rightElem : this._leftElem;
- array[Math.abs(index)] = elem;
- },
-
- length : function(index) {
- $assert($defined(index), 'Illegal index value');
- return (index >= 0) ? this._rightElem.length : this._leftElem.length;
- },
-
- upperLength : function() {
- return this.length(1);
- },
-
- lowerLength : function() {
- return this.length(-1);
- },
-
- inspect : function() {
- var result = '{';
- var lenght = this._leftElem.length;
- for (var i = 0; i < lenght; i++) {
- var entry = this._leftElem[lenght - i - 1];
- if (entry != null) {
- if (i != 0) {
- result += ', ';
- }
- result += entry.inspect();
- }
- }
-
- lenght = this._rightElem.length;
- for (var i = 0; i < lenght; i++) {
- var entry = this._rightElem[i];
- if (entry != null) {
- if (i != 0) {
- result += ', ';
- }
- result += entry.inspect();
- }
- }
- result += '}';
-
- return result;
-
- }
-});
\ No newline at end of file
diff --git a/mindplot/src/main/javascript/layout/boards/original/BoardEntry.js b/mindplot/src/main/javascript/layout/boards/original/BoardEntry.js
deleted file mode 100644
index 900a22ea..00000000
--- a/mindplot/src/main/javascript/layout/boards/original/BoardEntry.js
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * 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.layout.boards.original.BoardEntry = new Class({
- initialize:function(lowerLimit, upperLimit, order) {
- if ($defined(lowerLimit) && $defined(upperLimit)) {
- $assert(lowerLimit < upperLimit, 'lowerLimit can not be greater that upperLimit');
- }
- this._upperLimit = upperLimit;
- this._lowerLimit = lowerLimit;
- this._order = order;
- this._topic = null;
- this._xPos = null;
- },
-
-
- getUpperLimit : function() {
- return this._upperLimit;
- },
-
- setXPosition : function(xPosition) {
- this._xPos = xPosition;
- },
-
- workoutEntryYCenter : function() {
- return this._lowerLimit + ((this._upperLimit - this._lowerLimit) / 2);
- },
-
- setUpperLimit : function(value) {
- $assert(!isNaN(value), "upper limit can not be null");
- $assert(!isNaN(value), "illegal value");
- this._upperLimit = value;
- },
-
- isCoordinateIn : function(coord) {
- return this._lowerLimit <= coord && coord < this._upperLimit;
- },
-
- getLowerLimit : function() {
- return this._lowerLimit;
- },
-
- setLowerLimit : function(value) {
- $assert(!isNaN(value), "upper limit can not be null");
- $assert(!isNaN(value), "illegal value");
- this._lowerLimit = value;
- },
-
- setOrder : function(value) {
- this._order = value;
- },
-
- getWidth : function() {
- return Math.abs(this._upperLimit - this._lowerLimit);
- },
-
-
- getTopic : function() {
- return this._topic;
- },
-
-
- removeTopic : function() {
- $assert(!this.isAvailable(), "Entry doesn't have a topic.");
- var topic = this.getTopic();
- this.setTopic(null);
- topic.setOrder(null);
- },
-
-
- update : function() {
- var topic = this.getTopic();
- this.setTopic(topic);
- },
-
- setTopic : function(topic, updatePosition) {
- if (!$defined(updatePosition) || ($defined(updatePosition) && !updatePosition)) {
- updatePosition = true;
- }
-
- this._topic = topic;
- if ($defined(topic)) {
- // Fixed positioning. Only for main topic ...
- var position = null;
- var topicPosition = topic.getPosition();
-
- // Must update position base on the border limits?
- if ($defined(this._xPos)) {
- position = new core.Point();
-
- // Update x position ...
- var topicSize = topic.getSize();
- var halfTopicWidh = parseInt(topicSize.width / 2);
- halfTopicWidh = (this._xPos > 0) ? halfTopicWidh : -halfTopicWidh;
- position.x = this._xPos + halfTopicWidh;
- position.y = this.workoutEntryYCenter();
- } else {
-
- // Central topic
- this._height = topic.getSize().height;
- var xPos = topicPosition.x;
- var yPos = this.workoutEntryYCenter();
- position = new core.Point(xPos, yPos);
- }
-
- // @todo: No esta de mas...
- topic.setPosition(position);
- topic.setOrder(this._order);
- }
- else {
- this._height = this._defaultWidth;
- }
- },
-
- isAvailable : function() {
- return !$defined(this._topic);
- },
-
- getOrder : function() {
- return this._order;
- },
-
- inspect : function() {
- return '(order: ' + this._order + ', lowerLimit:' + this._lowerLimit + ', upperLimit: ' + this._upperLimit + ', available:' + this.isAvailable() + ')';
- }
-});
\ No newline at end of file
diff --git a/mindplot/src/main/javascript/layout/boards/original/CentralTopicBoard.js b/mindplot/src/main/javascript/layout/boards/original/CentralTopicBoard.js
deleted file mode 100644
index 7b63216e..00000000
--- a/mindplot/src/main/javascript/layout/boards/original/CentralTopicBoard.js
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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.layout.boards.original.CentralTopicBoard = new Class({
- Extends:mindplot.layout.boards.original.Board,
- initialize:function(centralTopic, layoutManager) {
- var point = new core.Point(0, 0);
- this._layoutManager = layoutManager;
- this._rightBoard = new mindplot.layout.boards.original.VariableDistanceBoard(50, point);
- this._leftBoard = new mindplot.layout.boards.original.VariableDistanceBoard(50, point);
- this._centralTopic = centralTopic;
- },
-
- _getBoard : function(position) {
- return (position.x >= 0) ? this._rightBoard : this._leftBoard;
- },
-
- positionateDragTopic : function(dragTopic) {
- $assert(dragTopic != null, 'dragTopic can not be null');
- $assert(dragTopic.isDragTopic, 'dragTopic must be DragTopic instance');
-
- // This node is a main topic node. Position
- var dragPos = dragTopic.getPosition();
- var board = this._getBoard(dragPos);
-
- // Look for entry ...
- var entry = board.lookupEntryByPosition(dragPos);
-
- // Calculate 'y' position base on the entry ...
- var yCoord;
- if (!entry.isAvailable() && entry.getTopic() != dragTopic.getDraggedTopic()) {
- yCoord = entry.getLowerLimit();
- } else {
- yCoord = entry.workoutEntryYCenter();
- }
-
-
- // MainTopic can not be positioned over the drag topic ...
- var centralTopic = this._centralTopic;
- var centralTopicSize = centralTopic.getSize();
- var halfWidth = (centralTopicSize.width / 2);
- if (Math.abs(dragPos.x) < halfWidth + 60) {
- var distance = halfWidth + 60;
- dragPos.x = (dragPos.x > 0) ? distance : -distance;
- }
-
- // Update board position.
- var pivotPos = new core.Point(dragPos.x, yCoord);
- dragTopic.setBoardPosition(pivotPos);
- },
-
-
- addBranch : function(topic) {
- // Update topic position ...
- var position = topic.getPosition();
-
- var order = topic.getOrder();
- var board = this._getBoard(position);
- var entry = null;
- if (order != null) {
- entry = board.lookupEntryByOrder(order);
- } else {
- entry = board.lookupEntryByPosition(position);
- }
-
- // If the entry is not available, I must swap the the entries...
- if (!entry.isAvailable()) {
- board.freeEntry(entry);
- }
-
- // Add it to the board ...
- entry.setTopic(topic);
- board.update(entry);
- },
-
- updateChildrenPosition : function(topic, xOffset, modifiedTopics) {
- var board = this._rightBoard;
- var oldReferencePosition = board.getReferencePoint();
- var newReferencePosition = new core.Point(oldReferencePosition.x + xOffset, oldReferencePosition.y);
- board.updateReferencePoint(newReferencePosition);
-
- board = this._leftBoard;
- oldReferencePosition = board.getReferencePoint();
- newReferencePosition = new core.Point(oldReferencePosition.x - xOffset, oldReferencePosition.y);
- board.updateReferencePoint(newReferencePosition);
- },
-
- repositionate : function() {
- //@todo: implement ..
- }
-});
\ No newline at end of file
diff --git a/mindplot/src/main/javascript/layout/boards/original/FixedDistanceBoard.js b/mindplot/src/main/javascript/layout/boards/original/FixedDistanceBoard.js
deleted file mode 100644
index 1fa85e8b..00000000
--- a/mindplot/src/main/javascript/layout/boards/original/FixedDistanceBoard.js
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * 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.layout.boards.original.FixedDistanceBoard = new Class({
- Extends:mindplot.layout.boards.original.Board,
- initialize:function(defaultHeight, topic, layoutManager) {
- this._topic = topic;
- this._layoutManager = layoutManager;
- var reference = topic.getPosition();
- this.parent(defaultHeight, reference);
- this._height = defaultHeight;
- this._entries = [];
- },
-
- getHeight : function() {
- return this._height;
- },
-
- lookupEntryByOrder : function(order) {
- var result = null;
- var entries = this._entries;
- if (order < entries.length) {
- result = entries[order];
- }
-
- if (result == null) {
- var defaultHeight = this._defaultWidth;
- var reference = this.getReferencePoint();
- if (entries.length == 0) {
- var yReference = reference.y;
- result = this.createBoardEntry(yReference - (defaultHeight / 2), yReference + (defaultHeight / 2), 0);
- } else {
- var entriesLenght = entries.length;
- var lastEntry = entries[entriesLenght - 1];
- var lowerLimit = lastEntry.getUpperLimit();
- var upperLimit = lowerLimit + defaultHeight;
- result = this.createBoardEntry(lowerLimit, upperLimit, entriesLenght + 1);
- }
- }
- return result;
- },
-
- createBoardEntry : function(lowerLimit, upperLimit, order) {
- var result = new mindplot.layout.boards.original.BoardEntry(lowerLimit, upperLimit, order);
- var xPos = this.workoutXBorderDistance();
- result.setXPosition(xPos);
- return result;
- },
-
- updateReferencePoint : function() {
- var entries = this._entries;
- var parentTopic = this.getTopic();
- var parentPosition = parentTopic.workoutIncomingConnectionPoint(parentTopic.getPosition());
- var referencePoint = this.getReferencePoint();
- var yOffset = parentPosition.y - referencePoint.y;
-
- for (var i = 0; i < entries.length; i++) {
- var entry = entries[i];
-
- if ($defined(entry)) {
- var upperLimit = entry.getUpperLimit() + yOffset;
- var lowerLimit = entry.getLowerLimit() + yOffset;
- entry.setUpperLimit(upperLimit);
- entry.setLowerLimit(lowerLimit);
-
- // Fix x position ...
- var xPos = this.workoutXBorderDistance();
- entry.setXPosition(xPos);
- entry.update();
- }
- }
- this._referencePoint = parentPosition.clone();
-
- },
-
- /**
- * This x distance doesn't take into account the size of the shape.
- */
- workoutXBorderDistance : function() {
- var topic = this.getTopic();
-
- var topicPosition = topic.getPosition();
- var topicSize = topic.getSize();
- var halfTargetWidth = topicSize.width / 2;
- var result;
- if (topicPosition.x >= 0) {
- // It's at right.
- result = topicPosition.x + halfTargetWidth + mindplot.layout.boards.original.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE;
- } else {
- result = topicPosition.x - (halfTargetWidth + mindplot.layout.boards.original.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE);
- }
- return result;
- },
-
- getTopic : function() {
- return this._topic;
- },
-
- freeEntry : function(entry) {
- var newEntries = [];
- var entries = this._entries;
- var order = 0;
- for (var i = 0; i < entries.length; i++) {
- var e = entries[i];
- if (e == entry) {
- order++;
- }
- newEntries[order] = e;
- order++;
- }
- this._entries = newEntries;
- },
-
- repositionate : function() {
- // Workout width and update topic height.
- var entries = this._entries;
- var height = 0;
- var model = this._topic.getModel();
- if (entries.length >= 1 && !model.areChildrenShrunken()) {
- for (var i = 0; i < entries.length; i++) {
- var e = entries[i];
- if (e && e.getTopic()) {
- var topic = e.getTopic();
- var topicBoard = this._layoutManager.getTopicBoardForTopic(topic);
- var topicBoardHeight = topicBoard.getHeight();
-
-
- height += topicBoardHeight + mindplot.layout.boards.original.FixedDistanceBoard.INTER_TOPIC_DISTANCE;
- }
- }
- }
- else {
- var topic = this._topic;
- height = topic.getSize().height + mindplot.layout.boards.original.FixedDistanceBoard.INTER_TOPIC_DISTANCE;
- }
-
- var oldHeight = this._height;
- this._height = height;
-
- // I must update all the parent nodes first...
- if (oldHeight != this._height) {
- var topic = this._topic;
- var parentTopic = topic.getParent();
- if (parentTopic != null) {
- var board = this._layoutManager.getTopicBoardForTopic(parentTopic);
- board.repositionate();
- }
- }
-
-
- // Workout center the new topic center...
- var refence = this.getReferencePoint();
- var lowerLimit;
- if (entries.length > 0) {
- var l = 0;
- for (l = 0; l < entries.length; l++) {
- if ($defined(entries[l]))
- break;
- }
- var topic = entries[l].getTopic();
- var firstNodeHeight = topic.getSize().height;
- lowerLimit = refence.y - (height / 2) - (firstNodeHeight / 2) + 1;
- }
-
- var upperLimit = null;
-
- // Start moving all the elements ...
- var newEntries = [];
- var order = 0;
- for (var i = 0; i < entries.length; i++) {
- var e = entries[i];
- if (e && e.getTopic()) {
-
- var currentTopic = e.getTopic();
- e.setLowerLimit(lowerLimit);
-
- // Update entry ...
- var topicBoard = this._layoutManager.getTopicBoardForTopic(currentTopic);
- var topicBoardHeight = topicBoard.getHeight();
-
- upperLimit = lowerLimit + topicBoardHeight + mindplot.layout.boards.original.FixedDistanceBoard.INTER_TOPIC_DISTANCE;
- e.setUpperLimit(upperLimit);
- lowerLimit = upperLimit;
-
- e.setOrder(order);
- currentTopic.setOrder(order);
-
- e.update();
- newEntries[order] = e;
- order++;
- }
- }
- this._entries = newEntries;
- },
-
- removeTopic : function(topic) {
- var order = topic.getOrder();
- var entry = this.lookupEntryByOrder(order);
- $assert(!entry.isAvailable(), "Illegal state");
-
- entry.setTopic(null);
- topic.setOrder(null);
- this._entries.erase(entry);
-
- // Repositionate all elements ...
- this.repositionate();
- },
-
- addTopic : function(order, topic) {
-
- // If the entry is not available, I must swap the the entries...
- var entry = this.lookupEntryByOrder(order);
- if (!entry.isAvailable()) {
- this.freeEntry(entry);
- // Create a dummy entry ...
- // Puaj, do something with this...
- entry = this.createBoardEntry(-1, 0, order);
- this._entries[order] = entry;
- }
- this._entries[order] = entry;
-
- // Add to the board ...
- entry.setTopic(topic, false);
-
- // Repositionate all elements ...
- this.repositionate();
- },
-
- lookupEntryByPosition : function(pos) {
- $assert(pos, 'position can not be null');
-
- var entries = this._entries;
- var result = null;
- for (var i = 0; i < entries.length; i++) {
- var entry = entries[i];
- if (pos.y < entry.getUpperLimit() && pos.y >= entry.getLowerLimit()) {
- result = entry;
- }
- }
-
- if (result == null) {
- var defaultHeight = this._defaultWidth;
- if (entries.length == 0) {
- var reference = this.getReferencePoint();
- var yReference = reference.y;
- result = this.createBoardEntry(yReference - (defaultHeight / 2), yReference + (defaultHeight / 2), 0);
- } else {
- var firstEntry = entries[0];
- if (pos.y < firstEntry.getLowerLimit()) {
- var upperLimit = firstEntry.getLowerLimit();
- var lowerLimit = upperLimit - defaultHeight;
- result = this.createBoardEntry(lowerLimit, upperLimit, 0);
- } else {
- var entriesLenght = entries.length;
- var lastEntry = entries[entriesLenght - 1];
- var lowerLimit = lastEntry.getUpperLimit();
- var upperLimit = lowerLimit + defaultHeight;
- result = this.createBoardEntry(lowerLimit, upperLimit, entriesLenght);
- }
- }
- }
-
- return result;
- }
-});
-
-mindplot.layout.boards.original.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE = 60;
-mindplot.layout.boards.original.FixedDistanceBoard.INTER_TOPIC_DISTANCE = 6;
-
-
-
diff --git a/mindplot/src/main/javascript/layout/boards/original/MainTopicBoard.js b/mindplot/src/main/javascript/layout/boards/original/MainTopicBoard.js
deleted file mode 100644
index 0a529ce0..00000000
--- a/mindplot/src/main/javascript/layout/boards/original/MainTopicBoard.js
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * 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.layout.boards.original.MainTopicBoard = new Class({
- Extends:mindplot.layout.boards.original.Board,
- initialize:function(topic, layoutManager) {
- this._layoutManager = layoutManager;
- this._topic = topic;
- this._board = null;
- this._height = 0;
- },
-
-
- _getBoard: function() {
- if (!$defined(this._board)) {
- var topic = this._topic;
- this._board = new mindplot.layout.boards.original.FixedDistanceBoard(mindplot.MainTopic.DEFAULT_MAIN_TOPIC_HEIGHT, topic, this._layoutManager);
- }
- return this._board;
- },
-
- updateReferencePoint : function(position) {
- this._board.updateReferencePoint(position);
- },
-
- updateChildrenPosition : function(topic) {
- var board = this._getBoard();
- board.updateReferencePoint();
- },
-
- positionateDragTopic : function(dragTopic) {
- $assert(dragTopic != null, 'dragTopic can not be null');
- $assert(dragTopic.isDragTopic, 'dragTopic must be DragTopic instance');
-
- // This node is a main topic node. Position
- var dragPos = dragTopic.getPosition();
- var board = this._getBoard();
-
- // Look for entry ...
- var entry = board.lookupEntryByPosition(dragPos);
-
- // Calculate 'y' position base on the entry ...
- var yCoord;
- if (!entry.isAvailable() && entry.getTopic() != dragTopic.getDraggedTopic()) {
- yCoord = entry.getLowerLimit();
- } else {
- yCoord = entry.workoutEntryYCenter();
- }
-
- // Update board position.
- var targetTopic = dragTopic.getConnectedToTopic();
- var xCoord = this._workoutXBorderDistance(targetTopic);
-
- // Add the size of the pivot to the distance ...
- var halfPivotWidth = mindplot.DragTopic.PIVOT_SIZE.width / 2;
- xCoord = xCoord + ((dragPos.x > 0) ? halfPivotWidth : -halfPivotWidth);
-
- var pivotPos = new core.Point(xCoord, yCoord);
- dragTopic.setBoardPosition(pivotPos);
-
- var order = entry.getOrder();
- dragTopic.setOrder(order);
- },
-
- /**
- * This x distance doesn't take into account the size of the shape.
- */
- _workoutXBorderDistance : function(topic) {
- $assert(topic, 'topic can not be null');
- var board = this._getBoard();
- return board.workoutXBorderDistance(topic);
- },
-
- addBranch : function(topic) {
- var order = topic.getOrder();
- $assert($defined(order), "Order must be defined");
-
- // If the entry is not available, I must swap the the entries...
- var board = this._getBoard();
- var entry = board.lookupEntryByOrder(order);
- if (!entry.isAvailable()) {
- board.freeEntry(entry);
- }
-
- // Add the topic to the board ...
- board.addTopic(order, topic);
-
- // Repositionate all the parent topics ...
- var currentTopic = this._topic;
- if (currentTopic.getOutgoingConnectedTopic()) {
- var parentTopic = currentTopic.getOutgoingConnectedTopic();
- mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeRepositionateEvent, [parentTopic]);
- }
- },
-
- repositionate : function() {
- var board = this._getBoard();
- board.repositionate();
- },
-
- removeTopicFromBoard : function(topic) {
- var board = this._getBoard();
- board.removeTopic(topic);
-
- // Repositionate all the parent topics ...
- var parentTopic = this._topic;
- if (parentTopic.getOutgoingConnectedTopic()) {
- var connectedTopic = parentTopic.getOutgoingConnectedTopic();
- mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeRepositionateEvent, [connectedTopic]);
- }
- }
-});
\ No newline at end of file
diff --git a/mindplot/src/main/javascript/layout/boards/original/VariableDistanceBoard.js b/mindplot/src/main/javascript/layout/boards/original/VariableDistanceBoard.js
deleted file mode 100644
index 418e1de2..00000000
--- a/mindplot/src/main/javascript/layout/boards/original/VariableDistanceBoard.js
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * 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.layout.boards.original.VariableDistanceBoard = new Class({
- Extends: mindplot.layout.boards.original.Board,
- initialize: function(defaultHeight, referencePoint) {
- this.parent(defaultHeight, referencePoint);
- var zeroEntryCoordinate = referencePoint.y;
- var entry = this.createBoardEntry(zeroEntryCoordinate - (defaultHeight / 2), zeroEntryCoordinate + (defaultHeight / 2), 0);
- this._entries.set(0, entry);
- },
-
- lookupEntryByOrder:function(order) {
- var entries = this._entries;
- var index = this._orderToIndex(order);
-
- var result = entries.get(index);
- if (!$defined(result)) {
- // I've not found a entry. I have to create a new one.
- var i = 1;
- var zeroEntry = entries.get(0);
- var distance = zeroEntry.getWidth() / 2;
- var indexSign = Math.sign(index);
- var absIndex = Math.abs(index);
- while (i < absIndex) {
- // Move to the next entry ...
- var entry = entries.get(i, indexSign);
- if (entry != null) {
- distance += entry.getWidth();
- } else {
- distance += this._defaultWidth;
- }
- i++;
- }
-
- // Calculate limits ...
- var upperLimit = -1;
- var lowerLimit = -1;
- var offset = zeroEntry.workoutEntryYCenter();
- if (index >= 0) {
- lowerLimit = offset + distance;
- upperLimit = lowerLimit + this._defaultWidth;
- } else {
- upperLimit = offset - distance;
- lowerLimit = upperLimit - this._defaultWidth;
- }
-
- result = this.createBoardEntry(lowerLimit, upperLimit, order);
- }
- return result;
- },
-
- createBoardEntry:function(lowerLimit, upperLimit, order) {
- return new mindplot.layout.boards.original.BoardEntry(lowerLimit, upperLimit, order);
- },
-
- updateReferencePoint:function(position) {
- var entries = this._entries;
- var referencePoint = this._referencePoint;
-
- // Update zero entry current position.
- this._referencePoint = position.clone();
- var yOffset = position.y - referencePoint.y;
-
- var i = -entries.lowerLength();
- for (; i <= entries.length(1); i++) {
- var entry = entries.get(i);
- if (entry != null) {
- var upperLimit = entry.getUpperLimit() + yOffset;
- var lowerLimit = entry.getLowerLimit() + yOffset;
- entry.setUpperLimit(upperLimit);
- entry.setLowerLimit(lowerLimit);
-
- // Update topic position ...
- if (!entry.isAvailable()) {
- var topic = entry.getTopic();
- var topicPosition = topic.getPosition();
- topicPosition.y = topicPosition.y + yOffset;
-
- // MainTopicToCentral must be positioned based on the referencePoint.
- var xOffset = position.x - referencePoint.x;
- topicPosition.x = topicPosition.x + xOffset;
-
- topic.setPosition(topicPosition);
- }
- }
- }
- },
-
- lookupEntryByPosition:function(pos) {
- $assert(pos, 'position can not be null');
- var entries = this._entries;
- var zeroEntry = entries.get(0);
- if (zeroEntry.isCoordinateIn(pos.y)) {
- return zeroEntry;
- }
-
- // Is Upper or lower ?
- var sign = -1;
- if (pos.y >= zeroEntry.getUpperLimit()) {
- sign = 1;
- }
-
- var i = 1;
- var tempEntry = this.createBoardEntry();
- var currentEntry = zeroEntry;
- while (true) {
- // Move to the next entry ...
- var index = i * sign;
- var entry = entries.get(index);
- if ($defined(entry)) {
- currentEntry = entry;
- } else {
- // Calculate boundaries...
- var lowerLimit, upperLimit;
- if (sign > 0) {
- lowerLimit = currentEntry.getUpperLimit();
- upperLimit = lowerLimit + this._defaultWidth;
- }
- else {
- upperLimit = currentEntry.getLowerLimit();
- lowerLimit = upperLimit - this._defaultWidth;
- }
-
- // Update current entry.
- currentEntry = tempEntry;
- currentEntry.setLowerLimit(lowerLimit);
- currentEntry.setUpperLimit(upperLimit);
-
- var order = this._indexToOrder(index);
- currentEntry.setOrder(order);
- }
-
- // Have I found the item?
- if (currentEntry.isCoordinateIn(pos.y)) {
- break;
- }
- i++;
- }
- return currentEntry;
- },
-
- update:function(entry) {
- $assert(entry, 'Entry can not be null');
- var order = entry.getOrder();
- var index = this._orderToIndex(order);
-
- this._entries.set(index, entry);
-
- },
-
- freeEntry:function(entry) {
- var order = entry.getOrder();
- var entries = this._entries;
-
- var index = this._orderToIndex(order);
- var indexSign = Math.sign(index);
-
- var currentTopic = entry.getTopic();
- var i = Math.abs(index) + 1;
- while (currentTopic) {
- var e = entries.get(i, indexSign);
- if ($defined(currentTopic) && !$defined(e)) {
- var entryOrder = this._indexToOrder(i * indexSign);
- e = this.lookupEntryByOrder(entryOrder);
- }
-
- // Move the topic to the next entry ...
- var topic = null;
- if ($defined(e)) {
- topic = e.getTopic();
- if ($defined(currentTopic)) {
- e.setTopic(currentTopic);
- }
- this.update(e);
- }
- currentTopic = topic;
- i++;
- }
-
- // Clear the entry topic ...
- entry.setTopic(null);
- },
-
- _orderToIndex:function(order) {
- var index = Math.round(order / 2);
- return ((order % 2) == 0) ? index : -index;
- },
-
- _indexToOrder:function(index) {
- var order = Math.abs(index) * 2;
- return (index >= 0) ? order : order - 1;
- },
-
- inspect:function() {
- return this._entries.inspect();
- }
-
-});
\ No newline at end of file
diff --git a/mindplot/src/main/javascript/layout/text.xml b/mindplot/src/main/javascript/layout/text.xml
deleted file mode 100644
index 0f3cdb6e..00000000
--- a/mindplot/src/main/javascript/layout/text.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
\ No newline at end of file