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;
}
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);
}
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);
}
Aggregations