From: Andre Wobst <wobsta@us...> - 2005-02-10 11:43:24
On 10.02.05, pieter claassen wrote:
> I am not sure what the difference between sharedata and privatedata is. Is
> there a specific place in the code to go and look for more info? Are they
Unforunately there's only a little documentation about that. In the
docstring of graph.style._style you can find:
A style should never store private data by istance variables
(i.e. accessing self), but it should use the sharedata and privatedata
instances instead. A style instance can be used multiple times with
different sharedata and privatedata instances at the very same time.
The sharedata and privatedata instances act as data containers and
sharedata allows for sharing information across several styles.
pivatedata and sharedata are instances of the class styledata defined as
graph.graph.styledata. Its docstring is
Instances of this class are used to store data from the styles
and to pass point data to the styles by instances named privatedata
and sharedata. sharedata is shared between all the style(s) in use
by a data instance, while privatedata is private to each style and
used as a storage place instead of self to prevent side effects when
using a style several times.
Note that the crucial point is, that you should not use self to keep
data, but use privatedata and sharedata for that. Those instances are
local to the graph and style instance, not just local to the style
instance (you may want to use the same style instance in several
graphs). Beside that, you need to understand, that usually (indeed
always) there are several styles combined together. Some of them are
inserted automatically. There is for example a pos style, which reads
data and provides a vpos, i.e. a list of positions at the graph for
each direction in graph coordinates (coordinates in the range 0 to 1).
Other styles will use that information. For example the symbol style
will draw a symbol at that very position. In order to share the data
the information is kept in the instance sharedata. Other, local
information should be stored in privatedata.
by _ _ _ Dr. André Wobst
/ \ \ / ) wobsta@..., http://www.wobsta.de/
/ _ \ \/\/ / PyX - High quality PostScript figures with Python & TeX
(_/ \_)_/\_/ visit http://pyx.sourceforge.net/
Get latest updates about Open Source Projects, Conferences and News.