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