Search in sources :

Example 1 with ScoreLayoutPos

use of com.xenoage.zong.musiclayout.ScoreLayoutPos 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

Point2f (com.xenoage.utils.math.geom.Point2f)1 ScoreFrame (com.xenoage.zong.layout.frames.ScoreFrame)1 ScoreFrameChain (com.xenoage.zong.layout.frames.ScoreFrameChain)1 ScoreLayout (com.xenoage.zong.musiclayout.ScoreLayout)1 ScoreLayoutPos (com.xenoage.zong.musiclayout.ScoreLayoutPos)1