001/* =========================================================== 002 * JFreeChart : a free chart library for the Java(tm) platform 003 * =========================================================== 004 * 005 * (C) Copyright 2000-2022, by David Gilbert and Contributors. 006 * 007 * Project Info: http://www.jfree.org/jfreechart/index.html 008 * 009 * This library is free software; you can redistribute it and/or modify it 010 * under the terms of the GNU Lesser General Public License as published by 011 * the Free Software Foundation; either version 2.1 of the License, or 012 * (at your option) any later version. 013 * 014 * This library is distributed in the hope that it will be useful, but 015 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 016 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 017 * License for more details. 018 * 019 * You should have received a copy of the GNU Lesser General Public 020 * License along with this library; if not, write to the Free Software 021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 022 * USA. 023 * 024 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. 025 * Other names may be trademarks of their respective owners.] 026 * 027 * ------------ 028 * Overlay.java 029 * ------------ 030 * (C) Copyright 2009-2022, by David Gilbert. 031 * 032 * Original Author: David Gilbert; 033 * Contributor(s): -; 034 * 035 */ 036 037package org.jfree.chart.swing; 038 039import java.awt.Graphics2D; 040 041/** 042 * An {@code Overlay} is anything that can be drawn over top of a chart to add 043 * additional information to the chart. This interface defines the operations 044 * that must be supported for an overlay that can be added to a 045 * {@link ChartPanel} in Swing. 046 * <br><br> 047 * Note: if you are using JavaFX rather than Swing, then you need to look at 048 * the {@code OverlayFX} interface in the <b>JFreeChart-FX</b> project. 049 */ 050public interface Overlay { 051 052 /** 053 * Paints the visual representation of the overlay. This method will be 054 * called by the {@link ChartPanel} after the underlying chart has been 055 * fully rendered. When implementing this method, the {@code chartPanel} 056 * argument can be used to get state information from the chart (you can, 057 * for example, extract the axis ranges for the chart). 058 * 059 * @param g2 the graphics target (never {@code null}). 060 * @param chartPanel the chart panel (never {@code null}). 061 */ 062 void paintOverlay(Graphics2D g2, ChartPanel chartPanel); 063 064 /** 065 * Registers a change listener with the overlay. Typically this method 066 * not be called by user code, it exists so that the {@link ChartPanel} 067 * can register and receive notification of changes to the overlay (such 068 * changes will trigger an automatic repaint of the chart). 069 * 070 * @param listener the listener ({@code null} not permitted). 071 * 072 * @see #removeChangeListener(org.jfree.chart.event.OverlayChangeListener) 073 */ 074 void addChangeListener(OverlayChangeListener listener); 075 076 /** 077 * Deregisters a listener from the overlay. 078 * 079 * @param listener the listener ({@code null} not permitted). 080 * 081 * @see #addChangeListener(org.jfree.chart.event.OverlayChangeListener) 082 */ 083 void removeChangeListener(OverlayChangeListener listener); 084 085}