1 # Copyright 2022 highstreet technologies GmbH
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
17 Module containing a class representing an SVG Element as Connection Node Edge Point
19 from typing import Dict
20 from lxml import etree
21 from model.python.svg.svg import Svg
24 class ConnectionEdgePoint(Svg):
26 Class representing an SVG Element object as Connection Node Edge Point
30 def svg_main(self) -> etree.Element:
32 Mothod generating the main SVG Element shaping the TAPI object
33 :return SVG Element as main representations for the TAPI object
35 main = etree.Element("ellipse")
36 main.attrib['cx'] = str(self.center_x())
37 main.attrib['cy'] = str(self.center_y())
38 main.attrib['rx'] = str(2 * self.FONTSIZE)
39 main.attrib['ry'] = str(self.FONTSIZE)
40 main.attrib['class'] = " ".join(
41 [self.type_name(), self.tapi_object().role()])
44 def svg_label(self) -> etree.Element:
45 label = etree.Element('text')
46 label.attrib['x'] = str(self.center_x())
47 # +4px for font-size 14px (think of chars like 'gjy')
48 label.attrib['y'] = str(self.center_y() + 4)
49 label.text = self.__label_by_protocol(self.tapi_object().protocol())
52 def __label_by_protocol(self, protocol) -> str:
53 mapping: Dict[str, str] = {
62 search = protocol.split(":")[1]
64 return mapping[search]