Servoy Stuff - Home of all Servoy related stuff!


busy JSDoc keyListeners whois VelocityReport
BrowserSuite DateChooserBean DnDFileBean SliderBean SVGBean







Archive



Beans




SVGBean

The SVGBean v1.0.1

v1.0.1
Added support for transparency

v1.0
First public release

This bean was made by request, but is released as Open Source (LGPL License), it is compatible with Servoy developer and smart client but NOT web client.

 

It works in Servoy 4.1.x and Servoy 5+ for Windows and Mac and should work on Linux OSes (not tested).
A lighter version for Servoy 3.5.x (with no dataProvider support) could be done if there is enough interest to it.

 

The bean is capable of displaying any type of SVG graphics in a Servoy form. (SVG is short for Scalable Vector Graphic, an Open Source format that has the advantage of being vectorial, and that allows to create any kind of graphics, resolution independant).

 

In addition to simply displaying SVG files, the bean allows for scripting nodes by adding callback on click, and allowing to move SVG nodes and capture coordinates by using special object called MouseTrackers.

You will have to look at the sample solution to see what you can do with it and how it can be done.

 

In the SVG canvas, if allowUserInteractions is true, you can:

  • Zoom In: using ctrl (or cmd on Mac) + I
  • Zoom In: using ctrl (or cmd on Mac) + right mouse to drag a zone
  • Zoom Out: using ctrl (or cmd on Mac) + O
  • Reset the canvas: using ctrl (or cmd on Mac) + shift + right click
  • Real time zoom: using shift + right mouse drag
  • Panning: using shift + left mouse drag

The SVGBean is using the Apache Batik framework to interact with SVG Files, see http://xmlgraphics.apache.org/batik/ for more info on this library.

 

To install, you will have to dowload the SVG_install.zip archive which contains 2 folders: /beans and /plugins + a sample solution.

You will need to copy the content of these 2 folder into their respective Servoy folder :

- /beans/svg_bean.jar in your servoy/application_server/beans

- /plugins/svg_plugin.jar /plugins/svg_plugin.jar.jnlp and /plugins/svg_plugin/*.* in your servoy/application_server/plugins


To import the sample solution in Servoy 4.1.x, you will need to define an empty "svg_test" datasource.


Download packages:

- SVG_install.zip contains all you need to install the bean manually, as well as the required plugin and dependencies, and the sample solution. All signed with a trusted Certum CA certificate. Simply unzip and install as explained.
- signed SVG_install.zip contains all you need to install the bean manually, as well as the required plugin and dependencies, and the sample solution. Simply unzip and install as explained.
- the Eclipse project (the java sources of the bean), see the enclosed README.txt file to define the required Batik User library.

There is now a companion Google-Code project where you will be able to submit issues/feature requests and check out the code from SVN

 

KNOW BUGS/LIMITATIONS:

This bean is NOT web compatible. The SVG format is now accepted by most major browser (not Internet Explorer though) but it would be difficult to build the same kind of interactions with all the svg plugins around...

 

I only tested this one on Servoy 4.1.3 and 5.0beta1 on Windows and Mac but it should work fine in Linux since it doesn't use anything else than pure Java and the compilation has been targeted for Java 1.5.

 

The bean is not meant to be used in list view or table view, I cannot guarantee that it will display the SVG correctly in that case.

Same thing for printing, you will be able to print only one record at the time (because of the load time delay implied by the xml parsing and rendering to display an SVG image).

 

SVGBean might contain ECMAScript inline. But due to the fact that Batik uses a different version of the Rhino library than the one shipped with Servoy and the fact that Servoy traps some mouse events without redistributing them correctly to the canvas, SVG with ECMAScript that made use of events will not work and will display Exceptions in an Exception dialog.
There is little I can do to fix this, and that is also why I created the MouseTrackers object to interact with the SVG where scripting would not work.
MouseTrackers are not powerful enough to replace all the ECMAScripting you could put in the SVG, but if you have special needs for interaction send me a feature request...

 

 

If you like this bean, consider donating to help me make more cool stuff available!

You can send me a note with any comment, feature request, bug report, using the contact form.