001/* ===========================================================
002 * JFreeChart : a free chart library for the Java(tm) platform
003 * ===========================================================
004 *
005 * (C) Copyright 2000-present, 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 * XYItemRenderer.java
029 * -------------------
030 * (C) Copyright 2001-present, by David Gilbert and Contributors.
031 *
032 * Original Author:  David Gilbert;
033 * Contributor(s):   Mark Watson (www.markwatson.com);
034 *                   Sylvain Vieujot;
035 *                   Focus Computer Services Limited;
036 *                   Richard Atkinson;
037 *
038 */
039
040package org.jfree.chart.renderer.xy;
041
042import java.awt.Font;
043import java.awt.Graphics2D;
044import java.awt.Paint;
045import java.awt.Shape;
046import java.awt.Stroke;
047import java.awt.geom.Rectangle2D;
048
049import org.jfree.chart.LegendItem;
050import org.jfree.chart.LegendItemSource;
051import org.jfree.chart.annotations.XYAnnotation;
052import org.jfree.chart.axis.ValueAxis;
053import org.jfree.chart.event.RendererChangeEvent;
054import org.jfree.chart.event.RendererChangeListener;
055import org.jfree.chart.labels.ItemLabelPosition;
056import org.jfree.chart.labels.XYItemLabelGenerator;
057import org.jfree.chart.labels.XYSeriesLabelGenerator;
058import org.jfree.chart.labels.XYToolTipGenerator;
059import org.jfree.chart.plot.CrosshairState;
060import org.jfree.chart.plot.Marker;
061import org.jfree.chart.plot.PlotRenderingInfo;
062import org.jfree.chart.plot.XYPlot;
063import org.jfree.chart.ui.Layer;
064import org.jfree.chart.urls.XYURLGenerator;
065import org.jfree.data.Range;
066import org.jfree.data.xy.XYDataset;
067
068/**
069 * Interface for rendering the visual representation of a single (x, y) item on
070 * an {@link XYPlot}.
071 * <p>
072 * To support cloning charts, it is recommended that renderers implement both
073 * the {@link Cloneable} and {@code PublicCloneable} interfaces.
074 */
075public interface XYItemRenderer extends LegendItemSource {
076
077    /**
078     * Returns the plot that this renderer has been assigned to.
079     *
080     * @return The plot.
081     */
082    XYPlot getPlot();
083
084    /**
085     * Sets the plot that this renderer is assigned to.  This method will be
086     * called by the plot class...you do not need to call it yourself.
087     *
088     * @param plot  the plot.
089     */
090    void setPlot(XYPlot plot);
091
092    /**
093     * Returns the number of passes through the data required by the renderer.
094     *
095     * @return The pass count.
096     */
097    int getPassCount();
098
099    /**
100     * Returns the lower and upper bounds (range) of the x-values in the
101     * specified dataset.
102     *
103     * @param dataset  the dataset ({@code null} permitted).
104     *
105     * @return The range.
106     */
107    Range findDomainBounds(XYDataset dataset);
108
109    /**
110     * Returns the lower and upper bounds (range) of the y-values in the
111     * specified dataset.  The implementation of this method will take
112     * into account the presentation used by the renderers (for example,
113     * a renderer that "stacks" values will return a bigger range than
114     * a renderer that doesn't).
115     *
116     * @param dataset  the dataset ({@code null} permitted).
117     *
118     * @return The range (or {@code null} if the dataset is
119     *         {@code null} or empty).
120     */
121    Range findRangeBounds(XYDataset dataset);
122
123    /**
124     * Add a renderer change listener.
125     *
126     * @param listener  the listener.
127     *
128     * @see #removeChangeListener(RendererChangeListener)
129     */
130    void addChangeListener(RendererChangeListener listener);
131
132    /**
133     * Removes a change listener.
134     *
135     * @param listener  the listener.
136     *
137     * @see #addChangeListener(RendererChangeListener)
138     */
139    void removeChangeListener(RendererChangeListener listener);
140
141
142    //// VISIBLE //////////////////////////////////////////////////////////////
143
144    /**
145     * Returns a boolean that indicates whether or not the specified item
146     * should be drawn (this is typically used to hide an entire series).
147     *
148     * @param series  the series index.
149     * @param item  the item index.
150     *
151     * @return A boolean.
152     */
153    boolean getItemVisible(int series, int item);
154
155    /**
156     * Returns a boolean that indicates whether or not the specified series
157     * should be drawn (this is typically used to hide an entire series).
158     *
159     * @param series  the series index.
160     *
161     * @return A boolean.
162     */
163    boolean isSeriesVisible(int series);
164
165    /**
166     * Returns the flag that controls whether a series is visible.
167     *
168     * @param series  the series index (zero-based).
169     *
170     * @return The flag (possibly {@code null}).
171     *
172     * @see #setSeriesVisible(int, Boolean)
173     */
174    Boolean getSeriesVisible(int series);
175
176    /**
177     * Sets the flag that controls whether a series is visible and sends a
178     * {@link RendererChangeEvent} to all registered listeners.
179     *
180     * @param series  the series index (zero-based).
181     * @param visible  the flag ({@code null} permitted).
182     *
183     * @see #getSeriesVisible(int)
184     */
185    void setSeriesVisible(int series, Boolean visible);
186
187    /**
188     * Sets the flag that controls whether a series is visible and, if
189     * requested, sends a {@link RendererChangeEvent} to all registered
190     * listeners.
191     *
192     * @param series  the series index.
193     * @param visible  the flag ({@code null} permitted).
194     * @param notify  notify listeners?
195     *
196     * @see #getSeriesVisible(int)
197     */
198    void setSeriesVisible(int series, Boolean visible, boolean notify);
199
200    /**
201     * Returns the default visibility for all series.
202     *
203     * @return The default visibility.
204     *
205     * @see #setDefaultSeriesVisible(boolean)
206     */
207    boolean getDefaultSeriesVisible();
208
209    /**
210     * Sets the default visibility and sends a {@link RendererChangeEvent} to all
211     * registered listeners.
212     *
213     * @param visible  the flag.
214     *
215     * @see #getDefaultSeriesVisible()
216     */
217    void setDefaultSeriesVisible(boolean visible);
218
219    /**
220     * Sets the default visibility and, if requested, sends
221     * a {@link RendererChangeEvent} to all registered listeners.
222     *
223     * @param visible  the visibility.
224     * @param notify  notify listeners?
225     *
226     * @see #getDefaultSeriesVisible()
227     */
228    void setDefaultSeriesVisible(boolean visible, boolean notify);
229
230    // SERIES VISIBLE IN LEGEND (not yet respected by all renderers)
231
232    /**
233     * Returns {@code true} if the series should be shown in the legend,
234     * and {@code false} otherwise.
235     *
236     * @param series  the series index.
237     *
238     * @return A boolean.
239     */
240    boolean isSeriesVisibleInLegend(int series);
241
242    /**
243     * Returns the flag that controls whether a series is visible in the
244     * legend.  This method returns only the "per series" settings - to
245     * incorporate the override and base settings as well, you need to use the
246     * {@link #isSeriesVisibleInLegend(int)} method.
247     *
248     * @param series  the series index (zero-based).
249     *
250     * @return The flag (possibly {@code null}).
251     *
252     * @see #setSeriesVisibleInLegend(int, Boolean)
253     */
254    Boolean getSeriesVisibleInLegend(int series);
255
256    /**
257     * Sets the flag that controls whether a series is visible in the legend
258     * and sends a {@link RendererChangeEvent} to all registered listeners.
259     *
260     * @param series  the series index (zero-based).
261     * @param visible  the flag ({@code null} permitted).
262     *
263     * @see #getSeriesVisibleInLegend(int)
264     */
265    void setSeriesVisibleInLegend(int series, Boolean visible);
266
267    /**
268     * Sets the flag that controls whether a series is visible in the legend
269     * and, if requested, sends a {@link RendererChangeEvent} to all registered
270     * listeners.
271     *
272     * @param series  the series index.
273     * @param visible  the flag ({@code null} permitted).
274     * @param notify  notify listeners?
275     *
276     * @see #getSeriesVisibleInLegend(int)
277     */
278    void setSeriesVisibleInLegend(int series, Boolean visible,
279                                  boolean notify);
280
281    /**
282     * Returns the default visibility in the legend for all series.
283     *
284     * @return The default visibility.
285     *
286     * @see #setDefaultSeriesVisibleInLegend(boolean)
287     */
288    boolean getDefaultSeriesVisibleInLegend();
289
290    /**
291     * Sets the default visibility in the legend and sends a
292     * {@link RendererChangeEvent} to all registered listeners.
293     *
294     * @param visible  the flag.
295     *
296     * @see #getDefaultSeriesVisibleInLegend()
297     */
298    void setDefaultSeriesVisibleInLegend(boolean visible);
299
300    /**
301     * Sets the default visibility in the legend and, if requested, sends
302     * a {@link RendererChangeEvent} to all registered listeners.
303     *
304     * @param visible  the visibility.
305     * @param notify  notify listeners?
306     *
307     * @see #getDefaultSeriesVisibleInLegend()
308     */
309    void setDefaultSeriesVisibleInLegend(boolean visible, boolean notify);
310
311
312    //// PAINT ////////////////////////////////////////////////////////////////
313
314    /**
315     * Returns the paint used to color data items as they are drawn.
316     *
317     * @param row  the row (or series) index (zero-based).
318     * @param column  the column (or category) index (zero-based).
319     *
320     * @return The paint (never {@code null}).
321     */
322    Paint getItemPaint(int row, int column);
323
324    /**
325     * Returns the paint used to color an item drawn by the renderer.
326     *
327     * @param series  the series index (zero-based).
328     *
329     * @return The paint (possibly {@code null}).
330     *
331     * @see #setSeriesPaint(int, Paint)
332     */
333    Paint getSeriesPaint(int series);
334
335    /**
336     * Sets the paint used for a series and sends a {@link RendererChangeEvent}
337     * to all registered listeners.
338     *
339     * @param series  the series index (zero-based).
340     * @param paint  the paint ({@code null} permitted).
341     *
342     * @see #getSeriesPaint(int)
343     */
344    void setSeriesPaint(int series, Paint paint);
345
346    /**
347     * Sets the paint used for a series and sends a {@link RendererChangeEvent}
348     * to all registered listeners if requested.
349     *
350     * @param series  the series index (zero-based).
351     * @param paint  the paint ({@code null} permitted).
352     * @param notify  send a change event?
353     *
354     * @see #getSeriesPaint(int)
355     */
356    void setSeriesPaint(int series, Paint paint, boolean notify);
357
358    /**
359     * Returns the default paint.
360     *
361     * @return The default paint (never {@code null}).
362     *
363     * @see #setDefaultPaint(Paint)
364     */
365    Paint getDefaultPaint();
366
367    /**
368     * Sets the default paint and sends a {@link RendererChangeEvent} to all
369     * registered listeners.
370     *
371     * @param paint  the paint ({@code null} not permitted).
372     *
373     * @see #getDefaultPaint()
374     */
375    void setDefaultPaint(Paint paint);
376
377    /**
378     * Sets the default paint and sends a {@link RendererChangeEvent} to all
379     * registered listeners if requested.
380     *
381     * @param paint  the paint ({@code null} not permitted).
382     * @param notify  send a change event?
383     *
384     * @see #getDefaultPaint()
385     */
386    void setDefaultPaint(Paint paint, boolean notify);
387
388    // FILL PAINT
389
390    /**
391     * Returns the paint used to fill data items as they are drawn.
392     *
393     * @param row  the row (or series) index (zero-based).
394     * @param column  the column (or category) index (zero-based).
395     *
396     * @return The paint (never {@code null}).
397     */
398    Paint getItemFillPaint(int row, int column);
399
400    /**
401     * Returns the paint used to fill an item drawn by the renderer.
402     *
403     * @param series  the series index (zero-based).
404     *
405     * @return The paint (possibly {@code null}).
406     */
407    Paint getSeriesFillPaint(int series);
408
409    /**
410     * Sets the paint used for a series and sends a
411     * {@link RendererChangeEvent} to all registered listeners.
412     *
413     * @param series  the series index (zero-based).
414     * @param paint  the paint ({@code null} permitted).
415     */
416    void setSeriesFillPaint(int series, Paint paint);
417
418    /**
419     * Sets the paint used for a series and sends a
420     * {@link RendererChangeEvent} to all registered listeners if requested.
421     *
422     * @param series  the series index (zero-based).
423     * @param paint  the paint ({@code null} permitted).
424     * @param notify  send a change event?
425     */
426    void setSeriesFillPaint(int series, Paint paint, boolean notify);
427
428    /**
429     * Returns the default paint.
430     *
431     * @return The default paint (never {@code null}).
432     */
433    Paint getDefaultFillPaint();
434
435    /**
436     * Sets the default paint and sends a {@link RendererChangeEvent} to all
437     * registered listeners.
438     *
439     * @param paint  the paint ({@code null} not permitted).
440     */
441    void setDefaultFillPaint(Paint paint);
442
443    /**
444     * Sets the default paint and sends a {@link RendererChangeEvent} to all
445     * registered listeners if requested.
446     *
447     * @param paint  the paint ({@code null} not permitted).
448     * @param notify  send a change event?
449     */
450    void setDefaultFillPaint(Paint paint, boolean notify);
451
452    //// OUTLINE PAINT ////////////////////////////////////////////////////////
453
454    /**
455     * Returns the paint used to outline data items as they are drawn.
456     *
457     * @param row  the row (or series) index (zero-based).
458     * @param column  the column (or category) index (zero-based).
459     *
460     * @return The paint (never {@code null}).
461     */
462    Paint getItemOutlinePaint(int row, int column);
463
464    /**
465     * Returns the paint used to outline an item drawn by the renderer.
466     *
467     * @param series  the series (zero-based index).
468     *
469     * @return The paint (possibly {@code null}).
470     *
471     * @see #setSeriesOutlinePaint(int, Paint)
472     */
473    Paint getSeriesOutlinePaint(int series);
474
475    /**
476     * Sets the paint used for a series outline and sends a
477     * {@link RendererChangeEvent} to all registered listeners.
478     *
479     * @param series  the series index (zero-based).
480     * @param paint  the paint ({@code null} permitted).
481     *
482     * @see #getSeriesOutlinePaint(int)
483     */
484    void setSeriesOutlinePaint(int series, Paint paint);
485
486    /**
487     * Sets the paint used for a series outline and sends a
488     * {@link RendererChangeEvent} to all registered listeners if requested.
489     *
490     * @param series  the series index (zero-based).
491     * @param paint  the paint ({@code null} permitted).
492     * @param notify  send a change event?
493     *
494     * @see #getSeriesOutlinePaint(int)
495     */
496    void setSeriesOutlinePaint(int series, Paint paint, boolean notify);
497
498    /**
499     * Returns the default outline paint.
500     *
501     * @return The paint (never {@code null}).
502     *
503     * @see #setDefaultOutlinePaint(Paint)
504     */
505    Paint getDefaultOutlinePaint();
506
507    /**
508     * Sets the default outline paint and sends a {@link RendererChangeEvent} to
509     * all registered listeners.
510     *
511     * @param paint  the paint ({@code null} not permitted).
512     *
513     * @see #getDefaultOutlinePaint()
514     */
515    void setDefaultOutlinePaint(Paint paint);
516
517    /**
518     * Sets the default outline paint and sends a {@link RendererChangeEvent} to
519     * all registered listeners if requested.
520     *
521     * @param paint  the paint ({@code null} not permitted).
522     * @param notify  send a change event?
523     *
524     * @see #getDefaultOutlinePaint()
525     */
526    void setDefaultOutlinePaint(Paint paint, boolean notify);
527
528    //// STROKE ///////////////////////////////////////////////////////////////
529
530    /**
531     * Returns the stroke used to draw data items.
532     *
533     * @param row  the row (or series) index (zero-based).
534     * @param column  the column (or category) index (zero-based).
535     *
536     * @return The stroke (never {@code null}).
537     */
538    Stroke getItemStroke(int row, int column);
539
540    /**
541     * Returns the stroke used to draw the items in a series.
542     *
543     * @param series  the series (zero-based index).
544     *
545     * @return The stroke (possibly {@code null}).
546     *
547     * @see #setSeriesStroke(int, Stroke)
548     */
549    Stroke getSeriesStroke(int series);
550
551    /**
552     * Sets the stroke used for a series and sends a
553     * {@link RendererChangeEvent} to all registered listeners.
554     *
555     * @param series  the series index (zero-based).
556     * @param stroke  the stroke ({@code null} permitted).
557     *
558     * @see #getSeriesStroke(int)
559     */
560    void setSeriesStroke(int series, Stroke stroke);
561
562    /**
563     * Sets the stroke used for a series and sends a
564     * {@link RendererChangeEvent} to all registered listeners if requested.
565     *
566     * @param series  the series index (zero-based).
567     * @param stroke  the stroke ({@code null} permitted).
568     * @param notify  send a change event?
569     *
570     * @see #getSeriesStroke(int)
571     */
572    void setSeriesStroke(int series, Stroke stroke, boolean notify);
573
574    /**
575     * Returns the default stroke.
576     *
577     * @return The default stroke (never {@code null}).
578     *
579     * @see #setDefaultStroke(Stroke)
580     */
581    Stroke getDefaultStroke();
582
583    /**
584     * Sets the default stroke and sends a {@link RendererChangeEvent} to all
585     * registered listeners.
586     *
587     * @param stroke  the stroke ({@code null} not permitted).
588     *
589     * @see #getDefaultStroke()
590     */
591    void setDefaultStroke(Stroke stroke);
592
593    /**
594     * Sets the default stroke and sends a {@link RendererChangeEvent} to all
595     * registered listeners if requested.
596     *
597     * @param stroke  the stroke ({@code null} not permitted).
598     * @param notify  send a change event?
599     *
600     * @see #getDefaultStroke()
601     */
602    void setDefaultStroke(Stroke stroke, boolean notify);
603
604    //// OUTLINE STROKE ///////////////////////////////////////////////////////
605
606    /**
607     * Returns the stroke used to outline data items.  The default
608     * implementation passes control to the lookupSeriesOutlineStroke method.
609     * You can override this method if you require different behaviour.
610     *
611     * @param row  the row (or series) index (zero-based).
612     * @param column  the column (or category) index (zero-based).
613     *
614     * @return The stroke (never {@code null}).
615     */
616    Stroke getItemOutlineStroke(int row, int column);
617
618    /**
619     * Returns the stroke used to outline the items in a series.
620     *
621     * @param series  the series (zero-based index).
622     *
623     * @return The stroke (possibly {@code null}).
624     *
625     * @see #setSeriesOutlineStroke(int, Stroke)
626     */
627    Stroke getSeriesOutlineStroke(int series);
628
629    /**
630     * Sets the outline stroke used for a series and sends a
631     * {@link RendererChangeEvent} to all registered listeners.
632     *
633     * @param series  the series index (zero-based).
634     * @param stroke  the stroke ({@code null} permitted).
635     *
636     * @see #getSeriesOutlineStroke(int)
637     */
638    void setSeriesOutlineStroke(int series, Stroke stroke);
639
640    /**
641     * Sets the outline stroke used for a series and sends a
642     * {@link RendererChangeEvent} to all registered listeners if requested.
643     *
644     * @param series  the series index (zero-based).
645     * @param stroke  the stroke ({@code null} permitted).
646     * @param notify  send a change event?
647     *
648     * @see #getSeriesOutlineStroke(int)
649     */
650    void setSeriesOutlineStroke(int series, Stroke stroke, boolean notify);
651
652    /**
653     * Returns the default outline stroke.
654     *
655     * @return The stroke (never {@code null}).
656     *
657     * @see #setDefaultOutlineStroke(Stroke)
658     */
659    Stroke getDefaultOutlineStroke();
660
661    /**
662     * Sets the base outline stroke and sends a {@link RendererChangeEvent} to
663     * all registered listeners.
664     *
665     * @param stroke  the stroke ({@code null} not permitted).
666     *
667     * @see #getDefaultOutlineStroke()
668     */
669    void setDefaultOutlineStroke(Stroke stroke);
670
671    /**
672     * Sets the base outline stroke and sends a {@link RendererChangeEvent} to
673     * all registered listeners if requested.
674     *
675     * @param stroke  the stroke ({@code null} not permitted).
676     * @param notify  send a change event.
677     *
678     * @see #getDefaultOutlineStroke()
679     */
680    void setDefaultOutlineStroke(Stroke stroke, boolean notify);
681
682    //// SHAPE ////////////////////////////////////////////////////////////////
683
684    /**
685     * Returns a shape used to represent a data item.
686     *
687     * @param row  the row (or series) index (zero-based).
688     * @param column  the column (or category) index (zero-based).
689     *
690     * @return The shape (never {@code null}).
691     */
692    Shape getItemShape(int row, int column);
693
694    /**
695     * Returns a shape used to represent the items in a series.
696     *
697     * @param series  the series (zero-based index).
698     *
699     * @return The shape (possibly {@code null}).
700     *
701     * @see #setSeriesShape(int, Shape)
702     */
703    Shape getSeriesShape(int series);
704
705    /**
706     * Sets the shape used for a series and sends a {@link RendererChangeEvent}
707     * to all registered listeners.
708     *
709     * @param series  the series index (zero-based).
710     * @param shape  the shape ({@code null} permitted).
711     *
712     * @see #getSeriesShape(int)
713     */
714    void setSeriesShape(int series, Shape shape);
715
716    /**
717     * Sets the shape used for a series and sends a {@link RendererChangeEvent}
718     * to all registered listeners if requested.
719     *
720     * @param series  the series index (zero-based).
721     * @param shape  the shape ({@code null} permitted).
722     * @param notify  send a change event?
723     *
724     * @see #getSeriesShape(int)
725     */
726    void setSeriesShape(int series, Shape shape, boolean notify);
727
728    /**
729     * Returns the default shape.
730     *
731     * @return The shape (never {@code null}).
732     *
733     * @see #setDefaultShape(Shape)
734     */
735    Shape getDefaultShape();
736
737    /**
738     * Sets the default shape and sends a {@link RendererChangeEvent} to all
739     * registered listeners.
740     *
741     * @param shape  the shape ({@code null} not permitted).
742     *
743     * @see #getDefaultShape()
744     */
745    void setDefaultShape(Shape shape);
746
747    /**
748     * Sets the default shape and sends a {@link RendererChangeEvent} to all
749     * registered listeners if requested.
750     *
751     * @param shape  the shape ({@code null} not permitted).
752     * @param notify  send a change event?
753     *
754     * @see #getDefaultShape()
755     */
756    void setDefaultShape(Shape shape, boolean notify);
757
758
759    //// LEGEND ITEMS /////////////////////////////////////////////////////////
760
761    /**
762     * Returns a legend item for a series from a dataset.
763     *
764     * @param datasetIndex  the dataset index.
765     * @param series  the series (zero-based index).
766     *
767     * @return The legend item (possibly {@code null}).
768     */
769    LegendItem getLegendItem(int datasetIndex, int series);
770
771
772    //// LEGEND ITEM LABEL GENERATOR //////////////////////////////////////////
773
774    /**
775     * Returns the legend item label generator.
776     *
777     * @return The legend item label generator (never {@code null}).
778     *
779     * @see #setLegendItemLabelGenerator(XYSeriesLabelGenerator)
780     */
781    XYSeriesLabelGenerator getLegendItemLabelGenerator();
782
783    /**
784     * Sets the legend item label generator and sends a
785     * {@link RendererChangeEvent} to all registered listeners.
786     *
787     * @param generator  the generator ({@code null} not permitted).
788     */
789    void setLegendItemLabelGenerator(XYSeriesLabelGenerator generator);
790
791
792    //// TOOL TIP GENERATOR ///////////////////////////////////////////////////
793
794    /**
795     * Returns the tool tip generator for a data item.
796     *
797     * @param row  the row index (zero based).
798     * @param column  the column index (zero based).
799     *
800     * @return The generator (possibly {@code null}).
801     */
802    XYToolTipGenerator getToolTipGenerator(int row, int column);
803
804    /**
805     * Returns the tool tip generator for a series.
806     *
807     * @param series  the series index (zero based).
808     *
809     * @return The generator (possibly {@code null}).
810     *
811     * @see #setSeriesToolTipGenerator(int, XYToolTipGenerator)
812     */
813    XYToolTipGenerator getSeriesToolTipGenerator(int series);
814
815    /**
816     * Sets the tool tip generator for a series and sends a
817     * {@link RendererChangeEvent} to all registered listeners.
818     *
819     * @param series  the series index (zero based).
820     * @param generator  the generator ({@code null} permitted).
821     *
822     * @see #getSeriesToolTipGenerator(int)
823     */
824    void setSeriesToolTipGenerator(int series,
825                                   XYToolTipGenerator generator);
826
827    /**
828     * Returns the default tool tip generator.
829     *
830     * @return The generator (possibly {@code null}).
831     *
832     * @see #setDefaultToolTipGenerator(XYToolTipGenerator)
833     */
834    XYToolTipGenerator getDefaultToolTipGenerator();
835
836    /**
837     * Sets the default tool tip generator and sends a {@link RendererChangeEvent}
838     * to all registered listeners.
839     *
840     * @param generator  the generator ({@code null} permitted).
841     *
842     * @see #getDefaultToolTipGenerator()
843     */
844    void setDefaultToolTipGenerator(XYToolTipGenerator generator);
845
846    //// URL GENERATOR ////////////////////////////////////////////////////////
847
848    /**
849     * Returns the URL generator for HTML image maps.
850     *
851     * @return The URL generator (possibly null).
852     */
853    XYURLGenerator getURLGenerator();
854
855    /**
856     * Sets the URL generator for HTML image maps.
857     *
858     * @param urlGenerator the URL generator (null permitted).
859     */
860    void setURLGenerator(XYURLGenerator urlGenerator);
861
862    //// ITEM LABELS VISIBLE //////////////////////////////////////////////////
863
864    /**
865     * Returns {@code true} if an item label is visible, and
866     * {@code false} otherwise.
867     *
868     * @param row  the row index (zero-based).
869     * @param column  the column index (zero-based).
870     *
871     * @return A boolean.
872     */
873    boolean isItemLabelVisible(int row, int column);
874
875    /**
876     * Returns {@code true} if the item labels for a series are visible,
877     * and {@code false} otherwise.
878     *
879     * @param series  the series index (zero-based).
880     *
881     * @return A boolean.
882     */
883    boolean isSeriesItemLabelsVisible(int series);
884
885    /**
886     * Sets a flag that controls the visibility of the item labels for a
887     * series and sends a {@link RendererChangeEvent} to all registered
888     * listeners.
889     *
890     * @param series  the series index (zero-based).
891     * @param visible  the flag.
892     *
893     * @see #isSeriesItemLabelsVisible(int)
894     */
895    void setSeriesItemLabelsVisible(int series, boolean visible);
896
897    /**
898     * Sets a flag that controls the visibility of the item labels for a series.
899     *
900     * @param series  the series index (zero-based).
901     * @param visible  the flag ({@code null} permitted).
902     *
903     * @see #isSeriesItemLabelsVisible(int)
904     */
905    void setSeriesItemLabelsVisible(int series, Boolean visible);
906
907    /**
908     * Sets the visibility of item labels for a series and, if requested,
909     * sends a {@link RendererChangeEvent} to all registered listeners.
910     *
911     * @param series  the series index (zero-based).
912     * @param visible  the visible flag.
913     * @param notify  a flag that controls whether or not listeners are
914     *                notified.
915     *
916     * @see #isSeriesItemLabelsVisible(int)
917     */
918    void setSeriesItemLabelsVisible(int series, Boolean visible,
919                                    boolean notify);
920
921    /**
922     * Returns the default setting for item label visibility.
923     *
924     * @return A flag (possibly {@code null}).
925     *
926     * @see #setDefaultItemLabelsVisible(boolean)
927     */
928    boolean getDefaultItemLabelsVisible();
929
930    /**
931     * Sets the default flag that controls whether or not item labels are visible.
932     *
933     * @param visible  the flag.
934     *
935     * @see #getDefaultItemLabelsVisible()
936     */
937    void setDefaultItemLabelsVisible(boolean visible);
938
939    /**
940     * Sets the default visibility for item labels and, if requested, sends a
941     * {@link RendererChangeEvent} to all registered listeners.
942     *
943     * @param visible  the visibility flag.
944     * @param notify  a flag that controls whether or not listeners are
945     *                notified.
946     *
947     * @see #getDefaultItemLabelsVisible()
948     */
949    void setDefaultItemLabelsVisible(boolean visible, boolean notify);
950
951
952    //// ITEM LABEL GENERATOR /////////////////////////////////////////////////
953
954    /**
955     * Returns the item label generator for a data item.
956     *
957     * @param row  the row index (zero based).
958     * @param column  the column index (zero based).
959     *
960     * @return The generator (possibly {@code null}).
961     */
962    XYItemLabelGenerator getItemLabelGenerator(int row, int column);
963
964    /**
965     * Returns the item label generator for a series.
966     *
967     * @param series  the series index (zero based).
968     *
969     * @return The generator (possibly {@code null}).
970     *
971     * @see #setSeriesItemLabelGenerator(int, XYItemLabelGenerator)
972     */
973    XYItemLabelGenerator getSeriesItemLabelGenerator(int series);
974
975    /**
976     * Sets the item label generator for a series and sends a
977     * {@link RendererChangeEvent} to all registered listeners.
978     *
979     * @param series  the series index (zero based).
980     * @param generator  the generator ({@code null} permitted).
981     *
982     * @see #getSeriesItemLabelGenerator(int)
983     */
984    void setSeriesItemLabelGenerator(int series,
985                                     XYItemLabelGenerator generator);
986
987    /**
988     * Returns the default item label generator.
989     *
990     * @return The generator (possibly {@code null}).
991     *
992     * @see #setDefaultItemLabelGenerator(XYItemLabelGenerator)
993     */
994    XYItemLabelGenerator getDefaultItemLabelGenerator();
995
996    /**
997     * Sets the default item label generator and sends a
998     * {@link RendererChangeEvent} to all registered listeners.
999     *
1000     * @param generator  the generator ({@code null} permitted).
1001     *
1002     * @see #getDefaultItemLabelGenerator()
1003     */
1004    void setDefaultItemLabelGenerator(XYItemLabelGenerator generator);
1005
1006    //// ITEM LABEL FONT ///////////////////////////////////////////////////////
1007
1008    /**
1009     * Returns the font for an item label.
1010     *
1011     * @param row  the row index (zero-based).
1012     * @param column  the column index (zero-based).
1013     *
1014     * @return The font (never {@code null}).
1015     */
1016    Font getItemLabelFont(int row, int column);
1017
1018    /**
1019     * Returns the font for all the item labels in a series.
1020     *
1021     * @param series  the series index (zero-based).
1022     *
1023     * @return The font (possibly {@code null}).
1024     */
1025    Font getSeriesItemLabelFont(int series);
1026
1027    /**
1028     * Sets the item label font for a series and sends a
1029     * {@link RendererChangeEvent} to all registered listeners.
1030     *
1031     * @param series  the series index (zero-based).
1032     * @param font  the font ({@code null} permitted).
1033     *
1034     * @see #getSeriesItemLabelFont(int)
1035     */
1036    void setSeriesItemLabelFont(int series, Font font);
1037
1038    /**
1039     * Returns the default item label font (this is used when no other font
1040     * setting is available).
1041     *
1042     * @return The font (never {@code null}).
1043     *
1044     * @see #setDefaultItemLabelFont(Font)
1045     */
1046    Font getDefaultItemLabelFont();
1047
1048    /**
1049     * Sets the default item label font and sends a {@link RendererChangeEvent}
1050     * to all registered listeners.
1051     *
1052     * @param font  the font ({@code null} not permitted).
1053     *
1054     * @see #getDefaultItemLabelFont()
1055     */
1056    void setDefaultItemLabelFont(Font font);
1057
1058    //// ITEM LABEL PAINT  /////////////////////////////////////////////////////
1059
1060    /**
1061     * Returns the paint used to draw an item label.
1062     *
1063     * @param row  the row index (zero based).
1064     * @param column  the column index (zero based).
1065     *
1066     * @return The paint (never {@code null}).
1067     */
1068    Paint getItemLabelPaint(int row, int column);
1069
1070    /**
1071     * Returns the paint used to draw the item labels for a series.
1072     *
1073     * @param series  the series index (zero based).
1074     *
1075     * @return The paint (possibly {@code null}).
1076     *
1077     * @see #setSeriesItemLabelPaint(int, Paint)
1078     */
1079    Paint getSeriesItemLabelPaint(int series);
1080
1081    /**
1082     * Sets the item label paint for a series and sends a
1083     * {@link RendererChangeEvent} to all registered listeners.
1084     *
1085     * @param series  the series (zero based index).
1086     * @param paint  the paint ({@code null} permitted).
1087     *
1088     * @see #getSeriesItemLabelPaint(int)
1089     */
1090    void setSeriesItemLabelPaint(int series, Paint paint);
1091
1092    /**
1093     * Returns the default item label paint.
1094     *
1095     * @return The paint (never {@code null}).
1096     */
1097    Paint getDefaultItemLabelPaint();
1098
1099    /**
1100     * Sets the default item label paint and sends a {@link RendererChangeEvent}
1101     * to all registered listeners.
1102     *
1103     * @param paint  the paint ({@code null} not permitted).
1104     */
1105    void setDefaultItemLabelPaint(Paint paint);
1106
1107    // POSITIVE ITEM LABEL POSITION...
1108
1109    /**
1110     * Returns the item label position for positive values.
1111     *
1112     * @param row  the row index (zero-based).
1113     * @param column  the column index (zero-based).
1114     *
1115     * @return The item label position (never {@code null}).
1116     */
1117    ItemLabelPosition getPositiveItemLabelPosition(int row, int column);
1118
1119    /**
1120     * Returns the item label position for all positive values in a series.
1121     *
1122     * @param series  the series index (zero-based).
1123     *
1124     * @return The item label position (never {@code null}).
1125     */
1126    ItemLabelPosition getSeriesPositiveItemLabelPosition(int series);
1127
1128    /**
1129     * Sets the item label position for all positive values in a series and
1130     * sends a {@link RendererChangeEvent} to all registered listeners.
1131     *
1132     * @param series  the series index (zero-based).
1133     * @param position  the position ({@code null} permitted).
1134     */
1135    void setSeriesPositiveItemLabelPosition(int series,
1136                                            ItemLabelPosition position);
1137
1138    /**
1139     * Sets the item label position for all positive values in a series and (if
1140     * requested) sends a {@link RendererChangeEvent} to all registered
1141     * listeners.
1142     *
1143     * @param series  the series index (zero-based).
1144     * @param position  the position ({@code null} permitted).
1145     * @param notify  notify registered listeners?
1146     */
1147    void setSeriesPositiveItemLabelPosition(int series,
1148                                            ItemLabelPosition position, boolean notify);
1149
1150    /**
1151     * Returns the default positive item label position.
1152     *
1153     * @return The position (never {@code null}).
1154     */
1155    ItemLabelPosition getDefaultPositiveItemLabelPosition();
1156
1157    /**
1158     * Sets the default positive item label position.
1159     *
1160     * @param position  the position ({@code null} not permitted).
1161     */
1162    void setDefaultPositiveItemLabelPosition(ItemLabelPosition position);
1163
1164    /**
1165     * Sets the default positive item label position and, if requested, sends a
1166     * {@link RendererChangeEvent} to all registered listeners.
1167     *
1168     * @param position  the position ({@code null} not permitted).
1169     * @param notify  notify registered listeners?
1170     */
1171    void setDefaultPositiveItemLabelPosition(ItemLabelPosition position,
1172                                             boolean notify);
1173
1174
1175    // NEGATIVE ITEM LABEL POSITION...
1176
1177    /**
1178     * Returns the item label position for negative values.  This method can be
1179     * overridden to provide customisation of the item label position for
1180     * individual data items.
1181     *
1182     * @param row  the row index (zero-based).
1183     * @param column  the column (zero-based).
1184     *
1185     * @return The item label position (never {@code null}).
1186     */
1187    ItemLabelPosition getNegativeItemLabelPosition(int row, int column);
1188
1189    /**
1190     * Returns the item label position for all negative values in a series.
1191     *
1192     * @param series  the series index (zero-based).
1193     *
1194     * @return The item label position (never {@code null}).
1195     */
1196    ItemLabelPosition getSeriesNegativeItemLabelPosition(int series);
1197
1198    /**
1199     * Sets the item label position for negative values in a series and sends a
1200     * {@link RendererChangeEvent} to all registered listeners.
1201     *
1202     * @param series  the series index (zero-based).
1203     * @param position  the position ({@code null} permitted).
1204     */
1205    void setSeriesNegativeItemLabelPosition(int series,
1206                                            ItemLabelPosition position);
1207
1208    /**
1209     * Sets the item label position for negative values in a series and (if
1210     * requested) sends a {@link RendererChangeEvent} to all registered
1211     * listeners.
1212     *
1213     * @param series  the series index (zero-based).
1214     * @param position  the position ({@code null} permitted).
1215     * @param notify  notify registered listeners?
1216     */
1217    void setSeriesNegativeItemLabelPosition(int series,
1218                                            ItemLabelPosition position, boolean notify);
1219
1220    /**
1221     * Returns the default item label position for negative values.
1222     *
1223     * @return The position (never {@code null}).
1224     */
1225    ItemLabelPosition getDefaultNegativeItemLabelPosition();
1226
1227    /**
1228     * Sets the default item label position for negative values and sends a
1229     * {@link RendererChangeEvent} to all registered listeners.
1230     *
1231     * @param position  the position ({@code null} not permitted).
1232     */
1233    void setDefaultNegativeItemLabelPosition(ItemLabelPosition position);
1234
1235    /**
1236     * Sets the default negative item label position and, if requested, sends a
1237     * {@link RendererChangeEvent} to all registered listeners.
1238     *
1239     * @param position  the position ({@code null} not permitted).
1240     * @param notify  notify registered listeners?
1241     */
1242    void setDefaultNegativeItemLabelPosition(ItemLabelPosition position,
1243                                             boolean notify);
1244
1245
1246    // CREATE ENTITIES
1247
1248    /**
1249     * Returns {@code true} if an entity should be created for an item, and
1250     * {@code false} otherwise.
1251     * 
1252     * @param series  the series.
1253     * @param item  the item.
1254     * 
1255     * @return A boolean.
1256     */
1257    boolean getItemCreateEntity(int series, int item);
1258
1259    /**
1260     * Returns {@code true} if entities should be created for a series, and
1261     * {@code false} otherwise.  This method can return {@code null} in which
1262     * case the renderering framework will look at the default setting.
1263     * 
1264     * @param series  the series.
1265     * 
1266     * @return A boolean.
1267     */
1268    Boolean getSeriesCreateEntities(int series);
1269
1270    /**
1271     * Sets a flag that specifies whether or not entities should be created for
1272     * a series during rendering, and sends a change event to registered 
1273     * listeners.
1274     * 
1275     * @param series  the series.
1276     * @param create  the flag value ({@code null} permitted).
1277     */
1278    void setSeriesCreateEntities(int series, Boolean create);
1279
1280    /**
1281     * Sets a flag that specifies whether or not entities should be created for
1282     * a series during rendering, and sends a change event to registered 
1283     * listeners.
1284     * 
1285     * @param series  the series.
1286     * @param create  the flag value ({@code null} permitted).
1287     * @param notify  send a change event?
1288     */
1289    void setSeriesCreateEntities(int series, Boolean create,
1290                                 boolean notify);
1291
1292    /**
1293     * Returns the default value determining whether or not entities should be
1294     * created by the renderer.
1295     * 
1296     * @return A boolean. 
1297     */
1298    boolean getDefaultCreateEntities();
1299
1300    /**
1301     * Sets the default value determining whether or not entities should be
1302     * created by the renderer, and sends a change event to all registered
1303     * listeners.
1304     * 
1305     * @param create  the flag value.
1306     */
1307    void setDefaultCreateEntities(boolean create);
1308
1309    /**
1310     * Sets the default value determining whether or not entities should be
1311     * created by the renderer, and sends a change event to all registered
1312     * listeners.
1313     * 
1314     * @param create  the flag value.
1315     * @param notify  notify listeners?
1316     */
1317    void setDefaultCreateEntities(boolean create, boolean notify);
1318
1319    //// ANNOTATIONS //////////////////////////////////////////////////////////
1320
1321    /**
1322     * Adds an annotation and sends a {@link RendererChangeEvent} to all
1323     * registered listeners.  The annotation is added to the foreground
1324     * layer.
1325     *
1326     * @param annotation  the annotation ({@code null} not permitted).
1327     */
1328    void addAnnotation(XYAnnotation annotation);
1329
1330    /**
1331     * Adds an annotation to the specified layer.
1332     *
1333     * @param annotation  the annotation ({@code null} not permitted).
1334     * @param layer  the layer ({@code null} not permitted).
1335     */
1336    void addAnnotation(XYAnnotation annotation, Layer layer);
1337
1338    /**
1339     * Removes the specified annotation and sends a {@link RendererChangeEvent}
1340     * to all registered listeners.
1341     *
1342     * @param annotation  the annotation to remove ({@code null} not
1343     *                    permitted).
1344     *
1345     * @return A boolean to indicate whether or not the annotation was
1346     *         successfully removed.
1347     */
1348    boolean removeAnnotation(XYAnnotation annotation);
1349
1350    /**
1351     * Removes all annotations and sends a {@link RendererChangeEvent}
1352     * to all registered listeners.
1353     */
1354    void removeAnnotations();
1355
1356    /**
1357     * Draws all the annotations for the specified layer.
1358     *
1359     * @param g2  the graphics device.
1360     * @param dataArea  the data area.
1361     * @param domainAxis  the domain axis.
1362     * @param rangeAxis  the range axis.
1363     * @param layer  the layer.
1364     * @param info  the plot rendering info.
1365     */
1366    void drawAnnotations(Graphics2D g2, Rectangle2D dataArea,
1367                         ValueAxis domainAxis, ValueAxis rangeAxis, Layer layer,
1368                         PlotRenderingInfo info);
1369
1370    //// DRAWING //////////////////////////////////////////////////////////////
1371
1372    /**
1373     * Initialises the renderer then returns the number of 'passes' through the
1374     * data that the renderer will require (usually just one).  This method
1375     * will be called before the first item is rendered, giving the renderer
1376     * an opportunity to initialise any state information it wants to maintain.
1377     * The renderer can do nothing if it chooses.
1378     *
1379     * @param g2  the graphics device.
1380     * @param dataArea  the area inside the axes.
1381     * @param plot  the plot.
1382     * @param dataset  the dataset.
1383     * @param info  an optional info collection object to return data back to
1384     *              the caller.
1385     *
1386     * @return The number of passes the renderer requires.
1387     */
1388    XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea,
1389                                   XYPlot plot, XYDataset dataset, PlotRenderingInfo info);
1390
1391    /**
1392     * Called for each item to be plotted.
1393     * <p>
1394     * The {@link XYPlot} can make multiple passes through the dataset,
1395     * depending on the value returned by the renderer's initialise() method.
1396     *
1397     * @param g2  the graphics device.
1398     * @param state  the renderer state.
1399     * @param dataArea  the area within which the data is being rendered.
1400     * @param info  collects drawing info.
1401     * @param plot  the plot (can be used to obtain standard color
1402     *              information etc).
1403     * @param domainAxis  the domain axis.
1404     * @param rangeAxis  the range axis.
1405     * @param dataset  the dataset.
1406     * @param series  the series index (zero-based).
1407     * @param item  the item index (zero-based).
1408     * @param crosshairState  crosshair information for the plot
1409     *                        ({@code null} permitted).
1410     * @param pass  the pass index.
1411     */
1412    void drawItem(Graphics2D g2, XYItemRendererState state,
1413                  Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot,
1414                  ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset,
1415                  int series, int item, CrosshairState crosshairState, int pass);
1416
1417    /**
1418     * Fills a band between two values on the axis.  This can be used to color
1419     * bands between the grid lines.
1420     *
1421     * @param g2  the graphics device.
1422     * @param plot  the plot.
1423     * @param axis  the domain axis.
1424     * @param dataArea  the data area.
1425     * @param start  the start value.
1426     * @param end  the end value.
1427     */
1428    void fillDomainGridBand(Graphics2D g2, XYPlot plot, ValueAxis axis,
1429                            Rectangle2D dataArea, double start, double end);
1430
1431    /**
1432     * Fills a band between two values on the range axis.  This can be used to
1433     * color bands between the grid lines.
1434     *
1435     * @param g2  the graphics device.
1436     * @param plot  the plot.
1437     * @param axis  the range axis.
1438     * @param dataArea  the data area.
1439     * @param start  the start value.
1440     * @param end  the end value.
1441     */
1442    void fillRangeGridBand(Graphics2D g2, XYPlot plot, ValueAxis axis,
1443                           Rectangle2D dataArea, double start, double end);
1444
1445    /**
1446     * Draws a grid line against the domain axis.
1447     *
1448     * @param g2  the graphics device.
1449     * @param plot  the plot.
1450     * @param axis  the value axis.
1451     * @param dataArea  the area for plotting data.
1452     * @param value  the value.
1453     * @param paint  the paint ({@code null} not permitted).
1454     * @param stroke  the stroke ({@code null} not permitted).
1455     */
1456    void drawDomainLine(Graphics2D g2, XYPlot plot, ValueAxis axis,
1457                        Rectangle2D dataArea, double value, Paint paint, Stroke stroke);
1458
1459    /**
1460     * Draws a line perpendicular to the range axis.
1461     *
1462     * @param g2  the graphics device.
1463     * @param plot  the plot.
1464     * @param axis  the value axis.
1465     * @param dataArea  the area for plotting data.
1466     * @param value  the data value.
1467     * @param paint  the paint ({@code null} not permitted).
1468     * @param stroke  the stroke ({@code null} not permitted).
1469     */
1470    void drawRangeLine(Graphics2D g2, XYPlot plot, ValueAxis axis,
1471                       Rectangle2D dataArea, double value, Paint paint, Stroke stroke);
1472
1473    /**
1474     * Draws the specified {@code marker} against the domain axis.
1475     *
1476     * @param g2  the graphics device.
1477     * @param plot  the plot.
1478     * @param axis  the value axis.
1479     * @param marker  the marker.
1480     * @param dataArea  the axis data area.
1481     */
1482    void drawDomainMarker(Graphics2D g2, XYPlot plot, ValueAxis axis,
1483                          Marker marker, Rectangle2D dataArea);
1484
1485    /**
1486     * Draws a horizontal line across the chart to represent a 'range marker'.
1487     *
1488     * @param g2  the graphics device.
1489     * @param plot  the plot.
1490     * @param axis  the value axis.
1491     * @param marker  the marker line.
1492     * @param dataArea  the axis data area.
1493     */
1494    void drawRangeMarker(Graphics2D g2, XYPlot plot, ValueAxis axis,
1495                         Marker marker, Rectangle2D dataArea);
1496
1497}