use of com.xenoage.zong.core.Score in project Zong by Xenoage.
the class Test45b method test.
@Test
public void test() {
Score score = getScore();
assertEqualsEndBarlines(expectedEndBarlines, score);
assertEqualsVoltas(expectedVoltas, score);
}
use of com.xenoage.zong.core.Score in project Zong by Xenoage.
the class Test45c method test.
@Test
public void test() {
Score score = getScore();
assertEqualsStartBarlines(expectedStartBarlines, score);
assertEqualsEndBarlines(expectedEndBarlines, score);
}
use of com.xenoage.zong.core.Score in project Zong by Xenoage.
the class Test45g method test.
@Test
public void test() {
Score score = getScore();
assertEqualsStartBarlines(expectedStartBarlines, score);
assertEqualsEndBarlines(expectedEndBarlines, score);
}
use of com.xenoage.zong.core.Score in project Zong by Xenoage.
the class Base46e method getExpectedStaff.
static Staff getExpectedStaff() {
Score score = ScoreFactory.create1Staff();
Cursor cursor = new Cursor(score, mp0, true);
cursor.write(new TimeSignature(TimeType.Companion.getTimeCommon()));
// measure 0, voice 0
cursor.write(chord(Companion.pi('C', 0, 5), Companion.fr(1, 4)));
// measure 1, voice 0
cursor.setMp(atElement(0, 1, 0, 0));
cursor.write(chord(Companion.pi('C', 0, 5), Companion.fr(1, 4)));
cursor.write(chord(Companion.pi('A', 0, 4), Companion.fr(1, 4)));
cursor.write(chord(Companion.pi('F', 0, 4), Companion.fr(1, 4)));
cursor.write(chord(Companion.pi('C', 0, 5), Companion.fr(1, 4)));
// measure 1, voice 1
cursor.setMp(atElement(0, 1, 1, 0));
cursor.write(new Rest(Companion.fr(1, 4)));
cursor.write(chord(Companion.pi('C', 0, 4), Companion.fr(1, 4)));
return score.getStaff(0);
}
use of com.xenoage.zong.core.Score in project Zong by Xenoage.
the class SystemSpacer method compute.
/**
* Arranges an optimum number of measures columns in a system, beginning at the given measure,
* if possible.
* @param context the context of the layouter, with the {@link MP} set to the start measure
* @param usableSizeMm the usable size within the score frame in mm
* @param offsetYMm the vertical offset of the system in mm
* @param systemIndex the global system index (over all frames)
* @param isFirst true, iff this system is the first one in a score frame
* @param isAdditional true, iff this system is created for an additional frame, which is created
* for a complete score layout, but is not part of the defined layout
* @param measureColumnSpacings a list of all measure column spacings without leading spacings
* @param notations the notations of the elements, needed when a column has to be recomputed
* because of a leading spacing
*/
public Optional<SystemSpacing> compute(Context context, Size2f usableSizeMm, float offsetYMm, int systemIndex, boolean isFirst, boolean isAdditional, List<ColumnSpacing> measureColumnSpacings, Notations notations) {
int startMeasure = context.mp.measure;
// test if there is enough height for the system
Score score = context.score;
ScoreFormat scoreFormat = score.getFormat();
ScoreHeader scoreHeader = score.getHeader();
// compute spacing of staves
StavesSpacing stavesSpacing = stavesSpacer.compute(score, systemIndex);
// enough space?
if (offsetYMm + stavesSpacing.getTotalHeightMm() > usableSizeMm.height) {
// when the system is the first one in an additional frame, we force it into the frame
if (false == (isFirst && isAdditional))
// not enough space
return absent();
}
// compute the usable width for the system
float systemLeftMarginMm = getLeftMarginMm(systemIndex, scoreFormat, scoreHeader);
float systemRightMarginMm = getRightMarginMm(systemIndex, scoreFormat, scoreHeader);
float usableWidthMm = usableSizeMm.width - systemLeftMarginMm - systemRightMarginMm;
// append system measure-by-measure, until there is no space any more
// or until there are no measures left
int measuresCount = score.getMeasuresCount();
List<ColumnSpacing> system = alist();
float usedWidthMm = 0;
int iMeasure;
while (startMeasure + system.size() < measuresCount) {
iMeasure = startMeasure + system.size();
// decide if to add a leading spacing to the current measure or not
boolean firstMeasure = system.size() == 0;
ColumnSpacing column;
if (firstMeasure) {
// first measure within this system: add leading elements (clef, time sig.)
column = columnSpacer.compute(context, true, /* leading! */
notations);
} else {
// otherwise: use the precomputed spacing (without leading spacing)
column = measureColumnSpacings.get(iMeasure);
}
// this system is created for a complete score layout
if (false == canAppend(column, iMeasure, usableWidthMm, usedWidthMm, scoreHeader, firstMeasure)) {
if (system.size() == 0 && isAdditional) {
// force the single measure in this system
usedWidthMm += column.getWidthMm();
system.add(column);
} else {
// no more space for another measure
break;
}
} else {
usedWidthMm += column.getWidthMm();
system.add(column);
}
}
// we are finished
if (system.size() == 0) {
// not enough space for the system on this area
return absent();
} else {
SystemSpacing ret = new SystemSpacing(system, systemLeftMarginMm, systemRightMarginMm, usedWidthMm, stavesSpacing, offsetYMm);
return of(ret);
}
}
Aggregations