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
* BasicStrokeObjectDescription.java
29
* ---------------------------------
30
* (C)opyright 2003, 2004, by Thomas Morgner and Contributors.
32
* Original Author: Thomas Morgner;
33
* Contributor(s): David Gilbert (for Object Refinery Limited);
35
* $Id: BasicStrokeObjectDescription.java,v 1.3 2005/11/14 10:59:02 mungady Exp $
37
* Changes (from 19-Feb-2003)
38
* -------------------------
39
* 19-Feb-2003 : Added standard header and Javadocs (DG);
40
* 29-Apr-2003 : Distilled from the JFreeReport project and moved into JCommon
44
package org.jfree.xml.factory.objects;
46
import java.awt.BasicStroke;
49
* An object-description for a <code>BasicStroke</code> object.
51
* @author Thomas Morgner
53
public class BasicStrokeObjectDescription extends AbstractObjectDescription {
56
* Creates a new object description.
58
public BasicStrokeObjectDescription() {
59
super(BasicStroke.class);
60
setParameterDefinition("value", String.class);
64
* Returns a parameter as a float.
66
* @param param the parameter name.
68
* @return The float value.
70
private float getFloatParameter(final String param) {
71
final String p = (String) getParameter(param);
76
return Float.parseFloat(p);
84
* Creates a new <code>BasicStroke</code> object based on this description.
86
* @return The <code>BasicStroke</code> object.
88
public Object createObject() {
89
final float width = getFloatParameter("value");
90
return new BasicStroke(width);
94
* Sets the parameters for this description to match the supplied object.
96
* @param o the object (instance of <code>BasicStroke</code> required).
98
* @throws ObjectFactoryException if the supplied object is not an instance of
99
* <code>BasicStroke</code>.
101
public void setParameterFromObject(final Object o) throws ObjectFactoryException {
102
if (!(o instanceof BasicStroke)) {
103
throw new ObjectFactoryException("Expected object of type BasicStroke");
105
final BasicStroke bs = (BasicStroke) o;
106
setParameter("value", String.valueOf(bs.getLineWidth()));