Search in sources :

Example 11 with MaybeNull

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

the class BeamNotator method compute.

@MaybeNull
public BeamNotation compute(Beam beam, Notations notations) {
    // compute fragments
    List<Fragments> fragments = beamFragmenter.compute(beam);
    // get minimum stem length and gap
    BeamRules beamRules = BeamRules.getRules(beam);
    float gapIs = beamRules.getGapIs();
    // collect chords
    List<ChordNotation> chords = notations.getBeamChords(beam);
    // create notation
    BeamNotation beamNotation = new BeamNotation(beam, beam.getMP(), fragments, gapIs, chords);
    return beamNotation;
}
Also used : ChordNotation(com.xenoage.zong.musiclayout.notation.ChordNotation) Fragments(com.xenoage.zong.musiclayout.notation.beam.Fragments) BeamRules(com.xenoage.zong.musiclayout.notator.beam.lines.BeamRules) BeamNotation(com.xenoage.zong.musiclayout.notation.BeamNotation) MaybeNull(com.xenoage.utils.annotations.MaybeNull)

Example 12 with MaybeNull

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

the class Notator method compute.

/**
 * Computes the {@link Notation} of the given element.
 */
@MaybeNull
private Notation compute(MPElement element, Context context, Notations notations) {
    ElementNotator notator = notators.get(element.getMusicElementType());
    if (// element needs no notation
    notator == null)
        return null;
    Notation notation = notator.compute(element, context, notations);
    return notation;
}
Also used : Notation(com.xenoage.zong.musiclayout.notation.Notation) MaybeNull(com.xenoage.utils.annotations.MaybeNull)

Example 13 with MaybeNull

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

the class MxlPrint method read.

@MaybeNull
public static MxlPrint read(XmlReader reader) {
    MxlLayout layout = new MxlLayout();
    MxlPrintAttributes printAttributes = MxlPrintAttributes.read(reader);
    while (reader.openNextChildElement()) {
        layout.readElement(reader);
        reader.closeElement();
    }
    if (false == layout.isUsed())
        layout = null;
    if (layout != null || printAttributes != noPrintAttributes)
        return new MxlPrint(layout, printAttributes);
    else
        return null;
}
Also used : MxlPrintAttributes(com.xenoage.zong.musicxml.types.attributes.MxlPrintAttributes) MxlLayout(com.xenoage.zong.musicxml.types.groups.MxlLayout) MaybeNull(com.xenoage.utils.annotations.MaybeNull)

Example 14 with MaybeNull

use of com.xenoage.utils.annotations.MaybeNull 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 15 with MaybeNull

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

the class MxlDirection method read.

/**
 * Returns null, when no supported content was found.
 */
@MaybeNull
public static MxlDirection read(XmlReader reader) {
    // attributes
    MxlPlacement placement = MxlPlacement.read(reader);
    // elements
    List<MxlDirectionType> directionTypes = alist();
    Integer staff = null;
    MxlSound sound = null;
    while (reader.openNextChildElement()) {
        String n = reader.getElementName();
        switch(n) {
            case MxlDirectionType.elemName:
                MxlDirectionType directionType = MxlDirectionType.read(reader);
                if (directionType != null)
                    directionTypes.add(directionType);
                break;
            case "staff":
                staff = reader.getTextInt();
                break;
            case MxlSound.elemName:
                sound = MxlSound.read(reader);
                break;
        }
        reader.closeElement();
    }
    if (directionTypes.size() > 0) {
        return new MxlDirection(directionTypes, staff, sound, placement);
    } else {
        return null;
    }
}
Also used : MxlPlacement(com.xenoage.zong.musicxml.types.enums.MxlPlacement) MaybeNull(com.xenoage.utils.annotations.MaybeNull)

Aggregations

MaybeNull (com.xenoage.utils.annotations.MaybeNull)25 lombok.val (lombok.val)5 MxlPrintStyle (com.xenoage.zong.musicxml.types.attributes.MxlPrintStyle)4 MxlFont (com.xenoage.zong.musicxml.types.attributes.MxlFont)3 MxlPlacement (com.xenoage.zong.musicxml.types.enums.MxlPlacement)3 Dynamic (com.xenoage.zong.core.music.direction.Dynamic)2 GradientDynamics (com.xenoage.zong.io.midi.out.dynamics.type.GradientDynamics)2 MxlLayout (com.xenoage.zong.musicxml.types.groups.MxlLayout)2 FontInfo (com.xenoage.utils.font.FontInfo)1 FontStyle (com.xenoage.utils.font.FontStyle)1 BufferedInputStream (com.xenoage.utils.io.BufferedInputStream)1 Point2f (com.xenoage.utils.math.geom.Point2f)1 XmlException (com.xenoage.utils.xml.XmlException)1 XmlReader (com.xenoage.utils.xml.XmlReader)1 DynamicValue (com.xenoage.zong.core.music.direction.DynamicValue)1 Type (com.xenoage.zong.core.music.direction.Pedal.Type)1 Wedge (com.xenoage.zong.core.music.direction.Wedge)1 WedgeEnd (com.xenoage.zong.core.music.direction.WedgeEnd)1 BezierPoint (com.xenoage.zong.core.music.format.BezierPoint)1 SP (com.xenoage.zong.core.music.format.SP)1