Upload the contribution of vstf as bottleneck network framework.
[bottlenecks.git] / vstf / vstf / controller / reporters / report / pdf / styles.py
1 #!/usr/bin/python
2 # -*- coding: utf8 -*-
3 from reportlab.lib.styles import PropertySet
4 from reportlab.lib.pagesizes import A4
5 from reportlab.lib import colors
6 from reportlab.lib.styles import ParagraphStyle
7 from reportlab.lib.enums import TA_LEFT
8
9
10 class TemplateStyle(PropertySet):
11     defaults = dict(
12         page_height=A4[1],
13         page_wight=A4[0],
14         page_left=78,
15         page_top=60,
16         page_bottom=70,
17         page_right=78,
18         title_size=16,
19         title_leading=1.25,
20         title_font='Courier-Bold',
21         body_size=10,
22         body_leading=0.8,
23         body_font='Courier',
24         line_width=1,
25         logo_width=131.2,
26         logo_height=127.7
27     )
28
29
30 class ImageStyle(PropertySet):
31     defaults = dict(
32         image_height=165,
33         image_width=175,
34         image_hAlign='CENTRE',  # LEFT,CENTRE or RIGHT
35         image_vAlign='MIDDLE'  # BOTTOM,MIDDLE or TOP
36     )
37
38
39 class TableStyle(PropertySet):
40     defaults = dict(
41         table_hAlign='CENTRE',  # LEFT,CENTRE or RIGHT
42         table_vAlign='MIDDLE',  # BOTTOM,MIDDLE or TOP
43         table_colWidths=None,
44         table_rowHeights=None
45     )
46
47
48 class LinePlotStyle(PropertySet):
49     defaults = dict(
50         width=430,
51         height=400,
52         left=30,
53         bottom=20,
54         strokeColor=colors.black,
55         strokeWidth=1,
56         format=('%4.2f', '%4.0f', '%3.1f'),
57         labelsfont=7,
58         linestyle=[
59             (colors.red, 'Circle', 1.5),
60             (colors.blue, 'Diamond', 1.5),
61             (colors.gold, 'Square', 1.5),
62             (colors.green, 'Triangle', 1.5),
63             (colors.pink, 'FilledCircle', 1.5),
64             (colors.lightblue, 'FilledDiamond', 1.5),
65             (colors.lightgreen, 'FilledTriangle', 1.5)
66         ]
67     )
68
69
70 class LineChartStyle(PropertySet):
71     defaults = dict(
72         width=430,
73         height=400,
74         left=30,
75         bottom=20,
76         strokeColor=colors.lightgrey,
77         strokeWidth=1,
78         format=('%4.2f', '%3.1f'),
79         labelsfont=8,
80         linestyle=[
81             (colors.red, 'Circle', 1.5),
82             (colors.blue, 'Diamond', 1.5),
83             (colors.gold, 'Square', 1.5),
84             (colors.green, 'Triangle', 1.5),
85             (colors.pink, 'FilledCircle', 1.5),
86             (colors.lightblue, 'FilledDiamond', 1.5),
87             (colors.lightgreen, 'FilledTriangle', 1.5)
88         ]
89     )
90
91
92 class BarChartStyle(PropertySet):
93     defaults = dict(
94         width=430,
95         height=135,
96         left=30,
97         bottom=50,
98         top=0,
99         right=30,
100         groupSpacing=32,
101         barSpacing=4,
102         tick=3,
103         strokeColor=colors.lightgrey,
104         strokeWidth=1,
105         pillarstyle={
106             "loss": (colors.lightgreen, '%4.2f'),
107             "latency": (colors.indianred, '%4.1f'),
108             "fastlink": (colors.pink, '%4.1f'),
109             "l2switch": (colors.lightblue, '%4.1f'),
110             "kernel rdp": (colors.lightgreen, '%4.1f'),
111         },
112         background=colors.lightgrey,
113         labelsfont=6,
114     )
115
116
117 ts_left = TableStyle(
118     name='left',
119     table_hAlign='LEFT',  # LEFT,CENTRE or RIGHT
120     table_vAlign='BOTTOM',  # BOTTOM,MIDDLE or TOP
121     table_colWidths=None,
122     table_rowHeights=None
123 )
124
125 is_default = ImageStyle(name='default')
126 is_traffic = ImageStyle(name='traffic',
127                         image_height=150,
128                         image_width=360,
129                         image_hAlign='CENTRE')
130
131 ts_default = TableStyle(name='default')
132 lps_default = LinePlotStyle(name='default')
133 lcs_default = LineChartStyle(name='default')
134 bcs_default = BarChartStyle(name='default')
135 ps_head_lv1 = ParagraphStyle(name='ps_head_lv1',
136                              fontName='Courier-Bold',
137                              alignment=TA_LEFT,  # TA_CENTRE,
138                              fontSize=13,
139                              leading=22,
140                              leftIndent=0)
141
142 ps_head_lv2 = ParagraphStyle(name='ps_head_lv2',
143                              fontName='Courier',
144                              fontSize=12,
145                              leading=20,
146                              leftIndent=16)
147
148 ps_head_lv3 = ParagraphStyle(name='ps_head_lv3',
149                              fontSize=11,
150                              fontName='Courier',
151                              leading=20,
152                              leftIndent=16)
153
154 ps_head_lv4 = ParagraphStyle(name='ps_head_lv4',
155                              fontSize=13,
156                              fontName='Courier-Bold',
157                              leading=22,
158                              leftIndent=0)
159
160 ps_head_lv5 = ParagraphStyle(name='ps_head_lv5',
161                              fontSize=12,
162                              fontName='Courier',
163                              leading=20,
164                              leftIndent=16)
165
166 ps_head_lv6 = ParagraphStyle(name='ps_head_lv6',
167                              fontSize=11,
168                              fontName='Courier',
169                              leading=20,
170                              leftIndent=16)
171
172 ps_head_lv7 = ParagraphStyle(name='ps_head_lv7',
173                              fontSize=11,
174                              fontName='Courier',
175                              leading=18,
176                              leftIndent=0)
177
178 ps_head_lv8 = ParagraphStyle(name='ps_head_lv8',
179                              fontSize=11,
180                              fontName='Courier',
181                              leading=18,
182                              leftIndent=16)
183
184 ps_head_lv9 = ParagraphStyle(name='ps_head_lv9',
185                              fontSize=11,
186                              fontName='Courier',
187                              leading=18,
188                              leftIndent=32)
189
190 ps_body = ParagraphStyle(name='ps_body',
191                          fontSize=11,
192                          fontName='Courier',
193                          leading=18,
194                          leftIndent=32)
195
196 ps_space = ParagraphStyle(name='ps_space',
197                           fontSize=5,
198                           leading=5)