Esempio n. 1
0
    def generatePage(self, title, doc):
        pg = pml.Page(doc)

        pg.add(
            pml.TextOp(title, doc.w / 2.0, self.margin, 18,
                       pml.BOLD | pml.ITALIC | pml.UNDERLINED,
                       util.ALIGN_CENTER))

        pageCnt = len(self.pages)
        mmPerPage = max(0.1, self.chartWidth / pageCnt)

        pg.add(pml.TextOp("Page:", self.chartX - 1.0, self.pageY - 5.0, 10))

        # draw backround for every other row. this needs to be done before
        # drawing the grid.
        for i in range(len(self.cinfo)):
            y = self.chartY + i * self.charY

            if (i % 2) == 1:
                pg.add(pml.PDFOp("0.93 g"))
                pg.add(pml.RectOp(self.chartX, y, self.chartWidth, self.charY))
                pg.add(pml.PDFOp("0.0 g"))

        # line width to use
        lw = 0.25

        pg.add(pml.PDFOp("0.5 G"))

        # dashed pattern
        pg.add(pml.PDFOp("[2 2] 0 d"))

        # draw grid and page markers
        for i in xrange(pageCnt):
            if (i == 0) or ((i + 1) % 10) == 0:
                x = self.chartX + i * mmPerPage
                pg.add(
                    pml.TextOp("%d" % (i + 1),
                               x,
                               self.pageY,
                               10,
                               align=util.ALIGN_CENTER))
                if i != 0:
                    pg.add(pml.genLine(x, self.chartY, 0, self.chartHeight,
                                       lw))

        pg.add(
            pml.RectOp(self.chartX, self.chartY, self.chartWidth,
                       self.chartHeight, pml.NO_FILL, lw))

        pg.add(pml.PDFOp("0.0 G"))

        # restore normal line pattern
        pg.add(pml.PDFOp("[] 0 d"))

        # legend for page content bars
        pg.add(
            pml.RectOp(self.legendX, self.legendY, self.legendWidth,
                       self.legendHeight, pml.NO_FILL, lw))

        self.drawLegend(pg, 0, 1.0, "Other", lw)
        self.drawLegend(pg, 1, 0.7, "Character", lw)
        self.drawLegend(pg, 2, 0.5, "Dialogue", lw)
        self.drawLegend(pg, 3, 0.3, "Action", lw)

        # page content bars
        for i in xrange(pageCnt):
            x = self.chartX + i * mmPerPage
            y = self.barY + self.barHeight
            pi = self.pages[i]
            tlc = pi.getTotalLineCount()

            pg.add(pml.PDFOp("0.3 g"))
            pct = util.safeDivInt(pi.getLineCount(screenplay.ACTION), tlc)
            barH = self.barHeight * pct
            pg.add(pml.RectOp(x, y - barH, mmPerPage, barH))
            y -= barH

            pg.add(pml.PDFOp("0.5 g"))
            pct = util.safeDivInt(pi.getLineCount(screenplay.DIALOGUE), tlc)
            barH = self.barHeight * pct
            pg.add(pml.RectOp(x, y - barH, mmPerPage, barH))
            y -= barH

            pg.add(pml.PDFOp("0.7 g"))
            pct = util.safeDivInt(pi.getLineCount(screenplay.CHARACTER), tlc)
            barH = self.barHeight * pct
            pg.add(pml.RectOp(x, y - barH, mmPerPage, barH))
            y -= barH

        pg.add(pml.PDFOp("0.0 g"))

        # rectangle around page content bars
        pg.add(
            pml.RectOp(self.chartX, self.barY, self.chartWidth, self.barHeight,
                       pml.NO_FILL, lw))

        for i in range(len(self.cinfo)):
            y = self.chartY + i * self.charY
            ci = self.cinfo[i]

            pg.add(
                pml.TextOp(ci.name,
                           self.margin,
                           y + self.charY / 2.0,
                           self.charFs,
                           valign=util.VALIGN_CENTER))

            for i in xrange(pageCnt):
                pi = self.pages[i]
                cnt = pi.getSpeakerLineCount(ci.name)

                if cnt > 0:
                    h = self.charY * (float(cnt) / self.sp.cfg.linesOnPage)

                    pg.add(
                        pml.RectOp(self.chartX + i * mmPerPage,
                                   y + (self.charY - h) / 2.0, mmPerPage, h))

        return pg
Esempio n. 2
0
    def generatePage(self, title, doc):
        pg = pml.Page(doc)

        pg.add(
            pml.TextOp(title, doc.w / 2.0, self.margin, 18, pml.BOLD | pml.ITALIC | pml.UNDERLINED, util.ALIGN_CENTER)
        )

        pageCnt = len(self.pages)
        mmPerPage = max(0.1, self.chartWidth / pageCnt)

        pg.add(pml.TextOp("Page:", self.chartX - 1.0, self.pageY - 5.0, 10))

        # draw backround for every other row. this needs to be done before
        # drawing the grid.
        for i in range(len(self.cinfo)):
            y = self.chartY + i * self.charY

            if (i % 2) == 1:
                pg.add(pml.PDFOp("0.93 g"))
                pg.add(pml.RectOp(self.chartX, y, self.chartWidth, self.charY))
                pg.add(pml.PDFOp("0.0 g"))

        # line width to use
        lw = 0.25

        pg.add(pml.PDFOp("0.5 G"))

        # dashed pattern
        pg.add(pml.PDFOp("[2 2] 0 d"))

        # draw grid and page markers
        for i in xrange(pageCnt):
            if (i == 0) or ((i + 1) % 10) == 0:
                x = self.chartX + i * mmPerPage
                pg.add(pml.TextOp("%d" % (i + 1), x, self.pageY, 10, align=util.ALIGN_CENTER))
                if i != 0:
                    pg.add(pml.genLine(x, self.chartY, 0, self.chartHeight, lw))

        pg.add(pml.RectOp(self.chartX, self.chartY, self.chartWidth, self.chartHeight, pml.NO_FILL, lw))

        pg.add(pml.PDFOp("0.0 G"))

        # restore normal line pattern
        pg.add(pml.PDFOp("[] 0 d"))

        # legend for page content bars
        pg.add(pml.RectOp(self.legendX, self.legendY, self.legendWidth, self.legendHeight, pml.NO_FILL, lw))

        self.drawLegend(pg, 0, 1.0, "Other", lw)
        self.drawLegend(pg, 1, 0.7, "Character", lw)
        self.drawLegend(pg, 2, 0.5, "Dialogue", lw)
        self.drawLegend(pg, 3, 0.3, "Action", lw)

        # page content bars
        for i in xrange(pageCnt):
            x = self.chartX + i * mmPerPage
            y = self.barY + self.barHeight
            pi = self.pages[i]
            tlc = pi.getTotalLineCount()

            pg.add(pml.PDFOp("0.3 g"))
            pct = util.safeDivInt(pi.getLineCount(screenplay.ACTION), tlc)
            barH = self.barHeight * pct
            pg.add(pml.RectOp(x, y - barH, mmPerPage, barH))
            y -= barH

            pg.add(pml.PDFOp("0.5 g"))
            pct = util.safeDivInt(pi.getLineCount(screenplay.DIALOGUE), tlc)
            barH = self.barHeight * pct
            pg.add(pml.RectOp(x, y - barH, mmPerPage, barH))
            y -= barH

            pg.add(pml.PDFOp("0.7 g"))
            pct = util.safeDivInt(pi.getLineCount(screenplay.CHARACTER), tlc)
            barH = self.barHeight * pct
            pg.add(pml.RectOp(x, y - barH, mmPerPage, barH))
            y -= barH

        pg.add(pml.PDFOp("0.0 g"))

        # rectangle around page content bars
        pg.add(pml.RectOp(self.chartX, self.barY, self.chartWidth, self.barHeight, pml.NO_FILL, lw))

        for i in range(len(self.cinfo)):
            y = self.chartY + i * self.charY
            ci = self.cinfo[i]

            pg.add(pml.TextOp(ci.name, self.margin, y + self.charY / 2.0, self.charFs, valign=util.VALIGN_CENTER))

            for i in xrange(pageCnt):
                pi = self.pages[i]
                cnt = pi.getSpeakerLineCount(ci.name)

                if cnt > 0:
                    h = self.charY * (float(cnt) / self.sp.cfg.linesOnPage)

                    pg.add(pml.RectOp(self.chartX + i * mmPerPage, y + (self.charY - h) / 2.0, mmPerPage, h))

        return pg
Esempio n. 3
0
    def generatePage(self, title, doc):
        pg = pml.Page(doc)

        pg.add(
            pml.TextOp(title, doc.w / 2.0, self.margin, 18,
                       pml.BOLD | pml.ITALIC | pml.UNDERLINED,
                       util.ALIGN_CENTER))

        pageCnt = len(self.pages)
        mmPerPage = max(0.1, self.chartWidth / pageCnt)

        pg.add(pml.TextOp("Page:", self.chartX - 1.0, self.pageY - 5.0, 10))

        # draw backround for every other row. this needs to be done before
        # drawing the grid.
        for i in range(len(self.cinfo)):
            y = self.chartY + i * self.charY

            if (i % 2) == 1:
                pg.add(pml.SetFillGray(0.93))
                pg.add(pml.RectOp(self.chartX, y, self.chartWidth, self.charY))
                pg.add(pml.SetFillGray(0.0))

        # line width to use
        lw = 0.25

        pg.add(pml.SetStrokeGray(0.5))

        # dashed pattern
        pg.add(pml.SetDash([2, 2], 0))

        # draw grid and page markers
        for i in xrange(pageCnt):
            if (i == 0) or ((i + 1) % 10) == 0:
                x = self.chartX + i * mmPerPage
                pg.add(
                    pml.TextOp("%d" % (i + 1),
                               x,
                               self.pageY,
                               10,
                               align=util.ALIGN_CENTER))
                if i != 0:
                    pg.add(pml.genLine(x, self.chartY, 0, self.chartHeight,
                                       lw))

        pg.add(
            pml.RectOp(self.chartX, self.chartY, self.chartWidth,
                       self.chartHeight, pml.STROKE, lw))

        pg.add(pml.SetStrokeGray(0.0))

        # restore normal line pattern
        pg.add(pml.SetDash())

        # legend for page content bars
        pg.add(
            pml.RectOp(self.legendX, self.legendY, self.legendWidth,
                       self.legendHeight, pml.STROKE, lw))

        self.drawLegend(pg, 0, 1.0, "Other", lw)
        self.drawLegend(pg, 1, 0.7, "Character", lw)
        self.drawLegend(pg, 2, 0.5, "Dialogue", lw)
        self.drawLegend(pg, 3, 0.3, "Action", lw)

        # page content bars
        for i in xrange(pageCnt):
            x = self.chartX + i * mmPerPage
            y = self.barY + self.barHeight
            page = self.pages[i]
            tlc = page.getTotalLineCount()

            if tlc <> 0:
                for greyvalue, itemType in [
                        (0.3, screenplay.ACTION),\
                        (0.5, screenplay.DIALOGUE),\
                        (0.7, screenplay.CHARACTER)]:
                    pg.add(pml.SetFillGray(greyvalue))
                    ratio = page.getLineCount(itemType) / tlc
                    barH = self.barHeight * ratio
                    pg.add(pml.RectOp(x, y - barH, mmPerPage, barH))
                    y -= barH

        pg.add(pml.SetFillGray(0.0))

        # rectangle around page content bars
        pg.add(
            pml.RectOp(self.chartX, self.barY, self.chartWidth, self.barHeight,
                       pml.STROKE, lw))

        for i, character in enumerate(self.cinfo):
            y = self.chartY + i * self.charY

            pg.add(
                pml.TextOp(character.name,
                           self.margin,
                           y + self.charY / 2.0,
                           self.charFs,
                           valign=util.VALIGN_CENTER))

            for i in xrange(pageCnt):
                page = self.pages[i]
                cnt = page.getSpeakerLineCount(character.name)

                if cnt > 0:
                    h = self.charY * (float(cnt) / self.sp.cfg.linesOnPage)

                    pg.add(
                        pml.RectOp(self.chartX + i * mmPerPage,
                                   y + (self.charY - h) / 2.0, mmPerPage, h))

        return pg
Esempio n. 4
0
    def generatePage(self, title, doc):
        pg = pml.Page(doc)

        pg.add(pml.TextOp(title, doc.w / 2.0, self.margin, 18,
            pml.BOLD | pml.ITALIC | pml.UNDERLINED, util.ALIGN_CENTER))

        pageCnt = len(self.pages)
        mmPerPage = max(0.1, self.chartWidth / pageCnt)

        pg.add(pml.TextOp("Page:", self.chartX - 1.0, self.pageY - 5.0, 10))

        # draw backround for every other row. this needs to be done before
        # drawing the grid.
        for i in range(len(self.cinfo)):
            y = self.chartY + i * self.charY

            if (i % 2) == 1:
                pg.add(pml.SetFillGray(0.93))
                pg.add(pml.RectOp(self.chartX, y, self.chartWidth,
                                  self.charY))
                pg.add(pml.SetFillGray(0.0))

        # line width to use
        lw = 0.25

        pg.add(pml.SetStrokeGray(0.5))

        # dashed pattern
        pg.add(pml.SetDash([2,2],0))

        # draw grid and page markers
        for i in xrange(pageCnt):
            if (i == 0) or ((i + 1) % 10) == 0:
                x = self.chartX + i * mmPerPage
                pg.add(pml.TextOp("%d" % (i + 1), x, self.pageY,
                                  10, align = util.ALIGN_CENTER))
                if i != 0:
                    pg.add(pml.genLine(x, self.chartY, 0, self.chartHeight,
                                        lw))


        pg.add(pml.RectOp(self.chartX, self.chartY, self.chartWidth,
                          self.chartHeight, pml.STROKE, lw))

        pg.add(pml.SetStrokeGray(0.0))

        # restore normal line pattern
        pg.add(pml.SetDash())

        # legend for page content bars
        pg.add(pml.RectOp(self.legendX, self.legendY,
            self.legendWidth, self.legendHeight, pml.STROKE, lw))

        self.drawLegend(pg, 0, 1.0, "Other", lw)
        self.drawLegend(pg, 1, 0.7, "Character", lw)
        self.drawLegend(pg, 2, 0.5, "Dialogue", lw)
        self.drawLegend(pg, 3, 0.3, "Action", lw)

        # page content bars
        for i in xrange(pageCnt):
            x = self.chartX + i * mmPerPage
            y = self.barY + self.barHeight
            page = self.pages[i]
            tlc = page.getTotalLineCount()

            if tlc <> 0:
                for greyvalue, itemType in [
                        (0.3, screenplay.ACTION),\
                        (0.5, screenplay.DIALOGUE),\
                        (0.7, screenplay.CHARACTER)]:
                    pg.add(pml.SetFillGray(greyvalue))
                    ratio = page.getLineCount(itemType) / tlc
                    barH = self.barHeight * ratio
                    pg.add(pml.RectOp(x, y - barH, mmPerPage, barH))
                    y -= barH

        pg.add(pml.SetFillGray(0.0))

        # rectangle around page content bars
        pg.add(pml.RectOp(self.chartX, self.barY, self.chartWidth,
                         self.barHeight, pml.STROKE, lw))

        for i, character in enumerate(self.cinfo):
            y = self.chartY + i * self.charY

            pg.add(pml.TextOp(character.name, self.margin, y + self.charY / 2.0,
                self.charFs, valign = util.VALIGN_CENTER))

            for i in xrange(pageCnt):
                page = self.pages[i]
                cnt = page.getSpeakerLineCount(character.name)

                if cnt > 0:
                    h = self.charY * (float(cnt) / self.sp.cfg.linesOnPage)

                    pg.add(pml.RectOp(self.chartX + i * mmPerPage,
                        y + (self.charY - h) / 2.0, mmPerPage, h))

        return pg