EAVP Service Integration
This article provides instructions for how to make use of the Eclipse Advanced Visualization Project's visualization services in an RCP application.
EAVP's visualization suite is provided through OSGI services. Consuming these services requires some set up in the bundle. Inside a folder named OSGI-INF, you must have an xml file with content similar to the following:
<?xml version="1.0" encoding="UTF-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.example.ServiceConsumerName"> <implementation class="org.eclipse.example.ClassName"/> <reference bind="setVizServiceFactory" cardinality="1..1" interface="org.eclipse.eavp.viz.service.IVizServiceFactory" name="IVizServiceFactory" policy="dynamic"/> </scr:component>
"org.eclipse.example.ServiceConsumerName" can be replaced with whatever name you want, while "org.eclipse.example.ClassName" must specify a class with a setVizServiceFactory(IVizServiceFactory) method. This class will receive the IVizServiceFactory and this method should save it for future use.
In your MANIFEST.MF file, add the following line:
Alternatively, you may explicitly list each .xml file you wish to use for your Service-Component, each on a separate line.
Next, ensure that the xml files you created are included in your build.properties file. If not, check their check-boxes in the editor.
Finally, you must set the service containing bundles to auto-start. You must do this for org.eclipse.eavp.viz.service and for the bundles of any other services you wish to use. For example, you will have to set org.eclipse.eavp.viz.service.visit to auto-start in order to use VisIt support.
To set the start levels in your executable, open your .product file and switch to the Configuration tab. In the Start Levels section, find the required bundles and set their Auto-Start status to true.
To do this for launch configuration, select Run -> Run Configurations... from the toolbar. Select your run configuration from under the Eclipse Application category in the tree and switch to the Plug-ins tab. You can set the Auto-Start property for the required plug-ins to true in this menu.
Using the Services
To use a service, you must retrieve it from the factory and then create the visualization from it. Use the factory's .get(String) operation to retrieve a service by name. You can specify a literal name (which must match the return value from the desired service's getName() operation) to get a service. Alternatively, you can get the names of all services with getServiceNames(), and can iterate through the services using them, invoking getSupportedExtensions() on each one to test which files they can handle.
Then invoke createPlot() to open a file URI or createCanvas() to open an EAVP Geometry object, whichever is supported by the viz service. Then call .draw(Composite) to draw the visualization to a Composite.
Some IPlots may offer additional views of the data. If getNumAdditionalPages() returns a number greater than zero, you can draw these extra views in a MultiPageEditorPart using the createAdditionalPage() function.
For examples of working with the visualizations after they have been implemented, see the sample documentation for ICE: