KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > svggen > SVGClipDescriptor


1 /*
2
3    Copyright 2001,2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.svggen;
19
20 import java.util.HashMap JavaDoc;
21 import java.util.LinkedList JavaDoc;
22 import java.util.List JavaDoc;
23 import java.util.Map JavaDoc;
24
25 import org.w3c.dom.Element JavaDoc;
26
27 /**
28  * Describes an SVG clip
29  *
30  * @author <a HREF="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
31  * @version $Id: SVGClipDescriptor.java,v 1.8 2005/03/27 08:58:35 cam Exp $
32  * @see org.apache.batik.ext.awt.g2d.GraphicContext
33  * @see org.apache.batik.svggen.SVGDescriptor
34  */

35 public class SVGClipDescriptor implements SVGDescriptor, SVGSyntax{
36     private String JavaDoc clipPathValue;
37     private Element JavaDoc clipPathDef;
38
39     /**
40      * Creates a new SVGClipDescriptor.
41      * @param clipPathValue the clip path value
42      * @param clipPathDef definition of a clip path
43      */

44     public SVGClipDescriptor(String JavaDoc clipPathValue, Element JavaDoc clipPathDef){
45         if (clipPathValue == null)
46             throw new SVGGraphics2DRuntimeException(ErrorConstants.ERR_CLIP_NULL);
47
48         this.clipPathValue = clipPathValue;
49         this.clipPathDef = clipPathDef;
50     }
51
52     /**
53      * @param attrMap if not null, attribute name/value pairs
54      * for this descriptor should be written in this Map.
55      * Otherwise, a new Map will be created and attribute
56      * name/value pairs will be written into it.
57      * @return a map containing the SVG attributes needed by the
58      * descriptor.
59      */

60     public Map JavaDoc getAttributeMap(Map JavaDoc attrMap) {
61         if (attrMap == null)
62             attrMap = new HashMap JavaDoc();
63
64         attrMap.put(SVG_CLIP_PATH_ATTRIBUTE, clipPathValue);
65
66         return attrMap;
67     }
68
69
70     /**
71      * @param defSet if not null, definitions required to provide
72      * targets for the descriptor attribute values will be
73      * copied into defSet. If null, a new Set should be created
74      * and definitions copied into it. The set contains
75      * zero, one or more Elements.
76      * @return a set containing Elements that represent the definition
77      * of the descriptor's attribute values
78      */

79     public List JavaDoc getDefinitionSet(List JavaDoc defSet) {
80         if (defSet == null)
81             defSet = new LinkedList JavaDoc();
82
83         if (clipPathDef != null)
84             defSet.add(clipPathDef);
85
86         return defSet;
87     }
88 }
89
Popular Tags