Class Track

java.lang.Object
All Implemented Interfaces:
Composable, Playable, XMLWritable, java.lang.Runnable

public class Track
extends MusicList
implements XMLWritable
Track
A Track is a MusicList of Note objects
JMSL Notation Project
Author:
Nick Didkovsky, copyright 2000 Nick Didkovsky
  • Field Details

    • TOLERABLE_ERROR

      public static final double TOLERABLE_ERROR
  • Constructor Details

    • Track

      public Track​(Staff staff, int num)
    • Track

      public Track​(Staff staff, int num, Instrument ins)
  • Method Details

    • getWedgeShiftY

      public double getWedgeShiftY()
      shift cresc or decrec wedge up or down. The track of the first note of the wedge determines this shift
      Returns:
      the wedgeShiftY
    • setWedgeShiftY

      public void setWedgeShiftY​(double wedgeShiftY)
      shift cresc or decrec wedge up or down
      Parameters:
      wedgeShiftY - the wedgeShiftY to set
    • isBottomTrack

      public boolean isBottomTrack()
      legacy multitrack orientation: tracks numbered 0..numTracks/2 are stem down (bottom) and tracks with indexes greater than numStaves/2 are stem up (top) new way as of 2020-09-15 puts even numbered tracks in the bottom and odd numbered tracks in the top, so 0 and 1 are always interpreted the same
    • setInstrument

      public void setInstrument​(Instrument ins)
      Sets Instrument like superclass, also translates DimensionNameSpaces of existing Notes to DimensionNameSpace of Instrument
      Overrides:
      setInstrument in class MusicJob
    • getTrackIndex

      public int getTrackIndex()
      Returns:
      Track index (first track of a staff is 0, next is 1...
    • getStaff

      public Staff getStaff()
      Returns:
      the Staff to which this track belongs
    • getScore

      public Score getScore()
    • getNote

      public Note getNote​(int n)
    • getUserBeans

      public java.util.Vector getUserBeans()
    • addUserBean

      public void addUserBean​(java.lang.Object bean)
      Add a bean to a Staff. A bean is an object with primitive fields and matching getters and setters. These will be restored when loaded.
      Parameters:
      bean - The bean to add.
    • removeUserBean

      public void removeUserBean​(java.lang.Object bean)
    • setDrawingAnchor

      public void setDrawingAnchor​(java.awt.geom.Point2D p)
      drawingAnchor is the (x,y) point at top left of this Track's staff, equal to Note level 132
    • getDrawingAnchor

      public java.awt.geom.Point2D getDrawingAnchor()
    • isEmpty

      public boolean isEmpty()
    • size

      public int size()
      Description copied from class: MusicJob
      You can add children to a MusicJob with the add(Composable) method. size() returns the number of children added. Subclasses of MusicJob: MusicShape.size() returns the number of elements added ParallelCollection.size() returns the number of Composable children to be launched in parallel SequentialCollection.size() returns the number of Composable children to be launched in sequence
      Overrides:
      size in class MusicJob
      Returns:
      number of children add()'ed
    • hasElementsLaterThan

      public boolean hasElementsLaterThan​(double time)
    • getDuration

      public double getDuration()
      Description copied from class: MusicJob
      returns duration, duration is used optionally
      Overrides:
      getDuration in class MusicJob
      Returns:
      sum of getDurationData() of elements in this Track
    • getStartTimeOfNote

      public double getStartTimeOfNote​(Note note)
      Returns:
      the absolute time in this Track when Note is scheduled to start
    • getEndTimeOfNote

      public double getEndTimeOfNote​(Note note)
      Returns:
      the absolute time in this Track when Note is scheduled to stop (its startTime + its duration)
    • getFirstNoteAfterTime

      public Note getFirstNoteAfterTime​(double startTime)
      Returns:
      the First Note whose starting time is >= startTime. ie second qtr note if startTime=1.0
    • getInsertionIndexForTime

      public int getInsertionIndexForTime​(double startTime)
    • getLastNoteBeforeTime

      public Note getLastNoteBeforeTime​(double endTime)
      Returns:
      last note whose starttime is <= endTime, returns highest note of chord if last note is a chord root
    • getDurationReport

      public java.lang.String getDurationReport()
    • layoutChildren

      public void layoutChildren()
    • layoutChildren

      public void layoutChildren​(boolean setAnchors)
    • setMultitrackRestAdjustmentY

      public void setMultitrackRestAdjustmentY​(double adjustment)
      you may nudge the rests of this track up (-) or down (+) so that they can be repositioned in a multitrack setting
      Parameters:
      adjustmentY -
    • getMultitrackRestAdjustmentY

      public double getMultitrackRestAdjustmentY()
      Returns:
      the multiTrackRestAdjustmentY
    • manageAccidentals

      public void manageAccidentals​(AccidentalLevelManager accLevelManager, Note n)
    • resetAccidentalLevelManager

      public AccidentalLevelManager resetAccidentalLevelManager()
    • insertNote

      public void insertNote​(Note note, int index)
      Insert a note at specified insertion index. Note becomes the indexth note in track.
    • insertNote

      public void insertNote​(Note note)
      Insert a note at current insertion index, and increment insertion index so next note comes after
    • setInsertionIndex

      public void setInsertionIndex​(int i)
    • deleteNote

      public void deleteNote​(Note note)
      delete a Note from this track
      If isMonoNote, delete with removeElement()
      If isInterval, delete it from the chord handle's vector of intervals If isHandle of chord, removeElement, set new handle to first interval and insert that.
    • render

      public void render​(java.awt.Graphics g, double zoom)
    • getHierarchy

      public java.lang.String getHierarchy()
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • writeXML

      public void writeXML​(java.io.PrintWriter out) throws java.io.IOException
      Specified by:
      writeXML in interface XMLWritable
      Throws:
      java.io.IOException