add jsdoc to mindplot module

--HG--
branch : mindplot_jsdoc
This commit is contained in:
Christina Korger
2015-03-23 09:25:54 +01:00
parent 53e210456e
commit 47c4566435
46 changed files with 1524 additions and 108 deletions

View File

@@ -15,8 +15,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.model.Mindmap = new Class({
mindplot.model.Mindmap = new Class(/** @lends Mindmap */{
Extends:mindplot.model.IMindmap,
/**
* @constructs
* @param id
* @param version
* @extends mindplot.model.IMindmap
*/
initialize:function (id, version) {
$assert(id, "Id can not be null");
this._branches = [];
@@ -26,31 +33,41 @@ mindplot.model.Mindmap = new Class({
this._id = id;
},
/** */
getDescription:function () {
return this._description;
},
/** */
setDescription:function (value) {
this._description = value;
},
/** */
getId:function () {
return this._id;
},
/** */
setId:function (id) {
this._id = id;
},
/** */
getVersion:function () {
return this._version;
},
/** */
setVersion:function (version) {
this._version = version;
},
/**
* @param {mindplot.model.NodeModel} nodeModel
* @throws will throw an error if nodeModel is null, undefined or not a node model object
* @throws will throw an error if
*/
addBranch:function (nodeModel) {
$assert(nodeModel && nodeModel.isNodeModel(), 'Add node must be invoked with model objects');
var branches = this.getBranches();
@@ -64,19 +81,28 @@ mindplot.model.Mindmap = new Class({
this._branches.push(nodeModel);
},
/**
* @param nodeModel
*/
removeBranch:function (nodeModel) {
$assert(nodeModel && nodeModel.isNodeModel(), 'Remove node must be invoked with model objects');
return this._branches.erase(nodeModel);
},
/** */
getBranches:function () {
return this._branches;
},
/** */
getRelationships:function () {
return this._relationships;
},
/**
* @param node
* @return {Boolean} true if node already exists
*/
hasAlreadyAdded:function (node) {
var result = false;
@@ -90,11 +116,23 @@ mindplot.model.Mindmap = new Class({
}
},
/**
* @param type
* @param id
* @return the node model created
*/
createNode:function (type, id) {
type = !$defined(type) ? mindplot.model.INodeModel.MAIN_TOPIC_TYPE : type;
return new mindplot.model.NodeModel(type, this, id);
},
/**
* @param sourceNodeId
* @param targetNodeId
* @throws will throw an error if source node is null or undefined
* @throws will throw an error if target node is null or undefined
* @return the relationship model created
*/
createRelationship:function (sourceNodeId, targetNodeId) {
$assert($defined(sourceNodeId), 'from node cannot be null');
$assert($defined(targetNodeId), 'to node cannot be null');
@@ -102,14 +140,24 @@ mindplot.model.Mindmap = new Class({
return new mindplot.model.RelationshipModel(sourceNodeId, targetNodeId);
},
/**
* @param relationship
*/
addRelationship:function (relationship) {
this._relationships.push(relationship);
},
/**
* @param relationship
*/
deleteRelationship:function (relationship) {
this._relationships.erase(relationship);
},
/**
* @param id
* @return the node with the respective id or null if not in the mindmap
*/
findNodeById:function (id) {
var result = null;
for (var i = 0; i < this._branches.length; i++) {
@@ -124,6 +172,10 @@ mindplot.model.Mindmap = new Class({
}
);
/**
* @param mapId
* @return an empty mindmap with central topic only
*/
mindplot.model.Mindmap.buildEmpty = function (mapId) {
var result = new mindplot.model.Mindmap(mapId);
var node = result.createNode(mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE, 0);