Jelajahi Sumber

update circumference

Victor Domingues 4 tahun lalu
induk
melakukan
a5ec1ab3c7

+ 8 - 1
src/app/components/circumference-component/drawers/circumference-drawer.js

@@ -48,7 +48,6 @@ export class CircumferenceDrawer extends Drawer {
         }
     }
     drawcircumference(circumference) {
-        console.info(circumference.getRadius());
         const circle = new Konva.Circle({
             x: circumference.center.posX,
             y: circumference.center.posY,
@@ -67,4 +66,12 @@ export class CircumferenceDrawer extends Drawer {
         return circle;
 
     }
+    
+  update(aggregator, e) {
+    const center = aggregator.genericObject.center;
+    aggregator.konvaObject.radius(aggregator.genericObject.getRadius());
+    aggregator.konvaObject.x(center.posX);
+    aggregator.konvaObject.y(center.posY);
+    super.batchDraw();
+  }
 }

+ 4 - 3
src/app/components/circumference-component/models/circumference-model.js

@@ -7,11 +7,12 @@ export class CircumferenceModel {
         this._coordinates[1] = this.center.posY;
         this._coordinates[2] = this.radius.posX;
         this._coordinates[3] = this.radius.posY;
-    }
-    update(aggregator, event) {
-
     }
     getRadius() {
+        this._coordinates[0] = this.center.posX;
+        this._coordinates[1] = this.center.posY;
+        this._coordinates[2] = this.radius.posX;
+        this._coordinates[3] = this.radius.posY;
         const legA = this._coordinates[2] - this._coordinates[0];
         const legB = this._coordinates[3] - this._coordinates[1];
         const radius = Math.sqrt(Math.pow(legA, 2) + Math.pow(legB, 2));

+ 2 - 2
src/app/components/line-segment-component/drawers/line-segment-drawer.js

@@ -114,7 +114,7 @@ export class LineSegmentDrawer extends Drawer {
     aggregators[1].addAggregator(aggregator);
     aggregators[0].addAggregator(aggregator);
     Drawer.drawObject(this.konvaObject);
-    this.konvaObject.zIndex(0);
+    this.konvaObject.zIndex(1);
     super.batchDraw();
   }
 
@@ -157,7 +157,7 @@ export class LineSegmentDrawer extends Drawer {
       strokeScaleEnabled: false,
       class: ELEMENTS_CLASS.LINE_SEGMENT,
       connections: [],
-      index: 0,
+      index: 1,
       selectable: false,
       draggable: false
     });

+ 2 - 0
src/app/components/point-component/drawers/point-drawer.js

@@ -101,6 +101,8 @@ export class PointDrawer extends Drawer {
       return { geometricObject: point, konvaObject: group };
     } else {
       Drawer.drawObject(circle);
+      group.zIndex(Number.MAX_SAFE_INTEGER);
+      Drawer.stageBatchDraw();
       return { geometricObject: point, konvaObject: circle };
     }
   }

+ 2 - 18
src/app/core/drawers/drawer.js

@@ -12,7 +12,7 @@ export class Drawer {
     this.konvaObject;
     this.elementClass = undefined;
   }
-  onDragMove() {}
+  onDragMove() { }
   setElementClass(elementClass) {
     this.elementClass = elementClass;
   }
@@ -39,10 +39,7 @@ export class Drawer {
   batchDraw() {
     Drawer.stageBatchDraw();
   }
-  update(aggregator) {
-    throw "Not implemented exception";
-  }
-  updatePositions(aggregator, event) {
+  update(aggregator, event) {
     throw "Not implemented exception";
   }
   setKonvaObject(konvaObject) {
@@ -62,17 +59,4 @@ export class Drawer {
   static stageBatchDraw() {
     DrawerManager.batchDraw();
   }
-
-  static configureObjectEvents(object) {
-    object.on("mouseover", function() {
-      this.strokeWidth(HOVER_STYLE.strokeWidth);
-      this.stroke(HOVER_STYLE.stroke);
-      StageManger.getCurrentKonvaStage().draw();
-    });
-    object.on("mouseout", function() {
-      this.strokeWidth(STYLE.strokeWidth);
-      this.stroke(STYLE.stroke);
-      StageManger.getCurrentKonvaStage().draw();
-    });
-  }
 }