Introduce the convept of Feature to a topic.
This commit is contained in:
@@ -30,9 +30,39 @@ mindplot.model.NodeModel = new Class({
|
||||
this.setSize(50, 20);
|
||||
|
||||
this._children = [];
|
||||
this._icons = [];
|
||||
this._links = [];
|
||||
this._notes = [];
|
||||
this._feature = [];
|
||||
},
|
||||
|
||||
createFeature: function(type, attributes) {
|
||||
return mindplot.TopicFeature.createModel(type, this, attributes);
|
||||
},
|
||||
|
||||
addFeature: function(feature) {
|
||||
$assert(feature, 'feature can not be null');
|
||||
this._feature.push(feature);
|
||||
},
|
||||
|
||||
getFeatures: function() {
|
||||
return this._feature;
|
||||
},
|
||||
|
||||
removeFeature: function(feature) {
|
||||
$assert(feature, 'feature can not be null');
|
||||
this._feature.erase(feature);
|
||||
},
|
||||
|
||||
findFeatureByType : function(type) {
|
||||
$assert(type, 'type can not be null');
|
||||
return this._feature.filter(function(feature) {
|
||||
return feature.getType() == type;
|
||||
});
|
||||
},
|
||||
|
||||
findFeatureById : function(id) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
return this._feature.filter(function(feature) {
|
||||
return feature.getId() == id;
|
||||
})[0];
|
||||
},
|
||||
|
||||
getPropertiesKeys : function() {
|
||||
@@ -64,67 +94,10 @@ mindplot.model.NodeModel = new Class({
|
||||
});
|
||||
|
||||
result._properties = Object.clone(this._properties);
|
||||
result._icons = this._icons.clone();
|
||||
result._links = this._links.clone();
|
||||
result._notes = this._notes.clone();
|
||||
result._feature = this._feature.clone();
|
||||
return result;
|
||||
},
|
||||
|
||||
addChildren : function() {
|
||||
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
|
||||
this._children.push(child);
|
||||
child._parent = this;
|
||||
},
|
||||
|
||||
createLink : function(url) {
|
||||
$assert(url, 'Link URL must be specified.');
|
||||
return new mindplot.model.LinkModel(url, this);
|
||||
},
|
||||
|
||||
addLink : function(link) {
|
||||
$assert(link && link.isLinkModel(), 'Only LinkModel can be appended to Mindmap object as links');
|
||||
this._links.push(link);
|
||||
},
|
||||
|
||||
_removeLink : function(link) {
|
||||
$assert(link && link.isLinkModel(), 'Only LinkModel can be appended to Mindmap object as links');
|
||||
this._links.erase(link);
|
||||
},
|
||||
|
||||
createNote : function(text) {
|
||||
$assert(text != null, 'note text must be specified.');
|
||||
return new mindplot.model.NoteModel(text, this);
|
||||
},
|
||||
|
||||
addNote : function(note) {
|
||||
$assert(note && note.isNoteModel(), 'Only NoteModel can be appended to Mindmap object as links');
|
||||
this._notes.push(note);
|
||||
},
|
||||
|
||||
removeNote : function(note) {
|
||||
$assert(note && note.isNoteModel(), 'Only NoteModel can be appended to Mindmap object as links');
|
||||
this._notes.erase(note);
|
||||
},
|
||||
|
||||
createIcon : function(iconType) {
|
||||
$assert(iconType, 'IconType must be specified.');
|
||||
return new mindplot.model.IconModel(iconType, this);
|
||||
},
|
||||
|
||||
addIcon : function(icon) {
|
||||
$assert(icon && icon.isIconModel(), 'Only IconModel can be appended to Mindmap object as icons');
|
||||
this._icons.push(icon);
|
||||
},
|
||||
|
||||
removeIcon : function(icon) {
|
||||
$assert(icon && icon.isIconModel(), 'Only IconModel can be appended to Mindmap object as icons');
|
||||
this._icons.erase(icon);
|
||||
},
|
||||
|
||||
removeLastIcon : function() {
|
||||
this._icons.pop();
|
||||
},
|
||||
|
||||
appendChild : function(child) {
|
||||
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
|
||||
this._children.push(child);
|
||||
@@ -141,18 +114,6 @@ mindplot.model.NodeModel = new Class({
|
||||
return this._children;
|
||||
},
|
||||
|
||||
getIcons : function() {
|
||||
return this._icons;
|
||||
},
|
||||
|
||||
getLinks : function() {
|
||||
return this._links;
|
||||
},
|
||||
|
||||
getNotes : function() {
|
||||
return this._notes;
|
||||
},
|
||||
|
||||
getParent : function() {
|
||||
return this._parent;
|
||||
},
|
||||
|
Reference in New Issue
Block a user