Add IMindmap and INode.

This commit is contained in:
Paulo Veiga 2011-09-08 10:03:42 -03:00
parent 21f848e3df
commit 0c216778e5
21 changed files with 248 additions and 149 deletions

View File

@ -52,7 +52,9 @@
<concat destfile="${basedir}/target/tmp/mindplot.js" append="false"> <concat destfile="${basedir}/target/tmp/mindplot.js" append="false">
<filelist dir="${basedir}/src/main/javascript/" files="header.js"/> <filelist dir="${basedir}/src/main/javascript/" files="header.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="EventBus.js"/> <filelist dir="${basedir}/src/main/javascript/" files="EventBus.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="model/IMindmap.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="model/Mindmap.js"/> <filelist dir="${basedir}/src/main/javascript/" files="model/Mindmap.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="model/INodeModel.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="model/NodeModel.js"/> <filelist dir="${basedir}/src/main/javascript/" files="model/NodeModel.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="model/RelationshipModel.js"/> <filelist dir="${basedir}/src/main/javascript/" files="model/RelationshipModel.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="ActionDispatcher.js"/> <filelist dir="${basedir}/src/main/javascript/" files="ActionDispatcher.js"/>
@ -86,10 +88,13 @@
<filelist dir="${basedir}/src/main/javascript/" files="FixedDistanceBoard.js"/> <filelist dir="${basedir}/src/main/javascript/" files="FixedDistanceBoard.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="BoardEntry.js"/> <filelist dir="${basedir}/src/main/javascript/" files="BoardEntry.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="ModelCodeName.js"/> <filelist dir="${basedir}/src/main/javascript/" files="ModelCodeName.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="XMLMindmapSerializer_Pela.js"/> <filelist dir="${basedir}/src/main/javascript/"
<filelist dir="${basedir}/src/main/javascript/" files="XMLMindmapSerializer_Beta.js"/> files="XMLMindmapSerializer_Pela.js"/>
<filelist dir="${basedir}/src/main/javascript/"
files="XMLMindmapSerializer_Beta.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="Beta2PelaMigrator.js"/> <filelist dir="${basedir}/src/main/javascript/" files="Beta2PelaMigrator.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="XMLMindmapSerializerFactory.js"/> <filelist dir="${basedir}/src/main/javascript/"
files="XMLMindmapSerializerFactory.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="PersistanceManager.js"/> <filelist dir="${basedir}/src/main/javascript/" files="PersistanceManager.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="EditorProperties.js"/> <filelist dir="${basedir}/src/main/javascript/" files="EditorProperties.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="IconGroup.js"/> <filelist dir="${basedir}/src/main/javascript/" files="IconGroup.js"/>
@ -108,10 +113,13 @@
<filelist dir="${basedir}/src/main/javascript/" files="ControlPoint.js"/> <filelist dir="${basedir}/src/main/javascript/" files="ControlPoint.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="EditorOptions.js"/> <filelist dir="${basedir}/src/main/javascript/" files="EditorOptions.js"/>
<filelist dir="${basedir}/src/main/javascript/commands/" files="GenericFunctionCommand.js"/> <filelist dir="${basedir}/src/main/javascript/commands/"
files="GenericFunctionCommand.js"/>
<filelist dir="${basedir}/src/main/javascript/commands/" files="DeleteCommand.js"/> <filelist dir="${basedir}/src/main/javascript/commands/" files="DeleteCommand.js"/>
<filelist dir="${basedir}/src/main/javascript/commands/" files="DragTopicCommand.js"/> <filelist dir="${basedir}/src/main/javascript/commands/"
<filelist dir="${basedir}/src/main/javascript/commands/" files="AddTopicCommand.js"/> files="DragTopicCommand.js"/>
<filelist dir="${basedir}/src/main/javascript/commands/"
files="AddTopicCommand.js"/>
<filelist dir="${basedir}/src/main/javascript/" <filelist dir="${basedir}/src/main/javascript/"
files="commands/AddLinkToTopicCommand.js"/> files="commands/AddLinkToTopicCommand.js"/>
<filelist dir="${basedir}/src/main/javascript/" <filelist dir="${basedir}/src/main/javascript/"

View File

@ -41,7 +41,7 @@ mindplot.CentralTopic = new Class({
}, },
getTopicType : function() { getTopicType : function() {
return mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE; return mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE;
}, },
setCursor : function(type) { setCursor : function(type) {
@ -57,7 +57,7 @@ mindplot.CentralTopic = new Class({
// Create a new node ... // Create a new node ...
var model = this.getModel(); var model = this.getModel();
var mindmap = model.getMindmap(); var mindmap = model.getMindmap();
var childModel = mindmap.createNode(mindplot.model.NodeModel.MAIN_TOPIC_TYPE); var childModel = mindmap.createNode(mindplot.model.INodeModel.MAIN_TOPIC_TYPE);
if (prepositionate) { if (prepositionate) {
if (!$defined(this.___siblingDirection)) { if (!$defined(this.___siblingDirection)) {
@ -80,7 +80,7 @@ mindplot.CentralTopic = new Class({
}, },
_defaultShapeType : function() { _defaultShapeType : function() {
return mindplot.model.NodeModel.SHAPE_TYPE_ROUNDED_RECT; return mindplot.model.INodeModel.SHAPE_TYPE_ROUNDED_RECT;
}, },

View File

@ -27,7 +27,7 @@ mindplot.ConnectionLine = new Class({
var strokeColor = mindplot.ConnectionLine.getStrokeColor(); var strokeColor = mindplot.ConnectionLine.getStrokeColor();
var line; var line;
if (targetNode.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (targetNode.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
line = this._createLine(lineType, mindplot.ConnectionLine.CURVED); line = this._createLine(lineType, mindplot.ConnectionLine.CURVED);
if (line.getType() == "CurvedLine") { if (line.getType() == "CurvedLine") {
var ctrlPoints = this._getCtrlPoints(sourceNode, targetNode); var ctrlPoints = this._getCtrlPoints(sourceNode, targetNode);
@ -124,7 +124,7 @@ mindplot.ConnectionLine = new Class({
var offset = mindplot.Topic.CONNECTOR_WIDTH / 2; var offset = mindplot.Topic.CONNECTOR_WIDTH / 2;
var targetTopicSize = targetTopic.getSize(); var targetTopicSize = targetTopic.getSize();
var y; var y;
if (targetTopic.getShapeType() == mindplot.model.NodeModel.SHAPE_TYPE_LINE) { if (targetTopic.getShapeType() == mindplot.model.INodeModel.SHAPE_TYPE_LINE) {
y = targetTopicSize.height; y = targetTopicSize.height;
} else { } else {
y = targetTopicSize.height / 2; y = targetTopicSize.height / 2;

View File

@ -131,7 +131,7 @@ mindplot.DesignerKeyboard = new Class({
'right' : function() { 'right' : function() {
var node = model.selectedTopic(); var node = model.selectedTopic();
if (node) { if (node) {
if (node.getTopicType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (node.getTopicType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
this._goToSideChild(designer, node, 'RIGHT'); this._goToSideChild(designer, node, 'RIGHT');
} }
else { else {
@ -151,7 +151,7 @@ mindplot.DesignerKeyboard = new Class({
'left' : function() { 'left' : function() {
var node = model.selectedTopic(); var node = model.selectedTopic();
if (node) { if (node) {
if (node.getTopicType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (node.getTopicType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
this._goToSideChild(designer, node, 'LEFT'); this._goToSideChild(designer, node, 'LEFT');
} }
else { else {
@ -171,7 +171,7 @@ mindplot.DesignerKeyboard = new Class({
'up' : function() { 'up' : function() {
var node = model.selectedTopic(); var node = model.selectedTopic();
if (node) { if (node) {
if (node.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (node.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
this._goToBrother(designer, node, 'UP'); this._goToBrother(designer, node, 'UP');
} }
} else { } else {
@ -183,7 +183,7 @@ mindplot.DesignerKeyboard = new Class({
'down' : function() { 'down' : function() {
var node = model.selectedTopic(); var node = model.selectedTopic();
if (node) { if (node) {
if (node.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (node.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
this._goToBrother(designer, node, 'DOWN'); this._goToBrother(designer, node, 'DOWN');
} }
} else { } else {

View File

@ -192,7 +192,7 @@ mindplot.DragPivot = new Class({
$assert(targetTopic, 'parent can not be null'); $assert(targetTopic, 'parent can not be null');
this._targetTopic = targetTopic; this._targetTopic = targetTopic;
if (targetTopic.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (targetTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
this._line = this._straightLine; this._line = this._straightLine;
} else { } else {
this._line = this._curvedLine; this._line = this._curvedLine;

View File

@ -135,7 +135,7 @@ mindplot.DragTopic = new Class({
if (isDragConnected) { if (isDragConnected) {
var targetTopic = this.getConnectedToTopic(); var targetTopic = this.getConnectedToTopic();
if (targetTopic.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (targetTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
// Update topic position ... // Update topic position ...
var dragPivotPosition = dragPivot.getPosition(); var dragPivotPosition = dragPivot.getPosition();

View File

@ -48,12 +48,12 @@ mindplot.DragTopicPositioner = new Class({
var currentConnection = dragTopic.getConnectedToTopic(); var currentConnection = dragTopic.getConnectedToTopic();
if ($defined(currentConnection)) { if ($defined(currentConnection)) {
// MainTopic->MainTopicConnection. // MainTopic->MainTopicConnection.
if (currentConnection.getType() == mindplot.model.NodeModel.MAIN_TOPIC_TYPE) { if (currentConnection.getType() == mindplot.model.INodeModel.MAIN_TOPIC_TYPE) {
if (mainTopicToMainTopicConnection != currentConnection) { if (mainTopicToMainTopicConnection != currentConnection) {
dragTopic.disconnect(this._workspace); dragTopic.disconnect(this._workspace);
} }
} }
else if (currentConnection.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { else if (currentConnection.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
// Distance if greater that the allowed. // Distance if greater that the allowed.
var dragXPosition = dragTopic.getPosition().x; var dragXPosition = dragTopic.getPosition().x;
var currentXPosition = currentConnection.getPosition().x; var currentXPosition = currentConnection.getPosition().x;
@ -90,7 +90,7 @@ mindplot.DragTopicPositioner = new Class({
for (var i = 0; i < topics.length; i++) { for (var i = 0; i < topics.length; i++) {
var targetTopic = topics[i]; var targetTopic = topics[i];
var position = dragTopic.getPosition(); var position = dragTopic.getPosition();
if (targetTopic.getType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE && targetTopic != draggedNode) { if (targetTopic.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE && targetTopic != draggedNode) {
var canBeConnected = dragTopic.canBeConnectedTo(targetTopic); var canBeConnected = dragTopic.canBeConnectedTo(targetTopic);
if (canBeConnected) { if (canBeConnected) {
var targetPosition = targetTopic.getPosition(); var targetPosition = targetTopic.getPosition();

View File

@ -31,10 +31,10 @@ mindplot.MainTopic = new Class({
// Create a new node ... // Create a new node ...
var model = this.getModel(); var model = this.getModel();
var mindmap = model.getMindmap(); var mindmap = model.getMindmap();
siblingModel = mindmap.createNode(mindplot.model.NodeModel.MAIN_TOPIC_TYPE); siblingModel = mindmap.createNode(mindplot.model.INodeModel.MAIN_TOPIC_TYPE);
// Positionate following taking into account the sibling positon. // Positionate following taking into account the sibling positon.
if (positionate && parentTopic.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (positionate && parentTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
var pos = this.getPosition(); var pos = this.getPosition();
siblingModel.setPosition(pos.x, pos.y); siblingModel.setPosition(pos.x, pos.y);
} }
@ -50,7 +50,7 @@ mindplot.MainTopic = new Class({
// Create a new node ... // Create a new node ...
var model = this.getModel(); var model = this.getModel();
var mindmap = model.getMindmap(); var mindmap = model.getMindmap();
var childModel = mindmap.createNode(mindplot.model.NodeModel.MAIN_TOPIC_TYPE); var childModel = mindmap.createNode(mindplot.model.INodeModel.MAIN_TOPIC_TYPE);
// Get the hights model order position ... // Get the hights model order position ...
var children = this._getChildren(); var children = this._getChildren();
@ -99,14 +99,14 @@ mindplot.MainTopic = new Class({
_defaultShapeType : function() { _defaultShapeType : function() {
return mindplot.model.NodeModel.SHAPE_TYPE_LINE; return mindplot.model.INodeModel.SHAPE_TYPE_LINE;
}, },
updateTopicShape : function(targetTopic, workspace) { updateTopicShape : function(targetTopic, workspace) {
// Change figure based on the connected topic ... // Change figure based on the connected topic ...
var model = this.getModel(); var model = this.getModel();
var shapeType = model.getShapeType(); var shapeType = model.getShapeType();
if (targetTopic.getType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (targetTopic.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
if (!$defined(shapeType)) { if (!$defined(shapeType)) {
// Get the real shape type ... // Get the real shape type ...
shapeType = this.getShapeType(); shapeType = this.getShapeType();
@ -127,7 +127,7 @@ mindplot.MainTopic = new Class({
if (!$defined(shapeType)) { if (!$defined(shapeType)) {
// Change figure ... // Change figure ...
shapeType = this.getShapeType(); shapeType = this.getShapeType();
this._setShapeType(mindplot.model.NodeModel.SHAPE_TYPE_ROUNDED_RECT, false); this._setShapeType(mindplot.model.INodeModel.SHAPE_TYPE_ROUNDED_RECT, false);
} }
var innerShape = this.getInnerShape(); var innerShape = this.getInnerShape();
innerShape.setVisibility(true); innerShape.setVisibility(true);
@ -171,7 +171,7 @@ mindplot.MainTopic = new Class({
var isAtRight = mindplot.util.Shape.isAtRight(sourcePosition, pos); var isAtRight = mindplot.util.Shape.isAtRight(sourcePosition, pos);
var result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight); var result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight);
if (this.getShapeType() == mindplot.model.NodeModel.SHAPE_TYPE_LINE) { if (this.getShapeType() == mindplot.model.INodeModel.SHAPE_TYPE_LINE) {
result.y = result.y + (this.getSize().height / 2); result.y = result.y + (this.getSize().height / 2);
} }
@ -196,7 +196,7 @@ mindplot.MainTopic = new Class({
var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, pos); var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, pos);
var result; var result;
if (this.getShapeType() == mindplot.model.NodeModel.SHAPE_TYPE_LINE) { if (this.getShapeType() == mindplot.model.INodeModel.SHAPE_TYPE_LINE) {
// if (!this.isConnectedToCentralTopic()) // if (!this.isConnectedToCentralTopic())
// { // {
result = new core.Point(); result = new core.Point();
@ -238,7 +238,7 @@ mindplot.MainTopic = new Class({
_getInnerPadding : function() { _getInnerPadding : function() {
var result; var result;
var parent = this.getModel().getParent(); var parent = this.getModel().getParent();
if (parent && mindplot.model.NodeModel.MAIN_TOPIC_TYPE == parent.getType()) { if (parent && mindplot.model.INodeModel.MAIN_TOPIC_TYPE == parent.getType()) {
result = 3; result = 3;
} }
else { else {
@ -251,14 +251,14 @@ mindplot.MainTopic = new Class({
var model = this.getModel(); var model = this.getModel();
var parent = model.getParent(); var parent = model.getParent();
return parent && parent.getType() === mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE; return parent && parent.getType() === mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE;
}, },
_defaultText : function() { _defaultText : function() {
var targetTopic = this.getOutgoingConnectedTopic(); var targetTopic = this.getOutgoingConnectedTopic();
var result = ""; var result = "";
if ($defined(targetTopic)) { if ($defined(targetTopic)) {
if (targetTopic.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (targetTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
result = "Main Topic"; result = "Main Topic";
} else { } else {
result = "Sub Topic"; result = "Sub Topic";
@ -273,7 +273,7 @@ mindplot.MainTopic = new Class({
var targetTopic = this.getOutgoingConnectedTopic(); var targetTopic = this.getOutgoingConnectedTopic();
var result; var result;
if ($defined(targetTopic)) { if ($defined(targetTopic)) {
if (targetTopic.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (targetTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
result = { result = {
font:"Arial", font:"Arial",
size: 8, size: 8,

View File

@ -94,7 +94,7 @@ mindplot.MindmapDesigner = new Class({
// Create a new topic model ... // Create a new topic model ...
var mindmap = this.getMindmap(); var mindmap = this.getMindmap();
var model = mindmap.createNode(mindplot.model.NodeModel.MAIN_TOPIC_TYPE); var model = mindmap.createNode(mindplot.model.INodeModel.MAIN_TOPIC_TYPE);
model.setPosition(pos.x, pos.y); model.setPosition(pos.x, pos.y);
// Get central topic ... // Get central topic ...
@ -281,7 +281,7 @@ mindplot.MindmapDesigner = new Class({
} }
var topic = nodes[0]; var topic = nodes[0];
if (topic.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (topic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
// Central topic doesn't have siblings ... // Central topic doesn't have siblings ...
this.createChildForSelectedNode(); this.createChildForSelectedNode();
@ -514,7 +514,7 @@ mindplot.MindmapDesigner = new Class({
}, },
_removeNode : function(node) { _removeNode : function(node) {
if (node.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (node.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
var parent = node._parent; var parent = node._parent;
node.disconnect(this._workspace); node.disconnect(this._workspace);
@ -539,7 +539,7 @@ mindplot.MindmapDesigner = new Class({
deleteCurrentNode : function() { deleteCurrentNode : function() {
var validateFunc = function(object) { var validateFunc = function(object) {
return object.getType() == mindplot.RelationshipLine.type || object.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE return object.getType() == mindplot.RelationshipLine.type || object.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE
}; };
var validateError = 'Central topic can not be deleted.'; var validateError = 'Central topic can not be deleted.';
@ -580,7 +580,7 @@ mindplot.MindmapDesigner = new Class({
changeBackgroundColor : function(color) { changeBackgroundColor : function(color) {
var validateFunc = function(topic) { var validateFunc = function(topic) {
return topic.getShapeType() != mindplot.model.NodeModel.SHAPE_TYPE_LINE return topic.getShapeType() != mindplot.model.INodeModel.SHAPE_TYPE_LINE
}; };
var validateError = 'Color can not be set to line topics.'; var validateError = 'Color can not be set to line topics.';
@ -592,7 +592,7 @@ mindplot.MindmapDesigner = new Class({
changeBorderColor : function(color) { changeBorderColor : function(color) {
var validateFunc = function(topic) { var validateFunc = function(topic) {
return topic.getShapeType() != mindplot.model.NodeModel.SHAPE_TYPE_LINE return topic.getShapeType() != mindplot.model.INodeModel.SHAPE_TYPE_LINE
}; };
var validateError = 'Color can not be set to line topics.'; var validateError = 'Color can not be set to line topics.';
var topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError); var topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);
@ -610,7 +610,7 @@ mindplot.MindmapDesigner = new Class({
changeTopicShape : function(shape) { changeTopicShape : function(shape) {
var validateFunc = function(topic) { var validateFunc = function(topic) {
return !(topic.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE && shape == mindplot.model.NodeModel.SHAPE_TYPE_LINE) return !(topic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE && shape == mindplot.model.INodeModel.SHAPE_TYPE_LINE)
}; };
var validateError = 'Central Topic shape can not be changed to line figure.'; var validateError = 'Central Topic shape can not be changed to line figure.';
var topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError); var topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);

View File

@ -135,10 +135,10 @@ mindplot.NodeGraph.create = function(nodeModel, options) {
$assert(type, 'Node model type can not be null'); $assert(type, 'Node model type can not be null');
var result; var result;
if (type == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (type == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
result = new mindplot.CentralTopic(nodeModel, options); result = new mindplot.CentralTopic(nodeModel, options);
} else } else
if (type == mindplot.model.NodeModel.MAIN_TOPIC_TYPE) { if (type == mindplot.model.INodeModel.MAIN_TOPIC_TYPE) {
result = new mindplot.MainTopic(nodeModel, options); result = new mindplot.MainTopic(nodeModel, options);
} else { } else {
assert(false, "unsupported node type:" + type); assert(false, "unsupported node type:" + type);

View File

@ -32,7 +32,7 @@ mindplot.Topic = new Class({
// Position a topic .... // Position a topic ....
var pos = model.getPosition(); var pos = model.getPosition();
if (pos != null && model.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (pos != null && model.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
this.setPosition(pos); this.setPosition(pos);
} }
@ -151,7 +151,7 @@ mindplot.Topic = new Class({
this._setBorderColor(brColor, false); this._setBorderColor(brColor, false);
// Define the pointer ... // Define the pointer ...
if (this.getType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (this.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
this._innerShape.setCursor('move'); this._innerShape.setCursor('move');
} else { } else {
this._innerShape.setCursor('default'); this._innerShape.setCursor('default');
@ -167,16 +167,16 @@ mindplot.Topic = new Class({
type = this.getShapeType(); type = this.getShapeType();
} }
if (type == mindplot.model.NodeModel.SHAPE_TYPE_RECT) { if (type == mindplot.model.INodeModel.SHAPE_TYPE_RECT) {
result = new web2d.Rect(0, attributes); result = new web2d.Rect(0, attributes);
} }
else if (type == mindplot.model.NodeModel.SHAPE_TYPE_ELIPSE) { else if (type == mindplot.model.INodeModel.SHAPE_TYPE_ELIPSE) {
result = new web2d.Rect(0.9, attributes); result = new web2d.Rect(0.9, attributes);
} }
else if (type == mindplot.model.NodeModel.SHAPE_TYPE_ROUNDED_RECT) { else if (type == mindplot.model.INodeModel.SHAPE_TYPE_ROUNDED_RECT) {
result = new web2d.Rect(0.3, attributes); result = new web2d.Rect(0.3, attributes);
} }
else if (type == mindplot.model.NodeModel.SHAPE_TYPE_LINE) { else if (type == mindplot.model.INodeModel.SHAPE_TYPE_LINE) {
result = new web2d.Line({strokeColor:"#495879",strokeWidth:1, strokeOpacity:1}); result = new web2d.Line({strokeColor:"#495879",strokeWidth:1, strokeOpacity:1});
result.setSize = function(width, height) { result.setSize = function(width, height) {
this.size = {width:width, height:height}; this.size = {width:width, height:height};
@ -226,7 +226,7 @@ mindplot.Topic = new Class({
getOuterShape : function() { getOuterShape : function() {
if (!$defined(this._outerShape)) { if (!$defined(this._outerShape)) {
var rect = this.buildShape(mindplot.Topic.OUTER_SHAPE_ATTRIBUTES, mindplot.model.NodeModel.SHAPE_TYPE_ROUNDED_RECT); var rect = this.buildShape(mindplot.Topic.OUTER_SHAPE_ATTRIBUTES, mindplot.model.INodeModel.SHAPE_TYPE_ROUNDED_RECT);
rect.setPosition(-2, -3); rect.setPosition(-2, -3);
rect.setOpacity(0); rect.setOpacity(0);
this._outerShape = rect; this._outerShape = rect;
@ -408,7 +408,7 @@ mindplot.Topic = new Class({
if (!disableEventsListeners) { if (!disableEventsListeners) {
// Propagate mouse events ... // Propagate mouse events ...
if (this.getType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (this.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
result.setCursor('move'); result.setCursor('move');
} else { } else {
result.setCursor('default'); result.setCursor('default');
@ -621,7 +621,7 @@ mindplot.Topic = new Class({
this.getOrBuildIconGroup(); this.getOrBuildIconGroup();
} }
if (this.getType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (this.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
shrinkConnector.addToWorkspace(group); shrinkConnector.addToWorkspace(group);
} }
@ -828,7 +828,7 @@ mindplot.Topic = new Class({
setBranchVisibility : function(value) { setBranchVisibility : function(value) {
var current = this; var current = this;
var parent = this; var parent = this;
while (parent != null && parent.getType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { while (parent != null && parent.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
current = parent; current = parent;
parent = current.getParent(); parent = current.getParent();
} }

View File

@ -44,11 +44,11 @@ mindplot.XMLMindmapSerializer_Beta = new Class({
var parentTopic = document.createElement("topic"); var parentTopic = document.createElement("topic");
// Set topic attributes... // Set topic attributes...
if (topic.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (topic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
parentTopic.setAttribute("central", true); parentTopic.setAttribute("central", true);
} else { } else {
var parent = topic.getParent(); var parent = topic.getParent();
if (parent == null || parent.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (parent == null || parent.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
var pos = topic.getPosition(); var pos = topic.getPosition();
parentTopic.setAttribute("position", pos.x + ',' + pos.y); parentTopic.setAttribute("position", pos.x + ',' + pos.y);
} else { } else {
@ -179,7 +179,7 @@ mindplot.XMLMindmapSerializer_Beta = new Class({
}, },
_deserializeNode : function(domElem, mindmap) { _deserializeNode : function(domElem, mindmap) {
var type = (domElem.getAttribute('central') != null) ? mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE : mindplot.model.NodeModel.MAIN_TOPIC_TYPE; var type = (domElem.getAttribute('central') != null) ? mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE : mindplot.model.INodeModel.MAIN_TOPIC_TYPE;
var topic = mindmap.createNode(type); var topic = mindmap.createNode(type);
// Load attributes... // Load attributes...

View File

@ -62,7 +62,7 @@ mindplot.XMLMindmapSerializer_Pela = new Class({
var parentTopic = document.createElement("topic"); var parentTopic = document.createElement("topic");
// Set topic attributes... // Set topic attributes...
if (topic.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (topic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
parentTopic.setAttribute("central", true); parentTopic.setAttribute("central", true);
} else { } else {
var parent = topic.getParent(); var parent = topic.getParent();
@ -234,7 +234,7 @@ mindplot.XMLMindmapSerializer_Pela = new Class({
}, },
_deserializeNode : function(domElem, mindmap) { _deserializeNode : function(domElem, mindmap) {
var type = (domElem.getAttribute('central') != null) ? mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE : mindplot.model.NodeModel.MAIN_TOPIC_TYPE; var type = (domElem.getAttribute('central') != null) ? mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE : mindplot.model.INodeModel.MAIN_TOPIC_TYPE;
// Load attributes... // Load attributes...
var id = domElem.getAttribute('id'); var id = domElem.getAttribute('id');
if ($defined(id)) { if ($defined(id)) {

View File

@ -38,7 +38,7 @@ mindplot.collaboration.framework.AbstractCollaborativeFramework = new Class({
_buildInitialCollaborativeModel: function() { _buildInitialCollaborativeModel: function() {
var mindmap = this._collaborativeModelFactory.buildMindMap(); var mindmap = this._collaborativeModelFactory.buildMindMap();
var centralTopic = mindmap.createNode(mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE); var centralTopic = mindmap.createNode(mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE);
mindmap.addBranch(centralTopic, true); mindmap.addBranch(centralTopic, true);
this.addMindmap(mindmap); this.addMindmap(mindmap);
return mindmap; return mindmap;

View File

@ -29,6 +29,7 @@ mindplot.commands.DragTopicCommand = new Class({
this._order = order; this._order = order;
this._id = mindplot.Command._nextUUID(); this._id = mindplot.Command._nextUUID();
}, },
execute: function(commandContext) { execute: function(commandContext) {
var topic = commandContext.findTopics([this._objectsIds])[0]; var topic = commandContext.findTopics([this._objectsIds])[0];
@ -37,14 +38,10 @@ mindplot.commands.DragTopicCommand = new Class({
var origParentTopic = topic.getOutgoingConnectedTopic(); var origParentTopic = topic.getOutgoingConnectedTopic();
var origOrder = null; var origOrder = null;
var origPosition = null; var origPosition = null;
// if (topic.getType() == mindplot.model.NodeModel.MAIN_TOPIC_TYPE && origParentTopic != null && origParentTopic.getType() == mindplot.model.NodeModel.MAIN_TOPIC_TYPE)
// {
// In this case, topics are positioned using order ... // In this case, topics are positioned using order ...
origOrder = topic.getOrder(); origOrder = topic.getOrder();
// } else origPosition = topic.getPosition();
// {
origPosition = topic.getPosition().clone();
// }
// Disconnect topic .. // Disconnect topic ..
if ($defined(origParentTopic)) { if ($defined(origParentTopic)) {

View File

@ -74,7 +74,7 @@ mindplot.layout.BaseLayoutManager = new Class({
}, },
_isCentralTopic:function(node){ _isCentralTopic:function(node){
var type = node.getModel().getType(); var type = node.getModel().getType();
return type == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE; return type == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE;
}, },
getClassName:function(){ getClassName:function(){
return mindplot.layout.BaseLayoutManager.NAME; return mindplot.layout.BaseLayoutManager.NAME;

View File

@ -58,7 +58,7 @@ mindplot.layout.FreeMindLayoutManager = mindplot.layout.BaseLayoutManager.extend
}); });
// Add drag behaviour ... // Add drag behaviour ...
if (topic.getType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) if (topic.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE)
{ {
topic.addEvent("mousedown",this._reconnectMouseDownListener.bindWithEvent(this,[topic])); topic.addEvent("mousedown",this._reconnectMouseDownListener.bindWithEvent(this,[topic]));
} }
@ -261,7 +261,7 @@ mindplot.layout.FreeMindLayoutManager = mindplot.layout.BaseLayoutManager.extend
} }
}, },
addHelpers:function(node){ addHelpers:function(node){
if (node.getType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) if (node.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE)
this._addMoveHelper(node); this._addMoveHelper(node);
}, },
_addMoveHelper:function(node){ _addMoveHelper:function(node){

View File

@ -61,7 +61,7 @@ mindplot.layout.OriginalLayoutManager = new Class({
} }
} }
nodesByOrder = null; nodesByOrder = null;
return node.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE ? result : children; return node.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE ? result : children;
}, },
_nodeResizeEvent:function(node) { _nodeResizeEvent:function(node) {
@ -123,7 +123,7 @@ mindplot.layout.OriginalLayoutManager = new Class({
registerListenersOnNode : function(topic) { registerListenersOnNode : function(topic) {
// Register node listeners ... // Register node listeners ...
if (topic.getType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { if (topic.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
// Central Topic doesn't support to be dragged // Central Topic doesn't support to be dragged
var dragger = this._dragger; var dragger = this._dragger;

View File

@ -0,0 +1,164 @@
/*
* 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.model.IMindmap = new Class({
initialize : function() {
throw "Unsupported operation";
},
getCentralTopic : function() {
return this.getBranches()[0];
},
getDescription : function() {
throw "Unsupported operation";
},
setDescription : function(value) {
throw "Unsupported operation";
},
getId : function() {
throw "Unsupported operation";
},
setId : function(id) {
throw "Unsupported operation";
},
getVersion : function() {
throw "Unsupported operation";
},
setVersion : function(version) {
throw "Unsupported operation";
},
addBranch : function(nodeModel) {
throw "Unsupported operation";
},
getBranches : function() {
throw "Unsupported operation";
},
removeBranch : function(node) {
throw "Unsupported operation";
},
getRelationships : function() {
throw "Unsupported operation";
},
connect : function(parent, child) {
// Child already has a parent ?
$assert(!child.getParent(), 'Child model seems to be already connected');
// Connect node...
parent._appendChild(child);
// Remove from the branch ...
this.removeBranch(child);
},
disconnect : function(child) {
var parent = child.getParent();
$assert(child, 'Child can not be null.');
$assert(parent, 'Child model seems to be already connected');
parent._removeChild(child);
this.addBranch(child);
},
hasAlreadyAdded : function(node) {
throw "Unsupported operation";
},
createNode : function(type, id) {
throw "Unsupported operation";
},
createRelationship : function(fromNode, toNode) {
throw "Unsupported operation";
},
addRelationship : function(relationship) {
throw "Unsupported operation";
},
removeRelationship : function(relationship) {
throw "Unsupported operation";
},
inspect : function() {
var result = '';
result = '{ ';
var branches = this.getBranches();
for (var i = 0; i < branches.length; i++) {
var node = branches[i];
if (i != 0) {
result = result + ', ';
}
result = result + this._toString(node);
}
result = result + ' } ';
return result;
},
_toString : function(node) {
var result = node.inspect();
var children = node.getChildren();
for (var i = 0; i < children.length; i++) {
var child = children[i];
if (i == 0) {
result = result + '-> {';
} else {
result = result + ', ';
}
result = result + this._toString(child);
if (i == children.length - 1) {
result = result + '}';
}
}
return result;
},
copyTo : function(mindmap) {
var version = this.getVersion();
mindmap.setVersion(version);
var desc = this.getDescription();
mindmap.setDescription(desc);
var sbranchs = this.getBranches();
sbranchs.forEach(function(snode) {
var tnode = mindmap.createNode(snode.getType(), snode.getId());
snode.copyTo(tnode);
mindmap.addBranch(snode);
});
}
});

View File

@ -51,7 +51,7 @@ mindplot.model.INodeModel = new Class({
}, },
getText : function() { getText : function() {
this.getProperty('text'); return this.getProperty('text');
}, },
setPosition : function(x, y) { setPosition : function(x, y) {
@ -162,7 +162,7 @@ mindplot.model.INodeModel = new Class({
}, },
areChildrenShrinked : function() { areChildrenShrinked : function() {
this.getProperty('childrenShrinked'); return this.getProperty('childrenShrinked');
}, },
setChildrenShrinked : function(value) { setChildrenShrinked : function(value) {

View File

@ -16,6 +16,7 @@
* limitations under the License. * limitations under the License.
*/ */
mindplot.model.Mindmap = new Class({ mindplot.model.Mindmap = new Class({
Extends: mindplot.model.IMindmap,
initialize : function() { initialize : function() {
this._branches = []; this._branches = [];
this._description = null; this._description = null;
@ -23,10 +24,6 @@ mindplot.model.Mindmap = new Class({
this._relationships = []; this._relationships = [];
}, },
getCentralTopic : function() {
return this._branches[0];
},
getDescription : function() { getDescription : function() {
return this._description; return this._description;
}, },
@ -44,14 +41,14 @@ mindplot.model.Mindmap = new Class({
return this._version; return this._version;
}, },
setVersion : function(version) { setVersion : function(version) {
this._version = version; this._version = version;
}, },
addBranch : function(nodeModel) { addBranch : function(nodeModel) {
$assert(nodeModel && nodeModel.isNodeModel(), 'Add node must be invoked with model objects'); $assert(nodeModel && nodeModel.isNodeModel(), 'Add node must be invoked with model objects');
if (this._branches.length == 0) { var branches = this.getBranches();
if (branches.length == 0) {
$assert(nodeModel.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE, "First element must be the central topic"); $assert(nodeModel.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE, "First element must be the central topic");
nodeModel.setPosition(0, 0); nodeModel.setPosition(0, 0);
} else { } else {
@ -61,6 +58,11 @@ mindplot.model.Mindmap = new Class({
this._branches.push(nodeModel); this._branches.push(nodeModel);
}, },
removeBranch : function(nodeModel){
$assert(nodeModel && nodeModel.isNodeModel(), 'Remove node must be invoked with model objects');
return this._branches.erase(nodeModel);
},
getBranches : function() { getBranches : function() {
return this._branches; return this._branches;
}, },
@ -69,30 +71,6 @@ mindplot.model.Mindmap = new Class({
return this._relationships; return this._relationships;
}, },
connect : function(parent, child) {
// Child already has a parent ?
var branches = this.getBranches();
$assert(!child.getParent(), 'Child model seems to be already connected');
// Connect node...
parent._appendChild(child);
// Remove from the branch ...
branches.erase(child);
},
disconnect : function(child) {
var parent = child.getParent();
$assert(child, 'Child can not be null.');
$assert(parent, 'Child model seems to be already connected');
parent._removeChild(child);
var branches = this.getBranches();
branches.push(child);
},
hasAlreadyAdded : function(node) { hasAlreadyAdded : function(node) {
var result = false; var result = false;
@ -108,13 +86,7 @@ mindplot.model.Mindmap = new Class({
createNode : function(type, id) { createNode : function(type, id) {
$assert(type, "node type can not be null"); $assert(type, "node type can not be null");
return this._createNode(type, id); return new mindplot.model.NodeModel(type, this, id);
},
_createNode : function(type, id) {
$assert(type, 'Node type must be specified.');
var result = new mindplot.model.NodeModel(type, this, id);
return result;
}, },
createRelationship : function(fromNode, toNode) { createRelationship : function(fromNode, toNode) {
@ -130,48 +102,6 @@ mindplot.model.Mindmap = new Class({
removeRelationship : function(relationship) { removeRelationship : function(relationship) {
this._relationships.erase(relationship); this._relationships.erase(relationship);
},
inspect : function() {
var result = '';
result = '{ ';
var branches = this.getBranches();
for (var i = 0; i < branches.length; i++) {
var node = branches[i];
if (i != 0) {
result = result + ', ';
}
result = result + this._toString(node);
}
result = result + ' } ';
return result;
},
_toString : function(node) {
var result = node.inspect();
var children = node.getChildren();
for (var i = 0; i < children.length; i++) {
var child = children[i];
if (i == 0) {
result = result + '-> {';
} else {
result = result + ', ';
}
result = result + this._toString(child);
if (i == children.length - 1) {
result = result + '}';
}
}
return result;
} }
} }
); );