Пример #1
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());
        }