Search in sources :

Example 1 with RestSpacing

use of com.xenoage.zong.musiclayout.spacing.RestSpacing in project Zong by Xenoage.

the class VoiceStamper method stampVoice.

public List<Stamping> stampVoice(VoiceSpacing voice, float voiceXMm, StaffStampings staffStampings, boolean stampLeadingRests, StamperContext context, // TODO:
FormattedTextStyle defaultLyricStyle, Map<Beam, BeamSpacing> beams, OpenSlursCache openCurvedLinesCache, OpenLyricsCache openLyricsCache, LastLyrics lastLyrics, OpenTupletsCache openTupletsCache) {
    List<Stamping> ret = alist();
    // create the voice elements
    boolean onlyRestsSoFar = true;
    for (ElementSpacing spacingElement : voice.elements) {
        MusicElement element = spacingElement.getElement();
        if (element != null) /* TODO && (stampRests || !(element instanceof Rest)) */
        {
            Notation notation = context.getNotation(element);
            float xMm = voiceXMm + spacingElement.xIs * voice.interlineSpace;
            if (element instanceof Chord) {
                // chord
                onlyRestsSoFar = false;
                Chord chord = (Chord) element;
                BeamSpacing beam = beams.get(chord.getBeam());
                ret.addAll(chordStamper.stampAll((ChordNotation) spacingElement.getNotation(), xMm, beam, staffStampings, context, defaultLyricStyle, openCurvedLinesCache, openLyricsCache, lastLyrics, openTupletsCache));
            } else if (spacingElement instanceof RestSpacing) {
                // rest
                if (false == onlyRestsSoFar || stampLeadingRests) {
                    // not a leading rest, or a leading rest which should be stamped
                    ret.add(elementStamper.createRestStamping((RestSpacing) spacingElement, xMm, context));
                }
            } else {
                throw new IllegalArgumentException("Notation not supported: " + notation);
            }
        }
    }
    return ret;
}
Also used : ElementSpacing(com.xenoage.zong.musiclayout.spacing.ElementSpacing) Stamping(com.xenoage.zong.musiclayout.stampings.Stamping) BeamSpacing(com.xenoage.zong.musiclayout.spacing.BeamSpacing) ChordNotation(com.xenoage.zong.musiclayout.notation.ChordNotation) MusicElement(com.xenoage.zong.core.music.MusicElement) RestSpacing(com.xenoage.zong.musiclayout.spacing.RestSpacing) Notation(com.xenoage.zong.musiclayout.notation.Notation) ChordNotation(com.xenoage.zong.musiclayout.notation.ChordNotation) Chord(com.xenoage.zong.core.music.chord.Chord)

Aggregations

MusicElement (com.xenoage.zong.core.music.MusicElement)1 Chord (com.xenoage.zong.core.music.chord.Chord)1 ChordNotation (com.xenoage.zong.musiclayout.notation.ChordNotation)1 Notation (com.xenoage.zong.musiclayout.notation.Notation)1 BeamSpacing (com.xenoage.zong.musiclayout.spacing.BeamSpacing)1 ElementSpacing (com.xenoage.zong.musiclayout.spacing.ElementSpacing)1 RestSpacing (com.xenoage.zong.musiclayout.spacing.RestSpacing)1 Stamping (com.xenoage.zong.musiclayout.stampings.Stamping)1