Search in sources :

Example 1 with FramesSpacing

use of com.xenoage.zong.musiclayout.spacing.FramesSpacing in project Zong by Xenoage.

the class FramesSpacer method compute.

public FramesSpacing compute(List<ColumnSpacing> columns, Target target, Context context, Notations notations) {
    context.saveMp();
    ArrayList<FrameSpacing> frames = alist();
    int measuresCount = context.score.getMeasuresCount();
    int iMeasure = 0;
    int iSystem = 0;
    int iFrame = 0;
    boolean additionalFrameIteration;
    while (true) {
        additionalFrameIteration = false;
        // find score frame
        Size2f frameSize;
        if (iFrame < target.areas.size()) {
            // there is another existing score frame
            frameSize = target.getArea(iFrame).sizeMm;
        } else {
            // there is no another existing score frame
            if (false == target.isCompleteLayout) {
                // we are not interested in the stuff after the last score frame. exit.
                break;
            } else if (iMeasure >= measuresCount) {
                // all measures layouted. exit.
                break;
            } else {
                // still material to layout and additional frames requested. create one.
                frameSize = target.additionalArea.sizeMm;
                additionalFrameIteration = true;
            }
        }
        // some material left to layout?
        if (iMeasure < measuresCount) {
            // more measures to layout
            context.mp = atMeasure(iMeasure);
            FrameSpacing frame = frameSpacer.compute(context, iSystem, frameSize, additionalFrameIteration, columns, notations);
            if (frame.getSystems().size() > 0) {
                // at least one measure in this frame. remember frame
                frames.add(frame);
                iMeasure = frame.getEndMeasure() + 1;
                iSystem += frame.getSystems().size();
            } else {
                // do not create endless list of empty additional frames
                if (!additionalFrameIteration) {
                    frames.add(FrameSpacing.empty(frameSize));
                } else {
                    break;
                }
            }
        } else {
            // no material left. empty frame.
            frames.add(FrameSpacing.empty(frameSize));
        }
        // next frame
        iFrame++;
    }
    context.restoreMp();
    return new FramesSpacing(frames);
}
Also used : FramesSpacing(com.xenoage.zong.musiclayout.spacing.FramesSpacing) FrameSpacing(com.xenoage.zong.musiclayout.spacing.FrameSpacing) Size2f(com.xenoage.utils.math.geom.Size2f)

Example 2 with FramesSpacing

use of com.xenoage.zong.musiclayout.spacing.FramesSpacing in project Zong by Xenoage.

the class ScoreLayouter method createLayoutWithExceptions.

/**
 * Computes the whole layout and returns it.
 * If something fails, an exception is thrown.
 */
public ScoreLayout createLayoutWithExceptions() {
    // notations of elements
    Notations notations = notator.computeAll(context);
    // compute optimal measure column spacings
    List<ColumnSpacing> columns = columnsSpacer.compute(notations, context);
    // break columns into systems and frames
    FramesSpacing frames = framesSpacer.compute(columns, target, context, notations);
    // system stretching (horizontal)
    fillSystemsHorizontally(frames, target);
    // frame filling (vertical)
    fillFramesVertically(frames, target, context.score);
    // compute beam spacings. these are computed only now, after the horizontal
    // and vertical spacing of the score is fixed, since the beam slants depend on the
    // exact spacings
    Map<Beam, BeamSpacing> beams = beamsSpacer.compute(context.score, notations, frames);
    // create score frame layouts from the collected information
    List<ScoreFrameLayout> scoreFrameLayouts = createScoreFrameLayouts(frames, notations, context, beams);
    // create score layout
    return new ScoreLayout(context.score, scoreFrameLayouts, context.symbols, context.settings);
}
Also used : Beam(com.xenoage.zong.core.music.beam.Beam) FramesSpacing(com.xenoage.zong.musiclayout.spacing.FramesSpacing) BeamSpacing(com.xenoage.zong.musiclayout.spacing.BeamSpacing) ColumnSpacing(com.xenoage.zong.musiclayout.spacing.ColumnSpacing) Notations(com.xenoage.zong.musiclayout.notation.Notations) ScoreLayout(com.xenoage.zong.musiclayout.ScoreLayout) ScoreFrameLayout(com.xenoage.zong.musiclayout.ScoreFrameLayout)

Aggregations

FramesSpacing (com.xenoage.zong.musiclayout.spacing.FramesSpacing)2 Size2f (com.xenoage.utils.math.geom.Size2f)1 Beam (com.xenoage.zong.core.music.beam.Beam)1 ScoreFrameLayout (com.xenoage.zong.musiclayout.ScoreFrameLayout)1 ScoreLayout (com.xenoage.zong.musiclayout.ScoreLayout)1 Notations (com.xenoage.zong.musiclayout.notation.Notations)1 BeamSpacing (com.xenoage.zong.musiclayout.spacing.BeamSpacing)1 ColumnSpacing (com.xenoage.zong.musiclayout.spacing.ColumnSpacing)1 FrameSpacing (com.xenoage.zong.musiclayout.spacing.FrameSpacing)1