Relationship lines can now be selected and deleted

This commit is contained in:
Pablo Luna
2010-12-22 19:34:24 -03:00
parent 67c4968aca
commit ae64037f3a
20 changed files with 400 additions and 207 deletions

View File

@@ -19,18 +19,17 @@
mindplot.ControlPoint = function()
{
this._controlPoints= [new web2d.Elipse({width:6, height:6, stroke:'1 solid #6589de',fillColor:'gray', visibility:false}),
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._controlPoints[0].addEventListener('mousedown',this._mouseDown.bindWithEvent(this, mindplot.ControlPoint.FROM));
this._controlPoints[0].addEventListener('click',this._mouseClick.bindWithEvent(this));
this._controlPoints[0].addEventListener('dblclick',this._mouseClick.bindWithEvent(this));
this._controlPoints[1].addEventListener('mousedown',this._mouseDown.bindWithEvent(this,mindplot.ControlPoint.TO));
this._controlPoints[1].addEventListener('click',this._mouseClick.bindWithEvent(this));
this._controlPoints[1].addEventListener('dblclick',this._mouseClick.bindWithEvent(this));
this._mouseClickOnBackgroundFunction = this._mouseClickOnBackground.bind(this);
this._controlPointsController[0].addEventListener('mousedown',this._mouseDown.bindWithEvent(this, mindplot.ControlPoint.FROM));
this._controlPointsController[0].addEventListener('click',this._mouseClick.bindWithEvent(this));
this._controlPointsController[0].addEventListener('dblclick',this._mouseClick.bindWithEvent(this));
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) {
@@ -43,12 +42,18 @@ mindplot.ControlPoint.prototype.setLine= function(line) {
}
this._line= line;
this._createControlPoint();
this._endPoint = [];
this._orignalCtrlPoint = [];
this._orignalCtrlPoint[0] = this._controls[0].clone();
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._createControlPoint = function() {
this._controls= this._line.getLine().getControlPoints();
this._controlPoints[0].setPosition(this._controls[mindplot.ControlPoint.FROM].x, this._controls[mindplot.ControlPoint.FROM].y-3);
this._controlPoints[1].setPosition(this._controls[mindplot.ControlPoint.TO].x, this._controls[mindplot.ControlPoint.TO].y-3);
this._controlPointsController[0].setPosition(this._controls[mindplot.ControlPoint.FROM].x, this._controls[mindplot.ControlPoint.FROM].y-3);
this._controlPointsController[1].setPosition(this._controls[mindplot.ControlPoint.TO].x, this._controls[mindplot.ControlPoint.TO].y-3);
var pos = this._line.getLine().getFrom();
this._controlLines[0].setFrom(pos.x, pos.y);
this._controlLines[0].setTo(this._controls[mindplot.ControlPoint.FROM].x+3, this._controls[mindplot.ControlPoint.FROM].y);
@@ -88,7 +93,7 @@ mindplot.ControlPoint.prototype._mouseMove = function(event, point) {
}
this._controls[point].x=pos.x;
this._controls[point].y=pos.y;
this._controlPoints[point].setPosition(pos.x-5,pos.y-3);
this._controlPointsController[point].setPosition(pos.x-5,pos.y-3);
this._controlLines[point].setFrom(cords.x, cords.y);
this._controlLines[point].setTo(pos.x-2,pos.y);
this._line.getLine().updateLine(point);
@@ -114,42 +119,46 @@ mindplot.ControlPoint.prototype._mouseClick = function(event){
return false;
};
mindplot.ControlPoint.prototype._mouseClickOnBackground = function(event){
this.setVisibility(false);
};
mindplot.ControlPoint.prototype.setVisibility = function(visible){
if(visible){
this._workspace.getScreenManager().addEventListener('mousedown',this._mouseClickOnBackgroundFunction);
this._controlLines[0].moveToFront();
this._controlLines[1].moveToFront();
this._controlPoints[0].moveToFront();
this._controlPoints[1].moveToFront();
this._controlPointsController[0].moveToFront();
this._controlPointsController[1].moveToFront();
}
else{
this._workspace.getScreenManager().removeEventListener('mousedown',this._mouseClickOnBackgroundFunction);
}
this._controlPoints[0].setVisibility(visible);
this._controlPoints[1].setVisibility(visible);
this._controlPointsController[0].setVisibility(visible);
this._controlPointsController[1].setVisibility(visible);
this._controlLines[0].setVisibility(visible);
this._controlLines[1].setVisibility(visible);
};
mindplot.ControlPoint.prototype.addToWorkspace = function(workspace){
this._workspace = workspace;
workspace.appendChild(this._controlPoints[0]);
workspace.appendChild(this._controlPoints[1]);
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){
this._workspace = null;
workspace.removeChild(this._controlPoints[0]);
workspace.removeChild(this._controlPoints[1]);
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){
return this._controls[index];
};
mindplot.ControlPoint.prototype.getOriginalEndPoint = function(index){
return this._endPoint[index];
};
mindplot.ControlPoint.prototype.getOriginalCtrlPoint = function(index){
return this._orignalCtrlPoint[index];
};
mindplot.ControlPoint.FROM = 0;
mindplot.ControlPoint.TO = 1;