improving performance

This commit is contained in:
Pablo Luna 2011-05-06 15:29:25 +01:00
parent 06c736ab04
commit ad98ccc8e0
4 changed files with 29 additions and 14 deletions

View File

@ -124,7 +124,7 @@ mindplot.ConnectionLine.prototype.redraw = function()
line2d.setSrcControlPoint(ctrlPoints[0]); line2d.setSrcControlPoint(ctrlPoints[0]);
line2d.setDestControlPoint(ctrlPoints[1]); line2d.setDestControlPoint(ctrlPoints[1]);
} }
line2d.moveToBack(); // line2d.moveToBack();
// Add connector ... // Add connector ...
this._positionateConnector(targetTopic); this._positionateConnector(targetTopic);
@ -169,6 +169,7 @@ mindplot.ConnectionLine.prototype.setStroke = function(color, style, opacity)
mindplot.ConnectionLine.prototype.addToWorkspace = function(workspace) mindplot.ConnectionLine.prototype.addToWorkspace = function(workspace)
{ {
workspace.appendChild(this._line2d); workspace.appendChild(this._line2d);
this._line2d.moveToBack();
}; };
mindplot.ConnectionLine.prototype.removeFromWorkspace = function(workspace) mindplot.ConnectionLine.prototype.removeFromWorkspace = function(workspace)

View File

@ -33,22 +33,26 @@ objects.extend(web2d.peer.svg.CurvedLinePeer, web2d.peer.svg.ElementPeer);
web2d.peer.svg.CurvedLinePeer.prototype.setSrcControlPoint = function(control){ web2d.peer.svg.CurvedLinePeer.prototype.setSrcControlPoint = function(control){
this._customControlPoint_1 = true; this._customControlPoint_1 = true;
var change = this._control1.x!=control.x || this._control1.y!=control.y;
if(core.Utils.isDefined(control.x)){ if(core.Utils.isDefined(control.x)){
this._control1 = control; this._control1 = control;
this._control1.x = parseInt(this._control1.x); this._control1.x = parseInt(this._control1.x);
this._control1.y = parseInt(this._control1.y) this._control1.y = parseInt(this._control1.y)
} }
this._updatePath(); if(change)
this._updatePath();
}; };
web2d.peer.svg.CurvedLinePeer.prototype.setDestControlPoint = function(control){ web2d.peer.svg.CurvedLinePeer.prototype.setDestControlPoint = function(control){
this._customControlPoint_2 = true; this._customControlPoint_2 = true;
var change = this._control2.x!=control.x || this._control2.y!=control.y;
if(core.Utils.isDefined(control.x)){ if(core.Utils.isDefined(control.x)){
this._control2 = control; this._control2 = control;
this._control2.x = parseInt(this._control2.x); this._control2.x = parseInt(this._control2.x);
this._control2.y = parseInt(this._control2.y) this._control2.y = parseInt(this._control2.y)
} }
this._updatePath(); if(change)
this._updatePath();
}; };
web2d.peer.svg.CurvedLinePeer.prototype.isSrcControlPointCustom = function() { web2d.peer.svg.CurvedLinePeer.prototype.isSrcControlPointCustom = function() {
@ -75,16 +79,20 @@ web2d.peer.svg.CurvedLinePeer.prototype.getControlPoints = function(){
web2d.peer.svg.CurvedLinePeer.prototype.setFrom = function(x1, y1) web2d.peer.svg.CurvedLinePeer.prototype.setFrom = function(x1, y1)
{ {
var change = this._x1!=parseInt(x1) || this._y1!=parseInt(y1);
this._x1 = parseInt(x1); this._x1 = parseInt(x1);
this._y1 = parseInt(y1); this._y1 = parseInt(y1);
this._updatePath(); if(change)
this._updatePath();
}; };
web2d.peer.svg.CurvedLinePeer.prototype.setTo = function(x2, y2) web2d.peer.svg.CurvedLinePeer.prototype.setTo = function(x2, y2)
{ {
var change = this._x2!=parseInt(x2) || this._y2!=parseInt(y2);
this._x2 = parseInt(x2); this._x2 = parseInt(x2);
this._y2 = parseInt(y2); this._y2 = parseInt(y2);
this._updatePath(); if(change)
this._updatePath();
}; };
web2d.peer.svg.CurvedLinePeer.prototype.getFrom = function() web2d.peer.svg.CurvedLinePeer.prototype.getFrom = function()
@ -152,7 +160,7 @@ web2d.peer.svg.CurvedLinePeer.prototype.isShowStartArrow = function(){
web2d.peer.svg.CurvedLinePeer.prototype._updatePath = function(avoidControlPointFix) web2d.peer.svg.CurvedLinePeer.prototype._updatePath = function(avoidControlPointFix)
{ {
if(core.Utils.isDefined(this._x1) && core.Utils.isDefined(this._y1)) if(core.Utils.isDefined(this._x1) && core.Utils.isDefined(this._y1) && core.Utils.isDefined(this._x2) && core.Utils.isDefined(this._y2))
{ {
this._calculateAutoControlPoints(avoidControlPointFix); this._calculateAutoControlPoints(avoidControlPointFix);
var path = "M"+this._x1+","+this._y1 var path = "M"+this._x1+","+this._y1
@ -179,7 +187,6 @@ web2d.peer.svg.CurvedLinePeer.prototype._updateStyle = function()
}; };
web2d.peer.svg.CurvedLinePeer.prototype._calculateAutoControlPoints = function(avoidControlPointFix){ web2d.peer.svg.CurvedLinePeer.prototype._calculateAutoControlPoints = function(avoidControlPointFix){
if(core.Utils.isDefined(this._x1) && core.Utils.isDefined(this._x2)){
//Both points available, calculate real points //Both points available, calculate real points
var defaultpoints = core.Utils.calculateDefaultControlPoints(new core.Point(this._x1, this._y1),new core.Point(this._x2,this._y2)); var defaultpoints = core.Utils.calculateDefaultControlPoints(new core.Point(this._x1, this._y1),new core.Point(this._x2,this._y2));
if(!this._customControlPoint_1 && !(core.Utils.isDefined(avoidControlPointFix) && avoidControlPointFix==0)){ if(!this._customControlPoint_1 && !(core.Utils.isDefined(avoidControlPointFix) && avoidControlPointFix==0)){
@ -190,7 +197,6 @@ web2d.peer.svg.CurvedLinePeer.prototype._calculateAutoControlPoints = function(a
this._control2.x = defaultpoints[1].x; this._control2.x = defaultpoints[1].x;
this._control2.y = defaultpoints[1].y; this._control2.y = defaultpoints[1].y;
} }
}
}; };
web2d.peer.svg.CurvedLinePeer.prototype.setDashed = function(length,spacing){ web2d.peer.svg.CurvedLinePeer.prototype.setDashed = function(length,spacing){

View File

@ -152,13 +152,13 @@ web2d.peer.svg.ElementPeer.prototype.removeEventListener = function(type, listen
web2d.peer.svg.ElementPeer.prototype.setSize = function(width, height) web2d.peer.svg.ElementPeer.prototype.setSize = function(width, height)
{ {
if (core.Utils.isDefined(width)) if (core.Utils.isDefined(width) && this._size.width != parseInt(width))
{ {
this._size.width = parseInt(width); this._size.width = parseInt(width);
this._native.setAttribute('width', parseInt(width)); this._native.setAttribute('width', parseInt(width));
} }
if (core.Utils.isDefined(height)) if (core.Utils.isDefined(height) && this._size.height != parseInt(height))
{ {
this._size.height = parseInt(height); this._size.height = parseInt(height);
this._native.setAttribute('height', parseInt(height)); this._native.setAttribute('height', parseInt(height));

View File

@ -36,9 +36,11 @@ objects.extend(web2d.peer.svg.GroupPeer, web2d.peer.svg.ElementPeer);
web2d.peer.svg.GroupPeer.prototype.setCoordSize = function(width, height) web2d.peer.svg.GroupPeer.prototype.setCoordSize = function(width, height)
{ {
var change = this._coordSize.width!=width || this._coordSize.height!=height;
this._coordSize.width = width; this._coordSize.width = width;
this._coordSize.height = height; this._coordSize.height = height;
this.updateTransform(); if(change)
this.updateTransform();
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle"); web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle");
}; };
@ -81,6 +83,7 @@ web2d.peer.svg.GroupPeer.prototype.updateTransform = function()
web2d.peer.svg.GroupPeer.prototype.setCoordOrigin = function(x, y) web2d.peer.svg.GroupPeer.prototype.setCoordOrigin = function(x, y)
{ {
var change = x!=this._coordOrigin.x || y!=this._coordOrigin.y;
if (core.Utils.isDefined(x)) if (core.Utils.isDefined(x))
{ {
this._coordOrigin.x = x; this._coordOrigin.x = x;
@ -90,17 +93,21 @@ web2d.peer.svg.GroupPeer.prototype.setCoordOrigin = function(x, y)
{ {
this._coordOrigin.y = y; this._coordOrigin.y = y;
} }
this.updateTransform(); if(change)
this.updateTransform();
}; };
web2d.peer.svg.GroupPeer.prototype.setSize = function(width, height) web2d.peer.svg.GroupPeer.prototype.setSize = function(width, height)
{ {
var change = width != this._size.width || height!=this._size.height;
web2d.peer.svg.GroupPeer.superClass.setSize.call(this, width, height); web2d.peer.svg.GroupPeer.superClass.setSize.call(this, width, height);
this.updateTransform(); if(change)
this.updateTransform();
}; };
web2d.peer.svg.GroupPeer.prototype.setPosition = function(x, y) web2d.peer.svg.GroupPeer.prototype.setPosition = function(x, y)
{ {
var change = x!=this._position.x || y!=this._position.y;
if (core.Utils.isDefined(x)) if (core.Utils.isDefined(x))
{ {
this._position.x = parseInt(x); this._position.x = parseInt(x);
@ -110,7 +117,8 @@ web2d.peer.svg.GroupPeer.prototype.setPosition = function(x, y)
{ {
this._position.y = parseInt(y); this._position.y = parseInt(y);
} }
this.updateTransform(); if(change)
this.updateTransform();
}; };
web2d.peer.svg.GroupPeer.prototype.getPosition = function() web2d.peer.svg.GroupPeer.prototype.getPosition = function()