Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Help: Unterstand the code of the Seralizer (ChartEngine)
internet
Hello,<br />
I create with BIRT a few diagrams. I've used most of the code from the example Seralizer.<br />
I want to know what the program sections.<br />
Here's the code.<br />
<br />
I have written as comments my guess:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>public static boolean generateChart()
{
// Starting the Engine. What is "STANDALONE" ?
PlatformConfig pf = new PlatformConfig();
pf.setProperty("STANDALONE", true);
// I dont know
ChartEngine ce = ChartEngine.instance(pf);
// I dont know
gr = ce.getGenerator();
try {
// device renderers for dv.SWT, dv.PNG, dv.JPG
// dv.PDF, dv.SVG, dv.SWING, dv.PNG24, div.BMP
// I dont know
dRenderer = ce.getRenderer("dv" + outputFormat);
dServer = dRenderer.getDisplayServer();
// Import of the .chart - file
cmf = ce.getSerializer().read(new FileInputStream(inputPath));
// I dont know
cm = (Chart) EcoreUtil.copy((Chart) cmf);
// Bind Chart. The defintion for the axis
// stehen sollen. Das Design wird in der .chart - Datei festgelegt
bindChart((ChartWithAxes) cm, xAxis, yAxis);
} catch (Exception e) {
e.printStackTrace();
}
// Definition of the size of the chart
dRenderer.setProperty(IDeviceRenderer.FILE_IDENTIFIER, outputPath); //$NON-NLS-1$
// I dont know????
Bounds bo = BoundsImpl.create(0, 0, sizeWidth, sizeHeight);
bo.scale(72d / dRenderer.getDisplayServer().getDpiResolution());
try {
// It renders the chart
gcs = gr.build(dServer, cm, bo, null, null, null);
// I dont know???
gr.render(dRenderer, gcs);
} catch (ChartException e) {
e.printStackTrace();
}
}</pre>
<br />
<br />
Please help me.
Find more posts tagged with
Comments
JasonW
1 - What is Standalone? - The chart engine can be ran in an OSGi container or by just using some jars. Standalone means no OSGi.
2 - ChartEngine ce = ChartEngine.instance(pf); This line creates the chart engine or returns the already created instance of it. The call is synchronized to make sure only one copy of the engine is created.
3 - gr = ce.getGenerator(); This call returns the portion of the Chart Engine that is responsible for generating the chart ( ie data access, metrics, aggregates, etc). Like the chart engine it is also wrapped in a singleton.
4 -
// device renderers for dv.SWT, dv.PNG, dv.JPG
// dv.PDF, dv.SVG, dv.SWING, dv.PNG24, div.BMP
// I dont know
dRenderer = ce.getRenderer("dv" + outputFormat);dServer = dRenderer.getDisplayServer();
The chart engine is setup to be extensible and supplies many output format options. The device renders supply support for various output formats ( bmp, jpg, png, swt, etc). The device renderer implements device primitives like drawLine, drawText and is extrapolated from the code that generates the chart. It also allows new output formats to be created without changing the main apis.
5 -
cm = (Chart) EcoreUtil.copy((Chart) cmf);
I believe this is just making a deep copy of the chart model.
6 -
Bounds bo = BoundsImpl.create(0, 0, sizeWidth, sizeHeight);
bo.scale(72d / dRenderer.getDisplayServer().getDpiResolution());
This code sets the actual size of the chart.
7 -
gcs = gr.build(dServer, cm, bo, null, null, null);
This builds the chart data internally but nothing is rendered yet.
gr.render(dRenderer, gcs);
This renders the chart to the device type.
Jason