Search in sources :

Example 6 with MxlPrintStyle

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;
}
Also used : MxlPlacement(com.xenoage.zong.musicxml.types.enums.MxlPlacement) MxlPrintStyle(com.xenoage.zong.musicxml.types.attributes.MxlPrintStyle) DynamicValue(com.xenoage.zong.core.music.direction.DynamicValue) MaybeNull(com.xenoage.utils.annotations.MaybeNull)

Example 7 with MxlPrintStyle

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;
    }
}
Also used : MxlNoteTypeValue(com.xenoage.zong.musicxml.types.enums.MxlNoteTypeValue) MxlPrintStyle(com.xenoage.zong.musicxml.types.attributes.MxlPrintStyle) MaybeNull(com.xenoage.utils.annotations.MaybeNull)

Example 8 with MxlPrintStyle

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();
}
Also used : MxlPrintStyleContent(com.xenoage.zong.musicxml.types.util.MxlPrintStyleContent) MxlFont(com.xenoage.zong.musicxml.types.attributes.MxlFont) MxlPrintStyle(com.xenoage.zong.musicxml.types.attributes.MxlPrintStyle) MaybeNull(com.xenoage.utils.annotations.MaybeNull)

Aggregations

MxlPrintStyle (com.xenoage.zong.musicxml.types.attributes.MxlPrintStyle)8 MaybeNull (com.xenoage.utils.annotations.MaybeNull)4 NonNull (com.xenoage.utils.annotations.NonNull)4 MxlPlacement (com.xenoage.zong.musicxml.types.enums.MxlPlacement)2 Color (com.xenoage.utils.color.Color)1 FontInfo (com.xenoage.utils.font.FontInfo)1 DynamicValue (com.xenoage.zong.core.music.direction.DynamicValue)1 FormattedTextStyle (com.xenoage.zong.core.text.FormattedTextStyle)1 MxlFont (com.xenoage.zong.musicxml.types.attributes.MxlFont)1 MxlAccidentalText (com.xenoage.zong.musicxml.types.enums.MxlAccidentalText)1 MxlLeftCenterRight (com.xenoage.zong.musicxml.types.enums.MxlLeftCenterRight)1 MxlNoteTypeValue (com.xenoage.zong.musicxml.types.enums.MxlNoteTypeValue)1 MxlUprightInverted (com.xenoage.zong.musicxml.types.enums.MxlUprightInverted)1 MxlVAlign (com.xenoage.zong.musicxml.types.enums.MxlVAlign)1 MxlPrintStyleContent (com.xenoage.zong.musicxml.types.util.MxlPrintStyleContent)1