Update 8/03/2003
New SVG work is available at www.elementengine.com
I am interested in your comments.
Carmen
Update 2/13/2000
This version handles fonts and lines better, including dashes and line width.
Update 6/11/99
In converting Windows Metafiles into Java, I used Polylines with defined vertices
as a method of translating WMF polygons. It is not clear in the spec that a polyline
can be filled. This has been reworked to use a path. So,
polyline verts = " 69,18 82,8 99,3 118,5 135,12 149,21 156,13 165,9 177,13 183,28 180,50 164,91 155,107 154,114 151,121 141,127 139,136 155,206 157,251 126,342 133,357 128,376 83,376 75,368 67,350 61,350 53,369 4,369 2,361 5,354 12,342 16,321 4,257 4,244 7,218 9,179 26,127 43,93 32,77 30,70 24,67 16,49 17,35 18,23 30,12 40,7 53,7 62,12 69,18 69,18 69,18"/
becomes
path d = "M 69,18L82,8L99,3L118,5L135,12L149,21L156,13L165,9L177,13L183,28L180,50L164,91L155,107L154,114L151,121L141,127L139,136L155,206L157,251L126,342L133,357L128,376L83,376L75,368L67,350L61,350L53,369L4,369L2,361L5,354L12,342L16,321L4,257L4,244L7,218L9,179L26,127L43,93L32,77L30,70L24,67L16,49L17,35L18,23L30,12L40,7L53,7L62,12L69,18L69,18L69,18"/
I have also included other path support, but this need testing.
The new source is available below and newlion.svg was created using the new converter.
wmf2svg is program for converting a Windows Metafile (WMF) into an SVG
Usage: java wmf2svg
Example: java wmf2svg test1.wmf test1.svg
Source Code:
wmf2svg.java
WMFToolkit.java
svgImage is a component for displaying SVG Images directly in Java
A main function is included that instantiates a JPanel and displays the requested SVG file
Usage: java svgImage
Example: java svgImage test1.svg
Requires: IBM's XML4J. Classpath must be properly set.
Source Code: svgImage.java
Samples
test1.svg
test1.wmf
lion.svg
lion.wmf
This is a work in progress. In development, I am working on this in a closed loop.
The converter program will create an SVG file that can be played by the viewer. There is
a lot of room for this to grow.
Supported Functions
text - not fonts, they are printed as descriptions
rect
ellipse
Polyline
colors
This allows a good rendering of many metafiles that are created by using many polygons.
The lion is an example.
I hope to expand the list of supported functions quickly. For conversion, Font Support,
bitmaps as JPEGs, and use of patterns would follow. For the viewer, this just scratches the surface, and
a long list of Java 2D functionality will be incorporated.