/usr/lib/python2.7/dist-packages/actdiag/metrics.py is in python-actdiag 0.5.3-5.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 | # -*- 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 __future__ import division
from collections import namedtuple
import blockdiag.metrics
from blockdiag.utils import Box, XY
from actdiag import elements
class DiagramMetrics(blockdiag.metrics.DiagramMetrics):
def __init__(self, diagram, **kwargs):
super(DiagramMetrics, self).__init__(diagram, **kwargs)
if diagram.page_padding is None:
if diagram.orientation == 'landscape':
padding = self.node_width + self.span_width
self.page_padding = [0, 0, 0, padding]
else:
padding = self.node_height + self.span_height
self.page_padding = [padding, 0, 0, 0]
def pagesize(self, width=None, height=None):
if width:
self.colwidth = width
else:
width = self.colwidth
if height:
self.colheight = height
else:
height = self.colheight
return super(DiagramMetrics, self).pagesize(width, height)
def frame(self, lanes):
dummy = elements.DiagramNode(None)
dummy.xy = XY(0, 0)
dummy.colwidth = self.colwidth
dummy.colheight = self.colheight
cell = self.cell(dummy, use_padding=False)
headerbox = Box(cell.topleft.x - self.span_width // 2,
(cell.topleft.y - self.node_height -
self.span_height - 2),
cell.topright.x + self.span_width // 2,
cell.topright.y - self.span_height // 2)
outline = Box(headerbox[0], headerbox[1], headerbox[2],
cell.bottom.y + self.span_height // 2)
separators = [(XY(headerbox[0], headerbox[3]),
XY(headerbox[2], headerbox[3]))]
for lane in lanes[:-1]:
x = lane.xy.x + lane.colwidth + 1
m = self.cell(lane, use_padding=False)
span_width = self.spreadsheet.span_width[x] // 2
x1 = m.right.x + span_width
xy = (XY(x1, outline[1]), XY(x1, outline[3]))
separators.append(xy)
Frame = namedtuple('Frame', 'headerbox outline separators')
return Frame(headerbox, outline, separators)
def lane_textbox(self, lane):
headerbox = self.frame([]).headerbox
m = self.cell(lane, use_padding=False)
x1 = m.left.x
x2 = m.right.x
return Box(x1, headerbox[1], x2, headerbox[3])
def lane_headerbox(self, lane):
headerbox = self.frame([]).headerbox
m = self.cell(lane)
x1 = m.left.x - self.spreadsheet.span_width[lane.xy.x] // 2
x2 = m.right.x + self.spreadsheet.span_width[lane.xy.x + 1] // 2
return Box(x1, headerbox[1], x2, headerbox[3])
|