Search in sources :

Example 6 with ScoreFrameChain

use of com.xenoage.zong.layout.frames.ScoreFrameChain in project Zong by Xenoage.

the class Layout method computeLP.

/**
 * Returns the {@link LayoutPos} of the given {@link MP} within the given {@link Score}
 * at the given line position, or null if unknown.
 */
public LayoutPos computeLP(Score score, MP mp, float lp) {
    ScoreFrameChain chain = getScoreFrameChain(score);
    if (chain != null) {
        ScoreLayout sl = chain.getScoreLayout();
        ScoreLayoutPos slp = sl.getScoreLP(mp, lp);
        if (slp != null) {
            ScoreFrame frame = chain.getFrames().get(slp.frameIndex);
            Page page = frame.getParentPage();
            if (page != null) {
                Point2f frameP = slp.pMm.sub(frame.getSize().width / 2, frame.getSize().height / 2);
                int pageIndex = pages.indexOf(page);
                Point2f pMm = frame.getPagePosition(frameP);
                return layoutPos(this, pageIndex, pMm);
            }
        }
    }
    return null;
}
Also used : ScoreFrame(com.xenoage.zong.layout.frames.ScoreFrame) Point2f(com.xenoage.utils.math.geom.Point2f) ScoreFrameChain(com.xenoage.zong.layout.frames.ScoreFrameChain) ScoreLayout(com.xenoage.zong.musiclayout.ScoreLayout) ScoreLayoutPos(com.xenoage.zong.musiclayout.ScoreLayoutPos)

Aggregations

ScoreFrameChain (com.xenoage.zong.layout.frames.ScoreFrameChain)6 ScoreFrame (com.xenoage.zong.layout.frames.ScoreFrame)4 ScoreLayout (com.xenoage.zong.musiclayout.ScoreLayout)4 Point2f (com.xenoage.utils.math.geom.Point2f)3 ScoreLayoutArea (com.xenoage.zong.musiclayout.layouter.ScoreLayoutArea)3 ScoreLayouter (com.xenoage.zong.musiclayout.layouter.ScoreLayouter)3 Target (com.xenoage.zong.musiclayout.layouter.Target)3 Size2f (com.xenoage.utils.math.geom.Size2f)2 PageFormat (com.xenoage.zong.core.format.PageFormat)2 Layout (com.xenoage.zong.layout.Layout)2 Page (com.xenoage.zong.layout.Page)2 Context (com.xenoage.zong.musiclayout.layouter.Context)2 Paint (android.graphics.Paint)1 Untested (com.xenoage.utils.annotations.Untested)1 Score (com.xenoage.zong.core.Score)1 LayoutFormat (com.xenoage.zong.core.format.LayoutFormat)1 LayoutFormat.defaultLayoutFormat (com.xenoage.zong.core.format.LayoutFormat.defaultLayoutFormat)1 PageMargins (com.xenoage.zong.core.format.PageMargins)1 ScoreFormat (com.xenoage.zong.core.format.ScoreFormat)1 SystemLayout (com.xenoage.zong.core.format.SystemLayout)1