use of com.xenoage.zong.musicxml.types.attributes.MxlPrintStyle in project Zong by Xenoage.
the class MxlDynamics method read.
/**
* Reads the given element and returns it, or returns null if
* the element is empty or not supported.
*/
@MaybeNull
public static MxlDynamics read(XmlReader reader) {
// attributes
MxlPrintStyle printStyle = MxlPrintStyle.read(reader);
MxlPlacement placement = MxlPlacement.read(reader);
// get first element
if (false == reader.openNextChildElement())
// dynamics element may be empty according to schema
return null;
String childText = reader.getElementName();
reader.closeElement();
DynamicValue element = getEnumValue(childText, DynamicValue.values());
if (element != null)
return new MxlDynamics(element, printStyle, placement);
else
return null;
}
use of com.xenoage.zong.musicxml.types.attributes.MxlPrintStyle in project Zong by Xenoage.
the class MxlMetronome method read.
/**
* Returns null, if the given element contains an unsupported metronome type.
*/
@MaybeNull
public static MxlMetronome read(XmlReader reader) {
// attributes
MxlPrintStyle printStyle = MxlPrintStyle.read(reader);
// elements
String sBeatUnit = null;
int dotsCount = 0;
Integer perMinute = null;
while (reader.openNextChildElement()) {
String n = reader.getElementName();
switch(n) {
case "beat-unit":
sBeatUnit = reader.getText();
break;
case "beat-unit-dot":
dotsCount++;
break;
case "per-minute":
perMinute = parseIntegerNull(reader.getText());
break;
}
reader.closeElement();
}
if (sBeatUnit != null && perMinute != null) {
MxlNoteTypeValue beatUnit = MxlNoteTypeValue.read(sBeatUnit);
return new MxlMetronome(beatUnit, dotsCount, perMinute, printStyle);
} else {
return null;
}
}
use of com.xenoage.zong.musicxml.types.attributes.MxlPrintStyle in project Zong by Xenoage.
the class FontInfoReader method read.
/**
* Reads the font from the given element, if it is a {@link MxlPrintStyleContent} element
* and contains font information. The returned font is based on the given default font.
*/
@MaybeNull
public static FontInfo read(Object printStyleElement, FontInfo defaultFont) {
if (false == printStyleElement instanceof MxlPrintStyleContent)
return null;
MxlPrintStyle mxlPrintStyle = ((MxlPrintStyleContent) printStyleElement).getPrintStyle();
MxlFont mxlFont = mxlPrintStyle.getFont();
return new FontInfoReader(mxlFont, defaultFont).read();
}
Aggregations