소스 검색

Update 'src/app/components/point-component/drawers/point-drawer.js'

Some fixes to allow the MidPoint creation through GEO file with the correct ID
(e.g. one with "1:3" was been created with ID=1)
Indentation improvements
leo 2 년 전
부모
커밋
e18e53cd57
1개의 변경된 파일38개의 추가작업 그리고 34개의 파일을 삭제
  1. 38 34
      src/app/components/point-component/drawers/point-drawer.js

+ 38 - 34
src/app/components/point-component/drawers/point-drawer.js

@@ -1,3 +1,8 @@
+/*
+ iGeom
+ LInE  www.usp.br/line
+ */
+
 import { ELEMENTS_CLASS } from "../../../core/enums/elements-class-enum";
 import { label as Label } from "../../../component-registry/label";
 import { app as App } from "../../../app";
@@ -11,35 +16,37 @@ const STYLE = {
   fill2: "#828783",
   strokeWidth: 1,
   stroke: "#9bc364"
-};
+  };
+
 export class PointDrawer extends SelectableDrawer {
-  constructor() {
+
+  constructor () {
     super();
     this.point;
     this.label;
     this.text;
     this.states = ["center"];
     super.setElementClass(ELEMENTS_CLASS.POINT);
-  }
+    }
 
-  draw(e) {
+  draw (e) {
     if (e != undefined && e.attrs != undefined && e.attrs.genericObject != undefined) {
       const aggregator = this.drawPoint(e.attrs.genericObject);
       return aggregator;
-    }
+      }
     if (this.state == undefined) {
       super.setState(this.states[0]);
       App.setStatus("Selecione o centro do Ponto");
-    }
+      }
     if (this.state == this.states[0]) {
       App.setStatus("Selecione o centro do Ponto");
       const aggregator = this.drawPoint();
       super.setState(this.states[0]);
       return aggregator;
+      }
     }
-  }
 
-  drawPoint(point) {
+  drawPoint (point) {
     const pos = App.pos();
     let drawResult;
     if (point == undefined) {
@@ -50,37 +57,32 @@ export class PointDrawer extends SelectableDrawer {
 
     this.point = drawResult.geometricObject;
     super.setKonvaObject(drawResult.konvaObject);
-    const aggregator = new DrawerAggregator(
-      this,
-      this.point,
-      this.konvaObject,
-      ELEMENTS_CLASS.POINT
-    );
+    const aggregator = new DrawerAggregator(this, this.point, this.konvaObject, ELEMENTS_CLASS.POINT); // app/core/drawers/drawer-aggregator.js
     super.addAggregator(aggregator);
     this.konvaObject.on("dragmove", aggregator.update.bind(aggregator));
     return aggregator;
-  }
+    }
 
-  update(aggregator, event) {
+  update (aggregator, event) {
     aggregator.konvaObject.children.forEach(function (element) {
       if (element.attrs.class == ELEMENTS_CLASS.POINT) {
         aggregator.genericObject.update(element, event);
-      }
-    });
-  }
+        }
+      });
+    }
 
-  inserPointInLineSegment(konvaObject) {
+  inserPointInLineSegment (konvaObject) {
     const drawerAggregators = objects.getByKonvaObject(konvaObject);
     if (drawerAggregators == undefined || drawerAggregators.length == 0) return;
     const drawerAggregator = drawerAggregators[0];
     drawerAggregator.drawer.insertPoint(drawerAggregator);
-  }
+    }
 
-  static drawAndGetPoint(x, y, useLabel) {
+  static drawAndGetPoint (x, y, useLabel) {
     return PointDrawer.drawPoint(new PointModel(x, y), useLabel);
-  }
+    }
 
-  static drawPoint(point, useLabel, draggable, selectable) {
+  static drawPoint (point, useLabel, draggable, selectable) {
     const group = SelectableDrawer.getKonvaGroup(draggable);
     const circle = PointDrawer.getKonvaCircle(point, draggable, selectable);
 
@@ -89,7 +91,7 @@ export class PointDrawer extends SelectableDrawer {
       point.setLabel(label);
       const text = PointDrawer.getKonvaText(point, label);
       group.add(text);
-    }
+      }
 
     if (selectable == undefined || selectable)
       SelectableDrawer.setSelectableIfSelectorChanged(circle);
@@ -103,17 +105,17 @@ export class PointDrawer extends SelectableDrawer {
       SelectableDrawer.drawObject(circle);
       SelectableDrawer.setMaxIndex(circle);
       return { geometricObject: point, konvaObject: circle };
+      }
     }
-  }
 
-  static getKonvaCircle(point, draggable, selectable) {
+  static getKonvaCircle (point, draggable, selectable) {
     let fill = draggable == undefined || draggable ? STYLE.fill : STYLE.fill2;
     let stroke = draggable == undefined || draggable ? STYLE.stroke : STYLE.fill2;
 
     if (point.backgroundColor != undefined) {
       fill = point.backgroundColor;
       stroke = point.backgroundColor;
-    }
+      }
 
     return new Konva.Circle({
       x: point.posX,
@@ -133,9 +135,10 @@ export class PointDrawer extends SelectableDrawer {
       startPosY: point.posY,
       listening: true,
       selectable: selectable
-    });
-  }
-  static getKonvaText(point, label) {
+      });
+    }
+
+  static getKonvaText (point, label) {
     return new Konva.Text({
       x: point.posX + 10,
       y: point.posY - 10,
@@ -149,6 +152,7 @@ export class PointDrawer extends SelectableDrawer {
       resizeEnabled: false,
       transformEnabled: false,
       selectable: false
-    });
-  }
-}
+      });
+    }
+
+  }