Search in sources :

Example 1 with BarlineStyle

use of com.xenoage.zong.core.music.barline.BarlineStyle in project Zong by Xenoage.

the class BarlineReader method read.

private void read() {
    MxlRightLeftMiddle location = mxlBarline.getLocation();
    MxlRepeat repeat = mxlBarline.getRepeat();
    BarlineStyle style = null;
    if (mxlBarline.getBarStyle() != null)
        style = Equivalents.barlineStyles.getBy2(mxlBarline.getBarStyle().getBarStyle());
    if (repeat != null) {
        // repeat barline
        if (repeat.getDirection() == MxlBackwardForward.Forward) {
            style = notNull(style, BarlineStyle.HeavyLight);
            barline = Companion.barlineForwardRepeat(style);
        } else if (repeat.getDirection() == MxlBackwardForward.Backward) {
            style = notNull(style, BarlineStyle.LightHeavy);
            int times = notNull(repeat.getTimes(), 1);
            barline = Companion.barlineBackwardRepeat(style, times);
        }
    } else if (style != null) {
        // regular barline
        barline = Companion.barline(style);
    }
    if (barline != null) {
        // side / beat
        if (location == MxlRightLeftMiddle.Left)
            side = Left;
        else if (location == MxlRightLeftMiddle.Right)
            side = Right;
    }
}
Also used : MxlRightLeftMiddle(com.xenoage.zong.musicxml.types.enums.MxlRightLeftMiddle) MxlRepeat(com.xenoage.zong.musicxml.types.attributes.MxlRepeat) BarlineStyle(com.xenoage.zong.core.music.barline.BarlineStyle)

Example 2 with BarlineStyle

use of com.xenoage.zong.core.music.barline.BarlineStyle in project Zong by Xenoage.

the class BarlineRenderer method draw.

/**
 * Draws the given {@link BarlineStamping} on the given {@link Canvas},
 * using the given {@link RendererArgs}.
 */
@Override
public void draw(Stamping stamping, Canvas canvas, RendererArgs args) {
    BarlineStamping barlineSt = (BarlineStamping) stamping;
    List<StaffStamping> staves = barlineSt.staves;
    float xPosition = barlineSt.xMm;
    float xCorrection = 0;
    // lines
    BarlineGroup.Style group = barlineSt.groupStyle;
    BarlineStyle style = barlineSt.barline.getStyle();
    if (group == null || group == BarlineGroup.Style.Single || group == BarlineGroup.Style.Common) {
        // draw single barlines
        for (StaffStamping staff : staves) {
            xCorrection = paintBarline(canvas, args, staff, (staff.linesCount - 1) * 2, staff, 0, xPosition, style);
        }
    }
    if (group == BarlineGroup.Style.Mensurstrich || group == BarlineGroup.Style.Common) {
        // draw barlines between staves
        for (int i = 0; i < staves.size() - 1; i++) {
            xCorrection = paintBarline(canvas, args, staves.get(i), 0, staves.get(i + 1), (staves.get(i + 1).linesCount - 1) * 2, xPosition, style);
        }
    }
    // repeat dots
    // TODO: xCorrection is the value of the last staff, but this may differ
    // draw repeat dots directly after drawing the corresponding staff!
    BarlineRepeat repeat = barlineSt.barline.getRepeat();
    if (repeat == BarlineRepeat.Forward || repeat == BarlineRepeat.Both) {
        paintRepeatDots(staves, xPosition + xCorrection, 1, canvas, args);
    }
    if (repeat == BarlineRepeat.Backward || repeat == BarlineRepeat.Both) {
        paintRepeatDots(staves, xPosition + xCorrection, -1, canvas, args);
    }
}
Also used : BarlineRepeat(com.xenoage.zong.core.music.barline.BarlineRepeat) BarlineStamping(com.xenoage.zong.musiclayout.stampings.BarlineStamping) StaffStamping(com.xenoage.zong.musiclayout.stampings.StaffStamping) BarlineStyle(com.xenoage.zong.core.music.barline.BarlineStyle) BarlineGroup(com.xenoage.zong.core.music.group.BarlineGroup)

Aggregations

BarlineStyle (com.xenoage.zong.core.music.barline.BarlineStyle)2 BarlineRepeat (com.xenoage.zong.core.music.barline.BarlineRepeat)1 BarlineGroup (com.xenoage.zong.core.music.group.BarlineGroup)1 BarlineStamping (com.xenoage.zong.musiclayout.stampings.BarlineStamping)1 StaffStamping (com.xenoage.zong.musiclayout.stampings.StaffStamping)1 MxlRepeat (com.xenoage.zong.musicxml.types.attributes.MxlRepeat)1 MxlRightLeftMiddle (com.xenoage.zong.musicxml.types.enums.MxlRightLeftMiddle)1