this.to = target;
this.modeledge.t = target.modelnode;
refreshConstraints();
adjust();
this.from = from;
this.to = to;
adjust();
sendToBack();
//add pointers to the modelnodes to the modeledge
this.modeledge.s = this.from.modelnode;
this.modeledge.t = this.to.modelnode;
refreshConstraints();
/*
* So I'm going to express the connector constraints in script rather than tags so that we can easily change the nodes
* an edge is bound to
*/
var adjustDel = new LzDelegate(this, "adjust");
adjustDel.register(from, "onx");
adjustDel.register(from, "ony");
adjustDel.register(to, "onx");
adjustDel.register(to, "ony");
adjustDel.register(from, "onwidth");
adjustDel.register(to, "onwidth");
__refreshdxdy();
setHeight(__calcHeight());
setRotation(__calcAngle());
/*
* Figure out the distance between start and endpoints
*/
var x1 = from.x+from.width/2;
var y1 = from.y+from.height/2;
var x2 = to.x+to.width/2;
var y2 = to.y+to.height/2;
dx = x1-x2;
dy = y1 - y2;
//distance between two points.
return Math.sqrt(dx*dx+dy*dy);
0) angle = Math.PI / 2.0; //90
else angle = (Math.PI * 3.0) / 2.0; //-90
}
else if(dy == 0) {
if(dx > 0) angle = 0;
else angle = Math.PI; //180
}
//done with special cases
else {
if(dx < 0) angle = Math.atan(dy/dx) + Math.PI;
else if(dy < 0) angle = Math.atan(dy/dx) + (2*Math.PI);
else angle = Math.atan(dy/dx);
}
/*
* add an offset of 90 because OpenLaszlo views always point downward.
* and then convert to degrees.
*/
return (angle * 180) / Math.PI + 90;
]]>
= (90-tAngleDeg)) & (angle <= (90+tAngleDeg))
|
(angle >= (270-tAngleDeg)) & (angle <= (270+tAngleDeg))
) {
var a = classroot.to.height/2;
var theta = Math.abs(angle-90);
var b = a*Math.tan(toRad(theta));
var hyp = Math.sqrt(a*a+ b*b);
setAttribute("y", parent.height-hyp-this.height/2);
}
//else follow the left and right edges of the target node.
else {
thresholdAngle = Math.atan((classroot.to.height/2)/(classroot.to.width/2));
tAngleDeg = thresholdAngle*180/Math.PI;
//Debug.write(angle, tAngleDeg);
var a = classroot.to.width/2;
var theta = Math.abs(angle);
var b = a*Math.tan(toRad(theta));
var hyp = Math.sqrt(a*a+ b*b);
setAttribute("y", parent.height-hyp-this.height/2+2);
}
function toDeg(radians) {
return radians*180/Math.PI;
}
function toRad(degrees) {
return degrees*Math.PI/180;
}
]]>
if (classroot.modeledge.sourceButton == null)
{
setText("?");
}
classroot.dodblclick();
setAttribute('backgroundStartColor', kyellow);
setAttribute('backgroundStopColor', kyellow);
setAttribute('borderColor', korange);
drawStructure();
setAttribute('backgroundStartColor', nodeblue);
setAttribute('backgroundStopColor', nodeblue);
setAttribute('borderColor', nodedarkblue);
drawStructure();
drawStructure();
drawStructure();
if (parent.highlighted == true) {
canvas.dview.eManipulation.setAttribute("y", parent.y - this.y * Math.sin((-parent.rotation-90)*Math.PI/180));
canvas.dview.eManipulationBG.setAttribute("y", parent.y - this.y * Math.sin((-parent.rotation-90)*Math.PI/180));
canvas.dview.eManipulation.setAttribute("x", parent.x + this.y * Math.cos((-parent.rotation-90)*Math.PI/180));
canvas.dview.eManipulationBG.setAttribute("x", parent.x + this.y * Math.cos((-parent.rotation-90)*Math.PI/180));
}
this.highlighted = true;
arrowhead.setResource("arrowheadhswf");
line.setAttribute('width', 3);
line.sendToBack();
setAttribute('color', kyellow);
setBGColor(korange);
thint.highlight();
bringToFront();
from.bringToFront();
to.bringToFront();
if (canvas.leftp.state == "CLOSED") {
var x = this.x + thint.y * Math.cos((-this.rotation-90)*Math.PI/180);
var y = this.y - thint.y * Math.sin((-this.rotation-90)*Math.PI/180);
//Debug.write("this.x is ", (this.x));
//Debug.write("this.y is ", (this.y));
//Debug.write("angle is ", (-this.rotation-90));
//Debug.write("x is ", x);
//Debug.write("y is ", y);
canvas.dview.eManipulationBG.animateIn();
//dview.eManipulation.setVisible(true);
//dview.eManipulation.setAttribute('x', x);
//dview.eManipulation.setAttribute('y', y);
}
if (canvas.leftp.state == "CLOSED") {
canvas.dview.eManipulationBG.animateOut();
}
this.highlighted = false;
arrowhead.setResource("arrowheadswf");
line.setAttribute('width', 1);
setAttribute('color', kblue2);
setBGColor(null);
thint.unhighlight();
dodblclick();
//this was factored out so that it can be used in other parts
parent.onselectswitch.sendEvent();
parent.setAttribute('selectedobj', this);
if (this.highlighted == true) {
if (canvas.leftp.state == "CLOSED") {
canvas.dview.eManipulationBG.animateIn();
}
else {
canvas.dview.eManipulationBG.animateOut();
}
}