use of com.xenoage.zong.musiclayout.notation.TimeNotation in project Zong by Xenoage.
the class TimeNotator method compute.
public TimeNotation compute(TimeSignature time, Context context) {
// front and rear gap: 1 space
float gap = 1f;
// gap between digits: 0.1 space
float digitGap = 0.1f;
// the numbers of a normal time signature are centered.
// the width of the time signature is the width of the wider number
float numeratorWidth = context.symbols.computeNumberWidth(time.getType().getNumerator(), digitGap);
float denominatorWidth = context.symbols.computeNumberWidth(time.getType().getDenominator(), digitGap);
float width = Math.max(numeratorWidth, denominatorWidth);
// create element layout
float numeratorOffset = (width - numeratorWidth) / 2;
float denominatorOffset = (width - denominatorWidth) / 2;
return new TimeNotation(time, new ElementWidth(gap, width, gap), numeratorOffset, denominatorOffset, digitGap);
}
Aggregations