Search in sources :

Example 1 with StaffLayout

use of com.xenoage.zong.core.format.StaffLayout in project Zong by Xenoage.

the class StavesSpacer method compute.

public StavesSpacing compute(Score score, int systemIndex) {
    // compute staff distances
    ScoreFormat scoreFormat = score.getFormat();
    ScoreHeader scoreHeader = score.getHeader();
    float[] distancesMm = new float[score.getStavesCount() - 1];
    for (int iStaff : range(1, distancesMm.length)) {
        StaffLayout staffLayout = scoreHeader.getStaffLayout(systemIndex, iStaff);
        float staffDistanceMm = 0;
        if (staffLayout != null) {
            // use custom staff distance
            staffDistanceMm = staffLayout.getDistance();
        } else {
            // use default staff distance
            staffDistanceMm = scoreFormat.getStaffLayoutNotNull(iStaff).getDistance();
        }
        distancesMm[iStaff - 1] = staffDistanceMm;
    }
    // create spacing
    StavesSpacing stavesSpacing = new StavesSpacing(score.getStavesList().getStaves(), distancesMm, scoreFormat.getInterlineSpace());
    return stavesSpacing;
}
Also used : ScoreFormat(com.xenoage.zong.core.format.ScoreFormat) ScoreHeader(com.xenoage.zong.core.header.ScoreHeader) StavesSpacing(com.xenoage.zong.musiclayout.spacing.StavesSpacing) StaffLayout(com.xenoage.zong.core.format.StaffLayout)

Example 2 with StaffLayout

use of com.xenoage.zong.core.format.StaffLayout 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);
            }
        }
    }
}
Also used : ScoreHeader(com.xenoage.zong.core.header.ScoreHeader) MxlStaffLayout(com.xenoage.zong.musicxml.types.MxlStaffLayout) StaffLayout(com.xenoage.zong.core.format.StaffLayout) SystemLayout(com.xenoage.zong.core.format.SystemLayout) MxlSystemLayout(com.xenoage.zong.musicxml.types.MxlSystemLayout) SystemBreak(com.xenoage.zong.core.music.layout.SystemBreak) PageBreak(com.xenoage.zong.core.music.layout.PageBreak) Break(com.xenoage.zong.core.format.Break) MxlLayout(com.xenoage.zong.musicxml.types.groups.MxlLayout) MxlStaffLayout(com.xenoage.zong.musicxml.types.MxlStaffLayout) MxlPrint(com.xenoage.zong.musicxml.types.MxlPrint)

Example 3 with StaffLayout

use of com.xenoage.zong.core.format.StaffLayout in project Zong by Xenoage.

the class ScoreFormatReader method readStaffLayouts.

private void readStaffLayouts() {
    if (mxlLayout.getStaffLayouts() == null)
        return;
    for (MxlStaffLayout mxlStaffLayout : mxlLayout.getStaffLayouts()) {
        StaffLayoutReader staffLayoutReader = new StaffLayoutReader(mxlStaffLayout, tenthsMm);
        StaffLayout staffLayout = staffLayoutReader.read();
        Integer number = staffLayoutReader.getNumber();
        if (number == null)
            scoreFormat.setStaffLayoutOther(staffLayout);
        else
            scoreFormat.setStaffLayout(number - 1, staffLayout);
    }
}
Also used : StaffLayout(com.xenoage.zong.core.format.StaffLayout) MxlStaffLayout(com.xenoage.zong.musicxml.types.MxlStaffLayout) MxlStaffLayout(com.xenoage.zong.musicxml.types.MxlStaffLayout)

Aggregations

StaffLayout (com.xenoage.zong.core.format.StaffLayout)3 ScoreHeader (com.xenoage.zong.core.header.ScoreHeader)2 MxlStaffLayout (com.xenoage.zong.musicxml.types.MxlStaffLayout)2 Break (com.xenoage.zong.core.format.Break)1 ScoreFormat (com.xenoage.zong.core.format.ScoreFormat)1 SystemLayout (com.xenoage.zong.core.format.SystemLayout)1 PageBreak (com.xenoage.zong.core.music.layout.PageBreak)1 SystemBreak (com.xenoage.zong.core.music.layout.SystemBreak)1 StavesSpacing (com.xenoage.zong.musiclayout.spacing.StavesSpacing)1 MxlPrint (com.xenoage.zong.musicxml.types.MxlPrint)1 MxlSystemLayout (com.xenoage.zong.musicxml.types.MxlSystemLayout)1 MxlLayout (com.xenoage.zong.musicxml.types.groups.MxlLayout)1