This file is indexed.

/usr/lib/python2.7/dist-packages/chaco/cross_plot_frame.py is in python-chaco 4.4.1-1.2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
""" Defines the (deprecated) CrossPlotFrame class.
"""
#################################################################################
#
# NOTE: PlotFrames are deprecated.  There is no need to use them any more.
# This class will be removed sometime in the near future.
#
#################################################################################

from __future__ import with_statement

# Enthought library imports
from traits.api import Bool, Float

# Local, relative imports
from base_plot_frame import BasePlotFrame
from plot_containers import HPlotContainer, OverlayPlotContainer, VPlotContainer


class CrossPlotFrame(BasePlotFrame):
    """ A simple, box-layout based plotframe.

    This class supports a central plot area with optional axes on the top, bottom,
    and sides.  The legend can be placed to the bottom, left, right, or
    inside the plot area.  The title can be placed along any of the four
    edges.

    NOTE: PlotFrames are deprecated.  There is no need to use them any more.
    This class will be removed sometime in the future.
    """

    # Slots or positions on the frame where plot components can place themselves.
    # Overrides PlotFrame.
    slot_names = ("center", "left", "right", "top", "bottom")

    # Default width and height. Class attribute.
    default_bounds = (500,500)

    # The sizes of the various areas

    # Width of the left slot.
    left_width = Float(50.0)
    # Width of the right slot.
    right_width = Float(50.0)
    # Height of the top slot.
    top_height = Float(50.0)
    # Height of the bottom slot.
    bottom_height = Float(50.0)

    # Does the component need to do a layout call?
    _layout_needed = Bool(True)


    def __init__(self, **kwtraits):
        if kwtraits.has_key("bounds"):
            bounds = kwtraits.pop("bounds")
        else:
            bounds = list(self.default_bounds)
        BasePlotFrame.__init__(self, **kwtraits)

        # Create our plot containers
        self.set_slot("center", OverlayPlotContainer(resizable="hv"))
        self.set_slot("left", HPlotContainer(resizable="v"))
        self.set_slot("right", HPlotContainer(resizable="v"))
        self.set_slot("top", VPlotContainer(resizable="h"))
        self.set_slot("bottom", VPlotContainer(resizable="h"))

        self.bounds = bounds
        return

    def set_visible_slots(self, *names):
        """
        Convenience method to set the named slots to visible, while setting
        all others to not visible.
        """
        for slot in self.slot_names:
            if slot in names:
                self.get_slot(slot).visible = True
            else:
                self.get_slot(slot).visible = False
        return


    #------------------------------------------------------------------------
    # Protected methods
    #------------------------------------------------------------------------

    def _draw_component(self, gc, view_bounds=None, mode="normal"):
        """ Draws the component.

        This method is preserved for backwards compatibility with _old_draw().
        Overrides PlotComponent.
        """
        with gc:
            gc.translate_ctm(*self.position)
            for slotname in self.slot_names:
                if getattr(self, slotname).visible:
                    with gc:
                        self.get_slot(slotname).draw(gc, view_bounds, mode)
        return

    def _do_layout(self):
        """
        Performs a layout and sets the size and positions on this frame's
        containers, given its width and height.
        """
        left = self.left
        right = self.right
        top = self.top
        bottom = self.bottom
        center = self.center

        # Calculate the bounds of the resizable center container, then set
        # the bounds on all the containers.  center_x,_y represent the (x,y)
        # coordinate of the lower-left corner of the center region;
        # center_x2 and center_y2 represent the upper-right corner of the
        # center region.

        if self.left.visible:
            center_x = self.left_width
        else:
            center_x = self.x
        if self.bottom.visible:
            center_y = self.bottom_height
        else:
            center_y = self.y
        if self.right.visible:
            center_x2 = self.width - self.right_width - 1
        else:
            center_x2 = self.width
        if self.top.visible:
            center_y2 = self.height - self.top_height - 1
        else:
            center_y2 = self.height

        left.outer_position = [0.0, center_y]
        left.outer_bounds = [self.left_width, center_y2 - center_y + 1]

        right.outer_position = [center_x2 + 1, center_y]
        right.outer_bounds = [self.right_width, left.height]

        bottom.outer_position = [center_x, 0.0]
        bottom.outer_bounds = [center_x2 - center_x + 1, self.bottom_height]

        top.outer_position = [center_x, center_y2 + 1]
        top.outer_bounds = [bottom.width, self.top_height]

        center.outer_position = [center_x, center_y]
        center.outer_bounds = [bottom.width, left.height]

        for slot in self._frame_slots.values():
            if slot.visible:
                preferred_size = slot.get_preferred_size()
                if "h" not in slot.resizable:
                    slot.outer_width = preferred_size[0]
                if "v" not in slot.resizable:
                    slot.outer_height = preferred_size[1]
                slot.do_layout()

        return


    ### Persistence ###########################################################

    #_pickles = ("left_width", "right_width", "top_height", "bottom_height")

    def __getstate__(self):
        state = super(CrossPlotFrame,self).__getstate__()
        for key in ['_layout_needed']:
            if state.has_key(key):
                del state[key]

        return state


# EOF