Source for org.jfree.chart.LegendItem

   1: /* ===========================================================
   2:  * JFreeChart : a free chart library for the Java(tm) platform
   3:  * ===========================================================
   4:  *
   5:  * (C) Copyright 2000-2006, by Object Refinery Limited and Contributors.
   6:  *
   7:  * Project Info:  http://www.jfree.org/jfreechart/index.html
   8:  *
   9:  * This library is free software; you can redistribute it and/or modify it 
  10:  * under the terms of the GNU Lesser General Public License as published by 
  11:  * the Free Software Foundation; either version 2.1 of the License, or 
  12:  * (at your option) any later version.
  13:  *
  14:  * This library is distributed in the hope that it will be useful, but 
  15:  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
  16:  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
  17:  * License for more details.
  18:  *
  19:  * You should have received a copy of the GNU Lesser General Public
  20:  * License along with this library; if not, write to the Free Software
  21:  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
  22:  * USA.  
  23:  *
  24:  * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
  25:  * in the United States and other countries.]
  26:  *
  27:  * ---------------
  28:  * LegendItem.java
  29:  * ---------------
  30:  * (C) Copyright 2000-2006, by Object Refinery Limited and Contributors.
  31:  *
  32:  * Original Author:  David Gilbert (for Object Refinery Limited);
  33:  * Contributor(s):   Andrzej Porebski;
  34:  *                   David Li;
  35:  *                   Wolfgang Irler;
  36:  *                   Luke Quinane;
  37:  *
  38:  * $Id: LegendItem.java,v 1.9.2.5 2006/07/20 16:21:58 mungady Exp $
  39:  *
  40:  * Changes (from 2-Oct-2002)
  41:  * -------------------------
  42:  * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG);
  43:  * 17-Jan-2003 : Dropped outlineStroke attribute (DG);
  44:  * 08-Oct-2003 : Applied patch for displaying series line style, contributed by
  45:  *               Luke Quinane (DG);
  46:  * 21-Jan-2004 : Added the shapeFilled flag (DG);
  47:  * 04-Jun-2004 : Added equals() method, implemented Serializable (DG);
  48:  * 25-Nov-2004 : Changes required by new LegendTitle implementation (DG);
  49:  * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 
  50:  *               release (DG);
  51:  * 20-Apr-2005 : Added tooltip and URL text (DG);
  52:  * 28-Nov-2005 : Separated constructors for AttributedString labels (DG);
  53:  * 10-Dec-2005 : Fixed serialization bug (1377239) (DG);
  54:  * ------------- JFREECHART 1.0.0 ---------------------------------------------
  55:  * 20-Jul-2006 : Added dataset and series index fields (DG);
  56:  *
  57:  */
  58: 
  59: package org.jfree.chart;
  60: 
  61: import java.awt.BasicStroke;
  62: import java.awt.Color;
  63: import java.awt.Paint;
  64: import java.awt.Shape;
  65: import java.awt.Stroke;
  66: import java.awt.geom.Line2D;
  67: import java.io.IOException;
  68: import java.io.ObjectInputStream;
  69: import java.io.ObjectOutputStream;
  70: import java.io.Serializable;
  71: import java.text.AttributedString;
  72: import java.text.CharacterIterator;
  73: 
  74: import org.jfree.io.SerialUtilities;
  75: import org.jfree.util.AttributedStringUtilities;
  76: import org.jfree.util.ObjectUtilities;
  77: import org.jfree.util.ShapeUtilities;
  78: 
  79: /**
  80:  * A storage object for recording the properties of a legend item, without any 
  81:  * consideration for layout issues.  Instances of this class are immutable.
  82:  */
  83: public class LegendItem implements Serializable {
  84: 
  85:     // TODO:  keeping this class immutable is becoming a lot of overhead, need 
  86:     // to look at the consequences of dropping immutability
  87: 
  88:     /** For serialization. */
  89:     private static final long serialVersionUID = -797214582948827144L;
  90:     
  91:     /** The dataset index. */
  92:     private int datasetIndex;
  93:     
  94:     /** The series index. */
  95:     private int series;
  96:     
  97:     /** The label. */
  98:     private String label;
  99:     
 100:     /** The attributed label (if null, fall back to the regular label). */
 101:     private transient AttributedString attributedLabel;
 102: 
 103:     /** 
 104:      * The description (not currently used - could be displayed as a tool tip). 
 105:      */
 106:     private String description;
 107:     
 108:     /** The tool tip text. */
 109:     private String toolTipText;
 110:     
 111:     /** The url text. */
 112:     private String urlText;
 113: 
 114:     /** A flag that controls whether or not the shape is visible. */
 115:     private boolean shapeVisible;
 116:     
 117:     /** The shape. */
 118:     private transient Shape shape;
 119:     
 120:     /** A flag that controls whether or not the shape is filled. */
 121:     private boolean shapeFilled;
 122: 
 123:     /** The paint. */
 124:     private transient Paint fillPaint;
 125:     
 126:     /** A flag that controls whether or not the shape outline is visible. */
 127:     private boolean shapeOutlineVisible;
 128:     
 129:     /** The outline paint. */
 130:     private transient Paint outlinePaint;
 131:     
 132:     /** The outline stroke. */
 133:     private transient Stroke outlineStroke;
 134: 
 135:     /** A flag that controls whether or not the line is visible. */
 136:     private boolean lineVisible;
 137:     
 138:     /** The line. */
 139:     private transient Shape line;
 140:     
 141:     /** The stroke. */
 142:     private transient Stroke lineStroke;
 143:     
 144:     /** The line paint. */
 145:     private transient Paint linePaint;
 146: 
 147:     /**
 148:      * The shape must be non-null for a LegendItem - if no shape is required,
 149:      * use this.
 150:      */
 151:     private static final Shape UNUSED_SHAPE = new Line2D.Float();
 152:     
 153:     /**
 154:      * The stroke must be non-null for a LegendItem - if no stroke is required,
 155:      * use this.
 156:      */
 157:     private static final Stroke UNUSED_STROKE = new BasicStroke(0.0f);
 158:     
 159:     /**
 160:      * Creates a legend item with a filled shape.  The shape is not outlined,
 161:      * and no line is visible.
 162:      * 
 163:      * @param label  the label (<code>null</code> not permitted).
 164:      * @param description  the description (<code>null</code> permitted).
 165:      * @param toolTipText  the tool tip text (<code>null</code> permitted).
 166:      * @param urlText  the URL text (<code>null</code> permitted).
 167:      * @param shape  the shape (<code>null</code> not permitted).
 168:      * @param fillPaint  the paint used to fill the shape (<code>null</code>
 169:      *                   not permitted).
 170:      */
 171:     public LegendItem(String label, String description, 
 172:                       String toolTipText, String urlText, 
 173:                       Shape shape, Paint fillPaint) {
 174:         
 175:         this(label, description, toolTipText, urlText, 
 176:                 /* shape visible = */ true, shape, 
 177:                 /* shape filled = */ true, fillPaint, 
 178:                 /* shape outlined */ false, Color.black, UNUSED_STROKE,
 179:                 /* line visible */ false, UNUSED_SHAPE, UNUSED_STROKE,
 180:                 Color.black);
 181: 
 182:     }
 183:     
 184:     /**
 185:      * Creates a legend item with a filled and outlined shape.
 186:      * 
 187:      * @param label  the label (<code>null</code> not permitted).
 188:      * @param description  the description (<code>null</code> permitted).
 189:      * @param toolTipText  the tool tip text (<code>null</code> permitted).
 190:      * @param urlText  the URL text (<code>null</code> permitted).
 191:      * @param shape  the shape (<code>null</code> not permitted).
 192:      * @param fillPaint  the paint used to fill the shape (<code>null</code>
 193:      *                   not permitted).
 194:      * @param outlineStroke  the outline stroke (<code>null</code> not 
 195:      *                       permitted).
 196:      * @param outlinePaint  the outline paint (<code>null</code> not 
 197:      *                      permitted).
 198:      */
 199:     public LegendItem(String label, String description, 
 200:                       String toolTipText, String urlText, 
 201:                       Shape shape, Paint fillPaint, 
 202:                       Stroke outlineStroke, Paint outlinePaint) {
 203:         
 204:         this(label, description, toolTipText, urlText,
 205:                 /* shape visible = */ true, shape, 
 206:                 /* shape filled = */ true, fillPaint, 
 207:                 /* shape outlined = */ true, outlinePaint, outlineStroke,
 208:                 /* line visible */ false, UNUSED_SHAPE, UNUSED_STROKE,
 209:                 Color.black);
 210: 
 211:     }
 212:     
 213:     /**
 214:      * Creates a legend item using a line.
 215:      * 
 216:      * @param label  the label (<code>null</code> not permitted).
 217:      * @param description  the description (<code>null</code> permitted).
 218:      * @param toolTipText  the tool tip text (<code>null</code> permitted).
 219:      * @param urlText  the URL text (<code>null</code> permitted).
 220:      * @param line  the line (<code>null</code> not permitted).
 221:      * @param lineStroke  the line stroke (<code>null</code> not permitted).
 222:      * @param linePaint  the line paint (<code>null</code> not permitted).
 223:      */
 224:     public LegendItem(String label, String description, 
 225:                       String toolTipText, String urlText, 
 226:                       Shape line, Stroke lineStroke, Paint linePaint) {
 227:         
 228:         this(label, description, toolTipText, urlText,
 229:                 /* shape visible = */ false, UNUSED_SHAPE,
 230:                 /* shape filled = */ false, Color.black,
 231:                 /* shape outlined = */ false, Color.black, UNUSED_STROKE,
 232:                 /* line visible = */ true, line, lineStroke, linePaint);
 233:     }
 234:     
 235:     /**
 236:      * Creates a new legend item.
 237:      *
 238:      * @param label  the label (<code>null</code> not permitted).
 239:      * @param description  the description (not currently used, 
 240:      *        <code>null</code> permitted).
 241:      * @param toolTipText  the tool tip text (<code>null</code> permitted).
 242:      * @param urlText  the URL text (<code>null</code> permitted).
 243:      * @param shapeVisible  a flag that controls whether or not the shape is 
 244:      *                      displayed.
 245:      * @param shape  the shape (<code>null</code> permitted).
 246:      * @param shapeFilled  a flag that controls whether or not the shape is 
 247:      *                     filled.
 248:      * @param fillPaint  the fill paint (<code>null</code> not permitted).
 249:      * @param shapeOutlineVisible  a flag that controls whether or not the 
 250:      *                             shape is outlined.
 251:      * @param outlinePaint  the outline paint (<code>null</code> not permitted).
 252:      * @param outlineStroke  the outline stroke (<code>null</code> not 
 253:      *                       permitted).
 254:      * @param lineVisible  a flag that controls whether or not the line is 
 255:      *                     visible.
 256:      * @param line  the line.
 257:      * @param lineStroke  the stroke (<code>null</code> not permitted).
 258:      * @param linePaint  the line paint (<code>null</code> not permitted).
 259:      */
 260:     public LegendItem(String label, String description,
 261:                       String toolTipText, String urlText,
 262:                       boolean shapeVisible, Shape shape,
 263:                       boolean shapeFilled, Paint fillPaint, 
 264:                       boolean shapeOutlineVisible, Paint outlinePaint,
 265:                       Stroke outlineStroke,
 266:                       boolean lineVisible, Shape line,
 267:                       Stroke lineStroke, Paint linePaint) {
 268:         
 269:         if (label == null) {
 270:             throw new IllegalArgumentException("Null 'label' argument.");   
 271:         }
 272:         if (fillPaint == null) {
 273:             throw new IllegalArgumentException("Null 'fillPaint' argument.");   
 274:         }
 275:         if (lineStroke == null) {
 276:             throw new IllegalArgumentException("Null 'lineStroke' argument.");
 277:         }
 278:         if (outlinePaint == null) {
 279:             throw new IllegalArgumentException("Null 'outlinePaint' argument.");
 280:         }
 281:         if (outlineStroke == null) {
 282:             throw new IllegalArgumentException(
 283:                     "Null 'outlineStroke' argument.");   
 284:         }
 285:         this.label = label;
 286:         this.attributedLabel = null;
 287:         this.description = description;
 288:         this.shapeVisible = shapeVisible;
 289:         this.shape = shape;
 290:         this.shapeFilled = shapeFilled;
 291:         this.fillPaint = fillPaint;
 292:         this.shapeOutlineVisible = shapeOutlineVisible;
 293:         this.outlinePaint = outlinePaint;
 294:         this.outlineStroke = outlineStroke;
 295:         this.lineVisible = lineVisible;
 296:         this.line = line;
 297:         this.lineStroke = lineStroke;
 298:         this.linePaint = linePaint;
 299:         this.toolTipText = toolTipText;
 300:         this.urlText = urlText;
 301:     }
 302:     
 303:     /**
 304:      * Creates a legend item with a filled shape.  The shape is not outlined,
 305:      * and no line is visible.
 306:      * 
 307:      * @param label  the label (<code>null</code> not permitted).
 308:      * @param description  the description (<code>null</code> permitted).
 309:      * @param toolTipText  the tool tip text (<code>null</code> permitted).
 310:      * @param urlText  the URL text (<code>null</code> permitted).
 311:      * @param shape  the shape (<code>null</code> not permitted).
 312:      * @param fillPaint  the paint used to fill the shape (<code>null</code>
 313:      *                   not permitted).
 314:      */
 315:     public LegendItem(AttributedString label, String description, 
 316:                       String toolTipText, String urlText, 
 317:                       Shape shape, Paint fillPaint) {
 318:         
 319:         this(label, description, toolTipText, urlText, 
 320:                 /* shape visible = */ true, shape,
 321:                 /* shape filled = */ true, fillPaint,
 322:                 /* shape outlined = */ false, Color.black, UNUSED_STROKE,
 323:                 /* line visible = */ false, UNUSED_SHAPE, UNUSED_STROKE,
 324:                 Color.black);
 325:         
 326:     }
 327:     
 328:     /**
 329:      * Creates a legend item with a filled and outlined shape.
 330:      * 
 331:      * @param label  the label (<code>null</code> not permitted).
 332:      * @param description  the description (<code>null</code> permitted).
 333:      * @param toolTipText  the tool tip text (<code>null</code> permitted).
 334:      * @param urlText  the URL text (<code>null</code> permitted).
 335:      * @param shape  the shape (<code>null</code> not permitted).
 336:      * @param fillPaint  the paint used to fill the shape (<code>null</code>
 337:      *                   not permitted).
 338:      * @param outlineStroke  the outline stroke (<code>null</code> not 
 339:      *                       permitted).
 340:      * @param outlinePaint  the outline paint (<code>null</code> not 
 341:      *                      permitted).
 342:      */
 343:     public LegendItem(AttributedString label, String description, 
 344:                       String toolTipText, String urlText, 
 345:                       Shape shape, Paint fillPaint, 
 346:                       Stroke outlineStroke, Paint outlinePaint) {
 347:         
 348:         this(label, description, toolTipText, urlText,
 349:                 /* shape visible = */ true, shape,
 350:                 /* shape filled = */ true, fillPaint,
 351:                 /* shape outlined = */ true, outlinePaint, outlineStroke,
 352:                 /* line visible = */ false, UNUSED_SHAPE, UNUSED_STROKE,
 353:                 Color.black);
 354:     }
 355:     
 356:     /**
 357:      * Creates a legend item using a line.
 358:      * 
 359:      * @param label  the label (<code>null</code> not permitted).
 360:      * @param description  the description (<code>null</code> permitted).
 361:      * @param toolTipText  the tool tip text (<code>null</code> permitted).
 362:      * @param urlText  the URL text (<code>null</code> permitted).
 363:      * @param line  the line (<code>null</code> not permitted).
 364:      * @param lineStroke  the line stroke (<code>null</code> not permitted).
 365:      * @param linePaint  the line paint (<code>null</code> not permitted).
 366:      */
 367:     public LegendItem(AttributedString label, String description, 
 368:                       String toolTipText, String urlText, 
 369:                       Shape line, Stroke lineStroke, Paint linePaint) {
 370:         
 371:         this(label, description, toolTipText, urlText,
 372:                 /* shape visible = */ false, UNUSED_SHAPE,
 373:                 /* shape filled = */ false, Color.black,
 374:                 /* shape outlined = */ false, Color.black, UNUSED_STROKE,
 375:                 /* line visible = */ true, line, lineStroke, linePaint
 376:         );
 377:     }
 378:     
 379:     /**
 380:      * Creates a new legend item.
 381:      *
 382:      * @param label  the label (<code>null</code> not permitted).
 383:      * @param description  the description (not currently used, 
 384:      *        <code>null</code> permitted).
 385:      * @param toolTipText  the tool tip text (<code>null</code> permitted).
 386:      * @param urlText  the URL text (<code>null</code> permitted).
 387:      * @param shapeVisible  a flag that controls whether or not the shape is 
 388:      *                      displayed.
 389:      * @param shape  the shape (<code>null</code> permitted).
 390:      * @param shapeFilled  a flag that controls whether or not the shape is 
 391:      *                     filled.
 392:      * @param fillPaint  the fill paint (<code>null</code> not permitted).
 393:      * @param shapeOutlineVisible  a flag that controls whether or not the 
 394:      *                             shape is outlined.
 395:      * @param outlinePaint  the outline paint (<code>null</code> not permitted).
 396:      * @param outlineStroke  the outline stroke (<code>null</code> not 
 397:      *                       permitted).
 398:      * @param lineVisible  a flag that controls whether or not the line is 
 399:      *                     visible.
 400:      * @param line  the line.
 401:      * @param lineStroke  the stroke (<code>null</code> not permitted).
 402:      * @param linePaint  the line paint (<code>null</code> not permitted).
 403:      */
 404:     public LegendItem(AttributedString label, String description,
 405:                       String toolTipText, String urlText,
 406:                       boolean shapeVisible, Shape shape,
 407:                       boolean shapeFilled, Paint fillPaint, 
 408:                       boolean shapeOutlineVisible, Paint outlinePaint,
 409:                       Stroke outlineStroke,
 410:                       boolean lineVisible, Shape line, Stroke lineStroke,
 411:                       Paint linePaint) {
 412:         
 413:         if (label == null) {
 414:             throw new IllegalArgumentException("Null 'label' argument.");   
 415:         }
 416:         if (fillPaint == null) {
 417:             throw new IllegalArgumentException("Null 'fillPaint' argument.");   
 418:         }
 419:         if (lineStroke == null) {
 420:             throw new IllegalArgumentException("Null 'lineStroke' argument.");
 421:         }
 422:         if (outlinePaint == null) {
 423:             throw new IllegalArgumentException("Null 'outlinePaint' argument.");
 424:         }
 425:         if (outlineStroke == null) {
 426:             throw new IllegalArgumentException(
 427:                 "Null 'outlineStroke' argument.");   
 428:         }
 429:         this.label = characterIteratorToString(label.getIterator());
 430:         this.attributedLabel = label;
 431:         this.description = description;
 432:         this.shapeVisible = shapeVisible;
 433:         this.shape = shape;
 434:         this.shapeFilled = shapeFilled;
 435:         this.fillPaint = fillPaint;
 436:         this.shapeOutlineVisible = shapeOutlineVisible;
 437:         this.outlinePaint = outlinePaint;
 438:         this.outlineStroke = outlineStroke;
 439:         this.lineVisible = lineVisible;
 440:         this.line = line;
 441:         this.lineStroke = lineStroke;
 442:         this.linePaint = linePaint;
 443:         this.toolTipText = toolTipText;
 444:         this.urlText = urlText;
 445:     }
 446: 
 447:     /**
 448:      * Returns a string containing the characters from the given iterator.
 449:      * 
 450:      * @param iterator  the iterator (<code>null</code> not permitted).
 451:      * 
 452:      * @return A string.
 453:      */
 454:     private String characterIteratorToString(CharacterIterator iterator) {
 455:         int endIndex = iterator.getEndIndex();
 456:         int beginIndex = iterator.getBeginIndex();
 457:         int count = endIndex - beginIndex;
 458:         if (count <= 0) {
 459:             return "";
 460:         }
 461:         char[] chars = new char[count];
 462:         int i = 0;
 463:         char c = iterator.first();
 464:         while (c != CharacterIterator.DONE) {
 465:             chars[i] = c;
 466:             i++;
 467:             c = iterator.next();
 468:         }
 469:         return new String(chars);
 470:     }
 471:     
 472:     /**
 473:      * Returns the dataset index for this legend item.
 474:      * 
 475:      * @return The dataset index.
 476:      * 
 477:      * @since 1.0.2
 478:      */
 479:     public int getDatasetIndex() {
 480:         return this.datasetIndex;
 481:     }
 482:     
 483:     /**
 484:      * Sets the dataset index for this legend item.
 485:      * 
 486:      * @param index  the index.
 487:      * 
 488:      * @since 1.0.2
 489:      */
 490:     public void setDatasetIndex(int index) {
 491:         this.datasetIndex = index;
 492:     }
 493:     
 494:     /**
 495:      * Returns the series index for this legend item.
 496:      * 
 497:      * @return The series index.
 498:      * 
 499:      * @since 1.0.2
 500:      */
 501:     public int getSeriesIndex() {
 502:         return this.series;
 503:     }
 504:     
 505:     /**
 506:      * Sets the series index for this legend item.
 507:      * 
 508:      * @param index  the index.
 509:      * 
 510:      * @since 1.0.2
 511:      */
 512:     public void setSeriesIndex(int index) {
 513:         this.series = index;
 514:     }
 515:     
 516:     /**
 517:      * Returns the label.
 518:      *
 519:      * @return The label (never <code>null</code>).
 520:      */
 521:     public String getLabel() {
 522:         return this.label;
 523:     }
 524: 
 525:     /**
 526:      * Returns the attributed label.
 527:      *
 528:      * @return The attributed label (possibly <code>null</code>).
 529:      */
 530:     public AttributedString getAttributedLabel() {
 531:         return this.attributedLabel;
 532:     }
 533: 
 534:     /**
 535:      * Returns the description for the legend item.
 536:      * 
 537:      * @return The description.
 538:      */
 539:     public String getDescription() {
 540:         return this.description;   
 541:     }
 542:     
 543:     /**
 544:      * Returns the tool tip text.
 545:      * 
 546:      * @return The tool tip text (possibly <code>null</code>).
 547:      */
 548:     public String getToolTipText() {
 549:         return this.toolTipText;   
 550:     }
 551:     
 552:     /**
 553:      * Returns the URL text.
 554:      * 
 555:      * @return The URL text (possibly <code>null</code>).
 556:      */
 557:     public String getURLText() {
 558:         return this.urlText; 
 559:     }
 560:     
 561:     /**
 562:      * Returns a flag that indicates whether or not the shape is visible.
 563:      * 
 564:      * @return A boolean.
 565:      */
 566:     public boolean isShapeVisible() {
 567:         return this.shapeVisible;
 568:     }
 569:     
 570:     /**
 571:      * Returns the shape used to label the series represented by this legend 
 572:      * item.
 573:      *
 574:      * @return The shape (never <code>null</code>).
 575:      */
 576:     public Shape getShape() {
 577:         return this.shape;
 578:     }
 579:     
 580:     /**
 581:      * Returns a flag that controls whether or not the shape is filled.
 582:      * 
 583:      * @return A boolean.
 584:      */
 585:     public boolean isShapeFilled() {
 586:         return this.shapeFilled;
 587:     }
 588: 
 589:     /**
 590:      * Returns the fill paint.
 591:      *
 592:      * @return The fill paint (never <code>null</code>).
 593:      */
 594:     public Paint getFillPaint() {
 595:         return this.fillPaint;
 596:     }
 597: 
 598:     /**
 599:      * Returns the flag that controls whether or not the shape outline
 600:      * is visible.
 601:      * 
 602:      * @return A boolean.
 603:      */
 604:     public boolean isShapeOutlineVisible() {
 605:         return this.shapeOutlineVisible;
 606:     }
 607:     
 608:     /**
 609:      * Returns the line stroke for the series.
 610:      *
 611:      * @return The stroke (never <code>null</code>).
 612:      */
 613:     public Stroke getLineStroke() {
 614:         return this.lineStroke;
 615:     }
 616:     
 617:     /**
 618:      * Returns the paint used for lines.
 619:      * 
 620:      * @return The paint.
 621:      */
 622:     public Paint getLinePaint() {
 623:         return this.linePaint;
 624:     }
 625:     
 626:     /**
 627:      * Returns the outline paint.
 628:      *
 629:      * @return The outline paint (never <code>null</code>).
 630:      */
 631:     public Paint getOutlinePaint() {
 632:         return this.outlinePaint;
 633:     }
 634: 
 635:     /**
 636:      * Returns the outline stroke.
 637:      *
 638:      * @return The outline stroke (never <code>null</code>).
 639:      */
 640:     public Stroke getOutlineStroke() {
 641:         return this.outlineStroke;
 642:     }
 643:     
 644:     /**
 645:      * Returns a flag that indicates whether or not the line is visible.
 646:      * 
 647:      * @return A boolean.
 648:      */
 649:     public boolean isLineVisible() {
 650:         return this.lineVisible;
 651:     }
 652:     
 653:     /**
 654:      * Returns the line.
 655:      * 
 656:      * @return The line.
 657:      */
 658:     public Shape getLine() {
 659:         return this.line;
 660:     }
 661:     
 662:     /**
 663:      * Tests this item for equality with an arbitrary object.
 664:      * 
 665:      * @param obj  the object (<code>null</code> permitted).
 666:      * 
 667:      * @return A boolean.
 668:      */
 669:     public boolean equals(Object obj) {
 670:         if (obj == this) {
 671:             return true;   
 672:         }
 673:         if (!(obj instanceof LegendItem)) {
 674:                 return false;
 675:         }
 676:         LegendItem that = (LegendItem) obj;
 677:         if (this.datasetIndex != that.datasetIndex) {
 678:             return false;
 679:         }
 680:         if (this.series != that.series) {
 681:             return false;
 682:         }
 683:         if (!this.label.equals(that.label)) {
 684:             return false;
 685:         }
 686:         if (!AttributedStringUtilities.equal(this.attributedLabel, 
 687:                 that.attributedLabel)) {
 688:             return false;
 689:         }
 690:         if (!ObjectUtilities.equal(this.description, that.description)) {
 691:             return false;
 692:         }
 693:         if (this.shapeVisible != that.shapeVisible) {
 694:             return false;
 695:         }
 696:         if (!ShapeUtilities.equal(this.shape, that.shape)) {
 697:             return false;
 698:         }
 699:         if (this.shapeFilled != that.shapeFilled) {
 700:             return false;
 701:         }
 702:         if (!this.fillPaint.equals(that.fillPaint)) {
 703:             return false;   
 704:         }
 705:         if (this.shapeOutlineVisible != that.shapeOutlineVisible) {
 706:             return false;
 707:         }
 708:         if (!this.outlineStroke.equals(that.outlineStroke)) {
 709:             return false;   
 710:         }
 711:         if (!this.outlinePaint.equals(that.outlinePaint)) {
 712:             return false;   
 713:         }
 714:         if (!this.lineVisible == that.lineVisible) {
 715:             return false;
 716:         }
 717:         if (!ShapeUtilities.equal(this.line, that.line)) {
 718:             return false;
 719:         }
 720:         if (!this.lineStroke.equals(that.lineStroke)) {
 721:             return false;   
 722:         }
 723:         if (!this.linePaint.equals(that.linePaint)) {
 724:             return false;
 725:         }
 726:         return true;
 727:     }
 728:     
 729:     /**
 730:      * Provides serialization support.
 731:      *
 732:      * @param stream  the output stream (<code>null</code> not permitted).
 733:      *
 734:      * @throws IOException  if there is an I/O error.
 735:      */
 736:     private void writeObject(ObjectOutputStream stream) throws IOException {
 737:         stream.defaultWriteObject();
 738:         SerialUtilities.writeAttributedString(this.attributedLabel, stream);
 739:         SerialUtilities.writeShape(this.shape, stream);
 740:         SerialUtilities.writePaint(this.fillPaint, stream);
 741:         SerialUtilities.writeStroke(this.outlineStroke, stream);
 742:         SerialUtilities.writePaint(this.outlinePaint, stream);
 743:         SerialUtilities.writeShape(this.line, stream);
 744:         SerialUtilities.writeStroke(this.lineStroke, stream);
 745:         SerialUtilities.writePaint(this.linePaint, stream);
 746:     }
 747: 
 748:     /**
 749:      * Provides serialization support.
 750:      *
 751:      * @param stream  the input stream (<code>null</code> not permitted).
 752:      *
 753:      * @throws IOException  if there is an I/O error.
 754:      * @throws ClassNotFoundException  if there is a classpath problem.
 755:      */
 756:     private void readObject(ObjectInputStream stream) 
 757:         throws IOException, ClassNotFoundException {
 758:         stream.defaultReadObject();
 759:         this.attributedLabel = SerialUtilities.readAttributedString(stream);
 760:         this.shape = SerialUtilities.readShape(stream);
 761:         this.fillPaint = SerialUtilities.readPaint(stream);
 762:         this.outlineStroke = SerialUtilities.readStroke(stream);
 763:         this.outlinePaint = SerialUtilities.readPaint(stream);
 764:         this.line = SerialUtilities.readShape(stream);
 765:         this.lineStroke = SerialUtilities.readStroke(stream);
 766:         this.linePaint = SerialUtilities.readPaint(stream);
 767:     }
 768:     
 769: }