File: base_plot_container.py

package info (click to toggle)
python-chaco 4.4.1-1.2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,664 kB
  • ctags: 4,246
  • sloc: python: 25,890; ansic: 1,217; makefile: 18; sh: 5
file content (70 lines) | stat: -rw-r--r-- 2,790 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
""" Defines the BasePlotContainer class.
"""
import warnings

# Enthought library imports
from enable.api import Container
from traits.api import Bool, Instance, Property, Str, Tuple

# Local, relative imports
from plot_component import DEFAULT_DRAWING_ORDER, PlotComponent


class BasePlotContainer(Container):
    """
    A container for PlotComponents that conforms to being laid out by
    PlotFrames.  Serves as the base class for other PlotContainers.

    PlotContainers define a layout, i.e., a spatial relationship between
    their contained components.  (BasePlotContainer doesn't define one,
    but its various subclasses do.)

    BasePlotContainer is a subclass of Enable Container, so it is possible to
    insert Enable-level components into it.  However, because Enable
    components don't have the correct interfaces to participate in layout,
    the visual results will probably be incorrect.
    """

    # Redefine the container layers to name the main layer as "plot" instead
    # of the Enable default of "mainlayer"
    container_under_layers = Tuple("background", "image", "underlay", "plot")

    #------------------------------------------------------------------------
    # Duplicate trait declarations from PlotComponent.  We don't subclass
    # PlotComponent to avoid MRO complications with trait handlers and property
    # getters/setters.
    #------------------------------------------------------------------------

    draw_order = Instance(list, args=(DEFAULT_DRAWING_ORDER,))
    draw_layer = Str("plot")

    #------------------------------------------------------------------------
    # Deprecated traits
    #------------------------------------------------------------------------

    # Deprecated flag to indicate that a component needed to do old-style
    # drawing.  Unused by any recent Chaco component.
    use_draw_order = Bool(True)

    # Deprecated property for accessing the components in the container.
    plot_components = Property

    def _get_plot_components(self):
        warnings.warn("Use of plot_components attribute deprecated." \
                      "Use components attribute instead.", DeprecationWarning)
        return self._components

    def _set_plot_components(self, new):
        warnings.warn("Use of plot_components attribute deprecated." \
                      "Use components attribute instead.", DeprecationWarning)
        self._components = new

    def _use_draw_order_changed(self, old, new):
        """ Handler to catch the case when someone is trying to use the
        old-style drawing mechanism, which is now unsupported.
        """
        if new == False:
            raise RuntimeError("The old-style drawing mechanism is no longer " \
                    "supported in Chaco.")

# EOF