use of com.xenoage.zong.core.format.Break in project Zong by Xenoage.
the class SystemSpacer method canAppend.
/**
* Returns true, if the given measure can be appended to the currently computed system,
* otherwise false.
* It is not tested if there is enough vertical space, this must be done before.
*/
public boolean canAppend(ColumnSpacing column, int measureIndex, float usableWidthMm, float usedWidthMm, ScoreHeader scoreHeader, boolean isFirstMeasure) {
// if a line break is forced, do it (but one measure is always allowed)
Break br = scoreHeader.getColumnHeader(measureIndex).getMeasureBreak();
if (br != null && br.getSystemBreak() == SystemBreak.NewSystem && false == isFirstMeasure)
return false;
// if a line break is prohibited, force the measure to be within this system
if (br != null && br.getSystemBreak() == SystemBreak.NoNewSystem)
return true;
// enough horizontal space?
float remainingWidthMm = usableWidthMm - usedWidthMm;
if (remainingWidthMm < column.getWidthMm())
return false;
// ok, append the measure
return true;
}
use of com.xenoage.zong.core.format.Break in project Zong by Xenoage.
the class PrintReader method readToContext.
public void readToContext(Context context) {
ScoreHeader header = context.getScore().getHeader();
int measure = context.getMp().measure;
// system and page break
Break break_ = readBreak();
if (break_ != null) {
// MusicXML print is in the first broken measure, but we
// store the break in the last measure before the break (thus -1)
int breakMeasure = measure - 1;
if (// ignore, when in the first measure
breakMeasure >= 0)
context.writeColumnElement(break_, breakMeasure);
}
// the first measure of a score is also ok.
if (measure == 0 || break_ != null) {
// first page or new page?
boolean isPageBreak = break_ != null && break_.getPageBreak() == PageBreak.NewPage;
boolean isPageStarted = (measure == 0 || isPageBreak);
if (isPageBreak) {
// increment page index
context.incPageIndex();
}
// first system or new system?
boolean isSystemBreak = isPageBreak || (break_ != null && break_.getSystemBreak() == SystemBreak.NewSystem);
if (isSystemBreak) {
// increment system index
context.incSystemIndex();
}
// read system layout, if there
SystemLayout systemLayout = readSystemLayout(isPageStarted, context.getTenthMm());
if (systemLayout != null)
header.setSystemLayout(context.getSystemIndex(), systemLayout);
// staff layouts
MxlLayout mxlLayout = mxlPrint.getLayout();
if (mxlLayout != null) {
for (MxlStaffLayout mxlStaffLayout : it(mxlLayout.getStaffLayouts())) {
int staffIndex = mxlStaffLayout.getNumberNotNull() - 1;
// get system layout. if it does not exist yet, create it
systemLayout = header.getSystemLayout(context.getSystemIndex());
if (systemLayout == null) {
systemLayout = new SystemLayout();
header.setSystemLayout(context.getSystemIndex(), systemLayout);
}
StaffLayout staffLayout = new StaffLayoutReader(mxlStaffLayout, context.getTenthMm()).read();
systemLayout.setStaffLayout(context.getPartStaffIndices().getStart() + staffIndex, staffLayout);
}
}
}
}
use of com.xenoage.zong.core.format.Break in project Zong by Xenoage.
the class PrintReader method readBreak.
private Break readBreak() {
MxlPrintAttributes mxlPA = mxlPrint.getPrintAttributes();
SystemBreak systemBreak = readSystemBreak(mxlPA.getNewSystem());
PageBreak pageBreak = readPageBreak(mxlPA.getNewPage());
if (systemBreak != null || pageBreak != null)
return new Break(pageBreak, systemBreak);
return null;
}
Aggregations