mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-26 15:54:55 +01:00
More classes migrated to Mootools 1.3.
This commit is contained in:
parent
9759ee12cb
commit
f60755fd8e
@ -15,20 +15,19 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
mindplot.Beta2PelaMigrator = function(betaSerializer){
|
mindplot.Beta2PelaMigrator = new Class({
|
||||||
|
initialize : function(betaSerializer) {
|
||||||
this._betaSerializer = betaSerializer;
|
this._betaSerializer = betaSerializer;
|
||||||
this._pelaSerializer = new mindplot.XMLMindmapSerializer_Pela();
|
this._pelaSerializer = new mindplot.XMLMindmapSerializer_Pela();
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Beta2PelaMigrator.prototype.toXML = function(mindmap)
|
toXML : function(mindmap) {
|
||||||
{
|
|
||||||
return this._pelaSerializer.toXML(mindmap);
|
return this._pelaSerializer.toXML(mindmap);
|
||||||
};
|
},
|
||||||
|
|
||||||
|
loadFromDom : function(dom) {
|
||||||
mindplot.Beta2PelaMigrator.prototype.loadFromDom = function(dom)
|
|
||||||
{
|
|
||||||
var mindmap = this._betaSerializer.loadFromDom(dom);
|
var mindmap = this._betaSerializer.loadFromDom(dom);
|
||||||
mindmap.setVersion(mindplot.ModelCodeName.PELA);
|
mindmap.setVersion(mindplot.ModelCodeName.PELA);
|
||||||
return mindmap;
|
return mindmap;
|
||||||
};
|
}
|
||||||
|
});
|
||||||
|
@ -58,12 +58,14 @@ mindplot.Board = new Class({
|
|||||||
/**
|
/**
|
||||||
* ---------------------------------------
|
* ---------------------------------------
|
||||||
*/
|
*/
|
||||||
mindplot.BidirectionalArray = function() {
|
mindplot.BidirectionalArray = new Class({
|
||||||
|
|
||||||
|
initialize: function() {
|
||||||
this._leftElem = [];
|
this._leftElem = [];
|
||||||
this._rightElem = [];
|
this._rightElem = [];
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.BidirectionalArray.prototype.get = function(index, sign) {
|
get :function(index, sign) {
|
||||||
core.assert(core.Utils.isDefined(index), 'Illegal argument, index must be passed.');
|
core.assert(core.Utils.isDefined(index), 'Illegal argument, index must be passed.');
|
||||||
if (core.Utils.isDefined(sign)) {
|
if (core.Utils.isDefined(sign)) {
|
||||||
core.assert(index >= 0, 'Illegal absIndex value');
|
core.assert(index >= 0, 'Illegal absIndex value');
|
||||||
@ -77,29 +79,29 @@ mindplot.BidirectionalArray.prototype.get = function(index, sign) {
|
|||||||
result = this._leftElem[Math.abs(index)];
|
result = this._leftElem[Math.abs(index)];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.BidirectionalArray.prototype.set = function(index, elem) {
|
set : function(index, elem) {
|
||||||
core.assert(core.Utils.isDefined(index), 'Illegal index value');
|
core.assert(core.Utils.isDefined(index), 'Illegal index value');
|
||||||
|
|
||||||
var array = (index >= 0) ? this._rightElem : this._leftElem;
|
var array = (index >= 0) ? this._rightElem : this._leftElem;
|
||||||
array[Math.abs(index)] = elem;
|
array[Math.abs(index)] = elem;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.BidirectionalArray.prototype.length = function(index) {
|
length : function(index) {
|
||||||
core.assert(core.Utils.isDefined(index), 'Illegal index value');
|
core.assert(core.Utils.isDefined(index), 'Illegal index value');
|
||||||
return (index >= 0) ? this._rightElem.length : this._leftElem.length;
|
return (index >= 0) ? this._rightElem.length : this._leftElem.length;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.BidirectionalArray.prototype.upperLength = function() {
|
upperLength : function() {
|
||||||
return this.length(1);
|
return this.length(1);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.BidirectionalArray.prototype.lowerLength = function() {
|
lowerLength : function() {
|
||||||
return this.length(-1);
|
return this.length(-1);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.BidirectionalArray.prototype.inspect = function() {
|
inspect : function() {
|
||||||
var result = '{';
|
var result = '{';
|
||||||
var lenght = this._leftElem.length;
|
var lenght = this._leftElem.length;
|
||||||
for (var i = 0; i < lenght; i++) {
|
for (var i = 0; i < lenght; i++) {
|
||||||
@ -126,4 +128,5 @@ mindplot.BidirectionalArray.prototype.inspect = function() {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
};
|
}
|
||||||
|
});
|
@ -16,10 +16,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.BoardEntry = function(lowerLimit, upperLimit, order)
|
mindplot.BoardEntry = new Class({
|
||||||
{
|
initialize:function(lowerLimit, upperLimit, order) {
|
||||||
if (core.Utils.isDefined(lowerLimit) && core.Utils.isDefined(upperLimit))
|
if (core.Utils.isDefined(lowerLimit) && core.Utils.isDefined(upperLimit)) {
|
||||||
{
|
|
||||||
core.assert(lowerLimit < upperLimit, 'lowerLimit can not be greater that upperLimit');
|
core.assert(lowerLimit < upperLimit, 'lowerLimit can not be greater that upperLimit');
|
||||||
}
|
}
|
||||||
this._upperLimit = upperLimit;
|
this._upperLimit = upperLimit;
|
||||||
@ -27,96 +26,81 @@ mindplot.BoardEntry = function(lowerLimit, upperLimit, order)
|
|||||||
this._order = order;
|
this._order = order;
|
||||||
this._topic = null;
|
this._topic = null;
|
||||||
this._xPos = null;
|
this._xPos = null;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.BoardEntry.prototype.getUpperLimit = function()
|
|
||||||
{
|
getUpperLimit : function() {
|
||||||
return this._upperLimit;
|
return this._upperLimit;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.BoardEntry.prototype.setXPosition = function(xPosition)
|
setXPosition : function(xPosition) {
|
||||||
{
|
|
||||||
this._xPos = xPosition;
|
this._xPos = xPosition;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.BoardEntry.prototype.workoutEntryYCenter = function()
|
workoutEntryYCenter : function() {
|
||||||
{
|
|
||||||
return this._lowerLimit + ((this._upperLimit - this._lowerLimit) / 2);
|
return this._lowerLimit + ((this._upperLimit - this._lowerLimit) / 2);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.BoardEntry.prototype.setUpperLimit = function(value)
|
setUpperLimit : function(value) {
|
||||||
{
|
|
||||||
core.assert(core.Utils.isDefined(value), "upper limit can not be null");
|
core.assert(core.Utils.isDefined(value), "upper limit can not be null");
|
||||||
core.assert(!isNaN(value), "illegal value");
|
core.assert(!isNaN(value), "illegal value");
|
||||||
this._upperLimit = value;
|
this._upperLimit = value;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.BoardEntry.prototype.isCoordinateIn = function(coord)
|
isCoordinateIn : function(coord) {
|
||||||
{
|
|
||||||
return this._lowerLimit <= coord && coord < this._upperLimit;
|
return this._lowerLimit <= coord && coord < this._upperLimit;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.BoardEntry.prototype.getLowerLimit = function()
|
getLowerLimit : function() {
|
||||||
{
|
|
||||||
return this._lowerLimit;
|
return this._lowerLimit;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.BoardEntry.prototype.setLowerLimit = function(value)
|
setLowerLimit : function(value) {
|
||||||
{
|
|
||||||
core.assert(core.Utils.isDefined(value), "upper limit can not be null");
|
core.assert(core.Utils.isDefined(value), "upper limit can not be null");
|
||||||
core.assert(!isNaN(value), "illegal value");
|
core.assert(!isNaN(value), "illegal value");
|
||||||
this._lowerLimit = value;
|
this._lowerLimit = value;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.BoardEntry.prototype.setOrder = function(value)
|
setOrder : function(value) {
|
||||||
{
|
|
||||||
this._order = value;
|
this._order = value;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.BoardEntry.prototype.getWidth = function()
|
getWidth : function() {
|
||||||
{
|
|
||||||
return Math.abs(this._upperLimit - this._lowerLimit);
|
return Math.abs(this._upperLimit - this._lowerLimit);
|
||||||
};
|
},
|
||||||
|
|
||||||
|
|
||||||
mindplot.BoardEntry.prototype.getTopic = function()
|
getTopic : function() {
|
||||||
{
|
|
||||||
return this._topic;
|
return this._topic;
|
||||||
};
|
},
|
||||||
|
|
||||||
|
|
||||||
mindplot.BoardEntry.prototype.removeTopic = function()
|
removeTopic : function() {
|
||||||
{
|
|
||||||
core.assert(!this.isAvailable(), "Entry doesn't have a topic.");
|
core.assert(!this.isAvailable(), "Entry doesn't have a topic.");
|
||||||
var topic = this.getTopic();
|
var topic = this.getTopic();
|
||||||
this.setTopic(null);
|
this.setTopic(null);
|
||||||
topic.setOrder(null);
|
topic.setOrder(null);
|
||||||
};
|
},
|
||||||
|
|
||||||
|
|
||||||
mindplot.BoardEntry.prototype.update = function()
|
update : function() {
|
||||||
{
|
|
||||||
var topic = this.getTopic();
|
var topic = this.getTopic();
|
||||||
this.setTopic(topic);
|
this.setTopic(topic);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.BoardEntry.prototype.setTopic = function(topic, updatePosition)
|
setTopic : function(topic, updatePosition) {
|
||||||
{
|
if (!core.Utils.isDefined(updatePosition) || (core.Utils.isDefined(updatePosition) && !updatePosition)) {
|
||||||
if (!core.Utils.isDefined(updatePosition) || (core.Utils.isDefined(updatePosition) && !updatePosition))
|
|
||||||
{
|
|
||||||
updatePosition = true;
|
updatePosition = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._topic = topic;
|
this._topic = topic;
|
||||||
if (core.Utils.isDefined(topic))
|
if (core.Utils.isDefined(topic)) {
|
||||||
{
|
|
||||||
// Fixed positioning. Only for main topic ...
|
// Fixed positioning. Only for main topic ...
|
||||||
var position = null;
|
var position = null;
|
||||||
var topicPosition = topic.getPosition();
|
var topicPosition = topic.getPosition();
|
||||||
|
|
||||||
// Must update position base on the border limits?
|
// Must update position base on the border limits?
|
||||||
if (core.Utils.isDefined(this._xPos))
|
if (core.Utils.isDefined(this._xPos)) {
|
||||||
{
|
|
||||||
position = new core.Point();
|
position = new core.Point();
|
||||||
|
|
||||||
// Update x position ...
|
// Update x position ...
|
||||||
@ -138,23 +122,20 @@ mindplot.BoardEntry.prototype.setTopic = function(topic, updatePosition)
|
|||||||
topic.setPosition(position);
|
topic.setPosition(position);
|
||||||
topic.setOrder(this._order);
|
topic.setOrder(this._order);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
this._height = this._defaultWidth;
|
this._height = this._defaultWidth;
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.BoardEntry.prototype.isAvailable = function()
|
isAvailable : function() {
|
||||||
{
|
|
||||||
return !core.Utils.isDefined(this._topic);
|
return !core.Utils.isDefined(this._topic);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.BoardEntry.prototype.getOrder = function()
|
getOrder : function() {
|
||||||
{
|
|
||||||
return this._order;
|
return this._order;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.BoardEntry.prototype.inspect = function()
|
inspect : function() {
|
||||||
{
|
|
||||||
return '(order: ' + this._order + ', lowerLimit:' + this._lowerLimit + ', upperLimit: ' + this._upperLimit + ', available:' + this.isAvailable() + ')';
|
return '(order: ' + this._order + ', lowerLimit:' + this._lowerLimit + ', upperLimit: ' + this._upperLimit + ', available:' + this.isAvailable() + ')';
|
||||||
};
|
}
|
||||||
|
});
|
@ -16,10 +16,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.BubbleTip = function(divContainer){
|
mindplot.BubbleTip = new Class({
|
||||||
this.initialize(divContainer);
|
initialize : function(divContainer) {
|
||||||
};
|
|
||||||
mindplot.BubbleTip.prototype.initialize=function(divContainer){
|
|
||||||
this.options = {
|
this.options = {
|
||||||
panel:null,
|
panel:null,
|
||||||
container:null,
|
container:null,
|
||||||
@ -36,15 +34,15 @@ mindplot.BubbleTip.prototype.initialize=function(divContainer){
|
|||||||
this.buildBubble();
|
this.buildBubble();
|
||||||
this._isMouseOver = false;
|
this._isMouseOver = false;
|
||||||
this._open = false;
|
this._open = false;
|
||||||
};
|
},
|
||||||
mindplot.BubbleTip.prototype.scanElements=function(form){
|
scanElements : function(form) {
|
||||||
$$($(form).getElements('a')).each(function(el) {
|
$$($(form).getElements('a')).each(function(el) {
|
||||||
if (el.href && el.hasClass('bubble') && !el.onclick) {
|
if (el.href && el.hasClass('bubble') && !el.onclick) {
|
||||||
el.addEvent('mouseover', this.click.bindWithEvent(this, el));
|
el.addEvent('mouseover', this.click.bindWithEvent(this, el));
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
};
|
},
|
||||||
mindplot.BubbleTip.prototype.buildBubble=function(){
|
buildBubble : function() {
|
||||||
var opts = this.options;
|
var opts = this.options;
|
||||||
|
|
||||||
var panel = new Element('div').addClass('bubbleContainer');
|
var panel = new Element('div').addClass('bubbleContainer');
|
||||||
@ -55,28 +53,30 @@ mindplot.BubbleTip.prototype.buildBubble=function(){
|
|||||||
|
|
||||||
this.center = new Element('div').addClass('bubblePart').addClass('bubbleCenterBlue');
|
this.center = new Element('div').addClass('bubblePart').addClass('bubbleCenterBlue');
|
||||||
this.center.inject(panel);
|
this.center.inject(panel);
|
||||||
if(!$chk(opts.divContainer))
|
if (!$chk(opts.divContainer)) {
|
||||||
{
|
|
||||||
opts.divContainer = document.body;
|
opts.divContainer = document.body;
|
||||||
}
|
}
|
||||||
panel.injectTop(opts.divContainer);
|
panel.injectTop(opts.divContainer);
|
||||||
opts.panel = $(panel);
|
opts.panel = $(panel);
|
||||||
opts.panel.setStyle('opacity', 0);
|
opts.panel.setStyle('opacity', 0);
|
||||||
opts.panel.addEvent('mouseover',function(){this._isMouseOver=true;}.bind(this));
|
opts.panel.addEvent('mouseover', function() {
|
||||||
opts.panel.addEvent('mouseleave',function(event){this.close(event);}.bindWithEvent(this));//this.close.bindWithEvent(this)
|
this._isMouseOver = true;
|
||||||
|
}.bind(this));
|
||||||
|
opts.panel.addEvent('mouseleave', function(event) {
|
||||||
|
this.close(event);
|
||||||
|
}.bindWithEvent(this));//this.close.bindWithEvent(this)
|
||||||
|
|
||||||
};
|
},
|
||||||
mindplot.BubbleTip.prototype.click= function(event, el) {
|
click : function(event, el) {
|
||||||
return this.open(event, el);
|
return this.open(event, el);
|
||||||
};
|
},
|
||||||
mindplot.BubbleTip.prototype.open= function(event, content, source){
|
open : function(event, content, source) {
|
||||||
this._isMouseOver = true;
|
this._isMouseOver = true;
|
||||||
this._evt = new Event(event);
|
this._evt = new Event(event);
|
||||||
this.doOpen.delay(500, this, [content,source]);
|
this.doOpen.delay(500, this, [content,source]);
|
||||||
};
|
},
|
||||||
mindplot.BubbleTip.prototype.doOpen= function(content, source){
|
doOpen : function(content, source) {
|
||||||
if($chk(this._isMouseOver) &&!$chk(this._open) && !$chk(this._opening))
|
if ($chk(this._isMouseOver) && !$chk(this._open) && !$chk(this._opening)) {
|
||||||
{
|
|
||||||
this._opening = true;
|
this._opening = true;
|
||||||
var container = new Element('div');
|
var container = new Element('div');
|
||||||
$(content).inject(container);
|
$(content).inject(container);
|
||||||
@ -84,34 +84,36 @@ mindplot.BubbleTip.prototype.doOpen= function(content, source){
|
|||||||
this.options.container = container;
|
this.options.container = container;
|
||||||
$(this.options.container).inject(this.center);
|
$(this.options.container).inject(this.center);
|
||||||
this.init(this._evt, source);
|
this.init(this._evt, source);
|
||||||
$(this.options.panel).effect('opacity',{duration:500, onComplete:function(){this._open=true; this._opening = false;}.bind(this)}).start(0,100);
|
$(this.options.panel).effect('opacity', {duration:500, onComplete:function() {
|
||||||
|
this._open = true;
|
||||||
|
this._opening = false;
|
||||||
|
}.bind(this)}).start(0, 100);
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
mindplot.BubbleTip.prototype.updatePosition=function(event){
|
updatePosition : function(event) {
|
||||||
this._evt = new Event(event);
|
this._evt = new Event(event);
|
||||||
};
|
},
|
||||||
mindplot.BubbleTip.prototype.close=function(event){
|
close : function(event) {
|
||||||
this._isMouseOver = false;
|
this._isMouseOver = false;
|
||||||
this.doClose.delay(50, this, new Event(event));
|
this.doClose.delay(50, this, new Event(event));
|
||||||
};
|
},
|
||||||
mindplot.BubbleTip.prototype.doClose=function(event){
|
doClose : function(event) {
|
||||||
|
|
||||||
if (!$chk(this._isMouseOver) && $chk(this._opening))
|
if (!$chk(this._isMouseOver) && $chk(this._opening))
|
||||||
this.doClose.delay(500, this, this._evt);
|
this.doClose.delay(500, this, this._evt);
|
||||||
|
|
||||||
if(!$chk(this._isMouseOver) && $chk(this._open))
|
if (!$chk(this._isMouseOver) && $chk(this._open)) {
|
||||||
{
|
|
||||||
this.forceClose();
|
this.forceClose();
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
mindplot.BubbleTip.prototype.forceClose=function(){
|
forceClose : function() {
|
||||||
this.options.panel.effect('opacity', {duration:100, onComplete:function() {
|
this.options.panel.effect('opacity', {duration:100, onComplete:function() {
|
||||||
this._open = false;
|
this._open = false;
|
||||||
$(this.options.panel).setStyles({left:0,top:0});
|
$(this.options.panel).setStyles({left:0,top:0});
|
||||||
$(this.options.container).remove();
|
$(this.options.container).remove();
|
||||||
}.bind(this)}).start(100, 0);
|
}.bind(this)}).start(100, 0);
|
||||||
};
|
},
|
||||||
mindplot.BubbleTip.prototype.init=function(event,source){
|
init : function(event, source) {
|
||||||
var opts = this.options;
|
var opts = this.options;
|
||||||
var coordinates = $(opts.panel).getCoordinates();
|
var coordinates = $(opts.panel).getCoordinates();
|
||||||
var panelHeight = coordinates.height; //not total height, but close enough
|
var panelHeight = coordinates.height; //not total height, but close enough
|
||||||
@ -134,8 +136,8 @@ mindplot.BubbleTip.prototype.init=function(event,source){
|
|||||||
var height = $(this.center).getCoordinates().height;
|
var height = $(this.center).getCoordinates().height;
|
||||||
$(opts.panel).setStyles({width:width,height:height});
|
$(opts.panel).setStyles({width:width,height:height});
|
||||||
this.moveTopic(offset, $(opts.panel).getCoordinates().height, $(opts.panel).getCoordinates().width, invert, invertX);
|
this.moveTopic(offset, $(opts.panel).getCoordinates().height, $(opts.panel).getCoordinates().width, invert, invertX);
|
||||||
};
|
},
|
||||||
mindplot.BubbleTip.prototype.moveTopic=function(offset, panelHeight, panelWidth, invert, invertX){
|
moveTopic : function(offset, panelHeight, panelWidth, invert, invertX) {
|
||||||
var f = 1, fX = 1;
|
var f = 1, fX = 1;
|
||||||
if ($chk(invert))
|
if ($chk(invert))
|
||||||
f = 0;
|
f = 0;
|
||||||
@ -143,15 +145,15 @@ mindplot.BubbleTip.prototype.moveTopic=function(offset, panelHeight, panelWidth,
|
|||||||
fX = 0;
|
fX = 0;
|
||||||
var opts = this.options;
|
var opts = this.options;
|
||||||
$(opts.panel).setStyles({left:offset.x - (panelWidth * fX), top:offset.y - (panelHeight * f)});
|
$(opts.panel).setStyles({left:offset.x - (panelWidth * fX), top:offset.y - (panelHeight * f)});
|
||||||
};
|
}
|
||||||
|
|
||||||
mindplot.BubbleTip.getInstance = function(divContainer)
|
});
|
||||||
{
|
|
||||||
|
mindplot.BubbleTip.getInstance = function(divContainer) {
|
||||||
var result = mindplot.BubbleTip.instance;
|
var result = mindplot.BubbleTip.instance;
|
||||||
if(!core.Utils.isDefined(result))
|
if (!core.Utils.isDefined(result)) {
|
||||||
{
|
|
||||||
mindplot.BubbleTip.instance = new mindplot.BubbleTip(divContainer);
|
mindplot.BubbleTip.instance = new mindplot.BubbleTip(divContainer);
|
||||||
result = mindplot.BubbleTip.instance;
|
result = mindplot.BubbleTip.instance;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
}
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.ConnectionLine = function(sourceNode, targetNode, lineType)
|
mindplot.ConnectionLine = new Class({
|
||||||
{
|
initialize:function(sourceNode, targetNode, lineType) {
|
||||||
core.assert(targetNode, 'parentNode node can not be null');
|
core.assert(targetNode, 'parentNode node can not be null');
|
||||||
core.assert(sourceNode, 'childNode node can not be null');
|
core.assert(sourceNode, 'childNode node can not be null');
|
||||||
core.assert(sourceNode != targetNode, 'Cilcular connection');
|
core.assert(sourceNode != targetNode, 'Cilcular connection');
|
||||||
@ -27,8 +27,7 @@ mindplot.ConnectionLine = function(sourceNode, targetNode, lineType)
|
|||||||
|
|
||||||
var strokeColor = mindplot.ConnectionLine.getStrokeColor();
|
var strokeColor = mindplot.ConnectionLine.getStrokeColor();
|
||||||
var line;
|
var line;
|
||||||
if (targetNode.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE)
|
if (targetNode.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
{
|
|
||||||
line = this._createLine(lineType, mindplot.ConnectionLine.CURVED);
|
line = this._createLine(lineType, mindplot.ConnectionLine.CURVED);
|
||||||
// line = new web2d.Line();
|
// line = new web2d.Line();
|
||||||
if (line.getType() == "CurvedLine") {
|
if (line.getType() == "CurvedLine") {
|
||||||
@ -37,8 +36,7 @@ mindplot.ConnectionLine = function(sourceNode, targetNode, lineType)
|
|||||||
line.setDestControlPoint(ctrlPoints[1]);
|
line.setDestControlPoint(ctrlPoints[1]);
|
||||||
}
|
}
|
||||||
line.setStroke(1, 'solid', strokeColor);
|
line.setStroke(1, 'solid', strokeColor);
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
line = this._createLine(lineType, mindplot.ConnectionLine.SIMPLE_CURVED);
|
line = this._createLine(lineType, mindplot.ConnectionLine.SIMPLE_CURVED);
|
||||||
if (line.getType() == "CurvedLine") {
|
if (line.getType() == "CurvedLine") {
|
||||||
var ctrlPoints = this._getCtrlPoints(sourceNode, targetNode);
|
var ctrlPoints = this._getCtrlPoints(sourceNode, targetNode);
|
||||||
@ -50,16 +48,16 @@ mindplot.ConnectionLine = function(sourceNode, targetNode, lineType)
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._line2d = line;
|
this._line2d = line;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ConnectionLine.prototype._getCtrlPoints = function(sourceNode, targetNode){
|
_getCtrlPoints : function(sourceNode, targetNode) {
|
||||||
var srcPos = sourceNode.workoutOutgoingConnectionPoint(targetNode.getPosition());
|
var srcPos = sourceNode.workoutOutgoingConnectionPoint(targetNode.getPosition());
|
||||||
var destPos = targetNode.workoutIncomingConnectionPoint(sourceNode.getPosition());
|
var destPos = targetNode.workoutIncomingConnectionPoint(sourceNode.getPosition());
|
||||||
var deltaX = (srcPos.x - destPos.x) / 3;
|
var deltaX = (srcPos.x - destPos.x) / 3;
|
||||||
return [new core.Point(deltaX, 0), new core.Point(-deltaX, 0)];
|
return [new core.Point(deltaX, 0), new core.Point(-deltaX, 0)];
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ConnectionLine.prototype._createLine = function(lineType, defaultStyle){
|
_createLine : function(lineType, defaultStyle) {
|
||||||
if (!core.Utils.isDefined(lineType)) {
|
if (!core.Utils.isDefined(lineType)) {
|
||||||
lineType = defaultStyle;
|
lineType = defaultStyle;
|
||||||
}
|
}
|
||||||
@ -82,29 +80,21 @@ mindplot.ConnectionLine.prototype._createLine = function(lineType, defaultStyle)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return line;
|
return line;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ConnectionLine.getStrokeColor = function()
|
setVisibility : function(value) {
|
||||||
{
|
|
||||||
return '#495879';
|
|
||||||
};
|
|
||||||
|
|
||||||
mindplot.ConnectionLine.prototype.setVisibility = function(value)
|
|
||||||
{
|
|
||||||
this._line2d.setVisibility(value);
|
this._line2d.setVisibility(value);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ConnectionLine.prototype.isVisible = function()
|
isVisible : function() {
|
||||||
{
|
|
||||||
return this._line2d.isVisible();
|
return this._line2d.isVisible();
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ConnectionLine.prototype.setOpacity = function(opacity){
|
setOpacity : function(opacity) {
|
||||||
this._line2d.setOpacity(opacity);
|
this._line2d.setOpacity(opacity);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ConnectionLine.prototype.redraw = function()
|
redraw : function() {
|
||||||
{
|
|
||||||
var line2d = this._line2d;
|
var line2d = this._line2d;
|
||||||
var sourceTopic = this._sourceTopic;
|
var sourceTopic = this._sourceTopic;
|
||||||
var sourcePosition = sourceTopic.getPosition();
|
var sourcePosition = sourceTopic.getPosition();
|
||||||
@ -129,94 +119,88 @@ mindplot.ConnectionLine.prototype.redraw = function()
|
|||||||
// Add connector ...
|
// Add connector ...
|
||||||
this._positionateConnector(targetTopic);
|
this._positionateConnector(targetTopic);
|
||||||
|
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ConnectionLine.prototype._positionateConnector = function(targetTopic)
|
_positionateConnector : function(targetTopic) {
|
||||||
{
|
|
||||||
var targetPosition = targetTopic.getPosition();
|
var targetPosition = targetTopic.getPosition();
|
||||||
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.NodeModel.SHAPE_TYPE_LINE)
|
if (targetTopic.getShapeType() == mindplot.NodeModel.SHAPE_TYPE_LINE) {
|
||||||
{
|
|
||||||
y = targetTopicSize.height;
|
y = targetTopicSize.height;
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
y = targetTopicSize.height / 2;
|
y = targetTopicSize.height / 2;
|
||||||
}
|
}
|
||||||
y = y - offset;
|
y = y - offset;
|
||||||
|
|
||||||
var connector = targetTopic.getShrinkConnector();
|
var connector = targetTopic.getShrinkConnector();
|
||||||
if (Math.sign(targetPosition.x) > 0)
|
if (Math.sign(targetPosition.x) > 0) {
|
||||||
{
|
|
||||||
var x = targetTopicSize.width;
|
var x = targetTopicSize.width;
|
||||||
connector.setPosition(x, y);
|
connector.setPosition(x, y);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
var x = -mindplot.Topic.CONNECTOR_WIDTH;
|
var x = -mindplot.Topic.CONNECTOR_WIDTH;
|
||||||
connector.setPosition(x, y);
|
connector.setPosition(x, y);
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ConnectionLine.prototype.setStroke = function(color, style, opacity)
|
setStroke : function(color, style, opacity) {
|
||||||
{
|
|
||||||
var line2d = this._line2d;
|
var line2d = this._line2d;
|
||||||
this._line2d.setStroke(null, null, color, opacity);
|
this._line2d.setStroke(null, null, color, opacity);
|
||||||
};
|
},
|
||||||
|
|
||||||
|
addToWorkspace : function(workspace) {
|
||||||
mindplot.ConnectionLine.prototype.addToWorkspace = function(workspace)
|
|
||||||
{
|
|
||||||
workspace.appendChild(this._line2d);
|
workspace.appendChild(this._line2d);
|
||||||
this._line2d.moveToBack();
|
this._line2d.moveToBack();
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ConnectionLine.prototype.removeFromWorkspace = function(workspace)
|
removeFromWorkspace : function(workspace) {
|
||||||
{
|
|
||||||
workspace.removeChild(this._line2d);
|
workspace.removeChild(this._line2d);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ConnectionLine.prototype.getTargetTopic = function()
|
getTargetTopic : function() {
|
||||||
{
|
|
||||||
return this._targetTopic;
|
return this._targetTopic;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ConnectionLine.prototype.getSourceTopic = function()
|
getSourceTopic : function() {
|
||||||
{
|
|
||||||
return this._sourceTopic;
|
return this._sourceTopic;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ConnectionLine.prototype.getLineType = function(){
|
getLineType : function() {
|
||||||
return this._lineType;
|
return this._lineType;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ConnectionLine.prototype.getLine = function(){
|
getLine : function() {
|
||||||
return this._line2d;
|
return this._line2d;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ConnectionLine.prototype.getModel = function(){
|
getModel : function() {
|
||||||
return this._model;
|
return this._model;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ConnectionLine.prototype.setModel = function(model){
|
setModel : function(model) {
|
||||||
this._model = model;
|
this._model = model;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ConnectionLine.prototype.getType = function(){
|
getType : function() {
|
||||||
return "ConnectionLine";
|
return "ConnectionLine";
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ConnectionLine.prototype.getId = function(){
|
getId : function() {
|
||||||
return this._model.getId();
|
return this._model.getId();
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ConnectionLine.prototype.moveToBack = function(){
|
moveToBack : function() {
|
||||||
this._line2d.moveToBack();
|
this._line2d.moveToBack();
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ConnectionLine.prototype.moveToFront = function(){
|
moveToFront : function() {
|
||||||
this._line2d.moveToFront();
|
this._line2d.moveToFront();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mindplot.ConnectionLine.getStrokeColor = function() {
|
||||||
|
return '#495879';
|
||||||
};
|
};
|
||||||
|
|
||||||
mindplot.ConnectionLine.SIMPLE = 0;
|
mindplot.ConnectionLine.SIMPLE = 0;
|
||||||
|
@ -16,12 +16,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.ControlPoint = function()
|
mindplot.ControlPoint = new Class({
|
||||||
{
|
initialize:function() {
|
||||||
this._controlPointsController = [new web2d.Elipse({width:6, height:6, stroke:'1 solid #6589de',fillColor:'gray', visibility:false}),
|
this._controlPointsController = [new web2d.Elipse({width:6, height:6, stroke:'1 solid #6589de',fillColor:'gray', visibility:false}),
|
||||||
new web2d.Elipse({width:6, height:6, stroke:'1 solid #6589de',fillColor:'gray', visibility:false})];
|
new web2d.Elipse({width:6, height:6, stroke:'1 solid #6589de',fillColor:'gray', visibility:false})];
|
||||||
this._controlLines = [new web2d.Line({strokeColor:"#6589de", strokeWidth:1, opacity:0.3}),
|
this._controlLines = [new web2d.Line({strokeColor:"#6589de", strokeWidth:1, opacity:0.3}),
|
||||||
new web2d.Line({strokeColor:"#6589de", strokeWidth:1, opacity:0.3})];
|
new web2d.Line({strokeColor:"#6589de", strokeWidth:1, opacity:0.3})];
|
||||||
|
|
||||||
this._isBinded = false;
|
this._isBinded = false;
|
||||||
this._controlPointsController[0].addEventListener('mousedown', this._mouseDown.bindWithEvent(this, mindplot.ControlPoint.FROM));
|
this._controlPointsController[0].addEventListener('mousedown', this._mouseDown.bindWithEvent(this, mindplot.ControlPoint.FROM));
|
||||||
this._controlPointsController[0].addEventListener('click', this._mouseClick.bindWithEvent(this));
|
this._controlPointsController[0].addEventListener('click', this._mouseClick.bindWithEvent(this));
|
||||||
@ -29,13 +30,14 @@ mindplot.ControlPoint = function()
|
|||||||
this._controlPointsController[1].addEventListener('mousedown', this._mouseDown.bindWithEvent(this, mindplot.ControlPoint.TO));
|
this._controlPointsController[1].addEventListener('mousedown', this._mouseDown.bindWithEvent(this, mindplot.ControlPoint.TO));
|
||||||
this._controlPointsController[1].addEventListener('click', this._mouseClick.bindWithEvent(this));
|
this._controlPointsController[1].addEventListener('click', this._mouseClick.bindWithEvent(this));
|
||||||
this._controlPointsController[1].addEventListener('dblclick', this._mouseClick.bindWithEvent(this));
|
this._controlPointsController[1].addEventListener('dblclick', this._mouseClick.bindWithEvent(this));
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ControlPoint.prototype.setSide= function(side) {
|
|
||||||
|
setSide : function(side) {
|
||||||
this._side = side;
|
this._side = side;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ControlPoint.prototype.setLine= function(line) {
|
setLine : function(line) {
|
||||||
if (core.Utils.isDefined(this._line)) {
|
if (core.Utils.isDefined(this._line)) {
|
||||||
this._removeLine();
|
this._removeLine();
|
||||||
}
|
}
|
||||||
@ -47,14 +49,14 @@ mindplot.ControlPoint.prototype.setLine= function(line) {
|
|||||||
this._orignalCtrlPoint[1] = this._controls[1].clone();
|
this._orignalCtrlPoint[1] = this._controls[1].clone();
|
||||||
this._endPoint[0] = this._line.getLine().getFrom().clone();
|
this._endPoint[0] = this._line.getLine().getFrom().clone();
|
||||||
this._endPoint[1] = this._line.getLine().getTo().clone();
|
this._endPoint[1] = this._line.getLine().getTo().clone();
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ControlPoint.prototype.redraw = function(){
|
redraw : function() {
|
||||||
if (core.Utils.isDefined(this._line))
|
if (core.Utils.isDefined(this._line))
|
||||||
this._createControlPoint();
|
this._createControlPoint();
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ControlPoint.prototype._createControlPoint = function() {
|
_createControlPoint : function() {
|
||||||
this._controls = this._line.getLine().getControlPoints();
|
this._controls = this._line.getLine().getControlPoints();
|
||||||
var pos = this._line.getLine().getFrom();
|
var pos = this._line.getLine().getFrom();
|
||||||
this._controlPointsController[0].setPosition(this._controls[mindplot.ControlPoint.FROM].x + pos.x, this._controls[mindplot.ControlPoint.FROM].y + pos.y - 3);
|
this._controlPointsController[0].setPosition(this._controls[mindplot.ControlPoint.FROM].x + pos.x, this._controls[mindplot.ControlPoint.FROM].y + pos.y - 3);
|
||||||
@ -65,13 +67,13 @@ mindplot.ControlPoint.prototype._createControlPoint = function() {
|
|||||||
this._controlLines[1].setTo(this._controls[mindplot.ControlPoint.TO].x + pos.x + 3, this._controls[mindplot.ControlPoint.TO].y + pos.y);
|
this._controlLines[1].setTo(this._controls[mindplot.ControlPoint.TO].x + pos.x + 3, this._controls[mindplot.ControlPoint.TO].y + pos.y);
|
||||||
this._controlPointsController[1].setPosition(this._controls[mindplot.ControlPoint.TO].x + pos.x, this._controls[mindplot.ControlPoint.TO].y + pos.y - 3);
|
this._controlPointsController[1].setPosition(this._controls[mindplot.ControlPoint.TO].x + pos.x, this._controls[mindplot.ControlPoint.TO].y + pos.y - 3);
|
||||||
|
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ControlPoint.prototype._removeLine= function() {
|
_removeLine : function() {
|
||||||
|
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ControlPoint.prototype._mouseDown = function(event, point) {
|
_mouseDown : function(event, point) {
|
||||||
if (!this._isBinded) {
|
if (!this._isBinded) {
|
||||||
this._isBinded = true;
|
this._isBinded = true;
|
||||||
this._mouseMoveFunction = this._mouseMove.bindWithEvent(this, point);
|
this._mouseMoveFunction = this._mouseMove.bindWithEvent(this, point);
|
||||||
@ -82,9 +84,9 @@ mindplot.ControlPoint.prototype._mouseDown = function(event, point) {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stop();
|
event.stop();
|
||||||
return false;
|
return false;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ControlPoint.prototype._mouseMove = function(event, point) {
|
_mouseMove : function(event, point) {
|
||||||
var screen = this._workspace.getScreenManager();
|
var screen = this._workspace.getScreenManager();
|
||||||
var pos = screen.getWorkspaceMousePosition(event);
|
var pos = screen.getWorkspaceMousePosition(event);
|
||||||
var topic = null;
|
var topic = null;
|
||||||
@ -106,9 +108,9 @@ mindplot.ControlPoint.prototype._mouseMove = function(event, point) {
|
|||||||
/*event.preventDefault();
|
/*event.preventDefault();
|
||||||
event.stop();
|
event.stop();
|
||||||
return false;*/
|
return false;*/
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ControlPoint.prototype._mouseUp = function(event, point) {
|
_mouseUp : function(event, point) {
|
||||||
this._workspace.getScreenManager().removeEventListener('mousemove', this._mouseMoveFunction);
|
this._workspace.getScreenManager().removeEventListener('mousemove', this._mouseMoveFunction);
|
||||||
this._workspace.getScreenManager().removeEventListener('mouseup', this._mouseUpFunction);
|
this._workspace.getScreenManager().removeEventListener('mouseup', this._mouseUpFunction);
|
||||||
var command = new mindplot.commands.MoveControlPointCommand(this, point);
|
var command = new mindplot.commands.MoveControlPointCommand(this, point);
|
||||||
@ -117,15 +119,15 @@ mindplot.ControlPoint.prototype._mouseUp = function(event, point) {
|
|||||||
/*event.preventDefault();
|
/*event.preventDefault();
|
||||||
event.stop();
|
event.stop();
|
||||||
return false;*/
|
return false;*/
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ControlPoint.prototype._mouseClick = function(event){
|
_mouseClick : function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stop();
|
event.stop();
|
||||||
return false;
|
return false;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ControlPoint.prototype.setVisibility = function(visible){
|
setVisibility : function(visible) {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
this._controlLines[0].moveToFront();
|
this._controlLines[0].moveToFront();
|
||||||
this._controlLines[1].moveToFront();
|
this._controlLines[1].moveToFront();
|
||||||
@ -136,35 +138,36 @@ mindplot.ControlPoint.prototype.setVisibility = function(visible){
|
|||||||
this._controlPointsController[1].setVisibility(visible);
|
this._controlPointsController[1].setVisibility(visible);
|
||||||
this._controlLines[0].setVisibility(visible);
|
this._controlLines[0].setVisibility(visible);
|
||||||
this._controlLines[1].setVisibility(visible);
|
this._controlLines[1].setVisibility(visible);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ControlPoint.prototype.addToWorkspace = function(workspace){
|
addToWorkspace : function(workspace) {
|
||||||
this._workspace = workspace;
|
this._workspace = workspace;
|
||||||
workspace.appendChild(this._controlPointsController[0]);
|
workspace.appendChild(this._controlPointsController[0]);
|
||||||
workspace.appendChild(this._controlPointsController[1]);
|
workspace.appendChild(this._controlPointsController[1]);
|
||||||
workspace.appendChild(this._controlLines[0]);
|
workspace.appendChild(this._controlLines[0]);
|
||||||
workspace.appendChild(this._controlLines[1]);
|
workspace.appendChild(this._controlLines[1]);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ControlPoint.prototype.removeFromWorkspace = function(workspace){
|
removeFromWorkspace : function(workspace) {
|
||||||
this._workspace = null;
|
this._workspace = null;
|
||||||
workspace.removeChild(this._controlPointsController[0]);
|
workspace.removeChild(this._controlPointsController[0]);
|
||||||
workspace.removeChild(this._controlPointsController[1]);
|
workspace.removeChild(this._controlPointsController[1]);
|
||||||
workspace.removeChild(this._controlLines[0]);
|
workspace.removeChild(this._controlLines[0]);
|
||||||
workspace.removeChild(this._controlLines[1]);
|
workspace.removeChild(this._controlLines[1]);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ControlPoint.prototype.getControlPoint = function(index){
|
getControlPoint : function(index) {
|
||||||
return this._controls[index];
|
return this._controls[index];
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ControlPoint.prototype.getOriginalEndPoint = function(index){
|
getOriginalEndPoint : function(index) {
|
||||||
return this._endPoint[index];
|
return this._endPoint[index];
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.ControlPoint.prototype.getOriginalCtrlPoint = function(index){
|
getOriginalCtrlPoint : function(index) {
|
||||||
return this._orignalCtrlPoint[index];
|
return this._orignalCtrlPoint[index];
|
||||||
};
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mindplot.ControlPoint.FROM = 0;
|
mindplot.ControlPoint.FROM = 0;
|
||||||
mindplot.ControlPoint.TO = 1;
|
mindplot.ControlPoint.TO = 1;
|
||||||
|
@ -17,8 +17,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.DesignerActionRunner = new Class({
|
mindplot.DesignerActionRunner = new Class({
|
||||||
execute:function(command)
|
initialize: function(designer) {
|
||||||
{
|
this._designer = designer;
|
||||||
|
this._undoManager = new mindplot.DesignerUndoManager();
|
||||||
|
this._context = new mindplot.CommandContext(this._designer);
|
||||||
|
},
|
||||||
|
|
||||||
|
execute:function(command) {
|
||||||
core.assert(command, "command can not be null");
|
core.assert(command, "command can not be null");
|
||||||
// Execute action ...
|
// Execute action ...
|
||||||
command.execute(this._context);
|
command.execute(this._context);
|
||||||
@ -30,22 +35,16 @@ mindplot.DesignerActionRunner = new Class({
|
|||||||
var event = this._undoManager._buildEvent();
|
var event = this._undoManager._buildEvent();
|
||||||
this._designer._fireEvent("change", event);
|
this._designer._fireEvent("change", event);
|
||||||
},
|
},
|
||||||
initialize: function(designer)
|
|
||||||
{
|
undo: function() {
|
||||||
this._designer = designer;
|
|
||||||
this._undoManager = new mindplot.DesignerUndoManager();
|
|
||||||
this._context = new mindplot.CommandContext(this._designer);
|
|
||||||
},
|
|
||||||
undo: function()
|
|
||||||
{
|
|
||||||
this._undoManager.execUndo(this._context);
|
this._undoManager.execUndo(this._context);
|
||||||
|
|
||||||
// Fire event
|
// Fire event
|
||||||
var event = this._undoManager._buildEvent();
|
var event = this._undoManager._buildEvent();
|
||||||
this._designer._fireEvent("change", event);
|
this._designer._fireEvent("change", event);
|
||||||
},
|
},
|
||||||
redo: function()
|
|
||||||
{
|
redo: function() {
|
||||||
this._undoManager.execRedo(this._context);
|
this._undoManager.execRedo(this._context);
|
||||||
|
|
||||||
// Fire event
|
// Fire event
|
||||||
@ -53,33 +52,28 @@ mindplot.DesignerActionRunner = new Class({
|
|||||||
this._designer._fireEvent("change", event);
|
this._designer._fireEvent("change", event);
|
||||||
|
|
||||||
},
|
},
|
||||||
markAsChangeBase: function()
|
|
||||||
{
|
markAsChangeBase: function() {
|
||||||
return this._undoManager.markAsChangeBase();
|
return this._undoManager.markAsChangeBase();
|
||||||
},
|
},
|
||||||
hasBeenChanged: function()
|
hasBeenChanged: function() {
|
||||||
{
|
|
||||||
return this._undoManager.hasBeenChanged();
|
return this._undoManager.hasBeenChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mindplot.CommandContext = new Class({
|
mindplot.CommandContext = new Class({
|
||||||
initialize: function(designer)
|
initialize: function(designer) {
|
||||||
{
|
|
||||||
this._designer = designer;
|
this._designer = designer;
|
||||||
},
|
},
|
||||||
findTopics:function(topicsIds)
|
findTopics:function(topicsIds) {
|
||||||
{
|
|
||||||
var designerTopics = this._designer._topics;
|
var designerTopics = this._designer._topics;
|
||||||
if (!(topicsIds instanceof Array))
|
if (!(topicsIds instanceof Array)) {
|
||||||
{
|
|
||||||
topicsIds = [topicsIds];
|
topicsIds = [topicsIds];
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = designerTopics.filter(function(topic) {
|
var result = designerTopics.filter(function(topic) {
|
||||||
var found = false;
|
var found = false;
|
||||||
if (topic != null)
|
if (topic != null) {
|
||||||
{
|
|
||||||
var topicId = topic.getId();
|
var topicId = topic.getId();
|
||||||
found = topicsIds.contains(topicId);
|
found = topicsIds.contains(topicId);
|
||||||
}
|
}
|
||||||
@ -88,29 +82,24 @@ mindplot.CommandContext = new Class({
|
|||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
deleteTopic:function(topic)
|
deleteTopic:function(topic) {
|
||||||
{
|
|
||||||
this._designer._removeNode(topic);
|
this._designer._removeNode(topic);
|
||||||
},
|
},
|
||||||
createTopic:function(model, isVisible)
|
createTopic:function(model, isVisible) {
|
||||||
{
|
|
||||||
core.assert(model, "model can not be null");
|
core.assert(model, "model can not be null");
|
||||||
var topic = this._designer._nodeModelToNodeGraph(model, isVisible);
|
var topic = this._designer._nodeModelToNodeGraph(model, isVisible);
|
||||||
|
|
||||||
return topic;
|
return topic;
|
||||||
},
|
},
|
||||||
createModel:function()
|
createModel:function() {
|
||||||
{
|
|
||||||
var mindmap = this._designer.getMindmap();
|
var mindmap = this._designer.getMindmap();
|
||||||
var model = mindmap.createNode(mindplot.NodeModel.MAIN_TOPIC_TYPE);
|
var model = mindmap.createNode(mindplot.NodeModel.MAIN_TOPIC_TYPE);
|
||||||
return model;
|
return model;
|
||||||
},
|
},
|
||||||
connect:function(childTopic, parentTopic, isVisible)
|
connect:function(childTopic, parentTopic, isVisible) {
|
||||||
{
|
|
||||||
childTopic.connectTo(parentTopic, this._designer._workspace, isVisible);
|
childTopic.connectTo(parentTopic, this._designer._workspace, isVisible);
|
||||||
} ,
|
} ,
|
||||||
disconnect:function(topic)
|
disconnect:function(topic) {
|
||||||
{
|
|
||||||
topic.disconnect(this._designer._workspace);
|
topic.disconnect(this._designer._workspace);
|
||||||
},
|
},
|
||||||
createRelationship:function(model) {
|
createRelationship:function(model) {
|
||||||
@ -136,12 +125,10 @@ mindplot.CommandContext = new Class({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mindplot.DesignerActionRunner.setInstance = function(actionRunner)
|
mindplot.DesignerActionRunner.setInstance = function(actionRunner) {
|
||||||
{
|
|
||||||
mindplot.DesignerActionRunner._instance = actionRunner;
|
mindplot.DesignerActionRunner._instance = actionRunner;
|
||||||
};
|
};
|
||||||
|
|
||||||
mindplot.DesignerActionRunner.getInstance = function()
|
mindplot.DesignerActionRunner.getInstance = function() {
|
||||||
{
|
|
||||||
return mindplot.DesignerActionRunner._instance;
|
return mindplot.DesignerActionRunner._instance;
|
||||||
};
|
};
|
||||||
|
@ -17,76 +17,67 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.DesignerUndoManager = new Class({
|
mindplot.DesignerUndoManager = new Class({
|
||||||
initialize: function()
|
initialize: function() {
|
||||||
{
|
|
||||||
this._undoQueue = [];
|
this._undoQueue = [];
|
||||||
this._redoQueue = [];
|
this._redoQueue = [];
|
||||||
this._baseId = 0;
|
this._baseId = 0;
|
||||||
},
|
},
|
||||||
enqueue:function(command)
|
|
||||||
{
|
enqueue:function(command) {
|
||||||
core.assert(command, "Command can not be null");
|
core.assert(command, "Command can not be null");
|
||||||
var length = this._undoQueue.length;
|
var length = this._undoQueue.length;
|
||||||
if (command.discartDuplicated && length > 0)
|
if (command.discartDuplicated && length > 0) {
|
||||||
{
|
|
||||||
// Skip duplicated events ...
|
// Skip duplicated events ...
|
||||||
var lastItem = this._undoQueue[length - 1];
|
var lastItem = this._undoQueue[length - 1];
|
||||||
if (lastItem.discartDuplicated != command.discartDuplicated)
|
if (lastItem.discartDuplicated != command.discartDuplicated) {
|
||||||
{
|
|
||||||
this._undoQueue.push(command);
|
this._undoQueue.push(command);
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
this._undoQueue.push(command);
|
this._undoQueue.push(command);
|
||||||
}
|
}
|
||||||
this._redoQueue = [];
|
this._redoQueue = [];
|
||||||
},
|
},
|
||||||
execUndo: function(commandContext)
|
|
||||||
{
|
execUndo: function(commandContext) {
|
||||||
if (this._undoQueue.length > 0)
|
if (this._undoQueue.length > 0) {
|
||||||
{
|
|
||||||
var command = this._undoQueue.pop();
|
var command = this._undoQueue.pop();
|
||||||
this._redoQueue.push(command);
|
this._redoQueue.push(command);
|
||||||
|
|
||||||
command.undoExecute(commandContext);
|
command.undoExecute(commandContext);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
execRedo: function(commandContext)
|
|
||||||
{
|
execRedo: function(commandContext) {
|
||||||
if (this._redoQueue.length > 0)
|
if (this._redoQueue.length > 0) {
|
||||||
{
|
|
||||||
var command = this._redoQueue.pop();
|
var command = this._redoQueue.pop();
|
||||||
this._undoQueue.push(command);
|
this._undoQueue.push(command);
|
||||||
command.execute(commandContext);
|
command.execute(commandContext);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_buildEvent: function()
|
|
||||||
{
|
_buildEvent: function() {
|
||||||
return {undoSteps: this._undoQueue.length, redoSteps:this._redoQueue.length};
|
return {undoSteps: this._undoQueue.length, redoSteps:this._redoQueue.length};
|
||||||
},
|
},
|
||||||
markAsChangeBase: function()
|
|
||||||
{
|
markAsChangeBase: function() {
|
||||||
var undoLenght = this._undoQueue.length;
|
var undoLenght = this._undoQueue.length;
|
||||||
if (undoLenght > 0)
|
if (undoLenght > 0) {
|
||||||
{
|
|
||||||
var command = this._undoQueue[undoLenght - 1];
|
var command = this._undoQueue[undoLenght - 1];
|
||||||
this._baseId = command.getId();
|
this._baseId = command.getId();
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
this._baseId = 0;
|
this._baseId = 0;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hasBeenChanged: function()
|
|
||||||
{
|
hasBeenChanged: function() {
|
||||||
var result = true;
|
var result = true;
|
||||||
var undoLenght = this._undoQueue.length;
|
var undoLenght = this._undoQueue.length;
|
||||||
if (undoLenght == 0 && this._baseId == 0)
|
if (undoLenght == 0 && this._baseId == 0) {
|
||||||
{
|
|
||||||
result = false;
|
result = false;
|
||||||
} else if(undoLenght>0)
|
} else if (undoLenght > 0) {
|
||||||
{
|
|
||||||
var command = this._undoQueue[undoLenght - 1];
|
var command = this._undoQueue[undoLenght - 1];
|
||||||
result = (this._baseId != command.getId());
|
result = (this._baseId != command.getId());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}});
|
}
|
||||||
|
});
|
@ -20,7 +20,6 @@ mindplot.DragManager = function(workspace)
|
|||||||
{
|
{
|
||||||
this._workspace = workspace;
|
this._workspace = workspace;
|
||||||
this._listeners = {};
|
this._listeners = {};
|
||||||
var dragManager = this;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mindplot.DragManager.prototype.add = function(node)
|
mindplot.DragManager.prototype.add = function(node)
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.DragPivot = function()
|
mindplot.DragPivot = new Class({
|
||||||
{
|
initialize:function() {
|
||||||
this._position = new core.Point();
|
this._position = new core.Point();
|
||||||
this._size = mindplot.DragTopic.PIVOT_SIZE;
|
this._size = mindplot.DragTopic.PIVOT_SIZE;
|
||||||
this._line = null;
|
this._line = null;
|
||||||
@ -27,35 +27,31 @@ mindplot.DragPivot = function()
|
|||||||
this._dragPivot = this._buildRect();
|
this._dragPivot = this._buildRect();
|
||||||
this._connectRect = this._buildRect();
|
this._connectRect = this._buildRect();
|
||||||
this._targetTopic = null;
|
this._targetTopic = null;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.DragPivot.prototype.getTargetTopic = function()
|
getTargetTopic : function() {
|
||||||
{
|
|
||||||
return this._targetTopic;
|
return this._targetTopic;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.DragPivot.prototype._buildStraightLine = function()
|
_buildStraightLine : function() {
|
||||||
{
|
|
||||||
var line = new web2d.CurvedLine();
|
var line = new web2d.CurvedLine();
|
||||||
line.setStyle(web2d.CurvedLine.SIMPLE_LINE);
|
line.setStyle(web2d.CurvedLine.SIMPLE_LINE);
|
||||||
line.setStroke(1, 'solid', '#CC0033');
|
line.setStroke(1, 'solid', '#CC0033');
|
||||||
line.setOpacity(0.4);
|
line.setOpacity(0.4);
|
||||||
line.setVisibility(false);
|
line.setVisibility(false);
|
||||||
return line;
|
return line;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.DragPivot.prototype._buildCurvedLine = function()
|
_buildCurvedLine : function() {
|
||||||
{
|
|
||||||
var line = new web2d.CurvedLine();
|
var line = new web2d.CurvedLine();
|
||||||
line.setStyle(web2d.CurvedLine.SIMPLE_LINE);
|
line.setStyle(web2d.CurvedLine.SIMPLE_LINE);
|
||||||
line.setStroke(1, 'solid', '#CC0033');
|
line.setStroke(1, 'solid', '#CC0033');
|
||||||
line.setOpacity(0.4);
|
line.setOpacity(0.4);
|
||||||
line.setVisibility(false);
|
line.setVisibility(false);
|
||||||
return line;
|
return line;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.DragPivot.prototype._redraw = function(pivotPosition)
|
_redraw : function(pivotPosition) {
|
||||||
{
|
|
||||||
// Update line position.
|
// Update line position.
|
||||||
core.assert(this.getTargetTopic(), 'Illegal invocation. Target node can not be null');
|
core.assert(this.getTargetTopic(), 'Illegal invocation. Target node can not be null');
|
||||||
|
|
||||||
@ -64,8 +60,7 @@ mindplot.DragPivot.prototype._redraw = function(pivotPosition)
|
|||||||
|
|
||||||
// Pivot position has not changed. In this case, position change is not required.
|
// Pivot position has not changed. In this case, position change is not required.
|
||||||
var targetTopic = this.getTargetTopic();
|
var targetTopic = this.getTargetTopic();
|
||||||
if (currentPivotPosition.x != pivotPosition.x || currentPivotPosition.y != pivotPosition.y)
|
if (currentPivotPosition.x != pivotPosition.x || currentPivotPosition.y != pivotPosition.y) {
|
||||||
{
|
|
||||||
var position = this._position;
|
var position = this._position;
|
||||||
var fromPoint = targetTopic.workoutIncomingConnectionPoint(position);
|
var fromPoint = targetTopic.workoutIncomingConnectionPoint(position);
|
||||||
|
|
||||||
@ -83,8 +78,7 @@ mindplot.DragPivot.prototype._redraw = function(pivotPosition)
|
|||||||
pivotRect.setPosition(pivotPosition.x, pivotPosition.y);
|
pivotRect.setPosition(pivotPosition.x, pivotPosition.y);
|
||||||
|
|
||||||
// Display elements if it's required...
|
// Display elements if it's required...
|
||||||
if (!pivotRect.isVisible())
|
if (!pivotRect.isVisible()) {
|
||||||
{
|
|
||||||
// Make line visible only when the position has been already changed.
|
// Make line visible only when the position has been already changed.
|
||||||
// This solve several strange effects ;)
|
// This solve several strange effects ;)
|
||||||
var targetPoint = targetTopic.workoutIncomingConnectionPoint(pivotPoint);
|
var targetPoint = targetTopic.workoutIncomingConnectionPoint(pivotPoint);
|
||||||
@ -93,75 +87,64 @@ mindplot.DragPivot.prototype._redraw = function(pivotPosition)
|
|||||||
this.setVisibility(true);
|
this.setVisibility(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.DragPivot.prototype.setPosition = function(point)
|
setPosition : function(point) {
|
||||||
{
|
|
||||||
this._position = point;
|
this._position = point;
|
||||||
|
|
||||||
// Update visual position.
|
// Update visual position.
|
||||||
var pivotRect = this._getPivotRect();
|
|
||||||
var size = this.getSize();
|
var size = this.getSize();
|
||||||
|
|
||||||
var cx = point.x - (parseInt(size.width) / 2);
|
var cx = point.x - (parseInt(size.width) / 2);
|
||||||
var cy = point.y - (parseInt(size.height) / 2);
|
var cy = point.y - (parseInt(size.height) / 2);
|
||||||
|
|
||||||
// Update line ...
|
// Update line ...
|
||||||
if (this.getTargetTopic())
|
if (this.getTargetTopic()) {
|
||||||
{
|
|
||||||
var pivotPosition = {x:cx,y:cy};
|
var pivotPosition = {x:cx,y:cy};
|
||||||
this._redraw(pivotPosition);
|
this._redraw(pivotPosition);
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.DragPivot.prototype.getPosition = function()
|
getPosition : function() {
|
||||||
{
|
|
||||||
return this._position;
|
return this._position;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.DragPivot.prototype._buildRect = function()
|
_buildRect : function() {
|
||||||
{
|
|
||||||
var size = this._size;
|
var size = this._size;
|
||||||
var rectAttributes = {fillColor:'#CC0033',opacity:0.4,width:size.width,height:size.height,strokeColor:'#FF9933'};
|
var rectAttributes = {fillColor:'#CC0033',opacity:0.4,width:size.width,height:size.height,strokeColor:'#FF9933'};
|
||||||
var rect = new web2d.Rect(0, rectAttributes);
|
var rect = new web2d.Rect(0, rectAttributes);
|
||||||
rect.setVisibility(false);
|
rect.setVisibility(false);
|
||||||
return rect;
|
return rect;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.DragPivot.prototype._buildConnectRect = function()
|
_buildConnectRect : function() {
|
||||||
{
|
|
||||||
var size = this._size;
|
var size = this._size;
|
||||||
var rectAttributes = {fillColor:'#CC0033',opacity:0.4,width:size.width,height:size.height,strokeColor:'#FF9933'};
|
var rectAttributes = {fillColor:'#CC0033',opacity:0.4,width:size.width,height:size.height,strokeColor:'#FF9933'};
|
||||||
var result = new web2d.Rect(0, rectAttributes);
|
var result = new web2d.Rect(0, rectAttributes);
|
||||||
return result;
|
return result;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.DragPivot.prototype._getPivotRect = function()
|
_getPivotRect : function() {
|
||||||
{
|
|
||||||
return this._dragPivot;
|
return this._dragPivot;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.DragPivot.prototype.getSize = function()
|
getSize : function() {
|
||||||
{
|
|
||||||
var elem2d = this._getPivotRect();
|
var elem2d = this._getPivotRect();
|
||||||
return elem2d.getSize();
|
return elem2d.getSize();
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.DragPivot.prototype.setVisibility = function(value)
|
setVisibility : function(value) {
|
||||||
{
|
|
||||||
var pivotRect = this._getPivotRect();
|
var pivotRect = this._getPivotRect();
|
||||||
pivotRect.setVisibility(value);
|
pivotRect.setVisibility(value);
|
||||||
|
|
||||||
var connectRect = this._connectRect;
|
var connectRect = this._connectRect;
|
||||||
connectRect.setVisibility(value);
|
connectRect.setVisibility(value);
|
||||||
if (core.Utils.isDefined(this._line))
|
if (core.Utils.isDefined(this._line)) {
|
||||||
{
|
|
||||||
this._line.setVisibility(value);
|
this._line.setVisibility(value);
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.DragPivot.prototype.addToWorkspace = function(workspace)
|
addToWorkspace : function(workspace) {
|
||||||
{
|
|
||||||
var pivotRect = this._getPivotRect();
|
var pivotRect = this._getPivotRect();
|
||||||
workspace.appendChild(pivotRect);
|
workspace.appendChild(pivotRect);
|
||||||
|
|
||||||
@ -185,45 +168,36 @@ mindplot.DragPivot.prototype.addToWorkspace = function(workspace)
|
|||||||
connectRect.setVisibility(false);
|
connectRect.setVisibility(false);
|
||||||
workspace.appendChild(connectRect);
|
workspace.appendChild(connectRect);
|
||||||
connectRect.moveToBack();
|
connectRect.moveToBack();
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.DragPivot.prototype.removeFromWorkspace = function(workspace)
|
removeFromWorkspace : function(workspace) {
|
||||||
{
|
|
||||||
var shape = this._getPivotRect();
|
var shape = this._getPivotRect();
|
||||||
workspace.removeChild(shape);
|
workspace.removeChild(shape);
|
||||||
|
|
||||||
var connectToRect = this._connectRect;
|
var connectToRect = this._connectRect;
|
||||||
workspace.removeChild(connectToRect);
|
workspace.removeChild(connectToRect);
|
||||||
|
|
||||||
if (core.Utils.isDefined(this._straightLine))
|
if (core.Utils.isDefined(this._straightLine)) {
|
||||||
{
|
|
||||||
workspace.removeChild(this._straightLine);
|
workspace.removeChild(this._straightLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (core.Utils.isDefined(this._curvedLine))
|
if (core.Utils.isDefined(this._curvedLine)) {
|
||||||
{
|
|
||||||
workspace.removeChild(this._curvedLine);
|
workspace.removeChild(this._curvedLine);
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.DragPivot.prototype.connectTo = function(targetTopic)
|
connectTo : function(targetTopic) {
|
||||||
{
|
|
||||||
core.assert(!this._outgoingLine, 'Could not connect an already connected node');
|
core.assert(!this._outgoingLine, 'Could not connect an already connected node');
|
||||||
core.assert(targetTopic != this, 'Cilcular connection are not allowed');
|
core.assert(targetTopic != this, 'Cilcular connection are not allowed');
|
||||||
core.assert(targetTopic, 'parent can not be null');
|
core.assert(targetTopic, 'parent can not be null');
|
||||||
|
|
||||||
this._targetTopic = targetTopic;
|
this._targetTopic = targetTopic;
|
||||||
if (targetTopic.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE)
|
if (targetTopic.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
{
|
|
||||||
this._line = this._straightLine;
|
this._line = this._straightLine;
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
this._line = this._curvedLine;
|
this._line = this._curvedLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show pivot ...
|
|
||||||
var line = this._line;
|
|
||||||
|
|
||||||
// Connected to Rect ...
|
// Connected to Rect ...
|
||||||
var connectRect = this._connectRect;
|
var connectRect = this._connectRect;
|
||||||
var targetSize = targetTopic.getSize();
|
var targetSize = targetTopic.getSize();
|
||||||
@ -240,14 +214,14 @@ mindplot.DragPivot.prototype.connectTo = function(targetTopic)
|
|||||||
var pivotRect = this._getPivotRect();
|
var pivotRect = this._getPivotRect();
|
||||||
pivotRect.moveToFront();
|
pivotRect.moveToFront();
|
||||||
|
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.DragPivot.prototype.disconnect = function(workspace)
|
disconnect : function(workspace) {
|
||||||
{
|
|
||||||
core.assert(workspace, 'workspace can not be null.');
|
core.assert(workspace, 'workspace can not be null.');
|
||||||
core.assert(this._targetTopic, 'There are not connected topic.');
|
core.assert(this._targetTopic, 'There are not connected topic.');
|
||||||
|
|
||||||
this.setVisibility(false);
|
this.setVisibility(false);
|
||||||
this._targetTopic = null;
|
this._targetTopic = null;
|
||||||
this._line = null;
|
this._line = null;
|
||||||
};
|
}
|
||||||
|
});
|
||||||
|
@ -16,16 +16,15 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.DragTopicPositioner = function(layoutManager)
|
mindplot.DragTopicPositioner = new Class({
|
||||||
{
|
initialize:function(layoutManager) {
|
||||||
core.assert(layoutManager, 'layoutManager can not be null');
|
core.assert(layoutManager, 'layoutManager can not be null');
|
||||||
this._layoutManager = layoutManager;
|
this._layoutManager = layoutManager;
|
||||||
this._topics = layoutManager.getDesigner()._getTopics();
|
this._topics = layoutManager.getDesigner()._getTopics();
|
||||||
this._workspace = layoutManager.getDesigner().getWorkSpace();
|
this._workspace = layoutManager.getDesigner().getWorkSpace();
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.DragTopicPositioner.prototype.positionateDragTopic = function(dragTopic)
|
positionateDragTopic : function(dragTopic) {
|
||||||
{
|
|
||||||
// Workout the real position of the element on the board.
|
// Workout the real position of the element on the board.
|
||||||
var dragTopicPosition = dragTopic.getPosition();
|
var dragTopicPosition = dragTopic.getPosition();
|
||||||
var draggedTopic = dragTopic.getDraggedTopic();
|
var draggedTopic = dragTopic.getDraggedTopic();
|
||||||
@ -34,67 +33,53 @@ mindplot.DragTopicPositioner.prototype.positionateDragTopic = function(dragTopic
|
|||||||
this._checkDragTopicConnection(dragTopic);
|
this._checkDragTopicConnection(dragTopic);
|
||||||
|
|
||||||
// Position topic in the board
|
// Position topic in the board
|
||||||
if (dragTopic.isConnected())
|
if (dragTopic.isConnected()) {
|
||||||
{
|
|
||||||
var targetTopic = dragTopic.getConnectedToTopic();
|
var targetTopic = dragTopic.getConnectedToTopic();
|
||||||
var topicBoard = this._layoutManager.getTopicBoardForTopic(targetTopic);
|
var topicBoard = this._layoutManager.getTopicBoardForTopic(targetTopic);
|
||||||
topicBoard.positionateDragTopic(dragTopic);
|
topicBoard.positionateDragTopic(dragTopic);
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE = 400;
|
_checkDragTopicConnection : function(dragTopic) {
|
||||||
|
|
||||||
mindplot.DragTopicPositioner.prototype._checkDragTopicConnection = function(dragTopic)
|
|
||||||
{
|
|
||||||
var topics = this._topics;
|
var topics = this._topics;
|
||||||
|
|
||||||
// Must be disconnected from their current connection ?.
|
// Must be disconnected from their current connection ?.
|
||||||
var mainTopicToMainTopicConnection = this._lookUpForMainTopicToMainTopicConnection(dragTopic);
|
var mainTopicToMainTopicConnection = this._lookUpForMainTopicToMainTopicConnection(dragTopic);
|
||||||
var currentConnection = dragTopic.getConnectedToTopic();
|
var currentConnection = dragTopic.getConnectedToTopic();
|
||||||
if (core.Utils.isDefined(currentConnection))
|
if (core.Utils.isDefined(currentConnection)) {
|
||||||
{
|
|
||||||
// MainTopic->MainTopicConnection.
|
// MainTopic->MainTopicConnection.
|
||||||
if (currentConnection.getType()==mindplot.NodeModel.MAIN_TOPIC_TYPE)
|
if (currentConnection.getType() == mindplot.NodeModel.MAIN_TOPIC_TYPE) {
|
||||||
{
|
if (mainTopicToMainTopicConnection != currentConnection) {
|
||||||
if(mainTopicToMainTopicConnection != currentConnection)
|
|
||||||
{
|
|
||||||
dragTopic.disconnect(this._workspace);
|
dragTopic.disconnect(this._workspace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (currentConnection.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE)
|
else if (currentConnection.getType() == mindplot.NodeModel.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;
|
||||||
|
|
||||||
if(core.Utils.isDefined(mainTopicToMainTopicConnection))
|
if (core.Utils.isDefined(mainTopicToMainTopicConnection)) {
|
||||||
{
|
|
||||||
// I have to change the current connection to a main topic.
|
// I have to change the current connection to a main topic.
|
||||||
dragTopic.disconnect(this._workspace);
|
dragTopic.disconnect(this._workspace);
|
||||||
} else
|
} else
|
||||||
if (Math.abs(dragXPosition-currentXPosition) > mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE)
|
if (Math.abs(dragXPosition - currentXPosition) > mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE) {
|
||||||
{
|
|
||||||
dragTopic.disconnect(this._workspace);
|
dragTopic.disconnect(this._workspace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, connect nodes ...
|
// Finally, connect nodes ...
|
||||||
if (!dragTopic.isConnected())
|
if (!dragTopic.isConnected()) {
|
||||||
{
|
|
||||||
var centalTopic = topics[0];
|
var centalTopic = topics[0];
|
||||||
if (core.Utils.isDefined(mainTopicToMainTopicConnection))
|
if (core.Utils.isDefined(mainTopicToMainTopicConnection)) {
|
||||||
{
|
|
||||||
dragTopic.connectTo(mainTopicToMainTopicConnection);
|
dragTopic.connectTo(mainTopicToMainTopicConnection);
|
||||||
} else if (Math.abs(dragTopic.getPosition().x - centalTopic.getPosition().x) <= mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE)
|
} else if (Math.abs(dragTopic.getPosition().x - centalTopic.getPosition().x) <= mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE) {
|
||||||
{
|
|
||||||
dragTopic.connectTo(centalTopic);
|
dragTopic.connectTo(centalTopic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.DragTopicPositioner.prototype._lookUpForMainTopicToMainTopicConnection = function(dragTopic)
|
_lookUpForMainTopicToMainTopicConnection : function(dragTopic) {
|
||||||
{
|
|
||||||
var topics = this._topics;
|
var topics = this._topics;
|
||||||
var result = null;
|
var result = null;
|
||||||
var clouserDistance = -1;
|
var clouserDistance = -1;
|
||||||
@ -102,15 +87,12 @@ mindplot.DragTopicPositioner.prototype._lookUpForMainTopicToMainTopicConnection
|
|||||||
var distance = null;
|
var distance = null;
|
||||||
|
|
||||||
// Check MainTopic->MainTopic connection...
|
// Check MainTopic->MainTopic connection...
|
||||||
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.NodeModel.CENTRAL_TOPIC_TYPE && targetTopic != draggedNode)
|
if (targetTopic.getType() != mindplot.NodeModel.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();
|
||||||
var fix = position.y > targetPosition.y;
|
var fix = position.y > targetPosition.y;
|
||||||
var gap = 0;
|
var gap = 0;
|
||||||
@ -118,8 +100,7 @@ mindplot.DragTopicPositioner.prototype._lookUpForMainTopicToMainTopicConnection
|
|||||||
gap = Math.abs(targetPosition.y - targetTopic._getChildren()[0].getPosition().y)
|
gap = Math.abs(targetPosition.y - targetTopic._getChildren()[0].getPosition().y)
|
||||||
}
|
}
|
||||||
var yDistance = Math.abs(position.y - fix * gap - targetPosition.y);
|
var yDistance = Math.abs(position.y - fix * gap - targetPosition.y);
|
||||||
if(distance==null || yDistance<distance)
|
if (distance == null || yDistance < distance) {
|
||||||
{
|
|
||||||
result = targetTopic;
|
result = targetTopic;
|
||||||
distance = yDistance;
|
distance = yDistance;
|
||||||
}
|
}
|
||||||
@ -128,4 +109,7 @@ mindplot.DragTopicPositioner.prototype._lookUpForMainTopicToMainTopicConnection
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE = 400;
|
||||||
|
@ -4,5 +4,4 @@ mindplot.EditorOptions =
|
|||||||
// LayoutManager:"FreeMindLayout",
|
// LayoutManager:"FreeMindLayout",
|
||||||
textEditor:"TextEditor"
|
textEditor:"TextEditor"
|
||||||
// textEditor:"RichTextEditor"
|
// textEditor:"RichTextEditor"
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -16,26 +16,24 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.EditorProperties = function()
|
mindplot.EditorProperties = new Class({
|
||||||
{
|
initialize:function() {
|
||||||
this._zoom = 0;
|
this._zoom = 0;
|
||||||
this._position = 0;
|
this._position = 0;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.EditorProperties.prototype.setZoom = function(zoom)
|
setZoom : function(zoom) {
|
||||||
{
|
|
||||||
this._zoom = zoom;
|
this._zoom = zoom;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.EditorProperties.prototype.getZoom = function()
|
getZoom : function() {
|
||||||
{
|
|
||||||
return this._zoom;
|
return this._zoom;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.EditorProperties.prototype.asProperties = function()
|
asProperties : function() {
|
||||||
{
|
|
||||||
return "zoom=" + this._zoom + "\n";
|
return "zoom=" + this._zoom + "\n";
|
||||||
};
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
mindplot.EventBus = new Class({
|
mindplot.EventBus = new Class({
|
||||||
|
Extends:Options,
|
||||||
|
Implements:Events,
|
||||||
options: {
|
options: {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
this.setOptions(options);
|
this.setOptions(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
mindplot.EventBus.implement(new Events);
|
|
||||||
mindplot.EventBus.implement(new Options);
|
|
||||||
|
|
||||||
mindplot.EventBus.events = {
|
mindplot.EventBus.events = {
|
||||||
NodeResizeEvent:'NodeResizeEvent',
|
NodeResizeEvent:'NodeResizeEvent',
|
||||||
|
@ -16,42 +16,35 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.FixedDistanceBoard = function(defaultHeight, topic, layoutManager)
|
mindplot.FixedDistanceBoard = new Class({
|
||||||
{
|
Extends:mindplot.Board,
|
||||||
|
initialize:function(defaultHeight, topic, layoutManager) {
|
||||||
this._topic = topic;
|
this._topic = topic;
|
||||||
this._layoutManager = layoutManager;
|
this._layoutManager = layoutManager;
|
||||||
var reference = topic.getPosition();
|
var reference = topic.getPosition();
|
||||||
mindplot.FixedDistanceBoard.superClass.initialize.call(this, defaultHeight, reference);
|
this.parent(defaultHeight, reference);
|
||||||
this._height = defaultHeight;
|
this._height = defaultHeight;
|
||||||
this._entries = [];
|
this._entries = [];
|
||||||
};
|
},
|
||||||
|
|
||||||
objects.extend(mindplot.FixedDistanceBoard, mindplot.Board);
|
getHeight : function() {
|
||||||
|
|
||||||
mindplot.FixedDistanceBoard.prototype.getHeight = function()
|
|
||||||
{
|
|
||||||
return this._height;
|
return this._height;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.FixedDistanceBoard.prototype.lookupEntryByOrder = function(order)
|
lookupEntryByOrder : function(order) {
|
||||||
{
|
|
||||||
var result = null;
|
var result = null;
|
||||||
var entries = this._entries;
|
var entries = this._entries;
|
||||||
if (order < entries.length)
|
if (order < entries.length) {
|
||||||
{
|
|
||||||
result = entries[order];
|
result = entries[order];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == null)
|
if (result == null) {
|
||||||
{
|
|
||||||
var defaultHeight = this._defaultWidth;
|
var defaultHeight = this._defaultWidth;
|
||||||
var reference = this.getReferencePoint();
|
var reference = this.getReferencePoint();
|
||||||
if (entries.length == 0)
|
if (entries.length == 0) {
|
||||||
{
|
|
||||||
var yReference = reference.y;
|
var yReference = reference.y;
|
||||||
result = this.createBoardEntry(yReference - (defaultHeight / 2), yReference + (defaultHeight / 2), 0);
|
result = this.createBoardEntry(yReference - (defaultHeight / 2), yReference + (defaultHeight / 2), 0);
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
var entriesLenght = entries.length;
|
var entriesLenght = entries.length;
|
||||||
var lastEntry = entries[entriesLenght - 1];
|
var lastEntry = entries[entriesLenght - 1];
|
||||||
var lowerLimit = lastEntry.getUpperLimit();
|
var lowerLimit = lastEntry.getUpperLimit();
|
||||||
@ -60,26 +53,23 @@ mindplot.FixedDistanceBoard.prototype.lookupEntryByOrder = function(order)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.FixedDistanceBoard.prototype.createBoardEntry = function(lowerLimit, upperLimit, order)
|
createBoardEntry : function(lowerLimit, upperLimit, order) {
|
||||||
{
|
|
||||||
var result = new mindplot.BoardEntry(lowerLimit, upperLimit, order);
|
var result = new mindplot.BoardEntry(lowerLimit, upperLimit, order);
|
||||||
var xPos = this.workoutXBorderDistance();
|
var xPos = this.workoutXBorderDistance();
|
||||||
result.setXPosition(xPos);
|
result.setXPosition(xPos);
|
||||||
return result;
|
return result;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.FixedDistanceBoard.prototype.updateReferencePoint = function()
|
updateReferencePoint : function() {
|
||||||
{
|
|
||||||
var entries = this._entries;
|
var entries = this._entries;
|
||||||
var parentTopic = this.getTopic();
|
var parentTopic = this.getTopic();
|
||||||
var parentPosition = parentTopic.workoutIncomingConnectionPoint(parentTopic.getPosition());
|
var parentPosition = parentTopic.workoutIncomingConnectionPoint(parentTopic.getPosition());
|
||||||
var referencePoint = this.getReferencePoint();
|
var referencePoint = this.getReferencePoint();
|
||||||
var yOffset = parentPosition.y - referencePoint.y;
|
var yOffset = parentPosition.y - referencePoint.y;
|
||||||
|
|
||||||
for (var i = 0; i < entries.length; i++)
|
for (var i = 0; i < entries.length; i++) {
|
||||||
{
|
|
||||||
var entry = entries[i];
|
var entry = entries[i];
|
||||||
|
|
||||||
if (core.Utils.isDefined(entry)) {
|
if (core.Utils.isDefined(entry)) {
|
||||||
@ -96,71 +86,55 @@ mindplot.FixedDistanceBoard.prototype.updateReferencePoint = function()
|
|||||||
}
|
}
|
||||||
this._referencePoint = parentPosition.clone();
|
this._referencePoint = parentPosition.clone();
|
||||||
|
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE = 60;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This x distance doesn't take into account the size of the shape.
|
* This x distance doesn't take into account the size of the shape.
|
||||||
*/
|
*/
|
||||||
mindplot.FixedDistanceBoard.prototype.workoutXBorderDistance = function()
|
workoutXBorderDistance : function() {
|
||||||
{
|
|
||||||
var topic = this.getTopic();
|
var topic = this.getTopic();
|
||||||
|
|
||||||
var topicPosition = topic.getPosition();
|
var topicPosition = topic.getPosition();
|
||||||
var topicSize = topic.getSize();
|
var topicSize = topic.getSize();
|
||||||
var halfTargetWidth = topicSize.width / 2;
|
var halfTargetWidth = topicSize.width / 2;
|
||||||
var result;
|
var result;
|
||||||
if (topicPosition.x >= 0)
|
if (topicPosition.x >= 0) {
|
||||||
{
|
|
||||||
// It's at right.
|
// It's at right.
|
||||||
result = topicPosition.x + halfTargetWidth + mindplot.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE;
|
result = topicPosition.x + halfTargetWidth + mindplot.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE;
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
result = topicPosition.x - (halfTargetWidth + mindplot.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE);
|
result = topicPosition.x - (halfTargetWidth + mindplot.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.FixedDistanceBoard.prototype.getTopic = function()
|
getTopic : function() {
|
||||||
{
|
|
||||||
return this._topic;
|
return this._topic;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.FixedDistanceBoard.INTER_TOPIC_DISTANCE = 6;
|
freeEntry : function(entry) {
|
||||||
|
|
||||||
mindplot.FixedDistanceBoard.prototype.freeEntry = function(entry)
|
|
||||||
{
|
|
||||||
var newEntries = [];
|
var newEntries = [];
|
||||||
var entries = this._entries;
|
var entries = this._entries;
|
||||||
var order = 0;
|
var order = 0;
|
||||||
for (var i = 0; i < entries.length; i++)
|
for (var i = 0; i < entries.length; i++) {
|
||||||
{
|
|
||||||
var e = entries[i];
|
var e = entries[i];
|
||||||
if (e == entry)
|
if (e == entry) {
|
||||||
{
|
|
||||||
order++;
|
order++;
|
||||||
}
|
}
|
||||||
newEntries[order] = e;
|
newEntries[order] = e;
|
||||||
order++;
|
order++;
|
||||||
}
|
}
|
||||||
this._entries = newEntries;
|
this._entries = newEntries;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.FixedDistanceBoard.prototype.repositionate = function()
|
repositionate : function() {
|
||||||
{
|
|
||||||
// Workout width and update topic height.
|
// Workout width and update topic height.
|
||||||
var entries = this._entries;
|
var entries = this._entries;
|
||||||
var height = 0;
|
var height = 0;
|
||||||
var model = this._topic.getModel();
|
var model = this._topic.getModel();
|
||||||
if (entries.length >= 1 && !model.areChildrenShrinked())
|
if (entries.length >= 1 && !model.areChildrenShrinked()) {
|
||||||
{
|
for (var i = 0; i < entries.length; i++) {
|
||||||
for (var i = 0; i < entries.length; i++)
|
|
||||||
{
|
|
||||||
var e = entries[i];
|
var e = entries[i];
|
||||||
if (e && e.getTopic())
|
if (e && e.getTopic()) {
|
||||||
{
|
|
||||||
var topic = e.getTopic();
|
var topic = e.getTopic();
|
||||||
var topicBoard = this._layoutManager.getTopicBoardForTopic(topic);
|
var topicBoard = this._layoutManager.getTopicBoardForTopic(topic);
|
||||||
var topicBoardHeight = topicBoard.getHeight();
|
var topicBoardHeight = topicBoard.getHeight();
|
||||||
@ -179,12 +153,10 @@ mindplot.FixedDistanceBoard.prototype.repositionate = function()
|
|||||||
this._height = height;
|
this._height = height;
|
||||||
|
|
||||||
// I must update all the parent nodes first...
|
// I must update all the parent nodes first...
|
||||||
if (oldHeight != this._height)
|
if (oldHeight != this._height) {
|
||||||
{
|
|
||||||
var topic = this._topic;
|
var topic = this._topic;
|
||||||
var parentTopic = topic.getParent();
|
var parentTopic = topic.getParent();
|
||||||
if (parentTopic != null)
|
if (parentTopic != null) {
|
||||||
{
|
|
||||||
var board = this._layoutManager.getTopicBoardForTopic(parentTopic);
|
var board = this._layoutManager.getTopicBoardForTopic(parentTopic);
|
||||||
board.repositionate();
|
board.repositionate();
|
||||||
}
|
}
|
||||||
@ -197,8 +169,7 @@ mindplot.FixedDistanceBoard.prototype.repositionate = function()
|
|||||||
// Workout center the new topic center...
|
// Workout center the new topic center...
|
||||||
var refence = this.getReferencePoint();
|
var refence = this.getReferencePoint();
|
||||||
var lowerLimit;
|
var lowerLimit;
|
||||||
if (entries.length > 0)
|
if (entries.length > 0) {
|
||||||
{
|
|
||||||
var l = 0;
|
var l = 0;
|
||||||
for (l = 0; l < entries.length; l++) {
|
for (l = 0; l < entries.length; l++) {
|
||||||
if (core.Utils.isDefined(entries[l]))
|
if (core.Utils.isDefined(entries[l]))
|
||||||
@ -214,11 +185,9 @@ mindplot.FixedDistanceBoard.prototype.repositionate = function()
|
|||||||
// Start moving all the elements ...
|
// Start moving all the elements ...
|
||||||
var newEntries = [];
|
var newEntries = [];
|
||||||
var order = 0;
|
var order = 0;
|
||||||
for (var i = 0; i < entries.length; i++)
|
for (var i = 0; i < entries.length; i++) {
|
||||||
{
|
|
||||||
var e = entries[i];
|
var e = entries[i];
|
||||||
if (e && e.getTopic())
|
if (e && e.getTopic()) {
|
||||||
{
|
|
||||||
|
|
||||||
var currentTopic = e.getTopic();
|
var currentTopic = e.getTopic();
|
||||||
e.setLowerLimit(lowerLimit);
|
e.setLowerLimit(lowerLimit);
|
||||||
@ -240,10 +209,9 @@ mindplot.FixedDistanceBoard.prototype.repositionate = function()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._entries = newEntries;
|
this._entries = newEntries;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.FixedDistanceBoard.prototype.removeTopic = function(topic)
|
removeTopic : function(topic) {
|
||||||
{
|
|
||||||
var order = topic.getOrder();
|
var order = topic.getOrder();
|
||||||
var entry = this.lookupEntryByOrder(order);
|
var entry = this.lookupEntryByOrder(order);
|
||||||
core.assert(!entry.isAvailable(), "Illegal state");
|
core.assert(!entry.isAvailable(), "Illegal state");
|
||||||
@ -254,15 +222,13 @@ mindplot.FixedDistanceBoard.prototype.removeTopic = function(topic)
|
|||||||
|
|
||||||
// Repositionate all elements ...
|
// Repositionate all elements ...
|
||||||
this.repositionate();
|
this.repositionate();
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.FixedDistanceBoard.prototype.addTopic = function(order, topic)
|
addTopic : function(order, topic) {
|
||||||
{
|
|
||||||
|
|
||||||
// If the entry is not available, I must swap the the entries...
|
// If the entry is not available, I must swap the the entries...
|
||||||
var entry = this.lookupEntryByOrder(order);
|
var entry = this.lookupEntryByOrder(order);
|
||||||
if (!entry.isAvailable())
|
if (!entry.isAvailable()) {
|
||||||
{
|
|
||||||
this.freeEntry(entry);
|
this.freeEntry(entry);
|
||||||
// Create a dummy entry ...
|
// Create a dummy entry ...
|
||||||
// Puaj, do something with this...
|
// Puaj, do something with this...
|
||||||
@ -276,41 +242,33 @@ mindplot.FixedDistanceBoard.prototype.addTopic = function(order, topic)
|
|||||||
|
|
||||||
// Repositionate all elements ...
|
// Repositionate all elements ...
|
||||||
this.repositionate();
|
this.repositionate();
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.FixedDistanceBoard.prototype.lookupEntryByPosition = function(pos)
|
lookupEntryByPosition : function(pos) {
|
||||||
{
|
|
||||||
core.assert(core.Utils.isDefined(pos), 'position can not be null');
|
core.assert(core.Utils.isDefined(pos), 'position can not be null');
|
||||||
|
|
||||||
var entries = this._entries;
|
var entries = this._entries;
|
||||||
var result = null;
|
var result = null;
|
||||||
for (var i = 0; i < entries.length; i++)
|
for (var i = 0; i < entries.length; i++) {
|
||||||
{
|
|
||||||
var entry = entries[i];
|
var entry = entries[i];
|
||||||
if (pos.y < entry.getUpperLimit() && pos.y >= entry.getLowerLimit())
|
if (pos.y < entry.getUpperLimit() && pos.y >= entry.getLowerLimit()) {
|
||||||
{
|
|
||||||
result = entry;
|
result = entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == null)
|
if (result == null) {
|
||||||
{
|
|
||||||
var defaultHeight = this._defaultWidth;
|
var defaultHeight = this._defaultWidth;
|
||||||
if (entries.length == 0)
|
if (entries.length == 0) {
|
||||||
{
|
|
||||||
var reference = this.getReferencePoint();
|
var reference = this.getReferencePoint();
|
||||||
var yReference = reference.y;
|
var yReference = reference.y;
|
||||||
result = this.createBoardEntry(yReference - (defaultHeight / 2), yReference + (defaultHeight / 2), 0);
|
result = this.createBoardEntry(yReference - (defaultHeight / 2), yReference + (defaultHeight / 2), 0);
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
var firstEntry = entries[0];
|
var firstEntry = entries[0];
|
||||||
if (pos.y < firstEntry.getLowerLimit())
|
if (pos.y < firstEntry.getLowerLimit()) {
|
||||||
{
|
|
||||||
var upperLimit = firstEntry.getLowerLimit();
|
var upperLimit = firstEntry.getLowerLimit();
|
||||||
var lowerLimit = upperLimit - defaultHeight;
|
var lowerLimit = upperLimit - defaultHeight;
|
||||||
result = this.createBoardEntry(lowerLimit, upperLimit, 0);
|
result = this.createBoardEntry(lowerLimit, upperLimit, 0);
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
var entriesLenght = entries.length;
|
var entriesLenght = entries.length;
|
||||||
var lastEntry = entries[entriesLenght - 1];
|
var lastEntry = entries[entriesLenght - 1];
|
||||||
var lowerLimit = lastEntry.getUpperLimit();
|
var lowerLimit = lastEntry.getUpperLimit();
|
||||||
@ -321,4 +279,9 @@ mindplot.FixedDistanceBoard.prototype.lookupEntryByPosition = function(pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
}
|
||||||
|
})
|
||||||
|
;
|
||||||
|
mindplot.FixedDistanceBoard.INTER_TOPIC_DISTANCE = 6;
|
||||||
|
mindplot.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE = 60;
|
||||||
|
|
||||||
|
@ -16,26 +16,28 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.Icon = function(url){
|
mindplot.Icon = new Class({
|
||||||
|
initialize:function(url) {
|
||||||
this._image = new web2d.Image();
|
this._image = new web2d.Image();
|
||||||
this._image.setHref(url);
|
this._image.setHref(url);
|
||||||
this._image.setSize(12, 12);
|
this._image.setSize(12, 12);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Icon.prototype.getImage= function(){
|
getImage : function() {
|
||||||
return this._image;
|
return this._image;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Icon.prototype.setGroup= function(group){
|
setGroup : function(group) {
|
||||||
this._group = group;
|
this._group = group;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Icon.prototype.getGroup= function() {
|
getGroup : function() {
|
||||||
return this._group;
|
return this._group;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Icon.prototype.getSize=function(){
|
getSize : function() {
|
||||||
return this._image.getSize();
|
return this._image.getSize();
|
||||||
};
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,8 +16,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.IconGroup = function(topic) {
|
mindplot.IconGroup = new Class({
|
||||||
|
initialize : function(topic) {
|
||||||
var offset = topic.getOffset();
|
var offset = topic.getOffset();
|
||||||
|
|
||||||
this.options = {
|
this.options = {
|
||||||
width:0,
|
width:0,
|
||||||
height:0,
|
height:0,
|
||||||
@ -29,31 +31,30 @@ mindplot.IconGroup = function(topic) {
|
|||||||
};
|
};
|
||||||
this.updateIconGroupPosition();
|
this.updateIconGroupPosition();
|
||||||
this.registerListeners();
|
this.registerListeners();
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.IconGroup.prototype.setPosition = function(x, y) {
|
setPosition : function(x, y) {
|
||||||
this.options.x = x;
|
this.options.x = x;
|
||||||
this.options.y = y;
|
this.options.y = y;
|
||||||
this.options.nativeElem.setPosition(x, y);
|
this.options.nativeElem.setPosition(x, y);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.IconGroup.prototype.getPosition = function() {
|
getPosition : function() {
|
||||||
return {x:this.options.x, y:this.options.y};
|
return {x:this.options.x, y:this.options.y};
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.IconGroup.prototype.setSize = function(width, height) {
|
setSize : function(width, height) {
|
||||||
this.options.width = width;
|
this.options.width = width;
|
||||||
this.options.height = height;
|
this.options.height = height;
|
||||||
this.options.nativeElem.setSize(width, height);
|
this.options.nativeElem.setSize(width, height);
|
||||||
this.options.nativeElem.setCoordSize(width, height);
|
this.options.nativeElem.setCoordSize(width, height);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.IconGroup.prototype.getSize = function()
|
getSize : function() {
|
||||||
{
|
|
||||||
return {width:this.options.width, height:this.options.height};
|
return {width:this.options.width, height:this.options.height};
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.IconGroup.prototype.addIcon = function(icon) {
|
addIcon : function(icon) {
|
||||||
icon.setGroup(this);
|
icon.setGroup(this);
|
||||||
var newIcon = icon.getImage();
|
var newIcon = icon.getImage();
|
||||||
var nativeElem = this.options.nativeElem;
|
var nativeElem = this.options.nativeElem;
|
||||||
@ -65,8 +66,7 @@ mindplot.IconGroup.prototype.addIcon = function(icon) {
|
|||||||
nativeElem.appendChild(newIcon);
|
nativeElem.appendChild(newIcon);
|
||||||
|
|
||||||
size.width = size.width + iconSize.width;
|
size.width = size.width + iconSize.width;
|
||||||
if (iconSize.height > size.height)
|
if (iconSize.height > size.height) {
|
||||||
{
|
|
||||||
size.height = iconSize.height;
|
size.height = iconSize.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,63 +74,60 @@ mindplot.IconGroup.prototype.addIcon = function(icon) {
|
|||||||
nativeElem.setSize(size.width, size.height);
|
nativeElem.setSize(size.width, size.height);
|
||||||
this.options.width = size.width;
|
this.options.width = size.width;
|
||||||
this.options.height = size.height;
|
this.options.height = size.height;
|
||||||
};
|
},
|
||||||
mindplot.IconGroup.prototype.getIcons = function() {
|
|
||||||
return this.options.icons;
|
|
||||||
};
|
|
||||||
mindplot.IconGroup.prototype.removeIcon = function(url) {
|
|
||||||
this._removeIcon(this.getIcon(url));
|
|
||||||
};
|
|
||||||
|
|
||||||
mindplot.IconGroup.prototype.removeImageIcon = function(icon) {
|
getIcons : function() {
|
||||||
|
return this.options.icons;
|
||||||
|
},
|
||||||
|
|
||||||
|
removeIcon : function(url) {
|
||||||
|
this._removeIcon(this.getIcon(url));
|
||||||
|
},
|
||||||
|
|
||||||
|
removeImageIcon : function(icon) {
|
||||||
|
|
||||||
var imgIcon = this.getImageIcon(icon);
|
var imgIcon = this.getImageIcon(icon);
|
||||||
this._removeIcon(imgIcon);
|
this._removeIcon(imgIcon);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.IconGroup.prototype.getIcon = function(url) {
|
getIcon : function(url) {
|
||||||
var result = null;
|
var result = null;
|
||||||
this.options.icons.each(function(el, index) {
|
this.options.icons.each(function(el, index) {
|
||||||
var nativeImage = el.getImage();
|
var nativeImage = el.getImage();
|
||||||
if (nativeImage.getHref() == url)
|
if (nativeImage.getHref() == url) {
|
||||||
{
|
|
||||||
result = el;
|
result = el;
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
return result;
|
return result;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.IconGroup.prototype.getImageIcon=function(icon){
|
getImageIcon : function(icon) {
|
||||||
var result = null;
|
var result = null;
|
||||||
this.options.icons.each(function(el, index) {
|
this.options.icons.each(function(el, index) {
|
||||||
if(result == null && $chk(el.getModel().isIconModel) && el.getId()==icon.getId() && el.getUiId() == icon.getUiId())
|
if (result == null && $chk(el.getModel().isIconModel) && el.getId() == icon.getId() && el.getUiId() == icon.getUiId()) {
|
||||||
{
|
|
||||||
result = el;
|
result = el;
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
return result;
|
return result;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.IconGroup.prototype.findIconFromModel=function(iconModel){
|
findIconFromModel : function(iconModel) {
|
||||||
var result = null;
|
var result = null;
|
||||||
this.options.icons.each(function(el, index) {
|
this.options.icons.each(function(el, index) {
|
||||||
var elModel = el.getModel();
|
var elModel = el.getModel();
|
||||||
if(result == null && $chk(elModel.isIconModel) && elModel.getId()==iconModel.getId())
|
if (result == null && $chk(elModel.isIconModel) && elModel.getId() == iconModel.getId()) {
|
||||||
{
|
|
||||||
result = el;
|
result = el;
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
if(result==null)
|
if (result == null) {
|
||||||
{
|
|
||||||
throw "Icon can no be found.";
|
throw "Icon can no be found.";
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
},
|
||||||
|
|
||||||
|
_removeIcon : function(icon) {
|
||||||
mindplot.IconGroup.prototype._removeIcon = function(icon) {
|
|
||||||
var nativeImage = icon.getImage();
|
var nativeImage = icon.getImage();
|
||||||
this.options.icons.erase(icon);
|
this.options.icons.erase(icon);
|
||||||
var iconSize = nativeImage.getSize();
|
var iconSize = nativeImage.getSize();
|
||||||
@ -146,48 +143,47 @@ mindplot.IconGroup.prototype._removeIcon = function(icon) {
|
|||||||
}.bind(this));
|
}.bind(this));
|
||||||
size.width = size.width - iconSize.width;
|
size.width = size.width - iconSize.width;
|
||||||
this.setSize(size.width, size.height);
|
this.setSize(size.width, size.height);
|
||||||
};
|
},
|
||||||
mindplot.IconGroup.prototype.getNativeElement = function() {
|
|
||||||
|
getNativeElement : function() {
|
||||||
return this.options.nativeElem;
|
return this.options.nativeElem;
|
||||||
};
|
},
|
||||||
mindplot.IconGroup.prototype.moveToFront = function() {
|
|
||||||
|
moveToFront : function() {
|
||||||
this.options.nativeElem.moveToFront();
|
this.options.nativeElem.moveToFront();
|
||||||
}
|
},
|
||||||
mindplot.IconGroup.prototype.registerListeners = function() {
|
|
||||||
|
registerListeners : function() {
|
||||||
this.options.nativeElem.addEventListener('click', function(event) {
|
this.options.nativeElem.addEventListener('click', function(event) {
|
||||||
// Avoid node creation ...
|
// Avoid node creation ...
|
||||||
if (core.Utils.isDefined(event.stopPropagation))
|
if (core.Utils.isDefined(event.stopPropagation)) {
|
||||||
{
|
|
||||||
event.stopPropagation(true);
|
event.stopPropagation(true);
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
event.cancelBubble = true;
|
event.cancelBubble = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
this.options.nativeElem.addEventListener('dblclick', function(event)
|
this.options.nativeElem.addEventListener('dblclick', function(event) {
|
||||||
{
|
|
||||||
// Avoid node creation ...
|
// Avoid node creation ...
|
||||||
if (core.Utils.isDefined(event.stopPropagation))
|
if (core.Utils.isDefined(event.stopPropagation)) {
|
||||||
{
|
|
||||||
event.stopPropagation(true);
|
event.stopPropagation(true);
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
event.cancelBubble = true;
|
event.cancelBubble = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
},
|
||||||
mindplot.IconGroup.prototype.getTopic = function() {
|
|
||||||
return this.options.topic;
|
|
||||||
};
|
|
||||||
|
|
||||||
mindplot.IconGroup.prototype.updateIconGroupPosition = function() {
|
getTopic : function() {
|
||||||
|
return this.options.topic;
|
||||||
|
},
|
||||||
|
|
||||||
|
updateIconGroupPosition : function() {
|
||||||
var offsets = this._calculateOffsets();
|
var offsets = this._calculateOffsets();
|
||||||
this.setPosition(offsets.x, offsets.y);
|
this.setPosition(offsets.x, offsets.y);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.IconGroup.prototype._calculateOffsets = function() {
|
_calculateOffsets : function() {
|
||||||
var offset = this.options.topic.getOffset();
|
var offset = this.options.topic.getOffset();
|
||||||
var text = this.options.topic.getTextShape();
|
var text = this.options.topic.getTextShape();
|
||||||
var sizeHeight = text.getHtmlFontSize();
|
var sizeHeight = text.getHtmlFontSize();
|
||||||
@ -195,4 +191,5 @@ mindplot.IconGroup.prototype._calculateOffsets = function() {
|
|||||||
var shape = this.options.topic.getShapeType();
|
var shape = this.options.topic.getShapeType();
|
||||||
yOffset = text.getPosition().y + (sizeHeight - 18) / 2 + 1;
|
yOffset = text.getPosition().y + (sizeHeight - 18) / 2 + 1;
|
||||||
return {x:offset, y:yOffset};
|
return {x:offset, y:yOffset};
|
||||||
};
|
}
|
||||||
|
});
|
@ -16,76 +16,62 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.Mindmap = function()
|
mindplot.Mindmap = new Class({
|
||||||
{
|
initialize : function() {
|
||||||
this._branches = [];
|
this._branches = [];
|
||||||
this._name = null;
|
|
||||||
this._description = null;
|
this._description = null;
|
||||||
this._version = null;
|
this._version = null;
|
||||||
this._relationships = [];
|
this._relationships = [];
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Mindmap.prototype.getCentralTopic = function()
|
getCentralTopic : function() {
|
||||||
{
|
|
||||||
return this._branches[0];
|
return this._branches[0];
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Mindmap.prototype.getDescription = function()
|
getDescription : function() {
|
||||||
{
|
|
||||||
return this._description;
|
return this._description;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Mindmap.prototype.getId = function()
|
getId : function() {
|
||||||
{
|
|
||||||
return this._iconType;
|
return this._iconType;
|
||||||
};
|
},
|
||||||
|
|
||||||
|
|
||||||
mindplot.Mindmap.prototype.setId = function(id)
|
setId : function(id) {
|
||||||
{
|
|
||||||
this._iconType = id;
|
this._iconType = id;
|
||||||
};
|
},
|
||||||
|
|
||||||
|
|
||||||
mindplot.Mindmap.prototype.getVersion = function()
|
getVersion : function() {
|
||||||
{
|
|
||||||
return this._version;
|
return this._version;
|
||||||
};
|
},
|
||||||
|
|
||||||
|
|
||||||
mindplot.Mindmap.prototype.setVersion = function(version)
|
setVersion : function(version) {
|
||||||
{
|
|
||||||
this._version = version;
|
this._version = version;
|
||||||
};
|
},
|
||||||
|
|
||||||
|
addBranch : function(nodeModel) {
|
||||||
|
|
||||||
mindplot.Mindmap.prototype.addBranch = function(nodeModel)
|
|
||||||
{
|
|
||||||
core.assert(nodeModel && nodeModel.isNodeModel(), 'Add node must be invoked with model objects');
|
core.assert(nodeModel && nodeModel.isNodeModel(), 'Add node must be invoked with model objects');
|
||||||
if (this._branches.length == 0)
|
if (this._branches.length == 0) {
|
||||||
{
|
|
||||||
core.assert(nodeModel.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE, "First element must be the central topic");
|
core.assert(nodeModel.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE, "First element must be the central topic");
|
||||||
nodeModel.setPosition(0, 0);
|
nodeModel.setPosition(0, 0);
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
core.assert(nodeModel.getType() != mindplot.NodeModel.CENTRAL_TOPIC_TYPE, "Mindmaps only have one cental topic");
|
core.assert(nodeModel.getType() != mindplot.NodeModel.CENTRAL_TOPIC_TYPE, "Mindmaps only have one cental topic");
|
||||||
}
|
}
|
||||||
|
|
||||||
this._branches.push(nodeModel);
|
this._branches.push(nodeModel);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Mindmap.prototype.getBranches = function()
|
getBranches : function() {
|
||||||
{
|
|
||||||
return this._branches;
|
return this._branches;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Mindmap.prototype.getRelationships = function() {
|
getRelationships : function() {
|
||||||
return this._relationships;
|
return this._relationships;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Mindmap.prototype.connect = function(parent, child)
|
connect : function(parent, child) {
|
||||||
{
|
|
||||||
// Child already has a parent ?
|
// Child already has a parent ?
|
||||||
var branches = this.getBranches();
|
var branches = this.getBranches();
|
||||||
core.assert(!child.getParent(), 'Child model seems to be already connected');
|
core.assert(!child.getParent(), 'Child model seems to be already connected');
|
||||||
@ -95,10 +81,9 @@ mindplot.Mindmap.prototype.connect = function(parent, child)
|
|||||||
|
|
||||||
// Remove from the branch ...
|
// Remove from the branch ...
|
||||||
branches.erase(child);
|
branches.erase(child);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Mindmap.prototype.disconnect = function(child)
|
disconnect : function(child) {
|
||||||
{
|
|
||||||
var parent = child.getParent();
|
var parent = child.getParent();
|
||||||
core.assert(child, 'Child can not be null.');
|
core.assert(child, 'Child can not be null.');
|
||||||
core.assert(parent, 'Child model seems to be already connected');
|
core.assert(parent, 'Child model seems to be already connected');
|
||||||
@ -108,63 +93,55 @@ mindplot.Mindmap.prototype.disconnect = function(child)
|
|||||||
var branches = this.getBranches();
|
var branches = this.getBranches();
|
||||||
branches.push(child);
|
branches.push(child);
|
||||||
|
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Mindmap.prototype.hasAlreadyAdded = function(node)
|
hasAlreadyAdded : function(node) {
|
||||||
{
|
|
||||||
var result = false;
|
var result = false;
|
||||||
|
|
||||||
// Check in not connected nodes.
|
// Check in not connected nodes.
|
||||||
var branches = this._branches;
|
var branches = this._branches;
|
||||||
for (var i = 0; i < branches.length; i++)
|
for (var i = 0; i < branches.length; i++) {
|
||||||
{
|
|
||||||
result = branches[i]._isChildNode(node);
|
result = branches[i]._isChildNode(node);
|
||||||
if (result)
|
if (result) {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Mindmap.prototype.createNode = function(type, id)
|
createNode : function(type, id) {
|
||||||
{
|
|
||||||
core.assert(type, "node type can not be null");
|
core.assert(type, "node type can not be null");
|
||||||
return this._createNode(type, id);
|
return this._createNode(type, id);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Mindmap.prototype._createNode = function(type, id)
|
_createNode : function(type, id) {
|
||||||
{
|
|
||||||
core.assert(type, 'Node type must be specified.');
|
core.assert(type, 'Node type must be specified.');
|
||||||
var result = new mindplot.NodeModel(type, this, id);
|
var result = new mindplot.NodeModel(type, this, id);
|
||||||
return result;
|
return result;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Mindmap.prototype.createRelationship = function(fromNode, toNode){
|
createRelationship : function(fromNode, toNode) {
|
||||||
core.assert(fromNode, 'from node cannot be null');
|
core.assert(fromNode, 'from node cannot be null');
|
||||||
core.assert(toNode, 'to node cannot be null');
|
core.assert(toNode, 'to node cannot be null');
|
||||||
|
|
||||||
return new mindplot.RelationshipModel(fromNode, toNode);
|
return new mindplot.RelationshipModel(fromNode, toNode);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Mindmap.prototype.addRelationship = function(relationship) {
|
addRelationship : function(relationship) {
|
||||||
this._relationships.push(relationship);
|
this._relationships.push(relationship);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Mindmap.prototype.removeRelationship = function(relationship) {
|
removeRelationship : function(relationship) {
|
||||||
this._relationships.erase(relationship);
|
this._relationships.erase(relationship);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Mindmap.prototype.inspect = function()
|
inspect : function() {
|
||||||
{
|
|
||||||
var result = '';
|
var result = '';
|
||||||
result = '{ ';
|
result = '{ ';
|
||||||
|
|
||||||
var branches = this.getBranches();
|
var branches = this.getBranches();
|
||||||
for (var i = 0; i < branches.length; i++)
|
for (var i = 0; i < branches.length; i++) {
|
||||||
{
|
|
||||||
var node = branches[i];
|
var node = branches[i];
|
||||||
if (i != 0)
|
if (i != 0) {
|
||||||
{
|
|
||||||
result = result + ', ';
|
result = result + ', ';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,32 +151,29 @@ mindplot.Mindmap.prototype.inspect = function()
|
|||||||
result = result + ' } ';
|
result = result + ' } ';
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Mindmap.prototype._toString = function(node)
|
_toString : function(node) {
|
||||||
{
|
|
||||||
var result = node.inspect();
|
var result = node.inspect();
|
||||||
var children = node.getChildren();
|
var children = node.getChildren();
|
||||||
|
|
||||||
for (var i = 0; i < children.length; i++)
|
for (var i = 0; i < children.length; i++) {
|
||||||
{
|
|
||||||
var child = children[i];
|
var child = children[i];
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0) {
|
||||||
{
|
|
||||||
result = result + '-> {';
|
result = result + '-> {';
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
result = result + ', ';
|
result = result + ', ';
|
||||||
}
|
}
|
||||||
|
|
||||||
result = result + this._toString(child);
|
result = result + this._toString(child);
|
||||||
|
|
||||||
if (i == children.length - 1)
|
if (i == children.length - 1) {
|
||||||
{
|
|
||||||
result = result + '}';
|
result = result + '}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
);
|
@ -16,8 +16,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.NodeModel = function(type, mindmap, id)
|
mindplot.NodeModel = new Class({
|
||||||
{
|
initialize:function(type, mindmap, id) {
|
||||||
core.assert(type, 'Node type can not be null');
|
core.assert(type, 'Node type can not be null');
|
||||||
core.assert(mindmap, 'mindmap can not be null');
|
core.assert(mindmap, 'mindmap can not be null');
|
||||||
|
|
||||||
@ -48,15 +48,13 @@ mindplot.NodeModel = function(type, mindmap, id)
|
|||||||
this._borderColor = null;
|
this._borderColor = null;
|
||||||
this._backgroundColor = null;
|
this._backgroundColor = null;
|
||||||
this._areChildrenShrinked = false;
|
this._areChildrenShrinked = false;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.clone = function()
|
clone : function() {
|
||||||
{
|
|
||||||
var result = new mindplot.NodeModel(this._type, this._mindmap);
|
var result = new mindplot.NodeModel(this._type, this._mindmap);
|
||||||
result._order = this._order;
|
result._order = this._order;
|
||||||
result._type = this._type;
|
result._type = this._type;
|
||||||
result._children = this._children.map(function(item,index)
|
result._children = this._children.map(function(item, index) {
|
||||||
{
|
|
||||||
var model = item.clone();
|
var model = item.clone();
|
||||||
model._parent = result;
|
model._parent = result;
|
||||||
return model;
|
return model;
|
||||||
@ -81,215 +79,178 @@ mindplot.NodeModel.prototype.clone = function()
|
|||||||
result._backgroundColor = this._backgroundColor;
|
result._backgroundColor = this._backgroundColor;
|
||||||
result._areChildrenShrinked = this._areChildrenShrinked;
|
result._areChildrenShrinked = this._areChildrenShrinked;
|
||||||
return result;
|
return result;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.areChildrenShrinked = function()
|
areChildrenShrinked : function() {
|
||||||
{
|
|
||||||
return this._areChildrenShrinked;
|
return this._areChildrenShrinked;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.setChildrenShrinked = function(value)
|
setChildrenShrinked : function(value) {
|
||||||
{
|
|
||||||
this._areChildrenShrinked = value;
|
this._areChildrenShrinked = value;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getId = function()
|
getId : function() {
|
||||||
{
|
|
||||||
return this._id;
|
return this._id;
|
||||||
};
|
},
|
||||||
|
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.setId = function(id)
|
setId : function(id) {
|
||||||
{
|
|
||||||
this._id = id;
|
this._id = id;
|
||||||
if (mindplot.NodeModel._uuid < id) {
|
if (mindplot.NodeModel._uuid < id) {
|
||||||
mindplot.NodeModel._uuid = id;
|
mindplot.NodeModel._uuid = id;
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getType = function()
|
getType : function() {
|
||||||
{
|
|
||||||
return this._type;
|
return this._type;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.setText = function(text)
|
setText : function(text) {
|
||||||
{
|
|
||||||
this._text = text;
|
this._text = text;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getText = function()
|
getText : function() {
|
||||||
{
|
|
||||||
return this._text;
|
return this._text;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.isNodeModel = function()
|
isNodeModel : function() {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.isConnected = function()
|
isConnected : function() {
|
||||||
{
|
|
||||||
return this._parent != null;
|
return this._parent != null;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.createLink = function(url)
|
createLink : function(url) {
|
||||||
{
|
|
||||||
core.assert(url, 'Link URL must be specified.');
|
core.assert(url, 'Link URL must be specified.');
|
||||||
return new mindplot.LinkModel(url, this);
|
return new mindplot.LinkModel(url, this);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.addLink = function(link)
|
addLink : function(link) {
|
||||||
{
|
|
||||||
core.assert(link && link.isLinkModel(), 'Only LinkModel can be appended to Mindmap object as links');
|
core.assert(link && link.isLinkModel(), 'Only LinkModel can be appended to Mindmap object as links');
|
||||||
this._links.push(link);
|
this._links.push(link);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype._removeLink = function(link)
|
_removeLink : function(link) {
|
||||||
{
|
|
||||||
core.assert(link && link.isLinkModel(), 'Only LinkModel can be appended to Mindmap object as links');
|
core.assert(link && link.isLinkModel(), 'Only LinkModel can be appended to Mindmap object as links');
|
||||||
this._links.erase(link);
|
this._links.erase(link);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.createNote = function(text)
|
createNote : function(text) {
|
||||||
{
|
|
||||||
core.assert(text != null, 'note text must be specified.');
|
core.assert(text != null, 'note text must be specified.');
|
||||||
return new mindplot.NoteModel(text, this);
|
return new mindplot.NoteModel(text, this);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.addNote = function(note)
|
addNote : function(note) {
|
||||||
{
|
|
||||||
core.assert(note && note.isNoteModel(), 'Only NoteModel can be appended to Mindmap object as links');
|
core.assert(note && note.isNoteModel(), 'Only NoteModel can be appended to Mindmap object as links');
|
||||||
this._notes.push(note);
|
this._notes.push(note);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype._removeNote = function(note)
|
_removeNote : function(note) {
|
||||||
{
|
|
||||||
core.assert(note && note.isNoteModel(), 'Only NoteModel can be appended to Mindmap object as links');
|
core.assert(note && note.isNoteModel(), 'Only NoteModel can be appended to Mindmap object as links');
|
||||||
this._notes.erase(note);
|
this._notes.erase(note);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.createIcon = function(iconType)
|
createIcon : function(iconType) {
|
||||||
{
|
|
||||||
core.assert(iconType, 'IconType must be specified.');
|
core.assert(iconType, 'IconType must be specified.');
|
||||||
return new mindplot.IconModel(iconType, this);
|
return new mindplot.IconModel(iconType, this);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.addIcon = function(icon)
|
addIcon : function(icon) {
|
||||||
{
|
|
||||||
core.assert(icon && icon.isIconModel(), 'Only IconModel can be appended to Mindmap object as icons');
|
core.assert(icon && icon.isIconModel(), 'Only IconModel can be appended to Mindmap object as icons');
|
||||||
this._icons.push(icon);
|
this._icons.push(icon);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype._removeIcon = function(icon)
|
_removeIcon : function(icon) {
|
||||||
{
|
|
||||||
core.assert(icon && icon.isIconModel(), 'Only IconModel can be appended to Mindmap object as icons');
|
core.assert(icon && icon.isIconModel(), 'Only IconModel can be appended to Mindmap object as icons');
|
||||||
this._icons.erase(icon);
|
this._icons.erase(icon);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.removeLastIcon = function()
|
removeLastIcon : function() {
|
||||||
{
|
|
||||||
this._icons.pop();
|
this._icons.pop();
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype._appendChild = function(child)
|
_appendChild : function(child) {
|
||||||
{
|
|
||||||
core.assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
|
core.assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
|
||||||
this._children.push(child);
|
this._children.push(child);
|
||||||
child._parent = this;
|
child._parent = this;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype._removeChild = function(child)
|
_removeChild : function(child) {
|
||||||
{
|
|
||||||
core.assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object.');
|
core.assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object.');
|
||||||
this._children.erase(child);
|
this._children.erase(child);
|
||||||
child._parent = null;
|
child._parent = null;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.setPosition = function(x, y)
|
setPosition : function(x, y) {
|
||||||
{
|
|
||||||
core.assert(core.Utils.isDefined(x), "x coordinate must be defined");
|
core.assert(core.Utils.isDefined(x), "x coordinate must be defined");
|
||||||
core.assert(core.Utils.isDefined(y), "y coordinate must be defined");
|
core.assert(core.Utils.isDefined(y), "y coordinate must be defined");
|
||||||
|
|
||||||
if (!core.Utils.isDefined(this._position))
|
if (!core.Utils.isDefined(this._position)) {
|
||||||
{
|
|
||||||
this._position = new core.Point();
|
this._position = new core.Point();
|
||||||
}
|
}
|
||||||
this._position.x = parseInt(x);
|
this._position.x = parseInt(x);
|
||||||
this._position.y = parseInt(y);
|
this._position.y = parseInt(y);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getPosition = function()
|
getPosition : function() {
|
||||||
{
|
|
||||||
return this._position;
|
return this._position;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.setFinalPosition = function(x, y)
|
setFinalPosition : function(x, y) {
|
||||||
{
|
|
||||||
core.assert(core.Utils.isDefined(x), "x coordinate must be defined");
|
core.assert(core.Utils.isDefined(x), "x coordinate must be defined");
|
||||||
core.assert(core.Utils.isDefined(y), "y coordinate must be defined");
|
core.assert(core.Utils.isDefined(y), "y coordinate must be defined");
|
||||||
|
|
||||||
if (!core.Utils.isDefined(this._finalPosition))
|
if (!core.Utils.isDefined(this._finalPosition)) {
|
||||||
{
|
|
||||||
this._finalPosition = new core.Point();
|
this._finalPosition = new core.Point();
|
||||||
}
|
}
|
||||||
this._finalPosition.x = parseInt(x);
|
this._finalPosition.x = parseInt(x);
|
||||||
this._finalPosition.y = parseInt(y);
|
this._finalPosition.y = parseInt(y);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getFinalPosition = function()
|
getFinalPosition : function() {
|
||||||
{
|
|
||||||
return this._finalPosition;
|
return this._finalPosition;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.setSize = function(width, height)
|
setSize : function(width, height) {
|
||||||
{
|
|
||||||
this._size.width = width;
|
this._size.width = width;
|
||||||
this._size.height = height;
|
this._size.height = height;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getSize = function()
|
getSize : function() {
|
||||||
{
|
|
||||||
return {width:this._size.width,height:this._size.height};
|
return {width:this._size.width,height:this._size.height};
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getChildren = function()
|
getChildren : function() {
|
||||||
{
|
|
||||||
return this._children;
|
return this._children;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getIcons = function()
|
getIcons : function() {
|
||||||
{
|
|
||||||
return this._icons;
|
return this._icons;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getLinks = function()
|
getLinks : function() {
|
||||||
{
|
|
||||||
return this._links;
|
return this._links;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getNotes = function()
|
getNotes : function() {
|
||||||
{
|
|
||||||
return this._notes;
|
return this._notes;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getParent = function()
|
getParent : function() {
|
||||||
{
|
|
||||||
return this._parent;
|
return this._parent;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getMindmap = function()
|
getMindmap : function() {
|
||||||
{
|
|
||||||
return this._mindmap;
|
return this._mindmap;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.setParent = function(parent)
|
setParent : function(parent) {
|
||||||
{
|
|
||||||
core.assert(parent != this, 'The same node can not be parent and child if itself.');
|
core.assert(parent != this, 'The same node can not be parent and child if itself.');
|
||||||
this._parent = parent;
|
this._parent = parent;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.canBeConnected = function(sourceModel, sourcePosition, targetTopicHeight)
|
canBeConnected : function(sourceModel, sourcePosition, targetTopicHeight) {
|
||||||
{
|
|
||||||
core.assert(sourceModel != this, 'The same node can not be parent and child if itself.');
|
core.assert(sourceModel != this, 'The same node can not be parent and child if itself.');
|
||||||
core.assert(sourcePosition, 'childPosition can not be null.');
|
core.assert(sourcePosition, 'childPosition can not be null.');
|
||||||
core.assert(core.Utils.isDefined(targetTopicHeight), 'childrenWidth can not be null.');
|
core.assert(core.Utils.isDefined(targetTopicHeight), 'childrenWidth can not be null.');
|
||||||
@ -300,8 +261,7 @@ mindplot.NodeModel.prototype.canBeConnected = function(sourceModel, sourcePositi
|
|||||||
var targetPosition = targetModel.getPosition();
|
var targetPosition = targetModel.getPosition();
|
||||||
var result = false;
|
var result = false;
|
||||||
|
|
||||||
if (sourceModel.getType() == mindplot.NodeModel.MAIN_TOPIC_TYPE)
|
if (sourceModel.getType() == mindplot.NodeModel.MAIN_TOPIC_TYPE) {
|
||||||
{
|
|
||||||
// Finally, check current node ubication.
|
// Finally, check current node ubication.
|
||||||
var targetTopicSize = targetModel.getSize();
|
var targetTopicSize = targetModel.getSize();
|
||||||
var yDistance = Math.abs(sourcePosition.y - targetPosition.y);
|
var yDistance = Math.abs(sourcePosition.y - targetPosition.y);
|
||||||
@ -310,187 +270,149 @@ mindplot.NodeModel.prototype.canBeConnected = function(sourceModel, sourcePositi
|
|||||||
gap += Math.abs(targetPosition.y - targetModel.getChildren()[0].getPosition().y);
|
gap += Math.abs(targetPosition.y - targetModel.getChildren()[0].getPosition().y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yDistance <= gap)
|
if (yDistance <= gap) {
|
||||||
{
|
|
||||||
// Circular connection ?
|
// Circular connection ?
|
||||||
if (!sourceModel._isChildNode(this))
|
if (!sourceModel._isChildNode(this)) {
|
||||||
{
|
|
||||||
var toleranceDistance = (targetTopicSize.width / 2) + targetTopicHeight;
|
var toleranceDistance = (targetTopicSize.width / 2) + targetTopicHeight;
|
||||||
|
|
||||||
var xDistance = sourcePosition.x - targetPosition.x;
|
var xDistance = sourcePosition.x - targetPosition.x;
|
||||||
var isTargetAtRightFromCentral = targetPosition.x >= 0;
|
var isTargetAtRightFromCentral = targetPosition.x >= 0;
|
||||||
|
|
||||||
if (isTargetAtRightFromCentral)
|
if (isTargetAtRightFromCentral) {
|
||||||
{
|
if (xDistance >= -targetTopicSize.width / 2 && xDistance <= mindplot.NodeModel.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE / 2 + (targetTopicSize.width / 2)) {
|
||||||
if (xDistance >= -targetTopicSize.width/2 && xDistance <= mindplot.NodeModel.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE /2 + (targetTopicSize.width / 2))
|
|
||||||
{
|
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else
|
} else {
|
||||||
{
|
if (xDistance <= targetTopicSize.width / 2 && Math.abs(xDistance) <= mindplot.NodeModel.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE / 2 + (targetTopicSize.width / 2)) {
|
||||||
if (xDistance <= targetTopicSize.width/2 && Math.abs(xDistance) <= mindplot.NodeModel.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE /2 + (targetTopicSize.width / 2))
|
|
||||||
{
|
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
throw "No implemented yet";
|
throw "No implemented yet";
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE = 220;
|
_isChildNode : function(node) {
|
||||||
|
|
||||||
mindplot.NodeModel.prototype._isChildNode = function(node)
|
|
||||||
{
|
|
||||||
var result = false;
|
var result = false;
|
||||||
if (node == this)
|
if (node == this) {
|
||||||
{
|
|
||||||
result = true;
|
result = true;
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
var children = this.getChildren();
|
var children = this.getChildren();
|
||||||
for (var i = 0; i < children.length; i++)
|
for (var i = 0; i < children.length; i++) {
|
||||||
{
|
|
||||||
var child = children[i];
|
var child = children[i];
|
||||||
result = child._isChildNode(node);
|
result = child._isChildNode(node);
|
||||||
if (result)
|
if (result) {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.connectTo = function(parent)
|
connectTo : function(parent) {
|
||||||
{
|
|
||||||
var mindmap = this.getMindmap();
|
var mindmap = this.getMindmap();
|
||||||
mindmap.connect(parent, this);
|
mindmap.connect(parent, this);
|
||||||
this._parent = parent;
|
this._parent = parent;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.disconnect = function()
|
disconnect : function() {
|
||||||
{
|
|
||||||
var mindmap = this.getMindmap();
|
var mindmap = this.getMindmap();
|
||||||
mindmap.disconnect(this);
|
mindmap.disconnect(this);
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getOrder = function()
|
getOrder : function() {
|
||||||
{
|
|
||||||
return this._order;
|
return this._order;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getShapeType = function()
|
getShapeType : function() {
|
||||||
{
|
|
||||||
return this._shapeType;
|
return this._shapeType;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.setShapeType = function(type)
|
setShapeType : function(type) {
|
||||||
{
|
|
||||||
this._shapeType = type;
|
this._shapeType = type;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.setOrder = function(value)
|
setOrder : function(value) {
|
||||||
{
|
|
||||||
this._order = value;
|
this._order = value;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.setFontFamily = function(value)
|
setFontFamily : function(value) {
|
||||||
{
|
|
||||||
this._fontFamily = value;
|
this._fontFamily = value;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getOrder = function()
|
getOrder : function() {
|
||||||
{
|
|
||||||
return this._order;
|
return this._order;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getFontFamily = function()
|
getFontFamily : function() {
|
||||||
{
|
|
||||||
return this._fontFamily;
|
return this._fontFamily;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.setFontStyle = function(value)
|
setFontStyle : function(value) {
|
||||||
{
|
|
||||||
this._fontStyle = value;
|
this._fontStyle = value;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getFontStyle = function()
|
getFontStyle : function() {
|
||||||
{
|
|
||||||
return this._fontStyle;
|
return this._fontStyle;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.setFontWeight = function(value)
|
setFontWeight : function(value) {
|
||||||
{
|
|
||||||
this._fontWeight = value;
|
this._fontWeight = value;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getFontWeight = function()
|
getFontWeight : function() {
|
||||||
{
|
|
||||||
return this._fontWeight;
|
return this._fontWeight;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.setFontColor = function(value)
|
setFontColor : function(value) {
|
||||||
{
|
|
||||||
this._fontColor = value;
|
this._fontColor = value;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getFontColor = function()
|
getFontColor : function() {
|
||||||
{
|
|
||||||
return this._fontColor;
|
return this._fontColor;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.setFontSize = function(value)
|
setFontSize : function(value) {
|
||||||
{
|
|
||||||
this._fontSize = value;
|
this._fontSize = value;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getFontSize = function()
|
getFontSize : function() {
|
||||||
{
|
|
||||||
return this._fontSize;
|
return this._fontSize;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getBorderColor = function()
|
getBorderColor : function() {
|
||||||
{
|
|
||||||
return this._borderColor;
|
return this._borderColor;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.setBorderColor = function(color)
|
setBorderColor : function(color) {
|
||||||
{
|
|
||||||
this._borderColor = color;
|
this._borderColor = color;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.getBackgroundColor = function()
|
getBackgroundColor : function() {
|
||||||
{
|
|
||||||
return this._backgroundColor;
|
return this._backgroundColor;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.setBackgroundColor = function(color)
|
setBackgroundColor : function(color) {
|
||||||
{
|
|
||||||
this._backgroundColor = color;
|
this._backgroundColor = color;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.deleteNode = function()
|
deleteNode : function() {
|
||||||
{
|
|
||||||
var mindmap = this._mindmap;
|
var mindmap = this._mindmap;
|
||||||
|
|
||||||
// if it has children nodes, Their must be disconnected.
|
// if it has children nodes, Their must be disconnected.
|
||||||
var lenght = this._children;
|
var lenght = this._children;
|
||||||
for (var i = 0; i < lenght; i++)
|
for (var i = 0; i < lenght; i++) {
|
||||||
{
|
|
||||||
var child = this._children[i];
|
var child = this._children[i];
|
||||||
mindmap.disconnect(child);
|
mindmap.disconnect(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
var parent = this._parent;
|
var parent = this._parent;
|
||||||
if (core.Utils.isDefined(parent))
|
if (core.Utils.isDefined(parent)) {
|
||||||
{
|
|
||||||
// if it is connected, I must remove it from the parent..
|
// if it is connected, I must remove it from the parent..
|
||||||
mindmap.disconnect(this);
|
mindmap.disconnect(this);
|
||||||
}
|
}
|
||||||
@ -499,27 +421,12 @@ mindplot.NodeModel.prototype.deleteNode = function()
|
|||||||
var branches = mindmap.getBranches();
|
var branches = mindmap.getBranches();
|
||||||
branches.erase(this);
|
branches.erase(this);
|
||||||
|
|
||||||
};
|
},
|
||||||
|
|
||||||
/**
|
inspect : function() {
|
||||||
* @todo: This method must be implemented.
|
|
||||||
*/
|
|
||||||
mindplot.NodeModel._nextUUID = function()
|
|
||||||
{
|
|
||||||
if (!core.Utils.isDefined(this._uuid))
|
|
||||||
{
|
|
||||||
this._uuid = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._uuid = this._uuid + 1;
|
|
||||||
return this._uuid;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
mindplot.NodeModel.prototype.inspect = function()
|
|
||||||
{
|
|
||||||
return '(type:' + this.getType() + ' , id: ' + this.getId() + ')';
|
return '(type:' + this.getType() + ' , id: ' + this.getId() + ')';
|
||||||
};
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mindplot.NodeModel.CENTRAL_TOPIC_TYPE = 'CentralTopic';
|
mindplot.NodeModel.CENTRAL_TOPIC_TYPE = 'CentralTopic';
|
||||||
mindplot.NodeModel.MAIN_TOPIC_TYPE = 'MainTopic';
|
mindplot.NodeModel.MAIN_TOPIC_TYPE = 'MainTopic';
|
||||||
@ -530,4 +437,17 @@ mindplot.NodeModel.SHAPE_TYPE_ROUNDED_RECT = 'rounded rectagle';
|
|||||||
mindplot.NodeModel.SHAPE_TYPE_ELIPSE = 'elipse';
|
mindplot.NodeModel.SHAPE_TYPE_ELIPSE = 'elipse';
|
||||||
mindplot.NodeModel.SHAPE_TYPE_LINE = 'line';
|
mindplot.NodeModel.SHAPE_TYPE_LINE = 'line';
|
||||||
|
|
||||||
|
mindplot.NodeModel.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE = 220;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo: This method must be implemented.
|
||||||
|
*/
|
||||||
|
mindplot.NodeModel._nextUUID = function() {
|
||||||
|
if (!core.Utils.isDefined(this._uuid)) {
|
||||||
|
this._uuid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._uuid = this._uuid + 1;
|
||||||
|
return this._uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.Note = function(textModel, topic, designer) {
|
mindplot.Note = new Class({
|
||||||
|
Extends: mindplot.Icon,
|
||||||
|
initialize : function(textModel, topic, designer) {
|
||||||
var divContainer = designer.getWorkSpace().getScreenManager().getContainer();
|
var divContainer = designer.getWorkSpace().getScreenManager().getContainer();
|
||||||
var bubbleTip = mindplot.BubbleTip.getInstance(divContainer);
|
var bubbleTip = mindplot.BubbleTip.getInstance(divContainer);
|
||||||
mindplot.Icon.call(this, mindplot.Note.IMAGE_URL);
|
mindplot.Icon.call(this, mindplot.Note.IMAGE_URL);
|
||||||
@ -61,14 +63,14 @@ mindplot.Note = function(textModel, topic, designer) {
|
|||||||
|
|
||||||
var msg = new Element('div');
|
var msg = new Element('div');
|
||||||
var textarea = new Element('div').inject(msg);
|
var textarea = new Element('div').inject(msg);
|
||||||
textarea.innerHTML = "Text"
|
textarea.innerHTML = "Text";
|
||||||
|
|
||||||
var formElem = new Element('form', {'action': 'none', 'id':'noteFormId'});
|
var formElem = new Element('form', {'action': 'none', 'id':'noteFormId'});
|
||||||
var text = textModel.getText();
|
var text = textModel.getText();
|
||||||
text = unescape(text);
|
text = unescape(text);
|
||||||
var textInput = new Element('textarea', {'value':text}).setStyles({'width':280, 'height':50});
|
var textInput = new Element('textarea', {'value':text}).setStyles({'width':280, 'height':50});
|
||||||
textInput.inject(formElem);
|
textInput.inject(formElem);
|
||||||
formElem.inject(msg)
|
formElem.inject(msg);
|
||||||
|
|
||||||
var okFunction = function(e) {
|
var okFunction = function(e) {
|
||||||
var result = true;
|
var result = true;
|
||||||
@ -78,8 +80,7 @@ mindplot.Note = function(textModel, topic, designer) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
formElem.addEvent('submit', function(e)
|
formElem.addEvent('submit', function(e) {
|
||||||
{
|
|
||||||
$(okButtonId).fireEvent('click', e);
|
$(okButtonId).fireEvent('click', e);
|
||||||
e = new Event(e);
|
e = new Event(e);
|
||||||
e.stop();
|
e.stop();
|
||||||
@ -93,7 +94,6 @@ mindplot.Note = function(textModel, topic, designer) {
|
|||||||
buttonContainer.inject(container);
|
buttonContainer.inject(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var note = this;
|
var note = this;
|
||||||
image.addEventListener('mouseover', function(event) {
|
image.addEventListener('mouseover', function(event) {
|
||||||
var text = textModel.getText();
|
var text = textModel.getText();
|
||||||
@ -111,23 +111,17 @@ mindplot.Note = function(textModel, topic, designer) {
|
|||||||
image.addEventListener('mouseout', function(event) {
|
image.addEventListener('mouseout', function(event) {
|
||||||
bubbleTip.close(event);
|
bubbleTip.close(event);
|
||||||
});
|
});
|
||||||
};
|
},
|
||||||
|
|
||||||
objects.extend(mindplot.Note, mindplot.Icon);
|
getText: function() {
|
||||||
|
|
||||||
mindplot.Note.prototype.initialize = function() {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
mindplot.Note.prototype.getText=function(){
|
|
||||||
return this._text;
|
return this._text;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Note.prototype.getModel=function(){
|
getModel : function() {
|
||||||
return this._noteModel;
|
return this._noteModel;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.Note.buildDialog = function(designer, okFunction, okButtonId) {
|
buildDialog : function(designer, okFunction, okButtonId) {
|
||||||
var windoo = new Windoo({
|
var windoo = new Windoo({
|
||||||
title: 'Write note',
|
title: 'Write note',
|
||||||
theme: Windoo.Themes.wise,
|
theme: Windoo.Themes.wise,
|
||||||
@ -147,8 +141,7 @@ mindplot.Note.buildDialog = function(designer, okFunction, okButtonId) {
|
|||||||
var ok = new Element('input', {'type': 'button', 'class':'btn-primary', 'value': 'Ok','class':'btn-primary','id':okButtonId}).setStyle('marginRight', 10);
|
var ok = new Element('input', {'type': 'button', 'class':'btn-primary', 'value': 'Ok','class':'btn-primary','id':okButtonId}).setStyle('marginRight', 10);
|
||||||
ok.addEvent('click', function(event) {
|
ok.addEvent('click', function(event) {
|
||||||
var couldBeUpdated = okFunction.attempt();
|
var couldBeUpdated = okFunction.attempt();
|
||||||
if (couldBeUpdated)
|
if (couldBeUpdated) {
|
||||||
{
|
|
||||||
$(document).addEvent('keydown', designer.keyEventHandler.bindWithEvent(designer));
|
$(document).addEvent('keydown', designer.keyEventHandler.bindWithEvent(designer));
|
||||||
windoo.close();
|
windoo.close();
|
||||||
}
|
}
|
||||||
@ -159,7 +152,8 @@ mindplot.Note.buildDialog = function(designer, okFunction, okButtonId) {
|
|||||||
windoo.addPanel(panel);
|
windoo.addPanel(panel);
|
||||||
$(document).removeEvents('keydown');
|
$(document).removeEvents('keydown');
|
||||||
return windoo;
|
return windoo;
|
||||||
};
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mindplot.Note.IMAGE_URL = "../images/note.png";
|
mindplot.Note.IMAGE_URL = "../images/note.png";
|
||||||
|
|
||||||
|
@ -16,30 +16,27 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.NoteModel = function(text, topic)
|
mindplot.NoteModel = new Class({
|
||||||
{
|
initialize : function(text, topic) {
|
||||||
core.assert(text != null, 'note text can not be null');
|
core.assert(text != null, 'note text can not be null');
|
||||||
core.assert(topic, 'mindmap can not be null');
|
core.assert(topic, 'mindmap can not be null');
|
||||||
this._text = text;
|
this._text = text;
|
||||||
this._topic = topic;
|
this._topic = topic;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NoteModel.prototype.getText = function()
|
getText:function() {
|
||||||
{
|
|
||||||
return this._text;
|
return this._text;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NoteModel.prototype.setText = function(text)
|
setText : function(text) {
|
||||||
{
|
|
||||||
this._text = text;
|
this._text = text;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NoteModel.prototype.getTopic = function()
|
getTopic : function() {
|
||||||
{
|
|
||||||
return this._topic;
|
return this._topic;
|
||||||
};
|
},
|
||||||
|
|
||||||
mindplot.NoteModel.prototype.isNoteModel = function()
|
isNoteModel : function() {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user