SObjectItem.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { SPoint, SSize } from "@saga-web/draw/lib";
  2. import { SGraphyItem } from "@saga-web/graphy/lib";
  3. /**
  4. * 对象item
  5. *
  6. * @author 郝建龙(1061851420@qq.com)
  7. */
  8. export abstract class SObjectItem extends SGraphyItem {
  9. /** 宽度 */
  10. private _width: number = 64;
  11. get width(): number {
  12. return this._width;
  13. }
  14. set width(v: number) {
  15. if (v > 0) {
  16. if (v != this._width) {
  17. let w = this._width;
  18. this._width = v;
  19. this.onResize(
  20. new SSize(w, this._height),
  21. new SSize(this._width, this._height)
  22. );
  23. }
  24. }
  25. }
  26. /** 高度 */
  27. private _height: number = 64;
  28. get height(): number {
  29. return this._height;
  30. }
  31. set height(v: number) {
  32. if (v > 0) {
  33. if (v != this._height) {
  34. let h = this._height;
  35. this._height = v;
  36. this.onResize(
  37. new SSize(this._width, h),
  38. new SSize(this._width, this._height)
  39. );
  40. }
  41. }
  42. }
  43. /** 原点 */
  44. origin = new SPoint();
  45. /**
  46. * 宽高发发生变化
  47. *
  48. * @param oldSize 改之前的大小
  49. * @param newSize 改之后大小
  50. * */
  51. protected onResize(oldSize: SSize, newSize: SSize) {} // Function onResize()
  52. } // Class SObjectItem