diff -Nru svgsalamander-1.1.1+dfsg/_config.yml svgsalamander-1.1.4/_config.yml --- svgsalamander-1.1.1+dfsg/_config.yml 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/_config.yml 2022-02-26 23:40:50.000000000 +0000 @@ -0,0 +1 @@ +theme: jekyll-theme-cayman \ No newline at end of file diff -Nru svgsalamander-1.1.1+dfsg/debian/changelog svgsalamander-1.1.4/debian/changelog --- svgsalamander-1.1.1+dfsg/debian/changelog 2019-03-04 08:28:49.000000000 +0000 +++ svgsalamander-1.1.4/debian/changelog 2022-12-07 10:18:49.000000000 +0000 @@ -1,3 +1,17 @@ +svgsalamander (1.1.4-1) unstable; urgency=medium + + * Team upload. + * New upstream release + - Removed the patches + - Build with Maven instead of Ant + * Standards-Version updated to 4.6.1 + * Switch to debhelper level 13 + * Changed the priority from extra to optional + * Updated the homepage URL + * Updated the watch file + + -- Emmanuel Bourg Wed, 07 Dec 2022 11:18:49 +0100 + svgsalamander (1.1.1+dfsg-3) unstable; urgency=medium * Team upload. diff -Nru svgsalamander-1.1.1+dfsg/debian/clean svgsalamander-1.1.4/debian/clean --- svgsalamander-1.1.1+dfsg/debian/clean 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/debian/clean 2022-12-07 09:40:29.000000000 +0000 @@ -0,0 +1,7 @@ +svg-core/src/main/java/com/kitfox/svg/animation/parser/AnimTimeParser.java +svg-core/src/main/java/com/kitfox/svg/animation/parser/AnimTimeParserConstants.java +svg-core/src/main/java/com/kitfox/svg/animation/parser/AnimTimeParserTokenManager.java +svg-core/src/main/java/com/kitfox/svg/animation/parser/ParseException.java +svg-core/src/main/java/com/kitfox/svg/animation/parser/SimpleCharStream.java +svg-core/src/main/java/com/kitfox/svg/animation/parser/Token.java +svg-core/src/main/java/com/kitfox/svg/animation/parser/TokenMgrError.java diff -Nru svgsalamander-1.1.1+dfsg/debian/compat svgsalamander-1.1.4/debian/compat --- svgsalamander-1.1.1+dfsg/debian/compat 2019-03-04 08:09:50.000000000 +0000 +++ svgsalamander-1.1.4/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -9 diff -Nru svgsalamander-1.1.1+dfsg/debian/control svgsalamander-1.1.4/debian/control --- svgsalamander-1.1.1+dfsg/debian/control 2019-03-04 08:28:41.000000000 +0000 +++ svgsalamander-1.1.4/debian/control 2022-12-07 10:06:24.000000000 +0000 @@ -1,24 +1,22 @@ Source: svgsalamander +Section: java +Priority: optional Maintainer: Debian Java Maintainers Uploaders: Felix Natter -Section: java -Priority: extra -Build-Depends: debhelper (>= 9), - javahelper, - maven-repo-helper -Build-Depends-Indep: default-jdk, - ant, - ant-optional, - javacc -Standards-Version: 3.9.8 +Build-Depends: + ant, + debhelper-compat (= 13), + default-jdk, + javacc, + maven-debian-helper +Standards-Version: 4.6.1 Vcs-Browser: https://salsa.debian.org/java-team/svgsalamander Vcs-Git: https://salsa.debian.org/java-team/svgsalamander.git -Homepage: http://svgsalamander.java.net/ +Homepage: https://github.com/blackears/svgSalamander/wiki Package: libsvgsalamander-java Architecture: all -Depends: ${misc:Depends}, - ${java:Depends} +Depends: ${misc:Depends}, ${java:Depends} Recommends: ${java:Recommends} Description: SVG engine for Java SVG Salamander is an SVG engine for Java that's designed to be small, diff -Nru svgsalamander-1.1.1+dfsg/debian/libsvgsalamander-java.jlibs svgsalamander-1.1.4/debian/libsvgsalamander-java.jlibs --- svgsalamander-1.1.1+dfsg/debian/libsvgsalamander-java.jlibs 2019-03-04 08:09:50.000000000 +0000 +++ svgsalamander-1.1.4/debian/libsvgsalamander-java.jlibs 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -www/binaries/svgSalamander.jar -www/binaries/svgSalamander-tiny.jar diff -Nru svgsalamander-1.1.1+dfsg/debian/libsvgsalamander-java.poms svgsalamander-1.1.4/debian/libsvgsalamander-java.poms --- svgsalamander-1.1.1+dfsg/debian/libsvgsalamander-java.poms 2019-03-04 08:09:50.000000000 +0000 +++ svgsalamander-1.1.4/debian/libsvgsalamander-java.poms 2022-12-07 09:52:44.000000000 +0000 @@ -1 +1,29 @@ -svg-core/pom.xml +# List of POM files for the package +# Format of this file is: +# [option]* +# where option can be: +# --ignore: ignore this POM and its artifact if any +# --ignore-pom: don't install the POM. To use on POM files that are created +# temporarily for certain artifacts such as Javadoc jars. [mh_install, mh_installpoms] +# --no-parent: remove the tag from the POM +# --package=: an alternative package to use when installing this POM +# and its artifact +# --has-package-version: to indicate that the original version of the POM is the same as the upstream part +# of the version for the package. +# --keep-elements=: a list of XML elements to keep in the POM +# during a clean operation with mh_cleanpom or mh_installpom +# --artifact=: path to the build artifact associated with this POM, +# it will be installed when using the command mh_install. [mh_install] +# --java-lib: install the jar into /usr/share/java to comply with Debian +# packaging guidelines +# --usj-name=: name to use when installing the library in /usr/share/java +# --usj-version=: version to use when installing the library in /usr/share/java +# --no-usj-versionless: don't install the versionless link in /usr/share/java +# --dest-jar=: the destination for the real jar. +# It will be installed with mh_install. [mh_install] +# --classifier=: Optional, the classifier for the jar. Empty by default. +# --site-xml=: Optional, the location for site.xml if it needs to be installed. +# Empty by default. [mh_install] +# + +svg-core/pom.xml --has-package-version --java-lib --relocate=com.kitfox:kitfox-svg-salamander diff -Nru svgsalamander-1.1.1+dfsg/debian/maven.ignoreRules svgsalamander-1.1.4/debian/maven.ignoreRules --- svgsalamander-1.1.1+dfsg/debian/maven.ignoreRules 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/debian/maven.ignoreRules 2022-12-07 09:32:45.000000000 +0000 @@ -0,0 +1,3 @@ + +com.helger.maven ph-javacc-maven-plugin +org.sonatype.plugins nexus-staging-maven-plugin diff -Nru svgsalamander-1.1.1+dfsg/debian/patches/0001-Make-build-use-system-libraries.patch svgsalamander-1.1.4/debian/patches/0001-Make-build-use-system-libraries.patch --- svgsalamander-1.1.1+dfsg/debian/patches/0001-Make-build-use-system-libraries.patch 2019-03-04 08:09:50.000000000 +0000 +++ svgsalamander-1.1.4/debian/patches/0001-Make-build-use-system-libraries.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -Description: Make build use system libraries -Author: Nicolas Dandrimont -Forwarded: not-needed -Last-Update: 2011-02-18 ---- a/svg-core/build.xml -+++ b/svg-core/build.xml -@@ -68,7 +68,7 @@ - --> - - -- -+ - - - diff -Nru svgsalamander-1.1.1+dfsg/debian/patches/0002-Disable-useless-automated-jar-signing.patch svgsalamander-1.1.4/debian/patches/0002-Disable-useless-automated-jar-signing.patch --- svgsalamander-1.1.1+dfsg/debian/patches/0002-Disable-useless-automated-jar-signing.patch 2019-03-04 08:09:50.000000000 +0000 +++ svgsalamander-1.1.4/debian/patches/0002-Disable-useless-automated-jar-signing.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -Description: Disable jar signing in ant script -Author: Felix Natter -Forwarded: not-needed -Last-Update: 2016-07-23 ---- a/svg-core/build.xml -+++ b/svg-core/build.xml -@@ -110,23 +110,7 @@ - - - -- -- -- -- -- -- -- -- -- -- -- -- - -- - - - diff -Nru svgsalamander-1.1.1+dfsg/debian/patches/0005-dont-call-netbeans-ant-tasks.patch svgsalamander-1.1.4/debian/patches/0005-dont-call-netbeans-ant-tasks.patch --- svgsalamander-1.1.1+dfsg/debian/patches/0005-dont-call-netbeans-ant-tasks.patch 2019-03-04 08:09:50.000000000 +0000 +++ svgsalamander-1.1.4/debian/patches/0005-dont-call-netbeans-ant-tasks.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -Description: Skip some netbeans ant tasks by setting mkdist.disabled:=true -Author: Felix Natter -Forwarded: not-needed -Last-Update: 2016-07-23 ---- a/svg-core/build.xml -+++ b/svg-core/build.xml -@@ -79,6 +79,7 @@ - - - -+ - - - diff -Nru svgsalamander-1.1.1+dfsg/debian/patches/0006-modify-broken-upstream-pom.patch svgsalamander-1.1.4/debian/patches/0006-modify-broken-upstream-pom.patch --- svgsalamander-1.1.1+dfsg/debian/patches/0006-modify-broken-upstream-pom.patch 2019-03-04 08:09:50.000000000 +0000 +++ svgsalamander-1.1.4/debian/patches/0006-modify-broken-upstream-pom.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,172 +0,0 @@ -Description: Fix version and remove build information and ant dependency - in outdated upstream pom.xml (outdated according to author) -Author: Felix Natter -Forwarded: not-needed -Last-Update: 2016-07-29 ---- a/svg-core/pom.xml -+++ b/svg-core/pom.xml -@@ -11,7 +11,7 @@ - - com.kitfox - kitfox-svg-salamander -- 1.0.39 -+ 1.1.1 - jar - - ${project.artifactId} -@@ -22,7 +22,7 @@ - - 2011 - -- http://java.net/projects/svgsalamander -+ https://github.com/blackears/svgSalamander/ - - - Kitfox Studios -@@ -77,146 +77,4 @@ - - - -- -- -- -- -- org.apache.ant -- ant -- 1.8.1 -- -- -- -- -- -- -- -- ${basedir}/src/main/java -- -- -- ${basedir}/src/main/res -- -- -- -- -- ${basedir}/src/test/java -- -- -- ${basedir}/src/test/res -- -- -- -- -- -- -- -- org.codehaus.mojo -- javacc-maven-plugin -- 2.6 -- -- -- javacc -- generate-sources -- -- javacc -- -- -- ${basedir}/src/main/java -- -- **/*.jjt -- -- -- -- -- -- -- -- -- org.apache.maven.plugins -- maven-compiler-plugin -- 2.3.2 -- -- 1.6 -- 1.6 -- -- -- -- -- -- org.apache.maven.plugins -- maven-enforcer-plugin -- 1.0 -- -- -- enforce-maven-version -- -- enforce -- -- -- -- -- [3.0,) -- you-must-run-maven-3.0-or-above -- -- -- -- -- -- -- -- -- -- -- org.apache.maven.plugins -- maven-javadoc-plugin -- 2.7 -- -- true -- false -- -- public -- http://java.sun.com/javase/1.6.0/docs/api -- -- true -- true -- ${project.name} API ${project.version} / -- ${maven.build.timestamp} -- ${project.name} API ${project.version} / -- ${maven.build.timestamp} --
${project.organization.name}]]>
--
${project.organization.name}]]>
-- -- -- Copyright © {inceptionYear}-{currentYear} -- ${project.organization.name}]]>. -- All Rights Reserved. -- --
--
-- -- -- -- org.apache.maven.plugins -- maven-source-plugin -- 2.1.2 -- -- -- -- -- -- -- org.apache.maven.plugins -- maven-release-plugin -- -- -- clean verify -- -- deploy -- -- -- --
-- --
-- - diff -Nru svgsalamander-1.1.1+dfsg/debian/patches/0007-CVE-2017-5617-Allow-only-data-scheme.patch svgsalamander-1.1.4/debian/patches/0007-CVE-2017-5617-Allow-only-data-scheme.patch --- svgsalamander-1.1.1+dfsg/debian/patches/0007-CVE-2017-5617-Allow-only-data-scheme.patch 2019-03-04 08:09:50.000000000 +0000 +++ svgsalamander-1.1.4/debian/patches/0007-CVE-2017-5617-Allow-only-data-scheme.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -Description: Fix CVE-2017-5617: svgSalamander SSRF (Server-Side Request Forgery) - See: http://www.openwall.com/lists/oss-security/2017/01/27/3 -Author: Vincent Privat -Origin: https://josm.openstreetmap.de/changeset/11526/josm -Bug: https://github.com/blackears/svgSalamander/issues/11 -Bug-Debian: https://bugs.debian.org/853134 - ---- a/svg-core/src/main/java/com/kitfox/svg/ImageSVG.java -+++ b/svg-core/src/main/java/com/kitfox/svg/ImageSVG.java -@@ -112,21 +112,10 @@ public class ImageSVG extends Renderable - if (getPres(sty.setName("xlink:href"))) - { - URI src = sty.getURIValue(getXMLBase()); -+ // CVE-2017-5617: Allow only data scheme - if ("data".equals(src.getScheme())) - { - imageSrc = new URL(null, src.toASCIIString(), new Handler()); -- } else -- { -- try -- { -- imageSrc = src.toURL(); -- } catch (Exception e) -- { -- Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, -- "Could not parse xlink:href " + src, e); --// e.printStackTrace(); -- imageSrc = null; -- } - } - } - } catch (Exception e) -@@ -134,32 +123,33 @@ public class ImageSVG extends Renderable - throw new SVGException(e); - } - -- diagram.getUniverse().registerImage(imageSrc); -- -- //Set widths if not set -- BufferedImage img = diagram.getUniverse().getImage(imageSrc); -- if (img == null) -+ if (imageSrc != null) - { -- xform = new AffineTransform(); -- bounds = new Rectangle2D.Float(); -- return; -- } -+ diagram.getUniverse().registerImage(imageSrc); - -- if (width == 0) -- { -- width = img.getWidth(); -- } -- if (height == 0) -- { -- height = img.getHeight(); -- } -+ //Set widths if not set -+ BufferedImage img = diagram.getUniverse().getImage(imageSrc); -+ if (img == null) -+ { -+ xform = new AffineTransform(); -+ bounds = new Rectangle2D.Float(); -+ return; -+ } - -- //Determine image xform -- xform = new AffineTransform(); --// xform.setToScale(this.width / img.getWidth(), this.height / img.getHeight()); --// xform.translate(this.x, this.y); -- xform.translate(this.x, this.y); -- xform.scale(this.width / img.getWidth(), this.height / img.getHeight()); -+ if (width == 0) -+ { -+ width = img.getWidth(); -+ } -+ if (height == 0) -+ { -+ height = img.getHeight(); -+ } -+ -+ //Determine image xform -+ xform = new AffineTransform(); -+ xform.translate(this.x, this.y); -+ xform.scale(this.width / img.getWidth(), this.height / img.getHeight()); -+ } - - bounds = new Rectangle2D.Float(this.x, this.y, this.width, this.height); - } -@@ -328,16 +318,14 @@ public class ImageSVG extends Renderable - { - URI src = sty.getURIValue(getXMLBase()); - -- URL newVal; -+ URL newVal = null; -+ // CVE-2017-5617: Allow only data scheme - if ("data".equals(src.getScheme())) - { - newVal = new URL(null, src.toASCIIString(), new Handler()); -- } else -- { -- newVal = src.toURL(); - } - -- if (!newVal.equals(imageSrc)) -+ if (newVal != null && !newVal.equals(imageSrc)) - { - imageSrc = newVal; - shapeChange = true; diff -Nru svgsalamander-1.1.1+dfsg/debian/patches/0008-module-info.patch svgsalamander-1.1.4/debian/patches/0008-module-info.patch --- svgsalamander-1.1.1+dfsg/debian/patches/0008-module-info.patch 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/debian/patches/0008-module-info.patch 2022-12-07 09:49:37.000000000 +0000 @@ -0,0 +1,45 @@ +Description: Removes the module descriptor (have fun with this mess if you need it) +Author: Emmanuel Bourg +Forwarded: not-needed +--- a/svg-core/src/main/java/module-info.java ++++ /dev/null +@@ -1,39 +0,0 @@ +-/* +- * Copyright (c) 2022, kitfox +- * All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions are met: +- * +- * * Redistributions of source code must retain the above copyright notice, this +- * list of conditions and the following disclaimer. +- * * Redistributions in binary form must reproduce the above copyright notice, +- * this list of conditions and the following disclaimer in the documentation +- * and/or other materials provided with the distribution. +- * +- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +- * SUBSTITUTE GOODS OR SEeRVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +- * POSSIBILITY OF SUCH DAMAGE. +- */ +- +-module com.kitfox.svgSalamander { +- requires static ant; +- requires static ant.launcher; +- requires java.desktop; +- requires java.xml; +- requires java.logging; +- +- exports com.kitfox.svg; +- exports com.kitfox.svg.animation; +- exports com.kitfox.svg.app; +- exports com.kitfox.svg.app.ant; +- exports com.kitfox.svg.app.beans; +-} diff -Nru svgsalamander-1.1.1+dfsg/debian/patches/series svgsalamander-1.1.4/debian/patches/series --- svgsalamander-1.1.1+dfsg/debian/patches/series 2019-03-04 08:23:28.000000000 +0000 +++ svgsalamander-1.1.4/debian/patches/series 2022-12-07 09:35:05.000000000 +0000 @@ -1,5 +1 @@ -0001-Make-build-use-system-libraries.patch -0002-Disable-useless-automated-jar-signing.patch -0005-dont-call-netbeans-ant-tasks.patch -0006-modify-broken-upstream-pom.patch -0007-CVE-2017-5617-Allow-only-data-scheme.patch +0008-module-info.patch diff -Nru svgsalamander-1.1.1+dfsg/debian/README.Debian svgsalamander-1.1.4/debian/README.Debian --- svgsalamander-1.1.1+dfsg/debian/README.Debian 2019-03-04 08:09:50.000000000 +0000 +++ svgsalamander-1.1.4/debian/README.Debian 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -svgsalamander for Debian ------------------------- - -SVGSalamander in Debian has been stripped off the embedded batik code -copy, as it was only kept by upstream for compatibility with Java < 6. - -You should be able to replace calls for the embedded batik with calls -to the system's java.awt. - - -- Nicolas Dandrimont , Sun, 27 Mar 2011 13:09:43 +0200 diff -Nru svgsalamander-1.1.1+dfsg/debian/README.source svgsalamander-1.1.4/debian/README.source --- svgsalamander-1.1.1+dfsg/debian/README.source 2019-03-04 08:09:50.000000000 +0000 +++ svgsalamander-1.1.4/debian/README.source 2022-12-07 10:17:48.000000000 +0000 @@ -4,7 +4,6 @@ The source code is downloaded from the github releases page (see debian/watch): https://github.com/blackears/svgSalamander/releases -(svgsalamander has moved to github starting from version 1.0) The tarball is cleaned of .jar and .zip files, amongs others (see Files-Excluded: in debian/copyright). @@ -15,11 +14,5 @@ Parametric Cubes" by Marion R. Holmes, and can be fetched from http://oai.dtic.mil/oai/oai?verb=getRecord&metadataPrefix=html&identifier=ADA277978. -Most importantly, an embedded (partial) copy of batik has been -removed, and replaced by JDK6 API (see -0004-Use-system-awt-gradient-instead-of-the-embedded-batik.patch). - -See the get-orig-source target for debian/rules to fetch a clean tarball. - -- Felix Natter Sat, 6 Aug 2016 15:41:00 +0200 -- Nicolas Dandrimont , Sun, 6 Mar 2011 15:07:47 +0100 diff -Nru svgsalamander-1.1.1+dfsg/debian/rules svgsalamander-1.1.4/debian/rules --- svgsalamander-1.1.1+dfsg/debian/rules 2019-03-04 08:23:05.000000000 +0000 +++ svgsalamander-1.1.4/debian/rules 2022-12-07 10:05:12.000000000 +0000 @@ -1,34 +1,19 @@ #!/usr/bin/make -f -# -*- makefile -*- - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -JAVA_HOME=/usr/lib/jvm/default-java -ANT = /usr/bin/ant -Djavac.source=1.6 -Djavac.target=1.6 -Djavac.classpath=/usr/share/java/ant.jar - -PACKAGE = svgsalamander -SRC_VERSION := $(shell dpkg-parsechangelog | sed -ne 's/^Version: \(\([0-9]\+\):\)\?\(.*\)-.*/\3/p') -SVN_REVISION := $(shell echo ${SRC_VERSION} | sed -ne 's/^.*svn\([0-9]\+\)/\1/p') -TARBALL = $(PACKAGE)_$(SRC_VERSION).orig.tar.gz - %: - dh $@ --parallel --with javahelper,maven-repo-helper + dh $@ --buildsystem=maven override_dh_auto_build: - -mkdir -p $(CURDIR)/svg-core/src/gen/res - -mkdir -p $(CURDIR)/svg-core/src/gen/java - cd $(CURDIR)/svg-core && $(ANT) jar - -override_dh_clean: - -mkdir -p $(CURDIR)/svg-core/src/gen/res - -mkdir -p $(CURDIR)/svg-core/src/gen/java - cd $(CURDIR)/svg-core && $(ANT) clean - -rm www/binaries/*.jar - dh_clean + # Invoke javacc to replace the missing ph-javacc-maven-plugin + javacc -OUTPUT_DIRECTORY=svg-core/src/main/java/com/kitfox/svg/animation/parser svg-core/src/main/java/com/kitfox/svg/animation/parser/AnimTimeParser.jjt + + dh_auto_build -- -f svg-core/pom.xml package + +override_dh_auto_test: + dh_auto_test -- -f svg-core/pom.xml test -.PHONY: get-orig-source +override_dh_auto_install: + dh_auto_install -- -f svg-core/pom.xml -get-orig-source: - uscan --force-download --rename --repack +override_dh_auto_clean: + dh_auto_clean -- -f svg-core/pom.xml clean diff -Nru svgsalamander-1.1.1+dfsg/debian/watch svgsalamander-1.1.4/debian/watch --- svgsalamander-1.1.1+dfsg/debian/watch 2019-03-04 08:09:50.000000000 +0000 +++ svgsalamander-1.1.4/debian/watch 2022-12-07 09:18:34.000000000 +0000 @@ -1,8 +1,3 @@ -version=3 -opts=\ -dversionmangle=s/\+(debian|dfsg|ds|deb)\d*$//,\ -uversionmangle=s/(\d)[_\.\-\+]?((RC|rc|pre|dev|beta|alpha)\d*)$/$1~$2/;s/RC/rc/,\ -filenamemangle=s/(?:.*?)?(?:rel|v|svgSalamander)?[\-\_]?(\d\S+)\.(tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))/svgSalamander-$1.$2/,\ -repacksuffix=+dfsg \ -https://github.com/blackears/svgSalamander/releases \ -(?:.*?/)?(?:rel|v|svgSalamander)?[\-\_]?(\d\S+)\.(?:tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz))) +version=4 +opts="mode=git" \ +https://github.com/blackears/svgSalamander refs/tags/v([\d.]+) diff -Nru svgsalamander-1.1.1+dfsg/doc/usingSvgSalamander.md svgsalamander-1.1.4/doc/usingSvgSalamander.md --- svgsalamander-1.1.1+dfsg/doc/usingSvgSalamander.md 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/doc/usingSvgSalamander.md 2022-02-26 23:40:50.000000000 +0000 @@ -0,0 +1,181 @@ +# Using SVG Salamander + +SVG Salamander uses Java2D for all rendering, so it should integrate nicely with Swing projects. + +The included `com.kitfox.svg.app.SVGPlayer` and `com.kitfox.svg.app.SVGViewer` classes implement a simple movie player and viewer for SVG content and examining the code is a great starting point for understanding the technical underpinnings of SVG Salamander. + +The basic process is: + +- Create an `SVGUniverse` +- Call `universe.loadSVG()` to load the SVG file into memory. (You can call this several times to load multiple files into the same universe. If an SVG file references another SVG file, the referenced files will be automatically loaded) +- Call `universe.getDiagram()` to get an `SVGDiagram` object that can be used to render the SVG file. +- Create a Graphics2D that the SVG should be rendered to. Make sure that either the `Graphics2D` has it's clip area set or that you call `diagram.setIgnoringClipHeuristic(true)`. If the clip heuristic is not being ignored, shapes that do not appear within the clip area will not be rendered in the first place. +- To change rendering with time, call `universe.setCurTime()` and then `universe.updateTime()` to update the universe to the time required. Call `diagram.render()` again to draw the new frame at this updated time. + +The `SVGDiagram` is the object you are going to be most concerned with. It provides a way to access the root of the SVG document you loaded and a means to render it to a `Graphics2D`. + +## Accessing the document + +All elements in an SVG document can be given an id that can be used to access the document in parts. For example, you can create a circle with the code ``. This circle can be referenced later with the key word `myCircle`. + +SVG Salamander provides the ability to access document parts with SVGDiagram.getElement(String elementName). You can then read and write the attributes of the element directly. + +## Using SVG in forms + +The Salamander JAR contains some controls to let you use SVG easily in Swing forms. They are: + +- com.kitfox.svg.app.beans.SVGPanel +- com.kitfox.svg.app.beans.SVGIcon + +These components are both beans and can be used in NetBeans or other beans aware Java editors. Once you have installed the Jar in your editor (see your IDE's documentation for how to do this), you can place them on your form. + +Both of these beans have anti-aliasing turned off by default. To turn it on, be sure to call `setAntiAlias(true)`. + +A fast way to place an SVG element on your form: + +- Place an SVG file in the resources directory of your project +- Place a SVGPanel on your form +- Set SvgResourcePath to the path of your resource +- Check ScaleToFit to force the graphic to scale to the fill size of the panel + +## Updating the SVG document + +SVG Salamander parallels the DOM model internally, and can be interactively updated at runtime. That is, you can change colors, positions and other aspects of a loaded SVGDiagram. + +### Tree Navigation + +Use `SVGDiagram.getRoot()` to get an instance of SVGRoot. The SVGRoot corresponds to the element of an SVG document. You can then get a list of it's children by calling `SVGRoot.getChildren(null)`. The tree can be further navigated at deeper depths by calling the `getChildren()` method. + +### Adding and Editing Attributes + +SVG Salamander stores attributes as strings and parses them into values at runtime to draw the SVG elements. This allows for the rich variety of types of values that the SVG specification defines. Attributes can also be either style attributes or presentation attributes. Style attributes are defined in the `style` attribute of an SVG element. Presentation attributes are the attributes defined as attributes outside of the `style` attribute. If both style and presentation attributes are present, the style attribute overrides the presentation attribute. For example: + +``` + +``` + +In the above, the style attributes are fill, stroke and stroke-width while the presentation attributes are cx, cy, rx and ry. + +SVG Salamander distinguishes between the two types of attributes by using the `AnimationElement.AT_CSS` and `AnimationElement.AT_XML` constants. `AnimationElement.AT_CSS` represents style attributes, and `AnimationElement.AT_XML` represents presentation attributes. If both style and presentation attributes exist for the same attribute name, the style attribute takes precedence. + +To check if an attribute is defined: + +``` +svgElement.hasAttribute("x", AnimationElement.AT_XML); +``` + +To add a new attribute, call your element with the name of the attribute, a constant representing whether this attribute should be a style or presentation attribute, and a valid string representing the value of this attribute. If this attribute is already defined, this will throw a `RuntimeException`, so make sure to call `hasAttribute()` first if you're not sure if this attribute exists. The following example adds a new style attribute to the given SVG element: + +``` +svgElement.addAttribute("fill-opacity", AnimationElement.AT_CSS, "0.5"); +``` + +To set an attribute, call the set function with the string representation of the value to set the attribute to. Make sure that the element already exists, or this will throw an exception: + +``` +svgElement.setAttribute("x", AnimationElement.AT_XML, "0.5"); +``` + +Sometimes after setting an attribute, it will be necessary to take an animation step to update the element to reflect it's current state. For example, after setting the `r` attribute of a circle, it will be necessary to call `updateTime(timeInSeconds)` on the circle or on one of the circle's ancestors to update the circle's shape. If your SVG diagram isn't using animation, you can pass any value in as the time. Not all attributes will require `updateTime()` to be called, but calling this will not hurt. Typically, attributes that alter shape will require an update while attributes that alter fills and colors do not. For convenience, you might want to update all the elements in a diagram, and then call `svgDiagram.updateTime()` to update the entire document at once. + +``` +circle.setAttribute("r", AnimationElement.AT_XML, "10"); +circle.updateTime(0f); +``` + +At the moment, you can only set the text of `tspan` elements. You can do this by calling `setText()` on the `tspan` element. After doing this, you need to call `rebuild()` on the text element that contains the `tspan` element to update the caching data. + +To get the value of an attribute, you can create an empty attribute and pass it to `getStyle()`. This will overwrite the value in the passed style attribute with the element's value of the attribute. + +``` +StyleAttribute attrib = new StyleAttribute(); +svgElement.getStyle("fill", attrib); +double value = attrib.getDoubleValue(); +``` + +Note that getting the value of a style attribute will first check to see if this attribute has a style set. If not, it checks to find the closest ancestor that may have this style set. If no ancestor has this attribute set, it then checks to see if a presentation attribute with the same name is set on this element. This is in keeping with the SVG convention that style attributes override first ancestors and then presentation attributes. To get the value of only the style attribute of this element, call `getStyleAbsolute()` instead. `getPresAbsolute()` will check for the local presentation attribute. + +### Adding and removing children + +To add a new element, create an instance of the element you wish to add, set its attributes, and then add it to its parent element in the scene graph: + +``` +SVGDiagram diagram = SVGCache.getSVGUniverse().getDiagram(uri); +Group group = (Group)diagram.getElement("parentGroup"); +Circle circle = new Circle(); +try { + circle.addAttribute("cx", AnimationElement.AT_XML, "80"); + circle.addAttribute("cy", AnimationElement.AT_XML, "80"); + circle.addAttribute("r", AnimationElement.AT_XML, "10"); + group.loaderAddChild(null, circle); + + //Update animation state for group and it's descendants so that it reflects new animation values. + // We could also call diagram.update(0.0) or SVGCache.getSVGUniverse().update(). Note that calling + // circle.update(0.0) won't display anything since even though it will update the circle's state, + // it won't update the parent group's state. + group.updateTime(0.0); +} catch (SVGException e) { + e.printStackTrace(); +} +``` + +To remove an element, call `removeChild()` on an element capable of having children: + +``` +SVGDiagram diagram = SVGCache.getSVGUniverse().getDiagram(uri); +Group group = (Group)diagram.getElement("circleGroup"); +Circle circle = (Circle)diagram.getElement("circleToRemove"); +try { + group.removeChild(circle); +} catch (SVGException e) { + e.printStackTrace(); +} +``` + +## Picking + +To pick shapes within an SVGDiagram, use the `pick()` method: + +``` +SVGDiagram diagram = SVGCache.getSVGUniverse().getDiagram(uri); +Point pickPoint = new Point(20, 80); +Vector pickedElements = diagram.pick(pickPoint, null); +``` + +The `pick` method will return a vector of vectors of `SVGElements`. Each vector contains the path from the root of the diagram to the picked `RenderableElement`. + +## Ant Task + +The SVG Salamander Ant task allows you to easily convert SVG documents to images from an Ant script. To use it, include the SVGSalamander.jar in your class path and write an Ant target similar to: + +``` + + + + + + + + + +``` + +### Parameters: + +- destDir - If present, specifies a directory to write SVG files to. Otherwise writes images to directory SVG file was found in +- format - File format for output images. The java core javax.imageio.ImageIO class is used for creating images, so format strings will depend on what files your system is configured to handle. By default, "gif", "jpg" and "png" files are guaranteed to be present. If omitted, "png" is used by default. +- backgroundColor - Optional background color. Color can be specified as a standard HTML color. That is, as the name of a standard color such as "blue" or "limegreen", using the # notation as in #ff00ff for magenta, or in rgb format listing the components as in rgb(255, 192, 192) for pink. If omitted, background is transparent. +- antiAlias - If set, shapes are drawn using anti-aliasing. Defaults to true. +- interpolation - String describing image interpolation algorithm. Can be one of "nearest neighbor", "bilinear" or "bicubic". Defaults to "bicubic". +- width - If greater than 0, determines the width of the written image. Otherwise, the width is obtained from the SVG document. Defaults to -1; +- height - If greater than 0, determines the height of the written image. Otherwise, the height is obtained from the SVG document. Defaults to -1. +- sizeToFit - If true and the width and height of the output image differ from that of the SVG image, the valid area of the SVG image will be resized to fit the specified size. +- verbose - If true, prints out diagnostic information about processing. Defaults to false. + + + + + + + + diff -Nru svgsalamander-1.1.1+dfsg/.github/FUNDING.yml svgsalamander-1.1.4/.github/FUNDING.yml --- svgsalamander-1.1.1+dfsg/.github/FUNDING.yml 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/.github/FUNDING.yml 2022-02-26 23:40:50.000000000 +0000 @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: markmckay +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff -Nru svgsalamander-1.1.1+dfsg/.gitignore svgsalamander-1.1.4/.gitignore --- svgsalamander-1.1.1+dfsg/.gitignore 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/.gitignore 2022-02-26 23:40:50.000000000 +0000 @@ -0,0 +1,21 @@ +/svg-core/nbproject/private/ +/svg-core/build/ +/svg-core/dist/ +/svg-example/build/ +/svg-core/nbproject +/svg-core/src/gen +/libraries/nblibraries-private.properties +/libraries/nblibraries.properties +/svg-core/tempKeystore +/svg-example/nbproject +/svg-core/target/ +/svg-example/target/ +/svg-example/dist +/svg-core/.settings +/svg-core/.classpath +/svg-core/.project +/svg-example/.classpath +/svg-example/.project +/svg-example/.settings +**/*.iml +**/.idea/ \ No newline at end of file diff -Nru svgsalamander-1.1.1+dfsg/libraries/nblibraries.properties svgsalamander-1.1.4/libraries/nblibraries.properties --- svgsalamander-1.1.1+dfsg/libraries/nblibraries.properties 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/libraries/nblibraries.properties 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -libs.CopyLibs.classpath=\ - ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar -libs.CopyLibs.displayName=CopyLibs Task -libs.CopyLibs.prop-version=2.0 -libs.junit.classpath=\ - ${base}/junit/junit-3.8.2.jar -libs.junit.javadoc=\ - ${base}/junit/junit-3.8.2-api.zip -libs.junit_4.classpath=\ - ${base}/junit_4/junit-4.1.jar diff -Nru svgsalamander-1.1.1+dfsg/licenses/license-BSD.txt svgsalamander-1.1.4/licenses/license-BSD.txt --- svgsalamander-1.1.1+dfsg/licenses/license-BSD.txt 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/licenses/license-BSD.txt 2022-02-26 23:40:50.000000000 +0000 @@ -0,0 +1,24 @@ +Copyright (c) 2004, Mark McKay +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of SVG Salamander nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff -Nru svgsalamander-1.1.1+dfsg/README.md svgsalamander-1.1.4/README.md --- svgsalamander-1.1.1+dfsg/README.md 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/README.md 2022-02-26 23:40:50.000000000 +0000 @@ -1,34 +1,36 @@ -SVG Salamander -============== -SVG Salamander is an SVG engine for Java that's designed to be small, fast, and allow programmers to use it with a minimum of fuss. It's in particular targeted for making it easy to integrate SVG into Java games and making it much easier for artists to design 2D game content - from rich interactive menus to charts and graphcs to complex animations. - -Features --------- -* Ant task to allow easy conversion from SVG to images from within Ant scripts -* SVGIcon class greatly simplifies loading and drawing images to screen -* A much smaller code foot print than Batik, and only one JAR file to include -* Direct access to the scene graph tree. You can use Java commands to manipulate it directly. -* An index of all named shapes in the SVG graph is easily accessible. -* Picking shapes given (x, y) coordinates is possible, and can be used to implement graphical buttons selected by the mouse -* Clip region sensitivity makes for fast rendering when only updating part of the image. This makes panning the camera quite efficient. -* Easy rendering to any Graphics2D or BufferedImage. Unlike Batik, the SVG Salamander engine does not own the graphics context, so you can pass it whatever graphics context you like. -* Internal and external links are implemented as URIs, which allows the engine to automatically import linked documents - even if they're stored on a remote server. -* SVG can be read from an InputStream, so you can create documents dynamicly from an in-program XSLT transformation. - -Current status --------------- -SalamanderSVG is part of the Salamander project hosted on http://www.kitfox.com - -Projects using SVG Salamander ------------------------------ -* [Apache Pivot](http://pivot.apache.org/) - An alternate crossplatform GUI for Java. -* [VisiCut](http://visicut.org/) - A tool for laser precision cutting. -* [Xoetrope](http://www.xoetrope.com/) - An alternate crossplatform GUI for Java. -* [Power Line](http://suchanek.name/programs/powerline/index.html) - A slide editor for SVG. -* [Tygron](http://www.tygron.com/) - Serious games illustrating urban planning and climate change. -* [NeoLogica](http://www.neologica.it/eng/Home.php) - Medical imaging. -* [JOSM](https://josm.openstreetmap.de/) - Java OpenStreetMap Editor. - -License -------- -SVG Salamander is avaible both under the [LGPL](https://svgsalamander.java.net/license/license-lgpl.txt) and [BSD](https://svgsalamander.java.net/license/license-bsd.txt) licenses. +# SVG Salamander +SVG Salamander is an SVG engine for Java that's designed to be small, fast, and allow programmers to use it with a minimum of fuss. It's in particular targeted for making it easy to integrate SVG into Java games and making it much easier for artists to design 2D game content - from rich interactive menus to charts and graphics to complex animations. + +## Features + +- Ant task to allow easy conversion from SVG to images from within Ant scripts +- `SVGIcon` class greatly simplifies loading and drawing images to screen +- A much smaller code foot print than Batik, and only one JAR file to include +- Direct access to the scene graph tree. You can use Java commands to manipulate it directly. +- An index of all named shapes in the SVG graph is easily accessible. +- Picking shapes given (x, y) coordinates is possible, and can be used to implement graphical buttons selected by the mouse +- Clip region sensitivity makes for fast rendering when only updating part of the image. This makes panning the camera quite efficient. +- Easy rendering to any `Graphics2D` or `BufferedImage`. Unlike Batik, the SVG Salamander engine does not own the graphics context, so you can pass it whatever graphics context you like. +- Internal and external links are implemented as URIs, which allows the engine to automatically import linked documents - even if they're stored on a remote server. +- SVG can be read from an `InputStream`, so you can create documents dynamically from an in-program XSLT transformation. + +## Documentation + +[An overview of how to use SVG Salamader in your project.](doc/usingSvgSalamander.md) + +## Current status + +SVG Salamander is part of the Salamander project hosted on http://www.kitfox.com + +## Projects using SVG Salamander +- [Apache Pivot](http://pivot.apache.org/) - An alternate crossplatform GUI for Java. +- [VisiCut](http://visicut.org/) - A tool for laser precision cutting. +- [Xoetrope](http://www.xoetrope.com/) - An alternate crossplatform GUI for Java. +- [Power Line](http://suchanek.name/programs/powerline/index.html) - A slide editor for SVG. +- [Tygron](http://www.tygron.com/) - Serious games illustrating urban planning and climate change. +- [NeoLogica](http://www.neologica.it/eng/Home.php) - Medical imaging. +- [JOSM](https://josm.openstreetmap.de/) - Java OpenStreetMap Editor. +- [Freeplane](http://freeplane.org) - Java program for working with Mind Maps + +## License +SVG Salamander is available under two licenses. You may choose to use either the [LGPL](www/license/license-lgpl.txt) license or the [BSD](www/license/license-bsd.txt) license - whichever is more appropriate for your project. diff -Nru svgsalamander-1.1.1+dfsg/svg-core/build.xml svgsalamander-1.1.4/svg-core/build.xml --- svgsalamander-1.1.1+dfsg/svg-core/build.xml 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/build.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,147 +0,0 @@ - - - - - - Builds, tests, and runs the project svg-salamander-core. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -Nru svgsalamander-1.1.1+dfsg/svg-core/nbproject/build-impl.xml svgsalamander-1.1.4/svg-core/nbproject/build-impl.xml --- svgsalamander-1.1.1+dfsg/svg-core/nbproject/build-impl.xml 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/nbproject/build-impl.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1493 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.www.dir - Must set src.dir - Must set src.java.dir - Must set src.res.dir - Must set res.dir - Must set test.src.dir - Must set test.res.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -Nru svgsalamander-1.1.1+dfsg/svg-core/nbproject/genfiles.properties svgsalamander-1.1.4/svg-core/nbproject/genfiles.properties --- svgsalamander-1.1.1+dfsg/svg-core/nbproject/genfiles.properties 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/nbproject/genfiles.properties 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -build.xml.data.CRC32=16a7c89c -build.xml.script.CRC32=91ddbaab -build.xml.stylesheet.CRC32=be360661 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=478066e1 -nbproject/build-impl.xml.script.CRC32=515d6ec8 -nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48 diff -Nru svgsalamander-1.1.1+dfsg/svg-core/nbproject/project.properties svgsalamander-1.1.4/svg-core/nbproject/project.properties --- svgsalamander-1.1.1+dfsg/svg-core/nbproject/project.properties 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/nbproject/project.properties 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -application.title=svg-salamander-core -application.vendor=kitfox -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/svg-salamander-core.jar -dist.javadoc.dir=${dist.dir}/javadoc -endorsed.classpath= -excludes= -file.reference.ant.jar=..\\libraries\\ant.jar -file.reference.javacc.jar=..\\libraries\\javacc.jar -file.reference.main-java=src/main/java -file.reference.main-res=src/main/res -file.reference.svgsalamander-www=../www -file.reference.test-java=src/test/java -file.reference.test-res=src/test/res -includes=** -jar.compress=true -javac.classpath=\ - ${file.reference.ant.jar}:\ - ${file.reference.javacc.jar} -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.external.vm=false -javac.processorpath=\ - ${javac.classpath} -javac.source=1.4 -javac.target=1.4 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath}:\ - ${libs.junit_4.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api" -jnlp.codebase.type=user -jnlp.codebase.user=https://svgsalamander.dev.java.net/binaries/ -jnlp.enabled=false -jnlp.offline-allowed=true -jnlp.signed=true -main.class=com.kitfox.svg.app.SVGPlayer -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=default_platform -res.dir=${file.reference.main-res} -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.dir=${file.reference.main-java} -src.java.dir=src\\gen\\java -src.res.dir=src\\gen\\res -src.www.dir=${file.reference.svgsalamander-www} -test.res.dir=${file.reference.test-res} -test.src.dir=${file.reference.test-java} diff -Nru svgsalamander-1.1.1+dfsg/svg-core/nbproject/project.xml svgsalamander-1.1.4/svg-core/nbproject/project.xml --- svgsalamander-1.1.1+dfsg/svg-core/nbproject/project.xml 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/nbproject/project.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ - - - org.netbeans.modules.java.j2seproject - - - svg-salamander-core - 1.6.5 - - - - - - - - - - - - - - ..\libraries\nblibraries.properties - - - diff -Nru svgsalamander-1.1.1+dfsg/svg-core/pom.xml svgsalamander-1.1.4/svg-core/pom.xml --- svgsalamander-1.1.1+dfsg/svg-core/pom.xml 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/pom.xml 2022-02-26 23:40:50.000000000 +0000 @@ -1,222 +1,160 @@ - - - 4.0.0 - - - org.sonatype.oss - oss-parent - 7 - - - - com.kitfox - kitfox-svg-salamander - 1.0.39 - jar - - ${project.artifactId} - - ${project.name} SVGSalamander is a light weight - SVG renderer and animator for Java. - - - 2011 - - http://java.net/projects/svgsalamander - - - Kitfox Studios - http://www.kitfox.com/ - - - - - http://svgsalamander.java.net/tags/kitfox-svg-salamander-1.0.39 - scm:svn:https://svn.java.net/svn/svgsalamander~svn/tags/kitfox-svg-salamander-1.0.39 - scm:svn:https://svn.java.net/svn/svgsalamander~svn/tags/kitfox-svg-salamander-1.0.39 - - - - - - - BSD - http://www.opensource.org/licenses/bsd-license.php - repo - - - GNU Lesser General Public License, version 2.1 - http://www.gnu.org/licenses/lgpl-2.1.html - repo - - - - - - - mark-mckay - Mark McKay - mark@kitfox.com - - owner - - - the creator - - - - - - - - UTF-8 - UTF-8 - - - kitfox-source-repo - - - - - - - - org.apache.ant - ant - 1.8.1 - - - - - - - - ${basedir}/src/main/java - - - ${basedir}/src/main/res - - - - - ${basedir}/src/test/java - - - ${basedir}/src/test/res - - - - - - - - org.codehaus.mojo - javacc-maven-plugin - 2.6 - - - javacc - generate-sources - - javacc - - - ${basedir}/src/main/java - - **/*.jjt - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.6 - 1.6 - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - 1.0 - - - enforce-maven-version - - enforce - - - - - [3.0,) - you-must-run-maven-3.0-or-above - - - - - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.7 - - true - false - - public - http://java.sun.com/javase/1.6.0/docs/api - - true - true - ${project.name} API ${project.version} / - ${maven.build.timestamp} - ${project.name} API ${project.version} / - ${maven.build.timestamp} -
<a href="${project.organization.url}" target="_blank">${project.organization.name}</a>
-
<a href="${project.organization.url}" target="_blank">${project.organization.name}</a>
- - - Copyright © {inceptionYear}-{currentYear} - <a href="${project.organization.url}" target="_blank">${project.organization.name}</a>. - All Rights Reserved. - -
-
- - - - org.apache.maven.plugins - maven-source-plugin - 2.1.2 - - - - - - - org.apache.maven.plugins - maven-release-plugin - - - clean verify - - deploy - - - -
- -
- + + + 4.0.0 + + com.kitfox + svgSalamander + 1.1.4 + jar + + com.kitfox:svgSalamander + A tool for displaying and playing SVG content using the Java2D. + https://github.com/blackears/svgSalamander + + + + BSD License + https://opensource.org/licenses/BSD-2-Clause + + + + + + Mark McKay + mark@kitfox.com + kitfox.com + http://www.kitfox.com + + + + + scm:git:git://github.com/blackears/svgSalamander.git + scm:git:ssh://github.com:blackears/svgSalamander.git + https://github.com/blackears/svgSalamander/tree/master/svg-core + + + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + + + 1.9 + 1.9 + + + + + org.apache.ant + ant + 1.9.13 + true + + + + + + + com.helger.maven + ph-javacc-maven-plugin + 4.1.0 + + + generate-sources + + jjtree-javacc + + + 1.9 + true + org.javacc.parser + src/main/java/com/kitfox/svg/animation/parser + + **.jjt + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.1.2 + + + + com.kitfox.svg + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.8 + true + + ossrh + https://oss.sonatype.org/ + true + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.10.0 + + + + + + deploy + + + + maven-gpg-plugin + 1.6 + + + sign-artifacts + verify + + sign + + + + + + maven-source-plugin + 3.0.1 + + + attach-sources + + jar-no-fork + + + + + + maven-javadoc-plugin + 3.0.1 + + + package + + jar + + + + + + + + + diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/A.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/A.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/A.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/A.java 2022-02-26 23:40:50.000000000 +0000 @@ -55,11 +55,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override protected void build() throws SVGException { super.build(); @@ -83,6 +85,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { boolean changeState = super.updateTime(curTime); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/AnimateBase.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/AnimateBase.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/AnimateBase.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/AnimateBase.java 2022-02-26 23:40:50.000000000 +0000 @@ -63,11 +63,13 @@ { } + @Override public void evalParametric(AnimationTimeEval state, double curTime) { evalParametric(state, curTime, repeatCount, repeatDur == null ? Double.NaN : repeatDur.evalTime()); } + @Override public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent) throws SAXException { //Load style string @@ -105,6 +107,7 @@ } } + @Override protected void rebuild(AnimTimeParser animTimeParser) throws SVGException { super.rebuild(animTimeParser); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/AnimateColor.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/AnimateColor.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/AnimateColor.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/AnimateColor.java 2022-02-26 23:40:50.000000000 +0000 @@ -64,11 +64,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent) throws SAXException { //Load style string @@ -101,6 +103,7 @@ (int)(b1 * invInterp + b2 * interp)); } + @Override protected void rebuild(AnimTimeParser animTimeParser) throws SVGException { super.rebuild(animTimeParser); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/Animate.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/Animate.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/Animate.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/Animate.java 2022-02-26 23:40:50.000000000 +0000 @@ -87,6 +87,7 @@ { } + @Override public String getTagName() { return TAG_NAME; @@ -97,6 +98,7 @@ return dataType; } + @Override public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent) throws SAXException { //Load style string @@ -392,6 +394,7 @@ return 0; } + @Override protected void rebuild(AnimTimeParser animTimeParser) throws SVGException { super.rebuild(animTimeParser); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/AnimateMotion.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/AnimateMotion.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/AnimateMotion.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/AnimateMotion.java 2022-02-26 23:40:50.000000000 +0000 @@ -46,7 +46,6 @@ import java.awt.geom.PathIterator; import java.awt.geom.Point2D; import java.util.ArrayList; -import java.util.Iterator; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.xml.sax.Attributes; @@ -61,7 +60,7 @@ { public static final String TAG_NAME = "animateMotion"; - static final Matcher matchPoint = Pattern.compile("\\s*(\\d+)[^\\d]+(\\d+)\\s*").matcher(""); + static final Pattern patPoint = Pattern.compile("\\s*(\\d+)[^\\d]+(\\d+)\\s*"); // protected double fromValue; // protected double toValue; @@ -72,7 +71,7 @@ public static final int RT_ANGLE = 0; //Rotate by constant 'rotate' degrees public static final int RT_AUTO = 1; //Rotate to reflect tangent of position on path - final ArrayList bezierSegs = new ArrayList(); + final ArrayList bezierSegs = new ArrayList(); double curveLength; /** Creates a new instance of Animate */ @@ -80,11 +79,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent) throws SAXException { //Load style string @@ -139,7 +140,7 @@ { Point2D.Float ptFrom = new Point2D.Float(), ptTo = new Point2D.Float(); - matchPoint.reset(from); + Matcher matchPoint = patPoint.matcher(from); if (matchPoint.matches()) { setPoint(ptFrom, matchPoint.group(1), matchPoint.group(2)); @@ -223,6 +224,7 @@ * Evaluates this animation element for the passed interpolation time. Interp * must be on [0..1]. */ + @Override public AffineTransform eval(AffineTransform xform, double interp) { Point2D.Double point = new Point2D.Double(); @@ -236,10 +238,7 @@ } double curLength = curveLength * interp; - for (Iterator it = bezierSegs.iterator(); it.hasNext();) - { - Bezier bez = (Bezier)it.next(); - + for (Bezier bez : bezierSegs) { double bezLength = bez.getLength(); if (curLength < bezLength) { @@ -257,6 +256,7 @@ } + @Override protected void rebuild(AnimTimeParser animTimeParser) throws SVGException { super.rebuild(animTimeParser); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/AnimateTransform.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/AnimateTransform.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/AnimateTransform.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/AnimateTransform.java 2022-02-26 23:40:50.000000000 +0000 @@ -82,11 +82,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent) throws SAXException { //Load style string @@ -174,6 +176,7 @@ * Evaluates this animation element for the passed interpolation time. Interp * must be on [0..1]. */ + @Override public AffineTransform eval(AffineTransform xform, double interp) { int idx = 0; @@ -255,6 +258,7 @@ return xform; } + @Override protected void rebuild(AnimTimeParser animTimeParser) throws SVGException { super.rebuild(animTimeParser); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/AnimateXform.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/AnimateXform.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/AnimateXform.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/AnimateXform.java 2022-02-26 23:40:50.000000000 +0000 @@ -54,6 +54,7 @@ { } + @Override public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent) throws SAXException { super.loaderStartElement(helper, attrs, parent); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/AnimationElement.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/AnimationElement.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/AnimationElement.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/AnimationElement.java 2022-02-26 23:40:50.000000000 +0000 @@ -109,6 +109,7 @@ } } + @Override public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent) throws SAXException { //Load style string @@ -348,6 +349,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) { //Animation elements to not change with time diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/AnimTimeParser.jjt svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/AnimTimeParser.jjt --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/AnimTimeParser.jjt 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/AnimTimeParser.jjt 1970-01-01 00:00:00.000000000 +0000 @@ -1,336 +0,0 @@ -/** - * SVG Salamander - * Copyright (c) 2004, Mark McKay - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Mark McKay can be contacted at mark@kitfox.com. Salamander and other - * projects can be found at http://www.kitfox.com - */ - - -options { - MULTI=true; - STATIC=false; -} - -PARSER_BEGIN(AnimTimeParser) - -package com.kitfox.svg.animation.parser; - -import com.kitfox.svg.SVGConst; -import com.kitfox.svg.animation.TimeBase; -import com.kitfox.svg.animation.TimeCompound; -import com.kitfox.svg.animation.TimeDiscrete; -import com.kitfox.svg.animation.TimeIndefinite; -import com.kitfox.svg.animation.TimeLookup; -import com.kitfox.svg.animation.TimeSum; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.logging.Level; -import java.util.logging.Logger; - -public class AnimTimeParser -{ - /** - * Test the parser - */ - public static void main(String args[]) throws ParseException - { -// AnimTimeParser parser = new AnimTimeParser(System.in); - StringReader reader; - - reader = new StringReader("1:30 + 5ms"); - AnimTimeParser parser = new AnimTimeParser(reader); - TimeBase tc; - - tc = parser.Expr(); - System.err.println("AnimTimeParser eval to " + tc.evalTime()); - - reader = new StringReader("19"); - parser.ReInit(reader); - tc = parser.Expr(); - System.err.println("AnimTimeParser eval to " + tc.evalTime()); - } - -} - -PARSER_END(AnimTimeParser) - - - - -/** - * Tokens - */ - -SKIP : /* WHITE SPACE */ -{ - " " -| "\t" -| "\n" -| "\r" -| "\f" -} - -TOKEN : -{ - < #LETTER: [ "a"-"z", "A"-"Z" ] > -| - < #DIGIT: [ "0"-"9"] > -| - < INTEGER: ()+ > -| - < FLOAT: (["+", "-"])? ((()* "." ()+) | (()+)) (["E", "e"] (["+", "-"])? ()+)? > -| - < INDEFINITE: "indefinite" > -| - < MOUSE_OVER: "mouseover" > -| - < WHEN_NOT_ACTIVE: "whenNotActive" > -| - < UNITS: "ms" | "s" | "min" | "h" > -| - < IDENTIFIER: (||"_"|"-")* > - -} - - - - - - - -/** - * Expression structure - */ - - -TimeBase Expr() : -{ - TimeBase term; - ArrayList list = new ArrayList(); -} -{ - ( term = Sum() - { - list.add(term); - } - )? - ( LOOKAHEAD(2) ";" term = Sum() - { - list.add(term); - } - ) * - (";")? - - { - switch (list.size()) - { - case 0: - return new TimeIndefinite(); - case 1: - return (TimeBase)list.get(0); - default: - return new TimeCompound(list); - } - } -} - -TimeBase Sum() : -{ - Token t = null; - TimeBase t1; - TimeBase t2 = null; -} -{ - t1=Term() ( (t="+" | t="-") t2 = Term() )? - { - if (t2 == null) return t1; - - if (t.image.equals("-")) - { - return new TimeSum(t1, t2, false); - } - else - { - return new TimeSum(t1, t2, true); - } - } -} - - -TimeBase Term() : -{ - TimeBase base; -} -{ - base=IndefiniteTime() - { return base; } - | base=LiteralTime() - { return base; } - | base=LookupTime() - { return base; } - | base=EventTime() - { return base; } -} - -TimeIndefinite IndefiniteTime() : -{} -{ - - { - return new TimeIndefinite(); - } -} - -TimeDiscrete EventTime() : -{} -{ - ( | ) - { - //For now, map all events to the zero time - return new TimeDiscrete(0); - } -} - -TimeDiscrete LiteralTime() : -{ - double t1, t2, t3 = Double.NaN, value; - Token t; -} -{ - t1=Number() - { - value = t1; - } - ( - - (":" t2=Number() (":" t3=Number())? - { - //Return clock time format (convert to seconds) - if (Double.isNaN(t3)) - { - value = t1 * 60 + t2; - } - else - { - value = t1 * 3600 + t2 * 60 + t3; - } - } - ) - - | - - (t= - { - //Return units format (convert to seconds) - if (t.image.equals("ms")) value = t1 / 1000; - if (t.image.equals("min")) value = t1 * 60; - if (t.image.equals("h")) value = t1 * 3600; - } - ) - )? - { - return new TimeDiscrete(value); - } -} - - -TimeLookup LookupTime() : -{ - double paramNum = 0.0; - Token node, event; -} -{ - node= "." event= (paramNum=ParamList())? - { - return new TimeLookup(null, node.image, event.image, "" + paramNum); - } -} - -double ParamList() : -{ - double num; -} -{ - "(" num=Number() ")" - { - return num; - } -} - -double Number() : -{ - Token t; -} -{ - t= - { - try { - return Double.parseDouble(t.image); - } - catch (Exception e) { - Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, - "Could not parse double '" + t.image + "'", e); - } - - return 0.0; - } - | t= - { - try { - return Double.parseDouble(t.image); - } - catch (Exception e) { - Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, - "Could not parse double '" + t.image + "'", e); - } - - return 0.0; - } -} - -int Integer() : -{ - Token t; -} -{ - t= - { - try { - return Integer.parseInt(t.image); - } - catch (Exception e) { - Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, - "Could not parse int '" + t.image + "'", e); - } - - return 0; - } -} - diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/parser/AnimTimeParser.jjt svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/parser/AnimTimeParser.jjt --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/parser/AnimTimeParser.jjt 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/parser/AnimTimeParser.jjt 2022-02-26 23:40:50.000000000 +0000 @@ -0,0 +1,336 @@ +/** + * SVG Salamander + * Copyright (c) 2004, Mark McKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Mark McKay can be contacted at mark@kitfox.com. Salamander and other + * projects can be found at http://www.kitfox.com + */ + + +options { + MULTI=true; + STATIC=false; +} + +PARSER_BEGIN(AnimTimeParser) + +package com.kitfox.svg.animation.parser; + +import com.kitfox.svg.SVGConst; +import com.kitfox.svg.animation.TimeBase; +import com.kitfox.svg.animation.TimeCompound; +import com.kitfox.svg.animation.TimeDiscrete; +import com.kitfox.svg.animation.TimeIndefinite; +import com.kitfox.svg.animation.TimeLookup; +import com.kitfox.svg.animation.TimeSum; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class AnimTimeParser +{ + /** + * Test the parser + */ + public static void main(String args[]) throws ParseException + { +// AnimTimeParser parser = new AnimTimeParser(System.in); + StringReader reader; + + reader = new StringReader("1:30 + 5ms"); + AnimTimeParser parser = new AnimTimeParser(reader); + TimeBase tc; + + tc = parser.Expr(); + System.err.println("AnimTimeParser eval to " + tc.evalTime()); + + reader = new StringReader("19"); + parser.ReInit(reader); + tc = parser.Expr(); + System.err.println("AnimTimeParser eval to " + tc.evalTime()); + } + +} + +PARSER_END(AnimTimeParser) + + + + +/** + * Tokens + */ + +SKIP : /* WHITE SPACE */ +{ + " " +| "\t" +| "\n" +| "\r" +| "\f" +} + +TOKEN : +{ + < #LETTER: [ "a"-"z", "A"-"Z" ] > +| + < #DIGIT: [ "0"-"9"] > +| + < INTEGER: ()+ > +| + < FLOAT: (["+", "-"])? ((()* "." ()+) | (()+)) (["E", "e"] (["+", "-"])? ()+)? > +| + < INDEFINITE: "indefinite" > +| + < MOUSE_OVER: "mouseover" > +| + < WHEN_NOT_ACTIVE: "whenNotActive" > +| + < UNITS: "ms" | "s" | "min" | "h" > +| + < IDENTIFIER: (||"_"|"-")* > + +} + + + + + + + +/** + * Expression structure + */ + + +TimeBase Expr() : +{ + TimeBase term; + ArrayList list = new ArrayList(); +} +{ + ( term = Sum() + { + list.add(term); + } + )? + ( LOOKAHEAD(2) ";" term = Sum() + { + list.add(term); + } + ) * + (";")? + + { + switch (list.size()) + { + case 0: + return new TimeIndefinite(); + case 1: + return (TimeBase)list.get(0); + default: + return new TimeCompound(list); + } + } +} + +TimeBase Sum() : +{ + Token t = null; + TimeBase t1; + TimeBase t2 = null; +} +{ + t1=Term() ( (t="+" | t="-") t2 = Term() )? + { + if (t2 == null) return t1; + + if (t.image.equals("-")) + { + return new TimeSum(t1, t2, false); + } + else + { + return new TimeSum(t1, t2, true); + } + } +} + + +TimeBase Term() : +{ + TimeBase base; +} +{ + base=IndefiniteTime() + { return base; } + | base=LiteralTime() + { return base; } + | base=LookupTime() + { return base; } + | base=EventTime() + { return base; } +} + +TimeIndefinite IndefiniteTime() : +{} +{ + + { + return new TimeIndefinite(); + } +} + +TimeDiscrete EventTime() : +{} +{ + ( | ) + { + //For now, map all events to the zero time + return new TimeDiscrete(0); + } +} + +TimeDiscrete LiteralTime() : +{ + double t1, t2, t3 = Double.NaN, value; + Token t; +} +{ + t1=Number() + { + value = t1; + } + ( + + (":" t2=Number() (":" t3=Number())? + { + //Return clock time format (convert to seconds) + if (Double.isNaN(t3)) + { + value = t1 * 60 + t2; + } + else + { + value = t1 * 3600 + t2 * 60 + t3; + } + } + ) + + | + + (t= + { + //Return units format (convert to seconds) + if (t.image.equals("ms")) value = t1 / 1000; + if (t.image.equals("min")) value = t1 * 60; + if (t.image.equals("h")) value = t1 * 3600; + } + ) + )? + { + return new TimeDiscrete(value); + } +} + + +TimeLookup LookupTime() : +{ + double paramNum = 0.0; + Token node, event; +} +{ + node= "." event= (paramNum=ParamList())? + { + return new TimeLookup(null, node.image, event.image, "" + paramNum); + } +} + +double ParamList() : +{ + double num; +} +{ + "(" num=Number() ")" + { + return num; + } +} + +double Number() : +{ + Token t; +} +{ + t= + { + try { + return Double.parseDouble(t.image); + } + catch (Exception e) { + Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, + "Could not parse double '" + t.image + "'", e); + } + + return 0.0; + } + | t= + { + try { + return Double.parseDouble(t.image); + } + catch (Exception e) { + Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, + "Could not parse double '" + t.image + "'", e); + } + + return 0.0; + } +} + +int Integer() : +{ + Token t; +} +{ + t= + { + try { + return Integer.parseInt(t.image); + } + catch (Exception e) { + Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, + "Could not parse int '" + t.image + "'", e); + } + + return 0; + } +} + diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/SetSmil.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/SetSmil.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/SetSmil.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/SetSmil.java 2022-02-26 23:40:50.000000000 +0000 @@ -62,11 +62,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent) throws SAXException { //Load style string @@ -75,6 +77,7 @@ toValue = attrs.getValue("to"); } + @Override protected void rebuild(AnimTimeParser animTimeParser) throws SVGException { super.rebuild(animTimeParser); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TimeBase.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TimeBase.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TimeBase.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TimeBase.java 2022-02-26 23:40:50.000000000 +0000 @@ -49,8 +49,8 @@ */ abstract public class TimeBase { - static final Matcher matchIndefinite = Pattern.compile("\\s*indefinite\\s*").matcher(""); - static final Matcher matchUnitTime = Pattern.compile("\\s*([-+]?((\\d*\\.\\d+)|(\\d+))([-+]?[eE]\\d+)?)\\s*(h|min|s|ms)?\\s*").matcher(""); + static final Pattern patIndefinite = Pattern.compile("\\s*indefinite\\s*"); + static final Pattern patUnitTime = Pattern.compile("\\s*([-+]?((\\d*\\.\\d+)|(\\d+))([-+]?[eE]\\d+)?)\\s*(h|min|s|ms)?\\s*"); /* public static TimeBase parseTime(String text) @@ -68,10 +68,10 @@ protected static TimeBase parseTimeComponent(String text) { - matchIndefinite.reset(text); + Matcher matchIndefinite = patIndefinite.matcher(text); if (matchIndefinite.matches()) return new TimeIndefinite(); - matchUnitTime.reset(text); + Matcher matchUnitTime = patUnitTime.matcher(text); if (matchUnitTime.matches()) { String val = matchUnitTime.group(1); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TimeCompound.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TimeCompound.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TimeCompound.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TimeCompound.java 2022-02-26 23:40:50.000000000 +0000 @@ -37,7 +37,6 @@ package com.kitfox.svg.animation; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.regex.Pattern; @@ -57,23 +56,22 @@ * This is a list of times. This element's time is calculated as the greatest * member that is less than the current time. */ - final List componentTimes; + final List componentTimes; private AnimationElement parent; /** Creates a new instance of TimeDiscrete */ - public TimeCompound(List timeBases) + public TimeCompound(List timeBases) { componentTimes = Collections.unmodifiableList(timeBases); } + @Override public double evalTime() { double agg = 0.0; - for (Iterator it = componentTimes.iterator(); it.hasNext();) - { - TimeBase timeEle = (TimeBase)it.next(); + for (TimeBase timeEle : componentTimes) { double time = timeEle.evalTime(); agg += time; } @@ -81,13 +79,12 @@ return agg; } + @Override public void setParentElement(AnimationElement ele) { this.parent = ele; - for (Iterator it = componentTimes.iterator(); it.hasNext();) - { - TimeBase timeEle = (TimeBase)it.next(); + for (TimeBase timeEle : componentTimes) { timeEle.setParentElement(ele); } } diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TimeDiscrete.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TimeDiscrete.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TimeDiscrete.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TimeDiscrete.java 2022-02-26 23:40:50.000000000 +0000 @@ -53,6 +53,7 @@ this.secs = secs; } + @Override public double evalTime() { return secs; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TimeIndefinite.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TimeIndefinite.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TimeIndefinite.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TimeIndefinite.java 2022-02-26 23:40:50.000000000 +0000 @@ -50,6 +50,7 @@ { } + @Override public double evalTime() { return Double.POSITIVE_INFINITY; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TimeLookup.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TimeLookup.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TimeLookup.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TimeLookup.java 2022-02-26 23:40:50.000000000 +0000 @@ -73,11 +73,13 @@ this.paramList = paramList; } + @Override public double evalTime() { return 0.0; } + @Override public void setParentElement(AnimationElement ele) { parent = ele; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TimeSum.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TimeSum.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TimeSum.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TimeSum.java 2022-02-26 23:40:50.000000000 +0000 @@ -57,11 +57,13 @@ this.add = add; } + @Override public double evalTime() { return add ? t1.evalTime() + t2.evalTime() : t1.evalTime() - t2.evalTime(); } + @Override public void setParentElement(AnimationElement ele) { t1.setParentElement(ele); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TrackBase.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TrackBase.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TrackBase.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TrackBase.java 2022-02-26 23:40:50.000000000 +0000 @@ -59,7 +59,7 @@ //It doesn't make sense to sort this, since some events will depend on // other events - in many cases, there will be no meaningful sorted order. - final ArrayList animEvents = new ArrayList(); + final ArrayList animEvents = new ArrayList(); /** Creates a new instance of TrackManager */ // public TrackBase(SVGElement parent) diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TrackColor.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TrackColor.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TrackColor.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TrackColor.java 2022-02-26 23:40:50.000000000 +0000 @@ -41,7 +41,6 @@ import java.util.*; import com.kitfox.svg.*; -import com.kitfox.svg.xml.*; /** * A track holds the animation events for a single parameter of a single SVG @@ -59,6 +58,7 @@ super(ele.getParent(), ele); } + @Override public boolean getValue(StyleAttribute attrib, double curTime) { Color col = getValue(curTime); @@ -73,9 +73,8 @@ Color retVal = null; AnimationTimeEval state = new AnimationTimeEval(); - for (Iterator it = animEvents.iterator(); it.hasNext();) - { - AnimateBase ele = (AnimateBase)it.next(); + for (AnimationElement animationElement : animEvents) { + AnimateBase ele = (AnimateBase)animationElement; AnimateColorIface eleColor = (AnimateColorIface)ele; ele.evalParametric(state, curTime); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TrackDouble.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TrackDouble.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TrackDouble.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TrackDouble.java 2022-02-26 23:40:50.000000000 +0000 @@ -40,7 +40,6 @@ import java.util.*; import com.kitfox.svg.*; -import com.kitfox.svg.xml.*; /** * A track holds the animation events for a single parameter of a single SVG @@ -57,6 +56,7 @@ super(ele.getParent(), ele); } + @Override public boolean getValue(StyleAttribute attrib, double curTime) { double val = getValue(curTime); @@ -93,9 +93,8 @@ AnimationTimeEval state = new AnimationTimeEval(); // boolean pastEnd = true; - for (Iterator it = animEvents.iterator(); it.hasNext();) - { - Animate ele = (Animate)it.next(); + for (AnimationElement animationElement : animEvents) { + Animate ele = (Animate)animationElement; ele.evalParametric(state, curTime); //Go to next element if this one does not affect processing diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TrackManager.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TrackManager.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TrackManager.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TrackManager.java 2022-02-26 23:40:50.000000000 +0000 @@ -39,6 +39,7 @@ import java.util.*; import com.kitfox.svg.*; + import java.io.Serializable; /** @@ -69,6 +70,7 @@ this.type = type; } + @Override public int hashCode() { int hash = name == null ? 0 : name.hashCode(); @@ -76,6 +78,7 @@ return hash; } + @Override public boolean equals(Object obj) { if (!(obj instanceof TrackKey)) return false; @@ -84,7 +87,7 @@ } } - HashMap tracks = new HashMap(); + HashMap tracks = new HashMap(); /** Creates a new instance of TrackManager */ public TrackManager() @@ -162,7 +165,7 @@ return tracks.size(); } - public Iterator iterator() + public Iterator iterator() { return tracks.values().iterator(); } diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TrackMotion.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TrackMotion.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TrackMotion.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TrackMotion.java 2022-02-26 23:40:50.000000000 +0000 @@ -41,7 +41,6 @@ import java.util.*; import com.kitfox.svg.*; -import com.kitfox.svg.xml.*; /** * A track holds the animation events for a single parameter of a single SVG @@ -60,6 +59,7 @@ super(ele.getParent(), ele); } + @Override public boolean getValue(StyleAttribute attrib, double curTime) throws SVGException { AffineTransform retVal = new AffineTransform(); @@ -100,9 +100,8 @@ AffineTransform xform = new AffineTransform(); // boolean pastEnd = true; - for (Iterator it = animEvents.iterator(); it.hasNext();) - { - AnimateMotion ele = (AnimateMotion)it.next(); + for (AnimationElement animationElement : animEvents) { + AnimateMotion ele = (AnimateMotion)animationElement; ele.evalParametric(state, curTime); //Go to next element if this one does not affect processing diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TrackPath.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TrackPath.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TrackPath.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TrackPath.java 2022-02-26 23:40:50.000000000 +0000 @@ -37,13 +37,11 @@ package com.kitfox.svg.animation; import com.kitfox.svg.xml.StyleAttribute; -import java.awt.*; import java.awt.geom.*; import java.util.*; import com.kitfox.svg.pathcmd.*; import com.kitfox.svg.*; -import com.kitfox.svg.xml.*; /** * A track holds the animation events for a single parameter of a single SVG @@ -61,6 +59,7 @@ super(ele.getParent(), ele); } + @Override public boolean getValue(StyleAttribute attrib, double curTime) { GeneralPath path = getValue(curTime); @@ -75,9 +74,8 @@ GeneralPath retVal = null; AnimationTimeEval state = new AnimationTimeEval(); - for (Iterator it = animEvents.iterator(); it.hasNext();) - { - AnimateBase ele = (AnimateBase)it.next(); + for (AnimationElement animationElement : animEvents) { + AnimateBase ele = (AnimateBase)animationElement; Animate eleAnim = (Animate)ele; ele.evalParametric(state, curTime); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TrackTransform.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TrackTransform.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/animation/TrackTransform.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/animation/TrackTransform.java 2022-02-26 23:40:50.000000000 +0000 @@ -41,7 +41,6 @@ import java.util.*; import com.kitfox.svg.*; -import com.kitfox.svg.xml.*; /** * A track holds the animation events for a single parameter of a single SVG @@ -58,6 +57,7 @@ super(ele.getParent(), ele); } + @Override public boolean getValue(StyleAttribute attrib, double curTime) throws SVGException { AffineTransform retVal = new AffineTransform(); @@ -97,9 +97,8 @@ AnimationTimeEval state = new AnimationTimeEval(); AffineTransform xform = new AffineTransform(); - for (Iterator it = animEvents.iterator(); it.hasNext();) - { - AnimateXform ele = (AnimateXform)it.next(); + for (AnimationElement animationElement : animEvents) { + AnimateXform ele = (AnimateXform)animationElement; ele.evalParametric(state, curTime); //Go to next element if this one does not affect processing diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/ant/SVGToImageAntTask.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/ant/SVGToImageAntTask.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/ant/SVGToImageAntTask.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/ant/SVGToImageAntTask.java 2022-02-26 23:40:50.000000000 +0000 @@ -57,32 +57,32 @@ *

Translates a group of SVG files into images.

* *

Parameters:

- *

    - *
  • destDir - If present, specifices a directory to write SVG files to. Otherwise + *
      + *
    • destDir - If present, specifies a directory to write SVG files to. Otherwise * writes images to directory SVG file was found in - * verbose - If true, prints processing information to the console - *
    • format - File format for output images. The java core javax.imageio.ImageIO + * verbose - If true, prints processing information to the console
    • + *
    • format - File format for output images. The java core javax.imageio.ImageIO * class is used for creating images, so format strings will depend on what * files your system is configured to handle. By default, "gif", "jpg" and "png" - * files are guaranteed to be present. If omitted, "png" is used by default. - *
    • backgroundColor - Optional background color. Color can be specified as a standard + * files are guaranteed to be present. If omitted, "png" is used by default.
    • + *
    • backgroundColor - Optional background color. Color can be specified as a standard * HTML color. That is, as the name of a standard color such as "blue" or - * "limegreen", using the # notaion as in #ff00ff for magenta, or in rgb format + * "limegreen", using the # notation as in #ff00ff for magenta, or in rgb format * listing the components as in rgb(255, 192, 192) for pink. If omitted, - * background is transparent. - *
    • antiAlias - If set, shapes are drawn using antialiasing. Defaults to true. - *
    • interpolation - String describing image interpolation alrogithm. Can - * be one of "nearest neighbor", "bilinear" or "bicubic". Defaults to "bicubic". - *
    • width - If greater than 0, determines the width of the written image. Otherwise, - * the width is obtained from the SVG document. Defaults to -1; - *
    • height - If greater than 0, determines the height of the written image. Otherwise, - * the height is obtained from the SVG document. Defaults to -1. - *
    • sizeToFit - If true and the width and height of the output image differ + * background is transparent.
    • + *
    • antiAlias - If set, shapes are drawn using anti-aliasing. Defaults to true.
    • + *
    • interpolation - String describing image interpolation algorithm. Can + * be one of "nearest neighbor", "bilinear" or "bicubic". Defaults to "bicubic".
    • + *
    • width - If greater than 0, determines the width of the written image. Otherwise, + * the width is obtained from the SVG document. Defaults to -1;
    • + *
    • height - If greater than 0, determines the height of the written image. Otherwise, + * the height is obtained from the SVG document. Defaults to -1.
    • + *
    • sizeToFit - If true and the width and height of the output image differ * from that of the SVG image, the valid area of the SVG image will be resized - * to fit the specified size. - *
    • verbose - IF true, prints out diagnostic infromation about processing. - * Defaults to false. - *

    + * to fit the specified size.
  • + *
  • verbose - If true, prints out diagnostic information about processing. + * Defaults to false.
  • + *
* * Example: * <SVGToImage destDir="${index.java}" format="jpg" verbose="true"> @@ -100,7 +100,7 @@ */ public class SVGToImageAntTask extends Task { - private ArrayList filesets = new ArrayList(); + private ArrayList filesets = new ArrayList(); boolean verbose = false; File destDir; private String format = "png"; @@ -175,6 +175,7 @@ /** * Adds a set of files. + * @param set */ public void addFileset(FileSet set) { @@ -183,13 +184,12 @@ + @Override public void execute() { if (verbose) log("Building SVG images"); - for (Iterator it = filesets.iterator(); it.hasNext();) - { - FileSet fs = (FileSet)it.next(); + for (FileSet fs : filesets) { FileScanner scanner = fs.getDirectoryScanner(getProject()); String[] files = scanner.getIncludedFiles(); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/beans/ProportionalLayoutPanel.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/beans/ProportionalLayoutPanel.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/beans/ProportionalLayoutPanel.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/beans/ProportionalLayoutPanel.java 2022-02-26 23:40:50.000000000 +0000 @@ -37,7 +37,6 @@ package com.kitfox.svg.app.beans; import java.awt.*; -import java.util.*; import javax.swing.*; /** @@ -63,6 +62,7 @@ initComponents(); } + @Override public void addNotify() { super.addNotify(); @@ -86,10 +86,12 @@ addComponentListener(new java.awt.event.ComponentAdapter() { + @Override public void componentResized(java.awt.event.ComponentEvent evt) { formComponentResized(evt); } + @Override public void componentShown(java.awt.event.ComponentEvent evt) { formComponentShown(evt); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/beans/SVGIcon.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/beans/SVGIcon.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/beans/SVGIcon.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/beans/SVGIcon.java 2022-02-26 23:40:50.000000000 +0000 @@ -106,6 +106,7 @@ changes.removePropertyChangeListener(p); } + @Override public Image getImage() { BufferedImage bi = new BufferedImage(getIconWidth(), getIconHeight(), BufferedImage.TYPE_INT_ARGB); @@ -116,7 +117,7 @@ /** * @return height of this icon */ - public int getIconHeight() + public int getIconHeightIgnoreAutosize() { if (preferredSize != null && (autosize == AUTOSIZE_VERT || autosize == AUTOSIZE_STRETCH @@ -136,7 +137,8 @@ /** * @return width of this icon */ - public int getIconWidth() + + public int getIconWidthIgnoreAutosize() { if (preferredSize != null && (autosize == AUTOSIZE_HORIZ || autosize == AUTOSIZE_STRETCH @@ -153,6 +155,49 @@ return (int)diagram.getWidth(); } + private boolean isAutoSizeBestFitUseFixedHeight(final int iconWidthIgnoreAutosize, final int iconHeightIgnoreAutosize, + final SVGDiagram diagram) + { + return iconHeightIgnoreAutosize/diagram.getHeight() < iconWidthIgnoreAutosize/diagram.getWidth(); + } + + @Override + public int getIconWidth() + { + final int iconWidthIgnoreAutosize = getIconWidthIgnoreAutosize(); + final int iconHeightIgnoreAutosize = getIconHeightIgnoreAutosize(); + final SVGDiagram diagram = svgUniverse.getDiagram(svgURI); + if (preferredSize != null && (autosize == AUTOSIZE_VERT || + (autosize == AUTOSIZE_BESTFIT && isAutoSizeBestFitUseFixedHeight(iconWidthIgnoreAutosize, iconHeightIgnoreAutosize, diagram)))) + { + final double aspectRatio = diagram.getHeight()/diagram.getWidth(); + return (int)(iconHeightIgnoreAutosize / aspectRatio); + } + else + { + return iconWidthIgnoreAutosize; + } + } + + @Override + public int getIconHeight() + { + final int iconWidthIgnoreAutosize = getIconWidthIgnoreAutosize(); + final int iconHeightIgnoreAutosize = getIconHeightIgnoreAutosize(); + final SVGDiagram diagram = svgUniverse.getDiagram(svgURI); + if (preferredSize != null && (autosize == AUTOSIZE_HORIZ || + (autosize == AUTOSIZE_BESTFIT && !isAutoSizeBestFitUseFixedHeight(iconWidthIgnoreAutosize, iconHeightIgnoreAutosize, diagram)))) + { + final double aspectRatio = diagram.getHeight()/diagram.getWidth(); + return (int)(iconWidthIgnoreAutosize * aspectRatio); + } + else + { + return iconHeightIgnoreAutosize; + } + } + + /** * Draws the icon to the specified component. * @param comp - Component to draw icon to. This is ignored by SVGIcon, and can be set to null; only gg is used for drawing the icon @@ -160,6 +205,7 @@ * @param x - X coordinate to draw icon * @param y - Y coordinate to draw icon */ + @Override public void paintIcon(Component comp, Graphics gg, int x, int y) { //Copy graphics object so that @@ -217,8 +263,8 @@ return; } - final int width = getIconWidth(); - final int height = getIconHeight(); + final int width = getIconWidthIgnoreAutosize(); + final int height = getIconHeightIgnoreAutosize(); // int width = getWidth(); // int height = getHeight(); @@ -378,7 +424,6 @@ /** * @deprecated - * @return */ public void setScaleToFit(boolean scaleToFit) { diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/beans/SVGPanel.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/beans/SVGPanel.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/beans/SVGPanel.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/beans/SVGPanel.java 2022-02-26 23:40:50.000000000 +0000 @@ -106,6 +106,7 @@ return (int)diagram.getWidth(); } + @Override public void paintComponent(Graphics gg) { super.paintComponent(gg); @@ -131,7 +132,7 @@ { try { - diagram.render(g); + diagram.render(this, g); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAliasHint); } catch (SVGException e) @@ -252,7 +253,6 @@ /** * @deprecated - * @return */ public void setScaleToFit(boolean scaleToFit) { diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/data/Handler.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/data/Handler.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/data/Handler.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/data/Handler.java 2022-02-26 23:40:50.000000000 +0000 @@ -92,10 +92,12 @@ } } + @Override public void connect() throws IOException { } + @Override public String getHeaderField(String name) { if ("content-type".equals(name)) @@ -106,6 +108,7 @@ return super.getHeaderField(name); } + @Override public InputStream getInputStream() throws IOException { return new ByteArrayInputStream(buf); @@ -117,6 +120,7 @@ // } } + @Override protected URLConnection openConnection(URL u) throws IOException { return new Connection(u); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/MainFrame.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/MainFrame.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/MainFrame.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/MainFrame.java 2022-02-26 23:40:50.000000000 +0000 @@ -66,6 +66,7 @@ setTitle("SVG Salamander - Application Launcher"); addWindowListener(new java.awt.event.WindowAdapter() { + @Override public void windowClosing(java.awt.event.WindowEvent evt) { exitForm(evt); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/PlayerDialog.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/PlayerDialog.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/PlayerDialog.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/PlayerDialog.java 2022-02-26 23:40:50.000000000 +0000 @@ -96,6 +96,7 @@ setTitle("Player"); addWindowListener(new java.awt.event.WindowAdapter() { + @Override public void windowClosed(java.awt.event.WindowEvent evt) { formWindowClosed(evt); @@ -157,6 +158,7 @@ }); text_curTime.addFocusListener(new java.awt.event.FocusAdapter() { + @Override public void focusLost(java.awt.event.FocusEvent evt) { text_curTimeFocusLost(evt); @@ -194,6 +196,7 @@ }); text_timeStep.addFocusListener(new java.awt.event.FocusAdapter() { + @Override public void focusLost(java.awt.event.FocusEvent evt) { text_timeStepFocusLost(evt); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/PlayerThread.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/PlayerThread.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/PlayerThread.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/PlayerThread.java 2022-02-26 23:40:50.000000000 +0000 @@ -45,7 +45,7 @@ */ public class PlayerThread implements Runnable { - HashSet listeners = new HashSet(); + HashSet listeners = new HashSet(); double curTime = 0; double timeStep = .2; @@ -129,9 +129,7 @@ private void fireTimeUpdateEvent() { - for (Iterator it = listeners.iterator(); it.hasNext();) - { - PlayerThreadListener listener = (PlayerThreadListener)it.next(); + for (PlayerThreadListener listener : listeners) { listener.updateTime(curTime, timeStep, playState); } } diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/SVGPlayer.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/SVGPlayer.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/SVGPlayer.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/SVGPlayer.java 2022-02-26 23:40:50.000000000 +0000 @@ -55,7 +55,6 @@ import java.security.AccessControlException; import java.util.ArrayList; import java.util.List; -import java.util.Vector; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; @@ -89,6 +88,7 @@ new javax.swing.filechooser.FileFilter() { final Matcher matchLevelFile = Pattern.compile(".*\\.svg[z]?").matcher(""); + @Override public boolean accept(File file) { if (file.isDirectory()) return true; @@ -97,6 +97,7 @@ return matchLevelFile.matches(); } + @Override public String getDescription() { return "SVG file (*.svg, *.svgz)"; } } ); @@ -132,6 +133,7 @@ svgDisplayPanel.setBgColor(Color.white); svgDisplayPanel.addMouseListener(new MouseAdapter() { + @Override public void mouseClicked(MouseEvent evt) { SVGDiagram diagram = svgDisplayPanel.getDiagram(); @@ -140,11 +142,10 @@ System.out.println("Picking at cursor (" + evt.getX() + ", " + evt.getY() + ")"); try { - List paths = diagram.pick(new Point2D.Float(evt.getX(), evt.getY()), null); + List> paths = diagram.pick(new Point2D.Float(evt.getX(), evt.getY()), null); for (int i = 0; i < paths.size(); i++) { - ArrayList path = (ArrayList)paths.get(i); - System.out.println(pathToString(path)); + System.out.println(pathToString(paths.get(i))); } } catch (SVGException ex) @@ -162,7 +163,7 @@ playerDialog = new PlayerDialog(this); } - private String pathToString(List path) + private String pathToString(List path) { if (path.size() == 0) return ""; @@ -171,7 +172,7 @@ for (int i = 1; i < path.size(); i++) { sb.append("/"); - sb.append(((SVGElement)path.get(i)).getId()); + sb.append(path.get(i).getId()); } return sb.toString(); } @@ -258,6 +259,7 @@ setTitle("SVG Player - Salamander Project"); addWindowListener(new java.awt.event.WindowAdapter() { + @Override public void windowClosing(java.awt.event.WindowEvent evt) { exitForm(evt); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/SVGViewer.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/SVGViewer.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/SVGViewer.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/SVGViewer.java 2022-02-26 23:40:50.000000000 +0000 @@ -53,7 +53,6 @@ import java.net.URLEncoder; import java.security.AccessControlException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -85,6 +84,7 @@ new javax.swing.filechooser.FileFilter() { final Matcher matchLevelFile = Pattern.compile(".*\\.svg[z]?").matcher(""); + @Override public boolean accept(File file) { if (file.isDirectory()) return true; @@ -93,6 +93,7 @@ return matchLevelFile.matches(); } + @Override public String getDescription() { return "SVG file (*.svg, *.svgz)"; } } ); @@ -208,6 +209,7 @@ setTitle("SVG Viewer - Salamander Project"); addWindowListener(new java.awt.event.WindowAdapter() { + @Override public void windowClosing(java.awt.event.WindowEvent evt) { exitForm(evt); @@ -218,10 +220,12 @@ panel_svgArea.addMouseListener(new java.awt.event.MouseAdapter() { + @Override public void mousePressed(java.awt.event.MouseEvent evt) { panel_svgAreaMousePressed(evt); } + @Override public void mouseReleased(java.awt.event.MouseEvent evt) { panel_svgAreaMouseReleased(evt); @@ -326,7 +330,7 @@ private void panel_svgAreaMouseReleased(java.awt.event.MouseEvent evt)//GEN-FIRST:event_panel_svgAreaMouseReleased {//GEN-HEADEREND:event_panel_svgAreaMouseReleased SVGDiagram diagram = svgDisplayPanel.getDiagram(); - List pickedElements; + List> pickedElements; try { pickedElements = diagram.pick(new Point(evt.getX(), evt.getY()), null); @@ -338,16 +342,10 @@ } System.out.println("Pick results:"); - for (Iterator it = pickedElements.iterator(); it.hasNext();) - { - ArrayList path = (ArrayList)it.next(); - + for (List path : pickedElements) { System.out.print(" Path: "); - for (Iterator it2 = path.iterator(); it2.hasNext();) - { - SVGElement ele = (SVGElement)it2.next(); - + for (SVGElement ele : path) { System.out.print("" + ele.getId() + "(" + ele.getClass().getName() + ") "); } System.out.println(); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/VersionDialog.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/VersionDialog.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/VersionDialog.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/VersionDialog.java 2022-02-26 23:40:50.000000000 +0000 @@ -39,13 +39,8 @@ import com.kitfox.svg.SVGConst; import java.net.*; import java.io.*; -import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; -import javax.swing.event.*; -import javax.swing.*; -import javax.swing.text.html.*; - /** * diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/BufferPainter.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/BufferPainter.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/BufferPainter.java 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/BufferPainter.java 2022-02-26 23:40:50.000000000 +0000 @@ -0,0 +1,215 @@ +package com.kitfox.svg; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.geom.AffineTransform; +import java.awt.geom.Point2D; +import java.awt.image.BufferedImage; +import java.awt.image.ImageObserver; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +public class BufferPainter +{ + public static final boolean DEBUG_PAINT = false; + + public static class Cache + { + private final BufferedImage img; + private final Rectangle bounds; + private final AffineTransform transform; + + public Cache(BufferedImage img, Rectangle bounds, AffineTransform transform) + { + this.img = img; + this.bounds = bounds; + this.transform = transform; + } + + boolean isCompatible(AffineTransform tx) + { + return tx.getScaleX() == transform.getScaleX() + && tx.getScaleY() == transform.getScaleY() + && tx.getShearX() == transform.getShearX() + && tx.getShearY() == transform.getShearY(); + } + + Rectangle getBoundsForTransform(AffineTransform tx) + { + double dx = tx.getTranslateX() - transform.getTranslateX(); + double dy = tx.getTranslateY() - transform.getTranslateY(); + return new Rectangle((int) (bounds.x + dx), (int) (bounds.y + dy), + bounds.width, bounds.height); + } + } + + public static void paintElement(Graphics2D g, RenderableElement element) throws SVGException + { + if (element.cachedMask != null + || (element.filter != null && !element.filter.filterEffects.isEmpty())) + { + renderElement(g, element); + } else + { + element.doRender(g); + } + } + + private static float getTransformScale(Point2D.Float origin, Point2D.Float testPoint, + AffineTransform transform) + { + transform.transform(testPoint, testPoint); + float dx = testPoint.x - origin.x; + float dy = testPoint.y - origin.y; + return (float) Math.sqrt(dx * dx + dy * dy); + } + + private static void renderElement(Graphics2D g, RenderableElement element) throws SVGException + { + AffineTransform transform = g.getTransform(); + + Graphics2D gg = (Graphics2D) g.create(); + Rectangle elementBounds = element.getBoundingBox().getBounds(); + Rectangle transformedBounds = transform.createTransformedShape(elementBounds).getBounds(); + Rectangle dstBounds = new Rectangle(transformedBounds); + + ImageObserver observer = element.diagram.getCurrentRenderTarget(); + + Cache cache = element.getBufferCache(); + BufferedImage elementImage; + + if (cache == null || observer == null || !cache.isCompatible(transform)) + { + elementImage = renderToBuffer(gg, element, transform, transformedBounds, dstBounds); + if (observer != null) + { + // Only do caching if we are painting to a component. + Cache cacheEntry = new Cache(elementImage, new Rectangle(dstBounds), transform); + element.setBufferImage(cacheEntry); + } + } else + { + elementImage = cache.img; + dstBounds.setBounds(cache.getBoundsForTransform(transform)); + } + + // Reset the transform. We already accounted for it in the buffer image. + gg.setTransform(new AffineTransform()); + gg.drawImage(elementImage, dstBounds.x, dstBounds.y, observer); + if (DEBUG_PAINT) + { + gg.setColor(Color.GREEN); + gg.drawRect(dstBounds.x, dstBounds.y, dstBounds.width, dstBounds.height); + if (!dstBounds.equals(transformedBounds)) + { + gg.setColor(Color.PINK); + gg.drawRect(transformedBounds.x, transformedBounds.y, transformedBounds.width, transformedBounds.height); + } + } + gg.dispose(); + } + + private static BufferedImage renderToBuffer(Graphics2D gg, RenderableElement element, + AffineTransform transform, Rectangle transformedBounds, + Rectangle dstBounds) throws SVGException + { + Point2D.Float origin = new Point2D.Float(0, 0); + transform.transform(origin, origin); + + // As filter operations are commonly implemented using convolutions they need to be + // aware of any possible scaling to compensate for it in their kernel size. + Point2D.Float testPoint = new Point2D.Float(1, 0); + float xScale = getTransformScale(origin, testPoint, transform); + testPoint.setLocation(0, 1); + float yScale = getTransformScale(origin, testPoint, transform); + + List filterOps = element.filter == null + ? Collections.emptyList() + : element.filter.filterEffects.stream() + .flatMap(f -> f.getOperations(dstBounds, xScale, yScale).stream()) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + + for (FilterEffects.FilterOp filterOp : filterOps) + { + int right = Math.max(dstBounds.x + dstBounds.width, + filterOp.requiredImageBounds.x + filterOp.requiredImageBounds.width); + int bottom = Math.max(dstBounds.y + dstBounds.height, + filterOp.requiredImageBounds.y + filterOp.requiredImageBounds.height); + dstBounds.x = Math.min(dstBounds.x, filterOp.requiredImageBounds.x); + dstBounds.y = Math.min(dstBounds.y, filterOp.requiredImageBounds.y); + dstBounds.width = right - dstBounds.x; + dstBounds.height = bottom - dstBounds.y; + } + + + BufferedImage elementImage = BufferPainter.paintToBuffer(gg, transform, dstBounds, transformedBounds, + element, null, true); + + for (FilterEffects.FilterOp filterOp : filterOps) + { + elementImage = filterOp.op.filter(elementImage, null); + } + + if (element.cachedMask != null) + { + // Draw the mask image. Implicitly the mask is empty i.e. has a completely black background. + // We can't draw the mask directly to the elementImage using the mask composite as + // masks may change the mask value a location at any time during mask realization. + BufferedImage maskImage = BufferPainter.paintToBuffer(gg, transform, dstBounds, transformedBounds, + element.cachedMask, Color.BLACK, false); + + Graphics2D elementGraphics = (Graphics2D) elementImage.getGraphics(); + elementGraphics.setRenderingHints(gg.getRenderingHints()); + elementGraphics.setComposite(element.cachedMask.createMaskComposite()); + elementGraphics.drawImage(maskImage, 0, 0, element.diagram.getCurrentRenderTarget()); + elementGraphics.dispose(); + } + return elementImage; + } + + public static BufferedImage paintToBuffer(Graphics2D g, AffineTransform transform, + Rectangle srcBounds, RenderableElement element, + Color bgColor) throws SVGException + { + return paintToBuffer(g, transform, srcBounds, srcBounds, element, bgColor, false); + } + + /* + * The srcBounds parameter is expected to be pre-transformed by the given transform. + */ + public static BufferedImage paintToBuffer(Graphics2D g, AffineTransform transform, + Rectangle dstBounds, Rectangle srcBounds, + RenderableElement element, + Color bgColor, boolean preMultiplied) throws SVGException + { + int type = preMultiplied + ? BufferedImage.TYPE_INT_ARGB_PRE + : BufferedImage.TYPE_INT_ARGB; + BufferedImage img = new BufferedImage(dstBounds.width, dstBounds.height, type); + Graphics2D imgGraphics = (Graphics2D) img.getGraphics(); + if (g != null) + { + imgGraphics.setRenderingHints(g.getRenderingHints()); + } else if (bgColor != null) + { + imgGraphics.setColor(bgColor); + imgGraphics.fillRect(0, 0, img.getWidth(), img.getHeight()); + } + int xRelative = srcBounds.x - dstBounds.x; + int yRelative = srcBounds.y - dstBounds.y; + imgGraphics.translate(xRelative, yRelative); + imgGraphics.clipRect(0, 0, srcBounds.width, srcBounds.height); + + // Because we blit the image at the transformed location we have to compensate for the + // element location. + imgGraphics.translate(-srcBounds.x, -srcBounds.y); + imgGraphics.transform(transform); + element.doRender(imgGraphics); + imgGraphics.dispose(); + return img; + } +} diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Circle.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Circle.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Circle.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Circle.java 2022-02-26 23:40:50.000000000 +0000 @@ -61,11 +61,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override protected void build() throws SVGException { super.build(); @@ -90,18 +92,21 @@ circle.setFrame(cx - r, cy - r, r * 2f, r * 2f); } - public void render(Graphics2D g) throws SVGException + @Override + protected void doRender(Graphics2D g) throws SVGException { beginLayer(g); renderShape(g, circle); finishLayer(g); } + @Override public Shape getShape() { return shapeToParent(circle); } + @Override public Rectangle2D getBoundingBox() throws SVGException { return boundsToParent(includeStrokeInBounds(circle.getBounds2D())); @@ -114,6 +119,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { // if (trackManager.getNumTracks() == 0) return false; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/ClipPath.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/ClipPath.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/ClipPath.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/ClipPath.java 2022-02-26 23:40:50.000000000 +0000 @@ -38,7 +38,6 @@ import com.kitfox.svg.xml.StyleAttribute; import java.awt.Shape; import java.awt.geom.Area; -import java.util.Iterator; /** * @author Mark McKay @@ -59,6 +58,7 @@ { } + @Override public String getTagName() { return TAG_NAME; @@ -68,11 +68,13 @@ * Called after the start element but before the end element to indicate * each child tag that has been processed */ + @Override public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException { super.loaderAddChild(helper, child); } + @Override protected void build() throws SVGException { super.build(); @@ -102,9 +104,8 @@ } Area clipArea = null; - for (Iterator it = children.iterator(); it.hasNext();) - { - ShapeElement se = (ShapeElement) it.next(); + for (SVGElement svgElement : children) { + ShapeElement se = (ShapeElement) svgElement; if (clipArea == null) { @@ -130,11 +131,12 @@ * Updates all attributes in this diagram associated with a time event. Ie, * all attributes with track information. * - * @param curTime + * @param curTime Time at which to evaluate node * @return - true if this node has changed state as a result of the time * update * @throws com.kitfox.svg.SVGException */ + @Override public boolean updateTime(double curTime) throws SVGException { //Get current values for parameters diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/composite/AdobeCompositeContext.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/composite/AdobeCompositeContext.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/composite/AdobeCompositeContext.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/composite/AdobeCompositeContext.java 2022-02-26 23:40:50.000000000 +0000 @@ -52,7 +52,10 @@ float[] rgba_dstIn = new float[4]; float[] rgba_dstOut = new float[4]; - /** Creates a new instance of AdobeCompositeContext */ + /** Creates a new instance of AdobeCompositeContext + * @param compositeType + * @param extraAlpha + */ public AdobeCompositeContext(int compositeType, float extraAlpha) { this.compositeType = compositeType; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/composite/AdobeComposite.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/composite/AdobeComposite.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/composite/AdobeComposite.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/composite/AdobeComposite.java 2022-02-26 23:40:50.000000000 +0000 @@ -55,7 +55,11 @@ final int compositeType; final float extraAlpha; - /** Creates a new instance of AdobeComposite */ + /** + * Creates a new instance of AdobeComposite + * @param compositeType + * @param extraAlpha + */ public AdobeComposite(int compositeType, float extraAlpha) { this.compositeType = compositeType; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Defs.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Defs.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Defs.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Defs.java 2022-02-26 23:40:50.000000000 +0000 @@ -35,7 +35,7 @@ */ package com.kitfox.svg; -import java.util.Iterator; +import com.kitfox.svg.xml.StyleSheet; /** * @author Mark McKay @@ -53,6 +53,7 @@ { } + @Override public String getTagName() { return TAG_NAME; @@ -62,6 +63,7 @@ * Called after the start element but before the end element to indicate * each child tag that has been processed */ + @Override public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException { super.loaderAddChild(helper, child); @@ -69,15 +71,27 @@ // members.add(child); } + @Override public boolean updateTime(double curTime) throws SVGException { boolean stateChange = false; - for (Iterator it = children.iterator(); it.hasNext();) - { - SVGElement ele = (SVGElement) it.next(); + for (SVGElement ele : children) { stateChange = stateChange || ele.updateTime(curTime); } return super.updateTime(curTime) || stateChange; } + + public StyleSheet getStyleSheet() + { + for (int i = 0; i < getNumChildren(); ++i) + { + SVGElement ele = getChild(i); + if (ele instanceof Style) + { + return ((Style)ele).getStyleSheet(); + } + } + return null; + } } diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Desc.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Desc.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Desc.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Desc.java 2022-02-26 23:40:50.000000000 +0000 @@ -54,6 +54,7 @@ { } + @Override public String getTagName() { return TAG_NAME; @@ -62,6 +63,7 @@ /** * Called during load process to add text scanned within a tag */ + @Override public void loaderAddText(SVGLoaderHelper helper, String text) { this.text.append(text); @@ -72,6 +74,7 @@ return text.toString(); } + @Override public boolean updateTime(double curTime) { return false; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Ellipse.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Ellipse.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Ellipse.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Ellipse.java 2022-02-26 23:40:50.000000000 +0000 @@ -62,11 +62,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override protected void build() throws SVGException { super.build(); @@ -96,18 +98,21 @@ ellipse.setFrame(cx - rx, cy - ry, rx * 2f, ry * 2f); } - public void render(Graphics2D g) throws SVGException + @Override + protected void doRender(Graphics2D g) throws SVGException { beginLayer(g); renderShape(g, ellipse); finishLayer(g); } + @Override public Shape getShape() { return shapeToParent(ellipse); } + @Override public Rectangle2D getBoundingBox() throws SVGException { return boundsToParent(includeStrokeInBounds(ellipse.getBounds2D())); @@ -120,6 +125,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { // if (trackManager.getNumTracks() == 0) return false; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FeDistantLight.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FeDistantLight.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FeDistantLight.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FeDistantLight.java 2022-02-26 23:40:50.000000000 +0000 @@ -55,17 +55,18 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override protected void build() throws SVGException { super.build(); StyleAttribute sty = new StyleAttribute(); - String strn; if (getPres(sty.setName("azimuth"))) { @@ -88,6 +89,7 @@ return elevation; } + @Override public boolean updateTime(double curTime) throws SVGException { // if (trackManager.getNumTracks() == 0) return false; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FeGaussianBlur.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FeGaussianBlur.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FeGaussianBlur.java 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FeGaussianBlur.java 2022-02-26 23:40:50.000000000 +0000 @@ -0,0 +1,117 @@ +package com.kitfox.svg; + +import com.kitfox.svg.xml.StyleAttribute; + +import java.awt.Rectangle; +import java.awt.image.ConvolveOp; +import java.awt.image.Kernel; +import java.util.Arrays; +import java.util.List; + +public class FeGaussianBlur extends FilterEffects +{ + public static final String TAG_NAME = "fegaussianblur"; + + private float[] stdDeviation; + private float xCurrent; + private float yCurrent; + private ConvolveOp xBlur; + private ConvolveOp yBlur; + + @Override + public String getTagName() + { + return TAG_NAME; + } + + @Override + protected void build() throws SVGException + { + super.build(); + StyleAttribute sty = new StyleAttribute(); + + stdDeviation = new float[]{0f}; + if (getPres(sty.setName("stdDeviation"))) + { + stdDeviation = sty.getFloatList(); + } + xBlur = null; + yBlur = null; + } + + @Override + public List getOperations(Rectangle inputBounds, float xScale, float yScale) + { + float xSigma = xScale * stdDeviation[0]; + float ySigma = yScale * stdDeviation[Math.min(stdDeviation.length - 1, 1)]; + + return Arrays.asList( + xSigma > 0 + ? getGaussianBlurFilter(inputBounds, xSigma, true) + : null, + ySigma > 0 + ? getGaussianBlurFilter(inputBounds, ySigma, false) + : null + ); + } + + public FilterOp getGaussianBlurFilter(Rectangle inputBounds, float sigma, boolean horizontal) + { + int multiplier = 2; + float radius = 2f * sigma + 1; + int size = (int) Math.ceil(radius * multiplier) + 1; + if (horizontal && (xBlur == null || xCurrent != sigma) + || !horizontal && (yBlur == null || yCurrent != sigma)) + { + if (horizontal) + { + xCurrent = sigma; + } else + { + yCurrent = sigma; + } + float[] data = new float[size]; + + float radius2 = radius * radius; + float twoSigmaSquare = 2.0f * sigma * sigma; + float sigmaRoot = (float) Math.sqrt(twoSigmaSquare * Math.PI); + float total = 0.0f; + + float middle = size / 2f; + for (int i = 0; i < size; i++) + { + float distance = middle - i; + distance *= distance; + + data[i] = distance > radius2 + ? 0 + : (float) Math.exp(-distance / twoSigmaSquare) / sigmaRoot; + total += data[i]; + } + + for (int i = 0; i < data.length; i++) + { + data[i] /= total; + } + + if (horizontal) + { + xBlur = new ConvolveOp(new Kernel(size, 1, data), ConvolveOp.EDGE_NO_OP, null); + } else + { + yBlur = new ConvolveOp(new Kernel(1, size, data), ConvolveOp.EDGE_NO_OP, null); + } + } + + Rectangle dstBounds = new Rectangle(inputBounds); + if (horizontal) + { + dstBounds.grow(size, 0); + } else + { + dstBounds.grow(0, size); + } + + return new FilterOp(horizontal ? xBlur : yBlur, dstBounds); + } +} diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FeLight.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FeLight.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FeLight.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FeLight.java 2022-02-26 23:40:50.000000000 +0000 @@ -51,6 +51,7 @@ { } + @Override public String getTagName() { return TAG_NAME; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FePointLight.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FePointLight.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FePointLight.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FePointLight.java 2022-02-26 23:40:50.000000000 +0000 @@ -56,17 +56,18 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override protected void build() throws SVGException { super.build(); StyleAttribute sty = new StyleAttribute(); - String strn; if (getPres(sty.setName("x"))) { @@ -84,11 +85,13 @@ } } + @Override public float getX() { return x; } + @Override public float getY() { return y; @@ -99,6 +102,7 @@ return z; } + @Override public boolean updateTime(double curTime) throws SVGException { // if (trackManager.getNumTracks() == 0) return false; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FeSpotLight.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FeSpotLight.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FeSpotLight.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FeSpotLight.java 2022-02-26 23:40:50.000000000 +0000 @@ -61,17 +61,18 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override protected void build() throws SVGException { super.build(); StyleAttribute sty = new StyleAttribute(); - String strn; if (getPres(sty.setName("x"))) { @@ -107,11 +108,13 @@ } } + @Override public float getX() { return x; } + @Override public float getY() { return y; @@ -147,6 +150,7 @@ return limitingConeAngle; } + @Override public boolean updateTime(double curTime) throws SVGException { // if (trackManager.getNumTracks() == 0) return false; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FillElement.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FillElement.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FillElement.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FillElement.java 2022-02-26 23:40:50.000000000 +0000 @@ -58,6 +58,7 @@ * @param bounds - bounding box of shape being rendered * @param xform - The current transformation that the shape is being * rendered under. + * @return paint object */ abstract public Paint getPaint(Rectangle2D bounds, AffineTransform xform); } diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FilterEffects.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FilterEffects.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FilterEffects.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FilterEffects.java 2022-02-26 23:40:50.000000000 +0000 @@ -36,14 +36,18 @@ package com.kitfox.svg; import com.kitfox.svg.xml.StyleAttribute; + +import java.awt.Rectangle; +import java.awt.image.BufferedImageOp; import java.net.URI; import java.net.URL; +import java.util.List; /** * @author Mark McKay * @author Mark McKay */ -public class FilterEffects extends SVGElement +public abstract class FilterEffects extends SVGElement { public static final String TAG_NAME = "filtereffects"; @@ -60,7 +64,6 @@ float y = 0f; float width = 1f; float height = 1f; - String result = "defaultFilterName"; URL href = null; /** @@ -70,6 +73,7 @@ { } + @Override public String getTagName() { return TAG_NAME; @@ -79,6 +83,7 @@ * Called after the start element but before the end element to indicate * each child tag that has been processed */ + @Override public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException { super.loaderAddChild(helper, child); @@ -89,13 +94,14 @@ } } + @Override protected void build() throws SVGException { super.build(); - StyleAttribute sty = new StyleAttribute(); - String strn; - /* + /*StyleAttribute sty = new StyleAttribute(); + String strn; + if (getPres(sty.setName("filterUnits"))) { strn = sty.getStringValue().toLowerCase(); @@ -132,6 +138,10 @@ */ } + public List getOperations(Rectangle bounds, float xScale, float yScale) { + return null; + } + public float getX() { return x; @@ -152,6 +162,7 @@ return height; } + @Override public boolean updateTime(double curTime) throws SVGException { // if (trackManager.getNumTracks() == 0) return false; @@ -249,4 +260,14 @@ return stateChange; } + + public static class FilterOp { + public final BufferedImageOp op; + public final Rectangle requiredImageBounds; + + public FilterOp(BufferedImageOp op, Rectangle requiredImageBounds) { + this.op = op; + this.requiredImageBounds = requiredImageBounds; + } + } } diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Filter.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Filter.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Filter.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Filter.java 2022-02-26 23:40:50.000000000 +0000 @@ -61,7 +61,7 @@ float height = 1f; Point2D filterRes = new Point2D.Double(); URL href = null; - final ArrayList filterEffects = new ArrayList(); + final ArrayList filterEffects = new ArrayList<>(); /** * Creates a new instance of FillElement @@ -70,6 +70,7 @@ { } + @Override public String getTagName() { return TAG_NAME; @@ -79,16 +80,18 @@ * Called after the start element but before the end element to indicate * each child tag that has been processed */ + @Override public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException { super.loaderAddChild(helper, child); if (child instanceof FilterEffects) { - filterEffects.add(child); + filterEffects.add((FilterEffects) child); } } + @Override protected void build() throws SVGException { super.build(); @@ -174,6 +177,7 @@ return height; } + @Override public boolean updateTime(double curTime) throws SVGException { // if (trackManager.getNumTracks() == 0) return false; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FontFace.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FontFace.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FontFace.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FontFace.java 2022-02-26 23:40:50.000000000 +0000 @@ -71,11 +71,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override protected void build() throws SVGException { super.build(); @@ -228,6 +230,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) { //Fonts can't change diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Font.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Font.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Font.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Font.java 2022-02-26 23:40:50.000000000 +0000 @@ -58,7 +58,7 @@ int vertAdvY = -1; //Defaults to one 'em'. See font-face FontFace fontFace = null; MissingGlyph missingGlyph = null; - final HashMap glyphs = new HashMap(); + final HashMap glyphs = new HashMap(); /** * Creates a new instance of Font @@ -67,6 +67,7 @@ { } + @Override public String getTagName() { return TAG_NAME; @@ -76,6 +77,7 @@ * Called after the start element but before the end element to indicate * each child tag that has been processed */ + @Override public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException { super.loaderAddChild(helper, child); @@ -92,6 +94,7 @@ } } + @Override public void loaderEndElement(SVGLoaderHelper helper) throws SVGParseException { super.loaderEndElement(helper); @@ -101,6 +104,7 @@ helper.universe.registerFont(this); } + @Override protected void build() throws SVGException { super.build(); @@ -210,6 +214,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { //Fonts can't change diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Glyph.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Glyph.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Glyph.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Glyph.java 2022-02-26 23:40:50.000000000 +0000 @@ -62,11 +62,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override protected void build() throws SVGException { super.build(); @@ -91,6 +93,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { //Fonts can't change diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Gradient.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Gradient.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Gradient.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Gradient.java 2022-02-26 23:40:50.000000000 +0000 @@ -40,6 +40,7 @@ import java.awt.geom.AffineTransform; import java.net.URI; import java.util.ArrayList; +import java.util.Comparator; import java.util.Iterator; import java.util.logging.Level; import java.util.logging.Logger; @@ -61,7 +62,7 @@ protected int gradientUnits = GU_OBJECT_BOUNDING_BOX; //Either this gradient contains a list of stops, or it will take it's // stops from the referenced gradient - ArrayList stops = new ArrayList(); + ArrayList stops = new ArrayList(); URI stopRef = null; protected AffineTransform gradientTransform = null; @@ -76,6 +77,7 @@ { } + @Override public String getTagName() { return TAG_NAME; @@ -85,6 +87,7 @@ * Called after the start element but before the end element to indicate * each child tag that has been processed */ + @Override public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException { super.loaderAddChild(helper, child); @@ -96,6 +99,7 @@ appendStop((Stop) child); } + @Override protected void build() throws SVGException { super.build(); @@ -157,6 +161,41 @@ } } + private void buildStops() + { + ArrayList stopList = new ArrayList(stops); + stopList.sort(new Comparator(){ + public int compare(Stop o1, Stop o2) + { + return Float.compare(o1.offset, o2.offset); + } + }); + + //Remove doubles + for (int i = stopList.size() - 2; i >= 0; --i) + { + if (stopList.get(i + 1).offset == stopList.get(i).offset) + { + stopList.remove(i + 1); + } + } + + + stopFractions = new float[stopList.size()]; + stopColors = new Color[stopList.size()]; + int idx = 0; + for (Stop stop : stopList) + { + int stopColorVal = stop.color.getRGB(); + Color stopColor = new Color((stopColorVal >> 16) & 0xff, (stopColorVal >> 8) & 0xff, stopColorVal & 0xff, clamp((int) (stop.opacity * 255), 0, 255)); + + stopColors[idx] = stopColor; + stopFractions[idx] = stop.offset; + idx++; + } + + } + public float[] getStopFractions() { if (stopRef != null) @@ -170,18 +209,7 @@ return stopFractions; } - stopFractions = new float[stops.size()]; - int idx = 0; - for (Iterator it = stops.iterator(); it.hasNext();) - { - Stop stop = (Stop) it.next(); - float val = stop.offset; - if (idx != 0 && val < stopFractions[idx - 1]) - { - val = stopFractions[idx - 1]; - } - stopFractions[idx++] = val; - } + buildStops(); return stopFractions; } @@ -199,30 +227,22 @@ return stopColors; } - stopColors = new Color[stops.size()]; - int idx = 0; - for (Iterator it = stops.iterator(); it.hasNext();) - { - Stop stop = (Stop) it.next(); - int stopColorVal = stop.color.getRGB(); - Color stopColor = new Color((stopColorVal >> 16) & 0xff, (stopColorVal >> 8) & 0xff, stopColorVal & 0xff, clamp((int) (stop.opacity * 255), 0, 255)); - stopColors[idx++] = stopColor; - } + buildStops(); return stopColors; } - public void setStops(Color[] colors, float[] fractions) - { - if (colors.length != fractions.length) - { - throw new IllegalArgumentException(); - } - - this.stopColors = colors; - this.stopFractions = fractions; - stopRef = null; - } +// public void setStops(Color[] colors, float[] fractions) +// { +// if (colors.length != fractions.length) +// { +// throw new IllegalArgumentException(); +// } +// +// this.stopColors = colors; +// this.stopFractions = fractions; +// stopRef = null; +// } private int clamp(int val, int min, int max) { @@ -254,6 +274,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { // if (trackManager.getNumTracks() == 0) return false; @@ -261,7 +282,6 @@ //Get current values for parameters StyleAttribute sty = new StyleAttribute(); - boolean shapeChange = false; String strn; @@ -334,9 +354,7 @@ } //Check stops, if any - for (Iterator it = stops.iterator(); it.hasNext();) - { - Stop stop = (Stop) it.next(); + for (Stop stop : stops) { if (stop.updateTime(curTime)) { stateChange = true; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Group.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Group.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Group.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Group.java 2022-02-26 23:40:50.000000000 +0000 @@ -65,6 +65,7 @@ { } + @Override public String getTagName() { return TAG_NAME; @@ -74,6 +75,7 @@ * Called after the start element but before the end element to indicate * each child tag that has been processed */ + @Override public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException { super.loaderAddChild(helper, child); @@ -97,7 +99,8 @@ return true; } - void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException + @Override + protected void doPick(Point2D point, boolean boundingBox, List> retVec) throws SVGException { Point2D xPoint = new Point2D.Double(point.getX(), point.getY()); if (xform != null) @@ -112,9 +115,7 @@ } - for (Iterator it = children.iterator(); it.hasNext();) - { - SVGElement ele = (SVGElement) it.next(); + for (SVGElement ele : children) { if (ele instanceof RenderableElement) { RenderableElement rendEle = (RenderableElement) ele; @@ -124,7 +125,8 @@ } } - void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException + @Override + protected void doPick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List> retVec) throws SVGException { if (xform != null) { @@ -133,9 +135,7 @@ } - for (Iterator it = children.iterator(); it.hasNext();) - { - SVGElement ele = (SVGElement) it.next(); + for (SVGElement ele : children) { if (ele instanceof RenderableElement) { RenderableElement rendEle = (RenderableElement) ele; @@ -145,7 +145,8 @@ } } - public void render(Graphics2D g) throws SVGException + @Override + protected void doRender(Graphics2D g) throws SVGException { //Don't process if not visible StyleAttribute styleAttrib = new StyleAttribute(); @@ -168,7 +169,7 @@ beginLayer(g); - Iterator it = children.iterator(); + Iterator it = children.iterator(); // try // { @@ -184,7 +185,7 @@ Shape clip = g.getClip(); while (it.hasNext()) { - SVGElement ele = (SVGElement) it.next(); + SVGElement ele = it.next(); if (ele instanceof RenderableElement) { RenderableElement rendEle = (RenderableElement) ele; @@ -211,6 +212,7 @@ /** * Retrieves the cached bounding box of this group */ + @Override public Shape getShape() { if (cachedShape == null) @@ -224,10 +226,7 @@ { Area retShape = new Area(); - for (Iterator it = children.iterator(); it.hasNext();) - { - SVGElement ele = (SVGElement) it.next(); - + for (SVGElement ele : children) { if (ele instanceof ShapeElement) { ShapeElement shpEle = (ShapeElement) ele; @@ -245,6 +244,7 @@ /** * Retrieves the cached bounding box of this group */ + @Override public Rectangle2D getBoundingBox() throws SVGException { if (boundingBox == null) @@ -258,16 +258,13 @@ /** * Recalculates the bounding box by taking the union of the bounding boxes * of all children. Caches the result. + * @throws com.kitfox.svg.SVGException */ public void calcBoundingBox() throws SVGException { -// Rectangle2D retRect = new Rectangle2D.Float(); Rectangle2D retRect = null; - for (Iterator it = children.iterator(); it.hasNext();) - { - SVGElement ele = (SVGElement) it.next(); - + for (SVGElement ele : children) { if (ele instanceof RenderableElement) { RenderableElement rendEle = (RenderableElement) ele; @@ -303,17 +300,23 @@ boundingBox = boundsToParent(retRect); } + @Override public boolean updateTime(double curTime) throws SVGException { boolean changeState = super.updateTime(curTime); - Iterator it = children.iterator(); + Iterator it = children.iterator(); //Distribute message to all members of this group while (it.hasNext()) { - SVGElement ele = (SVGElement) it.next(); + SVGElement ele = it.next(); boolean updateVal = ele.updateTime(curTime); + if (updateVal && ele instanceof RenderableElement) + { + ((RenderableElement) ele).setBufferImage(null); + } + changeState = changeState || updateVal; //Update our shape if shape aware children change @@ -327,6 +330,11 @@ } } + if (changeState) + { + setBufferImage(null); + } + return changeState; } } diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Hkern.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Hkern.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Hkern.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Hkern.java 2022-02-26 23:40:50.000000000 +0000 @@ -49,11 +49,13 @@ String u2; int k; + @Override public String getTagName() { return TAG_NAME; } + @Override protected void build() throws SVGException { super.build(); @@ -78,6 +80,7 @@ } } + @Override public boolean updateTime(double curTime) throws SVGException { //Fonts can't change diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/ImageSVG.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/ImageSVG.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/ImageSVG.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/ImageSVG.java 2022-02-26 23:40:50.000000000 +0000 @@ -76,11 +76,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override protected void build() throws SVGException { super.build(); @@ -115,7 +117,8 @@ if ("data".equals(src.getScheme())) { imageSrc = new URL(null, src.toASCIIString(), new Handler()); - } else + } + else if (!diagram.getUniverse().isImageDataInlineOnly()) { try { @@ -124,7 +127,6 @@ { Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Could not parse xlink:href " + src, e); -// e.printStackTrace(); imageSrc = null; } } @@ -134,32 +136,33 @@ throw new SVGException(e); } - diagram.getUniverse().registerImage(imageSrc); - - //Set widths if not set - BufferedImage img = diagram.getUniverse().getImage(imageSrc); - if (img == null) + if (imageSrc != null) { - xform = new AffineTransform(); - bounds = new Rectangle2D.Float(); - return; - } + diagram.getUniverse().registerImage(imageSrc); - if (width == 0) - { - width = img.getWidth(); - } - if (height == 0) - { - height = img.getHeight(); - } + //Set widths if not set + BufferedImage img = diagram.getUniverse().getImage(imageSrc); + if (img == null) + { + xform = new AffineTransform(); + bounds = new Rectangle2D.Float(); + return; + } + + if (width == 0) + { + width = img.getWidth(); + } + if (height == 0) + { + height = img.getHeight(); + } - //Determine image xform - xform = new AffineTransform(); -// xform.setToScale(this.width / img.getWidth(), this.height / img.getHeight()); -// xform.translate(this.x, this.y); - xform.translate(this.x, this.y); - xform.scale(this.width / img.getWidth(), this.height / img.getHeight()); + //Determine image xform + xform = new AffineTransform(); + xform.translate(this.x, this.y); + xform.scale(this.width / img.getWidth(), this.height / img.getHeight()); + } bounds = new Rectangle2D.Float(this.x, this.y, this.width, this.height); } @@ -184,7 +187,8 @@ return height; } - void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException + @Override + protected void doPick(Point2D point, boolean boundingBox, List> retVec) throws SVGException { if (getBoundingBox().contains(point)) { @@ -192,7 +196,8 @@ } } - void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException + @Override + protected void doPick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List> retVec) throws SVGException { if (ltw.createTransformedShape(getBoundingBox()).intersects(pickArea)) { @@ -200,7 +205,8 @@ } } - public void render(Graphics2D g) throws SVGException + @Override + protected void doRender(Graphics2D g) throws SVGException { StyleAttribute styleAttrib = new StyleAttribute(); if (getStyle(styleAttrib.setName("visibility"))) @@ -250,7 +256,7 @@ AffineTransform curXform = g.getTransform(); g.transform(xform); - g.drawImage(img, 0, 0, null); + g.drawImage(img, 0, 0, diagram.getCurrentRenderTarget()); g.setTransform(curXform); if (oldComp != null) @@ -261,6 +267,7 @@ finishLayer(g); } + @Override public Rectangle2D getBoundingBox() { return boundsToParent(bounds); @@ -273,6 +280,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { // if (trackManager.getNumTracks() == 0) return false; @@ -328,16 +336,16 @@ { URI src = sty.getURIValue(getXMLBase()); - URL newVal; + URL newVal = null; if ("data".equals(src.getScheme())) { newVal = new URL(null, src.toASCIIString(), new Handler()); - } else + } else if (!diagram.getUniverse().isImageDataInlineOnly()) { newVal = src.toURL(); } - if (!newVal.equals(imageSrc)) + if (newVal != null && !newVal.equals(imageSrc)) { imageSrc = newVal; shapeChange = true; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/LinearGradient.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/LinearGradient.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/LinearGradient.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/LinearGradient.java 2022-02-26 23:40:50.000000000 +0000 @@ -64,11 +64,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override protected void build() throws SVGException { super.build(); @@ -96,6 +98,7 @@ } } + @Override public Paint getPaint(Rectangle2D bounds, AffineTransform xform) { MultipleGradientPaint.CycleMethod method; @@ -167,6 +170,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { // if (trackManager.getNumTracks() == 0) return stopChange; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Line.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Line.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Line.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Line.java 2022-02-26 23:40:50.000000000 +0000 @@ -62,11 +62,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override protected void build() throws SVGException { super.build(); @@ -96,18 +98,21 @@ line = new Line2D.Float(x1, y1, x2, y2); } - public void render(Graphics2D g) throws SVGException + @Override + protected void doRender(Graphics2D g) throws SVGException { beginLayer(g); renderShape(g, line); finishLayer(g); } + @Override public Shape getShape() { return shapeToParent(line); } + @Override public Rectangle2D getBoundingBox() throws SVGException { return boundsToParent(includeStrokeInBounds(line.getBounds2D())); @@ -120,6 +125,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { // if (trackManager.getNumTracks() == 0) return false; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Marker.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Marker.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Marker.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Marker.java 2022-02-26 23:40:50.000000000 +0000 @@ -60,11 +60,13 @@ float orient = Float.NaN; boolean markerUnitsStrokeWidth = true; //if set to false 'userSpaceOnUse' is assumed + @Override public String getTagName() { return TAG_NAME; } + @Override protected void build() throws SVGException { super.build(); @@ -130,6 +132,7 @@ markerXform.translate(-refX, -refY); } + @Override protected boolean outsideClip(Graphics2D g) throws SVGException { Shape clip = g.getClip(); @@ -143,12 +146,13 @@ } - public void render(Graphics2D g) throws SVGException + @Override + protected void doRender(Graphics2D g) throws SVGException { AffineTransform oldXform = g.getTransform(); g.transform(markerXform); - super.render(g); + super.doRender(g); g.setTransform(oldXform); } @@ -167,17 +171,19 @@ g.transform(markerXform); - super.render(g); + super.doRender(g); g.setTransform(cacheXform); } + @Override public Shape getShape() { Shape shape = super.getShape(); return markerXform.createTransformedShape(shape); } + @Override public Rectangle2D getBoundingBox() throws SVGException { Rectangle2D rect = super.getBoundingBox(); @@ -191,6 +197,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { boolean changeState = super.updateTime(curTime); @@ -228,7 +235,7 @@ public static class MarkerLayout { - private ArrayList markerList = new ArrayList(); + private ArrayList markerList = new ArrayList(); boolean started = false; public void layout(Shape shape) @@ -361,7 +368,7 @@ /** * @return the markerList */ - public ArrayList getMarkerList() + public ArrayList getMarkerList() { return markerList; } diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Mask.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Mask.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Mask.java 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Mask.java 2022-02-26 23:40:50.000000000 +0000 @@ -0,0 +1,212 @@ +/* + * SVG Salamander + * Copyright (c) 2004, Mark McKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Mark McKay can be contacted at mark@kitfox.com. Salamander and other + * projects can be found at http://www.kitfox.com + */ +package com.kitfox.svg; + +import java.awt.Color; +import java.awt.Composite; +import java.awt.CompositeContext; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.RenderingHints; +import java.awt.geom.AffineTransform; +import java.awt.geom.Area; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.Raster; +import java.awt.image.WritableRaster; +import java.util.List; + +/** + * Implements the mask element. + * + * @author Jannis Weis + */ +public class Mask extends Group +{ + public static final String TAG_NAME = "mask"; + + @Override + public String getTagName() { + return TAG_NAME; + } + + @Override + public void render(Graphics2D g) + { + } + + public Composite createMaskComposite() + { + return new MaskComposite(); + } + + @Override + void pick(Point2D point, boolean boundingBox, List> retVec) + { + } + + @Override + void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List> retVec) + { + } + + public void pickElement(Point2D point, boolean boundingBox, + List> retVec, RenderableElement element) throws SVGException + { + if (boundingBox) + { + element.doPick(point, true, retVec); + } else + { + Rectangle pickPoint = new Rectangle((int) point.getX(), (int) point.getY(), 1, 1); + BufferedImage img = BufferPainter.paintToBuffer(null, new AffineTransform(), pickPoint, this, Color.BLACK); + // Only try picking the element if the picked point is visible. + if (luminanceToAlpha(img.getRGB(0, 0)) > 0) + { + element.doPick(point, false, retVec); + } + } + } + + public void pickElement(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, + List> retVec, RenderableElement element) throws SVGException + { + // If at any point the considered picking area becomes empty we break out early. + if (pickArea.isEmpty()) return; + if (boundingBox) + { + element.doPick(pickArea, ltw,true, retVec); + } else + { + // Clip with the element bounds to avoid creating a larger buffer than needed. + Area transformedBounds = new Area(ltw.createTransformedShape(element.getBoundingBox())); + transformedBounds.intersect(new Area(pickArea)); + if (transformedBounds.isEmpty()) return; + + Rectangle pickRect = transformedBounds.getBounds(); + if (pickRect.isEmpty()) return; + + BufferedImage maskArea = BufferPainter.paintToBuffer(null, ltw, pickRect,this, Color.BLACK); + + // Pick if any pixel in the pick area is visible. + if (hasVisiblePixel(maskArea)) + { + element.doPick(pickArea, ltw, false, retVec); + } + } + } + + private boolean hasVisiblePixel(BufferedImage img) + { + Raster raster = img.getRaster(); + int x = raster.getMinX(); + int w = raster.getWidth(); + int y = raster.getMinY(); + int h = raster.getHeight(); + int[] srcPix = raster.getPixels(x, y, w, h, (int[]) null); + boolean hasVisiblePixel = false; + for (int i = 0; i < srcPix.length; i += 4) + { + int sr = srcPix[i]; + int sg = srcPix[i + 1]; + int sb = srcPix[i + 2]; + if (luminanceToAlpha(sr, sg, sb) > 0) + { + hasVisiblePixel = true; + break; + } + } + return hasVisiblePixel; + } + + private static double luminanceToAlpha(int rgb) + { + return luminanceToAlpha((rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, rgb & 0xFF); + } + + private static double luminanceToAlpha(int r, int g, int b) + { + // Assuming 'linearRGB' as the 'color-interpolation' value of the mask. + return 0.2125 * r + 0.7154 * g + 0.0721 * b; + } + + private static class MaskComposite implements Composite, CompositeContext + { + + @Override + public CompositeContext createContext(ColorModel srcColorModel, + ColorModel dstColorModel, RenderingHints hints) + { + return this; + } + + @Override + public void dispose() + { + } + + public void composeRGB(int[] src, int[] dst) + { + int w = src.length; + + for (int i = 0; i < w; i += 4) + { + int sr = src[i]; + int sg = src[i + 1]; + int sb = src[i + 2]; + int da = dst[i + 3]; + double luminance = luminanceToAlpha(sr, sg, sb) / 255d; + da *= luminance; + dst[i + 3] = Math.min(255, Math.max(0, da)); + } + } + + @Override + public void compose(Raster src, Raster dstIn, WritableRaster dstOut) { + assert dstIn == dstOut; + assert src.getNumBands() == dstIn.getNumBands(); + + int x = dstOut.getMinX(); + int w = dstOut.getWidth(); + int y = dstOut.getMinY(); + int h = dstOut.getHeight(); + int[] srcPix = src.getPixels(x, y, w, h, (int[]) null); + int[] dstPix = dstIn.getPixels(x, y, w, h, (int[]) null); + composeRGB(srcPix, dstPix); + dstOut.setPixels(x, y, w, h, dstPix); + } + } +} diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Metadata.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Metadata.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Metadata.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Metadata.java 2022-02-26 23:40:50.000000000 +0000 @@ -52,11 +52,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override public boolean updateTime(double curTime) { return false; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/MissingGlyph.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/MissingGlyph.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/MissingGlyph.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/MissingGlyph.java 2022-02-26 23:40:50.000000000 +0000 @@ -60,10 +60,10 @@ //We may define a path private Shape path = null; //Alternately, we may have child graphical elements - private int horizAdvX = -1; //Inherits font's value if not set - private int vertOriginX = -1; //Inherits font's value if not set - private int vertOriginY = -1; //Inherits font's value if not set - private int vertAdvY = -1; //Inherits font's value if not set + private float horizAdvX = -1; //Inherits font's value if not set + private float vertOriginX = -1; //Inherits font's value if not set + private float vertOriginY = -1; //Inherits font's value if not set + private float vertAdvY = -1; //Inherits font's value if not set /** * Creates a new instance of Font @@ -72,6 +72,7 @@ { } + @Override public String getTagName() { return TAG_NAME; @@ -81,11 +82,13 @@ * Called after the start element but before the end element to indicate * each child tag that has been processed */ + @Override public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException { super.loaderAddChild(helper, child); } + @Override protected void build() throws SVGException { super.build(); @@ -128,22 +131,22 @@ //Read glyph spacing info if (getPres(sty.setName("horiz-adv-x"))) { - horizAdvX = sty.getIntValue(); + horizAdvX = sty.getFloatValue(); } if (getPres(sty.setName("vert-origin-x"))) { - vertOriginX = sty.getIntValue(); + vertOriginX = sty.getFloatValue(); } if (getPres(sty.setName("vert-origin-y"))) { - vertOriginY = sty.getIntValue(); + vertOriginY = sty.getFloatValue(); } if (getPres(sty.setName("vert-adv-y"))) { - vertAdvY = sty.getIntValue(); + vertAdvY = sty.getFloatValue(); } } @@ -152,7 +155,8 @@ return path; } - public void render(Graphics2D g) throws SVGException + @Override + protected void doRender(Graphics2D g) throws SVGException { //Do not push or pop stack @@ -161,10 +165,10 @@ renderShape(g, path); } - Iterator it = children.iterator(); + Iterator it = children.iterator(); while (it.hasNext()) { - SVGElement ele = (SVGElement) it.next(); + SVGElement ele = it.next(); if (ele instanceof RenderableElement) { ((RenderableElement) ele).render(g); @@ -174,7 +178,7 @@ //Do not push or pop stack } - public int getHorizAdvX() + public float getHorizAdvX() { if (horizAdvX == -1) { @@ -183,7 +187,7 @@ return horizAdvX; } - public int getVertOriginX() + public float getVertOriginX() { if (vertOriginX == -1) { @@ -192,7 +196,7 @@ return vertOriginX; } - public int getVertOriginY() + public float getVertOriginY() { if (vertOriginY == -1) { @@ -201,7 +205,7 @@ return vertOriginY; } - public int getVertAdvY() + public float getVertAdvY() { if (vertAdvY == -1) { @@ -211,6 +215,7 @@ } + @Override public Shape getShape() { if (path != null) @@ -220,6 +225,7 @@ return null; } + @Override public Rectangle2D getBoundingBox() throws SVGException { if (path != null) @@ -236,6 +242,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { //Fonts can't change @@ -253,7 +260,7 @@ /** * @param horizAdvX the horizAdvX to set */ - public void setHorizAdvX(int horizAdvX) + public void setHorizAdvX(float horizAdvX) { this.horizAdvX = horizAdvX; } @@ -261,7 +268,7 @@ /** * @param vertOriginX the vertOriginX to set */ - public void setVertOriginX(int vertOriginX) + public void setVertOriginX(float vertOriginX) { this.vertOriginX = vertOriginX; } @@ -269,7 +276,7 @@ /** * @param vertOriginY the vertOriginY to set */ - public void setVertOriginY(int vertOriginY) + public void setVertOriginY(float vertOriginY) { this.vertOriginY = vertOriginY; } @@ -277,7 +284,7 @@ /** * @param vertAdvY the vertAdvY to set */ - public void setVertAdvY(int vertAdvY) + public void setVertAdvY(float vertAdvY) { this.vertAdvY = vertAdvY; } diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Arc.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Arc.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Arc.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Arc.java 2022-02-26 23:40:50.000000000 +0000 @@ -76,6 +76,7 @@ } // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) + @Override public void appendPath(GeneralPath path, BuildHistory hist) { float offx = isRelative ? hist.lastPoint.x : 0f; @@ -90,6 +91,7 @@ hist.setLastKnot(x + offx, y + offy); } + @Override public int getNumKnotsAdded() { return 6; @@ -101,6 +103,8 @@ * indicate if we increase or decrease the angles and the final * point of the arc. * + * @param path The path that the arc will be appended to. + * * @param rx the x radius of the ellipse * @param ry the y radius of the ellipse * @@ -157,6 +161,18 @@ * * AffineTransform.getRotateInstance * (angle, arc.getX()+arc.getWidth()/2, arc.getY()+arc.getHeight()/2); + * + * @param x0 origin of arc in x + * @param y0 origin of arc in y + * @param rx radius of arc in x + * @param ry radius of arc in y + * @param angle number of radians in arc + * @param largeArcFlag + * @param sweepFlag + * @param x ending coordinate of arc in x + * @param y ending coordinate of arc in y + * @return arc shape + * */ public static Arc2D computeArc(double x0, double y0, double rx, double ry, @@ -256,6 +272,7 @@ return arc; } + @Override public String toString() { return "A " + rx + " " + ry diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Cubic.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Cubic.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Cubic.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Cubic.java 2022-02-26 23:40:50.000000000 +0000 @@ -56,6 +56,7 @@ public Cubic() { } + @Override public String toString() { return "C " + k1x + " " + k1y @@ -74,6 +75,7 @@ } // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) + @Override public void appendPath(GeneralPath path, BuildHistory hist) { float offx = isRelative ? hist.lastPoint.x : 0f; @@ -87,6 +89,7 @@ hist.setLastKnot(k2x + offx, k2y + offy); } + @Override public int getNumKnotsAdded() { return 6; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/CubicSmooth.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/CubicSmooth.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/CubicSmooth.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/CubicSmooth.java 2022-02-26 23:40:50.000000000 +0000 @@ -63,6 +63,7 @@ } // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) + @Override public void appendPath(GeneralPath path, BuildHistory hist) { float offx = isRelative ? hist.lastPoint.x : 0f; @@ -81,11 +82,13 @@ hist.setLastKnot(k2x + offx, k2y + offy); } + @Override public int getNumKnotsAdded() { return 6; } + @Override public String toString() { return "S " + k2x + " " + k2y diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Horizontal.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Horizontal.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Horizontal.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Horizontal.java 2022-02-26 23:40:50.000000000 +0000 @@ -51,6 +51,7 @@ public Horizontal() { } + @Override public String toString() { return "H " + x; @@ -63,6 +64,7 @@ // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) + @Override public void appendPath(GeneralPath path, BuildHistory hist) { float offx = isRelative ? hist.lastPoint.x : 0f; @@ -73,6 +75,7 @@ hist.setLastKnot(x + offx, offy); } + @Override public int getNumKnotsAdded() { return 2; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/LineTo.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/LineTo.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/LineTo.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/LineTo.java 2022-02-26 23:40:50.000000000 +0000 @@ -60,6 +60,7 @@ // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) + @Override public void appendPath(GeneralPath path, BuildHistory hist) { float offx = isRelative ? hist.lastPoint.x : 0f; @@ -70,11 +71,13 @@ hist.setLastKnot(x + offx, y + offy); } + @Override public int getNumKnotsAdded() { return 2; } + @Override public String toString() { return "L " + x + " " + y; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/MoveTo.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/MoveTo.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/MoveTo.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/MoveTo.java 2022-02-26 23:40:50.000000000 +0000 @@ -59,6 +59,7 @@ } // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) + @Override public void appendPath(GeneralPath path, BuildHistory hist) { float offx = isRelative ? hist.lastPoint.x : 0f; @@ -70,11 +71,13 @@ hist.setLastKnot(x + offx, y + offy); } + @Override public int getNumKnotsAdded() { return 2; } + @Override public String toString() { return "M " + x + " " + y; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/PathParser.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/PathParser.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/PathParser.java 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/PathParser.java 2022-02-26 23:40:50.000000000 +0000 @@ -0,0 +1,251 @@ +/* + * SVG Salamander + * Copyright (c) 2004, Mark McKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Mark McKay can be contacted at mark@kitfox.com. Salamander and other + * projects can be found at http://www.kitfox.com + * + */ +package com.kitfox.svg.pathcmd; + +import java.util.ArrayList; +import java.util.List; + +/** + * A helper for parsing {@link PathCommand}s. + * + * @author Jannis Weis + */ +public class PathParser +{ + private final String input; + private final int inputLength; + private int index; + private char currentCommand; + + public PathParser(String input) { + this.input = input.trim(); + this.inputLength = this.input.length(); + } + + private boolean isCommandChar(char c) + { + return c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z'; + } + + private boolean isWhiteSpaceOrSeparator(char c) + { + return c <= ' ' || c == ','; + } + + private char peek() + { + return input.charAt(index); + } + + private void consume() + { + index++; + } + + private boolean hasNext() + { + return index < inputLength; + } + + // This only checks for the rough structure of a number as we need to know + // when to separate the next token. + // Explicit parsing is done by Float#parseFloat. + private boolean isValidNumberChar(char c, NumberCharState state) + { + boolean valid = '0' <= c && c <= '9'; + if (valid && state.iteration == 1 && input.charAt(index - 1) == '0') + { + // Break up combined zeros into multiple numbers. + return false; + } + state.signAllowed = state.signAllowed && !valid; + if (state.dotAllowed && !valid) + { + valid = c == '.'; + state.dotAllowed = !valid; + } + if (state.signAllowed && !valid) + { + valid = c == '+' || c == '-'; + state.signAllowed = valid; + } + if (state.exponentAllowed && !valid) + { + // Possible exponent notation. Needs at least one preceding number + valid = c == 'e' || c == 'E'; + state.exponentAllowed = !valid; + state.signAllowed = valid; + } + state.iteration++; + return valid; + } + + private void consumeWhiteSpaceOrSeparator() { + while (hasNext() && isWhiteSpaceOrSeparator(peek())) { + consume(); + } + } + + private float nextFloat() + { + int start = index; + NumberCharState state = new NumberCharState(); + while (hasNext() && isValidNumberChar(peek(), state)) { + consume(); + } + int end = index; + consumeWhiteSpaceOrSeparator(); + String token = input.substring(start, end); + try + { + return Float.parseFloat(token); + } catch (NumberFormatException e) + { + String msg = "Unexpected element while parsing cmd '" + currentCommand + + "' encountered token '" + token + "' rest=" + input.substring(start, Math.min(input.length(), start + 10)) + + " (index=" + index + " in input=" + input + ")"; + throw new IllegalStateException(msg, e); + } + } + + public PathCommand[] parsePathCommand() + { + List commands = new ArrayList<>(); + + currentCommand = 'Z'; + while (hasNext()) + { + char peekChar = peek(); + if (isCommandChar(peekChar)) + { + consume(); + currentCommand = peekChar; + } + consumeWhiteSpaceOrSeparator(); + + PathCommand cmd; + switch (currentCommand) + { + case 'M': + cmd = new MoveTo(false, nextFloat(), nextFloat()); + currentCommand = 'L'; + break; + case 'm': + cmd = new MoveTo(true, nextFloat(), nextFloat()); + currentCommand = 'l'; + break; + case 'L': + cmd = new LineTo(false, nextFloat(), nextFloat()); + break; + case 'l': + cmd = new LineTo(true, nextFloat(), nextFloat()); + break; + case 'H': + cmd = new Horizontal(false, nextFloat()); + break; + case 'h': + cmd = new Horizontal(true, nextFloat()); + break; + case 'V': + cmd = new Vertical(false, nextFloat()); + break; + case 'v': + cmd = new Vertical(true, nextFloat()); + break; + case 'A': + cmd = new Arc(false, nextFloat(), nextFloat(), + nextFloat(), + nextFloat() == 1f, nextFloat() == 1f, + nextFloat(), nextFloat()); + break; + case 'a': + cmd = new Arc(true, nextFloat(), nextFloat(), + nextFloat(), + nextFloat() == 1f, nextFloat() == 1f, + nextFloat(), nextFloat()); + break; + case 'Q': + cmd = new Quadratic(false, nextFloat(), nextFloat(), + nextFloat(), nextFloat()); + break; + case 'q': + cmd = new Quadratic(true, nextFloat(), nextFloat(), + nextFloat(), nextFloat()); + break; + case 'T': + cmd = new QuadraticSmooth(false, nextFloat(), nextFloat()); + break; + case 't': + cmd = new QuadraticSmooth(true, nextFloat(), nextFloat()); + break; + case 'C': + cmd = new Cubic(false, nextFloat(), nextFloat(), + nextFloat(), nextFloat(), + nextFloat(), nextFloat()); + break; + case 'c': + cmd = new Cubic(true, nextFloat(), nextFloat(), + nextFloat(), nextFloat(), + nextFloat(), nextFloat()); + break; + case 'S': + cmd = new CubicSmooth(false, nextFloat(), nextFloat(), + nextFloat(), nextFloat()); + break; + case 's': + cmd = new CubicSmooth(true, nextFloat(), nextFloat(), + nextFloat(), nextFloat()); + break; + case 'Z': + case 'z': + cmd = new Terminal(); + break; + default: + throw new RuntimeException("Invalid path element " + + currentCommand + "(at index=" + index + " in input=" + input + ")"); + } + commands.add(cmd); + } + return commands.toArray(new PathCommand[0]); + } + + private static class NumberCharState + { + int iteration = 0; + boolean dotAllowed = true; + boolean signAllowed = true; + boolean exponentAllowed = true; + } +} diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/PathUtil.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/PathUtil.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/PathUtil.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/PathUtil.java 2022-02-26 23:40:50.000000000 +0000 @@ -52,6 +52,9 @@ /** * Converts a GeneralPath into an SVG representation + * + * @param path The shape to be encoded + * @return A string encoding the path using the SVG path notation */ public static String buildPathString(GeneralPath path) { diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Quadratic.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Quadratic.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Quadratic.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Quadratic.java 2022-02-26 23:40:50.000000000 +0000 @@ -54,6 +54,7 @@ public Quadratic() { } + @Override public String toString() { return "Q " + kx + " " + ky @@ -69,6 +70,7 @@ } // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) + @Override public void appendPath(GeneralPath path, BuildHistory hist) { float offx = isRelative ? hist.lastPoint.x : 0f; @@ -79,6 +81,7 @@ hist.setLastKnot(kx + offx, ky + offy); } + @Override public int getNumKnotsAdded() { return 4; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/QuadraticSmooth.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/QuadraticSmooth.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/QuadraticSmooth.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/QuadraticSmooth.java 2022-02-26 23:40:50.000000000 +0000 @@ -52,6 +52,7 @@ public QuadraticSmooth() { } + @Override public String toString() { return "T " + x + " " + y; @@ -64,6 +65,7 @@ } // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) + @Override public void appendPath(GeneralPath path, BuildHistory hist) { float offx = isRelative ? hist.lastPoint.x : 0f; @@ -82,6 +84,7 @@ hist.setLastKnot(kx, ky); } + @Override public int getNumKnotsAdded() { return 4; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Terminal.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Terminal.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Terminal.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Terminal.java 2022-02-26 23:40:50.000000000 +0000 @@ -51,6 +51,7 @@ public Terminal() { } + @Override public String toString() { return "Z"; @@ -58,6 +59,7 @@ // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) + @Override public void appendPath(GeneralPath path, BuildHistory hist) { path.closePath(); @@ -65,6 +67,7 @@ hist.setLastKnot(hist.startPoint.x, hist.startPoint.y); } + @Override public int getNumKnotsAdded() { return 0; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Vertical.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Vertical.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Vertical.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Vertical.java 2022-02-26 23:40:50.000000000 +0000 @@ -51,6 +51,7 @@ public Vertical() { } + @Override public String toString() { return "V " + y; @@ -62,6 +63,7 @@ } // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) + @Override public void appendPath(GeneralPath path, BuildHistory hist) { float offx = hist.lastPoint.x; @@ -72,6 +74,7 @@ hist.setLastKnot(offx, y + offy); } + @Override public int getNumKnotsAdded() { return 2; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Path.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Path.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Path.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Path.java 2022-02-26 23:40:50.000000000 +0000 @@ -62,11 +62,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override protected void build() throws SVGException { super.build(); @@ -85,18 +87,21 @@ path = buildPath(d, fillRule); } - public void render(Graphics2D g) throws SVGException + @Override + protected void doRender(Graphics2D g) throws SVGException { beginLayer(g); renderShape(g, path); finishLayer(g); } + @Override public Shape getShape() { return shapeToParent(path); } + @Override public Rectangle2D getBoundingBox() throws SVGException { return boundsToParent(includeStrokeInBounds(path.getBounds2D())); @@ -109,6 +114,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { // if (trackManager.getNumTracks() == 0) return false; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/PatternSVG.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/PatternSVG.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/PatternSVG.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/PatternSVG.java 2022-02-26 23:40:50.000000000 +0000 @@ -46,7 +46,6 @@ import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.net.URI; -import java.util.Iterator; import java.util.logging.Level; import java.util.logging.Logger; @@ -76,6 +75,7 @@ { } + @Override public String getTagName() { return TAG_NAME; @@ -85,11 +85,13 @@ * Called after the start element but before the end element to indicate * each child tag that has been processed */ + @Override public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException { super.loaderAddChild(helper, child); } + @Override protected void build() throws SVGException { super.build(); @@ -226,9 +228,7 @@ g.setClip(0, 0, tileWidth, tileHeight); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - for (Iterator it = children.iterator(); it.hasNext();) - { - SVGElement ele = (SVGElement) it.next(); + for (SVGElement ele : children) { if (ele instanceof RenderableElement) { AffineTransform xform = new AffineTransform(); @@ -263,6 +263,7 @@ } } + @Override public Paint getPaint(Rectangle2D bounds, AffineTransform xform) { return texPaint; @@ -275,6 +276,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { //Patterns don't change state diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Polygon.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Polygon.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Polygon.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Polygon.java 2022-02-26 23:40:50.000000000 +0000 @@ -61,11 +61,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override protected void build() throws SVGException { super.build(); @@ -96,18 +98,21 @@ path.closePath(); } - public void render(Graphics2D g) throws SVGException + @Override + protected void doRender(Graphics2D g) throws SVGException { beginLayer(g); renderShape(g, path); finishLayer(g); } + @Override public Shape getShape() { return shapeToParent(path); } + @Override public Rectangle2D getBoundingBox() throws SVGException { return boundsToParent(includeStrokeInBounds(path.getBounds2D())); @@ -120,6 +125,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { // if (trackManager.getNumTracks() == 0) return false; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Polyline.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Polyline.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Polyline.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Polyline.java 2022-02-26 23:40:50.000000000 +0000 @@ -61,11 +61,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override public void build() throws SVGException { super.build(); @@ -95,18 +97,21 @@ } } - public void render(Graphics2D g) throws SVGException + @Override + protected void doRender(Graphics2D g) throws SVGException { beginLayer(g); renderShape(g, path); finishLayer(g); } + @Override public Shape getShape() { return shapeToParent(path); } + @Override public Rectangle2D getBoundingBox() throws SVGException { return boundsToParent(includeStrokeInBounds(path.getBounds2D())); @@ -119,6 +124,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { // if (trackManager.getNumTracks() == 0) return false; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/RadialGradient.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/RadialGradient.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/RadialGradient.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/RadialGradient.java 2022-02-26 23:40:50.000000000 +0000 @@ -36,6 +36,7 @@ package com.kitfox.svg; import com.kitfox.svg.xml.StyleAttribute; +import java.awt.Color; import java.awt.MultipleGradientPaint; import java.awt.Paint; import java.awt.RadialGradientPaint; @@ -65,11 +66,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override protected void build() throws SVGException { super.build(); @@ -105,6 +108,7 @@ } } + @Override public Paint getPaint(Rectangle2D bounds, AffineTransform xform) { MultipleGradientPaint.CycleMethod method; @@ -125,14 +129,22 @@ Paint paint; Point2D.Float pt1 = new Point2D.Float(cx, cy); Point2D.Float pt2 = hasFocus ? new Point2D.Float(fx, fy) : pt1; + float[] stopFractions = getStopFractions(); + Color[] stopColors = getStopColors(); + + //Verify that the stop fractions are valid + { + //for (int i = 0; i < + } + if (gradientUnits == GU_USER_SPACE_ON_USE) { paint = new RadialGradientPaint( pt1, r, pt2, - getStopFractions(), - getStopColors(), + stopFractions, + stopColors, method, MultipleGradientPaint.ColorSpaceType.SRGB, gradientTransform); @@ -148,8 +160,8 @@ pt1, r, pt2, - getStopFractions(), - getStopColors(), + stopFractions, + stopColors, method, MultipleGradientPaint.ColorSpaceType.SRGB, viewXform); @@ -165,6 +177,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { // if (trackManager.getNumTracks() == 0) return false; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Rect.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Rect.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Rect.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Rect.java 2022-02-26 23:40:50.000000000 +0000 @@ -68,6 +68,7 @@ { } + @Override public String getTagName() { return TAG_NAME; @@ -131,6 +132,7 @@ // setBounds(this.x, this.y, this.width, this.height); } */ + @Override protected void build() throws SVGException { super.build(); @@ -199,18 +201,21 @@ } } - public void render(Graphics2D g) throws SVGException + @Override + protected void doRender(Graphics2D g) throws SVGException { beginLayer(g); renderShape(g, rect); finishLayer(g); } + @Override public Shape getShape() { return shapeToParent(rect); } + @Override public Rectangle2D getBoundingBox() throws SVGException { return boundsToParent(includeStrokeInBounds(rect.getBounds2D())); @@ -223,6 +228,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { // if (trackManager.getNumTracks() == 0) return false; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/RenderableElement.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/RenderableElement.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/RenderableElement.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/RenderableElement.java 2022-02-26 23:40:50.000000000 +0000 @@ -3,16 +3,16 @@ * Copyright (c) 2004, Mark McKay * All rights reserved. * - * Redistribution and use in source and binary forms, with or + * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * - * - Redistributions of source code must retain the above + * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials + * disclaimer in the documentation and/or other materials * provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS @@ -26,8 +26,8 @@ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * + * OF THE POSSIBILITY OF SUCH DAMAGE. + * * Mark McKay can be contacted at mark@kitfox.com. Salamander and other * projects can be found at http://www.kitfox.com * @@ -54,12 +54,16 @@ abstract public class RenderableElement extends TransformableElement { AffineTransform cachedXform = null; - + + Mask cachedMask; + Filter filter; Shape cachedClip = null; public static final int VECTOR_EFFECT_NONE = 0; public static final int VECTOR_EFFECT_NON_SCALING_STROKE = 1; int vectorEffect; + private BufferPainter.Cache bufferCache; + /** * Creates a new instance of BoundedElement */ @@ -72,6 +76,17 @@ super(id, parent); } + BufferPainter.Cache getBufferCache() + { + return bufferCache; + } + + void setBufferImage(BufferPainter.Cache bufferCache) + { + this.bufferCache = bufferCache; + } + + @Override protected void build() throws SVGException { super.build(); @@ -91,13 +106,69 @@ { vectorEffect = VECTOR_EFFECT_NONE; } + + cachedMask = getMask(sty); + filter = getFilter(sty); } - abstract public void render(Graphics2D g) throws SVGException; + public void render(Graphics2D g) throws SVGException + { + BufferPainter.paintElement(g, this); + } + + private Mask getMask(StyleAttribute styleAttrib) throws SVGException + { + if (getStyle(styleAttrib.setName("mask"), false) + && !"none".equals(styleAttrib.getStringValue())) { + URI uri = styleAttrib.getURIValue(getXMLBase()); + if (uri == null) { + return null; + } + return (Mask) diagram.getUniverse().getElement(uri); + } + return null; + } - abstract void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException; + private Filter getFilter(StyleAttribute styleAttrib) throws SVGException + { + if (getStyle(styleAttrib.setName("filter"), false) + && !"none".equals(styleAttrib.getStringValue())) { + URI uri = styleAttrib.getURIValue(getXMLBase()); + if (uri == null) { + return null; + } + return (Filter) diagram.getUniverse().getElement(uri); + } + return null; + } + + abstract protected void doRender(Graphics2D g) throws SVGException; + + void pick(Point2D point, boolean boundingBox, List> retVec) throws SVGException + { + if (cachedMask != null) + { + cachedMask.pickElement(point, boundingBox, retVec, this); + } else + { + doPick(point, boundingBox, retVec); + } + } + + protected abstract void doPick(Point2D point, boolean boundingBox, List> retVec) throws SVGException; + + void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List> retVec) throws SVGException + { + if (cachedMask != null) + { + cachedMask.pickElement(pickArea, ltw, boundingBox, retVec, this); + } else + { + doPick(pickArea, ltw, boundingBox, retVec); + } + } - abstract void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException; + protected abstract void doPick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List> retVec) throws SVGException; abstract public Rectangle2D getBoundingBox() throws SVGException; /* @@ -110,6 +181,9 @@ /** * Pushes transform stack, transforms to local coordinates and sets up * clipping mask. + * + * @param g Graphics context + * @throws com.kitfox.svg.SVGException */ protected void beginLayer(Graphics2D g) throws SVGException { @@ -164,6 +238,7 @@ /** * Restores transform and clipping values to the way they were before this * layer was drawn. + * @param g */ protected void finishLayer(Graphics2D g) { diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/ShapeElement.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/ShapeElement.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/ShapeElement.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/ShapeElement.java 2022-02-26 23:40:50.000000000 +0000 @@ -75,7 +75,8 @@ public ShapeElement() { } - abstract public void render(java.awt.Graphics2D g) throws SVGException; + @Override + abstract protected void doRender(java.awt.Graphics2D g) throws SVGException; /* protected void setStrokeWidthScalar(float strokeWidthScalar) @@ -84,7 +85,8 @@ } */ - void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException + @Override + protected void doPick(Point2D point, boolean boundingBox, List> retVec) throws SVGException { // StyleAttribute styleAttrib = new StyleAttribute(); // if (getStyle(styleAttrib.setName("fill")) && getShape().contains(point)) @@ -94,9 +96,10 @@ } } - void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException + @Override + protected void doPick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List> retVec) throws SVGException { - StyleAttribute styleAttrib = new StyleAttribute(); +// StyleAttribute styleAttrib = new StyleAttribute(); // if (getStyle(styleAttrib.setName("fill")) && getShape().contains(point)) if (ltw.createTransformedShape((boundingBox ? getBoundingBox() : getShape())).intersects(pickArea)) { @@ -393,10 +396,10 @@ MarkerLayout layout = new MarkerLayout(); layout.layout(shape); - ArrayList list = layout.getMarkerList(); + ArrayList list = layout.getMarkerList(); for (int i = 0; i < list.size(); ++i) { - MarkerPos pos = (MarkerPos)list.get(i); + MarkerPos pos = list.get(i); switch (pos.type) { diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Stop.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Stop.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Stop.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Stop.java 2022-02-26 23:40:50.000000000 +0000 @@ -57,11 +57,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override protected void build() throws SVGException { super.build(); @@ -104,6 +106,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { // if (trackManager.getNumTracks() == 0) return false; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Style.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Style.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Style.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Style.java 2022-02-26 23:40:50.000000000 +0000 @@ -61,6 +61,7 @@ { } + @Override public String getTagName() { return TAG_NAME; @@ -69,6 +70,7 @@ /** * Called during load process to add text scanned within a tag */ + @Override public void loaderAddText(SVGLoaderHelper helper, String text) { this.text.append(text); @@ -77,6 +79,7 @@ styleSheet = null; } + @Override protected void build() throws SVGException { super.build(); @@ -89,6 +92,7 @@ } } + @Override public boolean updateTime(double curTime) throws SVGException { //Style sheet doesn't change diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGDiagram.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGDiagram.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGDiagram.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGDiagram.java 2022-02-26 23:40:50.000000000 +0000 @@ -3,16 +3,16 @@ * Copyright (c) 2004, Mark McKay * All rights reserved. * - * Redistribution and use in source and binary forms, with or + * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * - * - Redistributions of source code must retain the above + * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials + * disclaimer in the documentation and/or other materials * provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS @@ -26,8 +26,8 @@ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * + * OF THE POSSIBILITY OF SUCH DAMAGE. + * * Mark McKay can be contacted at mark@kitfox.com. Salamander and other * projects can be found at http://www.kitfox.com * @@ -36,6 +36,7 @@ package com.kitfox.svg; +import javax.swing.JComponent; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.geom.AffineTransform; @@ -59,15 +60,16 @@ public class SVGDiagram implements Serializable { public static final long serialVersionUID = 0; - + //Indexes elements within this SVG diagram - final HashMap idMap = new HashMap(); + final HashMap idMap = new HashMap(); SVGRoot root; final SVGUniverse universe; + private JComponent renderTarget; /** - * This is used by the SVGRoot to determine the width of the + * This is used by the SVGRoot to determine the width of the */ private Rectangle deviceViewport = new Rectangle(100, 100); @@ -89,7 +91,11 @@ */ final URI xmlBase; - /** Creates a new instance of SVGDiagram */ + /** + * Creates a new instance of SVGDiagram + * @param xmlBase + * @param universe + */ public SVGDiagram(URI xmlBase, SVGUniverse universe) { this.universe = universe; @@ -97,55 +103,72 @@ this.xmlBase = xmlBase; } + JComponent getCurrentRenderTarget() + { + return renderTarget; + } + + public void render(JComponent c, Graphics2D g) throws SVGException + { + renderTarget = c; + root.renderToViewport(g); + renderTarget = null; + } + /** * Draws this diagram to the passed graphics context + * @param g + * @throws com.kitfox.svg.SVGException */ public void render(Graphics2D g) throws SVGException { - root.renderToViewport(g); + render(null, g); } - + /** * Searches thorough the scene graph for all RenderableElements that have * shapes that contain the passed point. - * + * * For every shape which contains the pick point, a List containing the * path to the node is added to the return list. That is, the result of * SVGElement.getPath() is added for each entry. * + * @param point + * @param retVec * @return the passed in list + * @throws com.kitfox.svg.SVGException */ - public List pick(Point2D point, List retVec) throws SVGException + public List> pick(Point2D point, List> retVec) throws SVGException { return pick(point, false, retVec); } - - public List pick(Point2D point, boolean boundingBox, List retVec) throws SVGException + + public List> pick(Point2D point, boolean boundingBox, List> retVec) throws SVGException { if (retVec == null) { - retVec = new ArrayList(); + retVec = new ArrayList>(); } - + root.pick(point, boundingBox, retVec); - + return retVec; } - public List pick(Rectangle2D pickArea, List retVec) throws SVGException + public List> pick(Rectangle2D pickArea, List> retVec) throws SVGException { return pick(pickArea, false, retVec); } - - public List pick(Rectangle2D pickArea, boolean boundingBox, List retVec) throws SVGException + + public List> pick(Rectangle2D pickArea, boolean boundingBox, List> retVec) throws SVGException { if (retVec == null) { - retVec = new ArrayList(); + retVec = new ArrayList>(); } - + root.pick(pickArea, new AffineTransform(), boundingBox, retVec); - + return retVec; } @@ -169,15 +192,17 @@ if (root == null) return 0; return root.getDeviceWidth(); } - + public float getHeight() { if (root == null) return 0; return root.getDeviceHeight(); } - + /** * Returns the viewing rectangle of this diagram in device coordinates. + * @param rect + * @return */ public Rectangle2D getViewRect(Rectangle2D rect) { @@ -223,6 +248,8 @@ /** * Updates all attributes in this diagram associated with a time event. * Ie, all attributes with track information. + * @param curTime + * @throws com.kitfox.svg.SVGException */ public void updateTime(double curTime) throws SVGException { @@ -239,6 +266,7 @@ * Sets the dimensions of the device being rendered into. This is used by * SVGRoot when its x, y, width or height parameters are specified as * percentages. + * @param deviceViewport */ public void setDeviceViewport(Rectangle deviceViewport) { @@ -250,7 +278,7 @@ root.build(); } catch (SVGException ex) { - Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, + Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Could not build document", ex); } } diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGDisplayPanel.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGDisplayPanel.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGDisplayPanel.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGDisplayPanel.java 2022-02-26 23:40:50.000000000 +0000 @@ -105,6 +105,8 @@ /** * Update this image to reflect the passed time + * @param curTime + * @throws com.kitfox.svg.SVGException */ public void updateTime(double curTime) throws SVGException { @@ -113,6 +115,7 @@ diagram.updateTime(curTime); } + @Override public void paintComponent(Graphics gg) { Graphics2D g = (Graphics2D)gg; @@ -153,6 +156,7 @@ addComponentListener(new java.awt.event.ComponentAdapter() { + @Override public void componentResized(java.awt.event.ComponentEvent evt) { formComponentResized(evt); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGElementException.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGElementException.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGElementException.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGElementException.java 2022-02-26 23:40:50.000000000 +0000 @@ -48,6 +48,7 @@ /** * Creates a new instance of SVGException without detail message. + * @param element */ public SVGElementException(SVGElement element) { @@ -57,6 +58,7 @@ /** * Constructs an instance of SVGException with the specified detail message. + * @param element * @param msg the detail message. */ public SVGElementException(SVGElement element, String msg) diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGElement.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGElement.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGElement.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGElement.java 2022-02-26 23:40:50.000000000 +0000 @@ -38,37 +38,27 @@ import com.kitfox.svg.animation.AnimationElement; import com.kitfox.svg.animation.TrackBase; import com.kitfox.svg.animation.TrackManager; -import com.kitfox.svg.pathcmd.Arc; import com.kitfox.svg.pathcmd.BuildHistory; -import com.kitfox.svg.pathcmd.Cubic; -import com.kitfox.svg.pathcmd.CubicSmooth; -import com.kitfox.svg.pathcmd.Horizontal; -import com.kitfox.svg.pathcmd.LineTo; -import com.kitfox.svg.pathcmd.MoveTo; import com.kitfox.svg.pathcmd.PathCommand; -import com.kitfox.svg.pathcmd.Quadratic; -import com.kitfox.svg.pathcmd.QuadraticSmooth; -import com.kitfox.svg.pathcmd.Terminal; -import com.kitfox.svg.pathcmd.Vertical; +import com.kitfox.svg.pathcmd.PathParser; import com.kitfox.svg.xml.StyleAttribute; import com.kitfox.svg.xml.StyleSheet; import com.kitfox.svg.xml.XMLParseUtil; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + import java.awt.geom.AffineTransform; import java.awt.geom.GeneralPath; import java.io.Serializable; import java.net.URI; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; /** @@ -81,7 +71,7 @@ public static final long serialVersionUID = 0; public static final String SVG_NS = "http://www.w3.org/2000/svg"; protected SVGElement parent = null; - protected final ArrayList children = new ArrayList(); + protected final ArrayList children = new ArrayList(); protected String id = null; /** * CSS class. Used for applying style sheet information. @@ -90,28 +80,12 @@ /** * Styles defined for this elemnt via the style attribute. */ - protected final HashMap inlineStyles = new HashMap(); + protected final HashMap inlineStyles = new HashMap(); /** * Presentation attributes set for this element. Ie, any attribute other * than the style attribute. */ - protected final HashMap presAttribs = new HashMap(); - /** - * A list of presentation attributes to not include in the presentation - * attribute set. - */ - protected static final Set ignorePresAttrib; - - static - { - HashSet set = new HashSet(); -// set.add("id"); -// set.add("class"); -// set.add("style"); -// set.add("xml:base"); - - ignorePresAttrib = Collections.unmodifiableSet(set); - } + protected final HashMap presAttribs = new HashMap(); /** * This element may override the URI we resolve against with an xml:base * attribute. If so, a copy is placed here. Otherwise, we defer to our @@ -159,15 +133,16 @@ { this.parent = parent; } - + /** + * @param retVec * @return an ordered list of nodes from the root of the tree to this node */ - public List getPath(List retVec) + public List getPath(List retVec) { if (retVec == null) { - retVec = new ArrayList(); + retVec = new ArrayList(); } if (parent != null) @@ -185,11 +160,11 @@ * * @return The list containing the children of this group */ - public List getChildren(List retVec) + public List getChildren(List retVec) { if (retVec == null) { - retVec = new ArrayList(); + retVec = new ArrayList(); } retVec.addAll(children); @@ -203,9 +178,7 @@ */ public SVGElement getChild(String id) { - for (Iterator it = children.iterator(); it.hasNext();) - { - SVGElement ele = (SVGElement) it.next(); + for (SVGElement ele : children) { String eleId = ele.getId(); if (eleId != null && eleId.equals(id)) { @@ -219,6 +192,8 @@ /** * Searches children for given element. If found, returns index of child. * Otherwise returns -1. + * @param child + * @return index of child */ public int indexOfChild(SVGElement child) { @@ -228,10 +203,9 @@ /** * Swaps 2 elements in children. * - * @i index of first - * @j index of second - * - * @return true if successful, false otherwise + * @param i index of first child + * @param j index of second child + * @throws com.kitfox.svg.SVGException */ public void swapChildren(int i, int j) throws SVGException { @@ -240,7 +214,7 @@ return; } - Object temp = children.get(i); + SVGElement temp = children.get(i); children.set(i, children.get(j)); children.set(j, temp); build(); @@ -253,6 +227,8 @@ * @param attrs - Attributes of this tag * @param helper - An object passed to all SVG elements involved in this * build process to aid in sharing information. + * @param parent + * @throws org.xml.sax.SAXException */ public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent) throws SAXException { @@ -263,11 +239,12 @@ this.id = attrs.getValue("id"); if (this.id != null && !this.id.equals("")) { + this.id = this.id.intern(); diagram.setElement(this.id, this); } String className = attrs.getValue("class"); - this.cssClass = (className == null || className.equals("")) ? null : className; + this.cssClass = (className == null || className.equals("")) ? null : className.intern(); //docRoot = helper.docRoot; //universe = helper.universe; @@ -275,7 +252,7 @@ String style = attrs.getValue("style"); if (style != null) { - HashMap map = XMLParseUtil.parseStyle(style, inlineStyles); + HashMap map = XMLParseUtil.parseStyle(style, inlineStyles); } String base = attrs.getValue("xml:base"); @@ -294,14 +271,10 @@ int numAttrs = attrs.getLength(); for (int i = 0; i < numAttrs; i++) { - String name = attrs.getQName(i); - if (ignorePresAttrib.contains(name)) - { - continue; - } + String name = attrs.getQName(i).intern(); String value = attrs.getValue(i); - presAttribs.put(name, new StyleAttribute(name, value)); + presAttribs.put(name, new StyleAttribute(name, value == null ? null : value.intern())); } } @@ -365,17 +338,17 @@ } /** - * @return a set of Strings that corespond to CSS attributes on this element + * @return a set of Strings that correspond to CSS attributes on this element */ - public Set getInlineAttributes() + public Set getInlineAttributes() { return inlineStyles.keySet(); } /** - * @return a set of Strings that corespond to XML attributes on this element + * @return a set of Strings that correspond to XML attributes on this element */ - public Set getPresentationAttributes() + public Set getPresentationAttributes() { return presAttribs.keySet(); } @@ -383,6 +356,9 @@ /** * Called after the start element but before the end element to indicate * each child tag that has been processed + * @param helper + * @param child + * @throws com.kitfox.svg.SVGElementException */ public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException { @@ -401,9 +377,7 @@ { this.diagram = diagram; diagram.setElement(id, this); - for (Iterator it = children.iterator(); it.hasNext();) - { - SVGElement ele = (SVGElement) it.next(); + for (SVGElement ele : children) { ele.setDiagram(diagram); } } @@ -420,6 +394,8 @@ /** * Called during load process to add text scanned within a tag + * @param helper + * @param text */ public void loaderAddText(SVGLoaderHelper helper, String text) { @@ -428,6 +404,8 @@ /** * Called to indicate that this tag and the tags it contains have been * completely processed, and that it should finish any load processes. + * @param helper + * @throws com.kitfox.svg.SVGParseException */ public void loaderEndElement(SVGLoaderHelper helper) throws SVGParseException { @@ -444,6 +422,7 @@ /** * Called by internal processes to rebuild the geometry of this node from * it's presentation attributes, style attributes and animated tracks. + * @throws com.kitfox.svg.SVGException */ protected void build() throws SVGException { @@ -489,11 +468,12 @@ { return id; } - LinkedList contexts = new LinkedList(); + LinkedList contexts = new LinkedList(); /** * Hack to allow nodes to temporarily change their parents. The Use tag will * need this so it can alter the attributes that a particular node uses. + * @param context */ protected void pushParentContext(SVGElement context) { @@ -594,6 +574,8 @@ * @param recursive - If true and this object does not contain the named * style attribute, checks attributes of parents back to root until one * found. + * @param evalAnimation + * @return */ public boolean getStyle(StyleAttribute attrib, boolean recursive, boolean evalAnimation) throws SVGException @@ -605,7 +587,7 @@ attrib.setStringValue(styAttr == null ? "" : styAttr.getStringValue()); - //Evalutate coresponding track, if one exists + //Evalutate corresponding track, if one exists if (evalAnimation) { TrackBase track = trackManager.getTrack(styName, AnimationElement.AT_CSS); @@ -628,7 +610,7 @@ attrib.setStringValue(presAttr == null ? "" : presAttr.getStringValue()); - //Evalutate coresponding track, if one exists + //Evalutate corresponding track, if one exists if (evalAnimation) { TrackBase track = trackManager.getTrack(styName, AnimationElement.AT_XML); @@ -675,6 +657,7 @@ } /** + * @param styName * @return the raw style value of this attribute. Does not take the * presentation value or animation into consideration. Used by animations to * determine the base to animate from. @@ -688,19 +671,21 @@ /** * Copies the presentation attribute into the passed one. * + * @param attrib * @return - True if attribute was read successfully + * @throws com.kitfox.svg.SVGException */ public boolean getPres(StyleAttribute attrib) throws SVGException { String presName = attrib.getName(); - //Make sure we have a coresponding presentation attribute + //Make sure we have a corresponding presentation attribute StyleAttribute presAttr = (StyleAttribute) presAttribs.get(presName); //Copy presentation value directly attrib.setStringValue(presAttr == null ? "" : presAttr.getStringValue()); - //Evalutate coresponding track, if one exists + //Evalutate corresponding track, if one exists TrackBase track = trackManager.getTrack(presName, AnimationElement.AT_XML); if (track != null) { @@ -718,6 +703,7 @@ } /** + * @param styName * @return the raw presentation value of this attribute. Ignores any * modifications applied by style attributes or animation. Used by * animations to determine the starting point to animate from @@ -728,9 +714,10 @@ return (StyleAttribute) presAttribs.get(styName); } + private static final Pattern TRANSFORM_PATTERN = Pattern.compile("\\w+\\([^)]*\\)"); static protected AffineTransform parseTransform(String val) throws SVGException { - final Matcher matchExpression = Pattern.compile("\\w+\\([^)]*\\)").matcher(""); + final Matcher matchExpression = TRANSFORM_PATTERN.matcher(""); AffineTransform retXform = new AffineTransform(); @@ -743,9 +730,10 @@ return retXform; } + private static final Pattern WORD_PATTERN = Pattern.compile("([a-zA-Z]+|-?\\d+(\\.\\d+)?([eE]-?\\d+)?|-?\\.\\d+([eE]-?\\d+)?)"); static public AffineTransform parseSingleTransform(String val) throws SVGException { - final Matcher matchWord = Pattern.compile("([a-zA-Z]+|-?\\d+(\\.\\d+)?(e-?\\d+)?|-?\\.\\d+(e-?\\d+)?)").matcher(""); + final Matcher matchWord = WORD_PATTERN.matcher(""); AffineTransform retXform = new AffineTransform(); @@ -758,7 +746,7 @@ String function = matchWord.group().toLowerCase(); - LinkedList termList = new LinkedList(); + LinkedList termList = new LinkedList(); while (matchWord.find()) { termList.add(matchWord.group()); @@ -766,11 +754,11 @@ double[] terms = new double[termList.size()]; - Iterator it = termList.iterator(); + Iterator it = termList.iterator(); int count = 0; while (it.hasNext()) { - terms[count++] = XMLParseUtil.parseDouble((String) it.next()); + terms[count++] = XMLParseUtil.parseDouble(it.next()); } //Calculate transformation @@ -818,128 +806,9 @@ return retXform; } - static protected float nextFloat(LinkedList l) - { - String s = (String) l.removeFirst(); - return Float.parseFloat(s); - } - static protected PathCommand[] parsePathList(String list) { - final Matcher matchPathCmd = Pattern.compile("([MmLlHhVvAaQqTtCcSsZz])|([-+]?((\\d*\\.\\d+)|(\\d+))([eE][-+]?\\d+)?)").matcher(list); - - //Tokenize - LinkedList tokens = new LinkedList(); - while (matchPathCmd.find()) - { - tokens.addLast(matchPathCmd.group()); - } - - - boolean defaultRelative = false; - LinkedList cmdList = new LinkedList(); - char curCmd = 'Z'; - while (tokens.size() != 0) - { - String curToken = (String) tokens.removeFirst(); - char initChar = curToken.charAt(0); - if ((initChar >= 'A' && initChar <= 'Z') || (initChar >= 'a' && initChar <= 'z')) - { - curCmd = initChar; - } else - { - tokens.addFirst(curToken); - } - - PathCommand cmd = null; - - switch (curCmd) - { - case 'M': - cmd = new MoveTo(false, nextFloat(tokens), nextFloat(tokens)); - curCmd = 'L'; - break; - case 'm': - cmd = new MoveTo(true, nextFloat(tokens), nextFloat(tokens)); - curCmd = 'l'; - break; - case 'L': - cmd = new LineTo(false, nextFloat(tokens), nextFloat(tokens)); - break; - case 'l': - cmd = new LineTo(true, nextFloat(tokens), nextFloat(tokens)); - break; - case 'H': - cmd = new Horizontal(false, nextFloat(tokens)); - break; - case 'h': - cmd = new Horizontal(true, nextFloat(tokens)); - break; - case 'V': - cmd = new Vertical(false, nextFloat(tokens)); - break; - case 'v': - cmd = new Vertical(true, nextFloat(tokens)); - break; - case 'A': - cmd = new Arc(false, nextFloat(tokens), nextFloat(tokens), - nextFloat(tokens), - nextFloat(tokens) == 1f, nextFloat(tokens) == 1f, - nextFloat(tokens), nextFloat(tokens)); - break; - case 'a': - cmd = new Arc(true, nextFloat(tokens), nextFloat(tokens), - nextFloat(tokens), - nextFloat(tokens) == 1f, nextFloat(tokens) == 1f, - nextFloat(tokens), nextFloat(tokens)); - break; - case 'Q': - cmd = new Quadratic(false, nextFloat(tokens), nextFloat(tokens), - nextFloat(tokens), nextFloat(tokens)); - break; - case 'q': - cmd = new Quadratic(true, nextFloat(tokens), nextFloat(tokens), - nextFloat(tokens), nextFloat(tokens)); - break; - case 'T': - cmd = new QuadraticSmooth(false, nextFloat(tokens), nextFloat(tokens)); - break; - case 't': - cmd = new QuadraticSmooth(true, nextFloat(tokens), nextFloat(tokens)); - break; - case 'C': - cmd = new Cubic(false, nextFloat(tokens), nextFloat(tokens), - nextFloat(tokens), nextFloat(tokens), - nextFloat(tokens), nextFloat(tokens)); - break; - case 'c': - cmd = new Cubic(true, nextFloat(tokens), nextFloat(tokens), - nextFloat(tokens), nextFloat(tokens), - nextFloat(tokens), nextFloat(tokens)); - break; - case 'S': - cmd = new CubicSmooth(false, nextFloat(tokens), nextFloat(tokens), - nextFloat(tokens), nextFloat(tokens)); - break; - case 's': - cmd = new CubicSmooth(true, nextFloat(tokens), nextFloat(tokens), - nextFloat(tokens), nextFloat(tokens)); - break; - case 'Z': - case 'z': - cmd = new Terminal(); - break; - default: - throw new RuntimeException("Invalid path element"); - } - - cmdList.add(cmd); - defaultRelative = cmd.isRelative; - } - - PathCommand[] retArr = new PathCommand[cmdList.size()]; - cmdList.toArray(retArr); - return retArr; + return new PathParser(list).parsePathCommand(); } static protected GeneralPath buildPath(String text, int windingRule) @@ -970,8 +839,10 @@ * Updates all attributes in this diagram associated with a time event. Ie, * all attributes with track information. * + * @param curTime * @return - true if this node has changed state as a result of the time * update + * @throws com.kitfox.svg.SVGException */ abstract public boolean updateTime(double curTime) throws SVGException; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGLoaderHelper.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGLoaderHelper.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGLoaderHelper.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGLoaderHelper.java 2022-02-26 23:40:50.000000000 +0000 @@ -64,7 +64,12 @@ */ public final AnimTimeParser animTimeParser = new AnimTimeParser(new StringReader("")); - /** Creates a new instance of SVGLoaderHelper */ + /** + * Creates a new instance of SVGLoaderHelper + * @param xmlBase + * @param universe + * @param diagram + */ public SVGLoaderHelper(URI xmlBase, SVGUniverse universe, SVGDiagram diagram) { this.xmlBase = xmlBase; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGLoader.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGLoader.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGLoader.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGLoader.java 2022-02-26 23:40:50.000000000 +0000 @@ -52,11 +52,11 @@ */ public class SVGLoader extends DefaultHandler { - final HashMap nodeClasses = new HashMap(); + final HashMap> nodeClasses = new HashMap>(); //final HashMap attribClasses = new HashMap(); - final LinkedList buildStack = new LinkedList(); + final LinkedList buildStack = new LinkedList(); - final HashSet ignoreClasses = new HashSet(); + final HashSet ignoreClasses = new HashSet(); final SVGLoaderHelper helper; @@ -74,7 +74,11 @@ final boolean verbose; - /** Creates a new instance of SVGLoader */ + /** + * Creates a new instance of SVGLoader + * @param xmlBase + * @param universe + */ public SVGLoader(URI xmlBase, SVGUniverse universe) { this(xmlBase, universe, false); @@ -98,6 +102,7 @@ nodeClasses.put("desc", Desc.class); nodeClasses.put("ellipse", Ellipse.class); nodeClasses.put("filter", Filter.class); + nodeClasses.put(FeGaussianBlur.TAG_NAME, FeGaussianBlur.class); nodeClasses.put("font", Font.class); nodeClasses.put("font-face", FontFace.class); nodeClasses.put("g", Group.class); @@ -107,6 +112,7 @@ nodeClasses.put("line", Line.class); nodeClasses.put("lineargradient", LinearGradient.class); nodeClasses.put("marker", Marker.class); + nodeClasses.put("mask", Mask.class); nodeClasses.put("metadata", Metadata.class); nodeClasses.put("missing-glyph", MissingGlyph.class); nodeClasses.put("path", Path.class); @@ -144,6 +150,7 @@ return sb.toString(); } + @Override public void startDocument() throws SAXException { // System.err.println("Start doc"); @@ -151,11 +158,13 @@ // buildStack.clear(); } + @Override public void endDocument() throws SAXException { // System.err.println("End doc"); } + @Override public void startElement(String namespaceURI, String sName, String qName, Attributes attrs) throws SAXException { if (verbose) @@ -192,7 +201,7 @@ //System.err.println("+" + sName); try { - Class cls = (Class)obj; + Class cls = (Class)obj; SVGElement svgEle = (SVGElement)cls.newInstance(); SVGElement parent = null; @@ -210,6 +219,7 @@ } + @Override public void endElement(String namespaceURI, String sName, String qName) throws SAXException { @@ -264,6 +274,7 @@ } } + @Override public void characters(char buf[], int offset, int len) throws SAXException { @@ -280,6 +291,7 @@ } } + @Override public void processingInstruction(String target, String data) throws SAXException { diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGRoot.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGRoot.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGRoot.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGRoot.java 2022-02-26 23:40:50.000000000 +0000 @@ -39,11 +39,9 @@ import com.kitfox.svg.xml.NumberWithUnits; import com.kitfox.svg.xml.StyleAttribute; import com.kitfox.svg.xml.StyleSheet; -import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.Shape; -import java.awt.Toolkit; import java.awt.geom.AffineTransform; import java.awt.geom.NoninvertibleTransformException; import java.awt.geom.Point2D; @@ -94,11 +92,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override public void build() throws SVGException { super.build(); @@ -164,6 +164,7 @@ return (text.indexOf(find) != -1); } + @Override public SVGRoot getRoot() { return this; @@ -199,8 +200,8 @@ } else if (viewBox != null) { - xx = (float)viewBox.x; - ww = (float)viewBox.width; + xx = viewBox.x; + ww = viewBox.width; width = new NumberWithUnits(ww, NumberWithUnits.UT_PX); x = new NumberWithUnits(xx, NumberWithUnits.UT_PX); } @@ -227,8 +228,8 @@ } else if (viewBox != null) { - yy = (float)viewBox.y; - hh = (float)viewBox.height; + yy = viewBox.y; + hh = viewBox.height; height = new NumberWithUnits(hh, NumberWithUnits.UT_PX); y = new NumberWithUnits(yy, NumberWithUnits.UT_PX); } @@ -242,26 +243,16 @@ } clipRect.setRect(xx, yy, ww, hh); - -// if (viewBox == null) -// { -// viewXform.setToIdentity(); -// } -// else -// { -// //If viewport window is set, we are drawing to entire viewport -// clipRect.setRect(deviceViewport); -// -// viewXform.setToIdentity(); -// viewXform.setToTranslation(deviceViewport.x, deviceViewport.y); -// viewXform.scale(deviceViewport.width, deviceViewport.height); -// viewXform.scale(1 / viewBox.width, 1 / viewBox.height); -// viewXform.translate(-viewBox.x, -viewBox.y); -// } } public void renderToViewport(Graphics2D g) throws SVGException { + render(g); + } + + @Override + protected void doRender(Graphics2D g) throws SVGException + { prepareViewport(); Rectangle targetViewport = g.getClipBounds(); @@ -303,34 +294,42 @@ } else { -// Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); -// targetViewport = new Rectangle(0, 0, size.width, size.height); targetViewport = new Rectangle(deviceViewport); } clipRect.setRect(targetViewport); - if (viewBox == null) - { - viewXform.setToIdentity(); - } - else - { - viewXform.setToIdentity(); - viewXform.setToTranslation(targetViewport.x, targetViewport.y); - viewXform.scale(targetViewport.width, targetViewport.height); - viewXform.scale(1 / viewBox.width, 1 / viewBox.height); - viewXform.translate(-viewBox.x, -viewBox.y); - } + viewXform.setTransform(calcViewportTransform(targetViewport)); AffineTransform cachedXform = g.getTransform(); g.transform(viewXform); - super.render(g); + super.doRender(g); g.setTransform(cachedXform); } - public void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException + public AffineTransform calcViewportTransform(Rectangle targetViewport) + { + AffineTransform xform = new AffineTransform(); + + if (viewBox == null) + { + xform.setToIdentity(); + } + else + { + xform.setToIdentity(); + xform.setToTranslation(targetViewport.x, targetViewport.y); + xform.scale(targetViewport.width, targetViewport.height); + xform.scale(1 / viewBox.width, 1 / viewBox.height); + xform.translate(-viewBox.x, -viewBox.y); + } + + return xform; + } + + @Override + public void doPick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List> retVec) throws SVGException { if (viewXform != null) { @@ -338,10 +337,11 @@ ltw.concatenate(viewXform); } - super.pick(pickArea, ltw, boundingBox, retVec); + super.doPick(pickArea, ltw, boundingBox, retVec); } - public void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException + @Override + public void doPick(Point2D point, boolean boundingBox, List> retVec) throws SVGException { Point2D xPoint = new Point2D.Double(point.getX(), point.getY()); if (viewXform != null) @@ -355,15 +355,17 @@ } } - super.pick(xPoint, boundingBox, retVec); + super.doPick(xPoint, boundingBox, retVec); } + @Override public Shape getShape() { Shape shape = super.getShape(); return viewXform.createTransformedShape(shape); } + @Override public Rectangle2D getBoundingBox() throws SVGException { Rectangle2D bbox = super.getBoundingBox(); @@ -392,6 +394,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { boolean changeState = super.updateTime(curTime); @@ -472,6 +475,10 @@ { return ((Style)ele).getStyleSheet(); } + else if (ele instanceof Defs) + { + return ((Defs)ele).getStyleSheet(); + } } } diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGUniverse.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGUniverse.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGUniverse.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGUniverse.java 2022-02-26 23:40:50.000000000 +0000 @@ -57,12 +57,12 @@ import java.net.URL; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.logging.Level; import java.util.logging.Logger; import java.util.zip.GZIPInputStream; import javax.imageio.ImageIO; import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; @@ -88,20 +88,21 @@ * documents loaded from URLs will reflect their URLs and URIs for documents * initiated from streams will have the scheme svgSalamander. */ - final HashMap loadedDocs = new HashMap(); - final HashMap loadedFonts = new HashMap(); - final HashMap loadedImages = new HashMap(); + final HashMap loadedDocs = new HashMap(); + final HashMap loadedFonts = new HashMap(); + final HashMap> loadedImages = new HashMap>(); public static final String INPUTSTREAM_SCHEME = "svgSalamander"; /** * Current time in this universe. Used for resolving attributes that are * influenced by track information. Time is in milliseconds. Time 0 - * coresponds to the time of 0 in each member diagram. + * corresponds to the time of 0 in each member diagram. */ protected double curTime = 0.0; private boolean verbose = false; - //Cache reader for efficiency - XMLReader cachedReader; + //If true, elements will only load image data that is included using inline data: uris + private boolean imageDataInlineOnly = false; + /** * Creates a new instance of SVGUniverse */ @@ -150,9 +151,7 @@ */ public void updateTime() throws SVGException { - for (Iterator it = loadedDocs.values().iterator(); it.hasNext();) - { - SVGDiagram dia = (SVGDiagram) it.next(); + for (SVGDiagram dia : loadedDocs.values()) { dia.updateTime(curTime); } } @@ -168,9 +167,8 @@ public Font getDefaultFont() { - for (Iterator it = loadedFonts.values().iterator(); it.hasNext();) - { - return (Font) it.next(); + for (Font font : loadedFonts.values()) { + return font; } return null; } @@ -214,7 +212,7 @@ urlIdx++; } - SoftReference ref = new SoftReference(img); + SoftReference ref = new SoftReference(img); loadedImages.put(url, ref); return url; @@ -248,7 +246,7 @@ return; } - SoftReference ref; + SoftReference ref; try { String fileName = imageURL.getFile(); @@ -261,11 +259,11 @@ Graphics2D g = img.createGraphics(); icon.paintIcon(null, g, 0, 0); g.dispose(); - ref = new SoftReference(img); + ref = new SoftReference(img); } else { BufferedImage img = ImageIO.read(imageURL); - ref = new SoftReference(img); + ref = new SoftReference(img); } loadedImages.put(imageURL, ref); } catch (Exception e) @@ -277,7 +275,7 @@ BufferedImage getImage(URL imageURL) { - SoftReference ref = (SoftReference) loadedImages.get(imageURL); + SoftReference ref = (SoftReference) loadedImages.get(imageURL); if (ref == null) { return null; @@ -295,7 +293,7 @@ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Could not load image", e); } - ref = new SoftReference(img); + ref = new SoftReference(img); loadedImages.put(imageURL, ref); } @@ -325,16 +323,45 @@ return null; } + public URI cleanUri(URI uri) + { + String scheme = uri.getScheme(); + String schemeSpecific = uri.getSchemeSpecificPart(); + String frag = uri.getFragment(); + + if (schemeSpecific.startsWith("file:///")) + { + //Work around for URIs of resources obtained by Class.getResource() + schemeSpecific = "file:/" + schemeSpecific.substring(8); + } + else + { + return uri; + } + + try + { + return new URI(scheme, schemeSpecific, frag); + } + catch (URISyntaxException ex) + { + Logger.getLogger(SVGUniverse.class.getName()).log(Level.SEVERE, null, ex); + } + return null; + } + /** * Looks up a href within our universe. If the href refers to a document * that is not loaded, it will be loaded. The URL #target will then be - * checked against the SVG diagram's index and the coresponding element - * returned. If there is no coresponding index, null is returned. + * checked against the SVG diagram's index and the corresponding element + * returned. If there is no corresponding index, null is returned. */ public SVGElement getElement(URI path, boolean loadIfAbsent) { try { + path = cleanUri(path); + //Strip fragment from URI URI xmlBase = new URI(path.getScheme(), path.getSchemeSpecificPart(), null); @@ -393,7 +420,7 @@ { //Workaround for resources stored in jars loaded by Webstart. //http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6753651 - url = SVGUniverse.class.getResource("xmlBase.getPath()"); + url = SVGUniverse.class.getResource(xmlBase.getPath()); } else { @@ -466,7 +493,9 @@ } InputStream is = docRoot.openStream(); - return loadSVG(uri, new InputSource(createDocumentInputStream(is))); + URI result = loadSVG(uri, new InputSource(createDocumentInputStream(is))); + is.close(); + return result; } catch (URISyntaxException ex) { Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, @@ -577,19 +606,26 @@ } } - private XMLReader getXMLReaderCached() throws SAXException, ParserConfigurationException + static ThreadLocal threadSAXParser = new ThreadLocal(); + + private XMLReader getXMLReader() throws SAXException, ParserConfigurationException { - if (cachedReader == null) + SAXParser saxParser = threadSAXParser.get(); + if (saxParser == null) { - SAXParserFactory factory = SAXParserFactory.newInstance(); - factory.setNamespaceAware(true); - cachedReader = factory.newSAXParser().getXMLReader(); + SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); + saxParserFactory.setNamespaceAware(true); + saxParser = saxParserFactory.newSAXParser(); + threadSAXParser.set(saxParser); } - return cachedReader; + return saxParser.getXMLReader(); } protected URI loadSVG(URI xmlBase, InputSource is) { + xmlBase = cleanUri(xmlBase); + + // Use an instance of ourselves as the SAX event handler SVGLoader handler = new SVGLoader(xmlBase, this, verbose); @@ -601,7 +637,7 @@ try { // Parse the input - XMLReader reader = getXMLReaderCached(); + XMLReader reader = getXMLReader(); reader.setEntityResolver( new EntityResolver() { @@ -618,8 +654,8 @@ return xmlBase; } catch (SAXParseException sex) { - System.err.println("Error processing " + xmlBase); - System.err.println(sex.getMessage()); + Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, + "Error processing " + xmlBase, sex); loadedDocs.remove(xmlBase); return null; @@ -636,9 +672,9 @@ * Get list of uris of all loaded documents and subdocuments. * @return */ - public ArrayList getLoadedDocumentURIs() + public ArrayList getLoadedDocumentURIs() { - return new ArrayList(loadedDocs.keySet()); + return new ArrayList(loadedDocs.keySet()); } /** @@ -647,6 +683,7 @@ */ public void removeDocument(URI uri) { + uri = cleanUri(uri); loadedDocs.remove(uri); } @@ -677,4 +714,20 @@ return universe; } + + /** + * @return the imageDataInlineOnly + */ + public boolean isImageDataInlineOnly() + { + return imageDataInlineOnly; + } + + /** + * @param imageDataInlineOnly the imageDataInlineOnly to set + */ + public void setImageDataInlineOnly(boolean imageDataInlineOnly) + { + this.imageDataInlineOnly = imageDataInlineOnly; + } } diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Symbol.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Symbol.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Symbol.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Symbol.java 2022-02-26 23:40:50.000000000 +0000 @@ -60,11 +60,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override protected void build() throws SVGException { super.build(); @@ -93,6 +95,7 @@ viewXform.translate(-viewBox.getX(), -viewBox.getY()); } + @Override protected boolean outsideClip(Graphics2D g) throws SVGException { Shape clip = g.getClip(); @@ -107,22 +110,25 @@ } - public void render(Graphics2D g) throws SVGException + @Override + protected void doRender(Graphics2D g) throws SVGException { AffineTransform oldXform = g.getTransform(); g.transform(viewXform); - super.render(g); + super.doRender(g); g.setTransform(oldXform); } + @Override public Shape getShape() { Shape shape = super.getShape(); return viewXform.createTransformedShape(shape); } + @Override public Rectangle2D getBoundingBox() throws SVGException { Rectangle2D rect = super.getBoundingBox(); @@ -136,6 +142,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { // if (trackManager.getNumTracks() == 0) return false; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Text.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Text.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Text.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Text.java 2022-02-26 23:40:50.000000000 +0000 @@ -3,16 +3,16 @@ * Copyright (c) 2004, Mark McKay * All rights reserved. * - * Redistribution and use in source and binary forms, with or + * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * - * - Redistributions of source code must retain the above + * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials + * disclaimer in the documentation and/or other materials * provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS @@ -26,8 +26,8 @@ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * + * OF THE POSSIBILITY OF SUCH DAMAGE. + * * Mark McKay can be contacted at mark@kitfox.com. Salamander and other * projects can be found at http://www.kitfox.com * @@ -35,43 +35,29 @@ */ package com.kitfox.svg; -import com.kitfox.svg.util.FontSystem; +import com.kitfox.svg.util.FontUtil; import com.kitfox.svg.xml.StyleAttribute; -import java.awt.Graphics2D; -import java.awt.Shape; + import java.awt.geom.AffineTransform; -import java.awt.geom.GeneralPath; -import java.awt.geom.Point2D; +import java.awt.geom.Path2D; import java.awt.geom.Rectangle2D; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.regex.Matcher; -import java.util.regex.Pattern; +import java.util.Arrays; +import java.util.List; /** * @author Mark McKay * @author Mark McKay */ -public class Text extends ShapeElement +public class Text extends Tspan { public static final String TAG_NAME = "text"; - - float x = 0; - float y = 0; - AffineTransform transform = null; - String fontFamily; - float fontSize; - //List of strings and tspans containing the content of this node - LinkedList content = new LinkedList(); - Shape textShape; + public static final int TXAN_START = 0; public static final int TXAN_MIDDLE = 1; public static final int TXAN_END = 2; - int textAnchor = TXAN_START; public static final int TXST_NORMAL = 0; public static final int TXST_ITALIC = 1; public static final int TXST_OBLIQUE = 2; - int fontStyle; public static final int TXWE_NORMAL = 0; public static final int TXWE_BOLD = 1; public static final int TXWE_BOLDER = 2; @@ -85,11 +71,9 @@ public static final int TXWE_700 = 10; public static final int TXWE_800 = 11; public static final int TXWE_900 = 12; - int fontWeight; - float textLength = -1; - String lengthAdjust = "spacing"; - + int textAnchor = TXAN_START; + /** * Creates a new instance of Stop */ @@ -97,22 +81,12 @@ { } + @Override public String getTagName() { return TAG_NAME; } - public void appendText(String text) - { - content.addLast(text); - } - - public void appendTspan(Tspan tspan) throws SVGElementException - { - super.loaderAddChild(null, tspan); - content.addLast(tspan); - } - /** * Discard cached information */ @@ -121,119 +95,16 @@ build(); } - public java.util.List getContent() - { - return content; - } - - /** - * Called after the start element but before the end element to indicate - * each child tag that has been processed - */ - public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException + @Override + protected void build() throws SVGException { - super.loaderAddChild(helper, child); - - content.addLast(child); - } - - /** - * Called during load process to add text scanned within a tag - */ - public void loaderAddText(SVGLoaderHelper helper, String text) - { - Matcher matchWs = Pattern.compile("\\s*").matcher(text); - if (!matchWs.matches()) - { - content.addLast(text); - } + super.build(); + buildText(); } - public void build() throws SVGException + protected void buildAttributes(StyleAttribute sty) throws SVGException { - super.build(); - - StyleAttribute sty = new StyleAttribute(); - - if (getPres(sty.setName("x"))) - { - x = sty.getFloatValueWithUnits(); - } - - if (getPres(sty.setName("y"))) - { - y = sty.getFloatValueWithUnits(); - } - - if (getStyle(sty.setName("font-family"))) - { - fontFamily = sty.getStringValue(); - } - else - { - fontFamily = "Sans Serif"; - } - - if (getStyle(sty.setName("font-size"))) - { - fontSize = sty.getFloatValueWithUnits(); - } - else - { - fontSize = 12f; - } - - if (getStyle(sty.setName("textLength"))) - { - textLength = sty.getFloatValueWithUnits(); - } - else - { - textLength = -1; - } - - if (getStyle(sty.setName("lengthAdjust"))) - { - lengthAdjust = sty.getStringValue(); - } - else - { - lengthAdjust = "spacing"; - } - - if (getStyle(sty.setName("font-style"))) - { - String s = sty.getStringValue(); - if ("normal".equals(s)) - { - fontStyle = TXST_NORMAL; - } else if ("italic".equals(s)) - { - fontStyle = TXST_ITALIC; - } else if ("oblique".equals(s)) - { - fontStyle = TXST_OBLIQUE; - } - } else - { - fontStyle = TXST_NORMAL; - } - - if (getStyle(sty.setName("font-weight"))) - { - String s = sty.getStringValue(); - if ("normal".equals(s)) - { - fontWeight = TXWE_NORMAL; - } else if ("bold".equals(s)) - { - fontWeight = TXWE_BOLD; - } - } else - { - fontWeight = TXWE_NORMAL; - } - + super.buildAttributes(sty); if (getStyle(sty.setName("text-anchor"))) { String s = sty.getStringValue(); @@ -251,282 +122,64 @@ { textAnchor = TXAN_START; } + } - //text anchor - //text-decoration - //text-rendering - buildText(); + private void buildText() throws SVGException + { + buildShapeInformation(); + Cursor cursor = createInitialCursor(); + float xInitial = cursor.x; + super.buildTextShape(cursor); + alignSegmentsAtAnchor(fullPath, xInitial); } - protected void buildText() throws SVGException + private void alignSegmentsAtAnchor(Path2D textPath, float xInitial) { - //Get font - String[] families = fontFamily.split(","); - Font font = null; - for (int i = 0; i < families.length; ++i) + AffineTransform tx; + Rectangle2D bounds; + switch (textAnchor) { - font = diagram.getUniverse().getFont(fontFamily); - if (font != null) - { + case TXAN_MIDDLE: + bounds = textPath.getBounds2D(); + tx = AffineTransform.getTranslateInstance( + -(bounds.getX() + bounds.getWidth() / 2.0 - xInitial), 0 + ); + break; + case TXAN_END: + bounds = textPath.getBounds2D(); + tx = AffineTransform.getTranslateInstance( + -(bounds.getX() + bounds.getWidth() - xInitial), 0 + ); + break; + default: + tx = null; break; - } - } - - if (font == null) - { -// System.err.println("Could not load font"); - - font = new FontSystem(fontFamily, fontStyle, fontWeight, (int)fontSize); -// java.awt.Font sysFont = new java.awt.Font(fontFamily, style | weight, (int)fontSize); -// buildSysFont(sysFont); -// return; } - -// font = new java.awt.Font(font.getFamily(), style | weight, font.getSize()); - -// Area textArea = new Area(); - GeneralPath textPath = new GeneralPath(); - textShape = textPath; - - float cursorX = x, cursorY = y; - - FontFace fontFace = font.getFontFace(); - //int unitsPerEm = fontFace.getUnitsPerEm(); -// int ascent = fontFace.getAscent(); -// float fontScale = fontSize / (float) ascent; - -// AffineTransform oldXform = g.getTransform(); -// TextBuilder builder = new TextBuilder(); -// -// for (Iterator it = content.iterator(); it.hasNext();) -// { -// Object obj = it.next(); -// -// if (obj instanceof String) -// { -// String text = (String) obj; -// if (text != null) -// { -// text = text.trim(); -// } -// -// for (int i = 0; i < text.length(); i++) -// { -// String unicode = text.substring(i, i + 1); -// MissingGlyph glyph = font.getGlyph(unicode); -// -// builder.appendGlyph(glyph); -// } -// } -// else if (obj instanceof Tspan) -// { -// Tspan tspan = (Tspan)obj; -// tspan.buildGlyphs(builder); -// } -// } -// -// builder.formatGlyphs(); - - - - - - - - - AffineTransform xform = new AffineTransform(); - - for (Iterator it = content.iterator(); it.hasNext();) + if (tx != null) { - Object obj = it.next(); - - if (obj instanceof String) - { - String text = (String) obj; - if (text != null) - { - text = text.trim(); - } - -// strokeWidthScalar = 1f / fontScale; - - for (int i = 0; i < text.length(); i++) - { - xform.setToIdentity(); - xform.setToTranslation(cursorX, cursorY); -// xform.scale(fontScale, fontScale); -// g.transform(xform); - - String unicode = text.substring(i, i + 1); - MissingGlyph glyph = font.getGlyph(unicode); - - Shape path = glyph.getPath(); - if (path != null) - { - path = xform.createTransformedShape(path); - textPath.append(path, false); - } -// else glyph.render(g); - -// cursorX += fontScale * glyph.getHorizAdvX(); - cursorX += glyph.getHorizAdvX(); - -// g.setTransform(oldXform); - } - - strokeWidthScalar = 1f; - } - else if (obj instanceof Tspan) - { -// Tspan tspan = (Tspan) obj; -// -// xform.setToIdentity(); -// xform.setToTranslation(cursorX, cursorY); -// xform.scale(fontScale, fontScale); -//// tspan.setCursorX(cursorX); -//// tspan.setCursorY(cursorY); -// -// Shape tspanShape = tspan.getShape(); -// tspanShape = xform.createTransformedShape(tspanShape); -// textPath.append(tspanShape, false); -//// tspan.render(g); -//// cursorX = tspan.getCursorX(); -//// cursorY = tspan.getCursorY(); - - - Tspan tspan = (Tspan)obj; - Point2D cursor = new Point2D.Float(cursorX, cursorY); -// tspan.setCursorX(cursorX); -// tspan.setCursorY(cursorY); - tspan.appendToShape(textPath, cursor); -// cursorX = tspan.getCursorX(); -// cursorY = tspan.getCursorY(); - cursorX = (float)cursor.getX(); - cursorY = (float)cursor.getY(); - - } - + fullPath.transform(tx); + textBounds = fullPath.getBounds2D(); + transformSegments(segments, tx); } + } - switch (textAnchor) + private void transformSegments(List segments, AffineTransform transform) + { + for (TextSegment segment : segments) { - case TXAN_MIDDLE: + if (segment.textPath != null) { - AffineTransform at = new AffineTransform(); - at.translate(-textPath.getBounds().getWidth() / 2, 0); - textPath.transform(at); - break; - } - case TXAN_END: + segment.textPath.transform(transform); + } else { - AffineTransform at = new AffineTransform(); - at.translate(-textPath.getBounds().getWidth(), 0); - textPath.transform(at); - break; + segment.element.fullPath.transform(transform); + segment.element.textBounds = segment.element.fullPath.getBounds2D(); + transformSegments(segment.element.segments, transform); } } } -// private void buildSysFont(java.awt.Font font) throws SVGException -// { -// GeneralPath textPath = new GeneralPath(); -// textShape = textPath; -// -// float cursorX = x, cursorY = y; -// -//// FontMetrics fm = g.getFontMetrics(font); -// FontRenderContext frc = new FontRenderContext(null, true, true); -// -//// FontFace fontFace = font.getFontFace(); -// //int unitsPerEm = fontFace.getUnitsPerEm(); -//// int ascent = fm.getAscent(); -//// float fontScale = fontSize / (float)ascent; -// -//// AffineTransform oldXform = g.getTransform(); -// AffineTransform xform = new AffineTransform(); -// -// for (Iterator it = content.iterator(); it.hasNext();) -// { -// Object obj = it.next(); -// -// if (obj instanceof String) -// { -// String text = (String)obj; -// text = text.trim(); -// -// Shape textShape = font.createGlyphVector(frc, text).getOutline(cursorX, cursorY); -// textPath.append(textShape, false); -//// renderShape(g, textShape); -//// g.drawString(text, cursorX, cursorY); -// -// Rectangle2D rect = font.getStringBounds(text, frc); -// cursorX += (float) rect.getWidth(); -// } else if (obj instanceof Tspan) -// { -// /* -// Tspan tspan = (Tspan)obj; -// -// xform.setToIdentity(); -// xform.setToTranslation(cursorX, cursorY); -// -// Shape tspanShape = tspan.getShape(); -// tspanShape = xform.createTransformedShape(tspanShape); -// textArea.add(new Area(tspanShape)); -// -// cursorX += tspanShape.getBounds2D().getWidth(); -// */ -// -// -// Tspan tspan = (Tspan)obj; -// Point2D cursor = new Point2D.Float(cursorX, cursorY); -//// tspan.setCursorX(cursorX); -//// tspan.setCursorY(cursorY); -// tspan.appendToShape(textPath, cursor); -//// cursorX = tspan.getCursorX(); -//// cursorY = tspan.getCursorY(); -// cursorX = (float)cursor.getX(); -// cursorY = (float)cursor.getY(); -// -// } -// } -// -// switch (textAnchor) -// { -// case TXAN_MIDDLE: -// { -// AffineTransform at = new AffineTransform(); -// at.translate(-textPath.getBounds().getWidth() / 2, 0); -// textPath.transform(at); -// break; -// } -// case TXAN_END: -// { -// AffineTransform at = new AffineTransform(); -// at.translate(-Math.ceil(textPath.getBounds().getWidth()), 0); -// textPath.transform(at); -// break; -// } -// } -// } - - public void render(Graphics2D g) throws SVGException - { - beginLayer(g); - renderShape(g, textShape); - finishLayer(g); - } - - public Shape getShape() - { - return shapeToParent(textShape); - } - - public Rectangle2D getBoundingBox() throws SVGException - { - return boundsToParent(includeStrokeInBounds(textShape.getBounds2D())); - } - /** * Updates all attributes in this diagram associated with a time event. Ie, * all attributes with track information. @@ -534,118 +187,28 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { -// if (trackManager.getNumTracks() == 0) return false; boolean changeState = super.updateTime(curTime); //Get current values for parameters - StyleAttribute sty = new StyleAttribute(); - boolean shapeChange = false; - - if (getPres(sty.setName("x"))) - { - float newVal = sty.getFloatValueWithUnits(); - if (newVal != x) - { - x = newVal; - shapeChange = true; - } - } - - if (getPres(sty.setName("y"))) - { - float newVal = sty.getFloatValueWithUnits(); - if (newVal != y) - { - y = newVal; - shapeChange = true; - } - } - - if (getStyle(sty.setName("textLength"))) - { - textLength = sty.getFloatValueWithUnits(); - } - else - { - textLength = -1; - } - - if (getStyle(sty.setName("lengthAdjust"))) - { - lengthAdjust = sty.getStringValue(); - } - else - { - lengthAdjust = "spacing"; - } - - if (getPres(sty.setName("font-family"))) - { - String newVal = sty.getStringValue(); - if (!newVal.equals(fontFamily)) - { - fontFamily = newVal; - shapeChange = true; - } - } - - if (getPres(sty.setName("font-size"))) - { - float newVal = sty.getFloatValueWithUnits(); - if (newVal != fontSize) - { - fontSize = newVal; - shapeChange = true; - } - } - - - if (getStyle(sty.setName("font-style"))) - { - String s = sty.getStringValue(); - int newVal = fontStyle; - if ("normal".equals(s)) - { - newVal = TXST_NORMAL; - } else if ("italic".equals(s)) - { - newVal = TXST_ITALIC; - } else if ("oblique".equals(s)) - { - newVal = TXST_OBLIQUE; - } - if (newVal != fontStyle) - { - fontStyle = newVal; - shapeChange = true; - } - } - - if (getStyle(sty.setName("font-weight"))) - { - String s = sty.getStringValue(); - int newVal = fontWeight; - if ("normal".equals(s)) - { - newVal = TXWE_NORMAL; - } else if ("bold".equals(s)) - { - newVal = TXWE_BOLD; - } - if (newVal != fontWeight) - { - fontWeight = newVal; - shapeChange = true; - } - } + FontUtil.FontInfo fontInfoOld = fontInfo; + float[] xOld = x; + float[] yOld = y; + float[] dxOld = dx; + float[] dyOld = dy; + buildShapeInformation(); + + boolean shapeChange = !fontInfo.equals(fontInfoOld) + || !Arrays.equals(xOld, x) + || !Arrays.equals(yOld, y) + || !Arrays.equals(dxOld, dx) + || !Arrays.equals(dyOld, dy); if (shapeChange) { - build(); -// buildFont(); -// return true; + buildText(); } return changeState || shapeChange; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Title.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Title.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Title.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Title.java 2022-02-26 23:40:50.000000000 +0000 @@ -54,6 +54,7 @@ { } + @Override public String getTagName() { return TAG_NAME; @@ -62,6 +63,7 @@ /** * Called during load process to add text scanned within a tag */ + @Override public void loaderAddText(SVGLoaderHelper helper, String text) { this.text.append(text); @@ -79,6 +81,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { //Title does not change diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/TransformableElement.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/TransformableElement.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/TransformableElement.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/TransformableElement.java 2022-02-26 23:40:50.000000000 +0000 @@ -86,6 +86,7 @@ } */ + @Override protected void build() throws SVGException { super.build(); @@ -109,7 +110,7 @@ protected Rectangle2D boundsToParent(Rectangle2D rect) { - if (xform == null) + if (xform == null || rect == null) { return rect; } @@ -123,6 +124,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { StyleAttribute sty = new StyleAttribute(); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Tspan.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Tspan.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Tspan.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Tspan.java 2022-02-26 23:40:50.000000000 +0000 @@ -35,17 +35,19 @@ */ package com.kitfox.svg; -import com.kitfox.svg.util.FontSystem; +import com.kitfox.svg.util.FontUtil; import com.kitfox.svg.xml.StyleAttribute; import java.awt.Graphics2D; import java.awt.Shape; -import java.awt.font.FontRenderContext; -import java.awt.font.GlyphMetrics; -import java.awt.font.GlyphVector; import java.awt.geom.AffineTransform; import java.awt.geom.GeneralPath; -import java.awt.geom.Point2D; +import java.awt.geom.Path2D; import java.awt.geom.Rectangle2D; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * @author Mark McKay @@ -60,99 +62,101 @@ float[] dx = null; float[] dy = null; float[] rotate = null; - private String text = ""; -// float cursorX; -// float cursorY; -// Shape tspanShape; + float textLength = -1; + String lengthAdjust = "spacing"; + + // List of strings and tspans containing the content of this node + private final List content = new ArrayList<>(); + protected final ArrayList segments = new ArrayList<>(); + protected Rectangle2D textBounds; + protected Path2D fullPath; + + protected FontUtil.FontInfo fontInfo; + private Font font; + /** - * Creates a new instance of Stop + * Creates a new instance of Tspan */ public Tspan() { } + @Override public String getTagName() { return TAG_NAME; } -// public float getCursorX() -// { -// return cursorX; -// } -// -// public float getCursorY() -// { -// return cursorY; -// } -// -// public void setCursorX(float cursorX) -// { -// this.cursorX = cursorX; -// } -// -// public void setCursorY(float cursorY) -// { -// this.cursorY = cursorY; -// } - /* - public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent) - { - //Load style string - super.loaderStartElement(helper, attrs, parent); - - String x = attrs.getValue("x"); - String y = attrs.getValue("y"); - String dx = attrs.getValue("dx"); - String dy = attrs.getValue("dy"); - String rotate = attrs.getValue("rotate"); - - if (x != null) this.x = XMLParseUtil.parseFloatList(x); - if (y != null) this.y = XMLParseUtil.parseFloatList(y); - if (dx != null) this.dx = XMLParseUtil.parseFloatList(dx); - if (dy != null) this.dy = XMLParseUtil.parseFloatList(dy); - if (rotate != null) - { - this.rotate = XMLParseUtil.parseFloatList(rotate); - for (int i = 0; i < this.rotate.length; i++) - this.rotate[i] = (float)Math.toRadians(this.rotate[i]); - } - } + /** + * Called after the start element but before the end element to indicate + * each child tag that has been processed */ + @Override + public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException + { + super.loaderAddChild(helper, child); + + content.add(child); + } /** * Called during load process to add text scanned within a tag */ + @Override public void loaderAddText(SVGLoaderHelper helper, String text) { - this.text += text; + Matcher matchWs = Pattern.compile("\\s*").matcher(text); + if (!matchWs.matches()) + { + content.add(text); + } } - protected void build() throws SVGException + public List getContent() { - super.build(); + return content; + } - StyleAttribute sty = new StyleAttribute(); + /** + * Removes all strings and Tspan elements that are children of this element. + */ + public void clearContent() + { + content.clear(); + } + public void appendText(String text) + { + content.add(text); + } + + public void appendTspan(Tspan tspan) throws SVGElementException + { + super.loaderAddChild(null, tspan); + content.add(tspan); + } + + protected void buildAttributes(StyleAttribute sty) throws SVGException + { if (getPres(sty.setName("x"))) { - x = sty.getFloatList(); + x = sty.getFloatListWithUnits(); } if (getPres(sty.setName("y"))) { - y = sty.getFloatList(); + y = sty.getFloatListWithUnits(); } if (getPres(sty.setName("dx"))) { - dx = sty.getFloatList(); + dx = sty.getFloatListWithUnits(); } if (getPres(sty.setName("dy"))) { - dy = sty.getFloatList(); + dy = sty.getFloatListWithUnits(); } if (getPres(sty.setName("rotate"))) @@ -162,308 +166,168 @@ { rotate[i] = (float) Math.toRadians(this.rotate[i]); } - } - } - public void appendToShape(GeneralPath addShape, Point2D cursor) throws SVGException - { - StyleAttribute sty = new StyleAttribute(); - - String fontFamily = null; - if (getStyle(sty.setName("font-family"))) + if (getStyle(sty.setName("textLength"))) { - fontFamily = sty.getStringValue(); + textLength = sty.getFloatValueWithUnits(); } - - - float fontSize = 12f; - if (getStyle(sty.setName("font-size"))) + else { - fontSize = sty.getFloatValueWithUnits(); + textLength = -1; } - float letterSpacing = 0; - if (getStyle(sty.setName("letter-spacing"))) + if (getStyle(sty.setName("lengthAdjust"))) { - letterSpacing = sty.getFloatValueWithUnits(); + lengthAdjust = sty.getStringValue(); } - - int fontStyle = 0; - if (getStyle(sty.setName("font-style"))) - { - String s = sty.getStringValue(); - if ("normal".equals(s)) - { - fontStyle = Text.TXST_NORMAL; - } else if ("italic".equals(s)) - { - fontStyle = Text.TXST_ITALIC; - } else if ("oblique".equals(s)) - { - fontStyle = Text.TXST_OBLIQUE; - } - } else + else { - fontStyle = Text.TXST_NORMAL; + lengthAdjust = "spacing"; } + } - int fontWeight = 0; - if (getStyle(sty.setName("font-weight"))) - { - String s = sty.getStringValue(); - if ("normal".equals(s)) - { - fontWeight = Text.TXWE_NORMAL; - } else if ("bold".equals(s)) - { - fontWeight = Text.TXWE_BOLD; - } - } else - { - fontWeight = Text.TXWE_NORMAL; - } + protected void buildShapeInformation() throws SVGException + { + StyleAttribute sty = new StyleAttribute(); + buildAttributes(sty); + fontInfo = FontUtil.parseFontInfo(this, sty); + font = FontUtil.getFont(fontInfo, diagram); + } - //Get font - Font font = diagram.getUniverse().getFont(fontFamily); - if (font == null) - { - font = new FontSystem(fontFamily, fontStyle, fontWeight, (int)fontSize); -// addShapeSysFont(addShape, font, fontFamily, fontSize, letterSpacing, cursor); -// return; - } + protected void buildTextShape(Cursor cursor) throws SVGException + { + buildShapeInformation(); - FontFace fontFace = font.getFontFace(); -// int ascent = fontFace.getAscent(); -// float fontScale = fontSize / (float) ascent; + fullPath = new GeneralPath(); - AffineTransform xform = new AffineTransform(); + segments.clear(); + segments.ensureCapacity(content.size()); + int currentCursorOffset = cursor.offset; + cursor.offset = 0; -// strokeWidthScalar = 1f / fontScale; + AffineTransform transform = new AffineTransform(); - float cursorX = (float)cursor.getX(); - float cursorY = (float)cursor.getY(); - -// int i = 0; + float spaceAdvance = font.getGlyph(" ").getHorizAdvX(); - String drawText = this.text; - drawText = drawText.trim(); - for (int i = 0; i < drawText.length(); i++) + for (Serializable obj : content) { - if (x != null && i < x.length) - { - cursorX = x[i]; - } else if (dx != null && i < dx.length) + if (obj instanceof String) { - cursorX += dx[i]; - } - - if (y != null && i < y.length) - { - cursorY = y[i]; - } else if (dy != null && i < dy.length) + String text = ((String) obj); + String trimmed = text.trim(); + if (!text.isEmpty() && text.charAt(0) <= ' ') + cursor.x += font.getGlyph(" ").getHorizAdvX(); + Path2D textPath = createStringSegmentPath(trimmed, font, cursor, transform); + if (!text.isEmpty() && text.charAt(text.length() - 1) <= ' ') + cursor.x += spaceAdvance; + + fullPath.append(textPath, false); + segments.add(new TextSegment(textPath, this)); + } else if (obj instanceof Tspan) { - cursorY += dy[i]; + Tspan tspan = (Tspan) obj; + tspan.buildTextShape(cursor); + fullPath.append(tspan.fullPath, false); + segments.add(new TextSegment(null, (Tspan) obj)); } - // i++; - - xform.setToIdentity(); - xform.setToTranslation(cursorX, cursorY); -// xform.scale(fontScale, fontScale); - if (rotate != null) + } + + textBounds = fullPath.getBounds2D(); + cursor.offset += currentCursorOffset; + } + + private Path2D createStringSegmentPath(String text, Font font, Cursor cursor, AffineTransform xform) + { + Path2D textPath = new GeneralPath(); + + for (int i = 0; i < text.length(); i++) + { + // The positions are specified for the whole recursive content of a span. + // We need to account for any eventual text which occurred before. + cursor.x = getXCursorForIndex(cursor.x, cursor.offset + i); + cursor.y = getYCursorForIndex(cursor.y, cursor.offset + i); + + xform.setToTranslation(cursor.x, cursor.y); + if (rotate != null && cursor.offset + i < rotate.length) { - xform.rotate(rotate[i]); + xform.rotate(rotate[cursor.offset + i]); } - String unicode = drawText.substring(i, i + 1); + String unicode = text.substring(i, i + 1); MissingGlyph glyph = font.getGlyph(unicode); Shape path = glyph.getPath(); if (path != null) { path = xform.createTransformedShape(path); - addShape.append(path, false); + textPath.append(path, false); } - -// cursorX += fontScale * glyph.getHorizAdvX() + letterSpacing; - cursorX += glyph.getHorizAdvX() + letterSpacing; + cursor.x += glyph.getHorizAdvX() + fontInfo.letterSpacing; } + cursor.offset += text.length(); - //Save final draw point so calling method knows where to begin next - // text draw - cursor.setLocation(cursorX, cursorY); strokeWidthScalar = 1f; + return textPath; } -// private void addShapeSysFont(GeneralPath addShape, Font font, -// String fontFamily, float fontSize, float letterSpacing, Point2D cursor) -// { -// -// java.awt.Font sysFont = new java.awt.Font(fontFamily, java.awt.Font.PLAIN, (int) fontSize); -// -// FontRenderContext frc = new FontRenderContext(null, true, true); -// String renderText = this.text.trim(); -// -// AffineTransform xform = new AffineTransform(); -// -// float cursorX = (float)cursor.getX(); -// float cursorY = (float)cursor.getY(); -//// int i = 0; -// for (int i = 0; i < renderText.length(); i++) -// { -// if (x != null && i < x.length) -// { -// cursorX = x[i]; -// } else if (dx != null && i < dx.length) -// { -// cursorX += dx[i]; -// } -// -// if (y != null && i < y.length) -// { -// cursorY = y[i]; -// } else if (dy != null && i < dy.length) -// { -// cursorY += dy[i]; -// } -//// i++; -// -// xform.setToIdentity(); -// xform.setToTranslation(cursorX, cursorY); -// if (rotate != null) -// { -// xform.rotate(rotate[Math.min(i, rotate.length - 1)]); -// } -// -//// String unicode = renderText.substring(i, i + 1); -// GlyphVector textVector = sysFont.createGlyphVector(frc, renderText.substring(i, i + 1)); -// Shape glyphOutline = textVector.getGlyphOutline(0); -// GlyphMetrics glyphMetrics = textVector.getGlyphMetrics(0); -// -// glyphOutline = xform.createTransformedShape(glyphOutline); -// addShape.append(glyphOutline, false); -// -// -//// cursorX += fontScale * glyph.getHorizAdvX() + letterSpacing; -// cursorX += glyphMetrics.getAdvance() + letterSpacing; -// } -// -// cursor.setLocation(cursorX, cursorY); -// } - - public void render(Graphics2D g) throws SVGException - { - float cursorX = 0; - float cursorY = 0; - - if (x != null) - { - cursorX = x[0]; - cursorY = y[0]; - } else if (dx != null) - { - cursorX += dx[0]; - cursorY += dy[0]; - } - - StyleAttribute sty = new StyleAttribute(); + protected Cursor createInitialCursor() + { + return new Cursor(getXCursorForIndex(0, 0), + getYCursorForIndex(0, 0)); + } - String fontFamily = null; - if (getPres(sty.setName("font-family"))) - { - fontFamily = sty.getStringValue(); - } + private float getXCursorForIndex(float current, int index) + { + return getCursorForIndex(current, index, x, dx); + } + private float getYCursorForIndex(float current, int index) + { + return getCursorForIndex(current, index, y, dy); + } - float fontSize = 12f; - if (getPres(sty.setName("font-size"))) + private float getCursorForIndex(float current, int index, float[] absolutes, float[] deltas) + { + if (absolutes != null && index < absolutes.length) { - fontSize = sty.getFloatValueWithUnits(); - } - - //Get font - Font font = diagram.getUniverse().getFont(fontFamily); - if (font == null) + current = absolutes[index]; + } else if (deltas != null && index < deltas.length) { - System.err.println("Could not load font"); - java.awt.Font sysFont = new java.awt.Font(fontFamily, java.awt.Font.PLAIN, (int) fontSize); - renderSysFont(g, sysFont); - return; + current += deltas[index]; } + return current; + } - - FontFace fontFace = font.getFontFace(); - int ascent = fontFace.getAscent(); - float fontScale = fontSize / (float) ascent; - - AffineTransform oldXform = g.getTransform(); - AffineTransform xform = new AffineTransform(); - - strokeWidthScalar = 1f / fontScale; - - int posPtr = 1; - - for (int i = 0; i < text.length(); i++) - { - xform.setToTranslation(cursorX, cursorY); - xform.scale(fontScale, fontScale); - g.transform(xform); - - String unicode = text.substring(i, i + 1); - MissingGlyph glyph = font.getGlyph(unicode); - - Shape path = glyph.getPath(); - if (path != null) + @Override + protected void doRender(Graphics2D g) throws SVGException + { + beginLayer(g); + for (TextSegment segment : segments) { + if (segment.textPath != null) { - renderShape(g, path); + // Text portion of this span. + segment.element.renderShape(g, segment.textPath); } else { - glyph.render(g); - } - - if (x != null && posPtr < x.length) - { - cursorX = x[posPtr]; - cursorY = y[posPtr++]; - } else if (dx != null && posPtr < dx.length) - { - cursorX += dx[posPtr]; - cursorY += dy[posPtr++]; + // Child span. + segment.element.doRender(g); } - - cursorX += fontScale * glyph.getHorizAdvX(); - - g.setTransform(oldXform); } - - strokeWidthScalar = 1f; - } - - protected void renderSysFont(Graphics2D g, java.awt.Font font) throws SVGException - { - float cursorX = 0; - float cursorY = 0; - - int posPtr = 1; - FontRenderContext frc = g.getFontRenderContext(); - - Shape textShape = font.createGlyphVector(frc, text).getOutline(cursorX, cursorY); - renderShape(g, textShape); - Rectangle2D rect = font.getStringBounds(text, frc); - cursorX += (float) rect.getWidth(); + finishLayer(g); } + @Override public Shape getShape() { - return null; - //return shapeToParent(tspanShape); + return shapeToParent(fullPath); } + @Override public Rectangle2D getBoundingBox() { - return null; - //return boundsToParent(tspanShape.getBounds2D()); + return boundsToParent(textBounds); } /** @@ -473,6 +337,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { //Tspan does not change @@ -481,11 +346,50 @@ public String getText() { - return text; + return getText(new StringBuilder()); } - public void setText(String text) + private String getText(StringBuilder builder) { - this.text = text; + for (Serializable serializable : content) + { + if (serializable instanceof Tspan) + { + ((Tspan) serializable).getText(builder); + builder.append(' '); + } else if (serializable != null) + { + builder.append(serializable).append(' '); + } + } + if (builder.length() > 0) + { + // Remove trailing space. + return builder.substring(0, builder.length() - 1); + } else + { + return ""; + } + } + + protected static class TextSegment { + final Path2D textPath; + final Tspan element; + + private TextSegment(Path2D textPath, Tspan element) { + this.textPath = textPath; + this.element = element; + } + } + + protected static class Cursor { + float x; + float y; + int offset; + + public Cursor(float x, float y) { + this.x = x; + this.y = y; + } } } diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Use.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Use.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Use.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Use.java 2022-02-26 23:40:50.000000000 +0000 @@ -65,11 +65,13 @@ { } + @Override public String getTagName() { return TAG_NAME; } + @Override protected void build() throws SVGException { super.build(); @@ -108,7 +110,8 @@ refXform.translate(this.x, this.y); } - public void render(Graphics2D g) throws SVGException + @Override + protected void doRender(Graphics2D g) throws SVGException { beginLayer(g); @@ -133,6 +136,7 @@ finishLayer(g); } + @Override public Shape getShape() { SVGElement ref = diagram.getUniverse().getElement(href); @@ -147,6 +151,7 @@ return null; } + @Override public Rectangle2D getBoundingBox() throws SVGException { SVGElement ref = diagram.getUniverse().getElement(href); @@ -173,6 +178,7 @@ * @return - true if this node has changed state as a result of the time * update */ + @Override public boolean updateTime(double curTime) throws SVGException { // if (trackManager.getNumTracks() == 0) return false; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/util/Base64InputStream.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/util/Base64InputStream.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/util/Base64InputStream.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/util/Base64InputStream.java 2022-02-26 23:40:50.000000000 +0000 @@ -47,7 +47,7 @@ */ public class Base64InputStream extends FilterInputStream implements Base64Consts { - static final HashMap lookup64 = new HashMap(); + static final HashMap lookup64 = new HashMap(); static { byte[] ch = BASE64_CHARS.getBytes(); for (int i = 0; i < ch.length; i++) @@ -65,6 +65,7 @@ super(in); } + @Override public int read(byte[] b, int off, int len) throws IOException { for (int i = 0; i < len; ++i) @@ -80,6 +81,7 @@ } + @Override public int read() throws IOException { if (charsInBuf == 0) diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/util/Base64OutputStream.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/util/Base64OutputStream.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/util/Base64OutputStream.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/util/Base64OutputStream.java 2022-02-26 23:40:50.000000000 +0000 @@ -56,12 +56,14 @@ super(out); } + @Override public void close() throws IOException { writeBits(); super.close(); } + @Override public void write(int b) throws IOException { buf = buf << 8 | (b & 0xff); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/util/FontSystem.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/util/FontSystem.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/util/FontSystem.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/util/FontSystem.java 2022-02-26 23:40:50.000000000 +0000 @@ -39,12 +39,15 @@ import com.kitfox.svg.FontFace; import com.kitfox.svg.Glyph; import com.kitfox.svg.MissingGlyph; -import java.awt.Canvas; -import java.awt.FontMetrics; + +import java.awt.GraphicsEnvironment; import java.awt.font.FontRenderContext; import java.awt.font.GlyphMetrics; import java.awt.font.GlyphVector; +import java.awt.font.LineMetrics; import java.util.HashMap; +import java.util.HashSet; +import java.util.Locale; /** * @@ -53,11 +56,56 @@ public class FontSystem extends Font { java.awt.Font sysFont; - FontMetrics fm; - HashMap glyphCache = new HashMap(); + HashMap glyphCache = new HashMap<>(); + + static HashSet sysFontNames = new HashSet<>(); - public FontSystem(String fontFamily, int fontStyle, int fontWeight, int fontSize) + public static boolean checkIfSystemFontExists(String fontName) + { + if (sysFontNames.isEmpty()) + { + for (String name: GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(Locale.ENGLISH)) + { + sysFontNames.add(name); + } + } + + return sysFontNames.contains(fontName); + } + + public static FontSystem createFont(String[] fontFamilies, int fontStyle, int fontWeight, float fontSize) + { + for (String fontName: fontFamilies) + { + String javaFontName = mapJavaFontName(fontName); + if (checkIfSystemFontExists(javaFontName)) + { + return new FontSystem(javaFontName, fontStyle, fontWeight, fontSize); + } + } + + return null; + } + + private static String mapJavaFontName(String fontName) + { + if ("serif".equals(fontName)) + { + return java.awt.Font.SERIF; + } + else if ("sans-serif".equals(fontName)) + { + return java.awt.Font.SANS_SERIF; + } + else if ("monospace".equals(fontName)) + { + return java.awt.Font.MONOSPACED; + } + return fontName; + } + + private FontSystem(String fontFamily, int fontStyle, int fontWeight, float fontSize) { int style; switch (fontStyle) @@ -81,18 +129,20 @@ weight = java.awt.Font.PLAIN; break; } - sysFont = new java.awt.Font(fontFamily, style | weight, (int) fontSize); - - Canvas c = new Canvas(); - fm = c.getFontMetrics(sysFont); + + sysFont = new java.awt.Font(fontFamily, style | weight, 1).deriveFont(fontSize); + FontRenderContext fontRenderContext = new FontRenderContext(null, true, true); + LineMetrics lineMetrics = sysFont.getLineMetrics("M", fontRenderContext); + FontFace face = new FontFace(); - face.setAscent(fm.getAscent()); - face.setDescent(fm.getDescent()); - face.setUnitsPerEm(fm.charWidth('M')); + face.setAscent((int) lineMetrics.getAscent()); + face.setDescent((int) lineMetrics.getDescent()); + face.setUnitsPerEm((int) sysFont.getStringBounds("M", fontRenderContext).getWidth()); setFontFace(face); } + @Override public MissingGlyph getGlyph(String unicode) { FontRenderContext frc = new FontRenderContext(null, true, true); @@ -105,14 +155,14 @@ glyph.setPath(vec.getGlyphOutline(0)); GlyphMetrics gm = vec.getGlyphMetrics(0); - glyph.setHorizAdvX((int)gm.getAdvanceX()); - glyph.setVertAdvY((int)gm.getAdvanceY()); + glyph.setHorizAdvX(gm.getAdvanceX()); + glyph.setVertAdvY(gm.getAdvanceY()); glyph.setVertOriginX(0); glyph.setVertOriginY(0); glyphCache.put(unicode, glyph); } - + return glyph; } diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/util/FontUtil.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/util/FontUtil.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/util/FontUtil.java 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/util/FontUtil.java 2022-02-26 23:40:50.000000000 +0000 @@ -0,0 +1,181 @@ +/* + * SVG Salamander + * Copyright (c) 2004, Mark McKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Mark McKay can be contacted at mark@kitfox.com. Salamander and other + * projects can be found at http://www.kitfox.com + */ +package com.kitfox.svg.util; + +import com.kitfox.svg.Font; +import com.kitfox.svg.SVGDiagram; +import com.kitfox.svg.SVGElement; +import com.kitfox.svg.SVGException; +import com.kitfox.svg.Text; +import com.kitfox.svg.xml.StyleAttribute; + +import java.util.Arrays; +import java.util.Objects; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Utility class for parsing font information of an {@link SVGElement}. + * + * @author Jannis Weis + */ +public final class FontUtil +{ + + private static final String DEFAULT_FONT_FAMILY = "sans-serif"; + private static final float DEFAULT_FONT_SIZE = 12f; + private static final int DEFAULT_LETTER_SPACING = 0; + private static final int DEFAULT_FONT_STYLE = Text.TXST_NORMAL; + private static final int DEFAULT_FONT_WEIGHT = Text.TXWE_NORMAL; + + private FontUtil() {} + + public final static class FontInfo { + public final String[] families; + public final float size; + public final int style; + public final int weight; + public final float letterSpacing; + + public FontInfo(String[] families, float size, int style, int weight, float letterSpacing) + { + this.families = families; + this.size = size; + this.style = style; + this.weight = weight; + this.letterSpacing = letterSpacing; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (!(o instanceof FontInfo)) return false; + FontInfo fontInfo = (FontInfo) o; + return Float.compare(fontInfo.size, size) == 0 + && style == fontInfo.style && weight == fontInfo.weight + && Float.compare(fontInfo.letterSpacing, letterSpacing) == 0 + && Arrays.equals(families, fontInfo.families); + } + + @Override + public int hashCode() + { + int result = Objects.hash(size, style, weight, letterSpacing); + result = 31 * result + Arrays.hashCode(families); + return result; + } + } + + public static FontInfo parseFontInfo(SVGElement element, StyleAttribute sty) throws SVGException + { + String fontFamily = DEFAULT_FONT_FAMILY; + if (element.getStyle(sty.setName("font-family"))) + { + fontFamily = sty.getStringValue(); + } + + float fontSize = DEFAULT_FONT_SIZE; + if (element.getStyle(sty.setName("font-size"))) + { + fontSize = sty.getFloatValueWithUnits(); + } + + float letterSpacing = DEFAULT_LETTER_SPACING; + if (element.getStyle(sty.setName("letter-spacing"))) + { + letterSpacing = sty.getFloatValueWithUnits(); + } + + int fontStyle = DEFAULT_FONT_STYLE; + if (element.getStyle(sty.setName("font-style"))) + { + String s = sty.getStringValue(); + if ("normal".equals(s)) + { + fontStyle = Text.TXST_NORMAL; + } else if ("italic".equals(s)) + { + fontStyle = Text.TXST_ITALIC; + } else if ("oblique".equals(s)) + { + fontStyle = Text.TXST_OBLIQUE; + } + } + + int fontWeight = DEFAULT_FONT_WEIGHT; + if (element.getStyle(sty.setName("font-weight"))) + { + String s = sty.getStringValue(); + if ("normal".equals(s)) + { + fontWeight = Text.TXWE_NORMAL; + } else if ("bold".equals(s)) + { + fontWeight = Text.TXWE_BOLD; + } + } + + return new FontInfo(fontFamily.split(","), fontSize, fontStyle, fontWeight, letterSpacing); + } + + public static Font getFont(FontInfo info, SVGDiagram diagram) + { + return getFont(info.families, info.style, info.weight, info.size, diagram); + } + + private static Font getFont(String[] families, int fontStyle, int fontWeight, float fontSize, SVGDiagram diagram) + { + Font font = null; + for (String family : families) + { + font = diagram.getUniverse().getFont(family); + if (font != null) break; + } + if (font == null) + { + //Check system fonts + font = FontSystem.createFont(families, fontStyle, fontWeight, fontSize); + } + if (font == null) + { + Logger.getLogger(FontSystem.class.getName()) + .log(Level.WARNING, "Could not create font " + Arrays.toString(families)); + String[] defaultFont = new String[]{ FontUtil.DEFAULT_FONT_FAMILY }; + font = FontSystem.createFont(defaultFont, fontStyle, fontWeight, fontSize); + } + return font; + } + +} diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/ColorTable.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/ColorTable.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/ColorTable.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/ColorTable.java 2022-02-26 23:40:50.000000000 +0000 @@ -48,9 +48,9 @@ public class ColorTable { - static final Map colorTable; + static final Map colorTable; static { - HashMap table = new HashMap(); + HashMap table = new HashMap(); //We really should be interpreting the currentColor keyword as // a reference to the referring node's color, but this quick hack @@ -214,10 +214,7 @@ static public ColorTable instance() { return singleton; } public Color lookupColor(String name) { - Object obj = colorTable.get(name.toLowerCase()); - if (obj == null) return null; - - return (Color)obj; + return colorTable.get(name.toLowerCase()); } public static Color parseColor(String val) diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/cpx/CPXInputStream.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/cpx/CPXInputStream.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/cpx/CPXInputStream.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/cpx/CPXInputStream.java 2022-02-26 23:40:50.000000000 +0000 @@ -74,7 +74,11 @@ byte[] inBuffer = new byte[2048]; byte[] decryptBuffer = new byte[2048]; - /** Creates a new instance of CPXInputStream */ + /** + * Creates a new instance of CPXInputStream + * @param in + * @throws java.io.IOException + */ public CPXInputStream(InputStream in) throws IOException { super(in); @@ -97,6 +101,7 @@ /** * We do not allow marking */ + @Override public boolean markSupported() { return false; } /** @@ -108,6 +113,7 @@ * @exception IOException if an I/O error occurs. * @see java.io.FilterInputStream#in */ + @Override public void close() throws IOException { reachedEOF = true; in.close(); @@ -130,6 +136,7 @@ * @exception IOException if an I/O error occurs. * @see java.io.FilterInputStream#in */ + @Override public int read() throws IOException { final byte[] b = new byte[1]; @@ -158,6 +165,7 @@ * @exception IOException if an I/O error occurs. * @see java.io.FilterInputStream#read(byte[], int, int) */ + @Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); @@ -180,6 +188,7 @@ * @exception IOException if an I/O error occurs. * @see java.io.FilterInputStream#in */ + @Override public int read(byte[] b, int off, int len) throws IOException { if (reachedEOF) return -1; @@ -239,6 +248,7 @@ * Call when inflater indicates that it needs more bytes. * @return - true if we decrypted more bytes to deflate, false if we * encountered the end of stream + * @throws java.io.IOException */ protected boolean decryptChunk() throws IOException { @@ -259,11 +269,13 @@ * should not rely on this to determine the number of bytes that can be * read without blocking. */ + @Override public int available() { return reachedEOF ? 0 : 1; } /** * Skips bytes by reading them into a cached buffer */ + @Override public long skip(long n) throws IOException { int skipSize = (int)n; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/cpx/CPXOutputStream.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/cpx/CPXOutputStream.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/cpx/CPXOutputStream.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/cpx/CPXOutputStream.java 2022-02-26 23:40:50.000000000 +0000 @@ -47,7 +47,11 @@ Deflater deflater = new Deflater(Deflater.BEST_COMPRESSION); - /** Creates a new instance of CPXOutputStream */ + /** + * Creates a new instance of CPXOutputStream + * @param os + * @throws java.io.IOException + */ public CPXOutputStream(OutputStream os) throws IOException { super(os); @@ -67,6 +71,7 @@ * @param b the byte. * @exception IOException if an I/O error occurs. */ + @Override public void write(int b) throws IOException { final byte[] buf = new byte[1]; buf[0] = (byte)b; @@ -89,6 +94,7 @@ * @exception IOException if an I/O error occurs. * @see java.io.FilterOutputStream#write(byte[], int, int) */ + @Override public void write(byte b[]) throws IOException { write(b, 0, b.length); } @@ -115,6 +121,7 @@ * @exception IOException if an I/O error occurs. * @see java.io.FilterOutputStream#write(int) */ + @Override public void write(byte b[], int off, int len) throws IOException { deflater.setInput(b, off, len); @@ -152,6 +159,7 @@ * @exception IOException if an I/O error occurs. * @see java.io.FilterOutputStream#out */ + @Override public void flush() throws IOException { out.flush(); } @@ -168,6 +176,7 @@ * @see java.io.FilterOutputStream#flush() * @see java.io.FilterOutputStream#out */ + @Override public void close() throws IOException { deflater.finish(); processAllData(); diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/NumberWithUnits.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/NumberWithUnits.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/NumberWithUnits.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/NumberWithUnits.java 2022-02-26 23:40:50.000000000 +0000 @@ -122,11 +122,13 @@ } } + @Override public String toString() { return "" + value + unitsAsString(unitType); } + @Override public boolean equals(Object obj) { if (obj == null) { @@ -145,6 +147,7 @@ return true; } + @Override public int hashCode() { int hash = 5; diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/ReadableXMLElement.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/ReadableXMLElement.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/ReadableXMLElement.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/ReadableXMLElement.java 2022-02-26 23:40:50.000000000 +0000 @@ -38,8 +38,6 @@ import org.w3c.dom.*; import java.net.*; -import java.util.*; -import java.lang.reflect.*; /** * @author Mark McKay diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/StyleAttribute.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/StyleAttribute.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/StyleAttribute.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/StyleAttribute.java 2022-02-26 23:40:50.000000000 +0000 @@ -53,8 +53,7 @@ public static final long serialVersionUID = 0; static final Pattern patternUrl = Pattern.compile("\\s*url\\((.*)\\)\\s*"); - static final Matcher matchFpNumUnits = Pattern.compile("\\s*([-+]?((\\d*\\.\\d+)|(\\d+))([-+]?[eE]\\d+)?)\\s*(px|cm|mm|in|pc|pt|em|ex)\\s*").matcher(""); - + static final Pattern patternFpNumUnits = Pattern.compile("\\s*([-+]?((\\d*\\.\\d+)|(\\d+))([-+]?[eE]\\d+)?)\\s*(px|cm|mm|in|pc|pt|em|ex)\\s*"); String name; String stringValue; @@ -140,9 +139,9 @@ } public String getUnits() { - matchFpNumUnits.reset(stringValue); - if (!matchFpNumUnits.matches()) return null; - return matchFpNumUnits.group(6); + Matcher m = patternFpNumUnits.matcher(stringValue); + if (!m.matches()) return null; + return m.group(6); } public NumberWithUnits getNumberWithUnits() { @@ -154,6 +153,18 @@ NumberWithUnits number = getNumberWithUnits(); return convertUnitsToPixels(number.getUnits(), number.getValue()); } + + public float[] getFloatListWithUnits() + { + String[] values = getStringList(); + float[] result = new float[values.length]; + for (int i = 0; i < result.length; i++) + { + NumberWithUnits number = XMLParseUtil.parseNumberWithUnits(stringValue); + result[i] = convertUnitsToPixels(number.getUnits(), number.getValue()); + } + return result; + } static public float convertUnitsToPixels(int unitType, float value) { diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/StyleSheet.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/StyleSheet.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/StyleSheet.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/StyleSheet.java 2022-02-26 23:40:50.000000000 +0000 @@ -15,14 +15,14 @@ */ public class StyleSheet { - HashMap ruleMap = new HashMap(); + HashMap ruleMap = new HashMap(); public static StyleSheet parseSheet(String src) { //Implement CS parser later Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "CSS parser not implemented yet"); - return null; + return new StyleSheet(); } public void addStyleRule(StyleSheetRule rule, String value) diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/StyleSheetRule.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/StyleSheetRule.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/StyleSheetRule.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/StyleSheetRule.java 2022-02-26 23:40:50.000000000 +0000 @@ -21,6 +21,7 @@ this.className = className; } + @Override public int hashCode() { int hash = 7; @@ -30,6 +31,7 @@ return hash; } + @Override public boolean equals(Object obj) { if (obj == null) diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/WritableXMLElement.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/WritableXMLElement.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/WritableXMLElement.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/WritableXMLElement.java 2022-02-26 23:40:50.000000000 +0000 @@ -36,11 +36,6 @@ package com.kitfox.svg.xml; -import org.w3c.dom.*; -import java.net.*; -import java.util.*; -import java.lang.reflect.*; - /** * @author Mark McKay * @author Mark McKay diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java 2022-02-26 23:40:50.000000000 +0000 @@ -52,8 +52,10 @@ */ public class XMLParseUtil { - static final Matcher fpMatch = Pattern.compile("([-+]?((\\d*\\.\\d+)|(\\d+))([eE][+-]?\\d+)?)(\\%|in|cm|mm|pt|pc|px|em|ex)?").matcher(""); - static final Matcher intMatch = Pattern.compile("[-+]?\\d+").matcher(""); + static final Pattern fpPat = Pattern.compile("([-+]?((\\d*\\.\\d+)|(\\d+))([eE][+-]?\\d+)?)(\\%|in|cm|mm|pt|pc|px|em|ex)?"); + static final Pattern intPat = Pattern.compile("[-+]?\\d+"); + static final Pattern quotePat = Pattern.compile("^'|'$"); + /** Creates a new instance of XMLParseUtil */ private XMLParseUtil() @@ -81,7 +83,7 @@ } /** - * Returns the first node that is a direct child of root with the coresponding + * Returns the first node that is a direct child of root with the corresponding * name. Does not search children of children. */ public static Element getFirstChild(Element root, String name) @@ -105,7 +107,7 @@ final Matcher matchWs = Pattern.compile("[^\\s]+").matcher(""); matchWs.reset(list); - LinkedList matchList = new LinkedList(); + LinkedList matchList = new LinkedList(); while (matchWs.find()) { matchList.add(matchWs.group()); @@ -117,8 +119,8 @@ public static boolean isDouble(String val) { - fpMatch.reset(val); - return fpMatch.matches(); + Matcher m = fpPat.matcher(val); + return m.matches(); } public static double parseDouble(String val) @@ -144,10 +146,10 @@ { if (val == null) return 0; - fpMatch.reset(val); + Matcher matcher = fpPat.matcher(val); try { - if (!fpMatch.find()) return 0; + if (!matcher.find()) return 0; } catch (StringIndexOutOfBoundsException e) { @@ -155,7 +157,7 @@ "XMLParseUtil: regex parse problem: '" + val + "'", e); } - val = fpMatch.group(1); + val = matcher.group(1); //System.err.println("Parsing " + val); double retVal = 0; @@ -173,7 +175,7 @@ pixPerInch = 72; } final float inchesPerCm = .3936f; - final String units = fpMatch.group(6); + final String units = matcher.group(6); if ("%".equals(units)) retVal /= 100; else if ("in".equals(units)) @@ -211,18 +213,17 @@ public synchronized static double[] parseDoubleList(String list) { if (list == null) return null; + Matcher matcher = fpPat.matcher(list); - fpMatch.reset(list); - - LinkedList doubList = new LinkedList(); - while (fpMatch.find()) + LinkedList doubList = new LinkedList(); + while (matcher.find()) { - String val = fpMatch.group(1); + String val = matcher.group(1); doubList.add(Double.valueOf(val)); } double[] retArr = new double[doubList.size()]; - Iterator it = doubList.iterator(); + Iterator it = doubList.iterator(); int idx = 0; while (it.hasNext()) { @@ -254,18 +255,17 @@ public synchronized static float findFloat(String val) { if (val == null) return 0f; + Matcher matcher = fpPat.matcher(val); + if (!matcher.find()) return 0f; - fpMatch.reset(val); - if (!fpMatch.find()) return 0f; - - val = fpMatch.group(1); + val = matcher.group(1); //System.err.println("Parsing " + val); float retVal = 0f; try { retVal = Float.parseFloat(val); - String units = fpMatch.group(6); + String units = matcher.group(6); if ("%".equals(units)) retVal /= 100; } catch (Exception e) @@ -276,18 +276,17 @@ public synchronized static float[] parseFloatList(String list) { if (list == null) return null; + Matcher matcher = fpPat.matcher(list); - fpMatch.reset(list); - - LinkedList floatList = new LinkedList(); - while (fpMatch.find()) + LinkedList floatList = new LinkedList(); + while (matcher.find()) { - String val = fpMatch.group(1); + String val = matcher.group(1); floatList.add(Float.valueOf(val)); } float[] retArr = new float[floatList.size()]; - Iterator it = floatList.iterator(); + Iterator it = floatList.iterator(); int idx = 0; while (it.hasNext()) { @@ -316,11 +315,10 @@ public static int findInt(String val) { if (val == null) return 0; + Matcher matcher = intPat.matcher(val); + if (!matcher.find()) return 0; - intMatch.reset(val); - if (!intMatch.find()) return 0; - - val = intMatch.group(); + val = matcher.group(); //System.err.println("Parsing " + val); int retVal = 0; @@ -334,18 +332,17 @@ public static int[] parseIntList(String list) { if (list == null) return null; + Matcher matcher = intPat.matcher(list); - intMatch.reset(list); - - LinkedList intList = new LinkedList(); - while (intMatch.find()) + LinkedList intList = new LinkedList(); + while (matcher.find()) { - String val = intMatch.group(); + String val = matcher.group(); intList.add(Integer.valueOf(val)); } int[] retArr = new int[intList.size()]; - Iterator it = intList.iterator(); + Iterator it = intList.iterator(); int idx = 0; while (it.hasNext()) { @@ -514,7 +511,6 @@ { String sval = ele.getAttribute(name); - URL url; try { return new URL(docRoot, sval); @@ -528,7 +524,7 @@ /** * Returns the first ReadableXMLElement with the given name */ - public static ReadableXMLElement getElement(Class classType, Element root, String name, URL docRoot) + public static ReadableXMLElement getElement(Class classType, Element root, String name, URL docRoot) { if (root == null) return null; @@ -573,7 +569,7 @@ * an attribute of tag 'name' who's string value will be used as the key * in the HashMap */ - public static HashMap getElementHashMap(Class classType, Element root, String name, String key, URL docRoot) + public static HashMap getElementHashMap(Class classType, Element root, String name, String key, URL docRoot) { if (root == null) return null; @@ -583,7 +579,7 @@ return null; } - HashMap retMap = new HashMap(); + HashMap retMap = new HashMap(); NodeList nl = root.getChildNodes(); int size = nl.getLength(); @@ -615,7 +611,7 @@ return retMap; } - public static HashSet getElementHashSet(Class classType, Element root, String name, URL docRoot) + public static HashSet getElementHashSet(Class classType, Element root, String name, URL docRoot) { if (root == null) return null; @@ -625,7 +621,7 @@ return null; } - HashSet retSet = new HashSet(); + HashSet retSet = new HashSet(); NodeList nl = root.getChildNodes(); int size = nl.getLength(); @@ -660,7 +656,7 @@ } - public static LinkedList getElementLinkedList(Class classType, Element root, String name, URL docRoot) + public static LinkedList getElementLinkedList(Class classType, Element root, String name, URL docRoot) { if (root == null) return null; @@ -671,7 +667,7 @@ } NodeList nl = root.getChildNodes(); - LinkedList elementCache = new LinkedList(); + LinkedList elementCache = new LinkedList(); int size = nl.getLength(); for (int i = 0; i < size; i++) { @@ -698,7 +694,7 @@ return elementCache; } - public static Object[] getElementArray(Class classType, Element root, String name, URL docRoot) + public static Object[] getElementArray(Class classType, Element root, String name, URL docRoot) { if (root == null) return null; @@ -708,7 +704,7 @@ return null; } - LinkedList elementCache = getElementLinkedList(classType, root, name, docRoot); + LinkedList elementCache = getElementLinkedList(classType, root, name, docRoot); Object[] retArr = (Object[])Array.newInstance(classType, elementCache.size()); return elementCache.toArray(retArr); @@ -724,7 +720,7 @@ if (root == null) return null; NodeList nl = root.getChildNodes(); - LinkedList elementCache = new LinkedList(); + LinkedList elementCache = new LinkedList(); int size = nl.getLength(); for (int i = 0; i < size; i++) @@ -743,11 +739,11 @@ } int[] retArr = new int[elementCache.size()]; - Iterator it = elementCache.iterator(); + Iterator it = elementCache.iterator(); int idx = 0; while (it.hasNext()) { - retArr[idx++] = ((Integer)it.next()).intValue(); + retArr[idx++] = it.next().intValue(); } return retArr; @@ -763,7 +759,7 @@ if (root == null) return null; NodeList nl = root.getChildNodes(); - LinkedList elementCache = new LinkedList(); + LinkedList elementCache = new LinkedList(); int size = nl.getLength(); for (int i = 0; i < size; i++) @@ -779,11 +775,11 @@ } String[] retArr = new String[elementCache.size()]; - Iterator it = elementCache.iterator(); + Iterator it = elementCache.iterator(); int idx = 0; while (it.hasNext()) { - retArr[idx++] = (String)it.next(); + retArr[idx++] = it.next(); } return retArr; @@ -794,8 +790,8 @@ * @param styleString - A CSS formatted string of styles. Eg, * "font-size:12;fill:#d32c27;fill-rule:evenodd;stroke-width:1pt;" */ - public static HashMap parseStyle(String styleString) { - return parseStyle(styleString, new HashMap()); + public static HashMap parseStyle(String styleString) { + return parseStyle(styleString, new HashMap()); } /** @@ -804,7 +800,7 @@ * "font-size:12;fill:#d32c27;fill-rule:evenodd;stroke-width:1pt;" * @param map - A map to which these styles will be added */ - public static HashMap parseStyle(String styleString, HashMap map) { + public static HashMap parseStyle(String styleString, HashMap map) { final Pattern patSemi = Pattern.compile(";"); String[] styles = patSemi.split(styleString); @@ -821,9 +817,8 @@ { continue; } - - String key = styles[i].substring(0, colon).trim(); - String value = styles[i].substring(colon + 1).trim(); + String key = styles[i].substring(0, colon).trim().intern(); + String value = quotePat.matcher(styles[i].substring(colon + 1).trim()).replaceAll("").intern(); map.put(key, new StyleAttribute(key, value)); } diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/module-info.java svgsalamander-1.1.4/svg-core/src/main/java/module-info.java --- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/module-info.java 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/main/java/module-info.java 2022-02-26 23:40:50.000000000 +0000 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022, kitfox + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SEeRVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +module com.kitfox.svgSalamander { + requires static ant; + requires static ant.launcher; + requires java.desktop; + requires java.xml; + requires java.logging; + + exports com.kitfox.svg; + exports com.kitfox.svg.animation; + exports com.kitfox.svg.app; + exports com.kitfox.svg.app.ant; + exports com.kitfox.svg.app.beans; +} diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/test/java/com/kitfox/salamander/javascript/JSTest.java svgsalamander-1.1.4/svg-core/src/test/java/com/kitfox/salamander/javascript/JSTest.java --- svgsalamander-1.1.1+dfsg/svg-core/src/test/java/com/kitfox/salamander/javascript/JSTest.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/test/java/com/kitfox/salamander/javascript/JSTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/* - * JSTest.java - * - * Created on April 16, 2007, 12:59 AM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package com.kitfox.salamander.javascript; - -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; -import javax.script.ScriptException; - -/** - * http://java.sun.com/developer/technicalArticles/J2SE/Desktop/scripting/ - * - * @author kitfox - */ -public class JSTest -{ - - /** Creates a new instance of JSTest */ - public JSTest() - { - ScriptEngineManager mgr = new ScriptEngineManager(); - ScriptEngine jsEngine = mgr.getEngineByName("JavaScript"); - try { - jsEngine.eval("print('Hello, world!')"); - } catch (ScriptException ex) { - ex.printStackTrace(); - } - } - - public static void main(String[] args) - { - new JSTest(); - } -} diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/test/java/com/kitfox/svg/zip/ZipTestMain.java svgsalamander-1.1.4/svg-core/src/test/java/com/kitfox/svg/zip/ZipTestMain.java --- svgsalamander-1.1.1+dfsg/svg-core/src/test/java/com/kitfox/svg/zip/ZipTestMain.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-core/src/test/java/com/kitfox/svg/zip/ZipTestMain.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -/* - * ZipTestMain.java - * - * Created on July 18, 2007, 12:44 AM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package com.kitfox.svg.zip; - -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.util.zip.GZIPInputStream; - -/** - * - * @author kitfox - */ -public class ZipTestMain -{ - - /** Creates a new instance of ZipTestMain */ - public ZipTestMain() throws IOException - { - URL url = ZipTestMain.class.getResource("/missing.svgz"); -// URL url = ZipTestMain.class.getResource("/AdamTagletClasses.svg"); - InputStream is = url.openStream(); - BufferedInputStream bin = new BufferedInputStream(is); - - bin.mark(2); - int b0 = bin.read(); - int b1 = bin.read(); - bin.reset(); - - InputStreamReader reader; - - //Check for gzip magic number - if ((b1 << 8 | b0) == GZIPInputStream.GZIP_MAGIC) - { - GZIPInputStream iis = new GZIPInputStream(bin); - reader = new InputStreamReader(iis); - } - else - { - //Plain text - reader = new InputStreamReader(bin); - } - - - BufferedReader br = new BufferedReader(reader); - for (String s = br.readLine(); s != null; s = br.readLine()) - { - System.err.println(s); - } - } - - /** - * @param args the command line arguments - */ - public static void main(String[] args) - { - try - { - new ZipTestMain(); - } catch (IOException ex) - { - ex.printStackTrace(); - } - } - -} diff -Nru svgsalamander-1.1.1+dfsg/svg-example/build.xml svgsalamander-1.1.4/svg-example/build.xml --- svgsalamander-1.1.1+dfsg/svg-example/build.xml 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/build.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ - - - - - - - - - - - Builds, tests, and runs the project svg-example. - - - diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/build-impl.xml svgsalamander-1.1.4/svg-example/nbproject/build-impl.xml --- svgsalamander-1.1.1+dfsg/svg-example/nbproject/build-impl.xml 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/nbproject/build-impl.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1444 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.res.dir - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/genfiles.properties svgsalamander-1.1.4/svg-example/nbproject/genfiles.properties --- svgsalamander-1.1.1+dfsg/svg-example/nbproject/genfiles.properties 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/nbproject/genfiles.properties 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -build.xml.data.CRC32=5288c6a7 -build.xml.script.CRC32=0bbcf450 -build.xml.stylesheet.CRC32=8064a381@1.68.1.46 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=5288c6a7 -nbproject/build-impl.xml.script.CRC32=7ea6df96 -nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48 diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/private.properties svgsalamander-1.1.4/svg-example/nbproject/private/private.properties --- svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/private.properties 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/nbproject/private/private.properties 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -compile.on.save=false -do.depend=false -do.jar=true -javac.debug=true -javadoc.preview=true -user.properties.file=C:\\Users\\kitfox\\AppData\\Roaming\\NetBeans\\8.1\\build.properties diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/private.xml svgsalamander-1.1.4/svg-example/nbproject/private/private.xml --- svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/private.xml 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/nbproject/private/private.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ - - - - - - - file:/C:/dev/java.net/svgsalamander/trunk/svg-example/src/com/kitfox/svg/example/SimpleIconFrame.java - file:/C:/dev/java.net/svgsalamander/trunk/svg-example/src/svgsalamandererror/icons/btn-settings.svg - file:/C:/dev/java.net/svgsalamander/trunk/svg-example/src/svgsalamandererror/SvgSalamanderError.java - file:/C:/dev/java.net/svgsalamander/trunk/svg-example/res/com/kitfox/svg/example/dor-32-gradient.svg - file:/C:/dev/java.net/svgsalamander/trunk/svg-example/src/com/kitfox/svg/example/MenuIconTestFrame.java - - - diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/catalog.xml svgsalamander-1.1.4/svg-example/nbproject/private/retriever/catalog.xml --- svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/catalog.xml 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/nbproject/private/retriever/catalog.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/creativecommons.org/ns.xml svgsalamander-1.1.4/svg-example/nbproject/private/retriever/creativecommons.org/ns.xml --- svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/creativecommons.org/ns.xml 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/nbproject/private/retriever/creativecommons.org/ns.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,401 +0,0 @@ - - - - - - - Describing Copyright in RDF - Creative Commons Rights Expression Language - - - - - - - - - - - - - -
-
- -
-
- -
- -
-
-
-
-

Describing Copyright in RDF

-

Creative Commons Rights Expression Language

-
- -
-

The Creative Commons Rights Expression Language (CC - REL) lets you describe copyright licenses in RDF. - For more information on describing licenses in RDF - and attaching those descriptions to digital works, - see CC - REL in - the Creative - Commons wiki. -

- -

Classes

- -
-

Work

- a potentially - copyrightable work - -
- -
-

License

- a set of - requests/permissions to users of a Work, e.g. a - copyright license, the public domain, information - for distributors - - -
- -
-

Jurisdiction

- the legal jurisdiction - of a license -
- -
-

Permission

- an action that may or - may not be allowed or desired - -
- -
-

Requirement

- an action that may or - may not be requested of you - -
- -
-

Prohibition

- something you may be - asked not to do - -
- -

Permissions

- -
-

Reproduction

- making multiple - copies - -
- -
-

Distribution

- distribution, public - display, and publicly performance - -
- -
-

Derivative Works

- distribution of - derivative works - -
- -
-

Sharing

- permits commercial - derivatives, but only non-commercial - distribution -
- -

Requirements

- -
-

Notice

- copyright and license - notices be kept intact - -
- -
-

Attribution

- credit be given to - copyright holder and/or author - -
- -
-

Share Alike

- derivative works be - licensed under the same terms or compatible terms - as the original work - -
- -
-

Source Code

- source code (the - preferred form for making modifications) must be - provided when exercising some rights granted by - the license. - -
- -
-

Copyleft

- derivative and - combined works must be licensed under specified - terms, similar to those on the original - work -
- -
-

Lesser Copyleft

- derivative works must - be licensed under specified terms, with at least - the same conditions as the original work; - combinations with the work may be licensed under - different terms -
- -

Prohibitions

- -
-

Commercial Use

- exercising rights for - commercial purposes - -
- -
-

High Income Nation Use

- use in a - non-developing country -
- -

License Properties

- -
-

cc:permits

A - License - permits - a Permission. - -
- -
-

cc:requires

A - License - requires - a Requirement. - -
- -
-

cc:prohibits

A - License - prohibits - a Prohibition. - -
- -
-

cc:jurisdiction

A - License may - have - a jurisdiction, - as defined by Jurisdictions. -
- -
-

cc:legalcode

The - URL of the legal text of a License. -
- -
-

cc:deprecatedOn

A License may be deprecated; - provides the date deprecated - on. -
- - -

Work Properties

- -
-

cc:license

A Work has - license a License.
- (a subproperty - of dc:license, the - same as xhtml:license) - -
- -
-

cc:morePermissions

A - related - resource - which describes additional permissions or - alternative licenses for a - Work which may - be available. -
- -
-

cc:attributionName

- The name - the creator of a Work would like used when - attributing re-use. -
- -
-

cc:attributionURL

The - URL the creator of a Work would like used when - attributing re-use. -
- -
-

cc:useGuidelines

- - A related - resource - which defines non-binding use guidelines for the - work. -
- -

- -

RDF users might be interested in our - machine-readable RDF - Schema. A copy is also embedded in this - document.

-
- -
-
-
-
-
-
- - - - - - - diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/dublincore.org/2012/06/14/dcelements svgsalamander-1.1.4/svg-example/nbproject/private/retriever/dublincore.org/2012/06/14/dcelements --- svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/dublincore.org/2012/06/14/dcelements 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/nbproject/private/retriever/dublincore.org/2012/06/14/dcelements 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ - - -303 See Other - -

See Other

-

The answer to your request is located here.

- diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/www.w3.org/1999/02/22-rdf-syntax-ns.xml svgsalamander-1.1.4/svg-example/nbproject/private/retriever/www.w3.org/1999/02/22-rdf-syntax-ns.xml --- svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/www.w3.org/1999/02/22-rdf-syntax-ns.xml 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/nbproject/private/retriever/www.w3.org/1999/02/22-rdf-syntax-ns.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,141 +0,0 @@ - - - - The RDF Vocabulary (RDF) - This is the RDF Schema for the RDF vocabulary defined in the RDF namespace. - - - - - - - PlainLiteral - The class of plain (i.e. untyped) literal values. - - - - - - - type - The subject is an instance of a class. - - - - - - - Property - The class of RDF properties. - - - - - - Statement - - The class of RDF statements. - - - - - subject - The subject of the subject RDF statement. - - - - - - - predicate - The predicate of the subject RDF statement. - - - - - - - object - The object of the subject RDF statement. - - - - - - - Bag - The class of unordered containers. - - - - - - Seq - The class of ordered containers. - - - - - - Alt - The class of containers of alternatives. - - - - - - value - Idiomatic property used for structured values. - - - - - - - - - List - The class of RDF Lists. - - - - - - nil - The empty list, with no items in it. If the rest of a list is nil then the list has no more items in it. - - - - - first - The first item in the subject RDF list. - - - - - - - rest - The rest of the subject RDF list after the first item. - - - - - - - - XMLLiteral - The class of XML literal values. - - - - - - - - diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/www.w3.org/1999/xlink svgsalamander-1.1.4/svg-example/nbproject/private/retriever/www.w3.org/1999/xlink --- svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/www.w3.org/1999/xlink 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/nbproject/private/retriever/www.w3.org/1999/xlink 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ - - - - XLink namespace - - - - -
-

W3C

-
-

-This is an XML namespace defined in the -XML Linking Language (XLink) specification. -

-

-For more information about XML, please refer to The Extensible Markup Language -(XML) 1.0 specification. For more information about XML -namespaces, please refer to the -Namespaces in XML -specification. - -


-
- Webmaster
- Last modified: $Date: 2000/06/22 15:15:22 $ -
- - diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/www.w3.org/2000/svg.xml svgsalamander-1.1.4/svg-example/nbproject/private/retriever/www.w3.org/2000/svg.xml --- svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/www.w3.org/2000/svg.xml 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/nbproject/private/retriever/www.w3.org/2000/svg.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ - - - - - SVG namespace - - - - -
-

W3C

-
-

-This is an XML namespace, first defined in the -Scalable Vector Graphics (SVG) 1.0 Specification and subsequently added to by SVG 1.1 and SVG 1.2. The SVG namespace is mutable; names may be added over time by the W3C SVG Working Group by publication in W3C Technical Reports.

- -

The -latest version of the SVG specification can be found http://www.w3.org/TR/SVG. -

- -

-For more information about SVG, please refer to the W3C SVG overview. -For more information about XML, please refer to The Extensible Markup Language -(XML) 1.0 specification. For more information about XML -namespaces, please refer to the -Namespaces in XML -specification.

- -
-
- Webmaster
- Last modified: $Date: 2006/02/05 10:17:51 $ -
- - diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/project.properties svgsalamander-1.1.4/svg-example/nbproject/project.properties --- svgsalamander-1.1.1+dfsg/svg-example/nbproject/project.properties 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/nbproject/project.properties 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.run.all.processors=true -application.title=svg-example -application.vendor=kitfox -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/svg-example.jar -dist.javadoc.dir=${dist.dir}/javadoc -endorsed.classpath= -excludes= -includes=** -jar.compress=false -javac.classpath=\ - ${reference.svg-salamander-core.jar} -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.processorpath=\ - ${javac.classpath} -javac.source=1.5 -javac.target=1.5 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath}:\ - ${libs.junit_4.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -main.class=com.kitfox.svg.example.SimpleIconFrame -meta.inf.dir=${src.dir}/META-INF -platform.active=default_platform -project.svg-salamander-core=../svg-core -reference.svg-salamander-core.jar=${project.svg-salamander-core}/dist/svg-salamander-core.jar -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.dir=src -src.res.dir=res -test.src.dir=test diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/project.xml svgsalamander-1.1.4/svg-example/nbproject/project.xml --- svgsalamander-1.1.1+dfsg/svg-example/nbproject/project.xml 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/nbproject/project.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ - - - org.netbeans.modules.java.j2seproject - - - svg-example - - - - - - - - - - - svg-salamander-core - jar - - jar - clean - jar - - - - diff -Nru svgsalamander-1.1.1+dfsg/svg-example/pom.xml svgsalamander-1.1.4/svg-example/pom.xml --- svgsalamander-1.1.1+dfsg/svg-example/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/pom.xml 2022-02-26 23:40:50.000000000 +0000 @@ -0,0 +1,64 @@ + + + 4.0.0 + + com.kitfox + svgSalamander-examples + 1.1.4-SNAPSHOT + jar + + com.kitfox:svgSalamander Examples + Examples for displaying and playing SVG content using the Java2D. + https://github.com/blackears/svgSalamander + + + + BSD License + https://opensource.org/licenses/BSD-2-Clause + + + + + + Mark McKay + mark@kitfox.com + kitfox.com + http://www.kitfox.com + + + + + scm:git:git://github.com/blackears/svgSalamander.git + scm:git:ssh://github.com:blackears/svgSalamander.git + https://github.com/blackears/svgSalamander/tree/master/svg-examples + + + + 1.9 + 1.9 + + + + src + + + res + + + test + + + res + + + + + + ${project.groupId} + svgSalamander + 1.1.4 + + + diff -Nru svgsalamander-1.1.1+dfsg/svg-example/res/com/kitfox/svg/example/jira44-antialias.svg svgsalamander-1.1.4/svg-example/res/com/kitfox/svg/example/jira44-antialias.svg --- svgsalamander-1.1.1+dfsg/svg-example/res/com/kitfox/svg/example/jira44-antialias.svg 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/res/com/kitfox/svg/example/jira44-antialias.svg 2022-02-26 23:40:50.000000000 +0000 @@ -0,0 +1,208 @@ + + + JOSM Logotype 2019 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + JOSM Logotype 2019 + 2019-08-05 + + + Diamond00744 + + + + + Public Domain + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru svgsalamander-1.1.1+dfsg/svg-example/res/com/kitfox/svg/example/parseTransform.svg svgsalamander-1.1.4/svg-example/res/com/kitfox/svg/example/parseTransform.svg --- svgsalamander-1.1.1+dfsg/svg-example/res/com/kitfox/svg/example/parseTransform.svg 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/res/com/kitfox/svg/example/parseTransform.svg 2022-02-26 23:40:50.000000000 +0000 @@ -0,0 +1,5 @@ + + + Hello world! + + diff -Nru svgsalamander-1.1.1+dfsg/svg-example/res/com/kitfox/svg/example/pluginIcon.svg svgsalamander-1.1.4/svg-example/res/com/kitfox/svg/example/pluginIcon.svg --- svgsalamander-1.1.1+dfsg/svg-example/res/com/kitfox/svg/example/pluginIcon.svg 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/res/com/kitfox/svg/example/pluginIcon.svg 2022-02-26 23:40:50.000000000 +0000 @@ -0,0 +1,45 @@ + + image/svg+xml + + + + + + + + + + + + background + + + + Layer 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -Nru svgsalamander-1.1.1+dfsg/svg-example/res/com/kitfox/svg/example/rihard_minus.svg svgsalamander-1.1.4/svg-example/res/com/kitfox/svg/example/rihard_minus.svg --- svgsalamander-1.1.1+dfsg/svg-example/res/com/kitfox/svg/example/rihard_minus.svg 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/res/com/kitfox/svg/example/rihard_minus.svg 2022-02-26 23:40:50.000000000 +0000 @@ -0,0 +1,279 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Openclipart + + + + 2007-01-31T04:05:06 + + https://openclipart.org/detail/176152/Clipart-by-rihard + + + rihard + + + + + arithmetic + symbols + plus + minus + + + + + + + + + + + diff -Nru svgsalamander-1.1.1+dfsg/svg-example/res/com/kitfox/svg/example/Ruby_logo.svg svgsalamander-1.1.4/svg-example/res/com/kitfox/svg/example/Ruby_logo.svg --- svgsalamander-1.1.1+dfsg/svg-example/res/com/kitfox/svg/example/Ruby_logo.svg 1970-01-01 00:00:00.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/res/com/kitfox/svg/example/Ruby_logo.svg 2022-02-26 23:40:50.000000000 +0000 @@ -0,0 +1,136 @@ + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -Nru svgsalamander-1.1.1+dfsg/svg-example/src/com/kitfox/svg/example/SimpleIconFrame.java svgsalamander-1.1.4/svg-example/src/com/kitfox/svg/example/SimpleIconFrame.java --- svgsalamander-1.1.1+dfsg/svg-example/src/com/kitfox/svg/example/SimpleIconFrame.java 2016-08-20 09:47:17.000000000 +0000 +++ svgsalamander-1.1.4/svg-example/src/com/kitfox/svg/example/SimpleIconFrame.java 2022-02-26 23:40:50.000000000 +0000 @@ -40,14 +40,19 @@ import com.kitfox.svg.SVGException; import com.kitfox.svg.SVGUniverse; import com.kitfox.svg.ShapeElement; +import com.kitfox.svg.Text; +import com.kitfox.svg.animation.AnimationElement; import com.kitfox.svg.app.beans.SVGPanel; import java.awt.BorderLayout; import java.awt.geom.Point2D; +import java.io.File; +import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.UIManager; /** * @@ -65,55 +70,70 @@ getContentPane().add(panel, BorderLayout.CENTER); panel.setAntiAlias(true); panel.setAutosize(SVGPanel.AUTOSIZE_NONE); + +//URI uri = new File("D:\\dev\\github.com\\svgSalamander\\svg-example\\res\\DemoSVG\\Gnome_All.svg").toURI(); +//panel.setSvgURI(uri); + try { panel.setSvgURI(SimpleIconFrame.class.getResource("tux.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("dor-32-gradient.svg").toURI()); - -// panel.setSvgURI(SimpleIconFrame.class.getResource("bulb.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("notes.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("jira51-textLength.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("jira50-display.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("bigMarkers.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("radialGradient.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("jira43-tspanVariableX.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("textOnPath.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("tree.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("jt11.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("viewboxTest.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("boundingBoxPicking.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("issue.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("intro_flash.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("clipIssue.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("bug-31-path.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("100x100-mm.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("gradient.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("map2.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("imageClip.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("markerEnd.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("casing2.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("casing2-opt.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("PseudoColor.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("degrade.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("Z.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("test-brd.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("nonScalingStroke.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("areaCrash.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("use.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("data-uri-scheme-test-image.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("marker.svg").toURI()); -// panel.setSvgURI(SimpleIconFrame.class.getResource("markerTest.svg").toURI()); - -// panel.setSvgURI(SimpleIconFrame.class.getResource("class.svg").toURI()); -// SVGDiagram diagram = panel.getSvgUniverse().getDiagram(SimpleIconFrame.class.getResource("class.svg").toURI()); -// SVGRoot root = diagram.getRoot(); -// StyleSheet ss = new StyleSheet(); -// root.setStyleSheet(ss); -// ss.addStyleRule(new StyleSheetRule("stroke-width", "rect", null), "5"); -// ss.addStyleRule(new StyleSheetRule("fill", "rect", null), "none"); -// ss.addStyleRule(new StyleSheetRule("stroke", "rect", "alpha"), "red"); -// ss.addStyleRule(new StyleSheetRule("stroke", "rect", null), "green"); - +// panel.setSvgURI(SimpleIconFrame.class.getResource("Ruby_logo_1.svg").toURI()); +// panel.setSvgURI(SimpleIconFrame.class.getResource("pluginIcon.svg").toURI()); +// panel.setSvgURI(SimpleIconFrame.class.getResource("parseTransform.svg").toURI()); +// panel.setSvgURI(SimpleIconFrame.class.getResource("triangle.svg").toURI()); +// +// +// +//panel.setSvgURI(SimpleIconFrame.class.getResource("diylc.svg").toURI()); +//panel.setSvgURI(SimpleIconFrame.class.getResource("pcb.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("rihard_minus.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("dor-32-gradient.svg").toURI()); +// +//// panel.setSvgURI(SimpleIconFrame.class.getResource("bulb.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("notes.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("jira51-textLength.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("jira50-display.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("bigMarkers.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("radialGradient.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("jira43-tspanVariableX.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("textOnPath.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("tree.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("jt11.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("viewboxTest.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("boundingBoxPicking.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("issue.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("intro_flash.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("clipIssue.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("bug-31-path.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("100x100-mm.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("gradient.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("map2.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("imageClip.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("markerEnd.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("casing2.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("casing2-opt.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("PseudoColor.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("degrade.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("Z.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("test-brd.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("nonScalingStroke.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("areaCrash.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("use.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("data-uri-scheme-test-image.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("marker.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("markerTest.svg").toURI()); +//// panel.setSvgURI(SimpleIconFrame.class.getResource("boundingBoxPicking.svg").toURI()); +// +//// panel.setSvgURI(SimpleIconFrame.class.getResource("class.svg").toURI()); +//// SVGDiagram diagram = panel.getSvgUniverse().getDiagram(SimpleIconFrame.class.getResource("class.svg").toURI()); +//// SVGRoot root = diagram.getRoot(); +//// StyleSheet ss = new StyleSheet(); +//// root.setStyleSheet(ss); +//// ss.addStyleRule(new StyleSheetRule("stroke-width", "rect", null), "5"); +//// ss.addStyleRule(new StyleSheetRule("fill", "rect", null), "none"); +//// ss.addStyleRule(new StyleSheetRule("stroke", "rect", "alpha"), "red"); +//// ss.addStyleRule(new StyleSheetRule("stroke", "rect", null), "green"); +// } catch (URISyntaxException ex) { Logger.getLogger(SimpleIconFrame.class.getName()).log(Level.SEVERE, null, ex); } @@ -128,7 +148,6 @@ setSize(640, 480); } - /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is