~ubuntu-branches/debian/sid/pyx/sid

« back to all changes in this revision

Viewing changes to pyx/canvasitem.py

  • Committer: Bazaar Package Importer
  • Author(s): Stuart Prescott
  • Date: 2011-05-20 00:13:52 UTC
  • mto: (9.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20110520001352-odcuqpdezuusbbw1
Tags: upstream-0.11.1
Import upstream version 0.11.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
#
 
3
#
 
4
# Copyright (C) 2002-2007 Jörg Lehmann <joergl@users.sourceforge.net>
 
5
# Copyright (C) 2002-2007 André Wobst <wobsta@users.sourceforge.net>
 
6
#
 
7
# This file is part of PyX (http://pyx.sourceforge.net/).
 
8
#
 
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.
 
13
#
 
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.
 
18
#
 
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
 
22
 
 
23
class canvasitem:
 
24
 
 
25
    """Base class for everything which can be inserted into a canvas"""
 
26
 
 
27
    def bbox(self):
 
28
        """return bounding box of canvasitem"""
 
29
        pass
 
30
 
 
31
    def processPS(self, file, writer, context, registry, bbox):
 
32
        """process canvasitem by writing the corresponding PS code to file and
 
33
        by updating context, registry as well as bbox
 
34
 
 
35
        - the PS code corresponding to the canvasitem has to be written in the
 
36
          stream file, which provides a write(string) method
 
37
        - writer is the PSwriter used for the output
 
38
        - context is an instance of pswriter.context which is used for keeping 
 
39
          track of the graphics state (current linewidth, colorspace and font))
 
40
        - registry is used for tracking resources needed by the canvasitem
 
41
        - bbox has to be updated to include the bounding box of the canvasitem
 
42
        """
 
43
        raise NotImplementedError()
 
44
 
 
45
    def processPDF(self, file, writer, context, registry, bbox):
 
46
        """process canvasitem by writing the corresponding PDF code to file and
 
47
        by updating context, registry as well as bbox
 
48
 
 
49
        - the PDF code corresponding to the canvasitem has to be written in the
 
50
          stream file, which provides a write(string) method
 
51
        - writer is the PDFwriter used for the output, which contains properties
 
52
          like whether streamcompression is used
 
53
        - context is an instance of pdfwriter.context which is used for keeping
 
54
          track of the graphics state, in particular for the emulation of PS 
 
55
          behaviour regarding fill and stroke styles, for keeping track of the
 
56
          currently selected font as well as of text regions.
 
57
        - registry is used for tracking resources needed by the canvasitem
 
58
        - bbox has to be updated to include the bounding box of the canvasitem
 
59
        """
 
60
        raise NotImplementedError()