~garyvdm/bzr-gtk/brokenlines

« back to all changes in this revision

Viewing changes to viz/graphcell.py

  • Committer: Gary van der Merwe
  • Date: 2007-09-22 12:22:23 UTC
  • Revision ID: garyvdm@gmail.com-20070922122223-j9ilw4oz3turmw7s
First implementation of broken lines.

Show diffs side-by-side

added added

removed removed

Lines of Context:
145
145
        box_size = self.box_size(widget)
146
146
 
147
147
        ctx.set_line_width(box_size / 8)
148
 
        ctx.set_line_cap(cairo.LINE_CAP_SQUARE)
 
148
        ctx.set_line_cap(cairo.LINE_CAP_ROUND)
149
149
 
150
150
        # Draw lines into the cell
151
151
        for start, end, colour in self.in_lines:
172
172
        ctx.fill()
173
173
    
174
174
    def render_line (self, ctx, cell_area, box_size, mid, height, start, end, colour):
175
 
        startx = cell_area.x + box_size * start + box_size / 2
176
 
        endx = cell_area.x + box_size * end + box_size / 2
177
 
        
178
 
        ctx.move_to(startx, mid - height / 2)
179
 
        
180
 
        if start - end == 0 :
181
 
            ctx.line_to(endx, mid + height / 2)
 
175
        if start is None:
 
176
            x = cell_area.x + box_size * end + box_size / 2
 
177
            ctx.move_to(x, mid + height / 3)
 
178
            ctx.line_to(x, mid + height / 3)
 
179
            ctx.move_to(x, mid + height / 6)
 
180
            ctx.line_to(x, mid + height / 6)
 
181
            
 
182
        elif end is None:
 
183
            x = cell_area.x + box_size * start + box_size / 2
 
184
            ctx.move_to(x, mid - height / 3)
 
185
            ctx.line_to(x, mid - height / 3)
 
186
            ctx.move_to(x, mid - height / 6)
 
187
            ctx.line_to(x, mid - height / 6)
182
188
        else:
183
 
            ctx.curve_to(startx, mid - height / 5,
184
 
                         startx, mid - height / 5,
185
 
                         startx + (endx - startx) / 2, mid)
186
 
            
187
 
            ctx.curve_to(endx, mid + height / 5,
188
 
                         endx, mid + height / 5 ,
189
 
                         endx, mid + height / 2)
190
 
            
 
189
            startx = cell_area.x + box_size * start + box_size / 2
 
190
            endx = cell_area.x + box_size * end + box_size / 2
 
191
            
 
192
            ctx.move_to(startx, mid - height / 2)
 
193
            
 
194
            if start - end == 0 :
 
195
                ctx.line_to(endx, mid + height / 2)
 
196
            else:
 
197
                ctx.curve_to(startx, mid - height / 5,
 
198
                             startx, mid - height / 5,
 
199
                             startx + (endx - startx) / 2, mid)
 
200
                
 
201
                ctx.curve_to(endx, mid + height / 5,
 
202
                             endx, mid + height / 5 ,
 
203
                             endx, mid + height / 2)
 
204
                
191
205
        self.set_colour(ctx, colour, 0.0, 0.65)
192
206
        ctx.stroke()
193
207
        
 
 
b'\\ No newline at end of file'