1. /* ===========================================================
  2. * JFreeChart : a free chart library for the Java(tm) platform
  3. * ===========================================================
  4. *
  5. * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
  6. *
  7. * Project Info: http://www.jfree.org/jfreechart/index.html
  8. *
  9. * This library is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU Lesser General Public License as published by
  11. * the Free Software Foundation; either version 2.1 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This library is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  16. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  17. * License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public License
  20. * along with this library; if not, write to the Free Software Foundation,
  21. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
  24. * in the United States and other countries.]
  25. *
  26. * -------------------
  27. * XYItemRenderer.java
  28. * -------------------
  29. * (C) Copyright 2001-2005, by Object Refinery Limited and Contributors.
  30. *
  31. * Original Author: David Gilbert (for Object Refinery Limited);
  32. * Contributor(s): Mark Watson (www.markwatson.com);
  33. * Sylvain Vieujot;
  34. * Focus Computer Services Limited;
  35. * Richard Atkinson;
  36. *
  37. * $Id: XYItemRenderer.java,v 1.12 2005/03/08 15:54:50 mungady Exp $
  38. *
  39. * Changes
  40. * -------
  41. * 19-Oct-2001 : Version 1, based on code by Mark Watson (DG);
  42. * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG);
  43. * 13-Dec-2001 : Changed return type of drawItem from void --> Shape. The area
  44. * returned can be used as the tooltip region.
  45. * 23-Jan-2002 : Added DrawInfo parameter to drawItem() method (DG);
  46. * 28-Mar-2002 : Added a property change listener mechanism. Now renderers do
  47. * not have to be immutable (DG);
  48. * 04-Apr-2002 : Added the initialise() method (DG);
  49. * 09-Apr-2002 : Removed the translated zero from the drawItem method, it can
  50. * be calculated inside the initialise method if it is required.
  51. * Added a new getToolTipGenerator() method. Changed the return
  52. * type for drawItem() to void (DG);
  53. * 24-May-2002 : Added ChartRenderingInfo the initialise method API (DG);
  54. * 25-Jun-2002 : Removed redundant import (DG);
  55. * 20-Aug-2002 : Added get/setURLGenerator methods to interface (DG);
  56. * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG);
  57. * 18-Nov-2002 : Added methods for drawing grid lines (DG);
  58. * 17-Jan-2003 : Moved plot classes into a separate package (DG);
  59. * 27-Jan-2003 : Added shape lookup table (DG);
  60. * 05-Jun-2003 : Added domain and range grid bands (sponsored by Focus Computer
  61. * Services Ltd) (DG);
  62. * 27-Jul-2003 : Added getRangeType() to support stacked XY area charts (RA);
  63. * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG);
  64. * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState. Renamed
  65. * XYToolTipGenerator --> XYItemLabelGenerator (DG);
  66. * 26-Feb-2004 : Added lots of new methods (DG);
  67. * 30-Apr-2004 : Added getRangeExtent() method (DG);
  68. * 06-May-2004 : Added methods for controlling item label visibility (DG);
  69. * 13-May-2004 : Removed property change listener mechanism (DG);
  70. * 18-May-2004 : Added item label font and paint methods (DG);
  71. * 10-Sep-2004 : Removed redundant getRangeType() method (DG);
  72. * 06-Oct-2004 : Replaced getRangeExtent() with findRangeBounds() and added
  73. * findDomainBounds (DG);
  74. * 23-Nov-2004 : Changed drawRangeGridLine() --> drawRangeLine() (DG);
  75. * 07-Jan-2005 : Removed deprecated method (DG);
  76. * 24-Feb-2005 : Now extends LegendItemSource (DG);
  77. *
  78. */
  79. package org.jfree.chart.renderer.xy;
  80. import java.awt.Font;
  81. import java.awt.Graphics2D;
  82. import java.awt.Paint;
  83. import java.awt.Shape;
  84. import java.awt.Stroke;
  85. import java.awt.geom.Rectangle2D;
  86. import org.jfree.chart.LegendItem;
  87. import org.jfree.chart.LegendItemSource;
  88. import org.jfree.chart.annotations.XYAnnotation;
  89. import org.jfree.chart.axis.ValueAxis;
  90. import org.jfree.chart.event.RendererChangeEvent;
  91. import org.jfree.chart.event.RendererChangeListener;
  92. import org.jfree.chart.labels.ItemLabelPosition;
  93. import org.jfree.chart.labels.XYLabelGenerator;
  94. import org.jfree.chart.labels.XYToolTipGenerator;
  95. import org.jfree.chart.plot.CrosshairState;
  96. import org.jfree.chart.plot.Marker;
  97. import org.jfree.chart.plot.PlotRenderingInfo;
  98. import org.jfree.chart.plot.XYPlot;
  99. import org.jfree.chart.urls.XYURLGenerator;
  100. import org.jfree.data.Range;
  101. import org.jfree.data.xy.XYDataset;
  102. import org.jfree.ui.Layer;
  103. /**
  104. * Interface for rendering the visual representation of a single (x, y) item on
  105. * an {@link XYPlot}.
  106. * <p>
  107. * To support cloning charts, it is recommended that renderers implement both
  108. * the {@link Cloneable} and <code>PublicCloneable</code> interfaces.
  109. */
  110. public interface XYItemRenderer extends LegendItemSource {
  111. /**
  112. * Initialises the renderer then returns the number of 'passes' through the
  113. * data that the renderer will require (usually just one). This method
  114. * will be called before the first item is rendered, giving the renderer
  115. * an opportunity to initialise any state information it wants to maintain.
  116. * The renderer can do nothing if it chooses.
  117. *
  118. * @param g2 the graphics device.
  119. * @param dataArea the area inside the axes.
  120. * @param plot the plot.
  121. * @param dataset the dataset.
  122. * @param info an optional info collection object to return data back to
  123. * the caller.
  124. *
  125. * @return The number of passes the renderer requires.
  126. */
  127. public XYItemRendererState initialise(Graphics2D g2,
  128. Rectangle2D dataArea,
  129. XYPlot plot,
  130. XYDataset dataset,
  131. PlotRenderingInfo info);
  132. /**
  133. * Returns the number of passes through the data required by the renderer.
  134. *
  135. * @return The pass count.
  136. */
  137. public int getPassCount();
  138. /**
  139. * Returns a boolean that indicates whether or not the specified item
  140. * should be drawn (this is typically used to hide an entire series).
  141. *
  142. * @param series the series index.
  143. * @param item the item index.
  144. *
  145. * @return A boolean.
  146. */
  147. public boolean getItemVisible(int series, int item);
  148. /**
  149. * Returns the flag that controls the visibility of ALL series. This flag
  150. * overrides the per series and default settings - you must set it to
  151. * <code>null</code> if you want the other settings to apply.
  152. *
  153. * @return The flag (possibly <code>null</code>).
  154. */
  155. public Boolean getSeriesVisible();
  156. /**
  157. * Sets the flag that controls the visibility of ALL series and sends a
  158. * {@link RendererChangeEvent} to all registered listeners. This flag
  159. * overrides the per series and default settings - you must set it to
  160. * <code>null</code> if you want the other settings to apply.
  161. *
  162. * @param visible the flag (<code>null</code> permitted).
  163. */
  164. public void setSeriesVisible(Boolean visible);
  165. /**
  166. * Sets the flag that controls the visibility of ALL series and sends a
  167. * {@link RendererChangeEvent} to all registered listeners. This flag
  168. * overrides the per series and default settings - you must set it to
  169. * <code>null</code> if you want the other settings to apply.
  170. *
  171. * @param visible the flag (<code>null</code> permitted).
  172. * @param notify notify listeners?
  173. */
  174. public void setSeriesVisible(Boolean visible, boolean notify);
  175. /**
  176. * Returns the flag that controls whether a series is visible.
  177. *
  178. * @param series the series index (zero-based).
  179. *
  180. * @return The flag (possibly <code>null</code>).
  181. */
  182. public Boolean getSeriesVisible(int series);
  183. /**
  184. * Sets the flag that controls whether a series is visible and sends a
  185. * {@link RendererChangeEvent} to all registered listeners.
  186. *
  187. * @param series the series index (zero-based).
  188. * @param visible the flag (<code>null</code> permitted).
  189. */
  190. public void setSeriesVisible(int series, Boolean visible);
  191. /**
  192. * Sets the flag that controls whether a series is visible and, if
  193. * requested, sends a {@link RendererChangeEvent} to all registered
  194. * listeners.
  195. *
  196. * @param series the series index.
  197. * @param visible the flag (<code>null</code> permitted).
  198. * @param notify notify listeners?
  199. */
  200. public void setSeriesVisible(int series, Boolean visible, boolean notify);
  201. /**
  202. * Returns the base visibility for all series.
  203. *
  204. * @return The base visibility.
  205. */
  206. public boolean getBaseSeriesVisible();
  207. /**
  208. * Sets the base visibility and sends a {@link RendererChangeEvent} to all
  209. * registered listeners.
  210. *
  211. * @param visible the flag.
  212. */
  213. public void setBaseSeriesVisible(boolean visible);
  214. /**
  215. * Sets the base visibility and, if requested, sends
  216. * a {@link RendererChangeEvent} to all registered listeners.
  217. *
  218. * @param visible the visibility.
  219. * @param notify notify listeners?
  220. */
  221. public void setBaseSeriesVisible(boolean visible, boolean notify);
  222. // SERIES VISIBLE IN LEGEND (not yet respected by all renderers)
  223. /**
  224. * Returns <code>true</code> if the series should be shown in the legend,
  225. * and <code>false</code> otherwise.
  226. *
  227. * @param series the series index.
  228. *
  229. * @return A boolean.
  230. */
  231. public boolean isSeriesVisibleInLegend(int series);
  232. /**
  233. * Returns the flag that controls the visibility of ALL series in the
  234. * legend. This flag overrides the per series and default settings - you
  235. * must set it to <code>null</code> if you want the other settings to
  236. * apply.
  237. *
  238. * @return The flag (possibly <code>null</code>).
  239. */
  240. public Boolean getSeriesVisibleInLegend();
  241. /**
  242. * Sets the flag that controls the visibility of ALL series in the legend
  243. * and sends a {@link RendererChangeEvent} to all registered listeners.
  244. * This flag overrides the per series and default settings - you must set
  245. * it to <code>null</code> if you want the other settings to apply.
  246. *
  247. * @param visible the flag (<code>null</code> permitted).
  248. */
  249. public void setSeriesVisibleInLegend(Boolean visible);
  250. /**
  251. * Sets the flag that controls the visibility of ALL series in the legend
  252. * and sends a {@link RendererChangeEvent} to all registered listeners.
  253. * This flag overrides the per series and default settings - you must set
  254. * it to <code>null</code> if you want the other settings to apply.
  255. *
  256. * @param visible the flag (<code>null</code> permitted).
  257. * @param notify notify listeners?
  258. */
  259. public void setSeriesVisibleInLegend(Boolean visible, boolean notify);
  260. /**
  261. * Returns the flag that controls whether a series is visible in the
  262. * legend. This method returns only the "per series" settings - to
  263. * incorporate the override and base settings as well, you need to use the
  264. * {@link #isSeriesVisibleInLegend(int)} method.
  265. *
  266. * @param series the series index (zero-based).
  267. *
  268. * @return The flag (possibly <code>null</code>).
  269. */
  270. public Boolean getSeriesVisibleInLegend(int series);
  271. /**
  272. * Sets the flag that controls whether a series is visible in the legend
  273. * and sends a {@link RendererChangeEvent} to all registered listeners.
  274. *
  275. * @param series the series index (zero-based).
  276. * @param visible the flag (<code>null</code> permitted).
  277. */
  278. public void setSeriesVisibleInLegend(int series, Boolean visible);
  279. /**
  280. * Sets the flag that controls whether a series is visible in the legend
  281. * and, if requested, sends a {@link RendererChangeEvent} to all registered
  282. * listeners.
  283. *
  284. * @param series the series index.
  285. * @param visible the flag (<code>null</code> permitted).
  286. * @param notify notify listeners?
  287. */
  288. public void setSeriesVisibleInLegend(int series, Boolean visible,
  289. boolean notify);
  290. /**
  291. * Returns the base visibility in the legend for all series.
  292. *
  293. * @return The base visibility.
  294. */
  295. public boolean getBaseSeriesVisibleInLegend();
  296. /**
  297. * Sets the base visibility in the legend and sends a
  298. * {@link RendererChangeEvent} to all registered listeners.
  299. *
  300. * @param visible the flag.
  301. */
  302. public void setBaseSeriesVisibleInLegend(boolean visible);
  303. /**
  304. * Sets the base visibility in the legend and, if requested, sends
  305. * a {@link RendererChangeEvent} to all registered listeners.
  306. *
  307. * @param visible the visibility.
  308. * @param notify notify listeners?
  309. */
  310. public void setBaseSeriesVisibleInLegend(boolean visible, boolean notify);
  311. // PAINT
  312. /**
  313. * Returns the paint used to fill data items as they are drawn.
  314. *
  315. * @param row the row (or series) index (zero-based).
  316. * @param column the column (or category) index (zero-based).
  317. *
  318. * @return the paint (never <code>null</code>).
  319. */
  320. public Paint getItemPaint(int row, int column);
  321. /**
  322. * Returns the paint used to fill an item drawn by the renderer.
  323. *
  324. * @param series the series index (zero-based).
  325. *
  326. * @return the paint (never <code>null</code>).
  327. */
  328. public Paint getSeriesPaint(int series);
  329. /**
  330. * Sets the paint to be used for ALL series, and sends a
  331. * {@link RendererChangeEvent} to all registered listeners. If this is
  332. * <code>null</code>, the renderer will use the paint for the series.
  333. *
  334. * @param paint the paint (<code>null</code> permitted).
  335. */
  336. public void setPaint(Paint paint);
  337. /**
  338. * Sets the paint used for a series and sends a {@link RendererChangeEvent}
  339. * to all registered listeners.
  340. *
  341. * @param series the series index (zero-based).
  342. * @param paint the paint (<code>null</code> permitted).
  343. */
  344. public void setSeriesPaint(int series, Paint paint);
  345. /**
  346. * Returns the base paint.
  347. *
  348. * @return the base paint (never <code>null</code>).
  349. */
  350. public Paint getBasePaint();
  351. /**
  352. * Sets the base paint and sends a {@link RendererChangeEvent} to all
  353. * registered listeners.
  354. *
  355. * @param paint the paint (<code>null</code> not permitted).
  356. */
  357. public void setBasePaint(Paint paint);
  358. // OUTLINE PAINT
  359. /**
  360. * Returns the paint used to outline data items as they are drawn.
  361. *
  362. * @param row the row (or series) index (zero-based).
  363. * @param column the column (or category) index (zero-based).
  364. *
  365. * @return the paint (never <code>null</code>).
  366. */
  367. public Paint getItemOutlinePaint(int row, int column);
  368. /**
  369. * Returns the paint used to outline an item drawn by the renderer.
  370. *
  371. * @param series the series (zero-based index).
  372. *
  373. * @return the paint (never <code>null</code>).
  374. */
  375. public Paint getSeriesOutlinePaint(int series);
  376. /**
  377. * Sets the paint used for a series outline and sends a
  378. * {@link RendererChangeEvent} to all registered listeners.
  379. *
  380. * @param series the series index (zero-based).
  381. * @param paint the paint (<code>null</code> permitted).
  382. */
  383. public void setSeriesOutlinePaint(int series, Paint paint);
  384. /**
  385. * Sets the outline paint for ALL series (optional).
  386. *
  387. * @param paint the paint (<code>null</code> permitted).
  388. */
  389. public void setOutlinePaint(Paint paint);
  390. /**
  391. * Returns the base outline paint.
  392. *
  393. * @return the paint (never <code>null</code>).
  394. */
  395. public Paint getBaseOutlinePaint();
  396. /**
  397. * Sets the base outline paint and sends a {@link RendererChangeEvent} to
  398. * all registered listeners.
  399. *
  400. * @param paint the paint (<code>null</code> not permitted).
  401. */
  402. public void setBaseOutlinePaint(Paint paint);
  403. // STROKE
  404. /**
  405. * Returns the stroke used to draw data items.
  406. *
  407. * @param row the row (or series) index (zero-based).
  408. * @param column the column (or category) index (zero-based).
  409. *
  410. * @return the stroke (never <code>null</code>).
  411. */
  412. public Stroke getItemStroke(int row, int column);
  413. /**
  414. * Returns the stroke used to draw the items in a series.
  415. *
  416. * @param series the series (zero-based index).
  417. *
  418. * @return the stroke (never <code>null</code>).
  419. */
  420. public Stroke getSeriesStroke(int series);
  421. /**
  422. * Sets the stroke for ALL series and sends a {@link RendererChangeEvent}
  423. * to all registered listeners.
  424. *
  425. * @param stroke the stroke (<code>null</code> permitted).
  426. */
  427. public void setStroke(Stroke stroke);
  428. /**
  429. * Sets the stroke used for a series and sends a
  430. * {@link RendererChangeEvent} to all registered listeners.
  431. *
  432. * @param series the series index (zero-based).
  433. * @param stroke the stroke (<code>null</code> permitted).
  434. */
  435. public void setSeriesStroke(int series, Stroke stroke);
  436. /**
  437. * Returns the base stroke.
  438. *
  439. * @return the base stroke (never <code>null</code>).
  440. */
  441. public Stroke getBaseStroke();
  442. /**
  443. * Sets the base stroke.
  444. *
  445. * @param stroke the stroke (<code>null</code> not permitted).
  446. */
  447. public void setBaseStroke(Stroke stroke);
  448. // OUTLINE STROKE
  449. /**
  450. * Returns the stroke used to outline data items. The default
  451. * implementation passes control to the getSeriesOutlineStroke method.
  452. * You can override this method if you require different behaviour.
  453. *
  454. * @param row the row (or series) index (zero-based).
  455. * @param column the column (or category) index (zero-based).
  456. *
  457. * @return the stroke (never <code>null</code>).
  458. */
  459. public Stroke getItemOutlineStroke(int row, int column);
  460. /**
  461. * Returns the stroke used to outline the items in a series.
  462. *
  463. * @param series the series (zero-based index).
  464. *
  465. * @return the stroke (never <code>null</code>).
  466. */
  467. public Stroke getSeriesOutlineStroke(int series);
  468. /**
  469. * Sets the outline stroke for ALL series and sends a
  470. * {@link RendererChangeEvent} to all registered listeners.
  471. *
  472. * @param stroke the stroke (<code>null</code> permitted).
  473. */
  474. public void setOutlineStroke(Stroke stroke);
  475. /**
  476. * Sets the outline stroke used for a series and sends a
  477. * {@link RendererChangeEvent} to all registered listeners.
  478. *
  479. * @param series the series index (zero-based).
  480. * @param stroke the stroke (<code>null</code> permitted).
  481. */
  482. public void setSeriesOutlineStroke(int series, Stroke stroke);
  483. /**
  484. * Returns the base outline stroke.
  485. *
  486. * @return the stroke (never <code>null</code>).
  487. */
  488. public Stroke getBaseOutlineStroke();
  489. /**
  490. * Sets the base outline stroke and sends a {@link RendererChangeEvent} to
  491. * all registered listeners.
  492. *
  493. * @param stroke the stroke (<code>null</code> not permitted).
  494. */
  495. public void setBaseOutlineStroke(Stroke stroke);
  496. // SHAPE
  497. /**
  498. * Returns a shape used to represent a data item.
  499. *
  500. * @param row the row (or series) index (zero-based).
  501. * @param column the column (or category) index (zero-based).
  502. *
  503. * @return the shape (never <code>null</code>).
  504. */
  505. public Shape getItemShape(int row, int column);
  506. /**
  507. * Returns a shape used to represent the items in a series.
  508. *
  509. * @param series the series (zero-based index).
  510. *
  511. * @return the shape (never <code>null</code>).
  512. */
  513. public Shape getSeriesShape(int series);
  514. /**
  515. * Sets the shape for ALL series (optional) and sends a
  516. * {@link RendererChangeEvent} to all registered listeners.
  517. *
  518. * @param shape the shape (<code>null</code> permitted).
  519. */
  520. public void setShape(Shape shape);
  521. /**
  522. * Sets the shape used for a series and sends a {@link RendererChangeEvent}
  523. * to all registered listeners.
  524. *
  525. * @param series the series index (zero-based).
  526. * @param shape the shape (<code>null</code> permitted).
  527. */
  528. public void setSeriesShape(int series, Shape shape);
  529. /**
  530. * Returns the base shape.
  531. *
  532. * @return the shape (never <code>null</code>).
  533. */
  534. public Shape getBaseShape();
  535. /**
  536. * Sets the base shape and sends a {@link RendererChangeEvent} to all
  537. * registered listeners.
  538. *
  539. * @param shape the shape (<code>null</code> not permitted).
  540. */
  541. public void setBaseShape(Shape shape);
  542. // ITEM LABELS VISIBLE
  543. /**
  544. * Returns <code>true</code> if an item label is visible, and
  545. * <code>false</code> otherwise.
  546. *
  547. * @param row the row index (zero-based).
  548. * @param column the column index (zero-based).
  549. *
  550. * @return a boolean.
  551. */
  552. public boolean isItemLabelVisible(int row, int column);
  553. /**
  554. * Returns <code>true</code> if the item labels for a series are visible,
  555. * and <code>false</code> otherwise.
  556. *
  557. * @param series the series index (zero-based).
  558. *
  559. * @return a boolean.
  560. */
  561. public boolean isSeriesItemLabelsVisible(int series);
  562. /**
  563. * Sets a flag that controls whether or not the item labels for ALL series
  564. * are visible.
  565. *
  566. * @param visible the flag.
  567. */
  568. public void setItemLabelsVisible(boolean visible);
  569. /**
  570. * Sets a flag that controls whether or not the item labels for ALL series
  571. * are visible.
  572. *
  573. * @param visible the flag (<code>null</code> permitted).
  574. */
  575. public void setItemLabelsVisible(Boolean visible);
  576. /**
  577. * Sets the visibility of item labels for ALL series and, if requested,
  578. * sends a {@link RendererChangeEvent} to all registered listeners.
  579. *
  580. * @param visible a flag that controls whether or not the item labels are
  581. * visible (<code>null</code> permitted).
  582. * @param notify a flag that controls whether or not listeners are
  583. * notified.
  584. */
  585. public void setItemLabelsVisible(Boolean visible, boolean notify);
  586. /**
  587. * Sets a flag that controls the visibility of the item labels for a series.
  588. *
  589. * @param series the series index (zero-based).
  590. * @param visible the flag.
  591. */
  592. public void setSeriesItemLabelsVisible(int series, boolean visible);
  593. /**
  594. * Sets a flag that controls the visibility of the item labels for a series.
  595. *
  596. * @param series the series index (zero-based).
  597. * @param visible the flag (<code>null</code> permitted).
  598. */
  599. public void setSeriesItemLabelsVisible(int series, Boolean visible);
  600. /**
  601. * Sets the visibility of item labels for a series and, if requested,
  602. * sends a {@link RendererChangeEvent} to all registered listeners.
  603. *
  604. * @param series the series index (zero-based).
  605. * @param visible the visible flag.
  606. * @param notify a flag that controls whether or not listeners are
  607. * notified.
  608. */
  609. public void setSeriesItemLabelsVisible(int series, Boolean visible,
  610. boolean notify);
  611. /**
  612. * Returns the base setting for item label visibility.
  613. *
  614. * @return A flag (possibly <code>null</code>).
  615. */
  616. public Boolean getBaseItemLabelsVisible();
  617. /**
  618. * Sets the base flag that controls whether or not item labels are visible.
  619. *
  620. * @param visible the flag.
  621. */
  622. public void setBaseItemLabelsVisible(boolean visible);
  623. /**
  624. * Sets the base setting for item label visibility.
  625. *
  626. * @param visible the flag (<code>null</code> permitted).
  627. */
  628. public void setBaseItemLabelsVisible(Boolean visible);
  629. /**
  630. * Sets the base visibility for item labels and, if requested, sends a
  631. * {@link RendererChangeEvent} to all registered listeners.
  632. *
  633. * @param visible the visibility flag.
  634. * @param notify a flag that controls whether or not listeners are
  635. * notified.
  636. */
  637. public void setBaseItemLabelsVisible(Boolean visible, boolean notify);
  638. // LABEL GENERATOR
  639. /**
  640. * Returns the label generator for a data item.
  641. *
  642. * @param row the row index (zero based).
  643. * @param column the column index (zero based).
  644. *
  645. * @return the generator (possibly <code>null</code>).
  646. */
  647. public XYLabelGenerator getLabelGenerator(int row, int column);
  648. /**
  649. * Returns the label generator for a series.
  650. *
  651. * @param series the series index (zero based).
  652. *
  653. * @return the generator (possibly <code>null</code>).
  654. */
  655. public XYLabelGenerator getSeriesLabelGenerator(int series);
  656. /**
  657. * Sets the item label generator for ALL series and sends a
  658. * {@link RendererChangeEvent} to all registered listeners.
  659. *
  660. * @param generator the generator (<code>null</code> permitted).
  661. */
  662. public void setLabelGenerator(XYLabelGenerator generator);
  663. /**
  664. * Sets the label generator for a series and sends a
  665. * {@link RendererChangeEvent} to all registered listeners.
  666. *
  667. * @param series the series index (zero based).
  668. * @param generator the generator (<code>null</code> permitted).
  669. */
  670. public void setSeriesLabelGenerator(int series, XYLabelGenerator generator);
  671. /**
  672. * Returns the base item label generator.
  673. *
  674. * @return the generator (possibly <code>null</code>).
  675. */
  676. public XYLabelGenerator getBaseLabelGenerator();
  677. /**
  678. * Sets the base item label generator and sends a
  679. * {@link RendererChangeEvent} to all registered listeners.
  680. *
  681. * @param generator the generator (<code>null</code> permitted).
  682. */
  683. public void setBaseLabelGenerator(XYLabelGenerator generator);
  684. // TOOL TIP GENERATOR
  685. /**
  686. * Returns the tool tip generator for a data item.
  687. *
  688. * @param row the row index (zero based).
  689. * @param column the column index (zero based).
  690. *
  691. * @return The generator (possibly <code>null</code>).
  692. */
  693. public XYToolTipGenerator getToolTipGenerator(int row, int column);
  694. /**
  695. * Returns the tool tip generator for a series.
  696. *
  697. * @param series the series index (zero based).
  698. *
  699. * @return The generator (possibly <code>null</code>).
  700. */
  701. public XYToolTipGenerator getSeriesToolTipGenerator(int series);
  702. /**
  703. * Sets the tool tip generator for ALL series and sends a
  704. * {@link RendererChangeEvent} to all registered listeners.
  705. *
  706. * @param generator the generator (<code>null</code> permitted).
  707. */
  708. public void setToolTipGenerator(XYToolTipGenerator generator);
  709. /**
  710. * Sets the tool tip generator for a series and sends a
  711. * {@link RendererChangeEvent} to all registered listeners.
  712. *
  713. * @param series the series index (zero based).
  714. * @param generator the generator (<code>null</code> permitted).
  715. */
  716. public void setSeriesToolTipGenerator(int series,
  717. XYToolTipGenerator generator);
  718. /**
  719. * Returns the base tool tip generator.
  720. *
  721. * @return the generator (possibly <code>null</code>).
  722. */
  723. public XYToolTipGenerator getBaseToolTipGenerator();
  724. /**
  725. * Sets the base tool tip generator and sends a {@link RendererChangeEvent}
  726. * to all registered listeners.
  727. *
  728. * @param generator the generator (<code>null</code> permitted).
  729. */
  730. public void setBaseToolTipGenerator(XYToolTipGenerator generator);
  731. // URL GENERATOR
  732. /**
  733. * Returns the URL generator for HTML image maps.
  734. *
  735. * @return the URL generator (possibly null).
  736. */
  737. public XYURLGenerator getURLGenerator();
  738. /**
  739. * Sets the URL generator for HTML image maps.
  740. *
  741. * @param urlGenerator the URL generator (null permitted).
  742. */
  743. public void setURLGenerator(XYURLGenerator urlGenerator);
  744. //// ITEM LABEL FONT ///////////////////////////////////////////////////////
  745. /**
  746. * Returns the font for an item label.
  747. *
  748. * @param row the row index (zero-based).
  749. * @param column the column index (zero-based).
  750. *
  751. * @return The font (never <code>null</code>).
  752. */
  753. public Font getItemLabelFont(int row, int column);
  754. /**
  755. * Returns the font used for all item labels. This may be
  756. * <code>null</code>, in which case the per series font settings will apply.
  757. *
  758. * @return The font (possibly <code>null</code>).
  759. */
  760. public Font getItemLabelFont();
  761. /**
  762. * Sets the item label font for ALL series and sends a
  763. * {@link RendererChangeEvent} to all registered listeners. You can set
  764. * this to <code>null</code> if you prefer to set the font on a per series
  765. * basis.
  766. *
  767. * @param font the font (<code>null</code> permitted).
  768. */
  769. public void setItemLabelFont(Font font);
  770. /**
  771. * Returns the font for all the item labels in a series.
  772. *
  773. * @param series the series index (zero-based).
  774. *
  775. * @return The font (possibly <code>null</code>).
  776. */
  777. public Font getSeriesItemLabelFont(int series);
  778. /**
  779. * Sets the item label font for a series and sends a
  780. * {@link RendererChangeEvent} to all registered listeners.
  781. *
  782. * @param series the series index (zero-based).
  783. * @param font the font (<code>null</code> permitted).
  784. */
  785. public void setSeriesItemLabelFont(int series, Font font);
  786. /**
  787. * Returns the base item label font (this is used when no other font
  788. * setting is available).
  789. *
  790. * @return The font (<code>never</code> null).
  791. */
  792. public Font getBaseItemLabelFont();
  793. /**
  794. * Sets the base item label font and sends a {@link RendererChangeEvent}
  795. * to all registered listeners.
  796. *
  797. * @param font the font (<code>null</code> not permitted).
  798. */
  799. public void setBaseItemLabelFont(Font font);
  800. //// ITEM LABEL PAINT /////////////////////////////////////////////////////
  801. /**
  802. * Returns the paint used to draw an item label.
  803. *
  804. * @param row the row index (zero based).
  805. * @param column the column index (zero based).
  806. *
  807. * @return The paint (never <code>null</code>).
  808. */
  809. public Paint getItemLabelPaint(int row, int column);
  810. /**
  811. * Returns the paint used for all item labels. This may be
  812. * <code>null</code>, in which case the per series paint settings will
  813. * apply.
  814. *
  815. * @return The paint (possibly <code>null</code>).
  816. */
  817. public Paint getItemLabelPaint();
  818. /**
  819. * Sets the item label paint for ALL series and sends a
  820. * {@link RendererChangeEvent} to all registered listeners.
  821. *
  822. * @param paint the paint (<code>null</code> permitted).
  823. */
  824. public void setItemLabelPaint(Paint paint);
  825. /**
  826. * Returns the paint used to draw the item labels for a series.
  827. *
  828. * @param series the series index (zero based).
  829. *
  830. * @return The paint (possibly <code>null<code>).
  831. */
  832. public Paint getSeriesItemLabelPaint(int series);
  833. /**
  834. * Sets the item label paint for a series and sends a
  835. * {@link RendererChangeEvent} to all registered listeners.
  836. *
  837. * @param series the series (zero based index).
  838. * @param paint the paint (<code>null</code> permitted).
  839. */
  840. public void setSeriesItemLabelPaint(int series, Paint paint);
  841. /**
  842. * Returns the base item label paint.
  843. *
  844. * @return The paint (never <code>null<code>).
  845. */
  846. public Paint getBaseItemLabelPaint();
  847. /**
  848. * Sets the base item label paint and sends a {@link RendererChangeEvent}
  849. * to all registered listeners.
  850. *
  851. * @param paint the paint (<code>null</code> not permitted).
  852. */
  853. public void setBaseItemLabelPaint(Paint paint);
  854. // POSITIVE ITEM LABEL POSITION...
  855. /**
  856. * Returns the item label position for positive values.
  857. *
  858. * @param row the row index (zero-based).
  859. * @param column the column index (zero-based).
  860. *
  861. * @return the item label position (never <code>null</code>).
  862. */
  863. public ItemLabelPosition getPositiveItemLabelPosition(int row, int column);
  864. /**
  865. * Returns the item label position for positive values in ALL series.
  866. *
  867. * @return the item label position (possibly <code>null</code>).
  868. */
  869. public ItemLabelPosition getPositiveItemLabelPosition();
  870. /**
  871. * Sets the item label position for positive values in ALL series, and
  872. * sends a {@link RendererChangeEvent} to all registered listeners. You
  873. * need to set this to <code>null</code> to expose the settings for
  874. * individual series.
  875. *
  876. * @param position the position (<code>null</code> permitted).
  877. */
  878. public void setPositiveItemLabelPosition(ItemLabelPosition position);
  879. /**
  880. * Sets the positive item label position for ALL series and (if requested)
  881. * sends a {@link RendererChangeEvent} to all registered listeners.
  882. *
  883. * @param position the position (<code>null</code> permitted).
  884. * @param notify notify registered listeners?
  885. */
  886. public void setPositiveItemLabelPosition(ItemLabelPosition position,
  887. boolean notify);
  888. /**
  889. * Returns the item label position for all positive values in a series.
  890. *
  891. * @param series the series index (zero-based).
  892. *
  893. * @return the item label position (never <code>null</code>).
  894. */
  895. public ItemLabelPosition getSeriesPositiveItemLabelPosition(int series);
  896. /**
  897. * Sets the item label position for all positive values in a series and
  898. * sends a {@link RendererChangeEvent} to all registered listeners.
  899. *
  900. * @param series the series index (zero-based).
  901. * @param position the position (<code>null</code> permitted).
  902. */
  903. public void setSeriesPositiveItemLabelPosition(int series,
  904. ItemLabelPosition position);
  905. /**
  906. * Sets the item label position for all positive values in a series and (if
  907. * requested) sends a {@link RendererChangeEvent} to all registered
  908. * listeners.
  909. *
  910. * @param series the series index (zero-based).
  911. * @param position the position (<code>null</code> permitted).
  912. * @param notify notify registered listeners?
  913. */
  914. public void setSeriesPositiveItemLabelPosition(int series,
  915. ItemLabelPosition position,
  916. boolean notify);
  917. /**
  918. * Returns the base positive item label position.
  919. *
  920. * @return the position (never <code>null</code>).
  921. */
  922. public ItemLabelPosition getBasePositiveItemLabelPosition();
  923. /**
  924. * Sets the base positive item label position.
  925. *
  926. * @param position the position (<code>null</code> not permitted).
  927. */
  928. public void setBasePositiveItemLabelPosition(ItemLabelPosition position);
  929. /**
  930. * Sets the base positive item label position and, if requested, sends a
  931. * {@link RendererChangeEvent} to all registered listeners.
  932. *
  933. * @param position the position (<code>null</code> not permitted).
  934. * @param notify notify registered listeners?
  935. */
  936. public void setBasePositiveItemLabelPosition(ItemLabelPosition position,
  937. boolean notify);
  938. // NEGATIVE ITEM LABEL POSITION...
  939. /**
  940. * Returns the item label position for negative values. This method can be
  941. * overridden to provide customisation of the item label position for
  942. * individual data items.
  943. *
  944. * @param row the row index (zero-based).
  945. * @param column the column (zero-based).
  946. *
  947. * @return the item label position (never <code>null</code>).
  948. */
  949. public ItemLabelPosition getNegativeItemLabelPosition(int row, int column);
  950. /**
  951. * Returns the item label position for negative values in ALL series.
  952. *
  953. * @return the item label position (possibly <code>null</code>).
  954. */
  955. public ItemLabelPosition getNegativeItemLabelPosition();
  956. /**
  957. * Sets the item label position for negative values in ALL series, and
  958. * sends a {@link RendererChangeEvent} to all registered listeners. You
  959. * need to set this to <code>null</code> to expose the settings for
  960. * individual series.
  961. *
  962. * @param position the position (<code>null</code> permitted).
  963. */
  964. public void setNegativeItemLabelPosition(ItemLabelPosition position);
  965. /**
  966. * Sets the item label position for negative values in ALL series and (if
  967. * requested) sends a {@link RendererChangeEvent} to all registered
  968. * listeners.
  969. *
  970. * @param position the position (<code>null</code> permitted).
  971. * @param notify notify registered listeners?
  972. */
  973. public void setNegativeItemLabelPosition(ItemLabelPosition position,
  974. boolean notify);
  975. /**
  976. * Returns the item label position for all negative values in a series.
  977. *
  978. * @param series the series index (zero-based).
  979. *
  980. * @return the item label position (never <code>null</code>).
  981. */
  982. public ItemLabelPosition getSeriesNegativeItemLabelPosition(int series);
  983. /**
  984. * Sets the item label position for negative values in a series and sends a
  985. * {@link RendererChangeEvent} to all registered listeners.
  986. *
  987. * @param series the series index (zero-based).
  988. * @param position the position (<code>null</code> permitted).
  989. */
  990. public void setSeriesNegativeItemLabelPosition(int series,
  991. ItemLabelPosition position);
  992. /**
  993. * Sets the item label position for negative values in a series and (if
  994. * requested) sends a {@link RendererChangeEvent} to all registered
  995. * listeners.
  996. *
  997. * @param series the series index (zero-based).
  998. * @param position the position (<code>null</code> permitted).
  999. * @param notify notify registered listeners?
  1000. */
  1001. public void setSeriesNegativeItemLabelPosition(int series,
  1002. ItemLabelPosition position,
  1003. boolean notify);
  1004. /**
  1005. * Returns the base item label position for negative values.
  1006. *
  1007. * @return the position (never <code>null</code>).
  1008. */
  1009. public ItemLabelPosition getBaseNegativeItemLabelPosition();
  1010. /**
  1011. * Sets the base item label position for negative values and sends a
  1012. * {@link RendererChangeEvent} to all registered listeners.
  1013. *
  1014. * @param position the position (<code>null</code> not permitted).
  1015. */
  1016. public void setBaseNegativeItemLabelPosition(ItemLabelPosition position);
  1017. /**
  1018. * Sets the base negative item label position and, if requested, sends a
  1019. * {@link RendererChangeEvent} to all registered listeners.
  1020. *
  1021. * @param position the position (<code>null</code> not permitted).
  1022. * @param notify notify registered listeners?
  1023. */
  1024. public void setBaseNegativeItemLabelPosition(ItemLabelPosition position,
  1025. boolean notify);
  1026. /**
  1027. * Adds an annotation and sends a {@link RendererChangeEvent} to all
  1028. * registered listeners. The annotation is added to the foreground
  1029. * layer.
  1030. *
  1031. * @param annotation the annotation (<code>null</code> not permitted).
  1032. */
  1033. public void addAnnotation(XYAnnotation annotation);
  1034. /**
  1035. * Adds an annotation to the specified layer.
  1036. *
  1037. * @param annotation the annotation (<code>null</code> not permitted).
  1038. * @param layer the layer (<code>null</code> not permitted).
  1039. */
  1040. public void addAnnotation(XYAnnotation annotation, Layer layer);
  1041. /**
  1042. * Removes the specified annotation and sends a {@link RendererChangeEvent}
  1043. * to all registered listeners.
  1044. *
  1045. * @param annotation the annotation to remove (<code>null</code> not
  1046. * permitted).
  1047. *
  1048. * @return A boolean to indicate whether or not the annotation was
  1049. * successfully removed.
  1050. */
  1051. public boolean removeAnnotation(XYAnnotation annotation);
  1052. /**
  1053. * Removes all annotations and sends a {@link RendererChangeEvent}
  1054. * to all registered listeners.
  1055. */
  1056. public void removeAnnotations();
  1057. /**
  1058. * Draws all the annotations for the specified layer.
  1059. *
  1060. * @param g2 the graphics device.
  1061. * @param dataArea the data area.
  1062. * @param domainAxis the domain axis.
  1063. * @param rangeAxis the range axis.
  1064. * @param layer the layer.
  1065. * @param info the plot rendering info.
  1066. */
  1067. public void drawAnnotations(Graphics2D g2,
  1068. Rectangle2D dataArea,
  1069. ValueAxis domainAxis,
  1070. ValueAxis rangeAxis,
  1071. Layer layer,
  1072. PlotRenderingInfo info);
  1073. /**
  1074. * Called for each item to be plotted.
  1075. * <p>
  1076. * The {@link XYPlot} can make multiple passes through the dataset,
  1077. * depending on the value returned by the renderer's initialise() method.
  1078. *
  1079. * @param g2 the graphics device.
  1080. * @param state the renderer state.
  1081. * @param dataArea the area within which the data is being rendered.
  1082. * @param info collects drawing info.
  1083. * @param plot the plot (can be used to obtain standard color
  1084. * information etc).
  1085. * @param domainAxis the domain axis.
  1086. * @param rangeAxis the range axis.
  1087. * @param dataset the dataset.
  1088. * @param series the series index (zero-based).
  1089. * @param item the item index (zero-based).
  1090. * @param crosshairState crosshair information for the plot
  1091. * (<code>null</code> permitted).
  1092. * @param pass the pass index.
  1093. */
  1094. public void drawItem(Graphics2D g2,
  1095. XYItemRendererState state,
  1096. Rectangle2D dataArea,
  1097. PlotRenderingInfo info,
  1098. XYPlot plot,
  1099. ValueAxis domainAxis,
  1100. ValueAxis rangeAxis,
  1101. XYDataset dataset,
  1102. int series,
  1103. int item,
  1104. CrosshairState crosshairState,
  1105. int pass);
  1106. /**
  1107. * Returns a legend item for a series from a dataset.
  1108. *
  1109. * @param datasetIndex the dataset index.
  1110. * @param series the series (zero-based index).
  1111. *
  1112. * @return The legend item (possibly <code>null</code>).
  1113. */
  1114. public LegendItem getLegendItem(int datasetIndex, int series);
  1115. /**
  1116. * Fills a band between two values on the axis. This can be used to color
  1117. * bands between the grid lines.
  1118. *
  1119. * @param g2 the graphics device.
  1120. * @param plot the plot.
  1121. * @param axis the domain axis.
  1122. * @param dataArea the data area.
  1123. * @param start the start value.
  1124. * @param end the end value.
  1125. */
  1126. public void fillDomainGridBand(Graphics2D g2,
  1127. XYPlot plot,
  1128. ValueAxis axis,
  1129. Rectangle2D dataArea,
  1130. double start, double end);
  1131. /**
  1132. * Fills a band between two values on the range axis. This can be used to
  1133. * color bands between the grid lines.
  1134. *
  1135. * @param g2 the graphics device.
  1136. * @param plot the plot.
  1137. * @param axis the range axis.
  1138. * @param dataArea the data area.
  1139. * @param start the start value.
  1140. * @param end the end value.
  1141. */
  1142. public void fillRangeGridBand(Graphics2D g2,
  1143. XYPlot plot,
  1144. ValueAxis axis,
  1145. Rectangle2D dataArea,
  1146. double start, double end);
  1147. /**
  1148. * Draws a grid line against the domain axis.
  1149. *
  1150. * @param g2 the graphics device.
  1151. * @param plot the plot.
  1152. * @param axis the value axis.
  1153. * @param dataArea the area for plotting data (not yet adjusted for any
  1154. * 3D effect).
  1155. * @param value the value.
  1156. */
  1157. public void drawDomainGridLine(Graphics2D g2,
  1158. XYPlot plot,
  1159. ValueAxis axis,
  1160. Rectangle2D dataArea,
  1161. double value);
  1162. /**
  1163. * Draws a grid line against the range axis.
  1164. *
  1165. * @param g2 the graphics device.
  1166. * @param plot the plot.
  1167. * @param axis the value axis.
  1168. * @param dataArea the area for plotting data (not yet adjusted for any
  1169. * 3D effect).
  1170. * @param value the value.
  1171. * @param paint the paint (<code>null</code> not permitted).
  1172. * @param stroke the stroke (<code>null</code> not permitted).
  1173. */
  1174. public void drawRangeLine(Graphics2D g2,
  1175. XYPlot plot,
  1176. ValueAxis axis,
  1177. Rectangle2D dataArea,
  1178. double value,
  1179. Paint paint,
  1180. Stroke stroke);
  1181. /**
  1182. * Draws the specified <code>marker</code> against the domain axis.
  1183. *
  1184. * @param g2 the graphics device.
  1185. * @param plot the plot.
  1186. * @param axis the value axis.
  1187. * @param marker the marker.
  1188. * @param dataArea the axis data area.
  1189. */
  1190. public void drawDomainMarker(Graphics2D g2,
  1191. XYPlot plot,
  1192. ValueAxis axis,
  1193. Marker marker,
  1194. Rectangle2D dataArea);
  1195. /**
  1196. * Draws a horizontal line across the chart to represent a 'range marker'.
  1197. *
  1198. * @param g2 the graphics device.
  1199. * @param plot the plot.
  1200. * @param axis the value axis.
  1201. * @param marker the marker line.
  1202. * @param dataArea the axis data area.
  1203. */
  1204. public void drawRangeMarker(Graphics2D g2,
  1205. XYPlot plot,
  1206. ValueAxis axis,
  1207. Marker marker,
  1208. Rectangle2D dataArea);
  1209. /**
  1210. * Returns the plot that this renderer has been assigned to.
  1211. *
  1212. * @return the plot.
  1213. */
  1214. public XYPlot getPlot();
  1215. /**
  1216. * Sets the plot that this renderer is assigned to. This method will be
  1217. * called by the plot class...you do not need to call it yourself.
  1218. *
  1219. * @param plot the plot.
  1220. */
  1221. public void setPlot(XYPlot plot);
  1222. /**
  1223. * Returns the lower and upper bounds (range) of the x-values in the
  1224. * specified dataset.
  1225. *
  1226. * @param dataset the dataset (<code>null</code> permitted).
  1227. *
  1228. * @return The range.
  1229. */
  1230. public Range findDomainBounds(XYDataset dataset);
  1231. /**
  1232. * Returns the lower and upper bounds (range) of the y-values in the
  1233. * specified dataset. The implementation of this method will take
  1234. * into account the presentation used by the renderers (for example,
  1235. * a renderer that "stacks" values will return a bigger range than
  1236. * a renderer that doesn't.
  1237. *
  1238. * @param dataset the dataset (<code>null</code> permitted).
  1239. *
  1240. * @return The range (or <code>null</code> if the dataset is
  1241. * <code>null</code> or empty).
  1242. */
  1243. public Range findRangeBounds(XYDataset dataset);
  1244. /**
  1245. * Add a renderer change listener.
  1246. *
  1247. * @param listener the listener.
  1248. */
  1249. public void addChangeListener(RendererChangeListener listener);
  1250. /**
  1251. * Removes a change listener.
  1252. *
  1253. * @param listener the listener.
  1254. */
  1255. public void removeChangeListener(RendererChangeListener listener);
  1256. }