use of com.xenoage.zong.musiclayout.stampings.KeySignatureStamping in project Zong by Xenoage.
the class ElementStamper method createKeyStamping.
/**
* Creates a stamping for the given key signature.
*/
public KeySignatureStamping createKeyStamping(TraditionalKeyNotation key, float xMm, StamperContext context) {
val staff = context.getCurrentStaffStamping();
boolean useSharps = key.element.getFifths() > 0;
Symbol symbol = context.getSymbol(useSharps ? CommonSymbol.AccidentalSharp : CommonSymbol.AccidentalFlat);
Spacings spacings = context.getSettings().spacings;
float distance = (useSharps ? spacings.widthSharp : spacings.widthFlat);
return new KeySignatureStamping(key, xMm, staff, symbol, distance);
}
use of com.xenoage.zong.musiclayout.stampings.KeySignatureStamping in project Zong by Xenoage.
the class KeySignatureRenderer method draw.
/**
* Draws the given {@link KeySignatureStamping} on the given {@link Canvas},
* using the given {@link RendererArgs}.
*/
@Override
public void draw(Stamping stamping, Canvas canvas, RendererArgs args) {
KeySignatureStamping s = (KeySignatureStamping) stamping;
int fifths = s.key.element.getFifths();
if (fifths == 0)
return;
boolean useSharps = (fifths > 0);
float distance = s.distanceMm;
Symbol symbol = args.symbolPool.getSymbol(useSharps ? CommonSymbol.AccidentalSharp : CommonSymbol.AccidentalFlat);
// paint sharps/flats
fifths = Math.abs(fifths);
float interlineSpace = s.parentStaff.is;
for (int i = 0; i < fifths; i++) {
int linePosition = TraditionalKey.Companion.getLinePosition(i, useSharps, s.key.c4Lp, s.key.minLp);
StaffSymbolRenderer.drawWith(symbol, null, sp(s.xMm + i * distance * interlineSpace, linePosition), 1, s.parentStaff, false, canvas, args);
}
}
Aggregations