Search in sources :

Example 1 with Positioning

use of com.xenoage.zong.core.music.format.Positioning in project Zong by Xenoage.

the class FermataReader method read.

public static Fermata read(MxlFermata mxlFermata, StaffDetails staffDetails) {
    // determine position
    Positioning positioning = new PositioningReader(staffDetails).readFromAny(mxlFermata);
    if (positioning == null) {
        if (mxlFermata.getType() == MxlUprightInverted.Upright)
            positioning = Placement.Above;
        else if (mxlFermata.getType() == MxlUprightInverted.Inverted)
            positioning = Placement.Below;
    }
    Fermata fermata = new Fermata();
    fermata.setPositioning(positioning);
    return fermata;
}
Also used : Positioning(com.xenoage.zong.core.music.format.Positioning) MxlFermata(com.xenoage.zong.musicxml.types.MxlFermata) Fermata(com.xenoage.zong.core.music.annotation.Fermata)

Example 2 with Positioning

use of com.xenoage.zong.core.music.format.Positioning in project Zong by Xenoage.

the class DirectionStamper method computePosition.

/**
 * Computes the position for the given {@link Direction}
 * within the given {@link StaffStamping}.
 */
private SP computePosition(Direction direction, StaffStamping staffStamping, float defaultLP, float defaultLPAbove, float defaultLPBelow) {
    Positioning customPos = direction.getPositioning();
    MP mp = direction.getMP();
    if (mp == null)
        // TODO. Happens. But just with offical MusicXML sample Telemann.xml
        return SP.sp(0, 0);
    float x, lp;
    // default positioning
    x = notNull(staffStamping.system.getXMmAt(mp.getTime()), 0f) + staffStamping.positionMm.x;
    lp = defaultLP;
    // custom positioning
    if (customPos instanceof Placement) {
        Placement placement = (Placement) customPos;
        if (placement == Placement.Above)
            lp = defaultLPAbove;
        else
            lp = defaultLPBelow;
    } else if (customPos instanceof Position) {
        // coordinates
        Position pos = (Position) customPos;
        if (pos.x != null)
            x = pos.x;
        x += Position.getRelativeX(pos);
        // vertical position
        if (pos.y != null)
            lp = pos.y;
        lp += Position.getRelativeY(pos);
    }
    return sp(x, lp);
}
Also used : Positioning(com.xenoage.zong.core.music.format.Positioning) MP(com.xenoage.zong.core.position.MP) Placement(com.xenoage.zong.core.music.format.Placement) Position(com.xenoage.zong.core.music.format.Position)

Example 3 with Positioning

use of com.xenoage.zong.core.music.format.Positioning in project Zong by Xenoage.

the class DynamicsReader method read.

public static Dynamic read(MxlDynamics mxlDynamics, StaffDetails staffDetails) {
    DynamicValue type = mxlDynamics.getElement();
    Positioning positioning = new PositioningReader(staffDetails).readFromAny(mxlDynamics);
    Dynamic dynamics = new Dynamic(type);
    dynamics.setPositioning(positioning);
    return dynamics;
}
Also used : Positioning(com.xenoage.zong.core.music.format.Positioning) Dynamic(com.xenoage.zong.core.music.direction.Dynamic) DynamicValue(com.xenoage.zong.core.music.direction.DynamicValue)

Aggregations

Positioning (com.xenoage.zong.core.music.format.Positioning)3 Fermata (com.xenoage.zong.core.music.annotation.Fermata)1 Dynamic (com.xenoage.zong.core.music.direction.Dynamic)1 DynamicValue (com.xenoage.zong.core.music.direction.DynamicValue)1 Placement (com.xenoage.zong.core.music.format.Placement)1 Position (com.xenoage.zong.core.music.format.Position)1 MP (com.xenoage.zong.core.position.MP)1 MxlFermata (com.xenoage.zong.musicxml.types.MxlFermata)1