- Minor improvement on relationship. Show arrow.

This commit is contained in:
Paulo Gustavo Veiga 2012-09-04 23:29:24 -03:00
parent a86a38d157
commit 9a94326469
3 changed files with 24 additions and 6 deletions

View File

@ -20,7 +20,7 @@ mindplot.ConnectionLine = new Class({
initialize:function (sourceNode, targetNode, lineType) {
$assert(targetNode, 'parentNode node can not be null');
$assert(sourceNode, 'childNode node can not be null');
$assert(sourceNode != targetNode, 'Cilcular connection');
$assert(sourceNode != targetNode, 'Circular connection');
this._targetTopic = targetNode;
this._sourceTopic = sourceNode;

View File

@ -39,13 +39,24 @@ mindplot.RelationshipPivot = new Class({
this._workspace.enableWorkspaceEvents(false);
var sourcePos = sourceTopic.getPosition();
var strokeColor = mindplot.Relationship.getStrokeColor();
this._pivot = new web2d.CurvedLine();
this._pivot.setStyle(web2d.CurvedLine.SIMPLE_LINE);
this._pivot.setDashed(2, 2);
this._pivot.setFrom(sourcePos.x, sourcePos.y);
this._pivot.setTo(targetPos.x, targetPos.y);
this._workspace.appendChild(this._pivot);
this._pivot.setTo(targetPos.x, targetPos.y);
this._pivot.setStroke(2, 'solid', strokeColor);
this._pivot.setDashed(4, 2);
this._startArrow = new web2d.Arrow();
this._startArrow.setStrokeColor(strokeColor);
this._startArrow.setStrokeWidth(2);
this._startArrow.setFrom(sourcePos.x, sourcePos.y);
this._workspace.appendChild(this._pivot);
this._workspace.appendChild(this._startArrow);
this._workspace.addEvent('mousemove', this._mouseMoveEvent);
this._workspace.addEvent('click', this._onClickEvent);
@ -74,10 +85,12 @@ mindplot.RelationshipPivot = new Class({
}.bind(this));
workspace.removeChild(this._pivot);
workspace.removeChild(this._startArrow);
workspace.enableWorkspaceEvents(true);
this._sourceTopic = null;
this._pivot = null;
this._startArrow = null;
}
},
@ -85,7 +98,12 @@ mindplot.RelationshipPivot = new Class({
var screen = this._workspace.getScreenManager();
var pos = screen.getWorkspaceMousePosition(event);
this._pivot.setTo(pos.x - 1, pos.y - 1);
var gapDistance = Math.sign(pos.x - this._sourceTopic.getPosition().x) * 5;
this._pivot.setTo(pos.x - gapDistance, pos.y);
var controlPoints = this._pivot.getControlPoints();
this._startArrow.setFrom(pos.x - gapDistance, pos.y);
this._startArrow.setControlPoint(controlPoints[1]);
event.stopPropagation();
return false;
},

View File

@ -1025,7 +1025,7 @@ mindplot.Topic = new Class({
connectTo:function (targetTopic, workspace, isVisible) {
$assert(!this._outgoingLine, 'Could not connect an already connected node');
$assert(targetTopic != this, 'Cilcular connection are not allowed');
$assert(targetTopic != this, 'Circular connection are not allowed');
$assert(targetTopic, 'Parent Graph can not be null');
$assert(workspace, 'Workspace can not be null');