This file is indexed.

/usr/share/pyshared/blockdiag/noderenderer/roundedbox.py is in python-blockdiag 1.3.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# -*- coding: utf-8 -*-
#  Copyright 2011 Takeshi KOMIYA
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

from blockdiag.noderenderer import NodeShape
from blockdiag.noderenderer import install_renderer
from blockdiag.utils import XY, Box
from blockdiag.imagedraw.simplesvg import pathdata


class RoundedBox(NodeShape):
    def render_shape(self, drawer, _, **kwargs):
        # draw background
        self.render_shape_background(drawer, **kwargs)

        # draw outline
        box = self.metrics.cell(self.node).box
        if not kwargs.get('shadow'):
            if self.node.background:
                drawer.image(box, self.node.background)

            self.render_shape_outline(drawer, **kwargs)

    def render_shape_outline(self, drawer, **kwargs):
        m = self.metrics.cell(self.node)
        r = self.metrics.cellsize
        box = m.box

        lines = [(XY(box[0] + r, box[1]), XY(box[2] - r, box[1])),
                 (XY(box[2], box[1] + r), XY(box[2], box[3] - r)),
                 (XY(box[0] + r, box[3]), XY(box[2] - r, box[3])),
                 (XY(box[0], box[1] + r), XY(box[0], box[3] - r))]
        for line in lines:
            drawer.line(line, fill=self.node.linecolor, style=self.node.style)

        r2 = r * 2
        arcs = [(Box(box[0], box[1], box[0] + r2, box[1] + r2), 180, 270),
                (Box(box[2] - r2, box[1], box[2], box[1] + r2), 270, 360),
                (Box(box[2] - r2, box[3] - r2, box[2], box[3]), 0, 90),
                (Box(box[0], box[3] - r2, box[0] + r2, box[3]), 90, 180)]
        for arc in arcs:
            drawer.arc(arc[0], arc[1], arc[2],
                       fill=self.node.linecolor, style=self.node.style)

    def render_shape_background(self, drawer, **kwargs):
        fill = kwargs.get('fill')

        m = self.metrics.cell(self.node)
        r = self.metrics.cellsize

        box = m.box
        ellipses = [Box(box[0], box[1], box[0] + r * 2, box[1] + r * 2),
                    Box(box[2] - r * 2, box[1], box[2], box[1] + r * 2),
                    Box(box[0], box[3] - r * 2, box[0] + r * 2, box[3]),
                    Box(box[2] - r * 2, box[3] - r * 2, box[2], box[3])]

        for e in ellipses:
            if kwargs.get('shadow'):
                e = self.shift_shadow(e)
                if kwargs.get('style') == 'blur':
                    drawer.ellipse(e, fill=fill, outline=fill,
                                   filter='transp-blur')
                else:
                    drawer.ellipse(e, fill=fill, outline=fill)
            else:
                drawer.ellipse(e, fill=self.node.color,
                               outline=self.node.color)

        rects = [Box(box[0] + r, box[1], box[2] - r, box[3]),
                 Box(box[0], box[1] + r, box[2], box[3] - r)]
        for rect in rects:
            if kwargs.get('shadow'):
                rect = self.shift_shadow(rect)
                if kwargs.get('style') == 'blur':
                    drawer.rectangle(rect, fill=fill, outline=fill,
                                     filter='transp-blur')
                else:
                    drawer.rectangle(rect, fill=fill, outline=fill)
            else:
                drawer.rectangle(rect, fill=self.node.color,
                                 outline=self.node.color)

    def render_vector_shape(self, drawer, _, **kwargs):
        fill = kwargs.get('fill')

        # create pathdata
        box = self.metrics.cell(self.node).box
        r = self.metrics.cellsize

        if kwargs.get('shadow'):
            box = self.shift_shadow(box)

        path = pathdata(box[0] + r, box[1])
        path.line(box[2] - r, box[1])
        path.ellarc(r, r, 0, 0, 1, box[2], box[1] + r)
        path.line(box[2], box[3] - r)
        path.ellarc(r, r, 0, 0, 1, box[2] - r, box[3])
        path.line(box[0] + r, box[3])
        path.ellarc(r, r, 0, 0, 1, box[0], box[3] - r)
        path.line(box[0], box[1] + r)
        path.ellarc(r, r, 0, 0, 1, box[0] + r, box[1])

        # draw outline
        if kwargs.get('shadow'):
            if kwargs.get('style') == 'blur':
                drawer.path(path, fill=fill, outline=fill,
                            filter='transp-blur')
            else:
                drawer.path(path, fill=fill, outline=fill)
        elif self.node.background:
            drawer.path(path, fill=self.node.color, outline=self.node.color)
            drawer.image(self.textbox, self.node.background)
            drawer.path(path, fill="none",
                        outline=self.node.linecolor, style=self.node.style)
        else:
            drawer.path(path, fill=self.node.color,
                        outline=self.node.linecolor, style=self.node.style)


def setup(self):
    install_renderer('roundedbox', RoundedBox)