/** Return the duration of this staff system. This is the start time * difference between the first and last measure start time slices in the * first staff plus the duration of the last measure. (It is assumed that all * staves in the staff system have the same duration.) * This is used to compute the screen hotspots of the measure starts. */ public Rational getDuration() { if (_duration != null) { return(_duration); } if (getStaffCount() == 0 || getStaff(0).getMeasureStartCount() == 0) { // There are no staffs or time slices! This is unexpected. Just return 0. // DEBUG: maybe this should be handled more gracefully. _duration = new Rational(0, 1); return(_duration); } Staff staff = getStaff(0); MeasureStartTimeSlice lastMeasureStart = staff.getMeasureStart(staff.getMeasureStartCount() - 1); IntRatio result = new IntRatio(lastMeasureStart.getStartTime()); result.sub(getStartTime()); result.add(lastMeasureStart.getDuration()); _duration = new Rational(result); return(_duration); }
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()); }
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(); }
/** Return the duration of this staff system. This is the start time * difference between the first and last measure start time slices in the * first staff plus the duration of the last measure. (It is assumed that all * staves in the staff system have the same duration.) * This is used to compute the screen hotspots of the measure starts. */ public Rational getDuration() { if (_duration != null) return _duration; if (getStaffCount() == 0 || getStaff(0).getMeasureStartCount() == 0) { // There are no staffs or time slices! This is unexpected. Just return 0. // DEBUG: maybe this should be handled more gracefully. _duration = new Rational(0, 1); return _duration; } Staff staff = getStaff(0); MeasureStartTimeSlice lastMeasureStart = staff.getMeasureStart(staff.getMeasureStartCount() - 1); IntRatio result = new IntRatio(lastMeasureStart.getStartTime()); result.sub(getStartTime()); result.add(lastMeasureStart.getDuration()); _duration = new Rational(result); return _duration; }