1
/* ========================================================================
2
* JCommon : a free general purpose class library for the Java(tm) platform
3
* ========================================================================
5
* (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
7
* Project Info: http://www.jfree.org/jcommon/index.html
9
* 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.
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.
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,
24
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
25
* in the United States and other countries.]
27
* ------------------------
28
* Point2DWriteHandler.java
29
* ------------------------
30
* (C) Copyright 2003-2005, by Thomas Morgner and Contributors.
32
* Original Author: Thomas Morgner;
33
* Contributor(s): David Gilbert (for Object Refinery Limited);
35
* $Id: Point2DWriteHandler.java,v 1.3 2005/10/18 13:35:21 mungady Exp $
37
* Changes (from 25-Nov-2003)
38
* --------------------------
39
* 25-Nov-2003 : Added standard header (DG);
43
package org.jfree.xml.writer.coretypes;
45
import java.awt.geom.Point2D;
46
import java.io.IOException;
48
import org.jfree.xml.writer.AbstractXmlWriteHandler;
49
import org.jfree.xml.writer.AttributeList;
50
import org.jfree.xml.writer.XMLWriter;
51
import org.jfree.xml.writer.XMLWriterException;
54
* A handler for writing a {@link Point2D} object.
56
public class Point2DWriteHandler extends AbstractXmlWriteHandler {
59
* Default constructor.
61
public Point2DWriteHandler() {
66
* Performs the writing of a {@link Point2D} object.
68
* @param tagName the tag name.
69
* @param object the {@link Point2D} object.
70
* @param writer the writer.
71
* @param mPlexAttribute ??.
72
* @param mPlexValue ??.
74
* @throws IOException if there is an I/O error.
75
* @throws XMLWriterException if there is a writer error.
77
public void write(final String tagName, final Object object, final XMLWriter writer,
78
final String mPlexAttribute, final String mPlexValue)
79
throws IOException, XMLWriterException {
80
final Point2D point = (Point2D) object;
81
final double x = point.getX();
82
final double y = point.getY();
83
final AttributeList attribs = new AttributeList();
84
if (mPlexAttribute != null) {
85
attribs.setAttribute(mPlexAttribute, mPlexValue);
87
attribs.setAttribute("x", String.valueOf(x));
88
attribs.setAttribute("y", String.valueOf(y));
89
writer.writeTag(tagName, attribs, true);