コード例 #1
0
ファイル: base_plot_frame.py プロジェクト: brycehendrix/chaco
    def _dispatch_to_enable(self, event, suffix):
        """ Calls Enable-level event handlers.

        Overrides PlotComponent.
        """
        Container.dispatch(self, event, suffix)
        return
コード例 #2
0
 def overlay(self, other_component, gc, view_bounds=None, mode="normal"):
     c = other_component
     self.do_layout(component=c)
     gc.save_state()
     try:
         gc.clip_to_rect(c.x, c.y, c.width, c.height)
         Container._draw(self, gc, view_bounds)
     finally:
         gc.restore_state()
     return
コード例 #3
0
ファイル: base_plot_frame.py プロジェクト: brycehendrix/chaco
 def set_slot(self, slotname, container):
     """
     Sets the named slot to use the given container. *container* can be None.
     """
     if self._frame_slots.has_key(slotname):
         old_container = self._frame_slots[slotname]
         Container.remove(self, old_container)
     if container is not None:
         self._frame_slots[slotname] = container
         Container.add(self, container)
     return
コード例 #4
0
ファイル: edge.py プロジェクト: jcrabtree/godot
 def _component_default(self):
     """ Trait initialiser.
     """
     component = Container(auto_size=True, bgcolor="green")
     #        component.tools.append( MoveTool(component) )
     #        component.tools.append( TraitsTool(component) )
     return component
コード例 #5
0
ファイル: edge.py プロジェクト: jcrabtree/godot
    def _parse_xdot_directive(self, name, new):
        """ Handles parsing Xdot drawing directives.
        """
        parser = XdotAttrParser()
        components = parser.parse_xdot_data(new)

        # The absolute coordinate of the drawing container wrt graph origin.
        x1 = min([c.x for c in components])
        y1 = min([c.y for c in components])

        print "X1/Y1:", name, x1, y1

        # Components are positioned relative to their container. This
        # function positions the bottom-left corner of the components at
        # their origin rather than relative to the graph.
        #        move_to_origin( components )

        for c in components:
            if isinstance(c, Ellipse):
                component.x_origin -= x1
                component.y_origin -= y1
#                c.position = [ c.x - x1, c.y - y1 ]

            elif isinstance(c, (Polygon, BSpline)):
                print "Points:", c.points
                c.points = [(t[0] - x1, t[1] - y1) for t in c.points]
                print "Points:", c.points

            elif isinstance(c, Text):
                #                font = str_to_font( str(c.pen.font) )
                c.text_x, c.text_y = c.x - x1, c.y - y1

        container = Container(auto_size=True,
                              position=[x1, y1],
                              bgcolor="yellow")

        container.add(*components)

        if name == "_draw_":
            self.drawing = container
        elif name == "_hdraw_":
            self.arrowhead_drawing = container
        else:
            raise
コード例 #6
0
 def _component_default(self):
     """ Trait initialiser.
     """
     return Container(draw_axes=True, fit_window=False, auto_size=True)
コード例 #7
0
 def _dispatch_stateful_event(self, event, suffix):
     Container._dispatch_stateful_event(self, event, suffix)
     if not event.handled:
         if self.is_in(event.x, event.y):
             event.handled = True
     return
コード例 #8
0
ファイル: ellipse.py プロジェクト: jcrabtree/godot
#------------------------------------------------------------------------------

if __name__ == "__main__":
    from godot.component.component_viewer import ComponentViewer

    pen = Pen()
    ellipse = Ellipse(
#        filled=True,
        pen=pen, x_origin=200, y_origin=150, e_width=100, e_height=50,
#        bounds=[50, 50], position=[0, 0]

    )

    from enthought.enable.api import Container
    container = Container(
#        fit_window=False, auto_size=True,
        bounds=[200, 100], position=[100, 100],
        bgcolor="green")
    container.add( ellipse )

    ellipse.x_origin -= container.x
    ellipse.y_origin -= container.y

    viewer = ComponentViewer( component=container )

    from enthought.enable.primitives.api import Box
    box = Box(
        color="steelblue", border_color="darkorchid", border_size=1,
        bounds=[50, 50], position=[50, 50]
    )
    viewer.canvas.add(box)