action.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import { GenericObject } from "../../objects/generic-object";
  2. import { GEO_FILE } from "../../../enums/geo-file-enum";
  3. export class Action {
  4. constructor(genericObject) {
  5. this.id = genericObject.id;
  6. this.type = genericObject.elementClass;
  7. this.definition = this.r(
  8. genericObject.definitions.map(x => x.id).toString()
  9. );
  10. this.list = this.r(
  11. genericObject.dependentsOnThis.map(x => x.id).toString()
  12. );
  13. this.label = genericObject.labelIgeom;
  14. this.defined = genericObject.defined;
  15. this.color = genericObject.color;
  16. this.hidden = genericObject.visible ? 0 : 1;
  17. this.pixel = "";
  18. this.font = "";
  19. this.labelColor = genericObject.labelColor;
  20. this.genericObject = genericObject;
  21. }
  22. do() {
  23. const genericObject = new GenericObject(this.id);
  24. genericObject.color = this.color;
  25. genericObject.elementClass = this.type;
  26. genericObject.definition = this.definition;
  27. genericObject.list = this.list;
  28. genericObject.label = this.label;
  29. genericObject.visible = this.hidden == 0;
  30. }
  31. toMap() {
  32. const map = new Map();
  33. map.set("key", "value");
  34. return map;
  35. }
  36. fromMapList(map) { }
  37. toString() {
  38. return (
  39. "{" +
  40. `${this.d(GEO_FILE.ID, this.id)}, ` +
  41. `${this.d(GEO_FILE.TYPE, this.type)}, ` +
  42. `${this.d(GEO_FILE.DEFINITION, this.definition)}, ` +
  43. `${this.d(GEO_FILE.LIST, this.list)}, ` +
  44. `${this.d(GEO_FILE.LABEL, this.label)}, ` +
  45. `${this.d(GEO_FILE.DEFINED, this.defined)}, ` +
  46. `${this.d(GEO_FILE.COLOR, this.color)}, ` +
  47. `${this.d(GEO_FILE.HIDDEN, this.hidden)}, ` +
  48. `${this.d(GEO_FILE.PIXEL, this.pixel)}, ` +
  49. `${this.d(GEO_FILE.FONT, this.font)}, ` +
  50. `${this.d(GEO_FILE.LABEL_COLOR, this.labelColor)}` +
  51. `}!\n`
  52. );
  53. }
  54. d(key, value) {
  55. return `${key}:${value}`;
  56. }
  57. r(str) {
  58. return str.replace(/,/g, " ");
  59. }
  60. rehydrate() {
  61. this.id = this.genericObject.id;
  62. this.type = this.genericObject.elementClass;
  63. this.definition = this.r(
  64. this.genericObject.definitions.map(x => x.id).toString()
  65. );
  66. this.list = this.r(
  67. this.genericObject.dependentsOnThis.map(x => x.id).toString()
  68. );
  69. this.label = this.genericObject.labelIgeom;
  70. this.defined = this.genericObject.defined;
  71. this.color = this.genericObject.color;
  72. this.hidden = this.genericObject.visible ? 0 : 1;
  73. this.pixel = "";
  74. this.font = "";
  75. this.labelColor = "";
  76. }
  77. }