1# -*- coding: utf-8 -*-2# Copyright 2011 Takeshi KOMIYA3#4# Licensed under the Apache License, Version 2.0 (the "License");5# you may not use this file except in compliance with the License.6# You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS,12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13# See the License for the specific language governing permissions and14# limitations under the License.1516from blockdiag.noderenderer import install_renderer17from blockdiag.noderenderer.base import NodeShape18from blockdiag.utils import XY, Box192021class BeginPoint(NodeShape):22 def __init__(self, node, metrics=None):23 super(BeginPoint, self).__init__(node, metrics)2425 m = metrics.cell(node)2627 self.radius = metrics.cellsize28 self.center = m.center29 self.textbox = Box(m.top.x, m.top.y, m.right.x, m.right.y)30 self.textalign = 'left'31 self.connectors = [XY(self.center.x, self.center.y - self.radius),32 XY(self.center.x + self.radius, self.center.y),33 XY(self.center.x, self.center.y + self.radius),34 XY(self.center.x - self.radius, self.center.y)]3536 def render_shape(self, drawer, _, **kwargs):37 fill = kwargs.get('fill')3839 # draw outline40 r = self.radius41 box = Box(self.center.x - r, self.center.y - r,42 self.center.x + r, self.center.y + r)43 if kwargs.get('shadow'):44 box = self.shift_shadow(box)45 if kwargs.get('style') == 'blur':46 drawer.ellipse(box, fill=fill, outline=fill,47 filter='transp-blur')48 else:49 drawer.ellipse(box, fill=fill, outline=fill)50 else:51 if self.node.color == self.node.basecolor:52 color = self.node.linecolor53 else:54 color = self.node.color5556 drawer.ellipse(box, fill=color, outline=self.node.linecolor,57 style=self.node.style)585960def setup(self):61 install_renderer('beginpoint', BeginPoint)