Skip to content

Commit

Permalink
Check old and new package names for JFreeSVG (bug #207)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfree committed Feb 14, 2021
1 parent fd4f5ea commit c38f65a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ History
- removed unused `URLUtilities` class ([#162](https://github.com/jfree/jfreechart/pull/162))
- fixed `LayeredBarRenderer` (bugs [#169](https://github.com/jfree/jfreechart/issues/169) and [#175](https://github.com/jfree/jfreechart/issues/175));
- minor fix for `DefaultPieDataset` (bugs [#212](https://github.com/jfree/jfreechart/issues/212))
- fix `isJFreeSVGAvailable()` method (bugs [#207](https://github.com/jfree/jfreechart/issues/207))
- update French translations (bug #186);
- fix "Save_as" entries in localisation files (bug #184);
- add flags for visibility of outliers in `BoxAndWhiskerRenderer` ([#79](https://github.com/jfree/jfreechart/pull/79));
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/org/jfree/chart/util/ExportUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2020, by Object Refinery Limited and Contributors.
* (C) Copyright 2000-2021, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
Expand All @@ -27,7 +27,7 @@
* ----------------
* ExportUtils.java
* ----------------
* (C) Copyright 2014-2020 by Object Refinery Limited and Contributors.
* (C) Copyright 2014-2021 by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
Expand Down Expand Up @@ -69,9 +69,14 @@ public class ExportUtils {
public static boolean isJFreeSVGAvailable() {
Class<?> svgClass = null;
try {
svgClass = Class.forName("org.jfree.graphics2d.svg.SVGGraphics2D");
svgClass = Class.forName("org.jfree.svg.SVGGraphics2D");
} catch (ClassNotFoundException e) {
// svgClass will be null so the function will return false
// see if there is maybe an older version of JFreeSVG (different package name)
try {
svgClass = Class.forName("org.jfree.graphics2d.svg.SVGGraphics2D");
} catch (ClassNotFoundException e2) {
// svgClass will be null so the function will return false
}
}
return (svgClass != null);
}
Expand Down Expand Up @@ -104,8 +109,7 @@ public static boolean isOrsonPDFAvailable() {
* @param h the chart height.
* @param file the output file ({@code null} not permitted).
*/
public static void writeAsSVG(Drawable drawable, int w, int h,
File file) {
public static void writeAsSVG(Drawable drawable, int w, int h, File file) {
if (!ExportUtils.isJFreeSVGAvailable()) {
throw new IllegalStateException(
"JFreeSVG is not present on the classpath.");
Expand Down

0 comments on commit c38f65a

Please sign in to comment.