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