简体   繁体   中英

MusicXML files in java swing - visual representation and dynamic editing

I'm developing a desktop application with java swing which should be able to display the visual content (notes, clefs, measures) defined in a MusicXML file in the frame. All .xml parsers that I found allow me to only create trees. I couldn't display the content with the JEditorPane, too.

Can I do it or will I need to first transform it dynamically to some other format such as .pdf? If so - how can I do it in java?

Use a JTextArea to let the user edit raw XML. Load the file in the background using SwingWorker , as shown here , to mitigate the effect of any latency.

图片

@Override
protected Integer doInBackground() {
    BufferedReader in = null;
    try {
        in = new BufferedReader(new FileReader("build.xml"));
        String s;
        try {
            while ((s = in.readLine()) != null) {
                publish(s);
            }
        } catch (IOException ex) {
            ex.printStackTrace(System.err);
        }
    } catch (FileNotFoundException ex) {
        ex.printStackTrace(System.err);
    } finally {
        try {
            in.close();
        } catch (IOException ex) {
            ex.printStackTrace(System.err);
        }
    }
    return status;
}

By visual representation, I meant that I needed a way to display this type of visual output .

You might look at the JMusicXML project, which has "some Java awt/swing graphics player." More resources may be found here .

图片

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM