Create a script to generate a Topology
[oam.git] / code / network-topology-instance-generator / model / python / svg / node_edge_point.py
1 # Copyright 2022 highstreet technologies GmbH
2 #
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
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
15 #!/usr/bin/python
16 """
17 Module containing a class representing an SVG Element as Connection Node Edge Point
18 """
19 from lxml import etree
20 from model.python.svg.connection_edge_point import ConnectionEdgePoint
21 from model.python.svg.svg import Svg
22
23
24 class NodeEdgePoint(Svg):
25     """
26     Class representing an SVG Element object as Connection Node Edge Point
27     """
28     def width(self) -> int:
29         """
30         Getter for width of the SVG Element
31         :return Width in pixel
32         """
33         self.__width = ConnectionEdgePoint.width(self) * len(self.tapi_object().connection_edge_points())
34         return self.__width
35
36     # overwrite
37     def svg_main(self) -> etree.Element:
38         """
39         Mothod generating the main SVG Element shaping the TAPI object
40         :return SVG Element as main representations for the TAPI object
41         """
42         main = super().svg_main()
43         main = etree.Element("rect")
44         main.attrib["x"] = str(int(self.center_x() - self.width()/2))
45         main.attrib["y"] = str(int(self.center_y() - self.height()/2))
46         main.attrib["width"] = str(self.width())
47         main.attrib["height"] = str(self.height())
48         main.attrib["rx"] = str(int(self.FONTSIZE / 2))
49         main.attrib['class'] = " ".join(
50             [self.type_name(), self.tapi_object().name().lower()])
51         return main