Design notes

An extensible design

The Graphing framework allows programs that use it to graph varying types of data. When Stock Browser uses it, it adds the TPriceDrawer and TVolumeDrawer classes to draw stock data.

To write a pie-chart drawer, derive TPieChartDrawer from TGraphDrawer. Implement a constructor which takes all necessary information such as radius and center point (in graph coordinates) and collection of data. Implement DrawIntoGraph to map the center point and radius to visual points, then calculate the pie slice for each piece of data in the collection and draw it.

MGraphic versus TView

Instead of deriving TStandardGraph from MGraphic it's possible to represent the stock information with a subview. Either approach provides similar behavior, although using a graphic provides a little more flexibility. For instance, porting code to other platforms is easier because TStandardGraph relies only on MGraphic and not on TView and other portions of the view system.

The best way to change the program to use a view is by composition. You simply create a derived class of TView to hold and display a TStandardGraph object (like TGraphView does).


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker