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

« back to all changes in this revision

Viewing changes to chaco/tools/legend_highlighter.py

  • Committer: Package Import Robot
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2014-06-01 17:04:08 UTC
  • mfrom: (7.2.5 sid)
  • Revision ID: package-import@ubuntu.com-20140601170408-m86xvdjd83a4qon0
Tags: 4.4.1-1ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
 - Let the binary-predeb target work on the usr/lib/python* directory
   as we don't have usr/share/pyshared anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
    try:
13
13
        # FIXME: The size of the legend is not being computed correctly, so
14
14
        # always look at the front of the label where we know we'll get a hit.
15
 
        label = legend.get_label_at(legend.x+20, event.y)
 
15
        label = legend.get_label_at(legend.x + 20, event.y)
16
16
 
17
17
    except:
18
18
        raise
34
34
    or hide certain plots.
35
35
    """
36
36
 
 
37
    #: Which mousebutton to use to move the legend
37
38
    drag_button = "right"
38
39
 
 
40
    #: What to divide the alpha value by when plot is not selected
39
41
    dim_factor = Float(3.0)
40
42
 
 
43
    #: How much to scale the line when it is selected or deselected
 
44
    line_scale = Float(2.0)
 
45
 
41
46
    # The currently selected renderers
42
47
    _selected_renderers = List
43
48
 
60
65
            else:
61
66
                # User in single-select mode.
62
67
                add_plot = plot not in self._selected_renderers
63
 
                for p in self._selected_renderers:
64
 
                    self._selected_renderers.remove(p)
 
68
                self._selected_renderers = []
65
69
                if add_plot:
66
70
                    self._selected_renderers.append(plot)
67
71
 
68
 
            if len(self._selected_renderers) > 0:
69
 
                self._set_states(plot.container.plots)
 
72
            if self._selected_renderers:
 
73
                self._set_states(self.component.plots)
70
74
            else:
71
 
                self._reset_selects(plot.container.plots)
 
75
                self._reset_selects(self.component.plots)
72
76
            plot.request_redraw()
73
77
 
74
78
        event.handled = True
75
79
 
76
 
 
77
80
    def _reset_selects(self, plots):
78
81
        """ Set all renderers to their default values. """
79
82
        for plot in reduce(operator.add, plots.values()):
84
87
            plot.line_width = plot._orig_line_width
85
88
        return
86
89
 
87
 
 
88
90
    def _set_states(self, plots):
89
91
        """ Decorates a plot to indicate it is selected """
90
92
        for plot in reduce(operator.add, plots.values()):
93
95
                plot._orig_alpha = plot.alpha
94
96
                plot._orig_line_width = plot.line_width
95
97
            if plot in self._selected_renderers:
96
 
                plot.line_width = plot._orig_line_width * 2.0
 
98
                plot.line_width = plot._orig_line_width * self.line_scale
97
99
                plot.alpha = plot._orig_alpha
98
100
            else:
99
101
                plot.alpha = plot._orig_alpha / self.dim_factor
100
 
                plot.line_width = plot._orig_line_width / 2.0
 
102
                plot.line_width = plot._orig_line_width / self.line_scale
101
103
        # Move the selected renderers to the front
102
104
        if len(self._selected_renderers) > 0:
103
105
            container = self._selected_renderers[0].container