xushiting 2 years ago
parent
commit
334887d7ca
3 changed files with 76 additions and 77 deletions
  1. 16 18
      src/graphic/CanvasStyle/focus.js
  2. 17 17
      src/graphic/CanvasStyle/select.js
  3. 43 42
      src/graphic/Renderer/Draw.js

+ 16 - 18
src/graphic/CanvasStyle/focus.js

@@ -1,64 +1,62 @@
-import def from './default.js'
+import def from "./default.js";
 
 
 const Road = {
 const Road = {
   ...def.Road,
   ...def.Road,
   realLineWidth: 4,
   realLineWidth: 4,
   strokeStyle: "#3290FF",
   strokeStyle: "#3290FF",
-}
+};
 
 
 const CurveRoad = {
 const CurveRoad = {
   ...def.CurveRoad,
   ...def.CurveRoad,
   ...Road,
   ...Road,
   lineWidth: 2,
   lineWidth: 2,
-}
+};
 
 
-const Tag = {
-  ...def.Tag,
+const Text = {
+  ...def.Text,
   strokeStyle: "#00C8AF",
   strokeStyle: "#00C8AF",
   fillStyle: "#00C8AF",
   fillStyle: "#00C8AF",
-}
+};
 
 
 const Point = {
 const Point = {
   ...def.Point,
   ...def.Point,
   fillStyle: "#3290FF",
   fillStyle: "#3290FF",
-}
+};
 
 
 const RoadPoint = {
 const RoadPoint = {
   ...Point,
   ...Point,
-}
+};
 
 
 const CurveRoadPoint = {
 const CurveRoadPoint = {
   ...def.CurveRoadPoint,
   ...def.CurveRoadPoint,
-  ...Point
-}
+  ...Point,
+};
 
 
 const ControlPoint = {
 const ControlPoint = {
   ...def.ControlPoint,
   ...def.ControlPoint,
   fillStyle: "#3290FF",
   fillStyle: "#3290FF",
-}
-
+};
 
 
 const RoadEdge = {
 const RoadEdge = {
   ...def.RoadEdge,
   ...def.RoadEdge,
   lineWidth: 2,
   lineWidth: 2,
   strokeStyle: "#3290FF",
   strokeStyle: "#3290FF",
-}
+};
 
 
 const CurveRoadEdge = {
 const CurveRoadEdge = {
   ...def.CurveRoadEdge,
   ...def.CurveRoadEdge,
   lineWidth: 2,
   lineWidth: 2,
   strokeStyle: "#3290FF",
   strokeStyle: "#3290FF",
-}
-
+};
 
 
 export default {
 export default {
   Road,
   Road,
-  Tag,
+  Text,
   Point,
   Point,
   RoadPoint,
   RoadPoint,
   CurveRoadPoint,
   CurveRoadPoint,
   ControlPoint,
   ControlPoint,
   CurveRoad,
   CurveRoad,
   RoadEdge,
   RoadEdge,
-  CurveRoadEdge
-}
+  CurveRoadEdge,
+};

+ 17 - 17
src/graphic/CanvasStyle/select.js

@@ -1,62 +1,62 @@
-import def from './default.js'
+import def from "./default.js";
 
 
 const Road = {
 const Road = {
   ...def.Road,
   ...def.Road,
   realLineWidth: 4,
   realLineWidth: 4,
   strokeStyle: "#3290FF",
   strokeStyle: "#3290FF",
-}
+};
 
 
 const CurveRoad = {
 const CurveRoad = {
   ...def.CurveRoad,
   ...def.CurveRoad,
   ...Road,
   ...Road,
   lineWidth: 2,
   lineWidth: 2,
-}
+};
 
 
-const Tag = {
-  ...def.Tag,
+const Text = {
+  ...def.Text,
   strokeStyle: "#00C8AF",
   strokeStyle: "#00C8AF",
   fillStyle: "#00C8AF",
   fillStyle: "#00C8AF",
-}
+};
 
 
 const RoadEdge = {
 const RoadEdge = {
   ...def.RoadEdge,
   ...def.RoadEdge,
   lineWidth: 2,
   lineWidth: 2,
   strokeStyle: "#3290FF",
   strokeStyle: "#3290FF",
-}
+};
 
 
 const CurveRoadEdge = {
 const CurveRoadEdge = {
   ...def.CurveRoadEdge,
   ...def.CurveRoadEdge,
   lineWidth: 2,
   lineWidth: 2,
   strokeStyle: "#3290FF",
   strokeStyle: "#3290FF",
-}
+};
 
 
 const Point = {
 const Point = {
   ...def.Point,
   ...def.Point,
   fillStyle: "#3290FF",
   fillStyle: "#3290FF",
-}
+};
 
 
 const RoadPoint = {
 const RoadPoint = {
-  ...Point
-}
+  ...Point,
+};
 
 
 const CurveRoadPoint = {
 const CurveRoadPoint = {
   ...def.CurveRoadPoint,
   ...def.CurveRoadPoint,
-  ...Point
-}
+  ...Point,
+};
 
 
 const ControlPoint = {
 const ControlPoint = {
   ...def.ControlPoint,
   ...def.ControlPoint,
   fillStyle: "#3290FF",
   fillStyle: "#3290FF",
-}
+};
 
 
 export default {
 export default {
   Road,
   Road,
-  Tag,
+  Text,
   Point,
   Point,
   RoadPoint,
   RoadPoint,
   CurveRoadPoint,
   CurveRoadPoint,
   ControlPoint,
   ControlPoint,
   CurveRoad,
   CurveRoad,
   RoadEdge,
   RoadEdge,
-  CurveRoadEdge
-}
+  CurveRoadEdge,
+};

+ 43 - 42
src/graphic/Renderer/Draw.js

@@ -147,15 +147,15 @@ export default class Draw {
         ctx.moveTo(startScreen.x, startScreen.y);
         ctx.moveTo(startScreen.x, startScreen.y);
         ctx.lineTo(endScreen.x, endScreen.y);
         ctx.lineTo(endScreen.x, endScreen.y);
         ctx.stroke();
         ctx.stroke();
-      }
+      };
 
 
       ctx.save();
       ctx.save();
       const vectorStyle = help.setVectorStyle(ctx, vector);
       const vectorStyle = help.setVectorStyle(ctx, vector);
-      ctx.lineWidth = vector.midDivideWidth
-      draw()
-      ctx.strokeStyle = Style.bgColor
-      ctx.lineWidth = vector.midDivideWidth - vectorStyle.realLineWidth
-      draw()
+      ctx.lineWidth = vector.midDivideWidth;
+      draw();
+      ctx.strokeStyle = Style.bgColor;
+      ctx.lineWidth = vector.midDivideWidth - vectorStyle.realLineWidth;
+      draw();
       ctx.restore();
       ctx.restore();
     }
     }
 
 
@@ -252,10 +252,14 @@ export default class Draw {
 
 
   drawControlPoint(vector) {
   drawControlPoint(vector) {
     const start = coordinate.getScreenXY(
     const start = coordinate.getScreenXY(
-      dataService.getRoadEdge(vector.edgeInfo1.id).getPosition(vector.edgeInfo1.dir)
+      dataService
+        .getRoadEdge(vector.edgeInfo1.id)
+        .getPosition(vector.edgeInfo1.dir)
     );
     );
     const end = coordinate.getScreenXY(
     const end = coordinate.getScreenXY(
-      dataService.getRoadEdge(vector.edgeInfo2.id).getPosition(vector.edgeInfo2.dir)
+      dataService
+        .getRoadEdge(vector.edgeInfo2.id)
+        .getPosition(vector.edgeInfo2.dir)
     );
     );
     const pt2 = this.twoOrderBezier(
     const pt2 = this.twoOrderBezier(
       0.5,
       0.5,
@@ -288,14 +292,13 @@ export default class Draw {
     ctx.quadraticCurveTo(pt.x, pt.y, end.x, end.y);
     ctx.quadraticCurveTo(pt.x, pt.y, end.x, end.y);
     ctx.stroke();
     ctx.stroke();
     ctx.restore();
     ctx.restore();
-
   }
   }
 
 
   drawCurveRoad(vector) {
   drawCurveRoad(vector) {
     if (vector.display && vector.midDivide) {
     if (vector.display && vector.midDivide) {
       const covesArray = help.transformCoves([
       const covesArray = help.transformCoves([
         vector.midDivide.leftMidDivideCurves,
         vector.midDivide.leftMidDivideCurves,
-        vector.midDivide.rightMidDivideCurves
+        vector.midDivide.rightMidDivideCurves,
       ]);
       ]);
       const ctx = this.context;
       const ctx = this.context;
       ctx.save();
       ctx.save();
@@ -350,14 +353,12 @@ export default class Draw {
   }
   }
 
 
   drawRoadPoint(vector) {
   drawRoadPoint(vector) {
-    this.drawPoint(vector)
+    this.drawPoint(vector);
   }
   }
   drawPoint(vector) {
   drawPoint(vector) {
     const pt = coordinate.getScreenXY({ x: vector.x, y: vector.y });
     const pt = coordinate.getScreenXY({ x: vector.x, y: vector.y });
     const ctx = this.context;
     const ctx = this.context;
-    const draw = () => {
-
-    }
+    const draw = () => {};
 
 
     help.setVectorStyle(ctx, vector, vector.geoType || "Point");
     help.setVectorStyle(ctx, vector, vector.geoType || "Point");
     ctx.beginPath();
     ctx.beginPath();
@@ -421,7 +422,7 @@ export default class Draw {
   drawText(position, txt, angle) {
   drawText(position, txt, angle) {
     const ctx = this.context;
     const ctx = this.context;
     ctx.save();
     ctx.save();
-    help.setVectorStyle(ctx, null,"Text");
+    help.setVectorStyle(ctx, null, "Text");
 
 
     const pt = coordinate.getScreenXY(position);
     const pt = coordinate.getScreenXY(position);
     if (angle) {
     if (angle) {
@@ -434,56 +435,56 @@ export default class Draw {
     ctx.restore();
     ctx.restore();
   }
   }
 
 
-  drawTag(geometry, styleType, hide) {
+  drawText(geometry, styleType, hide) {
     this.context.save();
     this.context.save();
 
 
-    this.context.lineWidth = Style.Tag.lineWidth * coordinate.ratio;
-    this.context.strokeStyle = Style.Tag.strokeStyle;
-    this.context.fillStyle = Style.Tag.fillStyle;
+    this.context.lineWidth = Style.Text.lineWidth * coordinate.ratio;
+    this.context.strokeStyle = Style.Text.strokeStyle;
+    this.context.fillStyle = Style.Text.fillStyle;
 
 
     if (styleType) {
     if (styleType) {
       if (styleType == "style-1") {
       if (styleType == "style-1") {
         this.context.lineWidth =
         this.context.lineWidth =
-          Style.DownLoad.style1.Tag.lineWidth * coordinate.ratio;
-        this.context.strokeStyle = Style.DownLoad.style1.Tag.strokeStyle;
-        this.context.fillStyle = Style.DownLoad.style1.Tag.fillStyle;
+          Style.DownLoad.style1.Text.lineWidth * coordinate.ratio;
+        this.context.strokeStyle = Style.DownLoad.style1.Text.strokeStyle;
+        this.context.fillStyle = Style.DownLoad.style1.Text.fillStyle;
       } else if (styleType == "style-2") {
       } else if (styleType == "style-2") {
         this.context.lineWidth =
         this.context.lineWidth =
-          Style.DownLoad.style2.Tag.lineWidth * coordinate.ratio;
-        this.context.strokeStyle = Style.DownLoad.style2.Tag.strokeStyle;
-        this.context.fillStyle = Style.DownLoad.style2.Tag.fillStyle;
+          Style.DownLoad.style2.Text.lineWidth * coordinate.ratio;
+        this.context.strokeStyle = Style.DownLoad.style2.Text.strokeStyle;
+        this.context.fillStyle = Style.DownLoad.style2.Text.fillStyle;
       } else if (styleType == "style-3") {
       } else if (styleType == "style-3") {
         this.context.lineWidth =
         this.context.lineWidth =
-          Style.DownLoad.style3.Tag.lineWidth * coordinate.ratio;
-        this.context.strokeStyle = Style.DownLoad.style3.Tag.strokeStyle;
-        this.context.fillStyle = Style.DownLoad.style3.Tag.fillStyle;
+          Style.DownLoad.style3.Text.lineWidth * coordinate.ratio;
+        this.context.strokeStyle = Style.DownLoad.style3.Text.strokeStyle;
+        this.context.fillStyle = Style.DownLoad.style3.Text.fillStyle;
       } else if (styleType == "style-4") {
       } else if (styleType == "style-4") {
         this.context.lineWidth =
         this.context.lineWidth =
-          Style.DownLoad.style4.Tag.lineWidth * coordinate.ratio;
-        this.context.strokeStyle = Style.DownLoad.style4.Tag.strokeStyle;
-        this.context.fillStyle = Style.DownLoad.style4.Tag.fillStyle;
+          Style.DownLoad.style4.Text.lineWidth * coordinate.ratio;
+        this.context.strokeStyle = Style.DownLoad.style4.Text.strokeStyle;
+        this.context.fillStyle = Style.DownLoad.style4.Text.fillStyle;
       }
       }
     } else {
     } else {
       const selectItem = stateService.getSelectItem();
       const selectItem = stateService.getSelectItem();
       const draggingItem = stateService.getDraggingItem();
       const draggingItem = stateService.getDraggingItem();
       const focusItem = stateService.getFocusItem();
       const focusItem = stateService.getFocusItem();
 
 
-      if (selectItem && selectItem.type == VectorType.Tag) {
+      if (selectItem && selectItem.type == VectorType.Text) {
         if (geometry.vectorId == selectItem.vectorId) {
         if (geometry.vectorId == selectItem.vectorId) {
-          this.context.strokeStyle = Style.Select.Tag.strokeStyle;
-          this.context.fillStyle = Style.Select.Tag.fillStyle;
+          this.context.strokeStyle = Style.Select.Text.strokeStyle;
+          this.context.fillStyle = Style.Select.Text.fillStyle;
         }
         }
-      } else if (draggingItem && draggingItem.type == VectorType.Tag) {
+      } else if (draggingItem && draggingItem.type == VectorType.Text) {
         if (geometry.vectorId == draggingItem.vectorId) {
         if (geometry.vectorId == draggingItem.vectorId) {
-          this.context.strokeStyle = Style.Select.Tag.strokeStyle;
-          this.context.fillStyle = Style.Select.Tag.fillStyle;
+          this.context.strokeStyle = Style.Select.Text.strokeStyle;
+          this.context.fillStyle = Style.Select.Text.fillStyle;
         }
         }
       }
       }
 
 
-      if (focusItem && focusItem.type == VectorType.Tag) {
+      if (focusItem && focusItem.type == VectorType.Text) {
         if (geometry.vectorId == focusItem.vectorId) {
         if (geometry.vectorId == focusItem.vectorId) {
-          this.context.strokeStyle = Style.Focus.Tag.strokeStyle;
-          this.context.fillStyle = Style.Focus.Tag.fillStyle;
+          this.context.strokeStyle = Style.Focus.Text.strokeStyle;
+          this.context.fillStyle = Style.Focus.Text.fillStyle;
         }
         }
       }
       }
     }
     }
@@ -499,8 +500,8 @@ export default class Draw {
         });
         });
       }
       }
 
 
-      this.context.strokeStyle = Style.Tag.strokeStyle_adding;
-      this.context.fillStyle = Style.Tag.fillStyle_adding;
+      this.context.strokeStyle = Style.Text.strokeStyle_adding;
+      this.context.fillStyle = Style.Text.fillStyle_adding;
       this.context.beginPath();
       this.context.beginPath();
       this.context.moveTo(points[0].x, points[0].y);
       this.context.moveTo(points[0].x, points[0].y);
       this.context.lineTo(points[1].x, points[1].y);
       this.context.lineTo(points[1].x, points[1].y);