KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > chart2d > LegendProperties


1 /**
2  * Chart2D, a java library for drawing two dimensional charts.
3  * Copyright (C) 2001 Jason J. Simas
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * The author of this library may be contacted at:
19  * E-mail: jjsimas@users.sourceforge.net
20  * Street Address: J J Simas, 887 Tico Road, Ojai, CA 93023-3555 USA
21  */

22
23
24 package net.sourceforge.chart2d;
25
26
27 import java.awt.Color JavaDoc;
28 import java.awt.Dimension JavaDoc;
29 import java.awt.Font JavaDoc;
30 import java.util.Vector JavaDoc;
31
32
33 /**
34  * A data structure for holding the properties common to all legends.
35  * Pass this to any number of Chart2D objects.
36  */

37 public final class LegendProperties extends Properties {
38
39
40   /**
41    * The default is true.
42    */

43   public final static boolean LEGEND_EXISTENCE_DEFAULT = true;
44
45   /**
46    * The default is String[0].
47    */

48   public static final String JavaDoc[] LEGEND_LABELS_TEXTS_DEFAULT = new String JavaDoc[0];
49
50   /**
51    * The default is true.
52    */

53   public final static boolean LEGEND_BORDER_EXISTENCE_DEFAULT = true;
54
55   /**
56    * The default is 2.
57    */

58   public final static int LEGEND_BORDER_THICKNESS_MODEL_DEFAULT = 2;
59
60   /**
61    * The default is Color.gray.
62    */

63   public final static Color JavaDoc LEGEND_BORDER_COLOR_DEFAULT = Color.gray;
64
65   /**
66    * The default is true.
67    */

68   public final static boolean LEGEND_GAP_EXISTENCE_DEFAULT = true;
69
70   /**
71    * The default is 3.
72    */

73   public final static int LEGEND_GAP_THICKNESS_MODEL_DEFAULT = 3;
74
75   /**
76    * The default is false.
77    */

78   public final static boolean LEGEND_BACKGROUND_EXISTENCE_DEFAULT = false;
79
80   /**
81    * The default is Color.white.
82    */

83   public final static Color JavaDoc LEGEND_BACKGROUND_COLOR_DEFAULT = Color.white;
84
85   /**
86    * The default is 11.
87    */

88   public final static int LEGEND_LABELS_FONT_POINT_MODEL_DEFAULT = 11;
89
90   /**
91    * The default is "SansSerif".
92    */

93   public final static String JavaDoc LEGEND_LABELS_FONT_NAME_DEFAULT = "SansSerif";
94
95   /**
96    * The default is Color.black.
97    */

98   public final static Color JavaDoc LEGEND_LABELS_FONT_COLOR_DEFAULT = Color.black;
99
100   /**
101    * The default is Font.PLAIN.
102    */

103   public final static int LEGEND_LABELS_FONT_STYLE_DEFAULT = Font.PLAIN;
104
105   /**
106    * The default is true.
107    */

108   public final static boolean LEGEND_BETWEEN_LABELS_OR_BULLETS_GAP_EXISTENCE_DEFAULT = true;
109
110   /**
111    * The default is 5.
112    */

113   public final static int LEGEND_BETWEEN_LABELS_OR_BULLETS_GAP_THICKNESS_MODEL_DEFAULT = 5;
114
115   /**
116    * The default is true.
117    */

118   public final static boolean LEGEND_BETWEEN_LABELS_AND_BULLETS_GAP_EXISTENCE_DEFAULT = true;
119
120   /**
121    * The default is 3.
122    */

123   public final static int LEGEND_BETWEEN_LABELS_AND_BULLETS_GAP_THICKNESS_MODEL_DEFAULT = 3;
124
125   /**
126    * The default is true.
127    */

128   public final static boolean LEGEND_BULLETS_OUTLINE_EXISTENCE_DEFAULT = true;
129
130   /**
131    * The default is Color.black.
132    */

133   public final static Color JavaDoc LEGEND_BULLETS_OUTLINE_COLOR_DEFAULT = Color.black;
134
135   /**
136    * The default is the Dimension (9, 9).
137    */

138   public final static Dimension JavaDoc LEGEND_BULLETS_SIZE_MODEL_DEFAULT = new Dimension JavaDoc (9, 9);
139
140
141   private boolean legendExistence;
142   private String JavaDoc[] legendLabelsTexts;
143   private boolean legendBorderExistence;
144   private int legendBorderThicknessModel;
145   private Color JavaDoc legendBorderColor;
146   private boolean legendGapExistence;
147   private int legendGapThicknessModel;
148   private boolean legendBackgroundExistence;
149   private Color JavaDoc legendBackgroundColor;
150   private int legendLabelsFontPointModel;
151   private String JavaDoc legendLabelsFontName;
152   private Color JavaDoc legendLabelsFontColor;
153   private int legendLabelsFontStyle;
154   private boolean legendBetweenLabelsOrBulletsGapExistence;
155   private int legendBetweenLabelsOrBulletsGapThicknessModel;
156   private boolean legendBetweenLabelsAndBulletsGapExistence;
157   private int legendBetweenLabelsAndBulletsGapThicknessModel;
158   private boolean legendBulletsOutlineExistence;
159   private Color JavaDoc legendBulletsOutlineColor;
160   private Dimension JavaDoc legendBulletsSizeModel;
161
162   private boolean needsUpdate = true;
163   private final Vector JavaDoc chart2DVector = new Vector JavaDoc (5, 5);
164   private final Vector JavaDoc needsUpdateVector = new Vector JavaDoc (5, 5);
165
166
167   /**
168    * Creates a LegendProperties object with the documented default values.
169    */

170   public LegendProperties() {
171
172     needsUpdate = true;
173     setLegendPropertiesToDefaults();
174   }
175
176
177   /**
178    * Creates a LegendProperties object with property values copied from another object.
179    * The copying is a deep copy.
180    * @param legendProps The properties to copy.
181    */

182   public LegendProperties (LegendProperties legendProps) {
183
184     needsUpdate = true;
185     setLegendProperties (legendProps);
186   }
187
188
189   /**
190    * Sets all properties to their default values.
191    */

192   public final void setLegendPropertiesToDefaults() {
193
194     needsUpdate = true;
195     setLegendExistence (LEGEND_EXISTENCE_DEFAULT);
196     setLegendLabelsTexts (LEGEND_LABELS_TEXTS_DEFAULT);
197     setLegendBorderExistence (LEGEND_BORDER_EXISTENCE_DEFAULT);
198     setLegendBorderThicknessModel (LEGEND_BORDER_THICKNESS_MODEL_DEFAULT);
199     setLegendBorderColor (LEGEND_BORDER_COLOR_DEFAULT);
200     setLegendGapExistence (LEGEND_GAP_EXISTENCE_DEFAULT);
201     setLegendGapThicknessModel (LEGEND_GAP_THICKNESS_MODEL_DEFAULT);
202     setLegendBackgroundExistence (LEGEND_BACKGROUND_EXISTENCE_DEFAULT);
203     setLegendBackgroundColor (LEGEND_BACKGROUND_COLOR_DEFAULT);
204     setLegendLabelsFontPointModel (LEGEND_LABELS_FONT_POINT_MODEL_DEFAULT);
205     setLegendLabelsFontName (LEGEND_LABELS_FONT_NAME_DEFAULT);
206     setLegendLabelsFontColor (LEGEND_LABELS_FONT_COLOR_DEFAULT);
207     setLegendLabelsFontStyle (LEGEND_LABELS_FONT_STYLE_DEFAULT);
208     setLegendBetweenLabelsOrBulletsGapExistence (
209       LEGEND_BETWEEN_LABELS_OR_BULLETS_GAP_EXISTENCE_DEFAULT);
210     setLegendBetweenLabelsOrBulletsGapThicknessModel (
211       LEGEND_BETWEEN_LABELS_OR_BULLETS_GAP_THICKNESS_MODEL_DEFAULT);
212     setLegendBetweenLabelsAndBulletsGapExistence (
213       LEGEND_BETWEEN_LABELS_AND_BULLETS_GAP_EXISTENCE_DEFAULT);
214     setLegendBetweenLabelsAndBulletsGapThicknessModel (
215       LEGEND_BETWEEN_LABELS_AND_BULLETS_GAP_THICKNESS_MODEL_DEFAULT);
216     setLegendBulletsOutlineExistence (
217       LEGEND_BULLETS_OUTLINE_EXISTENCE_DEFAULT);
218     setLegendBulletsOutlineColor (LEGEND_BULLETS_OUTLINE_COLOR_DEFAULT);
219     setLegendBulletsSizeModel (LEGEND_BULLETS_SIZE_MODEL_DEFAULT);
220   }
221
222
223   /**
224    * Sets all properties to be the values of another LegendProperties object.
225    * The copying is a deep copy.
226    * @param legendProps The properties to copy.
227    */

228   public final void setLegendProperties (LegendProperties legendProps) {
229
230     needsUpdate = true;
231     setLegendExistence (legendProps.getLegendExistence());
232     setLegendBorderExistence (legendProps.getLegendBorderExistence());
233     setLegendBorderThicknessModel (legendProps.getLegendBorderThicknessModel());
234     setLegendBorderColor (legendProps.getLegendBorderColor());
235     setLegendGapExistence (legendProps.getLegendGapExistence());
236     String JavaDoc[] legendTexts = legendProps.getLegendLabelsTexts();
237     String JavaDoc[] copiedLegendTexts = new String JavaDoc[legendTexts.length];
238     for (int i = 0; i < legendTexts.length; ++i) copiedLegendTexts[i] = legendTexts[i];
239     setLegendLabelsTexts (copiedLegendTexts);
240     setLegendGapThicknessModel (legendProps.getLegendGapThicknessModel());
241     setLegendBackgroundExistence (legendProps.getLegendBackgroundExistence());
242     setLegendBackgroundColor (legendProps.getLegendBackgroundColor());
243     setLegendLabelsFontPointModel (legendProps.getLegendLabelsFontPointModel());
244     setLegendLabelsFontName (legendProps.getLegendLabelsFontName());
245     setLegendLabelsFontColor (legendProps.getLegendLabelsFontColor());
246     setLegendLabelsFontStyle (legendProps.getLegendLabelsFontStyle());
247     setLegendBetweenLabelsOrBulletsGapExistence (
248       legendProps.getLegendBetweenLabelsOrBulletsGapExistence());
249     setLegendBetweenLabelsOrBulletsGapThicknessModel (
250       legendProps.getLegendBetweenLabelsOrBulletsGapThicknessModel());
251     setLegendBetweenLabelsAndBulletsGapExistence (
252       legendProps.getLegendBetweenLabelsAndBulletsGapExistence());
253     setLegendBetweenLabelsAndBulletsGapThicknessModel (
254       legendProps.getLegendBetweenLabelsAndBulletsGapThicknessModel());
255     setLegendBulletsOutlineExistence (legendProps.getLegendBulletsOutlineExistence());
256     setLegendBulletsOutlineColor (legendProps.getLegendBulletsOutlineColor());
257     setLegendBulletsSizeModel (new Dimension JavaDoc (legendProps.getLegendBulletsSizeModel()));
258   }
259
260
261   /**
262    * Sets whether there will exist a legend on the chart.
263    * @param existence If true, there will be a legend for the chart.
264    */

265   public final void setLegendExistence (boolean existence) {
266
267     needsUpdate = true;
268     legendExistence = existence;
269   }
270
271
272   /**
273    * Sets the texts of the legend labels. The number of texts must be
274    * equal to the total number of data sets of this chart.
275    * @param texts The texts for the legend labels.
276    */

277   public final void setLegendLabelsTexts (String JavaDoc[] texts) {
278
279     needsUpdate = true;
280     legendLabelsTexts = texts;
281   }
282
283
284   /**
285    * Sets whether there will exist a border around the legend.
286    * @param existence If true, there will be a border around the legend.
287    */

288   public final void setLegendBorderExistence (boolean existence) {
289
290     needsUpdate = true;
291     legendBorderExistence = existence;
292   }
293
294
295   /**
296    * Sets the thickness of the border around the legend for the chart's
297    * model size.
298    * @param thickness The model thicknes for the chart.
299    */

300   public final void setLegendBorderThicknessModel (int thickness) {
301
302     needsUpdate = true;
303     legendBorderThicknessModel = thickness;
304   }
305
306
307   /**
308    * Sets the color of the border around the legend.
309    * @param color The color of the legend's border.
310    */

311   public final void setLegendBorderColor (Color JavaDoc color) {
312
313     needsUpdate = true;
314     legendBorderColor = color;
315   }
316
317
318   /**
319    * Sets whether a gap between the legend's border or edge and the
320    * legend's inner components exists.
321    * @param existence If true, then a gap exists.
322    */

323   public final void setLegendGapExistence (boolean existence) {
324
325     needsUpdate = true;
326     legendGapExistence = existence;
327   }
328
329
330   /**
331    * Sets the thickness of the legend's gap for the chart's model size.
332    * @param thickness The model thickness of the legend's gap.
333    */

334   public final void setLegendGapThicknessModel (int thickness) {
335
336     needsUpdate = true;
337     legendGapThicknessModel = thickness;
338   }
339
340
341   /**
342    * Sets whether the legend will have a painted background or not. If not
343    * whatever is behind the legend will show through the spaces of the legend.
344    * @param existence If true, the background of the legend will be painted.
345    */

346   public final void setLegendBackgroundExistence (boolean existence) {
347
348     needsUpdate = true;
349     legendBackgroundExistence = existence;
350   }
351
352
353   /**
354    * Sets the color of the legend's background.
355    * @param color The color of the legend's background.
356    */

357   public final void setLegendBackgroundColor (Color JavaDoc color) {
358
359     needsUpdate = true;
360     legendBackgroundColor = color;
361   }
362
363
364   /**
365    * Sets the point of the font of the legend's labels for the chart's
366    * model size.
367    * @param point The model font point of the legend's labels.
368    */

369   public final void setLegendLabelsFontPointModel (int point) {
370
371     needsUpdate = true;
372     legendLabelsFontPointModel = point;
373   }
374
375   /**
376    * Sets name of the font of the legend's labels.
377    * Accepts all values accepted by java.awt.Font.
378    * @param name The name of the font for the legend's labels.
379    */

380   public final void setLegendLabelsFontName (String JavaDoc name) {
381
382     needsUpdate = true;
383     legendLabelsFontName = name;
384   }
385
386
387   /**
388    * Sets the color of the font of the legend's labels.
389    * @param color The color of the font of the legend's labels.
390    */

391   public final void setLegendLabelsFontColor (Color JavaDoc color) {
392
393     needsUpdate = true;
394     legendLabelsFontColor = color;
395   }
396
397
398   /**
399    * Sets the style of the font of the legend's labels.
400    * Accepts all values that java.awt.Font accepts.
401    * @param style The style of the font of the legend's labels.
402    */

403   public final void setLegendLabelsFontStyle (int style) {
404
405     needsUpdate = true;
406     legendLabelsFontStyle = style;
407   }
408
409
410   /**
411    * Sets whether a gap between the legend's bullets or labels exists in
412    * their vertical placement.
413    * @param existence If true, a gap exists.
414    */

415   public final void setLegendBetweenLabelsOrBulletsGapExistence (boolean existence) {
416
417     needsUpdate = true;
418     legendBetweenLabelsOrBulletsGapExistence = existence;
419   }
420
421
422   /**
423    * Sets the thickness of the gap between the legend's bullets or labels
424    * exists in their vertical placement, for the chart's model size.
425    * @param thickness The model thickness of the gap.
426    */

427   public final void setLegendBetweenLabelsOrBulletsGapThicknessModel (int thickness) {
428
429     needsUpdate = true;
430     legendBetweenLabelsOrBulletsGapThicknessModel = thickness;
431   }
432
433
434   /**
435    * Sets whether the gap between the legend's bullets and labels exists
436    * in their horizontal placement.
437    * @param existence If true, a gap exists.
438    */

439   public final void setLegendBetweenLabelsAndBulletsGapExistence (boolean existence) {
440
441     needsUpdate = true;
442     legendBetweenLabelsAndBulletsGapExistence = existence;
443   }
444
445
446   /**
447    * Sets the thickness of the gap between the legend's bullets and labels
448    * in their horizontal placement, for the chart's model size.
449    * @param thickness The model thickness of teh gap.
450    */

451   public final void setLegendBetweenLabelsAndBulletsGapThicknessModel (int thickness) {
452
453     needsUpdate = true;
454     legendBetweenLabelsAndBulletsGapThicknessModel = thickness;
455   }
456
457
458   /**
459    * Sets whether a thin line is painted around the legend's bullets.
460    * @param existence If true, the legend's bullets will be outlined.
461    */

462   public final void setLegendBulletsOutlineExistence (boolean existence) {
463
464     needsUpdate = true;
465     legendBulletsOutlineExistence = existence;
466   }
467
468
469   /**
470    * Sets the color of the legend's bullets outline.
471    * @param color The color of the legend's bullets outline.
472    */

473   public final void setLegendBulletsOutlineColor (Color JavaDoc color) {
474
475     needsUpdate = true;
476     legendBulletsOutlineColor = color;
477   }
478
479
480   /**
481    * Sets the size of the legend's bullets for the chart's model size.
482    * @param size The size of the legend's bullets.
483    */

484   public final void setLegendBulletsSizeModel (Dimension JavaDoc size) {
485
486     needsUpdate = true;
487     legendBulletsSizeModel = size;
488   }
489
490
491   /**
492    * Gets whether there will exist a legend on the chart.
493    * @return boolean If true, there will be a legend for the chart.
494    */

495   public final boolean getLegendExistence() {
496     return legendExistence;
497   }
498
499
500   /**
501    * Gets the texts of the legend labels. The number of texts must be
502    * equal to the total number of data sets of this chart.
503    * @return String[] The texts for the legend labels.
504    */

505   public final String JavaDoc[] getLegendLabelsTexts() {
506     return legendLabelsTexts;
507   }
508
509
510   /**
511    * Gets whether there will exist a border around the legend.
512    * @return boolean If true, there will be a border around the legend.
513    */

514   public final boolean getLegendBorderExistence() {
515     return legendBorderExistence;
516   }
517
518
519   /**
520    * Gets the thickness of the border around the legend for the chart's
521    * model size.
522    * @return int The model thicknes for the chart.
523    */

524   public final int getLegendBorderThicknessModel() {
525     return legendBorderThicknessModel;
526   }
527
528
529   /**
530    * Gets the color of the border around the legend.
531    * @return Color The color of the legend's border.
532    */

533   public final Color JavaDoc getLegendBorderColor() {
534     return legendBorderColor;
535   }
536
537
538   /**
539    * Gets whether a gap between the legend's border or edge and the
540    * legend's inner components exists.
541    * @return boolean If true, then a gap exists.
542    */

543   public final boolean getLegendGapExistence() {
544     return legendGapExistence;
545   }
546
547
548   /**
549    * Gets the thickness of the legend's gap for the chart's model size.
550    * @return int The model thickness of the legend's gap.
551    */

552   public final int getLegendGapThicknessModel() {
553     return legendGapThicknessModel;
554   }
555
556
557   /**
558    * Gets whether the legend will have a painted background or not. If not
559    * whatever is behind the legend will show through the spaces of the legend.
560    * @return boolean If true, the background of the legend will be painted.
561    */

562   public final boolean getLegendBackgroundExistence() {
563     return legendBackgroundExistence;
564   }
565
566
567   /**
568    * Gets the color of the legend's background.
569    * @return Color The color of the legend's background.
570    */

571   public final Color JavaDoc getLegendBackgroundColor() {
572     return legendBackgroundColor;
573   }
574
575
576   /**
577    * Gets the point of the font of the legend's labels for the chart's
578    * model size.
579    * @return int The model font point of the legend's labels.
580    */

581   public final int getLegendLabelsFontPointModel() {
582     return legendLabelsFontPointModel;
583   }
584
585   /**
586    * Gets name of the font of the legend's labels.
587    * Accepts all values accepted by java.awt.Font.
588    * @return String The name of the font for the legend's labels.
589    */

590   public final String JavaDoc getLegendLabelsFontName() {
591     return legendLabelsFontName;
592   }
593
594
595   /**
596    * Gets the color of the font of the legend's labels.
597    * @return Color The color of the font of the legend's labels.
598    */

599   public final Color JavaDoc getLegendLabelsFontColor() {
600     return legendLabelsFontColor;
601   }
602
603
604   /**
605    * Gets the style of the font of the legend's labels.
606    * Accepts all values that java.awt.Font accepts.
607    * @return int The style of the font of the legend's labels.
608    */

609   public final int getLegendLabelsFontStyle() {
610     return legendLabelsFontStyle;
611   }
612
613
614   /**
615    * Gets whether a gap between the legend's bullets or labels exists in
616    * their vertical placement.
617    * @return boolean If true, a gap exists.
618    */

619   public final boolean getLegendBetweenLabelsOrBulletsGapExistence() {
620     return legendBetweenLabelsOrBulletsGapExistence;
621   }
622
623
624   /**
625    * Gets the thickness of the gap between the legend's bullets or labels
626    * exists in their vertical placement, for the chart's model size.
627    * @return int The model thickness of the gap.
628    */

629   public final int getLegendBetweenLabelsOrBulletsGapThicknessModel() {
630     return legendBetweenLabelsOrBulletsGapThicknessModel;
631   }
632
633
634   /**
635    * Gets whether the gap between the legend's bullets and labels exists
636    * in their horizontal placement.
637    * @return boolean If true, a gap exists.
638    */

639   public final boolean getLegendBetweenLabelsAndBulletsGapExistence() {
640     return legendBetweenLabelsAndBulletsGapExistence;
641   }
642
643
644   /**
645    * Gets the thickness of the gap between the legend's bullets and labels
646    * in their horizontal placement, for the chart's model size.
647    * @return int The model thickness of teh gap.
648    */

649   public final int getLegendBetweenLabelsAndBulletsGapThicknessModel() {
650     return legendBetweenLabelsAndBulletsGapThicknessModel;
651   }
652
653
654   /**
655    * Gets whether a thin line is painted around the legend's bullets.
656    * @return boolean If true, the legend's bullets will be outlined.
657    */

658   public final boolean getLegendBulletsOutlineExistence() {
659     return legendBulletsOutlineExistence;
660   }
661
662
663   /**
664    * Gets the color of the legend's bullets outline.
665    * @return Color The color of the legend's bullets outline.
666    */

667   public final Color JavaDoc getLegendBulletsOutlineColor() {
668     return legendBulletsOutlineColor;
669   }
670
671
672   /**
673    * Gets the size of the legend's bullets for the chart's model size.
674    * @return Dimension The size of the legend's bullets.
675    */

676   public final Dimension JavaDoc getLegendBulletsSizeModel() {
677     return legendBulletsSizeModel;
678   }
679
680
681   /**
682    * Gets whether this object needs to be updated with new properties.
683    * @param chart2D The object that may need to be updated.
684    * @return If true then needs update.
685    */

686   final boolean getChart2DNeedsUpdate (Chart2D chart2D) {
687
688     if (needsUpdate) return true;
689
690     int index = -1;
691     if ((index = chart2DVector.indexOf (chart2D)) != -1) {
692       return ((Boolean JavaDoc)needsUpdateVector.get (index)).booleanValue();
693     }
694
695     return false;
696   }
697
698
699   /**
700    * Adds a Chart2D to the set of objects using these properties.
701    * @param chart2D The Object2D to add.
702    */

703   final void addChart2D (Chart2D chart2D) {
704
705     if (!chart2DVector.contains (chart2D)) {
706       chart2DVector.add (chart2D);
707       needsUpdateVector.add (new Boolean JavaDoc (true));
708     }
709   }
710
711
712   /**
713    * Removes a Chart2D from the set of objects using these properties.
714    * @param chart2D The Object2D to add.
715    */

716   final void removeChart2D (Chart2D chart2D) {
717
718     int index = -1;
719     if ((index = chart2DVector.indexOf (chart2D)) != -1) {
720       chart2DVector.remove (index);
721       needsUpdateVector.remove (index);
722     }
723   }
724
725
726   /**
727    * Validates the properties of this object.
728    * If debug is true then prints a messages indicating whether each property is valid.
729    * Returns true if all the properties were valid and false otherwise.
730    * @param debug If true then will print status messages.
731    * @return If true then valid.
732    */

733   final boolean validate (boolean debug) {
734
735     if (debug) System.out.println ("Validating Chart2DProperties");
736
737     boolean valid = true;
738
739     if (legendLabelsTexts == null) {
740       valid = false;
741       if (debug) System.out.println ("LegendLabelsTexts == null");
742     }
743     if (legendBorderThicknessModel < 0) {
744       valid = false;
745       if (debug) System.out.println ("LegendBorderThicknessModel < 0");
746     }
747     if (legendBorderColor == null) {
748       valid = false;
749       if (debug) System.out.println ("LegendBorderColor == null");
750     }
751     if (legendGapThicknessModel < 0) {
752       valid = false;
753       if (debug) System.out.println ("LegendGapThicknessModel < 0");
754     }
755     if (legendBackgroundColor == null) {
756       valid = false;
757       if (debug) System.out.println ("LegendBackgroundColor == null");
758     }
759     if (legendLabelsFontPointModel < 0) {
760       valid = false;
761       if (debug) System.out.println ("LegendLabelsFontPointModel < 0");
762     }
763     if (legendLabelsFontName == null || !isFontNameExists (legendLabelsFontName)) {
764       valid = false;
765       if (debug) System.out.println ("Problem with LegendLabelsFontName");
766     }
767     if (legendLabelsFontColor == null) {
768       valid = false;
769       if (debug) System.out.println ("LegendLabelsFontColor == null");
770     }
771     if (legendLabelsFontStyle != Font.PLAIN && legendLabelsFontStyle != Font.ITALIC &&
772       legendLabelsFontStyle != Font.BOLD && legendLabelsFontStyle != (Font.ITALIC|Font.BOLD)) {
773       valid = false;
774       if (debug) System.out.println ("Problem with LegendLabelsFontStyle");
775     }
776     if (legendBetweenLabelsOrBulletsGapThicknessModel < 0) {
777       valid = false;
778       if (debug) System.out.println ("LegendBetweenLabelsOrBulletsGapThicknessModel < 0");
779     }
780     if (legendBetweenLabelsAndBulletsGapThicknessModel < 0) {
781       valid = false;
782       if (debug) System.out.println ("LegendBetweenLabelsAndBulletsGapThicknessModel < 0");
783     }
784     if (legendBulletsOutlineColor == null) {
785       valid = false;
786       if (debug) System.out.println ("LegendBulletsOutlineColor == null");
787     }
788     if (legendBulletsSizeModel == null ||
789       legendBulletsSizeModel.width < 0 || legendBulletsSizeModel.height < 0) {
790       valid = false;
791       if (debug) System.out.println ("Problem with LegendBulletsSizeModel");
792     }
793
794     if (debug) {
795       if (valid) System.out.println ("LegendProperties was valid");
796       else System.out.println ("LegendProperties was invalid");
797     }
798
799     return valid;
800   }
801
802
803   /**
804    * Updates the properties of this Chart2D.
805    * @param chart2D The object to update.
806    */

807   final void updateChart2D (Chart2D chart2D) {
808
809     if (getChart2DNeedsUpdate (chart2D)) {
810
811       if (needsUpdate) {
812         needsUpdate = false;
813         for (int i = 0; i < needsUpdateVector.size(); ++i) {
814           needsUpdateVector.set (i, new Boolean JavaDoc (true));
815         }
816       }
817
818       int index = -1;
819       if ((index = chart2DVector.indexOf (chart2D)) != -1) {
820         needsUpdateVector.set (index, new Boolean JavaDoc (false));
821       }
822     }
823   }
824 }
Popular Tags