use of com.xenoage.zong.core.music.format.SP in project Zong by Xenoage.
the class DirectionStamper method createWords.
/**
* Creates a {@link StaffTextStamping} for the given {@link Words}.
*/
public StaffTextStamping createWords(Words words, StamperContext context) {
val staff = context.getCurrentStaffStamping();
if (words.getText().getLength() == 0)
return null;
// positioning
// below: 5 IS below the base line
// above (default): 4 IS above the top line
float defaultLPBelow = -5f * 2;
float defaultLPAbove = (staff.linesCount - 1) * 2 + 4 * 2;
SP p = computePosition(words, staff, defaultLPAbove, defaultLPAbove, defaultLPBelow);
// create text
// TODO: FormattedTextStyle(words.getFontInfo());
FormattedTextStyle style = FormattedTextStyle.Companion.getDefaultStyle();
FormattedText text = styleText(words.getText(), style);
// create stamping
return new StaffTextStamping(text, p, staff, words);
}
use of com.xenoage.zong.core.music.format.SP in project Zong by Xenoage.
the class DirectionStamper method createDynamics.
/**
* Creates a {@link StaffTextStamping} for the given {@link Dynamic}s.
*/
public StaffTextStamping createDynamics(Dynamic dynamics, StamperContext context) {
val staff = context.getCurrentStaffStamping();
// positioning
// below (default): 3 IS below the base line, or 2 IS below the lowest note
// above: 2 IS above the top line, or 1 IS above the highest note
float defaultLPBelow = -3f * 2;
float defaultLPAbove = (context.getCurrentStaffStamping().linesCount - 1) * 2 + 2 * 2;
SP sp = computePosition(dynamics, staff, defaultLPBelow, defaultLPAbove, defaultLPBelow);
// create text
CList<FormattedTextElement> elements = clist();
for (CommonSymbol s : CommonSymbol.getDynamics(dynamics.getValue())) {
Symbol symbol = context.getSymbol(s);
elements.add(new FormattedTextSymbol(symbol, staff.is * FONT_SIZE_IN_IS, FormattedTextStyle.Companion.getDefaultColor()));
}
elements.close();
FormattedTextParagraph paragraph = new FormattedTextParagraph(elements, Alignment.Center);
FormattedText text = Companion.fText(paragraph);
// create stamping
return new StaffTextStamping(text, sp, staff, dynamics);
}
use of com.xenoage.zong.core.music.format.SP in project Zong by Xenoage.
the class DirectionStamper method createTempo.
/**
* Creates a {@link StaffTextStamping} for the given {@link Tempo}.
*/
public StaffTextStamping createTempo(Tempo tempo, StamperContext context) {
val staff = context.getCurrentStaffStamping();
// positioning
// below: 3 IS below the base line
// above (default): 2 IS above the top line
float defaultLPBelow = -3f * 2;
float defaultLPAbove = (staff.linesCount - 1) * 2 + 2 * 2;
SP p = computePosition(tempo, staff, defaultLPAbove, defaultLPAbove, defaultLPBelow);
// create text
FormattedText text = getTempoTextNotNull(tempo, context.layouter.symbols);
// create stamping
return new StaffTextStamping(text, p, staff, tempo);
}
use of com.xenoage.zong.core.music.format.SP in project Zong by Xenoage.
the class ElementStamper method createRestStamping.
/**
* Creates a stamping for the given rest.
*/
public StaffSymbolStamping createRestStamping(RestSpacing rest, float xMm, StamperContext context) {
val staff = context.getCurrentStaffStamping();
Symbol symbol = getRestSymbol(rest.getNotation().duration, context);
SP sp = sp(xMm, rest.lp);
return new StaffSymbolStamping(rest.notation, staff, symbol, null, sp, 1, false);
}
use of com.xenoage.zong.core.music.format.SP in project Zong by Xenoage.
the class SlurStamper method createForMiddleSystem.
/**
* Creates a {@link SlurStamping} for a curved line that
* starts at an earlier system and ends at a later system, but
* spans also the given system.
*/
SlurStamping createForMiddleSystem(StaffStamping staff, Slur slur) {
if (slur.getType() == SlurType.Tie) {
// ties can not have middle staves
return null;
}
// end points of the bezier curve
float p1x = staff.positionMm.x + staff.system.getMeasureStartAfterLeadingMm(staff.system.getStartMeasure()) - // TODO
5;
float p2x = staff.positionMm.x + staff.lengthMm;
float lp;
if (slur.getSide() == VSide.Top)
// 1 IS over the top staff line
lp = (staff.linesCount - 1) * 2 + 2;
else
// 1 IS below the bottom staff line
lp = -2;
SP p1 = sp(p1x, lp);
SP p2 = sp(p2x, lp);
// control points of the bezier curve
// default formatting
SP c1 = computeLeftControlPoint(slur, p1, p2, staff);
// default formatting
SP c2 = computeRightControlPoint(slur, p1, p2, staff);
return new SlurStamping(slur, p1, p2, c1, c2, staff, staff);
}
Aggregations