use of com.xenoage.zong.musicxml.types.choice.MxlPartListContent in project Zong by Xenoage.
the class StavesListReader method read.
public StavesList read() {
// list of parts
List<Part> parts = alist();
partsIDtoIndex = map();
// list of groups
List<PartsBarlineGroup> barlineGroups = alist();
List<PartsBracketGroup> bracketGroups = alist();
// open groups with number as index
Map<String, PartsBarlineGroup> openBarlineGroups = map();
Map<String, PartsBracketGroup> openBracketGroups = map();
// read score-part and part-group elements
// each score-part is a part in our application
MxlPartList mxlPartList = mxlScore.getScoreHeader().getPartList();
int currentPartIndex = 0;
for (MxlPartListContent mxlItem : mxlPartList.getContent()) {
// score-part
if (mxlItem.getPartListContentType() == PartListContentType.ScorePart) {
MxlScorePart mxlScorePart = (MxlScorePart) mxlItem;
Part part = PartReader.read(mxlScorePart, findCorrespondingPart(mxlScorePart, mxlScore));
parts.add(part);
partsIDtoIndex.put(mxlScorePart.getId(), currentPartIndex);
currentPartIndex++;
} else // part-group
if (mxlItem.getPartListContentType() == PartListContentType.PartGroup) {
PartsGroups group = readPartGroup(currentPartIndex, (MxlPartGroup) mxlItem, openBarlineGroups, openBracketGroups);
if (group != null) {
// a group was closed, add it
if (group.barlineGroup != null)
barlineGroups.add(group.barlineGroup);
if (group.bracketsGroup != null)
bracketGroups.add(group.bracketsGroup);
}
}
}
// if there are unclosed score-groups, report a problem
if (openBarlineGroups.size() > 0 || openBracketGroups.size() > 0) {
errorHandling.reportError("There are unclosed score-groups");
}
// count the number of staves and measures used by each part
HashMap<String, Integer> partsStaves = countStaves(mxlScore);
for (String partID : partsStaves.keySet()) {
Integer partIndex = partsIDtoIndex.get(partID);
if (partIndex == null)
throw new IllegalStateException("Unknown part \"" + partID + "\"");
Integer partStaves = partsStaves.get(partID);
if (partStaves == null)
throw new IllegalStateException("Unused part \"" + partID + "\"");
if (partStaves > 1)
parts.get(partIndex).setStavesCount(partStaves);
}
// creates the final StavesList for this document
stavesList = createStavesList(parts, barlineGroups, bracketGroups);
return stavesList;
}
use of com.xenoage.zong.musicxml.types.choice.MxlPartListContent in project Zong by Xenoage.
the class MxlPartList method write.
public void write(XmlWriter writer) {
writer.writeElementStart(elemName);
for (MxlPartListContent item : content) item.write(writer);
writer.writeElementEnd();
}
Aggregations