Difference between revisions of "Calc/Implementation/Chart2 Framework"

From Apache OpenOffice Wiki
Jump to: navigation, search
 
(One intermediate revision by one other user not shown)
Line 21: Line 21:
 
           - Data points
 
           - Data points
  
http://wiki.services.openoffice.org/w/images/8/8b/ChartElements.jpg
+
[[File:ChartElements.jpg]]
  
 
== '''2. Characters of chart2 Module''' ==
 
== '''2. Characters of chart2 Module''' ==
Line 27: Line 27:
 
Chart2 module well implemented uno interfaces. These interfaces are located in offapi\com\sun\star\chart which is the old interfaces and offapi\com\sun\star\chart2 which is the new. Each kernel chart objects must implement the corresponding interface defined in the offapi module. In order to keep the consistency with the old interface, some kernel objects implemented the new interface and also aggregated the old interface in the other hand.
 
Chart2 module well implemented uno interfaces. These interfaces are located in offapi\com\sun\star\chart which is the old interfaces and offapi\com\sun\star\chart2 which is the new. Each kernel chart objects must implement the corresponding interface defined in the offapi module. In order to keep the consistency with the old interface, some kernel objects implemented the new interface and also aggregated the old interface in the other hand.
 
Below chart is an illustration of ChartModel, which implemented the new interface chart2::XChartDocument and aggregated the old interface chart::XChartDocument.
 
Below chart is an illustration of ChartModel, which implemented the new interface chart2::XChartDocument and aggregated the old interface chart::XChartDocument.
 
http://wiki.services.openoffice.org/w/images/8/8a/ChartModelInterface.jpg
 
  
 
Below chart is another example to illustrate the interface implementations of some other kernel objects.
 
Below chart is another example to illustrate the interface implementations of some other kernel objects.
  
http://wiki.services.openoffice.org/w/images/thumb/0/04/ChartInterfaces.jpg/800px-ChartInterfaces.jpg
+
[[File:ChartInterfaces.jpg]]
  
  
Line 147: Line 145:
 
'''4.1. Create a default column chart'''
 
'''4.1. Create a default column chart'''
  
http://wiki.services.openoffice.org/w/images/thumb/b/b9/CreateDefaultChartProcess.jpg/800px-CreateDefaultChartProcess.jpg
+
[[File:CreateDefaultChartProcess.jpg]]
  
 
'''4.2. Create a title on chart'''
 
'''4.2. Create a title on chart'''
  
http://wiki.services.openoffice.org/w/images/thumb/6/6d/CreateTitleProcess.jpg/800px-CreateTitleProcess.jpg
+
[[File:CreateTitleProcess.jpg]]

Latest revision as of 01:50, 7 May 2012


1. Basic Concepts of Chart Kernel Objects

A chart model contains three major parts, titles(main title and sub-title), legend, and diagram which contains concrete chart data. The chart data is organized by chart type in a coordinate system. The chart type consist of data series, which represents as a series of individual data points with the same color. The data series is generally organized by column which is the default in the chart data table, but it can be organized by row as well. For some chart types, a data point needs several data units. For example, a bubble chart needs three data units: a X coordinate point, a Y coordinate point, and the bubble size. So it needs three columns(or rows according to the direction of the data series) to represent a completed data series. Each column or row is called data sequence. A diagram has a wall as the background of the coordinate system. For 3D charts, it also needs a floor. The hierarchical model of the chart kernel objects is like below chart.

  • Chart Model
 Titles
   - Main title
   - Sub-title
 Legend
 Diagram
   - Chart wall
   - Chart floor
   - Coordinate system
     - Chart type
       - Data series
         - Data sequence
         - Data points

ChartElements.jpg

2. Characters of chart2 Module

2.1. Well implemented uno interfaces Chart2 module well implemented uno interfaces. These interfaces are located in offapi\com\sun\star\chart which is the old interfaces and offapi\com\sun\star\chart2 which is the new. Each kernel chart objects must implement the corresponding interface defined in the offapi module. In order to keep the consistency with the old interface, some kernel objects implemented the new interface and also aggregated the old interface in the other hand. Below chart is an illustration of ChartModel, which implemented the new interface chart2::XChartDocument and aggregated the old interface chart::XChartDocument.

Below chart is another example to illustrate the interface implementations of some other kernel objects.

ChartInterfaces.jpg


2.2. Typical MVC design pattern

The source code under chart2 module was categorized into five parts: model, view, controller, inc and tools, which is a typical MVC design pattern.

  • model: kernel objects, binary file: chartmodelmi.dll
  • view: drawing, binary file: chartviewmi.dll
  • controller: events handler, interfaces for outside callers..., binary file: chartcontrollermi.dll
  • tools: tools for chart handling, helper classes, binary file: charttoolsmi.dll
  • inc: private include files


2.3. Breakdown of the MVC model

The section breakdowns the source code under chart2\source to interpret the major functions of each folder under model, view, controller.

2.3.1. Model

Folder Major Function
filter Interface with xmloff
main Kernel objects: ChartModel, Diagram, Title, Legend, DataSeries, DataPoint...
template Templates to create each chart type based on the chart data table

For each chart type, we must have below objects(use bubble chart as illustration):

  • a template (BubbleChartTypeTemplate under source\model\template) to create chart type model based on the original data source
  • a data source interpreter (BubbleDataInterpreter under source\model\template) to interpret the original data source and generate the chart type model according to the corresponding template
  • a chart type model (BubbleChartType under source\model\template)
  • a view object (BubbleChart under source\view\charttypes)


2.3.2. View

Folder Major Function
axes Coordinate system and axes
charttypes Shape creator for individual chart types
diagram View of diagram
main Kernel view objects: ChartView, VLegend, VTitle, VDataSeries...

VDataSeries contains view information for a data series, for example, X value, Y value, which coordinate this data series will be applied to(the diagram might contain two coordinate systems, main coordinate system and secondary coordinate system). Then chartypes uses these information to draw the corresponding shapes for each data point.


2.3.3. controller

Folder Major Function
accessibility ACC
chartapiwrapper Interfaces for outside callers
dialogs Chart internal dialogs
drawinglayer Bridge between drawing layer and SdrObject
itemsetwrapper Converter between property set and item set
main Major controllers: event handling, command dispatch...

Each visual object in chart will also correspond a SdrObject. drawinglayer is responsible for establishing a bridge between the visual objects to it's concrete SdrObject.

Under AOO's architecture, SfxItemSet is generally used to transfer object attributes. But as fore-mentioned, each object in chart2 module implemented uno interface, so XPropertySet which is a uno interface is used to transfer attributes within the chart2 module. Therefore itemsetwrapper was designed to be responsible for converting the attributes between SfxItemSet and XPropertySet.

3. Model, View, Wrapper and Helper

In general, a concrete model object will correspond a object set which contains four class. We use [Object] as the placeholder of the model object.

  • [Object]: kernel object in model
  • V[Object]: view-side object corresponding to model
  • [Object]Wrapper: wrapper to access the kernel object for outside callers
  • [Object]Helper: tool to create model object, or get/set the internal attributes of the model

Example:

  • Diagram, VDiagram, DiagramWrapper, DiagramHelper
  • Title, VTitle, TitleWrapper, TitleHelper
  • Legend, VLegend, LegendWrapper, LegendHelper

4. Chart handling process

This section will use two typical process to interpret how the chart model works to create each MVC objects. The first order is top to bottom; the second order is left to right.

Legend: M – Model; V – View; C – Controller; T – Tools

4.1. Create a default column chart

CreateDefaultChartProcess.jpg

4.2. Create a title on chart

CreateTitleProcess.jpg

Personal tools