1 18 package org.apache.batik.parser; 19 20 import java.awt.Shape ; 21 import java.awt.geom.GeneralPath ; 22 import java.io.IOException ; 23 import java.io.Reader ; 24 25 31 public class AWTPolylineProducer implements PointsHandler, ShapeProducer { 32 35 protected GeneralPath path; 36 37 40 protected boolean newPath; 41 42 45 protected int windingRule; 46 47 52 public static Shape createShape(Reader r, int wr) 53 throws IOException , 54 ParseException { 55 PointsParser p = new PointsParser(); 56 AWTPolylineProducer ph = new AWTPolylineProducer(); 57 58 ph.setWindingRule(wr); 59 p.setPointsHandler(ph); 60 p.parse(r); 61 62 return ph.getShape(); 63 } 64 65 68 public void setWindingRule(int i) { 69 windingRule = i; 70 } 71 72 75 public int getWindingRule() { 76 return windingRule; 77 } 78 79 84 public Shape getShape() { 85 return path; 86 } 87 88 91 public void startPoints() throws ParseException { 92 path = new GeneralPath (windingRule); 93 newPath = true; 94 } 95 96 99 public void point(float x, float y) throws ParseException { 100 if (newPath) { 101 newPath = false; 102 path.moveTo(x, y); 103 } else { 104 path.lineTo(x, y); 105 } 106 } 107 108 111 public void endPoints() throws ParseException { 112 } 113 } 114 | Popular Tags |