More classes migrated to Mootools 1.3.

This commit is contained in:
Paulo Veiga 2011-07-27 08:25:10 -03:00
parent 9759ee12cb
commit f60755fd8e
21 changed files with 2334 additions and 2584 deletions

View File

@ -1,34 +1,33 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.Beta2PelaMigrator = function(betaSerializer){
this._betaSerializer=betaSerializer;
this._pelaSerializer = new mindplot.XMLMindmapSerializer_Pela();
};
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.Beta2PelaMigrator = new Class({
initialize : function(betaSerializer) {
this._betaSerializer = betaSerializer;
this._pelaSerializer = new mindplot.XMLMindmapSerializer_Pela();
},
mindplot.Beta2PelaMigrator.prototype.toXML = function(mindmap)
{
return this._pelaSerializer.toXML(mindmap);
};
toXML : function(mindmap) {
return this._pelaSerializer.toXML(mindmap);
},
mindplot.Beta2PelaMigrator.prototype.loadFromDom = function(dom)
{
var mindmap = this._betaSerializer.loadFromDom(dom);
mindmap.setVersion(mindplot.ModelCodeName.PELA);
return mindmap;
};
loadFromDom : function(dom) {
var mindmap = this._betaSerializer.loadFromDom(dom);
mindmap.setVersion(mindplot.ModelCodeName.PELA);
return mindmap;
}
});

View File

@ -58,72 +58,75 @@ mindplot.Board = new Class({
/**
* ---------------------------------------
*/
mindplot.BidirectionalArray = function() {
this._leftElem = [];
this._rightElem = [];
};
mindplot.BidirectionalArray = new Class({
mindplot.BidirectionalArray.prototype.get = function(index, sign) {
core.assert(core.Utils.isDefined(index), 'Illegal argument, index must be passed.');
if (core.Utils.isDefined(sign)) {
core.assert(index >= 0, 'Illegal absIndex value');
index = index * sign;
}
initialize: function() {
this._leftElem = [];
this._rightElem = [];
},
var result = null;
if (index >= 0 && index < this._rightElem.length) {
result = this._rightElem[index];
} else if (index < 0 && Math.abs(index) < this._leftElem.length) {
result = this._leftElem[Math.abs(index)];
}
return result;
};
mindplot.BidirectionalArray.prototype.set = function(index, elem) {
core.assert(core.Utils.isDefined(index), 'Illegal index value');
var array = (index >= 0) ? this._rightElem : this._leftElem;
array[Math.abs(index)] = elem;
};
mindplot.BidirectionalArray.prototype.length = function(index) {
core.assert(core.Utils.isDefined(index), 'Illegal index value');
return (index >= 0) ? this._rightElem.length : this._leftElem.length;
};
mindplot.BidirectionalArray.prototype.upperLength = function() {
return this.length(1);
};
mindplot.BidirectionalArray.prototype.lowerLength = function() {
return this.length(-1);
};
mindplot.BidirectionalArray.prototype.inspect = function() {
var result = '{';
var lenght = this._leftElem.length;
for (var i = 0; i < lenght; i++) {
var entry = this._leftElem[lenght - i - 1];
if (entry != null) {
if (i != 0) {
result += ', ';
}
result += entry.inspect();
get :function(index, sign) {
core.assert(core.Utils.isDefined(index), 'Illegal argument, index must be passed.');
if (core.Utils.isDefined(sign)) {
core.assert(index >= 0, 'Illegal absIndex value');
index = index * sign;
}
}
lenght = this._rightElem.length;
for (var i = 0; i < lenght; i++) {
var entry = this._rightElem[i];
if (entry != null) {
if (i != 0) {
result += ', ';
}
result += entry.inspect();
var result = null;
if (index >= 0 && index < this._rightElem.length) {
result = this._rightElem[index];
} else if (index < 0 && Math.abs(index) < this._leftElem.length) {
result = this._leftElem[Math.abs(index)];
}
return result;
},
set : function(index, elem) {
core.assert(core.Utils.isDefined(index), 'Illegal index value');
var array = (index >= 0) ? this._rightElem : this._leftElem;
array[Math.abs(index)] = elem;
},
length : function(index) {
core.assert(core.Utils.isDefined(index), 'Illegal index value');
return (index >= 0) ? this._rightElem.length : this._leftElem.length;
},
upperLength : function() {
return this.length(1);
},
lowerLength : function() {
return this.length(-1);
},
inspect : function() {
var result = '{';
var lenght = this._leftElem.length;
for (var i = 0; i < lenght; i++) {
var entry = this._leftElem[lenght - i - 1];
if (entry != null) {
if (i != 0) {
result += ', ';
}
result += entry.inspect();
}
}
lenght = this._rightElem.length;
for (var i = 0; i < lenght; i++) {
var entry = this._rightElem[i];
if (entry != null) {
if (i != 0) {
result += ', ';
}
result += entry.inspect();
}
}
result += '}';
return result;
}
result += '}';
return result;
};
});

View File

@ -1,160 +1,141 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.BoardEntry = function(lowerLimit, upperLimit, order)
{
if (core.Utils.isDefined(lowerLimit) && core.Utils.isDefined(upperLimit))
{
core.assert(lowerLimit < upperLimit, 'lowerLimit can not be greater that upperLimit');
}
this._upperLimit = upperLimit;
this._lowerLimit = lowerLimit;
this._order = order;
this._topic = null;
this._xPos = null;
};
mindplot.BoardEntry.prototype.getUpperLimit = function()
{
return this._upperLimit;
};
mindplot.BoardEntry.prototype.setXPosition = function(xPosition)
{
this._xPos = xPosition;
};
mindplot.BoardEntry.prototype.workoutEntryYCenter = function()
{
return this._lowerLimit + ((this._upperLimit - this._lowerLimit) / 2);
};
mindplot.BoardEntry.prototype.setUpperLimit = function(value)
{
core.assert(core.Utils.isDefined(value), "upper limit can not be null");
core.assert(!isNaN(value), "illegal value");
this._upperLimit = value;
};
mindplot.BoardEntry.prototype.isCoordinateIn = function(coord)
{
return this._lowerLimit <= coord && coord < this._upperLimit;
};
mindplot.BoardEntry.prototype.getLowerLimit = function()
{
return this._lowerLimit;
};
mindplot.BoardEntry.prototype.setLowerLimit = function(value)
{
core.assert(core.Utils.isDefined(value), "upper limit can not be null");
core.assert(!isNaN(value), "illegal value");
this._lowerLimit = value;
};
mindplot.BoardEntry.prototype.setOrder = function(value)
{
this._order = value;
};
mindplot.BoardEntry.prototype.getWidth = function()
{
return Math.abs(this._upperLimit - this._lowerLimit);
};
mindplot.BoardEntry = new Class({
initialize:function(lowerLimit, upperLimit, order) {
if (core.Utils.isDefined(lowerLimit) && core.Utils.isDefined(upperLimit)) {
core.assert(lowerLimit < upperLimit, 'lowerLimit can not be greater that upperLimit');
}
this._upperLimit = upperLimit;
this._lowerLimit = lowerLimit;
this._order = order;
this._topic = null;
this._xPos = null;
},
mindplot.BoardEntry.prototype.getTopic = function()
{
return this._topic;
};
getUpperLimit : function() {
return this._upperLimit;
},
setXPosition : function(xPosition) {
this._xPos = xPosition;
},
workoutEntryYCenter : function() {
return this._lowerLimit + ((this._upperLimit - this._lowerLimit) / 2);
},
setUpperLimit : function(value) {
core.assert(core.Utils.isDefined(value), "upper limit can not be null");
core.assert(!isNaN(value), "illegal value");
this._upperLimit = value;
},
isCoordinateIn : function(coord) {
return this._lowerLimit <= coord && coord < this._upperLimit;
},
getLowerLimit : function() {
return this._lowerLimit;
},
setLowerLimit : function(value) {
core.assert(core.Utils.isDefined(value), "upper limit can not be null");
core.assert(!isNaN(value), "illegal value");
this._lowerLimit = value;
},
setOrder : function(value) {
this._order = value;
},
getWidth : function() {
return Math.abs(this._upperLimit - this._lowerLimit);
},
mindplot.BoardEntry.prototype.removeTopic = function()
{
core.assert(!this.isAvailable(), "Entry doesn't have a topic.");
var topic = this.getTopic();
this.setTopic(null);
topic.setOrder(null);
};
getTopic : function() {
return this._topic;
},
mindplot.BoardEntry.prototype.update = function()
{
var topic = this.getTopic();
this.setTopic(topic);
};
removeTopic : function() {
core.assert(!this.isAvailable(), "Entry doesn't have a topic.");
var topic = this.getTopic();
this.setTopic(null);
topic.setOrder(null);
},
mindplot.BoardEntry.prototype.setTopic = function(topic, updatePosition)
{
if (!core.Utils.isDefined(updatePosition) || (core.Utils.isDefined(updatePosition) && !updatePosition))
{
updatePosition = true;
}
this._topic = topic;
if (core.Utils.isDefined(topic))
{
// Fixed positioning. Only for main topic ...
var position = null;
var topicPosition = topic.getPosition();
update : function() {
var topic = this.getTopic();
this.setTopic(topic);
},
// Must update position base on the border limits?
if (core.Utils.isDefined(this._xPos))
{
position = new core.Point();
// Update x position ...
var topicSize = topic.getSize();
var halfTopicWidh = parseInt(topicSize.width / 2);
halfTopicWidh = (this._xPos > 0) ? halfTopicWidh:-halfTopicWidh;
position.x = this._xPos + halfTopicWidh;
position.y = this.workoutEntryYCenter();
} else {
// Central topic
this._height = topic.getSize().height;
var xPos = topicPosition.x;
var yPos = this.workoutEntryYCenter();
position = new core.Point(xPos, yPos);
setTopic : function(topic, updatePosition) {
if (!core.Utils.isDefined(updatePosition) || (core.Utils.isDefined(updatePosition) && !updatePosition)) {
updatePosition = true;
}
// @todo: No esta de mas...
topic.setPosition(position);
topic.setOrder(this._order);
this._topic = topic;
if (core.Utils.isDefined(topic)) {
// Fixed positioning. Only for main topic ...
var position = null;
var topicPosition = topic.getPosition();
// Must update position base on the border limits?
if (core.Utils.isDefined(this._xPos)) {
position = new core.Point();
// Update x position ...
var topicSize = topic.getSize();
var halfTopicWidh = parseInt(topicSize.width / 2);
halfTopicWidh = (this._xPos > 0) ? halfTopicWidh : -halfTopicWidh;
position.x = this._xPos + halfTopicWidh;
position.y = this.workoutEntryYCenter();
} else {
// Central topic
this._height = topic.getSize().height;
var xPos = topicPosition.x;
var yPos = this.workoutEntryYCenter();
position = new core.Point(xPos, yPos);
}
// @todo: No esta de mas...
topic.setPosition(position);
topic.setOrder(this._order);
}
else {
this._height = this._defaultWidth;
}
},
isAvailable : function() {
return !core.Utils.isDefined(this._topic);
},
getOrder : function() {
return this._order;
},
inspect : function() {
return '(order: ' + this._order + ', lowerLimit:' + this._lowerLimit + ', upperLimit: ' + this._upperLimit + ', available:' + this.isAvailable() + ')';
}
else
{
this._height = this._defaultWidth;
}
};
mindplot.BoardEntry.prototype.isAvailable = function()
{
return !core.Utils.isDefined(this._topic);
};
mindplot.BoardEntry.prototype.getOrder = function()
{
return this._order;
};
mindplot.BoardEntry.prototype.inspect = function()
{
return '(order: ' + this._order + ', lowerLimit:' + this._lowerLimit + ', upperLimit: ' + this._upperLimit + ', available:' + this.isAvailable() + ')';
};
});

View File

@ -1,117 +1,119 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.BubbleTip = function(divContainer){
this.initialize(divContainer);
};
mindplot.BubbleTip.prototype.initialize=function(divContainer){
this.options={
panel:null,
container:null,
divContainer:divContainer,
content:null,
onShowComplete:Class.empty,
onHideComplete:Class.empty,
width:null,
height:null,
form:null
};
if($chk(this.options.form))
mindplot.BubbleTip = new Class({
initialize : function(divContainer) {
this.options = {
panel:null,
container:null,
divContainer:divContainer,
content:null,
onShowComplete:Class.empty,
onHideComplete:Class.empty,
width:null,
height:null,
form:null
};
if ($chk(this.options.form))
this.scanElements(this.options.form);
this.buildBubble();
this._isMouseOver=false;
this._open=false;
};
mindplot.BubbleTip.prototype.scanElements=function(form){
this._isMouseOver = false;
this._open = false;
},
scanElements : function(form) {
$$($(form).getElements('a')).each(function(el) {
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);
};
mindplot.BubbleTip.prototype.buildBubble=function(){
},
buildBubble : function() {
var opts = this.options;
var panel = new Element('div').addClass('bubbleContainer');
if($chk(opts.height))
if ($chk(opts.height))
panel.setStyle('height', opts.height);
if($chk(opts.width))
if ($chk(opts.width))
panel.setStyle('width', opts.width);
this.center = new Element('div').addClass('bubblePart').addClass('bubbleCenterBlue');
this.center.inject(panel);
if(!$chk(opts.divContainer))
{
opts.divContainer=document.body;
if (!$chk(opts.divContainer)) {
opts.divContainer = document.body;
}
panel.injectTop(opts.divContainer);
opts.panel = $(panel);
opts.panel.setStyle('opacity',0);
opts.panel.addEvent('mouseover',function(){this._isMouseOver=true;}.bind(this));
opts.panel.addEvent('mouseleave',function(event){this.close(event);}.bindWithEvent(this));//this.close.bindWithEvent(this)
opts.panel.setStyle('opacity', 0);
opts.panel.addEvent('mouseover', function() {
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);
};
mindplot.BubbleTip.prototype.open= function(event, content, source){
this._isMouseOver=true;
},
open : function(event, content, source) {
this._isMouseOver = true;
this._evt = new Event(event);
this.doOpen.delay(500, this,[content,source]);
};
mindplot.BubbleTip.prototype.doOpen= function(content, source){
if($chk(this._isMouseOver) &&!$chk(this._open) && !$chk(this._opening))
{
this._opening=true;
this.doOpen.delay(500, this, [content,source]);
},
doOpen : function(content, source) {
if ($chk(this._isMouseOver) && !$chk(this._open) && !$chk(this._opening)) {
this._opening = true;
var container = new Element('div');
$(content).inject(container);
this.options.content=content;
this.options.container=container;
this.options.content = content;
this.options.container = container;
$(this.options.container).inject(this.center);
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.init(this._evt, source);
$(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);
};
mindplot.BubbleTip.prototype.close=function(event){
this._isMouseOver=false;
this.doClose.delay(50,this,new Event(event));
};
mindplot.BubbleTip.prototype.doClose=function(event){
},
close : function(event) {
this._isMouseOver = false;
this.doClose.delay(50, this, new Event(event));
},
doClose : function(event) {
if(!$chk(this._isMouseOver) && $chk(this._opening))
this.doClose.delay(500,this,this._evt);
if (!$chk(this._isMouseOver) && $chk(this._opening))
this.doClose.delay(500, this, this._evt);
if(!$chk(this._isMouseOver) && $chk(this._open))
{
if (!$chk(this._isMouseOver) && $chk(this._open)) {
this.forceClose();
}
};
mindplot.BubbleTip.prototype.forceClose=function(){
this.options.panel.effect('opacity',{duration:100, onComplete:function(){
this._open=false;
},
forceClose : function() {
this.options.panel.effect('opacity', {duration:100, onComplete:function() {
this._open = false;
$(this.options.panel).setStyles({left:0,top:0});
$(this.options.container).remove();
}.bind(this)}).start(100,0);
};
mindplot.BubbleTip.prototype.init=function(event,source){
}.bind(this)}).start(100, 0);
},
init : function(event, source) {
var opts = this.options;
var coordinates = $(opts.panel).getCoordinates();
var panelHeight = coordinates.height; //not total height, but close enough
@ -126,32 +128,32 @@ mindplot.BubbleTip.prototype.init=function(event,source){
var width = $(this.center).getCoordinates().width;
var invert = !(offset.y > panelHeight); //hint goes on the bottom
var invertX = (screenWidth-offset.x > panelWidth); // hint goes on the right
var invertX = (screenWidth - offset.x > panelWidth); // hint goes on the right
$(this.options.panel).remove();
this.buildBubble();
$(this.options.container).inject(this.center);
var height = $(this.center).getCoordinates().height;
$(opts.panel).setStyles({width:width,height:height});
this.moveTopic(offset, $(opts.panel).getCoordinates().height, $(opts.panel).getCoordinates().width, invert, invertX);
};
mindplot.BubbleTip.prototype.moveTopic=function(offset, panelHeight, panelWidth, invert, invertX){
var f = 1, fX=1;
if($chk(invert))
f=0;
if($chk(invertX))
fX=0;
this.moveTopic(offset, $(opts.panel).getCoordinates().height, $(opts.panel).getCoordinates().width, invert, invertX);
},
moveTopic : function(offset, panelHeight, panelWidth, invert, invertX) {
var f = 1, fX = 1;
if ($chk(invert))
f = 0;
if ($chk(invertX))
fX = 0;
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;
if(!core.Utils.isDefined(result))
{
if (!core.Utils.isDefined(result)) {
mindplot.BubbleTip.instance = new mindplot.BubbleTip(divContainer);
result = mindplot.BubbleTip.instance;
}
return result;
};
}

View File

@ -1,225 +1,209 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.ConnectionLine = function(sourceNode, targetNode, lineType)
{
core.assert(targetNode, 'parentNode node can not be null');
core.assert(sourceNode, 'childNode node can not be null');
core.assert(sourceNode != targetNode, 'Cilcular connection');
mindplot.ConnectionLine = new Class({
initialize:function(sourceNode, targetNode, lineType) {
core.assert(targetNode, 'parentNode node can not be null');
core.assert(sourceNode, 'childNode node can not be null');
core.assert(sourceNode != targetNode, 'Cilcular connection');
this._targetTopic = targetNode;
this._sourceTopic = sourceNode;
this._targetTopic = targetNode;
this._sourceTopic = sourceNode;
var strokeColor = mindplot.ConnectionLine.getStrokeColor();
var line;
if (targetNode.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE)
{
line = this._createLine(lineType,mindplot.ConnectionLine.CURVED);
// line = new web2d.Line();
if(line.getType()=="CurvedLine"){
var ctrlPoints = this._getCtrlPoints(sourceNode, targetNode);
line.setSrcControlPoint(ctrlPoints[0]);
line.setDestControlPoint(ctrlPoints[1]);
var strokeColor = mindplot.ConnectionLine.getStrokeColor();
var line;
if (targetNode.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE) {
line = this._createLine(lineType, mindplot.ConnectionLine.CURVED);
// line = new web2d.Line();
if (line.getType() == "CurvedLine") {
var ctrlPoints = this._getCtrlPoints(sourceNode, targetNode);
line.setSrcControlPoint(ctrlPoints[0]);
line.setDestControlPoint(ctrlPoints[1]);
}
line.setStroke(1, 'solid', strokeColor);
} else {
line = this._createLine(lineType, mindplot.ConnectionLine.SIMPLE_CURVED);
if (line.getType() == "CurvedLine") {
var ctrlPoints = this._getCtrlPoints(sourceNode, targetNode);
line.setSrcControlPoint(ctrlPoints[0]);
line.setDestControlPoint(ctrlPoints[1]);
}
// line = new web2d.PolyLine();
line.setStroke(1, 'solid', strokeColor);
}
line.setStroke(1, 'solid', strokeColor);
} else
{
line = this._createLine(lineType,mindplot.ConnectionLine.SIMPLE_CURVED);
if(line.getType()=="CurvedLine"){
var ctrlPoints = this._getCtrlPoints(sourceNode, targetNode);
line.setSrcControlPoint(ctrlPoints[0]);
line.setDestControlPoint(ctrlPoints[1]);
this._line2d = line;
},
_getCtrlPoints : function(sourceNode, targetNode) {
var srcPos = sourceNode.workoutOutgoingConnectionPoint(targetNode.getPosition());
var destPos = targetNode.workoutIncomingConnectionPoint(sourceNode.getPosition());
var deltaX = (srcPos.x - destPos.x) / 3;
return [new core.Point(deltaX, 0), new core.Point(-deltaX, 0)];
},
_createLine : function(lineType, defaultStyle) {
if (!core.Utils.isDefined(lineType)) {
lineType = defaultStyle;
}
// line = new web2d.PolyLine();
line.setStroke(1, 'solid', strokeColor);
lineType = parseInt(lineType);
this._lineType = lineType;
var line = null;
switch (lineType) {
case mindplot.ConnectionLine.POLYLINE:
line = new web2d.PolyLine();
break;
case mindplot.ConnectionLine.CURVED:
line = new web2d.CurvedLine();
break;
case mindplot.ConnectionLine.SIMPLE_CURVED:
line = new web2d.CurvedLine();
line.setStyle(web2d.CurvedLine.SIMPLE_LINE);
break;
default:
line = new web2d.Line();
break;
}
return line;
},
setVisibility : function(value) {
this._line2d.setVisibility(value);
},
isVisible : function() {
return this._line2d.isVisible();
},
setOpacity : function(opacity) {
this._line2d.setOpacity(opacity);
},
redraw : function() {
var line2d = this._line2d;
var sourceTopic = this._sourceTopic;
var sourcePosition = sourceTopic.getPosition();
var targetTopic = this._targetTopic;
var targetPosition = targetTopic.getPosition();
var sPos,tPos;
sPos = sourceTopic.workoutOutgoingConnectionPoint(targetPosition, false);
tPos = targetTopic.workoutIncomingConnectionPoint(sourcePosition, false);
line2d.setFrom(tPos.x, tPos.y);
line2d.setTo(sPos.x, sPos.y);
if (line2d.getType() == "CurvedLine") {
var ctrlPoints = this._getCtrlPoints(this._sourceTopic, this._targetTopic);
line2d.setSrcControlPoint(ctrlPoints[0]);
line2d.setDestControlPoint(ctrlPoints[1]);
}
// line2d.moveToBack();
// Add connector ...
this._positionateConnector(targetTopic);
},
_positionateConnector : function(targetTopic) {
var targetPosition = targetTopic.getPosition();
var offset = mindplot.Topic.CONNECTOR_WIDTH / 2;
var targetTopicSize = targetTopic.getSize();
var y;
if (targetTopic.getShapeType() == mindplot.NodeModel.SHAPE_TYPE_LINE) {
y = targetTopicSize.height;
} else {
y = targetTopicSize.height / 2;
}
y = y - offset;
var connector = targetTopic.getShrinkConnector();
if (Math.sign(targetPosition.x) > 0) {
var x = targetTopicSize.width;
connector.setPosition(x, y);
}
else {
var x = -mindplot.Topic.CONNECTOR_WIDTH;
connector.setPosition(x, y);
}
},
setStroke : function(color, style, opacity) {
var line2d = this._line2d;
this._line2d.setStroke(null, null, color, opacity);
},
addToWorkspace : function(workspace) {
workspace.appendChild(this._line2d);
this._line2d.moveToBack();
},
removeFromWorkspace : function(workspace) {
workspace.removeChild(this._line2d);
},
getTargetTopic : function() {
return this._targetTopic;
},
getSourceTopic : function() {
return this._sourceTopic;
},
getLineType : function() {
return this._lineType;
},
getLine : function() {
return this._line2d;
},
getModel : function() {
return this._model;
},
setModel : function(model) {
this._model = model;
},
getType : function() {
return "ConnectionLine";
},
getId : function() {
return this._model.getId();
},
moveToBack : function() {
this._line2d.moveToBack();
},
moveToFront : function() {
this._line2d.moveToFront();
}
});
this._line2d = line;
};
mindplot.ConnectionLine.prototype._getCtrlPoints = function(sourceNode, targetNode){
var srcPos = sourceNode.workoutOutgoingConnectionPoint(targetNode.getPosition());
var destPos = targetNode.workoutIncomingConnectionPoint(sourceNode.getPosition());
var deltaX = (srcPos.x -destPos.x)/3;
return [new core.Point(deltaX, 0), new core.Point(-deltaX, 0)];
};
mindplot.ConnectionLine.prototype._createLine = function(lineType, defaultStyle){
if(!core.Utils.isDefined(lineType)){
lineType = defaultStyle;
}
lineType = parseInt(lineType);
this._lineType = lineType;
var line = null;
switch(lineType){
case mindplot.ConnectionLine.POLYLINE:
line = new web2d.PolyLine();
break;
case mindplot.ConnectionLine.CURVED:
line = new web2d.CurvedLine();
break;
case mindplot.ConnectionLine.SIMPLE_CURVED:
line = new web2d.CurvedLine();
line.setStyle(web2d.CurvedLine.SIMPLE_LINE);
break;
default:
line = new web2d.Line();
break;
}
return line;
};
mindplot.ConnectionLine.getStrokeColor = function()
{
mindplot.ConnectionLine.getStrokeColor = function() {
return '#495879';
};
mindplot.ConnectionLine.prototype.setVisibility = function(value)
{
this._line2d.setVisibility(value);
};
mindplot.ConnectionLine.prototype.isVisible = function()
{
return this._line2d.isVisible();
};
mindplot.ConnectionLine.prototype.setOpacity = function(opacity){
this._line2d.setOpacity(opacity);
};
mindplot.ConnectionLine.prototype.redraw = function()
{
var line2d = this._line2d;
var sourceTopic = this._sourceTopic;
var sourcePosition = sourceTopic.getPosition();
var targetTopic = this._targetTopic;
var targetPosition = targetTopic.getPosition();
var sPos,tPos;
sPos = sourceTopic.workoutOutgoingConnectionPoint(targetPosition, false);
tPos = targetTopic.workoutIncomingConnectionPoint(sourcePosition, false);
line2d.setFrom(tPos.x, tPos.y);
line2d.setTo(sPos.x, sPos.y);
if(line2d.getType()=="CurvedLine"){
var ctrlPoints = this._getCtrlPoints(this._sourceTopic, this._targetTopic);
line2d.setSrcControlPoint(ctrlPoints[0]);
line2d.setDestControlPoint(ctrlPoints[1]);
}
// line2d.moveToBack();
// Add connector ...
this._positionateConnector(targetTopic);
};
mindplot.ConnectionLine.prototype._positionateConnector = function(targetTopic)
{
var targetPosition = targetTopic.getPosition();
var offset = mindplot.Topic.CONNECTOR_WIDTH / 2;
var targetTopicSize = targetTopic.getSize();
var y;
if (targetTopic.getShapeType() == mindplot.NodeModel.SHAPE_TYPE_LINE)
{
y = targetTopicSize.height;
} else
{
y = targetTopicSize.height / 2;
}
y = y - offset;
var connector = targetTopic.getShrinkConnector();
if (Math.sign(targetPosition.x) > 0)
{
var x = targetTopicSize.width;
connector.setPosition(x, y);
}
else
{
var x = -mindplot.Topic.CONNECTOR_WIDTH;
connector.setPosition(x, y);
}
};
mindplot.ConnectionLine.prototype.setStroke = function(color, style, opacity)
{
var line2d = this._line2d;
this._line2d.setStroke(null, null, color, opacity);
};
mindplot.ConnectionLine.prototype.addToWorkspace = function(workspace)
{
workspace.appendChild(this._line2d);
this._line2d.moveToBack();
};
mindplot.ConnectionLine.prototype.removeFromWorkspace = function(workspace)
{
workspace.removeChild(this._line2d);
};
mindplot.ConnectionLine.prototype.getTargetTopic = function()
{
return this._targetTopic;
};
mindplot.ConnectionLine.prototype.getSourceTopic = function()
{
return this._sourceTopic;
};
mindplot.ConnectionLine.prototype.getLineType = function(){
return this._lineType;
};
mindplot.ConnectionLine.prototype.getLine = function(){
return this._line2d;
};
mindplot.ConnectionLine.prototype.getModel = function(){
return this._model;
};
mindplot.ConnectionLine.prototype.setModel = function(model){
this._model = model;
};
mindplot.ConnectionLine.prototype.getType = function(){
return "ConnectionLine";
};
mindplot.ConnectionLine.prototype.getId = function(){
return this._model.getId();
};
mindplot.ConnectionLine.prototype.moveToBack = function(){
this._line2d.moveToBack();
};
mindplot.ConnectionLine.prototype.moveToFront = function(){
this._line2d.moveToFront();
};
mindplot.ConnectionLine.SIMPLE=0;
mindplot.ConnectionLine.POLYLINE=1;
mindplot.ConnectionLine.CURVED=2;
mindplot.ConnectionLine.SIMPLE_CURVED=3;
mindplot.ConnectionLine.SIMPLE = 0;
mindplot.ConnectionLine.POLYLINE = 1;
mindplot.ConnectionLine.CURVED = 2;
mindplot.ConnectionLine.SIMPLE_CURVED = 3;

View File

@ -1,170 +1,173 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.ControlPoint = function()
{
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})];
this._controlLines=[new web2d.Line({strokeColor:"#6589de", strokeWidth:1, opacity:0.3}),
new web2d.Line({strokeColor:"#6589de", strokeWidth:1, opacity:0.3})];
this._isBinded=false;
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('dblclick',this._mouseClick.bindWithEvent(this));
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('dblclick',this._mouseClick.bindWithEvent(this));
};
mindplot.ControlPoint = new Class({
initialize:function() {
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})];
this._controlLines = [new web2d.Line({strokeColor:"#6589de", strokeWidth:1, opacity:0.3}),
new web2d.Line({strokeColor:"#6589de", strokeWidth:1, opacity:0.3})];
mindplot.ControlPoint.prototype.setSide= function(side) {
this._side = side;
};
this._isBinded = false;
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('dblclick', this._mouseClick.bindWithEvent(this));
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('dblclick', this._mouseClick.bindWithEvent(this));
},
mindplot.ControlPoint.prototype.setLine= function(line) {
if(core.Utils.isDefined(this._line)){
this._removeLine();
}
this._line= line;
this._createControlPoint();
this._endPoint = [];
this._orignalCtrlPoint = [];
this._orignalCtrlPoint[0] = this._controls[0].clone();
this._orignalCtrlPoint[1] = this._controls[1].clone();
this._endPoint[0] = this._line.getLine().getFrom().clone();
this._endPoint[1] = this._line.getLine().getTo().clone();
};
mindplot.ControlPoint.prototype.redraw = function(){
if(core.Utils.isDefined(this._line))
setSide : function(side) {
this._side = side;
},
setLine : function(line) {
if (core.Utils.isDefined(this._line)) {
this._removeLine();
}
this._line = line;
this._createControlPoint();
};
this._endPoint = [];
this._orignalCtrlPoint = [];
this._orignalCtrlPoint[0] = this._controls[0].clone();
this._orignalCtrlPoint[1] = this._controls[1].clone();
this._endPoint[0] = this._line.getLine().getFrom().clone();
this._endPoint[1] = this._line.getLine().getTo().clone();
},
mindplot.ControlPoint.prototype._createControlPoint = function() {
this._controls= this._line.getLine().getControlPoints();
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._controlLines[0].setFrom(pos.x, pos.y);
this._controlLines[0].setTo(this._controls[mindplot.ControlPoint.FROM].x+pos.x+3, this._controls[mindplot.ControlPoint.FROM].y+pos.y);
pos = this._line.getLine().getTo();
this._controlLines[1].setFrom(pos.x, 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);
redraw : function() {
if (core.Utils.isDefined(this._line))
this._createControlPoint();
},
};
_createControlPoint : function() {
this._controls = this._line.getLine().getControlPoints();
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._controlLines[0].setFrom(pos.x, pos.y);
this._controlLines[0].setTo(this._controls[mindplot.ControlPoint.FROM].x + pos.x + 3, this._controls[mindplot.ControlPoint.FROM].y + pos.y);
pos = this._line.getLine().getTo();
this._controlLines[1].setFrom(pos.x, 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);
mindplot.ControlPoint.prototype._removeLine= function() {
},
};
_removeLine : function() {
mindplot.ControlPoint.prototype._mouseDown = function(event, point) {
if(!this._isBinded){
this._isBinded=true;
this._mouseMoveFunction = this._mouseMove.bindWithEvent(this,point);
this._workspace.getScreenManager().addEventListener('mousemove',this._mouseMoveFunction);
this._mouseUpFunction = this._mouseUp.bindWithEvent(this,point);
this._workspace.getScreenManager().addEventListener('mouseup',this._mouseUpFunction);
},
_mouseDown : function(event, point) {
if (!this._isBinded) {
this._isBinded = true;
this._mouseMoveFunction = this._mouseMove.bindWithEvent(this, point);
this._workspace.getScreenManager().addEventListener('mousemove', this._mouseMoveFunction);
this._mouseUpFunction = this._mouseUp.bindWithEvent(this, point);
this._workspace.getScreenManager().addEventListener('mouseup', this._mouseUpFunction);
}
event.preventDefault();
event.stop();
return false;
},
_mouseMove : function(event, point) {
var screen = this._workspace.getScreenManager();
var pos = screen.getWorkspaceMousePosition(event);
var topic = null;
if (point == 0) {
var cords = core.Utils.calculateRelationShipPointCoordinates(this._line.getSourceTopic(), pos);
this._line.setFrom(cords.x, cords.y);
this._line.setSrcControlPoint(new core.Point(pos.x - cords.x, pos.y - cords.y));
} else {
var cords = core.Utils.calculateRelationShipPointCoordinates(this._line.getTargetTopic(), pos);
this._line.setTo(cords.x, cords.y);
this._line.setDestControlPoint(new core.Point(pos.x - cords.x, pos.y - cords.y));
}
this._controls[point].x = (pos.x - cords.x);
this._controls[point].y = (pos.y - cords.y);
this._controlPointsController[point].setPosition(pos.x - 5, pos.y - 3);
this._controlLines[point].setFrom(cords.x, cords.y);
this._controlLines[point].setTo(pos.x - 2, pos.y);
this._line.getLine().updateLine(point);
/*event.preventDefault();
event.stop();
return false;*/
},
_mouseUp : function(event, point) {
this._workspace.getScreenManager().removeEventListener('mousemove', this._mouseMoveFunction);
this._workspace.getScreenManager().removeEventListener('mouseup', this._mouseUpFunction);
var command = new mindplot.commands.MoveControlPointCommand(this, point);
designer._actionRunner.execute(command); //todo:Uggly!! designer is global!!
this._isBinded = false;
/*event.preventDefault();
event.stop();
return false;*/
},
_mouseClick : function(event) {
event.preventDefault();
event.stop();
return false;
},
setVisibility : function(visible) {
if (visible) {
this._controlLines[0].moveToFront();
this._controlLines[1].moveToFront();
this._controlPointsController[0].moveToFront();
this._controlPointsController[1].moveToFront();
}
this._controlPointsController[0].setVisibility(visible);
this._controlPointsController[1].setVisibility(visible);
this._controlLines[0].setVisibility(visible);
this._controlLines[1].setVisibility(visible);
},
addToWorkspace : function(workspace) {
this._workspace = workspace;
workspace.appendChild(this._controlPointsController[0]);
workspace.appendChild(this._controlPointsController[1]);
workspace.appendChild(this._controlLines[0]);
workspace.appendChild(this._controlLines[1]);
},
removeFromWorkspace : function(workspace) {
this._workspace = null;
workspace.removeChild(this._controlPointsController[0]);
workspace.removeChild(this._controlPointsController[1]);
workspace.removeChild(this._controlLines[0]);
workspace.removeChild(this._controlLines[1]);
},
getControlPoint : function(index) {
return this._controls[index];
},
getOriginalEndPoint : function(index) {
return this._endPoint[index];
},
getOriginalCtrlPoint : function(index) {
return this._orignalCtrlPoint[index];
}
event.preventDefault();
event.stop();
return false;
};
mindplot.ControlPoint.prototype._mouseMove = function(event, point) {
var screen = this._workspace.getScreenManager();
var pos = screen.getWorkspaceMousePosition(event);
var topic = null;
if(point==0){
var cords = core.Utils.calculateRelationShipPointCoordinates(this._line.getSourceTopic(),pos);
this._line.setFrom(cords.x, cords.y);
this._line.setSrcControlPoint(new core.Point(pos.x - cords.x,pos.y - cords.y));
}else{
var cords = core.Utils.calculateRelationShipPointCoordinates(this._line.getTargetTopic(),pos);
this._line.setTo(cords.x, cords.y);
this._line.setDestControlPoint(new core.Point(pos.x - cords.x,pos.y - cords.y));
}
this._controls[point].x=(pos.x - cords.x);
this._controls[point].y=(pos.y - cords.y);
this._controlPointsController[point].setPosition(pos.x-5,pos.y-3);
this._controlLines[point].setFrom(cords.x, cords.y);
this._controlLines[point].setTo(pos.x-2,pos.y);
this._line.getLine().updateLine(point);
/*event.preventDefault();
event.stop();
return false;*/
};
mindplot.ControlPoint.prototype._mouseUp = function(event, point) {
this._workspace.getScreenManager().removeEventListener('mousemove',this._mouseMoveFunction);
this._workspace.getScreenManager().removeEventListener('mouseup',this._mouseUpFunction);
var command = new mindplot.commands.MoveControlPointCommand(this,point);
designer._actionRunner.execute(command); //todo:Uggly!! designer is global!!
this._isBinded=false;
/*event.preventDefault();
event.stop();
return false;*/
};
mindplot.ControlPoint.prototype._mouseClick = function(event){
event.preventDefault();
event.stop();
return false;
};
mindplot.ControlPoint.prototype.setVisibility = function(visible){
if(visible){
this._controlLines[0].moveToFront();
this._controlLines[1].moveToFront();
this._controlPointsController[0].moveToFront();
this._controlPointsController[1].moveToFront();
}
this._controlPointsController[0].setVisibility(visible);
this._controlPointsController[1].setVisibility(visible);
this._controlLines[0].setVisibility(visible);
this._controlLines[1].setVisibility(visible);
};
mindplot.ControlPoint.prototype.addToWorkspace = function(workspace){
this._workspace = workspace;
workspace.appendChild(this._controlPointsController[0]);
workspace.appendChild(this._controlPointsController[1]);
workspace.appendChild(this._controlLines[0]);
workspace.appendChild(this._controlLines[1]);
};
mindplot.ControlPoint.prototype.removeFromWorkspace = function(workspace){
this._workspace = null;
workspace.removeChild(this._controlPointsController[0]);
workspace.removeChild(this._controlPointsController[1]);
workspace.removeChild(this._controlLines[0]);
workspace.removeChild(this._controlLines[1]);
};
mindplot.ControlPoint.prototype.getControlPoint = function(index){
return this._controls[index];
};
mindplot.ControlPoint.prototype.getOriginalEndPoint = function(index){
return this._endPoint[index];
};
mindplot.ControlPoint.prototype.getOriginalCtrlPoint = function(index){
return this._orignalCtrlPoint[index];
};
});
mindplot.ControlPoint.FROM = 0;
mindplot.ControlPoint.TO = 1;

View File

@ -1,24 +1,29 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.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");
// Execute action ...
command.execute(this._context);
@ -30,22 +35,16 @@ mindplot.DesignerActionRunner = new Class({
var event = this._undoManager._buildEvent();
this._designer._fireEvent("change", event);
},
initialize: function(designer)
{
this._designer = designer;
this._undoManager = new mindplot.DesignerUndoManager();
this._context = new mindplot.CommandContext(this._designer);
},
undo: function()
{
undo: function() {
this._undoManager.execUndo(this._context);
// Fire event
var event = this._undoManager._buildEvent();
this._designer._fireEvent("change", event);
},
redo: function()
{
redo: function() {
this._undoManager.execRedo(this._context);
// Fire event
@ -53,33 +52,28 @@ mindplot.DesignerActionRunner = new Class({
this._designer._fireEvent("change", event);
},
markAsChangeBase: function()
{
markAsChangeBase: function() {
return this._undoManager.markAsChangeBase();
},
hasBeenChanged: function()
{
hasBeenChanged: function() {
return this._undoManager.hasBeenChanged();
}
});
mindplot.CommandContext = new Class({
initialize: function(designer)
{
initialize: function(designer) {
this._designer = designer;
},
findTopics:function(topicsIds)
{
findTopics:function(topicsIds) {
var designerTopics = this._designer._topics;
if (!(topicsIds instanceof Array))
{
if (!(topicsIds instanceof Array)) {
topicsIds = [topicsIds];
}
var result = designerTopics.filter(function(topic) {
var found = false;
if (topic != null)
{
if (topic != null) {
var topicId = topic.getId();
found = topicsIds.contains(topicId);
}
@ -88,32 +82,27 @@ mindplot.CommandContext = new Class({
});
return result;
},
deleteTopic:function(topic)
{
deleteTopic:function(topic) {
this._designer._removeNode(topic);
},
createTopic:function(model, isVisible)
{
createTopic:function(model, isVisible) {
core.assert(model, "model can not be null");
var topic = this._designer._nodeModelToNodeGraph(model, isVisible);
return topic;
},
createModel:function()
{
createModel:function() {
var mindmap = this._designer.getMindmap();
var model = mindmap.createNode(mindplot.NodeModel.MAIN_TOPIC_TYPE);
return model;
},
connect:function(childTopic, parentTopic, isVisible)
{
connect:function(childTopic, parentTopic, isVisible) {
childTopic.connectTo(parentTopic, this._designer._workspace, isVisible);
} ,
disconnect:function(topic)
{
disconnect:function(topic) {
topic.disconnect(this._designer._workspace);
},
createRelationship:function(model){
createRelationship:function(model) {
core.assert(model, "model cannot be null");
var relationship = this._designer.createRelationship(model);
return relationship;
@ -121,27 +110,25 @@ mindplot.CommandContext = new Class({
removeRelationship:function(model) {
this._designer.removeRelationship(model);
},
findRelationships:function(lineIds){
findRelationships:function(lineIds) {
var result = [];
lineIds.forEach(function(lineId, index){
lineIds.forEach(function(lineId, index) {
var line = this._designer._relationships[lineId];
if(core.Utils.isDefined(line)){
if (core.Utils.isDefined(line)) {
result.push(line);
}
}.bind(this));
return result;
},
getSelectedRelationshipLines:function(){
getSelectedRelationshipLines:function() {
return this._designer.getSelectedRelationshipLines();
}
});
mindplot.DesignerActionRunner.setInstance = function(actionRunner)
{
mindplot.DesignerActionRunner.setInstance = function(actionRunner) {
mindplot.DesignerActionRunner._instance = actionRunner;
};
mindplot.DesignerActionRunner.getInstance = function()
{
mindplot.DesignerActionRunner.getInstance = function() {
return mindplot.DesignerActionRunner._instance;
};

View File

@ -1,92 +1,83 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.DesignerUndoManager = new Class({
initialize: function()
{
initialize: function() {
this._undoQueue = [];
this._redoQueue = [];
this._baseId = 0;
},
enqueue:function(command)
{
enqueue:function(command) {
core.assert(command, "Command can not be null");
var length = this._undoQueue.length;
if (command.discartDuplicated && length > 0)
{
if (command.discartDuplicated && length > 0) {
// Skip duplicated events ...
var lastItem = this._undoQueue[length - 1];
if (lastItem.discartDuplicated != command.discartDuplicated)
{
if (lastItem.discartDuplicated != command.discartDuplicated) {
this._undoQueue.push(command);
}
} else
{
} else {
this._undoQueue.push(command);
}
this._redoQueue = [];
},
execUndo: function(commandContext)
{
if (this._undoQueue.length > 0)
{
execUndo: function(commandContext) {
if (this._undoQueue.length > 0) {
var command = this._undoQueue.pop();
this._redoQueue.push(command);
command.undoExecute(commandContext);
}
},
execRedo: function(commandContext)
{
if (this._redoQueue.length > 0)
{
execRedo: function(commandContext) {
if (this._redoQueue.length > 0) {
var command = this._redoQueue.pop();
this._undoQueue.push(command);
command.execute(commandContext);
}
},
_buildEvent: function()
{
_buildEvent: function() {
return {undoSteps: this._undoQueue.length, redoSteps:this._redoQueue.length};
},
markAsChangeBase: function()
{
markAsChangeBase: function() {
var undoLenght = this._undoQueue.length;
if (undoLenght > 0)
{
if (undoLenght > 0) {
var command = this._undoQueue[undoLenght - 1];
this._baseId = command.getId();
} else
{
} else {
this._baseId = 0;
}
},
hasBeenChanged: function()
{
hasBeenChanged: function() {
var result = true;
var undoLenght = this._undoQueue.length;
if (undoLenght == 0 && this._baseId == 0)
{
if (undoLenght == 0 && this._baseId == 0) {
result = false;
} else if(undoLenght>0)
{
} else if (undoLenght > 0) {
var command = this._undoQueue[undoLenght - 1];
result = (this._baseId != command.getId());
}
return result;
}});
}
});

View File

@ -20,7 +20,6 @@ mindplot.DragManager = function(workspace)
{
this._workspace = workspace;
this._listeners = {};
var dragManager = this;
};
mindplot.DragManager.prototype.add = function(node)

View File

@ -1,253 +1,227 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.DragPivot = function()
{
this._position = new core.Point();
this._size = mindplot.DragTopic.PIVOT_SIZE;
this._line = null;
mindplot.DragPivot = new Class({
initialize:function() {
this._position = new core.Point();
this._size = mindplot.DragTopic.PIVOT_SIZE;
this._line = null;
this._straightLine = this._buildStraightLine();
this._curvedLine = this._buildCurvedLine();
this._dragPivot = this._buildRect();
this._connectRect = this._buildRect();
this._targetTopic = null;
};
this._straightLine = this._buildStraightLine();
this._curvedLine = this._buildCurvedLine();
this._dragPivot = this._buildRect();
this._connectRect = this._buildRect();
this._targetTopic = null;
},
mindplot.DragPivot.prototype.getTargetTopic = function()
{
return this._targetTopic;
};
getTargetTopic : function() {
return this._targetTopic;
},
mindplot.DragPivot.prototype._buildStraightLine = function()
{
var line = new web2d.CurvedLine();
line.setStyle(web2d.CurvedLine.SIMPLE_LINE);
line.setStroke(1, 'solid', '#CC0033');
line.setOpacity(0.4);
line.setVisibility(false);
return line;
};
_buildStraightLine : function() {
var line = new web2d.CurvedLine();
line.setStyle(web2d.CurvedLine.SIMPLE_LINE);
line.setStroke(1, 'solid', '#CC0033');
line.setOpacity(0.4);
line.setVisibility(false);
return line;
},
mindplot.DragPivot.prototype._buildCurvedLine = function()
{
var line = new web2d.CurvedLine();
line.setStyle(web2d.CurvedLine.SIMPLE_LINE);
line.setStroke(1, 'solid', '#CC0033');
line.setOpacity(0.4);
line.setVisibility(false);
return line;
};
_buildCurvedLine : function() {
var line = new web2d.CurvedLine();
line.setStyle(web2d.CurvedLine.SIMPLE_LINE);
line.setStroke(1, 'solid', '#CC0033');
line.setOpacity(0.4);
line.setVisibility(false);
return line;
},
mindplot.DragPivot.prototype._redraw = function(pivotPosition)
{
// Update line position.
core.assert(this.getTargetTopic(), 'Illegal invocation. Target node can not be null');
_redraw : function(pivotPosition) {
// Update line position.
core.assert(this.getTargetTopic(), 'Illegal invocation. Target node can not be null');
var pivotRect = this._getPivotRect();
var currentPivotPosition = pivotRect.getPosition();
var pivotRect = this._getPivotRect();
var currentPivotPosition = pivotRect.getPosition();
// Pivot position has not changed. In this case, position change is not required.
var targetTopic = this.getTargetTopic();
if (currentPivotPosition.x != pivotPosition.x || currentPivotPosition.y != pivotPosition.y)
{
var position = this._position;
var fromPoint = targetTopic.workoutIncomingConnectionPoint(position);
// Pivot position has not changed. In this case, position change is not required.
var targetTopic = this.getTargetTopic();
if (currentPivotPosition.x != pivotPosition.x || currentPivotPosition.y != pivotPosition.y) {
var position = this._position;
var fromPoint = targetTopic.workoutIncomingConnectionPoint(position);
// Calculate pivot connection point ...
var size = this._size;
var targetPosition = targetTopic.getPosition();
var line = this._line;
// Calculate pivot connection point ...
var size = this._size;
var targetPosition = targetTopic.getPosition();
var line = this._line;
// Update Line position.
var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, position);
var pivotPoint = mindplot.util.Shape.calculateRectConnectionPoint(position, size, isAtRight);
line.setFrom(pivotPoint.x, pivotPoint.y);
// Update Line position.
var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, position);
var pivotPoint = mindplot.util.Shape.calculateRectConnectionPoint(position, size, isAtRight);
line.setFrom(pivotPoint.x, pivotPoint.y);
// Update rect position
pivotRect.setPosition(pivotPosition.x, pivotPosition.y);
// Update rect position
pivotRect.setPosition(pivotPosition.x, pivotPosition.y);
// Display elements if it's required...
if (!pivotRect.isVisible())
{
// Make line visible only when the position has been already changed.
// This solve several strange effects ;)
var targetPoint = targetTopic.workoutIncomingConnectionPoint(pivotPoint);
line.setTo(targetPoint.x, targetPoint.y);
// Display elements if it's required...
if (!pivotRect.isVisible()) {
// Make line visible only when the position has been already changed.
// This solve several strange effects ;)
var targetPoint = targetTopic.workoutIncomingConnectionPoint(pivotPoint);
line.setTo(targetPoint.x, targetPoint.y);
this.setVisibility(true);
this.setVisibility(true);
}
}
},
setPosition : function(point) {
this._position = point;
// Update visual position.
var size = this.getSize();
var cx = point.x - (parseInt(size.width) / 2);
var cy = point.y - (parseInt(size.height) / 2);
// Update line ...
if (this.getTargetTopic()) {
var pivotPosition = {x:cx,y:cy};
this._redraw(pivotPosition);
}
},
getPosition : function() {
return this._position;
},
_buildRect : function() {
var size = this._size;
var rectAttributes = {fillColor:'#CC0033',opacity:0.4,width:size.width,height:size.height,strokeColor:'#FF9933'};
var rect = new web2d.Rect(0, rectAttributes);
rect.setVisibility(false);
return rect;
},
_buildConnectRect : function() {
var size = this._size;
var rectAttributes = {fillColor:'#CC0033',opacity:0.4,width:size.width,height:size.height,strokeColor:'#FF9933'};
var result = new web2d.Rect(0, rectAttributes);
return result;
},
_getPivotRect : function() {
return this._dragPivot;
},
getSize : function() {
var elem2d = this._getPivotRect();
return elem2d.getSize();
},
setVisibility : function(value) {
var pivotRect = this._getPivotRect();
pivotRect.setVisibility(value);
var connectRect = this._connectRect;
connectRect.setVisibility(value);
if (core.Utils.isDefined(this._line)) {
this._line.setVisibility(value);
}
},
addToWorkspace : function(workspace) {
var pivotRect = this._getPivotRect();
workspace.appendChild(pivotRect);
var connectToRect = this._connectRect;
workspace.appendChild(connectToRect);
// Add a hidden straight line ...
var straighLine = this._straightLine;
straighLine.setVisibility(false);
workspace.appendChild(straighLine);
straighLine.moveToBack();
// Add a hidden curved line ...
var curvedLine = this._curvedLine;
curvedLine.setVisibility(false);
workspace.appendChild(curvedLine);
curvedLine.moveToBack();
// Add a connect rect ...
var connectRect = this._connectRect;
connectRect.setVisibility(false);
workspace.appendChild(connectRect);
connectRect.moveToBack();
},
removeFromWorkspace : function(workspace) {
var shape = this._getPivotRect();
workspace.removeChild(shape);
var connectToRect = this._connectRect;
workspace.removeChild(connectToRect);
if (core.Utils.isDefined(this._straightLine)) {
workspace.removeChild(this._straightLine);
}
if (core.Utils.isDefined(this._curvedLine)) {
workspace.removeChild(this._curvedLine);
}
},
connectTo : function(targetTopic) {
core.assert(!this._outgoingLine, 'Could not connect an already connected node');
core.assert(targetTopic != this, 'Cilcular connection are not allowed');
core.assert(targetTopic, 'parent can not be null');
this._targetTopic = targetTopic;
if (targetTopic.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE) {
this._line = this._straightLine;
} else {
this._line = this._curvedLine;
}
// Connected to Rect ...
var connectRect = this._connectRect;
var targetSize = targetTopic.getSize();
var width = targetSize.width;
var height = targetSize.height;
connectRect.setSize(width, height);
var targetPosition = targetTopic.getPosition();
var cx = Math.ceil(targetPosition.x - (width / 2));
var cy = Math.ceil(targetPosition.y - (height / 2));
connectRect.setPosition(cx, cy);
// Change elements position ...
var pivotRect = this._getPivotRect();
pivotRect.moveToFront();
},
disconnect : function(workspace) {
core.assert(workspace, 'workspace can not be null.');
core.assert(this._targetTopic, 'There are not connected topic.');
this.setVisibility(false);
this._targetTopic = null;
this._line = null;
}
};
mindplot.DragPivot.prototype.setPosition = function(point)
{
this._position = point;
// Update visual position.
var pivotRect = this._getPivotRect();
var size = this.getSize();
var cx = point.x - (parseInt(size.width) / 2);
var cy = point.y - (parseInt(size.height) / 2);
// Update line ...
if (this.getTargetTopic())
{
var pivotPosition = {x:cx,y:cy};
this._redraw(pivotPosition);
}
};
mindplot.DragPivot.prototype.getPosition = function()
{
return this._position;
};
mindplot.DragPivot.prototype._buildRect = function()
{
var size = this._size;
var rectAttributes = {fillColor:'#CC0033',opacity:0.4,width:size.width,height:size.height,strokeColor:'#FF9933'};
var rect = new web2d.Rect(0, rectAttributes);
rect.setVisibility(false);
return rect;
};
mindplot.DragPivot.prototype._buildConnectRect = function()
{
var size = this._size;
var rectAttributes = {fillColor:'#CC0033',opacity:0.4,width:size.width,height:size.height,strokeColor:'#FF9933'};
var result = new web2d.Rect(0, rectAttributes);
return result;
};
mindplot.DragPivot.prototype._getPivotRect = function()
{
return this._dragPivot;
};
mindplot.DragPivot.prototype.getSize = function()
{
var elem2d = this._getPivotRect();
return elem2d.getSize();
};
mindplot.DragPivot.prototype.setVisibility = function(value)
{
var pivotRect = this._getPivotRect();
pivotRect.setVisibility(value);
var connectRect = this._connectRect;
connectRect.setVisibility(value);
if (core.Utils.isDefined(this._line))
{
this._line.setVisibility(value);
}
};
mindplot.DragPivot.prototype.addToWorkspace = function(workspace)
{
var pivotRect = this._getPivotRect();
workspace.appendChild(pivotRect);
var connectToRect = this._connectRect;
workspace.appendChild(connectToRect);
// Add a hidden straight line ...
var straighLine = this._straightLine;
straighLine.setVisibility(false);
workspace.appendChild(straighLine);
straighLine.moveToBack();
// Add a hidden curved line ...
var curvedLine = this._curvedLine;
curvedLine.setVisibility(false);
workspace.appendChild(curvedLine);
curvedLine.moveToBack();
// Add a connect rect ...
var connectRect = this._connectRect;
connectRect.setVisibility(false);
workspace.appendChild(connectRect);
connectRect.moveToBack();
};
mindplot.DragPivot.prototype.removeFromWorkspace = function(workspace)
{
var shape = this._getPivotRect();
workspace.removeChild(shape);
var connectToRect = this._connectRect;
workspace.removeChild(connectToRect);
if (core.Utils.isDefined(this._straightLine))
{
workspace.removeChild(this._straightLine);
}
if (core.Utils.isDefined(this._curvedLine))
{
workspace.removeChild(this._curvedLine);
}
};
mindplot.DragPivot.prototype.connectTo = function(targetTopic)
{
core.assert(!this._outgoingLine, 'Could not connect an already connected node');
core.assert(targetTopic != this, 'Cilcular connection are not allowed');
core.assert(targetTopic, 'parent can not be null');
this._targetTopic = targetTopic;
if (targetTopic.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE)
{
this._line = this._straightLine;
} else
{
this._line = this._curvedLine;
}
// Show pivot ...
var line = this._line;
// Connected to Rect ...
var connectRect = this._connectRect;
var targetSize = targetTopic.getSize();
var width = targetSize.width;
var height = targetSize.height;
connectRect.setSize(width, height);
var targetPosition = targetTopic.getPosition();
var cx = Math.ceil(targetPosition.x - (width / 2));
var cy = Math.ceil(targetPosition.y - (height / 2));
connectRect.setPosition(cx, cy);
// Change elements position ...
var pivotRect = this._getPivotRect();
pivotRect.moveToFront();
};
mindplot.DragPivot.prototype.disconnect = function(workspace)
{
core.assert(workspace, 'workspace can not be null.');
core.assert(this._targetTopic, 'There are not connected topic.');
this.setVisibility(false);
this._targetTopic = null;
this._line = null;
};
});

View File

@ -1,131 +1,115 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.DragTopicPositioner = function(layoutManager)
{
core.assert(layoutManager, 'layoutManager can not be null');
this._layoutManager = layoutManager;
this._topics = layoutManager.getDesigner()._getTopics();
this._workspace = layoutManager.getDesigner().getWorkSpace();
};
mindplot.DragTopicPositioner = new Class({
initialize:function(layoutManager) {
core.assert(layoutManager, 'layoutManager can not be null');
this._layoutManager = layoutManager;
this._topics = layoutManager.getDesigner()._getTopics();
this._workspace = layoutManager.getDesigner().getWorkSpace();
},
mindplot.DragTopicPositioner.prototype.positionateDragTopic = function(dragTopic)
{
// Workout the real position of the element on the board.
var dragTopicPosition = dragTopic.getPosition();
var draggedTopic = dragTopic.getDraggedTopic();
positionateDragTopic : function(dragTopic) {
// Workout the real position of the element on the board.
var dragTopicPosition = dragTopic.getPosition();
var draggedTopic = dragTopic.getDraggedTopic();
// Topic can be connected ?
this._checkDragTopicConnection(dragTopic);
// Topic can be connected ?
this._checkDragTopicConnection(dragTopic);
// Position topic in the board
if (dragTopic.isConnected())
{
var targetTopic = dragTopic.getConnectedToTopic();
var topicBoard = this._layoutManager.getTopicBoardForTopic(targetTopic);
topicBoard.positionateDragTopic(dragTopic);
// Position topic in the board
if (dragTopic.isConnected()) {
var targetTopic = dragTopic.getConnectedToTopic();
var topicBoard = this._layoutManager.getTopicBoardForTopic(targetTopic);
topicBoard.positionateDragTopic(dragTopic);
}
},
_checkDragTopicConnection : function(dragTopic) {
var topics = this._topics;
// Must be disconnected from their current connection ?.
var mainTopicToMainTopicConnection = this._lookUpForMainTopicToMainTopicConnection(dragTopic);
var currentConnection = dragTopic.getConnectedToTopic();
if (core.Utils.isDefined(currentConnection)) {
// MainTopic->MainTopicConnection.
if (currentConnection.getType() == mindplot.NodeModel.MAIN_TOPIC_TYPE) {
if (mainTopicToMainTopicConnection != currentConnection) {
dragTopic.disconnect(this._workspace);
}
}
else if (currentConnection.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE) {
// Distance if greater that the allowed.
var dragXPosition = dragTopic.getPosition().x;
var currentXPosition = currentConnection.getPosition().x;
if (core.Utils.isDefined(mainTopicToMainTopicConnection)) {
// I have to change the current connection to a main topic.
dragTopic.disconnect(this._workspace);
} else
if (Math.abs(dragXPosition - currentXPosition) > mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE) {
dragTopic.disconnect(this._workspace);
}
}
}
// Finally, connect nodes ...
if (!dragTopic.isConnected()) {
var centalTopic = topics[0];
if (core.Utils.isDefined(mainTopicToMainTopicConnection)) {
dragTopic.connectTo(mainTopicToMainTopicConnection);
} else if (Math.abs(dragTopic.getPosition().x - centalTopic.getPosition().x) <= mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE) {
dragTopic.connectTo(centalTopic);
}
}
},
_lookUpForMainTopicToMainTopicConnection : function(dragTopic) {
var topics = this._topics;
var result = null;
var clouserDistance = -1;
var draggedNode = dragTopic.getDraggedTopic();
var distance = null;
// Check MainTopic->MainTopic connection...
for (var i = 0; i < topics.length; i++) {
var targetTopic = topics[i];
var position = dragTopic.getPosition();
if (targetTopic.getType() != mindplot.NodeModel.CENTRAL_TOPIC_TYPE && targetTopic != draggedNode) {
var canBeConnected = dragTopic.canBeConnectedTo(targetTopic);
if (canBeConnected) {
var targetPosition = targetTopic.getPosition();
var fix = position.y > targetPosition.y;
var gap = 0;
if (targetTopic._getChildren().length > 0) {
gap = Math.abs(targetPosition.y - targetTopic._getChildren()[0].getPosition().y)
}
var yDistance = Math.abs(position.y - fix * gap - targetPosition.y);
if (distance == null || yDistance < distance) {
result = targetTopic;
distance = yDistance;
}
}
}
}
return result;
}
};
});
mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE = 400;
mindplot.DragTopicPositioner.prototype._checkDragTopicConnection = function(dragTopic)
{
var topics = this._topics;
// Must be disconnected from their current connection ?.
var mainTopicToMainTopicConnection = this._lookUpForMainTopicToMainTopicConnection(dragTopic);
var currentConnection = dragTopic.getConnectedToTopic();
if (core.Utils.isDefined(currentConnection))
{
// MainTopic->MainTopicConnection.
if (currentConnection.getType()==mindplot.NodeModel.MAIN_TOPIC_TYPE)
{
if(mainTopicToMainTopicConnection != currentConnection)
{
dragTopic.disconnect(this._workspace);
}
}
else if (currentConnection.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE)
{
// Distance if greater that the allowed.
var dragXPosition = dragTopic.getPosition().x;
var currentXPosition = currentConnection.getPosition().x;
if(core.Utils.isDefined(mainTopicToMainTopicConnection))
{
// I have to change the current connection to a main topic.
dragTopic.disconnect(this._workspace);
}else
if (Math.abs(dragXPosition-currentXPosition) > mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE)
{
dragTopic.disconnect(this._workspace);
}
}
}
// Finally, connect nodes ...
if (!dragTopic.isConnected())
{
var centalTopic = topics[0];
if (core.Utils.isDefined(mainTopicToMainTopicConnection))
{
dragTopic.connectTo(mainTopicToMainTopicConnection);
} else if (Math.abs(dragTopic.getPosition().x - centalTopic.getPosition().x) <= mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE)
{
dragTopic.connectTo(centalTopic);
}
}
};
mindplot.DragTopicPositioner.prototype._lookUpForMainTopicToMainTopicConnection = function(dragTopic)
{
var topics = this._topics;
var result = null;
var clouserDistance = -1;
var draggedNode = dragTopic.getDraggedTopic();
var distance = null;
// Check MainTopic->MainTopic connection...
for (var i = 0; i < topics.length; i++)
{
var targetTopic = topics[i];
var position = dragTopic.getPosition();
if (targetTopic.getType() != mindplot.NodeModel.CENTRAL_TOPIC_TYPE && targetTopic != draggedNode)
{
var canBeConnected = dragTopic.canBeConnectedTo(targetTopic);
if (canBeConnected)
{
var targetPosition = targetTopic.getPosition();
var fix = position.y>targetPosition.y;
var gap = 0;
if(targetTopic._getChildren().length>0){
gap = Math.abs(targetPosition.y - targetTopic._getChildren()[0].getPosition().y)
}
var yDistance = Math.abs(position.y -fix*gap - targetPosition.y);
if(distance==null || yDistance<distance)
{
result = targetTopic;
distance = yDistance;
}
}
}
}
return result;
};

View File

@ -4,5 +4,4 @@ mindplot.EditorOptions =
// LayoutManager:"FreeMindLayout",
textEditor:"TextEditor"
// textEditor:"RichTextEditor"
};

View File

@ -1,41 +1,39 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.EditorProperties = function()
{
this._zoom = 0;
this._position = 0;
};
mindplot.EditorProperties = new Class({
initialize:function() {
this._zoom = 0;
this._position = 0;
},
mindplot.EditorProperties.prototype.setZoom = function(zoom)
{
this._zoom = zoom;
};
setZoom : function(zoom) {
this._zoom = zoom;
},
mindplot.EditorProperties.prototype.getZoom = function()
{
return this._zoom;
};
getZoom : function() {
return this._zoom;
},
mindplot.EditorProperties.prototype.asProperties = function()
{
return "zoom=" + this._zoom + "\n";
};
asProperties : function() {
return "zoom=" + this._zoom + "\n";
}
});

View File

@ -1,17 +1,16 @@
mindplot.EventBus = new Class({
Extends:Options,
Implements:Events,
options: {
},
initialize: function(options) {
this.setOptions(options);
}
});
mindplot.EventBus.implement(new Events);
mindplot.EventBus.implement(new Options);
mindplot.EventBus.events ={
mindplot.EventBus.events = {
NodeResizeEvent:'NodeResizeEvent',
NodeMoveEvent:'NodeMoveEvent',
NodeDisconnectEvent:'NodeDisconnectEvent',

View File

@ -1,324 +1,287 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.FixedDistanceBoard = function(defaultHeight, topic, layoutManager)
{
this._topic = topic;
this._layoutManager = layoutManager;
var reference = topic.getPosition();
mindplot.FixedDistanceBoard.superClass.initialize.call(this, defaultHeight, reference);
this._height = defaultHeight;
this._entries = [];
};
objects.extend(mindplot.FixedDistanceBoard, mindplot.Board);
mindplot.FixedDistanceBoard.prototype.getHeight = function()
{
return this._height;
};
mindplot.FixedDistanceBoard.prototype.lookupEntryByOrder = function(order)
{
var result = null;
var entries = this._entries;
if (order < entries.length)
{
result = entries[order];
}
if (result == null)
{
var defaultHeight = this._defaultWidth;
var reference = this.getReferencePoint();
if (entries.length == 0)
{
var yReference = reference.y;
result = this.createBoardEntry(yReference - (defaultHeight / 2), yReference + (defaultHeight / 2), 0);
} else
{
var entriesLenght = entries.length;
var lastEntry = entries[entriesLenght - 1];
var lowerLimit = lastEntry.getUpperLimit();
var upperLimit = lowerLimit + defaultHeight;
result = this.createBoardEntry(lowerLimit, upperLimit, entriesLenght + 1);
}
}
return result;
};
mindplot.FixedDistanceBoard.prototype.createBoardEntry = function(lowerLimit, upperLimit, order)
{
var result = new mindplot.BoardEntry(lowerLimit, upperLimit, order);
var xPos = this.workoutXBorderDistance();
result.setXPosition(xPos);
return result;
};
mindplot.FixedDistanceBoard.prototype.updateReferencePoint = function()
{
var entries = this._entries;
var parentTopic = this.getTopic();
var parentPosition = parentTopic.workoutIncomingConnectionPoint(parentTopic.getPosition());
var referencePoint = this.getReferencePoint();
var yOffset = parentPosition.y - referencePoint.y;
for (var i = 0; i < entries.length; i++)
{
var entry = entries[i];
if(core.Utils.isDefined(entry)){
var upperLimit = entry.getUpperLimit() + yOffset;
var lowerLimit = entry.getLowerLimit() + yOffset;
entry.setUpperLimit(upperLimit);
entry.setLowerLimit(lowerLimit);
// Fix x position ...
var xPos = this.workoutXBorderDistance();
entry.setXPosition(xPos);
entry.update();
}
}
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.
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.FixedDistanceBoard.prototype.workoutXBorderDistance = function()
{
var topic = this.getTopic();
var topicPosition = topic.getPosition();
var topicSize = topic.getSize();
var halfTargetWidth = topicSize.width / 2;
var result;
if (topicPosition.x >= 0)
{
// It's at right.
result = topicPosition.x + halfTargetWidth + mindplot.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE;
} else
{
result = topicPosition.x - (halfTargetWidth + mindplot.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE);
}
return result;
};
mindplot.FixedDistanceBoard = new Class({
Extends:mindplot.Board,
initialize:function(defaultHeight, topic, layoutManager) {
this._topic = topic;
this._layoutManager = layoutManager;
var reference = topic.getPosition();
this.parent(defaultHeight, reference);
this._height = defaultHeight;
this._entries = [];
},
mindplot.FixedDistanceBoard.prototype.getTopic = function()
{
return this._topic;
};
getHeight : function() {
return this._height;
},
mindplot.FixedDistanceBoard.INTER_TOPIC_DISTANCE = 6;
mindplot.FixedDistanceBoard.prototype.freeEntry = function(entry)
{
var newEntries = [];
var entries = this._entries;
var order = 0;
for (var i = 0; i < entries.length; i++)
{
var e = entries[i];
if (e == entry)
{
order++;
lookupEntryByOrder : function(order) {
var result = null;
var entries = this._entries;
if (order < entries.length) {
result = entries[order];
}
newEntries[order] = e;
order++;
}
this._entries = newEntries;
};
mindplot.FixedDistanceBoard.prototype.repositionate = function()
{
// Workout width and update topic height.
var entries = this._entries;
var height = 0;
var model = this._topic.getModel();
if (entries.length >= 1 && !model.areChildrenShrinked())
{
for (var i = 0; i < entries.length; i++)
{
var e = entries[i];
if (e && e.getTopic())
{
var topic = e.getTopic();
var topicBoard = this._layoutManager.getTopicBoardForTopic(topic);
var topicBoardHeight = topicBoard.getHeight();
height += topicBoardHeight + mindplot.FixedDistanceBoard.INTER_TOPIC_DISTANCE;
}
}
}
else {
var topic = this._topic;
height = topic.getSize().height + mindplot.FixedDistanceBoard.INTER_TOPIC_DISTANCE;
}
var oldHeight = this._height;
this._height = height;
// I must update all the parent nodes first...
if (oldHeight != this._height)
{
var topic = this._topic;
var parentTopic = topic.getParent();
if (parentTopic != null)
{
var board = this._layoutManager.getTopicBoardForTopic(parentTopic);
board.repositionate();
}
}
// @todo: Esto hace backtraking. Hay que cambiar la implementacion del set position de
// forma tal que no se mande a hacer el update de todos los hijos.
// Workout center the new topic center...
var refence = this.getReferencePoint();
var lowerLimit;
if (entries.length > 0)
{
var l = 0;
for(l=0; l<entries.length; l++){
if(core.Utils.isDefined(entries[l]))
break;
}
var topic = entries[l].getTopic();
var firstNodeHeight = topic.getSize().height;
lowerLimit = refence.y - (height / 2) - (firstNodeHeight / 2) + 1;
}
var upperLimit = null;
// Start moving all the elements ...
var newEntries = [];
var order = 0;
for (var i = 0; i < entries.length; i++)
{
var e = entries[i];
if (e && e.getTopic())
{
var currentTopic = e.getTopic();
e.setLowerLimit(lowerLimit);
// Update entry ...
var topicBoard = this._layoutManager.getTopicBoardForTopic(currentTopic);
var topicBoardHeight = topicBoard.getHeight();
upperLimit = lowerLimit + topicBoardHeight + mindplot.FixedDistanceBoard.INTER_TOPIC_DISTANCE;
e.setUpperLimit(upperLimit);
lowerLimit = upperLimit;
e.setOrder(order);
currentTopic.setOrder(order);
e.update();
newEntries[order] = e;
order++;
}
}
this._entries = newEntries;
};
mindplot.FixedDistanceBoard.prototype.removeTopic = function(topic)
{
var order = topic.getOrder();
var entry = this.lookupEntryByOrder(order);
core.assert(!entry.isAvailable(), "Illegal state");
entry.setTopic(null);
topic.setOrder(null);
this._entries.erase(entry);
// Repositionate all elements ...
this.repositionate();
};
mindplot.FixedDistanceBoard.prototype.addTopic = function(order, topic)
{
// If the entry is not available, I must swap the the entries...
var entry = this.lookupEntryByOrder(order);
if (!entry.isAvailable())
{
this.freeEntry(entry);
// Create a dummy entry ...
// Puaj, do something with this...
entry = this.createBoardEntry(-1, 0, order);
this._entries[order] = entry;
}
this._entries[order] = entry;
// Add to the board ...
entry.setTopic(topic, false);
// Repositionate all elements ...
this.repositionate();
};
mindplot.FixedDistanceBoard.prototype.lookupEntryByPosition = function(pos)
{
core.assert(core.Utils.isDefined(pos), 'position can not be null');
var entries = this._entries;
var result = null;
for (var i = 0; i < entries.length; i++)
{
var entry = entries[i];
if (pos.y < entry.getUpperLimit() && pos.y >= entry.getLowerLimit())
{
result = entry;
}
}
if (result == null)
{
var defaultHeight = this._defaultWidth;
if (entries.length == 0)
{
if (result == null) {
var defaultHeight = this._defaultWidth;
var reference = this.getReferencePoint();
var yReference = reference.y;
result = this.createBoardEntry(yReference - (defaultHeight / 2), yReference + (defaultHeight / 2), 0);
} else
{
var firstEntry = entries[0];
if (pos.y < firstEntry.getLowerLimit())
{
var upperLimit = firstEntry.getLowerLimit();
var lowerLimit = upperLimit - defaultHeight;
result = this.createBoardEntry(lowerLimit, upperLimit, 0);
} else
{
if (entries.length == 0) {
var yReference = reference.y;
result = this.createBoardEntry(yReference - (defaultHeight / 2), yReference + (defaultHeight / 2), 0);
} else {
var entriesLenght = entries.length;
var lastEntry = entries[entriesLenght - 1];
var lowerLimit = lastEntry.getUpperLimit();
var upperLimit = lowerLimit + defaultHeight;
result = this.createBoardEntry(lowerLimit, upperLimit, entriesLenght);
result = this.createBoardEntry(lowerLimit, upperLimit, entriesLenght + 1);
}
}
}
return result;
},
createBoardEntry : function(lowerLimit, upperLimit, order) {
var result = new mindplot.BoardEntry(lowerLimit, upperLimit, order);
var xPos = this.workoutXBorderDistance();
result.setXPosition(xPos);
return result;
},
updateReferencePoint : function() {
var entries = this._entries;
var parentTopic = this.getTopic();
var parentPosition = parentTopic.workoutIncomingConnectionPoint(parentTopic.getPosition());
var referencePoint = this.getReferencePoint();
var yOffset = parentPosition.y - referencePoint.y;
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
if (core.Utils.isDefined(entry)) {
var upperLimit = entry.getUpperLimit() + yOffset;
var lowerLimit = entry.getLowerLimit() + yOffset;
entry.setUpperLimit(upperLimit);
entry.setLowerLimit(lowerLimit);
// Fix x position ...
var xPos = this.workoutXBorderDistance();
entry.setXPosition(xPos);
entry.update();
}
}
this._referencePoint = parentPosition.clone();
},
/**
* This x distance doesn't take into account the size of the shape.
*/
workoutXBorderDistance : function() {
var topic = this.getTopic();
var topicPosition = topic.getPosition();
var topicSize = topic.getSize();
var halfTargetWidth = topicSize.width / 2;
var result;
if (topicPosition.x >= 0) {
// It's at right.
result = topicPosition.x + halfTargetWidth + mindplot.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE;
} else {
result = topicPosition.x - (halfTargetWidth + mindplot.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE);
}
return result;
},
getTopic : function() {
return this._topic;
},
freeEntry : function(entry) {
var newEntries = [];
var entries = this._entries;
var order = 0;
for (var i = 0; i < entries.length; i++) {
var e = entries[i];
if (e == entry) {
order++;
}
newEntries[order] = e;
order++;
}
this._entries = newEntries;
},
repositionate : function() {
// Workout width and update topic height.
var entries = this._entries;
var height = 0;
var model = this._topic.getModel();
if (entries.length >= 1 && !model.areChildrenShrinked()) {
for (var i = 0; i < entries.length; i++) {
var e = entries[i];
if (e && e.getTopic()) {
var topic = e.getTopic();
var topicBoard = this._layoutManager.getTopicBoardForTopic(topic);
var topicBoardHeight = topicBoard.getHeight();
height += topicBoardHeight + mindplot.FixedDistanceBoard.INTER_TOPIC_DISTANCE;
}
}
}
else {
var topic = this._topic;
height = topic.getSize().height + mindplot.FixedDistanceBoard.INTER_TOPIC_DISTANCE;
}
var oldHeight = this._height;
this._height = height;
// I must update all the parent nodes first...
if (oldHeight != this._height) {
var topic = this._topic;
var parentTopic = topic.getParent();
if (parentTopic != null) {
var board = this._layoutManager.getTopicBoardForTopic(parentTopic);
board.repositionate();
}
}
// @todo: Esto hace backtraking. Hay que cambiar la implementacion del set position de
// forma tal que no se mande a hacer el update de todos los hijos.
// Workout center the new topic center...
var refence = this.getReferencePoint();
var lowerLimit;
if (entries.length > 0) {
var l = 0;
for (l = 0; l < entries.length; l++) {
if (core.Utils.isDefined(entries[l]))
break;
}
var topic = entries[l].getTopic();
var firstNodeHeight = topic.getSize().height;
lowerLimit = refence.y - (height / 2) - (firstNodeHeight / 2) + 1;
}
var upperLimit = null;
// Start moving all the elements ...
var newEntries = [];
var order = 0;
for (var i = 0; i < entries.length; i++) {
var e = entries[i];
if (e && e.getTopic()) {
var currentTopic = e.getTopic();
e.setLowerLimit(lowerLimit);
// Update entry ...
var topicBoard = this._layoutManager.getTopicBoardForTopic(currentTopic);
var topicBoardHeight = topicBoard.getHeight();
upperLimit = lowerLimit + topicBoardHeight + mindplot.FixedDistanceBoard.INTER_TOPIC_DISTANCE;
e.setUpperLimit(upperLimit);
lowerLimit = upperLimit;
e.setOrder(order);
currentTopic.setOrder(order);
e.update();
newEntries[order] = e;
order++;
}
}
this._entries = newEntries;
},
removeTopic : function(topic) {
var order = topic.getOrder();
var entry = this.lookupEntryByOrder(order);
core.assert(!entry.isAvailable(), "Illegal state");
entry.setTopic(null);
topic.setOrder(null);
this._entries.erase(entry);
// Repositionate all elements ...
this.repositionate();
},
addTopic : function(order, topic) {
// If the entry is not available, I must swap the the entries...
var entry = this.lookupEntryByOrder(order);
if (!entry.isAvailable()) {
this.freeEntry(entry);
// Create a dummy entry ...
// Puaj, do something with this...
entry = this.createBoardEntry(-1, 0, order);
this._entries[order] = entry;
}
this._entries[order] = entry;
// Add to the board ...
entry.setTopic(topic, false);
// Repositionate all elements ...
this.repositionate();
},
lookupEntryByPosition : function(pos) {
core.assert(core.Utils.isDefined(pos), 'position can not be null');
var entries = this._entries;
var result = null;
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
if (pos.y < entry.getUpperLimit() && pos.y >= entry.getLowerLimit()) {
result = entry;
}
}
if (result == null) {
var defaultHeight = this._defaultWidth;
if (entries.length == 0) {
var reference = this.getReferencePoint();
var yReference = reference.y;
result = this.createBoardEntry(yReference - (defaultHeight / 2), yReference + (defaultHeight / 2), 0);
} else {
var firstEntry = entries[0];
if (pos.y < firstEntry.getLowerLimit()) {
var upperLimit = firstEntry.getLowerLimit();
var lowerLimit = upperLimit - defaultHeight;
result = this.createBoardEntry(lowerLimit, upperLimit, 0);
} else {
var entriesLenght = entries.length;
var lastEntry = entries[entriesLenght - 1];
var lowerLimit = lastEntry.getUpperLimit();
var upperLimit = lowerLimit + defaultHeight;
result = this.createBoardEntry(lowerLimit, upperLimit, entriesLenght);
}
}
}
return result;
}
})
;
mindplot.FixedDistanceBoard.INTER_TOPIC_DISTANCE = 6;
mindplot.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE = 60;
return result;
};

View File

@ -1,41 +1,43 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.Icon = function(url){
this._image = new web2d.Image();
this._image.setHref(url);
this._image.setSize(12,12);
};
mindplot.Icon = new Class({
initialize:function(url) {
this._image = new web2d.Image();
this._image.setHref(url);
this._image.setSize(12, 12);
},
mindplot.Icon.prototype.getImage= function(){
return this._image;
};
getImage : function() {
return this._image;
},
mindplot.Icon.prototype.setGroup= function(group){
this._group=group;
};
setGroup : function(group) {
this._group = group;
},
mindplot.Icon.prototype.getGroup= function() {
return this._group;
};
getGroup : function() {
return this._group;
},
mindplot.Icon.prototype.getSize=function(){
return this._image.getSize();
};
getSize : function() {
return this._image.getSize();
}
});

View File

@ -1,198 +1,195 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.IconGroup = function(topic) {
var offset = topic.getOffset();
this.options = {
width:0,
height:0,
x:offset.x / 2,
y:offset.y,
icons:[],
topic:topic,
nativeElem:new web2d.Group({width: 2, height:2,x: offset, y:offset, coordSizeWidth:1,coordSizeHeight:1})
};
this.updateIconGroupPosition();
this.registerListeners();
};
mindplot.IconGroup = new Class({
initialize : function(topic) {
var offset = topic.getOffset();
mindplot.IconGroup.prototype.setPosition = function(x, y) {
this.options.x = x;
this.options.y = y;
this.options.nativeElem.setPosition(x, y);
};
this.options = {
width:0,
height:0,
x:offset.x / 2,
y:offset.y,
icons:[],
topic:topic,
nativeElem:new web2d.Group({width: 2, height:2,x: offset, y:offset, coordSizeWidth:1,coordSizeHeight:1})
};
this.updateIconGroupPosition();
this.registerListeners();
},
mindplot.IconGroup.prototype.getPosition = function() {
return {x:this.options.x, y:this.options.y};
};
setPosition : function(x, y) {
this.options.x = x;
this.options.y = y;
this.options.nativeElem.setPosition(x, y);
},
mindplot.IconGroup.prototype.setSize = function(width, height) {
this.options.width = width;
this.options.height = height;
this.options.nativeElem.setSize(width, height);
this.options.nativeElem.setCoordSize(width, height);
};
getPosition : function() {
return {x:this.options.x, y:this.options.y};
},
mindplot.IconGroup.prototype.getSize = function()
{
return {width:this.options.width, height:this.options.height};
};
setSize : function(width, height) {
this.options.width = width;
this.options.height = height;
this.options.nativeElem.setSize(width, height);
this.options.nativeElem.setCoordSize(width, height);
},
mindplot.IconGroup.prototype.addIcon = function(icon) {
icon.setGroup(this);
var newIcon = icon.getImage();
var nativeElem = this.options.nativeElem;
var iconSize = newIcon.getSize();
var size = nativeElem.getSize();
newIcon.setPosition(size.width, 0);
this.options.icons.extend([icon]);
getSize : function() {
return {width:this.options.width, height:this.options.height};
},
nativeElem.appendChild(newIcon);
addIcon : function(icon) {
icon.setGroup(this);
var newIcon = icon.getImage();
var nativeElem = this.options.nativeElem;
var iconSize = newIcon.getSize();
var size = nativeElem.getSize();
newIcon.setPosition(size.width, 0);
this.options.icons.extend([icon]);
size.width = size.width + iconSize.width;
if (iconSize.height > size.height)
{
size.height = iconSize.height;
nativeElem.appendChild(newIcon);
size.width = size.width + iconSize.width;
if (iconSize.height > size.height) {
size.height = iconSize.height;
}
nativeElem.setCoordSize(size.width, size.height);
nativeElem.setSize(size.width, size.height);
this.options.width = size.width;
this.options.height = size.height;
},
getIcons : function() {
return this.options.icons;
},
removeIcon : function(url) {
this._removeIcon(this.getIcon(url));
},
removeImageIcon : function(icon) {
var imgIcon = this.getImageIcon(icon);
this._removeIcon(imgIcon);
},
getIcon : function(url) {
var result = null;
this.options.icons.each(function(el, index) {
var nativeImage = el.getImage();
if (nativeImage.getHref() == url) {
result = el;
}
}, this);
return result;
},
getImageIcon : function(icon) {
var result = null;
this.options.icons.each(function(el, index) {
if (result == null && $chk(el.getModel().isIconModel) && el.getId() == icon.getId() && el.getUiId() == icon.getUiId()) {
result = el;
}
}, this);
return result;
},
findIconFromModel : function(iconModel) {
var result = null;
this.options.icons.each(function(el, index) {
var elModel = el.getModel();
if (result == null && $chk(elModel.isIconModel) && elModel.getId() == iconModel.getId()) {
result = el;
}
}, this);
if (result == null) {
throw "Icon can no be found.";
}
return result;
},
_removeIcon : function(icon) {
var nativeImage = icon.getImage();
this.options.icons.erase(icon);
var iconSize = nativeImage.getSize();
var size = this.options.nativeElem.getSize();
var position = nativeImage.getPosition();
var childs = this.options.nativeElem.removeChild(nativeImage);
this.options.icons.each(function(icon, index) {
var img = icon.getImage();
var pos = img.getPosition();
if (pos.x > position.x) {
img.setPosition(pos.x - iconSize.width, 0);
}
}.bind(this));
size.width = size.width - iconSize.width;
this.setSize(size.width, size.height);
},
getNativeElement : function() {
return this.options.nativeElem;
},
moveToFront : function() {
this.options.nativeElem.moveToFront();
},
registerListeners : function() {
this.options.nativeElem.addEventListener('click', function(event) {
// Avoid node creation ...
if (core.Utils.isDefined(event.stopPropagation)) {
event.stopPropagation(true);
} else {
event.cancelBubble = true;
}
});
this.options.nativeElem.addEventListener('dblclick', function(event) {
// Avoid node creation ...
if (core.Utils.isDefined(event.stopPropagation)) {
event.stopPropagation(true);
} else {
event.cancelBubble = true;
}
});
},
getTopic : function() {
return this.options.topic;
},
updateIconGroupPosition : function() {
var offsets = this._calculateOffsets();
this.setPosition(offsets.x, offsets.y);
},
_calculateOffsets : function() {
var offset = this.options.topic.getOffset();
var text = this.options.topic.getTextShape();
var sizeHeight = text.getHtmlFontSize();
var yOffset = offset;
var shape = this.options.topic.getShapeType();
yOffset = text.getPosition().y + (sizeHeight - 18) / 2 + 1;
return {x:offset, y:yOffset};
}
nativeElem.setCoordSize(size.width, size.height);
nativeElem.setSize(size.width, size.height);
this.options.width = size.width;
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) {
var imgIcon = this.getImageIcon(icon);
this._removeIcon(imgIcon);
};
mindplot.IconGroup.prototype.getIcon = function(url) {
var result = null;
this.options.icons.each(function(el, index) {
var nativeImage = el.getImage();
if (nativeImage.getHref() == url)
{
result = el;
}
}, this);
return result;
};
mindplot.IconGroup.prototype.getImageIcon=function(icon){
var result = null;
this.options.icons.each(function(el,index){
if(result == null && $chk(el.getModel().isIconModel) && el.getId()==icon.getId() && el.getUiId() == icon.getUiId())
{
result = el;
}
},this);
return result;
};
mindplot.IconGroup.prototype.findIconFromModel=function(iconModel){
var result = null;
this.options.icons.each(function(el,index){
var elModel = el.getModel();
if(result == null && $chk(elModel.isIconModel) && elModel.getId()==iconModel.getId())
{
result = el;
}
},this);
if(result==null)
{
throw "Icon can no be found.";
}
return result;
};
mindplot.IconGroup.prototype._removeIcon = function(icon) {
var nativeImage = icon.getImage();
this.options.icons.erase(icon);
var iconSize = nativeImage.getSize();
var size = this.options.nativeElem.getSize();
var position = nativeImage.getPosition();
var childs = this.options.nativeElem.removeChild(nativeImage);
this.options.icons.each(function(icon,index){
var img = icon.getImage();
var pos = img.getPosition();
if(pos.x > position.x){
img.setPosition(pos.x-iconSize.width, 0);
}
}.bind(this));
size.width = size.width - iconSize.width;
this.setSize(size.width, size.height);
};
mindplot.IconGroup.prototype.getNativeElement = function() {
return this.options.nativeElem;
};
mindplot.IconGroup.prototype.moveToFront = function() {
this.options.nativeElem.moveToFront();
}
mindplot.IconGroup.prototype.registerListeners = function() {
this.options.nativeElem.addEventListener('click', function(event) {
// Avoid node creation ...
if (core.Utils.isDefined(event.stopPropagation))
{
event.stopPropagation(true);
} else
{
event.cancelBubble = true;
}
});
this.options.nativeElem.addEventListener('dblclick', function(event)
{
// Avoid node creation ...
if (core.Utils.isDefined(event.stopPropagation))
{
event.stopPropagation(true);
} else
{
event.cancelBubble = true;
}
});
};
mindplot.IconGroup.prototype.getTopic = function() {
return this.options.topic;
};
mindplot.IconGroup.prototype.updateIconGroupPosition = function() {
var offsets = this._calculateOffsets();
this.setPosition(offsets.x, offsets.y);
};
mindplot.IconGroup.prototype._calculateOffsets = function() {
var offset = this.options.topic.getOffset();
var text = this.options.topic.getTextShape();
var sizeHeight = text.getHtmlFontSize();
var yOffset = offset;
var shape = this.options.topic.getShapeType();
yOffset = text.getPosition().y + (sizeHeight - 18)/2 + 1;
return {x:offset, y:yOffset};
};
});

View File

@ -1,205 +1,179 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.Mindmap = function()
{
this._branches = [];
this._name = null;
this._description = null;
this._version=null;
this._relationships=[];
};
mindplot.Mindmap = new Class({
initialize : function() {
this._branches = [];
this._description = null;
this._version = null;
this._relationships = [];
},
mindplot.Mindmap.prototype.getCentralTopic = function()
{
return this._branches[0];
};
getCentralTopic : function() {
return this._branches[0];
},
mindplot.Mindmap.prototype.getDescription = function()
{
return this._description;
};
getDescription : function() {
return this._description;
},
mindplot.Mindmap.prototype.getId = function()
{
return this._iconType;
};
getId : function() {
return this._iconType;
},
mindplot.Mindmap.prototype.setId = function(id)
{
this._iconType = id;
};
setId : function(id) {
this._iconType = id;
},
mindplot.Mindmap.prototype.getVersion = function()
{
return this._version;
};
getVersion : function() {
return this._version;
},
mindplot.Mindmap.prototype.setVersion = function(version)
{
this._version = version;
};
setVersion : function(version) {
this._version = version;
},
addBranch : function(nodeModel) {
core.assert(nodeModel && nodeModel.isNodeModel(), 'Add node must be invoked with model objects');
if (this._branches.length == 0) {
core.assert(nodeModel.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE, "First element must be the central topic");
nodeModel.setPosition(0, 0);
} else {
core.assert(nodeModel.getType() != mindplot.NodeModel.CENTRAL_TOPIC_TYPE, "Mindmaps only have one cental topic");
}
this._branches.push(nodeModel);
},
mindplot.Mindmap.prototype.addBranch = function(nodeModel)
{
core.assert(nodeModel && nodeModel.isNodeModel(), 'Add node must be invoked with model objects');
if (this._branches.length == 0)
{
core.assert(nodeModel.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE, "First element must be the central topic");
nodeModel.setPosition(0, 0);
} else
{
core.assert(nodeModel.getType() != mindplot.NodeModel.CENTRAL_TOPIC_TYPE, "Mindmaps only have one cental topic");
}
getBranches : function() {
return this._branches;
},
this._branches.push(nodeModel);
};
getRelationships : function() {
return this._relationships;
},
mindplot.Mindmap.prototype.getBranches = function()
{
return this._branches;
};
connect : function(parent, child) {
// Child already has a parent ?
var branches = this.getBranches();
core.assert(!child.getParent(), 'Child model seems to be already connected');
mindplot.Mindmap.prototype.getRelationships = function() {
return this._relationships;
};
// Connect node...
parent._appendChild(child);
mindplot.Mindmap.prototype.connect = function(parent, child)
{
// Child already has a parent ?
var branches = this.getBranches();
core.assert(!child.getParent(), 'Child model seems to be already connected');
// Remove from the branch ...
branches.erase(child);
},
// Connect node...
parent._appendChild(child);
disconnect : function(child) {
var parent = child.getParent();
core.assert(child, 'Child can not be null.');
core.assert(parent, 'Child model seems to be already connected');
// Remove from the branch ...
branches.erase(child);
};
parent._removeChild(child);
mindplot.Mindmap.prototype.disconnect = function(child)
{
var parent = child.getParent();
core.assert(child, 'Child can not be null.');
core.assert(parent, 'Child model seems to be already connected');
var branches = this.getBranches();
branches.push(child);
parent._removeChild(child);
},
var branches = this.getBranches();
branches.push(child);
hasAlreadyAdded : function(node) {
var result = false;
};
// Check in not connected nodes.
var branches = this._branches;
for (var i = 0; i < branches.length; i++) {
result = branches[i]._isChildNode(node);
if (result) {
break;
}
}
},
mindplot.Mindmap.prototype.hasAlreadyAdded = function(node)
{
var result = false;
createNode : function(type, id) {
core.assert(type, "node type can not be null");
return this._createNode(type, id);
},
// Check in not connected nodes.
var branches = this._branches;
for (var i = 0; i < branches.length; i++)
{
result = branches[i]._isChildNode(node);
if (result)
{
break;
_createNode : function(type, id) {
core.assert(type, 'Node type must be specified.');
var result = new mindplot.NodeModel(type, this, id);
return result;
},
createRelationship : function(fromNode, toNode) {
core.assert(fromNode, 'from node cannot be null');
core.assert(toNode, 'to node cannot be null');
return new mindplot.RelationshipModel(fromNode, toNode);
},
addRelationship : function(relationship) {
this._relationships.push(relationship);
},
removeRelationship : function(relationship) {
this._relationships.erase(relationship);
},
inspect : function() {
var result = '';
result = '{ ';
var branches = this.getBranches();
for (var i = 0; i < branches.length; i++) {
var node = branches[i];
if (i != 0) {
result = result + ', ';
}
result = result + this._toString(node);
}
result = result + ' } ';
return result;
},
_toString : function(node) {
var result = node.inspect();
var children = node.getChildren();
for (var i = 0; i < children.length; i++) {
var child = children[i];
if (i == 0) {
result = result + '-> {';
} else {
result = result + ', ';
}
result = result + this._toString(child);
if (i == children.length - 1) {
result = result + '}';
}
}
return result;
}
}
};
mindplot.Mindmap.prototype.createNode = function(type, id)
{
core.assert(type, "node type can not be null");
return this._createNode(type, id);
};
mindplot.Mindmap.prototype._createNode = function(type, id)
{
core.assert(type, 'Node type must be specified.');
var result = new mindplot.NodeModel(type, this, id);
return result;
};
mindplot.Mindmap.prototype.createRelationship = function(fromNode, toNode){
core.assert(fromNode, 'from node cannot be null');
core.assert(toNode, 'to node cannot be null');
return new mindplot.RelationshipModel(fromNode, toNode);
};
mindplot.Mindmap.prototype.addRelationship = function(relationship) {
this._relationships.push(relationship);
};
mindplot.Mindmap.prototype.removeRelationship = function(relationship) {
this._relationships.erase(relationship);
};
mindplot.Mindmap.prototype.inspect = function()
{
var result = '';
result = '{ ';
var branches = this.getBranches();
for (var i = 0; i < branches.length; i++)
{
var node = branches[i];
if (i != 0)
{
result = result + ', ';
}
result = result + this._toString(node);
}
result = result + ' } ';
return result;
};
mindplot.Mindmap.prototype._toString = function(node)
{
var result = node.inspect();
var children = node.getChildren();
for (var i = 0; i < children.length; i++)
{
var child = children[i];
if (i == 0)
{
result = result + '-> {';
} else
{
result = result + ', ';
}
result = result + this._toString(child);
if (i == children.length - 1)
{
result = result + '}';
}
}
return result;
};
);

View File

@ -1,525 +1,432 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.NodeModel = function(type, mindmap, id)
{
core.assert(type, 'Node type can not be null');
core.assert(mindmap, 'mindmap can not be null');
mindplot.NodeModel = new Class({
initialize:function(type, mindmap, id) {
core.assert(type, 'Node type can not be null');
core.assert(mindmap, 'mindmap can not be null');
this._order = null;
this._type = type;
this._children = [];
this._icons = [];
this._links = [];
this._notes = [];
this._size = {width:50,height:20};
this._position = null;
if(core.Utils.isDefined(id)){
if(!core.Utils.isDefined(mindplot.NodeModel._uuid) || id>mindplot.NodeModel._uuid){
this._order = null;
this._type = type;
this._children = [];
this._icons = [];
this._links = [];
this._notes = [];
this._size = {width:50,height:20};
this._position = null;
if (core.Utils.isDefined(id)) {
if (!core.Utils.isDefined(mindplot.NodeModel._uuid) || id > mindplot.NodeModel._uuid) {
mindplot.NodeModel._uuid = id;
}
this._id = id;
} else {
this._id = mindplot.NodeModel._nextUUID();
}
this._mindmap = mindmap;
this._text = null;
this._shapeType = null;
this._fontFamily = null;
this._fontSize = null;
this._fontStyle = null;
this._fontWeight = null;
this._fontColor = null;
this._borderColor = null;
this._backgroundColor = null;
this._areChildrenShrinked = false;
},
clone : function() {
var result = new mindplot.NodeModel(this._type, this._mindmap);
result._order = this._order;
result._type = this._type;
result._children = this._children.map(function(item, index) {
var model = item.clone();
model._parent = result;
return model;
});
result._icons = this._icons;
result._links = this._links;
result._notes = this._notes;
result._size = this._size;
result._position = this._position;
result._id = this._id;
result._mindmap = this._mindmap;
result._text = this._text;
result._shapeType = this._shapeType;
result._fontFamily = this._fontFamily;
result._fontSize = this._fontSize;
result._fontStyle = this._fontStyle;
result._fontWeight = this._fontWeight;
result._fontColor = this._fontColor;
result._borderColor = this._borderColor;
result._backgroundColor = this._backgroundColor;
result._areChildrenShrinked = this._areChildrenShrinked;
return result;
},
areChildrenShrinked : function() {
return this._areChildrenShrinked;
},
setChildrenShrinked : function(value) {
this._areChildrenShrinked = value;
},
getId : function() {
return this._id;
},
setId : function(id) {
this._id = id;
if (mindplot.NodeModel._uuid < id) {
mindplot.NodeModel._uuid = id;
}
this._id = id;
} else {
this._id = mindplot.NodeModel._nextUUID();
}
this._mindmap = mindmap;
this._text = null;
this._shapeType = null;
this._fontFamily = null;
this._fontSize = null;
this._fontStyle = null;
this._fontWeight = null;
this._fontColor = null;
this._borderColor = null;
this._backgroundColor = null;
this._areChildrenShrinked = false;
};
},
mindplot.NodeModel.prototype.clone = function()
{
var result = new mindplot.NodeModel(this._type, this._mindmap);
result._order = this._order;
result._type = this._type;
result._children = this._children.map(function(item,index)
{
var model = item.clone();
model._parent = result;
return model;
});
getType : function() {
return this._type;
},
setText : function(text) {
this._text = text;
},
result._icons = this._icons;
result._links = this._links;
result._notes = this._notes;
result._size = this._size;
result._position = this._position;
result._id = this._id;
result._mindmap = this._mindmap;
result._text = this._text;
result._shapeType = this._shapeType;
result._fontFamily = this._fontFamily;
result._fontSize = this._fontSize;
result._fontStyle = this._fontStyle;
result._fontWeight = this._fontWeight;
result._fontColor = this._fontColor;
result._borderColor = this._borderColor;
result._backgroundColor = this._backgroundColor;
result._areChildrenShrinked = this._areChildrenShrinked;
return result;
};
getText : function() {
return this._text;
},
mindplot.NodeModel.prototype.areChildrenShrinked = function()
{
return this._areChildrenShrinked;
};
isNodeModel : function() {
return true;
},
mindplot.NodeModel.prototype.setChildrenShrinked = function(value)
{
this._areChildrenShrinked = value;
};
isConnected : function() {
return this._parent != null;
},
mindplot.NodeModel.prototype.getId = function()
{
return this._id;
};
createLink : function(url) {
core.assert(url, 'Link URL must be specified.');
return new mindplot.LinkModel(url, this);
},
addLink : function(link) {
core.assert(link && link.isLinkModel(), 'Only LinkModel can be appended to Mindmap object as links');
this._links.push(link);
},
mindplot.NodeModel.prototype.setId = function(id)
{
this._id = id;
if(mindplot.NodeModel._uuid<id){
mindplot.NodeModel._uuid = id;
}
};
_removeLink : function(link) {
core.assert(link && link.isLinkModel(), 'Only LinkModel can be appended to Mindmap object as links');
this._links.erase(link);
},
mindplot.NodeModel.prototype.getType = function()
{
return this._type;
};
createNote : function(text) {
core.assert(text != null, 'note text must be specified.');
return new mindplot.NoteModel(text, this);
},
mindplot.NodeModel.prototype.setText = function(text)
{
this._text = text;
};
addNote : function(note) {
core.assert(note && note.isNoteModel(), 'Only NoteModel can be appended to Mindmap object as links');
this._notes.push(note);
},
mindplot.NodeModel.prototype.getText = function()
{
return this._text;
};
_removeNote : function(note) {
core.assert(note && note.isNoteModel(), 'Only NoteModel can be appended to Mindmap object as links');
this._notes.erase(note);
},
mindplot.NodeModel.prototype.isNodeModel = function()
{
return true;
};
createIcon : function(iconType) {
core.assert(iconType, 'IconType must be specified.');
return new mindplot.IconModel(iconType, this);
},
mindplot.NodeModel.prototype.isConnected = function()
{
return this._parent != null;
};
addIcon : function(icon) {
core.assert(icon && icon.isIconModel(), 'Only IconModel can be appended to Mindmap object as icons');
this._icons.push(icon);
},
mindplot.NodeModel.prototype.createLink = function(url)
{
core.assert(url, 'Link URL must be specified.');
return new mindplot.LinkModel(url, this);
};
_removeIcon : function(icon) {
core.assert(icon && icon.isIconModel(), 'Only IconModel can be appended to Mindmap object as icons');
this._icons.erase(icon);
},
mindplot.NodeModel.prototype.addLink = function(link)
{
core.assert(link && link.isLinkModel(), 'Only LinkModel can be appended to Mindmap object as links');
this._links.push(link);
};
removeLastIcon : function() {
this._icons.pop();
},
mindplot.NodeModel.prototype._removeLink = function(link)
{
core.assert(link && link.isLinkModel(), 'Only LinkModel can be appended to Mindmap object as links');
this._links.erase(link);
};
_appendChild : function(child) {
core.assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
this._children.push(child);
child._parent = this;
},
mindplot.NodeModel.prototype.createNote = function(text)
{
core.assert(text!=null, 'note text must be specified.');
return new mindplot.NoteModel(text, this);
};
_removeChild : function(child) {
core.assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object.');
this._children.erase(child);
child._parent = null;
},
mindplot.NodeModel.prototype.addNote = function(note)
{
core.assert(note && note.isNoteModel(), 'Only NoteModel can be appended to Mindmap object as links');
this._notes.push(note);
};
setPosition : function(x, y) {
core.assert(core.Utils.isDefined(x), "x coordinate must be defined");
core.assert(core.Utils.isDefined(y), "y coordinate must be defined");
mindplot.NodeModel.prototype._removeNote = function(note)
{
core.assert(note && note.isNoteModel(), 'Only NoteModel can be appended to Mindmap object as links');
this._notes.erase(note);
};
mindplot.NodeModel.prototype.createIcon = function(iconType)
{
core.assert(iconType, 'IconType must be specified.');
return new mindplot.IconModel(iconType, this);
};
mindplot.NodeModel.prototype.addIcon = function(icon)
{
core.assert(icon && icon.isIconModel(), 'Only IconModel can be appended to Mindmap object as icons');
this._icons.push(icon);
};
mindplot.NodeModel.prototype._removeIcon = function(icon)
{
core.assert(icon && icon.isIconModel(), 'Only IconModel can be appended to Mindmap object as icons');
this._icons.erase(icon);
};
mindplot.NodeModel.prototype.removeLastIcon = function()
{
this._icons.pop();
};
mindplot.NodeModel.prototype._appendChild = function(child)
{
core.assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
this._children.push(child);
child._parent = this;
};
mindplot.NodeModel.prototype._removeChild = function(child)
{
core.assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object.');
this._children.erase(child);
child._parent = null;
};
mindplot.NodeModel.prototype.setPosition = function(x, y)
{
core.assert(core.Utils.isDefined(x), "x coordinate must be defined");
core.assert(core.Utils.isDefined(y), "y coordinate must be defined");
if (!core.Utils.isDefined(this._position))
{
this._position = new core.Point();
}
this._position.x = parseInt(x);
this._position.y = parseInt(y);
};
mindplot.NodeModel.prototype.getPosition = function()
{
return this._position;
};
mindplot.NodeModel.prototype.setFinalPosition = function(x, y)
{
core.assert(core.Utils.isDefined(x), "x coordinate must be defined");
core.assert(core.Utils.isDefined(y), "y coordinate must be defined");
if (!core.Utils.isDefined(this._finalPosition))
{
this._finalPosition = new core.Point();
}
this._finalPosition.x = parseInt(x);
this._finalPosition.y = parseInt(y);
};
mindplot.NodeModel.prototype.getFinalPosition = function()
{
return this._finalPosition;
};
mindplot.NodeModel.prototype.setSize = function(width, height)
{
this._size.width = width;
this._size.height = height;
};
mindplot.NodeModel.prototype.getSize = function()
{
return {width:this._size.width,height:this._size.height};
};
mindplot.NodeModel.prototype.getChildren = function()
{
return this._children;
};
mindplot.NodeModel.prototype.getIcons = function()
{
return this._icons;
};
mindplot.NodeModel.prototype.getLinks = function()
{
return this._links;
};
mindplot.NodeModel.prototype.getNotes = function()
{
return this._notes;
};
mindplot.NodeModel.prototype.getParent = function()
{
return this._parent;
};
mindplot.NodeModel.prototype.getMindmap = function()
{
return this._mindmap;
};
mindplot.NodeModel.prototype.setParent = function(parent)
{
core.assert(parent != this, 'The same node can not be parent and child if itself.');
this._parent = parent;
};
mindplot.NodeModel.prototype.canBeConnected = function(sourceModel, sourcePosition, targetTopicHeight)
{
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(core.Utils.isDefined(targetTopicHeight), 'childrenWidth can not be null.');
// Only can be connected if the node is in the left or rigth.
var targetModel = this;
var mindmap = targetModel.getMindmap();
var targetPosition = targetModel.getPosition();
var result = false;
if (sourceModel.getType() == mindplot.NodeModel.MAIN_TOPIC_TYPE)
{
// Finally, check current node ubication.
var targetTopicSize = targetModel.getSize();
var yDistance = Math.abs(sourcePosition.y - targetPosition.y);
var gap = 35 + targetTopicHeight / 2;
if(targetModel.getChildren().length>0){
gap += Math.abs(targetPosition.y - targetModel.getChildren()[0].getPosition().y);
if (!core.Utils.isDefined(this._position)) {
this._position = new core.Point();
}
this._position.x = parseInt(x);
this._position.y = parseInt(y);
},
if (yDistance <= gap)
{
// Circular connection ?
if (!sourceModel._isChildNode(this))
{
var toleranceDistance = (targetTopicSize.width / 2) + targetTopicHeight;
getPosition : function() {
return this._position;
},
var xDistance = sourcePosition.x - targetPosition.x;
var isTargetAtRightFromCentral = targetPosition.x >= 0;
setFinalPosition : function(x, y) {
core.assert(core.Utils.isDefined(x), "x coordinate must be defined");
core.assert(core.Utils.isDefined(y), "y coordinate must be defined");
if (isTargetAtRightFromCentral)
{
if (xDistance >= -targetTopicSize.width/2 && xDistance <= mindplot.NodeModel.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE /2 + (targetTopicSize.width / 2))
{
result = true;
}
if (!core.Utils.isDefined(this._finalPosition)) {
this._finalPosition = new core.Point();
}
this._finalPosition.x = parseInt(x);
this._finalPosition.y = parseInt(y);
},
} else
{
if (xDistance <= targetTopicSize.width/2 && Math.abs(xDistance) <= mindplot.NodeModel.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE /2 + (targetTopicSize.width / 2))
{
result = true;
getFinalPosition : function() {
return this._finalPosition;
},
setSize : function(width, height) {
this._size.width = width;
this._size.height = height;
},
getSize : function() {
return {width:this._size.width,height:this._size.height};
},
getChildren : function() {
return this._children;
},
getIcons : function() {
return this._icons;
},
getLinks : function() {
return this._links;
},
getNotes : function() {
return this._notes;
},
getParent : function() {
return this._parent;
},
getMindmap : function() {
return this._mindmap;
},
setParent : function(parent) {
core.assert(parent != this, 'The same node can not be parent and child if itself.');
this._parent = parent;
},
canBeConnected : function(sourceModel, sourcePosition, targetTopicHeight) {
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(core.Utils.isDefined(targetTopicHeight), 'childrenWidth can not be null.');
// Only can be connected if the node is in the left or rigth.
var targetModel = this;
var mindmap = targetModel.getMindmap();
var targetPosition = targetModel.getPosition();
var result = false;
if (sourceModel.getType() == mindplot.NodeModel.MAIN_TOPIC_TYPE) {
// Finally, check current node ubication.
var targetTopicSize = targetModel.getSize();
var yDistance = Math.abs(sourcePosition.y - targetPosition.y);
var gap = 35 + targetTopicHeight / 2;
if (targetModel.getChildren().length > 0) {
gap += Math.abs(targetPosition.y - targetModel.getChildren()[0].getPosition().y);
}
if (yDistance <= gap) {
// Circular connection ?
if (!sourceModel._isChildNode(this)) {
var toleranceDistance = (targetTopicSize.width / 2) + targetTopicHeight;
var xDistance = sourcePosition.x - targetPosition.x;
var isTargetAtRightFromCentral = targetPosition.x >= 0;
if (isTargetAtRightFromCentral) {
if (xDistance >= -targetTopicSize.width / 2 && xDistance <= mindplot.NodeModel.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE / 2 + (targetTopicSize.width / 2)) {
result = true;
}
} else {
if (xDistance <= targetTopicSize.width / 2 && Math.abs(xDistance) <= mindplot.NodeModel.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE / 2 + (targetTopicSize.width / 2)) {
result = true;
}
}
}
}
} else {
throw "No implemented yet";
}
} else
{
throw "No implemented yet";
}
return result;
};
return result;
},
mindplot.NodeModel.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE = 220;
mindplot.NodeModel.prototype._isChildNode = function(node)
{
var result = false;
if (node == this)
{
result = true;
} else
{
var children = this.getChildren();
for (var i = 0; i < children.length; i++)
{
var child = children[i];
result = child._isChildNode(node);
if (result)
{
break;
_isChildNode : function(node) {
var result = false;
if (node == this) {
result = true;
} else {
var children = this.getChildren();
for (var i = 0; i < children.length; i++) {
var child = children[i];
result = child._isChildNode(node);
if (result) {
break;
}
}
}
}
return result;
return result;
};
},
mindplot.NodeModel.prototype.connectTo = function(parent)
{
var mindmap = this.getMindmap();
mindmap.connect(parent, this);
this._parent = parent;
};
connectTo : function(parent) {
var mindmap = this.getMindmap();
mindmap.connect(parent, this);
this._parent = parent;
},
mindplot.NodeModel.prototype.disconnect = function()
{
var mindmap = this.getMindmap();
mindmap.disconnect(this);
};
mindplot.NodeModel.prototype.getOrder = function()
{
return this._order;
};
mindplot.NodeModel.prototype.getShapeType = function()
{
return this._shapeType;
};
mindplot.NodeModel.prototype.setShapeType = function(type)
{
this._shapeType = type;
};
mindplot.NodeModel.prototype.setOrder = function(value)
{
this._order = value;
};
mindplot.NodeModel.prototype.setFontFamily = function(value)
{
this._fontFamily = value;
};
mindplot.NodeModel.prototype.getOrder = function()
{
return this._order;
};
mindplot.NodeModel.prototype.getFontFamily = function()
{
return this._fontFamily;
};
mindplot.NodeModel.prototype.setFontStyle = function(value)
{
this._fontStyle = value;
};
mindplot.NodeModel.prototype.getFontStyle = function()
{
return this._fontStyle;
};
mindplot.NodeModel.prototype.setFontWeight = function(value)
{
this._fontWeight = value;
};
mindplot.NodeModel.prototype.getFontWeight = function()
{
return this._fontWeight;
};
mindplot.NodeModel.prototype.setFontColor = function(value)
{
this._fontColor = value;
};
mindplot.NodeModel.prototype.getFontColor = function()
{
return this._fontColor;
};
mindplot.NodeModel.prototype.setFontSize = function(value)
{
this._fontSize = value;
};
mindplot.NodeModel.prototype.getFontSize = function()
{
return this._fontSize;
};
mindplot.NodeModel.prototype.getBorderColor = function()
{
return this._borderColor;
};
mindplot.NodeModel.prototype.setBorderColor = function(color)
{
this._borderColor = color;
};
mindplot.NodeModel.prototype.getBackgroundColor = function()
{
return this._backgroundColor;
};
mindplot.NodeModel.prototype.setBackgroundColor = function(color)
{
this._backgroundColor = color;
};
mindplot.NodeModel.prototype.deleteNode = function()
{
var mindmap = this._mindmap;
// if it has children nodes, Their must be disconnected.
var lenght = this._children;
for (var i = 0; i < lenght; i++)
{
var child = this._children[i];
mindmap.disconnect(child);
}
var parent = this._parent;
if (core.Utils.isDefined(parent))
{
// if it is connected, I must remove it from the parent..
disconnect : function() {
var mindmap = this.getMindmap();
mindmap.disconnect(this);
},
getOrder : function() {
return this._order;
},
getShapeType : function() {
return this._shapeType;
},
setShapeType : function(type) {
this._shapeType = type;
},
setOrder : function(value) {
this._order = value;
},
setFontFamily : function(value) {
this._fontFamily = value;
},
getOrder : function() {
return this._order;
},
getFontFamily : function() {
return this._fontFamily;
},
setFontStyle : function(value) {
this._fontStyle = value;
},
getFontStyle : function() {
return this._fontStyle;
},
setFontWeight : function(value) {
this._fontWeight = value;
},
getFontWeight : function() {
return this._fontWeight;
},
setFontColor : function(value) {
this._fontColor = value;
},
getFontColor : function() {
return this._fontColor;
},
setFontSize : function(value) {
this._fontSize = value;
},
getFontSize : function() {
return this._fontSize;
},
getBorderColor : function() {
return this._borderColor;
},
setBorderColor : function(color) {
this._borderColor = color;
},
getBackgroundColor : function() {
return this._backgroundColor;
},
setBackgroundColor : function(color) {
this._backgroundColor = color;
},
deleteNode : function() {
var mindmap = this._mindmap;
// if it has children nodes, Their must be disconnected.
var lenght = this._children;
for (var i = 0; i < lenght; i++) {
var child = this._children[i];
mindmap.disconnect(child);
}
var parent = this._parent;
if (core.Utils.isDefined(parent)) {
// if it is connected, I must remove it from the parent..
mindmap.disconnect(this);
}
// It's an isolated node. It must be a hole branch ...
var branches = mindmap.getBranches();
branches.erase(this);
},
inspect : function() {
return '(type:' + this.getType() + ' , id: ' + this.getId() + ')';
}
// It's an isolated node. It must be a hole branch ...
var branches = mindmap.getBranches();
branches.erase(this);
};
/**
* @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() + ')';
};
});
mindplot.NodeModel.CENTRAL_TOPIC_TYPE = 'CentralTopic';
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_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;
}

View File

@ -1,165 +1,159 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.Note = function(textModel, topic, designer) {
var divContainer=designer.getWorkSpace().getScreenManager().getContainer();
var bubbleTip = mindplot.BubbleTip.getInstance(divContainer);
mindplot.Icon.call(this, mindplot.Note.IMAGE_URL);
this._noteModel = textModel;
this._topic = topic;
this._designer = designer;
var image = this.getImage();
var imgContainer = new Element('div').setStyles({textAlign:'center'});
this._textElem = new Element('div').setStyles({'max-height':100,'max-width':300, 'overflow':'auto'});
var text = unescape(textModel.getText());
text = text.replace(/\n/ig,"<br/>");
text = text.replace(/<script/ig, "&lt;script");
text = text.replace(/<\/script/ig, "&lt;\/script");
this._textElem.innerHTML = text;
this._text=textModel.getText();
this._textElem.inject(imgContainer);
var container = new Element('div');
imgContainer.inject(container);
if(!core.Utils.isDefined(designer._viewMode)|| (core.Utils.isDefined(designer._viewMode) && !designer._viewMode)){
var buttonContainer = new Element('div').setStyles({paddingTop:5, textAlign:'center'});
var editBtn = new Element('input', {type:'button', value:'Edit','class':'btn-primary'}).addClass('button').inject(buttonContainer);
var removeBtn = new Element('input', {type:'button', value:'Remove','class':'btn-primary'}).addClass('button').inject(buttonContainer);
editBtn.setStyle("margin-right", "3px");
removeBtn.setStyle("margin-left", "3px");
removeBtn.addEvent('click', function(event) {
var command = new mindplot.commands.RemoveNoteFromTopicCommand(this._topic.getId());
designer._actionRunner.execute(command);
bubbleTip.forceClose();
}.bindWithEvent(this));
var okButtonId = 'okNoteButtonId';
editBtn.addEvent('click', function(event) {
var topic = this._topic;
var designer = this._designer;
var note = this;
var msg = new Element('div');
var textarea = new Element('div').inject(msg);
textarea.innerHTML = "Text"
var formElem = new Element('form', {'action': 'none', 'id':'noteFormId'});
var text = textModel.getText();
text = unescape(text);
var textInput = new Element('textarea', {'value':text}).setStyles({'width':280, 'height':50});
textInput.inject(formElem);
formElem.inject(msg)
var okFunction = function(e) {
var result = true;
var text = textInput.value;
text = escape(text);
note._noteModel.setText(text);
return result;
};
formElem.addEvent('submit', function(e)
{
$(okButtonId).fireEvent('click', e);
e = new Event(e);
e.stop();
});
var dialog = mindplot.Note.buildDialog(designer, okFunction, okButtonId);
dialog.adopt(msg).show();
}.bindWithEvent(this));
buttonContainer.inject(container);
}
var note = this;
image.addEventListener('mouseover', function(event) {
var text = textModel.getText();
text = unescape(text);
text = text.replace(/\n/ig,"<br/>");
mindplot.Note = new Class({
Extends: mindplot.Icon,
initialize : function(textModel, topic, designer) {
var divContainer = designer.getWorkSpace().getScreenManager().getContainer();
var bubbleTip = mindplot.BubbleTip.getInstance(divContainer);
mindplot.Icon.call(this, mindplot.Note.IMAGE_URL);
this._noteModel = textModel;
this._topic = topic;
this._designer = designer;
var image = this.getImage();
var imgContainer = new Element('div').setStyles({textAlign:'center'});
this._textElem = new Element('div').setStyles({'max-height':100,'max-width':300, 'overflow':'auto'});
var text = unescape(textModel.getText());
text = text.replace(/\n/ig, "<br/>");
text = text.replace(/<script/ig, "&lt;script");
text = text.replace(/<\/script/ig, "&lt;\/script");
this._textElem.innerHTML = text;
this._text = textModel.getText();
bubbleTip.open(event, container, note);
}.bind(this));
image.addEventListener('mousemove', function(event) {
bubbleTip.updatePosition(event);
});
image.addEventListener('mouseout', function(event) {
bubbleTip.close(event);
});
};
this._textElem.inject(imgContainer);
objects.extend(mindplot.Note, mindplot.Icon);
var container = new Element('div');
mindplot.Note.prototype.initialize = function() {
imgContainer.inject(container);
};
if (!core.Utils.isDefined(designer._viewMode) || (core.Utils.isDefined(designer._viewMode) && !designer._viewMode)) {
var buttonContainer = new Element('div').setStyles({paddingTop:5, textAlign:'center'});
var editBtn = new Element('input', {type:'button', value:'Edit','class':'btn-primary'}).addClass('button').inject(buttonContainer);
var removeBtn = new Element('input', {type:'button', value:'Remove','class':'btn-primary'}).addClass('button').inject(buttonContainer);
mindplot.Note.prototype.getText=function(){
return this._text;
};
editBtn.setStyle("margin-right", "3px");
removeBtn.setStyle("margin-left", "3px");
mindplot.Note.prototype.getModel=function(){
return this._noteModel;
};
removeBtn.addEvent('click', function(event) {
var command = new mindplot.commands.RemoveNoteFromTopicCommand(this._topic.getId());
designer._actionRunner.execute(command);
bubbleTip.forceClose();
}.bindWithEvent(this));
mindplot.Note.buildDialog = function(designer, okFunction, okButtonId) {
var windoo = new Windoo({
title: 'Write note',
theme: Windoo.Themes.wise,
modal:true,
buttons:{'menu':false, 'close':false, 'minimize':false, 'roll':false, 'maximize':false},
destroyOnClose:true,
height:130
});
var okButtonId = 'okNoteButtonId';
editBtn.addEvent('click', function(event) {
var topic = this._topic;
var designer = this._designer;
var note = this;
var cancel = new Element('input', {'type': 'button', 'class':'btn-primary', 'value': 'Cancel','class':'btn-primary'}).setStyle('margin-right', "5px");
cancel.setStyle('margin-left', "5px");
cancel.addEvent('click', function(event) {
$(document).addEvent('keydown', designer.keyEventHandler.bindWithEvent(designer));
windoo.close();
}.bindWithEvent(this));
var msg = new Element('div');
var textarea = new Element('div').inject(msg);
textarea.innerHTML = "Text";
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) {
var couldBeUpdated = okFunction.attempt();
if (couldBeUpdated)
{
var formElem = new Element('form', {'action': 'none', 'id':'noteFormId'});
var text = textModel.getText();
text = unescape(text);
var textInput = new Element('textarea', {'value':text}).setStyles({'width':280, 'height':50});
textInput.inject(formElem);
formElem.inject(msg);
var okFunction = function(e) {
var result = true;
var text = textInput.value;
text = escape(text);
note._noteModel.setText(text);
return result;
};
formElem.addEvent('submit', function(e) {
$(okButtonId).fireEvent('click', e);
e = new Event(e);
e.stop();
});
var dialog = mindplot.Note.buildDialog(designer, okFunction, okButtonId);
dialog.adopt(msg).show();
}.bindWithEvent(this));
buttonContainer.inject(container);
}
var note = this;
image.addEventListener('mouseover', function(event) {
var text = textModel.getText();
text = unescape(text);
text = text.replace(/\n/ig, "<br/>");
text = text.replace(/<script/ig, "&lt;script");
text = text.replace(/<\/script/ig, "&lt;\/script");
this._textElem.innerHTML = text;
bubbleTip.open(event, container, note);
}.bind(this));
image.addEventListener('mousemove', function(event) {
bubbleTip.updatePosition(event);
});
image.addEventListener('mouseout', function(event) {
bubbleTip.close(event);
});
},
getText: function() {
return this._text;
},
getModel : function() {
return this._noteModel;
},
buildDialog : function(designer, okFunction, okButtonId) {
var windoo = new Windoo({
title: 'Write note',
theme: Windoo.Themes.wise,
modal:true,
buttons:{'menu':false, 'close':false, 'minimize':false, 'roll':false, 'maximize':false},
destroyOnClose:true,
height:130
});
var cancel = new Element('input', {'type': 'button', 'class':'btn-primary', 'value': 'Cancel','class':'btn-primary'}).setStyle('margin-right', "5px");
cancel.setStyle('margin-left', "5px");
cancel.addEvent('click', function(event) {
$(document).addEvent('keydown', designer.keyEventHandler.bindWithEvent(designer));
windoo.close();
}
}.bindWithEvent(this));
}.bindWithEvent(this));
var panel = new Element('div', {'styles': {'padding-top': 10, 'text-align': 'right'}}).adopt(ok, cancel);
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) {
var couldBeUpdated = okFunction.attempt();
if (couldBeUpdated) {
$(document).addEvent('keydown', designer.keyEventHandler.bindWithEvent(designer));
windoo.close();
}
}.bindWithEvent(this));
windoo.addPanel(panel);
$(document).removeEvents('keydown');
return windoo;
};
var panel = new Element('div', {'styles': {'padding-top': 10, 'text-align': 'right'}}).adopt(ok, cancel);
windoo.addPanel(panel);
$(document).removeEvents('keydown');
return windoo;
}
});
mindplot.Note.IMAGE_URL = "../images/note.png";

View File

@ -1,45 +1,42 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.NoteModel = function(text, topic)
{
core.assert(text!=null, 'note text can not be null');
core.assert(topic, 'mindmap can not be null');
this._text = text;
this._topic = topic;
};
mindplot.NoteModel = new Class({
initialize : function(text, topic) {
core.assert(text != null, 'note text can not be null');
core.assert(topic, 'mindmap can not be null');
this._text = text;
this._topic = topic;
},
mindplot.NoteModel.prototype.getText = function()
{
return this._text;
};
getText:function() {
return this._text;
},
mindplot.NoteModel.prototype.setText = function(text)
{
this._text=text;
};
setText : function(text) {
this._text = text;
},
mindplot.NoteModel.prototype.getTopic = function()
{
return this._topic;
};
getTopic : function() {
return this._topic;
},
mindplot.NoteModel.prototype.isNoteModel = function()
{
return true;
};
isNoteModel : function() {
return true;
}
});