Revize 2370f181
Přidáno uživatelem Martin Matas před téměř 6 roky(ů)
sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/GraphFactory.java | ||
---|---|---|
60 | 60 |
private void addVerticesToGraph(Graph graph, List<VertexDTO> vertices) { |
61 | 61 |
for (VertexDTO v : vertices) { |
62 | 62 |
|
63 |
List<String[]> attributes = new ArrayList<>(); |
|
64 |
attributes.add(convertListToArray(v.getAttributes().values())); |
|
63 |
List<String[]> attributes = sortAttributes(v.getAttributes(), attributeTypes); |
|
65 | 64 |
Vertex vertex = new Vertex(v.getId(), v.getName(), DEFAULT_ARCHETYPE_INDEX, "", attributes); |
66 | 65 |
graph.getVertices().add(vertex); |
67 | 66 |
} |
... | ... | |
70 | 69 |
private void addEdgesToGraph(Graph graph, List<EdgeDTO> edges) { |
71 | 70 |
for (EdgeDTO e : edges) { |
72 | 71 |
|
73 |
List<String[]> attributes = new ArrayList<>(); |
|
74 |
attributes.add(convertListToArray(e.getAttributes().values())); |
|
72 |
List<String[]> attributes = sortAttributes(e.getAttributes(), attributeTypes); |
|
75 | 73 |
SubedgeInfo subedgeInfo = new SubedgeInfo(e.getId(), DEFAULT_ARCHETYPE_INDEX, attributes); |
76 | 74 |
|
77 | 75 |
List<SubedgeInfo> subedgeInfos = new ArrayList<>(); |
... | ... | |
82 | 80 |
} |
83 | 81 |
} |
84 | 82 |
|
85 |
private String[] convertListToArray(Collection<String> list) { |
|
86 |
String[] array = new String[list.size()]; |
|
87 |
int i = 0; |
|
83 |
private List<String[]> sortAttributes(Map<String, String> unsortedAttributes, List<AttributeType> attributeTypes) { |
|
84 |
HashMap<String, List<String>> attributes = new HashMap<>(); |
|
88 | 85 |
|
89 |
for (String str: list) { |
|
90 |
array[i++] = str; |
|
86 |
attributeTypes.forEach(type -> { |
|
87 |
attributes.put(type.getName(), new ArrayList<>()); |
|
88 |
}); |
|
89 |
|
|
90 |
for (Map.Entry<String, String> e: unsortedAttributes.entrySet()) { |
|
91 |
if (attributes.containsKey(e.getKey())) { |
|
92 |
attributes.get(e.getKey()).add(e.getValue()); |
|
93 |
} |
|
91 | 94 |
} |
92 | 95 |
|
93 |
return array; |
|
96 |
List<String[]> finalAttributes = new ArrayList<>(); |
|
97 |
attributes.forEach((k, v) -> { |
|
98 |
finalAttributes.add(v.toArray(new String[0])); |
|
99 |
}); |
|
100 |
|
|
101 |
return finalAttributes; |
|
94 | 102 |
} |
95 | 103 |
|
96 | 104 |
private void prepareEdgeArchetypes() { |
Také k dispozici: Unified diff
Changed order of serialized attributes to fit order of attribute types