01: /* ========================================================================
02: * JCommon : a free general purpose class library for the Java(tm) platform
03: * ========================================================================
04: *
05: * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
06: *
07: * Project Info: http://www.jfree.org/jcommon/index.html
08: *
09: * This library is free software; you can redistribute it and/or modify it
10: * under the terms of the GNU Lesser General Public License as published by
11: * the Free Software Foundation; either version 2.1 of the License, or
12: * (at your option) any later version.
13: *
14: * This library is distributed in the hope that it will be useful, but
15: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17: * License for more details.
18: *
19: * You should have received a copy of the GNU Lesser General Public
20: * License along with this library; if not, write to the Free Software
21: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22: * USA.
23: *
24: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
25: * in the United States and other countries.]
26: *
27: * ------------------
28: * Point2DReadHandler
29: * ------------------
30: * (C) Copyright 2003, by Thomas Morgner and Contributors.
31: *
32: * Original Author: Thomas Morgner;
33: * Contributor(s): David Gilbert (for Object Refinery Limited);
34: *
35: * $Id: Point2DReadHandler.java,v 1.2 2005/10/18 13:33:32 mungady Exp $
36: *
37: * Changes (from 25-Nov-2003)
38: * --------------------------
39: * 25-Nov-2003 : Added standard header and Javadocs (DG);
40: *
41: */
42:
43: package org.jfree.xml.parser.coretypes;
44:
45: import java.awt.geom.Point2D;
46:
47: import org.jfree.xml.parser.AbstractXmlReadHandler;
48: import org.xml.sax.Attributes;
49: import org.xml.sax.SAXException;
50:
51: /**
52: * A SAX handler for reading {@link Point2D} objects from an XML element.
53: */
54: public class Point2DReadHandler extends AbstractXmlReadHandler {
55:
56: /** The point under construction. */
57: private Point2D point;
58:
59: /**
60: * Creates a new handler.
61: */
62: public Point2DReadHandler() {
63: super ();
64: }
65:
66: /**
67: * At the start of parsing, the attributes are read and used to construct the point.
68: *
69: * @param attrs the attributes.
70: *
71: * @throws SAXException if there is a parsing error.
72: */
73: protected void startParsing(final Attributes attrs)
74: throws SAXException {
75: final String x = attrs.getValue("x");
76: final String y = attrs.getValue("y");
77: this .point = new Point2D.Double(Double.parseDouble(x), Double
78: .parseDouble(y));
79: }
80:
81: /**
82: * Returns the point under construction.
83: *
84: * @return the point.
85: */
86: public Point2D getPoint2D() {
87: return this .point;
88: }
89:
90: /**
91: * Returns the point under construction.
92: *
93: * @return the point.
94: */
95: public Object getObject() {
96: return this.point;
97: }
98:
99: }
|