Class DefaultRhythmDatabase
- All Implemented Interfaces:
RhythmDatabase
Default rhythms are stored as Preferences.
-
Method Summary
Modifier and TypeMethodDescriptionvoidListeners are notified when the rhythm database has changed.booleanaddRhythm(RhythmProvider rp, RhythmInfo ri) Add one RhythmInfo to the database for the specified RhythmProvider.booleanAdd one Rhythm instance to the database for the specified RhythmProvider.addRhythmsFromRhythmProviders(boolean excludeBuiltinRhythms, boolean excludeFileRhythms, boolean forceFileRhythmsRescan) Poll RhythmProvider instances from the global lookup to add rhythms.Try to provide the rhythm instance which is an adapted version of r for a different time signature.Get the default Rhythm for TimeSignature ts.static RhythmDatabaseFactoryGet a factory which just provides the DefaultRhythmDatabase instance.static DefaultRhythmDatabasegetInstance(Preferences prefs) Get the RhythmInfo instance from the specified rhythm unique id.getRhythmInstance(String rId) Get a rhythm instance from its id.Get a rhythm instance from a RhythmInfo.Get the RhythmProvider for specified RhythmInfo.The RhythmProviders used by this database.getRhythms(Predicate<RhythmInfo> tester) Get the rhythms which are tested OK.The rhythms associated to the specified RhythmProvidervoidvoidsetDefaultRhythm(TimeSignature ts, RhythmInfo ri) Set the default rhythm for this TimeSignature.intsize()toString()Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jjazz.rhythmdatabase.api.RhythmDatabase
findRhythm, findRhythm, getDefaultStubRhythmInstance, getRhythms, getRhythms, getTimeSignatures, toContentString, toStatsString
-
Method Details
-
getInstance
- Parameters:
prefs- The preferences to store the default rhythms (per time signature)- Returns:
-
getFactoryInstance
Get a factory which just provides the DefaultRhythmDatabase instance.- Returns:
-
getRhythmInstance
Description copied from interface:RhythmDatabaseGet a rhythm instance from a RhythmInfo.This might result in a lengthy operation (e.g. because of file reading). Rhythm instances are cached.
- Specified by:
getRhythmInstancein interfaceRhythmDatabase- Parameters:
ri-- Returns:
- Throws:
UnavailableRhythmException
-
getRhythm
Description copied from interface:RhythmDatabaseGet the RhythmInfo instance from the specified rhythm unique id.RhyhmtInfo instances are cached.
- Specified by:
getRhythmin interfaceRhythmDatabase- Parameters:
rhythmId-- Returns:
- Can be null if not found.
-
getRhythms
Description copied from interface:RhythmDatabaseGet the rhythms which are tested OK.- Specified by:
getRhythmsin interfaceRhythmDatabase- Parameters:
tester-- Returns:
-
getRhythmProviders
Description copied from interface:RhythmDatabaseThe RhythmProviders used by this database.- Specified by:
getRhythmProvidersin interfaceRhythmDatabase- Returns:
-
getRhythmInstance
Description copied from interface:RhythmDatabaseGet a rhythm instance from its id.If rId contains 2 instances of the AdaptedRhythm.RHYTHM_ID_DELIMITER, then this id represents an AdaptedRhythm which is created on demand, see AdaptedRhythm.getUniqueId().In that case, the rhythm provider, the original rhythm and the time signature are obtained from rId, and the returned rhythm instance is obtained by calling RhythmProvider.getAdaptedRhythmInstance(Rhythm, TimeSignature).
Rhythm instances can be cached.
- Specified by:
getRhythmInstancein interfaceRhythmDatabase- Parameters:
rId- Unique rhythm id- Returns:
- The rhythm whose uniqueId matches rId
- Throws:
UnavailableRhythmException- See Also:
-
getAdaptedRhythmInstance
Description copied from interface:RhythmDatabaseTry to provide the rhythm instance which is an adapted version of r for a different time signature.If the adapted rhythm could be obtained it is added in the database. AdaptedRhythm instances are cached.
- Specified by:
getAdaptedRhythmInstancein interfaceRhythmDatabase- Parameters:
r-ts-- Returns:
- Can be null if no adapted rhythm is available.
-
getRhythms
Description copied from interface:RhythmDatabaseThe rhythms associated to the specified RhythmProvider- Specified by:
getRhythmsin interfaceRhythmDatabase- Parameters:
rp-- Returns:
-
getDefaultRhythm
Description copied from interface:RhythmDatabaseGet the default Rhythm for TimeSignature ts.- Specified by:
getDefaultRhythmin interfaceRhythmDatabase- Parameters:
ts- TimeSignature- Returns:
- Can not be null, but there is no guarantee that getRhythmInstance() on the returned value will work (e.g. if this RhythmInfo depends on a file which is no more available).
-
setDefaultRhythm
Description copied from interface:RhythmDatabaseSet the default rhythm for this TimeSignature.- Specified by:
setDefaultRhythmin interfaceRhythmDatabase- Parameters:
ts- TimeSignatureri-
-
getRhythmProvider
- Specified by:
getRhythmProviderin interfaceRhythmDatabase- Parameters:
r-- Returns:
- The RhythmProvider of the specified rhythm. Null if not found.
-
getRhythmProvider
Description copied from interface:RhythmDatabaseGet the RhythmProvider for specified RhythmInfo.- Specified by:
getRhythmProviderin interfaceRhythmDatabase- Parameters:
ri-- Returns:
- The RhythmProvider of the specified RhythmInfo. Can be null.
-
addRhythm
Description copied from interface:RhythmDatabaseAdd one RhythmInfo to the database for the specified RhythmProvider.Fire a state changed event if RhythmInfo is actually added.
- Specified by:
addRhythmin interfaceRhythmDatabase- Parameters:
rp-ri-- Returns:
- True if rInfo was actually added.
-
addRhythmInstance
Description copied from interface:RhythmDatabaseAdd one Rhythm instance to the database for the specified RhythmProvider.Fire a state changed event if Rhythm is actually added.
- Specified by:
addRhythmInstancein interfaceRhythmDatabase- Parameters:
rp-r-- Returns:
- True if r was actually added.
-
toString
-
size
public int size()- Specified by:
sizein interfaceRhythmDatabase- Returns:
- The number of rhythms in the database.
-
addChangeListener
Description copied from interface:RhythmDatabaseListeners are notified when the rhythm database has changed.Note that listeners might be notified out of the Event Dispatch Thread.
- Specified by:
addChangeListenerin interfaceRhythmDatabase- Parameters:
l-
-
removeChangeListener
- Specified by:
removeChangeListenerin interfaceRhythmDatabase
-
addRhythmsFromRhythmProviders
public MultipleErrorsReport addRhythmsFromRhythmProviders(boolean excludeBuiltinRhythms, boolean excludeFileRhythms, boolean forceFileRhythmsRescan) Poll RhythmProvider instances from the global lookup to add rhythms.- Parameters:
excludeBuiltinRhythms-excludeFileRhythms-forceFileRhythmsRescan- Unused when excludedFileRhythms is true- Returns:
- See Also:
-