001: /* ===========================================================
002: * JFreeChart : a free chart library for the Java(tm) platform
003: * ===========================================================
004: *
005: * (C) Copyright 2000-2007, 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: * LegendItem.java
029: * ---------------
030: * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
031: *
032: * Original Author: David Gilbert (for Object Refinery Limited);
033: * Contributor(s): Andrzej Porebski;
034: * David Li;
035: * Wolfgang Irler;
036: * Luke Quinane;
037: *
038: * $Id: LegendItem.java,v 1.9.2.7 2007/05/18 10:28:17 mungady Exp $
039: *
040: * Changes (from 2-Oct-2002)
041: * -------------------------
042: * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG);
043: * 17-Jan-2003 : Dropped outlineStroke attribute (DG);
044: * 08-Oct-2003 : Applied patch for displaying series line style, contributed by
045: * Luke Quinane (DG);
046: * 21-Jan-2004 : Added the shapeFilled flag (DG);
047: * 04-Jun-2004 : Added equals() method, implemented Serializable (DG);
048: * 25-Nov-2004 : Changes required by new LegendTitle implementation (DG);
049: * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0
050: * release (DG);
051: * 20-Apr-2005 : Added tooltip and URL text (DG);
052: * 28-Nov-2005 : Separated constructors for AttributedString labels (DG);
053: * 10-Dec-2005 : Fixed serialization bug (1377239) (DG);
054: * ------------- JFREECHART 1.0.x ---------------------------------------------
055: * 20-Jul-2006 : Added dataset and series index fields (DG);
056: * 13-Dec-2006 : Added fillPaintTransformer attribute (DG);
057: * 18-May-2007 : Added dataset and seriesKey fields (DG);
058: *
059: */
060:
061: package org.jfree.chart;
062:
063: import java.awt.BasicStroke;
064: import java.awt.Color;
065: import java.awt.Paint;
066: import java.awt.Shape;
067: import java.awt.Stroke;
068: import java.awt.geom.Line2D;
069: import java.io.IOException;
070: import java.io.ObjectInputStream;
071: import java.io.ObjectOutputStream;
072: import java.io.Serializable;
073: import java.text.AttributedString;
074: import java.text.CharacterIterator;
075:
076: import org.jfree.data.general.Dataset;
077: import org.jfree.io.SerialUtilities;
078: import org.jfree.ui.GradientPaintTransformer;
079: import org.jfree.ui.StandardGradientPaintTransformer;
080: import org.jfree.util.AttributedStringUtilities;
081: import org.jfree.util.ObjectUtilities;
082: import org.jfree.util.ShapeUtilities;
083:
084: /**
085: * A temporary storage object for recording the properties of a legend item,
086: * without any consideration for layout issues.
087: */
088: public class LegendItem implements Serializable {
089:
090: /** For serialization. */
091: private static final long serialVersionUID = -797214582948827144L;
092:
093: /**
094: * The dataset.
095: *
096: * @since 1.0.6
097: */
098: private Dataset dataset;
099:
100: /**
101: * The series key.
102: *
103: * @since 1.0.6
104: */
105: private Comparable seriesKey;
106:
107: /** The dataset index. */
108: private int datasetIndex;
109:
110: /** The series index. */
111: private int series;
112:
113: /** The label. */
114: private String label;
115:
116: /** The attributed label (if null, fall back to the regular label). */
117: private transient AttributedString attributedLabel;
118:
119: /**
120: * The description (not currently used - could be displayed as a tool tip).
121: */
122: private String description;
123:
124: /** The tool tip text. */
125: private String toolTipText;
126:
127: /** The url text. */
128: private String urlText;
129:
130: /** A flag that controls whether or not the shape is visible. */
131: private boolean shapeVisible;
132:
133: /** The shape. */
134: private transient Shape shape;
135:
136: /** A flag that controls whether or not the shape is filled. */
137: private boolean shapeFilled;
138:
139: /** The paint. */
140: private transient Paint fillPaint;
141:
142: /**
143: * A gradient paint transformer.
144: *
145: * @since 1.0.4
146: */
147: private GradientPaintTransformer fillPaintTransformer;
148:
149: /** A flag that controls whether or not the shape outline is visible. */
150: private boolean shapeOutlineVisible;
151:
152: /** The outline paint. */
153: private transient Paint outlinePaint;
154:
155: /** The outline stroke. */
156: private transient Stroke outlineStroke;
157:
158: /** A flag that controls whether or not the line is visible. */
159: private boolean lineVisible;
160:
161: /** The line. */
162: private transient Shape line;
163:
164: /** The stroke. */
165: private transient Stroke lineStroke;
166:
167: /** The line paint. */
168: private transient Paint linePaint;
169:
170: /**
171: * The shape must be non-null for a LegendItem - if no shape is required,
172: * use this.
173: */
174: private static final Shape UNUSED_SHAPE = new Line2D.Float();
175:
176: /**
177: * The stroke must be non-null for a LegendItem - if no stroke is required,
178: * use this.
179: */
180: private static final Stroke UNUSED_STROKE = new BasicStroke(0.0f);
181:
182: /**
183: * Creates a legend item with a filled shape. The shape is not outlined,
184: * and no line is visible.
185: *
186: * @param label the label (<code>null</code> not permitted).
187: * @param description the description (<code>null</code> permitted).
188: * @param toolTipText the tool tip text (<code>null</code> permitted).
189: * @param urlText the URL text (<code>null</code> permitted).
190: * @param shape the shape (<code>null</code> not permitted).
191: * @param fillPaint the paint used to fill the shape (<code>null</code>
192: * not permitted).
193: */
194: public LegendItem(String label, String description,
195: String toolTipText, String urlText, Shape shape,
196: Paint fillPaint) {
197:
198: this (label, description, toolTipText, urlText,
199: /* shape visible = */true, shape,
200: /* shape filled = */true, fillPaint,
201: /* shape outlined */false, Color.black, UNUSED_STROKE,
202: /* line visible */false, UNUSED_SHAPE, UNUSED_STROKE,
203: Color.black);
204:
205: }
206:
207: /**
208: * Creates a legend item with a filled and outlined shape.
209: *
210: * @param label the label (<code>null</code> not permitted).
211: * @param description the description (<code>null</code> permitted).
212: * @param toolTipText the tool tip text (<code>null</code> permitted).
213: * @param urlText the URL text (<code>null</code> permitted).
214: * @param shape the shape (<code>null</code> not permitted).
215: * @param fillPaint the paint used to fill the shape (<code>null</code>
216: * not permitted).
217: * @param outlineStroke the outline stroke (<code>null</code> not
218: * permitted).
219: * @param outlinePaint the outline paint (<code>null</code> not
220: * permitted).
221: */
222: public LegendItem(String label, String description,
223: String toolTipText, String urlText, Shape shape,
224: Paint fillPaint, Stroke outlineStroke, Paint outlinePaint) {
225:
226: this (label, description, toolTipText, urlText,
227: /* shape visible = */true, shape,
228: /* shape filled = */true, fillPaint,
229: /* shape outlined = */true, outlinePaint, outlineStroke,
230: /* line visible */false, UNUSED_SHAPE, UNUSED_STROKE,
231: Color.black);
232:
233: }
234:
235: /**
236: * Creates a legend item using a line.
237: *
238: * @param label the label (<code>null</code> not permitted).
239: * @param description the description (<code>null</code> permitted).
240: * @param toolTipText the tool tip text (<code>null</code> permitted).
241: * @param urlText the URL text (<code>null</code> permitted).
242: * @param line the line (<code>null</code> not permitted).
243: * @param lineStroke the line stroke (<code>null</code> not permitted).
244: * @param linePaint the line paint (<code>null</code> not permitted).
245: */
246: public LegendItem(String label, String description,
247: String toolTipText, String urlText, Shape line,
248: Stroke lineStroke, Paint linePaint) {
249:
250: this (label, description, toolTipText, urlText,
251: /* shape visible = */false, UNUSED_SHAPE,
252: /* shape filled = */false, Color.black,
253: /* shape outlined = */false, Color.black, UNUSED_STROKE,
254: /* line visible = */true, line, lineStroke, linePaint);
255: }
256:
257: /**
258: * Creates a new legend item.
259: *
260: * @param label the label (<code>null</code> not permitted).
261: * @param description the description (not currently used,
262: * <code>null</code> permitted).
263: * @param toolTipText the tool tip text (<code>null</code> permitted).
264: * @param urlText the URL text (<code>null</code> permitted).
265: * @param shapeVisible a flag that controls whether or not the shape is
266: * displayed.
267: * @param shape the shape (<code>null</code> permitted).
268: * @param shapeFilled a flag that controls whether or not the shape is
269: * filled.
270: * @param fillPaint the fill paint (<code>null</code> not permitted).
271: * @param shapeOutlineVisible a flag that controls whether or not the
272: * shape is outlined.
273: * @param outlinePaint the outline paint (<code>null</code> not permitted).
274: * @param outlineStroke the outline stroke (<code>null</code> not
275: * permitted).
276: * @param lineVisible a flag that controls whether or not the line is
277: * visible.
278: * @param line the line.
279: * @param lineStroke the stroke (<code>null</code> not permitted).
280: * @param linePaint the line paint (<code>null</code> not permitted).
281: */
282: public LegendItem(String label, String description,
283: String toolTipText, String urlText, boolean shapeVisible,
284: Shape shape, boolean shapeFilled, Paint fillPaint,
285: boolean shapeOutlineVisible, Paint outlinePaint,
286: Stroke outlineStroke, boolean lineVisible, Shape line,
287: Stroke lineStroke, Paint linePaint) {
288:
289: if (label == null) {
290: throw new IllegalArgumentException("Null 'label' argument.");
291: }
292: if (fillPaint == null) {
293: throw new IllegalArgumentException(
294: "Null 'fillPaint' argument.");
295: }
296: if (lineStroke == null) {
297: throw new IllegalArgumentException(
298: "Null 'lineStroke' argument.");
299: }
300: if (outlinePaint == null) {
301: throw new IllegalArgumentException(
302: "Null 'outlinePaint' argument.");
303: }
304: if (outlineStroke == null) {
305: throw new IllegalArgumentException(
306: "Null 'outlineStroke' argument.");
307: }
308: this .label = label;
309: this .attributedLabel = null;
310: this .description = description;
311: this .shapeVisible = shapeVisible;
312: this .shape = shape;
313: this .shapeFilled = shapeFilled;
314: this .fillPaint = fillPaint;
315: this .fillPaintTransformer = new StandardGradientPaintTransformer();
316: this .shapeOutlineVisible = shapeOutlineVisible;
317: this .outlinePaint = outlinePaint;
318: this .outlineStroke = outlineStroke;
319: this .lineVisible = lineVisible;
320: this .line = line;
321: this .lineStroke = lineStroke;
322: this .linePaint = linePaint;
323: this .toolTipText = toolTipText;
324: this .urlText = urlText;
325: }
326:
327: /**
328: * Creates a legend item with a filled shape. The shape is not outlined,
329: * and no line is visible.
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: */
339: public LegendItem(AttributedString label, String description,
340: String toolTipText, String urlText, Shape shape,
341: Paint fillPaint) {
342:
343: this (label, description, toolTipText, urlText,
344: /* shape visible = */true, shape,
345: /* shape filled = */true, fillPaint,
346: /* shape outlined = */false, Color.black, UNUSED_STROKE,
347: /* line visible = */false, UNUSED_SHAPE, UNUSED_STROKE,
348: Color.black);
349:
350: }
351:
352: /**
353: * Creates a legend item with a filled and outlined shape.
354: *
355: * @param label the label (<code>null</code> not permitted).
356: * @param description the description (<code>null</code> permitted).
357: * @param toolTipText the tool tip text (<code>null</code> permitted).
358: * @param urlText the URL text (<code>null</code> permitted).
359: * @param shape the shape (<code>null</code> not permitted).
360: * @param fillPaint the paint used to fill the shape (<code>null</code>
361: * not permitted).
362: * @param outlineStroke the outline stroke (<code>null</code> not
363: * permitted).
364: * @param outlinePaint the outline paint (<code>null</code> not
365: * permitted).
366: */
367: public LegendItem(AttributedString label, String description,
368: String toolTipText, String urlText, Shape shape,
369: Paint fillPaint, Stroke outlineStroke, Paint outlinePaint) {
370:
371: this (label, description, toolTipText, urlText,
372: /* shape visible = */true, shape,
373: /* shape filled = */true, fillPaint,
374: /* shape outlined = */true, outlinePaint, outlineStroke,
375: /* line visible = */false, UNUSED_SHAPE, UNUSED_STROKE,
376: Color.black);
377: }
378:
379: /**
380: * Creates a legend item using a line.
381: *
382: * @param label the label (<code>null</code> not permitted).
383: * @param description the description (<code>null</code> permitted).
384: * @param toolTipText the tool tip text (<code>null</code> permitted).
385: * @param urlText the URL text (<code>null</code> permitted).
386: * @param line the line (<code>null</code> not permitted).
387: * @param lineStroke the line stroke (<code>null</code> not permitted).
388: * @param linePaint the line paint (<code>null</code> not permitted).
389: */
390: public LegendItem(AttributedString label, String description,
391: String toolTipText, String urlText, Shape line,
392: Stroke lineStroke, Paint linePaint) {
393:
394: this (label, description, toolTipText, urlText,
395: /* shape visible = */false, UNUSED_SHAPE,
396: /* shape filled = */false, Color.black,
397: /* shape outlined = */false, Color.black, UNUSED_STROKE,
398: /* line visible = */true, line, lineStroke, linePaint);
399: }
400:
401: /**
402: * Creates a new legend item.
403: *
404: * @param label the label (<code>null</code> not permitted).
405: * @param description the description (not currently used,
406: * <code>null</code> permitted).
407: * @param toolTipText the tool tip text (<code>null</code> permitted).
408: * @param urlText the URL text (<code>null</code> permitted).
409: * @param shapeVisible a flag that controls whether or not the shape is
410: * displayed.
411: * @param shape the shape (<code>null</code> permitted).
412: * @param shapeFilled a flag that controls whether or not the shape is
413: * filled.
414: * @param fillPaint the fill paint (<code>null</code> not permitted).
415: * @param shapeOutlineVisible a flag that controls whether or not the
416: * shape is outlined.
417: * @param outlinePaint the outline paint (<code>null</code> not permitted).
418: * @param outlineStroke the outline stroke (<code>null</code> not
419: * permitted).
420: * @param lineVisible a flag that controls whether or not the line is
421: * visible.
422: * @param line the line.
423: * @param lineStroke the stroke (<code>null</code> not permitted).
424: * @param linePaint the line paint (<code>null</code> not permitted).
425: */
426: public LegendItem(AttributedString label, String description,
427: String toolTipText, String urlText, boolean shapeVisible,
428: Shape shape, boolean shapeFilled, Paint fillPaint,
429: boolean shapeOutlineVisible, Paint outlinePaint,
430: Stroke outlineStroke, boolean lineVisible, Shape line,
431: Stroke lineStroke, Paint linePaint) {
432:
433: if (label == null) {
434: throw new IllegalArgumentException("Null 'label' argument.");
435: }
436: if (fillPaint == null) {
437: throw new IllegalArgumentException(
438: "Null 'fillPaint' argument.");
439: }
440: if (lineStroke == null) {
441: throw new IllegalArgumentException(
442: "Null 'lineStroke' argument.");
443: }
444: if (outlinePaint == null) {
445: throw new IllegalArgumentException(
446: "Null 'outlinePaint' argument.");
447: }
448: if (outlineStroke == null) {
449: throw new IllegalArgumentException(
450: "Null 'outlineStroke' argument.");
451: }
452: this .label = characterIteratorToString(label.getIterator());
453: this .attributedLabel = label;
454: this .description = description;
455: this .shapeVisible = shapeVisible;
456: this .shape = shape;
457: this .shapeFilled = shapeFilled;
458: this .fillPaint = fillPaint;
459: this .shapeOutlineVisible = shapeOutlineVisible;
460: this .outlinePaint = outlinePaint;
461: this .outlineStroke = outlineStroke;
462: this .lineVisible = lineVisible;
463: this .line = line;
464: this .lineStroke = lineStroke;
465: this .linePaint = linePaint;
466: this .toolTipText = toolTipText;
467: this .urlText = urlText;
468: }
469:
470: /**
471: * Returns a string containing the characters from the given iterator.
472: *
473: * @param iterator the iterator (<code>null</code> not permitted).
474: *
475: * @return A string.
476: */
477: private String characterIteratorToString(CharacterIterator iterator) {
478: int endIndex = iterator.getEndIndex();
479: int beginIndex = iterator.getBeginIndex();
480: int count = endIndex - beginIndex;
481: if (count <= 0) {
482: return "";
483: }
484: char[] chars = new char[count];
485: int i = 0;
486: char c = iterator.first();
487: while (c != CharacterIterator.DONE) {
488: chars[i] = c;
489: i++;
490: c = iterator.next();
491: }
492: return new String(chars);
493: }
494:
495: /**
496: * Returns the dataset.
497: *
498: * @return The dataset.
499: *
500: * @since 1.0.6
501: *
502: * @see #setDatasetIndex(int)
503: */
504: public Dataset getDataset() {
505: return this .dataset;
506: }
507:
508: /**
509: * Sets the dataset.
510: *
511: * @param dataset the dataset.
512: *
513: * @since 1.0.6
514: */
515: public void setDataset(Dataset dataset) {
516: this .dataset = dataset;
517: }
518:
519: /**
520: * Returns the dataset index for this legend item.
521: *
522: * @return The dataset index.
523: *
524: * @since 1.0.2
525: *
526: * @see #setDatasetIndex(int)
527: * @see #getDataset()
528: */
529: public int getDatasetIndex() {
530: return this .datasetIndex;
531: }
532:
533: /**
534: * Sets the dataset index for this legend item.
535: *
536: * @param index the index.
537: *
538: * @since 1.0.2
539: *
540: * @see #getDatasetIndex()
541: */
542: public void setDatasetIndex(int index) {
543: this .datasetIndex = index;
544: }
545:
546: /**
547: * Returns the series key.
548: *
549: * @return The series key.
550: *
551: * @since 1.0.6
552: *
553: * @see #setSeriesKey(Comparable)
554: */
555: public Comparable getSeriesKey() {
556: return this .seriesKey;
557: }
558:
559: /**
560: * Sets the series key.
561: *
562: * @param key the series key.
563: *
564: * @since 1.0.6
565: */
566: public void setSeriesKey(Comparable key) {
567: this .seriesKey = key;
568: }
569:
570: /**
571: * Returns the series index for this legend item.
572: *
573: * @return The series index.
574: *
575: * @since 1.0.2
576: */
577: public int getSeriesIndex() {
578: return this .series;
579: }
580:
581: /**
582: * Sets the series index for this legend item.
583: *
584: * @param index the index.
585: *
586: * @since 1.0.2
587: */
588: public void setSeriesIndex(int index) {
589: this .series = index;
590: }
591:
592: /**
593: * Returns the label.
594: *
595: * @return The label (never <code>null</code>).
596: */
597: public String getLabel() {
598: return this .label;
599: }
600:
601: /**
602: * Returns the attributed label.
603: *
604: * @return The attributed label (possibly <code>null</code>).
605: */
606: public AttributedString getAttributedLabel() {
607: return this .attributedLabel;
608: }
609:
610: /**
611: * Returns the description for the legend item.
612: *
613: * @return The description.
614: */
615: public String getDescription() {
616: return this .description;
617: }
618:
619: /**
620: * Returns the tool tip text.
621: *
622: * @return The tool tip text (possibly <code>null</code>).
623: */
624: public String getToolTipText() {
625: return this .toolTipText;
626: }
627:
628: /**
629: * Returns the URL text.
630: *
631: * @return The URL text (possibly <code>null</code>).
632: */
633: public String getURLText() {
634: return this .urlText;
635: }
636:
637: /**
638: * Returns a flag that indicates whether or not the shape is visible.
639: *
640: * @return A boolean.
641: */
642: public boolean isShapeVisible() {
643: return this .shapeVisible;
644: }
645:
646: /**
647: * Returns the shape used to label the series represented by this legend
648: * item.
649: *
650: * @return The shape (never <code>null</code>).
651: */
652: public Shape getShape() {
653: return this .shape;
654: }
655:
656: /**
657: * Returns a flag that controls whether or not the shape is filled.
658: *
659: * @return A boolean.
660: */
661: public boolean isShapeFilled() {
662: return this .shapeFilled;
663: }
664:
665: /**
666: * Returns the fill paint.
667: *
668: * @return The fill paint (never <code>null</code>).
669: */
670: public Paint getFillPaint() {
671: return this .fillPaint;
672: }
673:
674: /**
675: * Returns the flag that controls whether or not the shape outline
676: * is visible.
677: *
678: * @return A boolean.
679: */
680: public boolean isShapeOutlineVisible() {
681: return this .shapeOutlineVisible;
682: }
683:
684: /**
685: * Returns the line stroke for the series.
686: *
687: * @return The stroke (never <code>null</code>).
688: */
689: public Stroke getLineStroke() {
690: return this .lineStroke;
691: }
692:
693: /**
694: * Returns the paint used for lines.
695: *
696: * @return The paint.
697: */
698: public Paint getLinePaint() {
699: return this .linePaint;
700: }
701:
702: /**
703: * Returns the outline paint.
704: *
705: * @return The outline paint (never <code>null</code>).
706: */
707: public Paint getOutlinePaint() {
708: return this .outlinePaint;
709: }
710:
711: /**
712: * Returns the outline stroke.
713: *
714: * @return The outline stroke (never <code>null</code>).
715: */
716: public Stroke getOutlineStroke() {
717: return this .outlineStroke;
718: }
719:
720: /**
721: * Returns a flag that indicates whether or not the line is visible.
722: *
723: * @return A boolean.
724: */
725: public boolean isLineVisible() {
726: return this .lineVisible;
727: }
728:
729: /**
730: * Returns the line.
731: *
732: * @return The line.
733: */
734: public Shape getLine() {
735: return this .line;
736: }
737:
738: /**
739: * Returns the transformer used when the fill paint is an instance of
740: * <code>GradientPaint</code>.
741: *
742: * @return The transformer (never <code>null</code>).
743: *
744: * @since 1.0.4
745: *
746: * @see #setFillPaintTransformer(GradientPaintTransformer)
747: */
748: public GradientPaintTransformer getFillPaintTransformer() {
749: return this .fillPaintTransformer;
750: }
751:
752: /**
753: * Sets the transformer used when the fill paint is an instance of
754: * <code>GradientPaint</code>.
755: *
756: * @param transformer the transformer (<code>null</code> not permitted).
757: *
758: * @since 1.0.4
759: *
760: * @see #getFillPaintTransformer()
761: */
762: public void setFillPaintTransformer(
763: GradientPaintTransformer transformer) {
764: if (transformer == null) {
765: throw new IllegalArgumentException(
766: "Null 'transformer' attribute.");
767: }
768: this .fillPaintTransformer = transformer;
769: }
770:
771: /**
772: * Tests this item for equality with an arbitrary object.
773: *
774: * @param obj the object (<code>null</code> permitted).
775: *
776: * @return A boolean.
777: */
778: public boolean equals(Object obj) {
779: if (obj == this ) {
780: return true;
781: }
782: if (!(obj instanceof LegendItem)) {
783: return false;
784: }
785: LegendItem that = (LegendItem) obj;
786: if (this .datasetIndex != that.datasetIndex) {
787: return false;
788: }
789: if (this .series != that.series) {
790: return false;
791: }
792: if (!this .label.equals(that.label)) {
793: return false;
794: }
795: if (!AttributedStringUtilities.equal(this .attributedLabel,
796: that.attributedLabel)) {
797: return false;
798: }
799: if (!ObjectUtilities.equal(this .description, that.description)) {
800: return false;
801: }
802: if (this .shapeVisible != that.shapeVisible) {
803: return false;
804: }
805: if (!ShapeUtilities.equal(this .shape, that.shape)) {
806: return false;
807: }
808: if (this .shapeFilled != that.shapeFilled) {
809: return false;
810: }
811: if (!this .fillPaint.equals(that.fillPaint)) {
812: return false;
813: }
814: if (!ObjectUtilities.equal(this .fillPaintTransformer,
815: that.fillPaintTransformer)) {
816: return false;
817: }
818: if (this .shapeOutlineVisible != that.shapeOutlineVisible) {
819: return false;
820: }
821: if (!this .outlineStroke.equals(that.outlineStroke)) {
822: return false;
823: }
824: if (!this .outlinePaint.equals(that.outlinePaint)) {
825: return false;
826: }
827: if (!this .lineVisible == that.lineVisible) {
828: return false;
829: }
830: if (!ShapeUtilities.equal(this .line, that.line)) {
831: return false;
832: }
833: if (!this .lineStroke.equals(that.lineStroke)) {
834: return false;
835: }
836: if (!this .linePaint.equals(that.linePaint)) {
837: return false;
838: }
839: return true;
840: }
841:
842: /**
843: * Provides serialization support.
844: *
845: * @param stream the output stream (<code>null</code> not permitted).
846: *
847: * @throws IOException if there is an I/O error.
848: */
849: private void writeObject(ObjectOutputStream stream)
850: throws IOException {
851: stream.defaultWriteObject();
852: SerialUtilities.writeAttributedString(this .attributedLabel,
853: stream);
854: SerialUtilities.writeShape(this .shape, stream);
855: SerialUtilities.writePaint(this .fillPaint, stream);
856: SerialUtilities.writeStroke(this .outlineStroke, stream);
857: SerialUtilities.writePaint(this .outlinePaint, stream);
858: SerialUtilities.writeShape(this .line, stream);
859: SerialUtilities.writeStroke(this .lineStroke, stream);
860: SerialUtilities.writePaint(this .linePaint, stream);
861: }
862:
863: /**
864: * Provides serialization support.
865: *
866: * @param stream the input stream (<code>null</code> not permitted).
867: *
868: * @throws IOException if there is an I/O error.
869: * @throws ClassNotFoundException if there is a classpath problem.
870: */
871: private void readObject(ObjectInputStream stream)
872: throws IOException, ClassNotFoundException {
873: stream.defaultReadObject();
874: this.attributedLabel = SerialUtilities
875: .readAttributedString(stream);
876: this.shape = SerialUtilities.readShape(stream);
877: this.fillPaint = SerialUtilities.readPaint(stream);
878: this.outlineStroke = SerialUtilities.readStroke(stream);
879: this.outlinePaint = SerialUtilities.readPaint(stream);
880: this.line = SerialUtilities.readShape(stream);
881: this.lineStroke = SerialUtilities.readStroke(stream);
882: this.linePaint = SerialUtilities.readPaint(stream);
883: }
884:
885: }
|