001/* =========================================================== 002 * JFreeChart : a free chart library for the Java(tm) platform 003 * =========================================================== 004 * 005 * (C) Copyright 2000-2020, 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 * SpiderWebPlot.java 029 * ------------------ 030 * (C) Copyright 2005-2020, by Heaps of Flavour Pty Ltd and Contributors. 031 * 032 * Company Info: http://www.i4-talent.com 033 * 034 * Original Author: Don Elliott; 035 * Contributor(s): David Gilbert (for Object Refinery Limited); 036 * Nina Jeliazkova; 037 * 038 * Changes 039 * ------- 040 * 28-Jan-2005 : First cut - missing a few features - still to do: 041 * - needs tooltips/URL/label generator functions 042 * - ticks on axes / background grid? 043 * 31-Jan-2005 : Renamed SpiderWebPlot, added label generator support, and 044 * reformatted for consistency with other source files in 045 * JFreeChart (DG); 046 * 20-Apr-2005 : Renamed CategoryLabelGenerator 047 * --> CategoryItemLabelGenerator (DG); 048 * 05-May-2005 : Updated draw() method parameters (DG); 049 * 10-Jun-2005 : Added equals() method and fixed serialization (DG); 050 * 16-Jun-2005 : Added default constructor and get/setDataset() 051 * methods (DG); 052 * ------------- JFREECHART 1.0.x --------------------------------------------- 053 * 05-Apr-2006 : Fixed bug preventing the display of zero values - see patch 054 * 1462727 (DG); 055 * 05-Apr-2006 : Added support for mouse clicks, tool tips and URLs - see patch 056 * 1463455 (DG); 057 * 01-Jun-2006 : Fix bug 1493199, NullPointerException when drawing with null 058 * info (DG); 059 * 05-Feb-2007 : Added attributes for axis stroke and paint, while fixing 060 * bug 1651277, and implemented clone() properly (DG); 061 * 06-Feb-2007 : Changed getPlotValue() to protected, as suggested in bug 062 * 1605202 (DG); 063 * 05-Mar-2007 : Restore clip region correctly (see bug 1667750) (DG); 064 * 18-May-2007 : Set dataset for LegendItem (DG); 065 * 02-Jun-2008 : Fixed bug with chart entities using TableOrder.BY_COLUMN (DG); 066 * 02-Jun-2008 : Fixed bug with null dataset (DG); 067 * 01-Jun-2009 : Set series key in getLegendItems() (DG); 068 * 02-Jul-2013 : Use ParamChecks (DG); 069 * 070 */ 071 072package org.jfree.chart.plot; 073 074import java.awt.AlphaComposite; 075import java.awt.BasicStroke; 076import java.awt.Color; 077import java.awt.Composite; 078import java.awt.Font; 079import java.awt.Graphics2D; 080import java.awt.Paint; 081import java.awt.Polygon; 082import java.awt.Rectangle; 083import java.awt.Shape; 084import java.awt.Stroke; 085import java.awt.font.FontRenderContext; 086import java.awt.font.LineMetrics; 087import java.awt.geom.Arc2D; 088import java.awt.geom.Ellipse2D; 089import java.awt.geom.Line2D; 090import java.awt.geom.Point2D; 091import java.awt.geom.Rectangle2D; 092import java.io.IOException; 093import java.io.ObjectInputStream; 094import java.io.ObjectOutputStream; 095import java.io.Serializable; 096import java.util.Iterator; 097import java.util.List; 098 099import org.jfree.chart.LegendItem; 100import org.jfree.chart.LegendItemCollection; 101import org.jfree.chart.entity.CategoryItemEntity; 102import org.jfree.chart.entity.EntityCollection; 103import org.jfree.chart.event.PlotChangeEvent; 104import org.jfree.chart.labels.CategoryItemLabelGenerator; 105import org.jfree.chart.labels.CategoryToolTipGenerator; 106import org.jfree.chart.labels.StandardCategoryItemLabelGenerator; 107import org.jfree.chart.ui.RectangleInsets; 108import org.jfree.chart.urls.CategoryURLGenerator; 109import org.jfree.chart.util.ObjectUtils; 110import org.jfree.chart.util.PaintList; 111import org.jfree.chart.util.PaintUtils; 112import org.jfree.chart.util.Args; 113import org.jfree.chart.util.Rotation; 114import org.jfree.chart.util.SerialUtils; 115import org.jfree.chart.util.ShapeUtils; 116import org.jfree.chart.util.StrokeList; 117import org.jfree.chart.util.TableOrder; 118import org.jfree.data.category.CategoryDataset; 119import org.jfree.data.general.DatasetChangeEvent; 120import org.jfree.data.general.DatasetUtils; 121 122/** 123 * A plot that displays data from a {@link CategoryDataset} in the form of a 124 * "spider web". Multiple series can be plotted on the same axis to allow 125 * easy comparison. This plot doesn't support negative values at present. 126 */ 127public class SpiderWebPlot extends Plot implements Cloneable, Serializable { 128 129 /** For serialization. */ 130 private static final long serialVersionUID = -5376340422031599463L; 131 132 /** The default head radius percent (currently 1%). */ 133 public static final double DEFAULT_HEAD = 0.01; 134 135 /** The default axis label gap (currently 10%). */ 136 public static final double DEFAULT_AXIS_LABEL_GAP = 0.10; 137 138 /** The default interior gap. */ 139 public static final double DEFAULT_INTERIOR_GAP = 0.25; 140 141 /** The maximum interior gap (currently 40%). */ 142 public static final double MAX_INTERIOR_GAP = 0.40; 143 144 /** The default starting angle for the radar chart axes. */ 145 public static final double DEFAULT_START_ANGLE = 90.0; 146 147 /** The default series label font. */ 148 public static final Font DEFAULT_LABEL_FONT = new Font("SansSerif", 149 Font.PLAIN, 10); 150 151 /** The default series label paint. */ 152 public static final Paint DEFAULT_LABEL_PAINT = Color.BLACK; 153 154 /** The default series label background paint. */ 155 public static final Paint DEFAULT_LABEL_BACKGROUND_PAINT 156 = new Color(255, 255, 192); 157 158 /** The default series label outline paint. */ 159 public static final Paint DEFAULT_LABEL_OUTLINE_PAINT = Color.BLACK; 160 161 /** The default series label outline stroke. */ 162 public static final Stroke DEFAULT_LABEL_OUTLINE_STROKE 163 = new BasicStroke(0.5f); 164 165 /** The default series label shadow paint. */ 166 public static final Paint DEFAULT_LABEL_SHADOW_PAINT = Color.LIGHT_GRAY; 167 168 /** 169 * The default maximum value plotted - forces the plot to evaluate 170 * the maximum from the data passed in 171 */ 172 public static final double DEFAULT_MAX_VALUE = -1.0; 173 174 /** The head radius as a percentage of the available drawing area. */ 175 protected double headPercent; 176 177 /** The space left around the outside of the plot as a percentage. */ 178 private double interiorGap; 179 180 /** The gap between the labels and the axes as a %age of the radius. */ 181 private double axisLabelGap; 182 183 /** 184 * The paint used to draw the axis lines. 185 * 186 * @since 1.0.4 187 */ 188 private transient Paint axisLinePaint; 189 190 /** 191 * The stroke used to draw the axis lines. 192 * 193 * @since 1.0.4 194 */ 195 private transient Stroke axisLineStroke; 196 197 /** The dataset. */ 198 private CategoryDataset dataset; 199 200 /** The maximum value we are plotting against on each category axis */ 201 private double maxValue; 202 203 /** 204 * The data extract order (BY_ROW or BY_COLUMN). This denotes whether 205 * the data series are stored in rows (in which case the category names are 206 * derived from the column keys) or in columns (in which case the category 207 * names are derived from the row keys). 208 */ 209 private TableOrder dataExtractOrder; 210 211 /** The starting angle. */ 212 private double startAngle; 213 214 /** The direction for drawing the radar axis and plots. */ 215 private Rotation direction; 216 217 /** The legend item shape. */ 218 private transient Shape legendItemShape; 219 220 /** The paint for ALL series (overrides list). */ 221 private transient Paint seriesPaint; 222 223 /** The series paint list. */ 224 private PaintList seriesPaintList; 225 226 /** The base series paint (fallback). */ 227 private transient Paint baseSeriesPaint; 228 229 /** The outline paint for ALL series (overrides list). */ 230 private transient Paint seriesOutlinePaint; 231 232 /** The series outline paint list. */ 233 private PaintList seriesOutlinePaintList; 234 235 /** The base series outline paint (fallback). */ 236 private transient Paint baseSeriesOutlinePaint; 237 238 /** The outline stroke for ALL series (overrides list). */ 239 private transient Stroke seriesOutlineStroke; 240 241 /** The series outline stroke list. */ 242 private StrokeList seriesOutlineStrokeList; 243 244 /** The base series outline stroke (fallback). */ 245 private transient Stroke baseSeriesOutlineStroke; 246 247 /** The font used to display the category labels. */ 248 private Font labelFont; 249 250 /** The color used to draw the category labels. */ 251 private transient Paint labelPaint; 252 253 /** The label generator. */ 254 private CategoryItemLabelGenerator labelGenerator; 255 256 /** controls if the web polygons are filled or not */ 257 private boolean webFilled = true; 258 259 /** A tooltip generator for the plot ({@code null} permitted). */ 260 private CategoryToolTipGenerator toolTipGenerator; 261 262 /** A URL generator for the plot ({@code null} permitted). */ 263 private CategoryURLGenerator urlGenerator; 264 265 /** 266 * Creates a default plot with no dataset. 267 */ 268 public SpiderWebPlot() { 269 this(null); 270 } 271 272 /** 273 * Creates a new spider web plot with the given dataset, with each row 274 * representing a series. 275 * 276 * @param dataset the dataset ({@code null} permitted). 277 */ 278 public SpiderWebPlot(CategoryDataset dataset) { 279 this(dataset, TableOrder.BY_ROW); 280 } 281 282 /** 283 * Creates a new spider web plot with the given dataset. 284 * 285 * @param dataset the dataset. 286 * @param extract controls how data is extracted ({@link TableOrder#BY_ROW} 287 * or {@link TableOrder#BY_COLUMN}). 288 */ 289 public SpiderWebPlot(CategoryDataset dataset, TableOrder extract) { 290 super(); 291 Args.nullNotPermitted(extract, "extract"); 292 this.dataset = dataset; 293 if (dataset != null) { 294 dataset.addChangeListener(this); 295 } 296 297 this.dataExtractOrder = extract; 298 this.headPercent = DEFAULT_HEAD; 299 this.axisLabelGap = DEFAULT_AXIS_LABEL_GAP; 300 this.axisLinePaint = Color.BLACK; 301 this.axisLineStroke = new BasicStroke(1.0f); 302 303 this.interiorGap = DEFAULT_INTERIOR_GAP; 304 this.startAngle = DEFAULT_START_ANGLE; 305 this.direction = Rotation.CLOCKWISE; 306 this.maxValue = DEFAULT_MAX_VALUE; 307 308 this.seriesPaint = null; 309 this.seriesPaintList = new PaintList(); 310 this.baseSeriesPaint = null; 311 312 this.seriesOutlinePaint = null; 313 this.seriesOutlinePaintList = new PaintList(); 314 this.baseSeriesOutlinePaint = DEFAULT_OUTLINE_PAINT; 315 316 this.seriesOutlineStroke = null; 317 this.seriesOutlineStrokeList = new StrokeList(); 318 this.baseSeriesOutlineStroke = DEFAULT_OUTLINE_STROKE; 319 320 this.labelFont = DEFAULT_LABEL_FONT; 321 this.labelPaint = DEFAULT_LABEL_PAINT; 322 this.labelGenerator = new StandardCategoryItemLabelGenerator(); 323 324 this.legendItemShape = DEFAULT_LEGEND_ITEM_CIRCLE; 325 } 326 327 /** 328 * Returns a short string describing the type of plot. 329 * 330 * @return The plot type. 331 */ 332 @Override 333 public String getPlotType() { 334 // return localizationResources.getString("Radar_Plot"); 335 return ("Spider Web Plot"); 336 } 337 338 /** 339 * Returns the dataset. 340 * 341 * @return The dataset (possibly {@code null}). 342 * 343 * @see #setDataset(CategoryDataset) 344 */ 345 public CategoryDataset getDataset() { 346 return this.dataset; 347 } 348 349 /** 350 * Sets the dataset used by the plot and sends a {@link PlotChangeEvent} 351 * to all registered listeners. 352 * 353 * @param dataset the dataset ({@code null} permitted). 354 * 355 * @see #getDataset() 356 */ 357 public void setDataset(CategoryDataset dataset) { 358 // if there is an existing dataset, remove the plot from the list of 359 // change listeners... 360 if (this.dataset != null) { 361 this.dataset.removeChangeListener(this); 362 } 363 364 // set the new dataset, and register the chart as a change listener... 365 this.dataset = dataset; 366 if (dataset != null) { 367 setDatasetGroup(dataset.getGroup()); 368 dataset.addChangeListener(this); 369 } 370 371 // send a dataset change event to self to trigger plot change event 372 datasetChanged(new DatasetChangeEvent(this, dataset)); 373 } 374 375 /** 376 * Method to determine if the web chart is to be filled. 377 * 378 * @return A boolean. 379 * 380 * @see #setWebFilled(boolean) 381 */ 382 public boolean isWebFilled() { 383 return this.webFilled; 384 } 385 386 /** 387 * Sets the webFilled flag and sends a {@link PlotChangeEvent} to all 388 * registered listeners. 389 * 390 * @param flag the flag. 391 * 392 * @see #isWebFilled() 393 */ 394 public void setWebFilled(boolean flag) { 395 this.webFilled = flag; 396 fireChangeEvent(); 397 } 398 399 /** 400 * Returns the data extract order (by row or by column). 401 * 402 * @return The data extract order (never {@code null}). 403 * 404 * @see #setDataExtractOrder(TableOrder) 405 */ 406 public TableOrder getDataExtractOrder() { 407 return this.dataExtractOrder; 408 } 409 410 /** 411 * Sets the data extract order (by row or by column) and sends a 412 * {@link PlotChangeEvent}to all registered listeners. 413 * 414 * @param order the order ({@code null} not permitted). 415 * 416 * @throws IllegalArgumentException if {@code order} is 417 * {@code null}. 418 * 419 * @see #getDataExtractOrder() 420 */ 421 public void setDataExtractOrder(TableOrder order) { 422 Args.nullNotPermitted(order, "order"); 423 this.dataExtractOrder = order; 424 fireChangeEvent(); 425 } 426 427 /** 428 * Returns the head percent (the default value is 0.01). 429 * 430 * @return The head percent (always > 0). 431 * 432 * @see #setHeadPercent(double) 433 */ 434 public double getHeadPercent() { 435 return this.headPercent; 436 } 437 438 /** 439 * Sets the head percent and sends a {@link PlotChangeEvent} to all 440 * registered listeners. Note that 0.10 is 10 percent. 441 * 442 * @param percent the percent (must be greater than zero). 443 * 444 * @see #getHeadPercent() 445 */ 446 public void setHeadPercent(double percent) { 447 Args.requireNonNegative(percent, "percent"); 448 this.headPercent = percent; 449 fireChangeEvent(); 450 } 451 452 /** 453 * Returns the start angle for the first radar axis. 454 * <BR> 455 * This is measured in degrees starting from 3 o'clock (Java Arc2D default) 456 * and measuring anti-clockwise. 457 * 458 * @return The start angle. 459 * 460 * @see #setStartAngle(double) 461 */ 462 public double getStartAngle() { 463 return this.startAngle; 464 } 465 466 /** 467 * Sets the starting angle and sends a {@link PlotChangeEvent} to all 468 * registered listeners. 469 * <P> 470 * The initial default value is 90 degrees, which corresponds to 12 o'clock. 471 * A value of zero corresponds to 3 o'clock... this is the encoding used by 472 * Java's Arc2D class. 473 * 474 * @param angle the angle (in degrees). 475 * 476 * @see #getStartAngle() 477 */ 478 public void setStartAngle(double angle) { 479 this.startAngle = angle; 480 fireChangeEvent(); 481 } 482 483 /** 484 * Returns the maximum value any category axis can take. 485 * 486 * @return The maximum value. 487 * 488 * @see #setMaxValue(double) 489 */ 490 public double getMaxValue() { 491 return this.maxValue; 492 } 493 494 /** 495 * Sets the maximum value any category axis can take and sends 496 * a {@link PlotChangeEvent} to all registered listeners. 497 * 498 * @param value the maximum value. 499 * 500 * @see #getMaxValue() 501 */ 502 public void setMaxValue(double value) { 503 this.maxValue = value; 504 fireChangeEvent(); 505 } 506 507 /** 508 * Returns the direction in which the radar axes are drawn 509 * (clockwise or anti-clockwise). 510 * 511 * @return The direction (never {@code null}). 512 * 513 * @see #setDirection(Rotation) 514 */ 515 public Rotation getDirection() { 516 return this.direction; 517 } 518 519 /** 520 * Sets the direction in which the radar axes are drawn and sends a 521 * {@link PlotChangeEvent} to all registered listeners. 522 * 523 * @param direction the direction ({@code null} not permitted). 524 * 525 * @see #getDirection() 526 */ 527 public void setDirection(Rotation direction) { 528 Args.nullNotPermitted(direction, "direction"); 529 this.direction = direction; 530 fireChangeEvent(); 531 } 532 533 /** 534 * Returns the interior gap, measured as a percentage of the available 535 * drawing space. 536 * 537 * @return The gap (as a percentage of the available drawing space). 538 * 539 * @see #setInteriorGap(double) 540 */ 541 public double getInteriorGap() { 542 return this.interiorGap; 543 } 544 545 /** 546 * Sets the interior gap and sends a {@link PlotChangeEvent} to all 547 * registered listeners. This controls the space between the edges of the 548 * plot and the plot area itself (the region where the axis labels appear). 549 * 550 * @param percent the gap (as a percentage of the available drawing space). 551 * 552 * @see #getInteriorGap() 553 */ 554 public void setInteriorGap(double percent) { 555 if ((percent < 0.0) || (percent > MAX_INTERIOR_GAP)) { 556 throw new IllegalArgumentException( 557 "Percentage outside valid range."); 558 } 559 if (this.interiorGap != percent) { 560 this.interiorGap = percent; 561 fireChangeEvent(); 562 } 563 } 564 565 /** 566 * Returns the axis label gap. 567 * 568 * @return The axis label gap. 569 * 570 * @see #setAxisLabelGap(double) 571 */ 572 public double getAxisLabelGap() { 573 return this.axisLabelGap; 574 } 575 576 /** 577 * Sets the axis label gap and sends a {@link PlotChangeEvent} to all 578 * registered listeners. 579 * 580 * @param gap the gap. 581 * 582 * @see #getAxisLabelGap() 583 */ 584 public void setAxisLabelGap(double gap) { 585 this.axisLabelGap = gap; 586 fireChangeEvent(); 587 } 588 589 /** 590 * Returns the paint used to draw the axis lines. 591 * 592 * @return The paint used to draw the axis lines (never {@code null}). 593 * 594 * @see #setAxisLinePaint(Paint) 595 * @see #getAxisLineStroke() 596 * @since 1.0.4 597 */ 598 public Paint getAxisLinePaint() { 599 return this.axisLinePaint; 600 } 601 602 /** 603 * Sets the paint used to draw the axis lines and sends a 604 * {@link PlotChangeEvent} to all registered listeners. 605 * 606 * @param paint the paint ({@code null} not permitted). 607 * 608 * @see #getAxisLinePaint() 609 * @since 1.0.4 610 */ 611 public void setAxisLinePaint(Paint paint) { 612 Args.nullNotPermitted(paint, "paint"); 613 this.axisLinePaint = paint; 614 fireChangeEvent(); 615 } 616 617 /** 618 * Returns the stroke used to draw the axis lines. 619 * 620 * @return The stroke used to draw the axis lines (never {@code null}). 621 * 622 * @see #setAxisLineStroke(Stroke) 623 * @see #getAxisLinePaint() 624 * @since 1.0.4 625 */ 626 public Stroke getAxisLineStroke() { 627 return this.axisLineStroke; 628 } 629 630 /** 631 * Sets the stroke used to draw the axis lines and sends a 632 * {@link PlotChangeEvent} to all registered listeners. 633 * 634 * @param stroke the stroke ({@code null} not permitted). 635 * 636 * @see #getAxisLineStroke() 637 * @since 1.0.4 638 */ 639 public void setAxisLineStroke(Stroke stroke) { 640 Args.nullNotPermitted(stroke, "stroke"); 641 this.axisLineStroke = stroke; 642 fireChangeEvent(); 643 } 644 645 //// SERIES PAINT ///////////////////////// 646 647 /** 648 * Returns the paint for ALL series in the plot. 649 * 650 * @return The paint (possibly {@code null}). 651 * 652 * @see #setSeriesPaint(Paint) 653 */ 654 public Paint getSeriesPaint() { 655 return this.seriesPaint; 656 } 657 658 /** 659 * Sets the paint for ALL series in the plot. If this is set to 660 * {@code null}, then a list of paints is used instead (to allow different 661 * colors to be used for each series of the radar group). 662 * 663 * @param paint the paint ({@code null} permitted). 664 * 665 * @see #getSeriesPaint() 666 */ 667 public void setSeriesPaint(Paint paint) { 668 this.seriesPaint = paint; 669 fireChangeEvent(); 670 } 671 672 /** 673 * Returns the paint for the specified series. 674 * 675 * @param series the series index (zero-based). 676 * 677 * @return The paint (never {@code null}). 678 * 679 * @see #setSeriesPaint(int, Paint) 680 */ 681 public Paint getSeriesPaint(int series) { 682 683 // return the override, if there is one... 684 if (this.seriesPaint != null) { 685 return this.seriesPaint; 686 } 687 688 // otherwise look up the paint list 689 Paint result = this.seriesPaintList.getPaint(series); 690 if (result == null) { 691 DrawingSupplier supplier = getDrawingSupplier(); 692 if (supplier != null) { 693 Paint p = supplier.getNextPaint(); 694 this.seriesPaintList.setPaint(series, p); 695 result = p; 696 } 697 else { 698 result = this.baseSeriesPaint; 699 } 700 } 701 return result; 702 703 } 704 705 /** 706 * Sets the paint used to fill a series of the radar and sends a 707 * {@link PlotChangeEvent} to all registered listeners. 708 * 709 * @param series the series index (zero-based). 710 * @param paint the paint ({@code null} permitted). 711 * 712 * @see #getSeriesPaint(int) 713 */ 714 public void setSeriesPaint(int series, Paint paint) { 715 this.seriesPaintList.setPaint(series, paint); 716 fireChangeEvent(); 717 } 718 719 /** 720 * Returns the base series paint. This is used when no other paint is 721 * available. 722 * 723 * @return The paint (never {@code null}). 724 * 725 * @see #setBaseSeriesPaint(Paint) 726 */ 727 public Paint getBaseSeriesPaint() { 728 return this.baseSeriesPaint; 729 } 730 731 /** 732 * Sets the base series paint. 733 * 734 * @param paint the paint ({@code null} not permitted). 735 * 736 * @see #getBaseSeriesPaint() 737 */ 738 public void setBaseSeriesPaint(Paint paint) { 739 Args.nullNotPermitted(paint, "paint"); 740 this.baseSeriesPaint = paint; 741 fireChangeEvent(); 742 } 743 744 //// SERIES OUTLINE PAINT //////////////////////////// 745 746 /** 747 * Returns the outline paint for ALL series in the plot. 748 * 749 * @return The paint (possibly {@code null}). 750 */ 751 public Paint getSeriesOutlinePaint() { 752 return this.seriesOutlinePaint; 753 } 754 755 /** 756 * Sets the outline paint for ALL series in the plot. If this is set to 757 * {@code null}, then a list of paints is used instead (to allow 758 * different colors to be used for each series). 759 * 760 * @param paint the paint ({@code null} permitted). 761 */ 762 public void setSeriesOutlinePaint(Paint paint) { 763 this.seriesOutlinePaint = paint; 764 fireChangeEvent(); 765 } 766 767 /** 768 * Returns the paint for the specified series. 769 * 770 * @param series the series index (zero-based). 771 * 772 * @return The paint (never {@code null}). 773 */ 774 public Paint getSeriesOutlinePaint(int series) { 775 // return the override, if there is one... 776 if (this.seriesOutlinePaint != null) { 777 return this.seriesOutlinePaint; 778 } 779 // otherwise look up the paint list 780 Paint result = this.seriesOutlinePaintList.getPaint(series); 781 if (result == null) { 782 result = this.baseSeriesOutlinePaint; 783 } 784 return result; 785 } 786 787 /** 788 * Sets the paint used to fill a series of the radar and sends a 789 * {@link PlotChangeEvent} to all registered listeners. 790 * 791 * @param series the series index (zero-based). 792 * @param paint the paint ({@code null} permitted). 793 */ 794 public void setSeriesOutlinePaint(int series, Paint paint) { 795 this.seriesOutlinePaintList.setPaint(series, paint); 796 fireChangeEvent(); 797 } 798 799 /** 800 * Returns the base series paint. This is used when no other paint is 801 * available. 802 * 803 * @return The paint (never {@code null}). 804 */ 805 public Paint getBaseSeriesOutlinePaint() { 806 return this.baseSeriesOutlinePaint; 807 } 808 809 /** 810 * Sets the base series paint. 811 * 812 * @param paint the paint ({@code null} not permitted). 813 */ 814 public void setBaseSeriesOutlinePaint(Paint paint) { 815 Args.nullNotPermitted(paint, "paint"); 816 this.baseSeriesOutlinePaint = paint; 817 fireChangeEvent(); 818 } 819 820 //// SERIES OUTLINE STROKE ///////////////////// 821 822 /** 823 * Returns the outline stroke for ALL series in the plot. 824 * 825 * @return The stroke (possibly {@code null}). 826 */ 827 public Stroke getSeriesOutlineStroke() { 828 return this.seriesOutlineStroke; 829 } 830 831 /** 832 * Sets the outline stroke for ALL series in the plot. If this is set to 833 * {@code null}, then a list of paints is used instead (to allow 834 * different colors to be used for each series). 835 * 836 * @param stroke the stroke ({@code null} permitted). 837 */ 838 public void setSeriesOutlineStroke(Stroke stroke) { 839 this.seriesOutlineStroke = stroke; 840 fireChangeEvent(); 841 } 842 843 /** 844 * Returns the stroke for the specified series. 845 * 846 * @param series the series index (zero-based). 847 * 848 * @return The stroke (never {@code null}). 849 */ 850 public Stroke getSeriesOutlineStroke(int series) { 851 852 // return the override, if there is one... 853 if (this.seriesOutlineStroke != null) { 854 return this.seriesOutlineStroke; 855 } 856 857 // otherwise look up the paint list 858 Stroke result = this.seriesOutlineStrokeList.getStroke(series); 859 if (result == null) { 860 result = this.baseSeriesOutlineStroke; 861 } 862 return result; 863 864 } 865 866 /** 867 * Sets the stroke used to fill a series of the radar and sends a 868 * {@link PlotChangeEvent} to all registered listeners. 869 * 870 * @param series the series index (zero-based). 871 * @param stroke the stroke ({@code null} permitted). 872 */ 873 public void setSeriesOutlineStroke(int series, Stroke stroke) { 874 this.seriesOutlineStrokeList.setStroke(series, stroke); 875 fireChangeEvent(); 876 } 877 878 /** 879 * Returns the base series stroke. This is used when no other stroke is 880 * available. 881 * 882 * @return The stroke (never {@code null}). 883 */ 884 public Stroke getBaseSeriesOutlineStroke() { 885 return this.baseSeriesOutlineStroke; 886 } 887 888 /** 889 * Sets the base series stroke. 890 * 891 * @param stroke the stroke ({@code null} not permitted). 892 */ 893 public void setBaseSeriesOutlineStroke(Stroke stroke) { 894 Args.nullNotPermitted(stroke, "stroke"); 895 this.baseSeriesOutlineStroke = stroke; 896 fireChangeEvent(); 897 } 898 899 /** 900 * Returns the shape used for legend items. 901 * 902 * @return The shape (never {@code null}). 903 * 904 * @see #setLegendItemShape(Shape) 905 */ 906 public Shape getLegendItemShape() { 907 return this.legendItemShape; 908 } 909 910 /** 911 * Sets the shape used for legend items and sends a {@link PlotChangeEvent} 912 * to all registered listeners. 913 * 914 * @param shape the shape ({@code null} not permitted). 915 * 916 * @see #getLegendItemShape() 917 */ 918 public void setLegendItemShape(Shape shape) { 919 Args.nullNotPermitted(shape, "shape"); 920 this.legendItemShape = shape; 921 fireChangeEvent(); 922 } 923 924 /** 925 * Returns the series label font. 926 * 927 * @return The font (never {@code null}). 928 * 929 * @see #setLabelFont(Font) 930 */ 931 public Font getLabelFont() { 932 return this.labelFont; 933 } 934 935 /** 936 * Sets the series label font and sends a {@link PlotChangeEvent} to all 937 * registered listeners. 938 * 939 * @param font the font ({@code null} not permitted). 940 * 941 * @see #getLabelFont() 942 */ 943 public void setLabelFont(Font font) { 944 Args.nullNotPermitted(font, "font"); 945 this.labelFont = font; 946 fireChangeEvent(); 947 } 948 949 /** 950 * Returns the series label paint. 951 * 952 * @return The paint (never {@code null}). 953 * 954 * @see #setLabelPaint(Paint) 955 */ 956 public Paint getLabelPaint() { 957 return this.labelPaint; 958 } 959 960 /** 961 * Sets the series label paint and sends a {@link PlotChangeEvent} to all 962 * registered listeners. 963 * 964 * @param paint the paint ({@code null} not permitted). 965 * 966 * @see #getLabelPaint() 967 */ 968 public void setLabelPaint(Paint paint) { 969 Args.nullNotPermitted(paint, "paint"); 970 this.labelPaint = paint; 971 fireChangeEvent(); 972 } 973 974 /** 975 * Returns the label generator. 976 * 977 * @return The label generator (never {@code null}). 978 * 979 * @see #setLabelGenerator(CategoryItemLabelGenerator) 980 */ 981 public CategoryItemLabelGenerator getLabelGenerator() { 982 return this.labelGenerator; 983 } 984 985 /** 986 * Sets the label generator and sends a {@link PlotChangeEvent} to all 987 * registered listeners. 988 * 989 * @param generator the generator ({@code null} not permitted). 990 * 991 * @see #getLabelGenerator() 992 */ 993 public void setLabelGenerator(CategoryItemLabelGenerator generator) { 994 Args.nullNotPermitted(generator, "generator"); 995 this.labelGenerator = generator; 996 } 997 998 /** 999 * Returns the tool tip generator for the plot. 1000 * 1001 * @return The tool tip generator (possibly {@code null}). 1002 * 1003 * @see #setToolTipGenerator(CategoryToolTipGenerator) 1004 * 1005 * @since 1.0.2 1006 */ 1007 public CategoryToolTipGenerator getToolTipGenerator() { 1008 return this.toolTipGenerator; 1009 } 1010 1011 /** 1012 * Sets the tool tip generator for the plot and sends a 1013 * {@link PlotChangeEvent} to all registered listeners. 1014 * 1015 * @param generator the generator ({@code null} permitted). 1016 * 1017 * @see #getToolTipGenerator() 1018 * 1019 * @since 1.0.2 1020 */ 1021 public void setToolTipGenerator(CategoryToolTipGenerator generator) { 1022 this.toolTipGenerator = generator; 1023 fireChangeEvent(); 1024 } 1025 1026 /** 1027 * Returns the URL generator for the plot. 1028 * 1029 * @return The URL generator (possibly {@code null}). 1030 * 1031 * @see #setURLGenerator(CategoryURLGenerator) 1032 * 1033 * @since 1.0.2 1034 */ 1035 public CategoryURLGenerator getURLGenerator() { 1036 return this.urlGenerator; 1037 } 1038 1039 /** 1040 * Sets the URL generator for the plot and sends a 1041 * {@link PlotChangeEvent} to all registered listeners. 1042 * 1043 * @param generator the generator ({@code null} permitted). 1044 * 1045 * @see #getURLGenerator() 1046 * 1047 * @since 1.0.2 1048 */ 1049 public void setURLGenerator(CategoryURLGenerator generator) { 1050 this.urlGenerator = generator; 1051 fireChangeEvent(); 1052 } 1053 1054 /** 1055 * Returns a collection of legend items for the spider web chart. 1056 * 1057 * @return The legend items (never {@code null}). 1058 */ 1059 @Override 1060 public LegendItemCollection getLegendItems() { 1061 LegendItemCollection result = new LegendItemCollection(); 1062 if (getDataset() == null) { 1063 return result; 1064 } 1065 List keys = null; 1066 if (this.dataExtractOrder == TableOrder.BY_ROW) { 1067 keys = this.dataset.getRowKeys(); 1068 } 1069 else if (this.dataExtractOrder == TableOrder.BY_COLUMN) { 1070 keys = this.dataset.getColumnKeys(); 1071 } 1072 if (keys == null) { 1073 return result; 1074 } 1075 1076 int series = 0; 1077 Iterator iterator = keys.iterator(); 1078 Shape shape = getLegendItemShape(); 1079 while (iterator.hasNext()) { 1080 Comparable key = (Comparable) iterator.next(); 1081 String label = key.toString(); 1082 String description = label; 1083 Paint paint = getSeriesPaint(series); 1084 Paint outlinePaint = getSeriesOutlinePaint(series); 1085 Stroke stroke = getSeriesOutlineStroke(series); 1086 LegendItem item = new LegendItem(label, description, 1087 null, null, shape, paint, stroke, outlinePaint); 1088 item.setDataset(getDataset()); 1089 item.setSeriesKey(key); 1090 item.setSeriesIndex(series); 1091 result.add(item); 1092 series++; 1093 } 1094 return result; 1095 } 1096 1097 /** 1098 * Returns a cartesian point from a polar angle, length and bounding box 1099 * 1100 * @param bounds the area inside which the point needs to be. 1101 * @param angle the polar angle, in degrees. 1102 * @param length the relative length. Given in percent of maximum extend. 1103 * 1104 * @return The cartesian point. 1105 */ 1106 protected Point2D getWebPoint(Rectangle2D bounds, 1107 double angle, double length) { 1108 1109 double angrad = Math.toRadians(angle); 1110 double x = Math.cos(angrad) * length * bounds.getWidth() / 2; 1111 double y = -Math.sin(angrad) * length * bounds.getHeight() / 2; 1112 1113 return new Point2D.Double(bounds.getX() + x + bounds.getWidth() / 2, 1114 bounds.getY() + y + bounds.getHeight() / 2); 1115 } 1116 1117 /** 1118 * Draws the plot on a Java 2D graphics device (such as the screen or a 1119 * printer). 1120 * 1121 * @param g2 the graphics device. 1122 * @param area the area within which the plot should be drawn. 1123 * @param anchor the anchor point ({@code null} permitted). 1124 * @param parentState the state from the parent plot, if there is one. 1125 * @param info collects info about the drawing. 1126 */ 1127 @Override 1128 public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, 1129 PlotState parentState, PlotRenderingInfo info) { 1130 1131 // adjust for insets... 1132 RectangleInsets insets = getInsets(); 1133 insets.trim(area); 1134 1135 if (info != null) { 1136 info.setPlotArea(area); 1137 info.setDataArea(area); 1138 } 1139 1140 drawBackground(g2, area); 1141 drawOutline(g2, area); 1142 1143 Shape savedClip = g2.getClip(); 1144 1145 g2.clip(area); 1146 Composite originalComposite = g2.getComposite(); 1147 g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1148 getForegroundAlpha())); 1149 1150 if (!DatasetUtils.isEmptyOrNull(this.dataset)) { 1151 int seriesCount, catCount; 1152 1153 if (this.dataExtractOrder == TableOrder.BY_ROW) { 1154 seriesCount = this.dataset.getRowCount(); 1155 catCount = this.dataset.getColumnCount(); 1156 } 1157 else { 1158 seriesCount = this.dataset.getColumnCount(); 1159 catCount = this.dataset.getRowCount(); 1160 } 1161 1162 // ensure we have a maximum value to use on the axes 1163 if (this.maxValue == DEFAULT_MAX_VALUE) { 1164 calculateMaxValue(seriesCount, catCount); 1165 } 1166 1167 // Next, setup the plot area 1168 1169 // adjust the plot area by the interior spacing value 1170 1171 double gapHorizontal = area.getWidth() * getInteriorGap(); 1172 double gapVertical = area.getHeight() * getInteriorGap(); 1173 1174 double X = area.getX() + gapHorizontal / 2; 1175 double Y = area.getY() + gapVertical / 2; 1176 double W = area.getWidth() - gapHorizontal; 1177 double H = area.getHeight() - gapVertical; 1178 1179 double headW = area.getWidth() * this.headPercent; 1180 double headH = area.getHeight() * this.headPercent; 1181 1182 // make the chart area a square 1183 double min = Math.min(W, H) / 2; 1184 X = (X + X + W) / 2 - min; 1185 Y = (Y + Y + H) / 2 - min; 1186 W = 2 * min; 1187 H = 2 * min; 1188 1189 Point2D centre = new Point2D.Double(X + W / 2, Y + H / 2); 1190 Rectangle2D radarArea = new Rectangle2D.Double(X, Y, W, H); 1191 1192 // draw the axis and category label 1193 for (int cat = 0; cat < catCount; cat++) { 1194 double angle = getStartAngle() 1195 + (getDirection().getFactor() * cat * 360 / catCount); 1196 1197 Point2D endPoint = getWebPoint(radarArea, angle, 1); 1198 // 1 = end of axis 1199 Line2D line = new Line2D.Double(centre, endPoint); 1200 g2.setPaint(this.axisLinePaint); 1201 g2.setStroke(this.axisLineStroke); 1202 g2.draw(line); 1203 drawLabel(g2, radarArea, 0.0, cat, angle, 360.0 / catCount); 1204 } 1205 1206 // Now actually plot each of the series polygons.. 1207 for (int series = 0; series < seriesCount; series++) { 1208 drawRadarPoly(g2, radarArea, centre, info, series, catCount, 1209 headH, headW); 1210 } 1211 } 1212 else { 1213 drawNoDataMessage(g2, area); 1214 } 1215 g2.setClip(savedClip); 1216 g2.setComposite(originalComposite); 1217 drawOutline(g2, area); 1218 } 1219 1220 /** 1221 * loop through each of the series to get the maximum value 1222 * on each category axis 1223 * 1224 * @param seriesCount the number of series 1225 * @param catCount the number of categories 1226 */ 1227 private void calculateMaxValue(int seriesCount, int catCount) { 1228 double v; 1229 Number nV; 1230 1231 for (int seriesIndex = 0; seriesIndex < seriesCount; seriesIndex++) { 1232 for (int catIndex = 0; catIndex < catCount; catIndex++) { 1233 nV = getPlotValue(seriesIndex, catIndex); 1234 if (nV != null) { 1235 v = nV.doubleValue(); 1236 if (v > this.maxValue) { 1237 this.maxValue = v; 1238 } 1239 } 1240 } 1241 } 1242 } 1243 1244 /** 1245 * Draws a radar plot polygon. 1246 * 1247 * @param g2 the graphics device. 1248 * @param plotArea the area we are plotting in (already adjusted). 1249 * @param centre the centre point of the radar axes 1250 * @param info chart rendering info. 1251 * @param series the series within the dataset we are plotting 1252 * @param catCount the number of categories per radar plot 1253 * @param headH the data point height 1254 * @param headW the data point width 1255 */ 1256 protected void drawRadarPoly(Graphics2D g2, 1257 Rectangle2D plotArea, 1258 Point2D centre, 1259 PlotRenderingInfo info, 1260 int series, int catCount, 1261 double headH, double headW) { 1262 1263 Polygon polygon = new Polygon(); 1264 1265 EntityCollection entities = null; 1266 if (info != null) { 1267 entities = info.getOwner().getEntityCollection(); 1268 } 1269 1270 // plot the data... 1271 for (int cat = 0; cat < catCount; cat++) { 1272 1273 Number dataValue = getPlotValue(series, cat); 1274 1275 if (dataValue != null) { 1276 double value = dataValue.doubleValue(); 1277 1278 if (value >= 0) { // draw the polygon series... 1279 1280 // Finds our starting angle from the centre for this axis 1281 1282 double angle = getStartAngle() 1283 + (getDirection().getFactor() * cat * 360 / catCount); 1284 1285 // The following angle calc will ensure there isn't a top 1286 // vertical axis - this may be useful if you don't want any 1287 // given criteria to 'appear' move important than the 1288 // others.. 1289 // + (getDirection().getFactor() 1290 // * (cat + 0.5) * 360 / catCount); 1291 1292 // find the point at the appropriate distance end point 1293 // along the axis/angle identified above and add it to the 1294 // polygon 1295 1296 Point2D point = getWebPoint(plotArea, angle, 1297 value / this.maxValue); 1298 polygon.addPoint((int) point.getX(), (int) point.getY()); 1299 1300 // put an elipse at the point being plotted.. 1301 1302 Paint paint = getSeriesPaint(series); 1303 Paint outlinePaint = getSeriesOutlinePaint(series); 1304 Stroke outlineStroke = getSeriesOutlineStroke(series); 1305 1306 Ellipse2D head = new Ellipse2D.Double(point.getX() 1307 - headW / 2, point.getY() - headH / 2, headW, 1308 headH); 1309 g2.setPaint(paint); 1310 g2.fill(head); 1311 g2.setStroke(outlineStroke); 1312 g2.setPaint(outlinePaint); 1313 g2.draw(head); 1314 1315 if (entities != null) { 1316 int row, col; 1317 if (this.dataExtractOrder == TableOrder.BY_ROW) { 1318 row = series; 1319 col = cat; 1320 } 1321 else { 1322 row = cat; 1323 col = series; 1324 } 1325 String tip = null; 1326 if (this.toolTipGenerator != null) { 1327 tip = this.toolTipGenerator.generateToolTip( 1328 this.dataset, row, col); 1329 } 1330 1331 String url = null; 1332 if (this.urlGenerator != null) { 1333 url = this.urlGenerator.generateURL(this.dataset, 1334 row, col); 1335 } 1336 1337 Shape area = new Rectangle( 1338 (int) (point.getX() - headW), 1339 (int) (point.getY() - headH), 1340 (int) (headW * 2), (int) (headH * 2)); 1341 CategoryItemEntity entity = new CategoryItemEntity( 1342 area, tip, url, this.dataset, 1343 this.dataset.getRowKey(row), 1344 this.dataset.getColumnKey(col)); 1345 entities.add(entity); 1346 } 1347 1348 } 1349 } 1350 } 1351 // Plot the polygon 1352 1353 Paint paint = getSeriesPaint(series); 1354 g2.setPaint(paint); 1355 g2.setStroke(getSeriesOutlineStroke(series)); 1356 g2.draw(polygon); 1357 1358 // Lastly, fill the web polygon if this is required 1359 1360 if (this.webFilled) { 1361 g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1362 0.1f)); 1363 g2.fill(polygon); 1364 g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1365 getForegroundAlpha())); 1366 } 1367 } 1368 1369 /** 1370 * Returns the value to be plotted at the intersection of the 1371 * series and the category. This allows us to plot 1372 * {@code BY_ROW} or {@code BY_COLUMN} which basically is just 1373 * reversing the definition of the categories and data series being 1374 * plotted. 1375 * 1376 * @param series the series to be plotted. 1377 * @param cat the category within the series to be plotted. 1378 * 1379 * @return The value to be plotted (possibly {@code null}). 1380 * 1381 * @see #getDataExtractOrder() 1382 */ 1383 protected Number getPlotValue(int series, int cat) { 1384 Number value = null; 1385 if (this.dataExtractOrder == TableOrder.BY_ROW) { 1386 value = this.dataset.getValue(series, cat); 1387 } 1388 else if (this.dataExtractOrder == TableOrder.BY_COLUMN) { 1389 value = this.dataset.getValue(cat, series); 1390 } 1391 return value; 1392 } 1393 1394 /** 1395 * Draws the label for one axis. 1396 * 1397 * @param g2 the graphics device. 1398 * @param plotArea the plot area 1399 * @param value the value of the label (ignored). 1400 * @param cat the category (zero-based index). 1401 * @param startAngle the starting angle. 1402 * @param extent the extent of the arc. 1403 */ 1404 protected void drawLabel(Graphics2D g2, Rectangle2D plotArea, double value, 1405 int cat, double startAngle, double extent) { 1406 FontRenderContext frc = g2.getFontRenderContext(); 1407 1408 String label; 1409 if (this.dataExtractOrder == TableOrder.BY_ROW) { 1410 // if series are in rows, then the categories are the column keys 1411 label = this.labelGenerator.generateColumnLabel(this.dataset, cat); 1412 } 1413 else { 1414 // if series are in columns, then the categories are the row keys 1415 label = this.labelGenerator.generateRowLabel(this.dataset, cat); 1416 } 1417 1418 Rectangle2D labelBounds = getLabelFont().getStringBounds(label, frc); 1419 LineMetrics lm = getLabelFont().getLineMetrics(label, frc); 1420 double ascent = lm.getAscent(); 1421 1422 Point2D labelLocation = calculateLabelLocation(labelBounds, ascent, 1423 plotArea, startAngle); 1424 1425 Composite saveComposite = g2.getComposite(); 1426 1427 g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1428 1.0f)); 1429 g2.setPaint(getLabelPaint()); 1430 g2.setFont(getLabelFont()); 1431 g2.drawString(label, (float) labelLocation.getX(), 1432 (float) labelLocation.getY()); 1433 g2.setComposite(saveComposite); 1434 } 1435 1436 /** 1437 * Returns the location for a label 1438 * 1439 * @param labelBounds the label bounds. 1440 * @param ascent the ascent (height of font). 1441 * @param plotArea the plot area 1442 * @param startAngle the start angle for the pie series. 1443 * 1444 * @return The location for a label. 1445 */ 1446 protected Point2D calculateLabelLocation(Rectangle2D labelBounds, 1447 double ascent, 1448 Rectangle2D plotArea, 1449 double startAngle) 1450 { 1451 Arc2D arc1 = new Arc2D.Double(plotArea, startAngle, 0, Arc2D.OPEN); 1452 Point2D point1 = arc1.getEndPoint(); 1453 1454 double deltaX = -(point1.getX() - plotArea.getCenterX()) 1455 * this.axisLabelGap; 1456 double deltaY = -(point1.getY() - plotArea.getCenterY()) 1457 * this.axisLabelGap; 1458 1459 double labelX = point1.getX() - deltaX; 1460 double labelY = point1.getY() - deltaY; 1461 1462 if (labelX < plotArea.getCenterX()) { 1463 labelX -= labelBounds.getWidth(); 1464 } 1465 1466 if (labelX == plotArea.getCenterX()) { 1467 labelX -= labelBounds.getWidth() / 2; 1468 } 1469 1470 if (labelY > plotArea.getCenterY()) { 1471 labelY += ascent; 1472 } 1473 1474 return new Point2D.Double(labelX, labelY); 1475 } 1476 1477 /** 1478 * Tests this plot for equality with an arbitrary object. 1479 * 1480 * @param obj the object ({@code null} permitted). 1481 * 1482 * @return A boolean. 1483 */ 1484 @Override 1485 public boolean equals(Object obj) { 1486 if (obj == this) { 1487 return true; 1488 } 1489 if (!(obj instanceof SpiderWebPlot)) { 1490 return false; 1491 } 1492 if (!super.equals(obj)) { 1493 return false; 1494 } 1495 SpiderWebPlot that = (SpiderWebPlot) obj; 1496 if (!this.dataExtractOrder.equals(that.dataExtractOrder)) { 1497 return false; 1498 } 1499 if (this.headPercent != that.headPercent) { 1500 return false; 1501 } 1502 if (this.interiorGap != that.interiorGap) { 1503 return false; 1504 } 1505 if (this.startAngle != that.startAngle) { 1506 return false; 1507 } 1508 if (!this.direction.equals(that.direction)) { 1509 return false; 1510 } 1511 if (this.maxValue != that.maxValue) { 1512 return false; 1513 } 1514 if (this.webFilled != that.webFilled) { 1515 return false; 1516 } 1517 if (this.axisLabelGap != that.axisLabelGap) { 1518 return false; 1519 } 1520 if (!PaintUtils.equal(this.axisLinePaint, that.axisLinePaint)) { 1521 return false; 1522 } 1523 if (!this.axisLineStroke.equals(that.axisLineStroke)) { 1524 return false; 1525 } 1526 if (!ShapeUtils.equal(this.legendItemShape, that.legendItemShape)) { 1527 return false; 1528 } 1529 if (!PaintUtils.equal(this.seriesPaint, that.seriesPaint)) { 1530 return false; 1531 } 1532 if (!this.seriesPaintList.equals(that.seriesPaintList)) { 1533 return false; 1534 } 1535 if (!PaintUtils.equal(this.baseSeriesPaint, that.baseSeriesPaint)) { 1536 return false; 1537 } 1538 if (!PaintUtils.equal(this.seriesOutlinePaint, 1539 that.seriesOutlinePaint)) { 1540 return false; 1541 } 1542 if (!this.seriesOutlinePaintList.equals(that.seriesOutlinePaintList)) { 1543 return false; 1544 } 1545 if (!PaintUtils.equal(this.baseSeriesOutlinePaint, 1546 that.baseSeriesOutlinePaint)) { 1547 return false; 1548 } 1549 if (!ObjectUtils.equal(this.seriesOutlineStroke, 1550 that.seriesOutlineStroke)) { 1551 return false; 1552 } 1553 if (!this.seriesOutlineStrokeList.equals( 1554 that.seriesOutlineStrokeList)) { 1555 return false; 1556 } 1557 if (!this.baseSeriesOutlineStroke.equals( 1558 that.baseSeriesOutlineStroke)) { 1559 return false; 1560 } 1561 if (!this.labelFont.equals(that.labelFont)) { 1562 return false; 1563 } 1564 if (!PaintUtils.equal(this.labelPaint, that.labelPaint)) { 1565 return false; 1566 } 1567 if (!this.labelGenerator.equals(that.labelGenerator)) { 1568 return false; 1569 } 1570 if (!ObjectUtils.equal(this.toolTipGenerator, 1571 that.toolTipGenerator)) { 1572 return false; 1573 } 1574 if (!ObjectUtils.equal(this.urlGenerator, 1575 that.urlGenerator)) { 1576 return false; 1577 } 1578 return true; 1579 } 1580 1581 /** 1582 * Returns a clone of this plot. 1583 * 1584 * @return A clone of this plot. 1585 * 1586 * @throws CloneNotSupportedException if the plot cannot be cloned for 1587 * any reason. 1588 */ 1589 @Override 1590 public Object clone() throws CloneNotSupportedException { 1591 SpiderWebPlot clone = (SpiderWebPlot) super.clone(); 1592 clone.legendItemShape = ShapeUtils.clone(this.legendItemShape); 1593 clone.seriesPaintList = (PaintList) this.seriesPaintList.clone(); 1594 clone.seriesOutlinePaintList 1595 = (PaintList) this.seriesOutlinePaintList.clone(); 1596 clone.seriesOutlineStrokeList 1597 = (StrokeList) this.seriesOutlineStrokeList.clone(); 1598 return clone; 1599 } 1600 1601 /** 1602 * Provides serialization support. 1603 * 1604 * @param stream the output stream. 1605 * 1606 * @throws IOException if there is an I/O error. 1607 */ 1608 private void writeObject(ObjectOutputStream stream) throws IOException { 1609 stream.defaultWriteObject(); 1610 1611 SerialUtils.writeShape(this.legendItemShape, stream); 1612 SerialUtils.writePaint(this.seriesPaint, stream); 1613 SerialUtils.writePaint(this.baseSeriesPaint, stream); 1614 SerialUtils.writePaint(this.seriesOutlinePaint, stream); 1615 SerialUtils.writePaint(this.baseSeriesOutlinePaint, stream); 1616 SerialUtils.writeStroke(this.seriesOutlineStroke, stream); 1617 SerialUtils.writeStroke(this.baseSeriesOutlineStroke, stream); 1618 SerialUtils.writePaint(this.labelPaint, stream); 1619 SerialUtils.writePaint(this.axisLinePaint, stream); 1620 SerialUtils.writeStroke(this.axisLineStroke, stream); 1621 } 1622 1623 /** 1624 * Provides serialization support. 1625 * 1626 * @param stream the input stream. 1627 * 1628 * @throws IOException if there is an I/O error. 1629 * @throws ClassNotFoundException if there is a classpath problem. 1630 */ 1631 private void readObject(ObjectInputStream stream) throws IOException, 1632 ClassNotFoundException { 1633 stream.defaultReadObject(); 1634 1635 this.legendItemShape = SerialUtils.readShape(stream); 1636 this.seriesPaint = SerialUtils.readPaint(stream); 1637 this.baseSeriesPaint = SerialUtils.readPaint(stream); 1638 this.seriesOutlinePaint = SerialUtils.readPaint(stream); 1639 this.baseSeriesOutlinePaint = SerialUtils.readPaint(stream); 1640 this.seriesOutlineStroke = SerialUtils.readStroke(stream); 1641 this.baseSeriesOutlineStroke = SerialUtils.readStroke(stream); 1642 this.labelPaint = SerialUtils.readPaint(stream); 1643 this.axisLinePaint = SerialUtils.readPaint(stream); 1644 this.axisLineStroke = SerialUtils.readStroke(stream); 1645 if (this.dataset != null) { 1646 this.dataset.addChangeListener(this); 1647 } 1648 } 1649 1650}