Search in sources :

Example 1 with MxlPageMargins

use of com.xenoage.zong.musicxml.types.MxlPageMargins in project Zong by Xenoage.

the class LayoutFormatReader method readPageLayout.

private void readPageLayout() {
    MxlPageLayout mxlPageLayout = mxlLayout.getPageLayout();
    if (mxlPageLayout == null)
        return;
    Size2f size = PageFormat.Companion.getDefaultValue().getSize();
    // page-width and page-height
    Size2f mxlPageSize = mxlPageLayout.getPageSize();
    if (mxlPageSize != null)
        size = new Size2f(tenthsMm * mxlPageSize.width, tenthsMm * mxlPageSize.height);
    // page-margins
    PageMargins pageMarginsLeft = PageMargins.Companion.getDefaultValue();
    PageMargins pageMarginsRight = PageMargins.Companion.getDefaultValue();
    for (MxlPageMargins mxlMargins : mxlPageLayout.getPageMargins()) {
        PageMargins pageMargins = new PageMargins(tenthsMm * mxlMargins.getLeftMargin(), tenthsMm * mxlMargins.getRightMargin(), tenthsMm * mxlMargins.getTopMargin(), tenthsMm * mxlMargins.getBottomMargin());
        // left, right page or both? default: both
        switch(mxlMargins.getType()) {
            case Both:
                pageMarginsLeft = pageMargins;
                pageMarginsRight = pageMargins;
                break;
            case Odd:
                pageMarginsRight = pageMargins;
                break;
            case Even:
                pageMarginsRight = pageMargins;
                break;
        }
    }
    layoutFormat = new LayoutFormat(new PageFormat(size, pageMarginsLeft), new PageFormat(size, pageMarginsRight));
}
Also used : MxlPageMargins(com.xenoage.zong.musicxml.types.MxlPageMargins) PageMargins(com.xenoage.zong.core.format.PageMargins) PageFormat(com.xenoage.zong.core.format.PageFormat) MxlPageLayout(com.xenoage.zong.musicxml.types.MxlPageLayout) Size2f(com.xenoage.utils.math.geom.Size2f) LayoutFormat.defaultLayoutFormat(com.xenoage.zong.core.format.LayoutFormat.defaultLayoutFormat) LayoutFormat(com.xenoage.zong.core.format.LayoutFormat) MxlPageMargins(com.xenoage.zong.musicxml.types.MxlPageMargins)

Aggregations

Size2f (com.xenoage.utils.math.geom.Size2f)1 LayoutFormat (com.xenoage.zong.core.format.LayoutFormat)1 LayoutFormat.defaultLayoutFormat (com.xenoage.zong.core.format.LayoutFormat.defaultLayoutFormat)1 PageFormat (com.xenoage.zong.core.format.PageFormat)1 PageMargins (com.xenoage.zong.core.format.PageMargins)1 MxlPageLayout (com.xenoage.zong.musicxml.types.MxlPageLayout)1 MxlPageMargins (com.xenoage.zong.musicxml.types.MxlPageMargins)1