mirror of https://gitee.com/openkylin/batik.git
Import Upstream version 1.16
This commit is contained in:
commit
59332cc043
|
@ -0,0 +1,314 @@
|
||||||
|
This file contains the PGP keys of various developers.
|
||||||
|
|
||||||
|
Users: pgp < KEYS
|
||||||
|
gpg --import KEYS
|
||||||
|
Developers:
|
||||||
|
pgp -kxa <your name> and append it to this file.
|
||||||
|
(pgpk -ll <your name> && pgpk -xa <your name>) >> this file.
|
||||||
|
(gpg --list-sigs <your name>
|
||||||
|
&& gpg --armor --export <your name>) >> this file.
|
||||||
|
|
||||||
|
pub 1024D/CC69CEED 2003-09-25 Thomas DeWeese <deweese@apache.org>
|
||||||
|
sig 3 CC69CEED 2003-09-25 Thomas DeWeese <deweese@apache.org>
|
||||||
|
sig 3 88C3A5A5 2003-11-18 [User id not found]
|
||||||
|
sig 3 CC78C893 2003-11-18 Rich Bowen <rbowen@rcbowen.com>
|
||||||
|
sig 3 EE65E321 2003-11-24 Martin Kraemer <martin@apache.org>
|
||||||
|
sig 2 A1D69759 2003-11-24 Michael Kellen <idsfa@visi.com>
|
||||||
|
sig FD093C41 2003-11-23 James M. Turner <turner@blackbear.com>
|
||||||
|
sig 2 76D83CC6 2003-11-22 Manoj Kasichainula <manoj@apache.org>
|
||||||
|
sig 3 A54DA2DF 2003-11-18 Erin Mulder <meara@alumni.princeton.edu>
|
||||||
|
sig 3 F5FC4B42 2003-11-21 Theodore W. Leung <twl@sauria.com>
|
||||||
|
sig 2 4C9165B6 2003-11-18 Aaron Mulder <ammulder@alumni.princeton.edu>
|
||||||
|
sig 2 65FDCDEE 2003-11-20 James Howison <james@freelancepropaganda.com>
|
||||||
|
sig 3 D147B776 2003-11-28 Mitch Comstock <mcomstock@raidworks.com>
|
||||||
|
sig 3 EE56550E 2003-12-01 Cliff Schmidt <cliff@alum.mit.edu>
|
||||||
|
sig 152924AF 2003-11-22 Sander Temme <sander@temme.net>
|
||||||
|
sig 964F31D9 2003-11-22 [User id not found]
|
||||||
|
sig 46B262C6 2003-11-24 Thies C. Arntzen <thies@project-pint.org>
|
||||||
|
sig 3 CE19D5C6 2003-11-18 Jamie Wallingford (legobuff) <jamie@legobuff.com>
|
||||||
|
sig 2 F88341D9 2003-11-30 Lars Eilebrecht <lars@eilebrecht.org>
|
||||||
|
sig 3 ADBF9E1A 2003-12-05 [User id not found]
|
||||||
|
sig 3 142B509B 2003-11-26 Glenn L. Nielsen <glenn@apache.org>
|
||||||
|
sub 1024g/9C4D8C6A 2003-09-25
|
||||||
|
sig CC69CEED 2003-09-25 Thomas DeWeese <deweese@apache.org>
|
||||||
|
sig 3 98B1CC53 2010-10-23 Benson Margulies <bimargulies@apache.org>
|
||||||
|
sub 4096R/C5E91334 2010-10-23
|
||||||
|
sig 98B1CC53 2010-10-23 Benson Margulies <bimargulies@apache.org>
|
||||||
|
|
||||||
|
|
||||||
|
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
Version: GnuPG v1.2.2 (Cygwin)
|
||||||
|
|
||||||
|
mQGiBD9yRQQRBACIfPXJX6+oylxt7I1wtb25rVAJj3dVDbGwifyM0DwoN7I3hNPN
|
||||||
|
GECm02Uwnfx+kz7+TZhBuO0fAnYQIiqdUmxYoe6ZR2Cd7z5GqgpsXy/zZT7C5+iZ
|
||||||
|
VZZaZj5hObrfQqQmpPIkr0B8AKLoF5uMWu1qrOfzJZN+uBZl8nBNvSQCqwCgsI5J
|
||||||
|
SdiddZPbmlPdsdPQD4AVeWMD/RQtaU/CEoj5urgF2TctZfHCIiBeL+Gdt8ivSQo+
|
||||||
|
0XD4PA4MCMUb/PEsnX0HZ/JZ3xszEUrMUS3EvW8DYISsUpKPU3ao9WGrhv0Iq4/O
|
||||||
|
l1dBje4/6WB74Lh1eZLPV502hKfRioUokGI30g3xU6KM+xBxo53S1nUGYwCX9ga8
|
||||||
|
wabtA/4/gxzqT38azZoZiy6F/aG8SQX1MQnX+WeAYmlYInHe7lIXzEf1QaYQRzuL
|
||||||
|
yeIN3Ie34H6CxNjzhFueJEA2hSLc5peIQWgMMjZb9ohgxPta4RjTQT1st6cVhuuQ
|
||||||
|
ZTlowWskBLPZjI00yDcF5qjEivXpTBg3jxoMjA+gV+weyXg6drQjVGhvbWFzIERl
|
||||||
|
V2Vlc2UgPGRld2Vlc2VAYXBhY2hlLm9yZz6IWwQTEQIAGwUCP3JFBQYLCQgHAwID
|
||||||
|
FQIDAxYCAQIeAQIXgAAKCRAui9CAzGnO7U7QAJ4lFbyO0w6kFJqaZ/nvbxSfPOx4
|
||||||
|
LACggUum73SzXoWG/6XvmOAtdw7I4h2IRgQTEQIABgUCP7ppogAKCRDLMqEHiMOl
|
||||||
|
pQEiAKCamlum3prIqJ0m5aW456mpHfAHSACfQ24dbuMMW4coSjUaxlV7ZNx8VmeI
|
||||||
|
RgQTEQIABgUCP7qVWwAKCRBc/Tf6zHjIk2B9AJ9/XGdpxguM3GwQVwoDSlqFq5Sq
|
||||||
|
fQCffrp4m1v3RLI70D4ao7RQXgSVfvaInAQTAQIABgUCP8KDwwAKCRA34/Rf7mXj
|
||||||
|
Ib1hA/4pIyeBkFE/LaRGQXr9To6Ec7uY53w4qXXcGXGpS00cvrHhe/PlH3awzn0E
|
||||||
|
3MBTP14JA9QfUpVKh7mvKVSF/LIh5eoSzjOgr7a9WLsEMemtznDACELtxmkSL5oZ
|
||||||
|
A87Q1rUFEjNXYsaggP+JTP9k9XhLsFVJMrb73HbfDtvXQhtkDYhGBBIRAgAGBQI/
|
||||||
|
wVKDAAoJEMwhMCCh1pdZID8AnAwbwDDdbuzILGku29naF4BetV3YAJ9wBzoB/gNJ
|
||||||
|
95/HgoLWziCJcOSm7IhGBBARAgAGBQI/wSNhAAoJEBoJ0YP9CTxBitIAnR/2mJ7i
|
||||||
|
YaPcD6iRthAaRjTr46y7AJ4/KcG3BPYkXrVA70B0AIz4zGrbjokBHAQSAQIABgUC
|
||||||
|
P7/GwQAKCRAG6s+qdtg8xhnPB/9pjKnddwoqjmPPpdCu575RNr1gllESrYt3D6Yl
|
||||||
|
/A6sm7YM9HwCwTwGp+QEKaXz6FnsCpiineNr9Y0gQHevRrf3aCEC43/KrDCaS7wz
|
||||||
|
FUZbOgArF20f1cdRMBRWn2Z28kc0ixlooff1zKF02lZc/55siZ489Ph8Jfkf9qEU
|
||||||
|
gKyRrA0FAFpIEsIR86ZIIRxG9thH29UOBx2O7ylXokcafEi33kgRGUgZFalurqip
|
||||||
|
h9qqkvzo059CLbYVSmQmP+gQQtKYTakA4/MGzDEoPmGZeTpxj/guja9lm6TFUAgC
|
||||||
|
Sp+iV95Jf295i5n8isHqizFH5T9PXpgD0m90zdwprPAoyN87iEYEExECAAYFAj+5
|
||||||
|
pDQACgkQEPpMiKVNot/v9gCfadaXy7iZrw5iwJgfs/DxuylbEKYAoMHc9KXxv1fx
|
||||||
|
X5jyJEyuzIf4mdx6iEYEExECAAYFAj+90J0ACgkQvrorh/X8S0ItRQCeIEqwyctt
|
||||||
|
VKyQEe9gfYGKTn5ULP4An3X/RwdS7lj17dXLW7sovINeBPU6iEYEEhECAAYFAj+5
|
||||||
|
1osACgkQuSRSrEyRZbatSwCfRslKMf6W7u6zw1+kB84iFwu5kLwAoIxL/QHLl/i8
|
||||||
|
FF5kK+XLMN8dJQWFiEYEEhECAAYFAj+8aasACgkQ7Jk9Y2X9ze6FHgCdF3c+wiXS
|
||||||
|
GbpBD78j9F5B4JRxhSwAoK8blL7jg30o2potF3aXr0GytfG1iEYEExECAAYFAj/H
|
||||||
|
18cACgkQpHQPOdFHt3bDKQCcDpG5aR28FswMHNDrW17h8DXPxwcAn3mq+K7c0jMt
|
||||||
|
I4R6d7RtYhix4wzZiEYEExECAAYFAj/K52MACgkQaFp3yu5WVQ7MHACfV7v2ruGa
|
||||||
|
xB9LkHO52Xj5qOkqH2AAnR7k71BfHYBwP9R4tlcIVUR88OdpiEYEEBECAAYFAj+/
|
||||||
|
rZwACgkQsr68QBUpJK+nxACfZYIx232iUI5jSTxmPk+6WLZykywAnRNX9aSkSZnC
|
||||||
|
X29kNhxoS4SPXwDLiEYEEBECAAYFAj+/rcsACgkQwR57R5ZPMdlOcQCfT87ttZzR
|
||||||
|
If1zqNfknnQA1Xh1dwwAnjy4IZ7qrnyxS7J8MftTiG8w64r6iEYEEBECAAYFAj/C
|
||||||
|
F+EACgkQidhMr0ayYsZiLgCdHvLwyjsAHN5IdXMzXEkMLKZ9ysQAn1vCHVdMOBvk
|
||||||
|
hI20VbP9CTYtyuifiEYEExECAAYFAj+5q2AACgkQqB7mSc4Z1cZPowCfVrHFq4n1
|
||||||
|
lIPKJvW7ljuI2Z+vyNcAnj19SZgH6kNV78LDXxfDSjVwLdm1iJkEEgECAAYFAj/K
|
||||||
|
cDAACgkQPo+38viDQdlBKQPnT3Mqp5a1zEFi9YC6Hxz3a5/iYAJYNatqIqUNDKAv
|
||||||
|
/zn3HDOfCE4vh5yVUGon2nfigI6+Ci+2IaLJDfX3ZWV98Cy1tcngAXe1goyuoWUq
|
||||||
|
fb+htpBXDOAoT6LKf5PPZPFAvbaeRuWy6gJgz70j4tptiHjRz1XBK7k8Q+nBuOmI
|
||||||
|
RgQTEQIABgUCP9DSnAAKCRBkB4bZrb+eGnENAJ47CRP/eBrFNi1bD2QmSGKuqjT9
|
||||||
|
oQCfVSYvgyBEMrNRl6VezKZpv+1AaBqIRgQTEQIABgUCP8QscgAKCRD6PI0mFCtQ
|
||||||
|
m7XTAJ9FL2mNfvTJXw/DR3HnalKmH9NCywCfVF0KHFtuAtV7Rowjo75+/T1dJuu5
|
||||||
|
AQ0EP3JFBxAEAKk/4CpfyEGo9W9qnaO96lgHq0kHs9Bf3cMKnN/4/2xgHEmUPTPO
|
||||||
|
r1Qa7JEH2xGVHenPokJ92pfu95eXGFX1Ngail4FVT8hQgXTyTSZ//g1N4zZ7ERb5
|
||||||
|
/bNnYry4Wi09RyMIaKcT2QwtUViNDW+/ThONPLXn7LRqS3tHUF4aUA9jAAMFA/42
|
||||||
|
A2fIB6wXPMff5oSrP0sM4gdbl2kWIRicAzRAMrSGmTFXZYcigPmj5WbL57Qxo3Cb
|
||||||
|
keko9ka4+v7H/hwqUK2gJU3iwepMvniWvhZTkG7Pi8Q4snYOBodRJje/Nbi3EEf1
|
||||||
|
5pAYYuFfn041/eZ2cPXAV9y4KWyGSKxSSA3udc+UQ4hGBBgRAgAGBQI/ckUHAAoJ
|
||||||
|
EC6L0IDMac7tdD4AoIS22fkfoO7BURrrj8Xjcr0ztM2eAJ9oJ7kL2LJXS+KxO499
|
||||||
|
KABuEF1Abw==
|
||||||
|
=w3cC
|
||||||
|
|
||||||
|
-----END PGP PUBLIC KEY BLOCK-----
|
||||||
|
|
||||||
|
pub 1024D/2983AB4B 2004-11-04
|
||||||
|
uid Cameron McCormack <cam@mcc.id.au>
|
||||||
|
sig 3 2983AB4B 2007-01-30 Cameron McCormack <cam@mcc.id.au>
|
||||||
|
sig P X 65D0FD58 2005-11-01 CA Cert Signing Authority (Root CA) <gpg@cacert.org>
|
||||||
|
sig 1880283C 2006-01-13 Anibal Monsalve Salazar <anibal@debian.org>
|
||||||
|
sig 3 2983AB4B 2004-11-04 Cameron McCormack <cam@mcc.id.au>
|
||||||
|
sig 5653C9C4 2007-02-02 Helen Faulkner <helen@thousand-ships.com>
|
||||||
|
sig 1 C2429EC4 2007-02-03 Tanat Tonguthaisri <Tanat@Tanat.Net>
|
||||||
|
sig B6D8A3F9 2007-02-06 James Healy <jimmy@deefa.com>
|
||||||
|
sig B6D8A3F9 2007-02-06 James Healy <jimmy@deefa.com>
|
||||||
|
sig 3 6E63F4AA 2007-02-08 Julien Goodwin (Studio442) <jgoodwin@studio442.com.au>
|
||||||
|
uid Cameron McCormack (ASF) <cam@apache.org>
|
||||||
|
sig 3 2983AB4B 2007-01-30 Cameron McCormack <cam@mcc.id.au>
|
||||||
|
sig 5653C9C4 2007-02-02 Helen Faulkner <helen@thousand-ships.com>
|
||||||
|
sig C2429EC4 2007-02-03 Tanat Tonguthaisri <Tanat@Tanat.Net>
|
||||||
|
sig B6D8A3F9 2007-02-06 James Healy <jimmy@deefa.com>
|
||||||
|
sig B6D8A3F9 2007-02-06 James Healy <jimmy@deefa.com>
|
||||||
|
sig 3 6E63F4AA 2007-02-08 Julien Goodwin (Studio442) <jgoodwin@studio442.com.au>
|
||||||
|
sub 1024g/8DBA9492 2004-11-04
|
||||||
|
sig 2983AB4B 2004-11-04 Cameron McCormack <cam@mcc.id.au>
|
||||||
|
|
||||||
|
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
Version: GnuPG v1.4.6 (GNU/Linux)
|
||||||
|
|
||||||
|
mQGiBEGKHY0RBADg/8UYIZCkyi67E6/ekrXelhZC5uxU6vIM/+VYVYKtFdSB4PVA
|
||||||
|
JbH4BanckmivMkzwyIOEM2B7+F1kVdV312E+DaNxHVmYOg0IECa5CvIbmSuRgk4+
|
||||||
|
JDeVx7e70NpbdLW44PGJ5Dhrl1K5d3E5giop3Hv6g3DhZMMCRyuEzbyvWwCgjaz2
|
||||||
|
UT3iV1PgzY8rzh31AfKTx4MD+gM4GgwHJbuxyyDmX0/ay6WaNS522aWa9z3DSyCc
|
||||||
|
n3yg1HQM11Fv7uPxG5590BrzvSPFoCRh1pVgxkQ4wS+wcn4Ym+hIJ+zw3rM9anic
|
||||||
|
932p372ApuYyVzsYwIhgUYnKx5J99utAal6O+HXLNA1VPo/0cNUwMo0SYZtr2k18
|
||||||
|
pqKzBADHrFk8guRayg5jG5bMnsLp7sm7mesLTTU+QXP9tD4anXnuEE2WXLSu8W5T
|
||||||
|
HMGeCdk1G3NI8fUcYIR1ufvC/eyONuWLrkLrzQgTIzyXqDdrInf8ncNFPd/ISQIf
|
||||||
|
QHCLevFJzxKF7I5dvj2XjzoYQnUmDbtb/BKtFufBBySGo+XC6LQhQ2FtZXJvbiBN
|
||||||
|
Y0Nvcm1hY2sgPGNhbUBtY2MuaWQuYXU+iGAEExECACECGwMGCwkIBwMCAxUCAwMW
|
||||||
|
AgECHgECF4AFAkW+jpQCGQEACgkQE84EBimDq0sI3QCeJLVGGI0j80dPzuYrIkkN
|
||||||
|
60Tk3Z0AmOahohArbU0jm2TBMlGA6a4pfWOIcwQQEQIAMwUCQ2b/xwWDAeEzgCYa
|
||||||
|
aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMAAKCRDSuw0BZdD9
|
||||||
|
WEo+AJ9KfZkb3gXPTbJqbfH20CjnbIaXzACgmGEZ47BijHcXz8MbCTELssfPfjGI
|
||||||
|
RgQQEQIABgUCQ8cmZgAKCRCKkGd5GIAoPOOoAKCw7EKFHsMzahfxjnZJS2Xm7vhx
|
||||||
|
XQCgh6FG32xM82jmHcRaHCVz8d8LGASIXgQTEQIAHgUCQYodjQIbAwYLCQgHAwID
|
||||||
|
FQIDAxYCAQIeAQIXgAAKCRATzgQGKYOrS4mvAJ9FcDjeNXaBzP0YTzxmAg45vF8H
|
||||||
|
qQCfQUHc8ML7tOJjmeze+hMGlorgP8OIRgQQEQIABgUCRcO3mgAKCRDd41zxVlPJ
|
||||||
|
xDb3AJ0SdAwyYoJeYoDU359lSvT0HiJDKgCfd4mdtuIIz/GL5sCsyEke/nuDCXiI
|
||||||
|
SgQQEQIACgUCRcQ9owMFAXgACgkQUiXz/cJCnsRcVgCgh5BGV7WQky4/yQXLKskz
|
||||||
|
2hlNZIAAoIDrPGSGhsAtTalokBazsXxRE15piEYEEBECAAYFAkXIJeIACgkQ4oaw
|
||||||
|
krbYo/lxHACbBuer2JC6esDobrHzL4L/DGDW42wAoKh8iAaD2kdrwU+d8mE/MRiB
|
||||||
|
U4mEiEYEEBECAAYFAkXILVcACgkQ4oawkrbYo/moGACfbzOhpr3ZfvUGE1wo0l0l
|
||||||
|
eKdBbHsAn1HPZxdZ5pRA4GP9H3D81OK6n6WDiEYEExECAAYFAkXKsPYACgkQ9DPL
|
||||||
|
X25j9Kp9QACfTPTEq40vQ+PLFkEF77Ddoa18obMAoKaHoQbs88Z8KWFY/+kpgu/Z
|
||||||
|
px4GtChDYW1lcm9uIE1jQ29ybWFjayAoQVNGKSA8Y2FtQGFwYWNoZS5vcmc+iGAE
|
||||||
|
ExECACAFAkW+jFgCGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRATzgQGKYOr
|
||||||
|
S3n/AJ0a/dIwFx7FFMPO2rbJTwVF9HC00gCeLg3tM+JiaE5tSLO31WnjYMqeweSI
|
||||||
|
RgQQEQIABgUCRcO3ngAKCRDd41zxVlPJxGRGAJ9B0bduntJQSgjDvETaEV4flSoM
|
||||||
|
0wCeIDl9XTvDnVj1XOcTrmVu3olGuP2IRgQQEQIABgUCRcQ+KwAKCRBSJfP9wkKe
|
||||||
|
xGBKAJ9vHLnLT2cDpAko3A2iVPsCacOOgACgw9MB+cq8b7vT3/zLnbVlJKgDdByI
|
||||||
|
RgQQEQIABgUCRcgl5AAKCRDihrCSttij+Wy+AKCrUzLcOx8f3+q/xptXJlhsikmZ
|
||||||
|
GgCgrgcF+SrW+ndNb9WnolD1XGXzWpGIRgQQEQIABgUCRcgtWQAKCRDihrCSttij
|
||||||
|
+XNIAJwMHO4rZ2Hx4YIMo9UELev5rhQ5nwCfQDkgn/tja76+WdJQ9VjITb4TNjuI
|
||||||
|
RgQTEQIABgUCRcqw+AAKCRD0M8tfbmP0qoY+AKCK+SC2D381Hy/L5DtqVQK4YOOF
|
||||||
|
ngCgoo1SbAERPBP8+1LzNi76zf+mdNS5AQ0EQYodjxAEAPLN/PQ+z9/HIjzNqjI7
|
||||||
|
FBwPJcd22qkszlINSL7u6uZGyZARJaRWFxyiLTGageqEmfRShTkb7jclmA/JJhfF
|
||||||
|
RCVeDaLczX2xSMRuuOZlhtnvQjXWF+yVdHAsCVtSFKJq6XvFzdpXZUXBCTXrubaq
|
||||||
|
Rorq6T9Tl/UMiuzDFwd+xIbXAAMFA/9W6BrwvENj2M3t0Wy6HmVeUXFdeseJEf0P
|
||||||
|
ajqOqAEFJ7P1mYXsqHl+S7qQW2q5PDmdn3e1EYluUE/PelQrkhP3Dezgz+vz72Fm
|
||||||
|
IE4fxV3i2qTRX+uKh35M9urQZAoQhPwrTf9OQqX6XqOif4Cq74+yHj7eCGJFQT3E
|
||||||
|
clr4A+5pfohJBBgRAgAJBQJBih2PAhsMAAoJEBPOBAYpg6tLsjQAnR+3nNjMVjiL
|
||||||
|
l8zaAV7uHW6kG/RDAJ9NR/VKAVvh92/AkosLHGrzwW9REg==
|
||||||
|
=YT6v
|
||||||
|
-----END PGP PUBLIC KEY BLOCK-----
|
||||||
|
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
Version: GnuPG/MacGPG2 v2.0.12 (Darwin)
|
||||||
|
|
||||||
|
mQINBEzDDl0BEADHvJW2uff8vfxbfy0IvNOK4aytU+HVEvKEmuSqYEzC8i3BF6RT
|
||||||
|
LOxTeRFlu92rYz5ypD0mdNCzQaH0xbkcjialP6FpPCByrM9fFv6hmxZFSY71rvqz
|
||||||
|
Aw606I0t9rt94wc6p5Rl8NIso4rbFp2VQeu9hiydtyc5b6xh5mcCb2tYuihfByuL
|
||||||
|
ozt0ZWHDk1tZJk/XhSDVZ84jHrWRY2zSa2laIxH+KnJFto8BkTxQgrwEL1ipzoJr
|
||||||
|
n3DMIWOtWQR7hdSGWA/V+FgA4I7HXMXVrxolt5FesiWUXkZ7mVjglExv6Mwmf48V
|
||||||
|
TFfx46fz8vO6q93XQV705p2Csam78tvAMNYkJs2xZ9iaFIE8ET2cMgPie9yXlqTL
|
||||||
|
JGFRoFnTDM4HVW2hU6DsS7OAv0TjxZ94VPElrIrp7sK8MMe9+3qkTQkvUvLmbDOH
|
||||||
|
+i0LBw3ULKrod1oNe9VU8wyBBOaB5WqCfdjMWQoNb0IbgTXOyRRfO7YgA+KTtta1
|
||||||
|
H91I8x15aW1ofnEjYDvrXmaScCVMJcaas/62XjlKlmwGJMcS69pVRlxdKGLjBDA4
|
||||||
|
dg5gnZ+O/L792UwHOjuuqU3ix65xQ1t9Xrw5QsvTEhHLmbaJIrK9cT0UYvtUR/em
|
||||||
|
LJ7uVQOjL0PLnFGwntc0B0JldWT11oAtOV1rHgTrRn+HQzC6bTxx6eQlYQARAQAB
|
||||||
|
tClCZW5zb24gTWFyZ3VsaWVzIDxiaW1hcmd1bGllc0BhcGFjaGUub3JnPokCNwQT
|
||||||
|
AQoAIQUCTMMOXQIbAwULCQgHAwUVCgkICwUWAgMBAAIeAQIXgAAKCRCcT36dmLHM
|
||||||
|
U2/KEACGKZVYVaSarUBdnZGpkgBEcdVxQulcPuAO6cK8omLesMJ365XFsFsWkDQY
|
||||||
|
TaOMsmoeuuhZw4IHf5M99BT0hPctdRAlrR5x2amWyOWrYUvutPVUrVFtC9W1tPn4
|
||||||
|
VVf50r3hxrwIkNY5Ib7ynyCZL4N/4ExazvsRmKnu6KALvqcmyBZPal1MLaICo1k3
|
||||||
|
wVJ8KCE84oja4BPgF4hDMrOh1JKEYtjaowCIJRZEZ29sBbkX1fEDl9c6Z78U37KT
|
||||||
|
3asaPqS13CGsapQ99b9LrBVqXpbmZ+y3SwU+G8TU5RnitRUF9T9+JYD6jHgUM344
|
||||||
|
qeAE8TMsd4C2n5cfEaAiwVuQ0u2ulxlw1VjUC3NaycSHcoPOehYdlD3IFE1QmwwA
|
||||||
|
XLbLVeCd27RxJ9+kLHsijdHUtwIaqmyC+qBXGof+NikpA+UHA1kgbW8MFgb1QRYN
|
||||||
|
DJWFQdIgB6H43pW7KxKT2fULYCUeOvt8nST+4X/YZwclAw5Cets2vtVcLvS5BdGz
|
||||||
|
+ANOyppjKH7DzWzYtnamMdS24i50zQu97vtaoijT3f4wW+dMP+mlusQ651+9rCcz
|
||||||
|
TXHYkHg9lKw9hy+jdphJPVTMH+QDkcJSsDFpi7k53iLHFcf2YwqK1BiYKoJXd6GH
|
||||||
|
FbjybE6c8nNfPywzhSKpM34UNY8EV/14sDonjBLQLnr4Z3NrWLkCDQRMww5dARAA
|
||||||
|
9qZSA8fGWEppVjhJcJ7oFPzSeAEFeU0z/lASN6E6AaV75n63eQgx00s//2s+ty99
|
||||||
|
tqp7a5giIhbSaH1EHQ71xBGalXBirWJnCf5/OkYIgoZUWovveNQHGANXjh6qKfwy
|
||||||
|
qe9SmWnMn28146LNXKxU/YO+UyYy1AC+0R/Woe5funUmv7db6q/y/+KC9Wbmue+M
|
||||||
|
HtAbFqDf07Gvp4rSNeSY97jki6dl9bfS5d/ofcvziBM4KCgalGaxTvYT6UI11i03
|
||||||
|
YnW57WjtOstIZuJ1q1f8CC3OzTHRMwzoxLKmkfKXzEBxz9eM3fk3zYA6OTdSTOWl
|
||||||
|
0akvAiPr2CW4pr3MvwHYw9wEAqWJwadQmBDCCLhRlOzqD4WIJA1C3y7vYtxI2OWf
|
||||||
|
wiUqtIantAr296vsamuhoiNXAG+GlpYaKasKLr/s7kHcdpH5oD2DkdVUiZHB2xs1
|
||||||
|
ZjlgpafG71wHDiNKlJokJ4nZpQOoyDCXEdzr5uOz4fJ5Du4PUgG5y74Cu1JHZ0uJ
|
||||||
|
Le65D+MT2TmmiFeQHhT9Txdk2AVgf5uQjHDcIAvMI0niehT+l3zZ4YtRBviRksG4
|
||||||
|
349OecTu+33JoJGqtYnOcuPUR8HBB2dQrPK/l47SUg6esF5duznU4XkNskvbBWu3
|
||||||
|
2aiakTz7XiDm0TEzWtBS/hMRIeH4IyjNux8CwEJfV/MAEQEAAYkCHwQYAQoACQUC
|
||||||
|
TMMOXQIbDAAKCRCcT36dmLHMU2u/D/4umQeJcH06a2aM2ETXNVqDK29yti1tCSqs
|
||||||
|
0jsZivZrK+O+oxqvTzcocYtQ2Fb8WjexGpQ41wN5zocH85cCPD+UisziV4r0NQYK
|
||||||
|
p1FhAJfkacIR4EtuEQrH2J7m4IDUXSqTW1jv36lXrAO/5ON07Wy3AROoJdFwrtO8
|
||||||
|
ja0jX7Z+pe6OaLmptGSFeANSXN6r4CdGYtLh3s5Srf9++WTl+llMLEMfwbAHPSXt
|
||||||
|
NV7zoq8j1UwI444W9C4DnVNBiku1e42pQUFt3BtEg22mW/1RdhOHUsisxE3hyUtN
|
||||||
|
E2zCpu7Un5aedt5W72WozbAb0LPlUx/0fXyPLFNQmBMHeMVnxZb7CvraBo6BGHL4
|
||||||
|
karbJBX2p+5s05/g8t5ljPbfakGNcUZRqbCk1neOQZYOiW8vI1FBbwGWiFWTISHQ
|
||||||
|
d+uj/eQTWiQsz4+e3PAVZ4ekDYAMS1HLLXaBwxr7MHRIHRVVKJI8mFbI9HfGKpPt
|
||||||
|
HDx+C47QkbQgPu1YL85g5mHkoP621r79zyGjW35HS2l4TCnUZ3q+WLvLMLpIsYcW
|
||||||
|
YNBshwOavdSYmk9lCSSCtilTjl1e0E4WOGtusJKpmkAphOkjFKttCE6Z0mSHenLP
|
||||||
|
numenORuE0/O7DgoihMrYzTTaRBkHLssIzfaPu96jcWjU9dhuxFW5AktUshr2RLw
|
||||||
|
EaWfWeQZ4Q==
|
||||||
|
=b8+3
|
||||||
|
-----END PGP PUBLIC KEY BLOCK-----
|
||||||
|
pub 2048R/D56B5F17 2012-10-30 [expires: 2017-10-29]
|
||||||
|
uid Luis Bernardo <lbernardo@apache.org>
|
||||||
|
sig 3 D56B5F17 2012-10-30 Luis Bernardo <lbernardo@apache.org>
|
||||||
|
sub 2048R/A83AC321 2012-10-30 [expires: 2017-10-29]
|
||||||
|
sig D56B5F17 2012-10-30 Luis Bernardo <lbernardo@apache.org>
|
||||||
|
|
||||||
|
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
Version: GnuPG v1.4.12 (Darwin)
|
||||||
|
|
||||||
|
mQENBFCQVQIBCADLgf95foKzcNUQMOoQOz9xtX3V4lYVy797am5GwHD2TdWNCma4
|
||||||
|
QzwmcNSbxhOvs1tinYw/RTg7k05TPcinPDdRRrOAzS0NRh4G8rfFhs7j+/Eyz84R
|
||||||
|
0lsclF0IXMunbQQP/XQHcTm8huz2PDPrqzgRM65XC3mBasFjbUL6UnYk40AEq22M
|
||||||
|
ZTIAwIXjvO5G8w4Xgj8goN96wX57P00LYNJBDTyflUAvM8U5C7C2BposgBy1shsM
|
||||||
|
wHKiitmjrlUpFM2ImCoIiKCHfaxUfxgnn8/sERll8Nq9k82UOSNGLtIWIZskpVBc
|
||||||
|
LRC8pKpB/SqAppsCjw0whSivB81DiaFZkbOlABEBAAG0JEx1aXMgQmVybmFyZG8g
|
||||||
|
PGxiZXJuYXJkb0BhcGFjaGUub3JnPokBPgQTAQIAKAUCUJBVAgIbAwUJCWYBgAYL
|
||||||
|
CQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQggNpidVrXxfjAQgAgqyUd8dWzyp6
|
||||||
|
v0x+ae2JuevL2YyePbQONxcxnttGz6COYmTmcR7P4UBrbo2IIfd1MwgKYMlQjhjy
|
||||||
|
GdBYReroBh43p9x1q5/XqCNpEYrOPPw8kefs1DuMVN+/3VeyWGjHBOxGmG/lBmrb
|
||||||
|
uo+UlIsFHJyS1SCi3s8Wz4Xqh+2/TCpiWEnBjoxv/h01nGb3uH8uCD52wMwDdmap
|
||||||
|
ITT4vwbo5168iAcFNKJmMMZbMiSItPG4Xjnl09mkjsxGbzTKIaF5UYkCuKlbQyHY
|
||||||
|
hWaWq21Nf3/z+5R0Ck8sGqAvJtMncQgkeFFRCVIPQDve+80AJNvaE2bdo1mliPJU
|
||||||
|
Nr/6gKS+erkBDQRQkFUCAQgA1aUuCpYBJtnUgyW/spjxV1iff20XNlu+cko2rhu/
|
||||||
|
GgV91l0LE7x7lKvQrOi8ZJ24F8bPUGwUyQFr7IVQZfBrLt+coFc2BvousU+7hHCq
|
||||||
|
oAGoxQmJQnIySV//sOaYqLOhj/Bzi39K8wiuR6xSpWfv9dWf8i5UAXVzQNixzn1Z
|
||||||
|
lNrQlbko7zHF//iAiz/jhkdir8Sl5/Kc9VY5JuR9HPugnYTutmh1kX88ywjhB01K
|
||||||
|
gJhaeH2Fx2T1xWctC3/aw8voe8SK+BZJCwRkWTzcixxgsB4ypfm16uD8tHsPHJf5
|
||||||
|
33KPVDlMqm9bELo4ZiiqGgYbBllKmvkntcDN6bCvBFxh+wARAQABiQElBBgBAgAP
|
||||||
|
BQJQkFUCAhsMBQkJZgGAAAoJEIIDaYnVa18XwYEIALNzDt09MMDBJqM+GxrygYte
|
||||||
|
+E+C++hMW4i/txaTcSwyWyy8jaukPlPvPkrulEAQk4cvSMS4Ei88+9LmxPNWR+ZH
|
||||||
|
2R2SfmK6IeRW+EJ7XPrHDhl/2aYXtT+CxjMaT7Bccx8ttv08286U+AWveSOmUW7k
|
||||||
|
P61lZzW4xesosbmKp0s08cUkXhz9Zv/bIDnxTZgVGmNmwS4wiP1kFztXTt7bGUva
|
||||||
|
wwvdUvINMp/lF1ZVPM6KCncfyokQG/9G7bV122RCPKMcBOljNM+q6KZVA1Zx9dSt
|
||||||
|
c1NM5vOYQhGd4wRYE2+xqjAC1VJz0fdLUBkv2qqBYVyXAAXMUpDdgrJsutms5pY=
|
||||||
|
=C/Js
|
||||||
|
-----END PGP PUBLIC KEY BLOCK-----
|
||||||
|
pub 4096R/7CDB6DEA 2015-05-20
|
||||||
|
uid Simon Steiner (CODE SIGNING KEY) <ssteiner@apache.org>
|
||||||
|
sub 4096R/73382B77 2015-05-20
|
||||||
|
|
||||||
|
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
Version: GnuPG v1
|
||||||
|
|
||||||
|
mQINBFVcZesBEAC5Poew53ijRTE5kV2o2Tj+plJmoQMRtfiurMUpPQ4s/vTz8Bte
|
||||||
|
WoHdNfJrzordHBZdy1S7V8p2kTtKWyaNFMyVoavBqo/BurmJ/3qUKH5otXkXuaAi
|
||||||
|
zFaJPeEnR6y7pxTYkwFKyrn7TE4I84JKZEMLEbJIw1YF3t76nj055/OnzRtwc2Df
|
||||||
|
cPyGqDALyoFXk6R04qIotVmlX3NwwF6A0M79+W+kWvPg4sD4R6SqwJb1UhcqHrqb
|
||||||
|
kQOllg74cBjyAikRbqrCfoydHM10gc8f5w9+8v/fbDkSBtoh8Y31WSK6ocoWIg85
|
||||||
|
I3odqHFxThwFTAYQC2tdw1M5kYcOiYVqw91JvBivpKH02vryH2BJu9zQDNFeyXud
|
||||||
|
wyengMLlzUUmf9jBk3M8IUE4JTerw1AzWj0b3jdvG7FrgHrlszb6eCzE3BdY7zGS
|
||||||
|
Qh6e+ROsF2LEKkbjxeAg58nl/h5iLythheY0S6sspeOTuDtgLgm8TZiGHA+j/qKH
|
||||||
|
DY+aRReI0X2bzqNZROhTIXHSKsoX9+9g5a+1NYQeZmiICNo4vj+r4+i037QvIoy6
|
||||||
|
3K4NSVQgKnR9bbgyQCUprifrkywKF5a8eP3wtUGtH2FNqFQg1rUKBgLjLbRJ8PF2
|
||||||
|
Ag8O0jmJBPxdOIdVP4vz37m+jyKE6L4JWjnaFldtD3NDJI1QQYX4MmXEaQARAQAB
|
||||||
|
tDZTaW1vbiBTdGVpbmVyIChDT0RFIFNJR05JTkcgS0VZKSA8c3N0ZWluZXJAYXBh
|
||||||
|
Y2hlLm9yZz6JAjgEEwECACIFAlVcZesCGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4B
|
||||||
|
AheAAAoJEFuT8d98223qTtoP/j5AH1w90HOiYioGGgxrxOciQdGNht0yOVPXHDyj
|
||||||
|
8oKNBKYhNYQ9tAxNxEZFVS2KxB3R5dy/Q/9XvOP/NYTP8p0VyXmxNMkicUhJQOJ/
|
||||||
|
6mnxkTY/jk7y2XkYtdCby28SfMdExbM501arnG+vmXRtr3TpRRAxXCfS3FBI2n1H
|
||||||
|
Y7aX8pVX3NNRQqGxjnSv4q/2NKrR1ZFt7aDuAO9VfLXd5NkJkaGJ7E7T4AQMJE6K
|
||||||
|
KYUFkYKGeOc5dm1mHZMTVanyYRS0qWSpcnsamdU76HQgtC7koJmaeeI0MtntMkpB
|
||||||
|
jObTY80iam97P81hfhEi9UsAPy0WPBmossNqQFYQ5kQzxq030C1ERJl1nXJCkIpl
|
||||||
|
CpVv/aIV+kM+WQeA41IHgfLZsxHTkYRxtCZXh8HbFhpyKGwNRZhyvPn0oSbjQcke
|
||||||
|
oAbfnxCj1YH6TQGJQH1R1rGPv3ph3omq9pRuJ/th4uFmq06xpO6VLjUICV9F1N1J
|
||||||
|
kmiVpivC5iRDKw30YeRFe/J0BpflPizQh2gnTFCg0Q0ICUdehGovWKPDkJsG2+hb
|
||||||
|
AJaxfYQg5cJQI1P0UOc3w6rLh2ye3qkSRxF1O9oyRHuAZtKtsabEg3v7bx6RnX1F
|
||||||
|
BYGCB8ckud+qYlBjiGKLP7fJotuZv3hFWlFBoXb9F0WDpx+gUoEUH8H+9ygodEUq
|
||||||
|
gjCRuQINBFVcZesBEADFcTVSAZoaax9xpw1zxwjVgfQrNfobqnJM33r2EBSB4b80
|
||||||
|
NbPOtoHJ2OUvHq4w84PB+H4+JNAIA2KbPOvzB+u1Bn5IgJr9asH5lhrnrUSR+YCw
|
||||||
|
UlnCw+2YJumdv/l6RKcFKbSRZHWSwTD3ZLBMuPUqX9uZkOuG1ftTkcVtfFHN3WAu
|
||||||
|
ckHjVxTSkaHhZ7ALz8LIUH+8AL3/3eThM1KEgx+bcod8YttctzjTy9cAaT93DwKO
|
||||||
|
qzqHXpk6Fpv9bvdiNye8Ye7f8487N0/3alMPpJqt2tHAqjxJRDb590/09cbt2N6l
|
||||||
|
6B+WlpM5hgkV//7ViL357Hids64sqbYSnmpQjZWUdafDvVvMKYbITmx26BEoWtIq
|
||||||
|
wwpj7+DdQlxd/7bAtyk8XiHe6Ej9FF1PUEvBQw5NXOUiCSBo0hzcMMNy1uRb/Wpd
|
||||||
|
oZX3TFKXTWulv95uzKGAo3zrUuKcfOGfDgqZ/H2dy8Yw9DaWJRnXyYwweUi1Ptnc
|
||||||
|
Nk9ktycypCcVbsOQhGdQJNyGVUVgVV1CWz5GJ3eqtjHY09r7HEm6bGviJRu/sosk
|
||||||
|
XmmjRUFpqwtDCRACYShDpnFjpmWTZegPcwpN+492qLP6cjh1XSN4Cg1YZ/0BMY4N
|
||||||
|
V/yeadQf/hbM5hzPOhN6mr+VHOLulyXuV49EWisIRferqaXG67zIXbVQ4qfqfwAR
|
||||||
|
AQABiQIfBBgBAgAJBQJVXGXrAhsMAAoJEFuT8d98223qGKoP/RtyjtE5zEkrd7oa
|
||||||
|
vRK5FmNtdh8r63v8lwjxayCfmpQw14AQaPY7//ulfJQExpxqcCLFIEBqZ8o22RYA
|
||||||
|
XnsV6RF3JAIjSktAh57GMqUljeNxBtlix2zv5MVi/XiYcmQrID812KNfp3/guJfK
|
||||||
|
3Us5BOxLyDwHylwyb88dLM3rP4W8VvaRAEXfd0/6rhEugdCdcHD1c+E1XliqBw/T
|
||||||
|
UP3JjnnABfKR4NMZ67ENxc5jPDg2Jh3wychGGhvLddqk32KEIDTbV2SZYxtw3ylP
|
||||||
|
cRUtEoVGvkCDj8KpcLvvTbE7QCOycQMj1aHt5tc0w+Ibqbj3X+DdJEAxuZhMDyR6
|
||||||
|
hDkIr7YGkRjFacYeaunoY4tX4+x4tkf33eNsBa3DV6r6R18DWh8o6bWzHpPuEMZT
|
||||||
|
ewbUuSHF9xm0Ti3uehDHNHIFsnEpGDanb2UMO1kd2Xr6kjabce4DIHn+PhOqwC1o
|
||||||
|
bO9KBKaWO4uR7K1eWjOkqn70F7ykGz01AveouwRyOjh59VdpVe/Zpgtp/IvD6bP2
|
||||||
|
FbW6pZZeHWWoj+zaDmyRDn5wRfGkNuLUIMblgCXQXttAm/nYdRwPQyAI+T5CP8f+
|
||||||
|
nmZfX1E6PwDD9rT+fU+0R1eAIkEZE+0UfWoBwbnei19Xqpwx6VH5x8mtfvUH9J5H
|
||||||
|
PYDEgpBqDxD3E1CYq/cVFhKQRxpK
|
||||||
|
=n+z/
|
||||||
|
-----END PGP PUBLIC KEY BLOCK-----
|
|
@ -0,0 +1,201 @@
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
|
@ -0,0 +1,180 @@
|
||||||
|
|
||||||
|
Project Maintenance Howto
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
This document introduces newcomers to the management and maintenance of
|
||||||
|
the Batik project hosted under xmlgraphics.apache.org
|
||||||
|
(http://xmlgraphics.apache.org/batik/).
|
||||||
|
|
||||||
|
Each project is required to use Ant as build tool and to be coherent with the
|
||||||
|
rest of the build systems of the other projects, so that nightly builds and
|
||||||
|
distribution creation can be done automatically without per-project scripts.
|
||||||
|
|
||||||
|
This implies it is *very* important that property names are not changed
|
||||||
|
but kept consistent with the other projects.
|
||||||
|
|
||||||
|
Distribution Creation
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
For creating a distribution the following steps must be done:
|
||||||
|
|
||||||
|
1) Modify build.xml with the distribution version. Only modify the version
|
||||||
|
for main releases (e.g. version value="1.1") but not for release
|
||||||
|
candidates or beta versions where only the revision type and
|
||||||
|
number should be updated (e.g. revisionType value="beta" and
|
||||||
|
revisionNumber value="3")
|
||||||
|
|
||||||
|
2) Add your public key to the KEYS file in the root directory of
|
||||||
|
Batik if it isn't already there. The following link has the
|
||||||
|
details on what this means and how to do it.
|
||||||
|
|
||||||
|
http://wiki.apache.org/old/SigningReleases
|
||||||
|
|
||||||
|
3) Commit these changes to SVN, in general only the following files
|
||||||
|
should be modified:
|
||||||
|
|
||||||
|
build.xml
|
||||||
|
KEYS
|
||||||
|
|
||||||
|
4) Tag the release on SVN:
|
||||||
|
|
||||||
|
svn copy https://svn.apache.org/repos/asf/xmlgraphics/batik/trunk \
|
||||||
|
https://svn.apache.org/repos/asf/xmlgraphics/batik/tags/<tag>
|
||||||
|
|
||||||
|
where <tag> is the version name, e.g. "batik-1_1rc3".
|
||||||
|
|
||||||
|
Note: sometimes, it is necessary to remove a tag because the
|
||||||
|
tests failed and a fix was required. To remove a tag, use
|
||||||
|
the delete command:
|
||||||
|
|
||||||
|
svn delete https://svn.apache.org/repos/asf/xmlgraphics/batik/tags/<tag>
|
||||||
|
|
||||||
|
5) Check out the tagged release to a new directory:
|
||||||
|
|
||||||
|
svn co https://svn.apache.org/repos/asf/xmlgraphics/batik/tags/<tag>
|
||||||
|
|
||||||
|
6) Run the build script with target "dist-zip":
|
||||||
|
|
||||||
|
build dist-zip
|
||||||
|
|
||||||
|
This will create the binary release zip, the source release zip and the
|
||||||
|
javadoc zip.
|
||||||
|
|
||||||
|
7) Test the distributions
|
||||||
|
|
||||||
|
build regard
|
||||||
|
build regard.manual
|
||||||
|
|
||||||
|
The build results are in the test-reports directory. Check that there
|
||||||
|
are no show-stoppers for the release. If there are fixes required,
|
||||||
|
you need to remove the tag (as explained in step 2) and then fix
|
||||||
|
any problem that requires attention. Then, you need to start at
|
||||||
|
step 1) again.
|
||||||
|
|
||||||
|
Note that you will need to have a copy of the W3C SVG
|
||||||
|
working group test suite in the 'beSuite' directory and
|
||||||
|
have that directory under the same root as xml-batik. See
|
||||||
|
http://www.w3.org/Graphics/SVG for instructions on how to get
|
||||||
|
the SVG test suite.
|
||||||
|
|
||||||
|
8) Update the README and CHANGES files describing the content of the
|
||||||
|
release and the modifications which have taken place,
|
||||||
|
http://www.apache.org/dist/xmlgraphics/batik/README. This file has a
|
||||||
|
small header followed by the contents of the CHANGES file from the
|
||||||
|
distribution.
|
||||||
|
|
||||||
|
9) If you are creating a release candidate, rename the distribution files
|
||||||
|
to an rc name. For example:
|
||||||
|
|
||||||
|
mv batik-src-1.1.zip batik-src-1.1rc1.zip
|
||||||
|
|
||||||
|
10) Sign and create md5 hashes for the releases. The following link
|
||||||
|
has full details on how to sign things (if you don't want to know
|
||||||
|
anything the last section 'Using GPG' tells you what commands work).
|
||||||
|
|
||||||
|
http://wiki.apache.org/old/SigningReleases
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
gpg --detach-sig --armor --output batik-1.5.zip.asc batik-1.5.zip
|
||||||
|
md5 batik-1.5.zip > batik-1.5.zip.md5
|
||||||
|
|
||||||
|
11) Use 'scp' to copy the distributions (with md5 hashes, and signature
|
||||||
|
files), the README, and the KEYS file under
|
||||||
|
|
||||||
|
/www/www.apache.org/dist/xmlgraphics/batik/
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
scp batik-1.1rc1.zip* vhardy@people.apache.org:/www/www.apache.org/dist/xml/batik/
|
||||||
|
|
||||||
|
12) Finish setting up the distribution directory in accordance with:
|
||||||
|
|
||||||
|
http://www.apache.org/dev/mirrors.html
|
||||||
|
http://people.apache.org/~bodewig/mirror.html
|
||||||
|
|
||||||
|
This makes sure that the distribution is mirrored nicely around
|
||||||
|
the world.
|
||||||
|
|
||||||
|
Start by logging into svn.apache.org (e.g. 'ssh vhardy@svn.apache.org').
|
||||||
|
|
||||||
|
First make sure file permissions are correct. The
|
||||||
|
new files should be owned by group 'xmlgraphics' and be group writable.
|
||||||
|
The following commands can do this (don't worry about links):
|
||||||
|
|
||||||
|
chgrp xmlgraphics batik-1.5.zip
|
||||||
|
chmod 664 batik-1.5.zip
|
||||||
|
|
||||||
|
If you are making a 'final' release you should delete the existing
|
||||||
|
'current' links and re-point them at the new release (do this
|
||||||
|
for every file with a version number in it - including md5, and
|
||||||
|
asc files):
|
||||||
|
|
||||||
|
cd /www/www.apache.org/dist/xmlgraphics/batik
|
||||||
|
rm batik-current.zip
|
||||||
|
ln -s batik-1.5.zip batik-current.zip
|
||||||
|
rm batik-current.zip.md5
|
||||||
|
ln -s batik-1.5.zip.md5 batik-current.zip.md5
|
||||||
|
rm batik-current.zip.asc
|
||||||
|
ln -s batik-1.5.zip.asc batik-current.zip.asc
|
||||||
|
<- lots more files ->
|
||||||
|
|
||||||
|
Finally remove the old releases (every release is automatically copied
|
||||||
|
to 'archive.apache.org/dist/xmlgraphics/batik' from
|
||||||
|
'www.apache.org/dist/xmlgraphics/batik' so you can just remove an old
|
||||||
|
release from www.apache.org):
|
||||||
|
|
||||||
|
rm batik-1.5b4.zip
|
||||||
|
|
||||||
|
13) Wait approximately 24hrs for the files to get to all the mirrors,
|
||||||
|
then send an email to the batik-dev and batik-users mailing lists
|
||||||
|
announcing the release.
|
||||||
|
|
||||||
|
Site Creation
|
||||||
|
-------------
|
||||||
|
|
||||||
|
For creating the web site, the following steps must be done:
|
||||||
|
|
||||||
|
[Note: due to JVM font-rendering problems, this is best done on a
|
||||||
|
Windows machine]
|
||||||
|
|
||||||
|
1) run the build script with target "publish", which will generate the
|
||||||
|
site and use ForrestBot to commit it to the repository
|
||||||
|
2) connect to people.apache.org with your account
|
||||||
|
3) execute "cd /www/xmlgraphics.apache.org/batik"
|
||||||
|
4) execute "svn update"
|
||||||
|
|
||||||
|
If the javadocs don't need to be regenerated, the "publishdoc" build
|
||||||
|
target can be used instead of "publish". This will be much quicker.
|
||||||
|
|
||||||
|
Note that because of the way ForrestBot works, any files that are no
|
||||||
|
longer part of the site will still remain in Subversion, and thus will
|
||||||
|
still be deployed. To delete files permanently, check out
|
||||||
|
https://svn.apache.org/repos/asf/xmlgraphics/site/deploy/batik/ and make
|
||||||
|
changes there directly.
|
||||||
|
|
||||||
|
Nightly Builds
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The nightly builds are currently performed by a crontab entry in
|
||||||
|
Thomas DeWeese's people.apache.org account: /home/deweese/bin/nightly.csh
|
|
@ -0,0 +1,18 @@
|
||||||
|
Apache Batik
|
||||||
|
Copyright 1999-2022 The Apache Software Foundation
|
||||||
|
|
||||||
|
This product includes software developed at
|
||||||
|
The Apache Software Foundation (http://www.apache.org/).
|
||||||
|
|
||||||
|
This software contains code from the World Wide Web Consortium (W3C) for the
|
||||||
|
Document Object Model API (DOM API) and SVG Document Type Definition (DTD).
|
||||||
|
|
||||||
|
This software contains code from the International Organisation for
|
||||||
|
Standardization for the definition of character entities used in the software's
|
||||||
|
documentation.
|
||||||
|
|
||||||
|
This product includes images from the Tango Desktop Project
|
||||||
|
(http://tango.freedesktop.org/).
|
||||||
|
|
||||||
|
This product includes images from the Pasodoble Icon Theme
|
||||||
|
(http://www.jesusda.com/projects/pasodoble).
|
|
@ -0,0 +1,79 @@
|
||||||
|
|
||||||
|
A P A C H E B A T I K
|
||||||
|
|
||||||
|
What is it?
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Batik is a Java based toolkit for applications which handle
|
||||||
|
images in the Scalable Vector Graphics (SVG) format for
|
||||||
|
various purposes, such as viewing, generation or
|
||||||
|
manipulation.
|
||||||
|
|
||||||
|
The project's ambition is to give developers a set of core
|
||||||
|
modules which can be used together or individually to
|
||||||
|
support specific SVG solutions. Examples of modules are
|
||||||
|
an SVG parser, an SVG generator and an SVG DOM
|
||||||
|
implementation. Another ambition of the Batik project is to
|
||||||
|
make it highly extensible (for example, Batik allows the
|
||||||
|
developer to handle custom SVG tags). Even though the
|
||||||
|
goal of the project is to provide a set of core modules, one
|
||||||
|
of the deliveries is a full fledged SVG Viewer
|
||||||
|
implementation which validates the various modules and
|
||||||
|
their inter-operability.
|
||||||
|
|
||||||
|
In a nutshell, Batik provides building blocks that developers
|
||||||
|
can assemble in various ways in their Java technology
|
||||||
|
applications to generate, parse, view or convert SVG
|
||||||
|
contents. For example, Batik contains a Swing component
|
||||||
|
that can add SVG viewing capability to all Java technology
|
||||||
|
applications. Batik can also be used to generate SVG on a
|
||||||
|
client or on a server, and Batik can convert SVG content
|
||||||
|
into other formats such as JPEG or PNG. Batik's goal is to
|
||||||
|
make it easy for application developers to handle SVG
|
||||||
|
content for various purposes, client-side or server-side.
|
||||||
|
|
||||||
|
|
||||||
|
Where is it?
|
||||||
|
------------
|
||||||
|
|
||||||
|
The home page for the Apache Batik project can be found in the Apache XML
|
||||||
|
Project web site (http://xmlgraphics.apache.org/batik/). There you also find
|
||||||
|
information on how to download the latest release as well as all the other
|
||||||
|
information you might need regarding this project.
|
||||||
|
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
o A Java 8 or later compatible virtual machine for your operating system.
|
||||||
|
|
||||||
|
|
||||||
|
Optional Libraries
|
||||||
|
------------------
|
||||||
|
|
||||||
|
By default, Batik includes a scripting engine for ECMAScript. It is possible
|
||||||
|
to add support for additional scripting languages (Python and TCL).
|
||||||
|
|
||||||
|
See http://xmlgraphics.apache.org/batik/install.html#optionalComponents for
|
||||||
|
details.
|
||||||
|
|
||||||
|
|
||||||
|
Installation Instructions and Documentation
|
||||||
|
-------------------------------------------
|
||||||
|
|
||||||
|
Read the Install page at http://xmlgraphics.apache.org/batik/install.html
|
||||||
|
for the installation instructions.
|
||||||
|
|
||||||
|
Look for the most updated documentation on the Apache Batik web site under
|
||||||
|
the Apache XML Graphics Project (http://xmlgraphics.apache.org/batik/).
|
||||||
|
|
||||||
|
|
||||||
|
Licensing and legal issues
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
For legal and licensing issues, please read the LICENSE and NOTICE files.
|
||||||
|
|
||||||
|
Thanks for using Apache Batik.
|
||||||
|
|
||||||
|
The Apache XML Graphics Project
|
||||||
|
http://xmlgraphics.apache.org/
|
|
@ -0,0 +1,262 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>batik-all</artifactId>
|
||||||
|
<name>${project.groupId}:${project.artifactId}</name>
|
||||||
|
<description>Batik aggregate artifact</description>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache.xmlgraphics</groupId>
|
||||||
|
<artifactId>batik</artifactId>
|
||||||
|
<version>1.16</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-anim</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-awt-util</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-bridge</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-codec</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-constants</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-css</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-dom</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-ext</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-extension</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-gui-util</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-gvt</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-i18n</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-parser</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-rasterizer-ext</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-rasterizer</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-script</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-slideshow</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-squiggle-ext</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-squiggle</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-svg-dom</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-svgbrowser</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-svggen</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-svgpp</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-svgrasterizer</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-swing</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-transcoder</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-util</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-ttf2svg</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-xml</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>xml-apis</groupId>
|
||||||
|
<artifactId>xml-apis</artifactId>
|
||||||
|
<version>${xmlapis.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>xml-apis</groupId>
|
||||||
|
<artifactId>xml-apis-ext</artifactId>
|
||||||
|
<version>${xmlapisext.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>xmlgraphics-commons</artifactId>
|
||||||
|
<version>${xmlgraphics.commons.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>package-all</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>single</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<addMavenDescriptor>false</addMavenDescriptor>
|
||||||
|
<appendAssemblyId>false</appendAssemblyId>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
|
||||||
|
<mainClass>org.apache.batik.apps.svgbrowser.Main</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
<descriptors>
|
||||||
|
<descriptor>src/tools/resources/assembly/assembly.xml</descriptor>
|
||||||
|
</descriptors>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
||||||
|
<id>all</id>
|
||||||
|
<formats>
|
||||||
|
<format>jar</format>
|
||||||
|
</formats>
|
||||||
|
<includeBaseDirectory>false</includeBaseDirectory>
|
||||||
|
<dependencySets>
|
||||||
|
<dependencySet>
|
||||||
|
<unpack>true</unpack>
|
||||||
|
<unpackOptions>
|
||||||
|
<excludes>
|
||||||
|
<exclude>META-INF/maven</exclude>
|
||||||
|
<exclude>META-INF/maven/**/*</exclude>
|
||||||
|
</excludes>
|
||||||
|
</unpackOptions>
|
||||||
|
<useTransitiveDependencies>false</useTransitiveDependencies>
|
||||||
|
<excludes>
|
||||||
|
<exclude>xml-apis:*</exclude>
|
||||||
|
<exclude>*:xmlgraphics-commons</exclude>
|
||||||
|
</excludes>
|
||||||
|
</dependencySet>
|
||||||
|
</dependencySets>
|
||||||
|
</assembly>
|
|
@ -0,0 +1,109 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>batik-anim</artifactId>
|
||||||
|
<name>${project.groupId}:${project.artifactId}</name>
|
||||||
|
<description>Batik animation engine</description>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache.xmlgraphics</groupId>
|
||||||
|
<artifactId>batik</artifactId>
|
||||||
|
<version>1.16</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-awt-util</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-css</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-dom</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-ext</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-parser</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-shared-resources</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-svg-dom</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>batik-util</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>xml-apis</groupId>
|
||||||
|
<artifactId>xml-apis-ext</artifactId>
|
||||||
|
<version>${xmlapisext.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<version>${dependency.version}</version><!--$NO-MVN-MAN-VER$-->
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>unpack-shared-resources</id>
|
||||||
|
<phase>prepare-package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>unpack-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<includeGroupIds>${project.groupId}</includeGroupIds>
|
||||||
|
<includeArtifactIds>batik-shared-resources</includeArtifactIds>
|
||||||
|
<includes>**/LICENSE,**/NOTICE</includes>
|
||||||
|
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,210 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.dom.AnimatableElement;
|
||||||
|
import org.apache.batik.anim.timing.TimedElement;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
|
||||||
|
// import org.apache.batik.anim.timing.Trace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An abstract base class for the different types of animation.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: AbstractAnimation.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public abstract class AbstractAnimation {
|
||||||
|
|
||||||
|
// Constants for calcMode.
|
||||||
|
public static final short CALC_MODE_DISCRETE = 0;
|
||||||
|
public static final short CALC_MODE_LINEAR = 1;
|
||||||
|
public static final short CALC_MODE_PACED = 2;
|
||||||
|
public static final short CALC_MODE_SPLINE = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The TimedElement that controls the timing of this animation.
|
||||||
|
*/
|
||||||
|
protected TimedElement timedElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The AnimatableElement that gives access to underlying values in the
|
||||||
|
* document.
|
||||||
|
*/
|
||||||
|
protected AnimatableElement animatableElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The animation that is lower in the sandwich.
|
||||||
|
*/
|
||||||
|
protected AbstractAnimation lowerAnimation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The animation that is higher in the sandwich.
|
||||||
|
*/
|
||||||
|
protected AbstractAnimation higherAnimation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this animation needs recomputing.
|
||||||
|
*/
|
||||||
|
protected boolean isDirty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this animation is active.
|
||||||
|
*/
|
||||||
|
protected boolean isActive;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this animation is frozen.
|
||||||
|
*/
|
||||||
|
protected boolean isFrozen;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The time at which this animation became active. Used for ensuring the
|
||||||
|
* sandwich order is correct when multiple animations become active
|
||||||
|
* simultaneously.
|
||||||
|
*/
|
||||||
|
protected float beginTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value of this animation.
|
||||||
|
*/
|
||||||
|
protected AnimatableValue value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value of this animation composed with any others.
|
||||||
|
*/
|
||||||
|
protected AnimatableValue composedValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this animation depends on the underlying value.
|
||||||
|
*/
|
||||||
|
protected boolean usesUnderlyingValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this animation is a 'to-animation'.
|
||||||
|
*/
|
||||||
|
protected boolean toAnimation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Animation.
|
||||||
|
*/
|
||||||
|
protected AbstractAnimation(TimedElement timedElement,
|
||||||
|
AnimatableElement animatableElement) {
|
||||||
|
this.timedElement = timedElement;
|
||||||
|
this.animatableElement = animatableElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the TimedElement for this animation.
|
||||||
|
*/
|
||||||
|
public TimedElement getTimedElement() {
|
||||||
|
return timedElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of this animation, or null if it isn't active.
|
||||||
|
*/
|
||||||
|
public AnimatableValue getValue() {
|
||||||
|
if (!isActive && !isFrozen) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the composed value of this animation, or null if it isn't active.
|
||||||
|
*/
|
||||||
|
public AnimatableValue getComposedValue() {
|
||||||
|
// Trace.enter(this, "getComposedValue", null); try {
|
||||||
|
// Trace.print("isActive == " + isActive + ", isFrozen == " + isFrozen + ", isDirty == " + isDirty);
|
||||||
|
if (!isActive && !isFrozen) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (isDirty) {
|
||||||
|
// Trace.print("willReplace() == " + willReplace());
|
||||||
|
// Trace.print("value == " + value);
|
||||||
|
AnimatableValue lowerValue = null;
|
||||||
|
if (!willReplace()) {
|
||||||
|
// Trace.print("lowerAnimation == " + lowerAnimation);
|
||||||
|
if (lowerAnimation == null) {
|
||||||
|
lowerValue = animatableElement.getUnderlyingValue();
|
||||||
|
usesUnderlyingValue = true;
|
||||||
|
} else {
|
||||||
|
lowerValue = lowerAnimation.getComposedValue();
|
||||||
|
usesUnderlyingValue = false;
|
||||||
|
}
|
||||||
|
// Trace.print("lowerValue == " + lowerValue);
|
||||||
|
}
|
||||||
|
composedValue =
|
||||||
|
value.interpolate(composedValue, null, 0f, lowerValue, 1);
|
||||||
|
// Trace.print("composedValue == " + composedValue);
|
||||||
|
isDirty = false;
|
||||||
|
}
|
||||||
|
return composedValue;
|
||||||
|
// } finally { Trace.exit(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string representation of this animation.
|
||||||
|
*/
|
||||||
|
public String toString() {
|
||||||
|
return timedElement.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this animation depends on the underlying value.
|
||||||
|
*/
|
||||||
|
public boolean usesUnderlyingValue() {
|
||||||
|
return usesUnderlyingValue || toAnimation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this animation will replace values on animations
|
||||||
|
* lower in the sandwich.
|
||||||
|
*/
|
||||||
|
protected boolean willReplace() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks this animation and any animation that depends on it
|
||||||
|
* as dirty.
|
||||||
|
*/
|
||||||
|
protected void markDirty() {
|
||||||
|
isDirty = true;
|
||||||
|
if (higherAnimation != null
|
||||||
|
&& !higherAnimation.willReplace()
|
||||||
|
&& !higherAnimation.isDirty) {
|
||||||
|
higherAnimation.markDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the element is sampled for its "last" value.
|
||||||
|
*/
|
||||||
|
protected void sampledLastValue(int repeatIteration) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the element is sampled at the given time. This updates
|
||||||
|
* the {@link #value} of the animation if active.
|
||||||
|
*/
|
||||||
|
protected abstract void sampledAt(float simpleTime, float simpleDur,
|
||||||
|
int repeatIteration);
|
||||||
|
}
|
|
@ -0,0 +1,696 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.dom.AnimationTarget;
|
||||||
|
import org.apache.batik.anim.dom.AnimationTargetListener;
|
||||||
|
import org.apache.batik.anim.timing.TimedDocumentRoot;
|
||||||
|
import org.apache.batik.anim.timing.TimedElement;
|
||||||
|
import org.apache.batik.anim.timing.TimegraphListener;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An abstract base class for managing animation in a document.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: AnimationEngine.java 1804130 2017-08-04 14:41:11Z ssteiner $
|
||||||
|
*/
|
||||||
|
public abstract class AnimationEngine {
|
||||||
|
|
||||||
|
// Constants to identify the type of animation.
|
||||||
|
public static final short ANIM_TYPE_XML = 0;
|
||||||
|
public static final short ANIM_TYPE_CSS = 1;
|
||||||
|
public static final short ANIM_TYPE_OTHER = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The document this AnimationEngine is managing animation for.
|
||||||
|
*/
|
||||||
|
protected Document document;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The root time container for the document.
|
||||||
|
*/
|
||||||
|
protected TimedDocumentRoot timedDocumentRoot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The time at which the document was paused, or 0 if the document is not
|
||||||
|
* paused.
|
||||||
|
*/
|
||||||
|
protected long pauseTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of AnimationTargets to TargetInfo objects.
|
||||||
|
*/
|
||||||
|
protected HashMap targets = new HashMap();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of AbstractAnimations to AnimationInfo objects.
|
||||||
|
*/
|
||||||
|
protected HashMap animations = new HashMap();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The listener object for animation target base value changes.
|
||||||
|
*/
|
||||||
|
protected Listener targetListener = new Listener();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new AnimationEngine for the given document.
|
||||||
|
*/
|
||||||
|
public AnimationEngine(Document doc) {
|
||||||
|
this.document = doc;
|
||||||
|
timedDocumentRoot = createDocumentRoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disposes this animation engine.
|
||||||
|
*/
|
||||||
|
public void dispose() {
|
||||||
|
// Remove any target listeners that are registered.
|
||||||
|
for (Object o : targets.entrySet()) {
|
||||||
|
Map.Entry e = (Map.Entry) o;
|
||||||
|
AnimationTarget target = (AnimationTarget) e.getKey();
|
||||||
|
TargetInfo info = (TargetInfo) e.getValue();
|
||||||
|
|
||||||
|
Iterator j = info.xmlAnimations.iterator();
|
||||||
|
while (j.hasNext()) {
|
||||||
|
DoublyIndexedTable.Entry e2 =
|
||||||
|
(DoublyIndexedTable.Entry) j.next();
|
||||||
|
String namespaceURI = (String) e2.getKey1();
|
||||||
|
String localName = (String) e2.getKey2();
|
||||||
|
Sandwich sandwich = (Sandwich) e2.getValue();
|
||||||
|
if (sandwich.listenerRegistered) {
|
||||||
|
target.removeTargetListener(namespaceURI, localName, false,
|
||||||
|
targetListener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
j = info.cssAnimations.entrySet().iterator();
|
||||||
|
while (j.hasNext()) {
|
||||||
|
Map.Entry e2 = (Map.Entry) j.next();
|
||||||
|
String propertyName = (String) e2.getKey();
|
||||||
|
Sandwich sandwich = (Sandwich) e2.getValue();
|
||||||
|
if (sandwich.listenerRegistered) {
|
||||||
|
target.removeTargetListener(null, propertyName, true,
|
||||||
|
targetListener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pauses the animations.
|
||||||
|
*/
|
||||||
|
public void pause() {
|
||||||
|
if (pauseTime == 0) {
|
||||||
|
pauseTime = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unpauses the animations.
|
||||||
|
*/
|
||||||
|
public void unpause() {
|
||||||
|
if (pauseTime != 0) {
|
||||||
|
Calendar begin = timedDocumentRoot.getDocumentBeginTime();
|
||||||
|
int dt = (int) (System.currentTimeMillis() - pauseTime);
|
||||||
|
begin.add(Calendar.MILLISECOND, dt);
|
||||||
|
pauseTime = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether animations are currently paused.
|
||||||
|
*/
|
||||||
|
public boolean isPaused() {
|
||||||
|
return pauseTime != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current document time.
|
||||||
|
*/
|
||||||
|
public float getCurrentTime() {
|
||||||
|
return timedDocumentRoot.getCurrentTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the current document time.
|
||||||
|
*/
|
||||||
|
public float setCurrentTime(float t) {
|
||||||
|
boolean p = pauseTime != 0;
|
||||||
|
unpause();
|
||||||
|
Calendar begin = timedDocumentRoot.getDocumentBeginTime();
|
||||||
|
float now =
|
||||||
|
timedDocumentRoot.convertEpochTime(System.currentTimeMillis());
|
||||||
|
begin.add(Calendar.MILLISECOND, (int) ((now - t) * 1000));
|
||||||
|
if (p) {
|
||||||
|
pause();
|
||||||
|
}
|
||||||
|
return tick(t, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an animation to the document.
|
||||||
|
* @param target the target element of the animation
|
||||||
|
* @param type the type of animation (must be one of the
|
||||||
|
* <code>ANIM_TYPE_*</code> constants defined in this class
|
||||||
|
* @param ns the namespace URI of the attribute being animated, if
|
||||||
|
* <code>type == </code>{@link #ANIM_TYPE_XML}
|
||||||
|
* @param an the attribute name if <code>type == </code>{@link
|
||||||
|
* #ANIM_TYPE_XML}, the property name if <code>type == </code>
|
||||||
|
* {@link #ANIM_TYPE_CSS}, and the animation type otherwise
|
||||||
|
* @param anim the animation
|
||||||
|
*/
|
||||||
|
public void addAnimation(AnimationTarget target, short type, String ns,
|
||||||
|
String an, AbstractAnimation anim) {
|
||||||
|
// org.apache.batik.anim.timing.Trace.enter(this, "addAnimation", new Object[] { target, new Short[type], ns, an, anim } ); try {
|
||||||
|
timedDocumentRoot.addChild(anim.getTimedElement());
|
||||||
|
|
||||||
|
AnimationInfo animInfo = getAnimationInfo(anim);
|
||||||
|
animInfo.type = type;
|
||||||
|
animInfo.attributeNamespaceURI = ns;
|
||||||
|
animInfo.attributeLocalName = an;
|
||||||
|
animInfo.target = target;
|
||||||
|
animations.put(anim, animInfo);
|
||||||
|
|
||||||
|
Sandwich sandwich = getSandwich(target, type, ns, an);
|
||||||
|
if (sandwich.animation == null) {
|
||||||
|
anim.lowerAnimation = null;
|
||||||
|
anim.higherAnimation = null;
|
||||||
|
} else {
|
||||||
|
sandwich.animation.higherAnimation = anim;
|
||||||
|
anim.lowerAnimation = sandwich.animation;
|
||||||
|
anim.higherAnimation = null;
|
||||||
|
}
|
||||||
|
sandwich.animation = anim;
|
||||||
|
if (anim.lowerAnimation == null) {
|
||||||
|
sandwich.lowestAnimation = anim;
|
||||||
|
}
|
||||||
|
// } finally { org.apache.batik.anim.timing.Trace.exit(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes an animation from the document.
|
||||||
|
*/
|
||||||
|
public void removeAnimation(AbstractAnimation anim) {
|
||||||
|
// org.apache.batik.anim.timing.Trace.enter(this, "removeAnimation", new Object[] { anim } ); try {
|
||||||
|
timedDocumentRoot.removeChild(anim.getTimedElement());
|
||||||
|
AbstractAnimation nextHigher = anim.higherAnimation;
|
||||||
|
if (nextHigher != null) {
|
||||||
|
nextHigher.markDirty();
|
||||||
|
}
|
||||||
|
moveToBottom(anim);
|
||||||
|
if (anim.higherAnimation != null) {
|
||||||
|
anim.higherAnimation.lowerAnimation = null;
|
||||||
|
}
|
||||||
|
AnimationInfo animInfo = getAnimationInfo(anim);
|
||||||
|
Sandwich sandwich = getSandwich(animInfo.target, animInfo.type,
|
||||||
|
animInfo.attributeNamespaceURI,
|
||||||
|
animInfo.attributeLocalName);
|
||||||
|
if (sandwich.animation == anim) {
|
||||||
|
sandwich.animation = null;
|
||||||
|
sandwich.lowestAnimation = null;
|
||||||
|
sandwich.shouldUpdate = true;
|
||||||
|
}
|
||||||
|
// } finally { org.apache.batik.anim.timing.Trace.exit(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Sandwich for the given animation type/attribute.
|
||||||
|
*/
|
||||||
|
protected Sandwich getSandwich(AnimationTarget target, short type,
|
||||||
|
String ns, String an) {
|
||||||
|
TargetInfo info = getTargetInfo(target);
|
||||||
|
Sandwich sandwich;
|
||||||
|
if (type == ANIM_TYPE_XML) {
|
||||||
|
sandwich = (Sandwich) info.xmlAnimations.get(ns, an);
|
||||||
|
if (sandwich == null) {
|
||||||
|
sandwich = new Sandwich();
|
||||||
|
info.xmlAnimations.put(ns, an, sandwich);
|
||||||
|
}
|
||||||
|
} else if (type == ANIM_TYPE_CSS) {
|
||||||
|
sandwich = (Sandwich) info.cssAnimations.get(an);
|
||||||
|
if (sandwich == null) {
|
||||||
|
sandwich = new Sandwich();
|
||||||
|
info.cssAnimations.put(an, sandwich);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sandwich = (Sandwich) info.otherAnimations.get(an);
|
||||||
|
if (sandwich == null) {
|
||||||
|
sandwich = new Sandwich();
|
||||||
|
info.otherAnimations.put(an, sandwich);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sandwich;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the TargetInfo for the given AnimationTarget.
|
||||||
|
*/
|
||||||
|
protected TargetInfo getTargetInfo(AnimationTarget target) {
|
||||||
|
TargetInfo info = (TargetInfo) targets.get(target);
|
||||||
|
if (info == null) {
|
||||||
|
info = new TargetInfo();
|
||||||
|
targets.put(target, info);
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the AnimationInfo for the given AbstractAnimation.
|
||||||
|
*/
|
||||||
|
protected AnimationInfo getAnimationInfo(AbstractAnimation anim) {
|
||||||
|
AnimationInfo info = (AnimationInfo) animations.get(anim);
|
||||||
|
if (info == null) {
|
||||||
|
info = new AnimationInfo();
|
||||||
|
animations.put(anim, info);
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static final Map.Entry[] MAP_ENTRY_ARRAY = new Map.Entry[0];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the animations in the document to the given document time.
|
||||||
|
* @param time the document time to sample at
|
||||||
|
* @param hyperlinking whether the document should be seeked to the given
|
||||||
|
* time, as with hyperlinking
|
||||||
|
*/
|
||||||
|
protected float tick(float time, boolean hyperlinking) {
|
||||||
|
float waitTime = timedDocumentRoot.seekTo(time, hyperlinking);
|
||||||
|
Map.Entry[] targetEntries =
|
||||||
|
(Map.Entry[]) targets.entrySet().toArray(MAP_ENTRY_ARRAY);
|
||||||
|
for (Map.Entry e : targetEntries) {
|
||||||
|
AnimationTarget target = (AnimationTarget) e.getKey();
|
||||||
|
TargetInfo info = (TargetInfo) e.getValue();
|
||||||
|
|
||||||
|
// Update the XML animations.
|
||||||
|
Iterator j = info.xmlAnimations.iterator();
|
||||||
|
while (j.hasNext()) {
|
||||||
|
DoublyIndexedTable.Entry e2 =
|
||||||
|
(DoublyIndexedTable.Entry) j.next();
|
||||||
|
String namespaceURI = (String) e2.getKey1();
|
||||||
|
String localName = (String) e2.getKey2();
|
||||||
|
Sandwich sandwich = (Sandwich) e2.getValue();
|
||||||
|
if (sandwich.shouldUpdate ||
|
||||||
|
sandwich.animation != null
|
||||||
|
&& sandwich.animation.isDirty) {
|
||||||
|
AnimatableValue av = null;
|
||||||
|
boolean usesUnderlying = false;
|
||||||
|
AbstractAnimation anim = sandwich.animation;
|
||||||
|
if (anim != null) {
|
||||||
|
av = anim.getComposedValue();
|
||||||
|
usesUnderlying =
|
||||||
|
sandwich.lowestAnimation.usesUnderlyingValue();
|
||||||
|
anim.isDirty = false;
|
||||||
|
}
|
||||||
|
if (usesUnderlying && !sandwich.listenerRegistered) {
|
||||||
|
target.addTargetListener(namespaceURI, localName, false,
|
||||||
|
targetListener);
|
||||||
|
sandwich.listenerRegistered = true;
|
||||||
|
} else if (!usesUnderlying && sandwich.listenerRegistered) {
|
||||||
|
target.removeTargetListener(namespaceURI, localName,
|
||||||
|
false, targetListener);
|
||||||
|
sandwich.listenerRegistered = false;
|
||||||
|
}
|
||||||
|
target.updateAttributeValue(namespaceURI, localName, av);
|
||||||
|
sandwich.shouldUpdate = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the CSS animations.
|
||||||
|
j = info.cssAnimations.entrySet().iterator();
|
||||||
|
while (j.hasNext()) {
|
||||||
|
Map.Entry e2 = (Map.Entry) j.next();
|
||||||
|
String propertyName = (String) e2.getKey();
|
||||||
|
Sandwich sandwich = (Sandwich) e2.getValue();
|
||||||
|
if (sandwich.shouldUpdate ||
|
||||||
|
sandwich.animation != null
|
||||||
|
&& sandwich.animation.isDirty) {
|
||||||
|
AnimatableValue av = null;
|
||||||
|
boolean usesUnderlying = false;
|
||||||
|
AbstractAnimation anim = sandwich.animation;
|
||||||
|
if (anim != null) {
|
||||||
|
av = anim.getComposedValue();
|
||||||
|
usesUnderlying =
|
||||||
|
sandwich.lowestAnimation.usesUnderlyingValue();
|
||||||
|
anim.isDirty = false;
|
||||||
|
}
|
||||||
|
if (usesUnderlying && !sandwich.listenerRegistered) {
|
||||||
|
target.addTargetListener(null, propertyName, true,
|
||||||
|
targetListener);
|
||||||
|
sandwich.listenerRegistered = true;
|
||||||
|
} else if (!usesUnderlying && sandwich.listenerRegistered) {
|
||||||
|
target.removeTargetListener(null, propertyName, true,
|
||||||
|
targetListener);
|
||||||
|
sandwich.listenerRegistered = false;
|
||||||
|
}
|
||||||
|
if (usesUnderlying) {
|
||||||
|
target.updatePropertyValue(propertyName, null);
|
||||||
|
}
|
||||||
|
if (!(usesUnderlying && av == null)) {
|
||||||
|
target.updatePropertyValue(propertyName, av);
|
||||||
|
}
|
||||||
|
sandwich.shouldUpdate = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the other animations.
|
||||||
|
j = info.otherAnimations.entrySet().iterator();
|
||||||
|
while (j.hasNext()) {
|
||||||
|
Map.Entry e2 = (Map.Entry) j.next();
|
||||||
|
String type = (String) e2.getKey();
|
||||||
|
Sandwich sandwich = (Sandwich) e2.getValue();
|
||||||
|
if (sandwich.shouldUpdate ||
|
||||||
|
sandwich.animation != null
|
||||||
|
&& sandwich.animation.isDirty) {
|
||||||
|
AnimatableValue av = null;
|
||||||
|
AbstractAnimation anim = sandwich.animation;
|
||||||
|
if (anim != null) {
|
||||||
|
av = sandwich.animation.getComposedValue();
|
||||||
|
anim.isDirty = false;
|
||||||
|
}
|
||||||
|
target.updateOtherValue(type, av);
|
||||||
|
sandwich.shouldUpdate = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return waitTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked to indicate an animation became active at the specified time.
|
||||||
|
*
|
||||||
|
* @param anim the animation
|
||||||
|
* @param begin the time the element became active, in document simple time
|
||||||
|
*/
|
||||||
|
public void toActive(AbstractAnimation anim, float begin) {
|
||||||
|
moveToTop(anim);
|
||||||
|
anim.isActive = true;
|
||||||
|
anim.beginTime = begin;
|
||||||
|
anim.isFrozen = false;
|
||||||
|
// Move the animation down, in case it began at the same time as another
|
||||||
|
// animation in the sandwich and it's earlier in document order.
|
||||||
|
pushDown(anim);
|
||||||
|
anim.markDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves the animation down the sandwich such that it is in the right
|
||||||
|
* position according to begin time and document order.
|
||||||
|
*/
|
||||||
|
protected void pushDown(AbstractAnimation anim) {
|
||||||
|
TimedElement e = anim.getTimedElement();
|
||||||
|
AbstractAnimation top = null;
|
||||||
|
boolean moved = false;
|
||||||
|
while (anim.lowerAnimation != null
|
||||||
|
&& (anim.lowerAnimation.isActive
|
||||||
|
|| anim.lowerAnimation.isFrozen)
|
||||||
|
&& (anim.lowerAnimation.beginTime > anim.beginTime
|
||||||
|
|| anim.lowerAnimation.beginTime == anim.beginTime
|
||||||
|
&& e.isBefore(anim.lowerAnimation.getTimedElement()))) {
|
||||||
|
AbstractAnimation higher = anim.higherAnimation;
|
||||||
|
AbstractAnimation lower = anim.lowerAnimation;
|
||||||
|
AbstractAnimation lowerLower = lower.lowerAnimation;
|
||||||
|
if (higher != null) {
|
||||||
|
higher.lowerAnimation = lower;
|
||||||
|
}
|
||||||
|
if (lowerLower != null) {
|
||||||
|
lowerLower.higherAnimation = anim;
|
||||||
|
}
|
||||||
|
lower.lowerAnimation = anim;
|
||||||
|
lower.higherAnimation = higher;
|
||||||
|
anim.lowerAnimation = lowerLower;
|
||||||
|
anim.higherAnimation = lower;
|
||||||
|
if (!moved) {
|
||||||
|
top = lower;
|
||||||
|
moved = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (moved) {
|
||||||
|
AnimationInfo animInfo = getAnimationInfo(anim);
|
||||||
|
Sandwich sandwich = getSandwich(animInfo.target, animInfo.type,
|
||||||
|
animInfo.attributeNamespaceURI,
|
||||||
|
animInfo.attributeLocalName);
|
||||||
|
if (sandwich.animation == anim) {
|
||||||
|
sandwich.animation = top;
|
||||||
|
}
|
||||||
|
if (anim.lowerAnimation == null) {
|
||||||
|
sandwich.lowestAnimation = anim;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked to indicate that this timed element became inactive.
|
||||||
|
*
|
||||||
|
* @param anim the animation
|
||||||
|
* @param isFrozen whether the element is frozen or not
|
||||||
|
*/
|
||||||
|
public void toInactive(AbstractAnimation anim, boolean isFrozen) {
|
||||||
|
anim.isActive = false;
|
||||||
|
anim.isFrozen = isFrozen;
|
||||||
|
anim.markDirty();
|
||||||
|
if (!isFrozen) {
|
||||||
|
anim.value = null;
|
||||||
|
anim.beginTime = Float.NEGATIVE_INFINITY;
|
||||||
|
moveToBottom(anim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked to indicate that this timed element has had its fill removed.
|
||||||
|
*/
|
||||||
|
public void removeFill(AbstractAnimation anim) {
|
||||||
|
anim.isActive = false;
|
||||||
|
anim.isFrozen = false;
|
||||||
|
anim.value = null;
|
||||||
|
anim.markDirty();
|
||||||
|
moveToBottom(anim);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves the given animation to the top of the sandwich.
|
||||||
|
*/
|
||||||
|
protected void moveToTop(AbstractAnimation anim) {
|
||||||
|
AnimationInfo animInfo = getAnimationInfo(anim);
|
||||||
|
Sandwich sandwich = getSandwich(animInfo.target, animInfo.type,
|
||||||
|
animInfo.attributeNamespaceURI,
|
||||||
|
animInfo.attributeLocalName);
|
||||||
|
sandwich.shouldUpdate = true;
|
||||||
|
if (anim.higherAnimation == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (anim.lowerAnimation == null) {
|
||||||
|
sandwich.lowestAnimation = anim.higherAnimation;
|
||||||
|
} else {
|
||||||
|
anim.lowerAnimation.higherAnimation = anim.higherAnimation;
|
||||||
|
}
|
||||||
|
anim.higherAnimation.lowerAnimation = anim.lowerAnimation;
|
||||||
|
if (sandwich.animation != null) {
|
||||||
|
sandwich.animation.higherAnimation = anim;
|
||||||
|
}
|
||||||
|
anim.lowerAnimation = sandwich.animation;
|
||||||
|
anim.higherAnimation = null;
|
||||||
|
sandwich.animation = anim;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves the given animation to the bottom of the sandwich.
|
||||||
|
*/
|
||||||
|
protected void moveToBottom(AbstractAnimation anim) {
|
||||||
|
if (anim.lowerAnimation == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AnimationInfo animInfo = getAnimationInfo(anim);
|
||||||
|
Sandwich sandwich = getSandwich(animInfo.target, animInfo.type,
|
||||||
|
animInfo.attributeNamespaceURI,
|
||||||
|
animInfo.attributeLocalName);
|
||||||
|
AbstractAnimation nextLower = anim.lowerAnimation;
|
||||||
|
nextLower.markDirty();
|
||||||
|
anim.lowerAnimation.higherAnimation = anim.higherAnimation;
|
||||||
|
if (anim.higherAnimation != null) {
|
||||||
|
anim.higherAnimation.lowerAnimation = anim.lowerAnimation;
|
||||||
|
} else {
|
||||||
|
sandwich.animation = nextLower;
|
||||||
|
sandwich.shouldUpdate = true;
|
||||||
|
}
|
||||||
|
sandwich.lowestAnimation.lowerAnimation = anim;
|
||||||
|
anim.higherAnimation = sandwich.lowestAnimation;
|
||||||
|
anim.lowerAnimation = null;
|
||||||
|
sandwich.lowestAnimation = anim;
|
||||||
|
if (sandwich.animation.isDirty) {
|
||||||
|
sandwich.shouldUpdate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a {@link TimegraphListener} to the document.
|
||||||
|
*/
|
||||||
|
public void addTimegraphListener(TimegraphListener l) {
|
||||||
|
timedDocumentRoot.addTimegraphListener(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a {@link TimegraphListener} from the document.
|
||||||
|
*/
|
||||||
|
public void removeTimegraphListener(TimegraphListener l) {
|
||||||
|
timedDocumentRoot.removeTimegraphListener(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked to indicate that this timed element has been sampled at the given
|
||||||
|
* time.
|
||||||
|
*
|
||||||
|
* @param anim the animation
|
||||||
|
* @param simpleTime the sample time in local simple time
|
||||||
|
* @param simpleDur the simple duration of the element
|
||||||
|
* @param repeatIteration the repeat iteration during which the element was
|
||||||
|
* sampled
|
||||||
|
*/
|
||||||
|
public void sampledAt(AbstractAnimation anim, float simpleTime,
|
||||||
|
float simpleDur, int repeatIteration) {
|
||||||
|
anim.sampledAt(simpleTime, simpleDur, repeatIteration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked to indicate that this timed element has been sampled at the end
|
||||||
|
* of its active time, at an integer multiple of the simple duration. This
|
||||||
|
* is the "last" value that will be used for filling, which cannot be
|
||||||
|
* sampled normally.
|
||||||
|
*/
|
||||||
|
public void sampledLastValue(AbstractAnimation anim, int repeatIteration) {
|
||||||
|
anim.sampledLastValue(repeatIteration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new returns a new TimedDocumentRoot object for the document.
|
||||||
|
*/
|
||||||
|
protected abstract TimedDocumentRoot createDocumentRoot();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener class for changes to base values on a target element.
|
||||||
|
*/
|
||||||
|
protected class Listener implements AnimationTargetListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked to indicate that base value of the specified attribute
|
||||||
|
* or property has changed.
|
||||||
|
*/
|
||||||
|
public void baseValueChanged(AnimationTarget t, String ns, String ln,
|
||||||
|
boolean isCSS) {
|
||||||
|
short type = isCSS ? ANIM_TYPE_CSS : ANIM_TYPE_XML;
|
||||||
|
Sandwich sandwich = getSandwich(t, type, ns, ln);
|
||||||
|
sandwich.shouldUpdate = true;
|
||||||
|
AbstractAnimation anim = sandwich.animation;
|
||||||
|
while (anim.lowerAnimation != null) {
|
||||||
|
anim = anim.lowerAnimation;
|
||||||
|
}
|
||||||
|
anim.markDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class to hold XML and CSS animations for a target element.
|
||||||
|
*/
|
||||||
|
protected static class TargetInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of XML attribute names to the corresponding {@link Sandwich}
|
||||||
|
* objects.
|
||||||
|
*/
|
||||||
|
public DoublyIndexedTable xmlAnimations = new DoublyIndexedTable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of CSS attribute names to the corresponding {@link Sandwich}
|
||||||
|
* objects.
|
||||||
|
*/
|
||||||
|
public HashMap cssAnimations = new HashMap();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of other animation types to the corresponding {@link Sandwich}
|
||||||
|
* objects.
|
||||||
|
*/
|
||||||
|
public HashMap otherAnimations = new HashMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class to hold an animation sandwich for a particular attribute.
|
||||||
|
*/
|
||||||
|
protected static class Sandwich {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The top-most animation in the sandwich.
|
||||||
|
*/
|
||||||
|
public AbstractAnimation animation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The bottom-most animation in the sandwich.
|
||||||
|
*/
|
||||||
|
public AbstractAnimation lowestAnimation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the animation needs to have its value copied into the
|
||||||
|
* document.
|
||||||
|
*/
|
||||||
|
public boolean shouldUpdate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether an {@link AnimationTargetListener} has been registered to
|
||||||
|
* listen for changes to the base value.
|
||||||
|
*/
|
||||||
|
public boolean listenerRegistered;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class to hold target information of an animation.
|
||||||
|
*/
|
||||||
|
protected static class AnimationInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The target of the animation.
|
||||||
|
*/
|
||||||
|
public AnimationTarget target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of animation. Must be one of the <code>ANIM_TYPE_*</code>
|
||||||
|
* constants defined in {@link AnimationEngine}.
|
||||||
|
*/
|
||||||
|
public short type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The namespace URI of the attribute to animate, if this is an XML
|
||||||
|
* attribute animation.
|
||||||
|
*/
|
||||||
|
public String attributeNamespaceURI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The local name of the attribute or the name of the CSS property to
|
||||||
|
* animate.
|
||||||
|
*/
|
||||||
|
public String attributeLocalName;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.timing.TimedElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An exception class for SMIL animation exceptions.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: AnimationException.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class AnimationException extends RuntimeException {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The timed element on which the error occurred.
|
||||||
|
*/
|
||||||
|
protected TimedElement e;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The error code.
|
||||||
|
*/
|
||||||
|
protected String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The parameters to use for the error message.
|
||||||
|
*/
|
||||||
|
protected Object[] params;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message.
|
||||||
|
*/
|
||||||
|
protected String message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new AnimationException.
|
||||||
|
* @param e the animation element on which the error occurred
|
||||||
|
* @param code the error code
|
||||||
|
* @param params the parameters to use for the error message
|
||||||
|
*/
|
||||||
|
public AnimationException(TimedElement e, String code, Object[] params) {
|
||||||
|
this.e = e;
|
||||||
|
this.code = code;
|
||||||
|
this.params = params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the timed element that caused this animation exception.
|
||||||
|
*/
|
||||||
|
public TimedElement getElement() {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the error code.
|
||||||
|
*/
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the error message parameters.
|
||||||
|
*/
|
||||||
|
public Object[] getParams() {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the error message according to the error code and parameters.
|
||||||
|
*/
|
||||||
|
public String getMessage() {
|
||||||
|
return TimedElement.formatMessage(code, params);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.dom.AnimatableElement;
|
||||||
|
import org.apache.batik.anim.timing.TimedElement;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An animation class for 'animateColor' animations.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: ColorAnimation.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class ColorAnimation extends SimpleAnimation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ColorAnimation.
|
||||||
|
*/
|
||||||
|
public ColorAnimation(TimedElement timedElement,
|
||||||
|
AnimatableElement animatableElement,
|
||||||
|
int calcMode,
|
||||||
|
float[] keyTimes,
|
||||||
|
float[] keySplines,
|
||||||
|
boolean additive,
|
||||||
|
boolean cumulative,
|
||||||
|
AnimatableValue[] values,
|
||||||
|
AnimatableValue from,
|
||||||
|
AnimatableValue to,
|
||||||
|
AnimatableValue by) {
|
||||||
|
super(timedElement, animatableElement, calcMode, keyTimes, keySplines,
|
||||||
|
additive, cumulative, values, from, to, by);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,167 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.dom.AnimatableElement;
|
||||||
|
import org.apache.batik.anim.timing.TimedElement;
|
||||||
|
import org.apache.batik.ext.awt.geom.Cubic;
|
||||||
|
import org.apache.batik.util.SMILConstants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An abstract animation class for those animations that interpolate
|
||||||
|
* values. Specifically, this is for animations that have the 'calcMode',
|
||||||
|
* 'keyTimes', 'keySplines', 'additive' and 'cumulative' attributes.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: InterpolatingAnimation.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public abstract class InterpolatingAnimation extends AbstractAnimation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interpolation mode of this animator. This should take one
|
||||||
|
* of the CALC_MODE_* constants defined in {@link AbstractAnimation}.
|
||||||
|
*/
|
||||||
|
protected int calcMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time values to control the pacing of the animation.
|
||||||
|
*/
|
||||||
|
protected float[] keyTimes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bezier control points that control the pacing of the animation.
|
||||||
|
*/
|
||||||
|
protected float[] keySplines;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cubics built from the bezier control points in {@link #keySplines}.
|
||||||
|
*/
|
||||||
|
protected Cubic[] keySplineCubics;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this animation adds to ones below it in the animation sandwich
|
||||||
|
* or replaces them.
|
||||||
|
*/
|
||||||
|
protected boolean additive;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this animation accumulates from previous iterations.
|
||||||
|
*/
|
||||||
|
protected boolean cumulative;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new InterpolatingAnimation.
|
||||||
|
*/
|
||||||
|
public InterpolatingAnimation(TimedElement timedElement,
|
||||||
|
AnimatableElement animatableElement,
|
||||||
|
int calcMode,
|
||||||
|
float[] keyTimes,
|
||||||
|
float[] keySplines,
|
||||||
|
boolean additive,
|
||||||
|
boolean cumulative) {
|
||||||
|
super(timedElement, animatableElement);
|
||||||
|
this.calcMode = calcMode;
|
||||||
|
this.keyTimes = keyTimes;
|
||||||
|
this.keySplines = keySplines;
|
||||||
|
this.additive = additive;
|
||||||
|
this.cumulative = cumulative;
|
||||||
|
|
||||||
|
if (calcMode == CALC_MODE_SPLINE) {
|
||||||
|
if (keySplines == null || keySplines.length % 4 != 0) {
|
||||||
|
throw timedElement.createException
|
||||||
|
("attribute.malformed",
|
||||||
|
new Object[] { null,
|
||||||
|
SMILConstants.SMIL_KEY_SPLINES_ATTRIBUTE });
|
||||||
|
}
|
||||||
|
keySplineCubics = new Cubic[keySplines.length / 4];
|
||||||
|
for (int i = 0; i < keySplines.length / 4; i++) {
|
||||||
|
keySplineCubics[i] = new Cubic(0, 0,
|
||||||
|
keySplines[i * 4],
|
||||||
|
keySplines[i * 4 + 1],
|
||||||
|
keySplines[i * 4 + 2],
|
||||||
|
keySplines[i * 4 + 3],
|
||||||
|
1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyTimes != null) {
|
||||||
|
boolean invalidKeyTimes = false;
|
||||||
|
if ((calcMode == CALC_MODE_LINEAR || calcMode == CALC_MODE_SPLINE
|
||||||
|
|| calcMode == CALC_MODE_PACED)
|
||||||
|
&& (keyTimes.length < 2
|
||||||
|
|| keyTimes[0] != 0
|
||||||
|
|| keyTimes[keyTimes.length - 1] != 1)
|
||||||
|
|| calcMode == CALC_MODE_DISCRETE
|
||||||
|
&& (keyTimes.length == 0 || keyTimes[0] != 0)) {
|
||||||
|
invalidKeyTimes = true;
|
||||||
|
}
|
||||||
|
if (!invalidKeyTimes) {
|
||||||
|
for (int i = 1; i < keyTimes.length; i++) {
|
||||||
|
if (keyTimes[i] < 0 || keyTimes[1] > 1
|
||||||
|
|| keyTimes[i] < keyTimes[i - 1]) {
|
||||||
|
invalidKeyTimes = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (invalidKeyTimes) {
|
||||||
|
throw timedElement.createException
|
||||||
|
("attribute.malformed",
|
||||||
|
new Object[] { null,
|
||||||
|
SMILConstants.SMIL_KEY_TIMES_ATTRIBUTE });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this animation will replace values on animations
|
||||||
|
* lower in the sandwich.
|
||||||
|
*/
|
||||||
|
protected boolean willReplace() {
|
||||||
|
return !additive;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the element is sampled for its "last" value.
|
||||||
|
*/
|
||||||
|
protected void sampledLastValue(int repeatIteration) {
|
||||||
|
sampledAtUnitTime(1f, repeatIteration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the element is sampled at the given time.
|
||||||
|
*/
|
||||||
|
protected void sampledAt(float simpleTime, float simpleDur,
|
||||||
|
int repeatIteration) {
|
||||||
|
float unitTime;
|
||||||
|
if (simpleDur == TimedElement.INDEFINITE) {
|
||||||
|
unitTime = 0;
|
||||||
|
} else {
|
||||||
|
unitTime = simpleTime / simpleDur;
|
||||||
|
}
|
||||||
|
sampledAtUnitTime(unitTime, repeatIteration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the element is sampled at the given unit time. This updates
|
||||||
|
* the {@link #value} of the animation if active.
|
||||||
|
*/
|
||||||
|
protected abstract void sampledAtUnitTime(float unitTime,
|
||||||
|
int repeatIteration);
|
||||||
|
}
|
|
@ -0,0 +1,331 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.dom.AnimatableElement;
|
||||||
|
import org.apache.batik.anim.timing.TimedElement;
|
||||||
|
import org.apache.batik.anim.values.AnimatableAngleValue;
|
||||||
|
import org.apache.batik.anim.values.AnimatableMotionPointValue;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
import org.apache.batik.ext.awt.geom.Cubic;
|
||||||
|
import org.apache.batik.ext.awt.geom.ExtendedGeneralPath;
|
||||||
|
import org.apache.batik.ext.awt.geom.ExtendedPathIterator;
|
||||||
|
import org.apache.batik.ext.awt.geom.PathLength;
|
||||||
|
import org.apache.batik.util.SMILConstants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An animation class for 'animateMotion' animations.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: MotionAnimation.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class MotionAnimation extends InterpolatingAnimation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The path that describes the motion.
|
||||||
|
*/
|
||||||
|
protected ExtendedGeneralPath path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The path length calculation object.
|
||||||
|
*/
|
||||||
|
protected PathLength pathLength;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The points defining the distance along the path that the
|
||||||
|
* keyTimes apply.
|
||||||
|
*/
|
||||||
|
protected float[] keyPoints;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether automatic rotation should be performed.
|
||||||
|
*/
|
||||||
|
protected boolean rotateAuto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the automatic rotation should be reversed.
|
||||||
|
*/
|
||||||
|
protected boolean rotateAutoReverse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The angle of rotation (in radians) to use when automatic rotation is
|
||||||
|
* not being used.
|
||||||
|
*/
|
||||||
|
protected float rotateAngle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new MotionAnimation.
|
||||||
|
*/
|
||||||
|
public MotionAnimation(TimedElement timedElement,
|
||||||
|
AnimatableElement animatableElement,
|
||||||
|
int calcMode,
|
||||||
|
float[] keyTimes,
|
||||||
|
float[] keySplines,
|
||||||
|
boolean additive,
|
||||||
|
boolean cumulative,
|
||||||
|
AnimatableValue[] values,
|
||||||
|
AnimatableValue from,
|
||||||
|
AnimatableValue to,
|
||||||
|
AnimatableValue by,
|
||||||
|
ExtendedGeneralPath path,
|
||||||
|
float[] keyPoints,
|
||||||
|
boolean rotateAuto,
|
||||||
|
boolean rotateAutoReverse,
|
||||||
|
float rotateAngle,
|
||||||
|
short rotateAngleUnit) {
|
||||||
|
super(timedElement, animatableElement, calcMode, keyTimes, keySplines,
|
||||||
|
additive, cumulative);
|
||||||
|
this.rotateAuto = rotateAuto;
|
||||||
|
this.rotateAutoReverse = rotateAutoReverse;
|
||||||
|
this.rotateAngle = AnimatableAngleValue.rad(rotateAngle, rotateAngleUnit);
|
||||||
|
|
||||||
|
if (path == null) {
|
||||||
|
path = new ExtendedGeneralPath();
|
||||||
|
if (values == null || values.length == 0) {
|
||||||
|
if (from != null) {
|
||||||
|
AnimatableMotionPointValue fromPt = (AnimatableMotionPointValue) from;
|
||||||
|
float x = fromPt.getX();
|
||||||
|
float y = fromPt.getY();
|
||||||
|
path.moveTo(x, y);
|
||||||
|
if (to != null) {
|
||||||
|
AnimatableMotionPointValue toPt = (AnimatableMotionPointValue) to;
|
||||||
|
path.lineTo(toPt.getX(), toPt.getY());
|
||||||
|
} else if (by != null) {
|
||||||
|
AnimatableMotionPointValue byPt = (AnimatableMotionPointValue) by;
|
||||||
|
path.lineTo(x + byPt.getX(), y + byPt.getY());
|
||||||
|
} else {
|
||||||
|
throw timedElement.createException
|
||||||
|
("values.to.by.path.missing",
|
||||||
|
new Object[] { null });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (to != null) {
|
||||||
|
AnimatableMotionPointValue unPt = (AnimatableMotionPointValue)
|
||||||
|
animatableElement.getUnderlyingValue();
|
||||||
|
AnimatableMotionPointValue toPt = (AnimatableMotionPointValue) to;
|
||||||
|
path.moveTo(unPt.getX(), unPt.getY());
|
||||||
|
path.lineTo(toPt.getX(), toPt.getY());
|
||||||
|
this.cumulative = false;
|
||||||
|
} else if (by != null) {
|
||||||
|
AnimatableMotionPointValue byPt = (AnimatableMotionPointValue) by;
|
||||||
|
path.moveTo(0, 0);
|
||||||
|
path.lineTo(byPt.getX(), byPt.getY());
|
||||||
|
this.additive = true;
|
||||||
|
} else {
|
||||||
|
throw timedElement.createException
|
||||||
|
("values.to.by.path.missing",
|
||||||
|
new Object[] { null });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
AnimatableMotionPointValue pt = (AnimatableMotionPointValue) values[0];
|
||||||
|
path.moveTo(pt.getX(), pt.getY());
|
||||||
|
for (int i = 1; i < values.length; i++) {
|
||||||
|
pt = (AnimatableMotionPointValue) values[i];
|
||||||
|
path.lineTo(pt.getX(), pt.getY());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.path = path;
|
||||||
|
pathLength = new PathLength(path);
|
||||||
|
int segments = 0;
|
||||||
|
ExtendedPathIterator epi = path.getExtendedPathIterator();
|
||||||
|
while (!epi.isDone()) {
|
||||||
|
int type = epi.currentSegment();
|
||||||
|
if (type != ExtendedPathIterator.SEG_MOVETO) {
|
||||||
|
segments++;
|
||||||
|
}
|
||||||
|
epi.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = keyPoints == null ? segments + 1 : keyPoints.length;
|
||||||
|
float totalLength = pathLength.lengthOfPath();
|
||||||
|
if (this.keyTimes != null && calcMode != CALC_MODE_PACED) {
|
||||||
|
if (this.keyTimes.length != count) {
|
||||||
|
throw timedElement.createException
|
||||||
|
("attribute.malformed",
|
||||||
|
new Object[] { null,
|
||||||
|
SMILConstants.SMIL_KEY_TIMES_ATTRIBUTE });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (calcMode == CALC_MODE_LINEAR || calcMode == CALC_MODE_SPLINE) {
|
||||||
|
this.keyTimes = new float[count];
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
this.keyTimes[i] = (float) i / (count - 1);
|
||||||
|
}
|
||||||
|
} else if (calcMode == CALC_MODE_DISCRETE) {
|
||||||
|
this.keyTimes = new float[count];
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
this.keyTimes[i] = (float) i / count;
|
||||||
|
}
|
||||||
|
} else { // CALC_MODE_PACED
|
||||||
|
// This corrects the keyTimes to be paced, so from now on
|
||||||
|
// it can be considered the same as CALC_MODE_LINEAR.
|
||||||
|
epi = path.getExtendedPathIterator();
|
||||||
|
this.keyTimes = new float[count];
|
||||||
|
int j = 0;
|
||||||
|
for (int i = 0; i < count - 1; i++) {
|
||||||
|
while (epi.currentSegment() ==
|
||||||
|
ExtendedPathIterator.SEG_MOVETO) {
|
||||||
|
j++;
|
||||||
|
epi.next();
|
||||||
|
}
|
||||||
|
this.keyTimes[i] =
|
||||||
|
pathLength.getLengthAtSegment(j) / totalLength;
|
||||||
|
j++;
|
||||||
|
epi.next();
|
||||||
|
}
|
||||||
|
this.keyTimes[count - 1] = 1f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyPoints != null) {
|
||||||
|
if (keyPoints.length != this.keyTimes.length) {
|
||||||
|
throw timedElement.createException
|
||||||
|
("attribute.malformed",
|
||||||
|
new Object[] { null,
|
||||||
|
SMILConstants.SMIL_KEY_POINTS_ATTRIBUTE });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
epi = path.getExtendedPathIterator();
|
||||||
|
keyPoints = new float[count];
|
||||||
|
int j = 0;
|
||||||
|
for (int i = 0; i < count - 1; i++) {
|
||||||
|
while (epi.currentSegment() ==
|
||||||
|
ExtendedPathIterator.SEG_MOVETO) {
|
||||||
|
j++;
|
||||||
|
epi.next();
|
||||||
|
}
|
||||||
|
keyPoints[i] = pathLength.getLengthAtSegment(j) / totalLength;
|
||||||
|
j++;
|
||||||
|
epi.next();
|
||||||
|
}
|
||||||
|
keyPoints[count - 1] = 1f;
|
||||||
|
}
|
||||||
|
this.keyPoints = keyPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the element is sampled at the given unit time. This updates
|
||||||
|
* the {@link #value} of the animation if active.
|
||||||
|
*/
|
||||||
|
protected void sampledAtUnitTime(float unitTime, int repeatIteration) {
|
||||||
|
AnimatableValue value, accumulation;
|
||||||
|
float interpolation = 0;
|
||||||
|
if (unitTime != 1) {
|
||||||
|
int keyTimeIndex = 0;
|
||||||
|
while (keyTimeIndex < keyTimes.length - 1
|
||||||
|
&& unitTime >= keyTimes[keyTimeIndex + 1]) {
|
||||||
|
keyTimeIndex++;
|
||||||
|
}
|
||||||
|
if (keyTimeIndex == keyTimes.length - 1 && calcMode == CALC_MODE_DISCRETE) {
|
||||||
|
keyTimeIndex = keyTimes.length - 2;
|
||||||
|
interpolation = 1;
|
||||||
|
} else {
|
||||||
|
if (calcMode == CALC_MODE_LINEAR || calcMode == CALC_MODE_PACED
|
||||||
|
|| calcMode == CALC_MODE_SPLINE) {
|
||||||
|
if (unitTime == 0) {
|
||||||
|
interpolation = 0;
|
||||||
|
} else {
|
||||||
|
interpolation = (unitTime - keyTimes[keyTimeIndex])
|
||||||
|
/ (keyTimes[keyTimeIndex + 1] - keyTimes[keyTimeIndex]);
|
||||||
|
}
|
||||||
|
if (calcMode == CALC_MODE_SPLINE && unitTime != 0) {
|
||||||
|
// XXX This could be done better, e.g. with
|
||||||
|
// Newton-Raphson.
|
||||||
|
Cubic c = keySplineCubics[keyTimeIndex];
|
||||||
|
float tolerance = 0.001f;
|
||||||
|
float min = 0;
|
||||||
|
float max = 1;
|
||||||
|
Point2D.Double p;
|
||||||
|
for (;;) {
|
||||||
|
float t = (min + max) / 2;
|
||||||
|
p = c.eval(t);
|
||||||
|
double x = p.getX();
|
||||||
|
if (Math.abs(x - interpolation) < tolerance) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (x < interpolation) {
|
||||||
|
min = t;
|
||||||
|
} else {
|
||||||
|
max = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
interpolation = (float) p.getY();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
float point = keyPoints[keyTimeIndex];
|
||||||
|
if (interpolation != 0) {
|
||||||
|
point += interpolation *
|
||||||
|
(keyPoints[keyTimeIndex + 1] - keyPoints[keyTimeIndex]);
|
||||||
|
}
|
||||||
|
point *= pathLength.lengthOfPath();
|
||||||
|
Point2D p = pathLength.pointAtLength(point);
|
||||||
|
float ang;
|
||||||
|
if (rotateAuto) {
|
||||||
|
ang = pathLength.angleAtLength(point);
|
||||||
|
if (rotateAutoReverse) {
|
||||||
|
ang += Math.PI;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ang = rotateAngle;
|
||||||
|
}
|
||||||
|
value = new AnimatableMotionPointValue(null, (float) p.getX(),
|
||||||
|
(float) p.getY(), ang);
|
||||||
|
} else {
|
||||||
|
Point2D p = pathLength.pointAtLength(pathLength.lengthOfPath());
|
||||||
|
float ang;
|
||||||
|
if (rotateAuto) {
|
||||||
|
ang = pathLength.angleAtLength(pathLength.lengthOfPath());
|
||||||
|
if (rotateAutoReverse) {
|
||||||
|
ang += Math.PI;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ang = rotateAngle;
|
||||||
|
}
|
||||||
|
value = new AnimatableMotionPointValue(null, (float) p.getX(),
|
||||||
|
(float) p.getY(), ang);
|
||||||
|
}
|
||||||
|
if (cumulative) {
|
||||||
|
Point2D p = pathLength.pointAtLength(pathLength.lengthOfPath());
|
||||||
|
float ang;
|
||||||
|
if (rotateAuto) {
|
||||||
|
ang = pathLength.angleAtLength(pathLength.lengthOfPath());
|
||||||
|
if (rotateAutoReverse) {
|
||||||
|
ang += Math.PI;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ang = rotateAngle;
|
||||||
|
}
|
||||||
|
accumulation = new AnimatableMotionPointValue(null, (float) p.getX(),
|
||||||
|
(float) p.getY(), ang);
|
||||||
|
} else {
|
||||||
|
accumulation = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.value = value.interpolate(this.value, null, interpolation,
|
||||||
|
accumulation, repeatIteration);
|
||||||
|
if (this.value.hasChanged()) {
|
||||||
|
markDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
import org.apache.batik.anim.dom.AnimatableElement;
|
||||||
|
import org.apache.batik.anim.timing.TimedElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An animation class for 'set' animations.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: SetAnimation.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SetAnimation extends AbstractAnimation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The set animation value.
|
||||||
|
*/
|
||||||
|
protected AnimatableValue to;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SetAnimation.
|
||||||
|
*/
|
||||||
|
public SetAnimation(TimedElement timedElement,
|
||||||
|
AnimatableElement animatableElement,
|
||||||
|
AnimatableValue to) {
|
||||||
|
super(timedElement, animatableElement);
|
||||||
|
this.to = to;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the element is sampled at the given time.
|
||||||
|
*/
|
||||||
|
protected void sampledAt(float simpleTime, float simpleDur,
|
||||||
|
int repeatIteration) {
|
||||||
|
if (value == null) {
|
||||||
|
value = to;
|
||||||
|
markDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the element is sampled for its "last" value.
|
||||||
|
*/
|
||||||
|
protected void sampledLastValue(int repeatIteration) {
|
||||||
|
if (value == null) {
|
||||||
|
value = to;
|
||||||
|
markDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,221 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.dom.AnimatableElement;
|
||||||
|
import org.apache.batik.anim.timing.TimedElement;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
import org.apache.batik.ext.awt.geom.Cubic;
|
||||||
|
import org.apache.batik.util.SMILConstants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An animation class for 'animate' animations.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: SimpleAnimation.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SimpleAnimation extends InterpolatingAnimation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Values between which to interpolate.
|
||||||
|
*/
|
||||||
|
protected AnimatableValue[] values;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starting value of the animation.
|
||||||
|
*/
|
||||||
|
protected AnimatableValue from;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ending value of the animation.
|
||||||
|
*/
|
||||||
|
protected AnimatableValue to;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Relative offset value for the animation.
|
||||||
|
*/
|
||||||
|
protected AnimatableValue by;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SimpleAnimation.
|
||||||
|
*/
|
||||||
|
public SimpleAnimation(TimedElement timedElement,
|
||||||
|
AnimatableElement animatableElement,
|
||||||
|
int calcMode,
|
||||||
|
float[] keyTimes,
|
||||||
|
float[] keySplines,
|
||||||
|
boolean additive,
|
||||||
|
boolean cumulative,
|
||||||
|
AnimatableValue[] values,
|
||||||
|
AnimatableValue from,
|
||||||
|
AnimatableValue to,
|
||||||
|
AnimatableValue by) {
|
||||||
|
super(timedElement, animatableElement, calcMode, keyTimes, keySplines,
|
||||||
|
additive, cumulative);
|
||||||
|
this.from = from;
|
||||||
|
this.to = to;
|
||||||
|
this.by = by;
|
||||||
|
|
||||||
|
if (values == null) {
|
||||||
|
if (from != null) {
|
||||||
|
values = new AnimatableValue[2];
|
||||||
|
values[0] = from;
|
||||||
|
if (to != null) {
|
||||||
|
values[1] = to;
|
||||||
|
} else if (by != null) {
|
||||||
|
values[1] = from.interpolate(null, null, 0f, by, 1);
|
||||||
|
} else {
|
||||||
|
throw timedElement.createException
|
||||||
|
("values.to.by.missing", new Object[] { null });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (to != null) {
|
||||||
|
values = new AnimatableValue[2];
|
||||||
|
values[0] = animatableElement.getUnderlyingValue();
|
||||||
|
values[1] = to;
|
||||||
|
this.cumulative = false;
|
||||||
|
toAnimation = true;
|
||||||
|
} else if (by != null) {
|
||||||
|
this.additive = true;
|
||||||
|
values = new AnimatableValue[2];
|
||||||
|
values[0] = by.getZeroValue();
|
||||||
|
values[1] = by;
|
||||||
|
} else {
|
||||||
|
throw timedElement.createException
|
||||||
|
("values.to.by.missing", new Object[] { null });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.values = values;
|
||||||
|
|
||||||
|
if (this.keyTimes != null && calcMode != CALC_MODE_PACED) {
|
||||||
|
if (this.keyTimes.length != values.length) {
|
||||||
|
throw timedElement.createException
|
||||||
|
("attribute.malformed",
|
||||||
|
new Object[] { null,
|
||||||
|
SMILConstants.SMIL_KEY_TIMES_ATTRIBUTE });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (calcMode == CALC_MODE_LINEAR || calcMode == CALC_MODE_SPLINE
|
||||||
|
|| calcMode == CALC_MODE_PACED && !values[0].canPace()) {
|
||||||
|
int count = values.length == 1 ? 2 : values.length;
|
||||||
|
this.keyTimes = new float[count];
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
this.keyTimes[i] = (float) i / (count - 1);
|
||||||
|
}
|
||||||
|
} else if (calcMode == CALC_MODE_DISCRETE) {
|
||||||
|
int count = values.length;
|
||||||
|
this.keyTimes = new float[count];
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
this.keyTimes[i] = (float) i / count;
|
||||||
|
}
|
||||||
|
} else { // CALC_MODE_PACED
|
||||||
|
// This corrects the keyTimes to be paced, so from now on
|
||||||
|
// it can be considered the same as CALC_MODE_LINEAR.
|
||||||
|
int count = values.length;
|
||||||
|
float[] cumulativeDistances = new float[count];
|
||||||
|
cumulativeDistances[0] = 0;
|
||||||
|
for (int i = 1; i < count; i++) {
|
||||||
|
cumulativeDistances[i] = cumulativeDistances[i - 1]
|
||||||
|
+ values[i - 1].distanceTo(values[i]);
|
||||||
|
}
|
||||||
|
float totalLength = cumulativeDistances[count - 1];
|
||||||
|
this.keyTimes = new float[count];
|
||||||
|
this.keyTimes[0] = 0;
|
||||||
|
for (int i = 1; i < count - 1; i++) {
|
||||||
|
this.keyTimes[i] = cumulativeDistances[i] / totalLength;
|
||||||
|
}
|
||||||
|
this.keyTimes[count - 1] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (calcMode == CALC_MODE_SPLINE
|
||||||
|
&& keySplines.length != (this.keyTimes.length - 1) * 4) {
|
||||||
|
throw timedElement.createException
|
||||||
|
("attribute.malformed",
|
||||||
|
new Object[] { null,
|
||||||
|
SMILConstants.SMIL_KEY_SPLINES_ATTRIBUTE });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the element is sampled at the given unit time. This updates
|
||||||
|
* the {@link #value} of the animation if active.
|
||||||
|
*/
|
||||||
|
protected void sampledAtUnitTime(float unitTime, int repeatIteration) {
|
||||||
|
AnimatableValue value, accumulation, nextValue;
|
||||||
|
float interpolation = 0;
|
||||||
|
if (unitTime != 1) {
|
||||||
|
int keyTimeIndex = 0;
|
||||||
|
while (keyTimeIndex < keyTimes.length - 1
|
||||||
|
&& unitTime >= keyTimes[keyTimeIndex + 1]) {
|
||||||
|
keyTimeIndex++;
|
||||||
|
}
|
||||||
|
value = values[keyTimeIndex];
|
||||||
|
if (calcMode == CALC_MODE_LINEAR
|
||||||
|
|| calcMode == CALC_MODE_PACED
|
||||||
|
|| calcMode == CALC_MODE_SPLINE) {
|
||||||
|
nextValue = values[keyTimeIndex + 1];
|
||||||
|
interpolation = (unitTime - keyTimes[keyTimeIndex])
|
||||||
|
/ (keyTimes[keyTimeIndex + 1] - keyTimes[keyTimeIndex]);
|
||||||
|
if (calcMode == CALC_MODE_SPLINE && unitTime != 0) {
|
||||||
|
// XXX This could be done better, e.g. with
|
||||||
|
// Newton-Raphson.
|
||||||
|
Cubic c = keySplineCubics[keyTimeIndex];
|
||||||
|
float tolerance = 0.001f;
|
||||||
|
float min = 0;
|
||||||
|
float max = 1;
|
||||||
|
Point2D.Double p;
|
||||||
|
for (;;) {
|
||||||
|
float t = (min + max) / 2;
|
||||||
|
p = c.eval(t);
|
||||||
|
double x = p.getX();
|
||||||
|
if (Math.abs(x - interpolation) < tolerance) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (x < interpolation) {
|
||||||
|
min = t;
|
||||||
|
} else {
|
||||||
|
max = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
interpolation = (float) p.getY();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
nextValue = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
value = values[values.length - 1];
|
||||||
|
nextValue = null;
|
||||||
|
}
|
||||||
|
if (cumulative) {
|
||||||
|
accumulation = values[values.length - 1];
|
||||||
|
} else {
|
||||||
|
accumulation = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.value = value.interpolate(this.value, nextValue, interpolation,
|
||||||
|
accumulation, repeatIteration);
|
||||||
|
if (this.value.hasChanged()) {
|
||||||
|
markDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,251 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.dom.AnimatableElement;
|
||||||
|
import org.apache.batik.anim.timing.TimedElement;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
import org.apache.batik.anim.values.AnimatableTransformListValue;
|
||||||
|
|
||||||
|
import org.w3c.dom.svg.SVGTransform;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An animation class for 'animateTransform' animations.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: TransformAnimation.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class TransformAnimation extends SimpleAnimation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The transform type. This should take one of the constants defined
|
||||||
|
* in {@link org.w3c.dom.svg.SVGTransform}.
|
||||||
|
*/
|
||||||
|
protected short type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time values to control the pacing of the second component of the
|
||||||
|
* animation.
|
||||||
|
*/
|
||||||
|
protected float[] keyTimes2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time values to control the pacing of the third component of the
|
||||||
|
* animation.
|
||||||
|
*/
|
||||||
|
protected float[] keyTimes3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new TransformAnimation.
|
||||||
|
*/
|
||||||
|
public TransformAnimation(TimedElement timedElement,
|
||||||
|
AnimatableElement animatableElement,
|
||||||
|
int calcMode,
|
||||||
|
float[] keyTimes,
|
||||||
|
float[] keySplines,
|
||||||
|
boolean additive,
|
||||||
|
boolean cumulative,
|
||||||
|
AnimatableValue[] values,
|
||||||
|
AnimatableValue from,
|
||||||
|
AnimatableValue to,
|
||||||
|
AnimatableValue by,
|
||||||
|
short type) {
|
||||||
|
// pretend we didn't get a calcMode="paced", since we need specialised
|
||||||
|
// behaviour in sampledAtUnitTime.
|
||||||
|
super(timedElement, animatableElement,
|
||||||
|
calcMode == CALC_MODE_PACED ? CALC_MODE_LINEAR : calcMode,
|
||||||
|
calcMode == CALC_MODE_PACED ? null : keyTimes,
|
||||||
|
keySplines, additive, cumulative, values, from, to, by);
|
||||||
|
this.calcMode = calcMode;
|
||||||
|
this.type = type;
|
||||||
|
|
||||||
|
if (calcMode != CALC_MODE_PACED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine the equivalent keyTimes for the individual components
|
||||||
|
// of the transforms for CALC_MODE_PACED.
|
||||||
|
int count = this.values.length;
|
||||||
|
float[] cumulativeDistances1;
|
||||||
|
float[] cumulativeDistances2 = null;
|
||||||
|
float[] cumulativeDistances3 = null;
|
||||||
|
switch (type) {
|
||||||
|
case SVGTransform.SVG_TRANSFORM_ROTATE:
|
||||||
|
cumulativeDistances3 = new float[count];
|
||||||
|
cumulativeDistances3[0] = 0f;
|
||||||
|
// fall through
|
||||||
|
case SVGTransform.SVG_TRANSFORM_SCALE:
|
||||||
|
case SVGTransform.SVG_TRANSFORM_TRANSLATE:
|
||||||
|
cumulativeDistances2 = new float[count];
|
||||||
|
cumulativeDistances2[0] = 0f;
|
||||||
|
// fall through
|
||||||
|
default:
|
||||||
|
cumulativeDistances1 = new float[count];
|
||||||
|
cumulativeDistances1[0] = 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i < this.values.length; i++) {
|
||||||
|
switch (type) {
|
||||||
|
case SVGTransform.SVG_TRANSFORM_ROTATE:
|
||||||
|
cumulativeDistances3[i] =
|
||||||
|
cumulativeDistances3[i - 1]
|
||||||
|
+ ((AnimatableTransformListValue)
|
||||||
|
this.values[i - 1]).distanceTo3(this.values[i]);
|
||||||
|
// fall through
|
||||||
|
case SVGTransform.SVG_TRANSFORM_SCALE:
|
||||||
|
case SVGTransform.SVG_TRANSFORM_TRANSLATE:
|
||||||
|
cumulativeDistances2[i] =
|
||||||
|
cumulativeDistances2[i - 1]
|
||||||
|
+ ((AnimatableTransformListValue)
|
||||||
|
this.values[i - 1]).distanceTo2(this.values[i]);
|
||||||
|
// fall through
|
||||||
|
default:
|
||||||
|
cumulativeDistances1[i] =
|
||||||
|
cumulativeDistances1[i - 1]
|
||||||
|
+ ((AnimatableTransformListValue)
|
||||||
|
this.values[i - 1]).distanceTo1(this.values[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case SVGTransform.SVG_TRANSFORM_ROTATE:
|
||||||
|
float totalLength = cumulativeDistances3[count - 1];
|
||||||
|
keyTimes3 = new float[count];
|
||||||
|
keyTimes3[0] = 0f;
|
||||||
|
for (int i = 1; i < count - 1; i++) {
|
||||||
|
keyTimes3[i] = cumulativeDistances3[i] / totalLength;
|
||||||
|
}
|
||||||
|
keyTimes3[count - 1] = 1f;
|
||||||
|
// fall through
|
||||||
|
case SVGTransform.SVG_TRANSFORM_SCALE:
|
||||||
|
case SVGTransform.SVG_TRANSFORM_TRANSLATE:
|
||||||
|
totalLength = cumulativeDistances2[count - 1];
|
||||||
|
keyTimes2 = new float[count];
|
||||||
|
keyTimes2[0] = 0f;
|
||||||
|
for (int i = 1; i < count - 1; i++) {
|
||||||
|
keyTimes2[i] = cumulativeDistances2[i] / totalLength;
|
||||||
|
}
|
||||||
|
keyTimes2[count - 1] = 1f;
|
||||||
|
// fall through
|
||||||
|
default:
|
||||||
|
totalLength = cumulativeDistances1[count - 1];
|
||||||
|
this.keyTimes = new float[count];
|
||||||
|
this.keyTimes[0] = 0f;
|
||||||
|
for (int i = 1; i < count - 1; i++) {
|
||||||
|
this.keyTimes[i] = cumulativeDistances1[i] / totalLength;
|
||||||
|
}
|
||||||
|
this.keyTimes[count - 1] = 1f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the element is sampled at the given unit time. This updates
|
||||||
|
* the {@link #value} of the animation if active.
|
||||||
|
*/
|
||||||
|
protected void sampledAtUnitTime(float unitTime, int repeatIteration) {
|
||||||
|
// Note that skews are handled by SimpleAnimation and not here, since
|
||||||
|
// they need just the one component of interpolation.
|
||||||
|
if (calcMode != CALC_MODE_PACED
|
||||||
|
|| type == SVGTransform.SVG_TRANSFORM_SKEWX
|
||||||
|
|| type == SVGTransform.SVG_TRANSFORM_SKEWY) {
|
||||||
|
super.sampledAtUnitTime(unitTime, repeatIteration);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AnimatableTransformListValue
|
||||||
|
value1, value2, value3 = null, nextValue1, nextValue2,
|
||||||
|
nextValue3 = null, accumulation;
|
||||||
|
float interpolation1 = 0f, interpolation2 = 0f, interpolation3 = 0f;
|
||||||
|
if (unitTime != 1) {
|
||||||
|
switch (type) {
|
||||||
|
case SVGTransform.SVG_TRANSFORM_ROTATE:
|
||||||
|
int keyTimeIndex = 0;
|
||||||
|
while (keyTimeIndex < keyTimes3.length - 1
|
||||||
|
&& unitTime >= keyTimes3[keyTimeIndex + 1]) {
|
||||||
|
keyTimeIndex++;
|
||||||
|
}
|
||||||
|
value3 = (AnimatableTransformListValue)
|
||||||
|
this.values[keyTimeIndex];
|
||||||
|
nextValue3 = (AnimatableTransformListValue)
|
||||||
|
this.values[keyTimeIndex + 1];
|
||||||
|
interpolation3 = (unitTime - keyTimes3[keyTimeIndex])
|
||||||
|
/ (keyTimes3[keyTimeIndex + 1] -
|
||||||
|
keyTimes3[keyTimeIndex]);
|
||||||
|
// fall through
|
||||||
|
default:
|
||||||
|
keyTimeIndex = 0;
|
||||||
|
while (keyTimeIndex < keyTimes2.length - 1
|
||||||
|
&& unitTime >= keyTimes2[keyTimeIndex + 1]) {
|
||||||
|
keyTimeIndex++;
|
||||||
|
}
|
||||||
|
value2 = (AnimatableTransformListValue)
|
||||||
|
this.values[keyTimeIndex];
|
||||||
|
nextValue2 = (AnimatableTransformListValue)
|
||||||
|
this.values[keyTimeIndex + 1];
|
||||||
|
interpolation2 = (unitTime - keyTimes2[keyTimeIndex])
|
||||||
|
/ (keyTimes2[keyTimeIndex + 1] -
|
||||||
|
keyTimes2[keyTimeIndex]);
|
||||||
|
|
||||||
|
keyTimeIndex = 0;
|
||||||
|
while (keyTimeIndex < keyTimes.length - 1
|
||||||
|
&& unitTime >= keyTimes[keyTimeIndex + 1]) {
|
||||||
|
keyTimeIndex++;
|
||||||
|
}
|
||||||
|
value1 = (AnimatableTransformListValue)
|
||||||
|
this.values[keyTimeIndex];
|
||||||
|
nextValue1 = (AnimatableTransformListValue)
|
||||||
|
this.values[keyTimeIndex + 1];
|
||||||
|
interpolation1 = (unitTime - keyTimes[keyTimeIndex])
|
||||||
|
/ (keyTimes[keyTimeIndex + 1] -
|
||||||
|
keyTimes[keyTimeIndex]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
value1 = value2 = value3 = (AnimatableTransformListValue)
|
||||||
|
this.values[this.values.length - 1];
|
||||||
|
nextValue1 = nextValue2 = nextValue3 = null;
|
||||||
|
interpolation1 = interpolation2 = interpolation3 = 1f;
|
||||||
|
}
|
||||||
|
if (cumulative) {
|
||||||
|
accumulation = (AnimatableTransformListValue)
|
||||||
|
this.values[this.values.length - 1];
|
||||||
|
} else {
|
||||||
|
accumulation = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case SVGTransform.SVG_TRANSFORM_ROTATE:
|
||||||
|
this.value = AnimatableTransformListValue.interpolate
|
||||||
|
((AnimatableTransformListValue) this.value, value1, value2,
|
||||||
|
value3, nextValue1, nextValue2, nextValue3, interpolation1,
|
||||||
|
interpolation2, interpolation3, accumulation,
|
||||||
|
repeatIteration);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.value = AnimatableTransformListValue.interpolate
|
||||||
|
((AnimatableTransformListValue) this.value, value1, value2,
|
||||||
|
nextValue1, nextValue2, interpolation1, interpolation2,
|
||||||
|
accumulation, repeatIteration);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.value.hasChanged()) {
|
||||||
|
markDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,349 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.css.engine.CSSNavigableNode;
|
||||||
|
import org.apache.batik.dom.AbstractAttr;
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.dom.events.NodeEventTarget;
|
||||||
|
import org.apache.batik.dom.svg.LiveAttributeValue;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGConstants;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.NamedNodeMap;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.events.MutationEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides a superclass to implement an SVG element, or
|
||||||
|
* an element interoperable with the SVG elements.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: AbstractElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public abstract class AbstractElement
|
||||||
|
extends org.apache.batik.dom.AbstractElement
|
||||||
|
implements NodeEventTarget, CSSNavigableNode, SVGConstants {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The live attribute values.
|
||||||
|
*/
|
||||||
|
protected transient DoublyIndexedTable liveAttributeValues =
|
||||||
|
new DoublyIndexedTable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Element object.
|
||||||
|
*/
|
||||||
|
protected AbstractElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Element object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
protected AbstractElement(String prefix, AbstractDocument owner) {
|
||||||
|
ownerDocument = owner;
|
||||||
|
setPrefix(prefix);
|
||||||
|
initializeAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
// CSSNavigableNode ///////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the CSS parent node of this node.
|
||||||
|
*/
|
||||||
|
public Node getCSSParentNode() {
|
||||||
|
return getXblParentNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the CSS previous sibling node of this node.
|
||||||
|
*/
|
||||||
|
public Node getCSSPreviousSibling() {
|
||||||
|
return getXblPreviousSibling();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the CSS next sibling node of this node.
|
||||||
|
*/
|
||||||
|
public Node getCSSNextSibling() {
|
||||||
|
return getXblNextSibling();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the CSS first child node of this node.
|
||||||
|
*/
|
||||||
|
public Node getCSSFirstChild() {
|
||||||
|
return getXblFirstChild();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the CSS last child of this node.
|
||||||
|
*/
|
||||||
|
public Node getCSSLastChild() {
|
||||||
|
return getXblLastChild();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this node is the root of a (conceptual) hidden tree
|
||||||
|
* that selectors will not work across.
|
||||||
|
*/
|
||||||
|
public boolean isHiddenFromSelectors() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attributes /////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public void fireDOMAttrModifiedEvent(String name, Attr node, String oldv,
|
||||||
|
String newv, short change) {
|
||||||
|
super.fireDOMAttrModifiedEvent(name, node, oldv, newv, change);
|
||||||
|
// This handles the SVG 1.2 behaviour where setting the value of
|
||||||
|
// 'id' must also change 'xml:id', and vice versa.
|
||||||
|
if (((SVGOMDocument) ownerDocument).isSVG12
|
||||||
|
&& (change == MutationEvent.ADDITION
|
||||||
|
|| change == MutationEvent.MODIFICATION)) {
|
||||||
|
if (node.getNamespaceURI() == null
|
||||||
|
&& node.getNodeName().equals(SVG_ID_ATTRIBUTE)) {
|
||||||
|
Attr a =
|
||||||
|
getAttributeNodeNS(XML_NAMESPACE_URI, SVG_ID_ATTRIBUTE);
|
||||||
|
if (a == null) {
|
||||||
|
setAttributeNS(XML_NAMESPACE_URI, XML_ID_QNAME, newv);
|
||||||
|
} else if (!a.getNodeValue().equals(newv)) {
|
||||||
|
a.setNodeValue(newv);
|
||||||
|
}
|
||||||
|
} else if (node.getNodeName().equals(XML_ID_QNAME)) {
|
||||||
|
Attr a = getAttributeNodeNS(null, SVG_ID_ATTRIBUTE);
|
||||||
|
if (a == null) {
|
||||||
|
setAttributeNS(null, SVG_ID_ATTRIBUTE, newv);
|
||||||
|
} else if (!a.getNodeValue().equals(newv)) {
|
||||||
|
a.setNodeValue(newv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the live attribute value associated with given
|
||||||
|
* attribute, if any.
|
||||||
|
* @param ns The attribute's namespace.
|
||||||
|
* @param ln The attribute's local name.
|
||||||
|
*/
|
||||||
|
public LiveAttributeValue getLiveAttributeValue(String ns, String ln) {
|
||||||
|
// if (liveAttributeValues == null) {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
return (LiveAttributeValue)liveAttributeValues.get(ns, ln);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Associates a live attribute value to this element.
|
||||||
|
* @param ns The attribute's namespace.
|
||||||
|
* @param ln The attribute's local name.
|
||||||
|
* @param val The live value.
|
||||||
|
*/
|
||||||
|
public void putLiveAttributeValue(String ns, String ln,
|
||||||
|
LiveAttributeValue val) {
|
||||||
|
// if (liveAttributeValues == null) {
|
||||||
|
// liveAttributeValues = new SoftDoublyIndexedTable();
|
||||||
|
// }
|
||||||
|
liveAttributeValues.put(ns, ln, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the AttributeInitializer for this element type.
|
||||||
|
* @return null if this element has no attribute with a default value.
|
||||||
|
*/
|
||||||
|
protected AttributeInitializer getAttributeInitializer() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the attributes of this element to their default value.
|
||||||
|
*/
|
||||||
|
protected void initializeAttributes() {
|
||||||
|
AttributeInitializer ai = getAttributeInitializer();
|
||||||
|
if (ai != null) {
|
||||||
|
ai.initializeAttributes(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets an attribute to the default value.
|
||||||
|
* @return true if a default value is known for the given attribute.
|
||||||
|
*/
|
||||||
|
protected boolean resetAttribute(String ns, String prefix, String ln) {
|
||||||
|
AttributeInitializer ai = getAttributeInitializer();
|
||||||
|
if (ai == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return ai.resetAttribute(this, ns, prefix, ln);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the attribute list.
|
||||||
|
*/
|
||||||
|
protected NamedNodeMap createAttributes() {
|
||||||
|
return new ExtendedNamedNodeHashMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets an unspecified attribute.
|
||||||
|
* @param nsURI The attribute namespace URI.
|
||||||
|
* @param name The attribute's qualified name.
|
||||||
|
* @param value The attribute's default value.
|
||||||
|
*/
|
||||||
|
public void setUnspecifiedAttribute(String nsURI, String name,
|
||||||
|
String value) {
|
||||||
|
if (attributes == null) {
|
||||||
|
attributes = createAttributes();
|
||||||
|
}
|
||||||
|
((ExtendedNamedNodeHashMap)attributes).
|
||||||
|
setUnspecifiedAttribute(nsURI, name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an attribute has been added.
|
||||||
|
*/
|
||||||
|
protected void attrAdded(Attr node, String newv) {
|
||||||
|
LiveAttributeValue lav = getLiveAttributeValue(node);
|
||||||
|
if (lav != null) {
|
||||||
|
lav.attrAdded(node, newv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an attribute has been modified.
|
||||||
|
*/
|
||||||
|
protected void attrModified(Attr node, String oldv, String newv) {
|
||||||
|
LiveAttributeValue lav = getLiveAttributeValue(node);
|
||||||
|
if (lav != null) {
|
||||||
|
lav.attrModified(node, oldv, newv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an attribute has been removed.
|
||||||
|
*/
|
||||||
|
protected void attrRemoved(Attr node, String oldv) {
|
||||||
|
LiveAttributeValue lav = getLiveAttributeValue(node);
|
||||||
|
if (lav != null) {
|
||||||
|
lav.attrRemoved(node, oldv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets Returns the live attribute value associated with given
|
||||||
|
* attribute, if any.
|
||||||
|
*/
|
||||||
|
private LiveAttributeValue getLiveAttributeValue(Attr node) {
|
||||||
|
String ns = node.getNamespaceURI();
|
||||||
|
return getLiveAttributeValue(ns, (ns == null)
|
||||||
|
? node.getNodeName()
|
||||||
|
: node.getLocalName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Importation ////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exports this node to the given document.
|
||||||
|
*/
|
||||||
|
protected Node export(Node n, AbstractDocument d) {
|
||||||
|
super.export(n, d);
|
||||||
|
((AbstractElement)n).initializeAttributes();
|
||||||
|
|
||||||
|
super.export(n, d);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deeply exports this node to the given document.
|
||||||
|
*/
|
||||||
|
protected Node deepExport(Node n, AbstractDocument d) {
|
||||||
|
super.export(n, d);
|
||||||
|
((AbstractElement)n).initializeAttributes();
|
||||||
|
|
||||||
|
super.deepExport(n, d);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An implementation of the {@link NamedNodeMap}.
|
||||||
|
*/
|
||||||
|
protected class ExtendedNamedNodeHashMap extends NamedNodeHashMap {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ExtendedNamedNodeHashMap object.
|
||||||
|
*/
|
||||||
|
public ExtendedNamedNodeHashMap() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an unspecified attribute to the map.
|
||||||
|
*
|
||||||
|
* @param nsURI The attribute namespace URI.
|
||||||
|
* @param name The attribute's qualified name.
|
||||||
|
* @param value The attribute's default value.
|
||||||
|
*/
|
||||||
|
public void setUnspecifiedAttribute( String nsURI, String name,
|
||||||
|
String value ) {
|
||||||
|
Attr attr = getOwnerDocument().createAttributeNS( nsURI, name );
|
||||||
|
attr.setValue( value );
|
||||||
|
( (AbstractAttr)attr ).setSpecified( false );
|
||||||
|
setNamedItemNS( attr );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link NamedNodeMap#removeNamedItemNS(String,String)}.
|
||||||
|
*/
|
||||||
|
public Node removeNamedItemNS( String namespaceURI, String localName )
|
||||||
|
throws DOMException {
|
||||||
|
if ( isReadonly() ) {
|
||||||
|
throw createDOMException
|
||||||
|
( DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.node.map",
|
||||||
|
new Object[]{} );
|
||||||
|
}
|
||||||
|
if ( localName == null ) {
|
||||||
|
throw createDOMException( DOMException.NOT_FOUND_ERR,
|
||||||
|
"attribute.missing",
|
||||||
|
new Object[]{""} );
|
||||||
|
}
|
||||||
|
AbstractAttr n = (AbstractAttr)remove( namespaceURI, localName );
|
||||||
|
if ( n == null ) {
|
||||||
|
throw createDOMException( DOMException.NOT_FOUND_ERR,
|
||||||
|
"attribute.missing",
|
||||||
|
new Object[]{localName} );
|
||||||
|
}
|
||||||
|
n.setOwnerElement( null );
|
||||||
|
String prefix = n.getPrefix();
|
||||||
|
|
||||||
|
// Reset the attribute to its default value
|
||||||
|
if ( !resetAttribute( namespaceURI, prefix, localName ) ) {
|
||||||
|
// Mutation event
|
||||||
|
fireDOMAttrModifiedEvent( n.getNodeName(), n,
|
||||||
|
n.getNodeValue(), "",
|
||||||
|
MutationEvent.REMOVAL );
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,431 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatableLengthValue;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
import org.apache.batik.dom.svg.LiveAttributeException;
|
||||||
|
import org.apache.batik.dom.svg.LiveAttributeValue;
|
||||||
|
import org.apache.batik.parser.UnitProcessor;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedLength;
|
||||||
|
import org.w3c.dom.svg.SVGLength;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides an implementation of the {@link
|
||||||
|
* SVGAnimatedLength} interface.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: AbstractSVGAnimatedLength.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public abstract class AbstractSVGAnimatedLength
|
||||||
|
extends AbstractSVGAnimatedValue
|
||||||
|
implements SVGAnimatedLength,
|
||||||
|
LiveAttributeValue {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constant represents horizontal lengths.
|
||||||
|
*/
|
||||||
|
public static final short HORIZONTAL_LENGTH =
|
||||||
|
UnitProcessor.HORIZONTAL_LENGTH;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constant represents vertical lengths.
|
||||||
|
*/
|
||||||
|
public static final short VERTICAL_LENGTH =
|
||||||
|
UnitProcessor.VERTICAL_LENGTH;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constant represents other lengths.
|
||||||
|
*/
|
||||||
|
public static final short OTHER_LENGTH =
|
||||||
|
UnitProcessor.OTHER_LENGTH;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This length's direction.
|
||||||
|
*/
|
||||||
|
protected short direction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base value.
|
||||||
|
*/
|
||||||
|
protected BaseSVGLength baseVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current animated value.
|
||||||
|
*/
|
||||||
|
protected AnimSVGLength animVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the value is changing.
|
||||||
|
*/
|
||||||
|
protected boolean changing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the value must be non-negative.
|
||||||
|
*/
|
||||||
|
protected boolean nonNegative;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGAnimatedLength.
|
||||||
|
* @param elt The associated element.
|
||||||
|
* @param ns The attribute's namespace URI.
|
||||||
|
* @param ln The attribute's local name.
|
||||||
|
* @param dir The length's direction.
|
||||||
|
* @param nonneg Whether the length must be non-negative.
|
||||||
|
*/
|
||||||
|
public AbstractSVGAnimatedLength(AbstractElement elt,
|
||||||
|
String ns,
|
||||||
|
String ln,
|
||||||
|
short dir,
|
||||||
|
boolean nonneg) {
|
||||||
|
super(elt, ns, ln);
|
||||||
|
direction = dir;
|
||||||
|
nonNegative = nonneg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the default value to use when the associated attribute
|
||||||
|
* was not specified.
|
||||||
|
*/
|
||||||
|
protected abstract String getDefaultValue();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedLength#getBaseVal()}.
|
||||||
|
*/
|
||||||
|
public SVGLength getBaseVal() {
|
||||||
|
if (baseVal == null) {
|
||||||
|
baseVal = new BaseSVGLength(direction);
|
||||||
|
}
|
||||||
|
return baseVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedLength#getAnimVal()}.
|
||||||
|
*/
|
||||||
|
public SVGLength getAnimVal() {
|
||||||
|
if (animVal == null) {
|
||||||
|
animVal = new AnimSVGLength(direction);
|
||||||
|
}
|
||||||
|
return animVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current animated length value. If the attribute is missing
|
||||||
|
* or malformed, an exception is thrown.
|
||||||
|
*/
|
||||||
|
public float getCheckedValue() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
if (animVal == null) {
|
||||||
|
animVal = new AnimSVGLength(direction);
|
||||||
|
}
|
||||||
|
if (nonNegative && animVal.value < 0) {
|
||||||
|
throw new LiveAttributeException
|
||||||
|
(element, localName,
|
||||||
|
LiveAttributeException.ERR_ATTRIBUTE_NEGATIVE,
|
||||||
|
animVal.getValueAsString());
|
||||||
|
}
|
||||||
|
return animVal.getValue();
|
||||||
|
} else {
|
||||||
|
if (baseVal == null) {
|
||||||
|
baseVal = new BaseSVGLength(direction);
|
||||||
|
}
|
||||||
|
baseVal.revalidate();
|
||||||
|
if (baseVal.missing) {
|
||||||
|
throw new LiveAttributeException
|
||||||
|
(element, localName,
|
||||||
|
LiveAttributeException.ERR_ATTRIBUTE_MISSING, null);
|
||||||
|
} else if (baseVal.unitType ==
|
||||||
|
SVGLength.SVG_LENGTHTYPE_UNKNOWN) {
|
||||||
|
throw new LiveAttributeException
|
||||||
|
(element, localName,
|
||||||
|
LiveAttributeException.ERR_ATTRIBUTE_MALFORMED,
|
||||||
|
baseVal.getValueAsString());
|
||||||
|
}
|
||||||
|
if (nonNegative && baseVal.value < 0) {
|
||||||
|
throw new LiveAttributeException
|
||||||
|
(element, localName,
|
||||||
|
LiveAttributeException.ERR_ATTRIBUTE_NEGATIVE,
|
||||||
|
baseVal.getValueAsString());
|
||||||
|
}
|
||||||
|
return baseVal.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the animated value with the given {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
protected void updateAnimatedValue(AnimatableValue val) {
|
||||||
|
if (val == null) {
|
||||||
|
hasAnimVal = false;
|
||||||
|
} else {
|
||||||
|
hasAnimVal = true;
|
||||||
|
AnimatableLengthValue animLength = (AnimatableLengthValue) val;
|
||||||
|
if (animVal == null) {
|
||||||
|
animVal = new AnimSVGLength(direction);
|
||||||
|
}
|
||||||
|
animVal.setAnimatedValue(animLength.getLengthType(),
|
||||||
|
animLength.getLengthValue());
|
||||||
|
}
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the base value of the attribute as an {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
public AnimatableValue getUnderlyingValue(AnimationTarget target) {
|
||||||
|
SVGLength base = getBaseVal();
|
||||||
|
return new AnimatableLengthValue
|
||||||
|
(target, base.getUnitType(), base.getValueInSpecifiedUnits(),
|
||||||
|
target.getPercentageInterpretation
|
||||||
|
(getNamespaceURI(), getLocalName(), false));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been added.
|
||||||
|
*/
|
||||||
|
public void attrAdded(Attr node, String newv) {
|
||||||
|
attrChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been modified.
|
||||||
|
*/
|
||||||
|
public void attrModified(Attr node, String oldv, String newv) {
|
||||||
|
attrChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been removed.
|
||||||
|
*/
|
||||||
|
public void attrRemoved(Attr node, String oldv) {
|
||||||
|
attrChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the attribute has changed in some way.
|
||||||
|
*/
|
||||||
|
protected void attrChanged() {
|
||||||
|
if (!changing && baseVal != null) {
|
||||||
|
baseVal.invalidate();
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents the SVGLength returned by {@link AbstractSVGAnimatedLength#getBaseVal() }.
|
||||||
|
*/
|
||||||
|
protected class BaseSVGLength extends AbstractSVGLength {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this length is valid.
|
||||||
|
*/
|
||||||
|
protected boolean valid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the attribute is missing.
|
||||||
|
*/
|
||||||
|
protected boolean missing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new BaseSVGLength.
|
||||||
|
* @param direction is one of HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTH
|
||||||
|
*/
|
||||||
|
public BaseSVGLength(short direction) {
|
||||||
|
super(direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalidates this length.
|
||||||
|
*/
|
||||||
|
public void invalidate() {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the value of the associated attribute.
|
||||||
|
*/
|
||||||
|
protected void reset() {
|
||||||
|
try {
|
||||||
|
changing = true;
|
||||||
|
valid = true;
|
||||||
|
String value = getValueAsString();
|
||||||
|
element.setAttributeNS(namespaceURI, localName, value);
|
||||||
|
} finally {
|
||||||
|
changing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the length, if needed.
|
||||||
|
*/
|
||||||
|
protected void revalidate() {
|
||||||
|
if (valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
missing = false;
|
||||||
|
valid = true;
|
||||||
|
|
||||||
|
Attr attr = element.getAttributeNodeNS(namespaceURI, localName);
|
||||||
|
String s;
|
||||||
|
if (attr == null) {
|
||||||
|
s = getDefaultValue();
|
||||||
|
if (s == null) {
|
||||||
|
missing = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
s = attr.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
parse(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the element this length is associated with.
|
||||||
|
*/
|
||||||
|
protected SVGOMElement getAssociatedElement() {
|
||||||
|
return (SVGOMElement)element;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents the SVGLength returned by {@link AbstractSVGAnimatedLength#getAnimVal()}.
|
||||||
|
*/
|
||||||
|
protected class AnimSVGLength extends AbstractSVGLength {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new AnimSVGLength.
|
||||||
|
* @param direction is one of HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTH
|
||||||
|
*/
|
||||||
|
public AnimSVGLength(short direction) {
|
||||||
|
super(direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLength#getUnitType()}.
|
||||||
|
*/
|
||||||
|
public short getUnitType() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getUnitType();
|
||||||
|
}
|
||||||
|
return getBaseVal().getUnitType();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLength#getValue()}.
|
||||||
|
*/
|
||||||
|
public float getValue() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getValue();
|
||||||
|
}
|
||||||
|
return getBaseVal().getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLength#getValueInSpecifiedUnits()}.
|
||||||
|
*/
|
||||||
|
public float getValueInSpecifiedUnits() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getValueInSpecifiedUnits();
|
||||||
|
}
|
||||||
|
return getBaseVal().getValueInSpecifiedUnits();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLength#getValueAsString()}.
|
||||||
|
*/
|
||||||
|
public String getValueAsString() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getValueAsString();
|
||||||
|
}
|
||||||
|
return getBaseVal().getValueAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLength#setValue(float)}.
|
||||||
|
*/
|
||||||
|
public void setValue(float value) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.length",
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGLength#setValueInSpecifiedUnits(float)}.
|
||||||
|
*/
|
||||||
|
public void setValueInSpecifiedUnits(float value) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.length",
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLength#setValueAsString(String)}.
|
||||||
|
*/
|
||||||
|
public void setValueAsString(String value) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.length",
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGLength#newValueSpecifiedUnits(short,float)}.
|
||||||
|
*/
|
||||||
|
public void newValueSpecifiedUnits(short unit, float value) {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.length",
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGLength#convertToSpecifiedUnits(short)}.
|
||||||
|
*/
|
||||||
|
public void convertToSpecifiedUnits(short unit) {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.length",
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the element this length is associated with.
|
||||||
|
*/
|
||||||
|
protected SVGOMElement getAssociatedElement() {
|
||||||
|
return (SVGOMElement) element;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the animated value.
|
||||||
|
* @param type one of the values defines in org.w3c.dom.svg.SVGLength
|
||||||
|
* @param val the length
|
||||||
|
*/
|
||||||
|
protected void setAnimatedValue(int type, float val) {
|
||||||
|
super.newValueSpecifiedUnits((short) type, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,133 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An abstract base class for the <code>SVGAnimated*</code> classes, that
|
||||||
|
* implements an {@link AnimatedAttributeListener} list.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: AbstractSVGAnimatedValue.java 1804130 2017-08-04 14:41:11Z ssteiner $
|
||||||
|
*/
|
||||||
|
public abstract class AbstractSVGAnimatedValue
|
||||||
|
implements AnimatedLiveAttributeValue {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The associated element.
|
||||||
|
*/
|
||||||
|
protected AbstractElement element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The namespace URI of the attribute.
|
||||||
|
*/
|
||||||
|
protected String namespaceURI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The local name of the attribute.
|
||||||
|
*/
|
||||||
|
protected String localName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether there is a current animated value.
|
||||||
|
*/
|
||||||
|
protected boolean hasAnimVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener list.
|
||||||
|
*/
|
||||||
|
protected LinkedList listeners = new LinkedList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new AbstractSVGAnimatedValue.
|
||||||
|
*/
|
||||||
|
public AbstractSVGAnimatedValue(AbstractElement elt, String ns, String ln) {
|
||||||
|
element = elt;
|
||||||
|
namespaceURI = ns;
|
||||||
|
localName = ln;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the namespace URI of the attribute.
|
||||||
|
*/
|
||||||
|
public String getNamespaceURI() {
|
||||||
|
return namespaceURI;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the local name of the attribute.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return localName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this animated value has a specified value.
|
||||||
|
* @return true if the DOM attribute is specified or if the attribute has
|
||||||
|
* an animated value, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean isSpecified() {
|
||||||
|
return hasAnimVal || element.hasAttributeNS(namespaceURI, localName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the animated value with the given {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
protected abstract void updateAnimatedValue(AnimatableValue val);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a listener for changes to the animated value.
|
||||||
|
*/
|
||||||
|
public void addAnimatedAttributeListener(AnimatedAttributeListener aal) {
|
||||||
|
if (!listeners.contains(aal)) {
|
||||||
|
listeners.add(aal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a listener for changes to the animated value.
|
||||||
|
*/
|
||||||
|
public void removeAnimatedAttributeListener(AnimatedAttributeListener aal) {
|
||||||
|
listeners.remove(aal);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fires the listeners for the base value.
|
||||||
|
*/
|
||||||
|
protected void fireBaseAttributeListeners() {
|
||||||
|
if (element instanceof SVGOMElement) {
|
||||||
|
((SVGOMElement) element).fireBaseAttributeListeners(namespaceURI,
|
||||||
|
localName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fires the listeners for the animated value.
|
||||||
|
*/
|
||||||
|
protected void fireAnimatedAttributeListeners() {
|
||||||
|
for (Object listener1 : listeners) {
|
||||||
|
AnimatedAttributeListener listener =
|
||||||
|
(AnimatedAttributeListener) listener1;
|
||||||
|
listener.animatedAttributeChanged(element, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,297 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.parser.LengthParser;
|
||||||
|
import org.apache.batik.parser.ParseException;
|
||||||
|
import org.apache.batik.parser.UnitProcessor;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.svg.SVGLength;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default implementation for SVGLength.
|
||||||
|
*
|
||||||
|
* This implementation provides the basic
|
||||||
|
* functionalities of SVGLength. To have
|
||||||
|
* a complete implementation, an element is
|
||||||
|
* required to resolve the units.
|
||||||
|
*
|
||||||
|
* According to the usage of this AbstractSVGLength,
|
||||||
|
* the <code>reset()</code> method is after
|
||||||
|
* changes being made to the unitType or the value
|
||||||
|
* of this length. Before any values are return
|
||||||
|
* to the user of the AbstractSVGLength, the
|
||||||
|
* <code>revalidate()</code> method is being called
|
||||||
|
* to insure the validity of the value and unit type
|
||||||
|
* held by this object.
|
||||||
|
*
|
||||||
|
* @author nicolas.socheleau@bitflash.com
|
||||||
|
* @version $Id: AbstractSVGLength.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public abstract class AbstractSVGLength
|
||||||
|
implements SVGLength {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constant represents horizontal lengths.
|
||||||
|
*/
|
||||||
|
public static final short HORIZONTAL_LENGTH =
|
||||||
|
UnitProcessor.HORIZONTAL_LENGTH;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constant represents vertical lengths.
|
||||||
|
*/
|
||||||
|
public static final short VERTICAL_LENGTH =
|
||||||
|
UnitProcessor.VERTICAL_LENGTH;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constant represents other lengths.
|
||||||
|
*/
|
||||||
|
public static final short OTHER_LENGTH =
|
||||||
|
UnitProcessor.OTHER_LENGTH;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of this length.
|
||||||
|
*/
|
||||||
|
protected short unitType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value of this length.
|
||||||
|
*/
|
||||||
|
protected float value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This length's direction.
|
||||||
|
*/
|
||||||
|
protected short direction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The context used to resolve the units.
|
||||||
|
*/
|
||||||
|
protected UnitProcessor.Context context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The unit string representations.
|
||||||
|
*/
|
||||||
|
protected static final String[] UNITS = {
|
||||||
|
"", "", "%", "em", "ex", "px", "cm", "mm", "in", "pt", "pc"
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the SVGElement associated to this length.
|
||||||
|
*/
|
||||||
|
protected abstract SVGOMElement getAssociatedElement();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new AbstractSVGLength.
|
||||||
|
*/
|
||||||
|
public AbstractSVGLength(short direction) {
|
||||||
|
context = new DefaultContext();
|
||||||
|
this.direction = direction;
|
||||||
|
this.value = 0.0f;
|
||||||
|
this.unitType = SVGLength.SVG_LENGTHTYPE_NUMBER;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLength#getUnitType()}.
|
||||||
|
*/
|
||||||
|
public short getUnitType() {
|
||||||
|
revalidate();
|
||||||
|
return unitType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLength#getValue()}.
|
||||||
|
*/
|
||||||
|
public float getValue() {
|
||||||
|
revalidate();
|
||||||
|
try {
|
||||||
|
return UnitProcessor.svgToUserSpace(value, unitType,
|
||||||
|
direction, context);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
// XXX Should we throw an exception here when the length
|
||||||
|
// type is unknown?
|
||||||
|
return 0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLength#setValue(float)}.
|
||||||
|
*/
|
||||||
|
public void setValue(float value) throws DOMException {
|
||||||
|
this.value = UnitProcessor.userSpaceToSVG(value, unitType,
|
||||||
|
direction, context);
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLength#getValueInSpecifiedUnits()}.
|
||||||
|
*/
|
||||||
|
public float getValueInSpecifiedUnits() {
|
||||||
|
revalidate();
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGLength#setValueInSpecifiedUnits(float)}.
|
||||||
|
*/
|
||||||
|
public void setValueInSpecifiedUnits(float value) throws DOMException {
|
||||||
|
revalidate();
|
||||||
|
this.value = value;
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLength#getValueAsString()}.
|
||||||
|
*/
|
||||||
|
public String getValueAsString() {
|
||||||
|
revalidate();
|
||||||
|
if (unitType == SVGLength.SVG_LENGTHTYPE_UNKNOWN) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return Float.toString(value) + UNITS[unitType];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLength#setValueAsString(String)}.
|
||||||
|
*/
|
||||||
|
public void setValueAsString(String value) throws DOMException {
|
||||||
|
parse(value);
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGLength#newValueSpecifiedUnits(short,float)}.
|
||||||
|
*/
|
||||||
|
public void newValueSpecifiedUnits(short unit, float value) {
|
||||||
|
unitType = unit;
|
||||||
|
this.value = value;
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGLength#convertToSpecifiedUnits(short)}.
|
||||||
|
*/
|
||||||
|
public void convertToSpecifiedUnits(short unit) {
|
||||||
|
float v = getValue();
|
||||||
|
unitType = unit;
|
||||||
|
setValue(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback method after changes
|
||||||
|
* made to this length.
|
||||||
|
*
|
||||||
|
* The default implementation does nothing.
|
||||||
|
*/
|
||||||
|
protected void reset() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback method before any value
|
||||||
|
* is return from this length.
|
||||||
|
*
|
||||||
|
* The default implementation does nothing.
|
||||||
|
*/
|
||||||
|
protected void revalidate() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a String value as a SVGLength.
|
||||||
|
*
|
||||||
|
* Initialize this length with the result
|
||||||
|
* of the parsing of this value.
|
||||||
|
* @param s String representation of a SVGlength.
|
||||||
|
*/
|
||||||
|
protected void parse(String s) {
|
||||||
|
try {
|
||||||
|
LengthParser lengthParser = new LengthParser();
|
||||||
|
UnitProcessor.UnitResolver ur =
|
||||||
|
new UnitProcessor.UnitResolver();
|
||||||
|
lengthParser.setLengthHandler(ur);
|
||||||
|
lengthParser.parse(s);
|
||||||
|
unitType = ur.unit;
|
||||||
|
value = ur.value;
|
||||||
|
} catch (ParseException e) {
|
||||||
|
unitType = SVG_LENGTHTYPE_UNKNOWN;
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To resolve the units.
|
||||||
|
*/
|
||||||
|
protected class DefaultContext implements UnitProcessor.Context {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the element.
|
||||||
|
*/
|
||||||
|
public Element getElement() {
|
||||||
|
return getAssociatedElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the size of a px CSS unit in millimeters.
|
||||||
|
*/
|
||||||
|
public float getPixelUnitToMillimeter() {
|
||||||
|
return getAssociatedElement().getSVGContext()
|
||||||
|
.getPixelUnitToMillimeter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the size of a px CSS unit in millimeters.
|
||||||
|
* This will be removed after next release.
|
||||||
|
* @see #getPixelUnitToMillimeter()
|
||||||
|
*/
|
||||||
|
public float getPixelToMM() {
|
||||||
|
return getPixelUnitToMillimeter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the font-size value.
|
||||||
|
*/
|
||||||
|
public float getFontSize() {
|
||||||
|
return getAssociatedElement().getSVGContext().getFontSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the x-height value.
|
||||||
|
*/
|
||||||
|
public float getXHeight() {
|
||||||
|
return 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the viewport width used to compute units.
|
||||||
|
*/
|
||||||
|
public float getViewportWidth() {
|
||||||
|
return getAssociatedElement().getSVGContext().getViewportWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the viewport height used to compute units.
|
||||||
|
*/
|
||||||
|
public float getViewportHeight() {
|
||||||
|
return getAssociatedElement().getSVGContext().getViewportHeight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,346 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.svg.AbstractSVGList;
|
||||||
|
import org.apache.batik.dom.svg.ListHandler;
|
||||||
|
import org.apache.batik.dom.svg.SVGItem;
|
||||||
|
import org.apache.batik.parser.LengthListHandler;
|
||||||
|
import org.apache.batik.parser.LengthListParser;
|
||||||
|
import org.apache.batik.parser.ParseException;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.svg.SVGException;
|
||||||
|
import org.w3c.dom.svg.SVGLength;
|
||||||
|
import org.w3c.dom.svg.SVGLengthList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is the implementation of
|
||||||
|
* <code>SVGLengthList</code>.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:nicolas.socheleau@bitflash.com">Nicolas Socheleau</a>
|
||||||
|
* @version $Id: AbstractSVGLengthList.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public abstract class AbstractSVGLengthList
|
||||||
|
extends AbstractSVGList
|
||||||
|
implements SVGLengthList {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This length list's direction.
|
||||||
|
*/
|
||||||
|
protected short direction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Separator for a length list.
|
||||||
|
*/
|
||||||
|
public static final String SVG_LENGTH_LIST_SEPARATOR
|
||||||
|
= " ";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the separator between values in the list.
|
||||||
|
*/
|
||||||
|
protected String getItemSeparator() {
|
||||||
|
return SVG_LENGTH_LIST_SEPARATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an SVGException when the checkItemType fails.
|
||||||
|
* @return SVGException
|
||||||
|
*/
|
||||||
|
protected abstract SVGException createSVGException(short type,
|
||||||
|
String key,
|
||||||
|
Object[] args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the element owning this SVGLengthList.
|
||||||
|
*/
|
||||||
|
protected abstract Element getElement();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGLengthList.
|
||||||
|
*/
|
||||||
|
protected AbstractSVGLengthList(short direction) {
|
||||||
|
this.direction = direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLengthList#initialize(SVGLength)}.
|
||||||
|
*/
|
||||||
|
public SVGLength initialize(SVGLength newItem)
|
||||||
|
throws DOMException, SVGException {
|
||||||
|
return (SVGLength) initializeImpl(newItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLengthList#getItem(int)}.
|
||||||
|
*/
|
||||||
|
public SVGLength getItem(int index) throws DOMException {
|
||||||
|
return (SVGLength) getItemImpl(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGLengthList#insertItemBefore(SVGLength,int)}.
|
||||||
|
*/
|
||||||
|
public SVGLength insertItemBefore(SVGLength newItem, int index)
|
||||||
|
throws DOMException, SVGException {
|
||||||
|
return (SVGLength) insertItemBeforeImpl(newItem, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGLengthList#replaceItem(SVGLength,int)}.
|
||||||
|
*/
|
||||||
|
public SVGLength replaceItem(SVGLength newItem, int index)
|
||||||
|
throws DOMException, SVGException {
|
||||||
|
return (SVGLength) replaceItemImpl(newItem,index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLengthList#removeItem(int)}.
|
||||||
|
*/
|
||||||
|
public SVGLength removeItem(int index) throws DOMException {
|
||||||
|
return (SVGLength) removeItemImpl(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLengthList#appendItem(SVGLength)}.
|
||||||
|
*/
|
||||||
|
public SVGLength appendItem(SVGLength newItem)
|
||||||
|
throws DOMException, SVGException {
|
||||||
|
return (SVGLength) appendItemImpl(newItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link SVGItem} object from the given {@link SVGLength}.
|
||||||
|
*/
|
||||||
|
protected SVGItem createSVGItem(Object newItem) {
|
||||||
|
SVGLength l = (SVGLength) newItem;
|
||||||
|
return new SVGLengthItem(l.getUnitType(), l.getValueInSpecifiedUnits(),
|
||||||
|
direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the attribute associated with this SVGLengthList.
|
||||||
|
*
|
||||||
|
* @param value attribute value
|
||||||
|
* @param handler length list handler
|
||||||
|
*/
|
||||||
|
protected void doParse(String value, ListHandler handler)
|
||||||
|
throws ParseException{
|
||||||
|
|
||||||
|
LengthListParser lengthListParser = new LengthListParser();
|
||||||
|
|
||||||
|
LengthListBuilder builder = new LengthListBuilder(handler);
|
||||||
|
|
||||||
|
lengthListParser.setLengthListHandler(builder);
|
||||||
|
lengthListParser.parse(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the given item is an {@link SVGLengthList}.
|
||||||
|
*/
|
||||||
|
protected void checkItemType(Object newItem) throws SVGException {
|
||||||
|
if (!(newItem instanceof SVGLength)) {
|
||||||
|
createSVGException(SVGException.SVG_WRONG_TYPE_ERR,
|
||||||
|
"expected.length", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An {@link SVGLength} in the list.
|
||||||
|
*/
|
||||||
|
protected class SVGLengthItem extends AbstractSVGLength implements SVGItem {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGLengthItem.
|
||||||
|
*/
|
||||||
|
public SVGLengthItem(short type, float value, short direction) {
|
||||||
|
super(direction);
|
||||||
|
this.unitType = type;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the element this length is associated with.
|
||||||
|
*/
|
||||||
|
protected SVGOMElement getAssociatedElement() {
|
||||||
|
return (SVGOMElement) AbstractSVGLengthList.this.getElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List the item belongs to.
|
||||||
|
*/
|
||||||
|
protected AbstractSVGList parentList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assigns a parent list to this item.
|
||||||
|
* @param list The list the item belongs.
|
||||||
|
*/
|
||||||
|
public void setParent(AbstractSVGList list) {
|
||||||
|
parentList = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the parent list of this item.
|
||||||
|
*/
|
||||||
|
public AbstractSVGList getParent() {
|
||||||
|
return parentList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies the parent list that this item has changed.
|
||||||
|
*/
|
||||||
|
protected void reset() {
|
||||||
|
if (parentList != null) {
|
||||||
|
parentList.itemChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper class to interface the {@link LengthListParser} and the
|
||||||
|
* {@link ListHandler}.
|
||||||
|
*/
|
||||||
|
protected class LengthListBuilder implements LengthListHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ListHandler to pass newly created {@link SVGLengthItem} objects
|
||||||
|
* to.
|
||||||
|
*/
|
||||||
|
protected ListHandler listHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The the length value just parsed.
|
||||||
|
*/
|
||||||
|
protected float currentValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The length unit just parsed.
|
||||||
|
*/
|
||||||
|
protected short currentType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new LengthListBuilder.
|
||||||
|
*/
|
||||||
|
public LengthListBuilder(ListHandler listHandler) {
|
||||||
|
this.listHandler = listHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements {@link LengthListHandler#startLengthList()}.
|
||||||
|
*/
|
||||||
|
public void startLengthList() throws ParseException {
|
||||||
|
listHandler.startList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements {@link LengthListHandler#startLength()}.
|
||||||
|
*/
|
||||||
|
public void startLength() throws ParseException {
|
||||||
|
currentType = SVGLength.SVG_LENGTHTYPE_NUMBER;
|
||||||
|
currentValue = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements {@link LengthListHandler#lengthValue(float)}.
|
||||||
|
*/
|
||||||
|
public void lengthValue(float v) throws ParseException {
|
||||||
|
currentValue = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements {@link LengthListHandler#em()}.
|
||||||
|
*/
|
||||||
|
public void em() throws ParseException {
|
||||||
|
currentType = SVGLength.SVG_LENGTHTYPE_EMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements {@link LengthListHandler#ex()}.
|
||||||
|
*/
|
||||||
|
public void ex() throws ParseException {
|
||||||
|
currentType = SVGLength.SVG_LENGTHTYPE_EXS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements {@link LengthListHandler#in()}.
|
||||||
|
*/
|
||||||
|
public void in() throws ParseException {
|
||||||
|
currentType = SVGLength.SVG_LENGTHTYPE_IN;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements {@link LengthListHandler#cm()}.
|
||||||
|
*/
|
||||||
|
public void cm() throws ParseException {
|
||||||
|
currentType = SVGLength.SVG_LENGTHTYPE_CM;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements {@link LengthListHandler#mm()}.
|
||||||
|
*/
|
||||||
|
public void mm() throws ParseException {
|
||||||
|
currentType = SVGLength.SVG_LENGTHTYPE_MM;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements {@link LengthListHandler#pc()}.
|
||||||
|
*/
|
||||||
|
public void pc() throws ParseException {
|
||||||
|
currentType = SVGLength.SVG_LENGTHTYPE_PC;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements {@link LengthListHandler#pt()}.
|
||||||
|
*/
|
||||||
|
public void pt() throws ParseException {
|
||||||
|
currentType = SVGLength.SVG_LENGTHTYPE_EMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements {@link LengthListHandler#px()}.
|
||||||
|
*/
|
||||||
|
public void px() throws ParseException {
|
||||||
|
currentType = SVGLength.SVG_LENGTHTYPE_PX;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements {@link LengthListHandler#percentage()}.
|
||||||
|
*/
|
||||||
|
public void percentage() throws ParseException {
|
||||||
|
currentType = SVGLength.SVG_LENGTHTYPE_PERCENTAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements {@link LengthListHandler#endLength()}.
|
||||||
|
*/
|
||||||
|
public void endLength() throws ParseException {
|
||||||
|
listHandler.item
|
||||||
|
(new SVGLengthItem(currentType,currentValue,direction));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements {@link LengthListHandler#endLengthList()}.
|
||||||
|
*/
|
||||||
|
public void endLengthList() throws ParseException {
|
||||||
|
listHandler.endList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An interface for animatable elements to expose their underlying values
|
||||||
|
* to the compositing functions in
|
||||||
|
* {@link org.apache.batik.anim.AbstractAnimation}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: AnimatableElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public interface AnimatableElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the underlying value of the animated attribute. Used for
|
||||||
|
* composition of additive animations.
|
||||||
|
*/
|
||||||
|
AnimatableValue getUnderlyingValue();
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An interface to listen for changes on any animatable XML attribute in
|
||||||
|
* an {@link SVGOMDocument}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: AnimatedAttributeListener.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public interface AnimatedAttributeListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to notify an object of a change to the animated value of
|
||||||
|
* an animatable XML attribute.
|
||||||
|
* @param e the owner element of the changed animatable attribute
|
||||||
|
* @param alav the AnimatedLiveAttributeValue that changed
|
||||||
|
*/
|
||||||
|
void animatedAttributeChanged(Element e, AnimatedLiveAttributeValue alav);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to notify an object of a change to the value of an 'other'
|
||||||
|
* animation.
|
||||||
|
* @param e the element being animated
|
||||||
|
* @param type the type of animation whose value changed
|
||||||
|
*/
|
||||||
|
void otherAnimationChanged(Element e, String type);
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
import org.apache.batik.dom.svg.LiveAttributeValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An interface for {@link LiveAttributeValue}s that have an animated value
|
||||||
|
* component.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: AnimatedLiveAttributeValue.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public interface AnimatedLiveAttributeValue extends LiveAttributeValue {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the namespace URI of this animated live attribute.
|
||||||
|
*/
|
||||||
|
String getNamespaceURI();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the local name of this animated live attribute.
|
||||||
|
*/
|
||||||
|
String getLocalName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the base value of the attribute as an {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
AnimatableValue getUnderlyingValue(AnimationTarget target);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a listener for changes to the animated value.
|
||||||
|
*/
|
||||||
|
void addAnimatedAttributeListener(AnimatedAttributeListener aal);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a listener for changes to the animated value.
|
||||||
|
*/
|
||||||
|
void removeAnimatedAttributeListener(AnimatedAttributeListener aal);
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.svg.SVGLength;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An interface for targets of animation to provide context information.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: AnimationTarget.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public interface AnimationTarget {
|
||||||
|
|
||||||
|
// Constants for percentage interpretation.
|
||||||
|
short PERCENTAGE_FONT_SIZE = 0;
|
||||||
|
short PERCENTAGE_VIEWPORT_WIDTH = 1;
|
||||||
|
short PERCENTAGE_VIEWPORT_HEIGHT = 2;
|
||||||
|
short PERCENTAGE_VIEWPORT_SIZE = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the element.
|
||||||
|
*/
|
||||||
|
Element getElement();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a property value in this target.
|
||||||
|
*/
|
||||||
|
void updatePropertyValue(String pn, AnimatableValue val);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates an attribute value in this target.
|
||||||
|
*/
|
||||||
|
void updateAttributeValue(String ns, String ln, AnimatableValue val);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a 'other' animation value in this target.
|
||||||
|
*/
|
||||||
|
void updateOtherValue(String type, AnimatableValue val);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the underlying value of an animatable XML attribute.
|
||||||
|
*/
|
||||||
|
AnimatableValue getUnderlyingValue(String ns, String ln);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets how percentage values are interpreted by the given attribute
|
||||||
|
* or property.
|
||||||
|
*/
|
||||||
|
short getPercentageInterpretation(String ns, String an, boolean isCSS);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether color interpolations should be done in linear RGB
|
||||||
|
* color space rather than sRGB.
|
||||||
|
*/
|
||||||
|
boolean useLinearRGBColorInterpolation();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the given SVG length into user units.
|
||||||
|
* @param v the SVG length value
|
||||||
|
* @param type the SVG length units (one of the
|
||||||
|
* {@link SVGLength}.SVG_LENGTH_* constants)
|
||||||
|
* @param pcInterp how to interpretet percentage values (one of the
|
||||||
|
* {@link AnimationTarget}.PERCENTAGE_* constants)
|
||||||
|
* @return the SVG value in user units
|
||||||
|
*/
|
||||||
|
float svgToUserSpace(float v, short type, short pcInterp);
|
||||||
|
|
||||||
|
// Listeners
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a listener for changes to the given attribute value.
|
||||||
|
*/
|
||||||
|
void addTargetListener(String ns, String an, boolean isCSS,
|
||||||
|
AnimationTargetListener l);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a listener for changes to the given attribute value.
|
||||||
|
*/
|
||||||
|
void removeTargetListener(String ns, String an, boolean isCSS,
|
||||||
|
AnimationTargetListener l);
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A listener class for animation targets. This will be for the animation
|
||||||
|
* engine to be notified of updates to dependencies such as font size
|
||||||
|
* changes and viewport sizes.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: AnimationTargetListener.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public interface AnimationTargetListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked to indicate that base value of the specified attribute
|
||||||
|
* or property has changed.
|
||||||
|
*/
|
||||||
|
void baseValueChanged(AnimationTarget t, String ns, String ln,
|
||||||
|
boolean isCSS);
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is used by elements to initialize and reset their attributes.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: AttributeInitializer.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class AttributeInitializer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of namespaces, prefixes and names.
|
||||||
|
*/
|
||||||
|
protected String[] keys;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The length of keys.
|
||||||
|
*/
|
||||||
|
protected int length;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attribute values table.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable values = new DoublyIndexedTable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new AttributeInitializer.
|
||||||
|
*/
|
||||||
|
public AttributeInitializer(int capacity) {
|
||||||
|
keys = new String[capacity * 3];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a default attribute value to the initializer.
|
||||||
|
* @param ns The attribute namespace URI.
|
||||||
|
* @param prefix The attribute's name prefix, or null.
|
||||||
|
* @param ln The attribute's local name.
|
||||||
|
* @param val The attribute's default value.
|
||||||
|
*/
|
||||||
|
public void addAttribute(String ns, String prefix, String ln, String val) {
|
||||||
|
int len = keys.length;
|
||||||
|
if (length == len) {
|
||||||
|
String[] t = new String[len * 2];
|
||||||
|
System.arraycopy( keys, 0, t, 0, len );
|
||||||
|
keys = t;
|
||||||
|
}
|
||||||
|
keys[length++] = ns;
|
||||||
|
keys[length++] = prefix;
|
||||||
|
keys[length++] = ln;
|
||||||
|
values.put(ns, ln, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the attributes of the given element.
|
||||||
|
*/
|
||||||
|
public void initializeAttributes(AbstractElement elt) {
|
||||||
|
for (int i = length - 1; i >= 2; i -= 3) {
|
||||||
|
resetAttribute(elt, keys[i - 2], keys[i - 1], keys[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets an attribute of the given element to its default value.
|
||||||
|
* @param elt The element to modify.
|
||||||
|
* @param ns The attribute namespace URI.
|
||||||
|
* @param prefix The attribute's name prefix.
|
||||||
|
* @param ln The attribute's local name.
|
||||||
|
* @return true if a default value is known for the given attribute and
|
||||||
|
* if it was resetted.
|
||||||
|
*/
|
||||||
|
public boolean resetAttribute(AbstractElement elt,
|
||||||
|
String ns, String prefix, String ln) {
|
||||||
|
String val = (String)values.get(ns, ln);
|
||||||
|
if (val == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (prefix != null) {
|
||||||
|
ln = prefix + ':' + ln;
|
||||||
|
}
|
||||||
|
elt.setUnspecifiedAttribute(ns, ln, val);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,132 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements foreign namespace elements that can be
|
||||||
|
* bound with XBL.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: BindableElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class BindableElement extends SVGGraphicsElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The namespace URI of the custom element.
|
||||||
|
*/
|
||||||
|
protected String namespaceURI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The local name of the custom element.
|
||||||
|
*/
|
||||||
|
protected String localName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The shadow tree.
|
||||||
|
*/
|
||||||
|
protected XBLOMShadowTreeElement xblShadowTree;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new BindableElement object.
|
||||||
|
*/
|
||||||
|
protected BindableElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new BindableElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
* @param ns The namespace of the custom element.
|
||||||
|
* @param ln The local name of the custom element.
|
||||||
|
*/
|
||||||
|
public BindableElement(String prefix,
|
||||||
|
AbstractDocument owner,
|
||||||
|
String ns,
|
||||||
|
String ln) {
|
||||||
|
super(prefix, owner);
|
||||||
|
namespaceURI = ns;
|
||||||
|
localName = ln;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getNamespaceURI()}.
|
||||||
|
*/
|
||||||
|
public String getNamespaceURI() {
|
||||||
|
return namespaceURI;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return localName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the AttributeInitializer for this element type.
|
||||||
|
* @return null if this element has no attribute with a default value.
|
||||||
|
*/
|
||||||
|
protected AttributeInitializer getAttributeInitializer() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new BindableElement(null, null, namespaceURI, localName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the shadow tree for this bindable element.
|
||||||
|
*/
|
||||||
|
public void setShadowTree(XBLOMShadowTreeElement s) {
|
||||||
|
xblShadowTree = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the shadow tree for this bindable element.
|
||||||
|
*/
|
||||||
|
public XBLOMShadowTreeElement getShadowTree() {
|
||||||
|
return xblShadowTree;
|
||||||
|
}
|
||||||
|
|
||||||
|
// CSSNavigableNode ///////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the shadow tree.
|
||||||
|
*/
|
||||||
|
public Node getCSSFirstChild() {
|
||||||
|
if (xblShadowTree != null) {
|
||||||
|
return xblShadowTree.getFirstChild();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the shadow tree.
|
||||||
|
*/
|
||||||
|
public Node getCSSLastChild() {
|
||||||
|
return getCSSFirstChild();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,401 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.util.MissingResourceException;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.dom.svg.SVGDocumentFactory;
|
||||||
|
import org.apache.batik.dom.util.SAXDocumentFactory;
|
||||||
|
import org.apache.batik.util.MimeTypeConstants;
|
||||||
|
import org.apache.batik.util.ParsedURL;
|
||||||
|
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import org.w3c.dom.DOMImplementation;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.svg.SVGDocument;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class contains methods for creating SVGDocument instances
|
||||||
|
* from an URI using SAX2.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SAXSVGDocumentFactory.java 1803524 2017-07-31 12:12:37Z ssteiner $
|
||||||
|
*/
|
||||||
|
public class SAXSVGDocumentFactory
|
||||||
|
extends SAXDocumentFactory
|
||||||
|
implements SVGDocumentFactory {
|
||||||
|
|
||||||
|
public static final Object LOCK = new Object();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Key used for public identifiers
|
||||||
|
*/
|
||||||
|
public static final String KEY_PUBLIC_IDS = "publicIds";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Key used for public identifiers
|
||||||
|
*/
|
||||||
|
public static final String KEY_SKIPPABLE_PUBLIC_IDS = "skippablePublicIds";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Key used for the skippable DTD substitution
|
||||||
|
*/
|
||||||
|
public static final String KEY_SKIP_DTD = "skipDTD";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Key used for system identifiers
|
||||||
|
*/
|
||||||
|
public static final String KEY_SYSTEM_ID = "systemId.";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The dtd public IDs resource bundle class name.
|
||||||
|
*/
|
||||||
|
protected static final String DTDIDS =
|
||||||
|
"org.apache.batik.anim.dom.resources.dtdids";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constant for HTTP content type header charset field.
|
||||||
|
*/
|
||||||
|
protected static final String HTTP_CHARSET = "charset";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The accepted DTD public IDs.
|
||||||
|
*/
|
||||||
|
protected static String dtdids;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The DTD public IDs we know we can skip.
|
||||||
|
*/
|
||||||
|
protected static String skippable_dtdids;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The DTD content to use when skipping
|
||||||
|
*/
|
||||||
|
protected static String skip_dtd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ResourceBunder for the public and system ids
|
||||||
|
*/
|
||||||
|
protected static Properties dtdProps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGDocumentFactory object.
|
||||||
|
* @param parser The SAX2 parser classname.
|
||||||
|
*/
|
||||||
|
public SAXSVGDocumentFactory(String parser) {
|
||||||
|
super(SVGDOMImplementation.getDOMImplementation(), parser);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGDocumentFactory object.
|
||||||
|
* @param parser The SAX2 parser classname.
|
||||||
|
* @param dd Whether a document descriptor must be generated.
|
||||||
|
*/
|
||||||
|
public SAXSVGDocumentFactory(String parser, boolean dd) {
|
||||||
|
super(SVGDOMImplementation.getDOMImplementation(), parser, dd);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SVGDocument createSVGDocument(String uri) throws IOException {
|
||||||
|
return (SVGDocument)createDocument(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a SVG Document instance.
|
||||||
|
* @param uri The document URI.
|
||||||
|
* @param inp The document input stream.
|
||||||
|
* @exception IOException if an error occured while reading the document.
|
||||||
|
*/
|
||||||
|
public SVGDocument createSVGDocument(String uri, InputStream inp)
|
||||||
|
throws IOException {
|
||||||
|
return (SVGDocument)createDocument(uri, inp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a SVG Document instance.
|
||||||
|
* @param uri The document URI.
|
||||||
|
* @param r The document reader.
|
||||||
|
* @exception IOException if an error occured while reading the document.
|
||||||
|
*/
|
||||||
|
public SVGDocument createSVGDocument(String uri, Reader r)
|
||||||
|
throws IOException {
|
||||||
|
return (SVGDocument)createDocument(uri, r);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a SVG Document instance.
|
||||||
|
* This method supports gzipped sources.
|
||||||
|
* @param uri The document URI.
|
||||||
|
* @exception IOException if an error occured while reading the document.
|
||||||
|
*/
|
||||||
|
public Document createDocument(String uri) throws IOException {
|
||||||
|
ParsedURL purl = new ParsedURL(uri);
|
||||||
|
|
||||||
|
InputStream is = purl.openStream
|
||||||
|
(MimeTypeConstants.MIME_TYPES_SVG_LIST.iterator());
|
||||||
|
uri = purl.getPostConnectionURL();
|
||||||
|
|
||||||
|
InputSource isrc = new InputSource(is);
|
||||||
|
|
||||||
|
// now looking for a charset encoding in the content type such
|
||||||
|
// as "image/svg+xml; charset=iso8859-1" this is not official
|
||||||
|
// for image/svg+xml yet! only for text/xml and maybe
|
||||||
|
// for application/xml
|
||||||
|
String contentType = purl.getContentType();
|
||||||
|
int cindex = -1;
|
||||||
|
if (contentType != null) {
|
||||||
|
contentType = contentType.toLowerCase();
|
||||||
|
cindex = contentType.indexOf(HTTP_CHARSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
String charset = null;
|
||||||
|
if (cindex != -1) {
|
||||||
|
int i = cindex + HTTP_CHARSET.length();
|
||||||
|
int eqIdx = contentType.indexOf('=', i);
|
||||||
|
if (eqIdx != -1) {
|
||||||
|
eqIdx++; // no one is interested in the equals sign...
|
||||||
|
|
||||||
|
// The patch had ',' as the terminator but I suspect
|
||||||
|
// that is the delimiter between possible charsets,
|
||||||
|
// but if another 'attribute' were in the accept header
|
||||||
|
// charset would be terminated by a ';'. So I look
|
||||||
|
// for both and take to closer of the two.
|
||||||
|
int idx = contentType.indexOf(',', eqIdx);
|
||||||
|
int semiIdx = contentType.indexOf(';', eqIdx);
|
||||||
|
if ((semiIdx != -1) && ((semiIdx < idx) || (idx == -1)))
|
||||||
|
idx = semiIdx;
|
||||||
|
if (idx != -1)
|
||||||
|
charset = contentType.substring(eqIdx, idx);
|
||||||
|
else
|
||||||
|
charset = contentType.substring(eqIdx);
|
||||||
|
charset = charset.trim();
|
||||||
|
isrc.setEncoding(charset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
isrc.setSystemId(uri);
|
||||||
|
|
||||||
|
SVGOMDocument doc = (SVGOMDocument) super.createDocument
|
||||||
|
(SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", uri, isrc);
|
||||||
|
doc.setParsedURL(new ParsedURL(uri));
|
||||||
|
doc.setDocumentInputEncoding(charset);
|
||||||
|
doc.setXmlStandalone(isStandalone);
|
||||||
|
doc.setXmlVersion(xmlVersion);
|
||||||
|
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a SVG Document instance.
|
||||||
|
* @param uri The document URI.
|
||||||
|
* @param inp The document input stream.
|
||||||
|
* @exception IOException if an error occured while reading the document.
|
||||||
|
*/
|
||||||
|
public Document createDocument(String uri, InputStream inp)
|
||||||
|
throws IOException {
|
||||||
|
Document doc;
|
||||||
|
InputSource is = new InputSource(inp);
|
||||||
|
is.setSystemId(uri);
|
||||||
|
|
||||||
|
try {
|
||||||
|
doc = super.createDocument
|
||||||
|
(SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", uri, is);
|
||||||
|
if (uri != null) {
|
||||||
|
((SVGOMDocument)doc).setParsedURL(new ParsedURL(uri));
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractDocument d = (AbstractDocument) doc;
|
||||||
|
d.setDocumentURI(uri);
|
||||||
|
d.setXmlStandalone(isStandalone);
|
||||||
|
d.setXmlVersion(xmlVersion);
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
throw new IOException(e.getMessage());
|
||||||
|
}
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a SVG Document instance.
|
||||||
|
* @param uri The document URI.
|
||||||
|
* @param r The document reader.
|
||||||
|
* @exception IOException if an error occured while reading the document.
|
||||||
|
*/
|
||||||
|
public Document createDocument(String uri, Reader r)
|
||||||
|
throws IOException {
|
||||||
|
Document doc;
|
||||||
|
InputSource is = new InputSource(r);
|
||||||
|
is.setSystemId(uri);
|
||||||
|
|
||||||
|
try {
|
||||||
|
doc = super.createDocument
|
||||||
|
(SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", uri, is);
|
||||||
|
if (uri != null) {
|
||||||
|
((SVGOMDocument)doc).setParsedURL(new ParsedURL(uri));
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractDocument d = (AbstractDocument) doc;
|
||||||
|
d.setDocumentURI(uri);
|
||||||
|
d.setXmlStandalone(isStandalone);
|
||||||
|
d.setXmlVersion(xmlVersion);
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
throw new IOException(e.getMessage());
|
||||||
|
}
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Document instance.
|
||||||
|
* @param ns The namespace URI of the root element of the document.
|
||||||
|
* @param root The name of the root element of the document.
|
||||||
|
* @param uri The document URI.
|
||||||
|
* @exception IOException if an error occured while reading the document.
|
||||||
|
*/
|
||||||
|
public Document createDocument(String ns, String root, String uri)
|
||||||
|
throws IOException {
|
||||||
|
if (!SVGDOMImplementation.SVG_NAMESPACE_URI.equals(ns) ||
|
||||||
|
!"svg".equals(root)) {
|
||||||
|
throw new RuntimeException("Bad root element");
|
||||||
|
}
|
||||||
|
return createDocument(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Document instance.
|
||||||
|
* @param ns The namespace URI of the root element of the document.
|
||||||
|
* @param root The name of the root element of the document.
|
||||||
|
* @param uri The document URI.
|
||||||
|
* @param is The document input stream.
|
||||||
|
* @exception IOException if an error occured while reading the document.
|
||||||
|
*/
|
||||||
|
public Document createDocument(String ns, String root, String uri,
|
||||||
|
InputStream is) throws IOException {
|
||||||
|
if (!SVGDOMImplementation.SVG_NAMESPACE_URI.equals(ns) ||
|
||||||
|
!"svg".equals(root)) {
|
||||||
|
throw new RuntimeException("Bad root element");
|
||||||
|
}
|
||||||
|
return createDocument(uri, is);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Document instance.
|
||||||
|
* @param ns The namespace URI of the root element of the document.
|
||||||
|
* @param root The name of the root element of the document.
|
||||||
|
* @param uri The document URI.
|
||||||
|
* @param r The document reader.
|
||||||
|
* @exception IOException if an error occured while reading the document.
|
||||||
|
*/
|
||||||
|
public Document createDocument(String ns, String root, String uri,
|
||||||
|
Reader r) throws IOException {
|
||||||
|
if (!SVGDOMImplementation.SVG_NAMESPACE_URI.equals(ns) ||
|
||||||
|
!"svg".equals(root)) {
|
||||||
|
throw new RuntimeException("Bad root element");
|
||||||
|
}
|
||||||
|
return createDocument(uri, r);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DOMImplementation getDOMImplementation(String ver) {
|
||||||
|
if (ver == null || ver.length() == 0
|
||||||
|
|| ver.equals("1.0") || ver.equals("1.1")) {
|
||||||
|
return SVGDOMImplementation.getDOMImplementation();
|
||||||
|
} else if (ver.equals("1.2")) {
|
||||||
|
return SVG12DOMImplementation.getDOMImplementation();
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Unsupport SVG version '" + ver + "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>SAX</b>: Implements {@link
|
||||||
|
* org.xml.sax.ContentHandler#startDocument()}.
|
||||||
|
*/
|
||||||
|
public void startDocument() throws SAXException {
|
||||||
|
super.startDocument();
|
||||||
|
// Do not assume namespace declarations when no DTD has been specified.
|
||||||
|
// namespaces.put("", SVGDOMImplementation.SVG_NAMESPACE_URI);
|
||||||
|
// namespaces.put("xlink", XLinkSupport.XLINK_NAMESPACE_URI);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>SAX2</b>: Implements {@link
|
||||||
|
* org.xml.sax.EntityResolver#resolveEntity(String,String)}.
|
||||||
|
*/
|
||||||
|
public InputSource resolveEntity(String publicId, String systemId)
|
||||||
|
throws SAXException {
|
||||||
|
try {
|
||||||
|
synchronized (LOCK) {
|
||||||
|
// Bootstrap if needed - move to a static block???
|
||||||
|
if (dtdProps == null) {
|
||||||
|
dtdProps = new Properties();
|
||||||
|
try {
|
||||||
|
Class cls = SAXSVGDocumentFactory.class;
|
||||||
|
InputStream is = cls.getResourceAsStream
|
||||||
|
("resources/dtdids.properties");
|
||||||
|
dtdProps.load(is);
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
throw new SAXException(ioe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dtdids == null)
|
||||||
|
dtdids = dtdProps.getProperty(KEY_PUBLIC_IDS);
|
||||||
|
|
||||||
|
if (skippable_dtdids == null)
|
||||||
|
skippable_dtdids =
|
||||||
|
dtdProps.getProperty(KEY_SKIPPABLE_PUBLIC_IDS);
|
||||||
|
|
||||||
|
if (skip_dtd == null)
|
||||||
|
skip_dtd = dtdProps.getProperty(KEY_SKIP_DTD);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (publicId == null)
|
||||||
|
return null; // Let SAX Parser find it.
|
||||||
|
|
||||||
|
if (!isValidating &&
|
||||||
|
(skippable_dtdids.indexOf(publicId) != -1)) {
|
||||||
|
// We are not validating and this is a DTD we can
|
||||||
|
// safely skip so do it... Here we provide just enough
|
||||||
|
// of the DTD to keep stuff running (set svg and
|
||||||
|
// xlink namespaces).
|
||||||
|
return new InputSource(new StringReader(skip_dtd));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dtdids.indexOf(publicId) != -1) {
|
||||||
|
String localSystemId =
|
||||||
|
dtdProps.getProperty(KEY_SYSTEM_ID +
|
||||||
|
publicId.replace(' ', '_'));
|
||||||
|
|
||||||
|
if (localSystemId != null && !"".equals(localSystemId)) {
|
||||||
|
return new InputSource
|
||||||
|
(getClass().getResource(localSystemId).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (MissingResourceException e) {
|
||||||
|
throw new SAXException(e);
|
||||||
|
}
|
||||||
|
// Let the SAX parser find the entity.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,551 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.apache.batik.css.engine.CSSContext;
|
||||||
|
import org.apache.batik.css.engine.CSSEngine;
|
||||||
|
import org.apache.batik.css.engine.SVG12CSSEngine;
|
||||||
|
import org.apache.batik.css.engine.value.ShorthandManager;
|
||||||
|
import org.apache.batik.css.engine.value.ValueManager;
|
||||||
|
import org.apache.batik.css.parser.ExtendedParser;
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.dom.AbstractNode;
|
||||||
|
import org.apache.batik.dom.AbstractStylableDocument;
|
||||||
|
import org.apache.batik.dom.GenericElement;
|
||||||
|
import org.apache.batik.dom.events.DocumentEventSupport;
|
||||||
|
import org.apache.batik.dom.events.EventSupport;
|
||||||
|
import org.apache.batik.dom.svg12.SVGOMWheelEvent;
|
||||||
|
import org.apache.batik.dom.svg12.XBLOMShadowTreeEvent;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.util.DOMUtilities;
|
||||||
|
import org.apache.batik.util.ParsedURL;
|
||||||
|
import org.apache.batik.util.SVG12Constants;
|
||||||
|
import org.apache.batik.util.XBLConstants;
|
||||||
|
|
||||||
|
import org.w3c.css.sac.InputSource;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.DocumentType;
|
||||||
|
import org.w3c.dom.DOMImplementation;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.events.Event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements the {@link DOMImplementation} interface.
|
||||||
|
* It provides support the SVG 1.2 documents.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVG12DOMImplementation.java 1831630 2018-05-15 12:56:55Z ssteiner $
|
||||||
|
*/
|
||||||
|
public class SVG12DOMImplementation
|
||||||
|
extends SVGDOMImplementation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGDOMImplementation object.
|
||||||
|
*/
|
||||||
|
public SVG12DOMImplementation() {
|
||||||
|
factories = svg12Factories;
|
||||||
|
registerFeature("CSS", "2.0");
|
||||||
|
registerFeature("StyleSheets", "2.0");
|
||||||
|
registerFeature("SVG", new String[] {"1.0", "1.1", "1.2"});
|
||||||
|
registerFeature("SVGEvents", new String[] {"1.0", "1.1", "1.2"});
|
||||||
|
}
|
||||||
|
|
||||||
|
public CSSEngine createCSSEngine(AbstractStylableDocument doc,
|
||||||
|
CSSContext ctx,
|
||||||
|
ExtendedParser ep,
|
||||||
|
ValueManager [] vms,
|
||||||
|
ShorthandManager [] sms) {
|
||||||
|
ParsedURL durl = ((SVGOMDocument)doc).getParsedURL();
|
||||||
|
CSSEngine result = new SVG12CSSEngine(doc, durl, ep, vms, sms, ctx);
|
||||||
|
|
||||||
|
URL url = getClass().getResource("resources/UserAgentStyleSheet.css");
|
||||||
|
if (url != null) {
|
||||||
|
ParsedURL purl = new ParsedURL(url);
|
||||||
|
InputSource is = new InputSource(purl.toString());
|
||||||
|
result.setUserAgentStyleSheet
|
||||||
|
(result.parseStyleSheet(is, purl, "all"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* DOMImplementation#createDocument(String,String,DocumentType)}.
|
||||||
|
*/
|
||||||
|
public Document createDocument(String namespaceURI,
|
||||||
|
String qualifiedName,
|
||||||
|
DocumentType doctype)
|
||||||
|
throws DOMException {
|
||||||
|
SVGOMDocument result = new SVG12OMDocument(doctype, this);
|
||||||
|
result.setIsSVG12(true);
|
||||||
|
// BUG 32108: return empty document if qualifiedName is null.
|
||||||
|
if (qualifiedName != null)
|
||||||
|
result.appendChild(result.createElementNS(namespaceURI,
|
||||||
|
qualifiedName));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements the behavior of Document.createElementNS() for this
|
||||||
|
* DOM implementation.
|
||||||
|
*/
|
||||||
|
public Element createElementNS(AbstractDocument document,
|
||||||
|
String namespaceURI,
|
||||||
|
String qualifiedName) {
|
||||||
|
if (namespaceURI == null)
|
||||||
|
return new GenericElement(qualifiedName.intern(), document);
|
||||||
|
|
||||||
|
String name = DOMUtilities.getLocalName(qualifiedName);
|
||||||
|
String prefix = DOMUtilities.getPrefix(qualifiedName);
|
||||||
|
if (SVG12Constants.SVG_NAMESPACE_URI.equals(namespaceURI)) {
|
||||||
|
ElementFactory ef = factories.get(name);
|
||||||
|
if (ef != null) {
|
||||||
|
return ef.create(prefix, document);
|
||||||
|
}
|
||||||
|
} else if (XBLConstants.XBL_NAMESPACE_URI.equals(namespaceURI)) {
|
||||||
|
ElementFactory ef = xblFactories.get(name);
|
||||||
|
if (ef != null) {
|
||||||
|
return ef.create(prefix, document);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (customFactories != null) {
|
||||||
|
ElementFactory cef;
|
||||||
|
cef = (ElementFactory)customFactories.get(namespaceURI, name);
|
||||||
|
if (cef != null) {
|
||||||
|
return cef.create(prefix, document);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BindableElement(prefix, document, namespaceURI, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an DocumentEventSupport object suitable for use with
|
||||||
|
* this implementation.
|
||||||
|
*/
|
||||||
|
public DocumentEventSupport createDocumentEventSupport() {
|
||||||
|
DocumentEventSupport result = super.createDocumentEventSupport();
|
||||||
|
result.registerEventFactory("WheelEvent",
|
||||||
|
new DocumentEventSupport.EventFactory() {
|
||||||
|
public Event createEvent() {
|
||||||
|
return new SVGOMWheelEvent();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
result.registerEventFactory("ShadowTreeEvent",
|
||||||
|
new DocumentEventSupport.EventFactory() {
|
||||||
|
public Event createEvent() {
|
||||||
|
return new XBLOMShadowTreeEvent();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an EventSupport object for the given node.
|
||||||
|
*/
|
||||||
|
public EventSupport createEventSupport(AbstractNode n) {
|
||||||
|
return new XBLEventSupport(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The element factories /////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The SVG element factories.
|
||||||
|
*/
|
||||||
|
protected static HashMap<String, ElementFactory> svg12Factories = new HashMap<String, ElementFactory>(svg11Factories);
|
||||||
|
|
||||||
|
static {
|
||||||
|
svg12Factories.put(SVG12Constants.SVG_FLOW_DIV_TAG,
|
||||||
|
new FlowDivElementFactory());
|
||||||
|
|
||||||
|
svg12Factories.put(SVG12Constants.SVG_FLOW_LINE_TAG,
|
||||||
|
new FlowLineElementFactory());
|
||||||
|
|
||||||
|
svg12Factories.put(SVG12Constants.SVG_FLOW_PARA_TAG,
|
||||||
|
new FlowParaElementFactory());
|
||||||
|
|
||||||
|
svg12Factories.put(SVG12Constants.SVG_FLOW_REGION_BREAK_TAG,
|
||||||
|
new FlowRegionBreakElementFactory());
|
||||||
|
|
||||||
|
svg12Factories.put(SVG12Constants.SVG_FLOW_REGION_TAG,
|
||||||
|
new FlowRegionElementFactory());
|
||||||
|
|
||||||
|
svg12Factories.put(SVG12Constants.SVG_FLOW_REGION_EXCLUDE_TAG,
|
||||||
|
new FlowRegionExcludeElementFactory());
|
||||||
|
|
||||||
|
svg12Factories.put(SVG12Constants.SVG_FLOW_ROOT_TAG,
|
||||||
|
new FlowRootElementFactory());
|
||||||
|
|
||||||
|
svg12Factories.put(SVG12Constants.SVG_FLOW_SPAN_TAG,
|
||||||
|
new FlowSpanElementFactory());
|
||||||
|
|
||||||
|
svg12Factories.put(SVG12Constants.SVG_HANDLER_TAG,
|
||||||
|
new HandlerElementFactory());
|
||||||
|
|
||||||
|
svg12Factories.put(SVG12Constants.SVG_MULTI_IMAGE_TAG,
|
||||||
|
new MultiImageElementFactory());
|
||||||
|
|
||||||
|
svg12Factories.put(SVG12Constants.SVG_SOLID_COLOR_TAG,
|
||||||
|
new SolidColorElementFactory());
|
||||||
|
|
||||||
|
svg12Factories.put(SVG12Constants.SVG_SUB_IMAGE_TAG,
|
||||||
|
new SubImageElementFactory());
|
||||||
|
|
||||||
|
svg12Factories.put(SVG12Constants.SVG_SUB_IMAGE_REF_TAG,
|
||||||
|
new SubImageRefElementFactory());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'flowDiv' element.
|
||||||
|
*/
|
||||||
|
protected static class FlowDivElementFactory
|
||||||
|
implements ElementFactory {
|
||||||
|
public FlowDivElementFactory() {
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new SVGOMFlowDivElement(prefix, (AbstractDocument)doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'flowLine' element.
|
||||||
|
*/
|
||||||
|
protected static class FlowLineElementFactory
|
||||||
|
implements ElementFactory {
|
||||||
|
public FlowLineElementFactory() {
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new SVGOMFlowLineElement(prefix, (AbstractDocument)doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'flowPara' element.
|
||||||
|
*/
|
||||||
|
protected static class FlowParaElementFactory
|
||||||
|
implements ElementFactory {
|
||||||
|
public FlowParaElementFactory() {
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new SVGOMFlowParaElement(prefix, (AbstractDocument)doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'flowRegionBreak' element.
|
||||||
|
*/
|
||||||
|
protected static class FlowRegionBreakElementFactory
|
||||||
|
implements ElementFactory {
|
||||||
|
public FlowRegionBreakElementFactory() {
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new SVGOMFlowRegionBreakElement(prefix, (AbstractDocument)doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'flowRegion' element.
|
||||||
|
*/
|
||||||
|
protected static class FlowRegionElementFactory
|
||||||
|
implements ElementFactory {
|
||||||
|
public FlowRegionElementFactory() {
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new SVGOMFlowRegionElement(prefix, (AbstractDocument)doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'flowRegion' element.
|
||||||
|
*/
|
||||||
|
protected static class FlowRegionExcludeElementFactory
|
||||||
|
implements ElementFactory {
|
||||||
|
public FlowRegionExcludeElementFactory() {
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new SVGOMFlowRegionExcludeElement(prefix, (AbstractDocument)doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'flowRoot' element.
|
||||||
|
*/
|
||||||
|
protected static class FlowRootElementFactory
|
||||||
|
implements ElementFactory {
|
||||||
|
public FlowRootElementFactory() {
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new SVGOMFlowRootElement(prefix, (AbstractDocument)doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'flowSpan' element.
|
||||||
|
*/
|
||||||
|
protected static class FlowSpanElementFactory
|
||||||
|
implements ElementFactory {
|
||||||
|
public FlowSpanElementFactory() {
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new SVGOMFlowSpanElement(prefix, (AbstractDocument)doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'handler' element.
|
||||||
|
*/
|
||||||
|
protected static class HandlerElementFactory
|
||||||
|
implements ElementFactory {
|
||||||
|
public HandlerElementFactory() {
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new SVGOMHandlerElement(prefix, (AbstractDocument)doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'multiImage' element.
|
||||||
|
*/
|
||||||
|
protected static class MultiImageElementFactory
|
||||||
|
implements ElementFactory {
|
||||||
|
public MultiImageElementFactory() {}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new SVGOMMultiImageElement
|
||||||
|
(prefix, (AbstractDocument)doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'solidColor' element.
|
||||||
|
*/
|
||||||
|
protected static class SolidColorElementFactory
|
||||||
|
implements ElementFactory {
|
||||||
|
public SolidColorElementFactory() {
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new SVGOMSolidColorElement(prefix, (AbstractDocument)doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'subImage' element.
|
||||||
|
*/
|
||||||
|
protected static class SubImageElementFactory
|
||||||
|
implements ElementFactory {
|
||||||
|
public SubImageElementFactory() {}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new SVGOMSubImageElement(prefix, (AbstractDocument)doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'SubImageRef' element.
|
||||||
|
*/
|
||||||
|
protected static class SubImageRefElementFactory
|
||||||
|
implements ElementFactory {
|
||||||
|
public SubImageRefElementFactory() {}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new SVGOMSubImageRefElement(prefix, (AbstractDocument)doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The XBL element factories.
|
||||||
|
*/
|
||||||
|
protected static HashMap<String, ElementFactory> xblFactories = new HashMap<String, ElementFactory>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
xblFactories.put(XBLConstants.XBL_XBL_TAG,
|
||||||
|
new XBLXBLElementFactory());
|
||||||
|
|
||||||
|
xblFactories.put(XBLConstants.XBL_DEFINITION_TAG,
|
||||||
|
new XBLDefinitionElementFactory());
|
||||||
|
|
||||||
|
xblFactories.put(XBLConstants.XBL_TEMPLATE_TAG,
|
||||||
|
new XBLTemplateElementFactory());
|
||||||
|
|
||||||
|
xblFactories.put(XBLConstants.XBL_CONTENT_TAG,
|
||||||
|
new XBLContentElementFactory());
|
||||||
|
|
||||||
|
xblFactories.put(XBLConstants.XBL_HANDLER_GROUP_TAG,
|
||||||
|
new XBLHandlerGroupElementFactory());
|
||||||
|
|
||||||
|
xblFactories.put(XBLConstants.XBL_IMPORT_TAG,
|
||||||
|
new XBLImportElementFactory());
|
||||||
|
|
||||||
|
xblFactories.put(XBLConstants.XBL_SHADOW_TREE_TAG,
|
||||||
|
new XBLShadowTreeElementFactory());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'xbl:xbl' element.
|
||||||
|
*/
|
||||||
|
protected static class XBLXBLElementFactory implements ElementFactory {
|
||||||
|
public XBLXBLElementFactory() {}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new XBLOMXBLElement(prefix, (AbstractDocument)doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'xbl:definition' element.
|
||||||
|
*/
|
||||||
|
protected static class XBLDefinitionElementFactory
|
||||||
|
implements ElementFactory {
|
||||||
|
public XBLDefinitionElementFactory() {}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new XBLOMDefinitionElement(prefix, (AbstractDocument)doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'xbl:template' element.
|
||||||
|
*/
|
||||||
|
protected static class XBLTemplateElementFactory
|
||||||
|
implements ElementFactory {
|
||||||
|
public XBLTemplateElementFactory() {}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new XBLOMTemplateElement(prefix, (AbstractDocument) doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'xbl:content' element.
|
||||||
|
*/
|
||||||
|
protected static class XBLContentElementFactory
|
||||||
|
implements ElementFactory {
|
||||||
|
public XBLContentElementFactory() {}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new XBLOMContentElement(prefix, (AbstractDocument)doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'xbl:handlerGroup' element.
|
||||||
|
*/
|
||||||
|
protected static class XBLHandlerGroupElementFactory
|
||||||
|
implements ElementFactory {
|
||||||
|
public XBLHandlerGroupElementFactory() {}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new XBLOMHandlerGroupElement(prefix, (AbstractDocument)doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'xbl:import' element.
|
||||||
|
*/
|
||||||
|
protected static class XBLImportElementFactory
|
||||||
|
implements ElementFactory {
|
||||||
|
public XBLImportElementFactory() {}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new XBLOMImportElement(prefix, (AbstractDocument)doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To create a 'xbl:shadowTree' element.
|
||||||
|
*/
|
||||||
|
protected static class XBLShadowTreeElementFactory
|
||||||
|
implements ElementFactory {
|
||||||
|
public XBLShadowTreeElementFactory() {}
|
||||||
|
/**
|
||||||
|
* Creates an instance of the associated element type.
|
||||||
|
*/
|
||||||
|
public Element create(String prefix, Document doc) {
|
||||||
|
return new XBLOMShadowTreeElement(prefix, (AbstractDocument)doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default instance of this class.
|
||||||
|
*/
|
||||||
|
protected static final DOMImplementation DOM_IMPLEMENTATION =
|
||||||
|
new SVG12DOMImplementation();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the default instance of this class.
|
||||||
|
*/
|
||||||
|
public static DOMImplementation getDOMImplementation() {
|
||||||
|
return DOM_IMPLEMENTATION;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,152 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.css.engine.CSSNavigableDocumentListener;
|
||||||
|
import org.apache.batik.constants.XMLConstants;
|
||||||
|
|
||||||
|
import org.w3c.dom.DOMImplementation;
|
||||||
|
import org.w3c.dom.DocumentType;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.events.EventListener;
|
||||||
|
import org.w3c.dom.svg.SVGDocument;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGDocument} and provides support for
|
||||||
|
* SVG 1.2 specifics.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: SVG12OMDocument.java 1851346 2019-01-15 13:41:00Z ssteiner $
|
||||||
|
*/
|
||||||
|
public class SVG12OMDocument extends SVGOMDocument {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new uninitialized document.
|
||||||
|
*/
|
||||||
|
protected SVG12OMDocument() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVG12OMDocument.
|
||||||
|
*/
|
||||||
|
public SVG12OMDocument(DocumentType dt, DOMImplementation impl) {
|
||||||
|
super(dt, impl);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AbstractDocument ///////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVG12OMDocument();
|
||||||
|
}
|
||||||
|
|
||||||
|
// CSSNavigableDocument ///////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an event listener for mutations on the
|
||||||
|
* CSSNavigableDocument tree.
|
||||||
|
*/
|
||||||
|
public void addCSSNavigableDocumentListener
|
||||||
|
(CSSNavigableDocumentListener l) {
|
||||||
|
if (cssNavigableDocumentListeners.containsKey(l)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DOMNodeInsertedListenerWrapper nodeInserted
|
||||||
|
= new DOMNodeInsertedListenerWrapper(l);
|
||||||
|
DOMNodeRemovedListenerWrapper nodeRemoved
|
||||||
|
= new DOMNodeRemovedListenerWrapper(l);
|
||||||
|
DOMSubtreeModifiedListenerWrapper subtreeModified
|
||||||
|
= new DOMSubtreeModifiedListenerWrapper(l);
|
||||||
|
DOMCharacterDataModifiedListenerWrapper cdataModified
|
||||||
|
= new DOMCharacterDataModifiedListenerWrapper(l);
|
||||||
|
DOMAttrModifiedListenerWrapper attrModified
|
||||||
|
= new DOMAttrModifiedListenerWrapper(l);
|
||||||
|
|
||||||
|
cssNavigableDocumentListeners.put
|
||||||
|
(l, new EventListener[] { nodeInserted,
|
||||||
|
nodeRemoved,
|
||||||
|
subtreeModified,
|
||||||
|
cdataModified,
|
||||||
|
attrModified });
|
||||||
|
|
||||||
|
XBLEventSupport es = (XBLEventSupport) initializeEventSupport();
|
||||||
|
|
||||||
|
es.addImplementationEventListenerNS
|
||||||
|
(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMNodeInserted",
|
||||||
|
nodeInserted, false);
|
||||||
|
es.addImplementationEventListenerNS
|
||||||
|
(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMNodeRemoved",
|
||||||
|
nodeRemoved, false);
|
||||||
|
es.addImplementationEventListenerNS
|
||||||
|
(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMSubtreeModified",
|
||||||
|
subtreeModified, false);
|
||||||
|
es.addImplementationEventListenerNS
|
||||||
|
(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMCharacterDataModified",
|
||||||
|
cdataModified, false);
|
||||||
|
es.addImplementationEventListenerNS
|
||||||
|
(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMAttrModified",
|
||||||
|
attrModified, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes an event listener for mutations on the
|
||||||
|
* CSSNavigableDocument tree.
|
||||||
|
*/
|
||||||
|
public void removeCSSNavigableDocumentListener
|
||||||
|
(CSSNavigableDocumentListener l) {
|
||||||
|
EventListener[] listeners
|
||||||
|
= (EventListener[]) cssNavigableDocumentListeners.get(l);
|
||||||
|
if (listeners == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
XBLEventSupport es = (XBLEventSupport) initializeEventSupport();
|
||||||
|
|
||||||
|
es.removeImplementationEventListenerNS
|
||||||
|
(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMNodeInserted",
|
||||||
|
listeners[0], false);
|
||||||
|
es.removeImplementationEventListenerNS
|
||||||
|
(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMNodeRemoved",
|
||||||
|
listeners[1], false);
|
||||||
|
es.removeImplementationEventListenerNS
|
||||||
|
(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMSubtreeModified",
|
||||||
|
listeners[2], false);
|
||||||
|
es.removeImplementationEventListenerNS
|
||||||
|
(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMCharacterDataModified",
|
||||||
|
listeners[3], false);
|
||||||
|
es.removeImplementationEventListenerNS
|
||||||
|
(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMAttrModified",
|
||||||
|
listeners[4], false);
|
||||||
|
|
||||||
|
cssNavigableDocumentListeners.remove(l);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.svg.SVGContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context interface for elements that can be the target of animations.
|
||||||
|
* This exposes the ability to attach {@link AnimationTargetListener}s
|
||||||
|
* to the element.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: SVGAnimationTargetContext.java 1808001 2017-09-11 09:51:29Z ssteiner $
|
||||||
|
*/
|
||||||
|
public interface SVGAnimationTargetContext extends SVGContext {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a listener for changes to the given CSS property.
|
||||||
|
*/
|
||||||
|
void addTargetListener(String pn, AnimationTargetListener l);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a listener for changes to the given attribute value.
|
||||||
|
*/
|
||||||
|
void removeTargetListener(String pn, AnimationTargetListener l);
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,77 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.dom.util.XMLSupport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides a common superclass for elements which contain
|
||||||
|
* descriptive text.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGDescriptiveElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public abstract class SVGDescriptiveElement extends SVGStylableElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGDescriptiveElement object.
|
||||||
|
*/
|
||||||
|
protected SVGDescriptiveElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGDescriptiveElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
protected SVGDescriptiveElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SVGLangSpace support //////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Returns the xml:lang attribute value.
|
||||||
|
*/
|
||||||
|
public String getXMLlang() {
|
||||||
|
return XMLSupport.getXMLLang(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Sets the xml:lang attribute value.
|
||||||
|
*/
|
||||||
|
public void setXMLlang(String lang) {
|
||||||
|
setAttributeNS(XML_NAMESPACE_URI, XML_LANG_QNAME, lang);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Returns the xml:space attribute value.
|
||||||
|
*/
|
||||||
|
public String getXMLspace() {
|
||||||
|
return XMLSupport.getXMLSpace(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Sets the xml:space attribute value.
|
||||||
|
*/
|
||||||
|
public void setXMLspace(String space) {
|
||||||
|
setAttributeNS(XML_NAMESPACE_URI, XML_SPACE_QNAME, space);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,296 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import java.awt.geom.AffineTransform;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatableMotionPointValue;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.dom.svg.SVGMotionAnimatableElement;
|
||||||
|
import org.apache.batik.dom.svg.SVGTestsSupport;
|
||||||
|
import org.apache.batik.dom.util.XMLSupport;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedBoolean;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedTransformList;
|
||||||
|
import org.w3c.dom.svg.SVGElement;
|
||||||
|
import org.w3c.dom.svg.SVGException;
|
||||||
|
import org.w3c.dom.svg.SVGMatrix;
|
||||||
|
import org.w3c.dom.svg.SVGRect;
|
||||||
|
import org.w3c.dom.svg.SVGStringList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides a common superclass for all graphics elements.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGGraphicsElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public abstract class SVGGraphicsElement
|
||||||
|
extends SVGStylableElement
|
||||||
|
implements SVGMotionAnimatableElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGStylableElement.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_TRANSFORM_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_TRANSFORM_LIST));
|
||||||
|
t.put(null, SVG_EXTERNAL_RESOURCES_REQUIRED_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_BOOLEAN));
|
||||||
|
// t.put(null, SVG_REQUIRED_EXTENSIONS_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_URI_LIST));
|
||||||
|
// t.put(null, SVG_REQUIRED_FEATURES_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_URI_LIST));
|
||||||
|
// t.put(null, SVG_SYSTEM_LANGUAGE_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_LANG_LIST));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'transform' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedTransformList transform;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'externalResourcesRequired' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedBoolean externalResourcesRequired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supplemental transformation due to motion animation.
|
||||||
|
*/
|
||||||
|
protected AffineTransform motionTransform;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGGraphicsElement.
|
||||||
|
*/
|
||||||
|
protected SVGGraphicsElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGGraphicsElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
protected SVGGraphicsElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
transform =
|
||||||
|
createLiveAnimatedTransformList(null, SVG_TRANSFORM_ATTRIBUTE, "");
|
||||||
|
externalResourcesRequired =
|
||||||
|
createLiveAnimatedBoolean
|
||||||
|
(null, SVG_EXTERNAL_RESOURCES_REQUIRED_ATTRIBUTE, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SVGLocatable support /////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGLocatable#getNearestViewportElement()}.
|
||||||
|
*/
|
||||||
|
public SVGElement getNearestViewportElement() {
|
||||||
|
return SVGLocatableSupport.getNearestViewportElement(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGLocatable#getFarthestViewportElement()}.
|
||||||
|
*/
|
||||||
|
public SVGElement getFarthestViewportElement() {
|
||||||
|
return SVGLocatableSupport.getFarthestViewportElement(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGLocatable#getBBox()}.
|
||||||
|
*/
|
||||||
|
public SVGRect getBBox() {
|
||||||
|
return SVGLocatableSupport.getBBox(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGLocatable#getCTM()}.
|
||||||
|
*/
|
||||||
|
public SVGMatrix getCTM() {
|
||||||
|
return SVGLocatableSupport.getCTM(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGLocatable#getScreenCTM()}.
|
||||||
|
*/
|
||||||
|
public SVGMatrix getScreenCTM() {
|
||||||
|
return SVGLocatableSupport.getScreenCTM(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGLocatable#getTransformToElement(SVGElement)}.
|
||||||
|
*/
|
||||||
|
public SVGMatrix getTransformToElement(SVGElement element)
|
||||||
|
throws SVGException {
|
||||||
|
return SVGLocatableSupport.getTransformToElement(this, element);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SVGTransformable support //////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGTransformable#getTransform()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedTransformList getTransform() {
|
||||||
|
return transform;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SVGExternalResourcesRequired support /////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGExternalResourcesRequired#getExternalResourcesRequired()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedBoolean getExternalResourcesRequired() {
|
||||||
|
return externalResourcesRequired;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SVGLangSpace support //////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Returns the xml:lang attribute value.
|
||||||
|
*/
|
||||||
|
public String getXMLlang() {
|
||||||
|
return XMLSupport.getXMLLang(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Sets the xml:lang attribute value.
|
||||||
|
*/
|
||||||
|
public void setXMLlang(String lang) {
|
||||||
|
setAttributeNS(XML_NAMESPACE_URI, XML_LANG_QNAME, lang);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Returns the xml:space attribute value.
|
||||||
|
*/
|
||||||
|
public String getXMLspace() {
|
||||||
|
return XMLSupport.getXMLSpace(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Sets the xml:space attribute value.
|
||||||
|
*/
|
||||||
|
public void setXMLspace(String space) {
|
||||||
|
setAttributeNS(XML_NAMESPACE_URI, XML_SPACE_QNAME, space);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SVGTests support ///////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGTests#getRequiredFeatures()}.
|
||||||
|
*/
|
||||||
|
public SVGStringList getRequiredFeatures() {
|
||||||
|
return SVGTestsSupport.getRequiredFeatures(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGTests#getRequiredExtensions()}.
|
||||||
|
*/
|
||||||
|
public SVGStringList getRequiredExtensions() {
|
||||||
|
return SVGTestsSupport.getRequiredExtensions(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGTests#getSystemLanguage()}.
|
||||||
|
*/
|
||||||
|
public SVGStringList getSystemLanguage() {
|
||||||
|
return SVGTestsSupport.getSystemLanguage(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGTests#hasExtension(String)}.
|
||||||
|
*/
|
||||||
|
public boolean hasExtension(String extension) {
|
||||||
|
return SVGTestsSupport.hasExtension(this, extension);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SVGMotionAnimatableElement ////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link AffineTransform} representing the current motion
|
||||||
|
* animation for this element.
|
||||||
|
*/
|
||||||
|
public AffineTransform getMotionTransform() {
|
||||||
|
return motionTransform;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AnimationTarget ///////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a 'other' animation value in this target.
|
||||||
|
*/
|
||||||
|
public void updateOtherValue(String type, AnimatableValue val) {
|
||||||
|
if (type.equals("motion")) {
|
||||||
|
if (motionTransform == null) {
|
||||||
|
motionTransform = new AffineTransform();
|
||||||
|
}
|
||||||
|
if (val == null) {
|
||||||
|
motionTransform.setToIdentity();
|
||||||
|
} else {
|
||||||
|
AnimatableMotionPointValue p = (AnimatableMotionPointValue) val;
|
||||||
|
motionTransform.setToTranslation(p.getX(), p.getY());
|
||||||
|
motionTransform.rotate(p.getAngle());
|
||||||
|
}
|
||||||
|
SVGOMDocument d = (SVGOMDocument) ownerDocument;
|
||||||
|
d.getAnimatedAttributeListener().otherAnimationChanged(this, type);
|
||||||
|
} else {
|
||||||
|
super.updateOtherValue(type, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,185 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import java.awt.geom.AffineTransform;
|
||||||
|
import java.awt.geom.NoninvertibleTransformException;
|
||||||
|
|
||||||
|
import org.apache.batik.css.engine.SVGCSSEngine;
|
||||||
|
import org.apache.batik.dom.svg.AbstractSVGMatrix;
|
||||||
|
import org.apache.batik.dom.svg.SVGContext;
|
||||||
|
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.svg.SVGElement;
|
||||||
|
import org.w3c.dom.svg.SVGException;
|
||||||
|
import org.w3c.dom.svg.SVGFitToViewBox;
|
||||||
|
import org.w3c.dom.svg.SVGMatrix;
|
||||||
|
import org.w3c.dom.svg.SVGRect;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides support for the SVGLocatable interface.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGLocatableSupport.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGLocatableSupport {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGLocatable element.
|
||||||
|
*/
|
||||||
|
public SVGLocatableSupport() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To implement {@link
|
||||||
|
* org.w3c.dom.svg.SVGLocatable#getNearestViewportElement()}.
|
||||||
|
*/
|
||||||
|
public static SVGElement getNearestViewportElement(Element e) {
|
||||||
|
Element elt = e;
|
||||||
|
while (elt != null) {
|
||||||
|
elt = SVGCSSEngine.getParentCSSStylableElement(elt);
|
||||||
|
if (elt instanceof SVGFitToViewBox) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (SVGElement)elt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To implement {@link
|
||||||
|
* org.w3c.dom.svg.SVGLocatable#getFarthestViewportElement()}.
|
||||||
|
*/
|
||||||
|
public static SVGElement getFarthestViewportElement(Element elt) {
|
||||||
|
Element rootSVG = elt.getOwnerDocument().getDocumentElement();
|
||||||
|
if (elt == rootSVG) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return (SVGElement) rootSVG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To implement {@link org.w3c.dom.svg.SVGLocatable#getBBox()}.
|
||||||
|
*/
|
||||||
|
public static SVGRect getBBox(Element elt) {
|
||||||
|
final SVGOMElement svgelt = (SVGOMElement)elt;
|
||||||
|
SVGContext svgctx = svgelt.getSVGContext();
|
||||||
|
if (svgctx == null) return null;
|
||||||
|
if (svgctx.getBBox() == null) return null;
|
||||||
|
|
||||||
|
return new SVGRect() {
|
||||||
|
public float getX() {
|
||||||
|
return (float)svgelt.getSVGContext().getBBox().getX();
|
||||||
|
}
|
||||||
|
public void setX(float x) throws DOMException {
|
||||||
|
throw svgelt.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.rect", null);
|
||||||
|
}
|
||||||
|
public float getY() {
|
||||||
|
return (float)svgelt.getSVGContext().getBBox().getY();
|
||||||
|
}
|
||||||
|
public void setY(float y) throws DOMException {
|
||||||
|
throw svgelt.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.rect", null);
|
||||||
|
}
|
||||||
|
public float getWidth() {
|
||||||
|
return (float)svgelt.getSVGContext().getBBox().getWidth();
|
||||||
|
}
|
||||||
|
public void setWidth(float width) throws DOMException {
|
||||||
|
throw svgelt.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.rect", null);
|
||||||
|
}
|
||||||
|
public float getHeight() {
|
||||||
|
return (float)svgelt.getSVGContext().getBBox().getHeight();
|
||||||
|
}
|
||||||
|
public void setHeight(float height) throws DOMException {
|
||||||
|
throw svgelt.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.rect", null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To implement {@link org.w3c.dom.svg.SVGLocatable#getCTM()}.
|
||||||
|
*/
|
||||||
|
public static SVGMatrix getCTM(Element elt) {
|
||||||
|
final SVGOMElement svgelt = (SVGOMElement)elt;
|
||||||
|
return new AbstractSVGMatrix() {
|
||||||
|
protected AffineTransform getAffineTransform() {
|
||||||
|
return svgelt.getSVGContext().getCTM();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To implement {@link org.w3c.dom.svg.SVGLocatable#getScreenCTM()}.
|
||||||
|
*/
|
||||||
|
public static SVGMatrix getScreenCTM(Element elt) {
|
||||||
|
final SVGOMElement svgelt = (SVGOMElement)elt;
|
||||||
|
return new AbstractSVGMatrix() {
|
||||||
|
protected AffineTransform getAffineTransform() {
|
||||||
|
SVGContext context = svgelt.getSVGContext();
|
||||||
|
AffineTransform ret = context.getGlobalTransform();
|
||||||
|
AffineTransform scrnTrans = context.getScreenTransform();
|
||||||
|
if (scrnTrans != null)
|
||||||
|
ret.preConcatenate(scrnTrans);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To implement {@link
|
||||||
|
* org.w3c.dom.svg.SVGLocatable#getTransformToElement(SVGElement)}.
|
||||||
|
*/
|
||||||
|
public static SVGMatrix getTransformToElement(Element elt,
|
||||||
|
SVGElement element)
|
||||||
|
throws SVGException {
|
||||||
|
final SVGOMElement currentElt = (SVGOMElement)elt;
|
||||||
|
final SVGOMElement targetElt = (SVGOMElement)element;
|
||||||
|
return new AbstractSVGMatrix() {
|
||||||
|
protected AffineTransform getAffineTransform() {
|
||||||
|
AffineTransform cat =
|
||||||
|
currentElt.getSVGContext().getGlobalTransform();
|
||||||
|
if (cat == null) {
|
||||||
|
cat = new AffineTransform();
|
||||||
|
}
|
||||||
|
AffineTransform tat =
|
||||||
|
targetElt.getSVGContext().getGlobalTransform();
|
||||||
|
if (tat == null) {
|
||||||
|
tat = new AffineTransform();
|
||||||
|
}
|
||||||
|
AffineTransform at = new AffineTransform(cat);
|
||||||
|
try {
|
||||||
|
at.preConcatenate(tat.createInverse());
|
||||||
|
return at;
|
||||||
|
} catch (NoninvertibleTransformException ex) {
|
||||||
|
throw currentElt.createSVGException
|
||||||
|
(SVGException.SVG_MATRIX_NOT_INVERTABLE,
|
||||||
|
"noninvertiblematrix",
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,141 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.dom.util.XLinkSupport;
|
||||||
|
import org.apache.batik.dom.util.XMLSupport;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAElement;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGAElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMAElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMAElement
|
||||||
|
extends SVGURIReferenceGraphicsElement
|
||||||
|
implements SVGAElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attribute initializer.
|
||||||
|
*/
|
||||||
|
protected static final AttributeInitializer attributeInitializer;
|
||||||
|
static {
|
||||||
|
attributeInitializer = new AttributeInitializer(4);
|
||||||
|
attributeInitializer.addAttribute(XMLSupport.XMLNS_NAMESPACE_URI,
|
||||||
|
null, "xmlns:xlink",
|
||||||
|
XLinkSupport.XLINK_NAMESPACE_URI);
|
||||||
|
attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
|
||||||
|
"xlink", "type", "simple");
|
||||||
|
attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
|
||||||
|
"xlink", "show", "replace");
|
||||||
|
attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
|
||||||
|
"xlink", "actuate", "onRequest");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGURIReferenceGraphicsElement.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_TARGET_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_CDATA));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'target' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMAElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMAElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
target = createLiveAnimatedString(null, SVG_TARGET_ATTRIBUTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_A_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAElement#getTarget()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getTarget() {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the AttributeInitializer for this element type.
|
||||||
|
* @return null if this element has no attribute with a default value.
|
||||||
|
*/
|
||||||
|
protected AttributeInitializer getAttributeInitializer() {
|
||||||
|
return attributeInitializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMAElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAltGlyphDefElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGAltGlyphDefElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMAltGlyphDefElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMAltGlyphDefElement
|
||||||
|
extends SVGOMElement
|
||||||
|
implements SVGAltGlyphDefElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAltGlyphDefElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMAltGlyphDefElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAltGlyphDefElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMAltGlyphDefElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_ALT_GLYPH_DEF_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMAltGlyphDefElement();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,141 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.dom.util.XLinkSupport;
|
||||||
|
import org.apache.batik.dom.util.XMLSupport;
|
||||||
|
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAltGlyphElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGAltGlyphElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMAltGlyphElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMAltGlyphElement
|
||||||
|
extends SVGURIReferenceTextPositioningElement
|
||||||
|
implements SVGAltGlyphElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attribute initializer.
|
||||||
|
*/
|
||||||
|
protected static final AttributeInitializer attributeInitializer;
|
||||||
|
static {
|
||||||
|
attributeInitializer = new AttributeInitializer(4);
|
||||||
|
attributeInitializer.addAttribute(XMLSupport.XMLNS_NAMESPACE_URI,
|
||||||
|
null, "xmlns:xlink",
|
||||||
|
XLinkSupport.XLINK_NAMESPACE_URI);
|
||||||
|
attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
|
||||||
|
"xlink", "type", "simple");
|
||||||
|
attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
|
||||||
|
"xlink", "show", "other");
|
||||||
|
attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
|
||||||
|
"xlink", "actuate", "onLoad");
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
// */
|
||||||
|
// protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
// static {
|
||||||
|
// DoublyIndexedTable t =
|
||||||
|
// new DoublyIndexedTable(SVGURIReferenceTextPositioningElement.xmlTraitInformation);
|
||||||
|
// t.put(null, SVG_FORMAT_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_GLYPH_REF_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// xmlTraitInformation = t;
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAltGlyphElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMAltGlyphElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAltGlyphElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMAltGlyphElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_ALT_GLYPH_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAltGlyphElement#getGlyphRef()}.
|
||||||
|
*/
|
||||||
|
public String getGlyphRef() {
|
||||||
|
return getAttributeNS(null, SVG_GLYPH_REF_ATTRIBUTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAltGlyphElement#setGlyphRef(String)}.
|
||||||
|
*/
|
||||||
|
public void setGlyphRef(String glyphRef) throws DOMException {
|
||||||
|
setAttributeNS(null, SVG_GLYPH_REF_ATTRIBUTE, glyphRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAltGlyphElement#getFormat()}.
|
||||||
|
*/
|
||||||
|
public String getFormat() {
|
||||||
|
return getAttributeNS(null, SVG_FORMAT_ATTRIBUTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAltGlyphElement#setFormat(String)}.
|
||||||
|
*/
|
||||||
|
public void setFormat(String format) throws DOMException {
|
||||||
|
setAttributeNS(null, SVG_FORMAT_ATTRIBUTE, format);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the AttributeInitializer for this element type.
|
||||||
|
* @return null if this element has no attribute with a default value.
|
||||||
|
*/
|
||||||
|
protected AttributeInitializer getAttributeInitializer() {
|
||||||
|
return attributeInitializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMAltGlyphElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Returns the table of TraitInformation objects for this element.
|
||||||
|
// */
|
||||||
|
// protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
// return xmlTraitInformation;
|
||||||
|
// }
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAltGlyphItemElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGAltGlyphItemElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMAltGlyphItemElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMAltGlyphItemElement
|
||||||
|
extends SVGOMElement
|
||||||
|
implements SVGAltGlyphItemElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAltGlyphItemElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMAltGlyphItemElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAltGlyphItemElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMAltGlyphItemElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_ALT_GLYPH_ITEM_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMAltGlyphItemElement();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,121 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimateColorElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGAnimateColorElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMAnimateColorElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMAnimateColorElement
|
||||||
|
extends SVGOMAnimationElement
|
||||||
|
implements SVGAnimateColorElement {
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
// */
|
||||||
|
// protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
// static {
|
||||||
|
// DoublyIndexedTable t =
|
||||||
|
// new DoublyIndexedTable(SVGOMAnimationElement.xmlTraitInformation);
|
||||||
|
// t.put(null, SVG_ACCUMULATE_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_ADDITIVE_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_ATTRIBUTE_TYPE_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_CALC_MODE_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_FILL_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_RESTART_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_ATTRIBUTE_NAME_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_BY_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_FROM_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_MAX_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_MIN_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_TO_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_VALUES_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_BEGIN_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_TIMING_SPECIFIER_LIST));
|
||||||
|
// t.put(null, SVG_END_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_TIMING_SPECIFIER_LIST));
|
||||||
|
// t.put(null, SVG_DUR_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_TIME));
|
||||||
|
// t.put(null, SVG_REPEAT_DUR_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_TIME));
|
||||||
|
// t.put(null, SVG_KEY_SPLINES_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_NUMBER_LIST));
|
||||||
|
// t.put(null, SVG_KEY_TIMES_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_NUMBER_LIST));
|
||||||
|
// t.put(null, SVG_REPEAT_COUNT_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_INTEGER));
|
||||||
|
// xmlTraitInformation = t;
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimateColorElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimateColorElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimateColorElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMAnimateColorElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_ANIMATE_COLOR_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMAnimateColorElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Returns the table of TraitInformation objects for this element.
|
||||||
|
// */
|
||||||
|
// protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
// return xmlTraitInformation;
|
||||||
|
// }
|
||||||
|
}
|
|
@ -0,0 +1,121 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimateElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGAnimateElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMAnimateElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMAnimateElement
|
||||||
|
extends SVGOMAnimationElement
|
||||||
|
implements SVGAnimateElement {
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
// */
|
||||||
|
// protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
// static {
|
||||||
|
// DoublyIndexedTable t =
|
||||||
|
// new DoublyIndexedTable(SVGOMAnimationElement.xmlTraitInformation);
|
||||||
|
// t.put(null, SVG_ACCUMULATE_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_ADDITIVE_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_ATTRIBUTE_TYPE_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_CALC_MODE_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_FILL_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_RESTART_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_ATTRIBUTE_NAME_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_BY_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_FROM_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_MAX_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_MIN_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_TO_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_VALUES_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_BEGIN_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_TIMING_SPECIFIER_LIST));
|
||||||
|
// t.put(null, SVG_END_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_TIMING_SPECIFIER_LIST));
|
||||||
|
// t.put(null, SVG_DUR_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_TIME));
|
||||||
|
// t.put(null, SVG_REPEAT_DUR_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_TIME));
|
||||||
|
// t.put(null, SVG_KEY_SPLINES_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_NUMBER_LIST));
|
||||||
|
// t.put(null, SVG_KEY_TIMES_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_NUMBER_LIST));
|
||||||
|
// t.put(null, SVG_REPEAT_COUNT_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_INTEGER));
|
||||||
|
// xmlTraitInformation = t;
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimateElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimateElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimateElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMAnimateElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_ANIMATE_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMAnimateElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Returns the table of TraitInformation objects for this element.
|
||||||
|
// */
|
||||||
|
// protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
// return xmlTraitInformation;
|
||||||
|
// }
|
||||||
|
}
|
|
@ -0,0 +1,149 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimateMotionElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGAnimateMotionElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMAnimateMotionElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMAnimateMotionElement
|
||||||
|
extends SVGOMAnimationElement
|
||||||
|
implements SVGAnimateMotionElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attribute initializer.
|
||||||
|
*/
|
||||||
|
protected static final AttributeInitializer attributeInitializer;
|
||||||
|
static {
|
||||||
|
attributeInitializer = new AttributeInitializer(1);
|
||||||
|
attributeInitializer.addAttribute(null,
|
||||||
|
null,
|
||||||
|
SVG_CALC_MODE_ATTRIBUTE,
|
||||||
|
SVG_PACED_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
// */
|
||||||
|
// protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
// static {
|
||||||
|
// DoublyIndexedTable t =
|
||||||
|
// new DoublyIndexedTable(SVGOMAnimationElement.xmlTraitInformation);
|
||||||
|
// t.put(null, SVG_ACCUMULATE_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_ADDITIVE_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_ATTRIBUTE_TYPE_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_CALC_MODE_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_FILL_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_ORIGIN_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_RESTART_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_ATTRIBUTE_NAME_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_BY_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_FROM_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_MAX_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_MIN_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_TO_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_VALUES_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_BEGIN_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_TIMING_SPECIFIER_LIST));
|
||||||
|
// t.put(null, SVG_END_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_TIMING_SPECIFIER_LIST));
|
||||||
|
// t.put(null, SVG_DUR_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_TIME));
|
||||||
|
// t.put(null, SVG_REPEAT_DUR_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_TIME));
|
||||||
|
// t.put(null, SVG_KEY_POINTS_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_NUMBER_LIST));
|
||||||
|
// t.put(null, SVG_KEY_SPLINES_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_NUMBER_LIST));
|
||||||
|
// t.put(null, SVG_KEY_TIMES_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_NUMBER_LIST));
|
||||||
|
// t.put(null, SVG_ROTATE_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_ANGLE_OR_IDENT));
|
||||||
|
// t.put(null, SVG_REPEAT_COUNT_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_INTEGER));
|
||||||
|
// t.put(null, SVG_D_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_PATH_DATA));
|
||||||
|
// xmlTraitInformation = t;
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimateMotionElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimateMotionElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimateMotionElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMAnimateMotionElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_ANIMATE_MOTION_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the AttributeInitializer for this element type.
|
||||||
|
* @return null if this element has no attribute with a default value.
|
||||||
|
*/
|
||||||
|
protected AttributeInitializer getAttributeInitializer() {
|
||||||
|
return attributeInitializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMAnimateMotionElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Returns the table of TraitInformation objects for this element.
|
||||||
|
// */
|
||||||
|
// protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
// return xmlTraitInformation;
|
||||||
|
// }
|
||||||
|
}
|
|
@ -0,0 +1,142 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimateTransformElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGAnimateTransformElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMAnimateTransformElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMAnimateTransformElement
|
||||||
|
extends SVGOMAnimationElement
|
||||||
|
implements SVGAnimateTransformElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attribute initializer.
|
||||||
|
*/
|
||||||
|
protected static final AttributeInitializer attributeInitializer;
|
||||||
|
static {
|
||||||
|
attributeInitializer = new AttributeInitializer(1);
|
||||||
|
attributeInitializer.addAttribute(null,
|
||||||
|
null,
|
||||||
|
SVG_TYPE_ATTRIBUTE,
|
||||||
|
SVG_TRANSLATE_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
// */
|
||||||
|
// protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
// static {
|
||||||
|
// DoublyIndexedTable t =
|
||||||
|
// new DoublyIndexedTable(SVGOMAnimationElement.xmlTraitInformation);
|
||||||
|
// t.put(null, SVG_ACCUMULATE_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_ADDITIVE_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_ATTRIBUTE_TYPE_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_CALC_MODE_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_FILL_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_RESTART_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// t.put(null, SVG_ATTRIBUTE_NAME_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_BY_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_FROM_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_MAX_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_MIN_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_TO_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_VALUES_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_BEGIN_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_TIMING_SPECIFIER_LIST));
|
||||||
|
// t.put(null, SVG_END_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_TIMING_SPECIFIER_LIST));
|
||||||
|
// t.put(null, SVG_DUR_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_TIME));
|
||||||
|
// t.put(null, SVG_REPEAT_DUR_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_TIME));
|
||||||
|
// t.put(null, SVG_KEY_SPLINES_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_NUMBER_LIST));
|
||||||
|
// t.put(null, SVG_KEY_TIMES_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_NUMBER_LIST));
|
||||||
|
// t.put(null, SVG_REPEAT_COUNT_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_INTEGER));
|
||||||
|
// xmlTraitInformation = t;
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimateTransformElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimateTransformElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimateTransformElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMAnimateTransformElement(String prefix,
|
||||||
|
AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_ANIMATE_TRANSFORM_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the AttributeInitializer for this element type.
|
||||||
|
* @return null if this element has no attribute with a default value.
|
||||||
|
*/
|
||||||
|
protected AttributeInitializer getAttributeInitializer() {
|
||||||
|
return attributeInitializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMAnimateTransformElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Returns the table of TraitInformation objects for this element.
|
||||||
|
// */
|
||||||
|
// protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
// return xmlTraitInformation;
|
||||||
|
// }
|
||||||
|
}
|
|
@ -0,0 +1,196 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatableBooleanValue;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedBoolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements the {@link SVGAnimatedBoolean} interface.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMAnimatedBoolean.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMAnimatedBoolean
|
||||||
|
extends AbstractSVGAnimatedValue
|
||||||
|
implements SVGAnimatedBoolean {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default value.
|
||||||
|
*/
|
||||||
|
protected boolean defaultValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the base value is valid.
|
||||||
|
*/
|
||||||
|
protected boolean valid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current base value.
|
||||||
|
*/
|
||||||
|
protected boolean baseVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current animated value.
|
||||||
|
*/
|
||||||
|
protected boolean animVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the value is changing.
|
||||||
|
*/
|
||||||
|
protected boolean changing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimatedBoolean.
|
||||||
|
* @param elt The associated element.
|
||||||
|
* @param ns The attribute's namespace URI.
|
||||||
|
* @param ln The attribute's local name.
|
||||||
|
* @param val The default value, if the attribute is not specified.
|
||||||
|
*/
|
||||||
|
public SVGOMAnimatedBoolean(AbstractElement elt,
|
||||||
|
String ns,
|
||||||
|
String ln,
|
||||||
|
boolean val) {
|
||||||
|
super(elt, ns, ln);
|
||||||
|
defaultValue = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedBoolean#getBaseVal()}.
|
||||||
|
*/
|
||||||
|
public boolean getBaseVal() {
|
||||||
|
if (!valid) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
return baseVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the base value from the attribute.
|
||||||
|
*/
|
||||||
|
protected void update() {
|
||||||
|
Attr attr = element.getAttributeNodeNS(namespaceURI, localName);
|
||||||
|
if (attr == null) {
|
||||||
|
baseVal = defaultValue;
|
||||||
|
} else {
|
||||||
|
baseVal = attr.getValue().equals("true");
|
||||||
|
}
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedBoolean#setBaseVal(boolean)}.
|
||||||
|
*/
|
||||||
|
public void setBaseVal(boolean baseVal) throws DOMException {
|
||||||
|
try {
|
||||||
|
this.baseVal = baseVal;
|
||||||
|
valid = true;
|
||||||
|
changing = true;
|
||||||
|
element.setAttributeNS(namespaceURI, localName,
|
||||||
|
String.valueOf(baseVal));
|
||||||
|
} finally {
|
||||||
|
changing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedBoolean#getAnimVal()}.
|
||||||
|
*/
|
||||||
|
public boolean getAnimVal() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return animVal;
|
||||||
|
}
|
||||||
|
if (!valid) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
return baseVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the animated value.
|
||||||
|
*/
|
||||||
|
public void setAnimatedValue(boolean animVal) {
|
||||||
|
hasAnimVal = true;
|
||||||
|
this.animVal = animVal;
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the animated value with the given {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
protected void updateAnimatedValue(AnimatableValue val) {
|
||||||
|
if (val == null) {
|
||||||
|
hasAnimVal = false;
|
||||||
|
} else {
|
||||||
|
hasAnimVal = true;
|
||||||
|
this.animVal = ((AnimatableBooleanValue) val).getValue();
|
||||||
|
}
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the base value of the attribute as an {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
public AnimatableValue getUnderlyingValue(AnimationTarget target) {
|
||||||
|
return new AnimatableBooleanValue(target, getBaseVal());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been added.
|
||||||
|
*/
|
||||||
|
public void attrAdded(Attr node, String newv) {
|
||||||
|
if (!changing) {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been modified.
|
||||||
|
*/
|
||||||
|
public void attrModified(Attr node, String oldv, String newv) {
|
||||||
|
if (!changing) {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been removed.
|
||||||
|
*/
|
||||||
|
public void attrRemoved(Attr node, String oldv) {
|
||||||
|
if (!changing) {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,243 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatableStringValue;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
import org.apache.batik.dom.svg.LiveAttributeException;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedEnumeration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides an implementation of the {@link
|
||||||
|
* SVGAnimatedEnumeration} interface.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMAnimatedEnumeration.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMAnimatedEnumeration extends AbstractSVGAnimatedValue
|
||||||
|
implements SVGAnimatedEnumeration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The values in this enumeration.
|
||||||
|
*/
|
||||||
|
protected String[] values;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default value, if the attribute is not specified.
|
||||||
|
*/
|
||||||
|
protected short defaultValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the current base value is valid.
|
||||||
|
*/
|
||||||
|
protected boolean valid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current base value.
|
||||||
|
*/
|
||||||
|
protected short baseVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current animated value.
|
||||||
|
*/
|
||||||
|
protected short animVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the value is changing.
|
||||||
|
*/
|
||||||
|
protected boolean changing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimatedEnumeration.
|
||||||
|
* @param elt The associated element.
|
||||||
|
* @param ns The attribute's namespace URI.
|
||||||
|
* @param ln The attribute's local name.
|
||||||
|
* @param val The values in this enumeration.
|
||||||
|
* @param def The default value to use.
|
||||||
|
*/
|
||||||
|
public SVGOMAnimatedEnumeration(AbstractElement elt,
|
||||||
|
String ns,
|
||||||
|
String ln,
|
||||||
|
String[] val,
|
||||||
|
short def) {
|
||||||
|
super(elt, ns, ln);
|
||||||
|
values = val;
|
||||||
|
defaultValue = def;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedEnumeration#getBaseVal()}.
|
||||||
|
*/
|
||||||
|
public short getBaseVal() {
|
||||||
|
if (!valid) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
return baseVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the base value as a string.
|
||||||
|
*/
|
||||||
|
public String getBaseValAsString() {
|
||||||
|
if (!valid) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
return values[baseVal];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the base value from the attribute.
|
||||||
|
*/
|
||||||
|
protected void update() {
|
||||||
|
String val = element.getAttributeNS(namespaceURI, localName);
|
||||||
|
if (val.length() == 0) {
|
||||||
|
baseVal = defaultValue;
|
||||||
|
} else {
|
||||||
|
baseVal = getEnumerationNumber(val);
|
||||||
|
}
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the enumeration number of the specified string.
|
||||||
|
*/
|
||||||
|
protected short getEnumerationNumber(String s) {
|
||||||
|
for (short i = 0; i < values.length; i++) {
|
||||||
|
if (s.equals(values[i])) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGAnimatedEnumeration#setBaseVal(short)}.
|
||||||
|
*/
|
||||||
|
public void setBaseVal(short baseVal) throws DOMException {
|
||||||
|
if (baseVal >= 0 && baseVal < values.length) {
|
||||||
|
try {
|
||||||
|
this.baseVal = baseVal;
|
||||||
|
valid = true;
|
||||||
|
changing = true;
|
||||||
|
element.setAttributeNS(namespaceURI, localName,
|
||||||
|
values[baseVal]);
|
||||||
|
} finally {
|
||||||
|
changing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedEnumeration#getAnimVal()}.
|
||||||
|
*/
|
||||||
|
public short getAnimVal() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return animVal;
|
||||||
|
}
|
||||||
|
if (!valid) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
return baseVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current animated value, throwing an exception if the attribute
|
||||||
|
* is malformed.
|
||||||
|
*/
|
||||||
|
public short getCheckedVal() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return animVal;
|
||||||
|
}
|
||||||
|
if (!valid) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
if (baseVal == 0) {
|
||||||
|
throw new LiveAttributeException
|
||||||
|
(element, localName,
|
||||||
|
LiveAttributeException.ERR_ATTRIBUTE_MALFORMED,
|
||||||
|
getBaseValAsString());
|
||||||
|
}
|
||||||
|
return baseVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the base value of the attribute as an {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
public AnimatableValue getUnderlyingValue(AnimationTarget target) {
|
||||||
|
return new AnimatableStringValue(target, getBaseValAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been added.
|
||||||
|
*/
|
||||||
|
public void attrAdded(Attr node, String newv) {
|
||||||
|
if (!changing) {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the animated value with the given {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
protected void updateAnimatedValue(AnimatableValue val) {
|
||||||
|
if (val == null) {
|
||||||
|
hasAnimVal = false;
|
||||||
|
} else {
|
||||||
|
hasAnimVal = true;
|
||||||
|
this.animVal =
|
||||||
|
getEnumerationNumber(((AnimatableStringValue) val).getString());
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been modified.
|
||||||
|
*/
|
||||||
|
public void attrModified(Attr node, String oldv, String newv) {
|
||||||
|
if (!changing) {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been removed.
|
||||||
|
*/
|
||||||
|
public void attrRemoved(Attr node, String oldv) {
|
||||||
|
if (!changing) {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,187 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatableIntegerValue;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedInteger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements the {@link SVGAnimatedInteger} interface.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMAnimatedInteger.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMAnimatedInteger
|
||||||
|
extends AbstractSVGAnimatedValue
|
||||||
|
implements SVGAnimatedInteger {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default value.
|
||||||
|
*/
|
||||||
|
protected int defaultValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the base value is valid.
|
||||||
|
*/
|
||||||
|
protected boolean valid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current base value.
|
||||||
|
*/
|
||||||
|
protected int baseVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current animated value.
|
||||||
|
*/
|
||||||
|
protected int animVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the value is changing.
|
||||||
|
*/
|
||||||
|
protected boolean changing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimatedInteger.
|
||||||
|
* @param elt The associated element.
|
||||||
|
* @param ns The attribute's namespace URI.
|
||||||
|
* @param ln The attribute's local name.
|
||||||
|
* @param val The default value, if the attribute is not specified.
|
||||||
|
*/
|
||||||
|
public SVGOMAnimatedInteger(AbstractElement elt,
|
||||||
|
String ns,
|
||||||
|
String ln,
|
||||||
|
int val) {
|
||||||
|
super(elt, ns, ln);
|
||||||
|
defaultValue = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedInteger#getBaseVal()}.
|
||||||
|
*/
|
||||||
|
public int getBaseVal() {
|
||||||
|
if (!valid) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
return baseVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the base value from the attribute.
|
||||||
|
*/
|
||||||
|
protected void update() {
|
||||||
|
Attr attr = element.getAttributeNodeNS(namespaceURI, localName);
|
||||||
|
if (attr == null) {
|
||||||
|
baseVal = defaultValue;
|
||||||
|
} else {
|
||||||
|
baseVal = Integer.parseInt(attr.getValue());
|
||||||
|
}
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedInteger#setBaseVal(int)}.
|
||||||
|
*/
|
||||||
|
public void setBaseVal(int baseVal) throws DOMException {
|
||||||
|
try {
|
||||||
|
this.baseVal = baseVal;
|
||||||
|
valid = true;
|
||||||
|
changing = true;
|
||||||
|
element.setAttributeNS(namespaceURI, localName,
|
||||||
|
String.valueOf(baseVal));
|
||||||
|
} finally {
|
||||||
|
changing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedInteger#getAnimVal()}.
|
||||||
|
*/
|
||||||
|
public int getAnimVal() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return animVal;
|
||||||
|
}
|
||||||
|
if (!valid) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
return baseVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the base value of the attribute as an {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
public AnimatableValue getUnderlyingValue(AnimationTarget target) {
|
||||||
|
return new AnimatableIntegerValue(target, getBaseVal());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the animated value with the given {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
protected void updateAnimatedValue(AnimatableValue val) {
|
||||||
|
if (val == null) {
|
||||||
|
hasAnimVal = false;
|
||||||
|
} else {
|
||||||
|
hasAnimVal = true;
|
||||||
|
this.animVal = ((AnimatableIntegerValue) val).getValue();
|
||||||
|
}
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been added.
|
||||||
|
*/
|
||||||
|
public void attrAdded(Attr node, String newv) {
|
||||||
|
if (!changing) {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been modified.
|
||||||
|
*/
|
||||||
|
public void attrModified(Attr node, String oldv, String newv) {
|
||||||
|
if (!changing) {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been removed.
|
||||||
|
*/
|
||||||
|
public void attrRemoved(Attr node, String oldv) {
|
||||||
|
if (!changing) {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides an implementation of the {@link
|
||||||
|
* org.w3c.dom.svg.SVGAnimatedLength} interface.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMAnimatedLength.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMAnimatedLength extends AbstractSVGAnimatedLength {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default value if the attribute is not specified.
|
||||||
|
*/
|
||||||
|
protected String defaultValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimatedLength.
|
||||||
|
* @param elt The associated element.
|
||||||
|
* @param ns The attribute's namespace URI.
|
||||||
|
* @param ln The attribute's local name.
|
||||||
|
* @param def The default value if the attribute is not specified.
|
||||||
|
* @param dir The length's direction.
|
||||||
|
* @param nonneg Whether the length must be non-negative.
|
||||||
|
*/
|
||||||
|
public SVGOMAnimatedLength(AbstractElement elt,
|
||||||
|
String ns,
|
||||||
|
String ln,
|
||||||
|
String def,
|
||||||
|
short dir,
|
||||||
|
boolean nonneg) {
|
||||||
|
super(elt, ns, ln, dir, nonneg);
|
||||||
|
defaultValue = def;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the default value to use when the associated attribute
|
||||||
|
* was not specified.
|
||||||
|
*/
|
||||||
|
protected String getDefaultValue() {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,536 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedLengthList;
|
||||||
|
import org.w3c.dom.svg.SVGException;
|
||||||
|
import org.w3c.dom.svg.SVGLength;
|
||||||
|
import org.w3c.dom.svg.SVGLengthList;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatableLengthListValue;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
import org.apache.batik.dom.svg.ListBuilder;
|
||||||
|
import org.apache.batik.dom.svg.LiveAttributeException;
|
||||||
|
import org.apache.batik.dom.svg.SVGItem;
|
||||||
|
import org.apache.batik.parser.ParseException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is the implementation of the {@link SVGAnimatedLengthList}
|
||||||
|
* interface.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:nicolas.socheleau@bitflash.com">Nicolas Socheleau</a>
|
||||||
|
* @version $Id: SVGOMAnimatedLengthList.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMAnimatedLengthList
|
||||||
|
extends AbstractSVGAnimatedValue
|
||||||
|
implements SVGAnimatedLengthList {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base value.
|
||||||
|
*/
|
||||||
|
protected BaseSVGLengthList baseVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The animated value.
|
||||||
|
*/
|
||||||
|
protected AnimSVGLengthList animVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the list is changing.
|
||||||
|
*/
|
||||||
|
protected boolean changing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default value for the length list.
|
||||||
|
*/
|
||||||
|
protected String defaultValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether empty length lists are allowed.
|
||||||
|
*/
|
||||||
|
protected boolean emptyAllowed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The direction of the lengths in this list.
|
||||||
|
*/
|
||||||
|
protected short direction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimatedLengthList.
|
||||||
|
* @param elt The associated element.
|
||||||
|
* @param ns The attribute's namespace URI.
|
||||||
|
* @param ln The attribute's local name.
|
||||||
|
* @param defaultValue The default value if the attribute is not specified.
|
||||||
|
* @param emptyAllowed Whether a list with no items is allowed.
|
||||||
|
* @param direction The direction of the lengths in the list.
|
||||||
|
*/
|
||||||
|
public SVGOMAnimatedLengthList(AbstractElement elt,
|
||||||
|
String ns,
|
||||||
|
String ln,
|
||||||
|
String defaultValue,
|
||||||
|
boolean emptyAllowed,
|
||||||
|
short direction) {
|
||||||
|
super(elt, ns, ln);
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
this.emptyAllowed = emptyAllowed;
|
||||||
|
this.direction = direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedLengthList#getBaseVal()}.
|
||||||
|
*/
|
||||||
|
public SVGLengthList getBaseVal() {
|
||||||
|
if (baseVal == null) {
|
||||||
|
baseVal = new BaseSVGLengthList();
|
||||||
|
}
|
||||||
|
return baseVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedLengthList#getAnimVal()}.
|
||||||
|
*/
|
||||||
|
public SVGLengthList getAnimVal() {
|
||||||
|
if (animVal == null) {
|
||||||
|
animVal = new AnimSVGLengthList();
|
||||||
|
}
|
||||||
|
return animVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throws an exception if the length list value is malformed.
|
||||||
|
*/
|
||||||
|
public void check() {
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
if (baseVal == null) {
|
||||||
|
baseVal = new BaseSVGLengthList();
|
||||||
|
}
|
||||||
|
baseVal.revalidate();
|
||||||
|
if (baseVal.missing) {
|
||||||
|
throw new LiveAttributeException
|
||||||
|
(element, localName,
|
||||||
|
LiveAttributeException.ERR_ATTRIBUTE_MISSING, null);
|
||||||
|
}
|
||||||
|
if (baseVal.malformed) {
|
||||||
|
throw new LiveAttributeException
|
||||||
|
(element, localName,
|
||||||
|
LiveAttributeException.ERR_ATTRIBUTE_MALFORMED,
|
||||||
|
baseVal.getValueAsString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the base value of the attribute as an {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
public AnimatableValue getUnderlyingValue(AnimationTarget target) {
|
||||||
|
SVGLengthList ll = getBaseVal();
|
||||||
|
int n = ll.getNumberOfItems();
|
||||||
|
short[] types = new short[n];
|
||||||
|
float[] values = new float[n];
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
SVGLength l = ll.getItem(i);
|
||||||
|
types[i] = l.getUnitType();
|
||||||
|
values[i] = l.getValueInSpecifiedUnits();
|
||||||
|
}
|
||||||
|
return new AnimatableLengthListValue
|
||||||
|
(target, types, values,
|
||||||
|
target.getPercentageInterpretation
|
||||||
|
(getNamespaceURI(), getLocalName(), false));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the animated value with the given {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
protected void updateAnimatedValue(AnimatableValue val) {
|
||||||
|
if (val == null) {
|
||||||
|
hasAnimVal = false;
|
||||||
|
} else {
|
||||||
|
hasAnimVal = true;
|
||||||
|
AnimatableLengthListValue animLengths =
|
||||||
|
(AnimatableLengthListValue) val;
|
||||||
|
if (animVal == null) {
|
||||||
|
animVal = new AnimSVGLengthList();
|
||||||
|
}
|
||||||
|
animVal.setAnimatedValue(animLengths.getLengthTypes(),
|
||||||
|
animLengths.getLengthValues());
|
||||||
|
}
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been added.
|
||||||
|
*/
|
||||||
|
public void attrAdded(Attr node, String newv) {
|
||||||
|
if (!changing && baseVal != null) {
|
||||||
|
baseVal.invalidate();
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been modified.
|
||||||
|
*/
|
||||||
|
public void attrModified(Attr node, String oldv, String newv) {
|
||||||
|
if (!changing && baseVal != null) {
|
||||||
|
baseVal.invalidate();
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been removed.
|
||||||
|
*/
|
||||||
|
public void attrRemoved(Attr node, String oldv) {
|
||||||
|
if (!changing && baseVal != null) {
|
||||||
|
baseVal.invalidate();
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link SVGLengthList} implementation for the base length list value.
|
||||||
|
*/
|
||||||
|
public class BaseSVGLengthList extends AbstractSVGLengthList {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the value is missing.
|
||||||
|
*/
|
||||||
|
protected boolean missing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the value is malformed.
|
||||||
|
*/
|
||||||
|
protected boolean malformed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new BaseSVGLengthList.
|
||||||
|
*/
|
||||||
|
public BaseSVGLengthList() {
|
||||||
|
super(SVGOMAnimatedLengthList.this.direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a DOMException.
|
||||||
|
*/
|
||||||
|
protected DOMException createDOMException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
return element.createDOMException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a SVGException.
|
||||||
|
*/
|
||||||
|
protected SVGException createSVGException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
|
||||||
|
return ((SVGOMElement)element).createSVGException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the element owning the attribute with which this length
|
||||||
|
* list is associated.
|
||||||
|
*/
|
||||||
|
protected Element getElement() {
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the DOM attribute containing the length list.
|
||||||
|
*/
|
||||||
|
protected String getValueAsString() {
|
||||||
|
Attr attr = element.getAttributeNodeNS(namespaceURI, localName);
|
||||||
|
if (attr == null) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
return attr.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the DOM attribute value containing the length list.
|
||||||
|
*/
|
||||||
|
protected void setAttributeValue(String value) {
|
||||||
|
try {
|
||||||
|
changing = true;
|
||||||
|
element.setAttributeNS(namespaceURI, localName, value);
|
||||||
|
} finally {
|
||||||
|
changing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the value of the associated attribute.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute() {
|
||||||
|
super.resetAttribute();
|
||||||
|
missing = false;
|
||||||
|
malformed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends the string representation of the given {@link SVGItem} to
|
||||||
|
* the DOM attribute. This is called in response to an append to
|
||||||
|
* the list.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute(SVGItem item) {
|
||||||
|
super.resetAttribute(item);
|
||||||
|
missing = false;
|
||||||
|
malformed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the list, if needed.
|
||||||
|
*/
|
||||||
|
protected void revalidate() {
|
||||||
|
if (valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
valid = true;
|
||||||
|
missing = false;
|
||||||
|
malformed = false;
|
||||||
|
|
||||||
|
String s = getValueAsString();
|
||||||
|
boolean isEmpty = s != null && s.length() == 0;
|
||||||
|
if (s == null || isEmpty && !emptyAllowed) {
|
||||||
|
missing = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isEmpty) {
|
||||||
|
itemList = new ArrayList(1);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
ListBuilder builder = new ListBuilder(this);
|
||||||
|
|
||||||
|
doParse(s, builder);
|
||||||
|
|
||||||
|
if (builder.getList() != null) {
|
||||||
|
clear(itemList);
|
||||||
|
}
|
||||||
|
itemList = builder.getList();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
itemList = new ArrayList(1);
|
||||||
|
valid = true;
|
||||||
|
malformed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link SVGLengthList} implementation for the animated length list value.
|
||||||
|
*/
|
||||||
|
protected class AnimSVGLengthList extends AbstractSVGLengthList {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new AnimSVGLengthList.
|
||||||
|
*/
|
||||||
|
public AnimSVGLengthList() {
|
||||||
|
super(SVGOMAnimatedLengthList.this.direction);
|
||||||
|
itemList = new ArrayList(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a DOMException.
|
||||||
|
*/
|
||||||
|
protected DOMException createDOMException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
return element.createDOMException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a SVGException.
|
||||||
|
*/
|
||||||
|
protected SVGException createSVGException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
|
||||||
|
return ((SVGOMElement)element).createSVGException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the element owning this SVGLengthList.
|
||||||
|
*/
|
||||||
|
protected Element getElement() {
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLengthList#getNumberOfItems()}.
|
||||||
|
*/
|
||||||
|
public int getNumberOfItems() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getNumberOfItems();
|
||||||
|
}
|
||||||
|
return getBaseVal().getNumberOfItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLengthList#getItem(int)}.
|
||||||
|
*/
|
||||||
|
public SVGLength getItem(int index) throws DOMException {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getItem(index);
|
||||||
|
}
|
||||||
|
return getBaseVal().getItem(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the DOM attribute containing the point list.
|
||||||
|
*/
|
||||||
|
protected String getValueAsString() {
|
||||||
|
if (itemList.size() == 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
StringBuffer sb = new StringBuffer( itemList.size() * 8 );
|
||||||
|
Iterator i = itemList.iterator();
|
||||||
|
if (i.hasNext()) {
|
||||||
|
sb.append(((SVGItem) i.next()).getValueAsString());
|
||||||
|
}
|
||||||
|
while (i.hasNext()) {
|
||||||
|
sb.append(getItemSeparator());
|
||||||
|
sb.append(((SVGItem) i.next()).getValueAsString());
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the DOM attribute value containing the point list.
|
||||||
|
*/
|
||||||
|
protected void setAttributeValue(String value) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLengthList#clear()}.
|
||||||
|
*/
|
||||||
|
public void clear() throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.length.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLengthList#initialize(SVGLength)}.
|
||||||
|
*/
|
||||||
|
public SVGLength initialize(SVGLength newItem)
|
||||||
|
throws DOMException, SVGException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.length.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGLengthList#insertItemBefore(SVGLength, int)}.
|
||||||
|
*/
|
||||||
|
public SVGLength insertItemBefore(SVGLength newItem, int index)
|
||||||
|
throws DOMException, SVGException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.length.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGLengthList#replaceItem(SVGLength, int)}.
|
||||||
|
*/
|
||||||
|
public SVGLength replaceItem(SVGLength newItem, int index)
|
||||||
|
throws DOMException, SVGException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.length.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLengthList#removeItem(int)}.
|
||||||
|
*/
|
||||||
|
public SVGLength removeItem(int index) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.length.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGLengthList#appendItem(SVGLength)}.
|
||||||
|
*/
|
||||||
|
public SVGLength appendItem(SVGLength newItem) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.length.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the animated value.
|
||||||
|
*/
|
||||||
|
protected void setAnimatedValue(short[] types, float[] values) {
|
||||||
|
int size = itemList.size();
|
||||||
|
int i = 0;
|
||||||
|
while (i < size && i < types.length) {
|
||||||
|
SVGLengthItem l = (SVGLengthItem) itemList.get(i);
|
||||||
|
l.unitType = types[i];
|
||||||
|
l.value = values[i];
|
||||||
|
l.direction = this.direction;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
while (i < types.length) {
|
||||||
|
appendItemImpl(new SVGLengthItem(types[i], values[i],
|
||||||
|
this.direction));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
while (size > types.length) {
|
||||||
|
removeItemImpl(--size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the value of the associated attribute. Does nothing, since
|
||||||
|
* there is no attribute for an animated value.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the value of the associated attribute. Does nothing, since
|
||||||
|
* there is no attribute for an animated value.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute(SVGItem item) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the list, if needed. Does nothing, since there is no
|
||||||
|
* attribute to read the list from.
|
||||||
|
*/
|
||||||
|
protected void revalidate() {
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,445 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
import org.apache.batik.dom.svg.SVGOMAngle;
|
||||||
|
import org.apache.batik.util.SVGConstants;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedAngle;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedEnumeration;
|
||||||
|
import org.w3c.dom.svg.SVGAngle;
|
||||||
|
import org.w3c.dom.svg.SVGMarkerElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class that handles an {@link SVGAnimatedAngle} and an
|
||||||
|
* {@link SVGAnimatedEnumeration} for the 'marker' element's
|
||||||
|
* 'orient' attribute.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: SVGOMAnimatedMarkerOrientValue.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMAnimatedMarkerOrientValue extends AbstractSVGAnimatedValue {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the base value is valid.
|
||||||
|
*/
|
||||||
|
protected boolean valid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The SVGAnimatedAngle.
|
||||||
|
*/
|
||||||
|
protected AnimatedAngle animatedAngle = new AnimatedAngle();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The SVGAnimatedEnumeration.
|
||||||
|
*/
|
||||||
|
protected AnimatedEnumeration animatedEnumeration =
|
||||||
|
new AnimatedEnumeration();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current base angle value.
|
||||||
|
*/
|
||||||
|
protected BaseSVGAngle baseAngleVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current base enumeration value.
|
||||||
|
*/
|
||||||
|
protected short baseEnumerationVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current animated angle value.
|
||||||
|
*/
|
||||||
|
protected AnimSVGAngle animAngleVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current animated enumeration value.
|
||||||
|
*/
|
||||||
|
protected short animEnumerationVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the value is changing.
|
||||||
|
*/
|
||||||
|
protected boolean changing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimatedMarkerOrientValue.
|
||||||
|
* @param elt The associated element.
|
||||||
|
* @param ns The attribute's namespace URI.
|
||||||
|
* @param ln The attribute's local name.
|
||||||
|
*/
|
||||||
|
public SVGOMAnimatedMarkerOrientValue(AbstractElement elt,
|
||||||
|
String ns,
|
||||||
|
String ln) {
|
||||||
|
super(elt, ns, ln);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the animated value with the given {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
protected void updateAnimatedValue(AnimatableValue val) {
|
||||||
|
// XXX TODO
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("Animation of marker orient value is not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the base value of the attribute as an {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
public AnimatableValue getUnderlyingValue(AnimationTarget target) {
|
||||||
|
// XXX TODO
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("Animation of marker orient value is not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been added.
|
||||||
|
*/
|
||||||
|
public void attrAdded(Attr node, String newv) {
|
||||||
|
if (!changing) {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been modified.
|
||||||
|
*/
|
||||||
|
public void attrModified(Attr node, String oldv, String newv) {
|
||||||
|
if (!changing) {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been removed.
|
||||||
|
*/
|
||||||
|
public void attrRemoved(Attr node, String oldv) {
|
||||||
|
if (!changing) {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the animated value to the given angle.
|
||||||
|
*/
|
||||||
|
public void setAnimatedValueToAngle(short unitType, float value) {
|
||||||
|
hasAnimVal = true;
|
||||||
|
animAngleVal.setAnimatedValue(unitType, value);
|
||||||
|
animEnumerationVal = SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE;
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the animated value to the "auto" value.
|
||||||
|
*/
|
||||||
|
public void setAnimatedValueToAuto() {
|
||||||
|
hasAnimVal = true;
|
||||||
|
animAngleVal.setAnimatedValue(SVGAngle.SVG_ANGLETYPE_UNSPECIFIED, 0);
|
||||||
|
animEnumerationVal = SVGMarkerElement.SVG_MARKER_ORIENT_AUTO;
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the animated value.
|
||||||
|
*/
|
||||||
|
public void resetAnimatedValue() {
|
||||||
|
hasAnimVal = false;
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link SVGAnimatedAngle} component of the orient value.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedAngle getAnimatedAngle() {
|
||||||
|
return animatedAngle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link SVGAnimatedEnumeration} component of the orient value.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedEnumeration getAnimatedEnumeration() {
|
||||||
|
return animatedEnumeration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents the SVGAngle returned by
|
||||||
|
* {@link AnimatedAngle#getBaseVal()}.
|
||||||
|
*/
|
||||||
|
protected class BaseSVGAngle extends SVGOMAngle {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalidates this angle.
|
||||||
|
*/
|
||||||
|
public void invalidate() {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the value of the associated attribute.
|
||||||
|
*/
|
||||||
|
protected void reset() {
|
||||||
|
try {
|
||||||
|
changing = true;
|
||||||
|
valid = true;
|
||||||
|
String value;
|
||||||
|
if (baseEnumerationVal ==
|
||||||
|
SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE) {
|
||||||
|
value = getValueAsString();
|
||||||
|
} else if (baseEnumerationVal ==
|
||||||
|
SVGMarkerElement.SVG_MARKER_ORIENT_AUTO) {
|
||||||
|
value = SVGConstants.SVG_AUTO_VALUE;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
element.setAttributeNS(namespaceURI, localName, value);
|
||||||
|
} finally {
|
||||||
|
changing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the angle, if needed.
|
||||||
|
*/
|
||||||
|
protected void revalidate() {
|
||||||
|
if (!valid) {
|
||||||
|
Attr attr = element.getAttributeNodeNS(namespaceURI, localName);
|
||||||
|
if (attr == null) {
|
||||||
|
setUnitType(SVGAngle.SVG_ANGLETYPE_UNSPECIFIED);
|
||||||
|
value = 0;
|
||||||
|
} else {
|
||||||
|
parse(attr.getValue());
|
||||||
|
}
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a String value as an SVGAngle. If orient="auto", the
|
||||||
|
* method will parse the value "0" instead.
|
||||||
|
*/
|
||||||
|
protected void parse(String s) {
|
||||||
|
if (s.equals(SVGConstants.SVG_AUTO_VALUE)) {
|
||||||
|
setUnitType(SVGAngle.SVG_ANGLETYPE_UNSPECIFIED);
|
||||||
|
value = 0;
|
||||||
|
baseEnumerationVal = SVGMarkerElement.SVG_MARKER_ORIENT_AUTO;
|
||||||
|
} else {
|
||||||
|
super.parse(s);
|
||||||
|
if (getUnitType() == SVGAngle.SVG_ANGLETYPE_UNKNOWN) {
|
||||||
|
baseEnumerationVal = SVGMarkerElement.SVG_MARKER_ORIENT_UNKNOWN;
|
||||||
|
} else {
|
||||||
|
baseEnumerationVal = SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents the SVGAngle returned by {@link AnimatedAngle#getAnimVal()}.
|
||||||
|
*/
|
||||||
|
protected class AnimSVGAngle extends SVGOMAngle {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAngle#getUnitType()}.
|
||||||
|
*/
|
||||||
|
public short getUnitType() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getUnitType();
|
||||||
|
}
|
||||||
|
return animatedAngle.getBaseVal().getUnitType();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAngle#getValue()}.
|
||||||
|
*/
|
||||||
|
public float getValue() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getValue();
|
||||||
|
}
|
||||||
|
return animatedAngle.getBaseVal().getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAngle#getValueInSpecifiedUnits()}.
|
||||||
|
*/
|
||||||
|
public float getValueInSpecifiedUnits() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getValueInSpecifiedUnits();
|
||||||
|
}
|
||||||
|
return animatedAngle.getBaseVal().getValueInSpecifiedUnits();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAngle#getValueAsString()}.
|
||||||
|
*/
|
||||||
|
public String getValueAsString() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getValueAsString();
|
||||||
|
}
|
||||||
|
return animatedAngle.getBaseVal().getValueAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAngle#setValue(float)}.
|
||||||
|
*/
|
||||||
|
public void setValue(float value) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.angle",
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGAngle#setValueInSpecifiedUnits(float)}.
|
||||||
|
*/
|
||||||
|
public void setValueInSpecifiedUnits(float value) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.angle",
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAngle#setValueAsString(String)}.
|
||||||
|
*/
|
||||||
|
public void setValueAsString(String value) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.angle",
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGAngle#newValueSpecifiedUnits(short,float)}.
|
||||||
|
*/
|
||||||
|
public void newValueSpecifiedUnits(short unit, float value) {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.angle",
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGAngle#convertToSpecifiedUnits(short)}.
|
||||||
|
*/
|
||||||
|
public void convertToSpecifiedUnits(short unit) {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.angle",
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the animated value.
|
||||||
|
*/
|
||||||
|
protected void setAnimatedValue(int type, float val) {
|
||||||
|
super.newValueSpecifiedUnits((short) type, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link SVGAnimatedAngle} component of the marker orient value.
|
||||||
|
*/
|
||||||
|
protected class AnimatedAngle implements SVGAnimatedAngle {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedAngle#getBaseVal()}.
|
||||||
|
*/
|
||||||
|
public SVGAngle getBaseVal() {
|
||||||
|
if (baseAngleVal == null) {
|
||||||
|
baseAngleVal = new BaseSVGAngle();
|
||||||
|
}
|
||||||
|
return baseAngleVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedAngle#getAnimVal()}.
|
||||||
|
*/
|
||||||
|
public SVGAngle getAnimVal() {
|
||||||
|
if (animAngleVal == null) {
|
||||||
|
animAngleVal = new AnimSVGAngle();
|
||||||
|
}
|
||||||
|
return animAngleVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link SVGAnimatedEnumeration} component of the marker orient value.
|
||||||
|
*/
|
||||||
|
protected class AnimatedEnumeration implements SVGAnimatedEnumeration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedEnumeration#getBaseVal()}.
|
||||||
|
*/
|
||||||
|
public short getBaseVal() {
|
||||||
|
if (baseAngleVal == null) {
|
||||||
|
baseAngleVal = new BaseSVGAngle();
|
||||||
|
}
|
||||||
|
baseAngleVal.revalidate();
|
||||||
|
return baseEnumerationVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGAnimatedEnumeration#setBaseVal(short)}.
|
||||||
|
*/
|
||||||
|
public void setBaseVal(short baseVal) throws DOMException {
|
||||||
|
if (baseVal == SVGMarkerElement.SVG_MARKER_ORIENT_AUTO) {
|
||||||
|
baseEnumerationVal = baseVal;
|
||||||
|
if (baseAngleVal == null) {
|
||||||
|
baseAngleVal = new BaseSVGAngle();
|
||||||
|
}
|
||||||
|
baseAngleVal.setUnitType(SVGAngle.SVG_ANGLETYPE_UNSPECIFIED);
|
||||||
|
baseAngleVal.setValue(0);
|
||||||
|
baseAngleVal.reset();
|
||||||
|
} else if (baseVal == SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE) {
|
||||||
|
baseEnumerationVal = baseVal;
|
||||||
|
if (baseAngleVal == null) {
|
||||||
|
baseAngleVal = new BaseSVGAngle();
|
||||||
|
}
|
||||||
|
baseAngleVal.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedEnumeration#getAnimVal()}.
|
||||||
|
*/
|
||||||
|
public short getAnimVal() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return animEnumerationVal;
|
||||||
|
}
|
||||||
|
if (baseAngleVal == null) {
|
||||||
|
baseAngleVal = new BaseSVGAngle();
|
||||||
|
}
|
||||||
|
baseAngleVal.revalidate();
|
||||||
|
return baseEnumerationVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,215 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatableNumberValue;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements the {@link SVGAnimatedNumber} interface.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMAnimatedNumber.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMAnimatedNumber
|
||||||
|
extends AbstractSVGAnimatedValue
|
||||||
|
implements SVGAnimatedNumber {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default value.
|
||||||
|
*/
|
||||||
|
protected float defaultValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the parsed number can be a percentage.
|
||||||
|
*/
|
||||||
|
protected boolean allowPercentage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the base value is valid.
|
||||||
|
*/
|
||||||
|
protected boolean valid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current base value.
|
||||||
|
*/
|
||||||
|
protected float baseVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current animated value.
|
||||||
|
*/
|
||||||
|
protected float animVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the value is changing.
|
||||||
|
*/
|
||||||
|
protected boolean changing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimatedNumber.
|
||||||
|
* @param elt The associated element.
|
||||||
|
* @param ns The attribute's namespace URI.
|
||||||
|
* @param ln The attribute's local name.
|
||||||
|
* @param val The default value, if the attribute is not specified.
|
||||||
|
*/
|
||||||
|
public SVGOMAnimatedNumber(AbstractElement elt,
|
||||||
|
String ns,
|
||||||
|
String ln,
|
||||||
|
float val) {
|
||||||
|
this(elt, ns, ln, val, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimatedNumber possibly parsing it as a percentage.
|
||||||
|
* @param elt The associated element.
|
||||||
|
* @param ns The attribute's namespace URI.
|
||||||
|
* @param ln The attribute's local name.
|
||||||
|
* @param val The default value, if the attribute is not specified.
|
||||||
|
* @param allowPercentage Allows number specified as a percentage.
|
||||||
|
*/
|
||||||
|
public SVGOMAnimatedNumber(AbstractElement elt,
|
||||||
|
String ns,
|
||||||
|
String ln,
|
||||||
|
float val,
|
||||||
|
boolean allowPercentage) {
|
||||||
|
super(elt, ns, ln);
|
||||||
|
defaultValue = val;
|
||||||
|
this.allowPercentage = allowPercentage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedNumber#getBaseVal()}.
|
||||||
|
*/
|
||||||
|
public float getBaseVal() {
|
||||||
|
if (!valid) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
return baseVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the base value from the attribute.
|
||||||
|
*/
|
||||||
|
protected void update() {
|
||||||
|
Attr attr = element.getAttributeNodeNS(namespaceURI, localName);
|
||||||
|
if (attr == null) {
|
||||||
|
baseVal = defaultValue;
|
||||||
|
} else {
|
||||||
|
String v = attr.getValue();
|
||||||
|
int len = v.length();
|
||||||
|
if (allowPercentage && len > 1 && v.charAt(len - 1) == '%') {
|
||||||
|
baseVal = .01f * Float.parseFloat(v.substring(0, len - 1));
|
||||||
|
} else {
|
||||||
|
baseVal = Float.parseFloat(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedNumber#setBaseVal(float)}.
|
||||||
|
*/
|
||||||
|
public void setBaseVal(float baseVal) throws DOMException {
|
||||||
|
try {
|
||||||
|
this.baseVal = baseVal;
|
||||||
|
valid = true;
|
||||||
|
changing = true;
|
||||||
|
element.setAttributeNS(namespaceURI, localName,
|
||||||
|
String.valueOf(baseVal));
|
||||||
|
} finally {
|
||||||
|
changing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedNumber#getAnimVal()}.
|
||||||
|
*/
|
||||||
|
public float getAnimVal() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return animVal;
|
||||||
|
}
|
||||||
|
if (!valid) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
return baseVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the base value of the attribute as an {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
public AnimatableValue getUnderlyingValue(AnimationTarget target) {
|
||||||
|
return new AnimatableNumberValue(target, getBaseVal());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the animated value with the given {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
protected void updateAnimatedValue(AnimatableValue val) {
|
||||||
|
if (val == null) {
|
||||||
|
hasAnimVal = false;
|
||||||
|
} else {
|
||||||
|
hasAnimVal = true;
|
||||||
|
this.animVal = ((AnimatableNumberValue) val).getValue();
|
||||||
|
}
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been added.
|
||||||
|
*/
|
||||||
|
public void attrAdded(Attr node, String newv) {
|
||||||
|
if (!changing) {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been modified.
|
||||||
|
*/
|
||||||
|
public void attrModified(Attr node, String oldv, String newv) {
|
||||||
|
if (!changing) {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been removed.
|
||||||
|
*/
|
||||||
|
public void attrRemoved(Attr node, String oldv) {
|
||||||
|
if (!changing) {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,513 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatableNumberListValue;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
import org.apache.batik.dom.svg.AbstractSVGNumberList;
|
||||||
|
import org.apache.batik.dom.svg.ListBuilder;
|
||||||
|
import org.apache.batik.dom.svg.LiveAttributeException;
|
||||||
|
import org.apache.batik.dom.svg.SVGItem;
|
||||||
|
import org.apache.batik.dom.svg.SVGNumberItem;
|
||||||
|
|
||||||
|
import org.apache.batik.parser.ParseException;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedNumberList;
|
||||||
|
import org.w3c.dom.svg.SVGException;
|
||||||
|
import org.w3c.dom.svg.SVGNumber;
|
||||||
|
import org.w3c.dom.svg.SVGNumberList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is the implementation of the {@link SVGAnimatedNumberList}
|
||||||
|
* interface.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:tonny@kiyut.com">Tonny Kohar</a>
|
||||||
|
* @version $Id: SVGOMAnimatedNumberList.java 1804130 2017-08-04 14:41:11Z ssteiner $
|
||||||
|
*/
|
||||||
|
public class SVGOMAnimatedNumberList
|
||||||
|
extends AbstractSVGAnimatedValue
|
||||||
|
implements SVGAnimatedNumberList {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base value.
|
||||||
|
*/
|
||||||
|
protected BaseSVGNumberList baseVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The animated value.
|
||||||
|
*/
|
||||||
|
protected AnimSVGNumberList animVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the list is changing.
|
||||||
|
*/
|
||||||
|
protected boolean changing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default value for the number list.
|
||||||
|
*/
|
||||||
|
protected String defaultValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether empty length lists are allowed.
|
||||||
|
*/
|
||||||
|
protected boolean emptyAllowed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimatedNumberList.
|
||||||
|
* @param elt The associated element.
|
||||||
|
* @param ns The attribute's namespace URI.
|
||||||
|
* @param ln The attribute's local name.
|
||||||
|
* @param defaultValue The default value if the attribute is not specified.
|
||||||
|
* @param emptyAllowed Whether an empty number list is allowed.
|
||||||
|
*/
|
||||||
|
public SVGOMAnimatedNumberList(AbstractElement elt,
|
||||||
|
String ns,
|
||||||
|
String ln,
|
||||||
|
String defaultValue,
|
||||||
|
boolean emptyAllowed) {
|
||||||
|
super(elt, ns, ln);
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
this.emptyAllowed = emptyAllowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedNumberList#getBaseVal()}.
|
||||||
|
*/
|
||||||
|
public SVGNumberList getBaseVal() {
|
||||||
|
if (baseVal == null) {
|
||||||
|
baseVal = new BaseSVGNumberList();
|
||||||
|
}
|
||||||
|
return baseVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedNumberList#getAnimVal()}.
|
||||||
|
*/
|
||||||
|
public SVGNumberList getAnimVal() {
|
||||||
|
if (animVal == null) {
|
||||||
|
animVal = new AnimSVGNumberList();
|
||||||
|
}
|
||||||
|
return animVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throws an exception if the number list value is malformed.
|
||||||
|
*/
|
||||||
|
public void check() {
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
if (baseVal == null) {
|
||||||
|
baseVal = new BaseSVGNumberList();
|
||||||
|
}
|
||||||
|
baseVal.revalidate();
|
||||||
|
if (baseVal.missing) {
|
||||||
|
throw new LiveAttributeException
|
||||||
|
(element, localName,
|
||||||
|
LiveAttributeException.ERR_ATTRIBUTE_MISSING, null);
|
||||||
|
}
|
||||||
|
if (baseVal.malformed) {
|
||||||
|
throw new LiveAttributeException
|
||||||
|
(element, localName,
|
||||||
|
LiveAttributeException.ERR_ATTRIBUTE_MALFORMED,
|
||||||
|
baseVal.getValueAsString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the base value of the attribute as an {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
public AnimatableValue getUnderlyingValue(AnimationTarget target) {
|
||||||
|
SVGNumberList nl = getBaseVal();
|
||||||
|
int n = nl.getNumberOfItems();
|
||||||
|
float[] numbers = new float[n];
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
numbers[i] = nl.getItem(n).getValue();
|
||||||
|
}
|
||||||
|
return new AnimatableNumberListValue(target, numbers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the animated value with the given {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
protected void updateAnimatedValue(AnimatableValue val) {
|
||||||
|
if (val == null) {
|
||||||
|
hasAnimVal = false;
|
||||||
|
} else {
|
||||||
|
hasAnimVal = true;
|
||||||
|
AnimatableNumberListValue animNumList =
|
||||||
|
(AnimatableNumberListValue) val;
|
||||||
|
if (animVal == null) {
|
||||||
|
animVal = new AnimSVGNumberList();
|
||||||
|
}
|
||||||
|
animVal.setAnimatedValue(animNumList.getNumbers());
|
||||||
|
}
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been added.
|
||||||
|
*/
|
||||||
|
public void attrAdded(Attr node, String newv) {
|
||||||
|
if (!changing && baseVal != null) {
|
||||||
|
baseVal.invalidate();
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been modified.
|
||||||
|
*/
|
||||||
|
public void attrModified(Attr node, String oldv, String newv) {
|
||||||
|
if (!changing && baseVal != null) {
|
||||||
|
baseVal.invalidate();
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been removed.
|
||||||
|
*/
|
||||||
|
public void attrRemoved(Attr node, String oldv) {
|
||||||
|
if (!changing && baseVal != null) {
|
||||||
|
baseVal.invalidate();
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link SVGNumberList} implementation for the base number list value.
|
||||||
|
*/
|
||||||
|
public class BaseSVGNumberList extends AbstractSVGNumberList {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the value is missing.
|
||||||
|
*/
|
||||||
|
protected boolean missing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the value is malformed.
|
||||||
|
*/
|
||||||
|
protected boolean malformed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a DOMException.
|
||||||
|
*/
|
||||||
|
protected DOMException createDOMException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
return element.createDOMException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a SVGException.
|
||||||
|
*/
|
||||||
|
protected SVGException createSVGException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
|
||||||
|
return ((SVGOMElement)element).createSVGException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the element owning the attribute with which this length
|
||||||
|
* list is associated.
|
||||||
|
*/
|
||||||
|
protected Element getElement() {
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the DOM attribute containing the number list.
|
||||||
|
*/
|
||||||
|
protected String getValueAsString() {
|
||||||
|
Attr attr = element.getAttributeNodeNS(namespaceURI, localName);
|
||||||
|
if (attr == null) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
return attr.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the DOM attribute value containing the number list.
|
||||||
|
*/
|
||||||
|
protected void setAttributeValue(String value) {
|
||||||
|
try {
|
||||||
|
changing = true;
|
||||||
|
element.setAttributeNS(namespaceURI, localName, value);
|
||||||
|
} finally {
|
||||||
|
changing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the value of the associated attribute.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute() {
|
||||||
|
super.resetAttribute();
|
||||||
|
missing = false;
|
||||||
|
malformed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends the string representation of the given {@link SVGItem} to
|
||||||
|
* the DOM attribute. This is called in response to an append to
|
||||||
|
* the list.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute(SVGItem item) {
|
||||||
|
super.resetAttribute(item);
|
||||||
|
missing = false;
|
||||||
|
malformed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the list, if needed.
|
||||||
|
*/
|
||||||
|
protected void revalidate() {
|
||||||
|
if (valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
valid = true;
|
||||||
|
missing = false;
|
||||||
|
malformed = false;
|
||||||
|
|
||||||
|
String s = getValueAsString();
|
||||||
|
boolean isEmpty = s != null && s.length() == 0;
|
||||||
|
if (s == null || isEmpty && !emptyAllowed) {
|
||||||
|
missing = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isEmpty) {
|
||||||
|
itemList = new ArrayList(1);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
ListBuilder builder = new ListBuilder(this);
|
||||||
|
|
||||||
|
doParse(s, builder);
|
||||||
|
|
||||||
|
if (builder.getList() != null) {
|
||||||
|
clear(itemList);
|
||||||
|
}
|
||||||
|
itemList = builder.getList();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
itemList = new ArrayList(1);
|
||||||
|
valid = true;
|
||||||
|
malformed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link SVGNumberList} implementation for the animated number list value.
|
||||||
|
*/
|
||||||
|
protected class AnimSVGNumberList extends AbstractSVGNumberList {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new AnimSVGNumberList.
|
||||||
|
*/
|
||||||
|
public AnimSVGNumberList() {
|
||||||
|
itemList = new ArrayList(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a DOMException.
|
||||||
|
*/
|
||||||
|
protected DOMException createDOMException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
return element.createDOMException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a SVGException.
|
||||||
|
*/
|
||||||
|
protected SVGException createSVGException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
|
||||||
|
return ((SVGOMElement)element).createSVGException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the element owning this SVGNumberList.
|
||||||
|
*/
|
||||||
|
protected Element getElement() {
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGNumberList#getNumberOfItems()}.
|
||||||
|
*/
|
||||||
|
public int getNumberOfItems() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getNumberOfItems();
|
||||||
|
}
|
||||||
|
return getBaseVal().getNumberOfItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGNumberList#getItem(int)}.
|
||||||
|
*/
|
||||||
|
public SVGNumber getItem(int index) throws DOMException {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getItem(index);
|
||||||
|
}
|
||||||
|
return getBaseVal().getItem(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the DOM attribute containing the point list.
|
||||||
|
*/
|
||||||
|
protected String getValueAsString() {
|
||||||
|
if (itemList.size() == 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
StringBuffer sb = new StringBuffer( itemList.size() * 8 );
|
||||||
|
Iterator i = itemList.iterator();
|
||||||
|
if (i.hasNext()) {
|
||||||
|
sb.append(((SVGItem) i.next()).getValueAsString());
|
||||||
|
}
|
||||||
|
while (i.hasNext()) {
|
||||||
|
sb.append(getItemSeparator());
|
||||||
|
sb.append(((SVGItem) i.next()).getValueAsString());
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the DOM attribute value containing the point list.
|
||||||
|
*/
|
||||||
|
protected void setAttributeValue(String value) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGNumberList#clear()}.
|
||||||
|
*/
|
||||||
|
public void clear() throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.number.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGNumberList#initialize(SVGNumber)}.
|
||||||
|
*/
|
||||||
|
public SVGNumber initialize(SVGNumber newItem)
|
||||||
|
throws DOMException, SVGException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.number.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGNumberList#insertItemBefore(SVGNumber, int)}.
|
||||||
|
*/
|
||||||
|
public SVGNumber insertItemBefore(SVGNumber newItem, int index)
|
||||||
|
throws DOMException, SVGException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.number.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGNumberList#replaceItem(SVGNumber, int)}.
|
||||||
|
*/
|
||||||
|
public SVGNumber replaceItem(SVGNumber newItem, int index)
|
||||||
|
throws DOMException, SVGException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.number.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGNumberList#removeItem(int)}.
|
||||||
|
*/
|
||||||
|
public SVGNumber removeItem(int index) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.number.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGNumberList#appendItem(SVGNumber)}.
|
||||||
|
*/
|
||||||
|
public SVGNumber appendItem(SVGNumber newItem) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.number.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the animated value.
|
||||||
|
*/
|
||||||
|
protected void setAnimatedValue(float[] values) {
|
||||||
|
int size = itemList.size();
|
||||||
|
int i = 0;
|
||||||
|
while (i < size && i < values.length) {
|
||||||
|
SVGNumberItem n = (SVGNumberItem) itemList.get(i);
|
||||||
|
n.setValue(values[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
while (i < values.length) {
|
||||||
|
appendItemImpl(new SVGNumberItem(values[i]));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
while (size > values.length) {
|
||||||
|
removeItemImpl(--size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the value of the associated attribute. Does nothing, since
|
||||||
|
* there is no attribute for an animated value.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the value of the associated attribute. Does nothing, since
|
||||||
|
* there is no attribute for an animated value.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute(SVGItem item) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the list, if needed. Does nothing, since there is no
|
||||||
|
* attribute to read the list from.
|
||||||
|
*/
|
||||||
|
protected void revalidate() {
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,806 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatablePathDataValue;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
import org.apache.batik.dom.svg.AbstractSVGNormPathSegList;
|
||||||
|
import org.apache.batik.dom.svg.AbstractSVGPathSegList;
|
||||||
|
import org.apache.batik.dom.svg.ListBuilder;
|
||||||
|
import org.apache.batik.dom.svg.LiveAttributeException;
|
||||||
|
import org.apache.batik.dom.svg.SVGAnimatedPathDataSupport;
|
||||||
|
import org.apache.batik.dom.svg.SVGItem;
|
||||||
|
import org.apache.batik.dom.svg.AbstractSVGPathSegList.SVGPathSegArcItem;
|
||||||
|
import org.apache.batik.dom.svg.AbstractSVGPathSegList.SVGPathSegCurvetoCubicItem;
|
||||||
|
import org.apache.batik.dom.svg.AbstractSVGPathSegList.SVGPathSegCurvetoCubicSmoothItem;
|
||||||
|
import org.apache.batik.dom.svg.AbstractSVGPathSegList.SVGPathSegCurvetoQuadraticItem;
|
||||||
|
import org.apache.batik.dom.svg.AbstractSVGPathSegList.SVGPathSegCurvetoQuadraticSmoothItem;
|
||||||
|
import org.apache.batik.dom.svg.AbstractSVGPathSegList.SVGPathSegLinetoHorizontalItem;
|
||||||
|
import org.apache.batik.dom.svg.AbstractSVGPathSegList.SVGPathSegLinetoVerticalItem;
|
||||||
|
import org.apache.batik.dom.svg.AbstractSVGPathSegList.SVGPathSegMovetoLinetoItem;
|
||||||
|
import org.apache.batik.dom.svg.SVGPathSegItem;
|
||||||
|
|
||||||
|
import org.apache.batik.parser.ParseException;
|
||||||
|
import org.apache.batik.parser.PathArrayProducer;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedPathData;
|
||||||
|
import org.w3c.dom.svg.SVGException;
|
||||||
|
import org.w3c.dom.svg.SVGPathSeg;
|
||||||
|
import org.w3c.dom.svg.SVGPathSegList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is the implementation of the {@link SVGAnimatedPathData}
|
||||||
|
* interface.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:nicolas.socheleau@bitflash.com">Nicolas Socheleau</a>
|
||||||
|
* @author <a href="mailto:andrest@world-affair.com">Andres Toussaint</a>
|
||||||
|
* @version $Id: SVGOMAnimatedPathData.java 1831635 2018-05-15 13:33:47Z ssteiner $
|
||||||
|
*/
|
||||||
|
public class SVGOMAnimatedPathData
|
||||||
|
extends AbstractSVGAnimatedValue
|
||||||
|
implements SVGAnimatedPathData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the list is changing.
|
||||||
|
*/
|
||||||
|
protected boolean changing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base path data value.
|
||||||
|
*/
|
||||||
|
protected BaseSVGPathSegList pathSegs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The normalized base path data value.
|
||||||
|
*/
|
||||||
|
protected NormalizedBaseSVGPathSegList normalizedPathSegs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The animated path data value.
|
||||||
|
*/
|
||||||
|
protected AnimSVGPathSegList animPathSegs;
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * The normalized animated base path data value.
|
||||||
|
// */
|
||||||
|
// protected NormalizedAnimSVGPathSegList normalizedPathSegs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default value for the 'd' attribute.
|
||||||
|
*/
|
||||||
|
protected String defaultValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimatedPathData.
|
||||||
|
* @param elt The associated element.
|
||||||
|
* @param ns The attribute's namespace URI.
|
||||||
|
* @param ln The attribute's local name.
|
||||||
|
* @param defaultValue The default value if the attribute is not specified.
|
||||||
|
*/
|
||||||
|
public SVGOMAnimatedPathData(AbstractElement elt,
|
||||||
|
String ns,
|
||||||
|
String ln,
|
||||||
|
String defaultValue) {
|
||||||
|
super(elt, ns, ln);
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGAnimatedPathData#getAnimatedNormalizedPathSegList()}.
|
||||||
|
*/
|
||||||
|
public SVGPathSegList getAnimatedNormalizedPathSegList() {
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGAnimatedPathData.getAnimatedNormalizedPathSegList is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGAnimatedPathData#getAnimatedPathSegList()}.
|
||||||
|
*/
|
||||||
|
public SVGPathSegList getAnimatedPathSegList() {
|
||||||
|
if (animPathSegs == null) {
|
||||||
|
animPathSegs = new AnimSVGPathSegList();
|
||||||
|
}
|
||||||
|
return animPathSegs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGAnimatedPathData#getNormalizedPathSegList()}.
|
||||||
|
* <p>
|
||||||
|
* Returns the SVGPathSegList mapping the normalized static 'd' attribute
|
||||||
|
* of the element.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* A normalized path is composed only of absolute moveto, lineto and
|
||||||
|
* cubicto path segments (M, L and C). Using this subset, the path
|
||||||
|
* description can be represented with fewer segment types. Be aware that
|
||||||
|
* the normalized 'd' attribute will be a larger String that the original.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* Relative values are transformed into absolute, quadratic curves are
|
||||||
|
* promoted to cubic curves, and arcs are converted into one or more
|
||||||
|
* cubic curves (one per quadrant).
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* Modifications to the normalized SVGPathSegList will result
|
||||||
|
* in substituting the original path with a set of normalized path
|
||||||
|
* segments.
|
||||||
|
* </p>
|
||||||
|
* @return a path segment list containing the normalized version of the path.
|
||||||
|
*/
|
||||||
|
public SVGPathSegList getNormalizedPathSegList() {
|
||||||
|
if (normalizedPathSegs == null) {
|
||||||
|
normalizedPathSegs = new NormalizedBaseSVGPathSegList();
|
||||||
|
}
|
||||||
|
return normalizedPathSegs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGAnimatedPathData#getPathSegList()}.
|
||||||
|
*/
|
||||||
|
public SVGPathSegList getPathSegList() {
|
||||||
|
if (pathSegs == null) {
|
||||||
|
pathSegs = new BaseSVGPathSegList();
|
||||||
|
}
|
||||||
|
return pathSegs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throws an exception if the path data is malformed.
|
||||||
|
*/
|
||||||
|
public void check() {
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
if (pathSegs == null) {
|
||||||
|
pathSegs = new BaseSVGPathSegList();
|
||||||
|
}
|
||||||
|
pathSegs.revalidate();
|
||||||
|
if (pathSegs.missing) {
|
||||||
|
throw new LiveAttributeException
|
||||||
|
(element, localName,
|
||||||
|
LiveAttributeException.ERR_ATTRIBUTE_MISSING, null);
|
||||||
|
}
|
||||||
|
if (pathSegs.malformed) {
|
||||||
|
throw new LiveAttributeException
|
||||||
|
(element, localName,
|
||||||
|
LiveAttributeException.ERR_ATTRIBUTE_MALFORMED,
|
||||||
|
pathSegs.getValueAsString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the base value of the attribute as an {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
public AnimatableValue getUnderlyingValue(AnimationTarget target) {
|
||||||
|
SVGPathSegList psl = getPathSegList();
|
||||||
|
PathArrayProducer pp = new PathArrayProducer();
|
||||||
|
SVGAnimatedPathDataSupport.handlePathSegList(psl, pp);
|
||||||
|
return new AnimatablePathDataValue(target, pp.getPathCommands(),
|
||||||
|
pp.getPathParameters());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the animated value with the given {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
protected void updateAnimatedValue(AnimatableValue val) {
|
||||||
|
if (val == null) {
|
||||||
|
hasAnimVal = false;
|
||||||
|
} else {
|
||||||
|
hasAnimVal = true;
|
||||||
|
AnimatablePathDataValue animPath = (AnimatablePathDataValue) val;
|
||||||
|
if (animPathSegs == null) {
|
||||||
|
animPathSegs = new AnimSVGPathSegList();
|
||||||
|
}
|
||||||
|
animPathSegs.setAnimatedValue(animPath.getCommands(),
|
||||||
|
animPath.getParameters());
|
||||||
|
}
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been added.
|
||||||
|
*/
|
||||||
|
public void attrAdded(Attr node, String newv) {
|
||||||
|
if (!changing) {
|
||||||
|
if (pathSegs != null) {
|
||||||
|
pathSegs.invalidate();
|
||||||
|
}
|
||||||
|
if (normalizedPathSegs != null) {
|
||||||
|
normalizedPathSegs.invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been modified.
|
||||||
|
*/
|
||||||
|
public void attrModified(Attr node, String oldv, String newv) {
|
||||||
|
if (!changing) {
|
||||||
|
if (pathSegs != null) {
|
||||||
|
pathSegs.invalidate();
|
||||||
|
}
|
||||||
|
if (normalizedPathSegs != null) {
|
||||||
|
normalizedPathSegs.invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been removed.
|
||||||
|
*/
|
||||||
|
public void attrRemoved(Attr node, String oldv) {
|
||||||
|
if (!changing) {
|
||||||
|
if (pathSegs != null) {
|
||||||
|
pathSegs.invalidate();
|
||||||
|
}
|
||||||
|
if (normalizedPathSegs != null) {
|
||||||
|
normalizedPathSegs.invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link SVGPathSegList} implementation for the base path data value.
|
||||||
|
*/
|
||||||
|
public class BaseSVGPathSegList extends AbstractSVGPathSegList {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the attribute is missing.
|
||||||
|
*/
|
||||||
|
protected boolean missing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the attribute is malformed.
|
||||||
|
*/
|
||||||
|
protected boolean malformed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a DOMException.
|
||||||
|
*/
|
||||||
|
protected DOMException createDOMException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
return element.createDOMException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a SVGException.
|
||||||
|
*/
|
||||||
|
protected SVGException createSVGException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
return ((SVGOMElement)element).createSVGException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the DOM attribute containing the path data.
|
||||||
|
*/
|
||||||
|
protected String getValueAsString() {
|
||||||
|
Attr attr = element.getAttributeNodeNS(namespaceURI, localName);
|
||||||
|
if (attr == null) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
return attr.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the DOM attribute value containing the path data.
|
||||||
|
*/
|
||||||
|
protected void setAttributeValue(String value) {
|
||||||
|
try {
|
||||||
|
changing = true;
|
||||||
|
element.setAttributeNS(namespaceURI, localName, value);
|
||||||
|
} finally {
|
||||||
|
changing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the value of the associated attribute.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute() {
|
||||||
|
super.resetAttribute();
|
||||||
|
missing = false;
|
||||||
|
malformed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends the string representation of the given {@link SVGItem} to
|
||||||
|
* the DOM attribute. This is called in response to an append to
|
||||||
|
* the list.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute(SVGItem item) {
|
||||||
|
super.resetAttribute(item);
|
||||||
|
missing = false;
|
||||||
|
malformed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the list, if needed.
|
||||||
|
*/
|
||||||
|
protected void revalidate() {
|
||||||
|
if (valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
valid = true;
|
||||||
|
missing = false;
|
||||||
|
malformed = false;
|
||||||
|
|
||||||
|
String s = getValueAsString();
|
||||||
|
if (s == null) {
|
||||||
|
missing = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ListBuilder builder = new ListBuilder(this);
|
||||||
|
|
||||||
|
doParse(s, builder);
|
||||||
|
|
||||||
|
if (builder.getList() != null) {
|
||||||
|
clear(itemList);
|
||||||
|
}
|
||||||
|
itemList = builder.getList();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
itemList = new ArrayList(1);
|
||||||
|
malformed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link SVGPathSegList} implementation for the normalized version of the
|
||||||
|
* base path data value.
|
||||||
|
*/
|
||||||
|
public class NormalizedBaseSVGPathSegList
|
||||||
|
extends AbstractSVGNormPathSegList {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the attribute is missing.
|
||||||
|
*/
|
||||||
|
protected boolean missing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the attribute is malformed.
|
||||||
|
*/
|
||||||
|
protected boolean malformed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a DOMException.
|
||||||
|
*/
|
||||||
|
protected DOMException createDOMException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
return element.createDOMException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a SVGException.
|
||||||
|
*/
|
||||||
|
protected SVGException createSVGException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
return ((SVGOMElement)element).createSVGException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the DOM attribute containing the path data.
|
||||||
|
*/
|
||||||
|
protected String getValueAsString() throws SVGException {
|
||||||
|
Attr attr = element.getAttributeNodeNS(namespaceURI, localName);
|
||||||
|
if (attr == null) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
return attr.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the DOM attribute value containing the path data.
|
||||||
|
*/
|
||||||
|
protected void setAttributeValue(String value) {
|
||||||
|
try {
|
||||||
|
changing = true;
|
||||||
|
element.setAttributeNS(namespaceURI, localName, value);
|
||||||
|
} finally {
|
||||||
|
changing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the list, if needed.
|
||||||
|
*/
|
||||||
|
protected void revalidate() {
|
||||||
|
if (valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
valid = true;
|
||||||
|
missing = false;
|
||||||
|
malformed = false;
|
||||||
|
|
||||||
|
String s = getValueAsString();
|
||||||
|
if (s == null) {
|
||||||
|
missing = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ListBuilder builder = new ListBuilder(this);
|
||||||
|
|
||||||
|
doParse(s, builder);
|
||||||
|
|
||||||
|
if (builder.getList() != null) {
|
||||||
|
clear(itemList);
|
||||||
|
}
|
||||||
|
itemList = builder.getList();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
itemList = new ArrayList(1);
|
||||||
|
malformed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link SVGPathSegList} implementation for the animated path data value.
|
||||||
|
*/
|
||||||
|
public class AnimSVGPathSegList extends AbstractSVGPathSegList {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new AnimSVGPathSegList.
|
||||||
|
*/
|
||||||
|
public AnimSVGPathSegList() {
|
||||||
|
itemList = new ArrayList(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a DOMException.
|
||||||
|
*/
|
||||||
|
protected DOMException createDOMException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
return element.createDOMException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a SVGException.
|
||||||
|
*/
|
||||||
|
protected SVGException createSVGException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
return ((SVGOMElement)element).createSVGException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGPathSegList#getNumberOfItems()}.
|
||||||
|
*/
|
||||||
|
public int getNumberOfItems() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getNumberOfItems();
|
||||||
|
}
|
||||||
|
return getPathSegList().getNumberOfItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGPathSegList#getItem(int)}.
|
||||||
|
*/
|
||||||
|
public SVGPathSeg getItem(int index) throws DOMException {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getItem(index);
|
||||||
|
}
|
||||||
|
return getPathSegList().getItem(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the DOM attribute containing the point list.
|
||||||
|
*/
|
||||||
|
protected String getValueAsString() {
|
||||||
|
if (itemList.size() == 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
StringBuffer sb = new StringBuffer( itemList.size() * 8 );
|
||||||
|
Iterator i = itemList.iterator();
|
||||||
|
if (i.hasNext()) {
|
||||||
|
sb.append(((SVGItem) i.next()).getValueAsString());
|
||||||
|
}
|
||||||
|
while (i.hasNext()) {
|
||||||
|
sb.append(getItemSeparator());
|
||||||
|
sb.append(((SVGItem) i.next()).getValueAsString());
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the DOM attribute value containing the point list.
|
||||||
|
*/
|
||||||
|
protected void setAttributeValue(String value) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGPathSegList#clear()}.
|
||||||
|
*/
|
||||||
|
public void clear() throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.pathseg.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGPathSegList#initialize(SVGPathSeg)}.
|
||||||
|
*/
|
||||||
|
public SVGPathSeg initialize(SVGPathSeg newItem)
|
||||||
|
throws DOMException, SVGException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.pathseg.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGPathSegList#insertItemBefore(SVGPathSeg, int)}.
|
||||||
|
*/
|
||||||
|
public SVGPathSeg insertItemBefore(SVGPathSeg newItem, int index)
|
||||||
|
throws DOMException, SVGException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.pathseg.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGPathSegList#replaceItem(SVGPathSeg, int)}.
|
||||||
|
*/
|
||||||
|
public SVGPathSeg replaceItem(SVGPathSeg newItem, int index)
|
||||||
|
throws DOMException, SVGException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.pathseg.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGPathSegList#removeItem(int)}.
|
||||||
|
*/
|
||||||
|
public SVGPathSeg removeItem(int index) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.pathseg.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGPathSegList#appendItem(SVGPathSeg)}.
|
||||||
|
*/
|
||||||
|
public SVGPathSeg appendItem(SVGPathSeg newItem) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.pathseg.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pass by reference integer for use by newItem.
|
||||||
|
*/
|
||||||
|
private int[] parameterIndex = new int[1];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGPathSegItem from the given path command and array
|
||||||
|
* of parameter values.
|
||||||
|
*/
|
||||||
|
protected SVGPathSegItem newItem(short command, float[] parameters,
|
||||||
|
int[] j) {
|
||||||
|
switch (command) {
|
||||||
|
case SVGPathSeg.PATHSEG_ARC_ABS:
|
||||||
|
case SVGPathSeg.PATHSEG_ARC_REL:
|
||||||
|
return new SVGPathSegArcItem(command, PATHSEG_LETTERS[command],
|
||||||
|
parameters[j[0]++],
|
||||||
|
parameters[j[0]++],
|
||||||
|
parameters[j[0]++],
|
||||||
|
parameters[j[0]++] != 0,
|
||||||
|
parameters[j[0]++] != 0,
|
||||||
|
parameters[j[0]++],
|
||||||
|
parameters[j[0]++]);
|
||||||
|
case SVGPathSeg.PATHSEG_CLOSEPATH:
|
||||||
|
return new SVGPathSegItem
|
||||||
|
(command, PATHSEG_LETTERS[command]);
|
||||||
|
case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:
|
||||||
|
case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:
|
||||||
|
return new SVGPathSegCurvetoCubicItem(command, PATHSEG_LETTERS[command],
|
||||||
|
parameters[j[0]++],
|
||||||
|
parameters[j[0]++],
|
||||||
|
parameters[j[0]++],
|
||||||
|
parameters[j[0]++],
|
||||||
|
parameters[j[0]++],
|
||||||
|
parameters[j[0]++]);
|
||||||
|
case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
|
||||||
|
case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:
|
||||||
|
return new SVGPathSegCurvetoCubicSmoothItem(command, PATHSEG_LETTERS[command],
|
||||||
|
parameters[j[0]++],
|
||||||
|
parameters[j[0]++],
|
||||||
|
parameters[j[0]++],
|
||||||
|
parameters[j[0]++]);
|
||||||
|
case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:
|
||||||
|
case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:
|
||||||
|
return new SVGPathSegCurvetoQuadraticItem(command, PATHSEG_LETTERS[command],
|
||||||
|
parameters[j[0]++],
|
||||||
|
parameters[j[0]++],
|
||||||
|
parameters[j[0]++],
|
||||||
|
parameters[j[0]++]);
|
||||||
|
case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:
|
||||||
|
case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:
|
||||||
|
return new SVGPathSegCurvetoQuadraticSmoothItem(command, PATHSEG_LETTERS[command],
|
||||||
|
parameters[j[0]++],
|
||||||
|
parameters[j[0]++]);
|
||||||
|
case SVGPathSeg.PATHSEG_LINETO_ABS:
|
||||||
|
case SVGPathSeg.PATHSEG_LINETO_REL:
|
||||||
|
case SVGPathSeg.PATHSEG_MOVETO_ABS:
|
||||||
|
case SVGPathSeg.PATHSEG_MOVETO_REL:
|
||||||
|
return new SVGPathSegMovetoLinetoItem(command, PATHSEG_LETTERS[command],
|
||||||
|
parameters[j[0]++],
|
||||||
|
parameters[j[0]++]);
|
||||||
|
case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:
|
||||||
|
case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:
|
||||||
|
return new SVGPathSegLinetoHorizontalItem(command, PATHSEG_LETTERS[command],
|
||||||
|
parameters[j[0]++]);
|
||||||
|
case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:
|
||||||
|
case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:
|
||||||
|
return new SVGPathSegLinetoVerticalItem(command, PATHSEG_LETTERS[command],
|
||||||
|
parameters[j[0]++]);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the animated value.
|
||||||
|
*/
|
||||||
|
protected void setAnimatedValue(short[] commands, float[] parameters) {
|
||||||
|
int size = itemList.size();
|
||||||
|
int i = 0;
|
||||||
|
int[] j = parameterIndex;
|
||||||
|
j[0] = 0;
|
||||||
|
while (i < size && i < commands.length) {
|
||||||
|
SVGPathSeg s = (SVGPathSeg) itemList.get(i);
|
||||||
|
if (s.getPathSegType() != commands[i]) {
|
||||||
|
s = newItem(commands[i], parameters, j);
|
||||||
|
} else {
|
||||||
|
switch (commands[i]) {
|
||||||
|
case SVGPathSeg.PATHSEG_ARC_ABS:
|
||||||
|
case SVGPathSeg.PATHSEG_ARC_REL: {
|
||||||
|
SVGPathSegArcItem ps = (SVGPathSegArcItem) s;
|
||||||
|
ps.setR1(parameters[j[0]++]);
|
||||||
|
ps.setR2(parameters[j[0]++]);
|
||||||
|
ps.setAngle(parameters[j[0]++]);
|
||||||
|
ps.setLargeArcFlag(parameters[j[0]++] != 0);
|
||||||
|
ps.setSweepFlag(parameters[j[0]++] != 0);
|
||||||
|
ps.setX(parameters[j[0]++]);
|
||||||
|
ps.setY(parameters[j[0]++]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SVGPathSeg.PATHSEG_CLOSEPATH:
|
||||||
|
// Nothing to update.
|
||||||
|
break;
|
||||||
|
case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:
|
||||||
|
case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL: {
|
||||||
|
SVGPathSegCurvetoCubicItem ps =
|
||||||
|
(SVGPathSegCurvetoCubicItem) s;
|
||||||
|
ps.setX1(parameters[j[0]++]);
|
||||||
|
ps.setY1(parameters[j[0]++]);
|
||||||
|
ps.setX2(parameters[j[0]++]);
|
||||||
|
ps.setY2(parameters[j[0]++]);
|
||||||
|
ps.setX(parameters[j[0]++]);
|
||||||
|
ps.setY(parameters[j[0]++]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
|
||||||
|
case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL: {
|
||||||
|
SVGPathSegCurvetoCubicSmoothItem ps =
|
||||||
|
(SVGPathSegCurvetoCubicSmoothItem) s;
|
||||||
|
ps.setX2(parameters[j[0]++]);
|
||||||
|
ps.setY2(parameters[j[0]++]);
|
||||||
|
ps.setX(parameters[j[0]++]);
|
||||||
|
ps.setY(parameters[j[0]++]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:
|
||||||
|
case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL: {
|
||||||
|
SVGPathSegCurvetoQuadraticItem ps =
|
||||||
|
(SVGPathSegCurvetoQuadraticItem) s;
|
||||||
|
ps.setX1(parameters[j[0]++]);
|
||||||
|
ps.setY1(parameters[j[0]++]);
|
||||||
|
ps.setX(parameters[j[0]++]);
|
||||||
|
ps.setY(parameters[j[0]++]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:
|
||||||
|
case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: {
|
||||||
|
SVGPathSegCurvetoQuadraticSmoothItem ps =
|
||||||
|
(SVGPathSegCurvetoQuadraticSmoothItem) s;
|
||||||
|
ps.setX(parameters[j[0]++]);
|
||||||
|
ps.setY(parameters[j[0]++]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SVGPathSeg.PATHSEG_LINETO_ABS:
|
||||||
|
case SVGPathSeg.PATHSEG_LINETO_REL:
|
||||||
|
case SVGPathSeg.PATHSEG_MOVETO_ABS:
|
||||||
|
case SVGPathSeg.PATHSEG_MOVETO_REL: {
|
||||||
|
SVGPathSegMovetoLinetoItem ps =
|
||||||
|
(SVGPathSegMovetoLinetoItem) s;
|
||||||
|
ps.setX(parameters[j[0]++]);
|
||||||
|
ps.setY(parameters[j[0]++]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:
|
||||||
|
case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS: {
|
||||||
|
SVGPathSegLinetoHorizontalItem ps =
|
||||||
|
(SVGPathSegLinetoHorizontalItem) s;
|
||||||
|
ps.setX(parameters[j[0]++]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:
|
||||||
|
case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS: {
|
||||||
|
SVGPathSegLinetoVerticalItem ps =
|
||||||
|
(SVGPathSegLinetoVerticalItem) s;
|
||||||
|
ps.setY(parameters[j[0]++]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
while (i < commands.length) {
|
||||||
|
appendItemImpl(newItem(commands[i], parameters, j));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
while (size > commands.length) {
|
||||||
|
removeItemImpl(--size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the value of the associated attribute. Does nothing, since
|
||||||
|
* there is no attribute for an animated value.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the value of the associated attribute. Does nothing, since
|
||||||
|
* there is no attribute for an animated value.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute(SVGItem item) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the list, if needed. Does nothing, since there is no
|
||||||
|
* attribute to read the list from.
|
||||||
|
*/
|
||||||
|
protected void revalidate() {
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,485 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatablePointListValue;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
import org.apache.batik.dom.svg.AbstractSVGPointList;
|
||||||
|
import org.apache.batik.dom.svg.ListBuilder;
|
||||||
|
import org.apache.batik.dom.svg.LiveAttributeException;
|
||||||
|
import org.apache.batik.dom.svg.SVGItem;
|
||||||
|
import org.apache.batik.dom.svg.SVGPointItem;
|
||||||
|
|
||||||
|
import org.apache.batik.parser.ParseException;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedPoints;
|
||||||
|
import org.w3c.dom.svg.SVGException;
|
||||||
|
import org.w3c.dom.svg.SVGPoint;
|
||||||
|
import org.w3c.dom.svg.SVGPointList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is the implementation of the SVGAnimatedPoints interface.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:nicolas.socheleau@bitflash.com">Nicolas Socheleau</a>
|
||||||
|
* @version $Id: SVGOMAnimatedPoints.java 1804130 2017-08-04 14:41:11Z ssteiner $
|
||||||
|
*/
|
||||||
|
public class SVGOMAnimatedPoints
|
||||||
|
extends AbstractSVGAnimatedValue
|
||||||
|
implements SVGAnimatedPoints {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base value.
|
||||||
|
*/
|
||||||
|
protected BaseSVGPointList baseVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The animated value.
|
||||||
|
*/
|
||||||
|
protected AnimSVGPointList animVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the list is changing.
|
||||||
|
*/
|
||||||
|
protected boolean changing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default value for the point list.
|
||||||
|
*/
|
||||||
|
protected String defaultValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimatedPoints.
|
||||||
|
* @param elt The associated element.
|
||||||
|
* @param ns The attribute's namespace URI.
|
||||||
|
* @param ln The attribute's local name.
|
||||||
|
* @param defaultValue The default value if the attribute is not specified.
|
||||||
|
*/
|
||||||
|
public SVGOMAnimatedPoints(AbstractElement elt,
|
||||||
|
String ns,
|
||||||
|
String ln,
|
||||||
|
String defaultValue) {
|
||||||
|
super(elt, ns, ln);
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedPoints#getPoints()}.
|
||||||
|
*/
|
||||||
|
public SVGPointList getPoints() {
|
||||||
|
if (baseVal == null) {
|
||||||
|
baseVal = new BaseSVGPointList();
|
||||||
|
}
|
||||||
|
return baseVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedPoints#getAnimatedPoints()}.
|
||||||
|
*/
|
||||||
|
public SVGPointList getAnimatedPoints() {
|
||||||
|
if (animVal == null) {
|
||||||
|
animVal = new AnimSVGPointList();
|
||||||
|
}
|
||||||
|
return animVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throws an exception if the points list value is malformed.
|
||||||
|
*/
|
||||||
|
public void check() {
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
if (baseVal == null) {
|
||||||
|
baseVal = new BaseSVGPointList();
|
||||||
|
}
|
||||||
|
baseVal.revalidate();
|
||||||
|
if (baseVal.missing) {
|
||||||
|
throw new LiveAttributeException
|
||||||
|
(element, localName,
|
||||||
|
LiveAttributeException.ERR_ATTRIBUTE_MISSING, null);
|
||||||
|
}
|
||||||
|
if (baseVal.malformed) {
|
||||||
|
throw new LiveAttributeException
|
||||||
|
(element, localName,
|
||||||
|
LiveAttributeException.ERR_ATTRIBUTE_MALFORMED,
|
||||||
|
baseVal.getValueAsString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the base value of the attribute as an {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
public AnimatableValue getUnderlyingValue(AnimationTarget target) {
|
||||||
|
SVGPointList pl = getPoints();
|
||||||
|
int n = pl.getNumberOfItems();
|
||||||
|
float[] points = new float[n * 2];
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
SVGPoint p = pl.getItem(i);
|
||||||
|
points[i * 2] = p.getX();
|
||||||
|
points[i * 2 + 1] = p.getY();
|
||||||
|
}
|
||||||
|
return new AnimatablePointListValue(target, points);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the animated value with the given {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
protected void updateAnimatedValue(AnimatableValue val) {
|
||||||
|
if (val == null) {
|
||||||
|
hasAnimVal = false;
|
||||||
|
} else {
|
||||||
|
hasAnimVal = true;
|
||||||
|
AnimatablePointListValue animPointList =
|
||||||
|
(AnimatablePointListValue) val;
|
||||||
|
if (animVal == null) {
|
||||||
|
animVal = new AnimSVGPointList();
|
||||||
|
}
|
||||||
|
animVal.setAnimatedValue(animPointList.getNumbers());
|
||||||
|
}
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been added.
|
||||||
|
*/
|
||||||
|
public void attrAdded(Attr node, String newv) {
|
||||||
|
if (!changing && baseVal != null) {
|
||||||
|
baseVal.invalidate();
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been modified.
|
||||||
|
*/
|
||||||
|
public void attrModified(Attr node, String oldv, String newv) {
|
||||||
|
if (!changing && baseVal != null) {
|
||||||
|
baseVal.invalidate();
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been removed.
|
||||||
|
*/
|
||||||
|
public void attrRemoved(Attr node, String oldv) {
|
||||||
|
if (!changing && baseVal != null) {
|
||||||
|
baseVal.invalidate();
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link SVGPointList} implementation for the base point list value.
|
||||||
|
*/
|
||||||
|
protected class BaseSVGPointList extends AbstractSVGPointList {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the attribute is missing.
|
||||||
|
*/
|
||||||
|
protected boolean missing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the attribute is malformed.
|
||||||
|
*/
|
||||||
|
protected boolean malformed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a DOMException.
|
||||||
|
*/
|
||||||
|
protected DOMException createDOMException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
return element.createDOMException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a SVGException.
|
||||||
|
*/
|
||||||
|
protected SVGException createSVGException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
|
||||||
|
return ((SVGOMElement)element).createSVGException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the DOM attribute containing the point list.
|
||||||
|
*/
|
||||||
|
protected String getValueAsString() {
|
||||||
|
Attr attr = element.getAttributeNodeNS(namespaceURI, localName);
|
||||||
|
if (attr == null) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
return attr.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the DOM attribute value containing the point list.
|
||||||
|
*/
|
||||||
|
protected void setAttributeValue(String value) {
|
||||||
|
try {
|
||||||
|
changing = true;
|
||||||
|
element.setAttributeNS(namespaceURI, localName, value);
|
||||||
|
} finally {
|
||||||
|
changing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the value of the associated attribute.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute() {
|
||||||
|
super.resetAttribute();
|
||||||
|
missing = false;
|
||||||
|
malformed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends the string representation of the given {@link SVGItem} to
|
||||||
|
* the DOM attribute. This is called in response to an append to
|
||||||
|
* the list.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute(SVGItem item) {
|
||||||
|
super.resetAttribute(item);
|
||||||
|
missing = false;
|
||||||
|
malformed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the list, if needed.
|
||||||
|
*/
|
||||||
|
protected void revalidate() {
|
||||||
|
if (valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
valid = true;
|
||||||
|
missing = false;
|
||||||
|
malformed = false;
|
||||||
|
|
||||||
|
String s = getValueAsString();
|
||||||
|
if (s == null) {
|
||||||
|
missing = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ListBuilder builder = new ListBuilder(this);
|
||||||
|
|
||||||
|
doParse(s, builder);
|
||||||
|
|
||||||
|
if (builder.getList() != null) {
|
||||||
|
clear(itemList);
|
||||||
|
}
|
||||||
|
itemList = builder.getList();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
itemList = new ArrayList(1);
|
||||||
|
malformed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link SVGPointList} implementation for the animated point list value.
|
||||||
|
*/
|
||||||
|
protected class AnimSVGPointList extends AbstractSVGPointList {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new AnimSVGPointList.
|
||||||
|
*/
|
||||||
|
public AnimSVGPointList() {
|
||||||
|
itemList = new ArrayList(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a DOMException.
|
||||||
|
*/
|
||||||
|
protected DOMException createDOMException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
return element.createDOMException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a SVGException.
|
||||||
|
*/
|
||||||
|
protected SVGException createSVGException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
|
||||||
|
return ((SVGOMElement)element).createSVGException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGPointList#getNumberOfItems()}.
|
||||||
|
*/
|
||||||
|
public int getNumberOfItems() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getNumberOfItems();
|
||||||
|
}
|
||||||
|
return getPoints().getNumberOfItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGPointList#getItem(int)}.
|
||||||
|
*/
|
||||||
|
public SVGPoint getItem(int index) throws DOMException {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getItem(index);
|
||||||
|
}
|
||||||
|
return getPoints().getItem(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the DOM attribute containing the point list.
|
||||||
|
*/
|
||||||
|
protected String getValueAsString() {
|
||||||
|
if (itemList.size() == 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
StringBuffer sb = new StringBuffer( itemList.size() * 8 );
|
||||||
|
Iterator i = itemList.iterator();
|
||||||
|
if (i.hasNext()) {
|
||||||
|
sb.append(((SVGItem) i.next()).getValueAsString());
|
||||||
|
}
|
||||||
|
while (i.hasNext()) {
|
||||||
|
sb.append(getItemSeparator());
|
||||||
|
sb.append(((SVGItem) i.next()).getValueAsString());
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the DOM attribute value containing the point list.
|
||||||
|
*/
|
||||||
|
protected void setAttributeValue(String value) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGPointList#clear()}.
|
||||||
|
*/
|
||||||
|
public void clear() throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.point.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGPointList#initialize(SVGPoint)}.
|
||||||
|
*/
|
||||||
|
public SVGPoint initialize(SVGPoint newItem)
|
||||||
|
throws DOMException, SVGException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.point.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGPointList#insertItemBefore(SVGPoint, int)}.
|
||||||
|
*/
|
||||||
|
public SVGPoint insertItemBefore(SVGPoint newItem, int index)
|
||||||
|
throws DOMException, SVGException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.point.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGPointList#replaceItem(SVGPoint, int)}.
|
||||||
|
*/
|
||||||
|
public SVGPoint replaceItem(SVGPoint newItem, int index)
|
||||||
|
throws DOMException, SVGException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.point.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGPointList#removeItem(int)}.
|
||||||
|
*/
|
||||||
|
public SVGPoint removeItem(int index) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.point.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGPointList#appendItem(SVGPoint)}.
|
||||||
|
*/
|
||||||
|
public SVGPoint appendItem(SVGPoint newItem) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.point.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the animated value.
|
||||||
|
*/
|
||||||
|
protected void setAnimatedValue(float[] pts) {
|
||||||
|
int size = itemList.size();
|
||||||
|
int i = 0;
|
||||||
|
while (i < size && i < pts.length / 2) {
|
||||||
|
SVGPointItem p = (SVGPointItem) itemList.get(i);
|
||||||
|
p.setX(pts[i * 2]);
|
||||||
|
p.setY(pts[i * 2 + 1]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
while (i < pts.length / 2) {
|
||||||
|
appendItemImpl(new SVGPointItem(pts[i * 2], pts[i * 2 + 1]));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
while (size > pts.length / 2) {
|
||||||
|
removeItemImpl(--size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the value of the associated attribute. Does nothing, since
|
||||||
|
* there is no attribute for an animated value.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the value of the associated attribute. Does nothing, since
|
||||||
|
* there is no attribute for an animated value.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute(SVGItem item) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the list, if needed. Does nothing, since there is no
|
||||||
|
* attribute to read the list from.
|
||||||
|
*/
|
||||||
|
protected void revalidate() {
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,289 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatablePreserveAspectRatioValue;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
import org.apache.batik.dom.svg.AbstractSVGPreserveAspectRatio;
|
||||||
|
import org.apache.batik.dom.svg.LiveAttributeException;
|
||||||
|
|
||||||
|
import org.apache.batik.util.SVGConstants;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedPreserveAspectRatio;
|
||||||
|
import org.w3c.dom.svg.SVGPreserveAspectRatio;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements the {@link SVGAnimatedPreserveAspectRatio} interface.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:tonny@kiyut.com">Tonny Kohar</a>
|
||||||
|
* @version $Id: SVGOMAnimatedPreserveAspectRatio.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMAnimatedPreserveAspectRatio
|
||||||
|
extends AbstractSVGAnimatedValue
|
||||||
|
implements SVGAnimatedPreserveAspectRatio {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base value.
|
||||||
|
*/
|
||||||
|
protected BaseSVGPARValue baseVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The animated value.
|
||||||
|
*/
|
||||||
|
protected AnimSVGPARValue animVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the value is changing.
|
||||||
|
*/
|
||||||
|
protected boolean changing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimatedPreserveAspectRatio.
|
||||||
|
* @param elt The associated element.
|
||||||
|
*/
|
||||||
|
public SVGOMAnimatedPreserveAspectRatio(AbstractElement elt) {
|
||||||
|
super(elt, null, SVGConstants.SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedPreserveAspectRatio#getBaseVal()}.
|
||||||
|
*/
|
||||||
|
public SVGPreserveAspectRatio getBaseVal() {
|
||||||
|
if (baseVal == null) {
|
||||||
|
baseVal = new BaseSVGPARValue();
|
||||||
|
}
|
||||||
|
return baseVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedPreserveAspectRatio#getAnimVal()}.
|
||||||
|
*/
|
||||||
|
public SVGPreserveAspectRatio getAnimVal() {
|
||||||
|
if (animVal == null) {
|
||||||
|
animVal = new AnimSVGPARValue();
|
||||||
|
}
|
||||||
|
return animVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throws an exception if the points list value is malformed.
|
||||||
|
*/
|
||||||
|
public void check() {
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
if (baseVal == null) {
|
||||||
|
baseVal = new BaseSVGPARValue();
|
||||||
|
}
|
||||||
|
if (baseVal.malformed) {
|
||||||
|
throw new LiveAttributeException
|
||||||
|
(element, localName,
|
||||||
|
LiveAttributeException.ERR_ATTRIBUTE_MALFORMED,
|
||||||
|
baseVal.getValueAsString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the base value of the attribute as an {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
public AnimatableValue getUnderlyingValue(AnimationTarget target) {
|
||||||
|
SVGPreserveAspectRatio par = getBaseVal();
|
||||||
|
return new AnimatablePreserveAspectRatioValue(target, par.getAlign(),
|
||||||
|
par.getMeetOrSlice());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the animated value with the given {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
protected void updateAnimatedValue(AnimatableValue val) {
|
||||||
|
if (val == null) {
|
||||||
|
hasAnimVal = false;
|
||||||
|
} else {
|
||||||
|
hasAnimVal = true;
|
||||||
|
if (animVal == null) {
|
||||||
|
animVal = new AnimSVGPARValue();
|
||||||
|
}
|
||||||
|
AnimatablePreserveAspectRatioValue animPAR =
|
||||||
|
(AnimatablePreserveAspectRatioValue) val;
|
||||||
|
animVal.setAnimatedValue(animPAR.getAlign(),
|
||||||
|
animPAR.getMeetOrSlice());
|
||||||
|
}
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been added.
|
||||||
|
*/
|
||||||
|
public void attrAdded(Attr node, String newv) {
|
||||||
|
if (!changing && baseVal != null) {
|
||||||
|
baseVal.invalidate();
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been modified.
|
||||||
|
*/
|
||||||
|
public void attrModified(Attr node, String oldv, String newv) {
|
||||||
|
if (!changing && baseVal != null) {
|
||||||
|
baseVal.invalidate();
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been removed.
|
||||||
|
*/
|
||||||
|
public void attrRemoved(Attr node, String oldv) {
|
||||||
|
if (!changing && baseVal != null) {
|
||||||
|
baseVal.invalidate();
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents the SVGPreserveAspectRatio returned by {@link
|
||||||
|
* #getBaseVal()}.
|
||||||
|
*/
|
||||||
|
public class BaseSVGPARValue extends AbstractSVGPreserveAspectRatio {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the attribute is malformed.
|
||||||
|
*/
|
||||||
|
protected boolean malformed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new BaseSVGPARValue.
|
||||||
|
*/
|
||||||
|
public BaseSVGPARValue() {
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a DOMException.
|
||||||
|
*/
|
||||||
|
protected DOMException createDOMException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
return element.createDOMException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the associated DOM attribute.
|
||||||
|
*/
|
||||||
|
protected void setAttributeValue(String value) throws DOMException {
|
||||||
|
try {
|
||||||
|
changing = true;
|
||||||
|
element.setAttributeNS
|
||||||
|
(null, SVGConstants.SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE,
|
||||||
|
value);
|
||||||
|
malformed = false;
|
||||||
|
} finally {
|
||||||
|
changing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Re-reads the DOM attribute value.
|
||||||
|
*/
|
||||||
|
protected void invalidate() {
|
||||||
|
String s = element.getAttributeNS
|
||||||
|
(null, SVGConstants.SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE);
|
||||||
|
setValueAsString(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents the SVGPreserveAspectRatio returned by {@link
|
||||||
|
* #getAnimVal()}.
|
||||||
|
*/
|
||||||
|
public class AnimSVGPARValue extends AbstractSVGPreserveAspectRatio {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a DOMException.
|
||||||
|
*/
|
||||||
|
protected DOMException createDOMException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
return element.createDOMException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the associated DOM attribute. Does nothing, since animated
|
||||||
|
* values aren't reflected in the DOM.
|
||||||
|
*/
|
||||||
|
protected void setAttributeValue(String value) throws DOMException {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGPreserveAspectRatio#getAlign()}.
|
||||||
|
*/
|
||||||
|
public short getAlign() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getAlign();
|
||||||
|
}
|
||||||
|
return getBaseVal().getAlign();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGPreserveAspectRatio#getMeetOrSlice()}.
|
||||||
|
*/
|
||||||
|
public short getMeetOrSlice() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getMeetOrSlice();
|
||||||
|
}
|
||||||
|
return getBaseVal().getMeetOrSlice();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGPreserveAspectRatio#setAlign(short)}.
|
||||||
|
*/
|
||||||
|
public void setAlign(short align) {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.preserve.aspect.ratio", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGPreserveAspectRatio#setMeetOrSlice(short)}.
|
||||||
|
*/
|
||||||
|
public void setMeetOrSlice(short meetOrSlice) {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.preserve.aspect.ratio", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the animated value.
|
||||||
|
*/
|
||||||
|
protected void setAnimatedValue(short align, short meetOrSlice) {
|
||||||
|
this.align = align;
|
||||||
|
this.meetOrSlice = meetOrSlice;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,395 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatableRectValue;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
import org.apache.batik.dom.svg.LiveAttributeException;
|
||||||
|
import org.apache.batik.dom.svg.SVGOMRect;
|
||||||
|
import org.apache.batik.parser.DefaultNumberListHandler;
|
||||||
|
import org.apache.batik.parser.NumberListParser;
|
||||||
|
import org.apache.batik.parser.ParseException;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedRect;
|
||||||
|
import org.w3c.dom.svg.SVGRect;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of {@link SVGAnimatedRect}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
|
||||||
|
* @version $Id: SVGOMAnimatedRect.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMAnimatedRect
|
||||||
|
extends AbstractSVGAnimatedValue
|
||||||
|
implements SVGAnimatedRect {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base value.
|
||||||
|
*/
|
||||||
|
protected BaseSVGRect baseVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The animated value.
|
||||||
|
*/
|
||||||
|
protected AnimSVGRect animVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the value is changing.
|
||||||
|
*/
|
||||||
|
protected boolean changing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default value.
|
||||||
|
*/
|
||||||
|
protected String defaultValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimatedRect.
|
||||||
|
* @param elt The associated element.
|
||||||
|
* @param ns The attribute's namespace URI.
|
||||||
|
* @param ln The attribute's local name.
|
||||||
|
* @param def The default value for the attribute.
|
||||||
|
*/
|
||||||
|
public SVGOMAnimatedRect(AbstractElement elt, String ns, String ln,
|
||||||
|
String def) {
|
||||||
|
super(elt, ns, ln);
|
||||||
|
defaultValue = def;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedRect#getBaseVal()}.
|
||||||
|
*/
|
||||||
|
public SVGRect getBaseVal() {
|
||||||
|
if (baseVal == null) {
|
||||||
|
baseVal = new BaseSVGRect();
|
||||||
|
}
|
||||||
|
return baseVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedRect#getAnimVal()}.
|
||||||
|
*/
|
||||||
|
public SVGRect getAnimVal() {
|
||||||
|
if (animVal == null) {
|
||||||
|
animVal = new AnimSVGRect();
|
||||||
|
}
|
||||||
|
return animVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the animated value with the given {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
protected void updateAnimatedValue(AnimatableValue val) {
|
||||||
|
if (val == null) {
|
||||||
|
hasAnimVal = false;
|
||||||
|
} else {
|
||||||
|
hasAnimVal = true;
|
||||||
|
AnimatableRectValue animRect = (AnimatableRectValue) val;
|
||||||
|
if (animVal == null) {
|
||||||
|
animVal = new AnimSVGRect();
|
||||||
|
}
|
||||||
|
animVal.setAnimatedValue(animRect.getX(), animRect.getY(),
|
||||||
|
animRect.getWidth(), animRect.getHeight());
|
||||||
|
}
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the base value of the attribute as an {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
public AnimatableValue getUnderlyingValue(AnimationTarget target) {
|
||||||
|
SVGRect r = getBaseVal();
|
||||||
|
return new AnimatableRectValue
|
||||||
|
(target, r.getX(), r.getY(), r.getWidth(), r.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been added.
|
||||||
|
*/
|
||||||
|
public void attrAdded(Attr node, String newv) {
|
||||||
|
if (!changing && baseVal != null) {
|
||||||
|
baseVal.invalidate();
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been modified.
|
||||||
|
*/
|
||||||
|
public void attrModified(Attr node, String oldv, String newv) {
|
||||||
|
if (!changing && baseVal != null) {
|
||||||
|
baseVal.invalidate();
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been removed.
|
||||||
|
*/
|
||||||
|
public void attrRemoved(Attr node, String oldv) {
|
||||||
|
if (!changing && baseVal != null) {
|
||||||
|
baseVal.invalidate();
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents the SVGRect returned by getBaseVal().
|
||||||
|
*/
|
||||||
|
protected class BaseSVGRect extends SVGOMRect {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this rect is valid.
|
||||||
|
*/
|
||||||
|
protected boolean valid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalidates this length.
|
||||||
|
*/
|
||||||
|
public void invalidate() {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the value of the associated attribute.
|
||||||
|
*/
|
||||||
|
protected void reset() {
|
||||||
|
try {
|
||||||
|
changing = true;
|
||||||
|
element.setAttributeNS
|
||||||
|
(namespaceURI, localName,
|
||||||
|
Float.toString(x) + ' ' + y + ' ' + w + ' ' + h);
|
||||||
|
} finally {
|
||||||
|
changing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the length, if needed.
|
||||||
|
*/
|
||||||
|
protected void revalidate() {
|
||||||
|
if (valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Attr attr = element.getAttributeNodeNS(namespaceURI, localName);
|
||||||
|
|
||||||
|
final String s = attr == null ? defaultValue : attr.getValue();
|
||||||
|
final float[] numbers = new float[4];
|
||||||
|
NumberListParser p = new NumberListParser();
|
||||||
|
p.setNumberListHandler(new DefaultNumberListHandler() {
|
||||||
|
protected int count;
|
||||||
|
public void endNumberList() {
|
||||||
|
if (count != 4) {
|
||||||
|
throw new LiveAttributeException
|
||||||
|
(element, localName,
|
||||||
|
LiveAttributeException.ERR_ATTRIBUTE_MALFORMED,
|
||||||
|
s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void numberValue(float v) throws ParseException {
|
||||||
|
if (count < 4) {
|
||||||
|
numbers[count] = v;
|
||||||
|
}
|
||||||
|
if (v < 0 && (count == 2 || count == 3)) {
|
||||||
|
throw new LiveAttributeException
|
||||||
|
(element, localName,
|
||||||
|
LiveAttributeException.ERR_ATTRIBUTE_MALFORMED,
|
||||||
|
s);
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
p.parse(s);
|
||||||
|
x = numbers[0];
|
||||||
|
y = numbers[1];
|
||||||
|
w = numbers[2];
|
||||||
|
h = numbers[3];
|
||||||
|
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGRect#getX()}.
|
||||||
|
*/
|
||||||
|
public float getX() {
|
||||||
|
revalidate();
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGRect#setX(float)}.
|
||||||
|
*/
|
||||||
|
public void setX(float x) throws DOMException {
|
||||||
|
this.x = x;
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGRect#getY()}.
|
||||||
|
*/
|
||||||
|
public float getY() {
|
||||||
|
revalidate();
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGRect#setY(float)}.
|
||||||
|
*/
|
||||||
|
public void setY(float y) throws DOMException {
|
||||||
|
this.y = y;
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGRect#getWidth()}.
|
||||||
|
*/
|
||||||
|
public float getWidth() {
|
||||||
|
revalidate();
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGRect#setWidth(float)}.
|
||||||
|
*/
|
||||||
|
public void setWidth(float width) throws DOMException {
|
||||||
|
this.w = width;
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGRect#getHeight()}.
|
||||||
|
*/
|
||||||
|
public float getHeight() {
|
||||||
|
revalidate();
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGRect#setHeight(float)}.
|
||||||
|
*/
|
||||||
|
public void setHeight(float height) throws DOMException {
|
||||||
|
this.h = height;
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents the SVGRect returned by getAnimVal().
|
||||||
|
*/
|
||||||
|
protected class AnimSVGRect extends SVGOMRect {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGRect#getX()}.
|
||||||
|
*/
|
||||||
|
public float getX() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getX();
|
||||||
|
}
|
||||||
|
return getBaseVal().getX();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGRect#getY()}.
|
||||||
|
*/
|
||||||
|
public float getY() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getY();
|
||||||
|
}
|
||||||
|
return getBaseVal().getY();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGRect#getWidth()}.
|
||||||
|
*/
|
||||||
|
public float getWidth() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getWidth();
|
||||||
|
}
|
||||||
|
return getBaseVal().getWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGRect#getHeight()}.
|
||||||
|
*/
|
||||||
|
public float getHeight() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getHeight();
|
||||||
|
}
|
||||||
|
return getBaseVal().getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGRect#setX(float)}.
|
||||||
|
*/
|
||||||
|
public void setX(float value) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.length",
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGRect#setY(float)}.
|
||||||
|
*/
|
||||||
|
public void setY(float value) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.length",
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGRect#setWidth(float)}.
|
||||||
|
*/
|
||||||
|
public void setWidth(float value) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.length",
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGRect#setHeight(float)}.
|
||||||
|
*/
|
||||||
|
public void setHeight(float value) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.length",
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the animated value.
|
||||||
|
*/
|
||||||
|
protected void setAnimatedValue(float x, float y, float w, float h) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.w = w;
|
||||||
|
this.h = h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatableStringValue;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements the {@link SVGAnimatedString} interface.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMAnimatedString.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMAnimatedString extends AbstractSVGAnimatedValue
|
||||||
|
implements SVGAnimatedString {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current animated value.
|
||||||
|
*/
|
||||||
|
protected String animVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimatedString.
|
||||||
|
* @param elt The associated element.
|
||||||
|
* @param ns The attribute's namespace URI.
|
||||||
|
* @param ln The attribute's local name.
|
||||||
|
*/
|
||||||
|
public SVGOMAnimatedString(AbstractElement elt,
|
||||||
|
String ns,
|
||||||
|
String ln) {
|
||||||
|
super(elt, ns, ln);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedString#getBaseVal()}.
|
||||||
|
*/
|
||||||
|
public String getBaseVal() {
|
||||||
|
return element.getAttributeNS(namespaceURI, localName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedString#setBaseVal(String)}.
|
||||||
|
*/
|
||||||
|
public void setBaseVal(String baseVal) throws DOMException {
|
||||||
|
element.setAttributeNS(namespaceURI, localName, baseVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedString#getAnimVal()}.
|
||||||
|
*/
|
||||||
|
public String getAnimVal() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return animVal;
|
||||||
|
}
|
||||||
|
return element.getAttributeNS(namespaceURI, localName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the base value of the attribute as an {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
public AnimatableValue getUnderlyingValue(AnimationTarget target) {
|
||||||
|
return new AnimatableStringValue(target, getBaseVal());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the animated value with the given {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
protected void updateAnimatedValue(AnimatableValue val) {
|
||||||
|
if (val == null) {
|
||||||
|
hasAnimVal = false;
|
||||||
|
} else {
|
||||||
|
hasAnimVal = true;
|
||||||
|
this.animVal = ((AnimatableStringValue) val).getString();
|
||||||
|
}
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been added.
|
||||||
|
*/
|
||||||
|
public void attrAdded(Attr node, String newv) {
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been modified.
|
||||||
|
*/
|
||||||
|
public void attrModified(Attr node, String oldv, String newv) {
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been removed.
|
||||||
|
*/
|
||||||
|
public void attrRemoved(Attr node, String oldv) {
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,507 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedTransformList;
|
||||||
|
import org.w3c.dom.svg.SVGException;
|
||||||
|
import org.w3c.dom.svg.SVGTransform;
|
||||||
|
import org.w3c.dom.svg.SVGTransformList;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatableTransformListValue;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
import org.apache.batik.dom.svg.AbstractSVGTransformList;
|
||||||
|
import org.apache.batik.dom.svg.ListBuilder;
|
||||||
|
import org.apache.batik.dom.svg.LiveAttributeException;
|
||||||
|
import org.apache.batik.dom.svg.SVGItem;
|
||||||
|
import org.apache.batik.parser.ParseException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is the implementation of the SVGAnimatedTransformList interface.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:nicolas.socheleau@bitflash.com">Nicolas Socheleau</a>
|
||||||
|
* @version $Id: SVGOMAnimatedTransformList.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMAnimatedTransformList
|
||||||
|
extends AbstractSVGAnimatedValue
|
||||||
|
implements SVGAnimatedTransformList {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base value.
|
||||||
|
*/
|
||||||
|
protected BaseSVGTransformList baseVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The animated value.
|
||||||
|
*/
|
||||||
|
protected AnimSVGTransformList animVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the list is changing.
|
||||||
|
*/
|
||||||
|
protected boolean changing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default value for the 'transform' attribute.
|
||||||
|
*/
|
||||||
|
protected String defaultValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimatedTransformList.
|
||||||
|
* @param elt The associated element.
|
||||||
|
* @param ns The attribute's namespace URI.
|
||||||
|
* @param ln The attribute's local name.
|
||||||
|
* @param defaultValue The default value if the attribute is not specified.
|
||||||
|
*/
|
||||||
|
public SVGOMAnimatedTransformList(AbstractElement elt,
|
||||||
|
String ns,
|
||||||
|
String ln,
|
||||||
|
String defaultValue) {
|
||||||
|
super(elt, ns, ln);
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedTransformList#getBaseVal()}.
|
||||||
|
*/
|
||||||
|
public SVGTransformList getBaseVal() {
|
||||||
|
if (baseVal == null) {
|
||||||
|
baseVal = new BaseSVGTransformList();
|
||||||
|
}
|
||||||
|
return baseVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimatedTransformList#getAnimVal()}.
|
||||||
|
*/
|
||||||
|
public SVGTransformList getAnimVal() {
|
||||||
|
if (animVal == null) {
|
||||||
|
animVal = new AnimSVGTransformList();
|
||||||
|
}
|
||||||
|
return animVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throws an exception if the points list value is malformed.
|
||||||
|
*/
|
||||||
|
public void check() {
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
if (baseVal == null) {
|
||||||
|
baseVal = new BaseSVGTransformList();
|
||||||
|
}
|
||||||
|
baseVal.revalidate();
|
||||||
|
if (baseVal.missing) {
|
||||||
|
throw new LiveAttributeException
|
||||||
|
(element, localName,
|
||||||
|
LiveAttributeException.ERR_ATTRIBUTE_MISSING, null);
|
||||||
|
}
|
||||||
|
if (baseVal.malformed) {
|
||||||
|
throw new LiveAttributeException
|
||||||
|
(element, localName,
|
||||||
|
LiveAttributeException.ERR_ATTRIBUTE_MALFORMED,
|
||||||
|
baseVal.getValueAsString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the base value of the attribute as an {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
public AnimatableValue getUnderlyingValue(AnimationTarget target) {
|
||||||
|
SVGTransformList tl = getBaseVal();
|
||||||
|
int n = tl.getNumberOfItems();
|
||||||
|
List v = new ArrayList(n);
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
v.add(tl.getItem(i));
|
||||||
|
}
|
||||||
|
return new AnimatableTransformListValue(target, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the animated value with the given {@link AnimatableValue}.
|
||||||
|
*/
|
||||||
|
protected void updateAnimatedValue(AnimatableValue val) {
|
||||||
|
if (val == null) {
|
||||||
|
hasAnimVal = false;
|
||||||
|
} else {
|
||||||
|
hasAnimVal = true;
|
||||||
|
AnimatableTransformListValue aval =
|
||||||
|
(AnimatableTransformListValue) val;
|
||||||
|
if (animVal == null) {
|
||||||
|
animVal = new AnimSVGTransformList();
|
||||||
|
}
|
||||||
|
animVal.setAnimatedValue(aval.getTransforms());
|
||||||
|
}
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been added.
|
||||||
|
*/
|
||||||
|
public void attrAdded(Attr node, String newv) {
|
||||||
|
if (!changing && baseVal != null) {
|
||||||
|
baseVal.invalidate();
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been modified.
|
||||||
|
*/
|
||||||
|
public void attrModified(Attr node, String oldv, String newv) {
|
||||||
|
if (!changing && baseVal != null) {
|
||||||
|
baseVal.invalidate();
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an Attr node has been removed.
|
||||||
|
*/
|
||||||
|
public void attrRemoved(Attr node, String oldv) {
|
||||||
|
if (!changing && baseVal != null) {
|
||||||
|
baseVal.invalidate();
|
||||||
|
}
|
||||||
|
fireBaseAttributeListeners();
|
||||||
|
if (!hasAnimVal) {
|
||||||
|
fireAnimatedAttributeListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link SVGTransformList} implementation for the base transform list value.
|
||||||
|
*/
|
||||||
|
public class BaseSVGTransformList extends AbstractSVGTransformList {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the attribute is missing.
|
||||||
|
*/
|
||||||
|
protected boolean missing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the attribute is malformed.
|
||||||
|
*/
|
||||||
|
protected boolean malformed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a DOMException.
|
||||||
|
*/
|
||||||
|
protected DOMException createDOMException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
return element.createDOMException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a SVGException.
|
||||||
|
*/
|
||||||
|
protected SVGException createSVGException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
|
||||||
|
return ((SVGOMElement)element).createSVGException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the DOM attribute containing the transform list.
|
||||||
|
*/
|
||||||
|
protected String getValueAsString() {
|
||||||
|
Attr attr = element.getAttributeNodeNS(namespaceURI, localName);
|
||||||
|
if (attr == null) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
return attr.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the DOM attribute value containing the transform list.
|
||||||
|
*/
|
||||||
|
protected void setAttributeValue(String value) {
|
||||||
|
try {
|
||||||
|
changing = true;
|
||||||
|
element.setAttributeNS(namespaceURI, localName, value);
|
||||||
|
} finally {
|
||||||
|
changing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the value of the associated attribute.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute() {
|
||||||
|
super.resetAttribute();
|
||||||
|
missing = false;
|
||||||
|
malformed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends the string representation of the given {@link SVGItem} to
|
||||||
|
* the DOM attribute. This is called in response to an append to
|
||||||
|
* the list.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute(SVGItem item) {
|
||||||
|
super.resetAttribute(item);
|
||||||
|
missing = false;
|
||||||
|
malformed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the list, if needed.
|
||||||
|
*/
|
||||||
|
protected void revalidate() {
|
||||||
|
if (valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
valid = true;
|
||||||
|
missing = false;
|
||||||
|
malformed = false;
|
||||||
|
|
||||||
|
String s = getValueAsString();
|
||||||
|
if (s == null) {
|
||||||
|
missing = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ListBuilder builder = new ListBuilder(this);
|
||||||
|
|
||||||
|
doParse(s, builder);
|
||||||
|
|
||||||
|
if (builder.getList() != null) {
|
||||||
|
clear(itemList);
|
||||||
|
}
|
||||||
|
itemList = builder.getList();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
itemList = new ArrayList(1);
|
||||||
|
malformed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link SVGTransformList} implementation for the animated transform list
|
||||||
|
* value.
|
||||||
|
*/
|
||||||
|
protected class AnimSVGTransformList extends AbstractSVGTransformList {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new AnimSVGTransformList.
|
||||||
|
*/
|
||||||
|
public AnimSVGTransformList() {
|
||||||
|
itemList = new ArrayList(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a DOMException.
|
||||||
|
*/
|
||||||
|
protected DOMException createDOMException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
return element.createDOMException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a SVGException.
|
||||||
|
*/
|
||||||
|
protected SVGException createSVGException(short type, String key,
|
||||||
|
Object[] args) {
|
||||||
|
|
||||||
|
return ((SVGOMElement)element).createSVGException(type, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGTransformList#getNumberOfItems()}.
|
||||||
|
*/
|
||||||
|
public int getNumberOfItems() {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getNumberOfItems();
|
||||||
|
}
|
||||||
|
return getBaseVal().getNumberOfItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGTransformList#getItem(int)}.
|
||||||
|
*/
|
||||||
|
public SVGTransform getItem(int index) throws DOMException {
|
||||||
|
if (hasAnimVal) {
|
||||||
|
return super.getItem(index);
|
||||||
|
}
|
||||||
|
return getBaseVal().getItem(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the DOM attribute containing the transform list.
|
||||||
|
*/
|
||||||
|
protected String getValueAsString() {
|
||||||
|
if (itemList.size() == 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
StringBuffer sb = new StringBuffer( itemList.size() * 8 );
|
||||||
|
Iterator i = itemList.iterator();
|
||||||
|
if (i.hasNext()) {
|
||||||
|
sb.append(((SVGItem) i.next()).getValueAsString());
|
||||||
|
}
|
||||||
|
while (i.hasNext()) {
|
||||||
|
sb.append(getItemSeparator());
|
||||||
|
sb.append(((SVGItem) i.next()).getValueAsString());
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the DOM attribute value containing the transform list.
|
||||||
|
*/
|
||||||
|
protected void setAttributeValue(String value) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGTransformList#clear()}.
|
||||||
|
*/
|
||||||
|
public void clear() throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.transform.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGTransformList#initialize(SVGTransform)}.
|
||||||
|
*/
|
||||||
|
public SVGTransform initialize(SVGTransform newItem)
|
||||||
|
throws DOMException, SVGException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.transform.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGTransformList#insertItemBefore(SVGTransform, int)}.
|
||||||
|
*/
|
||||||
|
public SVGTransform insertItemBefore(SVGTransform newItem, int index)
|
||||||
|
throws DOMException, SVGException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.transform.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGTransformList#replaceItem(SVGTransform, int)}.
|
||||||
|
*/
|
||||||
|
public SVGTransform replaceItem(SVGTransform newItem, int index)
|
||||||
|
throws DOMException, SVGException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.transform.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGTransformList#removeItem(int)}.
|
||||||
|
*/
|
||||||
|
public SVGTransform removeItem(int index) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.transform.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGTransformList#appendItem(SVGTransform)}.
|
||||||
|
*/
|
||||||
|
public SVGTransform appendItem(SVGTransform newItem) throws DOMException {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.transform.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGTransformList#consolidate()}.
|
||||||
|
*/
|
||||||
|
public SVGTransform consolidate() {
|
||||||
|
throw element.createDOMException
|
||||||
|
(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.transform.list", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the animated value to a list of transforms.
|
||||||
|
*/
|
||||||
|
protected void setAnimatedValue(Iterator it) {
|
||||||
|
int size = itemList.size();
|
||||||
|
int i = 0;
|
||||||
|
while (i < size && it.hasNext()) {
|
||||||
|
SVGTransformItem t = (SVGTransformItem) itemList.get(i);
|
||||||
|
t.assign((SVGTransform) it.next());
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
while (it.hasNext()) {
|
||||||
|
appendItemImpl(new SVGTransformItem((SVGTransform) it.next()));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
while (size > i) {
|
||||||
|
removeItemImpl(--size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the animated value to a single transform.
|
||||||
|
*/
|
||||||
|
protected void setAnimatedValue(SVGTransform transform) {
|
||||||
|
int size = itemList.size();
|
||||||
|
while (size > 1) {
|
||||||
|
removeItemImpl(--size);
|
||||||
|
}
|
||||||
|
if (size == 0) {
|
||||||
|
appendItemImpl(new SVGTransformItem(transform));
|
||||||
|
} else {
|
||||||
|
SVGTransformItem t = (SVGTransformItem) itemList.get(0);
|
||||||
|
t.assign(transform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the value of the associated attribute. Does nothing, since
|
||||||
|
* there is no attribute for an animated value.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the value of the associated attribute. Does nothing, since
|
||||||
|
* there is no attribute for an animated value.
|
||||||
|
*/
|
||||||
|
protected void resetAttribute(SVGItem item) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the list, if needed. Does nothing, since there is no
|
||||||
|
* attribute to read the list from.
|
||||||
|
*/
|
||||||
|
protected void revalidate() {
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,221 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.timing.TimedElement;
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.dom.svg.SVGAnimationContext;
|
||||||
|
import org.apache.batik.dom.svg.SVGTestsSupport;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedBoolean;
|
||||||
|
import org.w3c.dom.svg.SVGAnimationElement;
|
||||||
|
import org.w3c.dom.svg.SVGElement;
|
||||||
|
import org.w3c.dom.svg.SVGStringList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides an implementation of the {@link SVGAnimationElement} interface.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMAnimationElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public abstract class SVGOMAnimationElement
|
||||||
|
extends SVGOMElement
|
||||||
|
implements SVGAnimationElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMElement.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_EXTERNAL_RESOURCES_REQUIRED_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_BOOLEAN));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'externalResourcesRequired' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedBoolean externalResourcesRequired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimationElement.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimationElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMAnimationElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimationElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
externalResourcesRequired =
|
||||||
|
createLiveAnimatedBoolean
|
||||||
|
(null, SVG_EXTERNAL_RESOURCES_REQUIRED_ATTRIBUTE, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimationElement#getTargetElement()}.
|
||||||
|
*/
|
||||||
|
public SVGElement getTargetElement() {
|
||||||
|
return ((SVGAnimationContext) getSVGContext()).getTargetElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimationElement#getStartTime()}.
|
||||||
|
*/
|
||||||
|
public float getStartTime() {
|
||||||
|
return ((SVGAnimationContext) getSVGContext()).getStartTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimationElement#getCurrentTime()}.
|
||||||
|
*/
|
||||||
|
public float getCurrentTime() {
|
||||||
|
return ((SVGAnimationContext) getSVGContext()).getCurrentTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGAnimationElement#getSimpleDuration()}.
|
||||||
|
*/
|
||||||
|
public float getSimpleDuration() throws DOMException {
|
||||||
|
float dur = ((SVGAnimationContext) getSVGContext()).getSimpleDuration();
|
||||||
|
if (dur == TimedElement.INDEFINITE) {
|
||||||
|
throw createDOMException(DOMException.NOT_SUPPORTED_ERR,
|
||||||
|
"animation.dur.indefinite",
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
return dur;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the time that the document would seek to if this animation
|
||||||
|
* element were hyperlinked to, or <code>NaN</code> if there is no
|
||||||
|
* such begin time.
|
||||||
|
*/
|
||||||
|
public float getHyperlinkBeginTime() {
|
||||||
|
return ((SVGAnimationContext) getSVGContext()).getHyperlinkBeginTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ElementTimeControl ////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.smil.ElementTimeControl#beginElement()}.
|
||||||
|
*/
|
||||||
|
public boolean beginElement() throws DOMException {
|
||||||
|
return ((SVGAnimationContext) getSVGContext()).beginElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.smil.ElementTimeControl#beginElementAt(float)}.
|
||||||
|
*/
|
||||||
|
public boolean beginElementAt(float offset) throws DOMException {
|
||||||
|
return ((SVGAnimationContext) getSVGContext()).beginElementAt(offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.smil.ElementTimeControl#endElement()}.
|
||||||
|
*/
|
||||||
|
public boolean endElement() throws DOMException {
|
||||||
|
return ((SVGAnimationContext) getSVGContext()).endElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.smil.ElementTimeControl#endElementAt(float)}.
|
||||||
|
*/
|
||||||
|
public boolean endElementAt(float offset) throws DOMException {
|
||||||
|
return ((SVGAnimationContext) getSVGContext()).endElementAt(offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SVGExternalResourcesRequired support /////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGExternalResourcesRequired#getExternalResourcesRequired()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedBoolean getExternalResourcesRequired() {
|
||||||
|
return externalResourcesRequired;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SVGTests support ///////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGTests#getRequiredFeatures()}.
|
||||||
|
*/
|
||||||
|
public SVGStringList getRequiredFeatures() {
|
||||||
|
return SVGTestsSupport.getRequiredFeatures(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGTests#getRequiredExtensions()}.
|
||||||
|
*/
|
||||||
|
public SVGStringList getRequiredExtensions() {
|
||||||
|
return SVGTestsSupport.getRequiredExtensions(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGTests#getSystemLanguage()}.
|
||||||
|
*/
|
||||||
|
public SVGStringList getSystemLanguage() {
|
||||||
|
return SVGTestsSupport.getSystemLanguage(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGTests#hasExtension(String)}.
|
||||||
|
*/
|
||||||
|
public boolean hasExtension(String extension) {
|
||||||
|
return SVGTestsSupport.hasExtension(this, extension);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,150 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedLength;
|
||||||
|
import org.w3c.dom.svg.SVGCircleElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGCircleElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMCircleElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMCircleElement
|
||||||
|
extends SVGGraphicsElement
|
||||||
|
implements SVGCircleElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGGraphicsElement.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_CX_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_LENGTH, TraitInformation.PERCENTAGE_VIEWPORT_WIDTH));
|
||||||
|
t.put(null, SVG_CY_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_LENGTH, TraitInformation.PERCENTAGE_VIEWPORT_HEIGHT));
|
||||||
|
t.put(null, SVG_R_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_LENGTH, TraitInformation.PERCENTAGE_VIEWPORT_SIZE));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'cx' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedLength cx;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'cy' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedLength cy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'r' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedLength r;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMCircleElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMCircleElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMCircleElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMCircleElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
cx = createLiveAnimatedLength
|
||||||
|
(null, SVG_CX_ATTRIBUTE, SVG_CIRCLE_CX_DEFAULT_VALUE,
|
||||||
|
SVGOMAnimatedLength.HORIZONTAL_LENGTH, false);
|
||||||
|
cy = createLiveAnimatedLength
|
||||||
|
(null, SVG_CY_ATTRIBUTE, SVG_CIRCLE_CY_DEFAULT_VALUE,
|
||||||
|
SVGOMAnimatedLength.VERTICAL_LENGTH, false);
|
||||||
|
r = createLiveAnimatedLength
|
||||||
|
(null, SVG_R_ATTRIBUTE, null, SVGOMAnimatedLength.OTHER_LENGTH,
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_CIRCLE_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGCircleElement#getCx()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedLength getCx() {
|
||||||
|
return cx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGCircleElement#getCy()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedLength getCy() {
|
||||||
|
return cy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGCircleElement#getR()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedLength getR() {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMCircleElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,126 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedEnumeration;
|
||||||
|
import org.w3c.dom.svg.SVGClipPathElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGClipPathElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMClipPathElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMClipPathElement
|
||||||
|
extends SVGGraphicsElement
|
||||||
|
implements SVGClipPathElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGGraphicsElement.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_CLIP_PATH_UNITS_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_IDENT));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The clipPathUnits values.
|
||||||
|
*/
|
||||||
|
protected static final String[] CLIP_PATH_UNITS_VALUES = {
|
||||||
|
"",
|
||||||
|
SVG_USER_SPACE_ON_USE_VALUE,
|
||||||
|
SVG_OBJECT_BOUNDING_BOX_VALUE
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'clipPathUnits' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedEnumeration clipPathUnits;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMClipPathElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMClipPathElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMClipPathElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMClipPathElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
clipPathUnits =
|
||||||
|
createLiveAnimatedEnumeration
|
||||||
|
(null, SVG_CLIP_PATH_UNITS_ATTRIBUTE, CLIP_PATH_UNITS_VALUES,
|
||||||
|
(short) 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_CLIP_PATH_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGClipPathElement#getClipPathUnits()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedEnumeration getClipPathUnits() {
|
||||||
|
return clipPathUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMClipPathElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,218 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.dom.util.XLinkSupport;
|
||||||
|
import org.apache.batik.dom.util.XMLSupport;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGColorProfileElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link org.w3c.dom.svg.SVGColorProfileElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMColorProfileElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMColorProfileElement
|
||||||
|
extends SVGOMURIReferenceElement
|
||||||
|
implements SVGColorProfileElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attribute initializer.
|
||||||
|
*/
|
||||||
|
protected static final AttributeInitializer attributeInitializer;
|
||||||
|
static {
|
||||||
|
attributeInitializer = new AttributeInitializer(5);
|
||||||
|
attributeInitializer.addAttribute(null, null,
|
||||||
|
SVG_RENDERING_INTENT_ATTRIBUTE,
|
||||||
|
SVG_AUTO_VALUE);
|
||||||
|
attributeInitializer.addAttribute(XMLSupport.XMLNS_NAMESPACE_URI,
|
||||||
|
null, "xmlns:xlink",
|
||||||
|
XLinkSupport.XLINK_NAMESPACE_URI);
|
||||||
|
attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
|
||||||
|
"xlink", "type", "simple");
|
||||||
|
attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
|
||||||
|
"xlink", "show", "other");
|
||||||
|
attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
|
||||||
|
"xlink", "actuate", "onLoad");
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
// */
|
||||||
|
// protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
// static {
|
||||||
|
// DoublyIndexedTable t =
|
||||||
|
// new DoublyIndexedTable(SVGOMURIReferenceElement.xmlTraitInformation);
|
||||||
|
// t.put(XLINK_NAMESPACE_URI, XLINK_HREF_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_URI));
|
||||||
|
// t.put(null, SVG_NAME_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_LOCAL_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
// t.put(null, SVG_RENDERING_INTENT_ATTRIBUTE,
|
||||||
|
// new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
// xmlTraitInformation = t;
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMColorProfileElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMColorProfileElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMColorProfileElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMColorProfileElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_COLOR_PROFILE_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGColorProfileElement#getLocal()}.
|
||||||
|
*/
|
||||||
|
public String getLocal() {
|
||||||
|
return getAttributeNS(null, SVG_LOCAL_ATTRIBUTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGColorProfileElement#setLocal(String)}.
|
||||||
|
*/
|
||||||
|
public void setLocal(String local) throws DOMException {
|
||||||
|
setAttributeNS(null, SVG_LOCAL_ATTRIBUTE, local);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGColorProfileElement#getName()}.
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return getAttributeNS(null, SVG_NAME_ATTRIBUTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGColorProfileElement#setName(String)}.
|
||||||
|
*/
|
||||||
|
public void setName(String name) throws DOMException {
|
||||||
|
setAttributeNS(null, SVG_NAME_ATTRIBUTE, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGColorProfileElement#getRenderingIntent()}.
|
||||||
|
*/
|
||||||
|
public short getRenderingIntent() {
|
||||||
|
Attr attr = getAttributeNodeNS(null, SVG_RENDERING_INTENT_ATTRIBUTE);
|
||||||
|
if (attr == null) {
|
||||||
|
return RENDERING_INTENT_AUTO;
|
||||||
|
}
|
||||||
|
String val = attr.getValue();
|
||||||
|
switch (val.length()) {
|
||||||
|
case 4:
|
||||||
|
if (val.equals(SVG_AUTO_VALUE)) {
|
||||||
|
return RENDERING_INTENT_AUTO;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 10:
|
||||||
|
if (val.equals(SVG_PERCEPTUAL_VALUE)) {
|
||||||
|
return RENDERING_INTENT_PERCEPTUAL;
|
||||||
|
}
|
||||||
|
if (val.equals(SVG_SATURATE_VALUE)) {
|
||||||
|
return RENDERING_INTENT_SATURATION;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 21:
|
||||||
|
if (val.equals(SVG_ABSOLUTE_COLORIMETRIC_VALUE)) {
|
||||||
|
return RENDERING_INTENT_ABSOLUTE_COLORIMETRIC;
|
||||||
|
}
|
||||||
|
if (val.equals(SVG_RELATIVE_COLORIMETRIC_VALUE)) {
|
||||||
|
return RENDERING_INTENT_RELATIVE_COLORIMETRIC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return RENDERING_INTENT_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGColorProfileElement#setRenderingIntent(short)}.
|
||||||
|
*/
|
||||||
|
public void setRenderingIntent(short renderingIntent) throws DOMException {
|
||||||
|
switch (renderingIntent) {
|
||||||
|
case RENDERING_INTENT_AUTO:
|
||||||
|
setAttributeNS(null, SVG_RENDERING_INTENT_ATTRIBUTE,
|
||||||
|
SVG_AUTO_VALUE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RENDERING_INTENT_PERCEPTUAL:
|
||||||
|
setAttributeNS(null, SVG_RENDERING_INTENT_ATTRIBUTE,
|
||||||
|
SVG_PERCEPTUAL_VALUE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RENDERING_INTENT_RELATIVE_COLORIMETRIC:
|
||||||
|
setAttributeNS(null, SVG_RENDERING_INTENT_ATTRIBUTE,
|
||||||
|
SVG_RELATIVE_COLORIMETRIC_VALUE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RENDERING_INTENT_SATURATION:
|
||||||
|
setAttributeNS(null, SVG_RENDERING_INTENT_ATTRIBUTE,
|
||||||
|
SVG_SATURATE_VALUE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RENDERING_INTENT_ABSOLUTE_COLORIMETRIC:
|
||||||
|
setAttributeNS(null, SVG_RENDERING_INTENT_ATTRIBUTE,
|
||||||
|
SVG_ABSOLUTE_COLORIMETRIC_VALUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the AttributeInitializer for this element type.
|
||||||
|
* @return null if this element has no attribute with a default value.
|
||||||
|
*/
|
||||||
|
protected AttributeInitializer getAttributeInitializer() {
|
||||||
|
return attributeInitializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMColorProfileElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Returns the table of TraitInformation objects for this element.
|
||||||
|
// */
|
||||||
|
// protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
// return xmlTraitInformation;
|
||||||
|
// }
|
||||||
|
}
|
|
@ -0,0 +1,220 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedEnumeration;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedNumber;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedNumberList;
|
||||||
|
import org.w3c.dom.svg.SVGComponentTransferFunctionElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents the component transfer function elements.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMComponentTransferFunctionElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public abstract class SVGOMComponentTransferFunctionElement
|
||||||
|
extends SVGOMElement
|
||||||
|
implements SVGComponentTransferFunctionElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMElement.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_TYPE_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_IDENT));
|
||||||
|
t.put(null, SVG_TABLE_VALUES_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER_LIST));
|
||||||
|
t.put(null, SVG_SLOPE_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_INTERCEPT_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_AMPLITUDE_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_EXPONENT_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_OFFSET_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'type' attribute values.
|
||||||
|
*/
|
||||||
|
protected static final String[] TYPE_VALUES = {
|
||||||
|
"",
|
||||||
|
SVG_IDENTITY_VALUE,
|
||||||
|
SVG_TABLE_VALUE,
|
||||||
|
SVG_DISCRETE_VALUE,
|
||||||
|
SVG_LINEAR_VALUE,
|
||||||
|
SVG_GAMMA_VALUE
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'type' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedEnumeration type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'tableValues' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumberList tableValues;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'slope' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber slope;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'intercept' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber intercept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'amplitude' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber amplitude;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'exponent' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber exponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'offset' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber offset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Element object.
|
||||||
|
*/
|
||||||
|
protected SVGOMComponentTransferFunctionElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Element object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
protected SVGOMComponentTransferFunctionElement(String prefix,
|
||||||
|
AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
type =
|
||||||
|
createLiveAnimatedEnumeration
|
||||||
|
(null, SVG_TYPE_ATTRIBUTE, TYPE_VALUES, (short) 1);
|
||||||
|
tableValues =
|
||||||
|
createLiveAnimatedNumberList
|
||||||
|
(null, SVG_TABLE_VALUES_ATTRIBUTE,
|
||||||
|
SVG_COMPONENT_TRANSFER_FUNCTION_TABLE_VALUES_DEFAULT_VALUE,
|
||||||
|
false);
|
||||||
|
slope = createLiveAnimatedNumber(null, SVG_SLOPE_ATTRIBUTE, 1f);
|
||||||
|
intercept = createLiveAnimatedNumber(null, SVG_INTERCEPT_ATTRIBUTE, 0f);
|
||||||
|
amplitude = createLiveAnimatedNumber(null, SVG_AMPLITUDE_ATTRIBUTE, 1f);
|
||||||
|
exponent = createLiveAnimatedNumber(null, SVG_EXPONENT_ATTRIBUTE, 1f);
|
||||||
|
offset = createLiveAnimatedNumber(null, SVG_EXPONENT_ATTRIBUTE, 0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGComponentTransferFunctionElement#getType()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedEnumeration getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGComponentTransferFunctionElement#getTableValues()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumberList getTableValues() {
|
||||||
|
// XXX
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGComponentTransferFunctionElement.getTableValues is not implemented");
|
||||||
|
// return tableValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGComponentTransferFunctionElement#getSlope()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getSlope() {
|
||||||
|
return slope;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGComponentTransferFunctionElement#getIntercept()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getIntercept() {
|
||||||
|
return intercept;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGComponentTransferFunctionElement#getAmplitude()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getAmplitude() {
|
||||||
|
return amplitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGComponentTransferFunctionElement#getExponent()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getExponent() {
|
||||||
|
return exponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGComponentTransferFunctionElement#getOffset()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getOffset() {
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,217 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.dom.svg.SVGTestsSupport;
|
||||||
|
import org.apache.batik.dom.util.XLinkSupport;
|
||||||
|
import org.apache.batik.dom.util.XMLSupport;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedBoolean;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedLength;
|
||||||
|
import org.w3c.dom.svg.SVGCursorElement;
|
||||||
|
import org.w3c.dom.svg.SVGStringList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link org.w3c.dom.svg.SVGCursorElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMCursorElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMCursorElement
|
||||||
|
extends SVGOMURIReferenceElement
|
||||||
|
implements SVGCursorElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attribute initializer.
|
||||||
|
*/
|
||||||
|
protected static final AttributeInitializer attributeInitializer;
|
||||||
|
static {
|
||||||
|
attributeInitializer = new AttributeInitializer(4);
|
||||||
|
attributeInitializer.addAttribute(XMLSupport.XMLNS_NAMESPACE_URI,
|
||||||
|
null, "xmlns:xlink",
|
||||||
|
XLinkSupport.XLINK_NAMESPACE_URI);
|
||||||
|
attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
|
||||||
|
"xlink", "type", "simple");
|
||||||
|
attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
|
||||||
|
"xlink", "show", "other");
|
||||||
|
attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
|
||||||
|
"xlink", "actuate", "onLoad");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMURIReferenceElement.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_EXTERNAL_RESOURCES_REQUIRED_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_BOOLEAN));
|
||||||
|
t.put(null, SVG_X_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_WIDTH));
|
||||||
|
t.put(null, SVG_Y_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_HEIGHT));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'x' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedLength x;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'y' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedLength y;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'externalResourcesRequired' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedBoolean externalResourcesRequired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMCursorElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMCursorElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMCursorElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMCursorElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
x = createLiveAnimatedLength
|
||||||
|
(null, SVG_X_ATTRIBUTE, SVG_CURSOR_X_DEFAULT_VALUE,
|
||||||
|
SVGOMAnimatedLength.HORIZONTAL_LENGTH, false);
|
||||||
|
y = createLiveAnimatedLength
|
||||||
|
(null, SVG_Y_ATTRIBUTE, SVG_CURSOR_Y_DEFAULT_VALUE,
|
||||||
|
SVGOMAnimatedLength.VERTICAL_LENGTH, false);
|
||||||
|
externalResourcesRequired =
|
||||||
|
createLiveAnimatedBoolean
|
||||||
|
(null, SVG_EXTERNAL_RESOURCES_REQUIRED_ATTRIBUTE, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_CURSOR_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGCursorElement#getX()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedLength getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGCursorElement#getY()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedLength getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SVGExternalResourcesRequired support /////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGExternalResourcesRequired#getExternalResourcesRequired()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedBoolean getExternalResourcesRequired() {
|
||||||
|
return externalResourcesRequired;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SVGTests support ///////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGTests#getRequiredFeatures()}.
|
||||||
|
*/
|
||||||
|
public SVGStringList getRequiredFeatures() {
|
||||||
|
return SVGTestsSupport.getRequiredFeatures(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGTests#getRequiredExtensions()}.
|
||||||
|
*/
|
||||||
|
public SVGStringList getRequiredExtensions() {
|
||||||
|
return SVGTestsSupport.getRequiredExtensions(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGTests#getSystemLanguage()}.
|
||||||
|
*/
|
||||||
|
public SVGStringList getSystemLanguage() {
|
||||||
|
return SVGTestsSupport.getSystemLanguage(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGTests#hasExtension(String)}.
|
||||||
|
*/
|
||||||
|
public boolean hasExtension(String extension) {
|
||||||
|
return SVGTestsSupport.hasExtension(this, extension);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the AttributeInitializer for this element type.
|
||||||
|
* @return null if this element has no attribute with a default value.
|
||||||
|
*/
|
||||||
|
protected AttributeInitializer getAttributeInitializer() {
|
||||||
|
return attributeInitializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMCursorElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGDefinitionSrcElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGDefinitionSrcElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMDefinitionSrcElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMDefinitionSrcElement
|
||||||
|
extends SVGOMElement
|
||||||
|
implements SVGDefinitionSrcElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMDefinitionSrcElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMDefinitionSrcElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMDefinitionSrcElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMDefinitionSrcElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_DEFINITION_SRC_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMDefinitionSrcElement();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGDefsElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGDefsElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMDefsElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMDefsElement
|
||||||
|
extends SVGGraphicsElement
|
||||||
|
implements SVGDefsElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMDefsElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMDefsElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMDefsElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMDefsElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_DEFS_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMDefsElement();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGDescElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGDescElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMDescElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMDescElement
|
||||||
|
extends SVGDescriptiveElement
|
||||||
|
implements SVGDescElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMDescElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMDescElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMDescElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMDescElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_DESC_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMDescElement();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,799 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.MissingResourceException;
|
||||||
|
|
||||||
|
import org.apache.batik.css.engine.CSSNavigableDocument;
|
||||||
|
import org.apache.batik.css.engine.CSSNavigableDocumentListener;
|
||||||
|
import org.apache.batik.css.engine.CSSStylableElement;
|
||||||
|
import org.apache.batik.dom.AbstractStylableDocument;
|
||||||
|
import org.apache.batik.dom.GenericAttr;
|
||||||
|
import org.apache.batik.dom.GenericAttrNS;
|
||||||
|
import org.apache.batik.dom.GenericCDATASection;
|
||||||
|
import org.apache.batik.dom.GenericComment;
|
||||||
|
import org.apache.batik.dom.GenericDocumentFragment;
|
||||||
|
import org.apache.batik.dom.GenericElement;
|
||||||
|
import org.apache.batik.dom.GenericEntityReference;
|
||||||
|
import org.apache.batik.dom.GenericProcessingInstruction;
|
||||||
|
import org.apache.batik.dom.GenericText;
|
||||||
|
import org.apache.batik.dom.StyleSheetFactory;
|
||||||
|
import org.apache.batik.dom.events.EventSupport;
|
||||||
|
import org.apache.batik.dom.svg.IdContainer;
|
||||||
|
import org.apache.batik.dom.svg.SVGContext;
|
||||||
|
import org.apache.batik.dom.util.XMLSupport;
|
||||||
|
import org.apache.batik.i18n.Localizable;
|
||||||
|
import org.apache.batik.i18n.LocalizableSupport;
|
||||||
|
import org.apache.batik.util.ParsedURL;
|
||||||
|
import org.apache.batik.util.SVGConstants;
|
||||||
|
import org.apache.batik.constants.XMLConstants;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.CDATASection;
|
||||||
|
import org.w3c.dom.Comment;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.DOMImplementation;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.DocumentFragment;
|
||||||
|
import org.w3c.dom.DocumentType;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.EntityReference;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.ProcessingInstruction;
|
||||||
|
import org.w3c.dom.Text;
|
||||||
|
import org.w3c.dom.css.CSSStyleDeclaration;
|
||||||
|
import org.w3c.dom.css.DocumentCSS;
|
||||||
|
import org.w3c.dom.events.Event;
|
||||||
|
import org.w3c.dom.events.EventListener;
|
||||||
|
import org.w3c.dom.events.MutationEvent;
|
||||||
|
import org.w3c.dom.svg.SVGDocument;
|
||||||
|
import org.w3c.dom.svg.SVGLangSpace;
|
||||||
|
import org.w3c.dom.svg.SVGSVGElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGDocument}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMDocument.java 1851346 2019-01-15 13:41:00Z ssteiner $
|
||||||
|
*/
|
||||||
|
public class SVGOMDocument
|
||||||
|
extends AbstractStylableDocument
|
||||||
|
implements SVGDocument,
|
||||||
|
SVGConstants,
|
||||||
|
CSSNavigableDocument,
|
||||||
|
IdContainer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The error messages bundle class name.
|
||||||
|
*/
|
||||||
|
protected static final String RESOURCES =
|
||||||
|
"org.apache.batik.dom.svg.resources.Messages";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The localizable support for the error messages.
|
||||||
|
*/
|
||||||
|
protected transient LocalizableSupport localizableSupport =
|
||||||
|
new LocalizableSupport(RESOURCES, getClass().getClassLoader());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The string representing the referrer.
|
||||||
|
*/
|
||||||
|
protected String referrer = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The URL of the document.
|
||||||
|
*/
|
||||||
|
protected ParsedURL url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this document immutable?
|
||||||
|
*/
|
||||||
|
protected transient boolean readonly;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the document supports SVG 1.2.
|
||||||
|
*/
|
||||||
|
protected boolean isSVG12;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of CSSNavigableDocumentListeners to an array of wrapper
|
||||||
|
* DOM listeners.
|
||||||
|
*/
|
||||||
|
protected HashMap cssNavigableDocumentListeners = new HashMap();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main {@link AnimatedAttributeListener} that redispatches to all
|
||||||
|
* listeners in {@link #animatedAttributeListeners}.
|
||||||
|
*/
|
||||||
|
protected AnimatedAttributeListener mainAnimatedAttributeListener =
|
||||||
|
new AnimAttrListener();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of {@link AnimatedAttributeListener}s attached to this document.
|
||||||
|
*/
|
||||||
|
protected LinkedList animatedAttributeListeners = new LinkedList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The SVG context.
|
||||||
|
*/
|
||||||
|
protected transient SVGContext svgContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new uninitialized document.
|
||||||
|
*/
|
||||||
|
protected SVGOMDocument() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new document.
|
||||||
|
*/
|
||||||
|
public SVGOMDocument(DocumentType dt, DOMImplementation impl) {
|
||||||
|
super(dt, impl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements {@link Localizable#setLocale(Locale)}.
|
||||||
|
*/
|
||||||
|
public void setLocale(Locale l) {
|
||||||
|
super.setLocale(l);
|
||||||
|
localizableSupport.setLocale(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements {@link Localizable#formatMessage(String,Object[])}.
|
||||||
|
*/
|
||||||
|
public String formatMessage(String key, Object[] args)
|
||||||
|
throws MissingResourceException {
|
||||||
|
try {
|
||||||
|
return super.formatMessage(key, args);
|
||||||
|
} catch (MissingResourceException e) {
|
||||||
|
return localizableSupport.formatMessage(key, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGDocument#getTitle()}.
|
||||||
|
*/
|
||||||
|
public String getTitle() {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
boolean preserve = false;
|
||||||
|
|
||||||
|
for (Node n = getDocumentElement().getFirstChild();
|
||||||
|
n != null;
|
||||||
|
n = n.getNextSibling()) {
|
||||||
|
String ns = n.getNamespaceURI();
|
||||||
|
if (ns != null && ns.equals(SVG_NAMESPACE_URI)) {
|
||||||
|
if (n.getLocalName().equals(SVG_TITLE_TAG)) {
|
||||||
|
preserve = ((SVGLangSpace)n).getXMLspace().equals("preserve");
|
||||||
|
for (n = n.getFirstChild();
|
||||||
|
n != null;
|
||||||
|
n = n.getNextSibling()) {
|
||||||
|
if (n.getNodeType() == Node.TEXT_NODE) {
|
||||||
|
sb.append(n.getNodeValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String s = sb.toString();
|
||||||
|
return (preserve)
|
||||||
|
? XMLSupport.preserveXMLSpace(s)
|
||||||
|
: XMLSupport.defaultXMLSpace(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGDocument#getReferrer()}.
|
||||||
|
*/
|
||||||
|
public String getReferrer() {
|
||||||
|
return referrer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the referrer string.
|
||||||
|
*/
|
||||||
|
public void setReferrer(String s) {
|
||||||
|
referrer = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGDocument#getDomain()}.
|
||||||
|
*/
|
||||||
|
public String getDomain() {
|
||||||
|
return (url == null) ? null : url.getHost();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGDocument#getRootElement()}.
|
||||||
|
*/
|
||||||
|
public SVGSVGElement getRootElement() {
|
||||||
|
return (SVGSVGElement)getDocumentElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGDocument#getURL()}
|
||||||
|
*/
|
||||||
|
public String getURL() {
|
||||||
|
return documentURI;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the URI of the document. If the document URI cannot be
|
||||||
|
* represented as a {@link URL} (for example if it uses a <code>data:</code>
|
||||||
|
* URI scheme), then <code>null</code> will be returned.
|
||||||
|
*/
|
||||||
|
public URL getURLObject() {
|
||||||
|
try {
|
||||||
|
return new URL(documentURI);
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the URI of the document.
|
||||||
|
*/
|
||||||
|
public ParsedURL getParsedURL() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the URI of the document.
|
||||||
|
*/
|
||||||
|
public void setURLObject(URL url) {
|
||||||
|
setParsedURL(new ParsedURL(url));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the URI of the document.
|
||||||
|
*/
|
||||||
|
public void setParsedURL(ParsedURL url) {
|
||||||
|
this.url = url;
|
||||||
|
documentURI = url == null ? null : url.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link org.w3c.dom.Document#setDocumentURI(String)}.
|
||||||
|
*/
|
||||||
|
public void setDocumentURI(String uri) {
|
||||||
|
documentURI = uri;
|
||||||
|
url = uri == null ? null : new ParsedURL(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Document#createElement(String)}.
|
||||||
|
*/
|
||||||
|
public Element createElement(String tagName) throws DOMException {
|
||||||
|
return new GenericElement(tagName.intern(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Document#createDocumentFragment()}.
|
||||||
|
*/
|
||||||
|
public DocumentFragment createDocumentFragment() {
|
||||||
|
return new GenericDocumentFragment(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Document#createTextNode(String)}.
|
||||||
|
*/
|
||||||
|
public Text createTextNode(String data) {
|
||||||
|
return new GenericText(data, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Document#createComment(String)}.
|
||||||
|
*/
|
||||||
|
public Comment createComment(String data) {
|
||||||
|
return new GenericComment(data, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Document#createCDATASection(String)}
|
||||||
|
*/
|
||||||
|
public CDATASection createCDATASection(String data) throws DOMException {
|
||||||
|
return new GenericCDATASection(data, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* Document#createProcessingInstruction(String,String)}.
|
||||||
|
* @return a SVGStyleSheetProcessingInstruction if target is
|
||||||
|
* "xml-stylesheet" or a GenericProcessingInstruction otherwise.
|
||||||
|
*/
|
||||||
|
public ProcessingInstruction createProcessingInstruction(String target,
|
||||||
|
String data)
|
||||||
|
throws DOMException {
|
||||||
|
if ("xml-stylesheet".equals(target)) {
|
||||||
|
return new SVGStyleSheetProcessingInstruction
|
||||||
|
(data, this, (StyleSheetFactory)getImplementation());
|
||||||
|
}
|
||||||
|
return new GenericProcessingInstruction(target, data, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Document#createAttribute(String)}.
|
||||||
|
*/
|
||||||
|
public Attr createAttribute(String name) throws DOMException {
|
||||||
|
return new GenericAttr(name.intern(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Document#createEntityReference(String)}.
|
||||||
|
*/
|
||||||
|
public EntityReference createEntityReference(String name)
|
||||||
|
throws DOMException {
|
||||||
|
return new GenericEntityReference(name, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Document#createAttributeNS(String,String)}.
|
||||||
|
*/
|
||||||
|
public Attr createAttributeNS(String namespaceURI, String qualifiedName)
|
||||||
|
throws DOMException {
|
||||||
|
if (namespaceURI == null) {
|
||||||
|
return new GenericAttr(qualifiedName.intern(), this);
|
||||||
|
} else {
|
||||||
|
return new GenericAttrNS(namespaceURI.intern(),
|
||||||
|
qualifiedName.intern(),
|
||||||
|
this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Document#createElementNS(String,String)}.
|
||||||
|
*/
|
||||||
|
public Element createElementNS(String namespaceURI, String qualifiedName)
|
||||||
|
throws DOMException {
|
||||||
|
SVGDOMImplementation impl = (SVGDOMImplementation)implementation;
|
||||||
|
return impl.createElementNS(this, namespaceURI, qualifiedName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the document supports SVG 1.2.
|
||||||
|
*/
|
||||||
|
public boolean isSVG12() {
|
||||||
|
return isSVG12;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether the document supports SVG 1.2.
|
||||||
|
*/
|
||||||
|
public void setIsSVG12(boolean b) {
|
||||||
|
isSVG12 = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the given Attr node represents an 'id'
|
||||||
|
* for this document.
|
||||||
|
*/
|
||||||
|
public boolean isId(Attr node) {
|
||||||
|
if (node.getNamespaceURI() == null) {
|
||||||
|
return SVG_ID_ATTRIBUTE.equals(node.getNodeName());
|
||||||
|
}
|
||||||
|
return node.getNodeName().equals(XML_ID_QNAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the SVG context to use to get SVG specific informations.
|
||||||
|
*
|
||||||
|
* @param ctx the SVG context
|
||||||
|
*/
|
||||||
|
public void setSVGContext(SVGContext ctx) {
|
||||||
|
svgContext = ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the SVG context used to get SVG specific informations.
|
||||||
|
*/
|
||||||
|
public SVGContext getSVGContext() {
|
||||||
|
return svgContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
// CSSNavigableDocument ///////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an event listener for mutations on the
|
||||||
|
* CSSNavigableDocument tree.
|
||||||
|
*/
|
||||||
|
public void addCSSNavigableDocumentListener
|
||||||
|
(CSSNavigableDocumentListener l) {
|
||||||
|
if (cssNavigableDocumentListeners.containsKey(l)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DOMNodeInsertedListenerWrapper nodeInserted
|
||||||
|
= new DOMNodeInsertedListenerWrapper(l);
|
||||||
|
DOMNodeRemovedListenerWrapper nodeRemoved
|
||||||
|
= new DOMNodeRemovedListenerWrapper(l);
|
||||||
|
DOMSubtreeModifiedListenerWrapper subtreeModified
|
||||||
|
= new DOMSubtreeModifiedListenerWrapper(l);
|
||||||
|
DOMCharacterDataModifiedListenerWrapper cdataModified
|
||||||
|
= new DOMCharacterDataModifiedListenerWrapper(l);
|
||||||
|
DOMAttrModifiedListenerWrapper attrModified
|
||||||
|
= new DOMAttrModifiedListenerWrapper(l);
|
||||||
|
|
||||||
|
cssNavigableDocumentListeners.put
|
||||||
|
(l, new EventListener[] { nodeInserted,
|
||||||
|
nodeRemoved,
|
||||||
|
subtreeModified,
|
||||||
|
cdataModified,
|
||||||
|
attrModified });
|
||||||
|
|
||||||
|
addEventListenerNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMNodeInserted", nodeInserted, false, null);
|
||||||
|
addEventListenerNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMNodeRemoved", nodeRemoved, false, null);
|
||||||
|
addEventListenerNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMSubtreeModified", subtreeModified, false, null);
|
||||||
|
addEventListenerNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMCharacterDataModified", cdataModified, false,
|
||||||
|
null);
|
||||||
|
addEventListenerNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMAttrModified", attrModified, false, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes an event listener for mutations on the
|
||||||
|
* CSSNavigableDocument tree.
|
||||||
|
*/
|
||||||
|
public void removeCSSNavigableDocumentListener
|
||||||
|
(CSSNavigableDocumentListener l) {
|
||||||
|
EventListener[] listeners
|
||||||
|
= (EventListener[]) cssNavigableDocumentListeners.get(l);
|
||||||
|
if (listeners == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
removeEventListenerNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMNodeInserted", listeners[0], false);
|
||||||
|
removeEventListenerNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMNodeRemoved", listeners[1], false);
|
||||||
|
removeEventListenerNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMSubtreeModified", listeners[2], false);
|
||||||
|
removeEventListenerNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMCharacterDataModified", listeners[3], false);
|
||||||
|
removeEventListenerNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
|
||||||
|
"DOMAttrModified", listeners[4], false);
|
||||||
|
|
||||||
|
cssNavigableDocumentListeners.remove(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link AnimatedAttributeListener} for the document.
|
||||||
|
*/
|
||||||
|
protected AnimatedAttributeListener getAnimatedAttributeListener() {
|
||||||
|
return mainAnimatedAttributeListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The text of the override style declaration for this element has been
|
||||||
|
* modified.
|
||||||
|
*/
|
||||||
|
protected void overrideStyleTextChanged(CSSStylableElement e, String text) {
|
||||||
|
for (Object o : cssNavigableDocumentListeners.keySet()) {
|
||||||
|
CSSNavigableDocumentListener l =
|
||||||
|
(CSSNavigableDocumentListener) o;
|
||||||
|
l.overrideStyleTextChanged(e, text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A property in the override style declaration has been removed.
|
||||||
|
*/
|
||||||
|
protected void overrideStylePropertyRemoved(CSSStylableElement e,
|
||||||
|
String name) {
|
||||||
|
for (Object o : cssNavigableDocumentListeners.keySet()) {
|
||||||
|
CSSNavigableDocumentListener l =
|
||||||
|
(CSSNavigableDocumentListener) o;
|
||||||
|
l.overrideStylePropertyRemoved(e, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A property in the override style declaration has been changed.
|
||||||
|
*/
|
||||||
|
protected void overrideStylePropertyChanged
|
||||||
|
(CSSStylableElement e, String name, String value, String prio) {
|
||||||
|
for (Object o : cssNavigableDocumentListeners.keySet()) {
|
||||||
|
CSSNavigableDocumentListener l =
|
||||||
|
(CSSNavigableDocumentListener) o;
|
||||||
|
l.overrideStylePropertyChanged(e, name, value, prio);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an {@link AnimatedAttributeListener} to this document, to be
|
||||||
|
* notified of animated XML attribute changes.
|
||||||
|
*/
|
||||||
|
public void addAnimatedAttributeListener
|
||||||
|
(AnimatedAttributeListener aal) {
|
||||||
|
if (animatedAttributeListeners.contains(aal)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
animatedAttributeListeners.add(aal);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes an {@link AnimatedAttributeListener} from this document.
|
||||||
|
*/
|
||||||
|
public void removeAnimatedAttributeListener
|
||||||
|
(AnimatedAttributeListener aal) {
|
||||||
|
animatedAttributeListeners.remove(aal);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DOM node inserted listener wrapper.
|
||||||
|
*/
|
||||||
|
protected static class DOMNodeInsertedListenerWrapper implements EventListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The CSSNavigableDocumentListener.
|
||||||
|
*/
|
||||||
|
protected CSSNavigableDocumentListener listener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new DOMNodeInsertedListenerWrapper.
|
||||||
|
*/
|
||||||
|
public DOMNodeInsertedListenerWrapper(CSSNavigableDocumentListener l) {
|
||||||
|
listener = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the event.
|
||||||
|
*/
|
||||||
|
public void handleEvent(Event evt) {
|
||||||
|
evt = EventSupport.getUltimateOriginalEvent(evt);
|
||||||
|
listener.nodeInserted((Node) evt.getTarget());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DOM node removed listener wrapper.
|
||||||
|
*/
|
||||||
|
protected static class DOMNodeRemovedListenerWrapper implements EventListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The CSSNavigableDocumentListener.
|
||||||
|
*/
|
||||||
|
protected CSSNavigableDocumentListener listener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new DOMNodeRemovedListenerWrapper.
|
||||||
|
*/
|
||||||
|
public DOMNodeRemovedListenerWrapper(CSSNavigableDocumentListener l) {
|
||||||
|
listener = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the event.
|
||||||
|
*/
|
||||||
|
public void handleEvent(Event evt) {
|
||||||
|
evt = EventSupport.getUltimateOriginalEvent(evt);
|
||||||
|
listener.nodeToBeRemoved((Node) evt.getTarget());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DOM subtree modified listener wrapper.
|
||||||
|
*/
|
||||||
|
protected static class DOMSubtreeModifiedListenerWrapper implements EventListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The CSSNavigableDocumentListener.
|
||||||
|
*/
|
||||||
|
protected CSSNavigableDocumentListener listener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new DOMSubtreeModifiedListenerWrapper.
|
||||||
|
*/
|
||||||
|
public DOMSubtreeModifiedListenerWrapper
|
||||||
|
(CSSNavigableDocumentListener l) {
|
||||||
|
listener = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the event.
|
||||||
|
*/
|
||||||
|
public void handleEvent(Event evt) {
|
||||||
|
evt = EventSupport.getUltimateOriginalEvent(evt);
|
||||||
|
listener.subtreeModified((Node) evt.getTarget());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DOM character data modified listener wrapper.
|
||||||
|
*/
|
||||||
|
protected static class DOMCharacterDataModifiedListenerWrapper
|
||||||
|
implements EventListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The CSSNavigableDocumentListener.
|
||||||
|
*/
|
||||||
|
protected CSSNavigableDocumentListener listener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new DOMCharacterDataModifiedListenerWrapper.
|
||||||
|
*/
|
||||||
|
public DOMCharacterDataModifiedListenerWrapper
|
||||||
|
(CSSNavigableDocumentListener l) {
|
||||||
|
listener = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the event.
|
||||||
|
*/
|
||||||
|
public void handleEvent(Event evt) {
|
||||||
|
evt = EventSupport.getUltimateOriginalEvent(evt);
|
||||||
|
listener.characterDataModified((Node) evt.getTarget());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DOM attribute modified listener wrapper.
|
||||||
|
*/
|
||||||
|
protected static class DOMAttrModifiedListenerWrapper implements EventListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The CSSNavigableDocumentListener.
|
||||||
|
*/
|
||||||
|
protected CSSNavigableDocumentListener listener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new DOMAttrModifiedListenerWrapper.
|
||||||
|
*/
|
||||||
|
public DOMAttrModifiedListenerWrapper(CSSNavigableDocumentListener l) {
|
||||||
|
listener = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the event.
|
||||||
|
*/
|
||||||
|
public void handleEvent(Event evt) {
|
||||||
|
evt = EventSupport.getUltimateOriginalEvent(evt);
|
||||||
|
MutationEvent mevt = (MutationEvent) evt;
|
||||||
|
listener.attrModified((Element) evt.getTarget(),
|
||||||
|
(Attr) mevt.getRelatedNode(),
|
||||||
|
mevt.getAttrChange(),
|
||||||
|
mevt.getPrevValue(),
|
||||||
|
mevt.getNewValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener class for animated attribute changes.
|
||||||
|
*/
|
||||||
|
protected class AnimAttrListener implements AnimatedAttributeListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to notify an object of a change to the animated value of
|
||||||
|
* an animatable XML attribute.
|
||||||
|
* @param e the owner element of the changed animatable attribute
|
||||||
|
* @param alav the AnimatedLiveAttributeValue that changed
|
||||||
|
*/
|
||||||
|
public void animatedAttributeChanged(Element e,
|
||||||
|
AnimatedLiveAttributeValue alav) {
|
||||||
|
for (Object animatedAttributeListener : animatedAttributeListeners) {
|
||||||
|
AnimatedAttributeListener aal =
|
||||||
|
(AnimatedAttributeListener) animatedAttributeListener;
|
||||||
|
aal.animatedAttributeChanged(e, alav);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to notify an object of a change to the value of an 'other'
|
||||||
|
* animation.
|
||||||
|
* @param e the element being animated
|
||||||
|
* @param type the type of animation whose value changed
|
||||||
|
*/
|
||||||
|
public void otherAnimationChanged(Element e, String type) {
|
||||||
|
for (Object animatedAttributeListener : animatedAttributeListeners) {
|
||||||
|
AnimatedAttributeListener aal =
|
||||||
|
(AnimatedAttributeListener) animatedAttributeListener;
|
||||||
|
aal.otherAnimationChanged(e, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DocumentCSS ////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements
|
||||||
|
* {@link DocumentCSS#getOverrideStyle(Element,String)}.
|
||||||
|
*/
|
||||||
|
public CSSStyleDeclaration getOverrideStyle(Element elt,
|
||||||
|
String pseudoElt) {
|
||||||
|
if (elt instanceof SVGStylableElement && pseudoElt == null) {
|
||||||
|
return ((SVGStylableElement) elt).getOverrideStyle();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AbstractDocument ///////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether this node is readonly.
|
||||||
|
*/
|
||||||
|
public boolean isReadonly() {
|
||||||
|
return readonly;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets this node readonly attribute.
|
||||||
|
*/
|
||||||
|
public void setReadonly(boolean v) {
|
||||||
|
readonly = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMDocument();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy the fields of the current node into the given node.
|
||||||
|
* @param n a node of the type of this.
|
||||||
|
*/
|
||||||
|
protected Node copyInto(Node n) {
|
||||||
|
super.copyInto(n);
|
||||||
|
SVGOMDocument sd = (SVGOMDocument)n;
|
||||||
|
sd.localizableSupport = new LocalizableSupport
|
||||||
|
(RESOURCES, getClass().getClassLoader());
|
||||||
|
sd.referrer = referrer;
|
||||||
|
sd.url = url;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deeply copy the fields of the current node into the given node.
|
||||||
|
* @param n a node of the type of this.
|
||||||
|
*/
|
||||||
|
protected Node deepCopyInto(Node n) {
|
||||||
|
super.deepCopyInto(n);
|
||||||
|
SVGOMDocument sd = (SVGOMDocument)n;
|
||||||
|
sd.localizableSupport = new LocalizableSupport
|
||||||
|
(RESOURCES, getClass().getClassLoader());
|
||||||
|
sd.referrer = referrer;
|
||||||
|
sd.url = url;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Serialization //////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the object from the given stream.
|
||||||
|
*/
|
||||||
|
private void readObject(ObjectInputStream s)
|
||||||
|
throws IOException, ClassNotFoundException {
|
||||||
|
s.defaultReadObject();
|
||||||
|
|
||||||
|
localizableSupport = new LocalizableSupport
|
||||||
|
(RESOURCES, getClass().getClassLoader());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,954 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
import org.apache.batik.anim.values.AnimatableNumberOptionalNumberValue;
|
||||||
|
import org.apache.batik.anim.values.AnimatableValue;
|
||||||
|
import org.apache.batik.css.engine.CSSEngine;
|
||||||
|
import org.apache.batik.css.engine.CSSNavigableNode;
|
||||||
|
import org.apache.batik.css.engine.value.ShorthandManager;
|
||||||
|
import org.apache.batik.css.engine.value.ValueManager;
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.dom.AbstractStylableDocument;
|
||||||
|
import org.apache.batik.dom.svg.ExtendedTraitAccess;
|
||||||
|
import org.apache.batik.dom.svg.LiveAttributeValue;
|
||||||
|
import org.apache.batik.dom.svg.SVGContext;
|
||||||
|
import org.apache.batik.dom.svg.SVGOMException;
|
||||||
|
import org.apache.batik.dom.util.DOMUtilities;
|
||||||
|
import org.apache.batik.parser.UnitProcessor;
|
||||||
|
import org.apache.batik.util.CSSConstants;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.ParsedURL;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.DOMException;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedInteger;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedNumber;
|
||||||
|
import org.w3c.dom.svg.SVGElement;
|
||||||
|
import org.w3c.dom.svg.SVGException;
|
||||||
|
import org.w3c.dom.svg.SVGFitToViewBox;
|
||||||
|
import org.w3c.dom.svg.SVGLength;
|
||||||
|
import org.w3c.dom.svg.SVGSVGElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements the {@link SVGElement} interface.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMElement.java 1804130 2017-08-04 14:41:11Z ssteiner $
|
||||||
|
*/
|
||||||
|
public abstract class SVGOMElement
|
||||||
|
extends AbstractElement
|
||||||
|
implements SVGElement,
|
||||||
|
ExtendedTraitAccess,
|
||||||
|
AnimationTarget {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t = new DoublyIndexedTable();
|
||||||
|
t.put(null, SVG_ID_ATTRIBUTE,
|
||||||
|
new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
t.put(XML_NAMESPACE_URI, XML_BASE_ATTRIBUTE,
|
||||||
|
new TraitInformation(false, SVGTypes.TYPE_URI));
|
||||||
|
t.put(XML_NAMESPACE_URI, XML_SPACE_ATTRIBUTE,
|
||||||
|
new TraitInformation(false, SVGTypes.TYPE_IDENT));
|
||||||
|
t.put(XML_NAMESPACE_URI, XML_ID_ATTRIBUTE,
|
||||||
|
new TraitInformation(false, SVGTypes.TYPE_CDATA));
|
||||||
|
t.put(XML_NAMESPACE_URI, XML_LANG_ATTRIBUTE,
|
||||||
|
new TraitInformation(false, SVGTypes.TYPE_LANG));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this element immutable?
|
||||||
|
*/
|
||||||
|
protected transient boolean readonly;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The element prefix.
|
||||||
|
*/
|
||||||
|
protected String prefix;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The SVG context to get SVG specific informations.
|
||||||
|
*/
|
||||||
|
protected transient SVGContext svgContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping namespaceURI/local name pairs to {@link LinkedList}s
|
||||||
|
* of {@link AnimationTargetListener}s.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable targetListeners;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The context used to resolve the units.
|
||||||
|
*/
|
||||||
|
protected UnitProcessor.Context unitContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Element object.
|
||||||
|
*/
|
||||||
|
protected SVGOMElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Element object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
protected SVGOMElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
// initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
// initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Initializes the live attribute values of this element.
|
||||||
|
// */
|
||||||
|
// private void initializeLiveAttributes() {
|
||||||
|
// // If live attributes are added here, make sure to uncomment the
|
||||||
|
// // call to initializeLiveAttributes in the constructor and
|
||||||
|
// // initializeAllLiveAttributes method above.
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGElement#getId()}.
|
||||||
|
*/
|
||||||
|
public String getId() {
|
||||||
|
if (((SVGOMDocument) ownerDocument).isSVG12) {
|
||||||
|
Attr a = getAttributeNodeNS(XML_NAMESPACE_URI, SVG_ID_ATTRIBUTE);
|
||||||
|
if (a != null) {
|
||||||
|
return a.getNodeValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return getAttributeNS(null, SVG_ID_ATTRIBUTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGElement#setId(String)}.
|
||||||
|
*/
|
||||||
|
public void setId(String id) {
|
||||||
|
if (((SVGOMDocument) ownerDocument).isSVG12) {
|
||||||
|
setAttributeNS(XML_NAMESPACE_URI, XML_ID_QNAME, id);
|
||||||
|
Attr a = getAttributeNodeNS(null, SVG_ID_ATTRIBUTE);
|
||||||
|
if (a != null) {
|
||||||
|
a.setNodeValue(id);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setAttributeNS(null, SVG_ID_ATTRIBUTE, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGElement#getXMLbase()}.
|
||||||
|
*/
|
||||||
|
public String getXMLbase() {
|
||||||
|
return getAttributeNS(XML_NAMESPACE_URI, XML_BASE_ATTRIBUTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGElement#setXMLbase(String)}.
|
||||||
|
*/
|
||||||
|
public void setXMLbase(String xmlbase) throws DOMException {
|
||||||
|
setAttributeNS(XML_NAMESPACE_URI, XML_BASE_QNAME, xmlbase);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGElement#getOwnerSVGElement()}.
|
||||||
|
*/
|
||||||
|
public SVGSVGElement getOwnerSVGElement() {
|
||||||
|
for (Element e = CSSEngine.getParentCSSStylableElement(this);
|
||||||
|
e != null;
|
||||||
|
e = CSSEngine.getParentCSSStylableElement(e)) {
|
||||||
|
if (e instanceof SVGSVGElement) {
|
||||||
|
return (SVGSVGElement)e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGElement#getViewportElement()}.
|
||||||
|
*/
|
||||||
|
public SVGElement getViewportElement() {
|
||||||
|
for (Element e = CSSEngine.getParentCSSStylableElement(this);
|
||||||
|
e != null;
|
||||||
|
e = CSSEngine.getParentCSSStylableElement(e)) {
|
||||||
|
if (e instanceof SVGFitToViewBox) {
|
||||||
|
return (SVGElement)e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getNodeName()}.
|
||||||
|
*/
|
||||||
|
public String getNodeName() {
|
||||||
|
if (prefix == null || prefix.equals("")) {
|
||||||
|
return getLocalName();
|
||||||
|
}
|
||||||
|
|
||||||
|
return prefix + ':' + getLocalName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getNamespaceURI()}.
|
||||||
|
*/
|
||||||
|
public String getNamespaceURI() {
|
||||||
|
return SVGDOMImplementation.SVG_NAMESPACE_URI;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#setPrefix(String)}.
|
||||||
|
*/
|
||||||
|
public void setPrefix(String prefix) throws DOMException {
|
||||||
|
if (isReadonly()) {
|
||||||
|
throw createDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||||
|
"readonly.node",
|
||||||
|
new Object[] {(int) getNodeType(),
|
||||||
|
getNodeName() });
|
||||||
|
}
|
||||||
|
if (prefix != null &&
|
||||||
|
!prefix.equals("") &&
|
||||||
|
!DOMUtilities.isValidName(prefix)) {
|
||||||
|
throw createDOMException(DOMException.INVALID_CHARACTER_ERR,
|
||||||
|
"prefix",
|
||||||
|
new Object[] {(int) getNodeType(),
|
||||||
|
getNodeName(),
|
||||||
|
prefix });
|
||||||
|
}
|
||||||
|
this.prefix = prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the xml:base attribute value of the given element,
|
||||||
|
* resolving any dependency on parent bases if needed.
|
||||||
|
* Follows shadow trees when moving to parent nodes.
|
||||||
|
*/
|
||||||
|
protected String getCascadedXMLBase(Node node) {
|
||||||
|
String base = null;
|
||||||
|
Node n = node.getParentNode();
|
||||||
|
while (n != null) {
|
||||||
|
if (n.getNodeType() == Node.ELEMENT_NODE) {
|
||||||
|
base = getCascadedXMLBase(n);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (n instanceof CSSNavigableNode) {
|
||||||
|
n = ((CSSNavigableNode) n).getCSSParentNode();
|
||||||
|
} else {
|
||||||
|
n = n.getParentNode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (base == null) {
|
||||||
|
AbstractDocument doc;
|
||||||
|
if (node.getNodeType() == Node.DOCUMENT_NODE) {
|
||||||
|
doc = (AbstractDocument) node;
|
||||||
|
} else {
|
||||||
|
doc = (AbstractDocument) node.getOwnerDocument();
|
||||||
|
}
|
||||||
|
base = doc.getDocumentURI();
|
||||||
|
}
|
||||||
|
while (node != null && node.getNodeType() != Node.ELEMENT_NODE) {
|
||||||
|
node = node.getParentNode();
|
||||||
|
}
|
||||||
|
if (node == null) {
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
Element e = (Element) node;
|
||||||
|
Attr attr = e.getAttributeNodeNS(XML_NAMESPACE_URI, XML_BASE_ATTRIBUTE);
|
||||||
|
if (attr != null) {
|
||||||
|
if (base == null) {
|
||||||
|
base = attr.getNodeValue();
|
||||||
|
} else {
|
||||||
|
base = new ParsedURL(base, attr.getNodeValue()).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SVGContext ////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the SVG context to use to get SVG specific informations.
|
||||||
|
*
|
||||||
|
* @param ctx the SVG context
|
||||||
|
*/
|
||||||
|
public void setSVGContext(SVGContext ctx) {
|
||||||
|
svgContext = ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the SVG context used to get SVG specific informations.
|
||||||
|
*/
|
||||||
|
public SVGContext getSVGContext() {
|
||||||
|
return svgContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExtendedNode //////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an SVGException with the appropriate error message.
|
||||||
|
*/
|
||||||
|
public SVGException createSVGException(short type,
|
||||||
|
String key,
|
||||||
|
Object [] args) {
|
||||||
|
try {
|
||||||
|
return new SVGOMException
|
||||||
|
(type, getCurrentDocument().formatMessage(key, args));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return new SVGOMException(type, key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether this node is readonly.
|
||||||
|
*/
|
||||||
|
public boolean isReadonly() {
|
||||||
|
return readonly;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets this node readonly attribute.
|
||||||
|
*/
|
||||||
|
public void setReadonly(boolean v) {
|
||||||
|
readonly = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link SVGOMAnimatedTransformList} and stores it in
|
||||||
|
* this element's LiveAttributeValue table.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedTransformList createLiveAnimatedTransformList
|
||||||
|
(String ns, String ln, String def) {
|
||||||
|
SVGOMAnimatedTransformList v =
|
||||||
|
new SVGOMAnimatedTransformList(this, ns, ln, def);
|
||||||
|
liveAttributeValues.put(ns, ln, v);
|
||||||
|
v.addAnimatedAttributeListener
|
||||||
|
(((SVGOMDocument) ownerDocument).getAnimatedAttributeListener());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link SVGOMAnimatedBoolean} and stores it in
|
||||||
|
* this element's LiveAttributeValue table.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedBoolean createLiveAnimatedBoolean
|
||||||
|
(String ns, String ln, boolean def) {
|
||||||
|
SVGOMAnimatedBoolean v =
|
||||||
|
new SVGOMAnimatedBoolean(this, ns, ln, def);
|
||||||
|
liveAttributeValues.put(ns, ln, v);
|
||||||
|
v.addAnimatedAttributeListener
|
||||||
|
(((SVGOMDocument) ownerDocument).getAnimatedAttributeListener());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link SVGOMAnimatedString} and stores it in
|
||||||
|
* this element's LiveAttributeValue table.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString createLiveAnimatedString
|
||||||
|
(String ns, String ln) {
|
||||||
|
SVGOMAnimatedString v =
|
||||||
|
new SVGOMAnimatedString(this, ns, ln);
|
||||||
|
liveAttributeValues.put(ns, ln, v);
|
||||||
|
v.addAnimatedAttributeListener
|
||||||
|
(((SVGOMDocument) ownerDocument).getAnimatedAttributeListener());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link SVGOMAnimatedPreserveAspectRatio} and stores it in
|
||||||
|
* this element's LiveAttributeValue table.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedPreserveAspectRatio
|
||||||
|
createLiveAnimatedPreserveAspectRatio() {
|
||||||
|
SVGOMAnimatedPreserveAspectRatio v =
|
||||||
|
new SVGOMAnimatedPreserveAspectRatio(this);
|
||||||
|
liveAttributeValues.put(null, SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE, v);
|
||||||
|
v.addAnimatedAttributeListener
|
||||||
|
(((SVGOMDocument) ownerDocument).getAnimatedAttributeListener());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link SVGOMAnimatedMarkerOrientValue} and stores it in
|
||||||
|
* this element's LiveAttributeValue table.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedMarkerOrientValue
|
||||||
|
createLiveAnimatedMarkerOrientValue(String ns, String ln) {
|
||||||
|
SVGOMAnimatedMarkerOrientValue v =
|
||||||
|
new SVGOMAnimatedMarkerOrientValue(this, ns, ln);
|
||||||
|
liveAttributeValues.put(ns, ln, v);
|
||||||
|
v.addAnimatedAttributeListener
|
||||||
|
(((SVGOMDocument) ownerDocument).getAnimatedAttributeListener());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link SVGOMAnimatedPathData} and stores it in
|
||||||
|
* this element's LiveAttributeValue table.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedPathData
|
||||||
|
createLiveAnimatedPathData(String ns, String ln, String def) {
|
||||||
|
SVGOMAnimatedPathData v =
|
||||||
|
new SVGOMAnimatedPathData(this, ns, ln, def);
|
||||||
|
liveAttributeValues.put(ns, ln, v);
|
||||||
|
v.addAnimatedAttributeListener
|
||||||
|
(((SVGOMDocument) ownerDocument).getAnimatedAttributeListener());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link SVGOMAnimatedNumber} and stores it in
|
||||||
|
* this element's LiveAttributeValue table.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber createLiveAnimatedNumber
|
||||||
|
(String ns, String ln, float def) {
|
||||||
|
return createLiveAnimatedNumber(ns, ln, def, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link SVGOMAnimatedNumber} that can be parsed as a
|
||||||
|
* percentage and stores it in this element's LiveAttributeValue table.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber createLiveAnimatedNumber
|
||||||
|
(String ns, String ln, float def, boolean allowPercentage) {
|
||||||
|
SVGOMAnimatedNumber v =
|
||||||
|
new SVGOMAnimatedNumber(this, ns, ln, def, allowPercentage);
|
||||||
|
liveAttributeValues.put(ns, ln, v);
|
||||||
|
v.addAnimatedAttributeListener
|
||||||
|
(((SVGOMDocument) ownerDocument).getAnimatedAttributeListener());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link SVGOMAnimatedNumberList} and stores it in
|
||||||
|
* this element's LiveAttributeValue table.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumberList createLiveAnimatedNumberList
|
||||||
|
(String ns, String ln, String def, boolean canEmpty) {
|
||||||
|
SVGOMAnimatedNumberList v =
|
||||||
|
new SVGOMAnimatedNumberList(this, ns, ln, def, canEmpty);
|
||||||
|
liveAttributeValues.put(ns, ln, v);
|
||||||
|
v.addAnimatedAttributeListener
|
||||||
|
(((SVGOMDocument) ownerDocument).getAnimatedAttributeListener());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link SVGOMAnimatedPoints} and stores it in
|
||||||
|
* this element's LiveAttributeValue table.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedPoints createLiveAnimatedPoints
|
||||||
|
(String ns, String ln, String def) {
|
||||||
|
SVGOMAnimatedPoints v =
|
||||||
|
new SVGOMAnimatedPoints(this, ns, ln, def);
|
||||||
|
liveAttributeValues.put(ns, ln, v);
|
||||||
|
v.addAnimatedAttributeListener
|
||||||
|
(((SVGOMDocument) ownerDocument).getAnimatedAttributeListener());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link SVGOMAnimatedLengthList} and stores it in
|
||||||
|
* this element's LiveAttributeValue table.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedLengthList createLiveAnimatedLengthList
|
||||||
|
(String ns, String ln, String def, boolean emptyAllowed,
|
||||||
|
short dir) {
|
||||||
|
SVGOMAnimatedLengthList v =
|
||||||
|
new SVGOMAnimatedLengthList(this, ns, ln, def, emptyAllowed, dir);
|
||||||
|
liveAttributeValues.put(ns, ln, v);
|
||||||
|
v.addAnimatedAttributeListener
|
||||||
|
(((SVGOMDocument) ownerDocument).getAnimatedAttributeListener());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link SVGOMAnimatedInteger} and stores it in
|
||||||
|
* this element's LiveAttributeValue table.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedInteger createLiveAnimatedInteger
|
||||||
|
(String ns, String ln, int def) {
|
||||||
|
SVGOMAnimatedInteger v =
|
||||||
|
new SVGOMAnimatedInteger(this, ns, ln, def);
|
||||||
|
liveAttributeValues.put(ns, ln, v);
|
||||||
|
v.addAnimatedAttributeListener
|
||||||
|
(((SVGOMDocument) ownerDocument).getAnimatedAttributeListener());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link SVGOMAnimatedEnumeration} and stores it in
|
||||||
|
* this element's LiveAttributeValue table.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedEnumeration createLiveAnimatedEnumeration
|
||||||
|
(String ns, String ln, String[] val, short def) {
|
||||||
|
SVGOMAnimatedEnumeration v =
|
||||||
|
new SVGOMAnimatedEnumeration(this, ns, ln, val, def);
|
||||||
|
liveAttributeValues.put(ns, ln, v);
|
||||||
|
v.addAnimatedAttributeListener
|
||||||
|
(((SVGOMDocument) ownerDocument).getAnimatedAttributeListener());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link SVGOMAnimatedLength} and stores it in
|
||||||
|
* this element's LiveAttributeValue table.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedLength createLiveAnimatedLength
|
||||||
|
(String ns, String ln, String val, short dir, boolean nonneg) {
|
||||||
|
SVGOMAnimatedLength v =
|
||||||
|
new SVGOMAnimatedLength(this, ns, ln, val, dir, nonneg);
|
||||||
|
liveAttributeValues.put(ns, ln, v);
|
||||||
|
v.addAnimatedAttributeListener
|
||||||
|
(((SVGOMDocument) ownerDocument).getAnimatedAttributeListener());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link SVGOMAnimatedRect} and stores it in
|
||||||
|
* this element's LiveAttributeValue table.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedRect createLiveAnimatedRect
|
||||||
|
(String ns, String ln, String value) {
|
||||||
|
SVGOMAnimatedRect v = new SVGOMAnimatedRect(this, ns, ln, value);
|
||||||
|
liveAttributeValues.put(ns, ln, v);
|
||||||
|
v.addAnimatedAttributeListener
|
||||||
|
(((SVGOMDocument) ownerDocument).getAnimatedAttributeListener());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExtendedTraitAccess ///////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given CSS property is available on this element.
|
||||||
|
*/
|
||||||
|
public boolean hasProperty(String pn) {
|
||||||
|
AbstractStylableDocument doc = (AbstractStylableDocument) ownerDocument;
|
||||||
|
CSSEngine eng = doc.getCSSEngine();
|
||||||
|
return eng.getPropertyIndex(pn) != -1
|
||||||
|
|| eng.getShorthandIndex(pn) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given trait is available on this element.
|
||||||
|
*/
|
||||||
|
public boolean hasTrait(String ns, String ln) {
|
||||||
|
// XXX no traits yet
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given CSS property is animatable.
|
||||||
|
*/
|
||||||
|
public boolean isPropertyAnimatable(String pn) {
|
||||||
|
AbstractStylableDocument doc = (AbstractStylableDocument) ownerDocument;
|
||||||
|
CSSEngine eng = doc.getCSSEngine();
|
||||||
|
int idx = eng.getPropertyIndex(pn);
|
||||||
|
if (idx != -1) {
|
||||||
|
ValueManager[] vms = eng.getValueManagers();
|
||||||
|
return vms[idx].isAnimatableProperty();
|
||||||
|
}
|
||||||
|
idx = eng.getShorthandIndex(pn);
|
||||||
|
if (idx != -1) {
|
||||||
|
ShorthandManager[] sms = eng.getShorthandManagers();
|
||||||
|
return sms[idx].isAnimatableProperty();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given XML attribute is animatable.
|
||||||
|
*/
|
||||||
|
public final boolean isAttributeAnimatable(String ns, String ln) {
|
||||||
|
DoublyIndexedTable t = getTraitInformationTable();
|
||||||
|
TraitInformation ti = (TraitInformation) t.get(ns, ln);
|
||||||
|
if (ti != null) {
|
||||||
|
return ti.isAnimatable();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given CSS property is additive.
|
||||||
|
*/
|
||||||
|
public boolean isPropertyAdditive(String pn) {
|
||||||
|
AbstractStylableDocument doc = (AbstractStylableDocument) ownerDocument;
|
||||||
|
CSSEngine eng = doc.getCSSEngine();
|
||||||
|
int idx = eng.getPropertyIndex(pn);
|
||||||
|
if (idx != -1) {
|
||||||
|
ValueManager[] vms = eng.getValueManagers();
|
||||||
|
return vms[idx].isAdditiveProperty();
|
||||||
|
}
|
||||||
|
idx = eng.getShorthandIndex(pn);
|
||||||
|
if (idx != -1) {
|
||||||
|
ShorthandManager[] sms = eng.getShorthandManagers();
|
||||||
|
return sms[idx].isAdditiveProperty();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given XML attribute is additive.
|
||||||
|
*/
|
||||||
|
public boolean isAttributeAdditive(String ns, String ln) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given trait is animatable.
|
||||||
|
*/
|
||||||
|
public boolean isTraitAnimatable(String ns, String tn) {
|
||||||
|
// XXX no traits yet
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given trait is additive.
|
||||||
|
*/
|
||||||
|
public boolean isTraitAdditive(String ns, String tn) {
|
||||||
|
// XXX no traits yet
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the type of the given property.
|
||||||
|
*/
|
||||||
|
public int getPropertyType(String pn) {
|
||||||
|
AbstractStylableDocument doc =
|
||||||
|
(AbstractStylableDocument) ownerDocument;
|
||||||
|
CSSEngine eng = doc.getCSSEngine();
|
||||||
|
int idx = eng.getPropertyIndex(pn);
|
||||||
|
if (idx != -1) {
|
||||||
|
ValueManager[] vms = eng.getValueManagers();
|
||||||
|
return vms[idx].getPropertyType();
|
||||||
|
}
|
||||||
|
return SVGTypes.TYPE_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the type of the given attribute.
|
||||||
|
*/
|
||||||
|
public final int getAttributeType(String ns, String ln) {
|
||||||
|
DoublyIndexedTable t = getTraitInformationTable();
|
||||||
|
TraitInformation ti = (TraitInformation) t.get(ns, ln);
|
||||||
|
if (ti != null) {
|
||||||
|
return ti.getType();
|
||||||
|
}
|
||||||
|
return SVGTypes.TYPE_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AnimationTarget ///////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the element.
|
||||||
|
*/
|
||||||
|
public Element getElement() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a property value in this target. Ignored for non-stylable
|
||||||
|
* elements. Overridden in {@link SVGStylableElement} to actually update
|
||||||
|
* properties.
|
||||||
|
*/
|
||||||
|
public void updatePropertyValue(String pn, AnimatableValue val) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates an attribute value in this target.
|
||||||
|
*/
|
||||||
|
public void updateAttributeValue(String ns, String ln,
|
||||||
|
AnimatableValue val) {
|
||||||
|
LiveAttributeValue a = getLiveAttributeValue(ns, ln);
|
||||||
|
((AbstractSVGAnimatedValue) a).updateAnimatedValue(val);
|
||||||
|
// XXX Override this for NumberOptionalNumber values
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a 'other' animation value in this target.
|
||||||
|
*/
|
||||||
|
public void updateOtherValue(String type, AnimatableValue val) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the underlying value of an animatable XML attribute.
|
||||||
|
*/
|
||||||
|
public AnimatableValue getUnderlyingValue(String ns, String ln) {
|
||||||
|
LiveAttributeValue a = getLiveAttributeValue(ns, ln);
|
||||||
|
if (!(a instanceof AnimatedLiveAttributeValue)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return ((AnimatedLiveAttributeValue) a).getUnderlyingValue(this);
|
||||||
|
// XXX Override this for NumberOptionalNumber values
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an AnimatableNumberOptionalNumberValue for the base value of
|
||||||
|
* the given two SVGAnimatedIntegers.
|
||||||
|
*/
|
||||||
|
protected AnimatableValue getBaseValue(SVGAnimatedInteger n,
|
||||||
|
SVGAnimatedInteger on) {
|
||||||
|
return new AnimatableNumberOptionalNumberValue
|
||||||
|
(this, n.getBaseVal(), on.getBaseVal());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an AnimatableNumberOptionalNumberValue for the base value of
|
||||||
|
* the given two SVGAnimatedNumbers.
|
||||||
|
*/
|
||||||
|
protected AnimatableValue getBaseValue(SVGAnimatedNumber n,
|
||||||
|
SVGAnimatedNumber on) {
|
||||||
|
return new AnimatableNumberOptionalNumberValue
|
||||||
|
(this, n.getBaseVal(), on.getBaseVal());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets how percentage values are interpreted by the given attribute
|
||||||
|
* or property.
|
||||||
|
*/
|
||||||
|
public short getPercentageInterpretation(String ns, String an,
|
||||||
|
boolean isCSS) {
|
||||||
|
if (isCSS || ns == null) {
|
||||||
|
if (an.equals(CSSConstants.CSS_BASELINE_SHIFT_PROPERTY)
|
||||||
|
|| an.equals(CSSConstants.CSS_FONT_SIZE_PROPERTY)) {
|
||||||
|
return PERCENTAGE_FONT_SIZE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isCSS) {
|
||||||
|
DoublyIndexedTable t = getTraitInformationTable();
|
||||||
|
TraitInformation ti = (TraitInformation) t.get(ns, an);
|
||||||
|
if (ti != null) {
|
||||||
|
return ti.getPercentageInterpretation();
|
||||||
|
}
|
||||||
|
return PERCENTAGE_VIEWPORT_SIZE;
|
||||||
|
}
|
||||||
|
// Default for properties.
|
||||||
|
return PERCENTAGE_VIEWPORT_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets how percentage values are interpreted by the given attribute.
|
||||||
|
*/
|
||||||
|
protected final short getAttributePercentageInterpretation(String ns, String ln) {
|
||||||
|
return PERCENTAGE_VIEWPORT_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether color interpolations should be done in linear RGB
|
||||||
|
* color space rather than sRGB. Overriden in {@link SVGStylableElement}
|
||||||
|
* to actually look up the 'color-interpolation' property.
|
||||||
|
*/
|
||||||
|
public boolean useLinearRGBColorInterpolation() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the given SVG length into user units.
|
||||||
|
* @param v the SVG length value
|
||||||
|
* @param type the SVG length units (one of the
|
||||||
|
* {@link SVGLength}.SVG_LENGTH_* constants)
|
||||||
|
* @param pcInterp how to interpretet percentage values (one of the
|
||||||
|
* {@link SVGContext}.PERCENTAGE_* constants)
|
||||||
|
* @return the SVG value in user units
|
||||||
|
*/
|
||||||
|
public float svgToUserSpace(float v, short type, short pcInterp) {
|
||||||
|
if (unitContext == null) {
|
||||||
|
unitContext = new UnitContext();
|
||||||
|
}
|
||||||
|
if (pcInterp == PERCENTAGE_FONT_SIZE
|
||||||
|
&& type == SVGLength.SVG_LENGTHTYPE_PERCENTAGE) {
|
||||||
|
// XXX
|
||||||
|
return 0f;
|
||||||
|
} else {
|
||||||
|
return UnitProcessor.svgToUserSpace(v, type, (short) (3 - pcInterp),
|
||||||
|
unitContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a listener for changes to the given attribute value.
|
||||||
|
*/
|
||||||
|
public void addTargetListener(String ns, String an, boolean isCSS,
|
||||||
|
AnimationTargetListener l) {
|
||||||
|
if (!isCSS) {
|
||||||
|
if (targetListeners == null) {
|
||||||
|
targetListeners = new DoublyIndexedTable();
|
||||||
|
}
|
||||||
|
LinkedList ll = (LinkedList) targetListeners.get(ns, an);
|
||||||
|
if (ll == null) {
|
||||||
|
ll = new LinkedList();
|
||||||
|
targetListeners.put(ns, an, ll);
|
||||||
|
}
|
||||||
|
ll.add(l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a listener for changes to the given attribute value.
|
||||||
|
*/
|
||||||
|
public void removeTargetListener(String ns, String an, boolean isCSS,
|
||||||
|
AnimationTargetListener l) {
|
||||||
|
if (!isCSS) {
|
||||||
|
LinkedList ll = (LinkedList) targetListeners.get(ns, an);
|
||||||
|
ll.remove(l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fires the listeners registered for changes to the base value of the
|
||||||
|
* given attribute.
|
||||||
|
*/
|
||||||
|
void fireBaseAttributeListeners(String ns, String ln) {
|
||||||
|
if (targetListeners != null) {
|
||||||
|
LinkedList ll = (LinkedList) targetListeners.get(ns, ln);
|
||||||
|
for (Object aLl : ll) {
|
||||||
|
AnimationTargetListener l = (AnimationTargetListener) aLl;
|
||||||
|
l.baseValueChanged(this, ns, ln, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Importation/Cloning ///////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exports this node to the given document.
|
||||||
|
*/
|
||||||
|
protected Node export(Node n, AbstractDocument d) {
|
||||||
|
super.export(n, d);
|
||||||
|
SVGOMElement e = (SVGOMElement)n;
|
||||||
|
e.prefix = prefix;
|
||||||
|
e.initializeAllLiveAttributes();
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deeply exports this node to the given document.
|
||||||
|
*/
|
||||||
|
protected Node deepExport(Node n, AbstractDocument d) {
|
||||||
|
super.deepExport(n, d);
|
||||||
|
SVGOMElement e = (SVGOMElement)n;
|
||||||
|
e.prefix = prefix;
|
||||||
|
e.initializeAllLiveAttributes();
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy the fields of the current node into the given node.
|
||||||
|
* @param n a node of the type of this.
|
||||||
|
*/
|
||||||
|
protected Node copyInto(Node n) {
|
||||||
|
super.copyInto(n);
|
||||||
|
SVGOMElement e = (SVGOMElement)n;
|
||||||
|
e.prefix = prefix;
|
||||||
|
e.initializeAllLiveAttributes();
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deeply copy the fields of the current node into the given node.
|
||||||
|
* @param n a node of the type of this.
|
||||||
|
*/
|
||||||
|
protected Node deepCopyInto(Node n) {
|
||||||
|
super.deepCopyInto(n);
|
||||||
|
SVGOMElement e = (SVGOMElement)n;
|
||||||
|
e.prefix = prefix;
|
||||||
|
e.initializeAllLiveAttributes();
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To resolve the units.
|
||||||
|
*/
|
||||||
|
protected class UnitContext implements UnitProcessor.Context {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the element.
|
||||||
|
*/
|
||||||
|
public Element getElement() {
|
||||||
|
return SVGOMElement.this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the size of a px CSS unit in millimeters.
|
||||||
|
*/
|
||||||
|
public float getPixelUnitToMillimeter() {
|
||||||
|
return getSVGContext().getPixelUnitToMillimeter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the size of a px CSS unit in millimeters.
|
||||||
|
* This will be removed after next release.
|
||||||
|
* @see #getPixelUnitToMillimeter()
|
||||||
|
*/
|
||||||
|
public float getPixelToMM() {
|
||||||
|
return getPixelUnitToMillimeter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the font-size value.
|
||||||
|
*/
|
||||||
|
public float getFontSize() {
|
||||||
|
return getSVGContext().getFontSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the x-height value.
|
||||||
|
*/
|
||||||
|
public float getXHeight() {
|
||||||
|
return 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the viewport width used to compute units.
|
||||||
|
*/
|
||||||
|
public float getViewportWidth() {
|
||||||
|
return getSVGContext().getViewportWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the viewport height used to compute units.
|
||||||
|
*/
|
||||||
|
public float getViewportHeight() {
|
||||||
|
return getSVGContext().getViewportHeight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,167 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedLength;
|
||||||
|
import org.w3c.dom.svg.SVGEllipseElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGEllipseElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMEllipseElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMEllipseElement
|
||||||
|
extends SVGGraphicsElement
|
||||||
|
implements SVGEllipseElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGGraphicsElement.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_CX_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_WIDTH));
|
||||||
|
t.put(null, SVG_CY_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_HEIGHT));
|
||||||
|
t.put(null, SVG_RX_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_WIDTH));
|
||||||
|
t.put(null, SVG_RY_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_HEIGHT));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'cx' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedLength cx;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'cy' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedLength cy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'rx' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedLength rx;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'ry' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedLength ry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMEllipseElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMEllipseElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMEllipseElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMEllipseElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
cx = createLiveAnimatedLength
|
||||||
|
(null, SVG_CX_ATTRIBUTE, SVG_ELLIPSE_CX_DEFAULT_VALUE,
|
||||||
|
SVGOMAnimatedLength.HORIZONTAL_LENGTH, false);
|
||||||
|
cy = createLiveAnimatedLength
|
||||||
|
(null, SVG_CY_ATTRIBUTE, SVG_ELLIPSE_CY_DEFAULT_VALUE,
|
||||||
|
SVGOMAnimatedLength.VERTICAL_LENGTH, false);
|
||||||
|
rx = createLiveAnimatedLength
|
||||||
|
(null, SVG_RX_ATTRIBUTE, null,
|
||||||
|
SVGOMAnimatedLength.HORIZONTAL_LENGTH, true);
|
||||||
|
ry = createLiveAnimatedLength
|
||||||
|
(null, SVG_RY_ATTRIBUTE, null, SVGOMAnimatedLength.VERTICAL_LENGTH,
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_ELLIPSE_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGEllipseElement#getCx()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedLength getCx() {
|
||||||
|
return cx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGEllipseElement#getCy()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedLength getCy() {
|
||||||
|
return cy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGEllipseElement#getRx()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedLength getRx() {
|
||||||
|
return rx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGEllipseElement#getRy()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedLength getRy() {
|
||||||
|
return ry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMEllipseElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,161 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedEnumeration;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedString;
|
||||||
|
import org.w3c.dom.svg.SVGFEBlendElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFEBlendElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFEBlendElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFEBlendElement
|
||||||
|
extends SVGOMFilterPrimitiveStandardAttributes
|
||||||
|
implements SVGFEBlendElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMFilterPrimitiveStandardAttributes.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_IN_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_CDATA));
|
||||||
|
t.put(null, SVG_SURFACE_SCALE_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_DIFFUSE_CONSTANT_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_KERNEL_UNIT_LENGTH_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER_OPTIONAL_NUMBER));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'mode' attribute values.
|
||||||
|
*/
|
||||||
|
protected static final String[] MODE_VALUES = {
|
||||||
|
"",
|
||||||
|
SVG_NORMAL_VALUE,
|
||||||
|
SVG_MULTIPLY_VALUE,
|
||||||
|
SVG_SCREEN_VALUE,
|
||||||
|
SVG_DARKEN_VALUE,
|
||||||
|
SVG_LIGHTEN_VALUE
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'in' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString in;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'in2' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString in2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'mode' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedEnumeration mode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEBlendElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFEBlendElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEBlendElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFEBlendElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
in = createLiveAnimatedString(null, SVG_IN_ATTRIBUTE);
|
||||||
|
in2 = createLiveAnimatedString(null, SVG_IN2_ATTRIBUTE);
|
||||||
|
mode =
|
||||||
|
createLiveAnimatedEnumeration
|
||||||
|
(null, SVG_MODE_ATTRIBUTE, MODE_VALUES, (short) 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_BLEND_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEBlendElement#getIn1()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getIn1() {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEBlendElement#getIn2()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getIn2() {
|
||||||
|
return in2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEBlendElement#getMode()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedEnumeration getMode() {
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFEBlendElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,160 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedEnumeration;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedNumberList;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedString;
|
||||||
|
import org.w3c.dom.svg.SVGFEColorMatrixElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFEColorMatrixElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFEColorMatrixElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFEColorMatrixElement
|
||||||
|
extends SVGOMFilterPrimitiveStandardAttributes
|
||||||
|
implements SVGFEColorMatrixElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMFilterPrimitiveStandardAttributes.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_IN_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_CDATA));
|
||||||
|
t.put(null, SVG_TYPE_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_IDENT));
|
||||||
|
t.put(null, SVG_VALUES_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER_LIST));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'type' attribute values.
|
||||||
|
*/
|
||||||
|
protected static final String[] TYPE_VALUES = {
|
||||||
|
"",
|
||||||
|
SVG_MATRIX_VALUE,
|
||||||
|
SVG_SATURATE_VALUE,
|
||||||
|
SVG_HUE_ROTATE_VALUE,
|
||||||
|
SVG_LUMINANCE_TO_ALPHA_VALUE
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'in' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString in;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'type' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedEnumeration type;
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * The 'values' attribute value.
|
||||||
|
// */
|
||||||
|
// protected SVGOMAnimatedNumberList values;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEColorMatrixElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFEColorMatrixElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEColorMatrixElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFEColorMatrixElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
in = createLiveAnimatedString(null, SVG_IN_ATTRIBUTE);
|
||||||
|
type =
|
||||||
|
createLiveAnimatedEnumeration
|
||||||
|
(null, SVG_TYPE_ATTRIBUTE, TYPE_VALUES, (short) 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_COLOR_MATRIX_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEColorMatrixElement#getIn1()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getIn1() {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEColorMatrixElement#getType()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedEnumeration getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEColorMatrixElement#getValues()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumberList getValues() {
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFEColorMatrixElement.getValues is not implemented"); // XXX
|
||||||
|
// return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFEColorMatrixElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,115 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedString;
|
||||||
|
import org.w3c.dom.svg.SVGFEComponentTransferElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFEComponentTransferElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFEComponentTransferElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFEComponentTransferElement
|
||||||
|
extends SVGOMFilterPrimitiveStandardAttributes
|
||||||
|
implements SVGFEComponentTransferElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMFilterPrimitiveStandardAttributes.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_IN_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_CDATA));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'in' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString in;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEComponentTransferElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFEComponentTransferElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEComponentTransferElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFEComponentTransferElement(String prefix,
|
||||||
|
AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
in = createLiveAnimatedString(null, SVG_IN_ATTRIBUTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link org.w3c.dom.Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_COMPONENT_TRANSFER_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEComponentTransferElement#getIn1()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getIn1() {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFEComponentTransferElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,221 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedEnumeration;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedNumber;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedString;
|
||||||
|
import org.w3c.dom.svg.SVGFECompositeElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFECompositeElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFECompositeElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFECompositeElement
|
||||||
|
extends SVGOMFilterPrimitiveStandardAttributes
|
||||||
|
implements SVGFECompositeElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMFilterPrimitiveStandardAttributes.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_IN_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_CDATA));
|
||||||
|
t.put(null, SVG_IN2_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_CDATA));
|
||||||
|
t.put(null, SVG_OPERATOR_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_IDENT));
|
||||||
|
t.put(null, SVG_K1_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_K2_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_K3_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_K4_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'operator' attribute values.
|
||||||
|
*/
|
||||||
|
protected static final String[] OPERATOR_VALUES = {
|
||||||
|
"",
|
||||||
|
SVG_OVER_VALUE,
|
||||||
|
SVG_IN_VALUE,
|
||||||
|
SVG_OUT_VALUE,
|
||||||
|
SVG_ATOP_VALUE,
|
||||||
|
SVG_XOR_VALUE,
|
||||||
|
SVG_ARITHMETIC_VALUE
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'in' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString in;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'in2' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString in2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'operator' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedEnumeration operator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'k1' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber k1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'k2' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber k2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'k3' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber k3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'k4' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber k4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFECompositeElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFECompositeElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFECompositeElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFECompositeElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
in = createLiveAnimatedString(null, SVG_IN_ATTRIBUTE);
|
||||||
|
in2 = createLiveAnimatedString(null, SVG_IN2_ATTRIBUTE);
|
||||||
|
operator =
|
||||||
|
createLiveAnimatedEnumeration
|
||||||
|
(null, SVG_OPERATOR_ATTRIBUTE, OPERATOR_VALUES, (short) 1);
|
||||||
|
k1 = createLiveAnimatedNumber(null, SVG_K1_ATTRIBUTE, 0f);
|
||||||
|
k2 = createLiveAnimatedNumber(null, SVG_K2_ATTRIBUTE, 0f);
|
||||||
|
k3 = createLiveAnimatedNumber(null, SVG_K3_ATTRIBUTE, 0f);
|
||||||
|
k4 = createLiveAnimatedNumber(null, SVG_K4_ATTRIBUTE, 0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_COMPOSITE_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFECompositeElement#getIn1()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getIn1() {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFECompositeElement#getIn2()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getIn2() {
|
||||||
|
return in2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFECompositeElement#getOperator()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedEnumeration getOperator() {
|
||||||
|
return operator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFECompositeElement#getK1()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getK1() {
|
||||||
|
return k1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFECompositeElement#getK2()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getK2() {
|
||||||
|
return k2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFECompositeElement#getK3()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getK3() {
|
||||||
|
return k3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFECompositeElement#getK4()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getK4() {
|
||||||
|
return k4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFECompositeElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,331 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedBoolean;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedEnumeration;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedInteger;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedNumber;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedNumberList;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedString;
|
||||||
|
import org.w3c.dom.svg.SVGFEConvolveMatrixElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFEConvolveMatrixElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFEConvolveMatrixElement.java 1805420 2017-08-18 13:04:41Z ssteiner $
|
||||||
|
*/
|
||||||
|
public class SVGOMFEConvolveMatrixElement
|
||||||
|
extends SVGOMFilterPrimitiveStandardAttributes
|
||||||
|
implements SVGFEConvolveMatrixElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMFilterPrimitiveStandardAttributes.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_IN_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_CDATA));
|
||||||
|
t.put(null, SVG_ORDER_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER_OPTIONAL_NUMBER));
|
||||||
|
t.put(null, SVG_KERNEL_UNIT_LENGTH_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER_OPTIONAL_NUMBER));
|
||||||
|
t.put(null, SVG_KERNEL_MATRIX_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER_LIST));
|
||||||
|
t.put(null, SVG_DIVISOR_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_BIAS_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_TARGET_X_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_INTEGER));
|
||||||
|
t.put(null, SVG_TARGET_Y_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_INTEGER));
|
||||||
|
t.put(null, SVG_EDGE_MODE_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_IDENT));
|
||||||
|
t.put(null, SVG_PRESERVE_ALPHA_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_BOOLEAN));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'edgeMode' attribute values.
|
||||||
|
*/
|
||||||
|
protected static final String[] EDGE_MODE_VALUES = {
|
||||||
|
"",
|
||||||
|
SVG_DUPLICATE_VALUE,
|
||||||
|
SVG_WRAP_VALUE,
|
||||||
|
SVG_NONE_VALUE
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'in' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString in;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'edgeMode' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedEnumeration edgeMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'bias' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber bias;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'preserveAlpha' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedBoolean preserveAlpha;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEConvolveMatrixElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFEConvolveMatrixElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEConvolveMatrixElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFEConvolveMatrixElement(String prefix,
|
||||||
|
AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
in = createLiveAnimatedString(null, SVG_IN_ATTRIBUTE);
|
||||||
|
edgeMode =
|
||||||
|
createLiveAnimatedEnumeration
|
||||||
|
(null, SVG_EDGE_MODE_ATTRIBUTE, EDGE_MODE_VALUES, (short) 1);
|
||||||
|
bias = createLiveAnimatedNumber(null, SVG_BIAS_ATTRIBUTE, 0f);
|
||||||
|
preserveAlpha =
|
||||||
|
createLiveAnimatedBoolean
|
||||||
|
(null, SVG_PRESERVE_ALPHA_ATTRIBUTE, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_CONVOLVE_MATRIX_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements SVGFEConvolveMatrixElement#getIn1().
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getIn1() {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEConvolveMatrixElement#getEdgeMode()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedEnumeration getEdgeMode() {
|
||||||
|
return edgeMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEConvolveMatrixElement#getKernelMatrix()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumberList getKernelMatrix() {
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFEConvolveMatrixElement.getKernelMatrix is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEConvolveMatrixElement#getOrderX()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedInteger getOrderX() {
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFEConvolveMatrixElement.getOrderX is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEConvolveMatrixElement#getOrderY()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedInteger getOrderY() {
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFEConvolveMatrixElement.getOrderY is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEConvolveMatrixElement#getTargetX()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedInteger getTargetX() {
|
||||||
|
// Default value relative to orderX...
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFEConvolveMatrixElement.getTargetX is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEConvolveMatrixElement#getTargetY()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedInteger getTargetY() {
|
||||||
|
// Default value relative to orderY...
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFEConvolveMatrixElement.getTargetY is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEConvolveMatrixElement#getDivisor()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getDivisor() {
|
||||||
|
// Default value relative to kernel matrix...
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFEConvolveMatrixElement.getDivisor is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGFEConvolveMatrixElement#getBias()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getBias() {
|
||||||
|
return bias;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGFEConvolveMatrixElement#getKernelUnitLengthX()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getKernelUnitLengthX() {
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFEConvolveMatrixElement.getKernelUnitLengthX is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGFEConvolveMatrixElement#getKernelUnitLengthY()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getKernelUnitLengthY() {
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFEConvolveMatrixElement.getKernelUnitLengthY is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGFEConvolveMatrixElement#getPreserveAlpha()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedBoolean getPreserveAlpha() {
|
||||||
|
return preserveAlpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFEConvolveMatrixElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AnimationTarget ///////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// XXX TBD
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Updates an attribute value in this target.
|
||||||
|
// */
|
||||||
|
// public void updateAttributeValue(String ns, String ln,
|
||||||
|
// AnimatableValue val) {
|
||||||
|
// if (ns == null) {
|
||||||
|
// if (ln.equals(SVG_ORDER_ATTRIBUTE)) {
|
||||||
|
// if (val == null) {
|
||||||
|
// // XXX Needs testing.
|
||||||
|
// updateIntegerAttributeValue(getOrderX(), null);
|
||||||
|
// updateIntegerAttributeValue(getOrderY(), null);
|
||||||
|
// } else {
|
||||||
|
// AnimatableNumberOptionalNumberValue anonv =
|
||||||
|
// (AnimatableNumberOptionalNumberValue) val;
|
||||||
|
// SVGOMAnimatedInteger ai =
|
||||||
|
// (SVGOMAnimatedInteger) getOrderX();
|
||||||
|
// ai.setAnimatedValue(Math.round(anonv.getNumber()));
|
||||||
|
// ai = (SVGOMAnimatedInteger) getOrderY();
|
||||||
|
// if (anonv.hasOptionalNumber()) {
|
||||||
|
// ai.setAnimatedValue
|
||||||
|
// (Math.round(anonv.getOptionalNumber()));
|
||||||
|
// } else {
|
||||||
|
// ai.setAnimatedValue(Math.round(anonv.getNumber()));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return;
|
||||||
|
// } else if (ln.equals(SVG_KERNEL_UNIT_LENGTH_ATTRIBUTE)) {
|
||||||
|
// // XXX Needs testing.
|
||||||
|
// if (val == null) {
|
||||||
|
// updateNumberAttributeValue(getKernelUnitLengthX(), null);
|
||||||
|
// updateNumberAttributeValue(getKernelUnitLengthY(), null);
|
||||||
|
// } else {
|
||||||
|
// AnimatableNumberOptionalNumberValue anonv =
|
||||||
|
// (AnimatableNumberOptionalNumberValue) val;
|
||||||
|
// SVGOMAnimatedNumber an =
|
||||||
|
// (SVGOMAnimatedNumber) getKernelUnitLengthX();
|
||||||
|
// an.setAnimatedValue(anonv.getNumber());
|
||||||
|
// an = (SVGOMAnimatedNumber) getKernelUnitLengthY();
|
||||||
|
// if (anonv.hasOptionalNumber()) {
|
||||||
|
// an.setAnimatedValue(anonv.getOptionalNumber());
|
||||||
|
// } else {
|
||||||
|
// an.setAnimatedValue(anonv.getNumber());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// super.updateAttributeValue(ns, ln, val);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Returns the underlying value of an animatable XML attribute.
|
||||||
|
// */
|
||||||
|
// public AnimatableValue getUnderlyingValue(String ns, String ln) {
|
||||||
|
// if (ns == null) {
|
||||||
|
// if (ln.equals(SVG_KERNEL_UNIT_LENGTH_ATTRIBUTE)) {
|
||||||
|
// return getBaseValue(getKernelUnitLengthX(),
|
||||||
|
// getKernelUnitLengthY());
|
||||||
|
// } else if (ln.equals(SVG_ORDER_ATTRIBUTE)) {
|
||||||
|
// return getBaseValue(getOrderX(), getOrderY());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return super.getUnderlyingValue(ns, ln);
|
||||||
|
// }
|
||||||
|
}
|
|
@ -0,0 +1,217 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedNumber;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedString;
|
||||||
|
import org.w3c.dom.svg.SVGFEDiffuseLightingElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFEDiffuseLightingElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFEDiffuseLightingElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFEDiffuseLightingElement
|
||||||
|
extends SVGOMFilterPrimitiveStandardAttributes
|
||||||
|
implements SVGFEDiffuseLightingElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMFilterPrimitiveStandardAttributes.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_IN_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_CDATA));
|
||||||
|
t.put(null, SVG_SURFACE_SCALE_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_DIFFUSE_CONSTANT_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_KERNEL_UNIT_LENGTH_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER_OPTIONAL_NUMBER));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'in' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString in;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'surfaceScale' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber surfaceScale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'diffuseConstant' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber diffuseConstant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEDiffuseLightingElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFEDiffuseLightingElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEDiffuseLightingElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFEDiffuseLightingElement(String prefix,
|
||||||
|
AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
in = createLiveAnimatedString(null, SVG_IN_ATTRIBUTE);
|
||||||
|
surfaceScale =
|
||||||
|
createLiveAnimatedNumber(null, SVG_SURFACE_SCALE_ATTRIBUTE, 1f);
|
||||||
|
diffuseConstant =
|
||||||
|
createLiveAnimatedNumber(null, SVG_DIFFUSE_CONSTANT_ATTRIBUTE, 1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_DIFFUSE_LIGHTING_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEDiffuseLightingElement#getIn1()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getIn1() {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGFEDiffuseLightingElement#getSurfaceScale()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getSurfaceScale() {
|
||||||
|
return surfaceScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGFEDiffuseLightingElement#getDiffuseConstant()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getDiffuseConstant() {
|
||||||
|
return diffuseConstant;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGFEDiffuseLightingElement#getKernelUnitLengthX()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getKernelUnitLengthX() {
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFEDiffuseLightingElement.getKernelUnitLengthX is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGFEDiffuseLightingElement#getKernelUnitLengthY()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getKernelUnitLengthY() {
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFEDiffuseLightingElement.getKernelUnitLengthY is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFEDiffuseLightingElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AnimationTarget ///////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// XXX TBD
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Updates an attribute value in this target.
|
||||||
|
// */
|
||||||
|
// public void updateAttributeValue(String ns, String ln,
|
||||||
|
// AnimatableValue val) {
|
||||||
|
// if (ns == null) {
|
||||||
|
// if (ln.equals(SVG_KERNEL_UNIT_LENGTH_ATTRIBUTE)) {
|
||||||
|
// // XXX Needs testing.
|
||||||
|
// if (val == null) {
|
||||||
|
// updateNumberAttributeValue(getKernelUnitLengthX(), null);
|
||||||
|
// updateNumberAttributeValue(getKernelUnitLengthY(), null);
|
||||||
|
// } else {
|
||||||
|
// AnimatableNumberOptionalNumberValue anonv =
|
||||||
|
// (AnimatableNumberOptionalNumberValue) val;
|
||||||
|
// SVGOMAnimatedNumber an =
|
||||||
|
// (SVGOMAnimatedNumber) getKernelUnitLengthX();
|
||||||
|
// an.setAnimatedValue(anonv.getNumber());
|
||||||
|
// an = (SVGOMAnimatedNumber) getKernelUnitLengthY();
|
||||||
|
// if (anonv.hasOptionalNumber()) {
|
||||||
|
// an.setAnimatedValue(anonv.getOptionalNumber());
|
||||||
|
// } else {
|
||||||
|
// an.setAnimatedValue(anonv.getNumber());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// super.updateAttributeValue(ns, ln, val);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Returns the underlying value of an animatable XML attribute.
|
||||||
|
// */
|
||||||
|
// public AnimatableValue getUnderlyingValue(String ns, String ln) {
|
||||||
|
// if (ns == null) {
|
||||||
|
// if (ln.equals(SVG_KERNEL_UNIT_LENGTH_ATTRIBUTE)) {
|
||||||
|
// return getBaseValue(getKernelUnitLengthX(),
|
||||||
|
// getKernelUnitLengthY());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return super.getUnderlyingValue(ns, ln);
|
||||||
|
// }
|
||||||
|
}
|
|
@ -0,0 +1,199 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedEnumeration;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedNumber;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedString;
|
||||||
|
import org.w3c.dom.svg.SVGFEDisplacementMapElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link org.w3c.dom.svg.SVGFEDisplacementMapElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFEDisplacementMapElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFEDisplacementMapElement
|
||||||
|
extends SVGOMFilterPrimitiveStandardAttributes
|
||||||
|
implements SVGFEDisplacementMapElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMFilterPrimitiveStandardAttributes.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_IN_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_CDATA));
|
||||||
|
t.put(null, SVG_IN2_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_CDATA));
|
||||||
|
t.put(null, SVG_SCALE_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_X_CHANNEL_SELECTOR_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_IDENT));
|
||||||
|
t.put(null, SVG_Y_CHANNEL_SELECTOR_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_IDENT));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'xChannelSelector' and 'yChannelSelector' attributes values.
|
||||||
|
*/
|
||||||
|
protected static final String[] CHANNEL_SELECTOR_VALUES = {
|
||||||
|
"",
|
||||||
|
SVG_R_VALUE,
|
||||||
|
SVG_G_VALUE,
|
||||||
|
SVG_B_VALUE,
|
||||||
|
SVG_A_VALUE
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'in' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString in;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'in2' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString in2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'scale' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber scale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'xChannelSelector' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedEnumeration xChannelSelector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'yChannelSelector' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedEnumeration yChannelSelector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEDisplacementMap object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFEDisplacementMapElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEDisplacementMapElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFEDisplacementMapElement(String prefix,
|
||||||
|
AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
in = createLiveAnimatedString(null, SVG_IN_ATTRIBUTE);
|
||||||
|
in2 = createLiveAnimatedString(null, SVG_IN2_ATTRIBUTE);
|
||||||
|
scale = createLiveAnimatedNumber(null, SVG_SCALE_ATTRIBUTE, 0f);
|
||||||
|
xChannelSelector =
|
||||||
|
createLiveAnimatedEnumeration
|
||||||
|
(null, SVG_X_CHANNEL_SELECTOR_ATTRIBUTE,
|
||||||
|
CHANNEL_SELECTOR_VALUES, (short) 4);
|
||||||
|
yChannelSelector =
|
||||||
|
createLiveAnimatedEnumeration
|
||||||
|
(null, SVG_Y_CHANNEL_SELECTOR_ATTRIBUTE,
|
||||||
|
CHANNEL_SELECTOR_VALUES, (short) 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link org.w3c.dom.Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_DISPLACEMENT_MAP_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGFEDisplacementMapElement#getIn1()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getIn1() {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGFEDisplacementMapElement#getIn2()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getIn2() {
|
||||||
|
return in2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGFEDisplacementMapElement#getScale()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getScale() {
|
||||||
|
return scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGFEDisplacementMapElement#getXChannelSelector()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedEnumeration getXChannelSelector() {
|
||||||
|
return xChannelSelector;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGFEDisplacementMapElement#getYChannelSelector()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedEnumeration getYChannelSelector() {
|
||||||
|
return yChannelSelector;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFEDisplacementMapElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,130 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedNumber;
|
||||||
|
import org.w3c.dom.svg.SVGFEDistantLightElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFEDistantLightElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFEDistantLightElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFEDistantLightElement
|
||||||
|
extends SVGOMElement
|
||||||
|
implements SVGFEDistantLightElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMElement.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_AZIMUTH_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_ELEVATION_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'azimuth' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber azimuth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'elevation' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber elevation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEDistantLightElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFEDistantLightElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEDistantLightElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFEDistantLightElement(String prefix,
|
||||||
|
AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
azimuth = createLiveAnimatedNumber(null, SVG_AZIMUTH_ATTRIBUTE, 0f);
|
||||||
|
elevation = createLiveAnimatedNumber(null, SVG_ELEVATION_ATTRIBUTE, 0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_DISTANT_LIGHT_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEDistantLightElement#getAzimuth()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getAzimuth() {
|
||||||
|
return azimuth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEDistantLightElement#getElevation()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getElevation() {
|
||||||
|
return elevation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFEDistantLightElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,115 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedString;
|
||||||
|
import org.w3c.dom.svg.SVGFEFloodElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFEFloodElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFEFloodElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFEFloodElement
|
||||||
|
extends SVGOMFilterPrimitiveStandardAttributes
|
||||||
|
implements SVGFEFloodElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMFilterPrimitiveStandardAttributes.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_IN_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_CDATA));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'in' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString in;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEFloodElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFEFloodElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEFloodElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFEFloodElement(String prefix,
|
||||||
|
AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
in = createLiveAnimatedString(null, SVG_IN_ATTRIBUTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_FLOOD_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEFloodElement#getIn1()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getIn1() {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFEFloodElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGFEFuncAElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFEFuncAElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFEFuncAElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFEFuncAElement
|
||||||
|
extends SVGOMComponentTransferFunctionElement
|
||||||
|
implements SVGFEFuncAElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Element object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFEFuncAElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Element object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFEFuncAElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_FUNC_A_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFEFuncAElement();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGFEFuncBElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFEFuncBElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFEFuncBElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFEFuncBElement
|
||||||
|
extends SVGOMComponentTransferFunctionElement
|
||||||
|
implements SVGFEFuncBElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Element object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFEFuncBElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Element object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFEFuncBElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_FUNC_B_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFEFuncBElement();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGFEFuncGElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFEFuncGElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFEFuncGElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFEFuncGElement
|
||||||
|
extends SVGOMComponentTransferFunctionElement
|
||||||
|
implements SVGFEFuncGElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Element object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFEFuncGElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Element object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFEFuncGElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_FUNC_G_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFEFuncGElement();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGFEFuncRElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFEFuncRElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFEFuncRElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFEFuncRElement
|
||||||
|
extends SVGOMComponentTransferFunctionElement
|
||||||
|
implements SVGFEFuncRElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Element object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFEFuncRElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Element object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFEFuncRElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_FUNC_R_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFEFuncRElement();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,190 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedNumber;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedString;
|
||||||
|
import org.w3c.dom.svg.SVGFEGaussianBlurElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFEGaussianBlurElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFEGaussianBlurElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFEGaussianBlurElement
|
||||||
|
extends SVGOMFilterPrimitiveStandardAttributes
|
||||||
|
implements SVGFEGaussianBlurElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMFilterPrimitiveStandardAttributes.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_IN_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_CDATA));
|
||||||
|
t.put(null, SVG_STD_DEVIATION_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER_OPTIONAL_NUMBER));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'in' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString in;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEGaussianBlurElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFEGaussianBlurElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEGaussianBlurElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFEGaussianBlurElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
in = createLiveAnimatedString(null, SVG_IN_ATTRIBUTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_GAUSSIAN_BLUR_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEGaussianBlurElement#getIn1()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getIn1() {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGFEGaussianBlurElement#getStdDeviationX()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getStdDeviationX() {
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFEGaussianBlurElement.getStdDeviationX is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGFEGaussianBlurElement#getStdDeviationY()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getStdDeviationY() {
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFEGaussianBlurElement.getStdDeviationY is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGFEGaussianBlurElement#setStdDeviation(float,float)}.
|
||||||
|
*/
|
||||||
|
public void setStdDeviation(float devX, float devY) {
|
||||||
|
setAttributeNS(null, SVG_STD_DEVIATION_ATTRIBUTE,
|
||||||
|
Float.toString(devX) + " " + Float.toString(devY));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFEGaussianBlurElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AnimationTarget ///////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// XXX TBD
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Updates an attribute value in this target.
|
||||||
|
// */
|
||||||
|
// public void updateAttributeValue(String ns, String ln,
|
||||||
|
// AnimatableValue val) {
|
||||||
|
// if (ns == null) {
|
||||||
|
// if (ln.equals(SVG_STD_DEVIATION_ATTRIBUTE)) {
|
||||||
|
// // XXX Needs testing.
|
||||||
|
// if (val == null) {
|
||||||
|
// updateNumberAttributeValue(getStdDeviationX(), null);
|
||||||
|
// updateNumberAttributeValue(getStdDeviationY(), null);
|
||||||
|
// } else {
|
||||||
|
// AnimatableNumberOptionalNumberValue anonv =
|
||||||
|
// (AnimatableNumberOptionalNumberValue) val;
|
||||||
|
// SVGOMAnimatedNumber an =
|
||||||
|
// (SVGOMAnimatedNumber) getStdDeviationX();
|
||||||
|
// an.setAnimatedValue(anonv.getNumber());
|
||||||
|
// an = (SVGOMAnimatedNumber) getStdDeviationY();
|
||||||
|
// if (anonv.hasOptionalNumber()) {
|
||||||
|
// an.setAnimatedValue(anonv.getOptionalNumber());
|
||||||
|
// } else {
|
||||||
|
// an.setAnimatedValue(anonv.getNumber());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// super.updateAttributeValue(ns, ln, val);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Returns the underlying value of an animatable XML attribute.
|
||||||
|
// */
|
||||||
|
// public AnimatableValue getUnderlyingValue(String ns, String ln) {
|
||||||
|
// if (ns == null) {
|
||||||
|
// if (ln.equals(SVG_STD_DEVIATION_ATTRIBUTE)) {
|
||||||
|
// return getBaseValue(getStdDeviationX(), getStdDeviationY());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return super.getUnderlyingValue(ns, ln);
|
||||||
|
// }
|
||||||
|
}
|
|
@ -0,0 +1,211 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.dom.util.XLinkSupport;
|
||||||
|
import org.apache.batik.dom.util.XMLSupport;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedBoolean;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedPreserveAspectRatio;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedString;
|
||||||
|
import org.w3c.dom.svg.SVGFEImageElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFEImageElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFEImageElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFEImageElement
|
||||||
|
extends SVGOMFilterPrimitiveStandardAttributes
|
||||||
|
implements SVGFEImageElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMFilterPrimitiveStandardAttributes.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_EXTERNAL_RESOURCES_REQUIRED_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_BOOLEAN));
|
||||||
|
t.put(null, SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_PRESERVE_ASPECT_RATIO_VALUE));
|
||||||
|
t.put(XLINK_NAMESPACE_URI, XLINK_HREF_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_URI));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attribute initializer.
|
||||||
|
*/
|
||||||
|
protected static final AttributeInitializer attributeInitializer;
|
||||||
|
static {
|
||||||
|
attributeInitializer = new AttributeInitializer(4);
|
||||||
|
attributeInitializer.addAttribute(XMLSupport.XMLNS_NAMESPACE_URI,
|
||||||
|
null, "xmlns:xlink",
|
||||||
|
XLinkSupport.XLINK_NAMESPACE_URI);
|
||||||
|
attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
|
||||||
|
"xlink", "type", "simple");
|
||||||
|
attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
|
||||||
|
"xlink", "show", "embed");
|
||||||
|
attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
|
||||||
|
"xlink", "actuate", "onLoad");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'xlink:href' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString href;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'preserveAspectRatio' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedPreserveAspectRatio preserveAspectRatio;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'externalResourcesRequired' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedBoolean externalResourcesRequired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEImageElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFEImageElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEImageElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFEImageElement(String prefix,
|
||||||
|
AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
href =
|
||||||
|
createLiveAnimatedString(XLINK_NAMESPACE_URI, XLINK_HREF_ATTRIBUTE);
|
||||||
|
preserveAspectRatio = createLiveAnimatedPreserveAspectRatio();
|
||||||
|
externalResourcesRequired =
|
||||||
|
createLiveAnimatedBoolean
|
||||||
|
(null, SVG_EXTERNAL_RESOURCES_REQUIRED_ATTRIBUTE, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_IMAGE_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGURIReference#getHref()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getHref() {
|
||||||
|
return href;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEImageElement#getPreserveAspectRatio()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedPreserveAspectRatio getPreserveAspectRatio() {
|
||||||
|
return preserveAspectRatio;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SVGLangSpace support //////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Returns the xml:lang attribute value.
|
||||||
|
*/
|
||||||
|
public String getXMLlang() {
|
||||||
|
return XMLSupport.getXMLLang(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Sets the xml:lang attribute value.
|
||||||
|
*/
|
||||||
|
public void setXMLlang(String lang) {
|
||||||
|
setAttributeNS(XML_NAMESPACE_URI, XML_LANG_QNAME, lang);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Returns the xml:space attribute value.
|
||||||
|
*/
|
||||||
|
public String getXMLspace() {
|
||||||
|
return XMLSupport.getXMLSpace(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Sets the xml:space attribute value.
|
||||||
|
*/
|
||||||
|
public void setXMLspace(String space) {
|
||||||
|
setAttributeNS(XML_NAMESPACE_URI, XML_SPACE_QNAME, space);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SVGExternalResourcesRequired support /////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGExternalResourcesRequired#getExternalResourcesRequired()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedBoolean getExternalResourcesRequired() {
|
||||||
|
return externalResourcesRequired;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the AttributeInitializer for this element type.
|
||||||
|
* @return null if this element has no attribute with a default value.
|
||||||
|
*/
|
||||||
|
protected AttributeInitializer getAttributeInitializer() {
|
||||||
|
return attributeInitializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFEImageElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGFEMergeElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFEMergeElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFEMergeElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFEMergeElement
|
||||||
|
extends SVGOMFilterPrimitiveStandardAttributes
|
||||||
|
implements SVGFEMergeElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEMergeElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFEMergeElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEMergeElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFEMergeElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_MERGE_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFEMergeElement();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,115 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedString;
|
||||||
|
import org.w3c.dom.svg.SVGFEMergeNodeElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFEMergeNodeElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFEMergeNodeElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFEMergeNodeElement
|
||||||
|
extends SVGOMElement
|
||||||
|
implements SVGFEMergeNodeElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMElement.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_IN_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_CDATA));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'in' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString in;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEMergeNodeElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFEMergeNodeElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEMergeNodeElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFEMergeNodeElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
in = createLiveAnimatedString(null, SVG_IN_ATTRIBUTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_MERGE_NODE_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGFEMergeNodeElement#getIn1()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getIn1() {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFEMergeNodeElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,205 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedEnumeration;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedNumber;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedString;
|
||||||
|
import org.w3c.dom.svg.SVGFEMorphologyElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFEMorphologyElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFEMorphologyElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFEMorphologyElement
|
||||||
|
extends SVGOMFilterPrimitiveStandardAttributes
|
||||||
|
implements SVGFEMorphologyElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMFilterPrimitiveStandardAttributes.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_IN_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_CDATA));
|
||||||
|
t.put(null, SVG_OPERATOR_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_IDENT));
|
||||||
|
t.put(null, SVG_RADIUS_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER_OPTIONAL_NUMBER));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'operator' attribute values.
|
||||||
|
*/
|
||||||
|
protected static final String[] OPERATOR_VALUES = {
|
||||||
|
"",
|
||||||
|
SVG_ERODE_VALUE,
|
||||||
|
SVG_DILATE_VALUE
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'in' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString in;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'operator' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedEnumeration operator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEMorphologyElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFEMorphologyElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEMorphologyElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFEMorphologyElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
in = createLiveAnimatedString(null, SVG_IN_ATTRIBUTE);
|
||||||
|
operator =
|
||||||
|
createLiveAnimatedEnumeration
|
||||||
|
(null, SVG_OPERATOR_ATTRIBUTE, OPERATOR_VALUES, (short) 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_MORPHOLOGY_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEMorphologyElement#getIn1()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getIn1() {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEMorphologyElement#getOperator()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedEnumeration getOperator() {
|
||||||
|
return operator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEMorphologyElement#getRadiusX()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getRadiusX() {
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFEMorphologyElement.getRadiusX is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEMorphologyElement#getRadiusY()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getRadiusY() {
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFEMorphologyElement.getRadiusY is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFEMorphologyElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AnimationTarget ///////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// XXX TBD
|
||||||
|
// /**
|
||||||
|
// * Updates an attribute value in this target.
|
||||||
|
// */
|
||||||
|
// public void updateAttributeValue(String ns, String ln,
|
||||||
|
// AnimatableValue val) {
|
||||||
|
// if (ns == null) {
|
||||||
|
// if (ln.equals(SVG_RADIUS_ATTRIBUTE)) {
|
||||||
|
// // XXX Needs testing.
|
||||||
|
// if (val == null) {
|
||||||
|
// updateNumberAttributeValue(getRadiusX(), null);
|
||||||
|
// updateNumberAttributeValue(getRadiusY(), null);
|
||||||
|
// } else {
|
||||||
|
// AnimatableNumberOptionalNumberValue anonv =
|
||||||
|
// (AnimatableNumberOptionalNumberValue) val;
|
||||||
|
// SVGOMAnimatedNumber ai =
|
||||||
|
// (SVGOMAnimatedNumber) getRadiusX();
|
||||||
|
// ai.setAnimatedValue(anonv.getNumber());
|
||||||
|
// ai = (SVGOMAnimatedNumber) getRadiusY();
|
||||||
|
// if (anonv.hasOptionalNumber()) {
|
||||||
|
// ai.setAnimatedValue(anonv.getOptionalNumber());
|
||||||
|
// } else {
|
||||||
|
// ai.setAnimatedValue(anonv.getNumber());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// super.updateAttributeValue(ns, ln, val);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Returns the underlying value of an animatable XML attribute.
|
||||||
|
// */
|
||||||
|
// public AnimatableValue getUnderlyingValue(String ns, String ln) {
|
||||||
|
// if (ns == null) {
|
||||||
|
// if (ln.equals(SVG_RADIUS_ATTRIBUTE)) {
|
||||||
|
// return getBaseValue(getRadiusX(), getRadiusY());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return super.getUnderlyingValue(ns, ln);
|
||||||
|
// }
|
||||||
|
}
|
|
@ -0,0 +1,148 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedNumber;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedString;
|
||||||
|
import org.w3c.dom.svg.SVGFEOffsetElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFEOffsetElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFEOffsetElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFEOffsetElement
|
||||||
|
extends SVGOMFilterPrimitiveStandardAttributes
|
||||||
|
implements SVGFEOffsetElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMFilterPrimitiveStandardAttributes.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_IN_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_CDATA));
|
||||||
|
t.put(null, SVG_DX_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_DY_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'in' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString in;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'dx' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber dx;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'dy' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber dy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEOffsetElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFEOffsetElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEOffsetElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFEOffsetElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
in = createLiveAnimatedString(null, SVG_IN_ATTRIBUTE);
|
||||||
|
dx = createLiveAnimatedNumber(null, SVG_DX_ATTRIBUTE, 0f);
|
||||||
|
dy = createLiveAnimatedNumber(null, SVG_DY_ATTRIBUTE, 0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_OFFSET_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGFEOffsetElement#getIn1()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getIn1() {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGFEOffsetElement#getDx()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getDx() {
|
||||||
|
return dx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGFEOffsetElement#getDy()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getDy() {
|
||||||
|
return dy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFEOffsetElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,145 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedNumber;
|
||||||
|
import org.w3c.dom.svg.SVGFEPointLightElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFEPointLightElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFEPointLightElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFEPointLightElement
|
||||||
|
extends SVGOMElement
|
||||||
|
implements SVGFEPointLightElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMElement.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_X_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_Y_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_Z_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'x' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber x;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'y' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber y;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'z' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber z;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEPointLightElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFEPointLightElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFEPointLightElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFEPointLightElement(String prefix,
|
||||||
|
AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
x = createLiveAnimatedNumber(null, SVG_X_ATTRIBUTE, 0f);
|
||||||
|
y = createLiveAnimatedNumber(null, SVG_Y_ATTRIBUTE, 0f);
|
||||||
|
z = createLiveAnimatedNumber(null, SVG_Z_ATTRIBUTE, 0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_POINT_LIGHT_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEPointLightElement#getX()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEPointLightElement#getY()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFEPointLightElement#getZ()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getZ() {
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFEPointLightElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,167 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedNumber;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedString;
|
||||||
|
import org.w3c.dom.svg.SVGFESpecularLightingElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFESpecularLightingElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFESpecularLightingElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFESpecularLightingElement
|
||||||
|
extends SVGOMFilterPrimitiveStandardAttributes
|
||||||
|
implements SVGFESpecularLightingElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMFilterPrimitiveStandardAttributes.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_IN_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_CDATA));
|
||||||
|
t.put(null, SVG_SURFACE_SCALE_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_SPECULAR_CONSTANT_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_SPECULAR_EXPONENT_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'in' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString in;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'surfaceScale' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber surfaceScale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'specularConstant' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber specularConstant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'specularExponent' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber specularExponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFESpecularLightingElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFESpecularLightingElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFESpecularLightingElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFESpecularLightingElement(String prefix,
|
||||||
|
AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
in = createLiveAnimatedString(null, SVG_IN_ATTRIBUTE);
|
||||||
|
surfaceScale =
|
||||||
|
createLiveAnimatedNumber(null, SVG_SURFACE_SCALE_ATTRIBUTE, 1f);
|
||||||
|
specularConstant =
|
||||||
|
createLiveAnimatedNumber(null, SVG_SPECULAR_CONSTANT_ATTRIBUTE, 1f);
|
||||||
|
specularExponent =
|
||||||
|
createLiveAnimatedNumber(null, SVG_SPECULAR_EXPONENT_ATTRIBUTE, 1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_SPECULAR_LIGHTING_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFESpecularLightingElement#getIn1()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getIn1() {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGFESpecularLightingElement#getSurfaceScale()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getSurfaceScale() {
|
||||||
|
return surfaceScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGFESpecularLightingElement#getSpecularConstant()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getSpecularConstant() {
|
||||||
|
return specularConstant;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGFESpecularLightingElement#getSpecularExponent()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getSpecularExponent() {
|
||||||
|
return specularExponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFESpecularLightingElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,228 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedNumber;
|
||||||
|
import org.w3c.dom.svg.SVGFESpotLightElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFESpotLightElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFESpotLightElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFESpotLightElement
|
||||||
|
extends SVGOMElement
|
||||||
|
implements SVGFESpotLightElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMElement.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_X_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_Y_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_Z_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_POINTS_AT_X_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_POINTS_AT_Y_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_POINTS_AT_Z_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_SPECULAR_EXPONENT_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_LIMITING_CONE_ANGLE_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'x' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber x;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'y' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber y;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'z' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber z;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'pointsAtX' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber pointsAtX;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'pointsAtY' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber pointsAtY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'pointsAtZ' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber pointsAtZ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'specularExponent' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber specularExponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'limitingConeAngle' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber limitingConeAngle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFESpotLightElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFESpotLightElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFESpotLightElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFESpotLightElement(String prefix,
|
||||||
|
AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
x = createLiveAnimatedNumber(null, SVG_X_ATTRIBUTE, 0f);
|
||||||
|
y = createLiveAnimatedNumber(null, SVG_Y_ATTRIBUTE, 0f);
|
||||||
|
z = createLiveAnimatedNumber(null, SVG_Z_ATTRIBUTE, 0f);
|
||||||
|
pointsAtX =
|
||||||
|
createLiveAnimatedNumber(null, SVG_POINTS_AT_X_ATTRIBUTE, 0f);
|
||||||
|
pointsAtY =
|
||||||
|
createLiveAnimatedNumber(null, SVG_POINTS_AT_Y_ATTRIBUTE, 0f);
|
||||||
|
pointsAtZ =
|
||||||
|
createLiveAnimatedNumber(null, SVG_POINTS_AT_Z_ATTRIBUTE, 0f);
|
||||||
|
specularExponent =
|
||||||
|
createLiveAnimatedNumber(null, SVG_SPECULAR_EXPONENT_ATTRIBUTE, 1f);
|
||||||
|
limitingConeAngle =
|
||||||
|
createLiveAnimatedNumber
|
||||||
|
(null, SVG_LIMITING_CONE_ANGLE_ATTRIBUTE, 0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_SPOT_LIGHT_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFESpotLightElement#getX()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFESpotLightElement#getY()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFESpotLightElement#getZ()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getZ() {
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFESpotLightElement#getPointsAtX()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getPointsAtX() {
|
||||||
|
return pointsAtX;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFESpotLightElement#getPointsAtY()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getPointsAtY() {
|
||||||
|
return pointsAtY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFESpotLightElement#getPointsAtZ()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getPointsAtZ() {
|
||||||
|
return pointsAtZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGFESpotLightElement#getSpecularExponent()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getSpecularExponent() {
|
||||||
|
return specularExponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGFESpotLightElement#getLimitingConeAngle()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getLimitingConeAngle() {
|
||||||
|
return limitingConeAngle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFESpotLightElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,114 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedString;
|
||||||
|
import org.w3c.dom.svg.SVGFETileElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFETileElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFETileElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFETileElement
|
||||||
|
extends SVGOMFilterPrimitiveStandardAttributes
|
||||||
|
implements SVGFETileElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMFilterPrimitiveStandardAttributes.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_IN_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_CDATA));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'in' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString in;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFETileElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFETileElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFETileElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFETileElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
in = createLiveAnimatedString(null, SVG_IN_ATTRIBUTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_TILE_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFETileElement#getIn1()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getIn1() {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFETileElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,251 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedEnumeration;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedInteger;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedNumber;
|
||||||
|
import org.w3c.dom.svg.SVGFETurbulenceElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFETurbulenceElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFETurbulenceElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFETurbulenceElement
|
||||||
|
extends SVGOMFilterPrimitiveStandardAttributes
|
||||||
|
implements SVGFETurbulenceElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGOMFilterPrimitiveStandardAttributes.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_BASE_FREQUENCY_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER_OPTIONAL_NUMBER));
|
||||||
|
t.put(null, SVG_NUM_OCTAVES_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_INTEGER));
|
||||||
|
t.put(null, SVG_SEED_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER));
|
||||||
|
t.put(null, SVG_STITCH_TILES_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_IDENT));
|
||||||
|
t.put(null, SVG_TYPE_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_IDENT));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'stitchTiles' attribute values.
|
||||||
|
*/
|
||||||
|
protected static final String[] STITCH_TILES_VALUES = {
|
||||||
|
"",
|
||||||
|
SVG_STITCH_VALUE,
|
||||||
|
SVG_NO_STITCH_VALUE
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'type' attribute values.
|
||||||
|
*/
|
||||||
|
protected static final String[] TYPE_VALUES = {
|
||||||
|
"",
|
||||||
|
SVG_FRACTAL_NOISE_VALUE,
|
||||||
|
SVG_TURBULENCE_VALUE
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'numOctaves' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedInteger numOctaves;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'seed' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedNumber seed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'stitchTiles' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedEnumeration stitchTiles;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'type' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedEnumeration type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFETurbulence object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFETurbulenceElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFETurbulenceElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFETurbulenceElement(String prefix,
|
||||||
|
AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
numOctaves =
|
||||||
|
createLiveAnimatedInteger(null, SVG_NUM_OCTAVES_ATTRIBUTE, 1);
|
||||||
|
seed = createLiveAnimatedNumber(null, SVG_SEED_ATTRIBUTE, 0f);
|
||||||
|
stitchTiles =
|
||||||
|
createLiveAnimatedEnumeration
|
||||||
|
(null, SVG_STITCH_TILES_ATTRIBUTE, STITCH_TILES_VALUES,
|
||||||
|
(short) 2);
|
||||||
|
type =
|
||||||
|
createLiveAnimatedEnumeration
|
||||||
|
(null, SVG_TYPE_ATTRIBUTE, TYPE_VALUES, (short) 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FE_TURBULENCE_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGFETurbulenceElement#getBaseFrequencyX()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getBaseFrequencyX() {
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFETurbulenceElement.getBaseFrequencyX is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* SVGFETurbulenceElement#getBaseFrequencyY()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getBaseFrequencyY() {
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFETurbulenceElement.getBaseFrequencyY is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFETurbulenceElement#getNumOctaves()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedInteger getNumOctaves() {
|
||||||
|
return numOctaves;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFETurbulenceElement#getSeed()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedNumber getSeed() {
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFETurbulenceElement#getStitchTiles()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedEnumeration getStitchTiles() {
|
||||||
|
return stitchTiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFETurbulenceElement#getType()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedEnumeration getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFETurbulenceElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AnimationTarget ///////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// XXX TBD
|
||||||
|
// /**
|
||||||
|
// * Updates an attribute value in this target.
|
||||||
|
// */
|
||||||
|
// public void updateAttributeValue(String ns, String ln,
|
||||||
|
// AnimatableValue val) {
|
||||||
|
// if (ns == null) {
|
||||||
|
// if (ln.equals(SVG_BASE_FREQUENCY_ATTRIBUTE)) {
|
||||||
|
// // XXX Needs testing.
|
||||||
|
// if (val == null) {
|
||||||
|
// updateNumberAttributeValue(getBaseFrequencyX(), null);
|
||||||
|
// updateNumberAttributeValue(getBaseFrequencyY(), null);
|
||||||
|
// } else {
|
||||||
|
// AnimatableNumberOptionalNumberValue anonv =
|
||||||
|
// (AnimatableNumberOptionalNumberValue) val;
|
||||||
|
// SVGOMAnimatedNumber an =
|
||||||
|
// (SVGOMAnimatedNumber) getBaseFrequencyX();
|
||||||
|
// an.setAnimatedValue(anonv.getNumber());
|
||||||
|
// an = (SVGOMAnimatedNumber) getBaseFrequencyY();
|
||||||
|
// if (anonv.hasOptionalNumber()) {
|
||||||
|
// an.setAnimatedValue(anonv.getOptionalNumber());
|
||||||
|
// } else {
|
||||||
|
// an.setAnimatedValue(anonv.getNumber());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// super.updateAttributeValue(ns, ln, val);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Returns the underlying value of an animatable XML attribute.
|
||||||
|
// */
|
||||||
|
// public AnimatableValue getUnderlyingValue(String ns, String ln) {
|
||||||
|
// if (ns == null) {
|
||||||
|
// if (ln.equals(SVG_BASE_FREQUENCY_ATTRIBUTE)) {
|
||||||
|
// return getBaseValue(getBaseFrequencyX(), getBaseFrequencyY());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return super.getUnderlyingValue(ns, ln);
|
||||||
|
// }
|
||||||
|
}
|
|
@ -0,0 +1,379 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.dom.util.XLinkSupport;
|
||||||
|
import org.apache.batik.dom.util.XMLSupport;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedBoolean;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedEnumeration;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedInteger;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedLength;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedString;
|
||||||
|
import org.w3c.dom.svg.SVGFilterElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements {@link SVGFilterElement}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFilterElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFilterElement
|
||||||
|
extends SVGStylableElement
|
||||||
|
implements SVGFilterElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGStylableElement.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_FILTER_UNITS_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_IDENT));
|
||||||
|
t.put(null, SVG_PRIMITIVE_UNITS_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_IDENT));
|
||||||
|
t.put(null, SVG_X_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_WIDTH));
|
||||||
|
t.put(null, SVG_Y_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_HEIGHT));
|
||||||
|
t.put(null, SVG_WIDTH_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_WIDTH));
|
||||||
|
t.put(null, SVG_HEIGHT_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_HEIGHT));
|
||||||
|
t.put(null, SVG_FILTER_RES_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_NUMBER_OPTIONAL_NUMBER));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attribute initializer.
|
||||||
|
*/
|
||||||
|
protected static final AttributeInitializer attributeInitializer;
|
||||||
|
static {
|
||||||
|
attributeInitializer = new AttributeInitializer(4);
|
||||||
|
attributeInitializer.addAttribute(XMLSupport.XMLNS_NAMESPACE_URI,
|
||||||
|
null, "xmlns:xlink",
|
||||||
|
XLinkSupport.XLINK_NAMESPACE_URI);
|
||||||
|
attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
|
||||||
|
"xlink", "type", "simple");
|
||||||
|
attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
|
||||||
|
"xlink", "show", "other");
|
||||||
|
attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
|
||||||
|
"xlink", "actuate", "onLoad");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The units values.
|
||||||
|
*/
|
||||||
|
protected static final String[] UNITS_VALUES = {
|
||||||
|
"",
|
||||||
|
SVG_USER_SPACE_ON_USE_VALUE,
|
||||||
|
SVG_OBJECT_BOUNDING_BOX_VALUE
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'filterUnits' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedEnumeration filterUnits;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'primitiveUnits' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedEnumeration primitiveUnits;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'x' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedLength x;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'y' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedLength y;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'width' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedLength width;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'height' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedLength height;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'xlink:href' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString href;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'externalResourcesRequired' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedBoolean externalResourcesRequired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFilterElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFilterElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFilterElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFilterElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
filterUnits =
|
||||||
|
createLiveAnimatedEnumeration
|
||||||
|
(null, SVG_FILTER_UNITS_ATTRIBUTE, UNITS_VALUES, (short) 2);
|
||||||
|
primitiveUnits =
|
||||||
|
createLiveAnimatedEnumeration
|
||||||
|
(null, SVG_PRIMITIVE_UNITS_ATTRIBUTE, UNITS_VALUES, (short) 1);
|
||||||
|
x = createLiveAnimatedLength
|
||||||
|
(null, SVG_X_ATTRIBUTE, SVG_FILTER_X_DEFAULT_VALUE,
|
||||||
|
SVGOMAnimatedLength.HORIZONTAL_LENGTH, false);
|
||||||
|
y = createLiveAnimatedLength
|
||||||
|
(null, SVG_Y_ATTRIBUTE, SVG_FILTER_Y_DEFAULT_VALUE,
|
||||||
|
SVGOMAnimatedLength.VERTICAL_LENGTH, false);
|
||||||
|
width =
|
||||||
|
createLiveAnimatedLength
|
||||||
|
(null, SVG_WIDTH_ATTRIBUTE, SVG_FILTER_WIDTH_DEFAULT_VALUE,
|
||||||
|
SVGOMAnimatedLength.HORIZONTAL_LENGTH, true);
|
||||||
|
height =
|
||||||
|
createLiveAnimatedLength
|
||||||
|
(null, SVG_HEIGHT_ATTRIBUTE, SVG_FILTER_HEIGHT_DEFAULT_VALUE,
|
||||||
|
SVGOMAnimatedLength.VERTICAL_LENGTH, true);
|
||||||
|
href =
|
||||||
|
createLiveAnimatedString(XLINK_NAMESPACE_URI, XLINK_HREF_ATTRIBUTE);
|
||||||
|
externalResourcesRequired =
|
||||||
|
createLiveAnimatedBoolean
|
||||||
|
(null, SVG_EXTERNAL_RESOURCES_REQUIRED_ATTRIBUTE, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG_FILTER_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFilterElement#getFilterUnits()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedEnumeration getFilterUnits() {
|
||||||
|
return filterUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFilterElement#getPrimitiveUnits()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedEnumeration getPrimitiveUnits() {
|
||||||
|
return primitiveUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFilterElement#getX()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedLength getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFilterElement#getY()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedLength getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFilterElement#getWidth()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedLength getWidth() {
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFilterElement#getHeight()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedLength getHeight() {
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFilterElement#getFilterResX()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedInteger getFilterResX() {
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFilterElement.getFilterResX is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFilterElement#getFilterResY()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedInteger getFilterResY() {
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFilterElement.getFilterResY is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link SVGFilterElement#setFilterRes(int,int)}.
|
||||||
|
*/
|
||||||
|
public void setFilterRes(int filterResX, int filterResY) {
|
||||||
|
throw new UnsupportedOperationException
|
||||||
|
("SVGFilterElement.setFilterRes is not implemented"); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
// SVGURIReference support /////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link org.w3c.dom.svg.SVGURIReference#getHref()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getHref() {
|
||||||
|
return href;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SVGExternalResourcesRequired support /////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGExternalResourcesRequired#getExternalResourcesRequired()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedBoolean getExternalResourcesRequired() {
|
||||||
|
return externalResourcesRequired;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SVGLangSpace support //////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Returns the xml:lang attribute value.
|
||||||
|
*/
|
||||||
|
public String getXMLlang() {
|
||||||
|
return XMLSupport.getXMLLang(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Sets the xml:lang attribute value.
|
||||||
|
*/
|
||||||
|
public void setXMLlang(String lang) {
|
||||||
|
setAttributeNS(XML_NAMESPACE_URI, XML_LANG_QNAME, lang);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Returns the xml:space attribute value.
|
||||||
|
*/
|
||||||
|
public String getXMLspace() {
|
||||||
|
return XMLSupport.getXMLSpace(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Sets the xml:space attribute value.
|
||||||
|
*/
|
||||||
|
public void setXMLspace(String space) {
|
||||||
|
setAttributeNS(XML_NAMESPACE_URI, XML_SPACE_QNAME, space);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the AttributeInitializer for this element type.
|
||||||
|
* @return null if this element has no attribute with a default value.
|
||||||
|
*/
|
||||||
|
protected AttributeInitializer getAttributeInitializer() {
|
||||||
|
return attributeInitializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFilterElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
// AnimationTarget ///////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// XXX TBD
|
||||||
|
// /**
|
||||||
|
// * Updates an attribute value in this target.
|
||||||
|
// */
|
||||||
|
// public void updateAttributeValue(String ns, String ln,
|
||||||
|
// AnimatableValue val) {
|
||||||
|
// if (ns == null) {
|
||||||
|
// if (ln.equals(SVG_FILTER_RES_ATTRIBUTE)) {
|
||||||
|
// // XXX Needs testing.
|
||||||
|
// if (val == null) {
|
||||||
|
// updateIntegerAttributeValue(getFilterResX(), null);
|
||||||
|
// updateIntegerAttributeValue(getFilterResY(), null);
|
||||||
|
// } else {
|
||||||
|
// AnimatableNumberOptionalNumberValue anonv =
|
||||||
|
// (AnimatableNumberOptionalNumberValue) val;
|
||||||
|
// SVGOMAnimatedInteger ai =
|
||||||
|
// (SVGOMAnimatedInteger) getFilterResX();
|
||||||
|
// ai.setAnimatedValue(Math.round(anonv.getNumber()));
|
||||||
|
// ai = (SVGOMAnimatedInteger) getFilterResY();
|
||||||
|
// if (anonv.hasOptionalNumber()) {
|
||||||
|
// ai.setAnimatedValue
|
||||||
|
// (Math.round(anonv.getOptionalNumber()));
|
||||||
|
// } else {
|
||||||
|
// ai.setAnimatedValue(Math.round(anonv.getNumber()));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// super.updateAttributeValue(ns, ln, val);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Returns the underlying value of an animatable XML attribute.
|
||||||
|
// */
|
||||||
|
// public AnimatableValue getUnderlyingValue(String ns, String ln) {
|
||||||
|
// if (ns == null) {
|
||||||
|
// if (ln.equals(SVG_FILTER_RES_ATTRIBUTE)) {
|
||||||
|
// return getBaseValue(getFilterResX(), getFilterResY());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return super.getUnderlyingValue(ns, ln);
|
||||||
|
// }
|
||||||
|
}
|
|
@ -0,0 +1,179 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.DoublyIndexedTable;
|
||||||
|
import org.apache.batik.util.SVGTypes;
|
||||||
|
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedLength;
|
||||||
|
import org.w3c.dom.svg.SVGAnimatedString;
|
||||||
|
import org.w3c.dom.svg.SVGFilterPrimitiveStandardAttributes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents a SVGElement with support for standard filter
|
||||||
|
* attributes.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
|
||||||
|
* @version $Id: SVGOMFilterPrimitiveStandardAttributes.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public abstract class SVGOMFilterPrimitiveStandardAttributes
|
||||||
|
extends SVGStylableElement
|
||||||
|
implements SVGFilterPrimitiveStandardAttributes {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table mapping XML attribute names to TraitInformation objects.
|
||||||
|
*/
|
||||||
|
protected static DoublyIndexedTable xmlTraitInformation;
|
||||||
|
static {
|
||||||
|
DoublyIndexedTable t =
|
||||||
|
new DoublyIndexedTable(SVGStylableElement.xmlTraitInformation);
|
||||||
|
t.put(null, SVG_X_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_WIDTH));
|
||||||
|
t.put(null, SVG_Y_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_HEIGHT));
|
||||||
|
t.put(null, SVG_WIDTH_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_WIDTH));
|
||||||
|
t.put(null, SVG_HEIGHT_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_HEIGHT));
|
||||||
|
t.put(null, SVG_RESULT_ATTRIBUTE,
|
||||||
|
new TraitInformation(true, SVGTypes.TYPE_CDATA));
|
||||||
|
xmlTraitInformation = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'x' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedLength x;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'y' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedLength y;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'width' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedLength width;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'height' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedLength height;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'result' attribute value.
|
||||||
|
*/
|
||||||
|
protected SVGOMAnimatedString result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFilterPrimitiveStandardAttributes object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFilterPrimitiveStandardAttributes() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SVGOMFilterPrimitiveStandardAttributes object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
protected SVGOMFilterPrimitiveStandardAttributes(String prefix,
|
||||||
|
AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all live attributes for this element.
|
||||||
|
*/
|
||||||
|
protected void initializeAllLiveAttributes() {
|
||||||
|
super.initializeAllLiveAttributes();
|
||||||
|
initializeLiveAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the live attribute values of this element.
|
||||||
|
*/
|
||||||
|
private void initializeLiveAttributes() {
|
||||||
|
x = createLiveAnimatedLength
|
||||||
|
(null, SVG_X_ATTRIBUTE, SVG_FILTER_PRIMITIVE_X_DEFAULT_VALUE,
|
||||||
|
SVGOMAnimatedLength.HORIZONTAL_LENGTH, false);
|
||||||
|
y = createLiveAnimatedLength
|
||||||
|
(null, SVG_Y_ATTRIBUTE, SVG_FILTER_PRIMITIVE_Y_DEFAULT_VALUE,
|
||||||
|
SVGOMAnimatedLength.VERTICAL_LENGTH, false);
|
||||||
|
width =
|
||||||
|
createLiveAnimatedLength
|
||||||
|
(null, SVG_WIDTH_ATTRIBUTE,
|
||||||
|
SVG_FILTER_PRIMITIVE_WIDTH_DEFAULT_VALUE,
|
||||||
|
SVGOMAnimatedLength.HORIZONTAL_LENGTH, true);
|
||||||
|
height =
|
||||||
|
createLiveAnimatedLength
|
||||||
|
(null, SVG_HEIGHT_ATTRIBUTE,
|
||||||
|
SVG_FILTER_PRIMITIVE_HEIGHT_DEFAULT_VALUE,
|
||||||
|
SVGOMAnimatedLength.VERTICAL_LENGTH, true);
|
||||||
|
result = createLiveAnimatedString(null, SVG_RESULT_ATTRIBUTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGFilterPrimitiveStandardAttributes#getX()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedLength getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGFilterPrimitiveStandardAttributes#getY()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedLength getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGFilterPrimitiveStandardAttributes#getWidth()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedLength getWidth() {
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGFilterPrimitiveStandardAttributes#getHeight()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedLength getHeight() {
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link
|
||||||
|
* org.w3c.dom.svg.SVGFilterPrimitiveStandardAttributes#getResult()}.
|
||||||
|
*/
|
||||||
|
public SVGAnimatedString getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the table of TraitInformation objects for this element.
|
||||||
|
*/
|
||||||
|
protected DoublyIndexedTable getTraitInformationTable() {
|
||||||
|
return xmlTraitInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.SVG12Constants;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.svg.SVGTextContentElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements the flowDiv element from SVG 1.2
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:thomas.deweese@kodak.com">Thomas DeWeese</a>
|
||||||
|
* @version $Id: SVGOMFlowDivElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFlowDivElement
|
||||||
|
extends SVGOMTextContentElement
|
||||||
|
implements SVGTextContentElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new BatikRegularPolygonElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFlowDivElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new BatikRegularPolygonElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFlowDivElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link org.w3c.dom.Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG12Constants.SVG_FLOW_DIV_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFlowDivElement();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.apache.batik.anim.dom;
|
||||||
|
|
||||||
|
import org.apache.batik.dom.AbstractDocument;
|
||||||
|
import org.apache.batik.util.SVG12Constants;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements a regular polygon extension to SVG
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:thomas.deweese@kodak.com">Thomas DeWeese</a>
|
||||||
|
* @version $Id: SVGOMFlowLineElement.java 1733416 2016-03-03 07:07:13Z gadams $
|
||||||
|
*/
|
||||||
|
public class SVGOMFlowLineElement
|
||||||
|
extends SVGOMTextPositioningElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new BatikRegularPolygonElement object.
|
||||||
|
*/
|
||||||
|
protected SVGOMFlowLineElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new BatikRegularPolygonElement object.
|
||||||
|
* @param prefix The namespace prefix.
|
||||||
|
* @param owner The owner document.
|
||||||
|
*/
|
||||||
|
public SVGOMFlowLineElement(String prefix, AbstractDocument owner) {
|
||||||
|
super(prefix, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>DOM</b>: Implements {@link org.w3c.dom.Node#getLocalName()}.
|
||||||
|
*/
|
||||||
|
public String getLocalName() {
|
||||||
|
return SVG12Constants.SVG_FLOW_LINE_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new uninitialized instance of this object's class.
|
||||||
|
*/
|
||||||
|
protected Node newNode() {
|
||||||
|
return new SVGOMFlowLineElement();
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue