mtd.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. if (typeof b !== "function" && b !== null)
  11. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  12. extendStatics(d, b);
  13. function __() { this.constructor = d; }
  14. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15. };
  16. })();
  17. Object.defineProperty(exports, "__esModule", { value: true });
  18. exports.SVGmtd = void 0;
  19. var Wrapper_js_1 = require("../Wrapper.js");
  20. var mtd_js_1 = require("../../common/Wrappers/mtd.js");
  21. var mtd_js_2 = require("../../../core/MmlTree/MmlNodes/mtd.js");
  22. var SVGmtd = (function (_super) {
  23. __extends(SVGmtd, _super);
  24. function SVGmtd() {
  25. return _super !== null && _super.apply(this, arguments) || this;
  26. }
  27. SVGmtd.prototype.placeCell = function (x, y, W, H, D) {
  28. var bbox = this.getBBox();
  29. var h = Math.max(bbox.h, .75);
  30. var d = Math.max(bbox.d, .25);
  31. var calign = this.node.attributes.get('columnalign');
  32. var ralign = this.node.attributes.get('rowalign');
  33. var alignX = this.getAlignX(W, bbox, calign);
  34. var alignY = this.getAlignY(H, D, h, d, ralign);
  35. this.place(x + alignX, y + alignY);
  36. return [alignX, alignY];
  37. };
  38. SVGmtd.prototype.placeColor = function (x, y, W, H) {
  39. var adaptor = this.adaptor;
  40. var child = this.firstChild();
  41. if (child && adaptor.kind(child) === 'rect' && adaptor.getAttribute(child, 'data-bgcolor')) {
  42. adaptor.setAttribute(child, 'x', this.fixed(x));
  43. adaptor.setAttribute(child, 'y', this.fixed(y));
  44. adaptor.setAttribute(child, 'width', this.fixed(W));
  45. adaptor.setAttribute(child, 'height', this.fixed(H));
  46. }
  47. };
  48. SVGmtd.kind = mtd_js_2.MmlMtd.prototype.kind;
  49. return SVGmtd;
  50. }((0, mtd_js_1.CommonMtdMixin)(Wrapper_js_1.SVGWrapper)));
  51. exports.SVGmtd = SVGmtd;
  52. //# sourceMappingURL=mtd.js.map