diff options
author | OszkarSemerath <oszkar.semerath@gmail.com> | 2018-03-24 21:44:49 -0400 |
---|---|---|
committer | OszkarSemerath <oszkar.semerath@gmail.com> | 2018-03-24 21:44:49 -0400 |
commit | f42954a45bea9f3e40090447804f33f12c080640 (patch) | |
tree | 1c57d4ca595bf7825460c6aa080f93ea04d5689c /Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.visualisation/src/hu/bme/mit | |
parent | Factory for string literals. (diff) | |
download | VIATRA-Generator-f42954a45bea9f3e40090447804f33f12c080640.tar.gz VIATRA-Generator-f42954a45bea9f3e40090447804f33f12c080640.tar.zst VIATRA-Generator-f42954a45bea9f3e40090447804f33f12c080640.zip |
upgraded attribute support for the graph solver
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.visualisation/src/hu/bme/mit')
-rw-r--r-- | Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.visualisation/src/hu/bme/mit/inf/dslreasoner/visualisation/pi2graphviz/PartialInterpretation2Graphviz.xtend | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.visualisation/src/hu/bme/mit/inf/dslreasoner/visualisation/pi2graphviz/PartialInterpretation2Graphviz.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.visualisation/src/hu/bme/mit/inf/dslreasoner/visualisation/pi2graphviz/PartialInterpretation2Graphviz.xtend index e4ff4146..95e1f74d 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.visualisation/src/hu/bme/mit/inf/dslreasoner/visualisation/pi2graphviz/PartialInterpretation2Graphviz.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.visualisation/src/hu/bme/mit/inf/dslreasoner/visualisation/pi2graphviz/PartialInterpretation2Graphviz.xtend | |||
@@ -29,6 +29,8 @@ import static guru.nidi.graphviz.model.Factory.* | |||
29 | 29 | ||
30 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 30 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* |
31 | import java.awt.image.BufferedImage | 31 | import java.awt.image.BufferedImage |
32 | import java.util.Collection | ||
33 | import org.eclipse.xtext.xbase.lib.Functions.Function1 | ||
32 | 34 | ||
33 | class GraphvizVisualisation implements PartialInterpretationVisualiser { | 35 | class GraphvizVisualisation implements PartialInterpretationVisualiser { |
34 | 36 | ||
@@ -44,6 +46,16 @@ class GraphvizVisualisation implements PartialInterpretationVisualiser { | |||
44 | visualisePartialInterpretation(partialInterpretation,false) | 46 | visualisePartialInterpretation(partialInterpretation,false) |
45 | } | 47 | } |
46 | 48 | ||
49 | def private getElements(PartialInterpretation model) { | ||
50 | return | ||
51 | model.problem.elements + | ||
52 | model.newElements + | ||
53 | model.booleanelements+ | ||
54 | model.integerelements+ | ||
55 | model.stringelement+ | ||
56 | model.realelements | ||
57 | } | ||
58 | |||
47 | def private visualisePartialInterpretation(PartialInterpretation partialInterpretation, boolean concretizationOnly) { | 59 | def private visualisePartialInterpretation(PartialInterpretation partialInterpretation, boolean concretizationOnly) { |
48 | val problem = partialInterpretation.problem | 60 | val problem = partialInterpretation.problem |
49 | 61 | ||
@@ -51,7 +63,7 @@ class GraphvizVisualisation implements PartialInterpretationVisualiser { | |||
51 | val oldElements = problem.elements | 63 | val oldElements = problem.elements |
52 | val newElements = partialInterpretation.newElements | 64 | val newElements = partialInterpretation.newElements |
53 | //val prototypeElements = #[partialInterpretation.openWorldElementPrototype] | 65 | //val prototypeElements = #[partialInterpretation.openWorldElementPrototype] |
54 | val allElements = problem.elements + partialInterpretation.newElements | 66 | val allElements = getElements(partialInterpretation) |
55 | 67 | ||
56 | // Indexing types | 68 | // Indexing types |
57 | val mustTypes = new HashMap<DefinedElement,Set<Type>> | 69 | val mustTypes = new HashMap<DefinedElement,Set<Type>> |
@@ -90,7 +102,18 @@ class GraphvizVisualisation implements PartialInterpretationVisualiser { | |||
90 | elements2ID.put(newElement,id) | 102 | elements2ID.put(newElement,id) |
91 | elements2Node.put(newElement,image) | 103 | elements2Node.put(newElement,image) |
92 | } | 104 | } |
93 | // Prototype elements | 105 | // for(booleanElementIndex: 0..<partialInterpretation.booleanelements.size) { |
106 | // val newElement = partialInterpretation.booleanelements.get(booleanElementIndex) | ||
107 | // val id = '''«newElement.value»''' | ||
108 | // val image = drawElement(newElement,id,false,emptySet,emptySet) | ||
109 | // elements2ID.put(newElement,id) | ||
110 | // elements2Node.put(newElement,image) | ||
111 | // } | ||
112 | |||
113 | partialInterpretation.booleanelements.drawDataTypes([it.value.toString],elements2Node,elements2ID) | ||
114 | partialInterpretation.integerelements.drawDataTypes([it.value.toString],elements2Node,elements2ID) | ||
115 | partialInterpretation.stringelement.drawDataTypes(['''"«it.value.toString»"'''],elements2Node,elements2ID) | ||
116 | partialInterpretation.realelements.drawDataTypes([it.value.toString],elements2Node,elements2ID) | ||
94 | 117 | ||
95 | // Drawing the edges | 118 | // Drawing the edges |
96 | val edges = new HashMap | 119 | val edges = new HashMap |
@@ -116,6 +139,16 @@ class GraphvizVisualisation implements PartialInterpretationVisualiser { | |||
116 | return new GraphvisVisualisation(graph) | 139 | return new GraphvisVisualisation(graph) |
117 | } | 140 | } |
118 | 141 | ||
142 | def protected <T extends DefinedElement> void drawDataTypes(Collection<T> collection, Function1<T,String> namer, HashMap<DefinedElement, Node> elements2Node, HashMap<DefinedElement, String> elements2ID) { | ||
143 | for(booleanElementIndex: 0..<collection.size) { | ||
144 | val newElement = collection.get(booleanElementIndex) | ||
145 | val id = namer.apply(newElement) | ||
146 | val image = drawElement(newElement,id,false,emptySet,emptySet) | ||
147 | elements2ID.put(newElement,id) | ||
148 | elements2Node.put(newElement,image) | ||
149 | } | ||
150 | } | ||
151 | |||
119 | def protected drawElement(DefinedElement element, String ID, boolean old, Set<Type> mustTypes, Set<Type> mayTypes) { | 152 | def protected drawElement(DefinedElement element, String ID, boolean old, Set<Type> mustTypes, Set<Type> mayTypes) { |
120 | var tableStyle = ''' CELLSPACING="0" BORDER="2" CELLBORDER="0" CELLPADDING="1" STYLE="ROUNDED"''' | 153 | var tableStyle = ''' CELLSPACING="0" BORDER="2" CELLBORDER="0" CELLPADDING="1" STYLE="ROUNDED"''' |
121 | if(typeColoringStyle==TypeColoringStyle::AVERAGE) { | 154 | if(typeColoringStyle==TypeColoringStyle::AVERAGE) { |