def overlay(self, component, gc, view_bounds=None, mode="normal"): """ Draws the tooltip overlaid on another component. Overrides and extends ToolTip.overlay() """ if self.clip_to_plot: gc.save_state() c = component gc.clip_to_rect(c.x, c.y, c.width, c.height) self.do_layout() if self.label_style == 'box': self._render_box(component, gc, view_bounds=view_bounds, mode=mode) else: self._render_bubble(component, gc, view_bounds=view_bounds, mode=mode) # draw the marker if self.marker_visible: render_markers(gc, [self._screen_coords], self.marker, self.marker_size, self.marker_color_, self.marker_line_width, self.marker_line_color_, self.custom_symbol) if self.clip_to_plot: gc.restore_state()
def _render_marker_at_indices(self, gc, screen_pts, prefix, sep="_"): """ screen_pt should always be a list """ if len(screen_pts) == 0: return plot = self.component mapped_attribs = ("color", "outline_color", "marker") other_attribs = ("marker_size", "line_width") kwargs = {} for attr in mapped_attribs + other_attribs: if attr in mapped_attribs: # Resolve the mapped trait valname = attr + "_" else: valname = attr tmp = getattr(self, prefix+sep+valname) if tmp is not None: kwargs[attr] = tmp else: kwargs[attr] = getattr(plot, valname) # If the marker type is 'custom', we have to pass in the custom_symbol # kwarg to render_markers. if kwargs.get("marker", None) == "custom": kwargs["custom_symbol"] = plot.custom_symbol with gc: gc.clip_to_rect(plot.x, plot.y, plot.width, plot.height) render_markers(gc, screen_pts, **kwargs)
def _render_marker_at_indices(self, gc, screen_pts, prefix, sep="_"): """ screen_pt should always be a list """ if len(screen_pts) == 0: return plot = self.component mapped_attribs = ("color", "outline_color", "marker") other_attribs = ("marker_size", "line_width") kwargs = {} for attr in mapped_attribs + other_attribs: if attr in mapped_attribs: # Resolve the mapped trait valname = attr + "_" else: valname = attr tmp = getattr(self, prefix + sep + valname) if tmp is not None: kwargs[attr] = tmp else: kwargs[attr] = getattr(plot, valname) # If the marker type is 'custom', we have to pass in the custom_symbol # kwarg to render_markers. if kwargs.get("marker", None) == "custom": kwargs["custom_symbol"] = plot.custom_symbol with gc: gc.clip_to_rect(plot.x, plot.y, plot.width, plot.height) render_markers(gc, screen_pts, **kwargs)
def overlay(self, component, gc, view_bounds=None, mode="normal"): """ Draws the tooltip overlaid on another component. Overrides and extends ToolTip.overlay() """ if self.clip_to_plot: gc.save_state() c = component gc.clip_to_rect(c.x, c.y, c.width, c.height) self.do_layout() # draw the arrow if necessary if self.arrow_visible: if self._cached_arrow is None: if self.arrow_root in self._root_positions: ox, oy = self._root_positions[self.arrow_root] else: if self.arrow_root == "auto": arrow_root = self.label_position else: arrow_root = self.arrow_root ox, oy = self._root_positions.get( self._position_root_map.get(arrow_root, "DUMMY"), (self.x + self.width / 2, self.y + self.height / 2)) if type(ox) == str: ox = getattr(self, ox) oy = getattr(self, oy) self._cached_arrow = draw_arrow(gc, (ox, oy), self._screen_coords, self.arrow_color_, arrowhead_size=self.arrow_size, offset1=3, offset2=self.marker_size + 3, minlen=self.arrow_min_length, maxlen=self.arrow_max_length) else: draw_arrow(gc, None, None, self.arrow_color_, arrow=self._cached_arrow, minlen=self.arrow_min_length, maxlen=self.arrow_max_length) # layout and render the label itself ToolTip.overlay(self, component, gc, view_bounds, mode) # draw the marker if self.marker_visible: render_markers(gc, [self._screen_coords], self.marker, self.marker_size, self.marker_color_, self.marker_line_width, self.marker_line_color_, self.custom_symbol) if self.clip_to_plot: gc.restore_state()
def overlay(self, component, gc, view_bounds=None, mode="normal"): """ Draws the tooltip overlaid on another component. Overrides and extends ToolTip.overlay() """ if self.clip_to_plot: gc.save_state() c = component gc.clip_to_rect(c.x, c.y, c.width, c.height) self.do_layout() # draw the arrow if necessary if self.arrow_visible: if self._cached_arrow is None: if self.arrow_root in self._root_positions: ox, oy = self._root_positions[self.arrow_root] else: if self.arrow_root == "auto": arrow_root = self.label_position else: arrow_root = self.arrow_root ox, oy = self._root_positions.get( self._position_root_map.get(arrow_root, "DUMMY"), (self.x+self.width/2, self.y+self.height/2) ) if type(ox) == str: ox = getattr(self, ox) oy = getattr(self, oy) self._cached_arrow = draw_arrow(gc, (ox, oy), self._screen_coords, self.arrow_color_, arrowhead_size=self.arrow_size, offset1=3, offset2=self.marker_size+3, minlen=self.arrow_min_length, maxlen=self.arrow_max_length) else: draw_arrow(gc, None, None, self.arrow_color_, arrow=self._cached_arrow, minlen=self.arrow_min_length, maxlen=self.arrow_max_length) # layout and render the label itself ToolTip.overlay(self, component, gc, view_bounds, mode) # draw the marker if self.marker_visible: render_markers(gc, [self._screen_coords], self.marker, self.marker_size, self.marker_color_, self.marker_line_width, self.marker_line_color_, self.custom_symbol) if self.clip_to_plot: gc.restore_state()