Page 1 of 1

Open SVG conversion result

Posted: Wed May 16, 2018 1:52 pm
by bwbohl
Hi,

I' currently working on a framework for MEI (Music Encoding Initative) and I would like to include a rendering engine that generates SVGs from the XML encoding.

I tried two things so far

1) I successfully added a custom transformation scenario based on ant that executes a jar to generate the SVG and it will be opened in oxygen's text edit mode. Nevertheless it would be great to open it in Author Mode or in the SVG Viewer in order to see the image right away.

2) I defined custom Author actions that would launch the same command line call of the jar in order to generate the SVG. Is there a way to specify how to open the result of the action in oXygen. Opening it in system default is not what I want…

Many thanks!
Benjamin

Re: Open SVG conversion result

Posted: Wed May 16, 2018 3:30 pm
by Radu
Hi Benjamin,

So:
I' currently working on a framework for MEI (Music Encoding Initative) and I would like to include a rendering engine that generates SVGs from the XML encoding.
So somehow convert XML to an SVG which shows the sheet music equivalent? Nice idea.

I tried two things so far:
1) I successfully added a custom transformation scenario based on ant that executes a jar to generate the SVG and it will be opened in oxygen's text edit mode. Nevertheless it would be great to open it in Author Mode or in the SVG Viewer in order to see the image right away.
Somehow by default SVGs open in Oxygen in the Text editing mode.
If in the "Document Type Association" preferences page you edit the "SVG" framework configuration (or you extend and edit it) you can force set the "Initial edit mode".
Unfortunately for ANT-based transformation scenarios we do not have an option in the "Output" tab to open a certain file in the Oxygen image previewer.
2) I defined custom Author actions that would launch the same command line call of the jar in order to generate the SVG. Is there a way to specify how to open the result of the action in oXygen. Opening it in system default is not what I want…
Actually we also have API to run pre-configured transformation scenarios like authorAccess.getEditorAccess().runTransformationScenarios(allNames, null);. So your custom author action could also invoke the pre-configured scenario and after it finishes maybe it could use our API to open the SVG in the main editing area, imposing also the Author editing page for it:

Code: Select all

        authorAccess.getEditorAccess().runTransformationScenarios(allNames, new TransformationFeedback() {

@Override
public void transformationStopped() {
//
}

@Override
public void transformationFinished(boolean success) {
PluginWorkspaceProvider.getPluginWorkspace().open(...., EditorPageConstants.PAGE_AUTHOR);
}
});
You can also force the open to be done in the Oxygen internal Image Preview view:

Code: Select all

authorAccess.getWorkspaceAccess().open(new URL("file:/D:/path/to/svg/batik3D.svg"), null, "application/image");
because otherwise the SVG is opened as regular XML content in the main editing area.

Also if you plan to create your own custom view to render the SVG, for ours we use the "org.apache.batik.swing.gvt.JGVTComponent" component included in the Batik libraries which are already shipped with Oxygen. Probably on the Apache Batik web site you can see samples for loading SVG images in these "JGVTComponent"'s.

Regards,
Radu