KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > dom > svg > SVGOMColorProfileElement


1 /*
2
3    Copyright 2001-2004 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.dom.svg;
19
20 import org.apache.batik.dom.AbstractDocument;
21 import org.apache.batik.dom.util.XLinkSupport;
22 import org.apache.batik.dom.util.XMLSupport;
23 import org.w3c.dom.Attr JavaDoc;
24 import org.w3c.dom.DOMException JavaDoc;
25 import org.w3c.dom.Node JavaDoc;
26 import org.w3c.dom.svg.SVGColorProfileElement;
27
28 /**
29  * This class implements {@link org.w3c.dom.svg.SVGColorProfileElement}.
30  *
31  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
32  * @version $Id: SVGOMColorProfileElement.java,v 1.7 2004/08/18 07:13:14 vhardy Exp $
33  */

34 public class SVGOMColorProfileElement
35     extends SVGOMURIReferenceElement
36     implements SVGColorProfileElement {
37
38     /**
39      * The attribute initializer.
40      */

41     protected final static AttributeInitializer attributeInitializer;
42     static {
43         attributeInitializer = new AttributeInitializer(5);
44         attributeInitializer.addAttribute(null, null,
45                                           SVG_RENDERING_INTENT_ATTRIBUTE,
46                                           SVG_AUTO_VALUE);
47         attributeInitializer.addAttribute(XMLSupport.XMLNS_NAMESPACE_URI,
48                                           null, "xmlns:xlink",
49                                           XLinkSupport.XLINK_NAMESPACE_URI);
50         attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
51                                           "xlink", "type", "simple");
52         attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
53                                           "xlink", "show", "other");
54         attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
55                                           "xlink", "actuate", "onLoad");
56     }
57
58     /**
59      * Creates a new SVGOMColorProfileElement object.
60      */

61     protected SVGOMColorProfileElement() {
62     }
63
64     /**
65      * Creates a new SVGOMColorProfileElement object.
66      * @param prefix The namespace prefix.
67      * @param owner The owner document.
68      */

69     public SVGOMColorProfileElement(String JavaDoc prefix, AbstractDocument owner) {
70         super(prefix, owner);
71
72     }
73
74     /**
75      * <b>DOM</b>: Implements {@link Node#getLocalName()}.
76      */

77     public String JavaDoc getLocalName() {
78         return SVG_COLOR_PROFILE_TAG;
79     }
80
81     /**
82      * <b>DOM</b>: Implements {@link SVGColorProfileElement#getLocal()}.
83      */

84     public String JavaDoc getLocal() {
85         return getAttributeNS(null, SVG_LOCAL_ATTRIBUTE);
86     }
87
88     /**
89      * <b>DOM</b>: Implements {@link SVGColorProfileElement#setLocal(String)}.
90      */

91     public void setLocal(String JavaDoc local) throws DOMException JavaDoc {
92         setAttributeNS(null, SVG_LOCAL_ATTRIBUTE, local);
93     }
94
95     /**
96      * <b>DOM</b>: Implements {@link SVGColorProfileElement#getName()}.
97      */

98     public String JavaDoc getName() {
99         return getAttributeNS(null, SVG_NAME_ATTRIBUTE);
100     }
101
102     /**
103      * <b>DOM</b>: Implements {@link SVGColorProfileElement#setName(String)}.
104      */

105     public void setName(String JavaDoc name) throws DOMException JavaDoc {
106         setAttributeNS(null, SVG_NAME_ATTRIBUTE, name);
107     }
108
109     /**
110      * <b>DOM</b>: Implements {@link
111      * SVGColorProfileElement#getRenderingIntent()}.
112      */

113     public short getRenderingIntent() {
114         Attr JavaDoc attr = getAttributeNodeNS(null, SVG_RENDERING_INTENT_ATTRIBUTE);
115         if (attr == null) {
116             return RENDERING_INTENT_AUTO;
117         }
118         String JavaDoc val = attr.getValue();
119         switch (val.length()) {
120         case 4:
121             if (val.equals(SVG_AUTO_VALUE)) {
122                 return RENDERING_INTENT_AUTO;
123             }
124             break;
125
126         case 10:
127             if (val.equals(SVG_PERCEPTUAL_VALUE)) {
128                 return RENDERING_INTENT_PERCEPTUAL;
129             }
130             if (val.equals(SVG_SATURATE_VALUE)) {
131                 return RENDERING_INTENT_SATURATION;
132             }
133             break;
134
135         case 21:
136             if (val.equals(SVG_ABSOLUTE_COLORIMETRIC_VALUE)) {
137                 return RENDERING_INTENT_ABSOLUTE_COLORIMETRIC;
138             }
139             if (val.equals(SVG_RELATIVE_COLORIMETRIC_VALUE)) {
140                 return RENDERING_INTENT_RELATIVE_COLORIMETRIC;
141             }
142         }
143         return RENDERING_INTENT_UNKNOWN;
144     }
145
146     /**
147      * <b>DOM</b>: Implements {@link
148      * SVGColorProfileElement#setRenderingIntent(short)}.
149      */

150     public void setRenderingIntent(short renderingIntent) throws DOMException JavaDoc {
151         switch (renderingIntent) {
152         case RENDERING_INTENT_AUTO:
153             setAttributeNS(null, SVG_RENDERING_INTENT_ATTRIBUTE,
154                            SVG_AUTO_VALUE);
155             break;
156
157         case RENDERING_INTENT_PERCEPTUAL:
158             setAttributeNS(null, SVG_RENDERING_INTENT_ATTRIBUTE,
159                            SVG_PERCEPTUAL_VALUE);
160             break;
161
162         case RENDERING_INTENT_RELATIVE_COLORIMETRIC:
163             setAttributeNS(null, SVG_RENDERING_INTENT_ATTRIBUTE,
164                            SVG_RELATIVE_COLORIMETRIC_VALUE);
165             break;
166
167         case RENDERING_INTENT_SATURATION:
168             setAttributeNS(null, SVG_RENDERING_INTENT_ATTRIBUTE,
169                            SVG_SATURATE_VALUE);
170             break;
171
172         case RENDERING_INTENT_ABSOLUTE_COLORIMETRIC:
173             setAttributeNS(null, SVG_RENDERING_INTENT_ATTRIBUTE,
174                            SVG_ABSOLUTE_COLORIMETRIC_VALUE);
175         }
176     }
177
178     /**
179      * Returns the AttributeInitializer for this element type.
180      * @return null if this element has no attribute with a default value.
181      */

182     protected AttributeInitializer getAttributeInitializer() {
183         return attributeInitializer;
184     }
185
186     /**
187      * Returns a new uninitialized instance of this object's class.
188      */

189     protected Node JavaDoc newNode() {
190         return new SVGOMColorProfileElement();
191     }
192 }
193
Popular Tags