Line.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import VectorType from "../enum/VectorType.js";
  2. import VectorCategory from "../enum/VectorCategory.js";
  3. import SelectState from "../enum/SelectState.js";
  4. import Geometry from "./Geometry";
  5. import Constant from "../Constant.js";
  6. import Style from "@/graphic/CanvasStyle/index.js";
  7. import Settings from "../Settings";
  8. export default class Line extends Geometry {
  9. constructor(startId, endId, vectorId) {
  10. super();
  11. this.startId = startId;
  12. this.endId = endId;
  13. this.category = Settings.lineCategory;
  14. this.arrowColor = Style.Arrow.strokeStyle; //箭头类型会用到
  15. this.geoType = VectorType.Line;
  16. this.setId(vectorId);
  17. }
  18. //NormalLine,GuideLine,MeasureLine,BaseLine
  19. setCategory(value) {
  20. if (!value) {
  21. this.category = Settings.lineCategory;
  22. } else {
  23. }
  24. this.category = value;
  25. }
  26. getCategory() {
  27. return this.category;
  28. }
  29. setArrowColor(value) {
  30. this.arrowColor = value;
  31. }
  32. getDir(pointId) {
  33. if (this.startId == pointId) {
  34. return "start";
  35. } else if (this.endId == pointId) {
  36. return "end";
  37. } else {
  38. return null;
  39. }
  40. }
  41. }