diff --git a/README.md b/README.md
index 58f9bc7..f6f76d0 100644
--- a/README.md
+++ b/README.md
@@ -39,6 +39,14 @@ https://github.com/jfree/jfree-fxdemos
History
-------
##### Next release
+##### Version 2.0.3-SNAPSHOT (Current)
+
+- Migrated to JFreeChart 2.0 API.
+- Introduced JavaFX-native overlay system (`OverlayFX`, `AbstractOverlayFX`).
+- Replaced Swing-dependent event listeners with `OverlayChangeListenerFX`.
+- Removed internal dependency on `ShapeUtils` in interaction handlers.
+- Fixed Javadoc reference errors in `ChartCanvas`.
+
- requires Java 22 or later
diff --git a/pom.xml b/pom.xml
index 32a0a55..942686a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,7 +14,7 @@
org.jfree
org.jfree.chart.fx
- 2.0.3-SNAPSHOT
+ 2.0.4-SNAPSHOT
jar
@@ -64,7 +64,7 @@
org.jfree
jfreechart
- 1.5.7-SNAPSHOT
+ 2.0.0-SNAPSHOT
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
index f08acb2..2e37678 100644
--- a/src/main/java/module-info.java
+++ b/src/main/java/module-info.java
@@ -11,7 +11,7 @@
requires javafx.graphics;
requires javafx.controls;
requires org.jfree.fxgraphics2d;
- requires org.jfree.jfreechart;
+ requires org.jfree.chart;
exports org.jfree.chart.fx;
exports org.jfree.chart.fx.interaction;
exports org.jfree.chart.fx.overlay;
diff --git a/src/main/java/org/jfree/chart/fx/ChartCanvas.java b/src/main/java/org/jfree/chart/fx/ChartCanvas.java
index c2bc7aa..693b9af 100644
--- a/src/main/java/org/jfree/chart/fx/ChartCanvas.java
+++ b/src/main/java/org/jfree/chart/fx/ChartCanvas.java
@@ -43,34 +43,36 @@
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.List;
-import javafx.collections.FXCollections;
-import javafx.collections.ObservableList;
-import javafx.scene.canvas.Canvas;
-import javafx.scene.canvas.GraphicsContext;
-import javafx.scene.control.Tooltip;
-import javafx.scene.input.MouseEvent;
-import javafx.scene.input.ScrollEvent;
-import javafx.scene.text.FontSmoothingType;
-import org.jfree.chart.ChartMouseEvent;
+import java.util.Objects;
+
import org.jfree.chart.ChartRenderingInfo;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.event.ChartChangeEvent;
import org.jfree.chart.event.ChartChangeListener;
-import org.jfree.chart.event.OverlayChangeEvent;
-import org.jfree.chart.event.OverlayChangeListener;
import org.jfree.chart.fx.interaction.AnchorHandlerFX;
-import org.jfree.chart.fx.interaction.DispatchHandlerFX;
+import org.jfree.chart.fx.interaction.ChartMouseEventFX;
import org.jfree.chart.fx.interaction.ChartMouseListenerFX;
-import org.jfree.chart.fx.interaction.TooltipHandlerFX;
-import org.jfree.chart.fx.interaction.ScrollHandlerFX;
-import org.jfree.chart.fx.interaction.PanHandlerFX;
+import org.jfree.chart.fx.interaction.DispatchHandlerFX;
import org.jfree.chart.fx.interaction.MouseHandlerFX;
+import org.jfree.chart.fx.interaction.PanHandlerFX;
+import org.jfree.chart.fx.interaction.ScrollHandlerFX;
+import org.jfree.chart.fx.interaction.TooltipHandlerFX;
+import org.jfree.chart.fx.overlay.OverlayChangeEventFX;
+import org.jfree.chart.fx.overlay.OverlayChangeListenerFX;
import org.jfree.chart.fx.overlay.OverlayFX;
import org.jfree.chart.plot.PlotRenderingInfo;
-import org.jfree.chart.util.Args;
import org.jfree.fx.FXGraphics2D;
import org.jfree.fx.FXHints;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.scene.canvas.Canvas;
+import javafx.scene.canvas.GraphicsContext;
+import javafx.scene.control.Tooltip;
+import javafx.scene.input.MouseEvent;
+import javafx.scene.input.ScrollEvent;
+import javafx.scene.text.FontSmoothingType;
+
/**
* A canvas for displaying a {@link JFreeChart} in JavaFX. You can use the
* canvas directly to display charts, but usually the {@link ChartViewer}
@@ -89,7 +91,7 @@
*
*/
public class ChartCanvas extends Canvas implements ChartChangeListener,
- OverlayChangeListener {
+ OverlayChangeListenerFX {
/** The chart being displayed in the canvas. */
private JFreeChart chart;
@@ -325,7 +327,7 @@ public void setAnchor(Point2D anchor) {
* @param overlay the overlay ({@code null} not permitted).
*/
public void addOverlay(OverlayFX overlay) {
- Args.nullNotPermitted(overlay, "overlay");
+ Objects.requireNonNull(overlay, "overlay");
this.overlays.add(overlay);
overlay.addChangeListener(this);
draw();
@@ -337,7 +339,7 @@ public void addOverlay(OverlayFX overlay) {
* @param overlay the overlay to remove ({@code null} not permitted).
*/
public void removeOverlay(OverlayFX overlay) {
- Args.nullNotPermitted(overlay, "overlay");
+ Objects.requireNonNull(overlay, "overlay");
boolean removed = this.overlays.remove(overlay);
if (removed) {
overlay.removeChangeListener(this);
@@ -351,7 +353,7 @@ public void removeOverlay(OverlayFX overlay) {
* @param event the event.
*/
@Override
- public void overlayChanged(OverlayChangeEvent event) {
+ public void overlayChanged(OverlayChangeEventFX event) {
draw();
}
@@ -366,12 +368,12 @@ public List getChartMouseListeners() {
}
/**
- * Registers a listener to receive {@link ChartMouseEvent} notifications.
+ * Registers a listener to receive {@link ChartMouseEventFX} notifications.
*
* @param listener the listener ({@code null} not permitted).
*/
public void addChartMouseListener(ChartMouseListenerFX listener) {
- Args.nullNotPermitted(listener, "listener");
+ Objects.requireNonNull(listener, "listener");
this.chartMouseListeners.add(listener);
}
@@ -703,4 +705,3 @@ public void chartChanged(ChartChangeEvent event) {
}
}
-
diff --git a/src/main/java/org/jfree/chart/fx/ChartViewer.java b/src/main/java/org/jfree/chart/fx/ChartViewer.java
index 0847325..3c91475 100644
--- a/src/main/java/org/jfree/chart/fx/ChartViewer.java
+++ b/src/main/java/org/jfree/chart/fx/ChartViewer.java
@@ -38,6 +38,15 @@
import java.io.File;
import java.io.IOException;
+import java.util.Objects;
+
+import org.jfree.chart.ChartRenderingInfo;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.fx.interaction.ChartMouseEventFX;
+import org.jfree.chart.fx.interaction.ChartMouseListenerFX;
+import org.jfree.chart.fx.interaction.ZoomHandlerFX;
+import org.jfree.chart.util.ExportUtils;
+
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
@@ -47,13 +56,6 @@
import javafx.scene.paint.Paint;
import javafx.scene.shape.Rectangle;
import javafx.stage.FileChooser;
-import org.jfree.chart.ChartMouseEvent;
-import org.jfree.chart.ChartRenderingInfo;
-import org.jfree.chart.JFreeChart;
-import org.jfree.chart.fx.interaction.ChartMouseListenerFX;
-import org.jfree.chart.fx.interaction.ZoomHandlerFX;
-import org.jfree.chart.util.ExportUtils;
-import org.jfree.chart.util.Args;
/**
* A control for displaying a {@link JFreeChart} in JavaFX (embeds a
@@ -135,7 +137,7 @@ public JFreeChart getChart() {
* @param chart the chart ({@code null} not permitted).
*/
public void setChart(JFreeChart chart) {
- Args.nullNotPermitted(chart, "chart");
+ Objects.requireNonNull(chart, "chart");
this.canvas.setChart(chart);
}
@@ -194,13 +196,13 @@ protected void layoutChildren() {
}
/**
- * Registers a listener to receive {@link ChartMouseEvent} notifications
+ * Registers a listener to receive {@link ChartMouseEventFX} notifications
* from the canvas embedded in this viewer.
*
* @param listener the listener ({@code null} not permitted).
*/
public void addChartMouseListener(ChartMouseListenerFX listener) {
- Args.nullNotPermitted(listener, "listener");
+ Objects.requireNonNull(listener, "listener");
this.canvas.addChartMouseListener(listener);
}
@@ -211,7 +213,7 @@ public void addChartMouseListener(ChartMouseListenerFX listener) {
* @param listener the listener.
*/
public void removeChartMouseListener(ChartMouseListenerFX listener) {
- Args.nullNotPermitted(listener, "listener");
+ Objects.requireNonNull(listener, "listener");
this.canvas.removeChartMouseListener(listener);
}
diff --git a/src/main/java/org/jfree/chart/fx/interaction/AbstractMouseHandlerFX.java b/src/main/java/org/jfree/chart/fx/interaction/AbstractMouseHandlerFX.java
index 8239dc4..cd95f09 100644
--- a/src/main/java/org/jfree/chart/fx/interaction/AbstractMouseHandlerFX.java
+++ b/src/main/java/org/jfree/chart/fx/interaction/AbstractMouseHandlerFX.java
@@ -36,10 +36,10 @@
package org.jfree.chart.fx.interaction;
+import java.util.Objects;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.ScrollEvent;
import org.jfree.chart.fx.ChartCanvas;
-import org.jfree.chart.util.Args;
/**
* A base class that can be used to implement the {@link MouseHandlerFX}
@@ -81,7 +81,7 @@ public class AbstractMouseHandlerFX implements MouseHandlerFX {
*/
public AbstractMouseHandlerFX(String id, boolean altKey, boolean ctrlKey,
boolean metaKey, boolean shiftKey) {
- Args.nullNotPermitted(id, "id");
+ Objects.requireNonNull(id, "id");
this.id = id;
this.enabled = true;
this.altKey = altKey;
diff --git a/src/main/java/org/jfree/chart/fx/interaction/ChartMouseListenerFX.java b/src/main/java/org/jfree/chart/fx/interaction/ChartMouseListenerFX.java
index bf83830..476e9fe 100644
--- a/src/main/java/org/jfree/chart/fx/interaction/ChartMouseListenerFX.java
+++ b/src/main/java/org/jfree/chart/fx/interaction/ChartMouseListenerFX.java
@@ -36,13 +36,12 @@
package org.jfree.chart.fx.interaction;
-import org.jfree.chart.ChartMouseListener;
import org.jfree.chart.fx.ChartViewer;
/**
* A mouse listener that can receive event notifications from a (JavaFX)
* {@link ChartViewer} instance. This interface is equivalent to the
- * {@link ChartMouseListener} interface used for charts in Swing.
+ * ChartMouseListener interface used for charts in Swing.
*/
public interface ChartMouseListenerFX {
diff --git a/src/main/java/org/jfree/chart/fx/interaction/ScrollHandlerFX.java b/src/main/java/org/jfree/chart/fx/interaction/ScrollHandlerFX.java
index 84893f2..99b5328 100644
--- a/src/main/java/org/jfree/chart/fx/interaction/ScrollHandlerFX.java
+++ b/src/main/java/org/jfree/chart/fx/interaction/ScrollHandlerFX.java
@@ -41,7 +41,7 @@
import org.jfree.chart.ChartRenderingInfo;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.fx.ChartCanvas;
-import org.jfree.chart.plot.PiePlot;
+import org.jfree.chart.plot.pie.PiePlot;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.PlotRenderingInfo;
import org.jfree.chart.plot.Zoomable;
diff --git a/src/main/java/org/jfree/chart/fx/interaction/ZoomHandlerFX.java b/src/main/java/org/jfree/chart/fx/interaction/ZoomHandlerFX.java
index 9007001..f0070d4 100644
--- a/src/main/java/org/jfree/chart/fx/interaction/ZoomHandlerFX.java
+++ b/src/main/java/org/jfree/chart/fx/interaction/ZoomHandlerFX.java
@@ -38,13 +38,14 @@
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
-import javafx.scene.input.MouseEvent;
+
import org.jfree.chart.fx.ChartCanvas;
import org.jfree.chart.fx.ChartViewer;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.PlotRenderingInfo;
import org.jfree.chart.plot.Zoomable;
-import org.jfree.chart.util.ShapeUtils;
+
+import javafx.scene.input.MouseEvent;
/**
* Handles drag zooming of charts on a {@link ChartCanvas}. This
@@ -103,8 +104,9 @@ public void handleMousePressed(ChartCanvas canvas, MouseEvent e) {
Point2D pt = new Point2D.Double(e.getX(), e.getY());
Rectangle2D dataArea = canvas.findDataArea(pt);
if (dataArea != null) {
- this.startPoint = ShapeUtils.getPointInRectangle(e.getX(),
- e.getY(), dataArea);
+ double x = Math.max(dataArea.getMinX(), Math.min(e.getX(), dataArea.getMaxX()));
+ double y = Math.max(dataArea.getMinY(), Math.min(e.getY(), dataArea.getMaxY()));
+ this.startPoint = new Point2D.Double(x, y);
} else {
this.startPoint = null;
canvas.clearLiveHandler();
diff --git a/src/main/java/org/jfree/chart/fx/overlay/AbstractOverlayFX.java b/src/main/java/org/jfree/chart/fx/overlay/AbstractOverlayFX.java
new file mode 100644
index 0000000..9410e15
--- /dev/null
+++ b/src/main/java/org/jfree/chart/fx/overlay/AbstractOverlayFX.java
@@ -0,0 +1,99 @@
+/* ================================================
+ * JFreeChart-FX : JavaFX extensions for JFreeChart
+ * ================================================
+ *
+ * (C) Copyright 2017-present, by David Gilbert and Contributors.
+ *
+ * Project Info: https://github.com/jfree/jfreechart-fx
+ *
+ * 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.]
+ *
+ * ----------------------
+ * AbstractOverlayFX.java
+ * ----------------------
+ * (C) Copyright 2024-present, by David Gilbert and Contributors.
+ *
+ * Original Author: David Gilbert;
+ * Contributor(s): -;
+ *
+ */
+
+package org.jfree.chart.fx.overlay;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+/**
+ * A base class for implementing overlays for the {@link org.jfree.chart.fx.ChartCanvas}.
+ */
+public abstract class AbstractOverlayFX implements OverlayFX {
+
+ /** Storage for registered change listeners. */
+ private final transient List changeListeners = new CopyOnWriteArrayList<>();
+
+ /**
+ * Default constructor.
+ */
+ public AbstractOverlayFX() {
+ }
+
+ /**
+ * Registers a listener to receive notification of changes to the overlay.
+ *
+ * @param listener the listener ({@code null} not permitted).
+ */
+ @Override
+ public void addChangeListener(OverlayChangeListenerFX listener) {
+ Objects.requireNonNull(listener, "listener");
+ this.changeListeners.add(listener);
+ }
+
+ /**
+ * Deregisters a listener so that it no longer receives notification of
+ * changes to the overlay.
+ *
+ * @param listener the listener ({@code null} not permitted).
+ */
+ @Override
+ public void removeChangeListener(OverlayChangeListenerFX listener) {
+ Objects.requireNonNull(listener, "listener");
+ this.changeListeners.remove(listener);
+ }
+
+ /**
+ * Sends a {@link OverlayChangeEventFX} to all registered listeners.
+ */
+ public void fireOverlayChanged() {
+ OverlayChangeEventFX event = new OverlayChangeEventFX(this);
+ notifyListeners(event);
+ }
+
+ /**
+ * Notifies all registered listeners that the overlay has changed.
+ *
+ * @param event the event.
+ */
+ protected void notifyListeners(OverlayChangeEventFX event) {
+ for (OverlayChangeListenerFX listener : this.changeListeners) {
+ listener.overlayChanged(event);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/jfree/chart/fx/overlay/CrosshairOverlayFX.java b/src/main/java/org/jfree/chart/fx/overlay/CrosshairOverlayFX.java
index 8b2bb78..a152782 100644
--- a/src/main/java/org/jfree/chart/fx/overlay/CrosshairOverlayFX.java
+++ b/src/main/java/org/jfree/chart/fx/overlay/CrosshairOverlayFX.java
@@ -36,23 +36,39 @@
package org.jfree.chart.fx.overlay;
+import java.awt.BasicStroke;
+import java.awt.Color;
import java.awt.Graphics2D;
+import java.awt.Paint;
import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
import org.jfree.chart.JFreeChart;
+import org.jfree.chart.api.RectangleEdge;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.fx.ChartCanvas;
import org.jfree.chart.fx.ChartViewer;
-import org.jfree.chart.panel.CrosshairOverlay;
import org.jfree.chart.plot.Crosshair;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
-import org.jfree.chart.ui.RectangleEdge;
/**
* An overlay for a {@link ChartViewer} that draws crosshairs on a plot.
*/
-public class CrosshairOverlayFX extends CrosshairOverlay implements OverlayFX {
+public class CrosshairOverlayFX extends AbstractOverlayFX implements OverlayFX,
+ PropertyChangeListener {
+
+ private final List xCrosshairs = new ArrayList<>();
+
+ private final List yCrosshairs = new ArrayList<>();
/**
* Creates a new instance.
@@ -61,6 +77,88 @@ public CrosshairOverlayFX() {
super();
}
+ /**
+ * Adds a crosshair for the x-axis and sends a change event to all
+ * registered listeners.
+ *
+ * @param crosshair the crosshair ({@code null} not permitted).
+ */
+ public void addDomainCrosshair(Crosshair crosshair) {
+ Objects.requireNonNull(crosshair, "crosshair");
+ this.xCrosshairs.add(crosshair);
+ crosshair.addPropertyChangeListener(this);
+ fireOverlayChanged();
+ }
+
+ /**
+ * Removes a domain crosshair and sends a change event to all registered
+ * listeners.
+ *
+ * @param crosshair the crosshair ({@code null} not permitted).
+ */
+ public void removeDomainCrosshair(Crosshair crosshair) {
+ Objects.requireNonNull(crosshair, "crosshair");
+ if (this.xCrosshairs.remove(crosshair)) {
+ crosshair.removePropertyChangeListener(this);
+ fireOverlayChanged();
+ }
+ }
+
+ /**
+ * Returns a list of the domain crosshairs.
+ *
+ * @return A list (possibly empty, but never {@code null}).
+ */
+ public List getDomainCrosshairs() {
+ return Collections.unmodifiableList(this.xCrosshairs);
+ }
+
+ /**
+ * Adds a crosshair for the y-axis and sends a change event to all
+ * registered listeners.
+ *
+ * @param crosshair the crosshair ({@code null} not permitted).
+ */
+ public void addRangeCrosshair(Crosshair crosshair) {
+ Objects.requireNonNull(crosshair, "crosshair");
+ this.yCrosshairs.add(crosshair);
+ crosshair.addPropertyChangeListener(this);
+ fireOverlayChanged();
+ }
+
+ /**
+ * Removes a range crosshair and sends a change event to all registered
+ * listeners.
+ *
+ * @param crosshair the crosshair ({@code null} not permitted).
+ */
+ public void removeRangeCrosshair(Crosshair crosshair) {
+ Objects.requireNonNull(crosshair, "crosshair");
+ if (this.yCrosshairs.remove(crosshair)) {
+ crosshair.removePropertyChangeListener(this);
+ fireOverlayChanged();
+ }
+ }
+
+ /**
+ * Returns a list of the range crosshairs.
+ *
+ * @return A list (possibly empty, but never {@code null}).
+ */
+ public List getRangeCrosshairs() {
+ return Collections.unmodifiableList(this.yCrosshairs);
+ }
+
+ /**
+ * Receives notification of a property change event from a crosshair.
+ *
+ * @param event the event.
+ */
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ fireOverlayChanged();
+ }
+
@Override
public void paintOverlay(Graphics2D g2, ChartCanvas chartCanvas) {
if (chartCanvas.getRenderingInfo() == null) {
@@ -99,4 +197,46 @@ public void paintOverlay(Graphics2D g2, ChartCanvas chartCanvas) {
}
g2.setClip(savedClip);
}
+
+ /**
+ * Draws a vertical crosshair.
+ *
+ * @param g2 the graphics target.
+ * @param dataArea the data area.
+ * @param x the x-value in Java2D space.
+ * @param crosshair the crosshair.
+ */
+ protected void drawVerticalCrosshair(Graphics2D g2, Rectangle2D dataArea,
+ double x, Crosshair crosshair) {
+ if (x >= dataArea.getMinX() && x <= dataArea.getMaxX()) {
+ Line2D line = new Line2D.Double(x, dataArea.getMinY(), x,
+ dataArea.getMaxY());
+ Paint paint = crosshair.getPaint();
+ Stroke stroke = crosshair.getStroke();
+ g2.setPaint(paint != null ? paint : Color.BLACK);
+ g2.setStroke(stroke != null ? stroke : new BasicStroke(1.0f));
+ g2.draw(line);
+ }
+ }
+
+ /**
+ * Draws a horizontal crosshair.
+ *
+ * @param g2 the graphics target.
+ * @param dataArea the data area.
+ * @param y the y-value in Java2D space.
+ * @param crosshair the crosshair.
+ */
+ protected void drawHorizontalCrosshair(Graphics2D g2, Rectangle2D dataArea,
+ double y, Crosshair crosshair) {
+ if (y >= dataArea.getMinY() && y <= dataArea.getMaxY()) {
+ Line2D line = new Line2D.Double(dataArea.getMinX(), y,
+ dataArea.getMaxX(), y);
+ Paint paint = crosshair.getPaint();
+ Stroke stroke = crosshair.getStroke();
+ g2.setPaint(paint != null ? paint : Color.BLACK);
+ g2.setStroke(stroke != null ? stroke : new BasicStroke(1.0f));
+ g2.draw(line);
+ }
+ }
}
diff --git a/src/main/java/org/jfree/chart/fx/overlay/OverlayChangeEventFX.java b/src/main/java/org/jfree/chart/fx/overlay/OverlayChangeEventFX.java
new file mode 100644
index 0000000..ebae1bb
--- /dev/null
+++ b/src/main/java/org/jfree/chart/fx/overlay/OverlayChangeEventFX.java
@@ -0,0 +1,56 @@
+/* ================================================
+ * JFreeChart-FX : JavaFX extensions for JFreeChart
+ * ================================================
+ *
+ * (C) Copyright 2017-present, by David Gilbert and Contributors.
+ *
+ * Project Info: https://github.com/jfree/jfreechart-fx
+ *
+ * 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.]
+ *
+ * ------------------------
+ * OverlayChangeEventFX.java
+ * ------------------------
+ * (C) Copyright 2024-present, by David Gilbert and Contributors.
+ *
+ * Original Author: David Gilbert;
+ * Contributor(s): -;
+ *
+ */
+
+package org.jfree.chart.fx.overlay;
+
+import java.util.EventObject;
+
+/**
+ * An event that can be passed to an {@link OverlayChangeListenerFX} to
+ * indicate that an overlay has changed.
+ */
+public class OverlayChangeEventFX extends EventObject {
+
+ /**
+ * Creates a new event.
+ *
+ * @param source the source of the event.
+ */
+ public OverlayChangeEventFX(Object source) {
+ super(source);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/jfree/chart/fx/overlay/OverlayChangeListenerFX.java b/src/main/java/org/jfree/chart/fx/overlay/OverlayChangeListenerFX.java
new file mode 100644
index 0000000..1e71a98
--- /dev/null
+++ b/src/main/java/org/jfree/chart/fx/overlay/OverlayChangeListenerFX.java
@@ -0,0 +1,54 @@
+/* ================================================
+ * JFreeChart-FX : JavaFX extensions for JFreeChart
+ * ================================================
+ *
+ * (C) Copyright 2017-present, by David Gilbert and Contributors.
+ *
+ * Project Info: https://github.com/jfree/jfreechart-fx
+ *
+ * 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.]
+ *
+ * --------------------------
+ * OverlayChangeListenerFX.java
+ * --------------------------
+ * (C) Copyright 2024-present, by David Gilbert and Contributors.
+ *
+ * Original Author: David Gilbert;
+ * Contributor(s): -;
+ *
+ */
+
+package org.jfree.chart.fx.overlay;
+
+import java.util.EventListener;
+
+/**
+ * The interface that must be supported by objects that wish to receive
+ * notification of changes to an {@link OverlayFX}.
+ */
+public interface OverlayChangeListenerFX extends EventListener {
+
+ /**
+ * Receives notification of a change to an overlay.
+ *
+ * @param event the event.
+ */
+ void overlayChanged(OverlayChangeEventFX event);
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/jfree/chart/fx/overlay/OverlayFX.java b/src/main/java/org/jfree/chart/fx/overlay/OverlayFX.java
index 459670c..21d8aab 100644
--- a/src/main/java/org/jfree/chart/fx/overlay/OverlayFX.java
+++ b/src/main/java/org/jfree/chart/fx/overlay/OverlayFX.java
@@ -38,12 +38,26 @@
import java.awt.Graphics2D;
import org.jfree.chart.fx.ChartCanvas;
-import org.jfree.chart.panel.Overlay;
/**
* An overlay that can be added to a {@link ChartCanvas}.
*/
-public interface OverlayFX extends Overlay {
+public interface OverlayFX {
+
+ /**
+ * Registers a listener to receive notification of changes to the overlay.
+ *
+ * @param listener the listener.
+ */
+ void addChangeListener(OverlayChangeListenerFX listener);
+
+ /**
+ * Deregisters a listener so that it no longer receives notification of
+ * changes to the overlay.
+ *
+ * @param listener the listener.
+ */
+ void removeChangeListener(OverlayChangeListenerFX listener);
/**
* Paints the content of the overlay onto the specified chart canvas.