public static void writeAsSVG(Drawable drawable,int w,int h,File file){
  if (!ExportUtils.isJFreeSVGAvailable()) {
    throw new IllegalStateException("JFreeSVG is not present on the classpath.");
  }
  ParamChecks.nullNotPermitted(drawable,"drawable");
  ParamChecks.nullNotPermitted(file,"file");
  try {
    Class<?> svg2Class=Class.forName("org.jfree.graphics2d.svg.SVGGraphics2D");
    Constructor<?> c1=svg2Class.getConstructor(int.class,int.class);
    Graphics2D svg2=(Graphics2D)c1.newInstance(w,h);
    Rectangle2D drawArea=new Rectangle2D.Double(0,0,w,h);
    drawable.draw(svg2,drawArea);
    Class<?> svgUtilsClass=Class.forName("org.jfree.graphics2d.svg.SVGUtils");
    Method m1=svg2Class.getMethod("getSVGElement",(Class[])null);
    String element=(String)m1.invoke(svg2,(Object[])null);
    Method m2=svgUtilsClass.getMethod("writeToSVG",File.class,String.class);
    m2.invoke(svgUtilsClass,file,element);
  }
 catch (  ClassNotFoundException ex) {
    throw new RuntimeException(ex);
  }
catch (  InstantiationException ex) {
    throw new RuntimeException(ex);
  }
catch (  IllegalAccessException ex) {
    throw new RuntimeException(ex);
  }
catch (  NoSuchMethodException ex) {
    throw new RuntimeException(ex);
  }
catch (  SecurityException ex) {
    throw new RuntimeException(ex);
  }
catch (  IllegalArgumentException ex) {
    throw new RuntimeException(ex);
  }
catch (  InvocationTargetException ex) {
    throw new RuntimeException(ex);
  }
}

public static void writeAsSVG ( Drawable drawable , int w , int h , File file ) { if ( ! ExportUtils . isJFreeSVGAvailable ( ) ) { throw new IllegalStateException ( "JFreeSVG is not present on the classpath." ) ; } ParamChecks . nullNotPermitted ( drawable , "drawable" ) ; ParamChecks . nullNotPermitted ( file , "file" ) ; try { Class < ? > svg2Class = Class . forName ( "org.jfree.graphics2d.svg.SVGGraphics2D" ) ; Constructor < ? > c1 = svg2Class . getConstructor ( int . class , int . class ) ; Graphics2D svg2 = ( Graphics2D ) c1 . newInstance ( w , h ) ; Rectangle2D drawArea = new Rectangle2D . Double ( 0 , 0 , w , h ) ; drawable . draw ( svg2 , drawArea ) ; Class < ? > svgUtilsClass = Class . forName ( "org.jfree.graphics2d.svg.SVGUtils" ) ; Method m1 = svg2Class . getMethod ( "getSVGElement" , ( Class [ ] ) null ) ; String element = ( String ) m1 . invoke ( svg2 , ( Object [ ] ) null ) ; Method m2 = svgUtilsClass . getMethod ( "writeToSVG" , File . class , String . class ) ; m2 . invoke ( svgUtilsClass , file , element ) ; } catch ( ClassNotFoundException ex ) { throw new RuntimeException ( ex ) ; } catch ( InstantiationException ex ) { throw new RuntimeException ( ex ) ; } catch ( IllegalAccessException ex ) { throw new RuntimeException ( ex ) ; } catch ( NoSuchMethodException ex ) { throw new RuntimeException ( ex ) ; } catch ( SecurityException ex ) { throw new RuntimeException ( ex ) ; } catch ( IllegalArgumentException ex ) { throw new RuntimeException ( ex ) ; } catch ( InvocationTargetException ex ) { throw new RuntimeException ( ex ) ; } }
writes the current content to the specified file in svg format . this will only work when the jfreesvg library is found on the classpath . reflection is used to ensure there is no compile - time dependency on jfreesvg .
