~ubuntu-branches/ubuntu/utopic/python-chaco/utopic

« back to all changes in this revision

Viewing changes to enthought/chaco/plot_graphics_context.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2011-04-06 19:03:54 UTC
  • mfrom: (7.2.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110406190354-rwd55l2ezjecfo41
Tags: 3.4.0-2
d/rules: fix pyshared directory path (Closes: #621116)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
""" Defines the PlotGraphicsContext class.
2
2
"""
3
 
from enthought.kiva.backend_image import GraphicsContext
4
 
 
5
 
class PlotGraphicsContext(GraphicsContext):
 
3
 
 
4
from __future__ import with_statement
 
5
 
 
6
from enthought.kiva.image import GraphicsContext
 
7
 
 
8
class PlotGraphicsContextMixin(object):
 
9
 
6
10
    """ A Kiva graphics context, which facilitates rendering plots and plot
7
11
    components into an offscreen or memory buffer.  
8
12
    
20
24
        if type(size_or_ary) in (list, tuple) and len(size_or_ary) == 2:
21
25
            size_or_ary = (size_or_ary[0]*scale + 1, size_or_ary[1]*scale + 1)
22
26
        
23
 
        super(PlotGraphicsContext, self).__init__(size_or_ary, *args, **kw)
 
27
        super(PlotGraphicsContextMixin, self).__init__(size_or_ary, *args, **kw)
24
28
        self.translate_ctm(0.5, 0.5)
25
29
        self.scale_ctm(scale, scale)
26
30
        return
49
53
        if not container_coords:
50
54
            x = -x
51
55
            y = -y
52
 
        self.save_state()
53
 
        self.translate_ctm(x, y)
54
 
        try:
 
56
        with self:
 
57
            self.translate_ctm(x, y)
55
58
            component.draw(self, view_bounds=(0, 0, self.width(), self.height()))
56
 
        finally:
57
 
            self.restore_state()
58
59
        return
59
60
 
60
61
    def clip_to_rect(self, x, y, width, height):
63
64
        
64
65
        Overrides Kiva GraphicsContext.
65
66
        """
66
 
        GraphicsContext.clip_to_rect(self, x-0.5, y-0.5, width+1, height+1)
 
67
        super(PlotGraphicsContextMixin, self).clip_to_rect(x-0.5, y-0.5, width+1, height+1)
67
68
 
68
 
# EOF
 
69
class PlotGraphicsContext(PlotGraphicsContextMixin, GraphicsContext):
 
70
    pass
69
71