コード例 #1
0
ファイル: DiGraphObserver.py プロジェクト: ASayre/UCSBsketch
 def drawAnno( self, a ):
     if len(a.connectMap) > 0:
         for from_node in a.connectMap.keys():
             for connect_tuple in a.connectMap[from_node]:
                 edge,to_node = connect_tuple
                 SketchGUI.drawCircle( edge.tail.X, edge.tail.Y, radius=7, width=2, color="#ccffcc")
                 SketchGUI.drawCircle( edge.tip.X, edge.tip.Y, radius=7, width=2, color="#ccffcc")
コード例 #2
0
    def drawAnno( self, a ):
        if len(a.connectMap) > 0:
            node_map = {}
            for from_node in a.connectMap.keys():
                if from_node not in node_map:
                   node_map[from_node] = len(node_map)
                for connect_tuple in a.connectMap[from_node]:
                    edge,to_node = connect_tuple
                    if to_node not in node_map:
                       node_map[to_node] = len(node_map)

                    if from_node is not None:
                       SketchGUI.drawLine( edge.tail.X, edge.tail.Y, from_node.center.X, from_node.center.Y, width=2, color="#FA8072")
                    if to_node is not None:
                       SketchGUI.drawLine( edge.tip.X, edge.tip.Y, to_node.center.X, to_node.center.Y, width=2, color="#FA8072")

                    SketchGUI.drawCircle( edge.tail.X, edge.tail.Y, radius=2, width=2, color="#ccffcc")
                    SketchGUI.drawCircle( edge.tip.X, edge.tip.Y, radius=2, width=2, color="#ccffcc")

                    #x1,y1 = from_node.center.X, from_node.center.Y
                    #x2,y2 = edge.tail.X, edge.tail.Y
                    #SketchGUI.drawLine( x1,y1,x2,y2, width=2,color="#ccffcc")
                    #x1,y1 = to_node.center.X, to_node.center.Y
                    #x2,y2 = edge.tip.X, edge.tip.Y
                    #SketchGUI.drawLine( x1,y1,x2,y2, width=2,color="#ccffcc")

            for nodeAnno, nodeNum in node_map.items():
                if nodeAnno is not None:
                    x1,y1 = nodeAnno.center.X, nodeAnno.center.Y
                    SketchGUI.drawText(x1, y1, str(nodeNum))
コード例 #3
0
    def drawMyself( self ):
	for a in self.annotation_list:
            SketchGUI.drawCircle( a.center.X,a.center.Y, radius=a.radius, color="#bbbbff", width=2.0)
コード例 #4
0
ファイル: CircleObserver.py プロジェクト: ASayre/UCSBsketch
    def drawMyself( self ):
        vizlogger.debug("Drawing self: %s" % (self.annotation_list))
	for a in self.annotation_list:
            vizlogger.debug("Drawing Circle")
            SketchGUI.drawCircle( a.center.X, a.center.Y, radius=a.radius, color="#bbbbff", width=2.0)
コード例 #5
0
    def drawAnno( self, a ):
        tm_logger.debug(ET.tostring(a.xml()))

        edge_label_size = 15
        tape_label_size = 20
        active_color = "#BF5252"
        active_width = 7.0
        state_graph = a.state_graph_anno
        for from_node, connection_list in state_graph.connectMap.items():
            if from_node is not None:
                nodeColor = "#000000"
                if from_node == a.active_state:
                    nodeColor = active_color
                x, y = ( from_node.center.X, from_node.center.Y )
                SketchGUI.drawCircle (x, y, radius=from_node.radius, color=nodeColor, width=3.0)

            #GeomUtils.strokeSmooth(edge.tailstroke, width = len(edge.tailstroke.Points) / 3).drawMyself()
            for edge, to_node in connection_list:
                if edge == a.leading_edge['edge']:
                    edgeColor = active_color
                else:
                    edgeColor = "#000000"
                if to_node is not None:
                    nodeColor = "#000000"
                    nodeWidth = 3.0
                    if to_node == a.active_state:
                        nodeColor = active_color
                        nodeWidth = active_width
                    x, y = ( to_node.center.X, to_node.center.Y )
                    SketchGUI.drawCircle (x, y, radius=to_node.radius, color=nodeColor, fill="", width=nodeWidth)
                #Draw the smoothed tail
                if from_node is not None:
                    if edge.direction == "tail2head": #Connect the tail more closely to the edge
                        smooth_tail = Stroke([from_node.center] + edge.tailstroke.Points + [edge.tip])
                    else:
                        smooth_tail = Stroke([edge.tip] + edge.tailstroke.Points + [from_node.center])
                else:
                    smooth_tail = edge.tailstroke
                smooth_tail = GeomUtils.strokeSmooth(smooth_tail, width = len(edge.tailstroke.Points) / 3, preserveEnds = True)
                smooth_tail.drawMyself(color=edgeColor)

                #Draw the smoothed head
                ep1, ep2 = ( edge.headstroke.Points[0], edge.headstroke.Points[-1] )
                smooth_head = Stroke([ep1, edge.tip, ep2])
                smooth_head.drawMyself(color = edgeColor)

                if edge in a.edge2labels_map:
                    #Determine label offset
                     
                    for label in a.edge2labels_map[edge]:
                        textColor = "#000000"
                        if label == a.leading_edge['label']:
                            tm_logger.debug("Drawing leading label: %s" % (label.text))
                            textColor = active_color
                        tl, br = GeomUtils.strokelistBoundingBox(label.Strokes)

                        label_point = Point ((tl.X + br.X) / 2.0, (tl.Y + br.Y) / 2.0)
                        label_point.X -= edge_label_size
                        label_point.Y += edge_label_size
                        #label_point = smooth_tail.Points[len(smooth_tail.Points)/2]
                        SketchGUI.drawText (label_point.X, label_point.Y, InText=label.text, size=edge_label_size, color=textColor)
                    #endfor
                #endif
            #end for edge
        #end for from_node

        #Draw the tape string
        tl, br = GeomUtils.strokelistBoundingBox(a.Strokes)
        tape_label_pt = Point( \
            ((tl.X + br.X) / 2.0) - (len(a.tape_string) + 2) * tape_label_size / 2.0 , \
            br.Y - tape_label_size)

        for curIdx, tapeChar in enumerate(['-'] + a.tape_string + ['-']):
            curPt = Point(tape_label_pt.X + curIdx * tape_label_size, tape_label_pt.Y)
            charColor = "#000000"
            if curIdx - 1== a.tape_idx:
                charColor = active_color
            SketchGUI.drawText (curPt.X, curPt.Y, InText=tapeChar, size=tape_label_size, color=charColor)
コード例 #6
0
ファイル: ArrowObserver.py プロジェクト: ASayre/UCSBsketch
 def drawMyself( self ):
     for a in self.annotation_list:
         SketchGUI.drawCircle( a.tail.X, a.tail.Y, color="#93bfdd", width=2.0, radius=4)
         SketchGUI.drawCircle( a.tip.X, a.tip.Y, color="#93bfdd", width=2.0, radius=4)