Class SingleStaffPart

java.lang.Object
org.wmn4j.notation.SingleStaffPart
All Implemented Interfaces:
Iterable<Measure>, Part

public final class SingleStaffPart extends Object implements Part
Represents a part with a single staff in a score.

This class is immutable.

  • Method Details

    • of

      public static SingleStaffPart of(String name, Staff staff)
      Returns a part with a single staff with the given name and staff.
      Parameters:
      name - the name of the part
      staff - the staff of this part
      Returns:
      a part with a single staff with the given name and measures
    • of

      public static SingleStaffPart of(Map<Part.Attribute,String> partAttributes, Staff staff)
      Returns a part with a single staff with the given attributes and staff.
      Parameters:
      partAttributes - a map of attributes to be set for this part
      staff - the staff of this part
      Returns:
      a part with a single staff with the given attributes and measures
    • getName

      public Optional<String> getName()
      Description copied from interface: Part
      Returns the name of this part or empty if the part has no name.
      Specified by:
      getName in interface Part
      Returns:
      name of this part
    • isMultiStaff

      public boolean isMultiStaff()
      Description copied from interface: Part
      Returns true if this part has multiple staves.
      Specified by:
      isMultiStaff in interface Part
      Returns:
      true if this part has multiple staves
    • getStaffCount

      public int getStaffCount()
      Description copied from interface: Part
      Returns the number of staves in this part.
      Specified by:
      getStaffCount in interface Part
      Returns:
      number of staves in this part
    • getStaffNumbers

      public List<Integer> getStaffNumbers()
      Description copied from interface: Part
      Returns the numbers of the staves in this part in ascending order.
      Specified by:
      getStaffNumbers in interface Part
      Returns:
      the numbers of the staves in this part in ascending order
    • getMeasure

      public Measure getMeasure(int number)
      Returns the measure with the given number.
      Parameters:
      number - number of measure to return
      Returns:
      measure with the given number
    • getMeasure

      public Measure getMeasure(int staffNumber, int measureNumber)
      Description copied from interface: Part
      Returns the measure with the given number from the staff with the given number.
      Specified by:
      getMeasure in interface Part
      Parameters:
      staffNumber - the number of the staff from which the get the measure
      measureNumber - the number of the measure
      Returns:
      the measure with measureNumber from the staff with staffNumber
    • getStaff

      public Staff getStaff()
      Returns the staff in this part.
      Returns:
      the only staff in this part
    • getPartIterator

      public PartIterator getPartIterator()
      Description copied from interface: Part
      Returns a part iterator that can be used to iterate through the measures in this part.
      Specified by:
      getPartIterator in interface Part
      Returns:
      an iterator that can be used to iterate through the measures in this part
    • getPartIterator

      public PartIterator getPartIterator(int firstMeasure, int lastMeasure)
      Description copied from interface: Part
      Returns a part iterator that can be used to iterate through the measures in this part.
      Specified by:
      getPartIterator in interface Part
      Parameters:
      firstMeasure - the measure number of the first measure to be included in iteration
      lastMeasure - the measure number of the last measure to be included in iteration
      Returns:
      an iterator that can be used to iterate through the measures in this part
    • getAttribute

      public Optional<String> getAttribute(Part.Attribute attribute)
      Description copied from interface: Part
      Returns the given attribute. If the attribute is not present, returns empty.
      Specified by:
      getAttribute in interface Part
      Parameters:
      attribute - the attribute to return from this part
      Returns:
      the value of the attribute, or empty if the attribute is not set
    • getStaff

      public Staff getStaff(int staffNumber)
      Description copied from interface: Part
      Returns the staff with the given number.
      Specified by:
      getStaff in interface Part
      Parameters:
      staffNumber - the number of the staff to return
      Returns:
      the staff with the given number
    • getMeasureCount

      public int getMeasureCount()
      Description copied from interface: Part
      Returns the number of measures in this part. The count is based on the measure numbers, so even if a part has multiple staves its measure count is the largest measure number.
      Specified by:
      getMeasureCount in interface Part
      Returns:
      number of measures in the part. If there is a pickup measure, it is included in the count.
    • getFullMeasureCount

      public int getFullMeasureCount()
      Description copied from interface: Part
      Returns the number of complete measures. Does not include the pickup measure if there is one.
      Specified by:
      getFullMeasureCount in interface Part
      Returns:
      the number of measures excluding the pickup measure
    • toString

      public String toString()
      Overrides:
      toString in class Object