4 Story Decorator contains ImageStory, HeaderStory, PageBreakStory,
5 TableStory, LinePlotStory, TitleStory, ParagraphStory
9 from reportlab.platypus import PageBreak
10 from reportlab.lib import colors
11 from reportlab.platypus.tableofcontents import TableOfContents
22 return self._storylist
25 class StoryDecorator(Story):
26 def __init__(self, story, data=None, style=None):
33 # print self._story.storylist
36 return self._story.storylist
39 raise NotImplementedError("abstract StoryDecorator")
42 class ImageStory(StoryDecorator):
45 for filename in self._data:
46 if os.path.exists(filename) == False:
47 print "not find %s" % filename
49 if 'Traffic-types' in filename:
51 image_height = style.image_height
52 image_width = style.image_width
53 image_hAlign = style.image_hAlign
54 image_vAlign = style.image_vAlign
55 self._story.storylist.append(
56 eImage(filename, image_width, image_height, hAlign=image_hAlign, vAlign=image_vAlign))
59 image_height = style.image_height
60 image_width = style.image_width
61 image_hAlign = style.image_hAlign
62 image_vAlign = style.image_vAlign
63 # self._story.storylist.append(eGraphicsTable([[' ' * 5, eImage(filename, image_width, image_height, hAlign=image_hAlign, vAlign=image_vAlign)]], ts_left).table)
64 self._story.storylist.append(
65 eImage(filename, image_width, image_height, hAlign=image_hAlign, vAlign=image_vAlign))
68 class HeaderStory(StoryDecorator):
71 self._story.storylist.append(PageBreak())
74 class PageBreakStory(StoryDecorator):
76 print "PageBreak story"
77 self._story.storylist.append(PageBreak())
80 class TableOfContentsStory(StoryDecorator):
82 print "TableOfContents story"
83 self._data = [" ", " ", "Table Of Contents", ""]
85 self._story.storylist.append(eParagraph(self._data, style).para)
86 toc = TableOfContents()
87 toc.levelStyles = [ps_head_lv7, ps_head_lv8, ps_head_lv9]
88 self._story.storylist.append(toc)
91 class uTableStory(StoryDecorator):
98 self._story.storylist.append(eCommonTable(self._data, style).table)
101 class TableStory(StoryDecorator):
105 self._story.storylist.append(eDataTable(self._data, style).table)
108 class SpaceStory(StoryDecorator):
111 self._story.storylist.append(eParagraph([" ", " "], style).para)
114 class cTableStory(StoryDecorator):
119 self._story.storylist.append(eConfigTable(self._data, style).table)
120 elif self._style == 1:
121 self._story.storylist.append(eOptionsTable(self._data, style).table)
122 elif self._style == 2:
123 self._story.storylist.append(eProfileTable(self._data, style).table)
124 elif self._style == 3:
125 self._story.storylist.append(eSummaryTable(self._data, style).table)
126 elif self._style == 4:
127 self._story.storylist.append(eScenarioTable(self._data, style).table)
128 elif self._style == 5:
129 self._story.storylist.append(eGitInfoTable(self._data, style).table)
132 class LinePlotStory(StoryDecorator):
139 data = eGraphicsTable([[eLinePlot(self._data, style).draw]]).table
141 self._story.storylist.append(data)
144 class LineChartStory(StoryDecorator):
146 print "LineChartStory: "
151 data = eGraphicsTable([[eHorizontalLineChart(self._data, style).draw]]).table
153 self._story.storylist.append(data)
156 class BarChartStory(StoryDecorator):
158 print "BarChartStory: "
164 data = eGraphicsTable([[eBarChartColumn(self._data, style).draw]]).table
166 self._story.storylist.append(data)
169 class ParagraphStory(StoryDecorator):
171 print "Paragraph Story"
176 data = eParagraph(self._data, style).para
178 self._story.storylist.append(data)
181 class TitleStory(StoryDecorator):
183 print "Paragraph Story"
184 if self._style - 1 in range(9):
185 style = eval("ps_head_lv" + "%d" % self._style)
191 self._story.storylist.append(eParagraph(self._data, style).para)