[Git][java-team/jfreesvg][upstream] New upstream version 5.0.6
Christian Bayle (@bayle)
gitlab at salsa.debian.org
Wed Feb 26 23:47:52 GMT 2025
Christian Bayle pushed to branch upstream at Debian Java Maintainers / jfreesvg
Commits:
d6469dbc by Christian Bayle at 2025-02-26T19:18:18+01:00
New upstream version 5.0.6
- - - - -
27 changed files:
- + .github/FUNDING.yml
- .github/workflows/ci.yaml
- .gitignore
- README.md
- − jfreesvg.svg
- pom.xml
- src/main/java/org/jfree/svg/ImageElement.java
- src/main/java/org/jfree/svg/MeetOrSlice.java
- src/main/java/org/jfree/svg/PreserveAspectRatio.java
- src/main/java/org/jfree/svg/SVGGraphics2D.java
- src/main/java/org/jfree/svg/SVGGraphicsConfiguration.java
- src/main/java/org/jfree/svg/SVGGraphicsDevice.java
- src/main/java/org/jfree/svg/SVGHints.java
- src/main/java/org/jfree/svg/SVGUnits.java
- src/main/java/org/jfree/svg/SVGUtils.java
- src/main/java/org/jfree/svg/StandardFontFunction.java
- src/main/java/org/jfree/svg/ViewBox.java
- src/main/java/org/jfree/svg/util/Args.java
- src/main/java/org/jfree/svg/util/DoubleConverter.java
- src/main/java/org/jfree/svg/util/GradientPaintKey.java
- src/main/java/org/jfree/svg/util/GraphicsUtils.java
- src/main/java/org/jfree/svg/util/LinearGradientPaintKey.java
- src/main/java/org/jfree/svg/util/RadialGradientPaintKey.java
- src/test/java/org/jfree/svg/TestDoubleConversion.java
- src/test/java/org/jfree/svg/TestGeneral.java
- src/test/java/org/jfree/svg/TestSVGGraphics2D.java
- src/test/java/org/jfree/svg/util/ArgsTest.java
Changes:
=====================================
.github/FUNDING.yml
=====================================
@@ -0,0 +1,3 @@
+# These are supported funding model platforms
+
+github: [jfree]
=====================================
.github/workflows/ci.yaml
=====================================
@@ -8,8 +8,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
- os: [ubuntu-18.04, macOS-latest, windows-2016]
- java: [11, 13, 15, 16, 17-ea]
+ os: [ubuntu-latest, macOS-latest, windows-latest]
+ java: [11, 17, 21]
fail-fast: false
max-parallel: 4
name: Test JDK ${{ matrix.java }}, ${{ matrix.os }}
=====================================
.gitignore
=====================================
@@ -1,8 +1,8 @@
target
distribution
-
+.idea
*.class
-
+**/.DS_Store
# Package Files #
*.jar
*.war
=====================================
README.md
=====================================
@@ -1,9 +1,9 @@
JFreeSVG
========
-Version 5.0.2, by David Gilbert, 7 November 2021.
+Version 5.0.6, by David Gilbert, 23 June 2024.
-(C)opyright 2013-2021, by David Gilbert. All rights reserved.
+(C)opyright 2013-present, by David Gilbert. All rights reserved.
[](https://maven-badges.herokuapp.com/maven-central/org.jfree/org.jfree.svg)
@@ -31,7 +31,7 @@ JFreeSVG is published to the Central Repository. You can include it in your pro
<dependency>
<groupId>org.jfree</groupId>
<artifactId>org.jfree.svg</artifactId>
- <version>5.0.2</version>
+ <version>5.0.6</version>
</dependency>
JFreeSVG is a modular library with the module name `org.jfree.svg`.
@@ -41,7 +41,7 @@ To use JFreeSVG with Java 8, you can use the following (note the different artif
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreesvg</artifactId>
- <version>3.4.2</version>
+ <version>3.4.3</version>
</dependency>
Build
@@ -61,23 +61,45 @@ Testing
- the compositing rules in `AlphaComposite` are not implemented
- font metrics are approximated
-
+
+
License
-------
-JFreeSVG is free software under the terms of the GNU General Public License version 3 (GPLv3) or later. The license file is included in this distribution (gpl-3.0.txt). If you prefer not to be bound by the terms of the GPLv3, you can purchase an alternative license (please e-mail dave at jfree.org for details, or check the JFreeSVG home page).
+JFreeSVG is free software under the terms of the GNU General Public License version 3 (GPLv3) or later. The license file is included in this distribution (gpl-3.0.txt).
Please note that JFreeSVG is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Please refer to the license for details.
+If you prefer not to be bound by the terms of the GPLv3, you can obtain an alternative license by sponsoring the JFree project:
+
+- https://github.com/sponsors/jfree
Change History
--------------
+Version 5.0.6 (23 June 2024)
+- fix issue with `LinearGradientPaint` and `RadialGradientPaint` reference generation
+- minor code transformations suggested by the Datadog Static Analyzer and SonarLint
+- update Maven and JUnit dependencies
+
+Version 5.0.5 (19 February 2023)
+- fixed `drawArc()` and `fillArc()`
+- update Maven and JUnit dependencies
+
+Version 5.0.4 (9 January 2023)
+- minor code transformations
+- unit test fix
+- update Maven and JUnit dependencies
+
+Version 5.0.3 (22 June 2022)
+- remove duplicate calls to `getClipPathRef()`
+- update Maven plugin dependencies
+
Version 5.0.2 (7 November 2021)
-- add support for `TextAttribute.TRACKING`;
-- clarified Javadocs for `SVGHints.KEY_BEGIN_GROUP`.
+- add support for `TextAttribute.TRACKING`
+- clarified Javadocs for `SVGHints.KEY_BEGIN_GROUP`
Version 5.0.1 (4 August 2021)
- handle cycle methods for `GradientPaint` and `RadialGradientPaint`;
@@ -94,17 +116,14 @@ Version 5.0 (12 June 2021)
- added more JUnit tests;
- updated JUnit test dependency to version 5.7.2.
-
Version 4.2 (10 January 2021)
- replace `NumberFormat` with Ryu algorithm for performance gains ([#30](https://github.com/jfree/jfreesvg/pull/30));
- add winding rule to path data if required ([#25](https://github.com/jfree/jfreesvg/issues/25));
- migrated to JUnit 5.
-
Version 4.1 (26 March 2020)
- correction of fix for encoding of images ([#21](https://github.com/jfree/jfreesvg/issues/21)).
-
Version 4.0 (27 February 2020)
- created a module for JFreeSVG: `org.jfree.svg`;
- increased the minimum required Java version to 11;
@@ -113,7 +132,6 @@ Version 4.0 (27 February 2020)
- fix `drawArc()` and `fillArc()` methods to draw pie arcs;
- use `java.util.Base64` instead of `javax.xml.bind.DatatypeConverter`.
-
Version 3.4 (10 February 2019)
- added attribute for font size units override;
- added automatic module name (`org.jfree.jfreesvg`);
@@ -121,12 +139,10 @@ Version 3.4 (10 February 2019)
- fixed `drawString()` method for empty string;
- fixed `drawImage()` method for `null` `ImageOp`.
-
Version 3.3 (7 November 2017)
- the default `DEFS` key prefix should not begin with a number;
- transferred demo code to the [JFree-Demos](https://github.com/jfree/jfree-demos) project to streamline the distribution process.
-
Version 3.2 (9 October 2016)
- added facility to specify `units` for `width` and `height` attributes;
- added option to suppress `width` and `height` from SVG element;
=====================================
jfreesvg.svg deleted
=====================================
The diff for this file was not included because it is too large.
=====================================
pom.xml
=====================================
@@ -5,7 +5,7 @@
<groupId>org.jfree</groupId>
<artifactId>org.jfree.svg</artifactId>
- <version>5.0.2</version>
+ <version>5.0.6</version>
<packaging>jar</packaging>
<name>JFreeSVG</name>
@@ -42,13 +42,13 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
- <version>5.7.2</version>
+ <version>5.10.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
- <version>5.7.2</version>
+ <version>5.10.2</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -58,12 +58,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
- <version>3.1.0</version>
+ <version>3.3.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
- <version>3.2.0</version>
+ <version>3.3.1</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
@@ -71,7 +71,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <version>3.8.1</version>
+ <version>3.13.0</version>
<configuration>
<source>11</source>
<target>11</target>
@@ -82,12 +82,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
- <version>3.2.0</version>
+ <version>3.4.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>3.2.0</version>
+ <version>3.6.3</version>
<configuration>
<docfilessubdirs>true</docfilessubdirs>
<linksource>true</linksource>
@@ -95,16 +95,16 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
- <version>3.0.0-M5</version>
+ <version>3.2.5</version>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
- <version>3.0.0-M5</version>
+ <version>3.2.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
- <version>3.0.0-M1</version>
+ <version>3.1.2</version>
</plugin>
</plugins>
</build>
@@ -124,7 +124,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
- <version>1.5</version>
+ <version>3.2.4</version>
<executions>
<execution>
<id>sign-artifacts</id>
@@ -139,7 +139,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
- <version>1.6.7</version>
+ <version>1.7.0</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
@@ -151,7 +151,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>3.2.0</version>
+ <version>3.7.0</version>
<configuration>
<docfilessubdirs>true</docfilessubdirs>
<linksource>true</linksource>
@@ -169,7 +169,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
- <version>3.2.0</version>
+ <version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
=====================================
src/main/java/org/jfree/svg/ImageElement.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
=====================================
src/main/java/org/jfree/svg/MeetOrSlice.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
=====================================
src/main/java/org/jfree/svg/PreserveAspectRatio.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
=====================================
src/main/java/org/jfree/svg/SVGGraphics2D.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
@@ -212,7 +212,7 @@ public final class SVGGraphics2D extends Graphics2D {
* ensure that the keys are unique when creating more than one SVG element
* for a single HTML page.
*/
- private String defsKeyPrefix = "_" + System.nanoTime();
+ String defsKeyPrefix = "_" + System.nanoTime();
/**
* A map of all the gradients used, and the corresponding id. When
@@ -347,17 +347,16 @@ public final class SVGGraphics2D extends Graphics2D {
private Ellipse2D oval;
/**
- * An instance that is lazily instantiated in draw/fillArc and then
- * subsequently reused to avoid creating a lot of garbage.
+ * An instance that is reused in draw/fillArc to avoid creating a lot of garbage.
*/
- private Arc2D arc;
+ private final Arc2D arc = new Arc2D.Double();
/**
* If the current paint is an instance of {@link GradientPaint}, this
* field will contain the reference id that is used in the DEFS element
* for that linear gradient.
*/
- private String gradientPaintRef = null;
+ String gradientPaintRef;
/**
* The device configuration (this is lazily instantiated in the
@@ -405,6 +404,7 @@ public final class SVGGraphics2D extends Graphics2D {
*/
public SVGGraphics2D(double width, double height, SVGUnits units,
StringBuilder sb) {
+ super();
Args.requireFinitePositive(width, "width");
Args.requireFinitePositive(height, "height");
Args.nullNotPermitted(sb, "sb");
@@ -553,7 +553,7 @@ public final class SVGGraphics2D extends Graphics2D {
* Sets the double-to-string function that is used when writing coordinates
* for geometrical shapes in the SVG output. The default converter
* optimises for speed when generating the SVG and should cover normal
- * usage. However this method provides the ability to substitute
+ * usage. However, this method provides the ability to substitute
* an alternative function (for example, one that favours output size
* over speed of generation).
*
@@ -758,38 +758,30 @@ public final class SVGGraphics2D extends Graphics2D {
} else if (paint instanceof GradientPaint) {
GradientPaint gp = (GradientPaint) paint;
GradientPaintKey key = new GradientPaintKey(gp);
- String ref = this.gradientPaints.get(key);
- if (ref == null) {
+ this.gradientPaintRef = this.gradientPaints.computeIfAbsent(key, k -> {
int count = this.gradientPaints.keySet().size();
String id = this.defsKeyPrefix + "gp" + count;
this.elementIDs.add(id);
- this.gradientPaints.put(key, id);
- this.gradientPaintRef = id;
- } else {
- this.gradientPaintRef = ref;
- }
+ return id;
+ });
} else if (paint instanceof LinearGradientPaint) {
LinearGradientPaint lgp = (LinearGradientPaint) paint;
LinearGradientPaintKey key = new LinearGradientPaintKey(lgp);
- String ref = this.linearGradientPaints.get(key);
- if (ref == null) {
+ this.gradientPaintRef = this.linearGradientPaints.computeIfAbsent(key, k -> {
int count = this.linearGradientPaints.keySet().size();
String id = this.defsKeyPrefix + "lgp" + count;
this.elementIDs.add(id);
- this.linearGradientPaints.put(key, id);
- this.gradientPaintRef = id;
- }
+ return id;
+ });
} else if (paint instanceof RadialGradientPaint) {
RadialGradientPaint rgp = (RadialGradientPaint) paint;
RadialGradientPaintKey key = new RadialGradientPaintKey(rgp);
- String ref = this.radialGradientPaints.get(key);
- if (ref == null) {
+ this.gradientPaintRef = this.radialGradientPaints.computeIfAbsent(key, k -> {
int count = this.radialGradientPaints.keySet().size();
String id = this.defsKeyPrefix + "rgp" + count;
this.elementIDs.add(id);
- this.radialGradientPaints.put(key, id);
- this.gradientPaintRef = id;
- }
+ return id;
+ });
}
}
@@ -840,7 +832,7 @@ public final class SVGGraphics2D extends Graphics2D {
/**
* Sets the background color. This is used by the
* {@link #clearRect(int, int, int, int)} method. The reference
- * implementation allows {@code null} for the background color so
+ * implementation allows {@code null} for the background color, so
* we allow that too (but for that case, the clearRect method will do
* nothing).
*
@@ -1048,7 +1040,7 @@ public final class SVGGraphics2D extends Graphics2D {
} else {
this.elementIDs.add(elementID);
}
- builder.append(" id='").append(elementID).append("'");
+ builder.append(" id='").append(elementID).append('\'');
}
}
@@ -1079,15 +1071,15 @@ public final class SVGGraphics2D extends Graphics2D {
.append("' y1='").append(geomDP(l.getY1()))
.append("' x2='").append(geomDP(l.getX2()))
.append("' y2='").append(geomDP(l.getY2()))
- .append("' ");
- this.sb.append("style='").append(strokeStyle()).append("'");
+ .append('\'');
+ this.sb.append(" style='").append(strokeStyle()).append('\'');
if (!this.transform.isIdentity()) {
this.sb.append(" transform='").append(getSVGTransform(
- this.transform)).append("'");
+ this.transform)).append('\'');
}
- String clip = getClipPathRef();
- if (!clip.isEmpty()) {
- this.sb.append(' ').append(getClipPathRef());
+ String clipPathRef = getClipPathRef();
+ if (!clipPathRef.isEmpty()) {
+ this.sb.append(' ').append(clipPathRef);
}
this.sb.append("/>");
} else if (s instanceof Rectangle2D) {
@@ -1098,16 +1090,16 @@ public final class SVGGraphics2D extends Graphics2D {
.append("' y='").append(geomDP(r.getY()))
.append("' width='").append(geomDP(r.getWidth()))
.append("' height='").append(geomDP(r.getHeight()))
- .append("' ");
- this.sb.append("style='").append(strokeStyle())
- .append(";fill:none").append("'");
+ .append('\'');
+ this.sb.append(" style='").append(strokeStyle())
+ .append(";fill:none'");
if (!this.transform.isIdentity()) {
this.sb.append(" transform='").append(getSVGTransform(
this.transform)).append('\'');
}
- String clip = getClipPathRef();
- if (!clip.isEmpty()) {
- this.sb.append(' ').append(clip);
+ String clipPathRef = getClipPathRef();
+ if (!clipPathRef.isEmpty()) {
+ this.sb.append(' ').append(clipPathRef);
}
this.sb.append("/>");
} else if (s instanceof Ellipse2D) {
@@ -1118,16 +1110,16 @@ public final class SVGGraphics2D extends Graphics2D {
.append("' cy='").append(geomDP(e.getCenterY()))
.append("' rx='").append(geomDP(e.getWidth() / 2.0))
.append("' ry='").append(geomDP(e.getHeight() / 2.0))
- .append("' ");
- this.sb.append("style='").append(strokeStyle())
- .append(";fill:none").append("'");
+ .append('\'');
+ this.sb.append(" style='").append(strokeStyle())
+ .append(";fill:none'");
if (!this.transform.isIdentity()) {
this.sb.append(" transform='").append(getSVGTransform(
this.transform)).append('\'');
}
- String clip = getClipPathRef();
- if (!clip.isEmpty()) {
- this.sb.append(' ').append(clip);
+ String clipPathRef = getClipPathRef();
+ if (!clipPathRef.isEmpty()) {
+ this.sb.append(' ').append(clipPathRef);
}
this.sb.append("/>");
} else if (s instanceof Path2D) {
@@ -1135,14 +1127,14 @@ public final class SVGGraphics2D extends Graphics2D {
this.sb.append("<g");
appendOptionalElementIDFromHint(this.sb);
this.sb.append(" style='").append(strokeStyle())
- .append(";fill:none").append("'");
+ .append(";fill:none'");
if (!this.transform.isIdentity()) {
this.sb.append(" transform='").append(getSVGTransform(
this.transform)).append('\'');
}
- String clip = getClipPathRef();
- if (!clip.isEmpty()) {
- this.sb.append(' ').append(clip);
+ String clipPathRef = getClipPathRef();
+ if (!clipPathRef.isEmpty()) {
+ this.sb.append(' ').append(clipPathRef);
}
this.sb.append(">");
this.sb.append("<path ").append(getSVGPathData(path)).append("/>");
@@ -1181,9 +1173,9 @@ public final class SVGGraphics2D extends Graphics2D {
this.sb.append(" transform='").append(getSVGTransform(
this.transform)).append('\'');
}
- String clipStr = getClipPathRef();
- if (!clipStr.isEmpty()) {
- this.sb.append(' ').append(clipStr);
+ String clipPathRef = getClipPathRef();
+ if (!clipPathRef.isEmpty()) {
+ this.sb.append(' ').append(clipPathRef);
}
this.sb.append("/>");
} else if (s instanceof Ellipse2D) {
@@ -1200,9 +1192,9 @@ public final class SVGGraphics2D extends Graphics2D {
this.sb.append(" transform='").append(getSVGTransform(
this.transform)).append('\'');
}
- String clipStr = getClipPathRef();
- if (!clipStr.isEmpty()) {
- this.sb.append(' ').append(clipStr);
+ String clipPathRef = getClipPathRef();
+ if (!clipPathRef.isEmpty()) {
+ this.sb.append(' ').append(clipPathRef);
}
this.sb.append("/>");
} else if (s instanceof Path2D) {
@@ -1210,14 +1202,14 @@ public final class SVGGraphics2D extends Graphics2D {
this.sb.append("<g");
appendOptionalElementIDFromHint(this.sb);
this.sb.append(" style='").append(getSVGFillStyle());
- this.sb.append(";stroke:none").append('\'');
+ this.sb.append(";stroke:none'");
if (!this.transform.isIdentity()) {
this.sb.append(" transform='").append(getSVGTransform(
this.transform)).append('\'');
}
- String clipStr = getClipPathRef();
- if (!clipStr.isEmpty()) {
- this.sb.append(' ').append(clipStr);
+ String clipPathRef = getClipPathRef();
+ if (!clipPathRef.isEmpty()) {
+ this.sb.append(' ').append(clipPathRef);
}
this.sb.append('>');
this.sb.append("<path ").append(getSVGPathData(path)).append("/>");
@@ -1337,10 +1329,10 @@ public final class SVGGraphics2D extends Graphics2D {
private String rgbaColorStr(Color c) {
StringBuilder b = new StringBuilder("rgba(");
double alphaPercent = c.getAlpha() / 255.0;
- b.append(c.getRed()).append(",").append(c.getGreen()).append(",")
+ b.append(c.getRed()).append(',').append(c.getGreen()).append(',')
.append(c.getBlue());
- b.append(",").append(transformDP(alphaPercent));
- b.append(")");
+ b.append(',').append(transformDP(alphaPercent));
+ b.append(')');
return b.toString();
}
@@ -1351,7 +1343,7 @@ public final class SVGGraphics2D extends Graphics2D {
/**
* Returns a stroke style string based on the current stroke and
* alpha settings. Implementation note: the last attribute in the string
- * will not have a semi-colon after it.
+ * will not have a semicolon after it.
*
* @return A stroke style string.
*/
@@ -1406,7 +1398,9 @@ public final class SVGGraphics2D extends Graphics2D {
if (dashArray != null && dashArray.length != 0) {
b.append(";stroke-dasharray:");
for (int i = 0; i < dashArray.length; i++) {
- if (i != 0) b.append(",");
+ if (i != 0) {
+ b.append(",");
+ }
b.append(dashArray[i]);
}
}
@@ -1426,7 +1420,7 @@ public final class SVGGraphics2D extends Graphics2D {
* Returns the alpha value of the current {@code paint}, or {@code 1.0f} if
* it is not an instance of {@code Color}.
*
- * @return The alpha value (in the range {@code 0.0} to {@code 1.0}.
+ * @return The alpha value (in the range {@code 0.0} to {@code 1.0}).
*/
private float getColorAlpha() {
if (this.paint instanceof Color) {
@@ -1558,7 +1552,6 @@ public final class SVGGraphics2D extends Graphics2D {
b.append(" letter-spacing: ").append(geomDP(spacing)).append(';');
}
}
-
return b.toString();
}
@@ -1650,7 +1643,7 @@ public final class SVGGraphics2D extends Graphics2D {
}
String clipStr = getClipPathRef();
if (!clipStr.isEmpty()) {
- this.sb.append(' ').append(getClipPathRef());
+ this.sb.append(' ').append(clipStr);
}
this.sb.append(">");
this.sb.append(SVGUtils.escapeForXML(str)).append("</text>");
@@ -2206,7 +2199,7 @@ public final class SVGGraphics2D extends Graphics2D {
@Override
public void drawArc(int x, int y, int width, int height, int startAngle,
int arcAngle) {
- setArc(x, y, width, height, startAngle, arcAngle);
+ this.arc.setArc(x, y, width, height, startAngle, arcAngle, Arc2D.OPEN);
draw(this.arc);
}
@@ -2228,7 +2221,7 @@ public final class SVGGraphics2D extends Graphics2D {
@Override
public void fillArc(int x, int y, int width, int height, int startAngle,
int arcAngle) {
- setArc(x, y, width, height, startAngle, arcAngle);
+ this.arc.setArc(x, y, width, height, startAngle, arcAngle, Arc2D.PIE);
fill(this.arc);
}
@@ -2376,8 +2369,8 @@ public final class SVGGraphics2D extends Graphics2D {
appendOptionalElementIDFromHint(this.sb);
this.sb.append(" xlink:href='");
this.sb.append(href).append('\'');
- String clip = getClipPathRef();
- if (!clip.isEmpty()) {
+ String clipPathRef = getClipPathRef();
+ if (!clipPathRef.isEmpty()) {
this.sb.append(' ').append(getClipPathRef());
}
if (!this.transform.isIdentity()) {
@@ -2398,8 +2391,8 @@ public final class SVGGraphics2D extends Graphics2D {
this.sb.append(Base64.getEncoder().encodeToString(getPNGBytes(
img)));
this.sb.append('\'');
- String clip = getClipPathRef();
- if (!clip.isEmpty()) {
+ String clipPathRef = getClipPathRef();
+ if (!clipPathRef.isEmpty()) {
this.sb.append(' ').append(getClipPathRef());
}
if (!this.transform.isIdentity()) {
@@ -2694,10 +2687,9 @@ public final class SVGGraphics2D extends Graphics2D {
if (viewBox != null) {
svg.append(" viewBox='").append(viewBox.valueStr(this.geomDoubleConverter)).append('\'');
if (preserveAspectRatio != null) {
- svg.append(" preserveAspectRatio='")
- .append(preserveAspectRatio.toString());
+ svg.append(" preserveAspectRatio='").append(preserveAspectRatio);
if (meetOrSlice != null) {
- svg.append(' ').append(meetOrSlice.toString());
+ svg.append(' ').append(meetOrSlice);
}
svg.append('\'');
}
@@ -2707,17 +2699,14 @@ public final class SVGGraphics2D extends Graphics2D {
// only need to write DEFS if there is something to include
if (isDefsOutputRequired()) {
StringBuilder defs = new StringBuilder("<defs>");
- for (GradientPaintKey key : this.gradientPaints.keySet()) {
- defs.append(getLinearGradientElement(this.gradientPaints.get(key),
- key.getPaint()));
+ for (var entry : this.gradientPaints.entrySet()) {
+ defs.append(getLinearGradientElement(entry.getValue(), entry.getKey().getPaint()));
}
- for (LinearGradientPaintKey key : this.linearGradientPaints.keySet()) {
- defs.append(getLinearGradientElement(
- this.linearGradientPaints.get(key), key.getPaint()));
+ for (var entry : this.linearGradientPaints.entrySet()) {
+ defs.append(getLinearGradientElement(entry.getValue(), entry.getKey().getPaint()));
}
- for (RadialGradientPaintKey key : this.radialGradientPaints.keySet()) {
- defs.append(getRadialGradientElement(
- this.radialGradientPaints.get(key), key.getPaint()));
+ for (var entry : this.radialGradientPaints.entrySet()) {
+ defs.append(getRadialGradientElement(entry.getValue(), entry.getKey().getPaint()));
}
for (int i = 0; i < this.clipPaths.size(); i++) {
StringBuilder b = new StringBuilder("<clipPath id='")
@@ -2725,7 +2714,7 @@ public final class SVGGraphics2D extends Graphics2D {
.append("'>");
b.append("<path ").append(this.clipPaths.get(i)).append("/>");
b.append("</clipPath>");
- defs.append(b.toString());
+ defs.append(b);
}
defs.append("</defs>");
svg.append(defs);
@@ -2738,11 +2727,11 @@ public final class SVGGraphics2D extends Graphics2D {
/**
* Returns {@code true} if there are items that need to be written to the
* DEFS element, and {@code false} otherwise.
- *
- * @return A boolean.
+ *
+ * @return A boolean.
*/
private boolean isDefsOutputRequired() {
- return !(this.gradientPaints.isEmpty() && this.linearGradientPaints.isEmpty()
+ return !(this.gradientPaints.isEmpty() && this.linearGradientPaints.isEmpty()
&& this.radialGradientPaints.isEmpty() && this.clipPaths.isEmpty());
}
@@ -2973,29 +2962,6 @@ public final class SVGGraphics2D extends Graphics2D {
arcWidth, arcHeight);
}
}
-
- /**
- * Sets the attributes of the reusable {@link Arc2D} object that is used by
- * {@link #drawArc(int, int, int, int, int, int)} and
- * {@link #fillArc(int, int, int, int, int, int)} methods.
- *
- * @param x the x-coordinate.
- * @param y the y-coordinate.
- * @param width the width.
- * @param height the height.
- * @param startAngle the start angle in degrees, 0 = 3 o'clock.
- * @param arcAngle the angle (anticlockwise) in degrees.
- */
- private void setArc(int x, int y, int width, int height, int startAngle,
- int arcAngle) {
- if (this.arc == null) {
- this.arc = new Arc2D.Double(x, y, width, height, startAngle,
- arcAngle, Arc2D.PIE);
- } else {
- this.arc.setArc(x, y, width, height, startAngle, arcAngle,
- Arc2D.PIE);
- }
- }
/**
* Sets the attributes of the reusable {@link Ellipse2D} object that is
=====================================
src/main/java/org/jfree/svg/SVGGraphicsConfiguration.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
=====================================
src/main/java/org/jfree/svg/SVGGraphicsDevice.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
@@ -42,7 +42,7 @@ public class SVGGraphicsDevice extends GraphicsDevice {
private final String id;
- GraphicsConfiguration defaultConfig;
+ private final GraphicsConfiguration defaultConfig;
/**
* Creates a new instance.
=====================================
src/main/java/org/jfree/svg/SVGHints.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
@@ -492,15 +492,8 @@ public final class SVGHints {
hintsClass = Class.forName(className);
Field f = hintsClass.getDeclaredField(fieldName);
return (RenderingHints.Key) f.get(null);
- } catch (ClassNotFoundException e) {
- return null;
- } catch (NoSuchFieldException ex) {
- return null;
- } catch (SecurityException ex) {
- return null;
- } catch (IllegalArgumentException ex) {
- return null;
- } catch (IllegalAccessException ex) {
+ } catch (ClassNotFoundException | NoSuchFieldException | SecurityException | IllegalArgumentException |
+ IllegalAccessException e) {
return null;
}
}
@@ -560,9 +553,7 @@ public final class SVGHints {
|| VALUE_TEXT_RENDERING_PRECISION.equals(val)
|| VALUE_TEXT_RENDERING_SPEED.equals(val);
case 2: // KEY_IMAGE:URL
- return val == null || val instanceof String;
case 3: // KEY_ELEMENT_ID
- return val == null || val instanceof String;
case 4: // KEY_BEGIN_GROUP
return val == null || val instanceof String;
case 5: // KEY_END_GROUP
=====================================
src/main/java/org/jfree/svg/SVGUnits.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
=====================================
src/main/java/org/jfree/svg/SVGUtils.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
@@ -38,6 +38,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
import java.util.function.DoubleFunction;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -140,7 +141,7 @@ public class SVGUtils {
if (zip) {
os = new GZIPOutputStream(os);
}
- OutputStreamWriter osw = new OutputStreamWriter(os, "UTF-8");
+ OutputStreamWriter osw = new OutputStreamWriter(os, StandardCharsets.UTF_8);
writer = new BufferedWriter(osw);
writer.write("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
writer.write(svgElement + "\n");
@@ -170,7 +171,7 @@ public class SVGUtils {
BufferedWriter writer = null;
try {
FileOutputStream fos = new FileOutputStream(file);
- OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
+ OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
writer = new BufferedWriter(osw);
writer.write("<!DOCTYPE html>\n");
writer.write("<html>\n");
=====================================
src/main/java/org/jfree/svg/StandardFontFunction.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
=====================================
src/main/java/org/jfree/svg/ViewBox.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
=====================================
src/main/java/org/jfree/svg/util/Args.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
=====================================
src/main/java/org/jfree/svg/util/DoubleConverter.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
=====================================
src/main/java/org/jfree/svg/util/GradientPaintKey.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
=====================================
src/main/java/org/jfree/svg/util/GraphicsUtils.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
@@ -151,8 +151,8 @@ public final class GraphicsUtils {
Hashtable properties = new Hashtable();
String[] keys = img.getPropertyNames();
if (keys != null) {
- for (int i = 0; i < keys.length; i++) {
- properties.put(keys[i], img.getProperty(keys[i]));
+ for (String key : keys) {
+ properties.put(key, img.getProperty(key));
}
}
BufferedImage result = new BufferedImage(cm, raster,
=====================================
src/main/java/org/jfree/svg/util/LinearGradientPaintKey.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
@@ -81,10 +81,10 @@ public class LinearGradientPaintKey {
if (obj == this) {
return true;
}
- if (! (obj instanceof LinearGradientPaint)) {
+ if (! (obj instanceof LinearGradientPaintKey)) {
return false;
}
- LinearGradientPaint that = (LinearGradientPaint) obj;
+ LinearGradientPaint that = ((LinearGradientPaintKey) obj).paint;
if (!this.paint.getStartPoint().equals(that.getStartPoint())) {
return false;
}
=====================================
src/main/java/org/jfree/svg/util/RadialGradientPaintKey.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
@@ -79,10 +79,10 @@ public class RadialGradientPaintKey {
if (obj == this) {
return true;
}
- if (! (obj instanceof RadialGradientPaint)) {
+ if (! (obj instanceof RadialGradientPaintKey)) {
return false;
}
- RadialGradientPaint that = (RadialGradientPaint) obj;
+ RadialGradientPaint that = ((RadialGradientPaintKey) obj).paint;
if (!this.paint.getCenterPoint().equals(that.getCenterPoint())) {
return false;
}
=====================================
src/test/java/org/jfree/svg/TestDoubleConversion.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
=====================================
src/test/java/org/jfree/svg/TestGeneral.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
=====================================
src/test/java/org/jfree/svg/TestSVGGraphics2D.java
=====================================
@@ -1,8 +1,8 @@
/* ===================================================
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
- *
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ *
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
@@ -32,23 +32,7 @@
package org.jfree.svg;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.fail;
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.GradientPaint;
-import java.awt.Graphics2D;
-import java.awt.Image;
-import java.awt.Rectangle;
-import java.awt.RenderingHints;
-import java.awt.Shape;
+import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
@@ -57,12 +41,14 @@ import java.awt.image.BufferedImage;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;
+import static org.junit.jupiter.api.Assertions.*;
+
/**
* Some tests for a Graphics2D implementation. All tests should pass with the
* Graphics2D instance from a BufferedImage (which we can treat as a reference
* implementation).
*/
-public class TestSVGGraphics2D {
+class TestSVGGraphics2D {
/**
* Change this to true to test against a reference Graphics2D
@@ -90,7 +76,7 @@ public class TestSVGGraphics2D {
* Checks that the default transform is an identity transform.
*/
@Test
- public void checkDefaultTransform() {
+ void checkDefaultTransform() {
assertEquals(new AffineTransform(), g2.getTransform());
}
@@ -100,7 +86,7 @@ public class TestSVGGraphics2D {
* should be returning a copy of the actual transform object.
*/
@Test
- public void checkGetTransformSafety() {
+ void checkGetTransformSafety() {
AffineTransform t = g2.getTransform();
t.rotate(Math.PI);
assertNotEquals(t, g2.getTransform());
@@ -111,7 +97,7 @@ public class TestSVGGraphics2D {
* A basic check that setTransform() does indeed update the transform.
*/
@Test
- public void setTransform() {
+ void setTransform() {
AffineTransform t = new AffineTransform(1, 2, 3, 4, 5, 6);
g2.setTransform(t);
assertEquals(t, g2.getTransform());
@@ -134,7 +120,7 @@ public class TestSVGGraphics2D {
* AffineTransform.
*/
@Test
- public void checkSetTransformSafety() {
+ void checkSetTransformSafety() {
AffineTransform t = AffineTransform.getTranslateInstance(1.0, 2.0);
g2.setTransform(t);
assertEquals(t, g2.getTransform());
@@ -143,7 +129,7 @@ public class TestSVGGraphics2D {
}
@Test
- public void checkSetNonInvertibleTransform() {
+ void checkSetNonInvertibleTransform() {
AffineTransform t = AffineTransform.getScaleInstance(0.0, 0.0);
g2.setTransform(t);
assertEquals(t, g2.getTransform());
@@ -164,7 +150,7 @@ public class TestSVGGraphics2D {
* translation.
*/
@Test
- public void checkTransform() {
+ void checkTransform() {
AffineTransform t = new AffineTransform();
this.g2.setTransform(t);
this.g2.translate(30, 30);
@@ -181,7 +167,7 @@ public class TestSVGGraphics2D {
}
@Test
- public void checkTransformNull() {
+ void checkTransformNull() {
try {
this.g2.transform(null);
fail("Expected a NullPointerException.");
@@ -194,7 +180,7 @@ public class TestSVGGraphics2D {
* Basic checks for the scale(x, y) method.
*/
@Test
- public void scale() {
+ void scale() {
g2.scale(0.5, 2.0);
assertEquals(AffineTransform.getScaleInstance(0.5, 2.0),
g2.getTransform());
@@ -208,7 +194,7 @@ public class TestSVGGraphics2D {
* gives the correct values.
*/
@Test
- public void translateFollowedByScale() {
+ void translateFollowedByScale() {
g2.translate(2, 3);
assertEquals(AffineTransform.getTranslateInstance(2.0, 3.0),
g2.getTransform());
@@ -222,7 +208,7 @@ public class TestSVGGraphics2D {
* gives the correct values.
*/
@Test
- public void scaleFollowedByTranslate() {
+ void scaleFollowedByTranslate() {
g2.scale(2, 2);
assertEquals(AffineTransform.getScaleInstance(2.0, 2.0),
g2.getTransform());
@@ -234,7 +220,7 @@ public class TestSVGGraphics2D {
private static final double EPSILON = 0.000000001;
@Test
- public void scaleFollowedByRotate() {
+ void scaleFollowedByRotate() {
g2.scale(2, 2);
assertEquals(AffineTransform.getScaleInstance(2.0, 2.0),
g2.getTransform());
@@ -249,7 +235,7 @@ public class TestSVGGraphics2D {
}
@Test
- public void rotateFollowedByScale() {
+ void rotateFollowedByScale() {
g2.rotate(Math.PI);
assertEquals(AffineTransform.getRotateInstance(Math.PI),
g2.getTransform());
@@ -264,20 +250,20 @@ public class TestSVGGraphics2D {
* a new object each time.
*/
@Test
- public void checkGetClipSafety() {
+ void checkGetClipSafety() {
Rectangle2D r = new Rectangle2D.Double(0, 0, 1, 1);
this.g2.setClip(r);
Shape s = this.g2.getClip();
- assertFalse(r == s);
+ assertNotSame(r, s);
Shape s2 = this.g2.getClip();
- assertFalse(s == s2);
+ assertNotSame(s, s2);
}
/**
* The default user clip should be {@code null}.
*/
@Test
- public void checkDefaultClip() {
+ void checkDefaultClip() {
assertNull(g2.getClip(), "Default user clip should be null.");
}
@@ -286,7 +272,7 @@ public class TestSVGGraphics2D {
* the bounds.
*/
@Test
- public void checkGetClipBounds() {
+ void checkGetClipBounds() {
Rectangle2D r = new Rectangle2D.Double(0.25, 0.25, 0.5, 0.5);
this.g2.setClip(r);
assertEquals(new Rectangle(0, 0, 1, 1), this.g2.getClipBounds());
@@ -297,7 +283,7 @@ public class TestSVGGraphics2D {
* {@code null}.
*/
@Test
- public void checkGetClipBoundsWhenClipIsNull() {
+ void checkGetClipBoundsWhenClipIsNull() {
this.g2.setClip(null);
assertNull(this.g2.getClipBounds());
}
@@ -307,7 +293,7 @@ public class TestSVGGraphics2D {
* existing clip region.
*/
@Test
- public void checkClip() {
+ void checkClip() {
Rectangle2D r = new Rectangle2D.Double(1.0, 1.0, 3.0, 3.0);
this.g2.setClip(r);
this.g2.clip(new Rectangle2D.Double(0.0, 0.0, 2.0, 2.0));
@@ -320,7 +306,7 @@ public class TestSVGGraphics2D {
* the clip is empty.
*/
@Test
- public void checkNonIntersectingClip() {
+ void checkNonIntersectingClip() {
Rectangle2D r = new Rectangle2D.Double(1.0, 1.0, 3.0, 3.0);
this.g2.setClip(r);
this.g2.clip(new Rectangle2D.Double(5.0, 5.0, 1.0, 1.0));
@@ -332,7 +318,7 @@ public class TestSVGGraphics2D {
* modified clip.
*/
@Test
- public void checkClipAfterScaling() {
+ void checkClipAfterScaling() {
Rectangle2D r = new Rectangle2D.Double(1, 2, 3, 0.5);
this.g2.setClip(r);
assertEquals(r, this.g2.getClip().getBounds2D());
@@ -352,7 +338,7 @@ public class TestSVGGraphics2D {
* Translating will change the existing clip.
*/
@Test
- public void checkClipAfterTranslate() {
+ void checkClipAfterTranslate() {
Rectangle2D clip = new Rectangle2D.Double(0.0, 0.0, 1.0, 1.0);
this.g2.setClip(clip);
assertEquals(clip, this.g2.getClip().getBounds2D());
@@ -362,7 +348,7 @@ public class TestSVGGraphics2D {
}
@Test
- public void checkSetClipAfterTranslate() {
+ void checkSetClipAfterTranslate() {
this.g2.translate(1.0, 2.0);
this.g2.setClip(0, 0, 1, 1);
assertEquals(new Rectangle(0, 0, 1, 1), this.g2.getClip().getBounds());
@@ -374,7 +360,7 @@ public class TestSVGGraphics2D {
* Transforming will change the reported clipping shape.
*/
@Test
- public void checkClipAfterTransform() {
+ void checkClipAfterTransform() {
Rectangle2D clip = new Rectangle2D.Double(0, 0, 1, 1);
this.g2.setClip(clip);
assertEquals(clip, this.g2.getClip().getBounds2D());
@@ -394,7 +380,7 @@ public class TestSVGGraphics2D {
* does that make sense? Matching the behaviour for now.
*/
@Test
- public void checkClipWithLine2D() {
+ void checkClipWithLine2D() {
Rectangle2D r = new Rectangle2D.Double(1.0, 1.0, 3.0, 3.0);
this.g2.setClip(r);
this.g2.clip(new Line2D.Double(1.0, 2.0, 3.0, 4.0));
@@ -408,13 +394,10 @@ public class TestSVGGraphics2D {
* latest API docs (https://bugs.java.com/bugdatabase/view_bug.do?bug_id=6206189).
*/
@Test
- public void checkClipWithNullArgument() {
-
+ void checkClipWithNullArgument() {
// when there is a current clip set, a null pointer exception is expected
this.g2.setClip(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
- Exception exception = assertThrows(NullPointerException.class, () -> {
- this.g2.clip(null);
- });
+ assertThrows(NullPointerException.class, () -> this.g2.clip(null));
this.g2.setClip(null);
try {
@@ -428,7 +411,7 @@ public class TestSVGGraphics2D {
* A simple check for a call to clipRect().
*/
@Test
- public void checkClipRect() {
+ void checkClipRect() {
Rectangle2D clip = new Rectangle2D.Double(0, 0, 5, 5);
this.g2.setClip(clip);
@@ -438,7 +421,7 @@ public class TestSVGGraphics2D {
}
@Test
- public void checkClipRectParams() {
+ void checkClipRectParams() {
Rectangle2D clip = new Rectangle2D.Double(0, 0, 5, 5);
this.g2.setClip(clip);
@@ -453,7 +436,7 @@ public class TestSVGGraphics2D {
}
@Test
- public void checkDrawStringWithNullString() {
+ void checkDrawStringWithNullString() {
try {
g2.drawString((String) null, 1, 2);
fail("There should be a NullPointerException.");
@@ -469,7 +452,7 @@ public class TestSVGGraphics2D {
}
@Test
- public void checkDrawStringWithEmptyString() {
+ void checkDrawStringWithEmptyString() {
// this should not cause any exception
g2.setRenderingHint(SVGHints.KEY_DRAW_STRING_TYPE, SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
g2.drawString("", 1, 2);
@@ -480,8 +463,8 @@ public class TestSVGGraphics2D {
/**
* Some checks for the create() method.
*/
- @Test
- public void checkCreate() {
+ @Test
+ void checkCreate() {
this.g2.setClip(new Rectangle(1, 2, 3, 4));
Graphics2D copy = (Graphics2D) g2.create();
assertEquals(copy.getBackground(), g2.getBackground());
@@ -504,13 +487,13 @@ public class TestSVGGraphics2D {
* Paint instance.
*/
@Test
- public void checkSetPaintSafety() {
+ void checkSetPaintSafety() {
Point2D pt1 = new Point2D.Double(1.0, 2.0);
Point2D pt2 = new Point2D.Double(3.0, 4.0);
GradientPaint gp = new GradientPaint(pt1, Color.RED, pt2, Color.BLUE);
this.g2.setPaint(gp);
assertEquals(gp, this.g2.getPaint());
- assertTrue(gp == this.g2.getPaint());
+ assertSame(gp, this.g2.getPaint());
pt1.setLocation(7.0, 7.0);
assertEquals(gp, this.g2.getPaint());
}
@@ -520,7 +503,7 @@ public class TestSVGGraphics2D {
* impact on the current paint (that is, the call is silently ignored).
*/
@Test
- public void checkSetPaintNull() {
+ void checkSetPaintNull() {
this.g2.setPaint(Color.RED);
// this next call should have no impact
this.g2.setPaint(null);
@@ -532,7 +515,7 @@ public class TestSVGGraphics2D {
* background color.
*/
@Test
- public void checkSetPaintAlsoUpdatesColorButNotBackground() {
+ void checkSetPaintAlsoUpdatesColorButNotBackground() {
Color existingBackground = this.g2.getBackground();
this.g2.setPaint(Color.MAGENTA);
assertEquals(Color.MAGENTA, this.g2.getPaint());
@@ -545,7 +528,7 @@ public class TestSVGGraphics2D {
* Color, then the existing color remains unchanged.
*/
@Test
- public void checkSetPaintDoesNotUpdateColor() {
+ void checkSetPaintDoesNotUpdateColor() {
GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.BLUE);
this.g2.setColor(Color.MAGENTA);
@@ -561,7 +544,7 @@ public class TestSVGGraphics2D {
* @see #checkSetPaintAlsoUpdatesColorButNotBackground()
*/
@Test
- public void checkSetColorAlsoUpdatesPaint() {
+ void checkSetColorAlsoUpdatesPaint() {
this.g2.setColor(Color.MAGENTA);
assertEquals(Color.MAGENTA, this.g2.getPaint());
assertEquals(Color.MAGENTA, this.g2.getColor());
@@ -573,7 +556,7 @@ public class TestSVGGraphics2D {
* setPaint() method.
*/
@Test
- public void checkSetColorNull() {
+ void checkSetColorNull() {
this.g2.setColor(Color.RED);
this.g2.setColor(null);
assertEquals(Color.RED, this.g2.getColor());
@@ -583,11 +566,11 @@ public class TestSVGGraphics2D {
* Setting the background color does not change the color or paint.
*/
@Test
- public void checkSetBackground() {
+ void checkSetBackground() {
this.g2.setBackground(Color.CYAN);
assertEquals(Color.CYAN, this.g2.getBackground());
- assertFalse(Color.CYAN.equals(this.g2.getColor()));
- assertFalse(Color.CYAN.equals(this.g2.getPaint()));
+ assertNotEquals(Color.CYAN, this.g2.getColor());
+ assertNotEquals(Color.CYAN, this.g2.getPaint());
}
/**
@@ -595,10 +578,10 @@ public class TestSVGGraphics2D {
* allowing null (this is inconsistent with the behaviour of setColor()).
*/
@Test
- public void checkSetBackgroundNull() {
+ void checkSetBackgroundNull() {
this.g2.setBackground(Color.RED);
this.g2.setBackground(null);
- assertEquals(null, this.g2.getBackground());
+ assertNull(this.g2.getBackground());
}
/**
@@ -608,7 +591,7 @@ public class TestSVGGraphics2D {
* is no easy way to test for that.
*/
@Test
- public void checkClearRectWithNullBackground() {
+ void checkClearRectWithNullBackground() {
this.g2.setBackground(null);
this.g2.clearRect(1, 2, 3, 4);
//no exceptions and we're good
@@ -619,7 +602,7 @@ public class TestSVGGraphics2D {
* observed to throw an IllegalArgumentException.
*/
@Test
- public void checkSetCompositeNull() {
+ void checkSetCompositeNull() {
try {
this.g2.setComposite(null);
fail("Expected an IllegalArgumentException.");
@@ -629,7 +612,7 @@ public class TestSVGGraphics2D {
}
@Test
- public void checkSetStrokeNull() {
+ void checkSetStrokeNull() {
try {
this.g2.setStroke(null);
fail("Expected an IllegalArgumentException.");
@@ -642,7 +625,7 @@ public class TestSVGGraphics2D {
* Basic check of set then get.
*/
@Test
- public void checkSetRenderingHint() {
+ void checkSetRenderingHint() {
this.g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
RenderingHints.VALUE_STROKE_PURE);
assertEquals(RenderingHints.VALUE_STROKE_PURE,
@@ -654,7 +637,7 @@ public class TestSVGGraphics2D {
* NullPointerException when the key is null.
*/
@Test
- public void checkSetRenderingHintWithNullKey() {
+ void checkSetRenderingHintWithNullKey() {
try {
this.g2.setRenderingHint(null, "XYZ");
fail("NullPointerException is expected here.");
@@ -668,7 +651,7 @@ public class TestSVGGraphics2D {
* and return null in that case.
*/
@Test
- public void checkGetRenderingHintWithNullKey() {
+ void checkGetRenderingHintWithNullKey() {
assertNull(this.g2.getRenderingHint(null));
}
@@ -676,7 +659,7 @@ public class TestSVGGraphics2D {
* Check setting a hint with a value that doesn't match the key.
*/
@Test
- public void checkSetRenderingHintWithInconsistentValue() {
+ void checkSetRenderingHintWithInconsistentValue() {
try {
this.g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
RenderingHints.VALUE_ANTIALIAS_DEFAULT);
@@ -691,7 +674,7 @@ public class TestSVGGraphics2D {
* changing it will not affect the state of the Graphics2D instance.
*/
@Test
- public void checkGetRenderingHintsSafety() {
+ void checkGetRenderingHintsSafety() {
this.g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_OFF);
RenderingHints hints = this.g2.getRenderingHints();
@@ -702,7 +685,7 @@ public class TestSVGGraphics2D {
}
@Test
- public void checkSetRenderingHintsNull() {
+ void checkSetRenderingHintsNull() {
try {
this.g2.setRenderingHints(null);
fail("NullPointerException expected.");
@@ -712,7 +695,7 @@ public class TestSVGGraphics2D {
}
@Test
- public void checkHit() {
+ void checkHit() {
Shape shape = new Rectangle2D.Double(0.0, 0.0, 1.0, 1.0);
Rectangle r = new Rectangle(2, 2, 2, 2);
assertFalse(this.g2.hit(r, shape, false));
@@ -721,7 +704,7 @@ public class TestSVGGraphics2D {
}
@Test
- public void checkHitForOutline() {
+ void checkHitForOutline() {
Shape shape = new Rectangle2D.Double(0.0, 0.0, 3.0, 3.0);
Rectangle r = new Rectangle(1, 1, 1, 1);
assertFalse(this.g2.hit(r, shape, true));
@@ -736,7 +719,7 @@ public class TestSVGGraphics2D {
* to null does not change the current font setting.
*/
@Test
- public void checkSetFontNull() {
+ void checkSetFontNull() {
Font f = new Font("Serif", Font.PLAIN, 8);
this.g2.setFont(f);
assertEquals(f, this.g2.getFont());
@@ -745,7 +728,7 @@ public class TestSVGGraphics2D {
}
@Test
- public void checkDefaultStroke() {
+ void checkDefaultStroke() {
BasicStroke s = (BasicStroke) this.g2.getStroke();
assertEquals(BasicStroke.CAP_SQUARE, s.getEndCap());
assertEquals(1.0f, s.getLineWidth(), EPSILON);
@@ -756,7 +739,7 @@ public class TestSVGGraphics2D {
* Check that a null GlyphVector throws a {@code NullPointerException}.
*/
@Test
- public void drawGlyphVectorNull() {
+ void drawGlyphVectorNull() {
try {
g2.drawGlyphVector(null, 10, 10);
fail("Expecting a NullPointerException.");
@@ -769,7 +752,7 @@ public class TestSVGGraphics2D {
* Check the shear() method.
*/
@Test
- public void shear() {
+ void shear() {
g2.setTransform(new AffineTransform());
g2.shear(2.0, 3.0);
assertEquals(new AffineTransform(1, 3, 2, 1, 0, 0), g2.getTransform());
@@ -779,7 +762,7 @@ public class TestSVGGraphics2D {
* Checks a translate() followed by a shear().
*/
@Test
- public void shearFollowingTranslate() {
+ void shearFollowingTranslate() {
g2.setTransform(new AffineTransform());
g2.translate(10.0, 20.0);
g2.shear(2.0, 3.0);
@@ -787,7 +770,7 @@ public class TestSVGGraphics2D {
}
@Test
- public void drawImageWithNullBackground() {
+ void drawImageWithNullBackground() {
Image img = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
g2.drawImage(img, 10, 10, null, null);
assertTrue(true); // won't get here if there's an exception above
@@ -797,14 +780,14 @@ public class TestSVGGraphics2D {
* https://github.com/jfree/jfreesvg/issues/6
*/
@Test
- public void drawImageWithNullTransform() {
+ void drawImageWithNullTransform() {
Image img = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
g2.drawImage(img, null, null);
assertTrue(true); // won't get here if there's an exception above
}
@Test
- public void drawImageWithNullImage() {
+ void drawImageWithNullImage() {
// API docs say method does nothing if img is null
// still seems to return true
assertTrue(g2.drawImage(null, 10, 20, null));
@@ -816,7 +799,7 @@ public class TestSVGGraphics2D {
}
@Test
- public void drawImageWithNegativeDimensions() {
+ void drawImageWithNegativeDimensions() {
Image img = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
assertTrue(g2.drawImage(img, 1, 2, -10, 10, null));
assertTrue(g2.drawImage(img, 1, 2, 10, -10, null));
@@ -828,7 +811,7 @@ public class TestSVGGraphics2D {
* graphics state so clipping can impact other attributes.
*/
@Test
- public void checkColorAfterSetClip() {
+ void checkColorAfterSetClip() {
this.g2.setColor(Color.RED);
assertEquals(Color.RED, this.g2.getColor());
this.g2.setClip(0, 0, 10, 10);
@@ -843,7 +826,7 @@ public class TestSVGGraphics2D {
* See https://github.com/jfree/fxgraphics2d/issues/6
*/
@Test
- public void checkFontAfterSetClip() {
+ void checkFontAfterSetClip() {
this.g2.setFont(new Font(Font.DIALOG, Font.BOLD, 12));
assertEquals(new Font(Font.DIALOG, Font.BOLD, 12), this.g2.getFont());
this.g2.setClip(0, 0, 10, 10);
@@ -858,7 +841,7 @@ public class TestSVGGraphics2D {
* See https://github.com/jfree/fxgraphics2d/issues/6
*/
@Test
- public void checkStrokeAfterSetClip() {
+ void checkStrokeAfterSetClip() {
this.g2.setStroke(new BasicStroke(1.0f));
assertEquals(new BasicStroke(1.0f), this.g2.getStroke());
this.g2.setClip(0, 0, 10, 10);
@@ -874,7 +857,7 @@ public class TestSVGGraphics2D {
* the results of text measurements performed via getFontMetrics().
*/
@Test
- public void testGetFontMetrics() {
+ void testGetFontMetrics() {
Font f = new Font(Font.SANS_SERIF, Font.PLAIN, 10);
FontMetrics fm = this.g2.getFontMetrics(f);
int w = fm.stringWidth("ABC");
@@ -888,7 +871,7 @@ public class TestSVGGraphics2D {
}
@Test
- public void drawImageWithNullImageOp() {
+ void drawImageWithNullImageOp() {
BufferedImage img = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
g2.drawImage(img, null, 2, 3);
assertTrue(true); // won't get here if there's an exception above
@@ -897,8 +880,8 @@ public class TestSVGGraphics2D {
/**
* API docs say the method does nothing when called with a null image.
*/
- @Test
- public void drawRenderedImageWithNullImage() {
+ @Test
+ void drawRenderedImageWithNullImage() {
g2.drawRenderedImage(null, AffineTransform.getTranslateInstance(0, 0));
assertTrue(true); // won't get here if there's an exception above
}
@@ -908,7 +891,7 @@ public class TestSVGGraphics2D {
* should not throw an exception.
*/
@Test
- public void fillOrStrokeRectangleWithNegativeWidthMustNotFail() {
+ void fillOrStrokeRectangleWithNegativeWidthMustNotFail() {
g2.draw(new Rectangle2D.Double(0, 0, 0, 10));
g2.draw(new Rectangle2D.Double(0, 0, -10, 10));
g2.fill(new Rectangle2D.Double(0, 0, 0, 10));
@@ -921,16 +904,16 @@ public class TestSVGGraphics2D {
* should not throw an exception.
*/
@Test
- public void fillOrStrokeRectangleWithNegativeHeightMustNotFail() {
+ void fillOrStrokeRectangleWithNegativeHeightMustNotFail() {
g2.draw(new Rectangle2D.Double(0, 0, 0, 10));
- g2.draw(new Rectangle2D.Double(0, 0, -10, 10));
+ g2.draw(new Rectangle2D.Double(0, 0, 10, -10));
g2.fill(new Rectangle2D.Double(0, 0, 0, 10));
- g2.fill(new Rectangle2D.Double(0, 0, -10, 10));
+ g2.fill(new Rectangle2D.Double(0, 0, 10, -10));
assertTrue(true); // won't get here if there's an exception above
}
@Test
- public void checkClipAfterCreate() {
+ void checkClipAfterCreate() {
this.g2.setClip(10, 20, 30, 40);
assertEquals(new Rectangle(10, 20, 30, 40), g2.getClip().getBounds2D());
@@ -941,4 +924,47 @@ public class TestSVGGraphics2D {
assertEquals(new Rectangle(10, 20, 30, 40), g2.getClip().getBounds2D());
}
+ @Test
+ void checkGradientPaintRefGeneration() {
+ if (!(this.g2 instanceof SVGGraphics2D)) return;
+ SVGGraphics2D svg2 = (SVGGraphics2D) this.g2;
+ GradientPaint gp0 = new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE);
+ svg2.setPaint(gp0);
+ assertEquals(svg2.defsKeyPrefix + "gp0", svg2.gradientPaintRef);
+ GradientPaint gp1 = new GradientPaint(1.0f, 2.0f, Color.YELLOW, 3.0f, 4.0f, Color.GREEN);
+ svg2.setPaint(gp1);
+ assertEquals(svg2.defsKeyPrefix + "gp1", svg2.gradientPaintRef);
+ svg2.setPaint(gp0);
+ assertEquals(svg2.defsKeyPrefix + "gp0", svg2.gradientPaintRef);
+ }
+
+ @Test
+ void checkLinearGradientPaintRefGeneration() {
+ if (!(this.g2 instanceof SVGGraphics2D)) return;
+ SVGGraphics2D svg2 = (SVGGraphics2D) this.g2;
+ var lgp0 = new LinearGradientPaint(1.0f, 2.0f,3.0f, 4.0f, new float[] { 0.0f, 0.5f, 1.0f }, new Color[] { Color.RED, Color.BLUE, Color.GREEN });
+ svg2.setPaint(lgp0);
+ assertEquals(svg2.defsKeyPrefix + "lgp0", svg2.gradientPaintRef);
+ var lgp1 = new LinearGradientPaint(1.0f, 2.0f,3.0f, 4.0f, new float[] { 0.0f, 0.5f, 1.0f }, new Color[] { Color.YELLOW, Color.CYAN, Color.GRAY });
+ svg2.setPaint(lgp1);
+ assertEquals(svg2.defsKeyPrefix + "lgp1", svg2.gradientPaintRef);
+ svg2.setPaint(lgp0);
+ assertEquals(svg2.defsKeyPrefix + "lgp0", svg2.gradientPaintRef);
+ }
+
+ @Test
+ void checkRadialGradientPaintRefGeneration() {
+ if (!(this.g2 instanceof SVGGraphics2D)) return;
+ SVGGraphics2D svg2 = (SVGGraphics2D) this.g2;
+ var rgp0 = new RadialGradientPaint(1.0f, 2.0f, 3.0f, new float[] { 0.0f, 0.5f, 1.0f },
+ new Color[] { Color.RED, Color.BLUE, Color.GREEN });
+ svg2.setPaint(rgp0);
+ assertEquals(svg2.defsKeyPrefix + "rgp0", svg2.gradientPaintRef);
+ var rgp1 = new RadialGradientPaint(1.0f, 2.0f, 4.0f, new float[] { 0.0f, 0.5f, 1.0f },
+ new Color[] { Color.YELLOW, Color.CYAN, Color.GRAY });
+ svg2.setPaint(rgp1);
+ assertEquals(svg2.defsKeyPrefix + "rgp1", svg2.gradientPaintRef);
+ svg2.setPaint(rgp0);
+ assertEquals(svg2.defsKeyPrefix + "rgp0", svg2.gradientPaintRef);
+ }
}
=====================================
src/test/java/org/jfree/svg/util/ArgsTest.java
=====================================
@@ -2,7 +2,7 @@
* JFreeSVG : an SVG library for the Java(tm) platform
* ===================================================
*
- * (C)opyright 2013-2021, by David Gilbert. All rights reserved.
+ * (C)opyright 2013-present, by David Gilbert. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
@@ -45,15 +45,9 @@ public class ArgsTest {
*/
@Test
public void checkRequireFinitePositive() {
- assertThrows(IllegalArgumentException.class, () -> {
- Args.requireFinitePositive(0.0, "d");
- });
- assertThrows(IllegalArgumentException.class, () -> {
- Args.requireFinitePositive(Double.NEGATIVE_INFINITY, "d");
- });
- assertThrows(IllegalArgumentException.class, () -> {
- Args.requireFinitePositive(Double.NaN, "d");
- });
+ assertThrows(IllegalArgumentException.class, () -> Args.requireFinitePositive(0.0, "d"));
+ assertThrows(IllegalArgumentException.class, () -> Args.requireFinitePositive(Double.NEGATIVE_INFINITY, "d"));
+ assertThrows(IllegalArgumentException.class, () -> Args.requireFinitePositive(Double.NaN, "d"));
}
}
View it on GitLab: https://salsa.debian.org/java-team/jfreesvg/-/commit/d6469dbc73d3efcff06e3429a8ca8a136c1d05de
--
View it on GitLab: https://salsa.debian.org/java-team/jfreesvg/-/commit/d6469dbc73d3efcff06e3429a8ca8a136c1d05de
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20250226/6dd3d733/attachment.htm>
More information about the pkg-java-commits
mailing list