mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-26 07:44:56 +01:00
- Add UI cache for position.
This commit is contained in:
parent
68deab8b93
commit
a0e13ad9d3
@ -371,9 +371,14 @@ mindplot.Designer = new Class({
|
|||||||
var nodeModel = branches[i];
|
var nodeModel = branches[i];
|
||||||
var nodeGraph = this._nodeModelToNodeGraph(nodeModel, false);
|
var nodeGraph = this._nodeModelToNodeGraph(nodeModel, false);
|
||||||
|
|
||||||
|
// Now, refresh UI changes ...
|
||||||
|
nodeGraph.enableUICache(false);
|
||||||
|
|
||||||
// Update shrink render state...
|
// Update shrink render state...
|
||||||
nodeGraph.setBranchVisibility(true);
|
nodeGraph.setBranchVisibility(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var relationships = mindmapModel.getRelationships();
|
var relationships = mindmapModel.getRelationships();
|
||||||
for (var j = 0; j < relationships.length; j++) {
|
for (var j = 0; j < relationships.length; j++) {
|
||||||
this._relationshipModelToRelationship(relationships[j]);
|
this._relationshipModelToRelationship(relationships[j]);
|
||||||
@ -381,7 +386,7 @@ mindplot.Designer = new Class({
|
|||||||
|
|
||||||
// Place the focus on the Central Topic
|
// Place the focus on the Central Topic
|
||||||
var centralTopic = this.getModel().getCentralTopic();
|
var centralTopic = this.getModel().getCentralTopic();
|
||||||
this.goToNode.attempt(centralTopic, this);
|
this.goToNode(centralTopic);
|
||||||
},
|
},
|
||||||
|
|
||||||
getMindmap : function() {
|
getMindmap : function() {
|
||||||
@ -416,8 +421,7 @@ mindplot.Designer = new Class({
|
|||||||
var workspace = this._workspace;
|
var workspace = this._workspace;
|
||||||
workspace.appendChild(nodeGraph);
|
workspace.appendChild(nodeGraph);
|
||||||
return nodeGraph;
|
return nodeGraph;
|
||||||
}
|
},
|
||||||
,
|
|
||||||
|
|
||||||
_relationshipModelToRelationship : function(model) {
|
_relationshipModelToRelationship : function(model) {
|
||||||
$assert(model, "Node model can not be null");
|
$assert(model, "Node model can not be null");
|
||||||
|
@ -52,6 +52,6 @@ mindplot.LinkIcon = new Class({
|
|||||||
actionDispatcher.removeLinkFromTopic(this._topic.getId());
|
actionDispatcher.removeLinkFromTopic(this._topic.getId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mindplot.LinkIcon.IMAGE_URL = "../nicons/links.png";
|
mindplot.LinkIcon.IMAGE_URL = "../images/links.png";
|
||||||
|
|
||||||
|
|
@ -137,12 +137,8 @@ mindplot.MainTopic = new Class({
|
|||||||
return "MainTopic";
|
return "MainTopic";
|
||||||
},
|
},
|
||||||
|
|
||||||
_updatePositionOnChangeSize : function(oldSize, newSize, updatePosition) {
|
_updatePositionOnChangeSize : function(oldSize, newSize) {
|
||||||
|
|
||||||
if (!updatePosition && this.getModel().getFinalPosition()) {
|
|
||||||
this.setPosition(this.getModel().getFinalPosition(), false);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var xOffset = Math.round((newSize.width - oldSize.width) / 2);
|
var xOffset = Math.round((newSize.width - oldSize.width) / 2);
|
||||||
var pos = this.getPosition();
|
var pos = this.getPosition();
|
||||||
if ($defined(pos)) {
|
if ($defined(pos)) {
|
||||||
@ -153,15 +149,6 @@ mindplot.MainTopic = new Class({
|
|||||||
}
|
}
|
||||||
this.setPosition(pos);
|
this.setPosition(pos);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
setPosition : function(point, fireEvent) {
|
|
||||||
this.parent(point);
|
|
||||||
|
|
||||||
// Update board zero entry position...
|
|
||||||
if (fireEvent != false)
|
|
||||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeMoveEvent, [this]);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
workoutIncomingConnectionPoint : function(sourcePosition) {
|
workoutIncomingConnectionPoint : function(sourcePosition) {
|
||||||
@ -197,8 +184,6 @@ mindplot.MainTopic = new Class({
|
|||||||
var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, pos);
|
var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, pos);
|
||||||
var result;
|
var result;
|
||||||
if (this.getShapeType() == mindplot.model.INodeModel.SHAPE_TYPE_LINE) {
|
if (this.getShapeType() == mindplot.model.INodeModel.SHAPE_TYPE_LINE) {
|
||||||
// if (!this.isConnectedToCentralTopic())
|
|
||||||
// {
|
|
||||||
result = new core.Point();
|
result = new core.Point();
|
||||||
if (!isAtRight) {
|
if (!isAtRight) {
|
||||||
result.x = pos.x + (size.width / 2);
|
result.x = pos.x + (size.width / 2);
|
||||||
@ -206,27 +191,7 @@ mindplot.MainTopic = new Class({
|
|||||||
result.x = pos.x - (size.width / 2);
|
result.x = pos.x - (size.width / 2);
|
||||||
}
|
}
|
||||||
result.y = pos.y + (size.height / 2);
|
result.y = pos.y + (size.height / 2);
|
||||||
/*} else
|
|
||||||
{
|
|
||||||
// In this case, connetion line is not used as shape figure.
|
|
||||||
result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight, true);
|
|
||||||
result.y = pos.y + (size.height / 2);
|
|
||||||
*/
|
|
||||||
/*if(result.y>0){
|
|
||||||
result.y+=1;
|
|
||||||
}*/
|
|
||||||
/*
|
|
||||||
|
|
||||||
// Correction factor ...
|
|
||||||
if (!isAtRight)
|
|
||||||
{
|
|
||||||
result.x = result.x + 2;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
result.x = result.x - 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
}*/
|
|
||||||
} else {
|
} else {
|
||||||
result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight, true);
|
result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight, true);
|
||||||
}
|
}
|
||||||
|
@ -75,8 +75,7 @@ mindplot.MainTopicBoard = new Class({
|
|||||||
|
|
||||||
var order = entry.getOrder();
|
var order = entry.getOrder();
|
||||||
dragTopic.setOrder(order);
|
dragTopic.setOrder(order);
|
||||||
}
|
},
|
||||||
,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This x distance doesn't take into account the size of the shape.
|
* This x distance doesn't take into account the size of the shape.
|
||||||
|
@ -45,11 +45,8 @@ mindplot.NodeGraph = new Class({
|
|||||||
return this._elem2d;
|
return this._elem2d;
|
||||||
},
|
},
|
||||||
|
|
||||||
setPosition : function(point) {
|
setPosition : function(point, fireEvent) {
|
||||||
// Elements are positioned in the center.
|
throw "Unsupported operation";
|
||||||
var size = this._model.getSize();
|
|
||||||
this._elem2d.setPosition(point.x - (size.width / 2), point.y - (size.height / 2));
|
|
||||||
this._model.setPosition(point.x, point.y);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
addEvent : function(type, listener) {
|
addEvent : function(type, listener) {
|
||||||
@ -64,7 +61,7 @@ mindplot.NodeGraph = new Class({
|
|||||||
|
|
||||||
fireEvent: function(type) {
|
fireEvent: function(type) {
|
||||||
var elem = type.substr(0, 3) == "ont" ? this._event : this.get2DElement();
|
var elem = type.substr(0, 3) == "ont" ? this._event : this.get2DElement();
|
||||||
elem.fireEvent(type,this);
|
elem.fireEvent(type, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
setMouseEventsEnabled : function(isEnabled) {
|
setMouseEventsEnabled : function(isEnabled) {
|
||||||
@ -158,8 +155,8 @@ mindplot.NodeGraph.create = function(nodeModel, options) {
|
|||||||
if (type == mindplot.model.INodeModel.MAIN_TOPIC_TYPE) {
|
if (type == mindplot.model.INodeModel.MAIN_TOPIC_TYPE) {
|
||||||
result = new mindplot.MainTopic(nodeModel, options);
|
result = new mindplot.MainTopic(nodeModel, options);
|
||||||
} else {
|
} else {
|
||||||
assert(false, "unsupported node type:" + type);
|
$assert(false, "unsupported node type:" + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
};
|
@ -83,5 +83,5 @@ mindplot.NoteIcon = new Class({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mindplot.NoteIcon.IMAGE_URL = "../nicons/notes.png";
|
mindplot.NoteIcon.IMAGE_URL = "../images/notes.png";
|
||||||
|
|
||||||
|
@ -53,8 +53,8 @@ mindplot.StandaloneActionDispatcher = new Class({
|
|||||||
this.execute(command);
|
this.execute(command);
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteTopics: function(topicsIds,relIds) {
|
deleteTopics: function(topicsIds, relIds) {
|
||||||
var command = new mindplot.commands.DeleteCommand(topicsIds,relIds);
|
var command = new mindplot.commands.DeleteCommand(topicsIds, relIds);
|
||||||
this.execute(command);
|
this.execute(command);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -258,7 +258,9 @@ mindplot.CommandContext = new Class({
|
|||||||
|
|
||||||
createTopic:function(model, isVisible) {
|
createTopic:function(model, isVisible) {
|
||||||
$assert(model, "model can not be null");
|
$assert(model, "model can not be null");
|
||||||
return this._designer._nodeModelToNodeGraph(model, isVisible);
|
var result = this._designer._nodeModelToNodeGraph(model, isVisible);
|
||||||
|
result.enableUICache(false);
|
||||||
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
createModel:function() {
|
createModel:function() {
|
||||||
|
@ -42,6 +42,36 @@ mindplot.Topic = new Class({
|
|||||||
|
|
||||||
this._registerEvents();
|
this._registerEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._cacheUIEnabled = true;
|
||||||
|
this._iuCache = {};
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
isUICacheEnabled : function() {
|
||||||
|
return this._cacheUIEnabled;
|
||||||
|
},
|
||||||
|
|
||||||
|
enableUICache : function(value) {
|
||||||
|
this._cacheUIEnabled = value;
|
||||||
|
if (!value) {
|
||||||
|
this._flushUIUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Propagate the change to the children nodes ...
|
||||||
|
var children = this._getChildren();
|
||||||
|
for (var i = 0; i < children.length; i++) {
|
||||||
|
var node = children[i];
|
||||||
|
node.enableUICache(value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_flushUIUpdate: function() {
|
||||||
|
var position = this._iuCache['position'];
|
||||||
|
if (position) {
|
||||||
|
this.setPosition(position);
|
||||||
|
}
|
||||||
|
this._iuCache = {};
|
||||||
},
|
},
|
||||||
|
|
||||||
_registerEvents : function() {
|
_registerEvents : function() {
|
||||||
@ -305,6 +335,7 @@ mindplot.Topic = new Class({
|
|||||||
|
|
||||||
this._link = new mindplot.LinkIcon(this, linkModel);
|
this._link = new mindplot.LinkIcon(this, linkModel);
|
||||||
iconGroup.addIcon(this._link);
|
iconGroup.addIcon(this._link);
|
||||||
|
|
||||||
this._adjustShapes();
|
this._adjustShapes();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -317,6 +348,7 @@ mindplot.Topic = new Class({
|
|||||||
|
|
||||||
this._note = new mindplot.NoteIcon(this, noteModel);
|
this._note = new mindplot.NoteIcon(this, noteModel);
|
||||||
iconGroup.addIcon(this._note);
|
iconGroup.addIcon(this._note);
|
||||||
|
|
||||||
this._adjustShapes();
|
this._adjustShapes();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -402,7 +434,7 @@ mindplot.Topic = new Class({
|
|||||||
return this._relationships;
|
return this._relationships;
|
||||||
},
|
},
|
||||||
|
|
||||||
_buildTextShape : function(disableEventsListeners) {
|
_buildTextShape : function(readOnly) {
|
||||||
var result = new web2d.Text();
|
var result = new web2d.Text();
|
||||||
var family = this.getFontFamily();
|
var family = this.getFontFamily();
|
||||||
var size = this.getFontSize();
|
var size = this.getFontSize();
|
||||||
@ -413,7 +445,7 @@ mindplot.Topic = new Class({
|
|||||||
var color = this.getFontColor();
|
var color = this.getFontColor();
|
||||||
result.setColor(color);
|
result.setColor(color);
|
||||||
|
|
||||||
if (!disableEventsListeners) {
|
if (!readOnly) {
|
||||||
// Propagate mouse events ...
|
// Propagate mouse events ...
|
||||||
if (this.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
if (this.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
result.setCursor('move');
|
result.setCursor('move');
|
||||||
@ -469,6 +501,7 @@ mindplot.Topic = new Class({
|
|||||||
var model = this.getModel();
|
var model = this.getModel();
|
||||||
model.setFontWeight(value);
|
model.setFontWeight(value);
|
||||||
}
|
}
|
||||||
|
this._adjustShapes();
|
||||||
},
|
},
|
||||||
|
|
||||||
getFontWeight : function() {
|
getFontWeight : function() {
|
||||||
@ -538,11 +571,11 @@ mindplot.Topic = new Class({
|
|||||||
var model = this.getModel();
|
var model = this.getModel();
|
||||||
model.setText(text);
|
model.setText(text);
|
||||||
}
|
}
|
||||||
this._adjustShapes(updateModel);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setText : function(text) {
|
setText : function(text) {
|
||||||
this._setText(text, true);
|
this._setText(text, true);
|
||||||
|
this._adjustShapes();
|
||||||
},
|
},
|
||||||
|
|
||||||
getText : function() {
|
getText : function() {
|
||||||
@ -558,16 +591,15 @@ mindplot.Topic = new Class({
|
|||||||
this._setBackgroundColor(color, true);
|
this._setBackgroundColor(color, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
_setBackgroundColor : function(color, updateModel) {
|
_setBackgroundColor : function(color) {
|
||||||
var innerShape = this.getInnerShape();
|
var innerShape = this.getInnerShape();
|
||||||
innerShape.setFill(color);
|
innerShape.setFill(color);
|
||||||
|
|
||||||
var connector = this.getShrinkConnector();
|
var connector = this.getShrinkConnector();
|
||||||
connector.setFill(color);
|
connector.setFill(color);
|
||||||
if ($defined(updateModel) && updateModel) {
|
|
||||||
var model = this.getModel();
|
var model = this.getModel();
|
||||||
model.setBackgroundColor(color);
|
model.setBackgroundColor(color);
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getBackgroundColor : function() {
|
getBackgroundColor : function() {
|
||||||
@ -634,9 +666,6 @@ mindplot.Topic = new Class({
|
|||||||
|
|
||||||
// Register listeners ...
|
// Register listeners ...
|
||||||
this._registerDefaultListenersToElement(group, this);
|
this._registerDefaultListenersToElement(group, this);
|
||||||
|
|
||||||
// Put all the topic elements in place ...
|
|
||||||
this._adjustShapes(false);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_registerDefaultListenersToElement : function(elem, topic) {
|
_registerDefaultListenersToElement : function(elem, topic) {
|
||||||
@ -795,6 +824,14 @@ mindplot.Topic = new Class({
|
|||||||
* Point: references the center of the rect shape.!!!
|
* Point: references the center of the rect shape.!!!
|
||||||
*/
|
*/
|
||||||
setPosition : function(point) {
|
setPosition : function(point) {
|
||||||
|
$assert(point,"position can not be null");
|
||||||
|
|
||||||
|
// Update model's position ...
|
||||||
|
var model = this.getModel();
|
||||||
|
var currentPos = model.getPosition();
|
||||||
|
|
||||||
|
model.setPosition(point.x, point.y);
|
||||||
|
if (!this.isUICacheEnabled()) {
|
||||||
// Elements are positioned in the center.
|
// Elements are positioned in the center.
|
||||||
// All topic element must be positioned based on the innerShape.
|
// All topic element must be positioned based on the innerShape.
|
||||||
var size = this.getSize();
|
var size = this.getSize();
|
||||||
@ -805,15 +842,21 @@ mindplot.Topic = new Class({
|
|||||||
// Update visual position.
|
// Update visual position.
|
||||||
this._elem2d.setPosition(cx, cy);
|
this._elem2d.setPosition(cx, cy);
|
||||||
|
|
||||||
// Update model's position ...
|
|
||||||
var model = this.getModel();
|
|
||||||
model.setPosition(point.x, point.y);
|
|
||||||
|
|
||||||
// Update connection lines ...
|
// Update connection lines ...
|
||||||
this._updateConnectionLines();
|
this._updateConnectionLines();
|
||||||
|
|
||||||
// Check object state.
|
// Check object state.
|
||||||
this.invariant();
|
this.invariant();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this._iuCache['position'] = point;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$defined(currentPos) || currentPos.x != point.x || currentPos.y != point.y) {
|
||||||
|
|
||||||
|
// Fire Listener events ...
|
||||||
|
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeMoveEvent, [this]);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getOutgoingLine : function() {
|
getOutgoingLine : function() {
|
||||||
@ -986,21 +1029,21 @@ mindplot.Topic = new Class({
|
|||||||
innerShape.setSize(parseInt(size.width), parseInt(size.height));
|
innerShape.setSize(parseInt(size.width), parseInt(size.height));
|
||||||
},
|
},
|
||||||
|
|
||||||
setSize : function(size, force, updatePosition) {
|
setSize : function(size) {
|
||||||
var oldSize = this.getSize();
|
var oldSize = this.getSize();
|
||||||
if (oldSize.width != size.width || oldSize.height != size.height || force) {
|
if (parseInt(oldSize.width) != parseInt(size.width) || parseInt(oldSize.height) != parseInt(size.height)) {
|
||||||
this._setSize(size);
|
this._setSize(size);
|
||||||
|
|
||||||
// Update the figure position(ej: central topic must be centered) and children position.
|
// Update the figure position(ej: central topic must be centered) and children position.
|
||||||
this._updatePositionOnChangeSize(oldSize, size, updatePosition);
|
this._updatePositionOnChangeSize(oldSize, size);
|
||||||
|
|
||||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeResizeEvent, [this]);
|
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeResizeEvent, [this]);
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_updatePositionOnChangeSize : function(oldSize, newSize, updatePosition) {
|
_updatePositionOnChangeSize : function(oldSize, newSize) {
|
||||||
$assert(false, "this method must be overided");
|
$assert(false, "this method must be overrited");
|
||||||
},
|
},
|
||||||
|
|
||||||
disconnect : function(workspace) {
|
disconnect : function(workspace) {
|
||||||
@ -1042,7 +1085,6 @@ mindplot.Topic = new Class({
|
|||||||
var connector = targetTopic.getShrinkConnector();
|
var connector = targetTopic.getShrinkConnector();
|
||||||
connector.setVisibility(false);
|
connector.setVisibility(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1137,6 +1179,7 @@ mindplot.Topic = new Class({
|
|||||||
var elem = this.get2DElement();
|
var elem = this.get2DElement();
|
||||||
workspace.appendChild(elem);
|
workspace.appendChild(elem);
|
||||||
this._isInWorkspace = true;
|
this._isInWorkspace = true;
|
||||||
|
this._adjustShapes();
|
||||||
},
|
},
|
||||||
|
|
||||||
isInWorkspace : function() {
|
isInWorkspace : function() {
|
||||||
@ -1158,8 +1201,8 @@ mindplot.Topic = new Class({
|
|||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
_adjustShapes : function(updatePosition) {
|
_adjustShapes : function() {
|
||||||
(function() {
|
if (this._isInWorkspace) {
|
||||||
var textShape = this.getTextShape();
|
var textShape = this.getTextShape();
|
||||||
var textWidth = textShape.getWidth();
|
var textWidth = textShape.getWidth();
|
||||||
|
|
||||||
@ -1184,12 +1227,12 @@ mindplot.Topic = new Class({
|
|||||||
var height = textHeight + (topicPadding * 2);
|
var height = textHeight + (topicPadding * 2);
|
||||||
var width = textWidth + iconsWidth + (topicPadding * 2);
|
var width = textWidth + iconsWidth + (topicPadding * 2);
|
||||||
|
|
||||||
var size = {width:width,height:height};
|
var size = {width:parseInt(width),height:parseInt(height)};
|
||||||
this.setSize(size, false, updatePosition);
|
this.setSize(size);
|
||||||
|
|
||||||
// Position node ...
|
// Position node ...
|
||||||
textShape.setPosition(topicPadding + iconsWidth, topicPadding);
|
textShape.setPosition(topicPadding + iconsWidth, topicPadding);
|
||||||
}).delay(0, this);
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
addHelper : function(helper) {
|
addHelper : function(helper) {
|
||||||
|
@ -163,6 +163,7 @@ mindplot.VariableDistanceBoard = new Class({
|
|||||||
this._entries.set(index, entry);
|
this._entries.set(index, entry);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
freeEntry:function(entry) {
|
freeEntry:function(entry) {
|
||||||
var order = entry.getOrder();
|
var order = entry.getOrder();
|
||||||
var entries = this._entries;
|
var entries = this._entries;
|
||||||
|
@ -71,6 +71,7 @@ mindplot.XMLMindmapSerializer_Pela = new Class({
|
|||||||
parentTopic.setAttribute("position", pos.x + ',' + pos.y);
|
parentTopic.setAttribute("position", pos.x + ',' + pos.y);
|
||||||
|
|
||||||
var order = topic.getOrder();
|
var order = topic.getOrder();
|
||||||
|
if (!isNaN(order))
|
||||||
parentTopic.setAttribute("order", order);
|
parentTopic.setAttribute("order", order);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,11 +187,11 @@ mindplot.XMLMindmapSerializer_Pela = new Class({
|
|||||||
if (lineType == mindplot.ConnectionLine.CURVED || lineType == mindplot.ConnectionLine.SIMPLE_CURVED) {
|
if (lineType == mindplot.ConnectionLine.CURVED || lineType == mindplot.ConnectionLine.SIMPLE_CURVED) {
|
||||||
if ($defined(relationship.getSrcCtrlPoint())) {
|
if ($defined(relationship.getSrcCtrlPoint())) {
|
||||||
var srcPoint = relationship.getSrcCtrlPoint();
|
var srcPoint = relationship.getSrcCtrlPoint();
|
||||||
relationDom.setAttribute("srcCtrlPoint", srcPoint.x + "," + srcPoint.y);
|
relationDom.setAttribute("srcCtrlPoint", Math.round(srcPoint.x) + "," + Math.round(srcPoint.y));
|
||||||
}
|
}
|
||||||
if ($defined(relationship.getDestCtrlPoint())) {
|
if ($defined(relationship.getDestCtrlPoint())) {
|
||||||
var destPoint = relationship.getDestCtrlPoint();
|
var destPoint = relationship.getDestCtrlPoint();
|
||||||
relationDom.setAttribute("destCtrlPoint", destPoint.x + "," + destPoint.y);
|
relationDom.setAttribute("destCtrlPoint", Math.round(destPoint.x) + "," + Math.round(destPoint.y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
relationDom.setAttribute("endArrow", relationship.getEndArrow());
|
relationDom.setAttribute("endArrow", relationship.getEndArrow());
|
||||||
@ -238,6 +239,7 @@ mindplot.XMLMindmapSerializer_Pela = new Class({
|
|||||||
|
|
||||||
_deserializeNode : function(domElem, mindmap) {
|
_deserializeNode : function(domElem, mindmap) {
|
||||||
var type = (domElem.getAttribute('central') != null) ? mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE : mindplot.model.INodeModel.MAIN_TOPIC_TYPE;
|
var type = (domElem.getAttribute('central') != null) ? mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE : mindplot.model.INodeModel.MAIN_TOPIC_TYPE;
|
||||||
|
|
||||||
// Load attributes...
|
// Load attributes...
|
||||||
var id = domElem.getAttribute('id');
|
var id = domElem.getAttribute('id');
|
||||||
if ($defined(id)) {
|
if ($defined(id)) {
|
||||||
@ -311,7 +313,7 @@ mindplot.XMLMindmapSerializer_Pela = new Class({
|
|||||||
if ($defined(position)) {
|
if ($defined(position)) {
|
||||||
var pos = position.split(',');
|
var pos = position.split(',');
|
||||||
topic.setPosition(pos[0], pos[1]);
|
topic.setPosition(pos[0], pos[1]);
|
||||||
topic.setFinalPosition(pos[0], pos[1]);
|
// topic.setFinalPosition(pos[0], pos[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Creating icons and children nodes
|
//Creating icons and children nodes
|
||||||
@ -335,7 +337,6 @@ mindplot.XMLMindmapSerializer_Pela = new Class({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
|
||||||
return topic;
|
return topic;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -39,28 +39,34 @@ mindplot.commands.DragTopicCommand = new Class({
|
|||||||
var origOrder = null;
|
var origOrder = null;
|
||||||
var origPosition = null;
|
var origPosition = null;
|
||||||
|
|
||||||
|
// Cache nodes position ...
|
||||||
|
var topics = designer.getModel().getTopics();
|
||||||
|
topics.forEach(function(topic) {
|
||||||
|
topic.enableUICache(true);
|
||||||
|
});
|
||||||
|
|
||||||
// In this case, topics are positioned using order ...
|
// In this case, topics are positioned using order ...
|
||||||
origOrder = topic.getOrder();
|
origOrder = topic.getOrder();
|
||||||
origPosition = topic.getPosition();
|
origPosition = topic.getPosition();
|
||||||
|
|
||||||
// Disconnect topic ..
|
// Disconnect topic ..
|
||||||
if ($defined(origParentTopic)) {
|
if ($defined(origParentTopic) && origParentTopic != this._parentId) {
|
||||||
commandContext.disconnect(topic);
|
commandContext.disconnect(topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set topic order ...
|
// Set topic order ...
|
||||||
if (this._order != null) {
|
if (this._order != null) {
|
||||||
topic.setOrder(this._order);
|
topic.setOrder(this._order);
|
||||||
} else if (this._position != null) {
|
} else if (this._position != null) {
|
||||||
// Set position ...
|
// Set position ...
|
||||||
topic.setPosition(this._position);
|
topic.setPosition(this._position);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$assert("Illegal commnad state exception.");
|
$assert("Illegal commnad state exception.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, connect topic ...
|
// Finally, connect topic ...
|
||||||
|
if (origParentTopic != this._parentId) {
|
||||||
|
|
||||||
if ($defined(this._parentId)) {
|
if ($defined(this._parentId)) {
|
||||||
var parentTopic = commandContext.findTopics([this._parentId])[0];
|
var parentTopic = commandContext.findTopics([this._parentId])[0];
|
||||||
commandContext.connect(topic, parentTopic);
|
commandContext.connect(topic, parentTopic);
|
||||||
@ -71,11 +77,15 @@ mindplot.commands.DragTopicCommand = new Class({
|
|||||||
if ($defined(origParentTopic)) {
|
if ($defined(origParentTopic)) {
|
||||||
this._parentId = origParentTopic.getId();
|
this._parentId = origParentTopic.getId();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Store for undo ...
|
// Store for undo ...
|
||||||
this._order = origOrder;
|
this._order = origOrder;
|
||||||
this._position = origPosition;
|
this._position = origPosition;
|
||||||
|
|
||||||
|
topics.forEach(function(topic) {
|
||||||
|
topic.enableUICache(false);
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -8,80 +8,89 @@ mindplot.layout.BaseLayoutManager = new Class({
|
|||||||
this.setOptions(options);
|
this.setOptions(options);
|
||||||
this._createBoard();
|
this._createBoard();
|
||||||
this._designer = designer;
|
this._designer = designer;
|
||||||
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeResizeEvent,this._nodeResizeEvent.bind(this));
|
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeResizeEvent, this._nodeResizeEvent.bind(this));
|
||||||
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeMoveEvent,this._nodeMoveEvent.bind(this));
|
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeMoveEvent, this._nodeMoveEvent.bind(this));
|
||||||
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeDisconnectEvent,this._nodeDisconnectEvent.bind(this));
|
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeDisconnectEvent, this._nodeDisconnectEvent.bind(this));
|
||||||
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeConnectEvent,this._nodeConnectEvent.bind(this));
|
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeConnectEvent, this._nodeConnectEvent.bind(this));
|
||||||
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeRepositionateEvent,this._nodeRepositionateEvent.bind(this));
|
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeRepositionateEvent, this._nodeRepositionateEvent.bind(this));
|
||||||
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeShrinkEvent,this._nodeShrinkEvent.bind(this));
|
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeShrinkEvent, this._nodeShrinkEvent.bind(this));
|
||||||
},
|
},
|
||||||
_nodeResizeEvent:function(node){
|
|
||||||
|
_nodeResizeEvent:function(node) {
|
||||||
},
|
},
|
||||||
_nodeMoveEvent:function(node){
|
|
||||||
|
_nodeMoveEvent:function(node) {
|
||||||
var modifiedTopics = [];
|
var modifiedTopics = [];
|
||||||
this.getTopicBoardForTopic(node).updateChildrenPosition(node, modifiedTopics);
|
this.getTopicBoardForTopic(node).updateChildrenPosition(node, modifiedTopics);
|
||||||
},
|
},
|
||||||
_nodeDisconnectEvent:function(targetNode, node){
|
|
||||||
|
_nodeDisconnectEvent:function(targetNode, node) {
|
||||||
var modifiedTopics = [];
|
var modifiedTopics = [];
|
||||||
this.getTopicBoardForTopic(targetNode).removeTopicFromBoard(node,modifiedTopics);
|
this.getTopicBoardForTopic(targetNode).removeTopicFromBoard(node, modifiedTopics);
|
||||||
},
|
},
|
||||||
_nodeConnectEvent:function(targetNode, node){
|
|
||||||
|
_nodeConnectEvent:function(targetNode, node) {
|
||||||
var modifiedTopics = [];
|
var modifiedTopics = [];
|
||||||
this.getTopicBoardForTopic(targetNode).addBranch(node,modifiedTopics);
|
this.getTopicBoardForTopic(targetNode).addBranch(node, modifiedTopics);
|
||||||
},
|
},
|
||||||
_nodeRepositionateEvent:function(node){
|
|
||||||
|
_nodeRepositionateEvent:function(node) {
|
||||||
|
var modifiedTopics = [];
|
||||||
|
this.getTopicBoardForTopic(node).updateChildrenPosition(node, modifiedTopics);
|
||||||
},
|
},
|
||||||
_nodeShrinkEvent:function(node){
|
|
||||||
|
_nodeShrinkEvent:function(node) {
|
||||||
},
|
},
|
||||||
_createBoard:function(){
|
|
||||||
|
_createBoard:function() {
|
||||||
this._boards = new Hash();
|
this._boards = new Hash();
|
||||||
},
|
},
|
||||||
getTopicBoardForTopic:function(node){
|
getTopicBoardForTopic:function(node) {
|
||||||
var id = node.getId();
|
var id = node.getId();
|
||||||
var result = this._boards[id];
|
var result = this._boards[id];
|
||||||
if(!$defined(result)){
|
if (!$defined(result)) {
|
||||||
result = this._addNode(node);
|
result = this._addNode(node);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
_addNode:function(node){
|
_addNode:function(node) {
|
||||||
var board = null;
|
var board = null;
|
||||||
if (this._isCentralTopic(node))
|
if (this._isCentralTopic(node))
|
||||||
board = this._createCentralTopicBoard(node);
|
board = this._createCentralTopicBoard(node);
|
||||||
else
|
else
|
||||||
board = this._createMainTopicBoard(node);
|
board = this._createMainTopicBoard(node);
|
||||||
var id = node.getId();
|
var id = node.getId();
|
||||||
this._boards[id]=board;
|
this._boards[id] = board;
|
||||||
return board;
|
return board;
|
||||||
},
|
},
|
||||||
_createMainTopicBoard:function(node){
|
_createMainTopicBoard:function(node) {
|
||||||
return new mindplot.layout.boards.Board(node, this);
|
return new mindplot.layout.boards.Board(node, this);
|
||||||
},
|
},
|
||||||
_createCentralTopicBoard:function(node){
|
_createCentralTopicBoard:function(node) {
|
||||||
return new mindplot.layout.boards.Board(node, this);
|
return new mindplot.layout.boards.Board(node, this);
|
||||||
},
|
},
|
||||||
prepareNode:function(node, children){
|
prepareNode:function(node, children) {
|
||||||
|
|
||||||
},
|
},
|
||||||
addHelpers:function(node){
|
addHelpers:function(node) {
|
||||||
|
|
||||||
},
|
},
|
||||||
needsPrepositioning:function(){
|
needsPrepositioning:function() {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
getDesigner:function(){
|
getDesigner:function() {
|
||||||
return this._designer;
|
return this._designer;
|
||||||
},
|
},
|
||||||
_isCentralTopic:function(node){
|
_isCentralTopic:function(node) {
|
||||||
var type = node.getModel().getType();
|
var type = node.getModel().getType();
|
||||||
return type == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE;
|
return type == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE;
|
||||||
},
|
},
|
||||||
getClassName:function(){
|
getClassName:function() {
|
||||||
return mindplot.layout.BaseLayoutManager.NAME;
|
return mindplot.layout.BaseLayoutManager.NAME;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mindplot.layout.BaseLayoutManager.NAME ="BaseLayoutManager";
|
mindplot.layout.BaseLayoutManager.NAME = "BaseLayoutManager";
|
||||||
|
|
||||||
mindplot.layout.BaseLayoutManager.implement(new Events);
|
mindplot.layout.BaseLayoutManager.implement(new Events);
|
||||||
mindplot.layout.BaseLayoutManager.implement(new Options);
|
mindplot.layout.BaseLayoutManager.implement(new Options);
|
@ -32,6 +32,7 @@ mindplot.layout.OriginalLayoutManager = new Class({
|
|||||||
// Add shapes to speed up the loading process ...
|
// Add shapes to speed up the loading process ...
|
||||||
mindplot.DragTopic.init(workSpace);
|
mindplot.DragTopic.init(workSpace);
|
||||||
},
|
},
|
||||||
|
|
||||||
prepareNode:function(node, children) {
|
prepareNode:function(node, children) {
|
||||||
// Sort children by order to solve adding order in for OriginalLayoutManager...
|
// Sort children by order to solve adding order in for OriginalLayoutManager...
|
||||||
var nodesByOrder = new Hash();
|
var nodesByOrder = new Hash();
|
||||||
|
@ -14,7 +14,7 @@ mindplot.layout.boards.freemind.Entry = new Class({
|
|||||||
var pwidth = parent.getSize().width;
|
var pwidth = parent.getSize().width;
|
||||||
var width = node.getSize().width;
|
var width = node.getSize().width;
|
||||||
pos.x = pos.x + Math.sign(pos.x) * (this._DEFAULT_X_GAP + pwidth/2 + width/2);
|
pos.x = pos.x + Math.sign(pos.x) * (this._DEFAULT_X_GAP + pwidth/2 + width/2);
|
||||||
node.setPosition(pos, false);
|
node.setPosition(pos);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ mindplot.layout.boards.freemind.Entry = new Class({
|
|||||||
position.x = x;
|
position.x = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._node.setPosition(position, false);
|
this._node.setPosition(position);
|
||||||
},
|
},
|
||||||
getMarginTop:function(){
|
getMarginTop:function(){
|
||||||
return this._marginTop;
|
return this._marginTop;
|
||||||
|
@ -393,15 +393,15 @@ mindplot.widget.Menu = new Class({
|
|||||||
|
|
||||||
// designer.addEvent("modelUpdate", function(event) {
|
// designer.addEvent("modelUpdate", function(event) {
|
||||||
// if (event.undoSteps > 0) {
|
// if (event.undoSteps > 0) {
|
||||||
// $("undoEdition").setStyle("background-image", "url(../nicons/undo.png)");
|
// $("undoEdition").setStyle("background-image", "url(../images/undo.png)");
|
||||||
// } else {
|
// } else {
|
||||||
// $("undoEdition").setStyle("background-image", "url(../nicons/undo.png)");
|
// $("undoEdition").setStyle("background-image", "url(../images/undo.png)");
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// if (event.redoSteps > 0) {
|
// if (event.redoSteps > 0) {
|
||||||
// $("redoEdition").setStyle("background-image", "url(../nicons/redo.png)");
|
// $("redoEdition").setStyle("background-image", "url(../images/redo.png)");
|
||||||
// } else {
|
// } else {
|
||||||
// $("redoEdition").setStyle("background-image", "url(../nicons/redo.png)");
|
// $("redoEdition").setStyle("background-image", "url(../images/redo.png)");
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// });
|
// });
|
||||||
|
@ -26,10 +26,10 @@ mindplot.widget.TopicShapePanel = new Class({
|
|||||||
|
|
||||||
var content = new Element("div", {'class':'toolbarPanel','id':'topicShapePanel'});
|
var content = new Element("div", {'class':'toolbarPanel','id':'topicShapePanel'});
|
||||||
content.innerHTML = '' +
|
content.innerHTML = '' +
|
||||||
'<div id="rectagle" model="rectagle"><img src="../nicons/shape-rectangle.png" alt="Rectangle"></div>' +
|
'<div id="rectagle" model="rectagle"><img src="../images/shape-rectangle.png" alt="Rectangle"></div>' +
|
||||||
'<div id="rounded_rectagle" model="rounded rectagle" ><img src="../nicons/shape-rectangle-round.png" alt="Rounded Rectangle"></div>' +
|
'<div id="rounded_rectagle" model="rounded rectagle" ><img src="../images/shape-rectangle-round.png" alt="Rounded Rectangle"></div>' +
|
||||||
'<div id="line" model="line"><img src="../nicons/shape-line.png" alt="Line"></div>' +
|
'<div id="line" model="line"><img src="../images/shape-line.png" alt="Line"></div>' +
|
||||||
'<div id="elipse" model="elipse"><img src="../nicons/shape-circle.png"></div>';
|
'<div id="elipse" model="elipse"><img src="../images/shape-circle.png"></div>';
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user