Class Staff

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

public class Staff
extends ParallelCollection
implements XMLWritable
Staff
A Staff is a ParallelCollection of up to any number of Tracks, which get drawn on the same staff, played by the same instrument.
JMSL Notation Project
Author:
Nick Didkovsky, copyright 2000 Nick Didkovsky
  • Field Details

  • Constructor Details

  • Method Details

    • getExtendedLinesAbove

      public int getExtendedLinesAbove()
      Additional staff lines above the standard 5
      Returns:
      the extendedLinesAbove
    • setExtendedLinesAbove

      public void setExtendedLinesAbove​(int extendedLinesAbove)
      Additional staff lines above the standard 5
      Parameters:
      extendedLinesAbove - the extendedLinesAbove to set
    • getExtendedLinesBelow

      public int getExtendedLinesBelow()
      Additional staff lines below the standard 5
      Returns:
      the extendedLinesbelow
    • setExtendedLinesBelow

      public void setExtendedLinesBelow​(int extendedLinesbelow)
      Additional staff lines below the standard 5
      Parameters:
      extendedLinesbelow - the extendedLinesbelow to set
    • isStaffVisible

      public boolean isStaffVisible()
      Returns:
      the isStaffVisible
    • setStaffVisible

      public void setStaffVisible​(boolean isStaffVisible)
      Parameters:
      isStaffVisible - the isStaffVisible to set
    • getStaffIndex

      public int getStaffIndex()
    • setInstrumentIndex

      public void setInstrumentIndex​(int index)
    • getInstrumentIndex

      public int getInstrumentIndex()
    • setInstrument

      public void setInstrument()
    • setClefSetByHand

      public void setClefSetByHand​(boolean flag)
      Used to signal the end of a run of clef changes.
    • addTrack

      public Track addTrack()
      add a new Track to this staff. Staff has two tracks when constructed, so only call this if you want 3 or more tracks on a staff
      Returns:
      the new track
    • addTrack

      public Track addTrack​(Instrument ins)
      add a new Track to this staff, handing it indicated instrument. Staff has two tracks when constructed, so only call this if you want 3 or more tracks on a staff
      Returns:
      the new track
    • getClefSetByHand

      public boolean getClefSetByHand()
      Used to signal the end of a run of clef changes. Ex. If user sets clef of measure 10 to bass, then changes clef of measure 7 to alto, measures 7, 8, and 9 will change to alto, stopping at 10 which was manally changed.
    • setKeySignatureSetByHand

      public void setKeySignatureSetByHand​(boolean flag)
      Used to signal the end of a run of key changes. If true for a staff in measure n, then changing a keysignature in measures less than n will not affect the keysig measure n or measures later than n
    • getKeySignatureSetByHand

      public boolean getKeySignatureSetByHand()
      Used to signal the end of a run of clef changes. If true for a staff in measure n, then changing a keysignature in measures less than n will not affect measure n or measures later than n
    • getInsIndexSetByHand

      public boolean getInsIndexSetByHand()
    • setInsIndexSetByHand

      public void setInsIndexSetByHand​(boolean f)
    • getKeySignature

      public KeySignature getKeySignature()
    • setKeySignature

      public void setKeySignature​(KeySignature ks)
    • setDisplayClef

      public void setDisplayClef​(boolean flag)
      /** used by layout manager to indicate whether or not this should render and make room for a clef
    • getDisplayClef

      public boolean getDisplayClef()
      Returns:
      whether or not this should render and make room for a clef
    • setDisplayTimeSig

      public void setDisplayTimeSig​(boolean flag)
      used by layout manager to indicate whether or not this should render and make room for a time sig
    • getDisplayTimeSig

      public boolean getDisplayTimeSig()
      Returns:
      whether or not this should render and make room for a time sig
    • setDisplayKeySignature

      public void setDisplayKeySignature​(boolean flag)
      used by layout manager to indicate whether or not this should render and make room for a key sig
    • getDisplayKeySignature

      public boolean getDisplayKeySignature()
      Returns:
      whether or not this should render and make room for a key sig
    • isMultiTrack

      public boolean isMultiTrack()
      Returns:
      true if this staff holds more than one non-empty track. (ie NOT just a synonym for size() > 1)
    • getNonEmptyTrackCount

      public int getNonEmptyTrackCount()
      Returns:
      number of non-empty tracks contained in this staff (ie NOT just a synonym for size())
    • getMeasure

      public Measure getMeasure()
      Returns:
      the measure to which this Staff belongs
    • getTrack

      public Track getTrack​(int n)
      Returns:
      Track at indicated index
    • getScore

      public Score getScore()
      Returns:
      parent score
    • getMaxDuration

      public double getMaxDuration()
    • setClef

      public void setClef​(Clef clef)
    • getClef

      public Clef getClef()
    • getSpaceAbove

      public double getSpaceAbove()
      for layout; unscaled space above staff
    • getSpaceBelow

      public double getSpaceBelow()
      for layout; unscaled space below staff
    • getStaffHeight

      public static double getStaffHeight()
      for layout; unscaled distance between top and bottom line of staff
    • getTotalHeight

      public double getTotalHeight()
      Returns:
      sum of space above, below, and the staff itself
    • setSpaceAbove

      public void setSpaceAbove​(double d)
      for layout; set unscaled distance above staff
    • setSpaceBelow

      public void setSpaceBelow​(double d)
      for layout; set unscaled distance below staff
    • addToSpaceAbove

      public void addToSpaceAbove​(double delta)
    • addToSpaceBelow

      public void addToSpaceBelow​(double delta)
    • setDrawingAnchor

      public void setDrawingAnchor​(java.awt.geom.Point2D p)
      drawingAnchor is the (x,y) point at top left of drawable object, set by layout manager, changes as measures stretch, compress, realign, etc
    • getDrawingAnchor

      public java.awt.geom.Point2D getDrawingAnchor()
      drawingAnchor is the (x,y) point at top left of drawable object, set by layout manager, changes as measures stretch, compress, realign, etc
    • layoutChildren

      public void layoutChildren()
      Set the drawingAnchor for each Track equal to the left of the top line of the staff itelf
    • levelOfTopLine

      public double levelOfTopLine()
      Returns:
      y position of top line of Staff
    • within

      public boolean within​(java.awt.Point p)
      Returns:
      true if point is within bounding box of this staff
    • getInsertionIndex

      public int getInsertionIndex​(java.awt.geom.Point2D p, int trackIndex)
      return the index at which a Note is to be inserted, based on location p. 0 if before first element (ie become element 0 and push the rest up as a Java Vector insert is implemented). Selects based on active track.
    • getNearestLevel

      public int getNearestLevel​(java.awt.Point p)
      Returns:
      the level nearest to the Point.y
    • getBoundingInfo

      public java.util.Properties getBoundingInfo()
    • 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
    • closeStaffPropertiesXML

      public void closeStaffPropertiesXML​(java.io.PrintWriter out)
      Parameters:
      out -
    • writeStaffPropertiesXML

      public void writeStaffPropertiesXML​(java.io.PrintWriter out)
      Parameters:
      out -
    • 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)
    • setMaxKeySignatureWidthInMeasure

      public void setMaxKeySignatureWidthInMeasure​(int maxKeySignatureWidthInMeasure)
      Parameters:
      maxKeySignatureWidthInMeasure - The maxKeySignatureWidthInMeasure to set.