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 a4da6fb7cd
commit c298732f64
46 changed files with 1524 additions and 108 deletions

View File

@@ -16,7 +16,7 @@
* limitations under the License.
*/
mindplot.model.FeatureModel = new Class({
mindplot.model.FeatureModel = new Class(/** @lends FeatureModel */{
Static:{
_nextUUID:function () {
if (!$defined(mindplot.model.FeatureModel._uuid)) {
@@ -28,6 +28,12 @@ mindplot.model.FeatureModel = new Class({
}
},
/**
* @constructs
* @param type
* @throws will throw an exception if type is null or undefined
* assigns a unique id and the given type to the new model
*/
initialize:function (type) {
$assert(type, 'type can not be null');
this._id = mindplot.model.FeatureModel._nextUUID();
@@ -41,35 +47,42 @@ mindplot.model.FeatureModel = new Class({
};
},
/** */
getAttributes:function () {
return Object.clone(this._attributes);
},
/** */
setAttributes:function (attributes) {
for (key in attributes) {
this["set" + key.capitalize()](attributes[key]);
}
},
/** */
setAttribute:function (key, value) {
$assert(key, 'key id can not be null');
this._attributes[key] = value;
},
/** */
getAttribute:function (key) {
$assert(key, 'key id can not be null');
return this._attributes[key];
},
/** */
getId:function () {
return this._id;
},
/** */
setId:function (id) {
this._id = id;
},
/** */
getType:function () {
return this._type;
}

View File

@@ -15,55 +15,76 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.model.IMindmap = new Class({
mindplot.model.IMindmap = new Class(/** @lends IMindmap */{
/**
* @constructs
* @abstract
*/
initialize : function() {
throw "Unsupported operation";
},
/** */
getCentralTopic : function() {
return this.getBranches()[0];
},
/** @abstract */
getDescription : function() {
throw "Unsupported operation";
},
/** @abstract */
setDescription : function(value) {
throw "Unsupported operation";
},
/** @abstract */
getId : function() {
throw "Unsupported operation";
},
/** @abstract */
setId : function(id) {
throw "Unsupported operation";
},
/** @abstract */
getVersion : function() {
throw "Unsupported operation";
},
/** @abstract */
setVersion : function(version) {
throw "Unsupported operation";
},
/** @abstract */
addBranch : function(nodeModel) {
throw "Unsupported operation";
},
/** @abstract */
getBranches : function() {
throw "Unsupported operation";
},
/** @abstract */
removeBranch : function(node) {
throw "Unsupported operation";
},
/** @abstract */
getRelationships : function() {
throw "Unsupported operation";
},
/**
* @param parent
* @param child
* @throws will throw an error if child already has a connection to a parent node
*/
connect : function(parent, child) {
// Child already has a parent ?
$assert(!child.getParent(), 'Child model seems to be already connected');
@@ -75,6 +96,11 @@ mindplot.model.IMindmap = new Class({
this.removeBranch(child);
},
/**
* @param child
* @throws will throw an error if child is null or undefined
* @throws will throw an error if child's parent cannot be found
*/
disconnect : function(child) {
var parent = child.getParent();
$assert(child, 'Child can not be null.');
@@ -84,26 +110,32 @@ mindplot.model.IMindmap = new Class({
this.addBranch(child);
},
/** @abstract */
hasAlreadyAdded : function(node) {
throw "Unsupported operation";
},
/** @abstract */
createNode : function(type, id) {
throw "Unsupported operation";
},
/** @abstract */
createRelationship : function(fromNode, toNode) {
throw "Unsupported operation";
},
/** @abstract */
addRelationship : function(rel) {
throw "Unsupported operation";
},
/** @abstract */
deleteRelationship : function(relationship) {
throw "Unsupported operation";
},
/** */
inspect : function() {
var result = '';
result = '{ ';
@@ -125,6 +157,9 @@ mindplot.model.IMindmap = new Class({
return result;
},
/**
* @param target
*/
copyTo : function(target) {
var source = this;
var version = source.getVersion();

View File

@@ -16,16 +16,22 @@
* limitations under the License.
*/
mindplot.model.INodeModel = new Class({
mindplot.model.INodeModel = new Class(/** @lends INodeModel */{
/**
* @constructs
* @param mindmap
*/
initialize: function(mindmap) {
$assert(mindmap && mindmap.getBranches, 'mindmap can not be null');
this._mindmap = mindmap;
},
/** */
getId : function() {
return this.getProperty('id');
},
/** */
setId : function(id) {
if ($defined(id) && id > mindplot.model.INodeModel._uuid) {
mindplot.model.INodeModel._uuid = id;
@@ -38,28 +44,34 @@ mindplot.model.INodeModel = new Class({
},
/** */
getType : function() {
return this.getProperty('type');
},
/** */
setType : function(type) {
this.putProperty('type', type);
},
/** */
setText : function(text) {
this.putProperty('text', text);
},
/** */
getText : function() {
return this.getProperty('text');
},
/** */
setPosition : function(x, y) {
$assert(!isNaN(parseInt(x)), "x position is not valid:" + x);
$assert(!isNaN(parseInt(y)), "y position is not valid:" + y);
this.putProperty('position', '{x:' + parseInt(x) + ',y:' + parseInt(y) + '}');
},
/** */
getPosition : function() {
var value = this.getProperty('position');
var result = null;
@@ -69,10 +81,12 @@ mindplot.model.INodeModel = new Class({
return result;
},
/** */
setImageSize : function(width, height) {
this.putProperty('imageSize', '{width:' + width + ',height:' + height + '}');
},
/** */
getImageSize : function() {
var value = this.getProperty('imageSize');
var result = null;
@@ -82,133 +96,180 @@ mindplot.model.INodeModel = new Class({
return result;
},
/** */
setImageUrl:function(url) {
this.putProperty('imageUrl', url);
},
/** */
getMetadata:function() {
return this.getProperty('metadata');
},
/** */
setMetadata:function(json) {
this.putProperty('metadata', json);
},
/** */
getImageUrl:function() {
return this.getProperty('imageUrl');
},
/** */
getMindmap : function() {
return this._mindmap;
},
/**
* lets the mindmap handle the disconnect node operation
* @see mindplot.model.IMindmap.disconnect
*/
disconnect : function() {
var mindmap = this.getMindmap();
mindmap.disconnect(this);
},
/** */
getShapeType : function() {
return this.getProperty('shapeType');
},
/** */
setShapeType : function(type) {
this.putProperty('shapeType', type);
},
/** */
setOrder : function(value) {
$assert(typeof value === 'number' && isFinite(value) || value == null, "Order must be null or a number");
this.putProperty('order', value);
},
/** */
getOrder : function() {
return this.getProperty('order');
},
/** */
setFontFamily : function(fontFamily) {
this.putProperty('fontFamily', fontFamily);
},
/** */
getFontFamily : function() {
return this.getProperty('fontFamily');
},
/** */
setFontStyle : function(fontStyle) {
this.putProperty('fontStyle', fontStyle);
},
/** */
getFontStyle : function() {
return this.getProperty('fontStyle');
},
/** */
setFontWeight : function(weight) {
this.putProperty('fontWeight', weight);
},
/** */
getFontWeight : function() {
return this.getProperty('fontWeight');
},
/** */
setFontColor : function(color) {
this.putProperty('fontColor', color);
},
/** */
getFontColor : function() {
return this.getProperty('fontColor');
},
/** */
setFontSize : function(size) {
this.putProperty('fontSize', size);
},
/** */
getFontSize : function() {
return this.getProperty('fontSize');
},
/** */
getBorderColor : function() {
return this.getProperty('borderColor');
},
/** */
setBorderColor : function(color) {
this.putProperty('borderColor', color);
},
/** */
getBackgroundColor : function() {
return this.getProperty('backgroundColor');
},
/** */
setBackgroundColor : function(color) {
this.putProperty('backgroundColor', color);
},
/** */
areChildrenShrunken : function() {
var result = this.getProperty('shrunken');
return $defined(result) ? result : false;
},
/**
* @return {Boolean} true if the children nodes are hidden by the shrink option
*/
setChildrenShrunken : function(value) {
this.putProperty('shrunken', value);
},
/**
* @return {Boolean} true
*/
isNodeModel : function() {
return true;
},
/**
* @return {Boolean} true if the node model has a parent assigned to it
*/
isConnected : function() {
return this.getParent() != null;
},
/** @abstract */
append : function(node) {
throw "Unsupported operation";
},
/**
* lets the mindmap handle the connect node operation
* @throws will throw an error if parent is null or undefined
* @see mindplot.model.IMindmap.connect
*/
connectTo : function(parent) {
$assert(parent, "parent can not be null");
var mindmap = this.getMindmap();
mindmap.connect(parent, this);
},
/**
* @param target
* @return target
*/
copyTo : function(target) {
var source = this;
// Copy properties ...
@@ -218,7 +279,7 @@ mindplot.model.INodeModel = new Class({
target.putProperty(key, value);
});
// Copy childrens ...
// Copy children ...
var children = this.getChildren();
var tmindmap = target.getMindmap();
@@ -231,6 +292,10 @@ mindplot.model.INodeModel = new Class({
return target;
},
/**
* lets parent handle the delete node operation, or, if none defined, calls the mindmap to
* remove the respective branch
*/
deleteNode : function() {
var mindmap = this.getMindmap();
@@ -246,30 +311,37 @@ mindplot.model.INodeModel = new Class({
// console.log("After:" + mindmap.inspect());
},
/** @abstract */
getPropertiesKeys : function() {
throw "Unsupported operation";
},
/** @abstract */
putProperty: function(key, value) {
throw "Unsupported operation";
},
/** @abstract */
setParent : function(parent) {
throw "Unsupported operation";
},
/** @abstract */
getChildren : function() {
throw "Unsupported operation";
},
/** @abstract */
getParent : function() {
throw "Unsupported operation";
},
/** @abstract */
clone : function() {
throw "Unsupported operation";
},
/** */
inspect : function() {
var result = '{ type: ' + this.getType() +
' , id: ' + this.getId() +
@@ -293,12 +365,16 @@ mindplot.model.INodeModel = new Class({
return result;
},
/** @abstract */
removeChild : function(child) {
throw "Unsupported operation";
}
});
/**
* @enum {String}
*/
mindplot.model.TopicShape =
{
RECTANGLE : 'rectagle',
@@ -308,15 +384,28 @@ mindplot.model.TopicShape =
IMAGE : 'image'
};
/**
* @constant
* @type {String}
* @default
*/
mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE = 'CentralTopic';
/**
* @constant
* @type {String}
* @default
*/
mindplot.model.INodeModel.MAIN_TOPIC_TYPE = 'MainTopic';
/**
* @constant
* @type {Number}
* @default
*/
mindplot.model.INodeModel.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE = 220;
/**
* @todo: This method must be implemented.
* @todo: This method must be implemented. (unascribed)
*/
mindplot.model.INodeModel._nextUUID = function() {
if (!$defined(mindplot.model.INodeModel._uuid)) {

View File

@@ -16,20 +16,33 @@
* limitations under the License.
*/
mindplot.model.IconModel = new Class({
mindplot.model.IconModel = new Class(/** @lends IconModel */{
Extends:mindplot.model.FeatureModel,
/**
* @constructs
* @param attributes
* @extends mindplot.model.FeatureModel
*/
initialize:function (attributes) {
this.parent(mindplot.model.IconModel.FEATURE_TYPE);
this.setIconType(attributes.id);
},
/** @return the icon type id */
getIconType:function () {
return this.getAttribute('id');
},
/** @param {String} iconType the icon type id*/
setIconType:function (iconType) {
$assert(iconType, 'iconType id can not be null');
this.setAttribute('id', iconType);
}
});
/**
* @constant
* @type {String}
* @default
*/
mindplot.model.IconModel.FEATURE_TYPE = "icon";

View File

@@ -16,17 +16,27 @@
* limitations under the License.
*/
mindplot.model.LinkModel = new Class({
mindplot.model.LinkModel = new Class(/** @lends LinkModel */{
Extends:mindplot.model.FeatureModel,
/**
* @constructs
* @param attributes
* @extends mindplot.model.FeatureModel
*/
initialize:function (attributes) {
this.parent(mindplot.model.LinkModel.FEATURE_TYPE);
this.setUrl(attributes.url);
},
/** @return {String} the url attribute value */
getUrl:function () {
return this.getAttribute('url');
},
/**
* @param {String} url a URL provided by the user to set the link to
* @throws will throw an error if url is null or undefined
*/
setUrl:function (url) {
$assert(url, 'url can not be null');
@@ -35,8 +45,10 @@ mindplot.model.LinkModel = new Class({
var type = fixedUrl.contains('mailto:') ? 'mail' : 'url';
this.setAttribute('urlType', type);
},
//url format is already checked in LinkEditor.checkUrl
_fixUrl:function (url) {
var result = url;
if (!result.contains('http://') && !result.contains('https://') && !result.contains('mailto://')) {
@@ -45,10 +57,19 @@ mindplot.model.LinkModel = new Class({
return result;
},
/**
* @param {String} urlType the url type, either 'mail' or 'url'
* @throws will throw an error if urlType is null or undefined
*/
setUrlType:function (urlType) {
$assert(urlType, 'urlType can not be null');
this.setAttribute('urlType', urlType);
}
});
/**
* @constant
* @type {String}
* @default
*/
mindplot.model.LinkModel.FEATURE_TYPE = 'link';

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);

View File

@@ -16,8 +16,14 @@
* limitations under the License.
*/
mindplot.model.NodeModel = new Class({
mindplot.model.NodeModel = new Class(/** @lends NodeModel */{
Extends:mindplot.model.INodeModel,
/**
* @constructs
* @param {String} type node type
* @param mindmap
* @param id
*/
initialize:function (type, mindmap, id) {
$assert(type, 'Node type can not be null');
$assert(mindmap, 'mindmap can not be null');
@@ -32,19 +38,34 @@ mindplot.model.NodeModel = new Class({
this._feature = [];
},
/**
* @param type
* @param attributes
* @return {mindplot.model.FeatureModel} the created feature model
*/
createFeature:function (type, attributes) {
return mindplot.TopicFeature.createModel(type, attributes);
},
/**
* @param feature
* @throws will throw an error if feature is null or undefined
*/
addFeature:function (feature) {
$assert(feature, 'feature can not be null');
this._feature.push(feature);
},
/** */
getFeatures:function () {
return this._feature;
},
/**
* @param feature
* @throws will throw an error if feature is null or undefined
* @throws will throw an error if the feature could not be removed
*/
removeFeature:function (feature) {
$assert(feature, 'feature can not be null');
var size = this._feature.length;
@@ -55,6 +76,10 @@ mindplot.model.NodeModel = new Class({
},
/**
* @param {String} type the feature type, e.g. icon or link
* @throws will throw an error if type is null or undefined
*/
findFeatureByType:function (type) {
$assert(type, 'type can not be null');
return this._feature.filter(function (feature) {
@@ -62,35 +87,51 @@ mindplot.model.NodeModel = new Class({
});
},
/**
* @param {String} id
* @throws will throw an error if id is null or undefined
* @throws will throw an error if feature could not be found
* @return the feature with the given id
*/
findFeatureById:function (id) {
$assert($defined(id), 'id can not be null');
var result = this._feature.filter(function (feature) {
return feature.getId() == id;
});
$assert(result.length == 1, "Feature could not be found:" + id);
return result[0]
return result[0];
},
/** */
getPropertiesKeys:function () {
return Object.keys(this._properties);
},
/**
* @param key
* @param value
* @throws will throw an error if key is null or undefined
*/
putProperty:function (key, value) {
$defined(key, 'key can not be null');
this._properties[key] = value;
},
/** */
getProperties:function () {
return this._properties;
},
/** */
getProperty:function (key) {
$defined(key, 'key can not be null');
var result = this._properties[key];
return !$defined(result) ? null : result;
},
/**
* @return {mindplot.model.NodeModel} an identical clone of the NodeModel
*/
clone:function () {
var result = new mindplot.model.NodeModel(this.getType(), this._mindmap);
result._children = this._children.map(function (node) {
@@ -124,26 +165,37 @@ mindplot.model.NodeModel = new Class({
return result;
},
/**
* @param {mindplot.model.NodeModel} child
* @throws will throw an error if child is null, undefined or not a NodeModel object
*/
append:function (child) {
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
this._children.push(child);
child._parent = this;
},
/**
* @param {mindplot.model.NodeModel} child
* @throws will throw an error if child is null, undefined or not a NodeModel object
*/
removeChild:function (child) {
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object.');
this._children.erase(child);
child._parent = null;
},
/** */
getChildren:function () {
return this._children;
},
/** */
getParent:function () {
return this._parent;
},
/** */
setParent:function (parent) {
$assert(parent != this, 'The same node can not be parent and child if itself.');
this._parent = parent;
@@ -166,6 +218,10 @@ mindplot.model.NodeModel = new Class({
return result;
},
/**
* @id
* @return {mindplot.model.NodeModel} the node with the respective id
*/
findNodeById:function (id) {
var result = null;
if (this.getId() == id) {

View File

@@ -16,22 +16,34 @@
* limitations under the License.
*/
mindplot.model.NoteModel = new Class({
mindplot.model.NoteModel = new Class(/** @lends NoteModel */{
Extends:mindplot.model.FeatureModel,
/**
* @constructs
* @param attributes
* @extends mindplot.model.FeatureModel
*/
initialize:function (attributes) {
this.parent(mindplot.model.NoteModel.FEATURE_TYPE);
var noteText = attributes.text ? attributes.text : " ";
this.setText(noteText);
},
/** */
getText:function () {
return this.getAttribute('text');
},
/** */
setText:function (text) {
$assert(text, 'text can not be null');
this.setAttribute('text', text);
}
});
/**
* @constant
* @type {String}
* @default
*/
mindplot.model.NoteModel.FEATURE_TYPE = "note";

View File

@@ -15,7 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.model.RelationshipModel = new Class({
mindplot.model.RelationshipModel = new Class(/** @lends RelationshipModel */{
Static:{
_nextUUID:function () {
if (!$defined(mindplot.model.RelationshipModel._uuid)) {
@@ -26,6 +27,13 @@ mindplot.model.RelationshipModel = new Class({
}
},
/**
* @constructs
* @param sourceTopicId
* @param targetTopicId
* @throws will throw an error if sourceTopicId is null or undefined
* @throws will throw an error if targetTopicId is null or undefined
*/
initialize:function (sourceTopicId, targetTopicId) {
$assert($defined(sourceTopicId), 'from node type can not be null');
$assert($defined(targetTopicId), 'to node type can not be null');
@@ -40,59 +48,75 @@ mindplot.model.RelationshipModel = new Class({
this._startArrow = false;
},
/** */
getFromNode:function () {
return this._sourceTargetId;
},
/** */
getToNode:function () {
return this._targetTopicId;
},
/** */
getId:function () {
$assert(this._id, "id is null");
return this._id;
},
/** */
getLineType:function () {
return this._lineType;
},
/** */
setLineType:function (lineType) {
this._lineType = lineType;
},
/** */
getSrcCtrlPoint:function () {
return this._srcCtrlPoint;
},
/** */
setSrcCtrlPoint:function (srcCtrlPoint) {
this._srcCtrlPoint = srcCtrlPoint;
},
/** */
getDestCtrlPoint:function () {
return this._destCtrlPoint;
},
/** */
setDestCtrlPoint:function (destCtrlPoint) {
this._destCtrlPoint = destCtrlPoint;
},
/** */
getEndArrow:function () {
return this._endArrow;
},
/** */
setEndArrow:function (endArrow) {
this._endArrow = endArrow;
},
/** */
getStartArrow:function () {
return this._startArrow;
},
/** */
setStartArrow:function (startArrow) {
this._startArrow = startArrow;
},
/**
* @return a clone of the relationship model
*/
clone:function () {
var result = new mindplot.model.RelationshipModel(this._sourceTargetId, this._targetTopicId);
result._id = this._id;
@@ -104,6 +128,9 @@ mindplot.model.RelationshipModel = new Class({
return result;
},
/**
* @return {String} textual information about the relationship's source and target node
*/
inspect:function () {
return '(fromNode:' + this.getFromNode().getId() + ' , toNode: ' + this.getToNode().getId() + ')';
}