VexFlowMeasure.ts 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. import Vex = require("vexflow");
  2. import {StaffMeasure} from "../StaffMeasure";
  3. import {SourceMeasure} from "../../VoiceData/SourceMeasure";
  4. import {Staff} from "../../VoiceData/Staff";
  5. import {StaffLine} from "../StaffLine";
  6. import {SystemLinesEnum} from "../SystemLinesEnum";
  7. import {ClefInstruction} from "../../VoiceData/Instructions/ClefInstruction";
  8. import {KeyInstruction} from "../../VoiceData/Instructions/KeyInstruction";
  9. import {RhythmInstruction} from "../../VoiceData/Instructions/RhythmInstruction";
  10. import {VexFlowConverter, VexFlowRepetitionType, VexFlowBarlineType} from "./VexFlowConverter";
  11. import {VexFlowStaffEntry} from "./VexFlowStaffEntry";
  12. import {Beam} from "../../VoiceData/Beam";
  13. import {GraphicalNote} from "../GraphicalNote";
  14. import {GraphicalStaffEntry} from "../GraphicalStaffEntry";
  15. import StaveConnector = Vex.Flow.StaveConnector;
  16. import StaveNote = Vex.Flow.StaveNote;
  17. import {Logging} from "../../../Common/Logging";
  18. import {unitInPixels} from "./VexFlowMusicSheetDrawer";
  19. import {Tuplet} from "../../VoiceData/Tuplet";
  20. import { RepetitionInstructionEnum } from "../../VoiceData/Instructions/RepetitionInstruction";
  21. import { SystemLinePosition } from "../SystemLinePosition";
  22. export class VexFlowMeasure extends StaffMeasure {
  23. constructor(staff: Staff, staffLine: StaffLine = undefined, sourceMeasure: SourceMeasure = undefined) {
  24. super(staff, sourceMeasure, staffLine);
  25. this.minimumStaffEntriesWidth = -1;
  26. this.resetLayout();
  27. }
  28. // octaveOffset according to active clef
  29. public octaveOffset: number = 3;
  30. // The VexFlow Voices in the measure
  31. public vfVoices: { [voiceID: number]: Vex.Flow.Voice; } = {};
  32. // Call this function (if present) to x-format all the voices in the measure
  33. public formatVoices: (width: number) => void;
  34. // The VexFlow Ties in the measure
  35. public vfTies: Vex.Flow.StaveTie[] = [];
  36. // The repetition instructions given as words or symbols (coda, dal segno..)
  37. public vfRepetitionWords: Vex.Flow.Repetition[] = [];
  38. // The VexFlow Stave (= one measure in a staffline)
  39. private stave: Vex.Flow.Stave;
  40. // VexFlow StaveConnectors (vertical lines)
  41. private connectors: Vex.Flow.StaveConnector[] = [];
  42. // Intermediate object to construct beams
  43. private beams: { [voiceID: number]: [Beam, VexFlowStaffEntry[]][]; } = {};
  44. // VexFlow Beams
  45. private vfbeams: { [voiceID: number]: Vex.Flow.Beam[]; };
  46. // Intermediate object to construct tuplets
  47. private tuplets: { [voiceID: number]: [Tuplet, VexFlowStaffEntry[]][]; } = {};
  48. // VexFlow Tuplets
  49. private vftuplets: { [voiceID: number]: Vex.Flow.Tuplet[]; } = {};
  50. // Sets the absolute coordinates of the VFStave on the canvas
  51. public setAbsoluteCoordinates(x: number, y: number): void {
  52. this.stave.setX(x).setY(y);
  53. }
  54. /**
  55. * Reset all the geometric values and parameters of this measure and put it in an initialized state.
  56. * This is needed to evaluate a measure a second time by system builder.
  57. */
  58. public resetLayout(): void {
  59. // Take into account some space for the begin and end lines of the stave
  60. // Will be changed when repetitions will be implemented
  61. //this.beginInstructionsWidth = 20 / UnitInPixels;
  62. //this.endInstructionsWidth = 20 / UnitInPixels;
  63. this.stave = new Vex.Flow.Stave(0, 0, 0, {
  64. space_above_staff_ln: 0,
  65. space_below_staff_ln: 0,
  66. });
  67. this.updateInstructionWidth();
  68. }
  69. public clean(): void {
  70. this.vfTies.length = 0;
  71. this.connectors = [];
  72. // Clean up instructions
  73. this.resetLayout();
  74. }
  75. /**
  76. * returns the x-width of a given measure line.
  77. * @param line
  78. * @returns {SystemLinesEnum} the x-width
  79. */
  80. public getLineWidth(line: SystemLinesEnum): number {
  81. // FIXME: See values in VexFlow's stavebarline.js
  82. // ToDo: feature/Repetitions
  83. // Extend the lineWidth calculation with all repetition lines.
  84. // Change also the code in VexFlowConverter.line.
  85. const vfline: any = VexFlowConverter.line(line);
  86. switch (vfline) {
  87. case Vex.Flow.StaveConnector.type.SINGLE:
  88. return 1.0 / unitInPixels;
  89. case Vex.Flow.StaveConnector.type.DOUBLE:
  90. return 3.0 / unitInPixels;
  91. default:
  92. return 0;
  93. }
  94. }
  95. /**
  96. * adds the given clef to the begin of the measure.
  97. * This has to update/increase BeginInstructionsWidth.
  98. * @param clef
  99. */
  100. public addClefAtBegin(clef: ClefInstruction): void {
  101. this.octaveOffset = clef.OctaveOffset;
  102. const vfclef: { type: string, size: string, annotation: string } = VexFlowConverter.Clef(clef, "default");
  103. this.stave.addClef(vfclef.type, vfclef.size, vfclef.annotation, Vex.Flow.Modifier.Position.BEGIN);
  104. this.updateInstructionWidth();
  105. }
  106. /**
  107. * adds the given key to the begin of the measure.
  108. * This has to update/increase BeginInstructionsWidth.
  109. * @param currentKey the new valid key.
  110. * @param previousKey the old cancelled key. Needed to show which accidentals are not valid any more.
  111. * @param currentClef the valid clef. Needed to put the accidentals on the right y-positions.
  112. */
  113. public addKeyAtBegin(currentKey: KeyInstruction, previousKey: KeyInstruction, currentClef: ClefInstruction): void {
  114. this.stave.setKeySignature(
  115. VexFlowConverter.keySignature(currentKey),
  116. VexFlowConverter.keySignature(previousKey),
  117. undefined
  118. );
  119. this.updateInstructionWidth();
  120. }
  121. /**
  122. * adds the given rhythm to the begin of the measure.
  123. * This has to update/increase BeginInstructionsWidth.
  124. * @param rhythm
  125. */
  126. public addRhythmAtBegin(rhythm: RhythmInstruction): void {
  127. const timeSig: Vex.Flow.TimeSignature = VexFlowConverter.TimeSignature(rhythm);
  128. this.stave.addModifier(
  129. timeSig,
  130. Vex.Flow.Modifier.Position.BEGIN
  131. );
  132. this.updateInstructionWidth();
  133. }
  134. /**
  135. * adds the given clef to the end of the measure.
  136. * This has to update/increase EndInstructionsWidth.
  137. * @param clef
  138. */
  139. public addClefAtEnd(clef: ClefInstruction): void {
  140. const vfclef: { type: string, size: string, annotation: string } = VexFlowConverter.Clef(clef, "small");
  141. this.stave.setEndClef(vfclef.type, vfclef.size, vfclef.annotation);
  142. this.updateInstructionWidth();
  143. }
  144. public addMeasureLine(lineType: SystemLinesEnum, linePosition: SystemLinePosition): void {
  145. switch (linePosition) {
  146. case SystemLinePosition.MeasureBegin:
  147. switch (lineType) {
  148. case SystemLinesEnum.BoldThinDots:
  149. this.stave.setBegBarType(VexFlowBarlineType.REPEAT_BEGIN);
  150. break;
  151. default:
  152. break;
  153. }
  154. break;
  155. case SystemLinePosition.MeasureEnd:
  156. switch (lineType) {
  157. case SystemLinesEnum.DotsBoldBoldDots:
  158. this.stave.setEndBarType(VexFlowBarlineType.REPEAT_BOTH);
  159. break;
  160. case SystemLinesEnum.DotsThinBold:
  161. this.stave.setEndBarType(VexFlowBarlineType.REPEAT_END);
  162. break;
  163. case SystemLinesEnum.DoubleThin:
  164. this.stave.setEndBarType(VexFlowBarlineType.DOUBLE);
  165. break;
  166. case SystemLinesEnum.ThinBold:
  167. this.stave.setEndBarType(VexFlowBarlineType.END);
  168. break;
  169. default:
  170. break;
  171. }
  172. break;
  173. default:
  174. break;
  175. }
  176. }
  177. public addWordRepetition(repetitionInstruction: RepetitionInstructionEnum): void {
  178. let instruction: VexFlowRepetitionType = undefined;
  179. let position: any = Vex.Flow.Modifier.Position.END;
  180. switch (repetitionInstruction) {
  181. case RepetitionInstructionEnum.Segno:
  182. // create Segno Symbol:
  183. instruction = VexFlowRepetitionType.SEGNO_LEFT;
  184. position = Vex.Flow.Modifier.Position.BEGIN;
  185. break;
  186. case RepetitionInstructionEnum.Coda:
  187. // create Coda Symbol:
  188. instruction = VexFlowRepetitionType.CODA_LEFT;
  189. position = Vex.Flow.Modifier.Position.BEGIN;
  190. break;
  191. case RepetitionInstructionEnum.DaCapo:
  192. instruction = VexFlowRepetitionType.DC;
  193. break;
  194. case RepetitionInstructionEnum.DalSegno:
  195. instruction = VexFlowRepetitionType.DS;
  196. break;
  197. case RepetitionInstructionEnum.Fine:
  198. instruction = VexFlowRepetitionType.FINE;
  199. break;
  200. case RepetitionInstructionEnum.ToCoda:
  201. //instruction = "To Coda";
  202. break;
  203. case RepetitionInstructionEnum.DaCapoAlFine:
  204. instruction = VexFlowRepetitionType.DC_AL_FINE;
  205. break;
  206. case RepetitionInstructionEnum.DaCapoAlCoda:
  207. instruction = VexFlowRepetitionType.DC_AL_CODA;
  208. break;
  209. case RepetitionInstructionEnum.DalSegnoAlFine:
  210. instruction = VexFlowRepetitionType.DS_AL_FINE;
  211. break;
  212. case RepetitionInstructionEnum.DalSegnoAlCoda:
  213. instruction = VexFlowRepetitionType.DS_AL_CODA;
  214. break;
  215. default:
  216. break;
  217. }
  218. if (instruction !== undefined) {
  219. this.stave.addModifier(new Vex.Flow.Repetition(instruction, 0, 0), position);
  220. }
  221. }
  222. /**
  223. * Sets the overall x-width of the measure.
  224. * @param width
  225. */
  226. public setWidth(width: number): void {
  227. super.setWidth(width);
  228. // Set the width of the Vex.Flow.Stave
  229. this.stave.setWidth(width * unitInPixels);
  230. // Force the width of the Begin Instructions
  231. //this.stave.setNoteStartX(this.beginInstructionsWidth * UnitInPixels);
  232. }
  233. /**
  234. * This method is called after the StaffEntriesScaleFactor has been set.
  235. * Here the final x-positions of the staff entries have to be set.
  236. * (multiply the minimal positions with the scaling factor, considering the BeginInstructionsWidth)
  237. */
  238. public layoutSymbols(): void {
  239. //this.stave.format();
  240. }
  241. //public addGraphicalStaffEntry(entry: VexFlowStaffEntry): void {
  242. // super.addGraphicalStaffEntry(entry);
  243. //}
  244. //
  245. //public addGraphicalStaffEntryAtTimestamp(entry: VexFlowStaffEntry): void {
  246. // super.addGraphicalStaffEntryAtTimestamp(entry);
  247. // // TODO
  248. //}
  249. /**
  250. * Draw this measure on a VexFlow CanvasContext
  251. * @param ctx
  252. */
  253. public draw(ctx: Vex.Flow.RenderContext): void {
  254. // If this is the first stave in the vertical measure, call the format
  255. // method to set the width of all the voices
  256. if (this.formatVoices) {
  257. // The width of the voices does not include the instructions (StaveModifiers)
  258. this.formatVoices((this.PositionAndShape.BorderRight - this.beginInstructionsWidth - this.endInstructionsWidth) * unitInPixels);
  259. }
  260. // Force the width of the Begin Instructions
  261. this.stave.setNoteStartX(this.stave.getX() + unitInPixels * this.beginInstructionsWidth);
  262. // Draw stave lines
  263. this.stave.setContext(ctx).draw();
  264. // Draw all voices
  265. for (const voiceID in this.vfVoices) {
  266. if (this.vfVoices.hasOwnProperty(voiceID)) {
  267. this.vfVoices[voiceID].draw(ctx, this.stave);
  268. }
  269. }
  270. // Draw beams
  271. for (const voiceID in this.vfbeams) {
  272. if (this.vfbeams.hasOwnProperty(voiceID)) {
  273. for (const beam of this.vfbeams[voiceID]) {
  274. beam.setContext(ctx).draw();
  275. }
  276. }
  277. }
  278. // Draw tuplets
  279. for (const voiceID in this.vftuplets) {
  280. if (this.vftuplets.hasOwnProperty(voiceID)) {
  281. for (const tuplet of this.vftuplets[voiceID]) {
  282. tuplet.setContext(ctx).draw();
  283. }
  284. }
  285. }
  286. // Draw ties
  287. for (const tie of this.vfTies) {
  288. tie.setContext(ctx).draw();
  289. }
  290. // Draw vertical lines
  291. for (const connector of this.connectors) {
  292. connector.setContext(ctx).draw();
  293. }
  294. // now we can finally set the vexflow x positions back into the osmd object model:
  295. this.setStaffEntriesXPositions();
  296. }
  297. /**
  298. * Add a note to a beam
  299. * @param graphicalNote
  300. * @param beam
  301. */
  302. public handleBeam(graphicalNote: GraphicalNote, beam: Beam): void {
  303. const voiceID: number = graphicalNote.sourceNote.ParentVoiceEntry.ParentVoice.VoiceId;
  304. let beams: [Beam, VexFlowStaffEntry[]][] = this.beams[voiceID];
  305. if (beams === undefined) {
  306. beams = this.beams[voiceID] = [];
  307. }
  308. let data: [Beam, VexFlowStaffEntry[]];
  309. for (const mybeam of beams) {
  310. if (mybeam[0] === beam) {
  311. data = mybeam;
  312. }
  313. }
  314. if (data === undefined) {
  315. data = [beam, []];
  316. beams.push(data);
  317. }
  318. const parent: VexFlowStaffEntry = graphicalNote.parentStaffEntry as VexFlowStaffEntry;
  319. if (data[1].indexOf(parent) < 0) {
  320. data[1].push(parent);
  321. }
  322. }
  323. public handleTuplet(graphicalNote: GraphicalNote, tuplet: Tuplet): void {
  324. const voiceID: number = graphicalNote.sourceNote.ParentVoiceEntry.ParentVoice.VoiceId;
  325. tuplet = graphicalNote.sourceNote.NoteTuplet;
  326. let tuplets: [Tuplet, VexFlowStaffEntry[]][] = this.tuplets[voiceID];
  327. if (tuplets === undefined) {
  328. tuplets = this.tuplets[voiceID] = [];
  329. }
  330. let currentTupletBuilder: [Tuplet, VexFlowStaffEntry[]];
  331. for (const t of tuplets) {
  332. if (t[0] === tuplet) {
  333. currentTupletBuilder = t;
  334. }
  335. }
  336. if (currentTupletBuilder === undefined) {
  337. currentTupletBuilder = [tuplet, []];
  338. tuplets.push(currentTupletBuilder);
  339. }
  340. const parent: VexFlowStaffEntry = graphicalNote.parentStaffEntry as VexFlowStaffEntry;
  341. if (currentTupletBuilder[1].indexOf(parent) < 0) {
  342. currentTupletBuilder[1].push(parent);
  343. }
  344. }
  345. /**
  346. * Complete the creation of VexFlow Beams in this measure
  347. */
  348. public finalizeBeams(): void {
  349. // The following line resets the created Vex.Flow Beams and
  350. // created them brand new. Is this needed? And more importantly,
  351. // should the old beams be removed manually by the notes?
  352. this.vfbeams = {};
  353. for (const voiceID in this.beams) {
  354. if (this.beams.hasOwnProperty(voiceID)) {
  355. let vfbeams: Vex.Flow.Beam[] = this.vfbeams[voiceID];
  356. if (vfbeams === undefined) {
  357. vfbeams = this.vfbeams[voiceID] = [];
  358. }
  359. for (const beam of this.beams[voiceID]) {
  360. const notes: Vex.Flow.StaveNote[] = [];
  361. for (const entry of beam[1]) {
  362. const note: Vex.Flow.StaveNote = (<VexFlowStaffEntry>entry).vfNotes[voiceID];
  363. if (note !== undefined) {
  364. notes.push(note);
  365. }
  366. }
  367. if (notes.length > 1) {
  368. vfbeams.push(new Vex.Flow.Beam(notes, true));
  369. // just a test for coloring the notes:
  370. // for (let note of notes) {
  371. // (<Vex.Flow.StaveNote> note).setStyle({fillStyle: "green", strokeStyle: "green"});
  372. // }
  373. } else {
  374. Logging.log("Warning! Beam with no notes! Trying to ignore, but this is a serious problem.");
  375. }
  376. }
  377. }
  378. }
  379. }
  380. /**
  381. * Complete the creation of VexFlow Tuplets in this measure
  382. */
  383. public finalizeTuplets(): void {
  384. // The following line resets the created Vex.Flow Tuplets and
  385. // created them brand new. Is this needed? And more importantly,
  386. // should the old tuplets be removed manually from the notes?
  387. this.vftuplets = {};
  388. for (const voiceID in this.tuplets) {
  389. if (this.tuplets.hasOwnProperty(voiceID)) {
  390. let vftuplets: Vex.Flow.Tuplet[] = this.vftuplets[voiceID];
  391. if (vftuplets === undefined) {
  392. vftuplets = this.vftuplets[voiceID] = [];
  393. }
  394. for (const tupletBuilder of this.tuplets[voiceID]) {
  395. const tupletStaveNotes: Vex.Flow.StaveNote[] = [];
  396. const tupletStaffEntries: VexFlowStaffEntry[] = tupletBuilder[1];
  397. for (const tupletStaffEntry of tupletStaffEntries) {
  398. tupletStaveNotes.push((tupletStaffEntry).vfNotes[voiceID]);
  399. }
  400. if (tupletStaveNotes.length > 1) {
  401. const notesOccupied: number = 2;
  402. vftuplets.push(new Vex.Flow.Tuplet( tupletStaveNotes,
  403. {
  404. notes_occupied: notesOccupied,
  405. num_notes: tupletStaveNotes.length //, location: -1, ratioed: true
  406. }));
  407. } else {
  408. Logging.log("Warning! Tuplet with no notes! Trying to ignore, but this is a serious problem.");
  409. }
  410. }
  411. }
  412. }
  413. }
  414. public layoutStaffEntry(graphicalStaffEntry: GraphicalStaffEntry): void {
  415. return;
  416. }
  417. public staffMeasureCreatedCalculations(): void {
  418. for (let idx: number = 0, len: number = this.staffEntries.length; idx < len; ++idx) {
  419. const graphicalStaffEntry: VexFlowStaffEntry = (this.staffEntries[idx] as VexFlowStaffEntry);
  420. // create vex flow Notes:
  421. const gnotes: { [voiceID: number]: GraphicalNote[]; } = graphicalStaffEntry.graphicalNotes;
  422. for (const voiceID in gnotes) {
  423. if (gnotes.hasOwnProperty(voiceID)) {
  424. const vfnote: StaveNote = VexFlowConverter.StaveNote(gnotes[voiceID]);
  425. (graphicalStaffEntry as VexFlowStaffEntry).vfNotes[voiceID] = vfnote;
  426. }
  427. }
  428. }
  429. this.finalizeBeams();
  430. this.finalizeTuplets();
  431. for (let idx: number = 0, len: number = this.staffEntries.length; idx < len; ++idx) {
  432. const graphicalStaffEntry: VexFlowStaffEntry = (this.staffEntries[idx] as VexFlowStaffEntry);
  433. const gnotes: { [voiceID: number]: GraphicalNote[]; } = graphicalStaffEntry.graphicalNotes;
  434. // create vex flow voices and add tickables to it:
  435. const vfVoices: { [voiceID: number]: Vex.Flow.Voice; } = this.vfVoices;
  436. for (const voiceID in gnotes) {
  437. if (gnotes.hasOwnProperty(voiceID)) {
  438. if (!(voiceID in vfVoices)) {
  439. vfVoices[voiceID] = new Vex.Flow.Voice({
  440. beat_value: this.parentSourceMeasure.Duration.Denominator,
  441. num_beats: this.parentSourceMeasure.Duration.Numerator,
  442. resolution: Vex.Flow.RESOLUTION,
  443. }).setMode(Vex.Flow.Voice.Mode.SOFT);
  444. }
  445. vfVoices[voiceID].addTickable(graphicalStaffEntry.vfNotes[voiceID]);
  446. }
  447. }
  448. }
  449. }
  450. /**
  451. * Creates a line from 'top' to this measure, of type 'lineType'
  452. * @param top
  453. * @param lineType
  454. */
  455. public lineTo(top: VexFlowMeasure, lineType: any): void {
  456. const connector: StaveConnector = new Vex.Flow.StaveConnector(top.getVFStave(), this.stave);
  457. connector.setType(lineType);
  458. this.connectors.push(connector);
  459. }
  460. /**
  461. * Return the VexFlow Stave corresponding to this StaffMeasure
  462. * @returns {Vex.Flow.Stave}
  463. */
  464. public getVFStave(): Vex.Flow.Stave {
  465. return this.stave;
  466. }
  467. //private increaseBeginInstructionWidth(): void {
  468. // let modifiers: StaveModifier[] = this.stave.getModifiers();
  469. // let modifier: StaveModifier = modifiers[modifiers.length - 1];
  470. // //let padding: number = modifier.getCategory() === "keysignatures" ? modifier.getPadding(2) : 0;
  471. // let padding: number = modifier.getPadding(20);
  472. // let width: number = modifier.getWidth();
  473. // this.beginInstructionsWidth += (padding + width) / UnitInPixels;
  474. //}
  475. //
  476. //private increaseEndInstructionWidth(): void {
  477. // let modifiers: StaveModifier[] = this.stave.getModifiers();
  478. // let modifier: StaveModifier = modifiers[modifiers.length - 1];
  479. // let padding: number = 0;
  480. // let width: number = modifier.getWidth();
  481. // this.endInstructionsWidth += (padding + width) / UnitInPixels;
  482. //
  483. //}
  484. /**
  485. * After re-running the formatting on the VexFlow Stave, update the
  486. * space needed by Instructions (in VexFlow: StaveModifiers)
  487. */
  488. private updateInstructionWidth(): void {
  489. this.beginInstructionsWidth = (this.stave.getNoteStartX() - this.stave.getX()) / unitInPixels;
  490. this.endInstructionsWidth = (this.stave.getX() + this.stave.getWidth() - this.stave.getNoteEndX()) / unitInPixels;
  491. }
  492. /**
  493. * sets the vexflow x positions back into the bounding boxes of the staff entries in the osmd object model.
  494. * The positions are needed for cursor placement and mouse/tap interactions
  495. */
  496. private setStaffEntriesXPositions(): void {
  497. for (let idx3: number = 0, len3: number = this.staffEntries.length; idx3 < len3; ++idx3) {
  498. const gse: VexFlowStaffEntry = (<VexFlowStaffEntry> this.staffEntries[idx3]);
  499. const measure: StaffMeasure = gse.parentMeasure;
  500. const x: number =
  501. gse.getX() -
  502. measure.PositionAndShape.RelativePosition.x -
  503. measure.ParentStaffLine.PositionAndShape.RelativePosition.x -
  504. measure.parentMusicSystem.PositionAndShape.RelativePosition.x;
  505. gse.PositionAndShape.RelativePosition.x = x;
  506. gse.PositionAndShape.calculateAbsolutePosition();
  507. gse.PositionAndShape.calculateAbsolutePositionsOfChildren();
  508. }
  509. }
  510. }