reverted position balancing

This commit is contained in:
Морозов Андрей 2021-11-06 02:41:59 +04:00
parent 9ff6dd2745
commit f82cdf0814
1 changed files with 17 additions and 20 deletions

View File

@ -86,8 +86,7 @@ class CurvePainter extends CustomPainter {
return higest; return higest;
} }
Map<int, Offset> getDotPos(int dotsAm, Size size, int exclude) { Map<int, Offset> getDotPos(int dotsAm, Size size, [int? exclude]) {
dotsAm--;
Map<int, Offset> off = <int, Offset>{}; Map<int, Offset> off = <int, Offset>{};
var width = size.width / 2; var width = size.width / 2;
var height = size.height / 2; var height = size.height / 2;
@ -96,7 +95,6 @@ class CurvePainter extends CustomPainter {
double x = cos(2 * pi * i / dotsAm) * circleRad + width; double x = cos(2 * pi * i / dotsAm) * circleRad + width;
double y = sin(2 * pi * i / dotsAm) * circleRad + height; double y = sin(2 * pi * i / dotsAm) * circleRad + height;
if (i == exclude - 1) add++;
off[i + add] = Offset(x, y); off[i + add] = Offset(x, y);
} }
@ -125,7 +123,7 @@ class CurvePainter extends CustomPainter {
path.relativeCubicTo(0, 0, -(from.dx + to.dx) / length - 40, path.relativeCubicTo(0, 0, -(from.dx + to.dx) / length - 40,
-(from.dy + to.dy) / length - 40, to.dx - from.dx, to.dy - from.dy); -(from.dy + to.dy) / length - 40, to.dx - from.dx, to.dy - from.dy);
path = path =
ArrowPath.make(path: path, isDoubleSided: doubleSided, tipLength: 13); ArrowPath.make(path: path, isDoubleSided: doubleSided, tipLength: 16);
canvas.drawPath(path, paint); canvas.drawPath(path, paint);
} }
@ -212,23 +210,22 @@ class CurvePainter extends CustomPainter {
//Offset(size.width, size.height / 2)); //Offset(size.width, size.height / 2));
//gr = getGraph(); //gr = getGraph();
int higest = getHighConnections(); //int higest = getHighConnections();
if (higest > -1) { //if (higest > -1) {
var off = getDotPos(gr.getDotAmount(), size, higest); var off = getDotPos(gr.getDotAmount(), size); //, higest);
off[higest] = Offset(size.width / 2, size.height / 2); //off[higest] = Offset(size.width / 2, size.height / 2);
for (int i in off.keys) { for (int i in off.keys) {
drawDot(canvas, off[i]!); drawDot(canvas, off[i]!);
drawDotNames( drawDotNames(canvas, off[i]!, "${gr.getDots()[i - 1].getName()}:[${i}]");
canvas, off[i]!, "${gr.getDots()[i - 1].getName()}:[${i}]");
}
//var g = gr.getNoRepeatDots();
//print(g);
var g = gr.getDots();
drawConnections(canvas, size, g, off);
//pringArr(canvas, size);
//drawArrow(canvas, Offset(size.width / 2, size.height / 2),
// Offset(size.width / 2 + 50, size.height / 2 + 200));
} }
//var g = gr.getNoRepeatDots();
//print(g);
var g = gr.getDots();
drawConnections(canvas, size, g, off);
//pringArr(canvas, size);
//drawArrow(canvas, Offset(size.width / 2, size.height / 2),
// Offset(size.width / 2 + 50, size.height / 2 + 200));
//}
} }
@override @override