use of com.xenoage.zong.io.musicxml.in.MusicXmlScoreDocFileReader in project Zong by Xenoage.
the class WebApp method openFile.
private void openFile(String filePath) {
// show loading, hide score
if (loadingPanel != null)
loadingPanel.getStyle().setDisplay(BLOCK);
canvas.setVisible(false);
// load score
platformUtils().openFileAsync(filePath).thenAsync(scoreStream -> new MusicXmlScoreDocFileReader(scoreStream, null).read()).thenAsync(scoreDoc -> {
WebApp.this.scoreDoc = scoreDoc;
return platformUtils().openFileAsync("data/layout/default.xml");
}).thenDo(testXmlStream -> {
LayoutSettings layoutSettings;
try {
layoutSettings = LayoutSettingsReader.read(testXmlStream);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
Size2f areaSize = new Size2f(150, 10000);
SymbolPool symbolPool = zongPlatformUtils().getSymbolPool();
Context context = new Context(scoreDoc.getScore(), symbolPool, layoutSettings);
Target target = Target.completeLayoutTarget(new ScoreLayoutArea(areaSize));
paintLayout();
// show score, hide loading
canvas.setVisible(true);
if (loadingPanel != null)
loadingPanel.getStyle().setDisplay(NONE);
}).onError(ex -> consoleLog("Error: " + ex.toString()));
}
use of com.xenoage.zong.io.musicxml.in.MusicXmlScoreDocFileReader in project Zong by Xenoage.
the class App method load.
/**
* Loads the {@link ScoreDoc} with the given filename.
*/
public static ScoreDoc load(String filename) throws IOException {
String filepath = "files/" + filename;
InputStream in = io().openFile(filepath);
try {
return sync(new MusicXmlScoreDocFileReader(in, filepath).read());
} catch (Exception ex) {
throw new IOException(ex);
}
}
Aggregations