KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.Vector JavaDoc;
30 import java.awt.Font JavaDoc;
31
32
33 /**
34  * A data structure for holding the properties common to all PieChart2D charts.
35  * A PieChart2D object is an enclosed are with a title, pie sectors, pie labels, and a legend.
36  * Pass this to any number of PieChart2D objects.
37  */

38 final public class PieChart2DProperties extends Properties {
39
40
41   /**
42    * Indicates the pie numbers labels should have raw numbers.
43    */

44   public static final int RAW = 1;
45
46   /**
47    * Indicates the pie numbers labels should have percent ratios.
48    */

49   public static final int PERCENT = 2;
50
51   /**
52    * Signifies left.
53    */

54   public static final int LEFT = 0;
55
56   /**
57    * Signifies right.
58    */

59   public static final int RIGHT = 1;
60
61   /**
62    * Signifies top.
63    */

64   public static final int TOP = 2;
65
66   /**
67    * Signifies bottom.
68    */

69   public static final int BOTTOM = 3;
70
71   /**
72    * Signifies none.
73    */

74   public static final int NONE = 6;
75
76   /**
77    * The default is true.
78    */

79   public static final boolean CHART_BETWEEN_PIE_LABELS_AND_PIE_GAP_EXISTENCE_DEFAULT = true;
80
81   /**
82    * The default is 6.
83    */

84   public static final int CHART_BETWEEN_PIE_LABELS_AND_PIE_GAP_THICKNESS_MODEL_DEFAULT = 6;
85
86   /**
87    * The default is 30.
88    */

89   public static final int PIE_PREFERRED_SIZE_DEFAULT = 30;
90
91   /**
92    * The default is false.
93    */

94   public static final boolean PIE_SECTORS_OUTLINE_EXISTENCE_DEFAULT = false;
95
96   /**
97    * The default is Color.black.
98    */

99   public static final Color JavaDoc PIE_SECTORS_OUTLINE_COLOR_DEFAULT = Color.black;
100
101   /**
102    * The default is true.
103    */

104   public static final boolean PIE_LABELS_EXISTENCE_DEFAULT = true;
105
106   /**
107    * The default is RAW + PERCENT.
108    */

109   public static final int PIE_LABELS_TYPE_DEFAULT = RAW + PERCENT;
110
111   /**
112    * The default is true.
113    */

114   public static final boolean PIE_LABELS_BETWEEN_LABELS_GAP_EXISTENCE_DEFAULT = true;
115
116   /**
117    * The default is 3.
118    */

119   public static final int PIE_LABELS_BETWEEN_LABELS_GAP_THICKNESS_MODEL_DEFAULT = 3;
120
121   /**
122    * The default is true.
123    */

124   public static final boolean PIE_LABELS_POINTS_GAP_OFFSET_EXISTENCE_DEFAULT = true;
125
126   /**
127    * The default is .50f.
128    */

129   public static final float PIE_LABELS_POINTS_GAP_OFFSET_MODEL_RATIO_DEFAULT = .50f;
130
131   /**
132    * The default is .125f.
133    */

134   public static final float PIE_LABELS_POINTS_PIE_SECTORS_DEPTH_RATIO_DEFAULT = .125f;
135
136   /**
137    * The default is .25f.
138    */

139   public static final float PIE_LABELS_POINTS_BETWEEN_PIE_AND_LABEL_GAPS_DEPTH_RATIO_DEFAULT = .25f;
140
141   /**
142    * The default is true.
143    */

144   public static final boolean PIE_LABELS_LINES_EXISTENCE_DEFAULT = true;
145
146   /**
147    * The default is 1.
148    */

149   public static final int PIE_LABELS_LINES_THICKNESS_MODEL_DEFAULT = 1;
150
151   /**
152    * The default is Color.black.
153    */

154   public static final Color JavaDoc PIE_LABELS_LINES_COLOR_DEFAULT = Color.black;
155
156   /**
157    * The default is false.
158    */

159   public static final boolean PIE_LABELS_LINES_DOTS_EXISTENCE_DEFAULT = false;
160
161   /**
162    * The default is 2.
163    */

164   public static final int PIE_LABELS_LINES_DOTS_THICKNESS_MODEL_DEFAULT = 2;
165
166   /**
167    * The default is Color.black.
168    */

169   public static final Color JavaDoc PIE_LABELS_LINES_DOTS_COLOR_DEFAULT = Color.black;
170
171   /**
172    * The default is TOP.
173    */

174   public static final int PIE_SECTOR_LIGHT_SOURCE_DEFAULT = TOP;
175
176   /**
177    * The default is 10.
178    */

179   public final static int PIE_LABELS_FONT_POINT_MODEL_DEFAULT = 10;
180
181   /**
182    * The default is "SansSerif".
183    */

184   public final static String JavaDoc PIE_LABELS_FONT_NAME_DEFAULT = "SansSerif";
185
186   /**
187    * The default is Color.black.
188    */

189   public final static Color JavaDoc PIE_LABELS_FONT_COLOR_DEFAULT = Color.black;
190
191   /**
192    * The default is Font.PLAIN.
193    */

194   public final static int PIE_LABELS_FONT_STYLE_DEFAULT = Font.PLAIN;
195
196
197   private boolean chartBetweenPieLabelsAndPieGapExistence;
198   private int chartBetweenPieLabelsAndPieGapThicknessModel;
199   private int piePreferredSize;
200
201   private boolean pieLabelsExistence;
202   private int pieLabelsType;
203   private boolean pieLabelsBetweenLabelsGapExistence;
204   private int pieLabelsBetweenLabelsGapThicknessModel;
205   private boolean pieLabelsPointsGapOffsetExistence;
206   private float pieLabelsPointsGapOffsetModelRatio;
207   private float pieLabelsPointsPieSectorsDepthRatio;
208   private float pieLabelsPointsBetweenPieAndLabelGapsDepthRatio;
209
210   private boolean pieLabelsLinesExistence;
211   private int pieLabelsLinesThicknessModel;
212   private Color JavaDoc pieLabelsLinesColor;
213   private boolean pieLabelsLinesDotsExistence;
214   private int pieLabelsLinesDotsThicknessModel;
215   private Color JavaDoc pieLabelsLinesDotsColor;
216
217   private boolean pieSectorsOutlineExistence;
218   private Color JavaDoc pieSectorsOutlineColor;
219   private int pieSectorLightSource;
220
221   private int pieLabelsFontPointModel;
222   private String JavaDoc pieLabelsFontName;
223   private Color JavaDoc pieLabelsFontColor;
224   private int pieLabelsFontStyle;
225
226   private boolean needsUpdate = true;
227   private final Vector JavaDoc needsUpdateVector = new Vector JavaDoc (5, 5);
228   private final Vector JavaDoc pieChart2DVector = new Vector JavaDoc (5, 5);
229
230
231   /**
232    * Creates a PieChart2DProperties object with the documented default values.
233    */

234   public PieChart2DProperties() {
235
236     needsUpdate = true;
237     setPieChart2DPropertiesToDefaults();
238   }
239
240
241   /**
242    * Creates a PieChart2DProperties object with property values copied from another object.
243    * The copying is a deep copy.
244    * @param pieChart2DProps The properties to copy.
245    */

246   public PieChart2DProperties (PieChart2DProperties pieChart2DProps) {
247
248     needsUpdate = true;
249     setPieChart2DProperties (pieChart2DProps);
250   }
251
252
253   /**
254    * Sets all properties to their default values.
255    */

256   public final void setPieChart2DPropertiesToDefaults() {
257
258     needsUpdate = true;
259     setChartBetweenPieLabelsAndPieGapExistence (
260       CHART_BETWEEN_PIE_LABELS_AND_PIE_GAP_EXISTENCE_DEFAULT);
261     setChartBetweenPieLabelsAndPieGapThicknessModel (
262       CHART_BETWEEN_PIE_LABELS_AND_PIE_GAP_THICKNESS_MODEL_DEFAULT);
263     setPiePreferredSize (PIE_PREFERRED_SIZE_DEFAULT);
264     setPieSectorsOutlineExistence (PIE_SECTORS_OUTLINE_EXISTENCE_DEFAULT);
265     setPieSectorsOutlineColor (PIE_SECTORS_OUTLINE_COLOR_DEFAULT);
266     setPieLabelsExistence (PIE_LABELS_EXISTENCE_DEFAULT);
267     setPieLabelsType (PIE_LABELS_TYPE_DEFAULT);
268     setPieLabelsBetweenLabelsGapExistence (PIE_LABELS_BETWEEN_LABELS_GAP_EXISTENCE_DEFAULT);
269     setPieLabelsBetweenLabelsGapThicknessModel (
270       PIE_LABELS_BETWEEN_LABELS_GAP_THICKNESS_MODEL_DEFAULT);
271     setPieLabelsPointsGapOffsetExistence (
272       PIE_LABELS_POINTS_GAP_OFFSET_EXISTENCE_DEFAULT);
273     setPieLabelsPointsGapOffsetModelRatio (
274       PIE_LABELS_POINTS_GAP_OFFSET_MODEL_RATIO_DEFAULT);
275     setPieLabelsPointsPieSectorsDepthRatio (PIE_LABELS_POINTS_PIE_SECTORS_DEPTH_RATIO_DEFAULT);
276     setPieLabelsPointsBetweenPieAndLabelGapsDepthRatio (
277       PIE_LABELS_POINTS_BETWEEN_PIE_AND_LABEL_GAPS_DEPTH_RATIO_DEFAULT);
278     setPieLabelsLinesExistence (PIE_LABELS_LINES_EXISTENCE_DEFAULT);
279     setPieLabelsLinesThicknessModel (PIE_LABELS_LINES_THICKNESS_MODEL_DEFAULT);
280     setPieLabelsLinesColor (PIE_LABELS_LINES_COLOR_DEFAULT);
281     setPieLabelsLinesDotsExistence (PIE_LABELS_LINES_DOTS_EXISTENCE_DEFAULT);
282     setPieLabelsLinesDotsThicknessModel (PIE_LABELS_LINES_DOTS_THICKNESS_MODEL_DEFAULT);
283     setPieLabelsLinesDotsColor (PIE_LABELS_LINES_DOTS_COLOR_DEFAULT);
284     setPieSectorLightSource (PIE_SECTOR_LIGHT_SOURCE_DEFAULT);
285     setPieLabelsFontPointModel (PIE_LABELS_FONT_POINT_MODEL_DEFAULT);
286     setPieLabelsFontName (PIE_LABELS_FONT_NAME_DEFAULT);
287     setPieLabelsFontColor (PIE_LABELS_FONT_COLOR_DEFAULT);
288     setPieLabelsFontStyle (PIE_LABELS_FONT_STYLE_DEFAULT);
289   }
290
291
292   /**
293    * Sets all the properties to be the values of another PieChart2DProperties object.
294    * The copying is a deep copy.
295    * @param pieChart2DProps The properties to copy.
296    */

297   public final void setPieChart2DProperties (PieChart2DProperties pieChart2DProps) {
298
299     needsUpdate = true;
300     setChartBetweenPieLabelsAndPieGapExistence (
301       pieChart2DProps.getChartBetweenPieLabelsAndPieGapExistence());
302     setChartBetweenPieLabelsAndPieGapThicknessModel (
303       pieChart2DProps.getChartBetweenPieLabelsAndPieGapThicknessModel());
304     setPiePreferredSize (pieChart2DProps.getPiePreferredSize());
305     setPieSectorsOutlineExistence (pieChart2DProps.getPieSectorsOutlineExistence());
306     setPieSectorsOutlineColor (pieChart2DProps.getPieSectorsOutlineColor());
307     setPieLabelsExistence (pieChart2DProps.getPieLabelsExistence());
308     setPieLabelsType (pieChart2DProps.getPieLabelsType());
309     setPieLabelsBetweenLabelsGapExistence (pieChart2DProps.getPieLabelsBetweenLabelsGapExistence());
310     setPieLabelsBetweenLabelsGapThicknessModel (
311       pieChart2DProps.getPieLabelsBetweenLabelsGapThicknessModel());
312     setPieLabelsPointsGapOffsetExistence (
313       pieChart2DProps.getPieLabelsPointsGapOffsetExistence());
314     setPieLabelsPointsGapOffsetModelRatio (
315       pieChart2DProps.getPieLabelsPointsGapOffsetModelRatio());
316     setPieLabelsPointsPieSectorsDepthRatio (
317       pieChart2DProps.getPieLabelsPointsPieSectorsDepthRatio());
318     setPieLabelsPointsBetweenPieAndLabelGapsDepthRatio (
319       pieChart2DProps.getPieLabelsPointsBetweenPieAndLabelGapsDepthRatio());
320     setPieLabelsLinesExistence (pieChart2DProps.getPieLabelsLinesExistence());
321     setPieLabelsLinesThicknessModel (pieChart2DProps.getPieLabelsLinesThicknessModel());
322     setPieLabelsLinesColor (pieChart2DProps.getPieLabelsLinesColor());
323     setPieLabelsLinesDotsExistence (pieChart2DProps.getPieLabelsLinesDotsExistence());
324     setPieLabelsLinesDotsThicknessModel (pieChart2DProps.getPieLabelsLinesDotsThicknessModel());
325     setPieLabelsLinesDotsColor (pieChart2DProps.getPieLabelsLinesDotsColor());
326     setPieSectorLightSource (pieSectorLightSource);
327     setPieLabelsFontPointModel (pieChart2DProps.getPieLabelsFontPointModel());
328     setPieLabelsFontName (pieChart2DProps.getPieLabelsFontName());
329     setPieLabelsFontColor (pieChart2DProps.getPieLabelsFontColor());
330     setPieLabelsFontStyle (pieChart2DProps.getPieLabelsFontStyle());
331   }
332
333
334   /**
335    * Sets from which direction the light is coming for shading of the pie sectors.
336    * Uses fields TOP, BOTTOM, LEFT, RIGHT, and NONE.
337    * @param source The direction of the light.
338    */

339   final void setPieSectorLightSource (int source) {
340
341     needsUpdate = true;
342     pieSectorLightSource = source;
343   }
344
345
346   /**
347    * Specifies whether the gap between each pie label and the pie exists.
348    * @param existence If true, the gap exists.
349    */

350   public final void setChartBetweenPieLabelsAndPieGapExistence (boolean existence) {
351
352     needsUpdate = true;
353     chartBetweenPieLabelsAndPieGapExistence = existence;
354   }
355
356
357   /**
358    * Specifies the thickness of the gap between each pie label and the pie for the chart's model
359    * size.
360    * @param int The model thickness of the gap.
361    */

362   public final void setChartBetweenPieLabelsAndPieGapThicknessModel (int thickness) {
363
364     needsUpdate = true;
365     chartBetweenPieLabelsAndPieGapThicknessModel = thickness;
366   }
367
368
369   /**
370    * Specifies the preffered size of the pie in the pie chart. A pie does not
371    * have a calculable preferred size so one must be explicitly provided in this
372    * method. The size indicates the length of the diameter of the pie.
373    * This length must be >= 10.
374    * @param size The preferred size of the pie.
375    */

376   public final void setPiePreferredSize (int size) {
377
378     needsUpdate = true;
379     piePreferredSize = size;
380   }
381
382
383   /**
384    * Specifies whether the sectors of the pie should have a thin outline.
385    * @param existence If true, then the pie will have a thin outline.
386    */

387   public final void setPieSectorsOutlineExistence (boolean existence) {
388
389     needsUpdate = true;
390     pieSectorsOutlineExistence = existence;
391   }
392
393
394   /**
395    * Specifies the color of the outline of the pie sectors.
396    * @param color The color of the outline of the pie sectors.
397    */

398   public final void setPieSectorsOutlineColor (Color JavaDoc color) {
399
400     needsUpdate = true;
401     pieSectorsOutlineColor = color;
402   }
403
404
405   /**
406    * Specifies whether the pie sectors of the pie chart will be labeled.
407    * The labels can be raw numbers or percents. They encircle the pie.
408    * Methods that specify properties of these labels are setPieLabelsType (int)
409    * and Chart2DProperties.setChartDataLabelsPrecision (int).
410    * @param existence If true, the pie sectors will be labeled.
411    */

412   public final void setPieLabelsExistence (boolean existence) {
413
414     needsUpdate = true;
415     pieLabelsExistence = existence;
416   }
417
418
419   /**
420    * Specifies the type of pie sector labels of the pie chart. The possible
421    * types are RAW, PERCENT, and RAW+PERCENT. The format for RAW+PERCENT is
422    * v (p%) where v is a data value and p is a percent value.
423    * @param type The type of the pie labels.
424    */

425   public final void setPieLabelsType (int type) {
426
427     needsUpdate = true;
428     pieLabelsType = type;
429   }
430
431
432   /**
433    * Specifies whether a gap between each pie sector label exists.
434    * The gap is applied both vertically and horizontally.
435    * @param existence If true, then the gap exists.
436    */

437   public final void setPieLabelsBetweenLabelsGapExistence (boolean existence) {
438
439     needsUpdate = true;
440     pieLabelsBetweenLabelsGapExistence = existence;
441   }
442
443
444   /**
445    * Specifies the thickness of the gap between each pie label for the chart's
446    * model size.
447    * @param thickness The thickness of the gap.
448    */

449   public final void setPieLabelsBetweenLabelsGapThicknessModel (int thickness) {
450
451     needsUpdate = true;
452     pieLabelsBetweenLabelsGapThicknessModel = thickness;
453   }
454
455
456   /**
457    * Specifies whether the gap between each pie label and a point from which a
458    * line may be drawn and/or on which a dot may be placed to relate each label
459    * with a particular pie sector exists.
460    * @param existence If true, the gap exists.
461    */

462   public final void setPieLabelsPointsGapOffsetExistence (boolean existence) {
463
464     needsUpdate = true;
465     pieLabelsPointsGapOffsetExistence = existence;
466   }
467
468
469   /**
470    * Specifies the ratio on the gap between the pie and the labels, for the gap between the
471    * labels and the labels point.
472    * @param ratio The ratio.
473    */

474   public final void setPieLabelsPointsGapOffsetModelRatio (float ratio) {
475
476     needsUpdate = true;
477     pieLabelsPointsGapOffsetModelRatio = ratio;
478   }
479
480
481   /**
482    * Specifies the depth within each pie sector a point is placed from which a
483    * line may be drawn and/or on which a dot may be placed to relate each label
484    * with a particular pie sector for the chart's model size.
485    * @param ratio The depth into the pie sector to the pie sector depth for
486    * the point's placement.
487    */

488   public final void setPieLabelsPointsPieSectorsDepthRatio (float ratio) {
489
490     needsUpdate = true;
491     pieLabelsPointsPieSectorsDepthRatio = ratio;
492   }
493
494
495   /**
496    * Specifies the depth within each gap between each pie sector and label,
497    * from each pie, of the point at which a line coming from a label and a line
498    * coming from a pie, meet.
499    * @param ratio The depth into the gap where the lines labeling lines meet.
500    */

501   public final void setPieLabelsPointsBetweenPieAndLabelGapsDepthRatio (float ratio) {
502
503     needsUpdate = true;
504     pieLabelsPointsBetweenPieAndLabelGapsDepthRatio = ratio;
505   }
506
507
508   /**
509    * Specifies whether lines relating each pie sector with its particular label exists.
510    * @param existence If true, then the pie labels lines exist.
511    */

512   public final void setPieLabelsLinesExistence (boolean existence) {
513
514     needsUpdate = true;
515     pieLabelsLinesExistence = existence;
516   }
517
518
519   /**
520    * Specifies the thickness of the lines relating each pie sector with its
521    * particular label for the model size of the chart.
522    * @param thickness The thickness of the line.
523    */

524   public final void setPieLabelsLinesThicknessModel (int thickness) {
525
526     needsUpdate = true;
527     pieLabelsLinesThicknessModel = thickness;
528   }
529
530
531   /**
532    * Specifies the color of the lines relating each pie sector with its particular label.
533    * @param color The color of the lines.
534    */

535   public final void setPieLabelsLinesColor (Color JavaDoc color) {
536
537     needsUpdate = true;
538     pieLabelsLinesColor = color;
539   }
540
541
542   /**
543    * Specifies whether dots exist at the beginning and ending of the lines
544    * relating each pie sector with its particular label.
545    * @param existence If true, then two dots per line will exist.
546    */

547   public final void setPieLabelsLinesDotsExistence (boolean existence) {
548
549     needsUpdate = true;
550     pieLabelsLinesDotsExistence = existence;
551   }
552
553
554   /**
555    * Specifies the thickness (ie diameter) of the dots that exist at the
556    * beginning and ending of the lines releating each pie sector with its
557    * particular label for the chart's model size.
558    * @param thickness The thickness of the dots.
559    */

560   public final void setPieLabelsLinesDotsThicknessModel (int thickness) {
561
562     needsUpdate = true;
563     pieLabelsLinesDotsThicknessModel = thickness;
564   }
565
566
567   /**
568    * Specifies the color of the dots that exist at the beginning and ending of
569    * the lines relating each pie sector with its particular label.
570    * @param color The color of the dots.
571    */

572   public final void setPieLabelsLinesDotsColor (Color JavaDoc color) {
573
574     needsUpdate = true;
575     pieLabelsLinesDotsColor = color;
576   }
577
578
579   /**
580    * Sets the point of the font of the pie labels for the chart's model size.
581    * @param point The model font point of the pie labels.
582    */

583   public final void setPieLabelsFontPointModel (int point) {
584
585     needsUpdate = true;
586     pieLabelsFontPointModel = point;
587   }
588
589   /**
590    * Sets name of the font of the pie labels.
591    * Accepts all values accepted by java.awt.Font.
592    * @param name The name of the font for the pie labels.
593    */

594   public final void setPieLabelsFontName (String JavaDoc name) {
595
596     needsUpdate = true;
597     pieLabelsFontName = name;
598   }
599
600
601   /**
602    * Sets the color of the font of the pie labels.
603    * @param color The color of the font of the pie labels.
604    */

605   public final void setPieLabelsFontColor (Color JavaDoc color) {
606
607     needsUpdate = true;
608     pieLabelsFontColor = color;
609   }
610
611
612   /**
613    * Sets the style of the font of the pie labels.
614    * Accepts all values that java.awt.Font accepts.
615    * @param style The style of the font of the pie labels.
616    */

617   public final void setPieLabelsFontStyle (int style) {
618
619     needsUpdate = true;
620     pieLabelsFontStyle = style;
621   }
622
623
624   /**
625    * Returns whether the gap between each pie label and the pie exists.
626    * @return If true, the gap exists.
627    */

628   public final boolean getChartBetweenPieLabelsAndPieGapExistence() {
629     return chartBetweenPieLabelsAndPieGapExistence;
630   }
631
632
633   /**
634    * Returns the thickness of the gap between each pie label and the pie
635    * for the chart's model size.
636    * @return The model thickness of the gap.
637    */

638   public final int getChartBetweenPieLabelsAndPieGapThicknessModel() {
639     return chartBetweenPieLabelsAndPieGapThicknessModel;
640   }
641
642
643   /**
644    * Returns the preffered size of the pie in the pie chart. A pie does not
645    * have a calculable preferred size so one must be explicitly provided in this
646    * method. The size indicates the length of the diameter of the pie.
647    * This length must be >= 10.
648    * @return The preferred size of the pie.
649    */

650   public final int getPiePreferredSize() {
651     return piePreferredSize;
652   }
653
654
655   /**
656    * Returns whether the sectors of the pie should have a thin outline.
657    * @return If true, then the pie will have a thin outline.
658    */

659   public final boolean getPieSectorsOutlineExistence() {
660     return pieSectorsOutlineExistence;
661   }
662
663
664   /**
665    * Returns the color of the outline of the pie sectors.
666    * @return The color of the outline of the pie sectors.
667    */

668   public final Color JavaDoc getPieSectorsOutlineColor() {
669     return pieSectorsOutlineColor;
670   }
671
672
673   /**
674    * Returns whether the pie sectors of the pie chart will be labeled.
675    * The labels can be raw numbers or percents. They encircle the pie.
676    * Methods that specify properties of these labels are setPieLabelsType (int)
677    * and Chart2DProperties.setChartDataLabelsPrecision (int).
678    * @return If true, the pie sectors will be labeled.
679    */

680   public final boolean getPieLabelsExistence() {
681     return pieLabelsExistence;
682   }
683
684
685   /**
686    * Returns the type of pie sector labels of the pie chart. The possible
687    * types are RAW, PERCENT, and RAW+PERCENT. The format for RAW+PERCENT is
688    * v (p%) where v is a data value and p is a percent value.
689    * @return The type of the pie labels.
690    */

691   public final int getPieLabelsType() {
692     return pieLabelsType;
693   }
694
695
696   /**
697    * Returns whether a gap between each pie sector label exists.
698    * The gap is applied both vertically and horizontally.
699    * @return If true, then the gap exists.
700    */

701   public final boolean getPieLabelsBetweenLabelsGapExistence() {
702     return pieLabelsBetweenLabelsGapExistence;
703   }
704
705
706   /**
707    * Returns the thickness of the gap between each pie label for the chart's model size.
708    * @return The thickness of the gap.
709    */

710   public final int getPieLabelsBetweenLabelsGapThicknessModel() {
711     return pieLabelsBetweenLabelsGapThicknessModel;
712   }
713
714
715   /**
716    * Returns whether the gap between each pie label and a point from which a
717    * line may be drawn and/or on which a dot may be placed to relate each label
718    * with a particular pie sector exists.
719    * @return If true, the gap exists.
720    */

721   public final boolean getPieLabelsPointsGapOffsetExistence() {
722     return pieLabelsPointsGapOffsetExistence;
723   }
724
725
726   /**
727    * Gets the ratio on the gap between the pie and the labels, for the gap between the
728    * labels and the labels point.
729    * @return The ratio.
730    */

731   public final float getPieLabelsPointsGapOffsetModelRatio() {
732     return pieLabelsPointsGapOffsetModelRatio;
733   }
734
735
736   /**
737    * Returns the depth within each pie sector a point is placed from which a
738    * line may be drawn and/or on which a dot may be placed to relate each label
739    * with a particular pie sector for the chart's model size.
740    * @return The depth into the pie sector to the pie sector depth for the point's placement.
741    */

742   public final float getPieLabelsPointsPieSectorsDepthRatio() {
743     return pieLabelsPointsPieSectorsDepthRatio;
744   }
745
746
747   /**
748    * Returns the depth within each gap between each pie sector and label,
749    * from each pie, of the point at which a line coming from a label and a line
750    * coming from a pie, meet.
751    * @return The depth into the gap where the lines labeling lines meet.
752    */

753   public final float getPieLabelsPointsBetweenPieAndLabelGapsDepthRatio() {
754     return pieLabelsPointsBetweenPieAndLabelGapsDepthRatio;
755   }
756
757
758   /**
759    * Returns whether lines relating each pie sector with its particular label exists.
760    * @return If true, then the pie labels lines exist.
761    */

762   public final boolean getPieLabelsLinesExistence() {
763     return pieLabelsLinesExistence;
764   }
765
766
767   /**
768    * Returns the thickness of the lines relating each pie sector with its
769    * particular label for the model size of the chart.
770    * @return The thickness of the line.
771    */

772   public final int getPieLabelsLinesThicknessModel() {
773     return pieLabelsLinesThicknessModel;
774   }
775
776
777   /**
778    * Returns the color of the lines relating each pie sector with its particular label.
779    * @return The color of the lines.
780    */

781   public final Color JavaDoc getPieLabelsLinesColor() {
782     return pieLabelsLinesColor;
783   }
784
785
786   /**
787    * Returns whether dots exist at the beginning and ending of the lines
788    * relating each pie sector with its particular label.
789    * @return If true, then two dots per line will exist.
790    */

791   public final boolean getPieLabelsLinesDotsExistence() {
792     return pieLabelsLinesDotsExistence;
793   }
794
795
796   /**
797    * Returns the thickness (ie diameter) of the dots that exist at the
798    * beginning and ending of the lines releating each pie sector with its
799    * particular label for the chart's model size.
800    * @return The thickness of the dots.
801    */

802   public final int getPieLabelsLinesDotsThicknessModel() {
803     return pieLabelsLinesDotsThicknessModel;
804   }
805
806
807   /**
808    * Returns the color of the dots that exist at the beginning and ending of
809    * the lines relating each pie sector with its particular label.
810    * @return The color of the dots.
811    */

812   public final Color JavaDoc getPieLabelsLinesDotsColor() {
813     return pieLabelsLinesDotsColor;
814   }
815
816
817   /**
818    * Gets from which direction the light is coming for shading of the pie sectors.
819    * Uses fields TOP, BOTTOM, LEFT, RIGHT, and NONE.
820    * @return The direction of the light.
821    */

822   public final int getPieSectorLightSource() {
823     return pieSectorLightSource;
824   }
825
826
827   /**
828    * Gets the point of the font of the pie labels for the chart's model size.
829    * @return int The model font point of the pie labels.
830    */

831   public final int getPieLabelsFontPointModel() {
832     return pieLabelsFontPointModel;
833   }
834
835   /**
836    * Gets name of the font of the pie labels.
837    * Accepts all values accepted by java.awt.Font.
838    * @return String The name of the font for the pie labels.
839    */

840   public final String JavaDoc getPieLabelsFontName() {
841     return pieLabelsFontName;
842   }
843
844
845   /**
846    * Gets the color of the font of the pie labels.
847    * @return Color The color of the font of the pie labels.
848    */

849   public final Color JavaDoc getPieLabelsFontColor() {
850     return pieLabelsFontColor;
851   }
852
853
854   /**
855    * Gets the style of the font of the pie labels.
856    * Accepts all values that java.awt.Font accepts.
857    * @return int The style of the font of the pie labels.
858    */

859   public final int getPieLabelsFontStyle() {
860     return pieLabelsFontStyle;
861   }
862
863
864   /**
865    * Gets whether this object needs to be updated with new properties.
866    * @param pieChart2D The object that might need to be updated.
867    * @return If true the object needs to be udpated.
868    */

869   final boolean getPieChart2DNeedsUpdate (PieChart2D pieChart2D) {
870
871     if (needsUpdate) return true;
872     int index = -1;
873     if ((index = pieChart2DVector.indexOf (pieChart2D)) != -1) {
874       return ((Boolean JavaDoc)needsUpdateVector.get (index)).booleanValue();
875     }
876     return false;
877   }
878
879
880   /**
881    * Adds a PieChart2D to the set of objects using these properties.
882    * @param pieChart2D The object to add.
883    */

884   final void addPieChart2D (PieChart2D pieChart2D) {
885
886     if (!pieChart2DVector.contains (pieChart2D)) {
887       pieChart2DVector.add (pieChart2D);
888       needsUpdateVector.add (new Boolean JavaDoc (true));
889     }
890   }
891
892
893   /**
894    * Removes a PieChart2D from the set of objects using these properties.
895    * @param pieChart2D The object to remove.
896    */

897   final void removePieChart2D (PieChart2D pieChart2D) {
898
899     int index = -1;
900     if ((index = pieChart2DVector.indexOf (pieChart2D)) != -1) {
901       pieChart2DVector.remove (index);
902       needsUpdateVector.remove (index);
903     }
904   }
905
906
907   /**
908    * Validates the properties of this object.
909    * If debug is true then prints a messages indicating whether each property is valid.
910    * Returns true if all the properties were valid and false otherwise.
911    * @param debug If true then will print status messages.
912    * @return If true then valid.
913    */

914   final boolean validate (boolean debug) {
915
916     if (debug) System.out.println ("Validating PieChart2DProperties");
917
918     boolean valid = true;
919
920     if (chartBetweenPieLabelsAndPieGapThicknessModel < 0) {
921       valid = false;
922       if (debug) System.out.println ("ChartBetweenPieLabelsAndPieGapThicknessModel < 0");
923     }
924     if (piePreferredSize < 0) {
925       valid = false;
926       if (debug) System.out.println ("Problem with PiePreferredSize");
927     }
928     if (pieLabelsType != RAW && pieLabelsType != PERCENT &&
929       pieLabelsType != (RAW + PERCENT)) {
930       valid = false;
931       if (debug) System.out.println ("Problem with PieLabelsType");
932     }
933     if (pieLabelsBetweenLabelsGapThicknessModel < 0) {
934       valid = false;
935       if (debug) System.out.println ("PieLabelsBetweenLabelsGapThicknessModel < 0");
936     }
937     if (pieLabelsPointsGapOffsetModelRatio < 0f ||
938       pieLabelsPointsGapOffsetModelRatio > 1f) {
939       valid = false;
940       if (debug) System.out.println ("Problem with PieLabelsPointsGapOffsetModelRatio");
941     }
942     if (pieLabelsPointsPieSectorsDepthRatio < 0f ||
943       pieLabelsPointsPieSectorsDepthRatio > 1f) {
944       valid = false;
945       if (debug) System.out.println ("Problem with pieLabelsPointsPieSectorsDepthRatio");
946     }
947     if (pieLabelsPointsBetweenPieAndLabelGapsDepthRatio < 0f ||
948       pieLabelsPointsBetweenPieAndLabelGapsDepthRatio > 1f) {
949       valid = false;
950       if (debug) System.out.println (
951         "Problem with pieLabelsPointsBetweenPieAndLabelGapsDepthRatio");
952     }
953     if (pieLabelsLinesThicknessModel < 0) {
954       valid = false;
955       if (debug) System.out.println ("PieLabelsLinesThicknessModel < 0");
956     }
957     if (pieLabelsLinesColor == null) {
958       valid = false;
959       if (debug) System.out.println ("PieLabelsLinesColor == null");
960     }
961     if (pieLabelsLinesDotsThicknessModel < 0) {
962       valid = false;
963       if (debug) System.out.println ("PieLabelsLinesDotsThicknessModel < 0");
964     }
965     if (pieLabelsLinesDotsColor == null) {
966       valid = false;
967       if (debug) System.out.println ("PieLabelsLinesDotsColor == null");
968     }
969     if (pieSectorsOutlineColor == null) {
970       valid = false;
971       if (debug) System.out.println ("PieSectorsOutlineColor == null");
972     }
973     if (pieSectorLightSource != TOP && pieSectorLightSource != BOTTOM &&
974       pieSectorLightSource != LEFT && pieSectorLightSource != RIGHT &&
975       pieSectorLightSource != NONE) {
976       valid = false;
977       if (debug) System.out.println ("Problem with PieSectorLightSource");
978     }
979     if (pieLabelsFontPointModel < 0) {
980       valid = false;
981       if (debug) System.out.println ("PieLabelsFontPointModel < 0");
982     }
983     if (pieLabelsFontName == null || !isFontNameExists (pieLabelsFontName)) {
984       valid = false;
985       if (debug) System.out.println ("Problem with PieLabelsFontName");
986     }
987     if (pieLabelsFontColor == null) {
988       valid = false;
989       if (debug) System.out.println ("PieLabelsFontColor == null");
990     }
991     if (pieLabelsFontStyle != Font.PLAIN && pieLabelsFontStyle != Font.ITALIC &&
992       pieLabelsFontStyle != Font.BOLD && pieLabelsFontStyle != (Font.ITALIC|Font.BOLD)) {
993       valid = false;
994       if (debug) System.out.println ("Problem with PieLabelsFontStyle");
995     }
996
997     if (debug) {
998       if (valid) System.out.println ("PieChart2DProperties was valid");
999       else System.out.println ("PieChart2DProperties was invalid");
1000    }
1001
1002    return valid;
1003  }
1004
1005
1006  /**
1007   * Updates the properties of this PieChart2D.
1008   * @param pieChart2D The object to update.
1009   */

1010  final void updatePieChart2D (PieChart2D pieChart2D) {
1011
1012    if (getPieChart2DNeedsUpdate (pieChart2D)) {
1013
1014      if (needsUpdate) {
1015        for (int i = 0; i < needsUpdateVector.size(); ++i) {
1016          needsUpdateVector.set (i, new Boolean JavaDoc (true));
1017        }
1018        needsUpdate = false;
1019      }
1020
1021      int index = -1;
1022      if ((index = pieChart2DVector.indexOf (pieChart2D)) != -1) {
1023        needsUpdateVector.set (index, new Boolean JavaDoc (false));
1024      }
1025    }
1026  }
1027}
Popular Tags