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 NodeShape181920class Box(NodeShape):21 def render_shape(self, drawer, _, **kwargs):22 fill = kwargs.get('fill')2324 # draw outline25 box = self.metrics.cell(self.node).box26 if kwargs.get('shadow'):27 box = self.shift_shadow(box)28 if kwargs.get('style') == 'blur':29 drawer.rectangle(box, fill=fill, outline=fill,30 filter='transp-blur')31 else:32 drawer.rectangle(box, fill=fill, outline=fill)33 elif self.node.background:34 drawer.rectangle(box, fill=self.node.color,35 outline=self.node.color)36 drawer.image(self.textbox, self.node.background)37 drawer.rectangle(box, outline=self.node.linecolor,38 style=self.node.style)39 else:40 drawer.rectangle(box, fill=self.node.color,41 outline=self.node.linecolor,42 style=self.node.style)434445def setup(self):46 install_renderer('box', Box)