use of com.xenoage.zong.musiclayout.notation.TraditionalKeyNotation 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);
}
use of com.xenoage.zong.musiclayout.notation.TraditionalKeyNotation in project Zong by Xenoage.
the class TraditionalKeyNotator method compute.
public TraditionalKeyNotation compute(TraditionalKey key, Context context) {
// compute width
float width = 0;
int fifth = key.getFifths();
if (fifth > 0)
width = fifth * context.settings.spacings.widthSharp;
else
width = -fifth * context.settings.spacings.widthFlat;
ElementWidth keyWidth = new ElementWidth(0, width, 1);
// compute LPs
ClefType contextClef = context.score.getClef(context.mp, Before);
int c4Lp = contextClef.getLp(Companion.pi(0, 0, 4));
int minLp = contextClef.getKeySignatureLowestLp(fifth);
return new TraditionalKeyNotation(key, keyWidth, c4Lp, minLp);
}
Aggregations