Search in sources :

Example 1 with ClefNotation

use of com.xenoage.zong.musiclayout.notation.ClefNotation in project Zong by Xenoage.

the class MeasureElementsSpacerTest method notations.

private Notations notations(Rest[] rests, Clef clef) {
    Notations ret = new Notations();
    ret.add(new ClefNotation(clef, new ElementWidth(clefWidth), 0, 1));
    return ret;
}
Also used : ElementWidth(com.xenoage.zong.musiclayout.spacing.ElementWidth) Notations(com.xenoage.zong.musiclayout.notation.Notations) ClefNotation(com.xenoage.zong.musiclayout.notation.ClefNotation)

Example 2 with ClefNotation

use of com.xenoage.zong.musiclayout.notation.ClefNotation in project Zong by Xenoage.

the class LeadingSpacingMock method createGClefSpacing.

/**
 * Creates an easy MeasureLeadingSpacing (with a g-clef)
 * that has the given width in IS.
 */
public static LeadingSpacing createGClefSpacing(float widthIs) {
    ClefNotation notation = new ClefNotation(new Clef(ClefType.Companion.getClefTreble()), new ElementWidth(widthIs), 0, 1);
    ElementSpacing spacing = new SimpleSpacing(notation, Companion.fr(0), 0);
    return new LeadingSpacing(alist(spacing), widthIs);
}
Also used : ElementSpacing(com.xenoage.zong.musiclayout.spacing.ElementSpacing) ElementWidth(com.xenoage.zong.musiclayout.spacing.ElementWidth) LeadingSpacing(com.xenoage.zong.musiclayout.spacing.LeadingSpacing) ClefNotation(com.xenoage.zong.musiclayout.notation.ClefNotation) Clef(com.xenoage.zong.core.music.clef.Clef)

Example 3 with ClefNotation

use of com.xenoage.zong.musiclayout.notation.ClefNotation in project Zong by Xenoage.

the class LeadingSpacer method compute.

/**
 * Computes the {@link LeadingSpacing} for the current measure.
 */
public LeadingSpacing compute(Context context, Notations notations) {
    float xOffset = context.settings.offsetMeasureStart;
    boolean useKey = false;
    MusicContext musicContext = context.getMusicContext(At, null);
    Key key = musicContext.getKey();
    if (key instanceof TraditionalKey) {
        useKey = true;
    }
    List<ElementSpacing> elements = alist(useKey ? 2 : 1);
    // it is not the same element instance, but has the same meaning
    Clef clef = new Clef(musicContext.getClef());
    ClefNotation clefNotation = new ClefNotation(clef, new ElementWidth(0, context.settings.spacings.widthClef, 0), musicContext.getClef().getLp(), 1);
    notations.add(clefNotation);
    xOffset += context.settings.spacings.widthClef / 2;
    elements.add(new SimpleSpacing(clefNotation, Companion.fr(0), xOffset));
    xOffset += context.settings.spacings.widthClef / 2;
    if (useKey) {
        TraditionalKey tkey = (TraditionalKey) key;
        xOffset += context.settings.spacings.widthDistanceMin;
        // it is not the same element instance, but has the same meaning
        TraditionalKey tradKey = new TraditionalKey(tkey.getFifths(), tkey.getMode());
        TraditionalKeyNotation keyNotation = traditionalKeyNotator.compute(tradKey, context);
        notations.add(keyNotation);
        elements.add(new SimpleSpacing(keyNotation, Companion.fr(0), xOffset));
        xOffset += keyNotation.getWidth().getWidth();
    }
    return new LeadingSpacing(elements, xOffset);
}
Also used : ElementWidth(com.xenoage.zong.musiclayout.spacing.ElementWidth) LeadingSpacing(com.xenoage.zong.musiclayout.spacing.LeadingSpacing) SimpleSpacing(com.xenoage.zong.musiclayout.spacing.SimpleSpacing) Clef(com.xenoage.zong.core.music.clef.Clef) ClefNotation(com.xenoage.zong.musiclayout.notation.ClefNotation) TraditionalKey(com.xenoage.zong.core.music.key.TraditionalKey) MusicContext(com.xenoage.zong.core.music.MusicContext) ElementSpacing(com.xenoage.zong.musiclayout.spacing.ElementSpacing) TraditionalKeyNotation(com.xenoage.zong.musiclayout.notation.TraditionalKeyNotation) TraditionalKey(com.xenoage.zong.core.music.key.TraditionalKey) Key(com.xenoage.zong.core.music.key.Key)

Aggregations

ClefNotation (com.xenoage.zong.musiclayout.notation.ClefNotation)3 ElementWidth (com.xenoage.zong.musiclayout.spacing.ElementWidth)3 Clef (com.xenoage.zong.core.music.clef.Clef)2 ElementSpacing (com.xenoage.zong.musiclayout.spacing.ElementSpacing)2 LeadingSpacing (com.xenoage.zong.musiclayout.spacing.LeadingSpacing)2 MusicContext (com.xenoage.zong.core.music.MusicContext)1 Key (com.xenoage.zong.core.music.key.Key)1 TraditionalKey (com.xenoage.zong.core.music.key.TraditionalKey)1 Notations (com.xenoage.zong.musiclayout.notation.Notations)1 TraditionalKeyNotation (com.xenoage.zong.musiclayout.notation.TraditionalKeyNotation)1 SimpleSpacing (com.xenoage.zong.musiclayout.spacing.SimpleSpacing)1