class com.xoetrope.swing.svg.XSvgImageMap

The XSvgImageMap class manages the display of an SVG (Scalable Vector Graphics) image. SVG is a language for describing two-dimensional graphics in XML. The class extends the XUI XPanel class to provide a panel to display the SVG image in and implements the MouseMotionListener and XAttributedComponent interfaces.

1. Constructor

public XSvgImageMap (int width, int height, String file)

The constructor shown above takes the width, height and path of the SVG file as parameters. The path specifies the entire path of the SVG file that is to be displayed.

2. Methods

3. Examples

Here is a simple Java swing example to display an SVG file using the XSvgImageMap class:
import com.xoetrope.swing.svg.XSvgImageMap;

public class TestSvg
    public static void main(String [] args)
            XSvgImageMap svgImage = new XSvgImageMap(400, 300, "C:/Images/image1.svg");
            JFrame frame = new JFrame("SVG Test");
            frame.setBackground (Color.WHITE);
            frame.setSize(400, 300);
            svgImage.display ();

In the above example "C:/Images/image1.svg" specifies the path to the SVG file you wish to display. Calling the display() method renders the SVG image and displays it in the XPanel. In order to have the image resize when you resize the frame, you will need to specify a viewBox attribute within your SVG file.
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki