VexFlowStaffEntry.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. var __extends = (this && this.__extends) || function (d, b) {
  3. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4. function __() { this.constructor = d; }
  5. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6. };
  7. var GraphicalStaffEntry_1 = require("../GraphicalStaffEntry");
  8. var VexFlowStaffEntry = (function (_super) {
  9. __extends(VexFlowStaffEntry, _super);
  10. function VexFlowStaffEntry(measure, sourceStaffEntry, staffEntryParent) {
  11. _super.call(this, measure, sourceStaffEntry, staffEntryParent);
  12. // The Graphical Notes belonging to this StaffEntry, sorted by voiceID
  13. this.graphicalNotes = {};
  14. // The corresponding VexFlow.StaveNotes
  15. this.vfNotes = {};
  16. }
  17. /**
  18. *
  19. * @returns {number} the x-position (in units) of this Staff Entry
  20. */
  21. VexFlowStaffEntry.prototype.getX = function () {
  22. var x = 0;
  23. var n = 0;
  24. var vfNotes = this.vfNotes;
  25. for (var voiceId in vfNotes) {
  26. if (vfNotes.hasOwnProperty(voiceId)) {
  27. x += (vfNotes[voiceId].getNoteHeadBeginX() + vfNotes[voiceId].getNoteHeadEndX()) / 2;
  28. n += 1;
  29. }
  30. }
  31. return x / n / 10.0;
  32. };
  33. return VexFlowStaffEntry;
  34. }(GraphicalStaffEntry_1.GraphicalStaffEntry));
  35. exports.VexFlowStaffEntry = VexFlowStaffEntry;