STextMarkerItem.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.STextMarkerItem = void 0;
  4. const lib_1 = require("@persagy-web/graph/lib");
  5. const draw_1 = require("@persagy-web/draw");
  6. class STextMarkerItem extends lib_1.STextItem {
  7. constructor(parent, data) {
  8. super(parent);
  9. this._scaleX = 1;
  10. this._scaleY = 1;
  11. this._rolate = 0;
  12. this.data = data;
  13. this.moveTo(data.Pos.X, data.Pos.Y);
  14. if (this.data.Scale) {
  15. this.scaleX = this.data.Scale.X;
  16. this.scaleY = this.data.Scale.Y;
  17. }
  18. if (this.data.Rolate && this.data.Rolate.Z) {
  19. this.rolate = this.data.Rolate.Z;
  20. }
  21. if (this.data.Size) {
  22. this.width = this.data.Size.Width;
  23. this.height = this.data.Size.Height;
  24. }
  25. if (this.data.Properties && this.data.Properties.Text) {
  26. if (this.data.Properties.Text instanceof String) {
  27. this.text = this.data.Properties.Text;
  28. }
  29. }
  30. }
  31. get scaleX() {
  32. return this._scaleX;
  33. }
  34. set scaleX(v) {
  35. this._scaleX = v;
  36. if (this.data.Scale) {
  37. this.data.Scale.X = v;
  38. }
  39. this.update();
  40. }
  41. get scaleY() {
  42. return this._scaleY;
  43. }
  44. set scaleY(v) {
  45. this._scaleY = v;
  46. if (this.data.Scale) {
  47. this.data.Scale.Y = v;
  48. }
  49. this.update();
  50. }
  51. get rolate() {
  52. return this._rolate;
  53. }
  54. set rolate(v) {
  55. this._rolate = v;
  56. if (this.data.Rolate) {
  57. this.data.Rolate.Z = v;
  58. }
  59. this.update();
  60. }
  61. set name(v) {
  62. this.data.Name = v;
  63. }
  64. set text(v) {
  65. if (this.data.Properties) {
  66. this.data.Properties.Text = v;
  67. }
  68. }
  69. set x(v) {
  70. this.data.Pos.X = v;
  71. }
  72. set y(v) {
  73. this.data.Pos.Y = v;
  74. }
  75. set width(v) {
  76. if (this.data.Size) {
  77. this.data.Size.Width = v;
  78. }
  79. }
  80. set height(v) {
  81. if (this.data.Size) {
  82. this.data.Size.Height = v;
  83. }
  84. }
  85. onDraw(painter) {
  86. painter.brush.color = new draw_1.SColor(this.color);
  87. painter.font = this.font;
  88. painter.scale(this.scaleX, this.scaleY);
  89. painter.rotate(this.rolate);
  90. this.drawFormatText();
  91. }
  92. }
  93. exports.STextMarkerItem = STextMarkerItem;