... | ... |
@@ -25,12 +25,8 @@ from gi.repository import Gdk |
25 | 25 |
from .lexer import ParseError, DotLexer |
26 | 26 |
|
27 | 27 |
from ..ui.colours import brewer_colors |
28 |
-from ..ui.pen import (Pen, BOLD, ITALIC, UNDERLINE, SUPERSCRIPT, |
|
29 |
- SUBSCRIPT, STRIKE_THROUGH, OVERLINE) |
|
30 |
-from ..ui.elements import (TextShape, ImageShape, EllipseShape, |
|
31 |
- PolygonShape, LineShape, BezierShape, |
|
32 |
- CompoundShape, Url, Jump, Element, |
|
33 |
- Node, Edge, Graph) |
|
28 |
+from ..ui.pen import Pen |
|
29 |
+from ..ui import elements |
|
34 | 30 |
|
35 | 31 |
|
36 | 32 |
EOF = -1 |
... | ... |
@@ -298,42 +294,42 @@ class XDotAttrParser: |
298 | 294 |
self.pen.fontname = name |
299 | 295 |
|
300 | 296 |
def handle_font_characteristics(self, flags): |
301 |
- self.pen.bold = bool(flags & BOLD) |
|
302 |
- self.pen.italic = bool(flags & ITALIC) |
|
303 |
- self.pen.underline = bool(flags & UNDERLINE) |
|
304 |
- self.pen.superscript = bool(flags & SUPERSCRIPT) |
|
305 |
- self.pen.subscript = bool(flags & SUBSCRIPT) |
|
306 |
- self.pen.strikethrough = bool(flags & STRIKE_THROUGH) |
|
307 |
- self.pen.overline = bool(flags & OVERLINE) |
|
297 |
+ self.pen.bold = bool(flags & Pen.BOLD) |
|
298 |
+ self.pen.italic = bool(flags & Pen.ITALIC) |
|
299 |
+ self.pen.underline = bool(flags & Pen.UNDERLINE) |
|
300 |
+ self.pen.superscript = bool(flags & Pen.SUPERSCRIPT) |
|
301 |
+ self.pen.subscript = bool(flags & Pen.SUBSCRIPT) |
|
302 |
+ self.pen.strikethrough = bool(flags & Pen.STRIKE_THROUGH) |
|
303 |
+ self.pen.overline = bool(flags & Pen.OVERLINE) |
|
308 | 304 |
if self.pen.overline: |
309 | 305 |
sys.stderr.write('warning: overlined text not supported yet\n') |
310 | 306 |
|
311 | 307 |
def handle_text(self, x, y, j, w, t): |
312 |
- self.shapes.append(TextShape(self.pen, x, y, j, w, t)) |
|
308 |
+ self.shapes.append(elements.TextShape(self.pen, x, y, j, w, t)) |
|
313 | 309 |
|
314 | 310 |
def handle_ellipse(self, x0, y0, w, h, filled=False): |
315 | 311 |
if filled: |
316 | 312 |
# xdot uses this to mean "draw a filled shape with an outline" |
317 |
- self.shapes.append(EllipseShape(self.pen, x0, y0, w, h, filled=True)) |
|
318 |
- self.shapes.append(EllipseShape(self.pen, x0, y0, w, h)) |
|
313 |
+ self.shapes.append(elements.EllipseShape(self.pen, x0, y0, w, h, filled=True)) |
|
314 |
+ self.shapes.append(elements.EllipseShape(self.pen, x0, y0, w, h)) |
|
319 | 315 |
|
320 | 316 |
def handle_image(self, x0, y0, w, h, path): |
321 |
- self.shapes.append(ImageShape(self.pen, x0, y0, w, h, path)) |
|
317 |
+ self.shapes.append(elements.ImageShape(self.pen, x0, y0, w, h, path)) |
|
322 | 318 |
|
323 | 319 |
def handle_line(self, points): |
324 |
- self.shapes.append(LineShape(self.pen, points)) |
|
320 |
+ self.shapes.append(elements.LineShape(self.pen, points)) |
|
325 | 321 |
|
326 | 322 |
def handle_bezier(self, points, filled=False): |
327 | 323 |
if filled: |
328 | 324 |
# xdot uses this to mean "draw a filled shape with an outline" |
329 |
- self.shapes.append(BezierShape(self.pen, points, filled=True)) |
|
330 |
- self.shapes.append(BezierShape(self.pen, points)) |
|
325 |
+ self.shapes.append(elements.BezierShape(self.pen, points, filled=True)) |
|
326 |
+ self.shapes.append(elements.BezierShape(self.pen, points)) |
|
331 | 327 |
|
332 | 328 |
def handle_polygon(self, points, filled=False): |
333 | 329 |
if filled: |
334 | 330 |
# xdot uses this to mean "draw a filled shape with an outline" |
335 |
- self.shapes.append(PolygonShape(self.pen, points, filled=True)) |
|
336 |
- self.shapes.append(PolygonShape(self.pen, points)) |
|
331 |
+ self.shapes.append(elements.PolygonShape(self.pen, points, filled=True)) |
|
332 |
+ self.shapes.append(elements.PolygonShape(self.pen, points)) |
|
337 | 333 |
|
338 | 334 |
|
339 | 335 |
class DotParser(Parser): |
... | ... |
@@ -527,7 +523,7 @@ class XDotParser(DotParser): |
527 | 523 |
parser = XDotAttrParser(self, attrs[attr]) |
528 | 524 |
shapes.extend(parser.parse()) |
529 | 525 |
url = attrs.get('URL', None) |
530 |
- node = Node(id, x, y, w, h, shapes, url) |
|
526 |
+ node = elements.Node(id, x, y, w, h, shapes, url) |
|
531 | 527 |
self.node_by_name[id] = node |
532 | 528 |
if shapes: |
533 | 529 |
self.nodes.append(node) |
... | ... |
@@ -547,11 +543,12 @@ class XDotParser(DotParser): |
547 | 543 |
if shapes: |
548 | 544 |
src = self.node_by_name[src_id] |
549 | 545 |
dst = self.node_by_name[dst_id] |
550 |
- self.edges.append(Edge(src, dst, points, shapes)) |
|
546 |
+ self.edges.append(elements.Edge(src, dst, points, shapes)) |
|
551 | 547 |
|
552 | 548 |
def parse(self): |
553 | 549 |
DotParser.parse(self) |
554 |
- return Graph(self.width, self.height, self.shapes, self.nodes, self.edges) |
|
550 |
+ return elements.Graph(self.width, self.height, self.shapes, |
|
551 |
+ self.nodes, self.edges) |
|
555 | 552 |
|
556 | 553 |
def parse_node_pos(self, pos): |
557 | 554 |
x, y = pos.split(b",") |
... | ... |
@@ -13,18 +13,19 @@ |
13 | 13 |
# You should have received a copy of the GNU Lesser General Public License |
14 | 14 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | 15 |
# |
16 |
-BOLD = 1 |
|
17 |
-ITALIC = 2 |
|
18 |
-UNDERLINE = 4 |
|
19 |
-SUPERSCRIPT = 8 |
|
20 |
-SUBSCRIPT = 16 |
|
21 |
-STRIKE_THROUGH = 32 |
|
22 |
-OVERLINE = 64 |
|
23 | 16 |
|
24 | 17 |
|
25 | 18 |
class Pen: |
26 | 19 |
"""Store pen attributes.""" |
27 | 20 |
|
21 |
+ BOLD = 1 |
|
22 |
+ ITALIC = 2 |
|
23 |
+ UNDERLINE = 4 |
|
24 |
+ SUPERSCRIPT = 8 |
|
25 |
+ SUBSCRIPT = 16 |
|
26 |
+ STRIKE_THROUGH = 32 |
|
27 |
+ OVERLINE = 64 |
|
28 |
+ |
|
28 | 29 |
def __init__(self): |
29 | 30 |
# set default attributes |
30 | 31 |
self.color = (0.0, 0.0, 0.0, 1.0) |
... | ... |
@@ -39,8 +39,8 @@ from gi.repository import Gdk |
39 | 39 |
from . import actions |
40 | 40 |
from ..dot.lexer import ParseError |
41 | 41 |
from ..dot.parser import XDotParser |
42 |
-from .animation import NoAnimation, ZoomToAnimation |
|
43 |
-from .actions import NullAction, PanAction, ZoomAction, ZoomAreaAction |
|
42 |
+from . import animation |
|
43 |
+from . import actions |
|
44 | 44 |
from .elements import Graph |
45 | 45 |
|
46 | 46 |
|
... | ... |
@@ -84,8 +84,8 @@ class DotWidget(Gtk.DrawingArea): |
84 | 84 |
self.x, self.y = 0.0, 0.0 |
85 | 85 |
self.zoom_ratio = 1.0 |
86 | 86 |
self.zoom_to_fit_on_resize = False |
87 |
- self.animation = NoAnimation(self) |
|
88 |
- self.drag_action = NullAction(self) |
|
87 |
+ self.animation = animation.NoAnimation(self) |
|
88 |
+ self.drag_action = actions.NullAction(self) |
|
89 | 89 |
self.presstime = None |
90 | 90 |
self.highlight = None |
91 | 91 |
self.highlight_search = False |
... | ... |
@@ -298,7 +298,7 @@ class DotWidget(Gtk.DrawingArea): |
298 | 298 |
return True |
299 | 299 |
if event.keyval == Gdk.KEY_Escape: |
300 | 300 |
self.drag_action.abort() |
301 |
- self.drag_action = NullAction(self) |
|
301 |
+ self.drag_action = actions.NullAction(self) |
|
302 | 302 |
return True |
303 | 303 |
if event.keyval == Gdk.KEY_r: |
304 | 304 |
self.reload() |
... | ... |
@@ -351,12 +351,12 @@ class DotWidget(Gtk.DrawingArea): |
351 | 351 |
if event.button in (1, 2): # left or middle button |
352 | 352 |
modifiers = Gtk.accelerator_get_default_mod_mask() |
353 | 353 |
if state & modifiers == Gdk.ModifierType.CONTROL_MASK: |
354 |
- return ZoomAction |
|
354 |
+ return actions.ZoomAction |
|
355 | 355 |
elif state & modifiers == Gdk.ModifierType.SHIFT_MASK: |
356 |
- return ZoomAreaAction |
|
356 |
+ return actions.ZoomAreaAction |
|
357 | 357 |
else: |
358 |
- return PanAction |
|
359 |
- return NullAction |
|
358 |
+ return actions.PanAction |
|
359 |
+ return actions.NullAction |
|
360 | 360 |
|
361 | 361 |
def on_area_button_press(self, area, event): |
362 | 362 |
self.animation.stop() |
... | ... |
@@ -389,7 +389,7 @@ class DotWidget(Gtk.DrawingArea): |
389 | 389 |
|
390 | 390 |
def on_area_button_release(self, area, event): |
391 | 391 |
self.drag_action.on_button_release(event) |
392 |
- self.drag_action = NullAction(self) |
|
392 |
+ self.drag_action = actions.NullAction(self) |
|
393 | 393 |
x, y = int(event.x), int(event.y) |
394 | 394 |
if self.is_click(event): |
395 | 395 |
el = self.get_element(x, y) |
... | ... |
@@ -431,7 +431,7 @@ class DotWidget(Gtk.DrawingArea): |
431 | 431 |
self.zoom_to_fit() |
432 | 432 |
|
433 | 433 |
def animate_to(self, x, y): |
434 |
- self.animation = ZoomToAnimation(self, x, y) |
|
434 |
+ self.animation = animation.ZoomToAnimation(self, x, y) |
|
435 | 435 |
self.animation.start() |
436 | 436 |
|
437 | 437 |
def window2graph(self, x, y): |