Class SongFactory
java.lang.Object
org.jjazz.song.api.SongFactory
- All Implemented Interfaces:
PropertyChangeListener,EventListener
Manage the creation and the registration of the songs.
All songs created by this factory are automatically registered. Registered songs are unregistered when song is closed.
-
Method Summary
Modifier and TypeMethodDescriptioncreateEmptySong(String songName) Create a 8-bar empty song with only the 4/4 initial Section named "A" and its corresponding SongPart.createEmptySong(String songName, int nbBars, String initSectionName, TimeSignature ts, String initialChord) Create an empty song with the specified parameters.createSong(String name, ChordLeadSheet cls) Create a Song from the specified chordleadsheet.createSong(String name, SongStructure sgs) Create a Song from a SongStructure and its parent ChordLeadSheet.createSong(String name, SongStructure sgs, boolean noClsSgsLink) Create a Song from a SongStructure and its parent ChordLeadSheet, possibly unlinked.findSong(ChordLeadSheet cls) Find in the created song the first one which uses the specified ChordLeadSheet.findSong(SongStructure sgs) Find in the created song the first one which uses the specified SongStructure.Return a deep copy of the specified song.static SongFactorygetNewSongName(String baseName) Provide a new song name which is not used by any currently opened song.booleanisSongNameUsed(String name) voidvoidregisterSong(Song sg) Register a song if it was not created by this SongFactory.voidunregisterSong(Song song) Remove a song from the list returned by getRegisteredSong().
-
Method Details
-
getInstance
-
getRegisteredSongs
-
registerSong
Register a song if it was not created by this SongFactory.- Parameters:
sg-
-
getNewSongName
-
unregisterSong
Remove a song from the list returned by getRegisteredSong().- Parameters:
song-
-
findSong
Find in the created song the first one which uses the specified SongStructure.- Parameters:
sgs-- Returns:
-
findSong
Find in the created song the first one which uses the specified ChordLeadSheet.- Parameters:
cls-- Returns:
-
createSong
Create a Song from the specified chordleadsheet.- Parameters:
name-cls-- Returns:
- Throws:
UnsupportedEditException- Can happen if too many timesignature changes resulting in not enough Midi channels for the various rhythms.
-
createSong
Create a Song from a SongStructure and its parent ChordLeadSheet.- Parameters:
name-sgs- sgs.getParentChordLeadSheet() must be non null- Returns:
- Throws:
UnsupportedEditException- Can happen if too many timesignature changes resulting in not enough Midi channels for the various rhythms.
-
createSong
public Song createSong(String name, SongStructure sgs, boolean noClsSgsLink) throws UnsupportedEditException Create a Song from a SongStructure and its parent ChordLeadSheet, possibly unlinked.- Parameters:
name-sgs- sgs.getParentChordLeadSheet() must be non nullnoClsSgsLink- If true, there will be no automatic update between the ChordLeadSheet and the SongStructure. To be used with care only for special purposes (e.g. unit tests), as the Song might be in an inconsistent state.- Returns:
- Throws:
UnsupportedEditException- Can happen if too many timesignature changes resulting in not enough Midi channels for the various rhythms.
-
createEmptySong
-
createEmptySong
public Song createEmptySong(String songName, int nbBars, String initSectionName, TimeSignature ts, String initialChord) Create an empty song with the specified parameters.- Parameters:
songName- The name of the songnbBars-initSectionName- The name of the initial sectionts- The time signature of the initial sectioninitialChord- eg "Cm7". A string describing an initial chord to be put at the start of the song. If null no chord is inserted.- Returns:
-
isSongNameUsed
-
getCopy
Return a deep copy of the specified song.Listeners or file are NOT copied. Returned song is not closed, even if the original song was.
- Parameters:
song-noClsSgsLink- If true, updating the chord leadsheet will not update the song structureregister- If true register the created song- Returns:
-
propertyChange
- Specified by:
propertyChangein interfacePropertyChangeListener
-