Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This little Java SE demo application can be found in the "demos" project within the package com.xenoage.zong.demos.minimal.

It consists of a single class named MinimalDemo. (following on 2014-12-04)java, which contains just a few lines which convert a MusicXML file into a PDF file.

These are the most important lines:

Code Block
languagejava
JseZongPlatformUtils.init(appName);

Zong! is available on multiple platforms, including Java SE, Android and JavaScript, which have all different capabilities. Thus it is required to initialize each Zong!-based app with the platform specific functionality, which is available in the JseZongPlatformUtils class for Java SE. This call is required only once. If you forget it, Zong! will throw an exception as soon as you call I/O methods for example.

Code Block
languagejava
ScoreDoc doc = ScoreDocIO.read(inFile, new MusicXmlScoreDocFileInput());

ScoreDoc is the main document class of Zong!. It contains the page layout and the musical data of a document.

To get an instance of a ScoreDoc, you can use the read method of the ScoreDocIO class in Java SE. It expects two arguments: the input file and a format specific loader. In our case, we use the MusicXmlScoreDocFileInput class to load a MusicXML document. As you might imagine, there may exist other classes like XYZScoreDocFileInput to load a score from a file in XYZ format.

Code Block
languagejava
ScoreDocIO.write(doc, outFile, new PdfScoreDocFileOutput());

This line saves the given document in the given file using the given file format specific writer. Like before, there exist other writers like MidiScoreDocFileOutput for MIDI sequences or PngScoreDocFileOutput for PNG images.