Search in sources :

Example 6 with PageFormat

use of com.xenoage.zong.core.format.PageFormat 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)6 PageFormat (com.xenoage.zong.core.format.PageFormat)6 PageMargins (com.xenoage.zong.core.format.PageMargins)5 ScoreFrame (com.xenoage.zong.layout.frames.ScoreFrame)4 Layout (com.xenoage.zong.layout.Layout)3 Page (com.xenoage.zong.layout.Page)3 Point2f (com.xenoage.utils.math.geom.Point2f)2 LayoutFormat (com.xenoage.zong.core.format.LayoutFormat)2 LayoutFormat.defaultLayoutFormat (com.xenoage.zong.core.format.LayoutFormat.defaultLayoutFormat)2 GroupFrame (com.xenoage.zong.layout.frames.GroupFrame)2 ScoreFrameChain (com.xenoage.zong.layout.frames.ScoreFrameChain)2 ScoreLayout (com.xenoage.zong.musiclayout.ScoreLayout)2 ScoreLayoutArea (com.xenoage.zong.musiclayout.layouter.ScoreLayoutArea)2 ScoreLayouter (com.xenoage.zong.musiclayout.layouter.ScoreLayouter)2 Target (com.xenoage.zong.musiclayout.layouter.Target)2 Paint (android.graphics.Paint)1 Score (com.xenoage.zong.core.Score)1 ScoreFormat (com.xenoage.zong.core.format.ScoreFormat)1 SystemLayout (com.xenoage.zong.core.format.SystemLayout)1 ColumnHeader (com.xenoage.zong.core.header.ColumnHeader)1