mirror of
https://github.com/UnickSoft/graphonline.git
synced 2025-07-01 23:36:00 +00:00
Fix self loop edges visualisation.
This commit is contained in:
parent
9aa9888e4b
commit
f3f54b6646
@ -434,8 +434,10 @@ BaseEdgeDrawer.prototype.GetTextCenterPoint = function (position1, position2, ha
|
||||
var centerPoint = Point.interpolate(position1, position2, 0.5);
|
||||
if (position1.equals(position2))
|
||||
{
|
||||
centerPoint.y = centerPoint.y - Math.cos(this.model.GetLoopShiftAngel()) * this.model.GetLoopSize() * 2;
|
||||
centerPoint.x = centerPoint.x - Math.sin(this.model.GetLoopShiftAngel()) * this.model.GetLoopSize() * 2;
|
||||
let sinVal = Math.sin(this.model.GetLoopShiftAngel());
|
||||
let cosVal = Math.cos(this.model.GetLoopShiftAngel());
|
||||
centerPoint.x = centerPoint.x - cosVal * this.model.GetLoopSize();
|
||||
centerPoint.y = centerPoint.y - (sinVal + Math.sign(sinVal) * 1.0) * this.model.GetLoopSize();
|
||||
}
|
||||
|
||||
return centerPoint;
|
||||
@ -547,8 +549,10 @@ CurvedArcDrawer.prototype.GetTextCenterPoint = function (position1, position2, h
|
||||
var centerPoint = this.model.GetCurvePoint(position1, position2, 0.5)
|
||||
if (position1.equals(position2))
|
||||
{
|
||||
centerPoint.y = centerPoint.y - Math.cos(this.model.GetLoopShiftAngel()) * this.model.GetLoopSize() * 2;
|
||||
centerPoint.x = centerPoint.x - Math.sin(this.model.GetLoopShiftAngel()) * this.model.GetLoopSize() * 2;
|
||||
let sinVal = Math.sin(this.model.GetLoopShiftAngel());
|
||||
let cosVal = Math.cos(this.model.GetLoopShiftAngel());
|
||||
centerPoint.x = centerPoint.x - cosVal * this.model.GetLoopSize();
|
||||
centerPoint.y = centerPoint.y - (sinVal + Math.sign(sinVal) * 1.0) * this.model.GetLoopSize();
|
||||
}
|
||||
|
||||
return centerPoint;
|
||||
|
@ -205,19 +205,29 @@ EdgeModel.prototype.SetCurveValue = function (value)
|
||||
EdgeModel.prototype.GetLoopSize = function ()
|
||||
{
|
||||
if (Math.abs(this.curveValue) <= 0.01)
|
||||
{ // without this condition arc disappears when curveValue=0
|
||||
{
|
||||
// without this condition arc disappears when curveValue=0
|
||||
return this.sizeOfLoop;
|
||||
}
|
||||
else
|
||||
{ // bigger curveValue -> bigger loop size
|
||||
return this.sizeOfLoop*Math.abs(this.curveValue)*(1/this.defaultCurve);
|
||||
{
|
||||
// bigger curveValue -> bigger loop size
|
||||
let normalCurve = this.curveValue;
|
||||
if (this.type == EdgeModels.line) {
|
||||
normalCurve = this.defaultCurve;
|
||||
}
|
||||
else if (normalCurve >= 0.0) {
|
||||
normalCurve += this.defaultCurve
|
||||
}
|
||||
|
||||
return this.sizeOfLoop * Math.abs(normalCurve) * (1 / this.defaultCurve);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
EdgeModel.prototype.GetLoopShiftAngel = function ()
|
||||
{
|
||||
if (this.curveValue > 0)
|
||||
if (this.type == EdgeModels.line || this.curveValue >= 0.0)
|
||||
{ // shift to top-left
|
||||
return this.loopShiftAngel;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
<script src="<?= Root('i/js/dev/jquery-ui.js')?>"></script>
|
||||
<script src="<?= Root('i/js/dev/jquery.feedback_me.js')?>"></script>
|
||||
<script src="<?= Root("script/canvas2svg.js")?>" ></script>
|
||||
<script src="<?= Root("script/example.js?v=65")?>" ></script>
|
||||
<script src="<?= Root("script/example.js?v=66")?>" ></script>
|
||||
|
||||
<!-- Yandex.RTB -->
|
||||
<script>window.yaContextCb=window.yaContextCb||[]</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user