GraphicalChordSymbolContainer.ts 1.5 KB

123456789101112131415161718192021222324252627282930
  1. import {TextAlignment} 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. export class GraphicalChordSymbolContainer extends GraphicalObject {
  9. private chordSymbolContainer: ChordSymbolContainer;
  10. private graphicalLabel: GraphicalLabel;
  11. constructor(chordSymbolContainer: ChordSymbolContainer, parent: BoundingBox, textHeight: number, transposeHalftones: number) {
  12. super();
  13. this.chordSymbolContainer = chordSymbolContainer;
  14. this.boundingBox = new BoundingBox(this, parent);
  15. this.calculateLabel(textHeight, transposeHalftones);
  16. }
  17. public get GetChordSymbolContainer(): ChordSymbolContainer {
  18. return this.chordSymbolContainer;
  19. }
  20. public get GetGraphicalLabel(): GraphicalLabel {
  21. return this.graphicalLabel;
  22. }
  23. private calculateLabel(textHeight: number, transposeHalftones: number): void {
  24. let text: string = ChordSymbolContainer.calculateChordText(this.chordSymbolContainer, transposeHalftones);
  25. this.graphicalLabel = new GraphicalLabel(new Label(text), textHeight, TextAlignment.CenterBottom, this.boundingBox);
  26. this.graphicalLabel.PositionAndShape.RelativePosition = new PointF2D(0.0, 0.0);
  27. this.boundingBox.ChildElements.push(this.graphicalLabel.PositionAndShape);
  28. }
  29. }