GraphicalChordSymbolContainer.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import {TextAlignmentEnum} from "../../Common/Enums/TextAlignment";
  2. import {Label} from "../Label";
  3. import {GraphicalLabel} from "./GraphicalLabel";
  4. import {ChordSymbolContainer} from "../VoiceData/ChordSymbolContainer";
  5. import {BoundingBox} from "./BoundingBox";
  6. import {GraphicalObject} from "./GraphicalObject";
  7. import {PointF2D} from "../../Common/DataObjects/PointF2D";
  8. import {EngravingRules} from "./EngravingRules";
  9. import { KeyInstruction } from "../VoiceData/Instructions/KeyInstruction";
  10. export class GraphicalChordSymbolContainer extends GraphicalObject {
  11. private chordSymbolContainer: ChordSymbolContainer;
  12. private graphicalLabel: GraphicalLabel;
  13. private rules: EngravingRules;
  14. constructor(chordSymbolContainer: ChordSymbolContainer, parent: BoundingBox, textHeight: number,
  15. keyInstruction: KeyInstruction, transposeHalftones: number, rules: EngravingRules) {
  16. super();
  17. this.chordSymbolContainer = chordSymbolContainer;
  18. this.boundingBox = new BoundingBox(this, parent);
  19. this.calculateLabel(textHeight, transposeHalftones, keyInstruction);
  20. this.rules = rules;
  21. }
  22. public get GetChordSymbolContainer(): ChordSymbolContainer {
  23. return this.chordSymbolContainer;
  24. }
  25. public get GetGraphicalLabel(): GraphicalLabel {
  26. return this.graphicalLabel;
  27. }
  28. private calculateLabel(textHeight: number, transposeHalftones: number, keyInstruction: KeyInstruction): void {
  29. const text: string = ChordSymbolContainer.calculateChordText(this.chordSymbolContainer, transposeHalftones, keyInstruction);
  30. this.graphicalLabel = new GraphicalLabel(new Label(text), textHeight, TextAlignmentEnum.CenterBottom, this.rules, this.boundingBox);
  31. this.graphicalLabel.PositionAndShape.RelativePosition = new PointF2D(0.0, 0.0);
  32. }
  33. }