Search in sources :

Example 6 with SP

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

the class DirectionStamper method createWords.

/**
 * Creates a {@link StaffTextStamping} for the given {@link Words}.
 */
public StaffTextStamping createWords(Words words, StamperContext context) {
    val staff = context.getCurrentStaffStamping();
    if (words.getText().getLength() == 0)
        return null;
    // positioning
    // below: 5 IS below the base line
    // above (default): 4 IS above the top line
    float defaultLPBelow = -5f * 2;
    float defaultLPAbove = (staff.linesCount - 1) * 2 + 4 * 2;
    SP p = computePosition(words, staff, defaultLPAbove, defaultLPAbove, defaultLPBelow);
    // create text
    // TODO: FormattedTextStyle(words.getFontInfo());
    FormattedTextStyle style = FormattedTextStyle.Companion.getDefaultStyle();
    FormattedText text = styleText(words.getText(), style);
    // create stamping
    return new StaffTextStamping(text, p, staff, words);
}
Also used : lombok.val(lombok.val) StaffTextStamping(com.xenoage.zong.musiclayout.stampings.StaffTextStamping) SP(com.xenoage.zong.core.music.format.SP)

Example 7 with SP

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

the class DirectionStamper method createDynamics.

/**
 * Creates a {@link StaffTextStamping} for the given {@link Dynamic}s.
 */
public StaffTextStamping createDynamics(Dynamic dynamics, StamperContext context) {
    val staff = context.getCurrentStaffStamping();
    // positioning
    // below (default): 3 IS below the base line, or 2 IS below the lowest note
    // above: 2 IS above the top line, or 1 IS above the highest note
    float defaultLPBelow = -3f * 2;
    float defaultLPAbove = (context.getCurrentStaffStamping().linesCount - 1) * 2 + 2 * 2;
    SP sp = computePosition(dynamics, staff, defaultLPBelow, defaultLPAbove, defaultLPBelow);
    // create text
    CList<FormattedTextElement> elements = clist();
    for (CommonSymbol s : CommonSymbol.getDynamics(dynamics.getValue())) {
        Symbol symbol = context.getSymbol(s);
        elements.add(new FormattedTextSymbol(symbol, staff.is * FONT_SIZE_IN_IS, FormattedTextStyle.Companion.getDefaultColor()));
    }
    elements.close();
    FormattedTextParagraph paragraph = new FormattedTextParagraph(elements, Alignment.Center);
    FormattedText text = Companion.fText(paragraph);
    // create stamping
    return new StaffTextStamping(text, sp, staff, dynamics);
}
Also used : lombok.val(lombok.val) CommonSymbol(com.xenoage.zong.symbols.common.CommonSymbol) Symbol(com.xenoage.zong.symbols.Symbol) StaffTextStamping(com.xenoage.zong.musiclayout.stampings.StaffTextStamping) SP(com.xenoage.zong.core.music.format.SP) CommonSymbol(com.xenoage.zong.symbols.common.CommonSymbol)

Example 8 with SP

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

the class DirectionStamper method createTempo.

/**
 * Creates a {@link StaffTextStamping} for the given {@link Tempo}.
 */
public StaffTextStamping createTempo(Tempo tempo, StamperContext context) {
    val staff = context.getCurrentStaffStamping();
    // positioning
    // below: 3 IS below the base line
    // above (default): 2 IS above the top line
    float defaultLPBelow = -3f * 2;
    float defaultLPAbove = (staff.linesCount - 1) * 2 + 2 * 2;
    SP p = computePosition(tempo, staff, defaultLPAbove, defaultLPAbove, defaultLPBelow);
    // create text
    FormattedText text = getTempoTextNotNull(tempo, context.layouter.symbols);
    // create stamping
    return new StaffTextStamping(text, p, staff, tempo);
}
Also used : lombok.val(lombok.val) StaffTextStamping(com.xenoage.zong.musiclayout.stampings.StaffTextStamping) SP(com.xenoage.zong.core.music.format.SP)

Example 9 with SP

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

the class ElementStamper method createRestStamping.

/**
 * Creates a stamping for the given rest.
 */
public StaffSymbolStamping createRestStamping(RestSpacing rest, float xMm, StamperContext context) {
    val staff = context.getCurrentStaffStamping();
    Symbol symbol = getRestSymbol(rest.getNotation().duration, context);
    SP sp = sp(xMm, rest.lp);
    return new StaffSymbolStamping(rest.notation, staff, symbol, null, sp, 1, false);
}
Also used : lombok.val(lombok.val) CommonSymbol(com.xenoage.zong.symbols.common.CommonSymbol) Symbol(com.xenoage.zong.symbols.Symbol) StaffSymbolStamping(com.xenoage.zong.musiclayout.stampings.StaffSymbolStamping) SP(com.xenoage.zong.core.music.format.SP)

Example 10 with SP

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

the class SlurStamper method createForMiddleSystem.

/**
 * Creates a {@link SlurStamping} for a curved line that
 * starts at an earlier system and ends at a later system, but
 * spans also the given system.
 */
SlurStamping createForMiddleSystem(StaffStamping staff, Slur slur) {
    if (slur.getType() == SlurType.Tie) {
        // ties can not have middle staves
        return null;
    }
    // end points of the bezier curve
    float p1x = staff.positionMm.x + staff.system.getMeasureStartAfterLeadingMm(staff.system.getStartMeasure()) - // TODO
    5;
    float p2x = staff.positionMm.x + staff.lengthMm;
    float lp;
    if (slur.getSide() == VSide.Top)
        // 1 IS over the top staff line
        lp = (staff.linesCount - 1) * 2 + 2;
    else
        // 1 IS below the bottom staff line
        lp = -2;
    SP p1 = sp(p1x, lp);
    SP p2 = sp(p2x, lp);
    // control points of the bezier curve
    // default formatting
    SP c1 = computeLeftControlPoint(slur, p1, p2, staff);
    // default formatting
    SP c2 = computeRightControlPoint(slur, p1, p2, staff);
    return new SlurStamping(slur, p1, p2, c1, c2, staff, staff);
}
Also used : SlurStamping(com.xenoage.zong.musiclayout.stampings.SlurStamping) SP(com.xenoage.zong.core.music.format.SP)

Aggregations

SP (com.xenoage.zong.core.music.format.SP)13 lombok.val (lombok.val)7 BezierPoint (com.xenoage.zong.core.music.format.BezierPoint)4 SlurWaypoint (com.xenoage.zong.core.music.slur.SlurWaypoint)4 SlurStamping (com.xenoage.zong.musiclayout.stampings.SlurStamping)4 StaffTextStamping (com.xenoage.zong.musiclayout.stampings.StaffTextStamping)4 Symbol (com.xenoage.zong.symbols.Symbol)4 CommonSymbol (com.xenoage.zong.symbols.common.CommonSymbol)4 VSide (com.xenoage.utils.math.VSide)2 Slur (com.xenoage.zong.core.music.slur.Slur)2 StaffSymbolStamping (com.xenoage.zong.musiclayout.stampings.StaffSymbolStamping)2 MaybeNull (com.xenoage.utils.annotations.MaybeNull)1 LinearInterpolationPoints (com.xenoage.utils.math.MathUtils.LinearInterpolationPoints)1 WaypointPosition (com.xenoage.zong.core.music.WaypointPosition)1 Beam (com.xenoage.zong.core.music.beam.Beam)1 Chord (com.xenoage.zong.core.music.chord.Chord)1 Lyric (com.xenoage.zong.core.music.lyric.Lyric)1 SyllableType (com.xenoage.zong.core.music.lyric.SyllableType)1 Tuplet (com.xenoage.zong.core.music.tuplet.Tuplet)1 ContinuedSlur (com.xenoage.zong.musiclayout.continued.ContinuedSlur)1