HighlightItem.js 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. import { SGraphItem } from "@saga-web/graph/lib";
  21. import { SColor, SLine, SPoint, SRect } from "@saga-web/draw/lib";
  22. import { ItemOrder, ItemColor } from '@saga-web/big/lib';
  23. /**
  24. * 吸附时高亮对象
  25. *
  26. * @author 郝建龙
  27. */
  28. export class HighlightItem extends SGraphItem {
  29. /**
  30. * 构造函数
  31. *
  32. * @param parent 指向父对象
  33. */
  34. constructor(parent) {
  35. super(parent);
  36. /** 对象与鼠标位置距离 */
  37. this.distance = 0;
  38. /** 对象类型 */
  39. this.type = 1;
  40. /** 点对象数据-当吸附的为线时,此点为垂线与线段的交点 */
  41. this._point = new SPoint();
  42. /** 点对象数据 */
  43. this._line = new SLine();
  44. this.visible = false;
  45. this.zOrder = ItemOrder.highLightOrder;
  46. } // Constructor
  47. get point() {
  48. return this._point;
  49. } // Get point
  50. set point(v) {
  51. this._point = v;
  52. this.type = 1;
  53. this.update();
  54. } // Set point
  55. get line() {
  56. return this._line;
  57. } // Get line
  58. set line(v) {
  59. this._line = v;
  60. this.type = 2;
  61. this.update();
  62. } // Set line
  63. /**
  64. * Item对象边界区域
  65. *
  66. * @return SRect
  67. */
  68. boundingRect() {
  69. return new SRect(this.point.x, this.point.y, 10, 10);
  70. } // Function boundingRect()
  71. /**
  72. * Item绘制操作
  73. *
  74. * @param painter painter对象
  75. */
  76. onDraw(painter) {
  77. if (this.type == 2) {
  78. painter.pen.color = ItemColor.highLightLineColor;
  79. painter.pen.lineWidth = painter.toPx(6);
  80. painter.drawLine(this.line);
  81. }
  82. painter.pen.color = SColor.Transparent;
  83. painter.brush.color = ItemColor.highLightPointColor;
  84. painter.drawCircle(this.point.x, this.point.y, painter.toPx(5));
  85. } // Function onDraw()
  86. } // Class HighlightItem