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