-
Notifications
You must be signed in to change notification settings - Fork 0
/
rendering_library.py
40 lines (34 loc) · 1.07 KB
/
rendering_library.py
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
from klighd_types.klighd.SKGraphSchema import *
def addRectangle(element):
rectangle = KRectangle()
if (element.data == None):
element.data = []
element.data.append(rectangle)
# hardcode ID for now. TODO: needs to be hierarchical once we have real hiearchical renderings.
setId(rectangle, "R0")
return rectangle
def addPolyline(element):
polyline = KPolyline()
if (element.data == None):
element.data = []
element.data.append(polyline)
setId(polyline, "R0")
return polyline
def addText(element, theText):
text = KText()
text.text = theText
if (element.data == None):
element.data = []
element.data.append(text)
setId(text, "R0")
return text
def addAction(element, action):
if (element.actions == None):
element.actions = []
element.actions.append(action)
def setId(element, id):
addProperty(element, "klighd.lsp.rendering.id", id)
def addProperty(element, key, value):
if (element.properties == None):
element.properties = {}
element.properties[key] = value