3
Copyright 2000-2004 The Apache Software Foundation
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
3
Licensed to the Apache Software Foundation (ASF) under one or more
4
contributor license agreements. See the NOTICE file distributed with
5
this work for additional information regarding copyright ownership.
6
The ASF licenses this file to You under the Apache License, Version 2.0
7
(the "License"); you may not use this file except in compliance with
8
the License. You may obtain a copy of the License at
9
10
http://www.apache.org/licenses/LICENSE-2.0
32
36
* This class implements {@link SVGFilterElement}.
34
38
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
35
* @version $Id: SVGOMFilterElement.java,v 1.16 2004/08/18 07:13:16 vhardy Exp $
39
* @version $Id: SVGOMFilterElement.java 592621 2007-11-07 05:58:12Z cam $
37
41
public class SVGOMFilterElement
38
42
extends SVGStylableElement
39
43
implements SVGFilterElement {
46
* Table mapping XML attribute names to TraitInformation objects.
48
protected static DoublyIndexedTable xmlTraitInformation;
50
DoublyIndexedTable t =
51
new DoublyIndexedTable(SVGStylableElement.xmlTraitInformation);
52
t.put(null, SVG_FILTER_UNITS_ATTRIBUTE,
53
new TraitInformation(true, SVGTypes.TYPE_IDENT));
54
t.put(null, SVG_PRIMITIVE_UNITS_ATTRIBUTE,
55
new TraitInformation(true, SVGTypes.TYPE_IDENT));
56
t.put(null, SVG_X_ATTRIBUTE,
57
new TraitInformation(true, SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_WIDTH));
58
t.put(null, SVG_Y_ATTRIBUTE,
59
new TraitInformation(true, SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_HEIGHT));
60
t.put(null, SVG_WIDTH_ATTRIBUTE,
61
new TraitInformation(true, SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_WIDTH));
62
t.put(null, SVG_HEIGHT_ATTRIBUTE,
63
new TraitInformation(true, SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_HEIGHT));
64
t.put(null, SVG_FILTER_RES_ATTRIBUTE,
65
new TraitInformation(true, SVGTypes.TYPE_NUMBER_OPTIONAL_NUMBER));
66
xmlTraitInformation = t;
42
70
* The attribute initializer.
44
protected final static AttributeInitializer attributeInitializer;
72
protected static final AttributeInitializer attributeInitializer;
46
74
attributeInitializer = new AttributeInitializer(4);
47
75
attributeInitializer.addAttribute(XMLSupport.XMLNS_NAMESPACE_URI,
59
87
* The units values.
61
protected final static String[] UNITS_VALUES = {
89
protected static final String[] UNITS_VALUES = {
63
91
SVG_USER_SPACE_ON_USE_VALUE,
64
92
SVG_OBJECT_BOUNDING_BOX_VALUE
96
* The 'filterUnits' attribute value.
98
protected SVGOMAnimatedEnumeration filterUnits;
101
* The 'primitiveUnits' attribute value.
103
protected SVGOMAnimatedEnumeration primitiveUnits;
106
* The 'x' attribute value.
108
protected SVGOMAnimatedLength x;
111
* The 'y' attribute value.
113
protected SVGOMAnimatedLength y;
116
* The 'width' attribute value.
118
protected SVGOMAnimatedLength width;
121
* The 'height' attribute value.
123
protected SVGOMAnimatedLength height;
126
* The 'xlink:href' attribute value.
128
protected SVGOMAnimatedString href;
131
* The 'externalResourcesRequired' attribute value.
133
protected SVGOMAnimatedBoolean externalResourcesRequired;
68
136
* Creates a new SVGOMFilterElement object.
70
138
protected SVGOMFilterElement() {
78
146
public SVGOMFilterElement(String prefix, AbstractDocument owner) {
79
147
super(prefix, owner);
148
initializeLiveAttributes();
152
* Initializes all live attributes for this element.
154
protected void initializeAllLiveAttributes() {
155
super.initializeAllLiveAttributes();
156
initializeLiveAttributes();
160
* Initializes the live attribute values of this element.
162
private void initializeLiveAttributes() {
164
createLiveAnimatedEnumeration
165
(null, SVG_FILTER_UNITS_ATTRIBUTE, UNITS_VALUES, (short) 2);
167
createLiveAnimatedEnumeration
168
(null, SVG_PRIMITIVE_UNITS_ATTRIBUTE, UNITS_VALUES, (short) 1);
169
x = createLiveAnimatedLength
170
(null, SVG_X_ATTRIBUTE, SVG_FILTER_X_DEFAULT_VALUE,
171
SVGOMAnimatedLength.HORIZONTAL_LENGTH, false);
172
y = createLiveAnimatedLength
173
(null, SVG_Y_ATTRIBUTE, SVG_FILTER_Y_DEFAULT_VALUE,
174
SVGOMAnimatedLength.VERTICAL_LENGTH, false);
176
createLiveAnimatedLength
177
(null, SVG_WIDTH_ATTRIBUTE, SVG_FILTER_WIDTH_DEFAULT_VALUE,
178
SVGOMAnimatedLength.HORIZONTAL_LENGTH, true);
180
createLiveAnimatedLength
181
(null, SVG_HEIGHT_ATTRIBUTE, SVG_FILTER_HEIGHT_DEFAULT_VALUE,
182
SVGOMAnimatedLength.VERTICAL_LENGTH, true);
184
createLiveAnimatedString(XLINK_NAMESPACE_URI, XLINK_HREF_ATTRIBUTE);
185
externalResourcesRequired =
186
createLiveAnimatedBoolean
187
(null, SVG_EXTERNAL_RESOURCES_REQUIRED_ATTRIBUTE, false);
90
198
* <b>DOM</b>: Implements {@link SVGFilterElement#getFilterUnits()}.
92
200
public SVGAnimatedEnumeration getFilterUnits() {
93
return getAnimatedEnumerationAttribute
94
(null, SVG_FILTER_UNITS_ATTRIBUTE, UNITS_VALUES,
99
205
* <b>DOM</b>: Implements {@link SVGFilterElement#getPrimitiveUnits()}.
101
207
public SVGAnimatedEnumeration getPrimitiveUnits() {
102
return getAnimatedEnumerationAttribute
103
(null, SVG_PRIMITIVE_UNITS_ATTRIBUTE, UNITS_VALUES,
208
return primitiveUnits;
108
212
* <b>DOM</b>: Implements {@link SVGFilterElement#getX()}.
110
214
public SVGAnimatedLength getX() {
111
return getAnimatedLengthAttribute
112
(null, SVG_X_ATTRIBUTE, SVG_FILTER_X_DEFAULT_VALUE,
113
SVGOMAnimatedLength.HORIZONTAL_LENGTH);
117
219
* <b>DOM</b>: Implements {@link SVGFilterElement#getY()}.
119
221
public SVGAnimatedLength getY() {
120
return getAnimatedLengthAttribute
121
(null, SVG_Y_ATTRIBUTE, SVG_FILTER_Y_DEFAULT_VALUE,
122
SVGOMAnimatedLength.VERTICAL_LENGTH);
126
226
* <b>DOM</b>: Implements {@link SVGFilterElement#getWidth()}.
128
228
public SVGAnimatedLength getWidth() {
129
return getAnimatedLengthAttribute
130
(null, SVG_WIDTH_ATTRIBUTE, SVG_FILTER_WIDTH_DEFAULT_VALUE,
131
SVGOMAnimatedLength.HORIZONTAL_LENGTH);
135
233
* <b>DOM</b>: Implements {@link SVGFilterElement#getHeight()}.
137
235
public SVGAnimatedLength getHeight() {
138
return getAnimatedLengthAttribute
139
(null, SVG_HEIGHT_ATTRIBUTE, SVG_FILTER_HEIGHT_DEFAULT_VALUE,
140
SVGOMAnimatedLength.VERTICAL_LENGTH);
144
240
* <b>DOM</b>: Implements {@link SVGFilterElement#getFilterResX()}.
146
242
public SVGAnimatedInteger getFilterResX() {
147
throw new RuntimeException(" !!! TODO: getFilterResX()");
243
throw new UnsupportedOperationException
244
("SVGFilterElement.getFilterResX is not implemented"); // XXX
151
248
* <b>DOM</b>: Implements {@link SVGFilterElement#getFilterResY()}.
153
250
public SVGAnimatedInteger getFilterResY() {
154
throw new RuntimeException(" !!! TODO: getFilterResY()");
251
throw new UnsupportedOperationException
252
("SVGFilterElement.getFilterResY is not implemented"); // XXX
158
256
* <b>DOM</b>: Implements {@link SVGFilterElement#setFilterRes(int,int)}.
160
258
public void setFilterRes(int filterResX, int filterResY) {
161
throw new RuntimeException(" !!! TODO: setFilterRes()");
259
throw new UnsupportedOperationException
260
("SVGFilterElement.setFilterRes is not implemented"); // XXX
164
263
// SVGURIReference support /////////////////////////////////////////////
177
276
* org.w3c.dom.svg.SVGExternalResourcesRequired#getExternalResourcesRequired()}.
179
278
public SVGAnimatedBoolean getExternalResourcesRequired() {
180
return SVGExternalResourcesRequiredSupport.
181
getExternalResourcesRequired(this);
279
return externalResourcesRequired;
283
* Returns the table of TraitInformation objects for this element.
285
protected DoublyIndexedTable getTraitInformationTable() {
286
return xmlTraitInformation;
184
289
// SVGLangSpace support //////////////////////////////////////////////////
229
330
protected Node newNode() {
230
331
return new SVGOMFilterElement();
334
// AnimationTarget ///////////////////////////////////////////////////////
338
// * Updates an attribute value in this target.
340
// public void updateAttributeValue(String ns, String ln,
341
// AnimatableValue val) {
343
// if (ln.equals(SVG_FILTER_RES_ATTRIBUTE)) {
344
// // XXX Needs testing.
345
// if (val == null) {
346
// updateIntegerAttributeValue(getFilterResX(), null);
347
// updateIntegerAttributeValue(getFilterResY(), null);
349
// AnimatableNumberOptionalNumberValue anonv =
350
// (AnimatableNumberOptionalNumberValue) val;
351
// SVGOMAnimatedInteger ai =
352
// (SVGOMAnimatedInteger) getFilterResX();
353
// ai.setAnimatedValue(Math.round(anonv.getNumber()));
354
// ai = (SVGOMAnimatedInteger) getFilterResY();
355
// if (anonv.hasOptionalNumber()) {
356
// ai.setAnimatedValue
357
// (Math.round(anonv.getOptionalNumber()));
359
// ai.setAnimatedValue(Math.round(anonv.getNumber()));
365
// super.updateAttributeValue(ns, ln, val);
369
// * Returns the underlying value of an animatable XML attribute.
371
// public AnimatableValue getUnderlyingValue(String ns, String ln) {
373
// if (ln.equals(SVG_FILTER_RES_ATTRIBUTE)) {
374
// return getBaseValue(getFilterResX(), getFilterResY());
377
// return super.getUnderlyingValue(ns, ln);