|
@@ -87,64 +87,36 @@ export class LineDrawer extends LineSegmentDrawer {
|
|
|
const pos = aggregator.genericObject.getMiddlePoint();
|
|
|
aggregator.konvaObject.children[0].x(pos.posX);
|
|
|
aggregator.konvaObject.children[0].y(pos.posY - 20);
|
|
|
- super.batchDra
|
|
|
- aggregator.konvaObject.children[1].points([
|
|
|
- pointA.posX,
|
|
|
- pointA.posY,
|
|
|
- pointB.posX,
|
|
|
- pointB.posY
|
|
|
- ]);
|
|
|
- super.batchDraw();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- static getKonvaLine(pointA, pointB, useLabel) {
|
|
|
-
|
|
|
- const lineSegment = new LineSegmentModel(pointA, pointB);
|
|
|
-
|
|
|
-
|
|
|
const xA = pointA.posX,
|
|
|
xB = pointB.posX,
|
|
|
yA = pointA.posY,
|
|
|
yB = pointB.posY;
|
|
|
|
|
|
+ const slope = (yB - yA) / (xB - xA);
|
|
|
+ const linearCoefficient = (yA * xB - yB * xA) / (xB - xA);
|
|
|
|
|
|
+ const y = linearCoefficient;
|
|
|
+ const x = -linearCoefficient / slope;
|
|
|
+ const points = [x, 0, 0, y];
|
|
|
|
|
|
-
|
|
|
- const d1 = xB - xA,
|
|
|
-
|
|
|
- d2 = yB - yA;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- const a = -d1 / d2;
|
|
|
- const b = (a * xA) * -1;
|
|
|
+ aggregator.konvaObject.children[1].points(points);
|
|
|
+ super.batchDraw();
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
+ static getKonvaLine(pointA, pointB, useLabel) {
|
|
|
|
|
|
- const Qy = -d1 / d2 * 0 + b;
|
|
|
- const Px = (0 - b) / a;
|
|
|
+ const xA = pointA.posX,
|
|
|
+ xB = pointB.posX,
|
|
|
+ yA = pointA.posY,
|
|
|
+ yB = pointB.posY;
|
|
|
|
|
|
+ const slope = (yB - yA) / (xB - xA);
|
|
|
+ const linearCoefficient = (yA * xB - yB * xA) / (xB - xA);
|
|
|
|
|
|
- const points = [Px, 0, 0, Qy];
|
|
|
+ const y = linearCoefficient;
|
|
|
+ const x = -linearCoefficient / slope;
|
|
|
|
|
|
+ const points = [x, 0, 0, y];
|
|
|
|
|
|
const line = new Konva.Line({
|
|
|
points: points,
|