fix plot style breakage
[PyX/mjg.git] / pyx / canvasitem.py
blob726bb9dcf25085f530a162e7ca4bcc71573e3ca4
1 # -*- encoding: utf-8 -*-
4 # Copyright (C) 2002-2007 Jörg Lehmann <joergl@users.sourceforge.net>
5 # Copyright (C) 2002-2007 André Wobst <wobsta@users.sourceforge.net>
7 # This file is part of PyX (http://pyx.sourceforge.net/).
9 # PyX is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # PyX is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with PyX; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 class canvasitem:
25 """Base class for everything which can be inserted into a canvas"""
27 def bbox(self):
28 """return bounding box of canvasitem"""
29 # TODO: we either should raise a NotImplementedError here or return
30 # an empty bounding box instance, as adding empty to a bouding box is
31 # allowed. (We could also alter the merging behavior of bboxes to allow
32 # None. Currently, canvasitem instances not overwriting this bbox method
33 # lead to an error.)
34 pass
36 def processPS(self, file, writer, context, registry, bbox):
37 """process canvasitem by writing the corresponding PS code to file and
38 by updating context, registry as well as bbox
40 - the PS code corresponding to the canvasitem has to be written in the
41 stream file, which provides a write(string) method
42 - writer is the PSwriter used for the output
43 - context is an instance of pswriter.context which is used for keeping
44 track of the graphics state (current linewidth, colorspace and font))
45 - registry is used for tracking resources needed by the canvasitem
46 - bbox has to be updated to include the bounding box of the canvasitem
47 """
48 raise NotImplementedError()
50 def processPDF(self, file, writer, context, registry, bbox):
51 """process canvasitem by writing the corresponding PDF code to file and
52 by updating context, registry as well as bbox
54 - the PDF code corresponding to the canvasitem has to be written in the
55 stream file, which provides a write(string) method
56 - writer is the PDFwriter used for the output, which contains properties
57 like whether streamcompression is used
58 - context is an instance of pdfwriter.context which is used for keeping
59 track of the graphics state, in particular for the emulation of PS
60 behaviour regarding fill and stroke styles, for keeping track of the
61 currently selected font as well as of text regions.
62 - registry is used for tracking resources needed by the canvasitem
63 - bbox has to be updated to include the bounding box of the canvasitem
64 """
65 raise NotImplementedError()