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

@ -15,20 +15,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.Beta2PelaMigrator = function(betaSerializer){
mindplot.Beta2PelaMigrator = new Class({
initialize : function(betaSerializer) {
this._betaSerializer = betaSerializer;
this._pelaSerializer = new mindplot.XMLMindmapSerializer_Pela();
};
},
mindplot.Beta2PelaMigrator.prototype.toXML = function(mindmap)
{
toXML : function(mindmap) {
return this._pelaSerializer.toXML(mindmap);
};
},
mindplot.Beta2PelaMigrator.prototype.loadFromDom = function(dom)
{
loadFromDom : function(dom) {
var mindmap = this._betaSerializer.loadFromDom(dom);
mindmap.setVersion(mindplot.ModelCodeName.PELA);
return mindmap;
};
}
});

View File

@ -58,12 +58,14 @@ mindplot.Board = new Class({
/**
* ---------------------------------------
*/
mindplot.BidirectionalArray = function() {
mindplot.BidirectionalArray = new Class({
initialize: function() {
this._leftElem = [];
this._rightElem = [];
};
},
mindplot.BidirectionalArray.prototype.get = function(index, sign) {
get :function(index, sign) {
core.assert(core.Utils.isDefined(index), 'Illegal argument, index must be passed.');
if (core.Utils.isDefined(sign)) {
core.assert(index >= 0, 'Illegal absIndex value');
@ -77,29 +79,29 @@ mindplot.BidirectionalArray.prototype.get = function(index, sign) {
result = this._leftElem[Math.abs(index)];
}
return result;
};
},
mindplot.BidirectionalArray.prototype.set = function(index, elem) {
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) {
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() {
upperLength : function() {
return this.length(1);
};
},
mindplot.BidirectionalArray.prototype.lowerLength = function() {
lowerLength : function() {
return this.length(-1);
};
},
mindplot.BidirectionalArray.prototype.inspect = function() {
inspect : function() {
var result = '{';
var lenght = this._leftElem.length;
for (var i = 0; i < lenght; i++) {
@ -126,4 +128,5 @@ mindplot.BidirectionalArray.prototype.inspect = function() {
return result;
};
}
});

View File

@ -16,10 +16,9 @@
* limitations under the License.
*/
mindplot.BoardEntry = function(lowerLimit, upperLimit, order)
{
if (core.Utils.isDefined(lowerLimit) && core.Utils.isDefined(upperLimit))
{
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;
@ -27,96 +26,81 @@ mindplot.BoardEntry = function(lowerLimit, upperLimit, order)
this._order = order;
this._topic = null;
this._xPos = null;
};
},
mindplot.BoardEntry.prototype.getUpperLimit = function()
{
getUpperLimit : function() {
return this._upperLimit;
};
},
mindplot.BoardEntry.prototype.setXPosition = function(xPosition)
{
setXPosition : function(xPosition) {
this._xPos = xPosition;
};
},
mindplot.BoardEntry.prototype.workoutEntryYCenter = function()
{
workoutEntryYCenter : function() {
return this._lowerLimit + ((this._upperLimit - this._lowerLimit) / 2);
};
},
mindplot.BoardEntry.prototype.setUpperLimit = function(value)
{
setUpperLimit : function(value) {
core.assert(core.Utils.isDefined(value), "upper limit can not be null");
core.assert(!isNaN(value), "illegal value");
this._upperLimit = value;
};
},
mindplot.BoardEntry.prototype.isCoordinateIn = function(coord)
{
isCoordinateIn : function(coord) {
return this._lowerLimit <= coord && coord < this._upperLimit;
};
},
mindplot.BoardEntry.prototype.getLowerLimit = function()
{
getLowerLimit : function() {
return this._lowerLimit;
};
},
mindplot.BoardEntry.prototype.setLowerLimit = function(value)
{
setLowerLimit : function(value) {
core.assert(core.Utils.isDefined(value), "upper limit can not be null");
core.assert(!isNaN(value), "illegal value");
this._lowerLimit = value;
};
},
mindplot.BoardEntry.prototype.setOrder = function(value)
{
setOrder : function(value) {
this._order = value;
};
},
mindplot.BoardEntry.prototype.getWidth = function()
{
getWidth : function() {
return Math.abs(this._upperLimit - this._lowerLimit);
};
},
mindplot.BoardEntry.prototype.getTopic = function()
{
getTopic : function() {
return this._topic;
};
},
mindplot.BoardEntry.prototype.removeTopic = function()
{
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.update = function()
{
update : function() {
var topic = this.getTopic();
this.setTopic(topic);
};
},
mindplot.BoardEntry.prototype.setTopic = function(topic, updatePosition)
{
if (!core.Utils.isDefined(updatePosition) || (core.Utils.isDefined(updatePosition) && !updatePosition))
{
setTopic : function(topic, updatePosition) {
if (!core.Utils.isDefined(updatePosition) || (core.Utils.isDefined(updatePosition) && !updatePosition)) {
updatePosition = true;
}
this._topic = topic;
if (core.Utils.isDefined(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))
{
if (core.Utils.isDefined(this._xPos)) {
position = new core.Point();
// Update x position ...
@ -138,23 +122,20 @@ mindplot.BoardEntry.prototype.setTopic = function(topic, updatePosition)
topic.setPosition(position);
topic.setOrder(this._order);
}
else
{
else {
this._height = this._defaultWidth;
}
};
},
mindplot.BoardEntry.prototype.isAvailable = function()
{
isAvailable : function() {
return !core.Utils.isDefined(this._topic);
};
},
mindplot.BoardEntry.prototype.getOrder = function()
{
getOrder : function() {
return this._order;
};
},
mindplot.BoardEntry.prototype.inspect = function()
{
inspect : function() {
return '(order: ' + this._order + ', lowerLimit:' + this._lowerLimit + ', upperLimit: ' + this._upperLimit + ', available:' + this.isAvailable() + ')';
};
}
});

View File

@ -16,10 +16,8 @@
* limitations under the License.
*/
mindplot.BubbleTip = function(divContainer){
this.initialize(divContainer);
};
mindplot.BubbleTip.prototype.initialize=function(divContainer){
mindplot.BubbleTip = new Class({
initialize : function(divContainer) {
this.options = {
panel:null,
container:null,
@ -36,15 +34,15 @@ mindplot.BubbleTip.prototype.initialize=function(divContainer){
this.buildBubble();
this._isMouseOver = false;
this._open = false;
};
mindplot.BubbleTip.prototype.scanElements=function(form){
},
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));
}
}, this);
};
mindplot.BubbleTip.prototype.buildBubble=function(){
},
buildBubble : function() {
var opts = this.options;
var panel = new Element('div').addClass('bubbleContainer');
@ -55,28 +53,30 @@ mindplot.BubbleTip.prototype.buildBubble=function(){
this.center = new Element('div').addClass('bubblePart').addClass('bubbleCenterBlue');
this.center.inject(panel);
if(!$chk(opts.divContainer))
{
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.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){
},
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))
{
},
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);
@ -84,34 +84,36 @@ mindplot.BubbleTip.prototype.doOpen= function(content, source){
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.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){
},
close : function(event) {
this._isMouseOver = false;
this.doClose.delay(50, this, new Event(event));
};
mindplot.BubbleTip.prototype.doClose=function(event){
},
doClose : function(event) {
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(){
},
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){
},
init : function(event, source) {
var opts = this.options;
var coordinates = $(opts.panel).getCoordinates();
var panelHeight = coordinates.height; //not total height, but close enough
@ -134,8 +136,8 @@ mindplot.BubbleTip.prototype.init=function(event,source){
var height = $(this.center).getCoordinates().height;
$(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){
},
moveTopic : function(offset, panelHeight, panelWidth, invert, invertX) {
var f = 1, fX = 1;
if ($chk(invert))
f = 0;
@ -143,15 +145,15 @@ mindplot.BubbleTip.prototype.moveTopic=function(offset, panelHeight, panelWidth,
fX = 0;
var opts = this.options;
$(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

@ -16,8 +16,8 @@
* limitations under the License.
*/
mindplot.ConnectionLine = function(sourceNode, targetNode, lineType)
{
mindplot.ConnectionLine = new Class({
initialize:function(sourceNode, targetNode, lineType) {
core.assert(targetNode, 'parentNode node can not be null');
core.assert(sourceNode, 'childNode node can not be null');
core.assert(sourceNode != targetNode, 'Cilcular connection');
@ -27,8 +27,7 @@ mindplot.ConnectionLine = function(sourceNode, targetNode, lineType)
var strokeColor = mindplot.ConnectionLine.getStrokeColor();
var line;
if (targetNode.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE)
{
if (targetNode.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE) {
line = this._createLine(lineType, mindplot.ConnectionLine.CURVED);
// line = new web2d.Line();
if (line.getType() == "CurvedLine") {
@ -37,8 +36,7 @@ mindplot.ConnectionLine = function(sourceNode, targetNode, lineType)
line.setDestControlPoint(ctrlPoints[1]);
}
line.setStroke(1, 'solid', strokeColor);
} else
{
} else {
line = this._createLine(lineType, mindplot.ConnectionLine.SIMPLE_CURVED);
if (line.getType() == "CurvedLine") {
var ctrlPoints = this._getCtrlPoints(sourceNode, targetNode);
@ -50,16 +48,16 @@ mindplot.ConnectionLine = function(sourceNode, targetNode, lineType)
}
this._line2d = line;
};
},
mindplot.ConnectionLine.prototype._getCtrlPoints = function(sourceNode, targetNode){
_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){
_createLine : function(lineType, defaultStyle) {
if (!core.Utils.isDefined(lineType)) {
lineType = defaultStyle;
}
@ -82,29 +80,21 @@ mindplot.ConnectionLine.prototype._createLine = function(lineType, defaultStyle)
break;
}
return line;
};
},
mindplot.ConnectionLine.getStrokeColor = function()
{
return '#495879';
};
mindplot.ConnectionLine.prototype.setVisibility = function(value)
{
setVisibility : function(value) {
this._line2d.setVisibility(value);
};
},
mindplot.ConnectionLine.prototype.isVisible = function()
{
isVisible : function() {
return this._line2d.isVisible();
};
},
mindplot.ConnectionLine.prototype.setOpacity = function(opacity){
setOpacity : function(opacity) {
this._line2d.setOpacity(opacity);
};
},
mindplot.ConnectionLine.prototype.redraw = function()
{
redraw : function() {
var line2d = this._line2d;
var sourceTopic = this._sourceTopic;
var sourcePosition = sourceTopic.getPosition();
@ -129,94 +119,88 @@ mindplot.ConnectionLine.prototype.redraw = function()
// Add connector ...
this._positionateConnector(targetTopic);
};
},
mindplot.ConnectionLine.prototype._positionateConnector = function(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)
{
if (targetTopic.getShapeType() == mindplot.NodeModel.SHAPE_TYPE_LINE) {
y = targetTopicSize.height;
} else
{
} else {
y = targetTopicSize.height / 2;
}
y = y - offset;
var connector = targetTopic.getShrinkConnector();
if (Math.sign(targetPosition.x) > 0)
{
if (Math.sign(targetPosition.x) > 0) {
var x = targetTopicSize.width;
connector.setPosition(x, y);
}
else
{
else {
var x = -mindplot.Topic.CONNECTOR_WIDTH;
connector.setPosition(x, y);
}
};
},
mindplot.ConnectionLine.prototype.setStroke = function(color, style, opacity)
{
setStroke : function(color, style, opacity) {
var line2d = this._line2d;
this._line2d.setStroke(null, null, color, opacity);
};
},
mindplot.ConnectionLine.prototype.addToWorkspace = function(workspace)
{
addToWorkspace : function(workspace) {
workspace.appendChild(this._line2d);
this._line2d.moveToBack();
};
},
mindplot.ConnectionLine.prototype.removeFromWorkspace = function(workspace)
{
removeFromWorkspace : function(workspace) {
workspace.removeChild(this._line2d);
};
},
mindplot.ConnectionLine.prototype.getTargetTopic = function()
{
getTargetTopic : function() {
return this._targetTopic;
};
},
mindplot.ConnectionLine.prototype.getSourceTopic = function()
{
getSourceTopic : function() {
return this._sourceTopic;
};
},
mindplot.ConnectionLine.prototype.getLineType = function(){
getLineType : function() {
return this._lineType;
};
},
mindplot.ConnectionLine.prototype.getLine = function(){
getLine : function() {
return this._line2d;
};
},
mindplot.ConnectionLine.prototype.getModel = function(){
getModel : function() {
return this._model;
};
},
mindplot.ConnectionLine.prototype.setModel = function(model){
setModel : function(model) {
this._model = model;
};
},
mindplot.ConnectionLine.prototype.getType = function(){
getType : function() {
return "ConnectionLine";
};
},
mindplot.ConnectionLine.prototype.getId = function(){
getId : function() {
return this._model.getId();
};
},
mindplot.ConnectionLine.prototype.moveToBack = function(){
moveToBack : function() {
this._line2d.moveToBack();
};
},
mindplot.ConnectionLine.prototype.moveToFront = function(){
moveToFront : function() {
this._line2d.moveToFront();
}
});
mindplot.ConnectionLine.getStrokeColor = function() {
return '#495879';
};
mindplot.ConnectionLine.SIMPLE = 0;

View File

@ -16,12 +16,13 @@
* limitations under the License.
*/
mindplot.ControlPoint = function()
{
mindplot.ControlPoint = new Class({
initialize:function() {
this._controlPointsController = [new web2d.Elipse({width:6, height:6, stroke:'1 solid #6589de',fillColor:'gray', visibility:false}),
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));
@ -29,13 +30,14 @@ mindplot.ControlPoint = function()
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.setSide= function(side) {
setSide : function(side) {
this._side = side;
};
},
mindplot.ControlPoint.prototype.setLine= function(line) {
setLine : function(line) {
if (core.Utils.isDefined(this._line)) {
this._removeLine();
}
@ -47,14 +49,14 @@ mindplot.ControlPoint.prototype.setLine= function(line) {
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(){
redraw : function() {
if (core.Utils.isDefined(this._line))
this._createControlPoint();
};
},
mindplot.ControlPoint.prototype._createControlPoint = function() {
_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);
@ -65,13 +67,13 @@ mindplot.ControlPoint.prototype._createControlPoint = function() {
this._controlLines[1].setTo(this._controls[mindplot.ControlPoint.TO].x + pos.x + 3, this._controls[mindplot.ControlPoint.TO].y + pos.y);
this._controlPointsController[1].setPosition(this._controls[mindplot.ControlPoint.TO].x + pos.x, this._controls[mindplot.ControlPoint.TO].y + pos.y - 3);
};
},
mindplot.ControlPoint.prototype._removeLine= function() {
_removeLine : function() {
};
},
mindplot.ControlPoint.prototype._mouseDown = function(event, point) {
_mouseDown : function(event, point) {
if (!this._isBinded) {
this._isBinded = true;
this._mouseMoveFunction = this._mouseMove.bindWithEvent(this, point);
@ -82,9 +84,9 @@ mindplot.ControlPoint.prototype._mouseDown = function(event, point) {
event.preventDefault();
event.stop();
return false;
};
},
mindplot.ControlPoint.prototype._mouseMove = function(event, point) {
_mouseMove : function(event, point) {
var screen = this._workspace.getScreenManager();
var pos = screen.getWorkspaceMousePosition(event);
var topic = null;
@ -106,9 +108,9 @@ mindplot.ControlPoint.prototype._mouseMove = function(event, point) {
/*event.preventDefault();
event.stop();
return false;*/
};
},
mindplot.ControlPoint.prototype._mouseUp = function(event, point) {
_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);
@ -117,15 +119,15 @@ mindplot.ControlPoint.prototype._mouseUp = function(event, point) {
/*event.preventDefault();
event.stop();
return false;*/
};
},
mindplot.ControlPoint.prototype._mouseClick = function(event){
_mouseClick : function(event) {
event.preventDefault();
event.stop();
return false;
};
},
mindplot.ControlPoint.prototype.setVisibility = function(visible){
setVisibility : function(visible) {
if (visible) {
this._controlLines[0].moveToFront();
this._controlLines[1].moveToFront();
@ -136,35 +138,36 @@ mindplot.ControlPoint.prototype.setVisibility = function(visible){
this._controlPointsController[1].setVisibility(visible);
this._controlLines[0].setVisibility(visible);
this._controlLines[1].setVisibility(visible);
};
},
mindplot.ControlPoint.prototype.addToWorkspace = function(workspace){
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){
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){
getControlPoint : function(index) {
return this._controls[index];
};
},
mindplot.ControlPoint.prototype.getOriginalEndPoint = function(index){
getOriginalEndPoint : function(index) {
return this._endPoint[index];
};
},
mindplot.ControlPoint.prototype.getOriginalCtrlPoint = function(index){
getOriginalCtrlPoint : function(index) {
return this._orignalCtrlPoint[index];
};
}
});
mindplot.ControlPoint.FROM = 0;
mindplot.ControlPoint.TO = 1;

View File

@ -17,8 +17,13 @@
*/
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,29 +82,24 @@ 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) {
@ -136,12 +125,10 @@ mindplot.CommandContext = new Class({
}
});
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

@ -17,76 +17,67 @@
*/
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

@ -16,8 +16,8 @@
* limitations under the License.
*/
mindplot.DragPivot = function()
{
mindplot.DragPivot = new Class({
initialize:function() {
this._position = new core.Point();
this._size = mindplot.DragTopic.PIVOT_SIZE;
this._line = null;
@ -27,35 +27,31 @@ mindplot.DragPivot = function()
this._dragPivot = this._buildRect();
this._connectRect = this._buildRect();
this._targetTopic = null;
};
},
mindplot.DragPivot.prototype.getTargetTopic = function()
{
getTargetTopic : function() {
return this._targetTopic;
};
},
mindplot.DragPivot.prototype._buildStraightLine = function()
{
_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()
{
_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)
{
_redraw : function(pivotPosition) {
// Update line position.
core.assert(this.getTargetTopic(), 'Illegal invocation. Target node can not be null');
@ -64,8 +60,7 @@ mindplot.DragPivot.prototype._redraw = function(pivotPosition)
// Pivot position has not changed. In this case, position change is not required.
var targetTopic = this.getTargetTopic();
if (currentPivotPosition.x != pivotPosition.x || currentPivotPosition.y != pivotPosition.y)
{
if (currentPivotPosition.x != pivotPosition.x || currentPivotPosition.y != pivotPosition.y) {
var position = this._position;
var fromPoint = targetTopic.workoutIncomingConnectionPoint(position);
@ -83,8 +78,7 @@ mindplot.DragPivot.prototype._redraw = function(pivotPosition)
pivotRect.setPosition(pivotPosition.x, pivotPosition.y);
// Display elements if it's required...
if (!pivotRect.isVisible())
{
if (!pivotRect.isVisible()) {
// Make line visible only when the position has been already changed.
// This solve several strange effects ;)
var targetPoint = targetTopic.workoutIncomingConnectionPoint(pivotPoint);
@ -93,75 +87,64 @@ mindplot.DragPivot.prototype._redraw = function(pivotPosition)
this.setVisibility(true);
}
}
};
},
mindplot.DragPivot.prototype.setPosition = function(point)
{
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())
{
if (this.getTargetTopic()) {
var pivotPosition = {x:cx,y:cy};
this._redraw(pivotPosition);
}
};
},
mindplot.DragPivot.prototype.getPosition = function()
{
getPosition : function() {
return this._position;
};
},
mindplot.DragPivot.prototype._buildRect = function()
{
_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()
{
_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()
{
_getPivotRect : function() {
return this._dragPivot;
};
},
mindplot.DragPivot.prototype.getSize = function()
{
getSize : function() {
var elem2d = this._getPivotRect();
return elem2d.getSize();
};
},
mindplot.DragPivot.prototype.setVisibility = function(value)
{
setVisibility : function(value) {
var pivotRect = this._getPivotRect();
pivotRect.setVisibility(value);
var connectRect = this._connectRect;
connectRect.setVisibility(value);
if (core.Utils.isDefined(this._line))
{
if (core.Utils.isDefined(this._line)) {
this._line.setVisibility(value);
}
};
},
mindplot.DragPivot.prototype.addToWorkspace = function(workspace)
{
addToWorkspace : function(workspace) {
var pivotRect = this._getPivotRect();
workspace.appendChild(pivotRect);
@ -185,45 +168,36 @@ mindplot.DragPivot.prototype.addToWorkspace = function(workspace)
connectRect.setVisibility(false);
workspace.appendChild(connectRect);
connectRect.moveToBack();
};
},
mindplot.DragPivot.prototype.removeFromWorkspace = function(workspace)
{
removeFromWorkspace : function(workspace) {
var shape = this._getPivotRect();
workspace.removeChild(shape);
var connectToRect = this._connectRect;
workspace.removeChild(connectToRect);
if (core.Utils.isDefined(this._straightLine))
{
if (core.Utils.isDefined(this._straightLine)) {
workspace.removeChild(this._straightLine);
}
if (core.Utils.isDefined(this._curvedLine))
{
if (core.Utils.isDefined(this._curvedLine)) {
workspace.removeChild(this._curvedLine);
}
};
},
mindplot.DragPivot.prototype.connectTo = function(targetTopic)
{
connectTo : function(targetTopic) {
core.assert(!this._outgoingLine, 'Could not connect an already connected node');
core.assert(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)
{
if (targetTopic.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE) {
this._line = this._straightLine;
} else
{
} else {
this._line = this._curvedLine;
}
// Show pivot ...
var line = this._line;
// Connected to Rect ...
var connectRect = this._connectRect;
var targetSize = targetTopic.getSize();
@ -240,14 +214,14 @@ mindplot.DragPivot.prototype.connectTo = function(targetTopic)
var pivotRect = this._getPivotRect();
pivotRect.moveToFront();
};
},
mindplot.DragPivot.prototype.disconnect = function(workspace)
{
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

@ -16,16 +16,15 @@
* limitations under the License.
*/
mindplot.DragTopicPositioner = function(layoutManager)
{
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)
{
positionateDragTopic : function(dragTopic) {
// Workout the real position of the element on the board.
var dragTopicPosition = dragTopic.getPosition();
var draggedTopic = dragTopic.getDraggedTopic();
@ -34,67 +33,53 @@ mindplot.DragTopicPositioner.prototype.positionateDragTopic = function(dragTopic
this._checkDragTopicConnection(dragTopic);
// Position topic in the board
if (dragTopic.isConnected())
{
if (dragTopic.isConnected()) {
var targetTopic = dragTopic.getConnectedToTopic();
var topicBoard = this._layoutManager.getTopicBoardForTopic(targetTopic);
topicBoard.positionateDragTopic(dragTopic);
}
};
},
mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE = 400;
mindplot.DragTopicPositioner.prototype._checkDragTopicConnection = function(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))
{
if (core.Utils.isDefined(currentConnection)) {
// MainTopic->MainTopicConnection.
if (currentConnection.getType()==mindplot.NodeModel.MAIN_TOPIC_TYPE)
{
if(mainTopicToMainTopicConnection != currentConnection)
{
if (currentConnection.getType() == mindplot.NodeModel.MAIN_TOPIC_TYPE) {
if (mainTopicToMainTopicConnection != currentConnection) {
dragTopic.disconnect(this._workspace);
}
}
else if (currentConnection.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE)
{
else if (currentConnection.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE) {
// Distance if greater that the allowed.
var dragXPosition = dragTopic.getPosition().x;
var currentXPosition = currentConnection.getPosition().x;
if(core.Utils.isDefined(mainTopicToMainTopicConnection))
{
if (core.Utils.isDefined(mainTopicToMainTopicConnection)) {
// I have to change the current connection to a main topic.
dragTopic.disconnect(this._workspace);
} else
if (Math.abs(dragXPosition-currentXPosition) > mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE)
{
if (Math.abs(dragXPosition - currentXPosition) > mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE) {
dragTopic.disconnect(this._workspace);
}
}
}
// Finally, connect nodes ...
if (!dragTopic.isConnected())
{
if (!dragTopic.isConnected()) {
var centalTopic = topics[0];
if (core.Utils.isDefined(mainTopicToMainTopicConnection))
{
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)
{
} 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)
{
_lookUpForMainTopicToMainTopicConnection : function(dragTopic) {
var topics = this._topics;
var result = null;
var clouserDistance = -1;
@ -102,15 +87,12 @@ mindplot.DragTopicPositioner.prototype._lookUpForMainTopicToMainTopicConnection
var distance = null;
// Check MainTopic->MainTopic connection...
for (var i = 0; i < topics.length; i++)
{
for (var i = 0; i < topics.length; i++) {
var targetTopic = topics[i];
var position = dragTopic.getPosition();
if (targetTopic.getType() != mindplot.NodeModel.CENTRAL_TOPIC_TYPE && targetTopic != draggedNode)
{
if (targetTopic.getType() != mindplot.NodeModel.CENTRAL_TOPIC_TYPE && targetTopic != draggedNode) {
var canBeConnected = dragTopic.canBeConnectedTo(targetTopic);
if (canBeConnected)
{
if (canBeConnected) {
var targetPosition = targetTopic.getPosition();
var fix = position.y > targetPosition.y;
var gap = 0;
@ -118,8 +100,7 @@ mindplot.DragTopicPositioner.prototype._lookUpForMainTopicToMainTopicConnection
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)
{
if (distance == null || yDistance < distance) {
result = targetTopic;
distance = yDistance;
}
@ -128,4 +109,7 @@ mindplot.DragTopicPositioner.prototype._lookUpForMainTopicToMainTopicConnection
}
}
return result;
};
}
});
mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE = 400;

View File

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

View File

@ -16,26 +16,24 @@
* limitations under the License.
*/
mindplot.EditorProperties = function()
{
mindplot.EditorProperties = new Class({
initialize:function() {
this._zoom = 0;
this._position = 0;
};
},
mindplot.EditorProperties.prototype.setZoom = function(zoom)
{
setZoom : function(zoom) {
this._zoom = zoom;
};
},
mindplot.EditorProperties.prototype.getZoom = function()
{
getZoom : function() {
return this._zoom;
};
},
mindplot.EditorProperties.prototype.asProperties = function()
{
asProperties : function() {
return "zoom=" + this._zoom + "\n";
};
}
});

View File

@ -1,15 +1,14 @@
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 = {
NodeResizeEvent:'NodeResizeEvent',

View File

@ -16,42 +16,35 @@
* limitations under the License.
*/
mindplot.FixedDistanceBoard = function(defaultHeight, topic, layoutManager)
{
mindplot.FixedDistanceBoard = new Class({
Extends:mindplot.Board,
initialize:function(defaultHeight, topic, layoutManager) {
this._topic = topic;
this._layoutManager = layoutManager;
var reference = topic.getPosition();
mindplot.FixedDistanceBoard.superClass.initialize.call(this, defaultHeight, reference);
this.parent(defaultHeight, reference);
this._height = defaultHeight;
this._entries = [];
};
},
objects.extend(mindplot.FixedDistanceBoard, mindplot.Board);
mindplot.FixedDistanceBoard.prototype.getHeight = function()
{
getHeight : function() {
return this._height;
};
},
mindplot.FixedDistanceBoard.prototype.lookupEntryByOrder = function(order)
{
lookupEntryByOrder : function(order) {
var result = null;
var entries = this._entries;
if (order < entries.length)
{
if (order < entries.length) {
result = entries[order];
}
if (result == null)
{
if (result == null) {
var defaultHeight = this._defaultWidth;
var reference = this.getReferencePoint();
if (entries.length == 0)
{
if (entries.length == 0) {
var yReference = reference.y;
result = this.createBoardEntry(yReference - (defaultHeight / 2), yReference + (defaultHeight / 2), 0);
} else
{
} else {
var entriesLenght = entries.length;
var lastEntry = entries[entriesLenght - 1];
var lowerLimit = lastEntry.getUpperLimit();
@ -60,26 +53,23 @@ mindplot.FixedDistanceBoard.prototype.lookupEntryByOrder = function(order)
}
}
return result;
};
},
mindplot.FixedDistanceBoard.prototype.createBoardEntry = function(lowerLimit, upperLimit, order)
{
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()
{
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++)
{
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
if (core.Utils.isDefined(entry)) {
@ -96,71 +86,55 @@ mindplot.FixedDistanceBoard.prototype.updateReferencePoint = function()
}
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.
*/
mindplot.FixedDistanceBoard.prototype.workoutXBorderDistance = function()
{
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)
{
if (topicPosition.x >= 0) {
// It's at right.
result = topicPosition.x + halfTargetWidth + mindplot.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE;
} else
{
} else {
result = topicPosition.x - (halfTargetWidth + mindplot.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE);
}
return result;
};
},
mindplot.FixedDistanceBoard.prototype.getTopic = function()
{
getTopic : function() {
return this._topic;
};
},
mindplot.FixedDistanceBoard.INTER_TOPIC_DISTANCE = 6;
mindplot.FixedDistanceBoard.prototype.freeEntry = function(entry)
{
freeEntry : function(entry) {
var newEntries = [];
var entries = this._entries;
var order = 0;
for (var i = 0; i < entries.length; i++)
{
for (var i = 0; i < entries.length; i++) {
var e = entries[i];
if (e == entry)
{
if (e == entry) {
order++;
}
newEntries[order] = e;
order++;
}
this._entries = newEntries;
};
},
mindplot.FixedDistanceBoard.prototype.repositionate = function()
{
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++)
{
if (entries.length >= 1 && !model.areChildrenShrinked()) {
for (var i = 0; i < entries.length; i++) {
var e = entries[i];
if (e && e.getTopic())
{
if (e && e.getTopic()) {
var topic = e.getTopic();
var topicBoard = this._layoutManager.getTopicBoardForTopic(topic);
var topicBoardHeight = topicBoard.getHeight();
@ -179,12 +153,10 @@ mindplot.FixedDistanceBoard.prototype.repositionate = function()
this._height = height;
// I must update all the parent nodes first...
if (oldHeight != this._height)
{
if (oldHeight != this._height) {
var topic = this._topic;
var parentTopic = topic.getParent();
if (parentTopic != null)
{
if (parentTopic != null) {
var board = this._layoutManager.getTopicBoardForTopic(parentTopic);
board.repositionate();
}
@ -197,8 +169,7 @@ mindplot.FixedDistanceBoard.prototype.repositionate = function()
// Workout center the new topic center...
var refence = this.getReferencePoint();
var lowerLimit;
if (entries.length > 0)
{
if (entries.length > 0) {
var l = 0;
for (l = 0; l < entries.length; l++) {
if (core.Utils.isDefined(entries[l]))
@ -214,11 +185,9 @@ mindplot.FixedDistanceBoard.prototype.repositionate = function()
// Start moving all the elements ...
var newEntries = [];
var order = 0;
for (var i = 0; i < entries.length; i++)
{
for (var i = 0; i < entries.length; i++) {
var e = entries[i];
if (e && e.getTopic())
{
if (e && e.getTopic()) {
var currentTopic = e.getTopic();
e.setLowerLimit(lowerLimit);
@ -240,10 +209,9 @@ mindplot.FixedDistanceBoard.prototype.repositionate = function()
}
}
this._entries = newEntries;
};
},
mindplot.FixedDistanceBoard.prototype.removeTopic = function(topic)
{
removeTopic : function(topic) {
var order = topic.getOrder();
var entry = this.lookupEntryByOrder(order);
core.assert(!entry.isAvailable(), "Illegal state");
@ -254,15 +222,13 @@ mindplot.FixedDistanceBoard.prototype.removeTopic = function(topic)
// Repositionate all elements ...
this.repositionate();
};
},
mindplot.FixedDistanceBoard.prototype.addTopic = function(order, topic)
{
addTopic : function(order, topic) {
// If the entry is not available, I must swap the the entries...
var entry = this.lookupEntryByOrder(order);
if (!entry.isAvailable())
{
if (!entry.isAvailable()) {
this.freeEntry(entry);
// Create a dummy entry ...
// Puaj, do something with this...
@ -276,41 +242,33 @@ mindplot.FixedDistanceBoard.prototype.addTopic = function(order, topic)
// Repositionate all elements ...
this.repositionate();
};
},
mindplot.FixedDistanceBoard.prototype.lookupEntryByPosition = function(pos)
{
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++)
{
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
if (pos.y < entry.getUpperLimit() && pos.y >= entry.getLowerLimit())
{
if (pos.y < entry.getUpperLimit() && pos.y >= entry.getLowerLimit()) {
result = entry;
}
}
if (result == null)
{
if (result == null) {
var defaultHeight = this._defaultWidth;
if (entries.length == 0)
{
if (entries.length == 0) {
var reference = this.getReferencePoint();
var yReference = reference.y;
result = this.createBoardEntry(yReference - (defaultHeight / 2), yReference + (defaultHeight / 2), 0);
} else
{
} else {
var firstEntry = entries[0];
if (pos.y < firstEntry.getLowerLimit())
{
if (pos.y < firstEntry.getLowerLimit()) {
var upperLimit = firstEntry.getLowerLimit();
var lowerLimit = upperLimit - defaultHeight;
result = this.createBoardEntry(lowerLimit, upperLimit, 0);
} else
{
} else {
var entriesLenght = entries.length;
var lastEntry = entries[entriesLenght - 1];
var lowerLimit = lastEntry.getUpperLimit();
@ -321,4 +279,9 @@ mindplot.FixedDistanceBoard.prototype.lookupEntryByPosition = function(pos)
}
return result;
};
}
})
;
mindplot.FixedDistanceBoard.INTER_TOPIC_DISTANCE = 6;
mindplot.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE = 60;

View File

@ -16,26 +16,28 @@
* limitations under the License.
*/
mindplot.Icon = function(url){
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(){
getImage : function() {
return this._image;
};
},
mindplot.Icon.prototype.setGroup= function(group){
setGroup : function(group) {
this._group = group;
};
},
mindplot.Icon.prototype.getGroup= function() {
getGroup : function() {
return this._group;
};
},
mindplot.Icon.prototype.getSize=function(){
getSize : function() {
return this._image.getSize();
};
}
});

View File

@ -16,8 +16,10 @@
* limitations under the License.
*/
mindplot.IconGroup = function(topic) {
mindplot.IconGroup = new Class({
initialize : function(topic) {
var offset = topic.getOffset();
this.options = {
width:0,
height:0,
@ -29,31 +31,30 @@ mindplot.IconGroup = function(topic) {
};
this.updateIconGroupPosition();
this.registerListeners();
};
},
mindplot.IconGroup.prototype.setPosition = function(x, y) {
setPosition : function(x, y) {
this.options.x = x;
this.options.y = y;
this.options.nativeElem.setPosition(x, y);
};
},
mindplot.IconGroup.prototype.getPosition = function() {
getPosition : function() {
return {x:this.options.x, y:this.options.y};
};
},
mindplot.IconGroup.prototype.setSize = function(width, height) {
setSize : function(width, height) {
this.options.width = width;
this.options.height = height;
this.options.nativeElem.setSize(width, height);
this.options.nativeElem.setCoordSize(width, height);
};
},
mindplot.IconGroup.prototype.getSize = function()
{
getSize : function() {
return {width:this.options.width, height:this.options.height};
};
},
mindplot.IconGroup.prototype.addIcon = function(icon) {
addIcon : function(icon) {
icon.setGroup(this);
var newIcon = icon.getImage();
var nativeElem = this.options.nativeElem;
@ -65,8 +66,7 @@ mindplot.IconGroup.prototype.addIcon = function(icon) {
nativeElem.appendChild(newIcon);
size.width = size.width + iconSize.width;
if (iconSize.height > size.height)
{
if (iconSize.height > size.height) {
size.height = iconSize.height;
}
@ -74,63 +74,60 @@ mindplot.IconGroup.prototype.addIcon = function(icon) {
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) {
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);
};
},
mindplot.IconGroup.prototype.getIcon = function(url) {
getIcon : function(url) {
var result = null;
this.options.icons.each(function(el, index) {
var nativeImage = el.getImage();
if (nativeImage.getHref() == url)
{
if (nativeImage.getHref() == url) {
result = el;
}
}, this);
return result;
};
},
mindplot.IconGroup.prototype.getImageIcon=function(icon){
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())
{
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){
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())
{
if (result == null && $chk(elModel.isIconModel) && elModel.getId() == iconModel.getId()) {
result = el;
}
}, this);
if(result==null)
{
if (result == null) {
throw "Icon can no be found.";
}
return result;
};
},
mindplot.IconGroup.prototype._removeIcon = function(icon) {
_removeIcon : function(icon) {
var nativeImage = icon.getImage();
this.options.icons.erase(icon);
var iconSize = nativeImage.getSize();
@ -146,48 +143,47 @@ mindplot.IconGroup.prototype._removeIcon = function(icon) {
}.bind(this));
size.width = size.width - iconSize.width;
this.setSize(size.width, size.height);
};
mindplot.IconGroup.prototype.getNativeElement = function() {
},
getNativeElement : function() {
return this.options.nativeElem;
};
mindplot.IconGroup.prototype.moveToFront = function() {
},
moveToFront : function() {
this.options.nativeElem.moveToFront();
}
mindplot.IconGroup.prototype.registerListeners = function() {
},
registerListeners : function() {
this.options.nativeElem.addEventListener('click', function(event) {
// Avoid node creation ...
if (core.Utils.isDefined(event.stopPropagation))
{
if (core.Utils.isDefined(event.stopPropagation)) {
event.stopPropagation(true);
} else
{
} else {
event.cancelBubble = true;
}
});
this.options.nativeElem.addEventListener('dblclick', function(event)
{
this.options.nativeElem.addEventListener('dblclick', function(event) {
// Avoid node creation ...
if (core.Utils.isDefined(event.stopPropagation))
{
if (core.Utils.isDefined(event.stopPropagation)) {
event.stopPropagation(true);
} else
{
} else {
event.cancelBubble = true;
}
});
};
mindplot.IconGroup.prototype.getTopic = function() {
return this.options.topic;
};
},
mindplot.IconGroup.prototype.updateIconGroupPosition = function() {
getTopic : function() {
return this.options.topic;
},
updateIconGroupPosition : function() {
var offsets = this._calculateOffsets();
this.setPosition(offsets.x, offsets.y);
};
},
mindplot.IconGroup.prototype._calculateOffsets = function() {
_calculateOffsets : function() {
var offset = this.options.topic.getOffset();
var text = this.options.topic.getTextShape();
var sizeHeight = text.getHtmlFontSize();
@ -195,4 +191,5 @@ mindplot.IconGroup.prototype._calculateOffsets = function() {
var shape = this.options.topic.getShapeType();
yOffset = text.getPosition().y + (sizeHeight - 18) / 2 + 1;
return {x:offset, y:yOffset};
};
}
});

View File

@ -16,76 +16,62 @@
* limitations under the License.
*/
mindplot.Mindmap = function()
{
mindplot.Mindmap = new Class({
initialize : function() {
this._branches = [];
this._name = null;
this._description = null;
this._version = null;
this._relationships = [];
};
},
mindplot.Mindmap.prototype.getCentralTopic = function()
{
getCentralTopic : function() {
return this._branches[0];
};
},
mindplot.Mindmap.prototype.getDescription = function()
{
getDescription : function() {
return this._description;
};
},
mindplot.Mindmap.prototype.getId = function()
{
getId : function() {
return this._iconType;
};
},
mindplot.Mindmap.prototype.setId = function(id)
{
setId : function(id) {
this._iconType = id;
};
},
mindplot.Mindmap.prototype.getVersion = function()
{
getVersion : function() {
return this._version;
};
},
mindplot.Mindmap.prototype.setVersion = function(version)
{
setVersion : function(version) {
this._version = version;
};
},
mindplot.Mindmap.prototype.addBranch = function(nodeModel)
{
addBranch : function(nodeModel) {
core.assert(nodeModel && nodeModel.isNodeModel(), 'Add node must be invoked with model objects');
if (this._branches.length == 0)
{
if (this._branches.length == 0) {
core.assert(nodeModel.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE, "First element must be the central topic");
nodeModel.setPosition(0, 0);
} else
{
} else {
core.assert(nodeModel.getType() != mindplot.NodeModel.CENTRAL_TOPIC_TYPE, "Mindmaps only have one cental topic");
}
this._branches.push(nodeModel);
};
},
mindplot.Mindmap.prototype.getBranches = function()
{
getBranches : function() {
return this._branches;
};
},
mindplot.Mindmap.prototype.getRelationships = function() {
getRelationships : function() {
return this._relationships;
};
},
mindplot.Mindmap.prototype.connect = function(parent, child)
{
connect : function(parent, child) {
// Child already has a parent ?
var branches = this.getBranches();
core.assert(!child.getParent(), 'Child model seems to be already connected');
@ -95,10 +81,9 @@ mindplot.Mindmap.prototype.connect = function(parent, child)
// Remove from the branch ...
branches.erase(child);
};
},
mindplot.Mindmap.prototype.disconnect = function(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');
@ -108,63 +93,55 @@ mindplot.Mindmap.prototype.disconnect = function(child)
var branches = this.getBranches();
branches.push(child);
};
},
mindplot.Mindmap.prototype.hasAlreadyAdded = function(node)
{
hasAlreadyAdded : function(node) {
var result = false;
// Check in not connected nodes.
var branches = this._branches;
for (var i = 0; i < branches.length; i++)
{
for (var i = 0; i < branches.length; i++) {
result = branches[i]._isChildNode(node);
if (result)
{
if (result) {
break;
}
}
};
},
mindplot.Mindmap.prototype.createNode = function(type, id)
{
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)
{
_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){
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) {
addRelationship : function(relationship) {
this._relationships.push(relationship);
};
},
mindplot.Mindmap.prototype.removeRelationship = function(relationship) {
removeRelationship : function(relationship) {
this._relationships.erase(relationship);
};
},
mindplot.Mindmap.prototype.inspect = function()
{
inspect : function() {
var result = '';
result = '{ ';
var branches = this.getBranches();
for (var i = 0; i < branches.length; i++)
{
for (var i = 0; i < branches.length; i++) {
var node = branches[i];
if (i != 0)
{
if (i != 0) {
result = result + ', ';
}
@ -174,32 +151,29 @@ mindplot.Mindmap.prototype.inspect = function()
result = result + ' } ';
return result;
};
},
mindplot.Mindmap.prototype._toString = function(node)
{
_toString : function(node) {
var result = node.inspect();
var children = node.getChildren();
for (var i = 0; i < children.length; i++)
{
for (var i = 0; i < children.length; i++) {
var child = children[i];
if (i == 0)
{
if (i == 0) {
result = result + '-> {';
} else
{
} else {
result = result + ', ';
}
result = result + this._toString(child);
if (i == children.length - 1)
{
if (i == children.length - 1) {
result = result + '}';
}
}
return result;
};
}
}
);

View File

@ -16,8 +16,8 @@
* limitations under the License.
*/
mindplot.NodeModel = function(type, mindmap, id)
{
mindplot.NodeModel = new Class({
initialize:function(type, mindmap, id) {
core.assert(type, 'Node type can not be null');
core.assert(mindmap, 'mindmap can not be null');
@ -48,15 +48,13 @@ mindplot.NodeModel = function(type, mindmap, id)
this._borderColor = null;
this._backgroundColor = null;
this._areChildrenShrinked = false;
};
},
mindplot.NodeModel.prototype.clone = function()
{
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)
{
result._children = this._children.map(function(item, index) {
var model = item.clone();
model._parent = result;
return model;
@ -81,215 +79,178 @@ mindplot.NodeModel.prototype.clone = function()
result._backgroundColor = this._backgroundColor;
result._areChildrenShrinked = this._areChildrenShrinked;
return result;
};
},
mindplot.NodeModel.prototype.areChildrenShrinked = function()
{
areChildrenShrinked : function() {
return this._areChildrenShrinked;
};
},
mindplot.NodeModel.prototype.setChildrenShrinked = function(value)
{
setChildrenShrinked : function(value) {
this._areChildrenShrinked = value;
};
},
mindplot.NodeModel.prototype.getId = function()
{
getId : function() {
return this._id;
};
},
mindplot.NodeModel.prototype.setId = function(id)
{
setId : function(id) {
this._id = id;
if (mindplot.NodeModel._uuid < id) {
mindplot.NodeModel._uuid = id;
}
};
},
mindplot.NodeModel.prototype.getType = function()
{
getType : function() {
return this._type;
};
},
mindplot.NodeModel.prototype.setText = function(text)
{
setText : function(text) {
this._text = text;
};
},
mindplot.NodeModel.prototype.getText = function()
{
getText : function() {
return this._text;
};
},
mindplot.NodeModel.prototype.isNodeModel = function()
{
isNodeModel : function() {
return true;
};
},
mindplot.NodeModel.prototype.isConnected = function()
{
isConnected : function() {
return this._parent != null;
};
},
mindplot.NodeModel.prototype.createLink = function(url)
{
createLink : function(url) {
core.assert(url, 'Link URL must be specified.');
return new mindplot.LinkModel(url, this);
};
},
mindplot.NodeModel.prototype.addLink = function(link)
{
addLink : function(link) {
core.assert(link && link.isLinkModel(), 'Only LinkModel can be appended to Mindmap object as links');
this._links.push(link);
};
},
mindplot.NodeModel.prototype._removeLink = function(link)
{
_removeLink : function(link) {
core.assert(link && link.isLinkModel(), 'Only LinkModel can be appended to Mindmap object as links');
this._links.erase(link);
};
},
mindplot.NodeModel.prototype.createNote = function(text)
{
createNote : function(text) {
core.assert(text != null, 'note text must be specified.');
return new mindplot.NoteModel(text, this);
};
},
mindplot.NodeModel.prototype.addNote = function(note)
{
addNote : function(note) {
core.assert(note && note.isNoteModel(), 'Only NoteModel can be appended to Mindmap object as links');
this._notes.push(note);
};
},
mindplot.NodeModel.prototype._removeNote = function(note)
{
_removeNote : function(note) {
core.assert(note && note.isNoteModel(), 'Only NoteModel can be appended to Mindmap object as links');
this._notes.erase(note);
};
},
mindplot.NodeModel.prototype.createIcon = function(iconType)
{
createIcon : function(iconType) {
core.assert(iconType, 'IconType must be specified.');
return new mindplot.IconModel(iconType, this);
};
},
mindplot.NodeModel.prototype.addIcon = function(icon)
{
addIcon : function(icon) {
core.assert(icon && icon.isIconModel(), 'Only IconModel can be appended to Mindmap object as icons');
this._icons.push(icon);
};
},
mindplot.NodeModel.prototype._removeIcon = function(icon)
{
_removeIcon : function(icon) {
core.assert(icon && icon.isIconModel(), 'Only IconModel can be appended to Mindmap object as icons');
this._icons.erase(icon);
};
},
mindplot.NodeModel.prototype.removeLastIcon = function()
{
removeLastIcon : function() {
this._icons.pop();
};
},
mindplot.NodeModel.prototype._appendChild = function(child)
{
_appendChild : function(child) {
core.assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
this._children.push(child);
child._parent = this;
};
},
mindplot.NodeModel.prototype._removeChild = function(child)
{
_removeChild : function(child) {
core.assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object.');
this._children.erase(child);
child._parent = null;
};
},
mindplot.NodeModel.prototype.setPosition = function(x, y)
{
setPosition : function(x, y) {
core.assert(core.Utils.isDefined(x), "x coordinate must be defined");
core.assert(core.Utils.isDefined(y), "y coordinate must be defined");
if (!core.Utils.isDefined(this._position))
{
if (!core.Utils.isDefined(this._position)) {
this._position = new core.Point();
}
this._position.x = parseInt(x);
this._position.y = parseInt(y);
};
},
mindplot.NodeModel.prototype.getPosition = function()
{
getPosition : function() {
return this._position;
};
},
mindplot.NodeModel.prototype.setFinalPosition = function(x, y)
{
setFinalPosition : function(x, y) {
core.assert(core.Utils.isDefined(x), "x coordinate must be defined");
core.assert(core.Utils.isDefined(y), "y coordinate must be defined");
if (!core.Utils.isDefined(this._finalPosition))
{
if (!core.Utils.isDefined(this._finalPosition)) {
this._finalPosition = new core.Point();
}
this._finalPosition.x = parseInt(x);
this._finalPosition.y = parseInt(y);
};
},
mindplot.NodeModel.prototype.getFinalPosition = function()
{
getFinalPosition : function() {
return this._finalPosition;
};
},
mindplot.NodeModel.prototype.setSize = function(width, height)
{
setSize : function(width, height) {
this._size.width = width;
this._size.height = height;
};
},
mindplot.NodeModel.prototype.getSize = function()
{
getSize : function() {
return {width:this._size.width,height:this._size.height};
};
},
mindplot.NodeModel.prototype.getChildren = function()
{
getChildren : function() {
return this._children;
};
},
mindplot.NodeModel.prototype.getIcons = function()
{
getIcons : function() {
return this._icons;
};
},
mindplot.NodeModel.prototype.getLinks = function()
{
getLinks : function() {
return this._links;
};
},
mindplot.NodeModel.prototype.getNotes = function()
{
getNotes : function() {
return this._notes;
};
},
mindplot.NodeModel.prototype.getParent = function()
{
getParent : function() {
return this._parent;
};
},
mindplot.NodeModel.prototype.getMindmap = function()
{
getMindmap : function() {
return this._mindmap;
};
},
mindplot.NodeModel.prototype.setParent = function(parent)
{
setParent : function(parent) {
core.assert(parent != this, 'The same node can not be parent and child if itself.');
this._parent = parent;
};
},
mindplot.NodeModel.prototype.canBeConnected = function(sourceModel, sourcePosition, targetTopicHeight)
{
canBeConnected : function(sourceModel, sourcePosition, targetTopicHeight) {
core.assert(sourceModel != this, 'The same node can not be parent and child if itself.');
core.assert(sourcePosition, 'childPosition can not be null.');
core.assert(core.Utils.isDefined(targetTopicHeight), 'childrenWidth can not be null.');
@ -300,8 +261,7 @@ mindplot.NodeModel.prototype.canBeConnected = function(sourceModel, sourcePositi
var targetPosition = targetModel.getPosition();
var result = false;
if (sourceModel.getType() == mindplot.NodeModel.MAIN_TOPIC_TYPE)
{
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);
@ -310,187 +270,149 @@ mindplot.NodeModel.prototype.canBeConnected = function(sourceModel, sourcePositi
gap += Math.abs(targetPosition.y - targetModel.getChildren()[0].getPosition().y);
}
if (yDistance <= gap)
{
if (yDistance <= gap) {
// Circular connection ?
if (!sourceModel._isChildNode(this))
{
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))
{
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))
{
} else {
if (xDistance <= targetTopicSize.width / 2 && Math.abs(xDistance) <= mindplot.NodeModel.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE / 2 + (targetTopicSize.width / 2)) {
result = true;
}
}
}
}
} else
{
} else {
throw "No implemented yet";
}
return result;
};
},
mindplot.NodeModel.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE = 220;
mindplot.NodeModel.prototype._isChildNode = function(node)
{
_isChildNode : function(node) {
var result = false;
if (node == this)
{
if (node == this) {
result = true;
} else
{
} else {
var children = this.getChildren();
for (var i = 0; i < children.length; i++)
{
for (var i = 0; i < children.length; i++) {
var child = children[i];
result = child._isChildNode(node);
if (result)
{
if (result) {
break;
}
}
}
return result;
};
},
mindplot.NodeModel.prototype.connectTo = function(parent)
{
connectTo : function(parent) {
var mindmap = this.getMindmap();
mindmap.connect(parent, this);
this._parent = parent;
};
},
mindplot.NodeModel.prototype.disconnect = function()
{
disconnect : function() {
var mindmap = this.getMindmap();
mindmap.disconnect(this);
};
},
mindplot.NodeModel.prototype.getOrder = function()
{
getOrder : function() {
return this._order;
};
},
mindplot.NodeModel.prototype.getShapeType = function()
{
getShapeType : function() {
return this._shapeType;
};
},
mindplot.NodeModel.prototype.setShapeType = function(type)
{
setShapeType : function(type) {
this._shapeType = type;
};
},
mindplot.NodeModel.prototype.setOrder = function(value)
{
setOrder : function(value) {
this._order = value;
};
},
mindplot.NodeModel.prototype.setFontFamily = function(value)
{
setFontFamily : function(value) {
this._fontFamily = value;
};
},
mindplot.NodeModel.prototype.getOrder = function()
{
getOrder : function() {
return this._order;
};
},
mindplot.NodeModel.prototype.getFontFamily = function()
{
getFontFamily : function() {
return this._fontFamily;
};
},
mindplot.NodeModel.prototype.setFontStyle = function(value)
{
setFontStyle : function(value) {
this._fontStyle = value;
};
},
mindplot.NodeModel.prototype.getFontStyle = function()
{
getFontStyle : function() {
return this._fontStyle;
};
},
mindplot.NodeModel.prototype.setFontWeight = function(value)
{
setFontWeight : function(value) {
this._fontWeight = value;
};
},
mindplot.NodeModel.prototype.getFontWeight = function()
{
getFontWeight : function() {
return this._fontWeight;
};
},
mindplot.NodeModel.prototype.setFontColor = function(value)
{
setFontColor : function(value) {
this._fontColor = value;
};
},
mindplot.NodeModel.prototype.getFontColor = function()
{
getFontColor : function() {
return this._fontColor;
};
},
mindplot.NodeModel.prototype.setFontSize = function(value)
{
setFontSize : function(value) {
this._fontSize = value;
};
},
mindplot.NodeModel.prototype.getFontSize = function()
{
getFontSize : function() {
return this._fontSize;
};
},
mindplot.NodeModel.prototype.getBorderColor = function()
{
getBorderColor : function() {
return this._borderColor;
};
},
mindplot.NodeModel.prototype.setBorderColor = function(color)
{
setBorderColor : function(color) {
this._borderColor = color;
};
},
mindplot.NodeModel.prototype.getBackgroundColor = function()
{
getBackgroundColor : function() {
return this._backgroundColor;
};
},
mindplot.NodeModel.prototype.setBackgroundColor = function(color)
{
setBackgroundColor : function(color) {
this._backgroundColor = color;
};
},
mindplot.NodeModel.prototype.deleteNode = function()
{
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++)
{
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 (core.Utils.isDefined(parent)) {
// if it is connected, I must remove it from the parent..
mindmap.disconnect(this);
}
@ -499,27 +421,12 @@ mindplot.NodeModel.prototype.deleteNode = function()
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()
{
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

@ -16,7 +16,9 @@
* limitations under the License.
*/
mindplot.Note = function(textModel, topic, designer) {
mindplot.Note = new Class({
Extends: mindplot.Icon,
initialize : function(textModel, topic, designer) {
var divContainer = designer.getWorkSpace().getScreenManager().getContainer();
var bubbleTip = mindplot.BubbleTip.getInstance(divContainer);
mindplot.Icon.call(this, mindplot.Note.IMAGE_URL);
@ -61,14 +63,14 @@ mindplot.Note = function(textModel, topic, designer) {
var msg = new Element('div');
var textarea = new Element('div').inject(msg);
textarea.innerHTML = "Text"
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)
formElem.inject(msg);
var okFunction = function(e) {
var result = true;
@ -78,8 +80,7 @@ mindplot.Note = function(textModel, topic, designer) {
return result;
};
formElem.addEvent('submit', function(e)
{
formElem.addEvent('submit', function(e) {
$(okButtonId).fireEvent('click', e);
e = new Event(e);
e.stop();
@ -93,7 +94,6 @@ mindplot.Note = function(textModel, topic, designer) {
buttonContainer.inject(container);
}
var note = this;
image.addEventListener('mouseover', function(event) {
var text = textModel.getText();
@ -111,23 +111,17 @@ mindplot.Note = function(textModel, topic, designer) {
image.addEventListener('mouseout', function(event) {
bubbleTip.close(event);
});
};
},
objects.extend(mindplot.Note, mindplot.Icon);
mindplot.Note.prototype.initialize = function() {
};
mindplot.Note.prototype.getText=function(){
getText: function() {
return this._text;
};
},
mindplot.Note.prototype.getModel=function(){
getModel : function() {
return this._noteModel;
};
},
mindplot.Note.buildDialog = function(designer, okFunction, okButtonId) {
buildDialog : function(designer, okFunction, okButtonId) {
var windoo = new Windoo({
title: 'Write note',
theme: Windoo.Themes.wise,
@ -147,8 +141,7 @@ mindplot.Note.buildDialog = function(designer, okFunction, okButtonId) {
var ok = new Element('input', {'type': 'button', 'class':'btn-primary', 'value': 'Ok','class':'btn-primary','id':okButtonId}).setStyle('marginRight', 10);
ok.addEvent('click', function(event) {
var couldBeUpdated = okFunction.attempt();
if (couldBeUpdated)
{
if (couldBeUpdated) {
$(document).addEvent('keydown', designer.keyEventHandler.bindWithEvent(designer));
windoo.close();
}
@ -159,7 +152,8 @@ mindplot.Note.buildDialog = function(designer, okFunction, okButtonId) {
windoo.addPanel(panel);
$(document).removeEvents('keydown');
return windoo;
};
}
});
mindplot.Note.IMAGE_URL = "../images/note.png";

View File

@ -16,30 +16,27 @@
* limitations under the License.
*/
mindplot.NoteModel = function(text, topic)
{
mindplot.NoteModel = new Class({
initialize : function(text, topic) {
core.assert(text != null, 'note text can not be null');
core.assert(topic, 'mindmap can not be null');
this._text = text;
this._topic = topic;
};
},
mindplot.NoteModel.prototype.getText = function()
{
getText:function() {
return this._text;
};
},
mindplot.NoteModel.prototype.setText = function(text)
{
setText : function(text) {
this._text = text;
};
},
mindplot.NoteModel.prototype.getTopic = function()
{
getTopic : function() {
return this._topic;
};
},
mindplot.NoteModel.prototype.isNoteModel = function()
{
isNoteModel : function() {
return true;
};
}
});