Skip to content

Commit 0fa8094

Browse files
committed
Switch SVG loading from the Batik library to JSVG.
1 parent 7d89336 commit 0fa8094

13 files changed

Lines changed: 373 additions & 77 deletions

File tree

nbbuild/cluster.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ nb.cluster.platform=\
189189
libs.jna,\
190190
libs.jna.platform,\
191191
libs.jsr223,\
192+
libs.jsvg,\
192193
libs.junit4,\
193194
libs.junit5,\
194195
libs.osgi,\

platform/libs.jsvg/build.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
21+
-->
22+
23+
<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
24+
<!-- for some information on what you could do (e.g. targets to override). -->
25+
<!-- If you delete this file and reopen the project it will be recreated. -->
26+
<project name="platform/libs.jsvg" default="build" basedir=".">
27+
<description>Builds the JSVG library wrapper module.</description>
28+
<import file="../../nbbuild/templates/projectized.xml"/>
29+
</project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
A84D34480044DB51A1448E9C0E32BD284B797288 com.github.weisj:jsvg:1.6.1
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Name: JSVG
2+
Version: 1.6.1
3+
Description: JSVG - A Java SVG implementation
4+
License: MIT
5+
Origin: JSVG
6+
URL: https://github.com/weisJ/jsvg
7+
Files: jsvg-1.6.1.jar
8+
9+
MIT License
10+
11+
Copyright (c) 2021-2024 Jannis Weis
12+
13+
Permission is hereby granted, free of charge, to any person obtaining a copy
14+
of this software and associated documentation files (the "Software"), to deal
15+
in the Software without restriction, including without limitation the rights
16+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17+
copies of the Software, and to permit persons to whom the Software is
18+
furnished to do so, subject to the following conditions:
19+
20+
The above copyright notice and this permission notice shall be included in all
21+
copies or substantial portions of the Software.
22+
23+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29+
SOFTWARE.

platform/libs.jsvg/manifest.mf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Manifest-Version: 1.0
2+
OpenIDE-Module: org.netbeans.libs.jsvg
3+
OpenIDE-Module-Implementation-Version: 1
4+
OpenIDE-Module-Localizing-Bundle: org/netbeans/libs/jsvg/Bundle.properties
5+
AutoUpdate-Show-In-Client: false
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
file.reference.jsvg-1.6.1.jar=external/jsvg-1.6.1.jar
19+
release.external/jsvg-1.6.1.jar=modules/ext/jsvg-1.6.1.jar
20+
21+
is.autoload=true
22+
javac.source=1.8
23+
24+
nbm.homepage=https://github.com/weisJ/jsvg
25+
sigtest.gen.fail.on.error=false
26+
spec.version.base=1.22.0
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
21+
-->
22+
<project xmlns="http://www.netbeans.org/ns/project/1">
23+
<type>org.netbeans.modules.apisupport.project</type>
24+
<configuration>
25+
<data xmlns="http://www.netbeans.org/ns/nb-module-project/2">
26+
<code-name-base>org.netbeans.libs.jsvg</code-name-base>
27+
<module-dependencies/>
28+
<public-packages>
29+
<package>com.github.weisj.jsvg</package>
30+
<package>com.github.weisj.jsvg.attributes</package>
31+
<package>com.github.weisj.jsvg.attributes.filter</package>
32+
<package>com.github.weisj.jsvg.attributes.font</package>
33+
<package>com.github.weisj.jsvg.attributes.paint</package>
34+
<package>com.github.weisj.jsvg.attributes.stroke</package>
35+
<package>com.github.weisj.jsvg.attributes.text</package>
36+
<package>com.github.weisj.jsvg.geometry</package>
37+
<package>com.github.weisj.jsvg.geometry.mesh</package>
38+
<package>com.github.weisj.jsvg.geometry.noise</package>
39+
<package>com.github.weisj.jsvg.geometry.path</package>
40+
<package>com.github.weisj.jsvg.geometry.size</package>
41+
<package>com.github.weisj.jsvg.geometry.util</package>
42+
<package>com.github.weisj.jsvg.nodes</package>
43+
<package>com.github.weisj.jsvg.nodes.animation</package>
44+
<package>com.github.weisj.jsvg.nodes.container</package>
45+
<package>com.github.weisj.jsvg.nodes.filter</package>
46+
<package>com.github.weisj.jsvg.nodes.mesh</package>
47+
<package>com.github.weisj.jsvg.nodes.prototype</package>
48+
<package>com.github.weisj.jsvg.nodes.prototype.spec</package>
49+
<package>com.github.weisj.jsvg.nodes.text</package>
50+
<package>com.github.weisj.jsvg.parser</package>
51+
<package>com.github.weisj.jsvg.parser.css</package>
52+
<package>com.github.weisj.jsvg.parser.resources</package>
53+
<package>com.github.weisj.jsvg.renderer</package>
54+
<package>com.github.weisj.jsvg.renderer.awt</package>
55+
<package>com.github.weisj.jsvg.renderer.jdk</package>
56+
<package>com.github.weisj.jsvg.util</package>
57+
</public-packages>
58+
<class-path-extension>
59+
<runtime-relative-path>ext/jsvg-1.6.1.jar</runtime-relative-path>
60+
<binary-origin>external/jsvg-1.6.1.jar</binary-origin>
61+
</class-path-extension>
62+
</data>
63+
</configuration>
64+
</project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
19+
OpenIDE-Module-Name=JSVG Library
20+
OpenIDE-Module-Short-Description=JSVG Library
21+
OpenIDE-Module-Long-Description=Contains the JSVG library, for reading and painting SVG files.
22+
OpenIDE-Module-Display-Category=Libraries

platform/openide.util.ui.svg/nbproject/project.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<code-name-base>org.openide.util.ui.svg</code-name-base>
2727
<module-dependencies>
2828
<dependency>
29-
<code-name-base>org.netbeans.libs.batik.read</code-name-base>
29+
<code-name-base>org.netbeans.libs.jsvg</code-name-base>
3030
<build-prerequisite/>
3131
<compile-dependency/>
3232
<run-dependency>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.openide.util.svg;
20+
21+
import com.github.weisj.jsvg.attributes.AttributeParser;
22+
import com.github.weisj.jsvg.parser.ElementLoader;
23+
import com.github.weisj.jsvg.parser.ParsedDocument;
24+
import java.util.Collections;
25+
import java.util.LinkedHashSet;
26+
import java.util.Set;
27+
28+
class DenyingElementLoader implements ElementLoader {
29+
private final Set<String> attemptedExternalURLsLoaded = new LinkedHashSet<>();
30+
31+
public Set<String> getAttemptedExternalURLsLoaded() {
32+
return Collections.unmodifiableSet(attemptedExternalURLsLoaded);
33+
}
34+
35+
@Override
36+
public <T> T loadElement(Class<T> type, String value,
37+
ParsedDocument document, AttributeParser attributeParser)
38+
{
39+
/* Same logic as in com.github.weisj.jsvg.parser.DefaultElementLoader for the
40+
AllowExternalResources.DENY case, but gathering up the attempted externally loaded URLs so
41+
we can make the whole loading operation fail and make testLoadImageWithExternalUseXlinkHref
42+
pass. */
43+
String url = attributeParser.parseUrl(value);
44+
if (url == null) {
45+
return null;
46+
}
47+
if (url.contains("#")) {
48+
String[] parts = url.split("#", 2);
49+
String name = parts[0];
50+
if (!name.isEmpty()) {
51+
attemptedExternalURLsLoaded.add(value);
52+
return null;
53+
}
54+
return document.getElementById(type, parts[1]);
55+
} else {
56+
return document.getElementById(type, url);
57+
}
58+
}
59+
}

0 commit comments

Comments
 (0)