SelectionStartSymbol.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import {PointF2D} from "../../Common/DataObjects/PointF2D";
  2. import {StaffLine} from "./StaffLine";
  3. import {OutlineAndFillStyleEnum} from "./DrawingEnums";
  4. import {GraphicalLine} from "./GraphicalLine";
  5. import {MusicSystem} from "./MusicSystem";
  6. import {GraphicalObject} from "./GraphicalObject";
  7. import {BoundingBox} from "./BoundingBox";
  8. import {CollectionUtil} from "../../Util/CollectionUtil";
  9. export class SelectionStartSymbol extends GraphicalObject {
  10. constructor(system: MusicSystem, xPosition: number) {
  11. super();
  12. const xCoordinate: number = xPosition;
  13. const yCoordinate: number = system.PositionAndShape.AbsolutePosition.y;
  14. const lineThickness: number = 0.4;
  15. const height: number = CollectionUtil.last(system.StaffLines).PositionAndShape.RelativePosition.y + 4;
  16. this.verticalLine = new GraphicalLine(
  17. new PointF2D(xCoordinate, yCoordinate),
  18. new PointF2D(xCoordinate, yCoordinate + height),
  19. lineThickness,
  20. OutlineAndFillStyleEnum.SelectionSymbol
  21. );
  22. for (let idx: number = 0, len: number = system.StaffLines.length; idx < len; ++idx) {
  23. const staffLine: StaffLine = system.StaffLines[idx];
  24. const anchor: PointF2D = new PointF2D(xCoordinate, yCoordinate + staffLine.PositionAndShape.RelativePosition.y);
  25. const arrowPoints: PointF2D[] = new Array(7);
  26. arrowPoints[0].x = anchor.x + 4;
  27. arrowPoints[0].y = anchor.y + 2;
  28. arrowPoints[1].x = anchor.x + 2.5;
  29. arrowPoints[1].y = anchor.y + 0.5;
  30. arrowPoints[2].x = anchor.x + 2.5;
  31. arrowPoints[2].y = anchor.y + 1.3;
  32. arrowPoints[3].x = anchor.x + 1;
  33. arrowPoints[3].y = anchor.y + 1.3;
  34. arrowPoints[4].x = anchor.x + 1;
  35. arrowPoints[4].y = anchor.y + 2.7;
  36. arrowPoints[5].x = anchor.x + 2.5;
  37. arrowPoints[5].y = anchor.y + 2.7;
  38. arrowPoints[6].x = anchor.x + 2.5;
  39. arrowPoints[6].y = anchor.y + 3.5;
  40. this.arrows.push(arrowPoints);
  41. }
  42. this.boundingBox = new BoundingBox(this);
  43. this.boundingBox.AbsolutePosition = new PointF2D(xCoordinate, yCoordinate);
  44. this.boundingBox.BorderLeft = -lineThickness;
  45. this.boundingBox.BorderRight = 4;
  46. this.boundingBox.BorderBottom = height;
  47. }
  48. public verticalLine: GraphicalLine;
  49. public arrows: PointF2D[][];
  50. }