| ... | ... |
@@ -78,7 +78,7 @@ class Shape: |
| 78 | 78 |
|
| 79 | 79 |
|
| 80 | 80 |
class TextShape(Shape): |
| 81 |
- |
|
| 81 |
+ |
|
| 82 | 82 |
#fontmap = pangocairo.CairoFontMap() |
| 83 | 83 |
#fontmap.set_resolution(72) |
| 84 | 84 |
#context = fontmap.create_context() |
| ... | ... |
@@ -100,7 +100,7 @@ class TextShape(Shape): |
| 100 | 100 |
layout = self.layout |
| 101 | 101 |
except AttributeError: |
| 102 | 102 |
layout = cr.create_layout() |
| 103 |
- |
|
| 103 |
+ |
|
| 104 | 104 |
# set font options |
| 105 | 105 |
# see http://lists.freedesktop.org/archives/cairo/2007-February/009688.html |
| 106 | 106 |
context = layout.get_context() |
| ... | ... |
@@ -109,16 +109,16 @@ class TextShape(Shape): |
| 109 | 109 |
fo.set_hint_style(cairo.HINT_STYLE_NONE) |
| 110 | 110 |
fo.set_hint_metrics(cairo.HINT_METRICS_OFF) |
| 111 | 111 |
pangocairo.context_set_font_options(context, fo) |
| 112 |
- |
|
| 112 |
+ |
|
| 113 | 113 |
# set font |
| 114 | 114 |
font = pango.FontDescription() |
| 115 | 115 |
font.set_family(self.pen.fontname) |
| 116 | 116 |
font.set_absolute_size(self.pen.fontsize*pango.SCALE) |
| 117 | 117 |
layout.set_font_description(font) |
| 118 |
- |
|
| 118 |
+ |
|
| 119 | 119 |
# set text |
| 120 | 120 |
layout.set_text(self.t) |
| 121 |
- |
|
| 121 |
+ |
|
| 122 | 122 |
# cache it |
| 123 | 123 |
self.layout = layout |
| 124 | 124 |
else: |
| ... | ... |
@@ -138,9 +138,9 @@ class TextShape(Shape): |
| 138 | 138 |
x = self.x - width |
| 139 | 139 |
else: |
| 140 | 140 |
assert 0 |
| 141 |
- |
|
| 141 |
+ |
|
| 142 | 142 |
y = self.y - height |
| 143 |
- |
|
| 143 |
+ |
|
| 144 | 144 |
cr.move_to(x, y) |
| 145 | 145 |
|
| 146 | 146 |
cr.set_source_rgba(*self.pen.color) |
| ... | ... |
@@ -234,7 +234,7 @@ class Element(CompoundShape): |
| 234 | 234 |
|
| 235 | 235 |
def __init__(self, shapes): |
| 236 | 236 |
CompoundShape.__init__(self, shapes) |
| 237 |
- |
|
| 237 |
+ |
|
| 238 | 238 |
def get_url(self, x, y): |
| 239 | 239 |
return None |
| 240 | 240 |
|
| ... | ... |
@@ -246,7 +246,7 @@ class Node(Element): |
| 246 | 246 |
|
| 247 | 247 |
def __init__(self, x, y, w, h, shapes, url): |
| 248 | 248 |
Element.__init__(self, shapes) |
| 249 |
- |
|
| 249 |
+ |
|
| 250 | 250 |
self.x = x |
| 251 | 251 |
self.y = y |
| 252 | 252 |
|
| ... | ... |
@@ -254,7 +254,7 @@ class Node(Element): |
| 254 | 254 |
self.y1 = y - 0.5*h |
| 255 | 255 |
self.x2 = x + 0.5*w |
| 256 | 256 |
self.y2 = y + 0.5*h |
| 257 |
- |
|
| 257 |
+ |
|
| 258 | 258 |
self.url = url |
| 259 | 259 |
|
| 260 | 260 |
def is_inside(self, x, y): |
| ... | ... |
@@ -301,7 +301,7 @@ class Graph(Shape): |
| 301 | 301 |
|
| 302 | 302 |
def __init__(self, width=1, height=1, nodes=(), edges=()): |
| 303 | 303 |
Shape.__init__(self) |
| 304 |
- |
|
| 304 |
+ |
|
| 305 | 305 |
self.width = width |
| 306 | 306 |
self.height = height |
| 307 | 307 |
self.nodes = nodes |
| ... | ... |
@@ -315,12 +315,12 @@ class Graph(Shape): |
| 315 | 315 |
|
| 316 | 316 |
cr.set_line_cap(cairo.LINE_CAP_BUTT) |
| 317 | 317 |
cr.set_line_join(cairo.LINE_JOIN_MITER) |
| 318 |
- |
|
| 318 |
+ |
|
| 319 | 319 |
for edge in self.edges: |
| 320 | 320 |
edge.draw(cr) |
| 321 | 321 |
for node in self.nodes: |
| 322 | 322 |
node.draw(cr) |
| 323 |
- |
|
| 323 |
+ |
|
| 324 | 324 |
def get_url(self, x, y): |
| 325 | 325 |
for node in self.nodes: |
| 326 | 326 |
url = node.get_url(x, y) |
| ... | ... |
@@ -472,7 +472,7 @@ class XDotAttrParser: |
| 472 | 472 |
|
| 473 | 473 |
|
| 474 | 474 |
class XDotParser: |
| 475 |
- |
|
| 475 |
+ |
|
| 476 | 476 |
def __init__(self, xdotcode): |
| 477 | 477 |
self.xdotcode = xdotcode |
| 478 | 478 |
|
| ... | ... |
@@ -495,7 +495,7 @@ class XDotParser: |
| 495 | 495 |
|
| 496 | 496 |
nodes = [] |
| 497 | 497 |
edges = [] |
| 498 |
- |
|
| 498 |
+ |
|
| 499 | 499 |
for node in graph.get_node_list(): |
| 500 | 500 |
if node.pos is None: |
| 501 | 501 |
continue |
| ... | ... |
@@ -514,7 +514,7 @@ class XDotParser: |
| 514 | 514 |
for edge in graph.get_edge_list(): |
| 515 | 515 |
if edge.pos is None: |
| 516 | 516 |
continue |
| 517 |
- points = self.parse_edge_pos(edge.pos) |
|
| 517 |
+ points = self.parse_edge_pos(edge.pos) |
|
| 518 | 518 |
shapes = [] |
| 519 | 519 |
for attr in ("_draw_", "_ldraw_", "_hdraw_", "_tdraw_", "_hldraw_", "_tldraw_"):
|
| 520 | 520 |
if hasattr(edge, attr): |
| ... | ... |
@@ -825,20 +825,20 @@ class DotWindow(gtk.Window): |
| 825 | 825 |
|
| 826 | 826 |
def main(): |
| 827 | 827 |
import optparse |
| 828 |
- |
|
| 828 |
+ |
|
| 829 | 829 |
parser = optparse.OptionParser( |
| 830 | 830 |
usage="\n\t%prog [file]", |
| 831 | 831 |
version="%%prog %s" % __version__) |
| 832 |
- |
|
| 832 |
+ |
|
| 833 | 833 |
(options, args) = parser.parse_args(sys.argv[1:]) |
| 834 |
- |
|
| 834 |
+ |
|
| 835 | 835 |
if len(args) == 0: |
| 836 | 836 |
fp = sys.stdin |
| 837 | 837 |
elif len(args) == 1: |
| 838 | 838 |
fp = file(args[0], 'rt') |
| 839 | 839 |
else: |
| 840 | 840 |
parser.error('incorrect number of arguments')
|
| 841 |
- |
|
| 841 |
+ |
|
| 842 | 842 |
win = DotWindow() |
| 843 | 843 |
win.set_dotcode(fp.read()) |
| 844 | 844 |
win.connect('destroy', gtk.main_quit)
|