Ejemplo n.º 1
0
        /** Creates new StaffSystem from the parentInput's input stream.
         * The next object in the input stream must be of this type.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream
         */
        static public StaffSystem newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, "LIST");

            riffInput.requireFOURCC(RIFF_ID);

            StaffSystem staffSystem = new StaffSystem
                                          (RiffStaffSystemHeader.newInstance(riffInput));

            // debug: check for NIFFStaffGrouping

            while (riffInput.getBytesRemaining() > 0)
            {
                Staff staff;
                if ((staff = RiffStaff.maybeNew(riffInput)) != null)
                {
                    // Call addChild() which will set the child's parent to this.
                    staffSystem.addStaff(staff);
                }
                // debug: must check for NIFFFontSymbol, etc.
                else
                {
                    // Did not recognize the chunk type, so skip
                    riffInput.skipChunk();
                }
            }

            return(staffSystem);
        }
Ejemplo n.º 2
0
        public int getSymbolCount()
        {
            if (_symbolPositioner != null)
            {
                return(_symbolPositioner.getSymbolCount());
            }

            // Create a new SymbolPositioner and add a position at each quarter note.
            _symbolPositioner = new SymbolPositioner();
            Rational quarter = new Rational(1, 4);

            for (IntRatio r = new IntRatio(0, 1);
                 r.compareTo(getDuration()) < 0;
                 r.add(quarter))
            {
                _symbolPositioner.add(new Rational(r), 0);
            }

            // Go through the entire staff system and for every measure which
            //   has the same start time and duration as this, set its
            //   SymbolPositioner to the new one and call its addToSymbolPositioner
            StaffSystem system = getParentStaff().getParentSystem();

            for (int staffIndex = 0; staffIndex < system.getStaffCount(); ++staffIndex)
            {
                Staff staff = system.getStaff(staffIndex);
                for (int measureIndex = 0;
                     measureIndex < staff.getMeasureStartCount();
                     ++measureIndex)
                {
                    MeasureStartTimeSlice measure = staff.getMeasureStart(measureIndex);
                    if (measure.getStartTime().Equals(getStartTime()) &&
                        measure.getDuration().Equals(getDuration()))
                    {
                        // This is an equivalent measure to this one in another
                        //   staff (or it is this same measure.
                        measure._symbolPositioner = _symbolPositioner;
                        measure.addToSymbolPositioner();

                        // There should not be any more measures in this staff
                        //   with the same start time.
                        break;
                    }
                }
            }

            return(_symbolPositioner.getSymbolCount());
        }
Ejemplo n.º 3
0
        /** Get the hotspot for this object in screen coordinates.
         */
        public FinalPoint getScreenHotspot()
        {
            if (_screenHotspot != null)
            {
                return(_screenHotspot);
            }

            // Compute the position by locating the start time within the staff duration.
            // DEBUG: This all assumes that the measures in each staff of the staff
            //   system have the same number of measures.  Maybe check this.
            StaffSystem parentSystem = getParentStaff().getParentSystem();

            _screenHotspot = new FinalPoint
                                 (getParentStaff().getScreenHotspot(),
                                 (int)((_startTime.doubleValue() - parentSystem.getStartTime().doubleValue())
                                       * parentSystem.getWidth() /
                                       parentSystem.getDuration().doubleValue()), 0);

            return(_screenHotspot);
        }
Ejemplo n.º 4
0
        /** Creates new StaffSystem from the parentInput's input stream.
         * The next object in the input stream must be of this type.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream
         */
        public static StaffSystem newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, "LIST");
              riffInput.requireFOURCC(RIFF_ID);

              StaffSystem staffSystem = new StaffSystem
             (RiffStaffSystemHeader.newInstance(riffInput));
              // debug: check for NIFFStaffGrouping

              while (riffInput.getBytesRemaining() > 0) {
            Staff staff;
            if ((staff = RiffStaff.maybeNew(riffInput)) != null)
              // Call addChild() which will set the child's parent to this.
              staffSystem.addStaff(staff);
            // debug: must check for NIFFFontSymbol, etc.
            else
              // Did not recognize the chunk type, so skip
              riffInput.skipChunk();
              }

              return staffSystem;
        }
Ejemplo n.º 5
0
 /** Add the given staffSystem to the StaffSystem list.
  * This does not call invalidate(), but you may need to before displaying.
  *
  * @param staffSystem  the StaffSystem to add.  It is an error if
  *        this is already the child of an object.
  * @throws HeirarchyException if the staffSystem has already
  *      been added as a child to another object.
  * @see #invalidate
  */
 public void addSystem(StaffSystem staffSystem)
 {
     addChild(staffSystem);
 }
Ejemplo n.º 6
0
 /** Add the given staffSystem to the StaffSystem list.
  * This does not call invalidate(), but you may need to before displaying.
  *
  * @param staffSystem  the StaffSystem to add.  It is an error if
  *        this is already the child of an object.
  * @throws HeirarchyException if the staffSystem has already
  *      been added as a child to another object.
  * @see #invalidate
  */
 public void addSystem(StaffSystem staffSystem)
 {
     addChild(staffSystem);
 }