Search in sources :

Example 11 with NonNull

use of com.xenoage.utils.annotations.NonNull in project Zong by Xenoage.

the class MxlBarStyleColor method read.

@NonNull
public static MxlBarStyleColor read(XmlReader reader) {
    MxlColor color = MxlColor.read(reader);
    MxlBarStyle barStyle = MxlBarStyle.read(reader);
    return new MxlBarStyleColor(barStyle, color);
}
Also used : MxlColor(com.xenoage.zong.musicxml.types.attributes.MxlColor) MxlBarStyle(com.xenoage.zong.musicxml.types.enums.MxlBarStyle) NonNull(com.xenoage.utils.annotations.NonNull)

Example 12 with NonNull

use of com.xenoage.utils.annotations.NonNull in project Zong by Xenoage.

the class MxlNote method read.

@NonNull
public static MxlNote read(XmlReader reader) {
    MxlNoteContent content = null;
    MxlInstrument instrument = null;
    MxlEditorialVoice editorialVoice = new MxlEditorialVoice();
    MxlNoteTypeValue noteType = null;
    int dots = 0;
    MxlStem stem = null;
    Integer staff = null;
    List<MxlBeam> beams = null;
    List<MxlNotations> notations = null;
    List<MxlLyric> lyrics = null;
    while (reader.openNextChildElement()) {
        String n = reader.getElementName();
        // but, be tolerant for errors, and also accept late grace or cue elements
        if (n.equals(MxlGraceNote.elemName)) {
            MxlGraceNote graceNote = MxlGraceNote.read(reader);
            if (// grace element too late, but accept it
            content instanceof MxlNormalNote)
                graceNote.setFullNote(((MxlNormalNote) content).getFullNote());
            content = graceNote;
        } else if (n.equals(MxlCueNote.elemName)) {
            MxlCueNote cueNote = MxlCueNote.read();
            if (// cue element too late, but accept it
            content instanceof MxlNormalNote)
                cueNote.setFullNote(((MxlNormalNote) content).getFullNote());
            content = cueNote;
        } else if (content == null) {
            content = MxlNormalNote.read();
        }
        // read content of child elements
        switch(n) {
            case MxlStem.elemName:
                stem = MxlStem.read(reader);
                break;
            case "staff":
                staff = reader.getTextIntNotNull();
                break;
            case MxlBeam.elemName:
                if (beams == null)
                    beams = new ArrayList<>();
                beams.add(MxlBeam.read(reader));
                break;
            case MxlInstrument.elemName:
                instrument = MxlInstrument.read(reader);
                break;
            case MxlNotations.elemName:
                if (notations == null)
                    notations = new ArrayList<>();
                notations.add(MxlNotations.read(reader));
                break;
            case MxlLyric.elemName:
                if (lyrics == null)
                    lyrics = new ArrayList<>();
                lyrics.add(MxlLyric.read(reader));
                break;
            case "type":
                noteType = MxlNoteTypeValue.read(reader.getText());
                break;
            case "dot":
                dots++;
                break;
            default:
                boolean read = content.readElement(reader);
                if (!read)
                    editorialVoice.readElement(reader);
                break;
        }
        reader.closeElement();
    }
    content.check(reader);
    if (false == editorialVoice.isUsed())
        editorialVoice = null;
    return new MxlNote(content, instrument, editorialVoice, noteType, dots, stem, staff, beams, notations, lyrics);
}
Also used : ArrayList(java.util.ArrayList) MxlEditorialVoice(com.xenoage.zong.musicxml.types.groups.MxlEditorialVoice) MxlNoteTypeValue(com.xenoage.zong.musicxml.types.enums.MxlNoteTypeValue) NonNull(com.xenoage.utils.annotations.NonNull)

Example 13 with NonNull

use of com.xenoage.utils.annotations.NonNull in project Zong by Xenoage.

the class MxlPageLayout method read.

@NonNull
public static MxlPageLayout read(XmlReader reader) {
    Float pageWidth = null;
    Float pageHeight = null;
    List<MxlPageMargins> pageMargins = alist();
    while (reader.openNextChildElement()) {
        String n = reader.getElementName();
        switch(n) {
            case "page-width":
                pageWidth = Parser.parseFloatNull(reader.getText());
                break;
            case "page-height":
                pageHeight = Parser.parseFloatNull(reader.getText());
                break;
            case "page-margins":
                pageMargins.add(MxlPageMargins.read(reader));
                break;
        }
        reader.closeElement();
    }
    Size2f pageSize = (pageWidth == null && pageHeight == null ? null : new Size2f(pageWidth, pageHeight));
    return new MxlPageLayout(pageSize, pageMargins);
}
Also used : Size2f(com.xenoage.utils.math.geom.Size2f) NonNull(com.xenoage.utils.annotations.NonNull)

Example 14 with NonNull

use of com.xenoage.utils.annotations.NonNull in project Zong by Xenoage.

the class MxlPedal method read.

@NonNull
public static MxlPedal read(XmlReader reader) {
    String type = reader.getAttributeNotNull("type");
    MxlPrintStyle printStyle = MxlPrintStyle.read(reader);
    return new MxlPedal(MxlStartStopChange.read(type), printStyle);
}
Also used : MxlPrintStyle(com.xenoage.zong.musicxml.types.attributes.MxlPrintStyle) NonNull(com.xenoage.utils.annotations.NonNull)

Example 15 with NonNull

use of com.xenoage.utils.annotations.NonNull in project Zong by Xenoage.

the class MxlEnding method read.

@NonNull
public static MxlEnding read(XmlReader reader) {
    String number = reader.getAttributeNotNull("number");
    MxlStartStopDiscontinue type = MxlStartStopDiscontinue.read(reader.getAttributeNotNull("type"));
    return new MxlEnding(number, type);
}
Also used : MxlStartStopDiscontinue(com.xenoage.zong.musicxml.types.enums.MxlStartStopDiscontinue) NonNull(com.xenoage.utils.annotations.NonNull)

Aggregations

NonNull (com.xenoage.utils.annotations.NonNull)20 MxlColor (com.xenoage.zong.musicxml.types.attributes.MxlColor)4 MxlPrintStyle (com.xenoage.zong.musicxml.types.attributes.MxlPrintStyle)4 MxlPosition (com.xenoage.zong.musicxml.types.attributes.MxlPosition)2 MxlEditorialVoice (com.xenoage.zong.musicxml.types.groups.MxlEditorialVoice)2 Color (com.xenoage.utils.color.Color)1 FontInfo (com.xenoage.utils.font.FontInfo)1 Size2f (com.xenoage.utils.math.geom.Size2f)1 XmlReader (com.xenoage.utils.xml.XmlReader)1 ScoreFormat (com.xenoage.zong.core.format.ScoreFormat)1 FormattedTextStyle (com.xenoage.zong.core.text.FormattedTextStyle)1 MxlCreditContent (com.xenoage.zong.musicxml.types.choice.MxlCreditContent)1 MxlAccidentalText (com.xenoage.zong.musicxml.types.enums.MxlAccidentalText)1 MxlBarStyle (com.xenoage.zong.musicxml.types.enums.MxlBarStyle)1 MxlBeamValue (com.xenoage.zong.musicxml.types.enums.MxlBeamValue)1 MxlGroupBarlineValue (com.xenoage.zong.musicxml.types.enums.MxlGroupBarlineValue)1 MxlGroupSymbolValue (com.xenoage.zong.musicxml.types.enums.MxlGroupSymbolValue)1 MxlLeftCenterRight (com.xenoage.zong.musicxml.types.enums.MxlLeftCenterRight)1 MxlMarginType (com.xenoage.zong.musicxml.types.enums.MxlMarginType)1 MxlNoteTypeValue (com.xenoage.zong.musicxml.types.enums.MxlNoteTypeValue)1