use of com.xenoage.zong.musiclayout.stampings.StaffTextStamping in project Zong by Xenoage.
the class BarlinesStamper method stamp.
public List<Stamping> stamp(SystemSpacing system, List<StaffStamping> systemStaves, Score score) {
List<Stamping> ret = alist();
StaffStamping firstStaff = getFirst(systemStaves);
int stavesCount = systemStaves.size();
int systemIndex = system.getSystemIndexInFrame();
float xOffset = firstStaff.positionMm.x;
// common barline at the beginning, when system has at least one measure
if (system.columns.size() > 0) {
ret.add(new BarlineStamping(Barline.Companion.barlineRegular(), systemStaves, xOffset, BarlineGroup.Style.Common));
}
// barlines within the system and measure numbers
for (int iMeasure : range(system.columns)) {
float xLeft = xOffset;
// measure numbering
MeasureNumbering measureNumbering = score.getFormat().getMeasureNumbering();
int globalMeasureIndex = system.getStartMeasure() + iMeasure;
boolean showMeasureNumber = false;
if (measureNumbering == MeasureNumbering.System) {
// measure number at the beginning of each system (except the first one)
showMeasureNumber = (iMeasure == 0 && globalMeasureIndex > 0);
} else if (measureNumbering == MeasureNumbering.Measure) {
// measure number at each measure (except the first one)
showMeasureNumber = (globalMeasureIndex > 0);
}
if (showMeasureNumber) {
FormattedText text = Companion.fText("" + (globalMeasureIndex + 1), new FormattedTextStyle(8), Alignment.Left);
ret.add(new StaffTextStamping(text, sp(xLeft, firstStaff.linesCount * 2), firstStaff, null));
}
// for the first measure in the system: begin after leading spacing
if (iMeasure == 0)
xLeft += system.columns.get(iMeasure).getLeadingWidthMm();
xOffset += system.columns.get(iMeasure).getWidthMm();
float xRight = xOffset;
// regard the groups of the score
for (int iStaff : range(stavesCount)) {
ColumnHeader columnHeader = score.getColumnHeader(globalMeasureIndex);
BarlineGroup.Style barlineGroupStyle = BarlineGroup.Style.Single;
BarlineGroup group = score.getStavesList().getBarlineGroupByStaff(iStaff);
if (group != null)
barlineGroupStyle = group.getStyle();
List<StaffStamping> groupStaves = getBarlineGroupStaves(systemStaves, group);
// start barline
Barline startBarline = columnHeader.getStartBarline();
if (startBarline != null) {
// don't draw a regular barline at the left side of first measure of a system
if ((startBarline.getStyle() == BarlineStyle.Regular && systemIndex == 0) == false)
ret.add(new BarlineStamping(startBarline, groupStaves, xLeft, barlineGroupStyle));
}
// end barline. if none is set, use a regular one.
Barline endBarline = columnHeader.getEndBarline();
if (endBarline == null)
endBarline = Barline.Companion.barlineRegular();
ret.add(new BarlineStamping(endBarline, groupStaves, xRight, barlineGroupStyle));
// middle barlines
for (BeatE<Barline> middleBarline : columnHeader.getMiddleBarlines()) {
ret.add(new BarlineStamping(middleBarline.getElement(), groupStaves, xLeft + system.columns.get(iMeasure).getBarlineOffsetMm(middleBarline.getBeat()), barlineGroupStyle));
}
// go to next group
if (group != null)
iStaff = group.getStaves().getStop();
}
}
return ret;
}
use of com.xenoage.zong.musiclayout.stampings.StaffTextStamping 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.musiclayout.stampings.StaffTextStamping 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.musiclayout.stampings.StaffTextStamping 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);
}
Aggregations