KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > LBChart2DFrameDemo


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 import net.sourceforge.chart2d.*;
25
26 import java.awt.Dimension JavaDoc;
27 import java.awt.Toolkit JavaDoc;
28 import java.awt.event.WindowAdapter JavaDoc;
29 import java.awt.event.WindowEvent JavaDoc;
30 import javax.swing.JApplet JavaDoc;
31 import javax.swing.JFrame JavaDoc;
32 import javax.swing.JTabbedPane JavaDoc;
33 import java.awt.Color JavaDoc;
34 import java.util.Random JavaDoc;
35
36
37 /**
38  * A Chart2D demo demonstrating the LBChart2D object.
39  * Container Class: JFrame<br>
40  * Program Types: Applet or Application<br>
41  */

42 public class LBChart2DFrameDemo extends JApplet JavaDoc {
43
44
45   private JFrame JavaDoc frame = null;
46   private static boolean isApplet = true;
47
48
49   /**
50    * For running as an application.
51    * Calls init() and start().
52    * @param args An unused parameter.
53    */

54   public static void main (String JavaDoc[] args) {
55
56     isApplet = false;
57     LBChart2DFrameDemo demo = new LBChart2DFrameDemo();
58     demo.init();
59     demo.start();
60     //exit on frame close event
61
}
62
63
64   /**
65    * Configure the chart and frame, and open the frame.
66    */

67   public void init() {
68
69     //Start configuring a JFrame GUI with a JTabbedPane for multiple chart panes
70
JTabbedPane JavaDoc panes = new JTabbedPane JavaDoc();
71
72     panes.addTab ("Bar", getChart2DDemoA());
73     panes.addTab ("Bar with Regions", getChart2DDemoB());
74     panes.addTab ("Bar with Trend Line", getChart2DDemoC());
75     panes.addTab ("Bar with Cat Coloring", getChart2DDemoD());
76     panes.addTab ("Bar True Stacked", getChart2DDemoE());
77     panes.addTab ("Line", getChart2DDemoF());
78     panes.addTab ("Line with Regions", getChart2DDemoG());
79     panes.addTab ("Filled Line True Stacked", getChart2DDemoH());
80     panes.addTab ("Line with Large Dataset", getChart2DDemoI());
81     panes.addTab ("Scatter / Dot", getChart2DDemoJ());
82     panes.addTab ("Line and Dot", getChart2DDemoK());
83     panes.addTab ("Standard Overlay", getChart2DDemoL());
84
85     //JTabbedPane specific GUI code
86
//Chart2D by default magnifies itself on user resize, the magnification
87
//raio is based on each chart's preferred size. So that all the charts
88
//have the same magnification ratio, we must make all the charts have the
89
//same preferred size. You can calculate each chart's preferred size
90
//dynamically (slower), OR you can pick a size that is at least a big as
91
//its dynamic preferred size and use this statically -- permanently.
92
//I recommend using dynamic calc while writing your code, then for
93
//production make sure to use the static code for the performance increase.
94
//Add a System.out.println (size) with the dynamic code, and use that size
95
//for your static code size.
96
//Also, setting the panes preferred size with a static size pushes
97
//calculation of charts in non-visible panes off, until they are visible.
98
//This means that start up time with a static panes size is the same as if
99
//you had only one Chart2D object.
100
boolean dynamicSizeCalc = false;
101     if (dynamicSizeCalc) {
102       int maxWidth = 0;
103       int maxHeight = 0;
104       for (int i = 0; i < panes.getTabCount(); ++i) {
105         Chart2D chart2D = (Chart2D)panes.getComponentAt (i);
106         chart2D.pack();
107         Dimension JavaDoc size = chart2D.getSize();
108         maxWidth = maxWidth > size.width ? maxWidth : size.width;
109         maxHeight = maxHeight > size.height ? maxHeight : size.height;
110       }
111       Dimension JavaDoc maxSize = new Dimension JavaDoc (maxWidth, maxHeight);
112       System.out.println (maxSize);
113       for (int i = 0; i < panes.getTabCount(); ++i) {
114         Chart2D chart2D = (Chart2D)panes.getComponentAt (i);
115         chart2D.setSize (maxSize);
116         chart2D.setPreferredSize (maxSize);
117       }
118       System.out.println (panes.getPreferredSize());
119     }
120     else {
121       Dimension JavaDoc maxSize = new Dimension JavaDoc (561, 214);
122       for (int i = 0; i < panes.getTabCount(); ++i) {
123         Chart2D chart2D = (Chart2D)panes.getComponentAt (i);
124         chart2D.setSize (maxSize);
125         chart2D.setPreferredSize (maxSize);
126       }
127       panes.setPreferredSize (new Dimension JavaDoc (566 + 5, 280 + 5)); //+ 5 slop
128
}
129
130     frame = new JFrame JavaDoc();
131     frame.getContentPane().add (panes);
132     frame.setTitle ("LBChart2DFrameDemo");
133     frame.addWindowListener (
134       new WindowAdapter JavaDoc() {
135         public void windowClosing (WindowEvent JavaDoc e) {
136           destroy();
137     } } );
138     frame.pack();
139     Dimension JavaDoc screenSize = Toolkit.getDefaultToolkit().getScreenSize();
140     frame.setLocation (
141       (screenSize.width - frame.getSize().width) / 2,
142       (screenSize.height - frame.getSize().height) / 2);
143   }
144
145
146   /**
147    * Shows the JFrame GUI.
148    */

149   public void start() {
150     frame.show();
151   }
152
153
154   /**
155    * Ends the application or applet.
156    */

157   public void destroy() {
158
159     if (frame != null) frame.dispose();
160     if (!isApplet) System.exit (0);
161   }
162
163
164   /**
165    * Builds the demo chart.
166    * @return The demo chart.
167    */

168   private Chart2D getChart2DDemoA() {
169
170     //<-- Begin Chart2D configuration -->
171

172     //Configure object properties
173
Object2DProperties object2DProps = new Object2DProperties();
174     object2DProps.setObjectTitleText ("Amperage Used Per Appliance");
175
176     //Configure chart properties
177
Chart2DProperties chart2DProps = new Chart2DProperties();
178     chart2DProps.setChartDataLabelsPrecision (-1);
179
180     //Configure legend properties
181
LegendProperties legendProps = new LegendProperties();
182     String JavaDoc[] legendLabels = {"2002", "2001", "2000"};
183     legendProps.setLegendLabelsTexts (legendLabels);
184
185     //Configure graph chart properties
186
GraphChart2DProperties graphChart2DProps = new GraphChart2DProperties();
187     String JavaDoc[] labelsAxisLabels = {"Computer", "Monitor", "AC", "Lighting", "Refrigerator"};
188     graphChart2DProps.setLabelsAxisLabelsTexts (labelsAxisLabels);
189     graphChart2DProps.setLabelsAxisTitleText ("Appliances");
190     graphChart2DProps.setNumbersAxisTitleText ("Amps on 120 Volt Line");
191
192     //Configure graph properties
193
GraphProperties graphProps = new GraphProperties();
194
195     //Configure dataset
196
Dataset dataset = new Dataset (3, 5, 1);
197     dataset.set (0, 0, 0, 3.5f);
198     dataset.set (0, 1, 0, 2.5f);
199     dataset.set (0, 2, 0, 10.0f);
200     dataset.set (0, 3, 0, 0.5f);
201     dataset.set (0, 4, 0, 2.0f);
202     dataset.set (1, 0, 0, 3.0f);
203     dataset.set (1, 1, 0, 2.0f);
204     dataset.set (1, 2, 0, 10.0f);
205     dataset.set (1, 3, 0, 1.0f);
206     dataset.set (1, 4, 0, 2.0f);
207     dataset.set (2, 0, 0, 2.5f);
208     dataset.set (2, 1, 0, 2.0f);
209     dataset.set (2, 2, 0, 10.5f);
210     dataset.set (2, 3, 0, 1.0f);
211     dataset.set (2, 4, 0, 2.5f);
212
213     //Configure graph component colors
214
MultiColorsProperties multiColorsProps = new MultiColorsProperties();
215
216     //Configure chart
217
LBChart2D chart2D = new LBChart2D();
218     chart2D.setObject2DProperties (object2DProps);
219     chart2D.setChart2DProperties (chart2DProps);
220     chart2D.setLegendProperties (legendProps);
221     chart2D.setGraphChart2DProperties (graphChart2DProps);
222     chart2D.addGraphProperties (graphProps);
223     chart2D.addDataset (dataset);
224     chart2D.addMultiColorsProperties (multiColorsProps);
225
226     //Optional validation: Prints debug messages if invalid only.
227
if (!chart2D.validate (false)) chart2D.validate (true);
228
229     //<-- End Chart2D configuration -->
230

231     return chart2D;
232   }
233
234
235   /**
236    * Builds the demo chart.
237    * @return The demo chart.
238    */

239   private Chart2D getChart2DDemoB() {
240
241     //<-- Begin Chart2D configuration -->
242

243     //Configure object properties
244
Object2DProperties object2DProps = new Object2DProperties();
245     object2DProps.setObjectTitleText ("Amperage Used Per Appliance");
246
247     //Configure chart properties
248
Chart2DProperties chart2DProps = new Chart2DProperties();
249     chart2DProps.setChartDataLabelsPrecision (-1);
250
251     //Configure legend properties
252
LegendProperties legendProps = new LegendProperties();
253     String JavaDoc[] legendLabels = {"2002", "2001", "2000"};
254     legendProps.setLegendLabelsTexts (legendLabels);
255
256     //Configure graph chart properties
257
GraphChart2DProperties graphChart2DProps = new GraphChart2DProperties();
258     String JavaDoc[] labelsAxisLabels = {"Computer", "Monitor", "AC", "Lighting", "Refrigerator"};
259     graphChart2DProps.setLabelsAxisLabelsTexts (labelsAxisLabels);
260     graphChart2DProps.setLabelsAxisTitleText ("Appliances");
261     graphChart2DProps.setNumbersAxisTitleText ("Amps on 120 Volt Line");
262
263     //Configure graph properties
264
GraphProperties graphProps = new GraphProperties();
265     graphProps.setGraphOutlineComponentsExistence (true);
266
267     //Configure dataset
268
Dataset dataset = new Dataset (3, 5, 1);
269     dataset.set (0, 0, 0, 3.5f);
270     dataset.set (0, 1, 0, 2.5f);
271     dataset.set (0, 2, 0, 10.0f);
272     dataset.set (0, 3, 0, 0.5f);
273     dataset.set (0, 4, 0, 2.0f);
274     dataset.set (1, 0, 0, 3.0f);
275     dataset.set (1, 1, 0, 2.0f);
276     dataset.set (1, 2, 0, 10.0f);
277     dataset.set (1, 3, 0, 1.0f);
278     dataset.set (1, 4, 0, 2.0f);
279     dataset.set (2, 0, 0, 2.5f);
280     dataset.set (2, 1, 0, 2.0f);
281     dataset.set (2, 2, 0, 10.5f);
282     dataset.set (2, 3, 0, 1.0f);
283     dataset.set (2, 4, 0, 2.5f);
284
285     //Configure graph component colors
286
MultiColorsProperties multiColorsProps = new MultiColorsProperties();
287
288     //Configure warning regions for graph
289
WarningRegionProperties warningRegionProps1 = new WarningRegionProperties();
290     warningRegionProps1.setHigh (WarningRegionProperties.HIGH);
291     warningRegionProps1.setLow (7f);
292
293     //Configure warning regions for graph
294
WarningRegionProperties warningRegionProps2 = new WarningRegionProperties();
295     warningRegionProps2.setHigh (7f);
296     warningRegionProps2.setLow (5f);
297     warningRegionProps2.setComponentColor (new Color JavaDoc (146, 105, 0));
298     warningRegionProps2.setBackgroundColor (new Color JavaDoc (222, 209, 176));
299
300     //Configure chart
301
LBChart2D chart2D = new LBChart2D();
302     chart2D.setObject2DProperties (object2DProps);
303     chart2D.setChart2DProperties (chart2DProps);
304     chart2D.setLegendProperties (legendProps);
305     chart2D.setGraphChart2DProperties (graphChart2DProps);
306     chart2D.addGraphProperties (graphProps);
307     chart2D.addDataset (dataset);
308     chart2D.addMultiColorsProperties (multiColorsProps);
309     chart2D.addWarningRegionProperties (warningRegionProps1);
310     chart2D.addWarningRegionProperties (warningRegionProps2);
311
312     //Optional validation: Prints debug messages if invalid only.
313
if (!chart2D.validate (false)) chart2D.validate (true);
314
315     //<-- End Chart2D configuration -->
316

317     return chart2D;
318   }
319
320
321   /**
322    * Builds the demo chart.
323    * @return The demo chart.
324    */

325   private Chart2D getChart2DDemoC() {
326
327     //<-- Begin Chart2D configuration -->
328

329     //Configure object properties
330
Object2DProperties object2DProps = new Object2DProperties();
331     object2DProps.setObjectTitleText ("Productivity by Age");
332
333     //Configure chart properties
334
Chart2DProperties chart2DProps = new Chart2DProperties();
335     chart2DProps.setChartDataLabelsPrecision (-2);
336
337     //Configure legend properties
338
LegendProperties legendProps = new LegendProperties();
339     String JavaDoc[] legendLabels = {"Mov. Avg.", "Raw Data"};
340     legendProps.setLegendLabelsTexts (legendLabels);
341
342     //Configure graph chart properties
343
GraphChart2DProperties graphChart2DProps = new GraphChart2DProperties();
344     String JavaDoc[] labelsAxisLabels =
345       {"20-25", "25-30", "30-35", "35-40", "40-45", "45-50", "50-55", "55-60", "60-65"};
346     graphChart2DProps.setLabelsAxisLabelsTexts (labelsAxisLabels);
347     graphChart2DProps.setLabelsAxisTitleText ("Age Ranges");
348     graphChart2DProps.setNumbersAxisTitleText ("Actual / Optimal");
349     graphChart2DProps.setChartDatasetCustomizeGreatestValue (true);
350     graphChart2DProps.setChartDatasetCustomGreatestValue (1f);
351     graphChart2DProps.setChartDatasetCustomizeLeastValue (true);
352     graphChart2DProps.setChartDatasetCustomLeastValue (.5f);
353
354     //Configure graph properties
355
GraphProperties graphProps = new GraphProperties();
356     graphProps.setGraphComponentsAlphaComposite (graphProps.ALPHA_COMPOSITE_MILD);
357
358     //Configure dataset
359
Dataset dataset = new Dataset (1, 9, 1);
360     dataset.set (0, 0, 0, .6f);
361     dataset.set (0, 1, 0, .9f);
362     dataset.set (0, 2, 0, .85f);
363     dataset.set (0, 3, 0, .8f);
364     dataset.set (0, 4, 0, .85f);
365     dataset.set (0, 5, 0, .8f);
366     dataset.set (0, 6, 0, .75f);
367     dataset.set (0, 7, 0, .75f);
368     dataset.set (0, 8, 0, .70f);
369
370     //Configure graph component colors
371
MultiColorsProperties multiColorsProps = new MultiColorsProperties();
372
373     //Configure graph properties (trend)
374
GraphProperties graphPropsTrend = new GraphProperties();
375     graphPropsTrend.setGraphBarsExistence (false);
376     graphPropsTrend.setGraphLinesExistence (true);
377
378     //Configure dataset (trend)
379
Dataset datasetTrend = new Dataset();
380     datasetTrend.addMovingAverage (dataset, 3);
381
382     //Configure graph component colors (trend)
383
MultiColorsProperties multiColorsPropsTrend = new MultiColorsProperties();
384     multiColorsPropsTrend.setColorsCustomize (true);
385     multiColorsPropsTrend.setColorsCustom (new Color JavaDoc[] {new Color JavaDoc (193, 183, 0)});
386
387     //Configure chart
388
LBChart2D chart2D = new LBChart2D();
389     chart2D.setObject2DProperties (object2DProps);
390     chart2D.setChart2DProperties (chart2DProps);
391     chart2D.setLegendProperties (legendProps);
392     chart2D.setGraphChart2DProperties (graphChart2DProps);
393     chart2D.addGraphProperties (graphPropsTrend);
394     chart2D.addDataset (datasetTrend);
395     chart2D.addMultiColorsProperties (multiColorsPropsTrend);
396     chart2D.addGraphProperties (graphProps);
397     chart2D.addDataset (dataset);
398     chart2D.addMultiColorsProperties (multiColorsProps);
399
400     //Optional validation: Prints debug messages if invalid only.
401
if (!chart2D.validate (false)) chart2D.validate (true);
402
403     //<-- End Chart2D configuration -->
404

405     return chart2D;
406   }
407
408
409   /**
410    * Builds the demo chart.
411    * @return The demo chart.
412    */

413   private Chart2D getChart2DDemoD() {
414
415     //<-- Begin Chart2D configuration -->
416

417     //Configure object properties
418
Object2DProperties object2DProps = new Object2DProperties();
419     object2DProps.setObjectTitleText ("Productivity by Age");
420
421     //Configure chart properties
422
Chart2DProperties chart2DProps = new Chart2DProperties();
423     chart2DProps.setChartDataLabelsPrecision (-2);
424
425     //Configure legend properties
426
LegendProperties legendProps = new LegendProperties();
427     legendProps.setLegendExistence (false);
428
429     //Configure graph chart properties
430
GraphChart2DProperties graphChart2DProps = new GraphChart2DProperties();
431     String JavaDoc[] labelsAxisLabels =
432       {"20-25", "25-30", "30-35", "35-40", "40-45", "45-50", "50-55", "55-60", "60-65"};
433     graphChart2DProps.setLabelsAxisLabelsTexts (labelsAxisLabels);
434     graphChart2DProps.setLabelsAxisTitleText ("Age Ranges");
435     graphChart2DProps.setNumbersAxisTitleText ("Actual / Optimal");
436     graphChart2DProps.setChartDatasetCustomizeGreatestValue (true);
437     graphChart2DProps.setChartDatasetCustomGreatestValue (1f);
438     graphChart2DProps.setChartDatasetCustomizeLeastValue (true);
439     graphChart2DProps.setChartDatasetCustomLeastValue (.5f);
440     graphChart2DProps.setGraphComponentsColoringByCat (true);
441     graphChart2DProps.setGraphComponentsColorsByCat (new MultiColorsProperties());
442
443     //Configure graph properties
444
GraphProperties graphProps = new GraphProperties();
445
446     //Configure dataset
447
Dataset dataset = new Dataset (1, 9, 1);
448     dataset.set (0, 0, 0, .6f);
449     dataset.set (0, 1, 0, .9f);
450     dataset.set (0, 2, 0, .85f);
451     dataset.set (0, 3, 0, .8f);
452     dataset.set (0, 4, 0, .85f);
453     dataset.set (0, 5, 0, .8f);
454     dataset.set (0, 6, 0, .75f);
455     dataset.set (0, 7, 0, .75f);
456     dataset.set (0, 8, 0, .70f);
457
458     //Configure graph component colors
459
MultiColorsProperties multiColorsProps = new MultiColorsProperties();
460
461     //Configure chart
462
LBChart2D chart2D = new LBChart2D();
463     chart2D.setObject2DProperties (object2DProps);
464     chart2D.setChart2DProperties (chart2DProps);
465     chart2D.setLegendProperties (legendProps);
466     chart2D.setGraphChart2DProperties (graphChart2DProps);
467     chart2D.addGraphProperties (graphProps);
468     chart2D.addDataset (dataset);
469     chart2D.addMultiColorsProperties (multiColorsProps);
470
471     //Optional validation: Prints debug messages if invalid only.
472
if (!chart2D.validate (false)) chart2D.validate (true);
473
474     //<-- End Chart2D configuration -->
475

476     return chart2D;
477   }
478
479
480   /**
481    * Builds the demo chart.
482    * @return The demo chart.
483    */

484   private Chart2D getChart2DDemoE() {
485
486     //<-- Begin Chart2D configuration -->
487

488     //Configure object properties
489
Object2DProperties object2DProps = new Object2DProperties();
490     object2DProps.setObjectTitleText ("Bugs Per MS Product");
491
492     //Configure chart properties
493
Chart2DProperties chart2DProps = new Chart2DProperties();
494     chart2DProps.setChartDataLabelsPrecision (2);
495
496     //Configure legend properties
497
LegendProperties legendProps = new LegendProperties();
498     String JavaDoc[] legendLabels = {"Unfound", "Fixed", "Unfixed", "Permanent"};
499     legendProps.setLegendLabelsTexts (legendLabels);
500
501     //Configure graph chart properties
502
GraphChart2DProperties graphChart2DProps = new GraphChart2DProperties();
503     String JavaDoc[] labelsAxisLabels = {"Windows", "Office", "Visual Dev", ".Net", "Explorer"};
504     graphChart2DProps.setLabelsAxisLabelsTexts (labelsAxisLabels);
505     graphChart2DProps.setLabelsAxisTitleText ("Products");
506     graphChart2DProps.setNumbersAxisTitleText ("Bugs");
507
508     //Configure graph properties
509
GraphProperties graphProps = new GraphProperties();
510     graphProps.setGraphAllowComponentAlignment (true);
511     graphProps.setGraphBarsRoundingRatio (0f);
512     graphProps.setGraphOutlineComponentsExistence (true);
513
514     //Configure dataset
515
Dataset dataset = new Dataset (4, 5, 1);
516     dataset.set (0, 0, 0, 110f);
517     dataset.set (0, 1, 0, 700f);
518     dataset.set (0, 2, 0, 300f);
519     dataset.set (0, 3, 0, 250f);
520     dataset.set (0, 4, 0, 800f);
521     dataset.set (1, 0, 0, 400f);
522     dataset.set (1, 1, 0, 200f);
523     dataset.set (1, 2, 0, 100f);
524     dataset.set (1, 3, 0, 650f);
525     dataset.set (1, 4, 0, 450f);
526     dataset.set (2, 0, 0, 500f);
527     dataset.set (2, 1, 0, 200f);
528     dataset.set (2, 2, 0, 100f);
529     dataset.set (2, 3, 0, 550f);
530     dataset.set (2, 4, 0, 350f);
531     dataset.set (3, 0, 0, 250f);
532     dataset.set (3, 1, 0, 150f);
533     dataset.set (3, 2, 0, 750f);
534     dataset.set (3, 3, 0, 100f);
535     dataset.set (3, 4, 0, 150f);
536     dataset.doConvertToStacked();
537
538     //Configure graph component colors
539
MultiColorsProperties multiColorsProps = new MultiColorsProperties();
540
541     //Configure chart
542
LBChart2D chart2D = new LBChart2D();
543     chart2D.setObject2DProperties (object2DProps);
544     chart2D.setChart2DProperties (chart2DProps);
545     chart2D.setLegendProperties (legendProps);
546     chart2D.setGraphChart2DProperties (graphChart2DProps);
547     chart2D.addGraphProperties (graphProps);
548     chart2D.addDataset (dataset);
549     chart2D.addMultiColorsProperties (multiColorsProps);
550
551     //Optional validation: Prints debug messages if invalid only.
552
if (!chart2D.validate (false)) chart2D.validate (true);
553
554     //<-- End Chart2D configuration -->
555

556     return chart2D;
557   }
558
559
560   /**
561    * Builds the demo chart.
562    * @return The demo chart.
563    */

564   private Chart2D getChart2DDemoF() {
565
566     //<-- Begin Chart2D configuration -->
567

568     //Configure object properties
569
Object2DProperties object2DProps = new Object2DProperties();
570     object2DProps.setObjectTitleText ("Programmers By Language");
571
572     //Configure chart properties
573
Chart2DProperties chart2DProps = new Chart2DProperties();
574
575     //Configure legend properties
576
LegendProperties legendProps = new LegendProperties();
577     String JavaDoc[] legendLabels = {"C", "C++", "Java"};
578     legendProps.setLegendLabelsTexts (legendLabels);
579
580     //Configure graph chart properties
581
GraphChart2DProperties graphChart2DProps = new GraphChart2DProperties();
582     String JavaDoc[] labelsAxisLabels =
583       {"1990", "1991", "1992", "1993", "1994", "1995",
584        "1996", "1997", "1998", "1999", "2001", "2002"};
585     graphChart2DProps.setLabelsAxisLabelsTexts (labelsAxisLabels);
586     graphChart2DProps.setLabelsAxisTitleText ("Years");
587     graphChart2DProps.setNumbersAxisTitleText ("Programmers");
588     graphChart2DProps.setChartDatasetCustomizeGreatestValue (true);
589     graphChart2DProps.setChartDatasetCustomGreatestValue (1000);
590     graphChart2DProps.setLabelsAxisTicksAlignment (graphChart2DProps.CENTERED);
591
592     //Configure graph properties
593
GraphProperties graphProps = new GraphProperties();
594     graphProps.setGraphBarsExistence (false);
595     graphProps.setGraphLinesExistence (true);
596     graphProps.setGraphOutlineComponentsExistence (true);
597     graphProps.setGraphAllowComponentAlignment (true);
598
599     //Configure dataset
600
Dataset dataset = new Dataset (3, 12, 1);
601     dataset.set (0, 0, 0, 100f); //1990
602
dataset.set (0, 1, 0, 200f); //1991
603
dataset.set (0, 2, 0, 300f); //1992
604
dataset.set (0, 3, 0, 400f); //1993
605
dataset.set (0, 4, 0, 100f); //1994
606
dataset.set (0, 5, 0, 200f); //1995
607
dataset.set (0, 6, 0, 100f); //1996
608
dataset.set (0, 7, 0, 0f); //1997
609
dataset.set (0, 8, 0, 100f); //1998
610
dataset.set (0, 9, 0, 100f); //1999
611
dataset.set (0, 10, 0, 200f); //2000
612
dataset.set (0, 11, 0, 300f); //2001
613
dataset.set (1, 0, 0, 0f); //1990
614
dataset.set (1, 1, 0, 0f); //1991
615
dataset.set (1, 2, 0, 0f); //1992
616
dataset.set (1, 3, 0, 100f); //1993
617
dataset.set (1, 4, 0, 200f); //1994
618
dataset.set (1, 5, 0, 400f); //1995
619
dataset.set (1, 6, 0, 500f); //1996
620
dataset.set (1, 7, 0, 700f); //1997
621
dataset.set (1, 8, 0, 900f); //1998
622
dataset.set (1, 9, 0, 100f); //1999
623
dataset.set (1, 10, 0, 200f); //2000
624
dataset.set (1, 11, 0, 300f); //2001
625
dataset.set (2, 0, 0, 0f); //1990
626
dataset.set (2, 1, 0, 0f); //1991
627
dataset.set (2, 2, 0, 0f); //1992
628
dataset.set (2, 3, 0, 0f); //1993
629
dataset.set (2, 4, 0, 100f); //1994
630
dataset.set (2, 5, 0, 200f); //1995
631
dataset.set (2, 6, 0, 300f); //1996
632
dataset.set (2, 7, 0, 400f); //1997
633
dataset.set (2, 8, 0, 500f); //1998
634
dataset.set (2, 9, 0, 100f); //1999
635
dataset.set (2, 10, 0, 300f); //2000
636
dataset.set (2, 11, 0, 900f); //2001
637

638     //Configure graph component colors
639
MultiColorsProperties multiColorsProps = new MultiColorsProperties();
640
641     //Configure chart
642
LBChart2D chart2D = new LBChart2D();
643     chart2D.setObject2DProperties (object2DProps);
644     chart2D.setChart2DProperties (chart2DProps);
645     chart2D.setLegendProperties (legendProps);
646     chart2D.setGraphChart2DProperties (graphChart2DProps);
647     chart2D.addGraphProperties (graphProps);
648     chart2D.addDataset (dataset);
649     chart2D.addMultiColorsProperties (multiColorsProps);
650
651     //Optional validation: Prints debug messages if invalid only.
652
if (!chart2D.validate (false)) chart2D.validate (true);
653
654     //<-- End Chart2D configuration -->
655

656     return chart2D;
657   }
658
659
660   /**
661    * Builds the demo chart.
662    * @return The demo chart.
663    */

664   private Chart2D getChart2DDemoG() {
665
666     //<-- Begin Chart2D configuration -->
667

668     //Configure object properties
669
Object2DProperties object2DProps = new Object2DProperties();
670     object2DProps.setObjectTitleText ("Programmers By Language");
671
672     //Configure chart properties
673
Chart2DProperties chart2DProps = new Chart2DProperties();
674
675     //Configure legend properties
676
LegendProperties legendProps = new LegendProperties();
677     String JavaDoc[] legendLabels = {"C", "C++", "Java"};
678     legendProps.setLegendLabelsTexts (legendLabels);
679
680     //Configure graph chart properties
681
GraphChart2DProperties graphChart2DProps = new GraphChart2DProperties();
682     String JavaDoc[] labelsAxisLabels =
683       {"1990", "1991", "1992", "1993", "1994", "1995",
684        "1996", "1997", "1998", "1999", "2001", "2002"};
685     graphChart2DProps.setLabelsAxisLabelsTexts (labelsAxisLabels);
686     graphChart2DProps.setLabelsAxisTitleText ("Years");
687     graphChart2DProps.setNumbersAxisTitleText ("Programmers");
688     graphChart2DProps.setChartDatasetCustomizeGreatestValue (true);
689     graphChart2DProps.setChartDatasetCustomGreatestValue (1000);
690     graphChart2DProps.setLabelsAxisTicksAlignment (graphChart2DProps.CENTERED);
691
692     //Configure graph properties
693
GraphProperties graphProps = new GraphProperties();
694     graphProps.setGraphBarsExistence (false);
695     graphProps.setGraphLinesExistence (true);
696     graphProps.setGraphAllowComponentAlignment (true);
697
698     //Configure dataset
699
Dataset dataset = new Dataset (3, 12, 1);
700     dataset.set (0, 0, 0, 100f); //1990
701
dataset.set (0, 1, 0, 200f); //1991
702
dataset.set (0, 2, 0, 300f); //1992
703
dataset.set (0, 3, 0, 400f); //1993
704
dataset.set (0, 4, 0, 100f); //1994
705
dataset.set (0, 5, 0, 200f); //1995
706
dataset.set (0, 6, 0, 100f); //1996
707
dataset.set (0, 7, 0, 0f); //1997
708
dataset.set (0, 8, 0, 100f); //1998
709
dataset.set (0, 9, 0, 100f); //1999
710
dataset.set (0, 10, 0, 200f); //2000
711
dataset.set (0, 11, 0, 300f); //2001
712
dataset.set (1, 0, 0, 0f); //1990
713
dataset.set (1, 1, 0, 0f); //1991
714
dataset.set (1, 2, 0, 0f); //1992
715
dataset.set (1, 3, 0, 100f); //1993
716
dataset.set (1, 4, 0, 200f); //1994
717
dataset.set (1, 5, 0, 400f); //1995
718
dataset.set (1, 6, 0, 500f); //1996
719
dataset.set (1, 7, 0, 700f); //1997
720
dataset.set (1, 8, 0, 900f); //1998
721
dataset.set (1, 9, 0, 100f); //1999
722
dataset.set (1, 10, 0, 200f); //2000
723
dataset.set (1, 11, 0, 300f); //2001
724
dataset.set (2, 0, 0, 0f); //1990
725
dataset.set (2, 1, 0, 0f); //1991
726
dataset.set (2, 2, 0, 0f); //1992
727
dataset.set (2, 3, 0, 0f); //1993
728
dataset.set (2, 4, 0, 100f); //1994
729
dataset.set (2, 5, 0, 200f); //1995
730
dataset.set (2, 6, 0, 300f); //1996
731
dataset.set (2, 7, 0, 400f); //1997
732
dataset.set (2, 8, 0, 500f); //1998
733
dataset.set (2, 9, 0, 100f); //1999
734
dataset.set (2, 10, 0, 300f); //2000
735
dataset.set (2, 11, 0, 900f); //2001
736

737     //Configure graph component colors
738
MultiColorsProperties multiColorsProps = new MultiColorsProperties();
739
740     //Configure warning regions for graph
741
WarningRegionProperties warningRegionProps1 = new WarningRegionProperties();
742     warningRegionProps1.setHigh (100);
743     warningRegionProps1.setLow (WarningRegionProperties.LOW);
744
745     //Configure warning regions for graph
746
WarningRegionProperties warningRegionProps2 = new WarningRegionProperties();
747     warningRegionProps2.setHigh (200);
748     warningRegionProps2.setLow (100);
749     warningRegionProps2.setComponentColor (new Color JavaDoc (146, 105, 0));
750     warningRegionProps2.setBackgroundColor (new Color JavaDoc (222, 209, 176));
751
752     //Configure chart
753
LBChart2D chart2D = new LBChart2D();
754     chart2D.setObject2DProperties (object2DProps);
755     chart2D.setChart2DProperties (chart2DProps);
756     chart2D.setLegendProperties (legendProps);
757     chart2D.setGraphChart2DProperties (graphChart2DProps);
758     chart2D.addGraphProperties (graphProps);
759     chart2D.addDataset (dataset);
760     chart2D.addMultiColorsProperties (multiColorsProps);
761     chart2D.addWarningRegionProperties (warningRegionProps1);
762     chart2D.addWarningRegionProperties (warningRegionProps2);
763
764     //Optional validation: Prints debug messages if invalid only.
765
if (!chart2D.validate (false)) chart2D.validate (true);
766
767     //<-- End Chart2D configuration -->
768

769     return chart2D;
770   }
771
772
773   /**
774    * Builds the demo chart.
775    * @return The demo chart.
776    */

777   private Chart2D getChart2DDemoH() {
778
779     //<-- Begin Chart2D configuration -->
780

781     //Configure object properties
782
Object2DProperties object2DProps = new Object2DProperties();
783     object2DProps.setObjectTitleText ("Programmers By Language");
784
785     //Configure chart properties
786
Chart2DProperties chart2DProps = new Chart2DProperties();
787     chart2DProps.setChartDataLabelsPrecision (2);
788
789     //Configure legend properties
790
LegendProperties legendProps = new LegendProperties();
791     String JavaDoc[] legendLabels = {"C", "C++", "Java"};
792     legendProps.setLegendLabelsTexts (legendLabels);
793
794     //Configure graph chart properties
795
GraphChart2DProperties graphChart2DProps = new GraphChart2DProperties();
796     String JavaDoc[] labelsAxisLabels =
797       {"1990", "1991", "1992", "1993", "1994", "1995",
798        "1996", "1997", "1998", "1999", "2001", "2002"};
799     graphChart2DProps.setLabelsAxisLabelsTexts (labelsAxisLabels);
800     graphChart2DProps.setLabelsAxisTitleText ("Years");
801     graphChart2DProps.setNumbersAxisTitleText ("Programmers");
802     graphChart2DProps.setLabelsAxisTicksAlignment (graphChart2DProps.CENTERED);
803
804     //Configure graph properties
805
GraphProperties graphProps = new GraphProperties();
806     graphProps.setGraphBarsExistence (false);
807     graphProps.setGraphLinesExistence (true);
808     graphProps.setGraphLinesFillInterior (true);
809     graphProps.setGraphLinesThicknessModel (1);
810     graphProps.setGraphAllowComponentAlignment (true);
811     graphProps.setGraphComponentsAlphaComposite (graphProps.ALPHA_COMPOSITE_MEDIUM);
812
813     //Configure dataset
814
Dataset dataset = new Dataset (3, 12, 1);
815     dataset.set (0, 0, 0, 100f); //1990
816
dataset.set (0, 1, 0, 200f); //1991
817
dataset.set (0, 2, 0, 300f); //1992
818
dataset.set (0, 3, 0, 400f); //1993
819
dataset.set (0, 4, 0, 100f); //1994
820
dataset.set (0, 5, 0, 200f); //1995
821
dataset.set (0, 6, 0, 100f); //1996
822
dataset.set (0, 7, 0, 0f); //1997
823
dataset.set (0, 8, 0, 100f); //1998
824
dataset.set (0, 9, 0, 100f); //1999
825
dataset.set (0, 10, 0, 200f); //2000
826
dataset.set (0, 11, 0, 300f); //2001
827
dataset.set (1, 0, 0, 0f); //1990
828
dataset.set (1, 1, 0, 0f); //1991
829
dataset.set (1, 2, 0, 0f); //1992
830
dataset.set (1, 3, 0, 100f); //1993
831
dataset.set (1, 4, 0, 200f); //1994
832
dataset.set (1, 5, 0, 400f); //1995
833
dataset.set (1, 6, 0, 500f); //1996
834
dataset.set (1, 7, 0, 700f); //1997
835
dataset.set (1, 8, 0, 900f); //1998
836
dataset.set (1, 9, 0, 100f); //1999
837
dataset.set (1, 10, 0, 200f); //2000
838
dataset.set (1, 11, 0, 300f); //2001
839
dataset.set (2, 0, 0, 0f); //1990
840
dataset.set (2, 1, 0, 0f); //1991
841
dataset.set (2, 2, 0, 0f); //1992
842
dataset.set (2, 3, 0, 0f); //1993
843
dataset.set (2, 4, 0, 100f); //1994
844
dataset.set (2, 5, 0, 200f); //1995
845
dataset.set (2, 6, 0, 300f); //1996
846
dataset.set (2, 7, 0, 400f); //1997
847
dataset.set (2, 8, 0, 500f); //1998
848
dataset.set (2, 9, 0, 100f); //1999
849
dataset.set (2, 10, 0, 300f); //2000
850
dataset.set (2, 11, 0, 900f); //2001
851
dataset.doConvertToStacked();
852
853     //Configure graph component colors
854
MultiColorsProperties multiColorsProps = new MultiColorsProperties();
855
856     //Configure chart
857
LBChart2D chart2D = new LBChart2D();
858     chart2D.setObject2DProperties (object2DProps);
859     chart2D.setChart2DProperties (chart2DProps);
860     chart2D.setLegendProperties (legendProps);
861     chart2D.setGraphChart2DProperties (graphChart2DProps);
862     chart2D.addGraphProperties (graphProps);
863     chart2D.addDataset (dataset);
864     chart2D.addMultiColorsProperties (multiColorsProps);
865
866     //Optional validation: Prints debug messages if invalid only.
867
if (!chart2D.validate (false)) chart2D.validate (true);
868
869     //<-- End Chart2D configuration -->
870

871     return chart2D;
872   }
873
874
875   /**
876    * Builds the demo chart.
877    * @return The demo chart.
878    */

879   private Chart2D getChart2DDemoI() {
880
881     //<-- Begin Chart2D configuration -->
882

883     //Configure object properties
884
Object2DProperties object2DProps = new Object2DProperties();
885     object2DProps.setObjectTitleText ("Weekly LOC Programmed");
886
887     //Configure chart properties
888
Chart2DProperties chart2DProps = new Chart2DProperties();
889     chart2DProps.setChartDataLabelsPrecision (1);
890
891     //Configure legend properties
892
LegendProperties legendProps = new LegendProperties();
893     String JavaDoc[] legendLabels = {"2001", "2000", "1999"};
894     legendProps.setLegendLabelsTexts (legendLabels);
895
896     //Configure graph chart properties
897
GraphChart2DProperties graphChart2DProps = new GraphChart2DProperties();
898     String JavaDoc[] labelsAxisLabels =
899       {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
900     graphChart2DProps.setLabelsAxisLabelsTexts (labelsAxisLabels);
901     graphChart2DProps.setLabelsAxisTitleText ("Weeks by Month");
902     graphChart2DProps.setNumbersAxisTitleText ("LOC");
903     graphChart2DProps.setLabelsAxisTicksAlignment (graphChart2DProps.CENTERED);
904
905     //Configure graph properties
906
GraphProperties graphProps = new GraphProperties();
907     graphProps.setGraphBarsExistence (false);
908     graphProps.setGraphLinesExistence (true);
909     graphProps.setGraphAllowComponentAlignment (true);
910     graphProps.setGraphLinesWithinCategoryOverlapRatio (1f);
911
912     //Configure dataset
913
Random JavaDoc random = new Random JavaDoc();
914     Dataset dataset = new Dataset (3, 12, 4);
915     for (int i = 0; i < dataset.getNumSets(); ++i) {
916       for (int j = 0; j < dataset.getNumCats(); ++j) {
917         for (int k = 0; k < dataset.getNumItems(); ++k) {
918           int increaseMetric = dataset.getNumSets() - i - 1;
919           dataset.set (i, j, k,
920             (increaseMetric + 1) * random.nextInt (5) + (increaseMetric + 1) * 30 + j * 3);
921         }
922       }
923     }
924
925     //Configure graph component colors
926
MultiColorsProperties multiColorsProps = new MultiColorsProperties();
927
928     //Configure chart
929
LBChart2D chart2D = new LBChart2D();
930     chart2D.setObject2DProperties (object2DProps);
931     chart2D.setChart2DProperties (chart2DProps);
932     chart2D.setLegendProperties (legendProps);
933     chart2D.setGraphChart2DProperties (graphChart2DProps);
934     chart2D.addGraphProperties (graphProps);
935     chart2D.addDataset (dataset);
936     chart2D.addMultiColorsProperties (multiColorsProps);
937
938     //Optional validation: Prints debug messages if invalid only.
939
if (!chart2D.validate (false)) chart2D.validate (true);
940
941     //<-- End Chart2D configuration -->
942

943     return chart2D;
944   }
945
946
947   /**
948    * Builds the demo chart.
949    * @return The demo chart.
950    */

951   private Chart2D getChart2DDemoJ() {
952
953     //<-- Begin Chart2D configuration -->
954

955     //Configure object properties
956
Object2DProperties object2DProps = new Object2DProperties();
957     object2DProps.setObjectTitleText ("Weekly LOC Programmed");
958
959     //Configure chart properties
960
Chart2DProperties chart2DProps = new Chart2DProperties();
961     chart2DProps.setChartDataLabelsPrecision (1);
962
963     //Configure legend properties
964
LegendProperties legendProps = new LegendProperties();
965     String JavaDoc[] legendLabels = {"2001", "2000", "1999"};
966     legendProps.setLegendLabelsTexts (legendLabels);
967
968     //Configure graph chart properties
969
GraphChart2DProperties graphChart2DProps = new GraphChart2DProperties();
970     String JavaDoc[] labelsAxisLabels =
971       {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
972     graphChart2DProps.setLabelsAxisLabelsTexts (labelsAxisLabels);
973     graphChart2DProps.setLabelsAxisTitleText ("Weeks by Month");
974     graphChart2DProps.setNumbersAxisTitleText ("LOC");
975     graphChart2DProps.setLabelsAxisTicksAlignment (graphChart2DProps.CENTERED);
976
977     //Configure graph properties
978
GraphProperties graphProps = new GraphProperties();
979     graphProps.setGraphBarsExistence (false);
980     graphProps.setGraphDotsExistence (true);
981     graphProps.setGraphAllowComponentAlignment (true);
982     graphProps.setGraphDotsWithinCategoryOverlapRatio (1f);
983
984     //Configure dataset
985
Random JavaDoc random = new Random JavaDoc();
986     Dataset dataset = new Dataset (3, 12, 4);
987     for (int i = 0; i < dataset.getNumSets(); ++i) {
988       for (int j = 0; j < dataset.getNumCats(); ++j) {
989         for (int k = 0; k < dataset.getNumItems(); ++k) {
990           int increaseMetric = dataset.getNumSets() - i - 1;
991           dataset.set (i, j, k,
992             (increaseMetric + 1) * random.nextInt (5) + (increaseMetric + 1) * 30 + j * 3);
993         }
994       }
995     }
996
997     //Configure graph component colors
998
MultiColorsProperties multiColorsProps = new MultiColorsProperties();
999
1000    //Configure chart
1001
LBChart2D chart2D = new LBChart2D();
1002    chart2D.setObject2DProperties (object2DProps);
1003    chart2D.setChart2DProperties (chart2DProps);
1004    chart2D.setLegendProperties (legendProps);
1005    chart2D.setGraphChart2DProperties (graphChart2DProps);
1006    chart2D.addGraphProperties (graphProps);
1007    chart2D.addDataset (dataset);
1008    chart2D.addMultiColorsProperties (multiColorsProps);
1009
1010    //Optional validation: Prints debug messages if invalid only.
1011
if (!chart2D.validate (false)) chart2D.validate (true);
1012
1013    //<-- End Chart2D configuration -->
1014

1015    return chart2D;
1016  }
1017
1018
1019  /**
1020   * Builds the demo chart.
1021   * @return The demo chart.
1022   */

1023  private Chart2D getChart2DDemoK() {
1024
1025    //<-- Begin Chart2D configuration -->
1026

1027    //Configure object properties
1028
Object2DProperties object2DProps = new Object2DProperties();
1029    object2DProps.setObjectTitleText ("Monthly LOC Programmed");
1030
1031    //Configure chart properties
1032
Chart2DProperties chart2DProps = new Chart2DProperties();
1033    chart2DProps.setChartDataLabelsPrecision (1);
1034
1035    //Configure legend properties
1036
LegendProperties legendProps = new LegendProperties();
1037    String JavaDoc[] legendLabels = {"2001", "2000", "1999"};
1038    legendProps.setLegendLabelsTexts (legendLabels);
1039
1040    //Configure graph chart properties
1041
GraphChart2DProperties graphChart2DProps = new GraphChart2DProperties();
1042    String JavaDoc[] labelsAxisLabels =
1043      {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
1044    graphChart2DProps.setLabelsAxisLabelsTexts (labelsAxisLabels);
1045    graphChart2DProps.setLabelsAxisTitleText ("Months");
1046    graphChart2DProps.setNumbersAxisTitleText ("LOC");
1047    graphChart2DProps.setLabelsAxisTicksAlignment (graphChart2DProps.CENTERED);
1048
1049    //Configure graph properties
1050
GraphProperties graphProps = new GraphProperties();
1051    graphProps.setGraphBarsExistence (false);
1052    graphProps.setGraphLinesExistence (true);
1053    graphProps.setGraphLinesThicknessModel (2);
1054    graphProps.setGraphLinesWithinCategoryOverlapRatio (1f);
1055    graphProps.setGraphDotsExistence (true);
1056    graphProps.setGraphDotsThicknessModel (10);
1057    graphProps.setGraphDotsWithinCategoryOverlapRatio (1f);
1058    graphProps.setGraphAllowComponentAlignment (true);
1059
1060    //Configure dataset
1061
Random JavaDoc random = new Random JavaDoc();
1062    Dataset dataset = new Dataset (3, 12, 1);
1063    for (int i = 0; i < dataset.getNumSets(); ++i) {
1064      for (int j = 0; j < dataset.getNumCats(); ++j) {
1065        for (int k = 0; k < dataset.getNumItems(); ++k) {
1066          int increaseMetric = dataset.getNumSets() - i - 1;
1067          dataset.set (i, j, k,
1068            (increaseMetric + 1) * random.nextInt (5) + (increaseMetric + 1) * 30 + j * 3);
1069        }
1070      }
1071    }
1072
1073    //Configure graph component colors
1074
MultiColorsProperties multiColorsProps = new MultiColorsProperties();
1075
1076    //Configure chart
1077
LBChart2D chart2D = new LBChart2D();
1078    chart2D.setObject2DProperties (object2DProps);
1079    chart2D.setChart2DProperties (chart2DProps);
1080    chart2D.setLegendProperties (legendProps);
1081    chart2D.setGraphChart2DProperties (graphChart2DProps);
1082    chart2D.addGraphProperties (graphProps);
1083    chart2D.addDataset (dataset);
1084    chart2D.addMultiColorsProperties (multiColorsProps);
1085
1086    //Optional validation: Prints debug messages if invalid only.
1087
if (!chart2D.validate (false)) chart2D.validate (true);
1088
1089    //<-- End Chart2D configuration -->
1090

1091    return chart2D;
1092  }
1093
1094
1095  /**
1096   * Builds the demo chart.
1097   * @return The demo chart.
1098   */

1099  private Chart2D getChart2DDemoL() {
1100
1101    //<-- Begin Chart2D configuration -->
1102

1103    //Configure object properties
1104
Object2DProperties object2DProps = new Object2DProperties();
1105    object2DProps.setObjectTitleText ("Monthly LOC | Defects Programmed");
1106
1107    //Configure chart properties
1108
Chart2DProperties chart2DProps = new Chart2DProperties();
1109    chart2DProps.setChartDataLabelsPrecision (1);
1110
1111    //Configure legend properties
1112
LegendProperties legendProps = new LegendProperties();
1113    String JavaDoc[] legendLabels =
1114      {"Defects Java", "Defects C++", "Defects C", "LOC Java", "LOC C++", "LOC C"};
1115    legendProps.setLegendLabelsTexts (legendLabels);
1116
1117    //Configure graph chart properties
1118
GraphChart2DProperties graphChart2DProps = new GraphChart2DProperties();
1119    String JavaDoc[] labelsAxisLabels = {"2001", "2000", "1999", "1998"};
1120    graphChart2DProps.setLabelsAxisLabelsTexts (labelsAxisLabels);
1121    graphChart2DProps.setLabelsAxisTitleText ("Months");
1122    graphChart2DProps.setNumbersAxisTitleText ("LOC | Defects");
1123    graphChart2DProps.setLabelsAxisTicksAlignment (graphChart2DProps.CENTERED);
1124
1125    //Configure graph properties for line overlay
1126
GraphProperties graphPropsLine = new GraphProperties();
1127    graphPropsLine.setGraphBarsExistence (false);
1128    graphPropsLine.setGraphLinesExistence (true);
1129    graphPropsLine.setGraphAllowComponentAlignment (true);
1130
1131    //Configure dataset for line overlay
1132
Random JavaDoc random = new Random JavaDoc();
1133    Dataset datasetLine = new Dataset (3, 4, 1);
1134    for (int i = 0; i < datasetLine.getNumSets(); ++i) {
1135      for (int j = 0; j < datasetLine.getNumCats(); ++j) {
1136        for (int k = 0; k < datasetLine.getNumItems(); ++k) {
1137          datasetLine.set (
1138            datasetLine.getNumSets() - 1 - i, j, k,
1139            (i + 1) * random.nextInt (5) + (i + 1) * 30 + j * 3);
1140        }
1141      }
1142    }
1143
1144    //Configure graph component colors for line overlay
1145
MultiColorsProperties multiColorsPropsLine = new MultiColorsProperties();
1146    multiColorsPropsLine.setColorsType (multiColorsPropsLine.PASTEL);
1147
1148    //Configure graph properties for bar underlay
1149
GraphProperties graphPropsBars = new GraphProperties();
1150    graphPropsBars.setGraphOutlineComponentsExistence (true);
1151    graphPropsBars.setGraphComponentsAlphaComposite (graphPropsBars.ALPHA_COMPOSITE_MILD);
1152
1153    //Configure dataset for bar underlay
1154
Dataset datasetBars = new Dataset (3, 4, 1);
1155    for (int i = 0; i < datasetBars.getNumSets(); ++i) {
1156      for (int j = 0; j < datasetBars.getNumCats(); ++j) {
1157        for (int k = 0; k < datasetBars.getNumItems(); ++k) {
1158          datasetBars.set (i, j, k, (i + 1) * random.nextInt (5) + (i + 1) * 30 + j * 3);
1159        }
1160      }
1161    }
1162
1163    //Configure graph component colors for bar underlay
1164
MultiColorsProperties multiColorsPropsBars = new MultiColorsProperties();
1165
1166    //Configure chart
1167
LBChart2D chart2D = new LBChart2D();
1168    chart2D.setObject2DProperties (object2DProps);
1169    chart2D.setChart2DProperties (chart2DProps);
1170    chart2D.setLegendProperties (legendProps);
1171    chart2D.setGraphChart2DProperties (graphChart2DProps);
1172    chart2D.addGraphProperties (graphPropsLine);
1173    chart2D.addDataset (datasetLine);
1174    chart2D.addMultiColorsProperties (multiColorsPropsLine);
1175    chart2D.addGraphProperties (graphPropsBars);
1176    chart2D.addDataset (datasetBars);
1177    chart2D.addMultiColorsProperties (multiColorsPropsBars);
1178
1179    //Optional validation: Prints debug messages if invalid only.
1180
if (!chart2D.validate (false)) chart2D.validate (true);
1181
1182    //<-- End Chart2D configuration -->
1183

1184    return chart2D;
1185  }
1186}
Popular Tags