Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package jfreechart for openSUSE:Factory checked in at 2025-02-21 21:36:40 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/jfreechart (Old) and /work/SRC/openSUSE:Factory/.jfreechart.new.1873 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "jfreechart" Fri Feb 21 21:36:40 2025 rev:4 rq:1247520 version:1.5.5 Changes: -------- --- /work/SRC/openSUSE:Factory/jfreechart/jfreechart.changes 2023-10-08 12:22:09.998458929 +0200 +++ /work/SRC/openSUSE:Factory/.jfreechart.new.1873/jfreechart.changes 2025-02-21 21:37:00.801851693 +0100 @@ -1,0 +2,8 @@ +Fri Feb 21 03:02:54 UTC 2025 - ming li <m...@suse.com> + +- Update to version 1.5.5 + * added XYBezierRenderer by Javier Robes + * fix cross-hair painting + * parameter range check for CompassPlot + +------------------------------------------------------------------- Old: ---- jfreechart-1.5.4.tar.gz New: ---- jfreechart-1.5.5.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ jfreechart.spec ++++++ --- /var/tmp/diff_new_pack.9nMDHQ/_old 2025-02-21 21:37:01.357874844 +0100 +++ /var/tmp/diff_new_pack.9nMDHQ/_new 2025-02-21 21:37:01.361875010 +0100 @@ -1,7 +1,7 @@ # # spec file for package jfreechart # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2025 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: jfreechart -Version: 1.5.4 +Version: 1.5.5 Release: 0 Summary: Java chart library License: LGPL-2.1-or-later ++++++ jfreechart-1.5.4.tar.gz -> jfreechart-1.5.5.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jfreechart-1.5.4/README.md new/jfreechart-1.5.5/README.md --- old/jfreechart-1.5.4/README.md 2023-01-08 17:10:37.000000000 +0100 +++ new/jfreechart-1.5.5/README.md 2024-06-23 17:53:17.000000000 +0200 @@ -1,7 +1,7 @@ JFreeChart ========== -Version 1.5.4, 8 January 2023. +Version 1.5.5, 23 June 2024. [](https://maven-badges.herokuapp.com/maven-central/org.jfree/jfreechart) @@ -33,7 +33,7 @@ <dependency> <groupId>org.jfree</groupId> <artifactId>jfreechart</artifactId> - <version>1.5.4</version> + <version>1.5.5</version> </dependency> @@ -56,6 +56,21 @@ History ------- +##### Version 1.5.5 (23 June 2024) +- added `XYBezierRenderer` by Javier Robes ([#286](https://github.com/jfree/jfreechart/pull/286)) +- fix cross-hair painting ([#340](https://github.com/jfree/jfreechart/issues/340)) +- parameter range check for `CompassPlot` ([#397](https://github.com/jfree/jfreechart/pull/397)) + +Note: some (supposed) security vulnerabilities have been reported for v1.5.4: + +- [CVE-2023-52070](https://nvd.nist.gov/vuln/detail/CVE-2023-52070) : an `ArrayIndexOutOfBoundsException` in `CompassPlot`\ + No fix is considered necessary, however ([#397](https://github.com/jfree/jfreechart/pull/397)) has been applied. + +- [CVE-2024-22949](https://nvd.nist.gov/vuln/detail/CVE-2024-22949) : a possible `NullPointerException` in `CategoryLineAnnotation`\ + No fix is considered necessary. + +- [CVE-2024-23076](https://nvd.nist.gov/vuln/detail/CVE-2024-23076) : a possible `NullPointerException` in `BubbleXYItemLabelGenerator`\ + No fix is considered necessary. ##### Version 1.5.4 (8 January 2023) - add new methods to access maps for datasets, renderers and axes in plots ([#201](https://github.com/jfree/jfreechart/issues/201)); @@ -68,7 +83,6 @@ - add argument checks for annotations ([#223](https://github.com/jfree/jfreechart/issues/223)); - removed `JFreeChartResources.java` file ([#239](https://github.com/jfree/jfreechart/issues/239)) - ##### Version 1.5.3 (21 February 2021) - add new `FlowPlot` class for drawing Sankey charts; - throw exception in `DefaultPieDataset` for invalid index ([#212](https://github.com/jfree/jfreechart/issues/212)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jfreechart-1.5.4/pom.xml new/jfreechart-1.5.5/pom.xml --- old/jfreechart-1.5.4/pom.xml 2023-01-08 17:10:37.000000000 +0100 +++ new/jfreechart-1.5.5/pom.xml 2024-06-23 17:53:17.000000000 +0200 @@ -10,7 +10,7 @@ <artifactId>jfreechart</artifactId> <groupId>org.jfree</groupId> - <version>1.5.4</version> + <version>1.5.5</version> <packaging>jar</packaging> <organization> @@ -61,19 +61,19 @@ <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> - <version>5.9.1</version> + <version>5.10.2</version> <scope>test</scope> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> - <version>5.9.1</version> + <version>5.10.2</version> <scope>test</scope> </dependency> <dependency> <groupId>nl.jqno.equalsverifier</groupId> <artifactId>equalsverifier</artifactId> - <version>3.12.3</version> + <version>3.16.1</version> <scope>test</scope> </dependency> </dependencies> @@ -91,13 +91,13 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-clean-plugin</artifactId> - <version>3.2.0</version> + <version>3.4.0</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>3.3.0</version> + <version>3.3.1</version> <configuration> <encoding>${project.build.sourceEncoding}</encoding> </configuration> @@ -106,7 +106,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>3.10.1</version> + <version>3.13.0</version> <configuration> <source>1.8</source> <target>1.8</target> @@ -119,7 +119,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>3.3.0</version> + <version>3.4.2</version> <configuration> <archive> <manifestEntries> @@ -132,7 +132,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> - <version>3.4.1</version> + <version>3.7.0</version> <configuration> <linksource>true</linksource> <source>8</source> @@ -143,7 +143,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>3.0.0-M7</version> + <version>3.3.0</version> <configuration> <includes> <include>**/*Test.java</include> @@ -156,13 +156,13 @@ </plugin> <plugin> <artifactId>maven-failsafe-plugin</artifactId> - <version>3.0.0-M7</version> + <version>3.3.0</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>3.1.0</version> + <version>3.1.2</version> </plugin> </plugins> @@ -173,7 +173,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-report-plugin</artifactId> - <version>3.0.0-M4</version> + <version>3.3.0</version> </plugin> <plugin> @@ -204,7 +204,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> @@ -219,7 +219,7 @@ <plugin> <groupId>org.sonatype.plugins</groupId> <artifactId>nexus-staging-maven-plugin</artifactId> - <version>1.6.13</version> + <version>1.7.0</version> <extensions>true</extensions> <configuration> <serverId>ossrh</serverId> @@ -231,7 +231,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> - <version>3.4.1</version> + <version>3.7.0</version> <configuration> <linksource>true</linksource> <source>8</source> @@ -250,7 +250,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> - <version>3.2.1</version> + <version>3.3.1</version> <executions> <execution> <id>attach-sources</id> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jfreechart-1.5.4/src/main/java/org/jfree/chart/ChartPanel.java new/jfreechart-1.5.5/src/main/java/org/jfree/chart/ChartPanel.java --- old/jfreechart-1.5.4/src/main/java/org/jfree/chart/ChartPanel.java 2023-01-08 17:10:37.000000000 +0100 +++ new/jfreechart-1.5.5/src/main/java/org/jfree/chart/ChartPanel.java 2024-06-23 17:53:17.000000000 +0200 @@ -849,7 +849,7 @@ } /** - * Sets the flag that controls whether or not zooming is enabled for the + * Sets the flag that controls whether zooming is enabled for the * domain axis. A check is made to ensure that the current plot supports * zooming for the domain values. * @@ -860,10 +860,9 @@ Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; - this.domainZoomable = flag && (z.isDomainZoomable()); + this.domainZoomable = z.isDomainZoomable(); } - } - else { + } else { this.domainZoomable = false; } } @@ -888,10 +887,9 @@ Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; - this.rangeZoomable = flag && (z.isRangeZoomable()); + this.rangeZoomable = z.isRangeZoomable(); } - } - else { + } else { this.rangeZoomable = false; } } @@ -1928,6 +1926,8 @@ if (this.chart == null) { return; } + this.chart.setNotify(true); + // new entity code... Object[] listeners = this.chartMouseListeners.getListeners( ChartMouseListener.class); @@ -2631,15 +2631,8 @@ try { Method m = g2.getClass().getMethod("getSVGElement"); svg = (String) m.invoke(g2); - } catch (NoSuchMethodException e) { - // null will be returned - } catch (SecurityException e) { - // null will be returned - } catch (IllegalAccessException e) { - // null will be returned - } catch (IllegalArgumentException e) { - // null will be returned - } catch (InvocationTargetException e) { + } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | + InvocationTargetException e) { // null will be returned } return svg; @@ -2650,19 +2643,8 @@ Class svgGraphics2d = Class.forName("org.jfree.graphics2d.svg.SVGGraphics2D"); Constructor ctor = svgGraphics2d.getConstructor(int.class, int.class); return (Graphics2D) ctor.newInstance(w, h); - } catch (ClassNotFoundException ex) { - return null; - } catch (NoSuchMethodException ex) { - return null; - } catch (SecurityException ex) { - return null; - } catch (InstantiationException ex) { - return null; - } catch (IllegalAccessException ex) { - return null; - } catch (IllegalArgumentException ex) { - return null; - } catch (InvocationTargetException ex) { + } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | + IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { return null; } } @@ -2759,19 +2741,8 @@ this.chart.draw(g2, drawArea); Method m3 = pdfDocClass.getMethod("writeToFile", File.class); m3.invoke(pdfDoc, file); - } catch (ClassNotFoundException ex) { - throw new RuntimeException(ex); - } catch (InstantiationException ex) { - throw new RuntimeException(ex); - } catch (IllegalAccessException ex) { - throw new RuntimeException(ex); - } catch (NoSuchMethodException ex) { - throw new RuntimeException(ex); - } catch (SecurityException ex) { - throw new RuntimeException(ex); - } catch (IllegalArgumentException ex) { - throw new RuntimeException(ex); - } catch (InvocationTargetException ex) { + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | + SecurityException | IllegalArgumentException | InvocationTargetException ex) { throw new RuntimeException(ex); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jfreechart-1.5.4/src/main/java/org/jfree/chart/annotations/CategoryLineAnnotation.java new/jfreechart-1.5.5/src/main/java/org/jfree/chart/annotations/CategoryLineAnnotation.java --- old/jfreechart-1.5.4/src/main/java/org/jfree/chart/annotations/CategoryLineAnnotation.java 2023-01-08 17:10:37.000000000 +0100 +++ new/jfreechart-1.5.5/src/main/java/org/jfree/chart/annotations/CategoryLineAnnotation.java 2024-06-23 17:53:17.000000000 +0200 @@ -274,11 +274,11 @@ /** * Draws the annotation. * - * @param g2 the graphics device. - * @param plot the plot. - * @param dataArea the data area. - * @param domainAxis the domain axis. - * @param rangeAxis the range axis. + * @param g2 the graphics device ({@code null} not permitted). + * @param plot the plot ({@code null} not permitted). + * @param dataArea the data area ({@code null} not permitted). + * @param domainAxis the domain axis ({@code null} not permitted). + * @param rangeAxis the range axis ({@code null} not permitted). */ @Override public void draw(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jfreechart-1.5.4/src/main/java/org/jfree/chart/plot/CompassPlot.java new/jfreechart-1.5.5/src/main/java/org/jfree/chart/plot/CompassPlot.java --- old/jfreechart-1.5.4/src/main/java/org/jfree/chart/plot/CompassPlot.java 2023-01-08 17:10:37.000000000 +0100 +++ new/jfreechart-1.5.5/src/main/java/org/jfree/chart/plot/CompassPlot.java 2024-06-23 17:53:17.000000000 +0200 @@ -464,7 +464,7 @@ * @param needle the needle. */ public void setSeriesNeedle(int index, MeterNeedle needle) { - if ((needle != null) && (index < this.seriesNeedle.length)) { + if ((needle != null) && (index >= 0) && (index < this.seriesNeedle.length)) { this.seriesNeedle[index] = needle; } fireChangeEvent(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jfreechart-1.5.4/src/main/java/org/jfree/chart/renderer/xy/XYBezierRenderer.java new/jfreechart-1.5.5/src/main/java/org/jfree/chart/renderer/xy/XYBezierRenderer.java --- old/jfreechart-1.5.4/src/main/java/org/jfree/chart/renderer/xy/XYBezierRenderer.java 1970-01-01 01:00:00.000000000 +0100 +++ new/jfreechart-1.5.5/src/main/java/org/jfree/chart/renderer/xy/XYBezierRenderer.java 2024-06-23 17:53:17.000000000 +0200 @@ -0,0 +1,611 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-present, by David Gilbert and Contributors. + * + * Project Info: http://www.jfree.org/jfreechart/index.html + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * XYBezierRenderer.java + * --------------------- + * (C) Copyright, by Javier Robes and Contributors. + * + * Original Author: Javier Robes; + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.geom.GeneralPath; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.ui.GradientPaintTransformer; +import org.jfree.chart.ui.RectangleEdge; +import org.jfree.chart.ui.StandardGradientPaintTransformer; +import org.jfree.chart.util.Args; +import org.jfree.data.xy.XYDataset; + + +/** + * A renderer that connects data points with Bezier cubic curves and/or + * draws shapes at each data point. This renderer is designed for use with + * the {@link XYPlot} class. + * <br><br> + * + * @since + */ +public class XYBezierRenderer extends XYLineAndShapeRenderer { + + /** + * An enumeration of the fill types for the renderer. + * + * @since 1.0.17 + */ + public static enum FillType { + + /** No fill. */ + NONE, + + /** Fill down to zero. */ + TO_ZERO, + + /** Fill to the lower bound. */ + TO_LOWER_BOUND, + + /** Fill to the upper bound. */ + TO_UPPER_BOUND + } + + /** + * Represents state information that applies to a single rendering of + * a chart. + */ + public static class XYBezierState extends State { + + /** The area to fill under the curve. */ + public GeneralPath fillArea; + + /** The points. */ + public List<Point2D> points; + + /** + * Creates a new state instance. + * + * @param info the plot rendering info. + */ + public XYBezierState(PlotRenderingInfo info) { + super(info); + this.fillArea = new GeneralPath(); + this.points = new ArrayList<>(); + } + } + + /** + * Resolution of Bezier curves (number of line segments between points) + */ + private int precision; + + /** + * Tension defines how sharply does the curve bends + */ + private double tension; + + /** + * A flag that can be set to specify + * to fill the area under the Bezier curve. + */ + private FillType fillType; + + private GradientPaintTransformer gradientPaintTransformer; + + /** + * Creates a new instance with the precision attribute defaulting to 5, + * the tension attribute defaulting to 2 + * and no fill of the area 'under' the Bezier curve. + */ + public XYBezierRenderer() { + this(5, 25, FillType.NONE); + } + + /** + * Creates a new renderer with the specified precision and tension + * and no fill of the area 'under' (between '0' and) the Bezier curve. + * + * @param precision the number of points between data items. + * @param tension value to define how sharply the curve bends + */ + public XYBezierRenderer(int precision, double tension) { + this(precision, tension ,FillType.NONE); + } + + /** + * Creates a new renderer with the specified precision + * and specified fill of the area 'under' (between '0' and) the Bezier curve. + * + * @param precision the number of points between data items. + * @param tension value to define how sharply the Bezier curve bends + * @param fillType the type of fill beneath the curve ({@code null} + * not permitted). + * + * @since 1.0.17 + */ + public XYBezierRenderer(int precision, double tension, FillType fillType) { + super(); + if (precision <= 0) { + throw new IllegalArgumentException("Requires precision > 0."); + } + if (tension <= 0) { + throw new IllegalArgumentException("Requires precision > 0."); + } + Args.nullNotPermitted(fillType, "fillType"); + this.precision = precision; + this.tension = tension; + this.fillType = fillType; + this.gradientPaintTransformer = new StandardGradientPaintTransformer(); + } + + /** + * Returns the number of line segments used to approximate the Bezier + * curve between data points. + * + * @return The number of line segments. + * + * @see #setPrecision(int) + */ + public int getPrecision() { + return this.precision; + } + + /** + * Set the resolution of Bezier curves and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param p number of line segments between points (must be > 0). + * + * @see #getPrecision() + */ + public void setPrecision(int p) { + if (p <= 0) { + throw new IllegalArgumentException("Requires p > 0."); + } + this.precision = p; + fireChangeEvent(); + } + + /** + * Returns the value of the tension which defines how sharply + * does the curve bends + * + * @return The value of tesion. + * + * @see #setTension(double) + */ + public double getTension() { + return this.tension; + } + + /** + * Set the value of the tension which defines how sharply + * does the curve bends and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param t value of tension (must be > 0). + * + * @see #getTension() + */ + public void setTension(double t) { + if (t <= 0) { + throw new IllegalArgumentException("Requires tension > 0."); + } + this.tension = t; + fireChangeEvent(); + } + + /** + * Returns the type of fill that the renderer draws beneath the curve. + * + * @return The type of fill (never {@code null}). + * + * @see #setFillType(FillType) + * + * @since 1.0.17 + */ + public FillType getFillType() { + return this.fillType; + } + + /** + * Set the fill type and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param fillType the fill type ({@code null} not permitted). + * + * @see #getFillType() + * + * @since 1.0.17 + */ + public void setFillType(FillType fillType) { + this.fillType = fillType; + fireChangeEvent(); + } + + /** + * Returns the gradient paint transformer, or {@code null}. + * + * @return The gradient paint transformer (possibly {@code null}). + * + * @since 1.0.17 + */ + public GradientPaintTransformer getGradientPaintTransformer() { + return this.gradientPaintTransformer; + } + + /** + * Sets the gradient paint transformer and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param gpt the transformer ({@code null} permitted). + * + * @since 1.0.17 + */ + public void setGradientPaintTransformer(GradientPaintTransformer gpt) { + this.gradientPaintTransformer = gpt; + fireChangeEvent(); + } + + /** + * Initialises the renderer. + * <P> + * This method will be called before the first item is rendered, giving the + * renderer an opportunity to initialise any state information it wants to + * maintain. The renderer can do nothing if it chooses. + * + * @param g2 the graphics device. + * @param dataArea the area inside the axes. + * @param plot the plot. + * @param data the data. + * @param info an optional info collection object to return data back to + * the caller. + * + * @return The renderer state. + */ + @Override + public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, + XYPlot plot, XYDataset data, PlotRenderingInfo info) { + + setDrawSeriesLineAsPath(true); + XYBezierState state = new XYBezierState(info); + state.setProcessVisibleItemsOnly(false); + return state; + } + + + /** + * Draws the item (first pass). This method draws the lines + * connecting the items. Instead of drawing separate lines, + * a GeneralPath is constructed and drawn at the end of + * the series painting. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param plot the plot (can be used to obtain standard color information + * etc). + * @param dataset the dataset. + * @param pass the pass. + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * @param xAxis the domain axis. + * @param yAxis the range axis. + * @param dataArea the area within which the data is being drawn. + */ + @Override + protected void drawPrimaryLineAsPath(XYItemRendererState state, + Graphics2D g2, XYPlot plot, XYDataset dataset, int pass, + int series, int item, ValueAxis xAxis, ValueAxis yAxis, + Rectangle2D dataArea) { + + XYBezierState s = (XYBezierState) state; + RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); + RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); + + // get the data points + double x1 = dataset.getXValue(series, item); + double y1 = dataset.getYValue(series, item); + double transX1 = xAxis.valueToJava2D(x1, dataArea, xAxisLocation); + double transY1 = yAxis.valueToJava2D(y1, dataArea, yAxisLocation); + + // Collect points + if (!Double.isNaN(transX1) && !Double.isNaN(transY1)) { + Point2D p = plot.getOrientation() == PlotOrientation.HORIZONTAL + ? new Point2D.Float((float) transY1, (float) transX1) + : new Point2D.Float((float) transX1, (float) transY1); + if (!s.points.contains(p)) + s.points.add(p); + } + + if (item == dataset.getItemCount(series) - 1) { // construct path + if (s.points.size() > 1) { + Point2D origin; + if (this.fillType == FillType.TO_ZERO) { + float xz = (float) xAxis.valueToJava2D(0, dataArea, + yAxisLocation); + float yz = (float) yAxis.valueToJava2D(0, dataArea, + yAxisLocation); + origin = plot.getOrientation() == PlotOrientation.HORIZONTAL + ? new Point2D.Float(yz, xz) + : new Point2D.Float(xz, yz); + } else if (this.fillType == FillType.TO_LOWER_BOUND) { + float xlb = (float) xAxis.valueToJava2D( + xAxis.getLowerBound(), dataArea, xAxisLocation); + float ylb = (float) yAxis.valueToJava2D( + yAxis.getLowerBound(), dataArea, yAxisLocation); + origin = plot.getOrientation() == PlotOrientation.HORIZONTAL + ? new Point2D.Float(ylb, xlb) + : new Point2D.Float(xlb, ylb); + } else {// fillType == TO_UPPER_BOUND + float xub = (float) xAxis.valueToJava2D( + xAxis.getUpperBound(), dataArea, xAxisLocation); + float yub = (float) yAxis.valueToJava2D( + yAxis.getUpperBound(), dataArea, yAxisLocation); + origin = plot.getOrientation() == PlotOrientation.HORIZONTAL + ? new Point2D.Float(yub, xub) + : new Point2D.Float(xub, yub); + } + + // we need at least two points to draw something + Point2D cp0 = s.points.get(0); + s.seriesPath.moveTo(cp0.getX(), cp0.getY()); + if (this.fillType != FillType.NONE) { + if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { + s.fillArea.moveTo(origin.getX(), cp0.getY()); + } else { + s.fillArea.moveTo(cp0.getX(), origin.getY()); + } + s.fillArea.lineTo(cp0.getX(), cp0.getY()); + } + if (s.points.size() == 2) { + // we need at least 3 points to Bezier. Draw simple line + // for two points + Point2D cp1 = s.points.get(1); + if (this.fillType != FillType.NONE) { + s.fillArea.lineTo(cp1.getX(), cp1.getY()); + s.fillArea.lineTo(cp1.getX(), origin.getY()); + s.fillArea.closePath(); + } + s.seriesPath.lineTo(cp1.getX(), cp1.getY()); + } + else if (s.points.size() == 3) { + // with 3 points only initial and end Bezier curves are required. + + Point2D[] pInitial = getInitalPoints(s); + addBezierPointsToSeriesPath(pInitial, s); + Point2D[] pFinal = getFinalPoints(s); + addBezierPointsToSeriesPath(pFinal, s); + + } + else { + // construct Bezier curve + int np = s.points.size(); // number of points + for(int i = 0; i < np - 1; i++) { + if(i == 0) { + // 3 points, 2 lines (initial an final Bezier curves) + Point2D[] initial3Points = new Point2D[3]; + initial3Points[0] = s.points.get(0); + initial3Points[1] = s.points.get(1); + initial3Points[2] = s.points.get(2); + Point2D[] pInitial = calcSegmentPointsInitial(initial3Points); + addBezierPointsToSeriesPath(pInitial, s); + } + if(i == np - 2) { + Point2D[] final3Points = new Point2D[4]; + final3Points[1] = s.points.get(np-3); + final3Points[2] = s.points.get(np-2); + final3Points[3] = s.points.get(np-1); + // No need for final3Points[0]. Not required + Point2D[] pFinal = calcSegmentPointsFinal(final3Points); + addBezierPointsToSeriesPath(pFinal, s); + } + if ((i != 0) && (i != (np - 2))){ + Point2D[] original4Points = new Point2D[4]; + original4Points[0] = s.points.get(i - 1); + original4Points[1] = s.points.get(i); + original4Points[2] = s.points.get(i + 1); + original4Points[3] = s.points.get(i + 2); + Point2D[] pMedium = calculateSegmentPoints(original4Points); + addBezierPointsToSeriesPath(pMedium, s); + } + } + } + // Add last point @ y=0 for fillPath and close path + if (this.fillType != FillType.NONE) { + if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { + s.fillArea.lineTo(origin.getX(), s.points.get( + s.points.size() - 1).getY()); + } else { + s.fillArea.lineTo(s.points.get( + s.points.size() - 1).getX(), origin.getY()); + } + s.fillArea.closePath(); + } + // fill under the curve... + if (this.fillType != FillType.NONE) { + Paint fp = getSeriesFillPaint(series); + if (this.gradientPaintTransformer != null + && fp instanceof GradientPaint) { + GradientPaint gp = this.gradientPaintTransformer + .transform((GradientPaint) fp, s.fillArea); + g2.setPaint(gp); + } else { + g2.setPaint(fp); + } + g2.fill(s.fillArea); + s.fillArea.reset(); + } + // then draw the line... + drawFirstPassShape(g2, pass, series, item, s.seriesPath); + } + // reset points vector + s.points = new ArrayList<>(); + } + } + + private void addBezierPointsToSeriesPath(Point2D[] segmentPoints, XYBezierState s) { + double x; + double y; + for (int t = 0 ; t <= this.precision; t++) { + double k = (double)t / this.precision; + double r = 1- k; + + x = Math.pow(r, 3) * segmentPoints[0].getX() + 3 * k * Math.pow(r, 2) * segmentPoints[1].getX() + + 3 * Math.pow(k, 2) * (1 - k) * segmentPoints[2].getX() + Math.pow(k, 3) * segmentPoints[3].getX(); + y = Math.pow(r, 3) * segmentPoints[0].getY() + 3 * k * Math.pow(r, 2) * segmentPoints[1].getY() + + 3 * Math.pow(k, 2) * (1 - k) * segmentPoints[2].getY() + Math.pow(k, 3) * segmentPoints[3].getY(); + s.seriesPath.lineTo(x, y); + if (this.fillType != FillType.NONE) { + s.fillArea.lineTo(x, y); + } + } + } + + private Point2D[] getFinalPoints(XYBezierState s) { + Point2D[] final3Points = new Point2D[4]; + final3Points[1] = s.points.get(0); + final3Points[2] = s.points.get(1); + final3Points[3] = s.points.get(2); + // No need for final3Points[0]. Not required + Point2D[] pFinal = calcSegmentPointsFinal(final3Points);//TENSION = 1.5 + return pFinal; + } + + private Point2D[] getInitalPoints(XYBezierState s) { + Point2D[] initial3Points = new Point2D[3]; + initial3Points[0] = s.points.get(0); + initial3Points[1] = s.points.get(1); + initial3Points[2] = s.points.get(2); + Point2D[] pInitial = calcSegmentPointsInitial(initial3Points);// TENSION = 1.5 + return pInitial; + } + + private Point2D[] calculateSegmentPoints(Point2D[] original4Points) { + Point2D[] points = new Point2D[4]; + points[0] = original4Points[1]; + points[3] = original4Points[2]; + for(int i = 1; i < 3; i++) { + Point2D aux1 = calcUnitaryVector(original4Points[i-1], original4Points[i]); + Point2D aux2 = calcUnitaryVector(original4Points[i+1], original4Points[i]); + Point2D aux3 = calcUnitaryVector(aux2, aux1); + + double x = original4Points[i].getX() + Math.pow(-1.0, i+1) * tension * aux3.getX(); + double y = original4Points[i].getY() + Math.pow(-1.0, i+1) * tension * aux3.getY(); + points[i] = new Point2D.Double(x, y); + } + return points; + } + + private Point2D[] calcSegmentPointsInitial(Point2D[] original3P) { + Point2D[] points = new Point2D[4]; + points[0] = original3P[0];// Endpoint 1 + points[3] = original3P[1];// Endpoint 2 + // Control point 1 + Point2D auxInitial = calcUnitaryVector(original3P[0], original3P[1]); + points[1] = original3P[0];// new Point2D.Double(x0, y0); + // Control point 2 + Point2D aux2 = calcUnitaryVector(original3P[2], original3P[1]); + Point2D aux3 = calcUnitaryVector(auxInitial, aux2); + double x = original3P[1].getX() + tension * aux3.getX(); + double y = original3P[1].getY() + tension * aux3.getY(); + points[2] = new Point2D.Double(x, y); + return points; + } + + private Point2D[] calcSegmentPointsFinal(Point2D[] original3P) { + /* + * Each segment is defined by its two endpoints and two control points. A + * control point determines the tangent at the corresponding endpoint. + */ + Point2D[] points = new Point2D[4]; + points[0] = original3P[2];// Endpoint 1 + points[3] = original3P[3];// Endpoint 2 + // Control point 2: points[2] + Point2D auxInitial = calcUnitaryVector(original3P[3], original3P[2]); + points[2] = original3P[3];// new Point2D.Double(x0, y0); + // Control point 1 + Point2D aux1 = calcUnitaryVector(original3P[3], original3P[2]); + Point2D aux2 = calcUnitaryVector(original3P[1], original3P[2]); + Point2D aux3 = calcUnitaryVector(aux1, aux2); + double x = original3P[2].getX() + tension * aux3.getX(); + double y = original3P[2].getY() + tension * aux3.getY(); + points[1] = new Point2D.Double(x, y); + return points; + } + + private Point2D calcUnitaryVector(Point2D pOrigin, Point2D pEnd) { + double module = Math.sqrt(Math.pow(pEnd.getX() - pOrigin.getX(), 2) + + Math.pow(pEnd.getY() - pOrigin.getY(), 2)); + if (module == 0) { + return null; + } + return new Point2D.Double((pEnd.getX() - pOrigin.getX()) / module, + (pEnd.getY() - pOrigin.getY()) /module); + } + + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object ({@code null} permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYBezierRenderer)) { + return false; + } + XYBezierRenderer that = (XYBezierRenderer) obj; + if (this.precision != that.precision) { + return false; + } + if (this.fillType != that.fillType) { + return false; + } + if (!Objects.equals(this.gradientPaintTransformer, that.gradientPaintTransformer)) { + return false; + } + return super.equals(obj); + } +} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jfreechart-1.5.4/src/test/java/org/jfree/chart/AreaChartTest.java new/jfreechart-1.5.5/src/test/java/org/jfree/chart/AreaChartTest.java --- old/jfreechart-1.5.4/src/test/java/org/jfree/chart/AreaChartTest.java 2023-01-08 17:10:37.000000000 +0100 +++ new/jfreechart-1.5.5/src/test/java/org/jfree/chart/AreaChartTest.java 2024-06-23 17:53:17.000000000 +0200 @@ -63,7 +63,7 @@ /** * Tests for an area chart. */ -public class AreaChartTest { +class AreaChartTest { /** A chart. */ private JFreeChart chart; @@ -81,7 +81,7 @@ * default generator. */ @Test - public void testSetSeriesToolTipGenerator() { + void testSetSeriesToolTipGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryToolTipGenerator tt @@ -96,7 +96,7 @@ * default generator. */ @Test - public void testSetSeriesURLGenerator() { + void testSetSeriesURLGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryURLGenerator url1 @@ -111,7 +111,7 @@ * are thrown (a problem that was occurring at one point). */ @Test - public void testDrawWithNullInfo() { + void testDrawWithNullInfo() { try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); @@ -129,7 +129,7 @@ * Replaces the chart's dataset and then checks that the new dataset is OK. */ @Test - public void testReplaceDataset() { + void testReplaceDataset() { Number[][] data = new Integer[][] {{-30, -20}, {-10, 10}, {20, 30}}; CategoryDataset newData = DatasetUtils.createCategoryDataset( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jfreechart-1.5.4/src/test/java/org/jfree/chart/JFreeChartTest.java new/jfreechart-1.5.5/src/test/java/org/jfree/chart/JFreeChartTest.java --- old/jfreechart-1.5.4/src/test/java/org/jfree/chart/JFreeChartTest.java 2023-01-08 17:10:37.000000000 +0100 +++ new/jfreechart-1.5.5/src/test/java/org/jfree/chart/JFreeChartTest.java 2024-06-23 17:53:17.000000000 +0200 @@ -67,14 +67,14 @@ /** * Tests for the {@link JFreeChart} class. */ -public class JFreeChartTest implements ChartChangeListener { +class JFreeChartTest implements ChartChangeListener { /** * Use EqualsVerifier to test that the contract between equals and hashCode * is properly implemented. */ @Test - public void testEqualsHashCode() { + void testEqualsHashCode() { EqualsVerifier.forClass(JFreeChart.class) .withPrefabValues(TextTitle.class, new TextTitle("tee"), @@ -113,7 +113,7 @@ * Check that the equals() method can distinguish all fields. */ @Test - public void testEquals() { + void testEquals() { JFreeChart chart1 = new JFreeChart("Title", new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true); JFreeChart chart2 = new JFreeChart("Title", @@ -210,7 +210,7 @@ * equals() testing. */ @Test - public void testEquals2() { + void testEquals2() { JFreeChart chart1 = new JFreeChart("Title", new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true); JFreeChart chart2 = new JFreeChart("Title", @@ -223,7 +223,7 @@ * Checks the subtitle count - should be 1 (the legend). */ @Test - public void testSubtitleCount() { + void testSubtitleCount() { int count = this.pieChart.getSubtitleCount(); assertEquals(1, count); } @@ -232,7 +232,7 @@ * Some checks for the getSubtitle() method. */ @Test - public void testGetSubtitle() { + void testGetSubtitle() { DefaultPieDataset<String> dataset = new DefaultPieDataset<>(); JFreeChart chart = ChartFactory.createPieChart("title", dataset); Title t = chart.getSubtitle(0); @@ -268,7 +268,7 @@ * Serialize a pie chart, restore it, and check for equality. */ @Test - public void testSerialization1() { + void testSerialization1() { DefaultPieDataset<String> data = new DefaultPieDataset<>(); data.setValue("Type 1", 54.5); data.setValue("Type 2", 23.9); @@ -285,12 +285,12 @@ * Serialize a 3D pie chart, restore it, and check for equality. */ @Test - public void testSerialization2() { + void testSerialization2() { DefaultPieDataset<String> data = new DefaultPieDataset<>(); data.setValue("Type 1", 54.5); data.setValue("Type 2", 23.9); data.setValue("Type 3", 45.8); - JFreeChart c1 = ChartFactory.createPieChart3D("Test", data); + JFreeChart c1 = ChartFactory.createPieChart("Test", data); JFreeChart c2 = TestUtils.serialised(c1); assertEquals(c1, c2); } @@ -299,7 +299,7 @@ * Serialize a bar chart, restore it, and check for equality. */ @Test - public void testSerialization3() { + void testSerialization3() { // row keys... String series1 = "First"; @@ -357,7 +357,7 @@ * Serialize a time seroes chart, restore it, and check for equality. */ @Test - public void testSerialization4() { + void testSerialization4() { RegularTimePeriod t = new Day(); TimeSeries series = new TimeSeries("Series 1"); @@ -377,7 +377,7 @@ * Some checks for the addSubtitle() methods. */ @Test - public void testAddSubtitle() { + void testAddSubtitle() { DefaultPieDataset<String> dataset = new DefaultPieDataset<>(); JFreeChart chart = ChartFactory.createPieChart("title", dataset); @@ -419,7 +419,7 @@ * Some checks for the getSubtitles() method. */ @Test - public void testGetSubtitles() { + void testGetSubtitles() { DefaultPieDataset<String> dataset = new DefaultPieDataset<>(); JFreeChart chart = ChartFactory.createPieChart("title", dataset); List<TextTitle> subtitles = chart.getSubtitles(); @@ -435,7 +435,7 @@ * Some checks for the default legend firing change events. */ @Test - public void testLegendEvents() { + void testLegendEvents() { DefaultPieDataset<String> dataset = new DefaultPieDataset<>(); JFreeChart chart = ChartFactory.createPieChart("title", dataset); chart.addChangeListener(this); @@ -449,7 +449,7 @@ * Some checks for title changes and event notification. */ @Test - public void testTitleChangeEvent() { + void testTitleChangeEvent() { DefaultPieDataset dataset = new DefaultPieDataset(); JFreeChart chart = ChartFactory.createPieChart("title", dataset); chart.addChangeListener(this); @@ -480,7 +480,7 @@ } @Test - public void testBug942() throws Exception { + void testBug942() { final String title = "Pie Chart Demo 1\n\n\ntestnew line"; assertEquals(title, ChartFactory.createPieChart(title, new DefaultPieDataset<String>()).getTitle().getText()); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jfreechart-1.5.4/src/test/java/org/jfree/chart/plot/CompassPlotTest.java new/jfreechart-1.5.5/src/test/java/org/jfree/chart/plot/CompassPlotTest.java --- old/jfreechart-1.5.4/src/test/java/org/jfree/chart/plot/CompassPlotTest.java 2023-01-08 17:10:37.000000000 +0100 +++ new/jfreechart-1.5.5/src/test/java/org/jfree/chart/plot/CompassPlotTest.java 2024-06-23 17:53:17.000000000 +0200 @@ -41,7 +41,7 @@ import java.awt.GradientPaint; import org.jfree.chart.TestUtils; - +import org.jfree.chart.needle.PointerNeedle; import org.jfree.data.general.DefaultValueDataset; import org.junit.jupiter.api.Test; @@ -132,4 +132,13 @@ assertEquals(p1, p2); } + /** + * Test faulty array bounds; CVE-2024-23077. + */ + @Test + public void testArrayBounds() { + CompassPlot p = new CompassPlot(new DefaultValueDataset(0)); + p.setSeriesNeedle(-1, new PointerNeedle()); + } + } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jfreechart-1.5.4/src/test/java/org/jfree/chart/renderer/xy/XYBezierRendererTest.java new/jfreechart-1.5.5/src/test/java/org/jfree/chart/renderer/xy/XYBezierRendererTest.java --- old/jfreechart-1.5.4/src/test/java/org/jfree/chart/renderer/xy/XYBezierRendererTest.java 1970-01-01 01:00:00.000000000 +0100 +++ new/jfreechart-1.5.5/src/test/java/org/jfree/chart/renderer/xy/XYBezierRendererTest.java 2024-06-23 17:53:17.000000000 +0200 @@ -0,0 +1,99 @@ +package org.jfree.chart.renderer.xy; + +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.TestUtils; +import org.jfree.chart.ui.GradientPaintTransformType; +import org.jfree.chart.ui.StandardGradientPaintTransformer; +import org.jfree.chart.util.CloneUtils; +import org.jfree.chart.util.PublicCloneable; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Tests for the {@link XYBezierRenderer} class. + */ +class XYBezierRendererTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + void testEquals() { + XYBezierRenderer r1 = new XYBezierRenderer(); + XYBezierRenderer r2 = new XYBezierRenderer(); + assertEquals(r1, r2); + assertEquals(r2, r1); + + r1.setPrecision(9); + assertNotEquals(r1, r2); + r2.setPrecision(9); + assertEquals(r1, r2); + + r1.setFillType(XYBezierRenderer.FillType.TO_ZERO); + assertNotEquals(r1, r2); + r2.setFillType(XYBezierRenderer.FillType.TO_ZERO); + assertEquals(r1, r2); + + r1.setGradientPaintTransformer(null); + assertNotEquals(r1, r2); + r2.setGradientPaintTransformer(null); + assertEquals(r1, r2); + + r1.setGradientPaintTransformer(new StandardGradientPaintTransformer( + GradientPaintTransformType.HORIZONTAL)); + assertNotEquals(r1, r2); + r2.setGradientPaintTransformer(new StandardGradientPaintTransformer( + GradientPaintTransformType.HORIZONTAL)); + assertEquals(r1, r2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + void testHashcode() { + XYBezierRenderer r1 = new XYBezierRenderer(); + XYBezierRenderer r2 = new XYBezierRenderer(); + assertEquals(r1, r2); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + void testCloning() throws CloneNotSupportedException { + Rectangle2D legendShape = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); + XYBezierRenderer r1 = new XYBezierRenderer(); + r1.setLegendLine(legendShape); + XYBezierRenderer r2 = (XYBezierRenderer) CloneUtils.clone(r1); + assertNotSame(r1, r2); + assertSame(r1.getClass(), r2.getClass()); + assertEquals(r1, r2); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + void testPublicCloneable() { + XYBezierRenderer r1 = new XYBezierRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + void testSerialization() { + XYBezierRenderer r1 = new XYBezierRenderer(); + XYBezierRenderer r2 = TestUtils.serialised(r1); + assertEquals(r1, r2); + } + + +} \ No newline at end of file