Search in sources :

Example 1 with SymbolPoolReader

use of com.xenoage.zong.io.symbols.SymbolPoolReader in project Zong by Xenoage.

the class GwtZongPlatformUtils method init.

/**
 * Initializes the {@link GwtZongPlatformUtils} as the {@link ZongPlatformUtils} instance
 * and {@link GwtPlatformUtils} as the {@link PlatformUtils} instance.
 */
public static void init(final AsyncCallback finished) {
    GwtPlatformUtils.init();
    ZongPlatformUtils.init(instance);
    // load default symbol pool
    new SymbolPoolReader("default").produce(new AsyncResult<SymbolPool>() {

        @Override
        public void onSuccess(SymbolPool symbolPool) {
            instance.symbolPool = symbolPool;
            finished.onSuccess();
        }

        @Override
        public void onFailure(Exception ex) {
            finished.onFailure(ex);
        }
    });
}
Also used : SymbolPoolReader(com.xenoage.zong.io.symbols.SymbolPoolReader) SymbolPool(com.xenoage.zong.symbols.SymbolPool)

Example 2 with SymbolPoolReader

use of com.xenoage.zong.io.symbols.SymbolPoolReader in project Zong by Xenoage.

the class DemoScoreLayoutTry method main.

public static void main(String... args) throws Exception {
    SymbolPool symbolPool = sync(new SymbolPoolReader("default"));
    LayoutSettings layoutSettings = LayoutSettingsReader.read(jsePlatformUtils().openFile("data/test/layout/LayoutSettingsTest.xml"));
    try {
        Score score = ScoreRevolutionary.createScore();
        Size2f areaSize = new Size2f(150, 10000);
        Context context = new Context(score, symbolPool, layoutSettings);
        Target target = Target.completeLayoutTarget(new ScoreLayoutArea(areaSize));
        ScoreLayout layout = new ScoreLayouter(context, target).createLayoutWithExceptions();
        System.out.println(layout.toString());
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : SymbolPoolReader(com.xenoage.zong.io.symbols.SymbolPoolReader) Score(com.xenoage.zong.core.Score) LayoutSettings(com.xenoage.zong.musiclayout.settings.LayoutSettings) Size2f(com.xenoage.utils.math.geom.Size2f) SymbolPool(com.xenoage.zong.symbols.SymbolPool) ScoreLayout(com.xenoage.zong.musiclayout.ScoreLayout)

Example 3 with SymbolPoolReader

use of com.xenoage.zong.io.symbols.SymbolPoolReader in project Zong by Xenoage.

the class ScoreLayouterTest method testSampleFiles.

/**
 * Try to layout all official MusicXML 1.1 and 2.0 sample files.
 * We can not test for the correct layout of course, but at least
 * we want to have no exceptions.
 */
@Test
public void testSampleFiles() throws Exception {
    SymbolPool symbolPool = sync(new SymbolPoolReader("default"));
    LayoutSettings layoutSettings = LayoutSettingsReader.read(jsePlatformUtils().openFile("data/test/layout/LayoutSettingsTest.xml"));
    for (String file : MusicXmlScoreFileInputTest.getSampleFiles()) {
        try {
            // System.out.println(file);
            Score score = new MusicXmlScoreFileInput().read(jsePlatformUtils().openFile(file), file);
            Size2f areaSize = new Size2f(150, 10000);
            Context context = new Context(score, symbolPool, layoutSettings);
            Target target = Target.completeLayoutTarget(new ScoreLayoutArea(areaSize));
            ScoreLayouter layouter = new ScoreLayouter(context, target);
            layouter.createLayoutWithExceptions();
        } catch (Exception ex) {
            ex.printStackTrace();
            fail("Failed to layout file: " + file);
        }
    }
}
Also used : SymbolPoolReader(com.xenoage.zong.io.symbols.SymbolPoolReader) Score(com.xenoage.zong.core.Score) LayoutSettings(com.xenoage.zong.musiclayout.settings.LayoutSettings) Size2f(com.xenoage.utils.math.geom.Size2f) SymbolPool(com.xenoage.zong.symbols.SymbolPool) MusicXmlScoreFileInput(com.xenoage.zong.io.musicxml.in.MusicXmlScoreFileInput) MusicXmlScoreFileInputTest(com.xenoage.zong.io.musicxml.in.MusicXmlScoreFileInputTest) Test(org.junit.Test)

Aggregations

SymbolPoolReader (com.xenoage.zong.io.symbols.SymbolPoolReader)3 SymbolPool (com.xenoage.zong.symbols.SymbolPool)3 Size2f (com.xenoage.utils.math.geom.Size2f)2 Score (com.xenoage.zong.core.Score)2 LayoutSettings (com.xenoage.zong.musiclayout.settings.LayoutSettings)2 MusicXmlScoreFileInput (com.xenoage.zong.io.musicxml.in.MusicXmlScoreFileInput)1 MusicXmlScoreFileInputTest (com.xenoage.zong.io.musicxml.in.MusicXmlScoreFileInputTest)1 ScoreLayout (com.xenoage.zong.musiclayout.ScoreLayout)1 Test (org.junit.Test)1