KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > birt > chart > examples > api > viewer > PrimitiveCharts


1 /***********************************************************************
2  * Copyright (c) 2004 Actuate Corporation.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * Actuate Corporation - initial API and implementation
10  ***********************************************************************/

11
12 package org.eclipse.birt.chart.examples.api.viewer;
13
14 import java.io.File JavaDoc;
15 import java.io.FileInputStream JavaDoc;
16
17 import javax.swing.JFileChooser JavaDoc;
18 import javax.swing.filechooser.FileFilter JavaDoc;
19
20 import org.eclipse.birt.chart.datafeed.StockEntry;
21 import org.eclipse.birt.chart.model.Chart;
22 import org.eclipse.birt.chart.model.ChartWithAxes;
23 import org.eclipse.birt.chart.model.ChartWithoutAxes;
24 import org.eclipse.birt.chart.model.DialChart;
25 import org.eclipse.birt.chart.model.Serializer;
26 import org.eclipse.birt.chart.model.attribute.Anchor;
27 import org.eclipse.birt.chart.model.attribute.Angle3D;
28 import org.eclipse.birt.chart.model.attribute.AxisType;
29 import org.eclipse.birt.chart.model.attribute.ChartDimension;
30 import org.eclipse.birt.chart.model.attribute.DataPoint;
31 import org.eclipse.birt.chart.model.attribute.DataPointComponentType;
32 import org.eclipse.birt.chart.model.attribute.Fill;
33 import org.eclipse.birt.chart.model.attribute.IntersectionType;
34 import org.eclipse.birt.chart.model.attribute.LegendItemType;
35 import org.eclipse.birt.chart.model.attribute.LineAttributes;
36 import org.eclipse.birt.chart.model.attribute.LineDecorator;
37 import org.eclipse.birt.chart.model.attribute.LineStyle;
38 import org.eclipse.birt.chart.model.attribute.Marker;
39 import org.eclipse.birt.chart.model.attribute.MarkerType;
40 import org.eclipse.birt.chart.model.attribute.NumberFormatSpecifier;
41 import org.eclipse.birt.chart.model.attribute.Orientation;
42 import org.eclipse.birt.chart.model.attribute.Position;
43 import org.eclipse.birt.chart.model.attribute.RiserType;
44 import org.eclipse.birt.chart.model.attribute.TickStyle;
45 import org.eclipse.birt.chart.model.attribute.impl.Angle3DImpl;
46 import org.eclipse.birt.chart.model.attribute.impl.ColorDefinitionImpl;
47 import org.eclipse.birt.chart.model.attribute.impl.DataPointComponentImpl;
48 import org.eclipse.birt.chart.model.attribute.impl.DataPointImpl;
49 import org.eclipse.birt.chart.model.attribute.impl.GradientImpl;
50 import org.eclipse.birt.chart.model.attribute.impl.InsetsImpl;
51 import org.eclipse.birt.chart.model.attribute.impl.JavaNumberFormatSpecifierImpl;
52 import org.eclipse.birt.chart.model.attribute.impl.LineAttributesImpl;
53 import org.eclipse.birt.chart.model.attribute.impl.NumberFormatSpecifierImpl;
54 import org.eclipse.birt.chart.model.attribute.impl.Rotation3DImpl;
55 import org.eclipse.birt.chart.model.component.Axis;
56 import org.eclipse.birt.chart.model.component.DialRegion;
57 import org.eclipse.birt.chart.model.component.MarkerLine;
58 import org.eclipse.birt.chart.model.component.Series;
59 import org.eclipse.birt.chart.model.component.impl.AxisImpl;
60 import org.eclipse.birt.chart.model.component.impl.CurveFittingImpl;
61 import org.eclipse.birt.chart.model.component.impl.DialRegionImpl;
62 import org.eclipse.birt.chart.model.component.impl.MarkerLineImpl;
63 import org.eclipse.birt.chart.model.component.impl.SeriesImpl;
64 import org.eclipse.birt.chart.model.data.DateTimeDataSet;
65 import org.eclipse.birt.chart.model.data.NumberDataSet;
66 import org.eclipse.birt.chart.model.data.SeriesDefinition;
67 import org.eclipse.birt.chart.model.data.StockDataSet;
68 import org.eclipse.birt.chart.model.data.TextDataSet;
69 import org.eclipse.birt.chart.model.data.impl.DateTimeDataSetImpl;
70 import org.eclipse.birt.chart.model.data.impl.NumberDataElementImpl;
71 import org.eclipse.birt.chart.model.data.impl.NumberDataSetImpl;
72 import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl;
73 import org.eclipse.birt.chart.model.data.impl.StockDataSetImpl;
74 import org.eclipse.birt.chart.model.data.impl.TextDataSetImpl;
75 import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl;
76 import org.eclipse.birt.chart.model.impl.ChartWithoutAxesImpl;
77 import org.eclipse.birt.chart.model.impl.DialChartImpl;
78 import org.eclipse.birt.chart.model.impl.SerializerImpl;
79 import org.eclipse.birt.chart.model.layout.Legend;
80 import org.eclipse.birt.chart.model.layout.Plot;
81 import org.eclipse.birt.chart.model.layout.TitleBlock;
82 import org.eclipse.birt.chart.model.type.AreaSeries;
83 import org.eclipse.birt.chart.model.type.BarSeries;
84 import org.eclipse.birt.chart.model.type.DialSeries;
85 import org.eclipse.birt.chart.model.type.LineSeries;
86 import org.eclipse.birt.chart.model.type.PieSeries;
87 import org.eclipse.birt.chart.model.type.ScatterSeries;
88 import org.eclipse.birt.chart.model.type.StockSeries;
89 import org.eclipse.birt.chart.model.type.impl.AreaSeriesImpl;
90 import org.eclipse.birt.chart.model.type.impl.BarSeriesImpl;
91 import org.eclipse.birt.chart.model.type.impl.DialSeriesImpl;
92 import org.eclipse.birt.chart.model.type.impl.LineSeriesImpl;
93 import org.eclipse.birt.chart.model.type.impl.PieSeriesImpl;
94 import org.eclipse.birt.chart.model.type.impl.ScatterSeriesImpl;
95 import org.eclipse.birt.chart.model.type.impl.StockSeriesImpl;
96 import org.eclipse.birt.chart.ui.util.ChartUIUtil;
97 import org.eclipse.birt.chart.util.CDateTime;
98 import org.eclipse.birt.core.ui.frameworks.taskwizard.WizardBase;
99
100 import com.ibm.icu.util.Calendar;
101
102 /**
103  * The class cannot be run individually. It provides sample model
104  * implementations for viewer selector classes in the package.
105  *
106  */

107
108 public final class PrimitiveCharts
109 {
110
111     /**
112      * Creates a simple bar chart model
113      *
114      * @return An instance of the simulated runtime chart model (containing
115      * filled datasets)
116      */

117     public static final Chart createBarChart( )
118     {
119         ChartWithAxes cwaBar = ChartWithAxesImpl.create( );
120
121         // Plot
122
cwaBar.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
123         cwaBar.getBlock( ).getOutline( ).setVisible( true );
124         Plot p = cwaBar.getPlot( );
125         p.getClientArea( ).setBackground( ColorDefinitionImpl.create( 255,
126                 255,
127                 225 ) );
128         p.getOutline( ).setVisible( false );
129
130         // Title
131
cwaBar.getTitle( ).getLabel( ).getCaption( ).setValue( "Bar Chart" ); //$NON-NLS-1$
132

133         // Legend
134
Legend lg = cwaBar.getLegend( );
135         lg.getText( ).getFont( ).setSize( 16 );
136         lg.setItemType( LegendItemType.CATEGORIES_LITERAL );
137
138         // X-Axis
139
Axis xAxisPrimary = cwaBar.getPrimaryBaseAxes( )[0];
140
141         xAxisPrimary.setType( AxisType.TEXT_LITERAL );
142         xAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );
143         xAxisPrimary.getOrigin( ).setType( IntersectionType.VALUE_LITERAL );
144         xAxisPrimary.getTitle( ).setVisible( true );
145
146         // Y-Axis
147
Axis yAxisPrimary = cwaBar.getPrimaryOrthogonalAxis( xAxisPrimary );
148         yAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.LEFT_LITERAL );
149         yAxisPrimary.setType( AxisType.LINEAR_LITERAL );
150         yAxisPrimary.getLabel( ).getCaption( ).getFont( ).setRotation( 90 );
151
152         // Data Set
153
TextDataSet categoryValues = TextDataSetImpl.create( new String JavaDoc[]{
154                 "Item 1", "Item 2", "Item 3"} ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
155
NumberDataSet orthoValues = NumberDataSetImpl.create( new double[]{
156                 25, 35, 15
157         } );
158
159         // X-Series
160
Series seCategory = SeriesImpl.create( );
161         seCategory.setDataSet( categoryValues );
162
163         SeriesDefinition sdX = SeriesDefinitionImpl.create( );
164         sdX.getSeriesPalette( ).update( 0 );
165         xAxisPrimary.getSeriesDefinitions( ).add( sdX );
166         sdX.getSeries( ).add( seCategory );
167
168         // Y-Series
169
BarSeries bs = (BarSeries) BarSeriesImpl.create( );
170         bs.setDataSet( orthoValues );
171         bs.setRiserOutline( null );
172         bs.getLabel( ).setVisible( true );
173         bs.setLabelPosition( Position.INSIDE_LITERAL );
174
175         SeriesDefinition sdY = SeriesDefinitionImpl.create( );
176         yAxisPrimary.getSeriesDefinitions( ).add( sdY );
177         sdY.getSeries( ).add( bs );
178
179         return cwaBar;
180     }
181
182     /**
183      * Creates a bar chart model with mutiple Y-series as a reference
184      * implementation
185      *
186      * @return An instance of the simulated runtime chart model (containing
187      * filled datasets)
188      */

189     public static final Chart createMultiBarChart( )
190     {
191         ChartWithAxes cwaBar = ChartWithAxesImpl.create( );
192
193         // Plot
194
cwaBar.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
195         Plot p = cwaBar.getPlot( );
196         p.getClientArea( )
197                 .setBackground( GradientImpl.create( ColorDefinitionImpl.create( 225,
198                         225,
199                         255 ),
200                         ColorDefinitionImpl.create( 255, 255, 225 ),
201                         -35,
202                         false ) );
203         p.getOutline( ).setVisible( true );
204
205         // Title
206
cwaBar.getTitle( )
207                 .getLabel( )
208                 .getCaption( )
209                 .setValue( "2-Series Bar Chart" );//$NON-NLS-1$
210

211         // Legend
212
Legend lg = cwaBar.getLegend( );
213         lg.getText( ).getFont( ).setSize( 16 );
214
215         // X-Axis
216
Axis xAxisPrimary = cwaBar.getPrimaryBaseAxes( )[0];
217         xAxisPrimary.getTitle( ).setVisible( true );
218         xAxisPrimary.setTitlePosition( Position.BELOW_LITERAL );
219         xAxisPrimary.setType( AxisType.TEXT_LITERAL );
220         xAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );
221         xAxisPrimary.getOrigin( ).setType( IntersectionType.VALUE_LITERAL );
222         xAxisPrimary.setLabelPosition( Position.BELOW_LITERAL );
223
224         // Y-Axis
225
Axis yAxisPrimary = cwaBar.getPrimaryOrthogonalAxis( xAxisPrimary );
226         yAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.LEFT_LITERAL );
227
228         // Data Set
229
TextDataSet categoryValues = TextDataSetImpl.create( new String JavaDoc[]{
230                 "Item 1", "Item 2", "Item 3"} ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
231
NumberDataSet orthoValues1 = NumberDataSetImpl.create( new double[]{
232                 25, 35, 15
233         } );
234         NumberDataSet orthoValues2 = NumberDataSetImpl.create( new double[]{
235                 17, 63.55, 27.29
236         } );
237
238         // X-Series
239
Series seCategory = SeriesImpl.create( );
240         seCategory.setDataSet( categoryValues );
241         SeriesDefinition sdX = SeriesDefinitionImpl.create( );
242         xAxisPrimary.getSeriesDefinitions( ).add( sdX );
243         sdX.getSeries( ).add( seCategory );
244
245         // Y-Series
246
BarSeries bs1 = (BarSeries) BarSeriesImpl.create( );
247         bs1.setSeriesIdentifier( "Series 1" );//$NON-NLS-1$
248
bs1.setDataSet( orthoValues1 );
249         bs1.setRiserOutline( null );
250         bs1.getLabel( ).setVisible( true );
251         bs1.setLabelPosition( Position.INSIDE_LITERAL );
252
253         BarSeries bs2 = (BarSeries) BarSeriesImpl.create( );
254         bs2.setSeriesIdentifier( "Series 2" );//$NON-NLS-1$
255
bs2.setDataSet( orthoValues2 );
256         bs2.setRiserOutline( null );
257         bs2.getLabel( ).setVisible( true );
258         bs2.setLabelPosition( Position.INSIDE_LITERAL );
259
260         SeriesDefinition sdY = SeriesDefinitionImpl.create( );
261         sdY.getSeriesPalette( ).update( 1 );
262         yAxisPrimary.getSeriesDefinitions( ).add( sdY );
263         sdY.getSeries( ).add( bs1 );
264         sdY.getSeries( ).add( bs2 );
265
266         return cwaBar;
267     }
268
269     /**
270      * Creates a line chart model as a reference implementation
271      *
272      * @return An instance of the simulated runtime chart model (containing
273      * filled datasets)
274      */

275     public static final Chart createLineChart( )
276     {
277         ChartWithAxes cwaLine = ChartWithAxesImpl.create( );
278
279         // Plot
280
cwaLine.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
281         Plot p = cwaLine.getPlot( );
282         p.getClientArea( ).setBackground( ColorDefinitionImpl.create( 255,
283                 255,
284                 225 ) );
285
286         // Title
287
cwaLine.getTitle( ).getLabel( ).getCaption( ).setValue( "Line Chart" );//$NON-NLS-1$
288

289         // Legend
290
cwaLine.getLegend( ).setVisible( false );
291
292         // X-Axis
293
Axis xAxisPrimary = cwaLine.getPrimaryBaseAxes( )[0];
294         xAxisPrimary.setType( AxisType.TEXT_LITERAL );
295         xAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );
296         xAxisPrimary.getOrigin( ).setType( IntersectionType.VALUE_LITERAL );
297         xAxisPrimary.getTitle( ).setVisible( true );
298
299         // Y-Axis
300
Axis yAxisPrimary = cwaLine.getPrimaryOrthogonalAxis( xAxisPrimary );
301         yAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.LEFT_LITERAL );
302
303         // Data Set
304
TextDataSet categoryValues = TextDataSetImpl.create( new String JavaDoc[]{
305                 "Item 1", "Item 2", "Item 3"} );//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
306
NumberDataSet orthoValues = NumberDataSetImpl.create( new double[]{
307                 25, 35, 15
308         } );
309
310         // X-Series
311
Series seCategory = SeriesImpl.create( );
312         seCategory.setDataSet( categoryValues );
313         SeriesDefinition sdX = SeriesDefinitionImpl.create( );
314
315         xAxisPrimary.getSeriesDefinitions( ).add( sdX );
316         sdX.getSeries( ).add( seCategory );
317
318         // Y-Sereis
319
LineSeries ls = (LineSeries) LineSeriesImpl.create( );
320         ls.setDataSet( orthoValues );
321         ls.getLineAttributes( ).setColor( ColorDefinitionImpl.CREAM( ) );
322         for ( int i = 0; i < ls.getMarkers( ).size( ); i++ )
323         {
324             ( (Marker) ls.getMarkers( ).get( i ) ).setType( MarkerType.TRIANGLE_LITERAL);
325         }
326         ls.getLabel( ).setVisible( true );
327
328         SeriesDefinition sdY = SeriesDefinitionImpl.create( );
329         sdY.getSeriesPalette( ).update( -2 );
330         yAxisPrimary.getSeriesDefinitions( ).add( sdY );
331         sdY.getSeries( ).add( ls );
332
333         return cwaLine;
334     }
335
336     /**
337      * Creates a pie chart model as a reference implementation
338      *
339      * @return An instance of the simulated runtime chart model (containing
340      * filled datasets)
341      */

342     public static final Chart createPieChart( )
343     {
344         ChartWithoutAxes cwoaPie = ChartWithoutAxesImpl.create( );
345
346         // Plot
347
cwoaPie.setSeriesThickness( 25 );
348         cwoaPie.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
349         Plot p = cwoaPie.getPlot( );
350         p.getClientArea( ).setBackground( null );
351         p.getClientArea( ).getOutline( ).setVisible( true );
352         p.getOutline( ).setVisible( true );
353
354         // Legend
355
Legend lg = cwoaPie.getLegend( );
356         lg.getText( ).getFont( ).setSize( 16 );
357         lg.setBackground( null );
358         lg.getOutline( ).setVisible( true );
359
360         // Title
361
cwoaPie.getTitle( ).getLabel( ).getCaption( ).setValue( "Pie Chart" );//$NON-NLS-1$
362
cwoaPie.getTitle( ).getOutline( ).setVisible( true );
363
364         // Data Set
365
TextDataSet categoryValues = TextDataSetImpl.create( new String JavaDoc[]{
366                 "New York", "Boston", "Chicago", "San Francisco", "Dallas"} );//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
367
NumberDataSet seriesOneValues = NumberDataSetImpl.create( new double[]{
368                 54.65, 21, 75.95, 91.28, 37.43
369         } );
370
371         // Base Series
372
Series seCategory = (Series) SeriesImpl.create( );
373         seCategory.setDataSet( categoryValues );
374
375         SeriesDefinition sd = SeriesDefinitionImpl.create( );
376         cwoaPie.getSeriesDefinitions( ).add( sd );
377         sd.getSeriesPalette( ).update( 0 );
378         sd.getSeries( ).add( seCategory );
379
380         // Orthogonal Series
381
PieSeries sePie = (PieSeries) PieSeriesImpl.create( );
382         sePie.setDataSet( seriesOneValues );
383         sePie.setSeriesIdentifier( "Cities" );//$NON-NLS-1$
384

385         SeriesDefinition sdCity = SeriesDefinitionImpl.create( );
386         sdCity.getQuery( ).setDefinition( "Census.City" );//$NON-NLS-1$
387
sd.getSeriesDefinitions( ).add( sdCity );
388         sdCity.getSeries( ).add( sePie );
389
390         return cwoaPie;
391     }
392
393     /**
394      * Creates a chart model containing multiple pies (grouped by categories) as
395      * a reference implementation
396      *
397      * @return An instance of the simulated runtime chart model (containing
398      * filled datasets)
399      */

400     public static final Chart createMultiPieChart( )
401     {
402         ChartWithoutAxes cwoaPie = ChartWithoutAxesImpl.create( );
403
404         // Plot
405
cwoaPie.setSeriesThickness( 25 );
406         cwoaPie.setGridColumnCount( 2 );
407         cwoaPie.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
408         Plot p = cwoaPie.getPlot( );
409         p.getClientArea( ).setBackground( null );
410         p.getClientArea( ).getOutline( ).setVisible( true );
411         p.getOutline( ).setVisible( true );
412
413         // Legend
414
Legend lg = cwoaPie.getLegend( );
415         lg.getText( ).getFont( ).setSize( 16 );
416         lg.setBackground( null );
417         lg.getOutline( ).setVisible( true );
418
419         // Title
420
cwoaPie.getTitle( )
421                 .getLabel( )
422                 .getCaption( )
423                 .setValue( "Multiple Series Pie Chart" );//$NON-NLS-1$
424
cwoaPie.getTitle( ).getOutline( ).setVisible( true );
425
426         // Data Set
427
TextDataSet categoryValues = TextDataSetImpl.create( new String JavaDoc[]{
428                 "Boston", "New York", "Chicago", "San Francisco", "Seattle"} );//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
429
NumberDataSet seriesOneValues = NumberDataSetImpl.create( new double[]{
430                 54.65, 21, 75.95, 91.28, 37.43
431         } );
432         NumberDataSet seriesTwoValues = NumberDataSetImpl.create( new double[]{
433                 15.65, 65, 25.95, 14.28, 37.43
434         } );
435         NumberDataSet seriesThreeValues = NumberDataSetImpl.create( new double[]{
436                 25.65, 85, 45.95, 64.28, 6.43
437         } );
438         NumberDataSet seriesFourValues = NumberDataSetImpl.create( new double[]{
439                 25.65, 55, 5.95, 14.28, 86.43
440         } );
441
442         // Base Sereis
443
Series seCategory = (Series) SeriesImpl.create( );
444         seCategory.setDataSet( categoryValues );
445
446         SeriesDefinition sd = SeriesDefinitionImpl.create( );
447         cwoaPie.getSeriesDefinitions( ).add( sd );
448         sd.getSeriesPalette( ).update( 1 );
449         sd.getSeries( ).add( seCategory );
450
451         // Orthogonal Series
452
PieSeries sePie1 = (PieSeries) PieSeriesImpl.create( );
453         sePie1.setDataSet( seriesOneValues );
454         sePie1.setSeriesIdentifier( "2000" );//$NON-NLS-1$
455
sePie1.getLabel( ).getCaption( ).getFont( ).setRotation( 25 );
456         sePie1.getTitle( ).getCaption( ).getFont( ).setRotation( 8 );
457         sePie1.setTitlePosition( Position.ABOVE_LITERAL );
458         sePie1.getTitle( ).getInsets( ).set( 8, 10, 0, 5 );
459
460         PieSeries sePie2 = (PieSeries) PieSeriesImpl.create( );
461         sePie2.setDataSet( seriesTwoValues );
462         sePie2.setSeriesIdentifier( "2001" );//$NON-NLS-1$
463
sePie2.getLabel( ).getCaption( ).getFont( ).setRotation( -65 );
464         sePie2.getTitle( ).getCaption( ).getFont( ).setRotation( 28 );
465         sePie2.getLabel( ).setBackground( ColorDefinitionImpl.YELLOW( ) );
466         sePie2.getLabel( ).setShadowColor( ColorDefinitionImpl.GREY( ) );
467         sePie2.setTitlePosition( Position.RIGHT_LITERAL );
468
469         PieSeries sePie3 = (PieSeries) PieSeriesImpl.create( );
470         sePie3.setDataSet( seriesThreeValues );
471         sePie3.setSeriesIdentifier( "2002" );//$NON-NLS-1$
472
sePie3.getTitle( ).getCaption( ).getFont( ).setRotation( 75 );
473         sePie3.setTitlePosition( Position.LEFT_LITERAL );
474
475         PieSeries sePie4 = (PieSeries) PieSeriesImpl.create( );
476         sePie4.setDataSet( seriesFourValues );
477         sePie4.setSeriesIdentifier( "2003" );//$NON-NLS-1$
478
sePie4.setLabelPosition( Position.INSIDE_LITERAL );
479
480         SeriesDefinition sdCity = SeriesDefinitionImpl.create( );
481         sd.getSeriesDefinitions( ).add( sdCity );
482         sdCity.getSeries( ).add( sePie1 );
483         sdCity.getSeries( ).add( sePie2 );
484         sdCity.getSeries( ).add( sePie3 );
485         sdCity.getSeries( ).add( sePie4 );
486
487         return cwoaPie;
488     }
489
490     /**
491      * Creates a stacked Bar & Line combination chart instance
492      *
493      * @return An instance of the simulated runtime chart model (containing
494      * filled datasets)
495      */

496     public static final Chart createStackedChart( )
497     {
498         ChartWithAxes cwaCombination = ChartWithAxesImpl.create( );
499
500         // Plot
501
cwaCombination.setUnitSpacing( 25 );
502         cwaCombination.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
503         Plot p = cwaCombination.getPlot( );
504         p.getClientArea( )
505                 .setBackground( GradientImpl.create( ColorDefinitionImpl.create( 255,
506                         235,
507                         255 ),
508                         ColorDefinitionImpl.create( 255, 255, 225 ),
509                         -35,
510                         false ) );
511
512         p.getClientArea( ).getInsets( ).set( 8, 8, 8, 8 );
513         p.getOutline( ).setVisible( true );
514
515         // Legend
516
Legend lg = cwaCombination.getLegend( );
517         lg.setBackground( ColorDefinitionImpl.YELLOW( ) );
518         lg.getOutline( ).setVisible( true );
519
520         // Title
521
cwaCombination.getTitle( )
522                 .getLabel( )
523                 .getCaption( )
524                 .setValue( "Project Sales" );//$NON-NLS-1$
525

526         // X-Axis
527
Axis xAxisPrimary = cwaCombination.getPrimaryBaseAxes( )[0];
528         xAxisPrimary.setType( AxisType.TEXT_LITERAL );
529
530         xAxisPrimary.getLabel( )
531                 .setBackground( ColorDefinitionImpl.create( 255, 255, 235 ) );
532         xAxisPrimary.getLabel( )
533                 .setShadowColor( ColorDefinitionImpl.create( 225, 225, 225 ) );
534         xAxisPrimary.getLabel( ).getCaption( ).getFont( ).setRotation( 25 );
535
536         xAxisPrimary.getOrigin( ).setType( IntersectionType.VALUE_LITERAL );
537         xAxisPrimary.setTitlePosition( Position.BELOW_LITERAL );
538         xAxisPrimary.setLabelPosition( Position.BELOW_LITERAL );
539
540         xAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );
541         xAxisPrimary.getMajorGrid( )
542                 .getLineAttributes( )
543                 .setStyle( LineStyle.DOTTED_LITERAL );
544         xAxisPrimary.getMajorGrid( )
545                 .getLineAttributes( )
546                 .setColor( ColorDefinitionImpl.create( 64, 64, 64 ) );
547         xAxisPrimary.getMajorGrid( ).getLineAttributes( ).setVisible( true );
548
549         xAxisPrimary.getTitle( ).getCaption( ).setValue( "Computer Components" );//$NON-NLS-1$
550
xAxisPrimary.getOrigin( ).setType( IntersectionType.MIN_LITERAL );
551
552         xAxisPrimary.getMinorGrid( )
553                 .getLineAttributes( )
554                 .setColor( ColorDefinitionImpl.CYAN( ) );
555         xAxisPrimary.getMinorGrid( ).getLineAttributes( ).setVisible( true );
556
557         // Y-Series
558
Axis yAxisPrimary = cwaCombination.getPrimaryOrthogonalAxis( xAxisPrimary );
559
560         yAxisPrimary.setLabelPosition( Position.LEFT_LITERAL );
561         yAxisPrimary.setTitlePosition( Position.LEFT_LITERAL );
562         yAxisPrimary.getTitle( )
563                 .getCaption( )
564                 .setValue( "Actual Sales ($Millions)" );//$NON-NLS-1$
565

566         yAxisPrimary.setType( AxisType.LINEAR_LITERAL );
567         yAxisPrimary.getLabel( ).getCaption( ).getFont( ).setRotation( 37 );
568
569         yAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.LEFT_LITERAL );
570         yAxisPrimary.getMajorGrid( )
571                 .getLineAttributes( )
572                 .setStyle( LineStyle.DOTTED_LITERAL );
573         yAxisPrimary.getMajorGrid( )
574                 .getLineAttributes( )
575                 .setColor( ColorDefinitionImpl.RED( ) );
576         yAxisPrimary.getMajorGrid( ).getLineAttributes( ).setVisible( true );
577         yAxisPrimary.getMinorGrid( ).setTickStyle( TickStyle.ACROSS_LITERAL );
578         yAxisPrimary.getMinorGrid( )
579                 .getLineAttributes( )
580                 .setStyle( LineStyle.DOTTED_LITERAL );
581         yAxisPrimary.getMinorGrid( )
582                 .getLineAttributes( )
583                 .setColor( ColorDefinitionImpl.GREEN( ) );
584
585         // Data Set
586
String JavaDoc[] saTextValues = {
587                 "CPUs", "Keyboards", "Video Cards",//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
588
"Monitors", "Motherboards", "Memory", "Storage Devices",//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
589
"Media", "Printers", "Scanners"};//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
590

591         TextDataSet categoryValues = TextDataSetImpl.create( saTextValues );
592         NumberDataSet seriesOneValues = NumberDataSetImpl.create( new double[]{
593                 56.99,
594                 352.95,
595                 201.95,
596                 299.95,
597                 95.95,
598                 25.45,
599                 129.33,
600                 26.5,
601                 43.5,
602                 122
603         } );
604         NumberDataSet seriesTwoValues = NumberDataSetImpl.create( new double[]{
605                 20, 35, 59, 105, 150, 37, 65, 99, 145, 185
606         } );
607         NumberDataSet seriesThreeValues = NumberDataSetImpl.create( new double[]{
608                 54.99, 21, 75.95, 39.95, 7.95, 91.22, 33.45, 25.63, 40, 13
609         } );
610         NumberDataSet seriesFourValues = NumberDataSetImpl.create( new double[]{
611                 15, 45, 43, 5, 19, 25, 35, 94, 15, 55
612         } );
613         NumberDataSet seriesFiveValues = NumberDataSetImpl.create( new double[]{
614                 43, 65, 35, 41, 45, 55, 29, 15, 85, 65
615         } );
616         NumberDataSet seriesSixValues = NumberDataSetImpl.create( new double[]{
617                 15, 45, 43, 5, 19, 25, 35, 94, 15, 55
618         } );
619         NumberDataSet seriesSevenValues = NumberDataSetImpl.create( new double[]{
620                 43, 65, 35, 41, 45, 55, 29, 15, 85, 65
621         } );
622
623         // X-Series
624
Series seCategory = SeriesImpl.create( );
625         seCategory.setDataSet( categoryValues );
626
627         SeriesDefinition sdX = SeriesDefinitionImpl.create( );
628         xAxisPrimary.getSeriesDefinitions( ).add( sdX );
629         sdX.getSeries( ).add( seCategory );
630
631         // Y-Series
632
BarSeries bs1 = (BarSeries) BarSeriesImpl.create( );
633         bs1.setSeriesIdentifier( "North America" );//$NON-NLS-1$
634
bs1.setDataSet( seriesOneValues );
635         bs1.setRiserOutline( null );
636         bs1.setRiser( RiserType.RECTANGLE_LITERAL );
637         bs1.setStacked( true );
638         DataPoint dp = DataPointImpl.create( "(", ")", ", " );//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
639
dp.getComponents( ).clear( );
640         dp.getComponents( )
641                 .add( DataPointComponentImpl.create( DataPointComponentType.BASE_VALUE_LITERAL,
642                         null ) );
643         dp.getComponents( )
644                 .add( DataPointComponentImpl.create( DataPointComponentType.ORTHOGONAL_VALUE_LITERAL,
645                         JavaNumberFormatSpecifierImpl.create( "0.00" ) ) );//$NON-NLS-1$
646
bs1.setDataPoint( dp );
647
648         BarSeries bs2 = (BarSeries) BarSeriesImpl.create( );
649         bs2.setSeriesIdentifier( "South America" );//$NON-NLS-1$
650
bs2.setDataSet( seriesThreeValues );
651         bs2.setRiserOutline( null );
652         bs2.setRiser( RiserType.RECTANGLE_LITERAL );
653         bs2.setStacked( true );
654         dp = DataPointImpl.create( "[", "]", ", " );//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
655
bs2.setDataPoint( dp );
656
657         BarSeries bs3 = (BarSeries) BarSeriesImpl.create( );
658         bs3.setSeriesIdentifier( "Eastern Europe" );//$NON-NLS-1$
659
bs3.setDataSet( seriesFourValues );
660         bs3.setRiserOutline( null );
661         bs3.setRiser( RiserType.RECTANGLE_LITERAL );
662         bs3.setStacked( true );
663
664         BarSeries bs4 = (BarSeries) BarSeriesImpl.create( );
665         bs4.setSeriesIdentifier( "Western Europe" );//$NON-NLS-1$
666
bs4.setDataSet( seriesFiveValues );
667         bs4.setRiserOutline( null );
668         bs4.setRiser( RiserType.RECTANGLE_LITERAL );
669         bs4.setStacked( true );
670
671         BarSeries bs5 = (BarSeries) BarSeriesImpl.create( );
672         bs5.setSeriesIdentifier( "Asia" );//$NON-NLS-1$
673
bs5.setDataSet( seriesSixValues );
674         bs5.setRiserOutline( null );
675         bs5.setRiser( RiserType.RECTANGLE_LITERAL );
676
677         BarSeries bs6 = (BarSeries) BarSeriesImpl.create( );
678         bs6.setSeriesIdentifier( "Australia" );//$NON-NLS-1$
679
bs6.setDataSet( seriesSevenValues );
680         bs6.setRiserOutline( null );
681         bs6.setRiser( RiserType.RECTANGLE_LITERAL );
682
683         LineSeries ls1 = (LineSeries) LineSeriesImpl.create( );
684         ls1.setSeriesIdentifier( "Expected Growth" );//$NON-NLS-1$
685
ls1.setDataSet( seriesTwoValues );
686         for ( int i = 0; i < ls1.getMarkers( ).size( ); i++ )
687         {
688             ( (Marker) ls1.getMarkers( ).get( i ) ).setType( MarkerType.BOX_LITERAL);
689         }
690         ls1.getLabel( ).setVisible( true );
691
692         SeriesDefinition sdY1 = SeriesDefinitionImpl.create( );
693         sdY1.getSeriesPalette( ).update( 0 );
694         yAxisPrimary.getSeriesDefinitions( ).add( sdY1 );
695
696         SeriesDefinition sdY2 = SeriesDefinitionImpl.create( );
697         sdY2.getSeriesPalette( ).update( 1 );
698         yAxisPrimary.getSeriesDefinitions( ).add( sdY2 );
699
700         SeriesDefinition sdY3 = SeriesDefinitionImpl.create( );
701         sdY3.getSeriesPalette( ).update( ColorDefinitionImpl.RED( ) );
702         yAxisPrimary.getSeriesDefinitions( ).add( sdY3 );
703
704         SeriesDefinition sdY4 = SeriesDefinitionImpl.create( );
705         sdY4.getSeriesPalette( ).update( ColorDefinitionImpl.GREEN( ) );
706         yAxisPrimary.getSeriesDefinitions( ).add( sdY4 );
707
708         SeriesDefinition sdY5 = SeriesDefinitionImpl.create( );
709         sdY5.getSeriesPalette( ).update( ColorDefinitionImpl.YELLOW( ) );
710         yAxisPrimary.getSeriesDefinitions( ).add( sdY5 );
711
712         sdY1.getSeries( ).add( bs1 );
713         sdY1.getSeries( ).add( bs2 );
714         sdY2.getSeries( ).add( bs3 );
715         sdY2.getSeries( ).add( bs4 );
716         sdY3.getSeries( ).add( bs5 );
717         sdY4.getSeries( ).add( bs6 );
718         sdY5.getSeries( ).add( ls1 );
719
720         return cwaCombination;
721     }
722
723     /**
724      * Creates a numeric scatter chart instance
725      *
726      * @return An instance of the simulated runtime chart model (containing
727      * filled datasets)
728      */

729     public static final Chart createScatterChart( )
730     {
731         ChartWithAxes cwaScatter = ChartWithAxesImpl.create( );
732
733         // Plot
734
cwaScatter.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
735         cwaScatter.getPlot( ).getClientArea( ).getOutline( ).setVisible( false );
736         cwaScatter.getPlot( )
737                 .getClientArea( )
738                 .setBackground( ColorDefinitionImpl.create( 255, 255, 225 ) );
739
740         // Title
741
cwaScatter.getTitle( )
742                 .getLabel( )
743                 .getCaption( )
744                 .setValue( "Numeric Scatter Chart" );//$NON-NLS-1$
745

746         // X-Axis
747
Axis xAxisPrimary = ( (ChartWithAxesImpl) cwaScatter ).getPrimaryBaseAxes( )[0];
748
749         xAxisPrimary.getTitle( ).getCaption( ).setValue( "X Axis" );//$NON-NLS-1$
750
xAxisPrimary.setType( AxisType.LINEAR_LITERAL );
751         xAxisPrimary.getLabel( )
752                 .getCaption( )
753                 .setColor( ColorDefinitionImpl.GREEN( ).darker( ) );
754         xAxisPrimary.getTitle( ).setVisible( false );
755
756         xAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );
757         xAxisPrimary.getMajorGrid( )
758                 .getLineAttributes( )
759                 .setStyle( LineStyle.DOTTED_LITERAL );
760         xAxisPrimary.getMajorGrid( )
761                 .getLineAttributes( )
762                 .setColor( ColorDefinitionImpl.GREY( ) );
763         xAxisPrimary.getMajorGrid( ).getLineAttributes( ).setVisible( true );
764
765         xAxisPrimary.getOrigin( ).setType( IntersectionType.VALUE_LITERAL );
766
767         // Y-Axis
768
Axis yAxisPrimary = ( (ChartWithAxesImpl) cwaScatter ).getPrimaryOrthogonalAxis( xAxisPrimary );
769
770         yAxisPrimary.getLabel( ).getCaption( ).setValue( "Price Axis" );//$NON-NLS-1$
771
yAxisPrimary.getLabel( )
772                 .getCaption( )
773                 .setColor( ColorDefinitionImpl.BLUE( ) );
774         yAxisPrimary.getTitle( ).setVisible( true );
775         yAxisPrimary.setType( AxisType.LINEAR_LITERAL );
776
777         yAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.LEFT_LITERAL );
778         yAxisPrimary.getMajorGrid( )
779                 .getLineAttributes( )
780                 .setStyle( LineStyle.DOTTED_LITERAL );
781         yAxisPrimary.getMajorGrid( )
782                 .getLineAttributes( )
783                 .setColor( ColorDefinitionImpl.GREY( ) );
784         yAxisPrimary.getMajorGrid( ).getLineAttributes( ).setVisible( true );
785
786         yAxisPrimary.getOrigin( ).setType( IntersectionType.VALUE_LITERAL );
787
788         // Data Set
789
NumberDataSet dsNumericValues1 = NumberDataSetImpl.create( new double[]{
790                 -46.55, 25.32, 84.46, 125.95, 38.65, -54.32, 30
791         } );
792         NumberDataSet dsNumericValues2 = NumberDataSetImpl.create( new double[]{
793                 125.99, 352.95, -201.95, 299.95, -95.95, 65.95, 58.95
794         } );
795
796         // X-Series
797
Series seBase = SeriesImpl.create( );
798         seBase.setDataSet( dsNumericValues1 );
799
800         SeriesDefinition sdX = SeriesDefinitionImpl.create( );
801         xAxisPrimary.getSeriesDefinitions( ).add( sdX );
802         sdX.getSeries( ).add( seBase );
803
804         // Y-Series
805
ScatterSeries ss = (ScatterSeries) ScatterSeriesImpl.create( );
806         ss.setSeriesIdentifier( "Unit Price" );//$NON-NLS-1$
807
for ( int i = 0; i < ss.getMarkers( ).size( ); i++ )
808         {
809             ( (Marker) ss.getMarkers( ).get( i ) ).setType( MarkerType.CIRCLE_LITERAL);
810         }
811         DataPoint dp = ss.getDataPoint( );
812         dp.getComponents( ).clear( );
813         dp.setPrefix( "(" );//$NON-NLS-1$
814
dp.setSuffix( ")" );//$NON-NLS-1$
815
dp.getComponents( )
816                 .add( DataPointComponentImpl.create( DataPointComponentType.BASE_VALUE_LITERAL,
817                         JavaNumberFormatSpecifierImpl.create( "0.00" ) ) );//$NON-NLS-1$
818
dp.getComponents( )
819                 .add( DataPointComponentImpl.create( DataPointComponentType.ORTHOGONAL_VALUE_LITERAL,
820                         JavaNumberFormatSpecifierImpl.create( "0.00" ) ) );//$NON-NLS-1$
821
ss.getLabel( ).getCaption( ).setColor( ColorDefinitionImpl.RED( ) );
822         ss.getLabel( ).setBackground( ColorDefinitionImpl.CYAN( ) );
823         ss.getLabel( ).setVisible( true );
824         ss.setDataSet( dsNumericValues2 );
825
826         SeriesDefinition sdY = SeriesDefinitionImpl.create( );
827         yAxisPrimary.getSeriesDefinitions( ).add( sdY );
828         sdY.getSeriesPalette( ).update( ColorDefinitionImpl.BLACK( ) );
829         sdY.getSeries( ).add( ss );
830
831         return cwaScatter;
832     }
833
834     /**
835      * Creates a stock chart instance
836      *
837      * @return An instance of the simulated runtime chart model (containing
838      * filled datasets)
839      */

840     public final static Chart createStockChart( )
841     {
842         ChartWithAxes cwaStock = ChartWithAxesImpl.create( );
843
844         // Title
845
cwaStock.getTitle( ).getLabel( ).getCaption( ).setValue( "Stock Chart" );//$NON-NLS-1$
846
TitleBlock tb = cwaStock.getTitle( );
847         tb.setBackground( GradientImpl.create( ColorDefinitionImpl.create( 0,
848                 128,
849                 0 ), ColorDefinitionImpl.create( 128, 0, 0 ), 0, false ) );
850         tb.getLabel( ).getCaption( ).setColor( ColorDefinitionImpl.WHITE( ) );
851
852         // Plot
853
cwaStock.getBlock( )
854                 .setBackground( GradientImpl.create( ColorDefinitionImpl.create( 196,
855                         196,
856                         196 ),
857                         ColorDefinitionImpl.WHITE( ),
858                         90,
859                         false ) );
860         cwaStock.getPlot( ).getClientArea( ).getInsets( ).set( 10, 10, 10, 10 );
861
862         // Legend
863
cwaStock.getLegend( ).setBackground( ColorDefinitionImpl.ORANGE( ) );
864
865         // X-Axis
866
Axis xAxisPrimary = ( (ChartWithAxesImpl) cwaStock ).getPrimaryBaseAxes( )[0];
867
868         xAxisPrimary.getTitle( ).getCaption( ).setValue( "X Axis" );//$NON-NLS-1$
869
xAxisPrimary.getTitle( )
870                 .getCaption( )
871                 .setColor( ColorDefinitionImpl.RED( ) );
872         xAxisPrimary.getTitle( ).getCaption( ).setValue( "Date" );//$NON-NLS-1$
873
xAxisPrimary.setTitlePosition( Position.ABOVE_LITERAL );
874
875         xAxisPrimary.getLabel( )
876                 .getCaption( )
877                 .setColor( ColorDefinitionImpl.RED( ) );
878         xAxisPrimary.getLabel( ).getCaption( ).getFont( ).setRotation( 65 );
879         xAxisPrimary.setLabelPosition( Position.ABOVE_LITERAL );
880
881         xAxisPrimary.setType( AxisType.DATE_TIME_LITERAL );
882         xAxisPrimary.getOrigin( ).setType( IntersectionType.MAX_LITERAL );
883
884         xAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.ABOVE_LITERAL );
885         xAxisPrimary.getMajorGrid( )
886                 .getLineAttributes( )
887                 .setColor( ColorDefinitionImpl.create( 255, 196, 196 ) );
888         xAxisPrimary.getMajorGrid( )
889                 .getLineAttributes( )
890                 .setStyle( LineStyle.DOTTED_LITERAL );
891         xAxisPrimary.getMajorGrid( ).getLineAttributes( ).setVisible( true );
892
893         xAxisPrimary.setCategoryAxis( true );
894
895         // Y-Axis (1)
896
Axis yAxisPrimary = ( (ChartWithAxesImpl) cwaStock ).getPrimaryOrthogonalAxis( xAxisPrimary );
897
898         yAxisPrimary.getLabel( ).getCaption( ).setValue( "Price Axis" );//$NON-NLS-1$
899
yAxisPrimary.getLabel( )
900                 .getCaption( )
901                 .setColor( ColorDefinitionImpl.BLUE( ) );
902         yAxisPrimary.setLabelPosition( Position.LEFT_LITERAL );
903
904         yAxisPrimary.getTitle( )
905                 .getCaption( )
906                 .setValue( "Microsoft ($ Stock Price)" );//$NON-NLS-1$
907
yAxisPrimary.getTitle( )
908                 .getCaption( )
909                 .setColor( ColorDefinitionImpl.BLUE( ) );
910         yAxisPrimary.setTitlePosition( Position.LEFT_LITERAL );
911
912         yAxisPrimary.getScale( ).setMin( NumberDataElementImpl.create( 24.5 ) );
913         yAxisPrimary.getScale( ).setMax( NumberDataElementImpl.create( 27.5 ) );
914         yAxisPrimary.getScale( ).setStep( 0.5 );
915
916         yAxisPrimary.getMajorGrid( )
917                 .getLineAttributes( )
918                 .setColor( ColorDefinitionImpl.create( 196, 196, 255 ) );
919         yAxisPrimary.getMajorGrid( )
920                 .getLineAttributes( )
921                 .setStyle( LineStyle.DOTTED_LITERAL );
922         yAxisPrimary.getMajorGrid( ).getLineAttributes( ).setVisible( true );
923         yAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.LEFT_LITERAL );
924
925         yAxisPrimary.setType( AxisType.LINEAR_LITERAL );
926         yAxisPrimary.getOrigin( ).setType( IntersectionType.MIN_LITERAL );
927
928         // Y-Axis (2)
929
Axis yAxisOverlay = AxisImpl.create( Axis.ORTHOGONAL );
930
931         yAxisOverlay.getLabel( )
932                 .getCaption( )
933                 .setColor( ColorDefinitionImpl.create( 0, 128, 0 ) );
934         yAxisOverlay.getLabel( ).getCaption( ).getFont( ).setRotation( -25 );
935         yAxisOverlay.setLabelPosition( Position.RIGHT_LITERAL );
936
937         yAxisOverlay.getTitle( ).getCaption( ).setValue( "Volume" );//$NON-NLS-1$
938
yAxisOverlay.getTitle( )
939                 .getCaption( )
940                 .setColor( ColorDefinitionImpl.GREEN( ).darker( ) );
941         yAxisOverlay.getTitle( ).getCaption( ).getFont( ).setRotation( 90 );
942         yAxisOverlay.getTitle( ).getCaption( ).getFont( ).setSize( 16 );
943         yAxisOverlay.getTitle( ).getCaption( ).getFont( ).setBold( true );
944         yAxisOverlay.getTitle( ).setVisible( true );
945         yAxisOverlay.setTitlePosition( Position.RIGHT_LITERAL );
946
947         yAxisOverlay.getLineAttributes( )
948                 .setColor( ColorDefinitionImpl.create( 0, 128, 0 ) );
949
950         yAxisOverlay.setType( AxisType.LINEAR_LITERAL );
951         yAxisOverlay.setOrientation( Orientation.VERTICAL_LITERAL );
952
953         yAxisOverlay.getMajorGrid( )
954                 .getLineAttributes( )
955                 .setColor( ColorDefinitionImpl.create( 64, 196, 64 ) );
956         yAxisOverlay.getMajorGrid( )
957                 .getLineAttributes( )
958                 .setStyle( LineStyle.DOTTED_LITERAL );
959         yAxisOverlay.getMajorGrid( ).getLineAttributes( ).setVisible( true );
960         yAxisOverlay.getMajorGrid( ).setTickStyle( TickStyle.RIGHT_LITERAL );
961
962         yAxisOverlay.getOrigin( ).setType( IntersectionType.MAX_LITERAL );
963         yAxisOverlay.getScale( )
964                 .setMax( NumberDataElementImpl.create( 180000000 ) );
965         yAxisOverlay.getScale( )
966                 .setMin( NumberDataElementImpl.create( 20000000 ) );
967
968         xAxisPrimary.getAssociatedAxes( ).add( yAxisOverlay );
969
970         // Data Set
971
DateTimeDataSet dsDateValues = DateTimeDataSetImpl.create( new Calendar[]{
972                 new CDateTime( 2004, 12, 27 ),
973                 new CDateTime( 2004, 12, 23 ),
974                 new CDateTime( 2004, 12, 22 ),
975                 new CDateTime( 2004, 12, 21 ),
976                 new CDateTime( 2004, 12, 20 ),
977                 new CDateTime( 2004, 12, 17 ),
978                 new CDateTime( 2004, 12, 16 ),
979                 new CDateTime( 2004, 12, 15 )
980         } );
981
982         StockDataSet dsStockValues = StockDataSetImpl.create( new StockEntry[]{
983                 new StockEntry( 27.01, 27.10, 26.82, 26.85 ),
984                 new StockEntry( 26.87, 27.15, 26.83, 27.01 ),
985                 new StockEntry( 26.84, 27.15, 26.78, 26.97 ),
986                 new StockEntry( 27.00, 27.17, 26.94, 27.07 ),
987                 new StockEntry( 27.01, 27.15, 26.89, 26.95 ),
988                 new StockEntry( 27.00, 27.32, 26.80, 26.96 ),
989                 new StockEntry( 27.15, 27.28, 27.01, 27.16 ),
990                 new StockEntry( 27.22, 27.40, 27.07, 27.11 ),
991         } );
992
993         NumberDataSet dsStockVolume = NumberDataSetImpl.create( new double[]{
994                 55958500,
995                 65801900,
996                 63651900,
997                 94646096,
998                 85552800,
999                 126184400,
1000                88997504,
1001                106303904
1002        } );
1003
1004        // X-Series
1005
Series seBase = SeriesImpl.create( );
1006        seBase.setDataSet( dsDateValues );
1007
1008        SeriesDefinition sdX = SeriesDefinitionImpl.create( );
1009        sdX.getSeriesPalette( ).update( 1 );
1010        xAxisPrimary.getSeriesDefinitions( ).add( sdX );
1011        sdX.getSeries( ).add( seBase );
1012
1013        // Y-Series
1014
BarSeries bs = (BarSeries) BarSeriesImpl.create( );
1015        bs.setRiserOutline( null );
1016        bs.setDataSet( dsStockVolume );
1017
1018        StockSeries ss = (StockSeries) StockSeriesImpl.create( );
1019        ss.setSeriesIdentifier( "Stock Price" );//$NON-NLS-1$
1020
ss.getLineAttributes( ).setColor( ColorDefinitionImpl.BLUE( ) );
1021        ss.setDataSet( dsStockValues );
1022
1023        SeriesDefinition sdY1 = SeriesDefinitionImpl.create( );
1024        sdY1.getSeriesPalette( ).update( ColorDefinitionImpl.CYAN( ) );
1025        yAxisPrimary.getSeriesDefinitions( ).add( sdY1 );
1026        sdY1.getSeries( ).add( ss );
1027
1028        SeriesDefinition sdY2 = SeriesDefinitionImpl.create( );
1029        sdY2.getSeriesPalette( ).update( ColorDefinitionImpl.GREEN( ) );
1030        yAxisOverlay.getSeriesDefinitions( ).add( sdY2 );
1031        sdY2.getSeries( ).add( bs );
1032
1033        return cwaStock;
1034    }
1035
1036    /**
1037     * Creates a Area chart model as a reference implementation
1038     *
1039     * @return An instance of the simulated runtime chart model (containing
1040     * filled datasets)
1041     */

1042    public static final Chart createAreaChart( )
1043    {
1044        ChartWithAxes cwaArea = ChartWithAxesImpl.create( );
1045
1046        // Plot/Title
1047
cwaArea.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
1048        Plot p = cwaArea.getPlot( );
1049        p.getClientArea( ).setBackground( ColorDefinitionImpl.create( 225,
1050                225,
1051                225 ) );
1052        cwaArea.getTitle( ).getLabel( ).getCaption( ).setValue( "Area Chart" );//$NON-NLS-1$
1053
cwaArea.getTitle( ).setVisible( true );
1054
1055        // Legend
1056
Legend lg = cwaArea.getLegend( );
1057        LineAttributes lia = lg.getOutline( );
1058        lg.getText( ).getFont( ).setSize( 16 );
1059        lia.setStyle( LineStyle.SOLID_LITERAL );
1060        lg.getInsets( ).set( 10, 5, 0, 0 );
1061        lg.getOutline( ).setVisible( false );
1062        lg.setAnchor( Anchor.NORTH_LITERAL );
1063
1064        // X-Axis
1065
Axis xAxisPrimary = cwaArea.getPrimaryBaseAxes( )[0];
1066        xAxisPrimary.setType( AxisType.TEXT_LITERAL );
1067        xAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );
1068        xAxisPrimary.getMajorGrid( )
1069                .setLineAttributes( LineAttributesImpl.create( ColorDefinitionImpl.BLUE( ),
1070                        LineStyle.SOLID_LITERAL,
1071                        1 ) );
1072        xAxisPrimary.getMinorGrid( ).getLineAttributes( ).setVisible( true );
1073        xAxisPrimary.getOrigin( ).setType( IntersectionType.MIN_LITERAL );
1074        xAxisPrimary.getTitle( ).getCaption( ).setValue( "Month" );//$NON-NLS-1$
1075
xAxisPrimary.getTitle( ).setVisible( true );
1076        xAxisPrimary.getTitle( ).getCaption( ).getFont( ).setRotation( 0 );
1077        xAxisPrimary.getLabel( ).setVisible( true );
1078
1079        // Y-Axis
1080
Axis yAxisPrimary = cwaArea.getPrimaryOrthogonalAxis( xAxisPrimary );
1081        yAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.LEFT_LITERAL );
1082        yAxisPrimary.getMajorGrid( )
1083                .setLineAttributes( LineAttributesImpl.create( ColorDefinitionImpl.BLACK( ),
1084                        LineStyle.SOLID_LITERAL,
1085                        1 ) );
1086        yAxisPrimary.getMinorGrid( ).getLineAttributes( ).setVisible( true );
1087        yAxisPrimary.setPercent( false );
1088        yAxisPrimary.getTitle( ).getCaption( ).setValue( "Net Profit" );//$NON-NLS-1$
1089
yAxisPrimary.getTitle( ).setVisible( true );
1090        yAxisPrimary.getTitle( ).getCaption( ).getFont( ).setRotation( 90 );
1091        yAxisPrimary.getLabel( ).setVisible( true );
1092
1093        MarkerLine ml = MarkerLineImpl.create( yAxisPrimary,
1094                NumberDataElementImpl.create( 2 ) );
1095        yAxisPrimary.getMarkerLines( ).add( ml );
1096
1097        // Data Set
1098
TextDataSet categoryValues = TextDataSetImpl.create( new String JavaDoc[]{
1099                "Jan.", "Feb.", "Mar.", "Apr", "May"} ); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$
1100
NumberDataSet orthoValues1 = NumberDataSetImpl.create( new double[]{
1101                14.32, -19.5, 8.38, 0.34, 9.22
1102        } );
1103        NumberDataSet orthoValues2 = NumberDataSetImpl.create( new double[]{
1104                4.2, -19.5, 0.0, 9.2, 7.6
1105        } );
1106
1107        // X-Series
1108
Series seCategory = SeriesImpl.create( );
1109        seCategory.setDataSet( categoryValues );
1110
1111        SeriesDefinition sdX = SeriesDefinitionImpl.create( );
1112        sdX.getSeriesPalette( ).update( 0 );
1113        xAxisPrimary.getSeriesDefinitions( ).add( sdX );
1114        sdX.getSeries( ).add( seCategory );
1115
1116        // Y-Series
1117
AreaSeries as1 = (AreaSeries) AreaSeriesImpl.create( );
1118        as1.setSeriesIdentifier( "Series 1" );//$NON-NLS-1$
1119
as1.setDataSet( orthoValues1 );
1120        as1.setTranslucent( true );
1121        as1.getLineAttributes( ).setColor( ColorDefinitionImpl.BLUE( ) );
1122        as1.getLabel( ).setVisible( true );
1123
1124        AreaSeries as2 = (AreaSeries) AreaSeriesImpl.create( );
1125        as2.setSeriesIdentifier( "Series 2" );//$NON-NLS-1$
1126
as2.setDataSet( orthoValues2 );
1127        as2.setTranslucent( true );
1128        as2.getLineAttributes( ).setColor( ColorDefinitionImpl.PINK( ) );
1129        as2.getLabel( ).setVisible( true );
1130
1131        SeriesDefinition sdY = SeriesDefinitionImpl.create( );
1132        sdY.getSeriesPalette( ).update( 1 );
1133        yAxisPrimary.getSeriesDefinitions( ).add( sdY );
1134        sdY.getSeries( ).add( as1 );
1135        sdY.getSeries( ).add( as2 );
1136
1137        return cwaArea;
1138
1139    }
1140
1141    /**
1142     * Creates a Single Dial, Multi Regions chart model as a reference
1143     * implementation
1144     *
1145     * @return An instance of the simulated runtime chart model (containing
1146     * filled datasets)
1147     */

1148    public static final Chart createSDialMRegionChart( )
1149    {
1150        DialChart dChart = (DialChart) DialChartImpl.create( );
1151        dChart.setDialSuperimposition( false );
1152        dChart.setGridColumnCount( 2 );
1153        dChart.setSeriesThickness( 25 );
1154
1155        // Title/Plot
1156
dChart.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
1157        Plot p = dChart.getPlot( );
1158        p.getClientArea( ).setBackground( ColorDefinitionImpl.CREAM( ) );
1159        p.getClientArea( ).getOutline( ).setVisible( false );
1160        p.getOutline( ).setVisible( false );
1161
1162        dChart.getTitle( )
1163                .getLabel( )
1164                .getCaption( )
1165                .setValue( "City Temperature" );//$NON-NLS-1$
1166
dChart.getTitle( ).getOutline( ).setVisible( false );
1167
1168        // Legend
1169
Legend lg = dChart.getLegend( );
1170        LineAttributes lia = lg.getOutline( );
1171        lg.getText( ).getFont( ).setSize( 16 );
1172        lia.setStyle( LineStyle.SOLID_LITERAL );
1173        lg.getInsets( ).setLeft( 10 );
1174        lg.getInsets( ).setRight( 10 );
1175        lg.setBackground( null );
1176        lg.getOutline( ).setVisible( false );
1177        lg.setShowValue( true );
1178        lg.getClientArea( ).setBackground( ColorDefinitionImpl.PINK( ) );
1179
1180        lg.getClientArea( ).getOutline( ).setVisible( true );
1181        lg.getTitle( ).getCaption( ).getFont( ).setSize( 20 );
1182        lg.getTitle( ).setInsets( InsetsImpl.create( 10, 10, 10, 10 ) );
1183        lg.getTitle( ).getCaption( ).setValue( "Weather" );//$NON-NLS-1$
1184
lg.getTitle( ).setVisible( true );
1185        lg.setTitlePosition( Position.ABOVE_LITERAL );
1186
1187        TextDataSet categoryValues = TextDataSetImpl.create( new String JavaDoc[]{
1188                "London", "Madrid", "Rome", "Moscow"} );//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
1189
NumberDataSet seriesValues = NumberDataSetImpl.create( new double[]{
1190                21.0, 39.0, 30.0, 10.0
1191        } );
1192
1193        SeriesDefinition sd = SeriesDefinitionImpl.create( );
1194        dChart.getSeriesDefinitions( ).add( sd );
1195        Series seCategory = (Series) SeriesImpl.create( );
1196
1197        final Fill[] fiaBase = {
1198                ColorDefinitionImpl.ORANGE( ),
1199                GradientImpl.create( ColorDefinitionImpl.create( 225, 225, 255 ),
1200                        ColorDefinitionImpl.create( 255, 255, 225 ),
1201                        -35,
1202                        false ),
1203                ColorDefinitionImpl.CREAM( ),
1204                ColorDefinitionImpl.RED( ),
1205                ColorDefinitionImpl.GREEN( ),
1206                ColorDefinitionImpl.BLUE( ).brighter( ),
1207                ColorDefinitionImpl.CYAN( ).darker( ),
1208        };
1209        sd.getSeriesPalette( ).getEntries( ).clear( );
1210        for ( int i = 0; i < fiaBase.length; i++ )
1211        {
1212            sd.getSeriesPalette( ).getEntries( ).add( fiaBase[i] );
1213        }
1214
1215        seCategory.setDataSet( categoryValues );
1216        sd.getSeries( ).add( seCategory );
1217
1218        SeriesDefinition sdCity = SeriesDefinitionImpl.create( );
1219
1220        // Dial
1221
DialSeries seDial = (DialSeries) DialSeriesImpl.create( );
1222        seDial.setDataSet( seriesValues );
1223        seDial.getDial( )
1224                .setFill( GradientImpl.create( ColorDefinitionImpl.create( 225,
1225                        255,
1226                        225 ),
1227                        ColorDefinitionImpl.create( 225, 225, 255 ),
1228                        45,
1229                        false ) );
1230        NumberFormatSpecifier nfs = NumberFormatSpecifierImpl.create( );
1231        nfs.setSuffix( "`C" );//$NON-NLS-1$
1232
nfs.setFractionDigits( 0 );
1233        seDial.getDial( ).setFormatSpecifier( nfs );
1234        seDial.setSeriesIdentifier( "Temperature" );//$NON-NLS-1$
1235
seDial.getNeedle( ).setDecorator( LineDecorator.CIRCLE_LITERAL );
1236        seDial.getDial( ).setStartAngle( -45 );
1237        seDial.getDial( ).setStopAngle( 225 );
1238        seDial.getDial( )
1239                .getMinorGrid( )
1240                .getTickAttributes( )
1241                .setVisible( true );
1242        seDial.getDial( )
1243                .getMinorGrid( )
1244                .getTickAttributes( )
1245                .setColor( ColorDefinitionImpl.BLACK( ) );
1246        seDial.getDial( )
1247                .getMinorGrid( )
1248                .setTickStyle( TickStyle.BELOW_LITERAL );
1249        seDial.getDial( )
1250                .getScale( )
1251                .setMin( NumberDataElementImpl.create( 0 ) );
1252        seDial.getDial( )
1253                .getScale( )
1254                .setMax( NumberDataElementImpl.create( 90 ) );
1255        seDial.getDial( ).getScale( ).setStep( 10 );
1256        seDial.getLabel( )
1257                .setOutline( LineAttributesImpl.create( ColorDefinitionImpl.GREY( )
1258                        .darker( ),
1259                        LineStyle.SOLID_LITERAL,
1260                        1 ) );
1261        seDial.getLabel( ).setBackground( ColorDefinitionImpl.GREY( )
1262                .brighter( ) );
1263
1264        DialRegion dregion1 = DialRegionImpl.create( );
1265        dregion1.setFill( ColorDefinitionImpl.GREEN( ) );
1266        dregion1.setOutline( LineAttributesImpl.create( ColorDefinitionImpl.BLACK( )
1267                .darker( ),
1268                LineStyle.SOLID_LITERAL,
1269                1 ) );
1270        dregion1.setStartValue( NumberDataElementImpl.create( 70 ) );
1271        dregion1.setEndValue( NumberDataElementImpl.create( 90 ) );
1272        dregion1.setInnerRadius( 40 );
1273        dregion1.setOuterRadius( -1 );
1274        seDial.getDial( ).getDialRegions( ).add( dregion1 );
1275
1276        DialRegion dregion2 = DialRegionImpl.create( );
1277        dregion2.setFill( ColorDefinitionImpl.YELLOW( ) );
1278        dregion2.setOutline( LineAttributesImpl.create( ColorDefinitionImpl.BLACK( )
1279                .darker( ),
1280                LineStyle.SOLID_LITERAL,
1281                1 ) );
1282        dregion2.setStartValue( NumberDataElementImpl.create( 40 ) );
1283        dregion2.setEndValue( NumberDataElementImpl.create( 70 ) );
1284        dregion2.setOuterRadius( 70 );
1285        seDial.getDial( ).getDialRegions( ).add( dregion2 );
1286
1287        DialRegion dregion3 = DialRegionImpl.create( );
1288        dregion3.setFill( ColorDefinitionImpl.RED( ) );
1289        dregion3.setOutline( LineAttributesImpl.create( ColorDefinitionImpl.BLACK( )
1290                .darker( ),
1291                LineStyle.SOLID_LITERAL,
1292                1 ) );
1293        dregion3.setStartValue( NumberDataElementImpl.create( 0 ) );
1294        dregion3.setEndValue( NumberDataElementImpl.create( 40 ) );
1295        dregion3.setInnerRadius( 40 );
1296        dregion3.setOuterRadius( 90 );
1297        seDial.getDial( ).getDialRegions( ).add( dregion3 );
1298
1299        sd.getSeriesDefinitions( ).add( sdCity );
1300        sdCity.getSeries( ).add( seDial );
1301
1302        return dChart;
1303    }
1304
1305    /**
1306     * Creates a Multi Dials, Multi Regions chart model as a reference
1307     * implementation
1308     *
1309     * @return An instance of the simulated runtime chart model (containing
1310     * filled datasets)
1311     */

1312    public static final Chart createMDialMRegionChart( )
1313    {
1314        DialChart dChart = (DialChart) DialChartImpl.create( );
1315        dChart.setDialSuperimposition( false );
1316        dChart.setGridColumnCount( 2 );
1317        dChart.setSeriesThickness( 25 );
1318
1319        // Title/Plot
1320
dChart.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
1321        Plot p = dChart.getPlot( );
1322        p.getClientArea( ).setBackground( ColorDefinitionImpl.CREAM( ) );
1323        p.getClientArea( ).getOutline( ).setVisible( false );
1324        p.getOutline( ).setVisible( false );
1325
1326        dChart.getTitle( ).getLabel( ).getCaption( ).setValue( "Meter Chart" );//$NON-NLS-1$
1327
dChart.getTitle( ).getOutline( ).setVisible( false );
1328
1329        // Legend
1330
Legend lg = dChart.getLegend( );
1331        LineAttributes lia = lg.getOutline( );
1332        lg.getText( ).getFont( ).setSize( 16 );
1333        lia.setStyle( LineStyle.SOLID_LITERAL );
1334        lg.getInsets( ).setLeft( 10 );
1335        lg.getInsets( ).setRight( 10 );
1336        lg.setBackground( null );
1337        lg.getOutline( ).setVisible( false );
1338        lg.setShowValue( true );
1339        lg.getClientArea( ).setBackground( ColorDefinitionImpl.PINK( ) );
1340
1341        lg.getClientArea( ).getOutline( ).setVisible( true );
1342        lg.getTitle( ).getCaption( ).getFont( ).setSize( 20 );
1343        lg.getTitle( ).setInsets( InsetsImpl.create( 10, 10, 10, 10 ) );
1344        lg.setTitlePosition( Position.ABOVE_LITERAL );
1345        lg.setPosition( Position.BELOW_LITERAL );
1346        lg.setItemType( LegendItemType.SERIES_LITERAL );
1347
1348        TextDataSet categoryValues = TextDataSetImpl.create( new String JavaDoc[]{
1349            "Moto"} );//$NON-NLS-1$
1350

1351        SeriesDefinition sd = SeriesDefinitionImpl.create( );
1352        dChart.getSeriesDefinitions( ).add( sd );
1353        Series seCategory = (Series) SeriesImpl.create( );
1354
1355        seCategory.setDataSet( categoryValues );
1356        sd.getSeries( ).add( seCategory );
1357
1358        SeriesDefinition sdCity = SeriesDefinitionImpl.create( );
1359
1360        final Fill[] fiaOrth = {
1361                ColorDefinitionImpl.PINK( ),
1362                ColorDefinitionImpl.ORANGE( ),
1363                ColorDefinitionImpl.WHITE( )
1364        };
1365        sdCity.getSeriesPalette( ).getEntries( ).clear( );
1366        for ( int i = 0; i < fiaOrth.length; i++ )
1367        {
1368            sdCity.getSeriesPalette( ).getEntries( ).add( fiaOrth[i] );
1369        }
1370
1371        // Dial 1
1372
DialSeries seDial1 = (DialSeries) DialSeriesImpl.create( );
1373        seDial1.setDataSet( NumberDataSetImpl.create( new double[]{
1374            20
1375        } ) );
1376        seDial1.getDial( )
1377                .setFill( GradientImpl.create( ColorDefinitionImpl.create( 225,
1378                        255,
1379                        225 ),
1380                        ColorDefinitionImpl.create( 225, 225, 255 ),
1381                        45,
1382                        false ) );
1383        seDial1.setSeriesIdentifier( "Temperature" );//$NON-NLS-1$
1384
seDial1.getNeedle( ).setDecorator( LineDecorator.CIRCLE_LITERAL );
1385        seDial1.getDial( ).setStartAngle( -45 );
1386        seDial1.getDial( ).setStopAngle( 225 );
1387        seDial1.getDial( )
1388                .getMinorGrid( )
1389                .getTickAttributes( )
1390                .setVisible( true );
1391        seDial1.getDial( )
1392                .getMinorGrid( )
1393                .getTickAttributes( )
1394                .setColor( ColorDefinitionImpl.BLACK( ) );
1395        seDial1.getDial( )
1396                .getMinorGrid( )
1397                .setTickStyle( TickStyle.BELOW_LITERAL );
1398        seDial1.getDial( )
1399                .getScale( )
1400                .setMin( NumberDataElementImpl.create( 0 ) );
1401        seDial1.getDial( )
1402                .getScale( )
1403                .setMax( NumberDataElementImpl.create( 90 ) );
1404        seDial1.getDial( ).getScale( ).setStep( 10 );
1405        seDial1.getLabel( )
1406                .setOutline( LineAttributesImpl.create( ColorDefinitionImpl.GREY( )
1407                        .darker( ),
1408                        LineStyle.SOLID_LITERAL,
1409                        1 ) );
1410        seDial1.getLabel( ).setBackground( ColorDefinitionImpl.GREY( )
1411                .brighter( ) );
1412
1413        DialRegion dregion1 = DialRegionImpl.create( );
1414        dregion1.setFill( ColorDefinitionImpl.GREEN( ) );
1415        dregion1.setOutline( LineAttributesImpl.create( ColorDefinitionImpl.BLACK( )
1416                .darker( ),
1417                LineStyle.SOLID_LITERAL,
1418                1 ) );
1419        dregion1.setStartValue( NumberDataElementImpl.create( 70 ) );
1420        dregion1.setEndValue( NumberDataElementImpl.create( 90 ) );
1421        dregion1.setInnerRadius( 40 );
1422        dregion1.setOuterRadius( -1 );
1423        seDial1.getDial( ).getDialRegions( ).add( dregion1 );
1424
1425        DialRegion dregion2 = DialRegionImpl.create( );
1426        dregion2.setFill( ColorDefinitionImpl.YELLOW( ) );
1427        dregion2.setOutline( LineAttributesImpl.create( ColorDefinitionImpl.BLACK( )
1428                .darker( ),
1429                LineStyle.SOLID_LITERAL,
1430                1 ) );
1431        dregion2.setStartValue( NumberDataElementImpl.create( 40 ) );
1432        dregion2.setEndValue( NumberDataElementImpl.create( 70 ) );
1433        dregion2.setOuterRadius( 70 );
1434        seDial1.getDial( ).getDialRegions( ).add( dregion2 );
1435
1436        DialRegion dregion3 = DialRegionImpl.create( );
1437        dregion3.setFill( ColorDefinitionImpl.RED( ) );
1438        dregion3.setOutline( LineAttributesImpl.create( ColorDefinitionImpl.BLACK( )
1439                .darker( ),
1440                LineStyle.SOLID_LITERAL,
1441                1 ) );
1442        dregion3.setStartValue( NumberDataElementImpl.create( 0 ) );
1443        dregion3.setEndValue( NumberDataElementImpl.create( 40 ) );
1444        dregion3.setInnerRadius( 40 );
1445        dregion3.setOuterRadius( 90 );
1446        seDial1.getDial( ).getDialRegions( ).add( dregion3 );
1447
1448        // Dial 2
1449
DialSeries seDial2 = (DialSeries) DialSeriesImpl.create( );
1450        seDial2.setDataSet( NumberDataSetImpl.create( new double[]{
1451            58
1452        } ) );
1453        seDial2.getDial( )
1454                .setFill( GradientImpl.create( ColorDefinitionImpl.create( 225,
1455                        255,
1456                        225 ),
1457                        ColorDefinitionImpl.create( 225, 225, 255 ),
1458                        45,
1459                        false ) );
1460        seDial2.setSeriesIdentifier( "Wind Speed" );//$NON-NLS-1$
1461
seDial2.getNeedle( ).setDecorator( LineDecorator.CIRCLE_LITERAL );
1462        seDial2.getDial( ).setStartAngle( -45 );
1463        seDial2.getDial( ).setStopAngle( 225 );
1464        seDial2.getDial( )
1465                .getMinorGrid( )
1466                .getTickAttributes( )
1467                .setVisible( true );
1468        seDial2.getDial( )
1469                .getMinorGrid( )
1470                .getTickAttributes( )
1471                .setColor( ColorDefinitionImpl.BLACK( ) );
1472        seDial2.getDial( )
1473                .getMinorGrid( )
1474                .setTickStyle( TickStyle.BELOW_LITERAL );
1475        seDial2.getDial( )
1476                .getScale( )
1477                .setMin( NumberDataElementImpl.create( 0 ) );
1478        seDial2.getDial( )
1479                .getScale( )
1480                .setMax( NumberDataElementImpl.create( 90 ) );
1481        seDial2.getDial( ).getScale( ).setStep( 10 );
1482        seDial2.getLabel( )
1483                .setOutline( LineAttributesImpl.create( ColorDefinitionImpl.GREY( )
1484                        .darker( ),
1485                        LineStyle.SOLID_LITERAL,
1486                        1 ) );
1487        seDial2.getLabel( ).setBackground( ColorDefinitionImpl.GREY( )
1488                .brighter( ) );
1489
1490        seDial2.getDial( ).getDialRegions( ).add( dregion1 );
1491        seDial2.getDial( ).getDialRegions( ).add( dregion2 );
1492        seDial2.getDial( ).getDialRegions( ).add( dregion3 );
1493
1494        // Dial 3
1495
DialSeries seDial3 = (DialSeries) DialSeriesImpl.create( );
1496        seDial3.setDataSet( NumberDataSetImpl.create( new double[]{
1497            80
1498        } ) );
1499        seDial3.getDial( )
1500                .setFill( GradientImpl.create( ColorDefinitionImpl.create( 225,
1501                        255,
1502                        225 ),
1503                        ColorDefinitionImpl.create( 225, 225, 255 ),
1504                        45,
1505                        false ) );
1506        seDial3.setSeriesIdentifier( "Viscosity" );//$NON-NLS-1$
1507
seDial3.getNeedle( ).setDecorator( LineDecorator.CIRCLE_LITERAL );
1508        seDial3.getDial( ).setStartAngle( -45 );
1509        seDial3.getDial( ).setStopAngle( 225 );
1510        seDial3.getDial( )
1511                .getMinorGrid( )
1512                .getTickAttributes( )
1513                .setVisible( true );
1514        seDial3.getDial( )
1515                .getMinorGrid( )
1516                .getTickAttributes( )
1517                .setColor( ColorDefinitionImpl.BLACK( ) );
1518        seDial3.getDial( )
1519                .getMinorGrid( )
1520                .setTickStyle( TickStyle.BELOW_LITERAL );
1521        seDial3.getDial( )
1522                .getScale( )
1523                .setMin( NumberDataElementImpl.create( 0 ) );
1524        seDial3.getDial( )
1525                .getScale( )
1526                .setMax( NumberDataElementImpl.create( 90 ) );
1527        seDial3.getDial( ).getScale( ).setStep( 10 );
1528        seDial3.getLabel( )
1529                .setOutline( LineAttributesImpl.create( ColorDefinitionImpl.GREY( )
1530                        .darker( ),
1531                        LineStyle.SOLID_LITERAL,
1532                        1 ) );
1533        seDial3.getLabel( ).setBackground( ColorDefinitionImpl.GREY( )
1534                .brighter( ) );
1535
1536        seDial3.getDial( ).getDialRegions( ).add( dregion1 );
1537        seDial3.getDial( ).getDialRegions( ).add( dregion2 );
1538        seDial3.getDial( ).getDialRegions( ).add( dregion3 );
1539
1540        dChart.setDialSuperimposition( true );
1541        sd.getSeriesDefinitions( ).add( sdCity );
1542        sdCity.getSeries( ).add( seDial1 );
1543        sdCity.getSeries( ).add( seDial2 );
1544        sdCity.getSeries( ).add( seDial3 );
1545
1546        return dChart;
1547    }
1548
1549    /**
1550     * Creates a Single Dial, Single Region chart model as a reference
1551     * implementation
1552     *
1553     * @return An instance of the simulated runtime chart model (containing
1554     * filled datasets)
1555     */

1556    public static final Chart createSDialSRegionChart( )
1557    {
1558        DialChart dChart = (DialChart) DialChartImpl.create( );
1559        dChart.setDialSuperimposition( false );
1560        dChart.setGridColumnCount( 2 );
1561        dChart.setSeriesThickness( 25 );
1562
1563        // Title/Plot
1564
dChart.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
1565        Plot p = dChart.getPlot( );
1566        p.getClientArea( ).setBackground( ColorDefinitionImpl.CREAM( ) );
1567        p.getClientArea( ).getOutline( ).setVisible( false );
1568        p.getOutline( ).setVisible( false );
1569
1570        dChart.getTitle( ).getLabel( ).getCaption( ).setValue( "Meter Chart" );//$NON-NLS-1$
1571
dChart.getTitle( ).getOutline( ).setVisible( false );
1572
1573        // Legend
1574
Legend lg = dChart.getLegend( );
1575        LineAttributes lia = lg.getOutline( );
1576        lg.getText( ).getFont( ).setSize( 16 );
1577        lia.setStyle( LineStyle.SOLID_LITERAL );
1578        lg.getInsets( ).setLeft( 10 );
1579        lg.getInsets( ).setRight( 10 );
1580        lg.setBackground( null );
1581        lg.getOutline( ).setVisible( false );
1582        lg.setShowValue( true );
1583        lg.getClientArea( ).setBackground( ColorDefinitionImpl.PINK( ) );
1584
1585        lg.getClientArea( ).getOutline( ).setVisible( true );
1586        lg.getTitle( ).getCaption( ).getFont( ).setSize( 20 );
1587        lg.getTitle( ).setInsets( InsetsImpl.create( 10, 10, 10, 10 ) );
1588        lg.setTitlePosition( Position.ABOVE_LITERAL );
1589
1590        // Data Set
1591
TextDataSet categoryValues = TextDataSetImpl.create( new String JavaDoc[]{
1592            "Speed"} );//$NON-NLS-1$
1593

1594        SeriesDefinition sd = SeriesDefinitionImpl.create( );
1595        dChart.getSeriesDefinitions( ).add( sd );
1596        Series seCategory = (Series) SeriesImpl.create( );
1597
1598        final Fill[] fiaBase = {
1599                ColorDefinitionImpl.ORANGE( ),
1600                GradientImpl.create( ColorDefinitionImpl.create( 225, 225, 255 ),
1601                        ColorDefinitionImpl.create( 255, 255, 225 ),
1602                        -35,
1603                        false ),
1604                ColorDefinitionImpl.CREAM( ),
1605                ColorDefinitionImpl.RED( ),
1606                ColorDefinitionImpl.GREEN( ),
1607                ColorDefinitionImpl.BLUE( ).brighter( ),
1608                ColorDefinitionImpl.CYAN( ).darker( ),
1609        };
1610        sd.getSeriesPalette( ).getEntries( ).clear( );
1611        for ( int i = 0; i < fiaBase.length; i++ )
1612        {
1613            sd.getSeriesPalette( ).getEntries( ).add( fiaBase[i] );
1614        }
1615
1616        seCategory.setDataSet( categoryValues );
1617        sd.getSeries( ).add( seCategory );
1618
1619        SeriesDefinition sdCity = SeriesDefinitionImpl.create( );
1620
1621        // Dial
1622
DialSeries seDial = (DialSeries) DialSeriesImpl.create( );
1623        seDial.setDataSet( NumberDataSetImpl.create( new double[]{
1624            60
1625        } ) );
1626        seDial.getDial( )
1627                .setFill( GradientImpl.create( ColorDefinitionImpl.create( 225,
1628                        225,
1629                        255 ),
1630                        ColorDefinitionImpl.create( 255, 255, 225 ),
1631                        -35,
1632                        false ) );
1633        seDial.getNeedle( ).setDecorator( LineDecorator.ARROW_LITERAL );
1634        seDial.getDial( )
1635                .getMinorGrid( )
1636                .getTickAttributes( )
1637                .setVisible( true );
1638        seDial.getDial( )
1639                .getMinorGrid( )
1640                .getTickAttributes( )
1641                .setColor( ColorDefinitionImpl.RED( ) );
1642        seDial.getDial( )
1643                .getMinorGrid( )
1644                .setTickStyle( TickStyle.BELOW_LITERAL );
1645        seDial.getDial( )
1646                .getScale( )
1647                .setMin( NumberDataElementImpl.create( 0 ) );
1648        seDial.getDial( )
1649                .getScale( )
1650                .setMax( NumberDataElementImpl.create( 180 ) );
1651        seDial.getDial( ).getScale( ).setStep( 30 );
1652        seDial.getLabel( )
1653                .setOutline( LineAttributesImpl.create( ColorDefinitionImpl.GREY( )
1654                        .darker( ),
1655                        LineStyle.SOLID_LITERAL,
1656                        1 ) );
1657        seDial.getLabel( ).setBackground( ColorDefinitionImpl.GREY( )
1658                .brighter( ) );
1659
1660        DialRegion dregion21 = DialRegionImpl.create( );
1661        dregion21.setFill( ColorDefinitionImpl.GREEN( ) );
1662        dregion21.setStartValue( NumberDataElementImpl.create( 0 ) );
1663        dregion21.setEndValue( NumberDataElementImpl.create( 80 ) );
1664        seDial.getDial( ).getDialRegions( ).add( dregion21 );
1665
1666        sd.getSeriesDefinitions( ).add( sdCity );
1667        sdCity.getSeries( ).add( seDial );
1668
1669        return dChart;
1670    }
1671
1672    /**
1673     * Creates a Multi Dials, Single Region chart model as a reference
1674     * implementation
1675     *
1676     * @return An instance of the simulated runtime chart model (containing
1677     * filled datasets)
1678     */

1679    public static final Chart createMDialSRegionChart( )
1680    {
1681        DialChart dChart = (DialChart) DialChartImpl.create( );
1682        dChart.setDialSuperimposition( false );
1683        dChart.setGridColumnCount( 2 );
1684        dChart.setSeriesThickness( 25 );
1685
1686        // Title/Plot
1687
dChart.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
1688        Plot p = dChart.getPlot( );
1689        p.getClientArea( ).setBackground( ColorDefinitionImpl.CREAM( ) );
1690        p.getClientArea( ).getOutline( ).setVisible( false );
1691        p.getOutline( ).setVisible( false );
1692
1693        dChart.getTitle( ).getLabel( ).getCaption( ).setValue( "Meter Chart" );//$NON-NLS-1$
1694
dChart.getTitle( ).getOutline( ).setVisible( false );
1695
1696        // Legend
1697
Legend lg = dChart.getLegend( );
1698        LineAttributes lia = lg.getOutline( );
1699        lg.getText( ).getFont( ).setSize( 16 );
1700        lia.setStyle( LineStyle.SOLID_LITERAL );
1701        lg.getInsets( ).setLeft( 10 );
1702        lg.getInsets( ).setRight( 10 );
1703        lg.setBackground( null );
1704        lg.getOutline( ).setVisible( false );
1705        lg.setShowValue( true );
1706        lg.getClientArea( ).setBackground( ColorDefinitionImpl.PINK( ) );
1707
1708        lg.getClientArea( ).getOutline( ).setVisible( true );
1709        lg.getTitle( ).getCaption( ).getFont( ).setSize( 20 );
1710        lg.getTitle( ).setInsets( InsetsImpl.create( 10, 10, 10, 10 ) );
1711        lg.setTitlePosition( Position.ABOVE_LITERAL );
1712        lg.setItemType( LegendItemType.SERIES_LITERAL );
1713
1714        // Data Set
1715
TextDataSet categoryValues = TextDataSetImpl.create( new String JavaDoc[]{
1716            "Speed"} );//$NON-NLS-1$
1717

1718        SeriesDefinition sdBase = SeriesDefinitionImpl.create( );
1719        dChart.getSeriesDefinitions( ).add( sdBase );
1720
1721        Series seCategory = (Series) SeriesImpl.create( );
1722        seCategory.setDataSet( categoryValues );
1723        sdBase.getSeries( ).add( seCategory );
1724
1725        SeriesDefinition sdOrth = SeriesDefinitionImpl.create( );
1726
1727        final Fill[] fiaOrth = {
1728                ColorDefinitionImpl.ORANGE( ),
1729                ColorDefinitionImpl.RED( ),
1730                ColorDefinitionImpl.GREEN( )
1731        };
1732
1733        sdOrth.getSeriesPalette( ).getEntries( ).clear( );
1734        for ( int i = 0; i < fiaOrth.length; i++ )
1735        {
1736            sdOrth.getSeriesPalette( ).getEntries( ).add( fiaOrth[i] );
1737        }
1738
1739        // Dial 1
1740
DialSeries seDial1 = (DialSeries) DialSeriesImpl.create( );
1741        seDial1.setDataSet( NumberDataSetImpl.create( new double[]{
1742            60
1743        } ) );
1744        seDial1.getDial( )
1745                .setFill( GradientImpl.create( ColorDefinitionImpl.create( 225,
1746                        225,
1747                        255 ),
1748                        ColorDefinitionImpl.create( 255, 255, 225 ),
1749                        -35,
1750                        false ) );
1751        seDial1.getNeedle( ).setDecorator( LineDecorator.ARROW_LITERAL );
1752        seDial1.getDial( )
1753                .getMinorGrid( )
1754                .getTickAttributes( )
1755                .setVisible( true );
1756        seDial1.getDial( )
1757                .getMinorGrid( )
1758                .getTickAttributes( )
1759                .setColor( ColorDefinitionImpl.RED( ) );
1760        seDial1.getDial( )
1761                .getMinorGrid( )
1762                .setTickStyle( TickStyle.BELOW_LITERAL );
1763        seDial1.getDial( )
1764                .getScale( )
1765                .setMin( NumberDataElementImpl.create( 0 ) );
1766        seDial1.getDial( )
1767                .getScale( )
1768                .setMax( NumberDataElementImpl.create( 180 ) );
1769        seDial1.getDial( ).getScale( ).setStep( 30 );
1770        seDial1.getLabel( )
1771                .setOutline( LineAttributesImpl.create( ColorDefinitionImpl.GREY( )
1772                        .darker( ),
1773                        LineStyle.SOLID_LITERAL,
1774                        1 ) );
1775        seDial1.getLabel( ).setBackground( ColorDefinitionImpl.GREY( )
1776                .brighter( ) );
1777        seDial1.setSeriesIdentifier( "Speed 1" );//$NON-NLS-1$
1778

1779        // Dail 2
1780
DialSeries seDial2 = (DialSeries) DialSeriesImpl.create( );
1781        seDial2.setDataSet( NumberDataSetImpl.create( new double[]{
1782            90
1783        } ) );
1784        seDial2.getDial( )
1785                .setFill( GradientImpl.create( ColorDefinitionImpl.create( 225,
1786                        225,
1787                        255 ),
1788                        ColorDefinitionImpl.create( 255, 255, 225 ),
1789                        -35,
1790                        false ) );
1791        seDial2.getNeedle( ).setDecorator( LineDecorator.ARROW_LITERAL );
1792        seDial2.getDial( )
1793                .getMinorGrid( )
1794                .getTickAttributes( )
1795                .setVisible( true );
1796        seDial2.getDial( )
1797                .getMinorGrid( )
1798                .getTickAttributes( )
1799                .setColor( ColorDefinitionImpl.RED( ) );
1800        seDial2.getDial( )
1801                .getMinorGrid( )
1802                .setTickStyle( TickStyle.BELOW_LITERAL );
1803        seDial2.getDial( )
1804                .getScale( )
1805                .setMin( NumberDataElementImpl.create( 0 ) );
1806        seDial2.getDial( )
1807                .getScale( )
1808                .setMax( NumberDataElementImpl.create( 180 ) );
1809        seDial2.getDial( ).getScale( ).setStep( 30 );
1810        seDial2.getLabel( )
1811                .setOutline( LineAttributesImpl.create( ColorDefinitionImpl.GREY( )
1812                        .darker( ),
1813                        LineStyle.SOLID_LITERAL,
1814                        1 ) );
1815        seDial2.getLabel( ).setBackground( ColorDefinitionImpl.GREY( )
1816                .brighter( ) );
1817        seDial2.setSeriesIdentifier( "Speed 2" );//$NON-NLS-1$
1818

1819        // Dial 3
1820
DialSeries seDial3 = (DialSeries) DialSeriesImpl.create( );
1821        seDial3.setDataSet( NumberDataSetImpl.create( new double[]{
1822            160
1823        } ) );
1824        seDial3.getDial( )
1825                .setFill( GradientImpl.create( ColorDefinitionImpl.create( 225,
1826                        225,
1827                        255 ),
1828                        ColorDefinitionImpl.create( 255, 255, 225 ),
1829                        -35,
1830                        false ) );
1831        seDial3.getNeedle( ).setDecorator( LineDecorator.ARROW_LITERAL );
1832        seDial3.getDial( )
1833                .getMinorGrid( )
1834                .getTickAttributes( )
1835                .setVisible( true );
1836        seDial3.getDial( )
1837                .getMinorGrid( )
1838                .getTickAttributes( )
1839                .setColor( ColorDefinitionImpl.RED( ) );
1840        seDial3.getDial( )
1841                .getMinorGrid( )
1842                .setTickStyle( TickStyle.BELOW_LITERAL );
1843        seDial3.getDial( )
1844                .getScale( )
1845                .setMin( NumberDataElementImpl.create( 0 ) );
1846        seDial3.getDial( )
1847                .getScale( )
1848                .setMax( NumberDataElementImpl.create( 180 ) );
1849        seDial3.getDial( ).getScale( ).setStep( 30 );
1850        seDial3.getLabel( )
1851                .setOutline( LineAttributesImpl.create( ColorDefinitionImpl.GREY( )
1852                        .darker( ),
1853                        LineStyle.SOLID_LITERAL,
1854                        1 ) );
1855        seDial3.getLabel( ).setBackground( ColorDefinitionImpl.GREY( )
1856                .brighter( ) );
1857        seDial3.setSeriesIdentifier( "Speed 3" );//$NON-NLS-1$
1858

1859        dChart.setDialSuperimposition( true );
1860        sdBase.getSeriesDefinitions( ).add( sdOrth );
1861        sdOrth.getSeries( ).add( seDial1 );
1862        sdOrth.getSeries( ).add( seDial2 );
1863        sdOrth.getSeries( ).add( seDial3 );
1864
1865        return dChart;
1866    }
1867
1868    /**
1869     * Creates a bar chart model with curve fitting series.
1870     *
1871     * @return An instance of the simulated runtime chart model (containing
1872     * filled datasets)
1873     */

1874    public static final Chart createCFBarChart( )
1875    {
1876        ChartWithAxes cwaBar = ChartWithAxesImpl.create( );
1877
1878        // Plot
1879
cwaBar.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
1880        cwaBar.getBlock( ).getOutline( ).setVisible( true );
1881        Plot p = cwaBar.getPlot( );
1882        p.getClientArea( ).setBackground( ColorDefinitionImpl.create( 255,
1883                255,
1884                225 ) );
1885        p.getOutline( ).setVisible( false );
1886
1887        // Title
1888
cwaBar.getTitle( ).getLabel( ).getCaption( ).setValue( "Bar Chart" );//$NON-NLS-1$
1889

1890        // Legend
1891
Legend lg = cwaBar.getLegend( );
1892        lg.getText( ).getFont( ).setSize( 16 );
1893        lg.setItemType( LegendItemType.CATEGORIES_LITERAL );
1894
1895        // X-Axis
1896
Axis xAxisPrimary = cwaBar.getPrimaryBaseAxes( )[0];
1897
1898        xAxisPrimary.setType( AxisType.TEXT_LITERAL );
1899        xAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );
1900        xAxisPrimary.getOrigin( ).setType( IntersectionType.VALUE_LITERAL );
1901        xAxisPrimary.getTitle( ).setVisible( true );
1902
1903        // Y-Axis
1904
Axis yAxisPrimary = cwaBar.getPrimaryOrthogonalAxis( xAxisPrimary );
1905        yAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.LEFT_LITERAL );
1906        yAxisPrimary.setType( AxisType.LINEAR_LITERAL );
1907        yAxisPrimary.getLabel( ).getCaption( ).getFont( ).setRotation( 90 );
1908
1909        // Data Set
1910
TextDataSet categoryValues = TextDataSetImpl.create( new String JavaDoc[]{
1911                "Item 1", "Item 2", "Item 3"} );//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
1912
NumberDataSet orthoValues = NumberDataSetImpl.create( new double[]{
1913                25, 35, 15
1914        } );
1915
1916        // X-Series
1917
Series seCategory = SeriesImpl.create( );
1918        seCategory.setDataSet( categoryValues );
1919
1920        SeriesDefinition sdX = SeriesDefinitionImpl.create( );
1921        sdX.getSeriesPalette( ).update( 0 );
1922        xAxisPrimary.getSeriesDefinitions( ).add( sdX );
1923        sdX.getSeries( ).add( seCategory );
1924
1925        // Y-Series
1926
BarSeries bs = (BarSeries) BarSeriesImpl.create( );
1927        bs.setDataSet( orthoValues );
1928        bs.setRiserOutline( null );
1929        bs.getLabel( ).setVisible( true );
1930        bs.setLabelPosition( Position.INSIDE_LITERAL );
1931        bs.setCurveFitting( CurveFittingImpl.create( ) );
1932
1933        SeriesDefinition sdY = SeriesDefinitionImpl.create( );
1934        yAxisPrimary.getSeriesDefinitions( ).add( sdY );
1935        sdY.getSeries( ).add( bs );
1936
1937        return cwaBar;
1938    }
1939
1940    /**
1941     * Creates a line chart model with curve fitting series
1942     *
1943     * @return An instance of the simulated runtime chart model (containing
1944     * filled datasets)
1945     */

1946    public static final Chart createCFLineChart( )
1947    {
1948        ChartWithAxes cwaLine = ChartWithAxesImpl.create( );
1949
1950        // Plot
1951
cwaLine.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
1952        Plot p = cwaLine.getPlot( );
1953        p.getClientArea( ).setBackground( ColorDefinitionImpl.create( 255,
1954                255,
1955                225 ) );
1956
1957        // Title
1958
cwaLine.getTitle( ).getLabel( ).getCaption( ).setValue( "Line Chart" );//$NON-NLS-1$
1959

1960        // Legend
1961
cwaLine.getLegend( ).setVisible( false );
1962
1963        // X-Axis
1964
Axis xAxisPrimary = cwaLine.getPrimaryBaseAxes( )[0];
1965        xAxisPrimary.setType( AxisType.TEXT_LITERAL );
1966        xAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );
1967        xAxisPrimary.getOrigin( ).setType( IntersectionType.VALUE_LITERAL );
1968        xAxisPrimary.getTitle( ).setVisible( true );
1969
1970        // Y-Axis
1971
Axis yAxisPrimary = cwaLine.getPrimaryOrthogonalAxis( xAxisPrimary );
1972        yAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.LEFT_LITERAL );
1973
1974        // Data Set
1975
TextDataSet categoryValues = TextDataSetImpl.create( new String JavaDoc[]{
1976                "Item 1", "Item 2", "Item 3"} );//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
1977
NumberDataSet orthoValues = NumberDataSetImpl.create( new double[]{
1978                25, 35, 15
1979        } );
1980
1981        // X-Series
1982
Series seCategory = SeriesImpl.create( );
1983        seCategory.setDataSet( categoryValues );
1984        SeriesDefinition sdX = SeriesDefinitionImpl.create( );
1985
1986        xAxisPrimary.getSeriesDefinitions( ).add( sdX );
1987        sdX.getSeries( ).add( seCategory );
1988
1989        // Y-Sereis
1990
LineSeries ls = (LineSeries) LineSeriesImpl.create( );
1991        ls.setDataSet( orthoValues );
1992        ls.getLineAttributes( ).setColor( ColorDefinitionImpl.CREAM( ) );
1993        for ( int i = 0; i < ls.getMarkers( ).size( ); i++ )
1994        {
1995            ( (Marker) ls.getMarkers( ).get( i ) ).setType( MarkerType.TRIANGLE_LITERAL);
1996        }
1997        ls.getLabel( ).setVisible( true );
1998        ls.setCurve( true );
1999
2000        SeriesDefinition sdY = SeriesDefinitionImpl.create( );
2001        sdY.getSeriesPalette( ).update( -2 );
2002        yAxisPrimary.getSeriesDefinitions( ).add( sdY );
2003        sdY.getSeries( ).add( ls );
2004
2005        return cwaLine;
2006    }
2007
2008    /**
2009     * Creates a stock chart model with curve fitting series.
2010     *
2011     * @return An instance of the simulated runtime chart model (containing
2012     * filled datasets)
2013     */

2014    public final static Chart createCFStockChart( )
2015    {
2016        ChartWithAxes cwaStock = ChartWithAxesImpl.create( );
2017
2018        // Title
2019
cwaStock.getTitle( ).getLabel( ).getCaption( ).setValue( "Stock Chart" );//$NON-NLS-1$
2020
TitleBlock tb = cwaStock.getTitle( );
2021        tb.setBackground( GradientImpl.create( ColorDefinitionImpl.create( 0,
2022                128,
2023                0 ), ColorDefinitionImpl.create( 128, 0, 0 ), 0, false ) );
2024        tb.getLabel( ).getCaption( ).setColor( ColorDefinitionImpl.WHITE( ) );
2025
2026        // Plot
2027
cwaStock.getBlock( )
2028                .setBackground( GradientImpl.create( ColorDefinitionImpl.create( 196,
2029                        196,
2030                        196 ),
2031                        ColorDefinitionImpl.WHITE( ),
2032                        90,
2033                        false ) );
2034        cwaStock.getPlot( ).getClientArea( ).getInsets( ).set( 10, 10, 10, 10 );
2035
2036        // Legend
2037
cwaStock.getLegend( ).setBackground( ColorDefinitionImpl.ORANGE( ) );
2038
2039        // X-Axis
2040
Axis xAxisPrimary = ( (ChartWithAxesImpl) cwaStock ).getPrimaryBaseAxes( )[0];
2041
2042        xAxisPrimary.getTitle( ).getCaption( ).setValue( "X Axis" );//$NON-NLS-1$
2043
xAxisPrimary.getTitle( )
2044                .getCaption( )
2045                .setColor( ColorDefinitionImpl.RED( ) );
2046        xAxisPrimary.getTitle( ).getCaption( ).setValue( "Date" );//$NON-NLS-1$
2047
xAxisPrimary.setTitlePosition( Position.ABOVE_LITERAL );
2048
2049        xAxisPrimary.getLabel( )
2050                .getCaption( )
2051                .setColor( ColorDefinitionImpl.RED( ) );
2052        xAxisPrimary.getLabel( ).getCaption( ).getFont( ).setRotation( 65 );
2053        xAxisPrimary.setLabelPosition( Position.ABOVE_LITERAL );
2054
2055        xAxisPrimary.setType( AxisType.DATE_TIME_LITERAL );
2056        xAxisPrimary.getOrigin( ).setType( IntersectionType.MAX_LITERAL );
2057
2058        xAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.ABOVE_LITERAL );
2059        xAxisPrimary.getMajorGrid( )
2060                .getLineAttributes( )
2061                .setColor( ColorDefinitionImpl.create( 255, 196, 196 ) );
2062        xAxisPrimary.getMajorGrid( )
2063                .getLineAttributes( )
2064                .setStyle( LineStyle.DOTTED_LITERAL );
2065        xAxisPrimary.getMajorGrid( ).getLineAttributes( ).setVisible( true );
2066
2067        xAxisPrimary.setCategoryAxis( true );
2068
2069        // Y-Axis
2070
Axis yAxisPrimary = ( (ChartWithAxesImpl) cwaStock ).getPrimaryOrthogonalAxis( xAxisPrimary );
2071
2072        yAxisPrimary.getLabel( ).getCaption( ).setValue( "Price Axis" );//$NON-NLS-1$
2073
yAxisPrimary.getLabel( )
2074                .getCaption( )
2075                .setColor( ColorDefinitionImpl.BLUE( ) );
2076        yAxisPrimary.setLabelPosition( Position.LEFT_LITERAL );
2077
2078        yAxisPrimary.getTitle( )
2079                .getCaption( )
2080                .setValue( "Microsoft ($ Stock Price)" );//$NON-NLS-1$
2081
yAxisPrimary.getTitle( )
2082                .getCaption( )
2083                .setColor( ColorDefinitionImpl.BLUE( ) );
2084        yAxisPrimary.setTitlePosition( Position.LEFT_LITERAL );
2085
2086        yAxisPrimary.getScale( ).setMin( NumberDataElementImpl.create( 24.5 ) );
2087        yAxisPrimary.getScale( ).setMax( NumberDataElementImpl.create( 27.5 ) );
2088        yAxisPrimary.getScale( ).setStep( 0.5 );
2089
2090        yAxisPrimary.getMajorGrid( )
2091                .getLineAttributes( )
2092                .setColor( ColorDefinitionImpl.create( 196, 196, 255 ) );
2093        yAxisPrimary.getMajorGrid( )
2094                .getLineAttributes( )
2095                .setStyle( LineStyle.DOTTED_LITERAL );
2096        yAxisPrimary.getMajorGrid( ).getLineAttributes( ).setVisible( true );
2097        yAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.LEFT_LITERAL );
2098
2099        yAxisPrimary.setType( AxisType.LINEAR_LITERAL );
2100        yAxisPrimary.getOrigin( ).setType( IntersectionType.MIN_LITERAL );
2101
2102        // Data Set
2103
DateTimeDataSet dsDateValues = DateTimeDataSetImpl.create( new Calendar[]{
2104                new CDateTime( 2004, 12, 27 ),
2105                new CDateTime( 2004, 12, 23 ),
2106                new CDateTime( 2004, 12, 22 ),
2107                new CDateTime( 2004, 12, 21 ),
2108                new CDateTime( 2004, 12, 20 ),
2109                new CDateTime( 2004, 12, 17 ),
2110                new CDateTime( 2004, 12, 16 ),
2111                new CDateTime( 2004, 12, 15 )
2112        } );
2113
2114        StockDataSet dsStockValues = StockDataSetImpl.create( new StockEntry[]{
2115                new StockEntry( 27.01, 27.10, 26.82, 26.85 ),
2116                new StockEntry( 26.87, 27.15, 26.83, 27.01 ),
2117                new StockEntry( 26.84, 27.15, 26.78, 26.97 ),
2118                new StockEntry( 27.00, 27.17, 26.94, 27.07 ),
2119                new StockEntry( 27.01, 27.15, 26.89, 26.95 ),
2120                new StockEntry( 27.00, 27.32, 26.80, 26.96 ),
2121                new StockEntry( 27.15, 27.28, 27.01, 27.16 ),
2122                new StockEntry( 27.22, 27.40, 27.07, 27.11 ),
2123        } );
2124
2125        // X-Series
2126
Series seBase = SeriesImpl.create( );
2127        seBase.setDataSet( dsDateValues );
2128
2129        SeriesDefinition sdX = SeriesDefinitionImpl.create( );
2130        sdX.getSeriesPalette( ).update( 1 );
2131        xAxisPrimary.getSeriesDefinitions( ).add( sdX );
2132        sdX.getSeries( ).add( seBase );
2133
2134        // Y-Series
2135
StockSeries ss = (StockSeries) StockSeriesImpl.create( );
2136        ss.setSeriesIdentifier( "Stock Price" );//$NON-NLS-1$
2137
ss.getLineAttributes( ).setColor( ColorDefinitionImpl.BLUE( ) );
2138        ss.setDataSet( dsStockValues );
2139        ss.setCurveFitting( CurveFittingImpl.create( ) );
2140
2141        SeriesDefinition sdY = SeriesDefinitionImpl.create( );
2142        sdY.getSeriesPalette( ).update( ColorDefinitionImpl.CYAN( ) );
2143        yAxisPrimary.getSeriesDefinitions( ).add( sdY );
2144        sdY.getSeries( ).add( ss );
2145
2146        return cwaStock;
2147    }
2148
2149    /**
2150     * Creates a Area chart model with curve fitting series implementation
2151     *
2152     * @return An instance of the simulated runtime chart model (containing
2153     * filled datasets)
2154     */

2155    public static final Chart createCFAreaChart( )
2156    {
2157        ChartWithAxes cwaArea = ChartWithAxesImpl.create( );
2158
2159        // Plot/Title
2160
cwaArea.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
2161        Plot p = cwaArea.getPlot( );
2162        p.getClientArea( ).setBackground( ColorDefinitionImpl.create( 225,
2163                225,
2164                225 ) );
2165        cwaArea.getTitle( ).getLabel( ).getCaption( ).setValue( "Area Chart" );//$NON-NLS-1$
2166
cwaArea.getTitle( ).setVisible( true );
2167
2168        // Legend
2169
Legend lg = cwaArea.getLegend( );
2170        LineAttributes lia = lg.getOutline( );
2171        lg.getText( ).getFont( ).setSize( 16 );
2172        lia.setStyle( LineStyle.SOLID_LITERAL );
2173        lg.getInsets( ).set( 10, 5, 0, 0 );
2174        lg.getOutline( ).setVisible( false );
2175        lg.setAnchor( Anchor.NORTH_LITERAL );
2176
2177        // X-Axis
2178
Axis xAxisPrimary = cwaArea.getPrimaryBaseAxes( )[0];
2179        xAxisPrimary.setType( AxisType.TEXT_LITERAL );
2180        xAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );
2181        xAxisPrimary.getMajorGrid( )
2182                .setLineAttributes( LineAttributesImpl.create( ColorDefinitionImpl.BLUE( ),
2183                        LineStyle.SOLID_LITERAL,
2184                        1 ) );
2185        xAxisPrimary.getMinorGrid( ).getLineAttributes( ).setVisible( true );
2186        xAxisPrimary.getOrigin( ).setType( IntersectionType.MIN_LITERAL );
2187        xAxisPrimary.getTitle( ).getCaption( ).setValue( "Month" );//$NON-NLS-1$
2188
xAxisPrimary.getTitle( ).setVisible( true );
2189        xAxisPrimary.getTitle( ).getCaption( ).getFont( ).setRotation( 0 );
2190        xAxisPrimary.getLabel( ).setVisible( true );
2191
2192        // Y-Axis
2193
Axis yAxisPrimary = cwaArea.getPrimaryOrthogonalAxis( xAxisPrimary );
2194        yAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.LEFT_LITERAL );
2195        yAxisPrimary.getMajorGrid( )
2196                .setLineAttributes( LineAttributesImpl.create( ColorDefinitionImpl.BLACK( ),
2197                        LineStyle.SOLID_LITERAL,
2198                        1 ) );
2199        yAxisPrimary.getMinorGrid( ).getLineAttributes( ).setVisible( true );
2200        yAxisPrimary.setPercent( false );
2201        yAxisPrimary.getTitle( ).getCaption( ).setValue( "Net Profit" );//$NON-NLS-1$
2202
yAxisPrimary.getTitle( ).setVisible( true );
2203        yAxisPrimary.getTitle( ).getCaption( ).getFont( ).setRotation( 90 );
2204        yAxisPrimary.getLabel( ).setVisible( true );
2205
2206        MarkerLine ml = MarkerLineImpl.create( yAxisPrimary,
2207                NumberDataElementImpl.create( 2 ) );
2208        yAxisPrimary.getMarkerLines( ).add( ml );
2209
2210        // Data Set
2211
TextDataSet categoryValues = TextDataSetImpl.create( new String JavaDoc[]{
2212                "Jan.", "Feb.", "Mar.", "Apr", "May"} ); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$
2213
NumberDataSet orthoValues = NumberDataSetImpl.create( new double[]{
2214                14.32, -19.5, 8.38, 0.34, 9.22
2215        } );
2216
2217        // X-Series
2218
Series seCategory = SeriesImpl.create( );
2219        seCategory.setDataSet( categoryValues );
2220
2221        SeriesDefinition sdX = SeriesDefinitionImpl.create( );
2222        sdX.getSeriesPalette( ).update( 0 );
2223        xAxisPrimary.getSeriesDefinitions( ).add( sdX );
2224        sdX.getSeries( ).add( seCategory );
2225
2226        // Y-Series
2227
AreaSeries as = (AreaSeries) AreaSeriesImpl.create( );
2228        as.setSeriesIdentifier( "Series" );//$NON-NLS-1$
2229
as.setDataSet( orthoValues );
2230        as.setTranslucent( true );
2231        as.getLineAttributes( ).setColor( ColorDefinitionImpl.BLUE( ) );
2232        as.getLabel( ).setVisible( true );
2233        as.setCurve( true );
2234
2235        SeriesDefinition sdY = SeriesDefinitionImpl.create( );
2236        sdY.getSeriesPalette( ).update( 1 );
2237        yAxisPrimary.getSeriesDefinitions( ).add( sdY );
2238        sdY.getSeries( ).add( as );
2239
2240        return cwaArea;
2241    }
2242
2243    public static final Chart create3DBarChart( )
2244    {
2245        ChartWithAxes cwaBar = ChartWithAxesImpl.create( );
2246        cwaBar.setDimension( ChartDimension.THREE_DIMENSIONAL_LITERAL );
2247
2248        // Plot
2249
cwaBar.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
2250        cwaBar.getBlock( ).getOutline( ).setVisible( true );
2251        Plot p = cwaBar.getPlot( );
2252        p.getClientArea( ).setBackground( ColorDefinitionImpl.create( 255,
2253                255,
2254                225 ) );
2255        p.getOutline( ).setVisible( false );
2256
2257        // Title
2258
cwaBar.getTitle( ).getLabel( ).getCaption( ).setValue( "3D Bar Chart" );//$NON-NLS-1$
2259

2260        // Legend
2261
Legend lg = cwaBar.getLegend( );
2262        lg.getText( ).getFont( ).setSize( 16 );
2263        lg.setItemType( LegendItemType.CATEGORIES_LITERAL );
2264
2265        // X-Axis
2266
Axis xAxisPrimary = cwaBar.getPrimaryBaseAxes( )[0];
2267
2268        xAxisPrimary.setType( AxisType.TEXT_LITERAL );
2269        xAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );
2270        xAxisPrimary.getOrigin( ).setType( IntersectionType.VALUE_LITERAL );
2271        xAxisPrimary.getTitle( ).setVisible( true );
2272
2273        // Y-Axis
2274
Axis yAxisPrimary = cwaBar.getPrimaryOrthogonalAxis( xAxisPrimary );
2275        yAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.LEFT_LITERAL );
2276        yAxisPrimary.setType( AxisType.LINEAR_LITERAL );
2277        yAxisPrimary.getLabel( ).getCaption( ).getFont( ).setRotation( 90 );
2278
2279        // Z-Axis
2280
Axis zAxis = AxisImpl.create( Axis.ANCILLARY_BASE );
2281        zAxis.setType( AxisType.TEXT_LITERAL );
2282        zAxis.setLabelPosition( Position.BELOW_LITERAL );
2283        zAxis.setTitlePosition( Position.BELOW_LITERAL );
2284        zAxis.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );
2285        zAxis.setOrientation( Orientation.HORIZONTAL_LITERAL );
2286        xAxisPrimary.getAncillaryAxes( ).add( zAxis );
2287
2288        // Data Set
2289
TextDataSet categoryValues = TextDataSetImpl.create( new String JavaDoc[]{
2290                "Item 1", "Item 2", "Item 3"} );//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
2291
NumberDataSet orthoValues = NumberDataSetImpl.create( new double[]{
2292                25, 35, 15
2293        } );
2294
2295        // X-Series
2296
Series seCategory = SeriesImpl.create( );
2297        seCategory.setDataSet( categoryValues );
2298
2299        SeriesDefinition sdX = SeriesDefinitionImpl.create( );
2300        sdX.getSeriesPalette( ).update( 0 );
2301        xAxisPrimary.getSeriesDefinitions( ).add( sdX );
2302        sdX.getSeries( ).add( seCategory );
2303
2304        // Y-Series
2305
BarSeries bs = (BarSeries) BarSeriesImpl.create( );
2306        bs.setDataSet( orthoValues );
2307        bs.setRiserOutline( null );
2308        bs.getLabel( ).setVisible( true );
2309        bs.setLabelPosition( Position.OUTSIDE_LITERAL );
2310
2311        SeriesDefinition sdY = SeriesDefinitionImpl.create( );
2312        yAxisPrimary.getSeriesDefinitions( ).add( sdY );
2313        sdY.getSeries( ).add( bs );
2314
2315        // Z-Series
2316
SeriesDefinition sdZ = SeriesDefinitionImpl.create( );
2317        zAxis.getSeriesDefinitions( ).add( sdZ );
2318
2319        // Rotate the chart
2320
cwaBar.setRotation( Rotation3DImpl.create( new Angle3D[]{
2321            Angle3DImpl.create( -20, 45, 0 )
2322        } ) );
2323
2324        return cwaBar;
2325    }
2326
2327    public static final Chart create3DLineChart( )
2328    {
2329        ChartWithAxes cwa3DLine = ChartWithAxesImpl.create( );
2330        cwa3DLine.setDimension( ChartDimension.THREE_DIMENSIONAL_LITERAL );
2331
2332        // Plot
2333
cwa3DLine.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
2334        Plot p = cwa3DLine.getPlot( );
2335        p.getClientArea( ).setBackground( ColorDefinitionImpl.create( 255,
2336                255,
2337                225 ) );
2338
2339        // Title
2340
cwa3DLine.getTitle( ).getLabel( ).getCaption( ).setValue( "Line Chart" );//$NON-NLS-1$
2341

2342        // Legend
2343
cwa3DLine.getLegend( ).setVisible( false );
2344
2345        // X-Axis
2346
Axis xAxisPrimary = cwa3DLine.getPrimaryBaseAxes( )[0];
2347        xAxisPrimary.setType( AxisType.TEXT_LITERAL );
2348        xAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );
2349        xAxisPrimary.getOrigin( ).setType( IntersectionType.VALUE_LITERAL );
2350        xAxisPrimary.getTitle( ).setVisible( true );
2351
2352        // Y-Axis
2353
Axis yAxisPrimary = cwa3DLine.getPrimaryOrthogonalAxis( xAxisPrimary );
2354        yAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.LEFT_LITERAL );
2355
2356        // Z-Axis
2357
Axis zAxis = AxisImpl.create( Axis.ANCILLARY_BASE );
2358        zAxis.setType( AxisType.TEXT_LITERAL );
2359        zAxis.setLabelPosition( Position.BELOW_LITERAL );
2360        zAxis.setTitlePosition( Position.BELOW_LITERAL );
2361        zAxis.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );
2362        zAxis.setOrientation( Orientation.HORIZONTAL_LITERAL );
2363        xAxisPrimary.getAncillaryAxes( ).add( zAxis );
2364
2365        // Data Set
2366
TextDataSet categoryValues = TextDataSetImpl.create( new String JavaDoc[]{
2367                "Item 1", "Item 2", "Item 3"} );//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
2368
NumberDataSet orthoValues = NumberDataSetImpl.create( new double[]{
2369                25, 35, 15
2370        } );
2371
2372        // X-Series
2373
Series seCategory = SeriesImpl.create( );
2374        seCategory.setDataSet( categoryValues );
2375        SeriesDefinition sdX = SeriesDefinitionImpl.create( );
2376
2377        xAxisPrimary.getSeriesDefinitions( ).add( sdX );
2378        sdX.getSeries( ).add( seCategory );
2379
2380        // Y-Sereis
2381
LineSeries ls = (LineSeries) LineSeriesImpl.create( );
2382        ls.setDataSet( orthoValues );
2383        ls.getLineAttributes( ).setColor( ColorDefinitionImpl.CREAM( ) );
2384        for ( int i = 0; i < ls.getMarkers( ).size( ); i++ )
2385        {
2386            ( (Marker) ls.getMarkers( ).get( i ) ).setType( MarkerType.TRIANGLE_LITERAL);
2387        }
2388        ls.getLabel( ).setVisible( true );
2389
2390        SeriesDefinition sdY = SeriesDefinitionImpl.create( );
2391        sdY.getSeriesPalette( ).update( -2 );
2392        yAxisPrimary.getSeriesDefinitions( ).add( sdY );
2393        sdY.getSeries( ).add( ls );
2394
2395        // Z-Series
2396
SeriesDefinition sdZ = SeriesDefinitionImpl.create( );
2397        zAxis.getSeriesDefinitions( ).add( sdZ );
2398
2399        // Rotate the chart
2400
cwa3DLine.setRotation( Rotation3DImpl.create( new Angle3D[]{
2401            Angle3DImpl.create( -20, 45, 0 )
2402        } ) );
2403
2404        return cwa3DLine;
2405    }
2406
2407    public static final Chart create3DAreaChart( )
2408    {
2409        ChartWithAxes cwa3DArea = ChartWithAxesImpl.create( );
2410        cwa3DArea.setDimension( ChartDimension.THREE_DIMENSIONAL_LITERAL );
2411
2412        // Plot/Title
2413
cwa3DArea.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
2414        Plot p = cwa3DArea.getPlot( );
2415        p.getClientArea( ).setBackground( ColorDefinitionImpl.create( 225,
2416                225,
2417                225 ) );
2418        cwa3DArea.getTitle( ).getLabel( ).getCaption( ).setValue( "Area Chart" );//$NON-NLS-1$
2419
cwa3DArea.getTitle( ).setVisible( true );
2420
2421        // Legend
2422
Legend lg = cwa3DArea.getLegend( );
2423        LineAttributes lia = lg.getOutline( );
2424        lg.getText( ).getFont( ).setSize( 16 );
2425        lia.setStyle( LineStyle.SOLID_LITERAL );
2426        lg.getInsets( ).set( 10, 5, 0, 0 );
2427        lg.getOutline( ).setVisible( false );
2428        lg.setAnchor( Anchor.NORTH_LITERAL );
2429
2430        // X-Axis
2431
Axis xAxisPrimary = cwa3DArea.getPrimaryBaseAxes( )[0];
2432        xAxisPrimary.setType( AxisType.TEXT_LITERAL );
2433        xAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );
2434        xAxisPrimary.getMajorGrid( )
2435                .setLineAttributes( LineAttributesImpl.create( ColorDefinitionImpl.BLUE( ),
2436                        LineStyle.SOLID_LITERAL,
2437                        1 ) );
2438        xAxisPrimary.getMinorGrid( ).getLineAttributes( ).setVisible( true );
2439        xAxisPrimary.getOrigin( ).setType( IntersectionType.MIN_LITERAL );
2440        xAxisPrimary.getTitle( ).getCaption( ).setValue( "Month" );//$NON-NLS-1$
2441
xAxisPrimary.getTitle( ).setVisible( true );
2442        xAxisPrimary.getTitle( ).getCaption( ).getFont( ).setRotation( 0 );
2443        xAxisPrimary.getLabel( ).setVisible( true );
2444
2445        // Y-Axis
2446
Axis yAxisPrimary = cwa3DArea.getPrimaryOrthogonalAxis( xAxisPrimary );
2447        yAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.LEFT_LITERAL );
2448        yAxisPrimary.getMajorGrid( )
2449                .setLineAttributes( LineAttributesImpl.create( ColorDefinitionImpl.BLACK( ),
2450                        LineStyle.SOLID_LITERAL,
2451                        1 ) );
2452        yAxisPrimary.getMinorGrid( ).getLineAttributes( ).setVisible( true );
2453        yAxisPrimary.setPercent( false );
2454        yAxisPrimary.getTitle( ).getCaption( ).setValue( "Net Profit" );//$NON-NLS-1$
2455
yAxisPrimary.getTitle( ).setVisible( true );
2456        yAxisPrimary.getTitle( ).getCaption( ).getFont( ).setRotation( 90 );
2457        yAxisPrimary.getLabel( ).setVisible( true );
2458
2459        // Z-Axis
2460
Axis zAxis = AxisImpl.create( Axis.ANCILLARY_BASE );
2461        zAxis.setType( AxisType.TEXT_LITERAL );
2462        zAxis.setLabelPosition( Position.BELOW_LITERAL );
2463        zAxis.setTitlePosition( Position.BELOW_LITERAL );
2464        zAxis.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );
2465        zAxis.setOrientation( Orientation.HORIZONTAL_LITERAL );
2466        xAxisPrimary.getAncillaryAxes( ).add( zAxis );
2467
2468        // Data Set
2469
TextDataSet categoryValues = TextDataSetImpl.create( new String JavaDoc[]{
2470                "Jan.", "Feb.", "Mar.", "Apr", "May"} ); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$
2471
NumberDataSet orthoValues1 = NumberDataSetImpl.create( new double[]{
2472                14.32, -19.5, 8.38, 0.34, 9.22
2473        } );
2474
2475        // X-Series
2476
Series seCategory = SeriesImpl.create( );
2477        seCategory.setDataSet( categoryValues );
2478
2479        SeriesDefinition sdX = SeriesDefinitionImpl.create( );
2480        sdX.getSeriesPalette( ).update( 0 );
2481        xAxisPrimary.getSeriesDefinitions( ).add( sdX );
2482        sdX.getSeries( ).add( seCategory );
2483
2484        // Y-Series
2485
AreaSeries as1 = (AreaSeries) AreaSeriesImpl.create( );
2486        as1.setSeriesIdentifier( "Series 1" );//$NON-NLS-1$
2487
as1.setDataSet( orthoValues1 );
2488        as1.getLineAttributes( ).setColor( ColorDefinitionImpl.BLUE( ) );
2489        as1.getLabel( ).setVisible( true );
2490
2491        SeriesDefinition sdY = SeriesDefinitionImpl.create( );
2492        sdY.getSeriesPalette( ).update( 1 );
2493        yAxisPrimary.getSeriesDefinitions( ).add( sdY );
2494        sdY.getSeries( ).add( as1 );
2495
2496        // Z-Series
2497
SeriesDefinition sdZ = SeriesDefinitionImpl.create( );
2498        zAxis.getSeriesDefinitions( ).add( sdZ );
2499
2500        // Rotate the chart
2501
cwa3DArea.setRotation( Rotation3DImpl.create( new Angle3D[]{
2502            Angle3DImpl.create( -20, 45, 0 )
2503        } ) );
2504
2505        return cwa3DArea;
2506    }
2507
2508    public static final Chart openChart( )
2509    {
2510        JFileChooser JavaDoc fileChooser = new JFileChooser JavaDoc( System.getProperty( "user.dir" )); //$NON-NLS-1$
2511
fileChooser.setFileFilter( new FileFilter JavaDoc( ) {
2512
2513            public boolean accept( File JavaDoc f )
2514            {
2515                return f.isDirectory( )
2516                        || f.isFile( ) && f.getName( ).endsWith( ".chart" ); //$NON-NLS-1$
2517
}
2518
2519            public String JavaDoc getDescription( )
2520            {
2521                return "*.chart(Chart files)"; //$NON-NLS-1$
2522
}
2523        } );
2524        
2525        Chart chart = null;
2526        Serializer serializer = null;
2527        fileChooser.showOpenDialog( fileChooser.getParent( ) );
2528        File JavaDoc chartFile = fileChooser.getSelectedFile( );
2529        if ( chartFile == null )
2530        {
2531            chartFile = new File JavaDoc( "testChart.chart" ); //$NON-NLS-1$
2532
}
2533        if ( chartFile == null )
2534        {
2535            throw new RuntimeException JavaDoc("No chart file specified!"); //$NON-NLS-1$
2536
}
2537
2538        // Reads the chart model
2539
try
2540        {
2541            serializer = SerializerImpl.instance( );
2542            if ( chartFile.exists( ) )
2543            {
2544
2545                chart = serializer.read( new FileInputStream JavaDoc( chartFile ) );
2546            }
2547        }
2548        catch ( Exception JavaDoc e )
2549        {
2550            WizardBase.displayException( e );
2551        }
2552
2553        // Data Set
2554
TextDataSet categoryValues = TextDataSetImpl.create( new String JavaDoc[]{
2555                "Jan.", "Feb.", "Mar.", "Apr", "May"} ); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$
2556
NumberDataSet orthoValues1 = NumberDataSetImpl.create( new double[]{
2557                14.32, -19.5, 8.38, 0.34, 9.22
2558        } );
2559
2560        ( (SeriesDefinition) ChartUIUtil.getBaseSeriesDefinitions( chart )
2561                .get( 0 ) ).getDesignTimeSeries( ).setDataSet( categoryValues );
2562        ( (SeriesDefinition) ChartUIUtil.getOrthogonalSeriesDefinitions( chart,
2563                0 ).get( 0 ) ).getDesignTimeSeries( )
2564                .setDataSet( orthoValues1 );
2565        return chart;
2566    }
2567}
Popular Tags