- Fix position on Beta version maps during loading ...

This commit is contained in:
Paulo Gustavo Veiga 2012-06-23 19:51:14 -03:00
parent 63113a529d
commit a3d129a034
6 changed files with 366 additions and 334 deletions

View File

@ -1115,7 +1115,7 @@ mindplot.Topic = new Class({
if (this.getModel().isConnected()) if (this.getModel().isConnected())
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeConnectEvent, {parentNode:this.getOutgoingConnectedTopic().getModel(), childNode: this.getModel()}); mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeConnectEvent, {parentNode:this.getOutgoingConnectedTopic().getModel(), childNode: this.getModel()});
} }
this._isInWorkspace = true; this._isInWorkspace = true;
this._adjustShapes(); this._adjustShapes();
}, },

View File

@ -1,329 +1,330 @@
/* /*
* Copyright [2011] [wisemapping] * Copyright [2011] [wisemapping]
* *
* Licensed under WiseMapping Public License, Version 1.0 (the "License"). * Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the * It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page; * "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the license at * You may obtain a copy of the license at
* *
* http://www.wisemapping.org/license * http://www.wisemapping.org/license
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
mindplot.model.INodeModel = new Class({ mindplot.model.INodeModel = new Class({
initialize: function(mindmap) { initialize: function(mindmap) {
$assert(mindmap && mindmap.getBranches, 'mindmap can not be null'); $assert(mindmap && mindmap.getBranches, 'mindmap can not be null');
this._mindmap = mindmap; this._mindmap = mindmap;
}, },
getId : function() { getId : function() {
return this.getProperty('id'); return this.getProperty('id');
}, },
setId : function(id) { setId : function(id) {
if ($defined(id) && id > mindplot.model.INodeModel._uuid) { if ($defined(id) && id > mindplot.model.INodeModel._uuid) {
mindplot.model.INodeModel._uuid = id; mindplot.model.INodeModel._uuid = id;
} }
if (!$defined(id)) { if (!$defined(id)) {
id = mindplot.model.INodeModel._nextUUID(); id = mindplot.model.INodeModel._nextUUID();
} }
this.putProperty('id', id); this.putProperty('id', id);
}, },
getType : function() { getType : function() {
return this.getProperty('type'); return this.getProperty('type');
}, },
setType : function(type) { setType : function(type) {
this.putProperty('type', type); this.putProperty('type', type);
}, },
setText : function(text) { setText : function(text) {
this.putProperty('text', text); this.putProperty('text', text);
}, },
getText : function() { getText : function() {
return this.getProperty('text'); return this.getProperty('text');
}, },
setPosition : function(x, y) { setPosition : function(x, y) {
$assert(!isNaN(parseInt(x)), "x position is not valid:" + x); $assert(!isNaN(parseInt(x)), "x position is not valid:" + x);
$assert(!isNaN(parseInt(y)), "x position is not valid:" + y); $assert(!isNaN(parseInt(y)), "x position is not valid:" + y);
this.putProperty('position', '{x:' + parseInt(x) + ',y:' + parseInt(y) + '}'); this.putProperty('position', '{x:' + parseInt(x) + ',y:' + parseInt(y) + '}');
}, },
getPosition : function() { getPosition : function() {
var value = this.getProperty('position'); var value = this.getProperty('position');
var result = null; var result = null;
if (value != null) { if (value != null) {
result = eval("(" + value + ")"); result = eval("(" + value + ")");
} }
return result; return result;
}, },
setImageSize : function(width, height) { setImageSize : function(width, height) {
this.putProperty('imageSize', '{width:' + width + ',height:' + height + '}'); this.putProperty('imageSize', '{width:' + width + ',height:' + height + '}');
}, },
getImageSize : function() { getImageSize : function() {
var value = this.getProperty('imageSize'); var value = this.getProperty('imageSize');
var result = null; var result = null;
if (value != null) { if (value != null) {
result = eval("(" + value + ")"); result = eval("(" + value + ")");
} }
return result; return result;
}, },
setImageUrl:function(url) { setImageUrl:function(url) {
this.putProperty('imageUrl', url); this.putProperty('imageUrl', url);
}, },
getMetadata:function() { getMetadata:function() {
return this.getProperty('metadata'); return this.getProperty('metadata');
}, },
setMetadata:function(json) { setMetadata:function(json) {
this.putProperty('metadata', json); this.putProperty('metadata', json);
}, },
getImageUrl:function() { getImageUrl:function() {
return this.getProperty('imageUrl'); return this.getProperty('imageUrl');
}, },
getMindmap : function() { getMindmap : function() {
return this._mindmap; return this._mindmap;
}, },
disconnect : function() { disconnect : function() {
var mindmap = this.getMindmap(); var mindmap = this.getMindmap();
mindmap.disconnect(this); mindmap.disconnect(this);
}, },
getShapeType : function() { getShapeType : function() {
return this.getProperty('shapeType'); return this.getProperty('shapeType');
}, },
setShapeType : function(type) { setShapeType : function(type) {
this.putProperty('shapeType', type); this.putProperty('shapeType', type);
}, },
setOrder : function(value) { setOrder : function(value) {
this.putProperty('order', value); $assert(typeof value === 'number' && isFinite(value) || value == null, "Order must be null or a number");
}, this.putProperty('order', value);
},
getOrder : function() {
return this.getProperty('order'); getOrder : function() {
}, return this.getProperty('order');
},
setFontFamily : function(fontFamily) {
this.putProperty('fontFamily', fontFamily); setFontFamily : function(fontFamily) {
}, this.putProperty('fontFamily', fontFamily);
},
getFontFamily : function() {
return this.getProperty('fontFamily'); getFontFamily : function() {
}, return this.getProperty('fontFamily');
},
setFontStyle : function(fontStyle) {
this.putProperty('fontStyle', fontStyle); setFontStyle : function(fontStyle) {
}, this.putProperty('fontStyle', fontStyle);
},
getFontStyle : function() {
return this.getProperty('fontStyle'); getFontStyle : function() {
}, return this.getProperty('fontStyle');
},
setFontWeight : function(weight) {
this.putProperty('fontWeight', weight); setFontWeight : function(weight) {
}, this.putProperty('fontWeight', weight);
},
getFontWeight : function() {
return this.getProperty('fontWeight'); getFontWeight : function() {
}, return this.getProperty('fontWeight');
},
setFontColor : function(color) {
this.putProperty('fontColor', color); setFontColor : function(color) {
}, this.putProperty('fontColor', color);
},
getFontColor : function() {
return this.getProperty('fontColor'); getFontColor : function() {
}, return this.getProperty('fontColor');
},
setFontSize : function(size) {
this.putProperty('fontSize', size); setFontSize : function(size) {
}, this.putProperty('fontSize', size);
},
getFontSize : function() {
return this.getProperty('fontSize'); getFontSize : function() {
}, return this.getProperty('fontSize');
},
getBorderColor : function() {
return this.getProperty('borderColor'); getBorderColor : function() {
}, return this.getProperty('borderColor');
},
setBorderColor : function(color) {
this.putProperty('borderColor', color); setBorderColor : function(color) {
}, this.putProperty('borderColor', color);
},
getBackgroundColor : function() {
return this.getProperty('backgroundColor'); getBackgroundColor : function() {
}, return this.getProperty('backgroundColor');
},
setBackgroundColor : function(color) {
this.putProperty('backgroundColor', color); setBackgroundColor : function(color) {
}, this.putProperty('backgroundColor', color);
},
areChildrenShrunken : function() {
var result = this.getProperty('shrunken'); areChildrenShrunken : function() {
return $defined(result) ? result : false; var result = this.getProperty('shrunken');
}, return $defined(result) ? result : false;
},
setChildrenShrunken : function(value) {
this.putProperty('shrunken', value); setChildrenShrunken : function(value) {
}, this.putProperty('shrunken', value);
},
isNodeModel : function() {
return true; isNodeModel : function() {
}, return true;
},
isConnected : function() {
return this.getParent() != null; isConnected : function() {
}, return this.getParent() != null;
},
appendChild : function(node) {
throw "Unsupported operation"; appendChild : function(node) {
}, throw "Unsupported operation";
},
connectTo : function(parent) {
$assert(parent, "parent can not be null"); connectTo : function(parent) {
var mindmap = this.getMindmap(); $assert(parent, "parent can not be null");
mindmap.connect(parent, this); var mindmap = this.getMindmap();
}, mindmap.connect(parent, this);
},
copyTo : function(target) {
var source = this; copyTo : function(target) {
// Copy properties ... var source = this;
var keys = source.getPropertiesKeys(); // Copy properties ...
keys.forEach(function(key) { var keys = source.getPropertiesKeys();
var value = source.getProperty(key); keys.forEach(function(key) {
target.putProperty(key, value); var value = source.getProperty(key);
}); target.putProperty(key, value);
});
// Copy childrens ...
var children = this.getChildren(); // Copy childrens ...
var tmindmap = target.getMindmap(); var children = this.getChildren();
var tmindmap = target.getMindmap();
children.forEach(function(snode) {
var tnode = tmindmap.createNode(snode.getType(), snode.getId()); children.forEach(function(snode) {
snode.copyTo(tnode); var tnode = tmindmap.createNode(snode.getType(), snode.getId());
target.appendChild(tnode); snode.copyTo(tnode);
}); target.appendChild(tnode);
});
return target;
}, return target;
},
deleteNode : function() {
var mindmap = this.getMindmap(); deleteNode : function() {
var mindmap = this.getMindmap();
console.log("Before:" + mindmap.inspect());
var parent = this.getParent(); console.log("Before:" + mindmap.inspect());
if ($defined(parent)) { var parent = this.getParent();
parent.removeChild(this); if ($defined(parent)) {
} else { parent.removeChild(this);
// If it has not parent, it must be an isolate topic ... } else {
mindmap.removeBranch(this); // If it has not parent, it must be an isolate topic ...
} mindmap.removeBranch(this);
// It's an isolated node. It must be a hole branch ... }
console.log("After:" + mindmap.inspect()); // It's an isolated node. It must be a hole branch ...
}, console.log("After:" + mindmap.inspect());
},
getPropertiesKeys : function() {
throw "Unsupported operation"; getPropertiesKeys : function() {
}, throw "Unsupported operation";
},
putProperty: function(key, value) {
throw "Unsupported operation"; putProperty: function(key, value) {
}, throw "Unsupported operation";
},
setParent : function(parent) {
throw "Unsupported operation"; setParent : function(parent) {
}, throw "Unsupported operation";
},
getChildren : function() {
throw "Unsupported operation"; getChildren : function() {
}, throw "Unsupported operation";
},
getParent : function() {
throw "Unsupported operation"; getParent : function() {
}, throw "Unsupported operation";
},
clone : function() {
throw "Unsupported operation"; clone : function() {
}, throw "Unsupported operation";
},
inspect : function() {
var result = '{ type: ' + this.getType() + inspect : function() {
' , id: ' + this.getId() + var result = '{ type: ' + this.getType() +
' , text: ' + this.getText(); ' , id: ' + this.getId() +
' , text: ' + this.getText();
var children = this.getChildren();
if (children.length > 0) { var children = this.getChildren();
result = result + ", children: {(size:" + children.length; if (children.length > 0) {
children.forEach(function(node) { result = result + ", children: {(size:" + children.length;
result = result + "=> ("; children.forEach(function(node) {
var keys = node.getPropertiesKeys(); result = result + "=> (";
keys.forEach(function(key) { var keys = node.getPropertiesKeys();
var value = node.getProperty(key); keys.forEach(function(key) {
result = result + key + ":" + value + ","; var value = node.getProperty(key);
}); result = result + key + ":" + value + ",";
result = result + "}" });
}.bind(this)); result = result + "}"
} }.bind(this));
}
result = result + ' }';
return result; result = result + ' }';
}, return result;
},
removeChild : function(child) {
throw "Unsupported operation"; removeChild : function(child) {
throw "Unsupported operation";
}
}); }
});
mindplot.model.TopicShape =
{ mindplot.model.TopicShape =
RECTANGLE : 'rectagle', {
ROUNDED_RECT : 'rounded rectagle', RECTANGLE : 'rectagle',
ELLIPSE : 'elipse', ROUNDED_RECT : 'rounded rectagle',
LINE : 'line', ELLIPSE : 'elipse',
IMAGE : 'image' LINE : 'line',
}; IMAGE : 'image'
};
mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE = 'CentralTopic';
mindplot.model.INodeModel.MAIN_TOPIC_TYPE = 'MainTopic'; mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE = 'CentralTopic';
mindplot.model.INodeModel.MAIN_TOPIC_TYPE = 'MainTopic';
mindplot.model.INodeModel.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE = 220;
mindplot.model.INodeModel.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE = 220;
/**
* @todo: This method must be implemented. /**
*/ * @todo: This method must be implemented.
mindplot.model.INodeModel._nextUUID = function() { */
if (!$defined(mindplot.model.INodeModel._uuid)) { mindplot.model.INodeModel._nextUUID = function() {
mindplot.model.INodeModel._uuid = 0; if (!$defined(mindplot.model.INodeModel._uuid)) {
} mindplot.model.INodeModel._uuid = 0;
}
mindplot.model.INodeModel._uuid = mindplot.model.INodeModel._uuid + 1;
return mindplot.model.INodeModel._uuid; mindplot.model.INodeModel._uuid = mindplot.model.INodeModel._uuid + 1;
}; return mindplot.model.INodeModel._uuid;
mindplot.model.INodeModel._uuid = 0; };
mindplot.model.INodeModel._uuid = 0;

View File

@ -30,6 +30,7 @@ mindplot.persistence.Pela2TangoMigrator = new Class({
var mindmap = this._pelaSerializer.loadFromDom(dom, mapId); var mindmap = this._pelaSerializer.loadFromDom(dom, mapId);
mindmap.setVersion(mindplot.persistence.ModelCodeName.TANGO); mindmap.setVersion(mindplot.persistence.ModelCodeName.TANGO);
this._fixOrder(mindmap); this._fixOrder(mindmap);
this._fixPosition(mindmap);
return mindmap; return mindmap;
}, },
@ -56,11 +57,38 @@ mindplot.persistence.Pela2TangoMigrator = new Class({
}); });
for (i = 0; i < rightNodes.length; i++) { for (i = 0; i < rightNodes.length; i++) {
rightNodes[i].setOrder(i*2); rightNodes[i].setOrder(i * 2);
} }
for (i = 0; i < leftNodes.length; i++) { for (i = 0; i < leftNodes.length; i++) {
leftNodes[i].setOrder(i*2+1); leftNodes[i].setOrder(i * 2 + 1);
} }
},
_fixPosition : function(mindmap) {
// Position was not required in previous versions. Try to synthesize one .
var centralNode = mindmap.getBranches()[0];
var children = centralNode.getChildren();
for (var i = 0; i < children.length; i++) {
var child = children[i];
var position = child.getPosition();
this._fixNodePosition(child, position)
}
},
_fixNodePosition : function(node, parentPosition) {
// Position was not required in previous versions. Try to synthesize one .
var position = node.getPosition();
if (!position) {
position = {x:parentPosition.x + 30,y:parentPosition.y};
node.setPosition(position.x, position.y);
}
var children = node.getChildren();
for (var i = 0; i < children.length; i++) {
var child = children[i];
this._fixNodePosition(child, position);
}
} }
}); });

View File

@ -195,7 +195,7 @@ mindplot.persistence.XMLSerializer_Beta = new Class({
var order = domElem.getAttribute('order'); var order = domElem.getAttribute('order');
if ($defined(order)) { if ($defined(order)) {
topic.setOrder(order); topic.setOrder(parseInt(order));
} }
var shape = domElem.getAttribute('shape'); var shape = domElem.getAttribute('shape');

View File

@ -0,0 +1,4 @@
# Compilation and Execution
Your will find all the steps and required documentation here: http://www.wisemapping.org/downloads/source

View File

@ -1 +0,0 @@
# SMTP Server Configurat