[MERGE] Remove the embedded pychart library, and use the online version
[odoo/odoo.git] /
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2000-2005 by Yasushi Saito (yasushi.saito@gmail.com)
4
5 # Jockey is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2, or (at your option) any
8 # later version.
9 #
10 # Jockey is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13 # for more details.
14 #
15 import fill_style
16 import line_style
17 import copy
18
19 def _draw_zap(can, p1, p2, style, pat):
20     x = copy.deepcopy(p1)
21     x.extend(p2)
22     can.polygon(None, pat, x)
23     can.lines(style, p1)
24     can.lines(style, p2)
25     
26
27 def zap_horizontally(can, style, pat, x1, y1, x2, y2, xsize, ysize):
28     """Draw a horizontal "zapping" symbol on the canvas that shows
29     that a graph is ripped in the middle.
30
31     Parameter <fill_style> specifies the style for the zig-zag lines.
32     PAT specifies the pattern with which the area is filled.
33     The symbol is drawn in the rectangle (<x1>, <y1>) - (<x2>, <y2>).
34     Each "zigzag" has the width <xsize>, height <ysize>."""
35
36     assert isinstance(style, line_style.T)
37     assert isinstance(pat, fill_style.T)
38
39     points = []
40     points2 = []
41     x = x1
42     y = y1
43     while x < x2:
44         points.append((x, y))
45         points2.append((x, y + (y2-y1)))
46         x += xsize
47         if y == y1:
48             y += ysize
49         else:
50             y -= ysize
51
52     points2.reverse()
53     _draw_zap(can, points, points2, style, pat)
54
55 def zap_vertically(can, style, pat, x1, y1, x2, y2, xsize, ysize):
56     """Draw a vertical "zapping" symbol on the canvas that shows
57     that a graph is ripped in the middle.
58
59     Parameter <fill_style> specifies the style for the zig-zag lines.
60     PAT specifies the pattern with which the area is filled.
61     The symbol is drawn in the rectangle (<x1>, <y1>) - (<x2>, <y2>).
62     Each "zigzag" has the width <xsize>, height <ysize>."""
63     
64     points = []
65     points2 = []
66     x = x1
67     y = y1
68     while y < y2:
69         points.append((x, y))
70         points2.append((x + (x2-x1), y))
71         y += ysize
72         if x == x1:
73             x += xsize
74         else:
75             x -= xsize
76
77     points2.reverse()
78     _draw_zap(can, points, points2, style, pat)
79