* @param meiData
* @return
*/
public static MusicDiagram createFormsDiagramFromMei(String fileName,
Mei meiData) {
MusicDiagram rootDiagram = new MusicDiagram(fileName, meiData);
rootDiagram.bootUp();
// read the sources in the mei file
rootDiagram.setSourceList(loadSourceList(meiData));
// initialize default ScoreDef
rootDiagram
.setScoreDefForm((ScoreDefForm) handleScoreDef(
MusicContainerFactory
.createScoreDef(MusicContainerFactory.DEFAULT_STAVES_COUNT),
rootDiagram));
// check if music.body is present
if (!MusicContainerFactory.checkContainsScore(meiData)) {
// no music or no body present
meiData.setMusic(((MusicContainerFactory.createDefaultMeiTree(
MusicContainerFactory.DEFAULT_STAVES_COUNT,
MusicContainerFactory.DEFAULT_MEASURES_COUNT)).getMusic()));
LogService.info(MusicMessages.Mei2FormsConverter_0);
}
// handle the mei body
for (int mdivIter = 0; mdivIter < meiData.getMusic().getBody()
.getMdivs().size(); mdivIter++) {
final Mdiv mdiv = meiData.getMusic().getBody().getMdivs()
.get(mdivIter);
for (Object scoreDefOrSection : mdiv.getScore()
.getGapsAndSbsAndCorrs()) {
if (scoreDefOrSection instanceof Section) {
rootDiagram.addChild(handleSection(
(Section) scoreDefOrSection, rootDiagram));
} else if (scoreDefOrSection instanceof ScoreDef) {
rootDiagram.setScoreDefForm((ScoreDefForm) handleScoreDef(
(ScoreDef) scoreDefOrSection, rootDiagram));
} else if (scoreDefOrSection instanceof App) {
rootDiagram.addChild(handleAppOutsideLayer(
(App) scoreDefOrSection, rootDiagram));
} else {
rootDiagram.addChild(handleUnknownMeiNode(
(MeiNode) scoreDefOrSection, rootDiagram));
}
}
}