HighlightItem.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * ********************************************************************************************************************
  3. *
  4. * :*$@@%$*: ;: ;; ;;
  5. * :@@%! :!@@%: %! ;%%@@%$ =@@@@@@@%; @%@@@%%%%@@@@@
  6. * :@%; :$= %%$$$%$$ ;$$ ;$@= !@$
  7. * =@! %! @ $=;% !@@@%: !$$$$$$$$$$$$$$=
  8. * =@* %! @ $= % %@= =%@! %=
  9. * *$%%! @@= ;=$%%%$*: %! @ $= % =%%%%%%@$ *%: =%
  10. * %@@!: !@@@%=$@@@@%! :*@@$: %! @ $= % $* ;@ @* :%*
  11. * ;@@! ;!!!;: ;@%: =======@%========* @ $$ % $%*****$@ :@$=*********=@$
  12. * $@* ;@@@%=!: *@*
  13. * =@$ ;;;!=%@@@@=! =@!
  14. * %@$: =@%: :*@@@* %@= Copyright (c) 2016-2019. 北京上格云技术有限公司
  15. * ;%@@$=$@@%* *@@@$=%@@%;
  16. * ::;:: ::;:: All rights reserved.
  17. *
  18. * ********************************************************************************************************************
  19. */
  20. // @ts-nocheck
  21. import { SGraphItem } from "@saga-web/graph/lib";
  22. import { SColor, SLine, SPainter, SPoint, SRect } from "@saga-web/draw/lib";
  23. import { ItemOrder, ItemColor } from '@saga-web/big/lib';
  24. /**
  25. * 吸附时高亮对象
  26. *
  27. * @author 郝建龙
  28. */
  29. export class HighlightItem extends SGraphItem {
  30. /** 对象与鼠标位置距离 */
  31. distance: number = 0;
  32. /** 对象类型 */
  33. private type: number = 1;
  34. /** 点对象数据-当吸附的为线时,此点为垂线与线段的交点 */
  35. _point: SPoint = new SPoint();
  36. get point(): SPoint {
  37. return this._point;
  38. } // Get point
  39. set point(v: SPoint) {
  40. this._point = v;
  41. this.type = 1;
  42. this.update();
  43. } // Set point
  44. /** 点对象数据 */
  45. _line: SLine = new SLine();
  46. get line(): SLine {
  47. return this._line;
  48. } // Get line
  49. set line(v: SLine) {
  50. this._line = v;
  51. this.type = 2;
  52. this.update();
  53. } // Set line
  54. /**
  55. * 构造函数
  56. *
  57. * @param parent 指向父对象
  58. */
  59. constructor(parent: SGraphItem | null) {
  60. super(parent);
  61. this.visible = false;
  62. this.zOrder = ItemOrder.highLightOrder;
  63. } // Constructor
  64. /**
  65. * Item对象边界区域
  66. *
  67. * @return SRect
  68. */
  69. boundingRect(): SRect {
  70. return new SRect(this.point.x, this.point.y, 10, 10);
  71. } // Function boundingRect()
  72. /**
  73. * Item绘制操作
  74. *
  75. * @param painter painter对象
  76. */
  77. onDraw(painter: SPainter): void {
  78. if (this.type == 2) {
  79. painter.pen.color = ItemColor.highLightLineColor;
  80. painter.pen.lineWidth = painter.toPx(6);
  81. painter.drawLine(this.line);
  82. }
  83. painter.pen.color = SColor.Transparent;
  84. painter.brush.color = ItemColor.highLightPointColor;
  85. painter.drawCircle(this.point.x, this.point.y, painter.toPx(5));
  86. } // Function onDraw()
  87. } // Class HighlightItem