|
|
@@ -10,9 +10,11 @@ Boolean function main(model : Element):
|
|
|
String attr_key
|
|
|
String group
|
|
|
String elem
|
|
|
- Integer loc
|
|
|
+ Integer loc_x
|
|
|
+ Integer loc_y
|
|
|
Integer text_loc
|
|
|
- loc = 10
|
|
|
+ loc_x = 10
|
|
|
+ loc_y = 10
|
|
|
|
|
|
Element to_remove
|
|
|
String elem_to_remove
|
|
|
@@ -41,102 +43,115 @@ Boolean function main(model : Element):
|
|
|
while (set_len(class_types) > 0):
|
|
|
class_type = set_pop(class_types)
|
|
|
|
|
|
- elements = allInstances(model, class_type)
|
|
|
-
|
|
|
- while (set_len(elements) > 0):
|
|
|
- class = set_pop(elements)
|
|
|
-
|
|
|
- Integer x
|
|
|
- Integer y
|
|
|
- x = loc
|
|
|
- y = 10
|
|
|
-
|
|
|
- // Check if there is already an associated element
|
|
|
- if (dict_in(as_to_cs, class)):
|
|
|
- // Yes, but is it still clean?
|
|
|
- Element related_groups
|
|
|
- Boolean dirty
|
|
|
- dirty = False
|
|
|
-
|
|
|
- related_groups = as_to_cs[class]
|
|
|
- while (set_len(related_groups) > 0):
|
|
|
- group = set_pop(related_groups)
|
|
|
- if (value_eq(read_attribute(model, group, "dirty"), True)):
|
|
|
- // No, so mark all as dirty
|
|
|
- dirty = True
|
|
|
- break!
|
|
|
- else:
|
|
|
- // Yes, so just ignore this!
|
|
|
- continue!
|
|
|
+ if (string_startswith(class_type, "abstract/")):
|
|
|
+ elements = allInstances(model, class_type)
|
|
|
+
|
|
|
+ while (set_len(elements) > 0):
|
|
|
+ class = set_pop(elements)
|
|
|
|
|
|
- if (bool_not(dirty)):
|
|
|
- dict_add(groups, class, group)
|
|
|
+ if (is_edge(model["model"][class])):
|
|
|
+ log("Skipping edge " + class)
|
|
|
continue!
|
|
|
- else:
|
|
|
- group = as_to_cs[class]
|
|
|
- group = set_pop(related_groups)
|
|
|
- to_remove = allAssociationDestinations(model, group, "rendered/contains")
|
|
|
- x = create_value(read_attribute(model, group, "x"))
|
|
|
- y = create_value(read_attribute(model, group, "y"))
|
|
|
-
|
|
|
- while (set_len(to_remove) > 0):
|
|
|
- elem_to_remove = set_pop(to_remove)
|
|
|
- if (read_type(model, elem_to_remove) == "rendered/Group"):
|
|
|
- set_add(to_remove, elem_to_remove)
|
|
|
+ log("Drawing " + class)
|
|
|
+
|
|
|
+ Integer x
|
|
|
+ Integer y
|
|
|
+ x = loc_x
|
|
|
+ y = loc_y
|
|
|
+
|
|
|
+ // Check if there is already an associated element
|
|
|
+ if (dict_in(as_to_cs, class)):
|
|
|
+ // Yes, but is it still clean?
|
|
|
+ Element related_groups
|
|
|
+ Boolean dirty
|
|
|
+ dirty = False
|
|
|
+
|
|
|
+ related_groups = as_to_cs[class]
|
|
|
+ while (set_len(related_groups) > 0):
|
|
|
+ group = set_pop(related_groups)
|
|
|
+ if (value_eq(read_attribute(model, group, "dirty"), True)):
|
|
|
+ // No, so mark all as dirty
|
|
|
+ dirty = True
|
|
|
+ break!
|
|
|
else:
|
|
|
- model_delete_element(model, elem_to_remove)
|
|
|
- model_delete_element(model, group)
|
|
|
-
|
|
|
- attr_keys = dict_keys(getAttributeList(model, class))
|
|
|
- text_loc = 5
|
|
|
-
|
|
|
- group = instantiate_node(model, "rendered/Group", "")
|
|
|
- instantiate_attribute(model, group, "x", x)
|
|
|
- instantiate_attribute(model, group, "y", y)
|
|
|
- instantiate_attribute(model, group, "__asid", list_read(string_split(class, "/"), 1))
|
|
|
- dict_add(groups, class, group)
|
|
|
- loc = loc + 200
|
|
|
-
|
|
|
- elem = instantiate_node(model, "rendered/Rectangle", "")
|
|
|
- instantiate_attribute(model, elem, "x", 0)
|
|
|
- instantiate_attribute(model, elem, "y", 0)
|
|
|
- instantiate_attribute(model, elem, "height", 40 + set_len(getAttributeList(model, class)) * 20)
|
|
|
- instantiate_attribute(model, elem, "width", 150)
|
|
|
- instantiate_attribute(model, elem, "lineWidth", 2)
|
|
|
- instantiate_attribute(model, elem, "lineColour", "black")
|
|
|
- instantiate_attribute(model, elem, "fillColour", "white")
|
|
|
- instantiate_link(model, "rendered/contains", "", group, elem)
|
|
|
+ // Yes, so just ignore this!
|
|
|
+ continue!
|
|
|
|
|
|
- elem = instantiate_node(model, "rendered/Text", "")
|
|
|
- instantiate_attribute(model, elem, "x", 5)
|
|
|
- instantiate_attribute(model, elem, "y", 3)
|
|
|
- instantiate_attribute(model, elem, "lineWidth", 1)
|
|
|
- instantiate_attribute(model, elem, "lineColour", "black")
|
|
|
- instantiate_attribute(model, elem, "text", string_join(class, " : " + cast_v2s(list_read(string_split(read_type(model, class), "/"), 1))))
|
|
|
- instantiate_link(model, "rendered/contains", "", group, elem)
|
|
|
+ if (bool_not(dirty)):
|
|
|
+ dict_add(groups, class, group)
|
|
|
+ continue!
|
|
|
+ else:
|
|
|
+ group = as_to_cs[class]
|
|
|
+ group = set_pop(related_groups)
|
|
|
+ to_remove = allAssociationDestinations(model, group, "rendered/contains")
|
|
|
+ x = create_value(read_attribute(model, group, "x"))
|
|
|
+ y = create_value(read_attribute(model, group, "y"))
|
|
|
+
|
|
|
+ while (set_len(to_remove) > 0):
|
|
|
+ elem_to_remove = set_pop(to_remove)
|
|
|
+ if (read_type(model, elem_to_remove) == "rendered/Group"):
|
|
|
+ set_add(to_remove, elem_to_remove)
|
|
|
+ else:
|
|
|
+ model_delete_element(model, elem_to_remove)
|
|
|
+ model_delete_element(model, group)
|
|
|
+
|
|
|
+ if (dict_in(groups, class)):
|
|
|
+ // Already rendered this, so skip
|
|
|
+ continue!
|
|
|
|
|
|
- elem = instantiate_node(model, "rendered/Line", "")
|
|
|
- instantiate_attribute(model, elem, "x", 0)
|
|
|
- instantiate_attribute(model, elem, "y", 20)
|
|
|
- instantiate_attribute(model, elem, "targetX", 150)
|
|
|
- instantiate_attribute(model, elem, "targetY", 20)
|
|
|
- instantiate_attribute(model, elem, "lineWidth", 1)
|
|
|
- instantiate_attribute(model, elem, "lineColour", "black")
|
|
|
- instantiate_attribute(model, elem, "arrow", False)
|
|
|
- instantiate_link(model, "rendered/contains", "", group, elem)
|
|
|
+ text_loc = 5
|
|
|
+
|
|
|
+ group = instantiate_node(model, "rendered/Group", "")
|
|
|
+ instantiate_attribute(model, group, "x", x)
|
|
|
+ instantiate_attribute(model, group, "y", y)
|
|
|
+ instantiate_attribute(model, group, "__asid", list_read(string_split(class, "/"), 1))
|
|
|
+ dict_add(groups, class, group)
|
|
|
+
|
|
|
+ loc_x = loc_x + 250
|
|
|
+ if (loc_x > 2000):
|
|
|
+ loc_x = 10
|
|
|
+ loc_y = loc_y + 300
|
|
|
+
|
|
|
+ elem = instantiate_node(model, "rendered/Rectangle", "")
|
|
|
+ instantiate_attribute(model, elem, "x", 0)
|
|
|
+ instantiate_attribute(model, elem, "y", 0)
|
|
|
+ instantiate_attribute(model, elem, "height", 40 + set_len(getAttributes(model, class)) * 20)
|
|
|
+ instantiate_attribute(model, elem, "width", 200)
|
|
|
+ instantiate_attribute(model, elem, "lineWidth", 2)
|
|
|
+ instantiate_attribute(model, elem, "lineColour", "black")
|
|
|
+ instantiate_attribute(model, elem, "fillColour", "white")
|
|
|
+ instantiate_link(model, "rendered/contains", "", group, elem)
|
|
|
|
|
|
- attrs = getAttributeList(model, class)
|
|
|
- attr_keys = dict_keys(attrs)
|
|
|
- while (dict_len(attr_keys) > 0):
|
|
|
- attr_key = set_pop(attr_keys)
|
|
|
elem = instantiate_node(model, "rendered/Text", "")
|
|
|
instantiate_attribute(model, elem, "x", 5)
|
|
|
- instantiate_attribute(model, elem, "y", text_loc + 20)
|
|
|
+ instantiate_attribute(model, elem, "y", 3)
|
|
|
instantiate_attribute(model, elem, "lineWidth", 1)
|
|
|
instantiate_attribute(model, elem, "lineColour", "black")
|
|
|
- instantiate_attribute(model, elem, "text", (attr_key + " = ") + cast_v2s(list_read(string_split(attrs[attr_key], "/"), 1)))
|
|
|
+ instantiate_attribute(model, elem, "text", string_join(cast_v2s(list_read(string_split(class, "/"), 1)), " : " + cast_v2s(list_read(string_split(read_type(model, class), "/"), 1))))
|
|
|
instantiate_link(model, "rendered/contains", "", group, elem)
|
|
|
- text_loc = text_loc + 15
|
|
|
+
|
|
|
+ elem = instantiate_node(model, "rendered/Line", "")
|
|
|
+ instantiate_attribute(model, elem, "x", 0)
|
|
|
+ instantiate_attribute(model, elem, "y", 20)
|
|
|
+ instantiate_attribute(model, elem, "targetX", 200)
|
|
|
+ instantiate_attribute(model, elem, "targetY", 20)
|
|
|
+ instantiate_attribute(model, elem, "lineWidth", 1)
|
|
|
+ instantiate_attribute(model, elem, "lineColour", "black")
|
|
|
+ instantiate_attribute(model, elem, "arrow", False)
|
|
|
+ instantiate_link(model, "rendered/contains", "", group, elem)
|
|
|
+
|
|
|
+ attrs = getAttributes(model, class)
|
|
|
+ attr_keys = dict_keys(attrs)
|
|
|
+ while (dict_len(attr_keys) > 0):
|
|
|
+ attr_key = set_pop(attr_keys)
|
|
|
+ elem = instantiate_node(model, "rendered/Text", "")
|
|
|
+ instantiate_attribute(model, elem, "x", 5)
|
|
|
+ instantiate_attribute(model, elem, "y", text_loc + 20)
|
|
|
+ instantiate_attribute(model, elem, "lineWidth", 1)
|
|
|
+ instantiate_attribute(model, elem, "lineColour", "black")
|
|
|
+ instantiate_attribute(model, elem, "text", (attr_key + " = ") + cast_v2s(attrs[attr_key]))
|
|
|
+ instantiate_link(model, "rendered/contains", "", group, elem)
|
|
|
+ text_loc = text_loc + 15
|
|
|
|
|
|
// Flush all associations
|
|
|
elements = allInstances(model, "rendered/ConnectingLine")
|
|
|
@@ -145,25 +160,55 @@ Boolean function main(model : Element):
|
|
|
model_delete_element(model, class)
|
|
|
|
|
|
// Rerender associations
|
|
|
- class_types = allInstances(metamodel, "Association")
|
|
|
+ Element to_render
|
|
|
+ to_render = set_create()
|
|
|
+ class_types = allInstances(metamodel, "Class")
|
|
|
while (set_len(class_types) > 0):
|
|
|
class_type = set_pop(class_types)
|
|
|
|
|
|
- elements = allInstances(model, "abstract/Association")
|
|
|
- while (set_len(elements) > 0):
|
|
|
- class = set_pop(elements)
|
|
|
-
|
|
|
- attr_keys = dict_keys(getAttributeList(model, class))
|
|
|
+ if (string_startswith(class_type, "abstract/")):
|
|
|
+ elements = allInstances(model, class_type)
|
|
|
+ while (set_len(elements) > 0):
|
|
|
+ class = set_pop(elements)
|
|
|
+ if (is_edge(model["model"][class])):
|
|
|
+ if (bool_not(set_in(to_render, class))):
|
|
|
+ set_add(to_render, class)
|
|
|
+
|
|
|
+ to_render = set_to_list(to_render)
|
|
|
+ Element delayed_elements
|
|
|
+ Integer num_to_render
|
|
|
+ delayed_elements = list_create()
|
|
|
+ while (list_len(to_render) > 0):
|
|
|
+ num_to_render = list_len(to_render)
|
|
|
+ while (list_len(to_render) > 0):
|
|
|
+ class = list_pop_final(to_render)
|
|
|
+ attr_keys = dict_keys(getAttributes(model, class))
|
|
|
+
|
|
|
+ log("Association: " + class)
|
|
|
+ log("Connects " + cast_v2s(readAssociationSource(model, class)))
|
|
|
+ log(" to " + cast_v2s(readAssociationDestination(model, class)))
|
|
|
+ if (bool_not(bool_and(dict_in(groups, readAssociationSource(model, class)), dict_in(groups, readAssociationDestination(model, class))))):
|
|
|
+ log("DELAY")
|
|
|
+ list_append(delayed_elements, class)
|
|
|
+ continue!
|
|
|
|
|
|
elem = instantiate_link(model, "rendered/ConnectingLine", "", groups[readAssociationSource(model, class)], groups[readAssociationDestination(model, class)])
|
|
|
- instantiate_attribute(model, elem, "offsetSourceX", 0)
|
|
|
- instantiate_attribute(model, elem, "offsetSourceY", 0)
|
|
|
- instantiate_attribute(model, elem, "offsetTargetX", 0)
|
|
|
- instantiate_attribute(model, elem, "offsetTargetY", 0)
|
|
|
- instantiate_attribute(model, elem, "lineWidth", 1)
|
|
|
+ dict_add(groups, class, elem)
|
|
|
+ instantiate_attribute(model, elem, "offsetSourceX", 100)
|
|
|
+ instantiate_attribute(model, elem, "offsetSourceY", 50)
|
|
|
+ instantiate_attribute(model, elem, "offsetTargetX", 100)
|
|
|
+ instantiate_attribute(model, elem, "offsetTargetY", 50)
|
|
|
+ instantiate_attribute(model, elem, "lineWidth", 4)
|
|
|
instantiate_attribute(model, elem, "lineColour", "black")
|
|
|
instantiate_attribute(model, elem, "arrow", True)
|
|
|
instantiate_attribute(model, elem, "__asid", list_read(string_split(class, "/"), 1))
|
|
|
instantiate_link(model, "rendered/contains", "", group, elem)
|
|
|
|
|
|
+ if (num_to_render == list_len(delayed_elements)):
|
|
|
+ log("Could not decrease number of rendered elements anymore...")
|
|
|
+ return True!
|
|
|
+ else:
|
|
|
+ to_render = delayed_elements
|
|
|
+ delayed_elements = list_create()
|
|
|
+
|
|
|
return True!
|