001 /* =========================================================== 002 * JFreeChart : a free chart library for the Java(tm) platform 003 * =========================================================== 004 * 005 * (C) Copyright 2000-2008, 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 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 025 * in the United States and other countries.] 026 * 027 * ------------------- 028 * XYAreaRenderer.java 029 * ------------------- 030 * (C) Copyright 2002-2008, by Hari and Contributors. 031 * 032 * Original Author: Hari (ourhari@hotmail.com); 033 * Contributor(s): David Gilbert (for Object Refinery Limited); 034 * Richard Atkinson; 035 * Christian W. Zuckschwerdt; 036 * 037 * Changes: 038 * -------- 039 * 03-Apr-2002 : Version 1, contributed by Hari. This class is based on the 040 * StandardXYItemRenderer class (DG); 041 * 09-Apr-2002 : Removed the translated zero from the drawItem method - 042 * overridden the initialise() method to calculate it (DG); 043 * 30-May-2002 : Added tool tip generator to constructor to match super 044 * class (DG); 045 * 25-Jun-2002 : Removed unnecessary local variable (DG); 046 * 05-Aug-2002 : Small modification to drawItem method to support URLs for HTML 047 * image maps (RA); 048 * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); 049 * 07-Nov-2002 : Renamed AreaXYItemRenderer --> XYAreaRenderer (DG); 050 * 25-Mar-2003 : Implemented Serializable (DG); 051 * 01-May-2003 : Modified drawItem() method signature (DG); 052 * 27-Jul-2003 : Made line and polygon properties protected rather than 053 * private (RA); 054 * 30-Jul-2003 : Modified entity constructor (CZ); 055 * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); 056 * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); 057 * 07-Oct-2003 : Added renderer state (DG); 058 * 08-Dec-2003 : Modified hotspot for chart entity (DG); 059 * 10-Feb-2004 : Changed the drawItem() method to make cut-and-paste overriding 060 * easier. Also moved state class into this class (DG); 061 * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState. Renamed 062 * XYToolTipGenerator --> XYItemLabelGenerator (DG); 063 * 15-Jul-2004 : Switched getX() with getXValue() and getY() with 064 * getYValue() (DG); 065 * 11-Nov-2004 : Now uses ShapeUtilities to translate shapes (DG); 066 * 19-Jan-2005 : Now accesses primitives only from dataset (DG); 067 * 21-Mar-2005 : Override getLegendItem() and equals() methods (DG); 068 * 20-Apr-2005 : Use generators for legend tooltips and URLs (DG); 069 * ------------- JFREECHART 1.0.x --------------------------------------------- 070 * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); 071 * 14-Feb-2007 : Fixed bug in clone() (DG); 072 * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); 073 * 04-May-2007 : Set processVisibleItemsOnly flag to false (DG); 074 * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); 075 * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); 076 * 17-Jun-2008 : Apply legend font and paint attributes (DG); 077 * 31-Dec-2008 : Fix for bug 2471906 - dashed outlines performance issue (DG); 078 * 079 */ 080 081 package org.jfree.chart.renderer.xy; 082 083 import java.awt.BasicStroke; 084 import java.awt.Graphics2D; 085 import java.awt.Paint; 086 import java.awt.Polygon; 087 import java.awt.Shape; 088 import java.awt.Stroke; 089 import java.awt.geom.Area; 090 import java.awt.geom.GeneralPath; 091 import java.awt.geom.Line2D; 092 import java.awt.geom.Rectangle2D; 093 import java.io.IOException; 094 import java.io.ObjectInputStream; 095 import java.io.ObjectOutputStream; 096 097 import org.jfree.chart.LegendItem; 098 import org.jfree.chart.axis.ValueAxis; 099 import org.jfree.chart.entity.EntityCollection; 100 import org.jfree.chart.event.RendererChangeEvent; 101 import org.jfree.chart.labels.XYSeriesLabelGenerator; 102 import org.jfree.chart.labels.XYToolTipGenerator; 103 import org.jfree.chart.plot.CrosshairState; 104 import org.jfree.chart.plot.PlotOrientation; 105 import org.jfree.chart.plot.PlotRenderingInfo; 106 import org.jfree.chart.plot.XYPlot; 107 import org.jfree.chart.urls.XYURLGenerator; 108 import org.jfree.data.xy.XYDataset; 109 import org.jfree.io.SerialUtilities; 110 import org.jfree.util.PublicCloneable; 111 import org.jfree.util.ShapeUtilities; 112 113 /** 114 * Area item renderer for an {@link XYPlot}. This class can draw (a) shapes at 115 * each point, or (b) lines between points, or (c) both shapes and lines, 116 * or (d) filled areas, or (e) filled areas and shapes. The example shown here 117 * is generated by the <code>XYAreaRendererDemo1.java</code> program included 118 * in the JFreeChart demo collection: 119 * <br><br> 120 * <img src="../../../../../images/XYAreaRendererSample.png" 121 * alt="XYAreaRendererSample.png" /> 122 */ 123 public class XYAreaRenderer extends AbstractXYItemRenderer 124 implements XYItemRenderer, PublicCloneable { 125 126 /** For serialization. */ 127 private static final long serialVersionUID = -4481971353973876747L; 128 129 /** 130 * A state object used by this renderer. 131 */ 132 static class XYAreaRendererState extends XYItemRendererState { 133 134 /** Working storage for the area under one series. */ 135 public Polygon area; 136 137 /** Working line that can be recycled. */ 138 public Line2D line; 139 140 /** 141 * Creates a new state. 142 * 143 * @param info the plot rendering info. 144 */ 145 public XYAreaRendererState(PlotRenderingInfo info) { 146 super(info); 147 this.area = new Polygon(); 148 this.line = new Line2D.Double(); 149 } 150 151 } 152 153 /** Useful constant for specifying the type of rendering (shapes only). */ 154 public static final int SHAPES = 1; 155 156 /** Useful constant for specifying the type of rendering (lines only). */ 157 public static final int LINES = 2; 158 159 /** 160 * Useful constant for specifying the type of rendering (shapes and lines). 161 */ 162 public static final int SHAPES_AND_LINES = 3; 163 164 /** Useful constant for specifying the type of rendering (area only). */ 165 public static final int AREA = 4; 166 167 /** 168 * Useful constant for specifying the type of rendering (area and shapes). 169 */ 170 public static final int AREA_AND_SHAPES = 5; 171 172 /** A flag indicating whether or not shapes are drawn at each XY point. */ 173 private boolean plotShapes; 174 175 /** A flag indicating whether or not lines are drawn between XY points. */ 176 private boolean plotLines; 177 178 /** A flag indicating whether or not Area are drawn at each XY point. */ 179 private boolean plotArea; 180 181 /** A flag that controls whether or not the outline is shown. */ 182 private boolean showOutline; 183 184 /** 185 * The shape used to represent an area in each legend item (this should 186 * never be <code>null</code>). 187 */ 188 private transient Shape legendArea; 189 190 /** 191 * Constructs a new renderer. 192 */ 193 public XYAreaRenderer() { 194 this(AREA); 195 } 196 197 /** 198 * Constructs a new renderer. 199 * 200 * @param type the type of the renderer. 201 */ 202 public XYAreaRenderer(int type) { 203 this(type, null, null); 204 } 205 206 /** 207 * Constructs a new renderer. To specify the type of renderer, use one of 208 * the constants: <code>SHAPES</code>, <code>LINES</code>, 209 * <code>SHAPES_AND_LINES</code>, <code>AREA</code> or 210 * <code>AREA_AND_SHAPES</code>. 211 * 212 * @param type the type of renderer. 213 * @param toolTipGenerator the tool tip generator to use 214 * (<code>null</code> permitted). 215 * @param urlGenerator the URL generator (<code>null</code> permitted). 216 */ 217 public XYAreaRenderer(int type, XYToolTipGenerator toolTipGenerator, 218 XYURLGenerator urlGenerator) { 219 220 super(); 221 setBaseToolTipGenerator(toolTipGenerator); 222 setURLGenerator(urlGenerator); 223 224 if (type == SHAPES) { 225 this.plotShapes = true; 226 } 227 if (type == LINES) { 228 this.plotLines = true; 229 } 230 if (type == SHAPES_AND_LINES) { 231 this.plotShapes = true; 232 this.plotLines = true; 233 } 234 if (type == AREA) { 235 this.plotArea = true; 236 } 237 if (type == AREA_AND_SHAPES) { 238 this.plotArea = true; 239 this.plotShapes = true; 240 } 241 this.showOutline = false; 242 GeneralPath area = new GeneralPath(); 243 area.moveTo(0.0f, -4.0f); 244 area.lineTo(3.0f, -2.0f); 245 area.lineTo(4.0f, 4.0f); 246 area.lineTo(-4.0f, 4.0f); 247 area.lineTo(-3.0f, -2.0f); 248 area.closePath(); 249 this.legendArea = area; 250 251 } 252 253 /** 254 * Returns true if shapes are being plotted by the renderer. 255 * 256 * @return <code>true</code> if shapes are being plotted by the renderer. 257 */ 258 public boolean getPlotShapes() { 259 return this.plotShapes; 260 } 261 262 /** 263 * Returns true if lines are being plotted by the renderer. 264 * 265 * @return <code>true</code> if lines are being plotted by the renderer. 266 */ 267 public boolean getPlotLines() { 268 return this.plotLines; 269 } 270 271 /** 272 * Returns true if Area is being plotted by the renderer. 273 * 274 * @return <code>true</code> if Area is being plotted by the renderer. 275 */ 276 public boolean getPlotArea() { 277 return this.plotArea; 278 } 279 280 /** 281 * Returns a flag that controls whether or not outlines of the areas are 282 * drawn. 283 * 284 * @return The flag. 285 * 286 * @see #setOutline(boolean) 287 */ 288 public boolean isOutline() { 289 return this.showOutline; 290 } 291 292 /** 293 * Sets a flag that controls whether or not outlines of the areas are drawn 294 * and sends a {@link RendererChangeEvent} to all registered listeners. 295 * 296 * @param show the flag. 297 * 298 * @see #isOutline() 299 */ 300 public void setOutline(boolean show) { 301 this.showOutline = show; 302 fireChangeEvent(); 303 } 304 305 /** 306 * Returns the shape used to represent an area in the legend. 307 * 308 * @return The legend area (never <code>null</code>). 309 */ 310 public Shape getLegendArea() { 311 return this.legendArea; 312 } 313 314 /** 315 * Sets the shape used as an area in each legend item and sends a 316 * {@link RendererChangeEvent} to all registered listeners. 317 * 318 * @param area the area (<code>null</code> not permitted). 319 */ 320 public void setLegendArea(Shape area) { 321 if (area == null) { 322 throw new IllegalArgumentException("Null 'area' argument."); 323 } 324 this.legendArea = area; 325 fireChangeEvent(); 326 } 327 328 /** 329 * Initialises the renderer and returns a state object that should be 330 * passed to all subsequent calls to the drawItem() method. 331 * 332 * @param g2 the graphics device. 333 * @param dataArea the area inside the axes. 334 * @param plot the plot. 335 * @param data the data. 336 * @param info an optional info collection object to return data back to 337 * the caller. 338 * 339 * @return A state object for use by the renderer. 340 */ 341 public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, 342 XYPlot plot, XYDataset data, PlotRenderingInfo info) { 343 XYAreaRendererState state = new XYAreaRendererState(info); 344 345 // in the rendering process, there is special handling for item 346 // zero, so we can't support processing of visible data items only 347 state.setProcessVisibleItemsOnly(false); 348 return state; 349 } 350 351 /** 352 * Returns a default legend item for the specified series. Subclasses 353 * should override this method to generate customised items. 354 * 355 * @param datasetIndex the dataset index (zero-based). 356 * @param series the series index (zero-based). 357 * 358 * @return A legend item for the series. 359 */ 360 public LegendItem getLegendItem(int datasetIndex, int series) { 361 LegendItem result = null; 362 XYPlot xyplot = getPlot(); 363 if (xyplot != null) { 364 XYDataset dataset = xyplot.getDataset(datasetIndex); 365 if (dataset != null) { 366 XYSeriesLabelGenerator lg = getLegendItemLabelGenerator(); 367 String label = lg.generateLabel(dataset, series); 368 String description = label; 369 String toolTipText = null; 370 if (getLegendItemToolTipGenerator() != null) { 371 toolTipText = getLegendItemToolTipGenerator().generateLabel( 372 dataset, series); 373 } 374 String urlText = null; 375 if (getLegendItemURLGenerator() != null) { 376 urlText = getLegendItemURLGenerator().generateLabel( 377 dataset, series); 378 } 379 Paint paint = lookupSeriesPaint(series); 380 result = new LegendItem(label, description, toolTipText, 381 urlText, this.legendArea, paint); 382 result.setLabelFont(lookupLegendTextFont(series)); 383 Paint labelPaint = lookupLegendTextPaint(series); 384 if (labelPaint != null) { 385 result.setLabelPaint(labelPaint); 386 } 387 result.setDataset(dataset); 388 result.setDatasetIndex(datasetIndex); 389 result.setSeriesKey(dataset.getSeriesKey(series)); 390 result.setSeriesIndex(series); 391 } 392 } 393 return result; 394 } 395 396 /** 397 * Draws the visual representation of a single data item. 398 * 399 * @param g2 the graphics device. 400 * @param state the renderer state. 401 * @param dataArea the area within which the data is being drawn. 402 * @param info collects information about the drawing. 403 * @param plot the plot (can be used to obtain standard color information 404 * etc). 405 * @param domainAxis the domain axis. 406 * @param rangeAxis the range axis. 407 * @param dataset the dataset. 408 * @param series the series index (zero-based). 409 * @param item the item index (zero-based). 410 * @param crosshairState crosshair information for the plot 411 * (<code>null</code> permitted). 412 * @param pass the pass index. 413 */ 414 public void drawItem(Graphics2D g2, XYItemRendererState state, 415 Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, 416 ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, 417 int series, int item, CrosshairState crosshairState, int pass) { 418 419 if (!getItemVisible(series, item)) { 420 return; 421 } 422 XYAreaRendererState areaState = (XYAreaRendererState) state; 423 424 // get the data point... 425 double x1 = dataset.getXValue(series, item); 426 double y1 = dataset.getYValue(series, item); 427 if (Double.isNaN(y1)) { 428 y1 = 0.0; 429 } 430 double transX1 = domainAxis.valueToJava2D(x1, dataArea, 431 plot.getDomainAxisEdge()); 432 double transY1 = rangeAxis.valueToJava2D(y1, dataArea, 433 plot.getRangeAxisEdge()); 434 435 // get the previous point and the next point so we can calculate a 436 // "hot spot" for the area (used by the chart entity)... 437 int itemCount = dataset.getItemCount(series); 438 double x0 = dataset.getXValue(series, Math.max(item - 1, 0)); 439 double y0 = dataset.getYValue(series, Math.max(item - 1, 0)); 440 if (Double.isNaN(y0)) { 441 y0 = 0.0; 442 } 443 double transX0 = domainAxis.valueToJava2D(x0, dataArea, 444 plot.getDomainAxisEdge()); 445 double transY0 = rangeAxis.valueToJava2D(y0, dataArea, 446 plot.getRangeAxisEdge()); 447 448 double x2 = dataset.getXValue(series, Math.min(item + 1, 449 itemCount - 1)); 450 double y2 = dataset.getYValue(series, Math.min(item + 1, 451 itemCount - 1)); 452 if (Double.isNaN(y2)) { 453 y2 = 0.0; 454 } 455 double transX2 = domainAxis.valueToJava2D(x2, dataArea, 456 plot.getDomainAxisEdge()); 457 double transY2 = rangeAxis.valueToJava2D(y2, dataArea, 458 plot.getRangeAxisEdge()); 459 460 double transZero = rangeAxis.valueToJava2D(0.0, dataArea, 461 plot.getRangeAxisEdge()); 462 Polygon hotspot = null; 463 if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { 464 hotspot = new Polygon(); 465 hotspot.addPoint((int) transZero, 466 (int) ((transX0 + transX1) / 2.0)); 467 hotspot.addPoint((int) ((transY0 + transY1) / 2.0), 468 (int) ((transX0 + transX1) / 2.0)); 469 hotspot.addPoint((int) transY1, (int) transX1); 470 hotspot.addPoint((int) ((transY1 + transY2) / 2.0), 471 (int) ((transX1 + transX2) / 2.0)); 472 hotspot.addPoint((int) transZero, 473 (int) ((transX1 + transX2) / 2.0)); 474 } 475 else { // vertical orientation 476 hotspot = new Polygon(); 477 hotspot.addPoint((int) ((transX0 + transX1) / 2.0), 478 (int) transZero); 479 hotspot.addPoint((int) ((transX0 + transX1) / 2.0), 480 (int) ((transY0 + transY1) / 2.0)); 481 hotspot.addPoint((int) transX1, (int) transY1); 482 hotspot.addPoint((int) ((transX1 + transX2) / 2.0), 483 (int) ((transY1 + transY2) / 2.0)); 484 hotspot.addPoint((int) ((transX1 + transX2) / 2.0), 485 (int) transZero); 486 } 487 488 if (item == 0) { // create a new area polygon for the series 489 areaState.area = new Polygon(); 490 // the first point is (x, 0) 491 double zero = rangeAxis.valueToJava2D(0.0, dataArea, 492 plot.getRangeAxisEdge()); 493 if (plot.getOrientation() == PlotOrientation.VERTICAL) { 494 areaState.area.addPoint((int) transX1, (int) zero); 495 } 496 else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { 497 areaState.area.addPoint((int) zero, (int) transX1); 498 } 499 } 500 501 // Add each point to Area (x, y) 502 if (plot.getOrientation() == PlotOrientation.VERTICAL) { 503 areaState.area.addPoint((int) transX1, (int) transY1); 504 } 505 else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { 506 areaState.area.addPoint((int) transY1, (int) transX1); 507 } 508 509 PlotOrientation orientation = plot.getOrientation(); 510 Paint paint = getItemPaint(series, item); 511 Stroke stroke = getItemStroke(series, item); 512 g2.setPaint(paint); 513 g2.setStroke(stroke); 514 515 Shape shape = null; 516 if (getPlotShapes()) { 517 shape = getItemShape(series, item); 518 if (orientation == PlotOrientation.VERTICAL) { 519 shape = ShapeUtilities.createTranslatedShape(shape, transX1, 520 transY1); 521 } 522 else if (orientation == PlotOrientation.HORIZONTAL) { 523 shape = ShapeUtilities.createTranslatedShape(shape, transY1, 524 transX1); 525 } 526 g2.draw(shape); 527 } 528 529 if (getPlotLines()) { 530 if (item > 0) { 531 if (plot.getOrientation() == PlotOrientation.VERTICAL) { 532 areaState.line.setLine(transX0, transY0, transX1, transY1); 533 } 534 else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { 535 areaState.line.setLine(transY0, transX0, transY1, transX1); 536 } 537 g2.draw(areaState.line); 538 } 539 } 540 541 // Check if the item is the last item for the series. 542 // and number of items > 0. We can't draw an area for a single point. 543 if (getPlotArea() && item > 0 && item == (itemCount - 1)) { 544 545 if (orientation == PlotOrientation.VERTICAL) { 546 // Add the last point (x,0) 547 areaState.area.addPoint((int) transX1, (int) transZero); 548 } 549 else if (orientation == PlotOrientation.HORIZONTAL) { 550 // Add the last point (x,0) 551 areaState.area.addPoint((int) transZero, (int) transX1); 552 } 553 554 g2.fill(areaState.area); 555 556 // draw an outline around the Area. 557 if (isOutline()) { 558 Shape area = areaState.area; 559 560 // Java2D has some issues drawing dashed lines around "large" 561 // geometrical shapes - for example, see bug 6620013 in the 562 // Java bug database. So, we'll check if the outline is 563 // dashed and, if it is, do our own clipping before drawing 564 // the outline... 565 Stroke outlineStroke = lookupSeriesOutlineStroke(series); 566 if (outlineStroke instanceof BasicStroke) { 567 BasicStroke bs = (BasicStroke) outlineStroke; 568 if (bs.getDashArray() != null) { 569 Area poly = new Area(areaState.area); 570 // we make the clip region slightly larger than the 571 // dataArea so that the clipped edges don't show lines 572 // on the chart 573 Area clip = new Area(new Rectangle2D.Double( 574 dataArea.getX() - 5.0, dataArea.getY() - 5.0, 575 dataArea.getWidth() + 10.0, 576 dataArea.getHeight() + 10.0)); 577 poly.intersect(clip); 578 area = poly; 579 } 580 } // end of workaround 581 582 g2.setStroke(outlineStroke); 583 g2.setPaint(lookupSeriesOutlinePaint(series)); 584 g2.draw(area); 585 } 586 } 587 588 int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); 589 int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); 590 updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, 591 rangeAxisIndex, transX1, transY1, orientation); 592 593 // collect entity and tool tip information... 594 EntityCollection entities = state.getEntityCollection(); 595 if (entities != null && hotspot != null) { 596 addEntity(entities, hotspot, dataset, series, item, 0.0, 0.0); 597 } 598 599 } 600 601 /** 602 * Returns a clone of the renderer. 603 * 604 * @return A clone. 605 * 606 * @throws CloneNotSupportedException if the renderer cannot be cloned. 607 */ 608 public Object clone() throws CloneNotSupportedException { 609 XYAreaRenderer clone = (XYAreaRenderer) super.clone(); 610 clone.legendArea = ShapeUtilities.clone(this.legendArea); 611 return clone; 612 } 613 614 /** 615 * Tests this renderer for equality with an arbitrary object. 616 * 617 * @param obj the object (<code>null</code> permitted). 618 * 619 * @return A boolean. 620 */ 621 public boolean equals(Object obj) { 622 if (obj == this) { 623 return true; 624 } 625 if (!(obj instanceof XYAreaRenderer)) { 626 return false; 627 } 628 XYAreaRenderer that = (XYAreaRenderer) obj; 629 if (this.plotArea != that.plotArea) { 630 return false; 631 } 632 if (this.plotLines != that.plotLines) { 633 return false; 634 } 635 if (this.plotShapes != that.plotShapes) { 636 return false; 637 } 638 if (this.showOutline != that.showOutline) { 639 return false; 640 } 641 if (!ShapeUtilities.equal(this.legendArea, that.legendArea)) { 642 return false; 643 } 644 return true; 645 } 646 647 /** 648 * Provides serialization support. 649 * 650 * @param stream the input stream. 651 * 652 * @throws IOException if there is an I/O error. 653 * @throws ClassNotFoundException if there is a classpath problem. 654 */ 655 private void readObject(ObjectInputStream stream) 656 throws IOException, ClassNotFoundException { 657 stream.defaultReadObject(); 658 this.legendArea = SerialUtilities.readShape(stream); 659 } 660 661 /** 662 * Provides serialization support. 663 * 664 * @param stream the output stream. 665 * 666 * @throws IOException if there is an I/O error. 667 */ 668 private void writeObject(ObjectOutputStream stream) throws IOException { 669 stream.defaultWriteObject(); 670 SerialUtilities.writeShape(this.legendArea, stream); 671 } 672 }