| /***************************************************************************** |
| * Copyright (C) The Apache Software Foundation. All rights reserved. * |
| * ------------------------------------------------------------------------- * |
| * This software is published under the terms of the Apache Software License * |
| * version 1.1, a copy of which has been included with this distribution in * |
| * the LICENSE file. * |
| *****************************************************************************/ |
| |
| package org.apache.batik.parser; |
| |
| import java.awt.Shape; |
| import java.awt.geom.GeneralPath; |
| import java.io.IOException; |
| import java.io.Reader; |
| |
| /** |
| * This class produces a polygon shape from a reader. |
| * |
| * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a> |
| * @version $Id$ |
| */ |
| public class AWTPolygonProducer extends AWTPolylineProducer { |
| /** |
| * Utility method for creating an ExtendedGeneralPath. |
| * @param r The reader used to read the path specification. |
| * @param wr The winding rule to use for creating the path. |
| * @param pf The parser factory to use. |
| */ |
| public static Shape createShape(Reader r, int wr, ParserFactory pf) |
| throws IOException, |
| ParseException { |
| PointsParser p = pf.createPointsParser(); |
| AWTPolygonProducer ph = new AWTPolygonProducer(); |
| |
| ph.setWindingRule(wr); |
| p.setPointsHandler(ph); |
| p.parse(r); |
| |
| return ph.getShape(); |
| } |
| |
| /** |
| * Implements {@link PointsHandler#endPoints()}. |
| */ |
| public void endPoints() throws ParseException { |
| path.closePath(); |
| } |
| } |