1 18 package org.apache.batik.svggen; 19 20 import java.awt.Polygon ; 21 import java.awt.Shape ; 22 import java.awt.geom.Arc2D ; 23 import java.awt.geom.Ellipse2D ; 24 import java.awt.geom.Line2D ; 25 import java.awt.geom.Rectangle2D ; 26 import java.awt.geom.RoundRectangle2D ; 27 28 import org.w3c.dom.Element ; 29 30 45 public class SVGShape extends SVGGraphicObjectConverter { 46 49 private SVGArc svgArc; 50 private SVGEllipse svgEllipse; 51 private SVGLine svgLine; 52 private SVGPath svgPath; 53 private SVGPolygon svgPolygon; 54 private SVGRectangle svgRectangle; 55 56 59 public SVGShape(SVGGeneratorContext generatorContext) { 60 super(generatorContext); 61 svgArc = new SVGArc(generatorContext); 62 svgEllipse = new SVGEllipse(generatorContext); 63 svgLine = new SVGLine(generatorContext); 64 svgPath = new SVGPath(generatorContext); 65 svgPolygon = new SVGPolygon(generatorContext); 66 svgRectangle = new SVGRectangle(generatorContext); 67 } 68 69 72 public Element toSVG(Shape shape){ 73 if(shape instanceof Polygon ) 74 return svgPolygon.toSVG((Polygon )shape); 75 else if(shape instanceof Rectangle2D ) 76 return svgRectangle.toSVG((Rectangle2D )shape); 77 else if(shape instanceof RoundRectangle2D ) 78 return svgRectangle.toSVG((RoundRectangle2D )shape); 79 else if(shape instanceof Ellipse2D ) 80 return svgEllipse.toSVG((Ellipse2D )shape); 81 else if(shape instanceof Line2D ) 82 return svgLine.toSVG((Line2D )shape); 83 else if(shape instanceof Arc2D ) 84 return svgArc.toSVG((Arc2D )shape); 85 else 86 return svgPath.toSVG(shape); 87 } 88 } 89 | Popular Tags |