diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.visualisation/src/hu/bme/mit/inf/dslreasoner')
-rw-r--r-- | Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.visualisation/src/hu/bme/mit/inf/dslreasoner/visualisation/pi2graphviz/PartialInterpretation2Graphviz.xtend | 49 |
1 files changed, 33 insertions, 16 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 05a4e6c2..cd0b3e00 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 | |||
@@ -30,6 +30,7 @@ import org.eclipse.xtext.xbase.lib.Functions.Function1 | |||
30 | import static guru.nidi.graphviz.model.Factory.* | 30 | import static guru.nidi.graphviz.model.Factory.* |
31 | 31 | ||
32 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 32 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* |
33 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PrimitiveElement | ||
33 | 34 | ||
34 | class GraphvizVisualiser implements PartialInterpretationVisualiser { | 35 | class GraphvizVisualiser implements PartialInterpretationVisualiser { |
35 | 36 | ||
@@ -106,10 +107,10 @@ class GraphvizVisualiser implements PartialInterpretationVisualiser { | |||
106 | // elements2Node.put(newElement,image) | 107 | // elements2Node.put(newElement,image) |
107 | // } | 108 | // } |
108 | 109 | ||
109 | partialInterpretation.newElements.filter(BooleanElement).drawDataTypes([it.value.toString],elements2Node,elements2ID) | 110 | //partialInterpretation.newElements.filter(BooleanElement).drawDataTypes([it.value.toString],elements2Node,elements2ID) |
110 | partialInterpretation.newElements.filter(IntegerElement).drawDataTypes([it.value.toString],elements2Node,elements2ID) | 111 | //partialInterpretation.newElements.filter(IntegerElement).drawDataTypes([it.value.toString],elements2Node,elements2ID) |
111 | partialInterpretation.newElements.filter(StringElement).drawDataTypes(['''"«it.value.toString»"'''],elements2Node,elements2ID) | 112 | //partialInterpretation.newElements.filter(StringElement).drawDataTypes(['''"«it.value.toString»"'''],elements2Node,elements2ID) |
112 | partialInterpretation.newElements.filter(RealElement).drawDataTypes([it.value.toString],elements2Node,elements2ID) | 113 | //partialInterpretation.newElements.filter(RealElement).drawDataTypes([it.value.toString],elements2Node,elements2ID) |
113 | 114 | ||
114 | // Drawing the edges | 115 | // Drawing the edges |
115 | val edges = new HashMap | 116 | val edges = new HashMap |
@@ -135,35 +136,51 @@ class GraphvizVisualiser implements PartialInterpretationVisualiser { | |||
135 | return new GraphvizVisualisation(graph) | 136 | return new GraphvizVisualisation(graph) |
136 | } | 137 | } |
137 | 138 | ||
138 | def protected <T extends DefinedElement> void drawDataTypes(Iterable<T> collection, Function1<T,String> namer, HashMap<DefinedElement, Node> elements2Node, HashMap<DefinedElement, String> elements2ID) { | 139 | // def protected <T extends DefinedElement> void drawDataTypes(Iterable<T> collection, Function1<T,String> namer, HashMap<DefinedElement, Node> elements2Node, HashMap<DefinedElement, String> elements2ID) { |
139 | for(booleanElementIndex: 0..<collection.size) { | 140 | // for(booleanElementIndex: 0..<collection.size) { |
140 | val newElement = collection.get(booleanElementIndex) | 141 | // val newElement = collection.get(booleanElementIndex) |
141 | val id = namer.apply(newElement) | 142 | // val name = namer.apply(newElement) |
142 | val image = drawElement(newElement,id,false,emptySet,emptySet) | 143 | // val image = drawElement(newElement,name,newElement.lookup(elements2ID),false,emptySet,emptySet) |
143 | elements2ID.put(newElement,id) | 144 | // elements2Node.put(newElement,image) |
144 | elements2Node.put(newElement,image) | 145 | // } |
145 | } | 146 | // } |
146 | } | ||
147 | 147 | ||
148 | def protected drawElement(DefinedElement element, String ID, boolean old, Set<Type> mustTypes, Set<Type> mayTypes) { | 148 | def protected drawElement(DefinedElement element, String ID, boolean old, Set<Type> mustTypes, Set<Type> mayTypes) { |
149 | var tableStyle = ''' CELLSPACING="0" BORDER="2" CELLBORDER="0" CELLPADDING="1" STYLE="ROUNDED"''' | 149 | var tableStyle = ''' CELLSPACING="0" BORDER="2" CELLBORDER="0" CELLPADDING="1" STYLE="ROUNDED"''' |
150 | if(typeColoringStyle==TypeColoringStyle::AVERAGE) { | 150 | if(typeColoringStyle==TypeColoringStyle::AVERAGE) { |
151 | tableStyle += ''' BGCOLOR="#«typePredicateColor(mustTypes).toBackgroundColorString»"''' | 151 | tableStyle += ''' BGCOLOR="#«typePredicateColor(mustTypes).toBackgroundColorString»"''' |
152 | } | 152 | } |
153 | val mainLabel = if(element.name !== null) { | 153 | val mainLabel = if(element instanceof PrimitiveElement) { |
154 | if(element.isValueSet) { | ||
155 | if(element instanceof BooleanElement) { element.value.toString } | ||
156 | else if(element instanceof IntegerElement) { element.value.toString } | ||
157 | else if(element instanceof RealElement) { element.value.toString } | ||
158 | else if(element instanceof StringElement) { "\""+element.value.toString+"\"" } | ||
159 | } else { | ||
160 | "?" | ||
161 | } | ||
162 | }else if(element.name !== null) { | ||
154 | val parts = element.name.split("\\s+") | 163 | val parts = element.name.split("\\s+") |
155 | textWithSubSup(parts.getOrNull(0),parts.getOrNull(1),parts.getOrNull(2),null) | 164 | textWithSubSup(parts.getOrNull(0),parts.getOrNull(1),parts.getOrNull(2),null) |
156 | } else { | 165 | } else { |
157 | val parts = ID.split("\\s+") | 166 | val parts = ID.split("\\s+") |
158 | textWithSubSup(parts.getOrNull(0),parts.getOrNull(1),parts.getOrNull(2),null) | 167 | textWithSubSup(parts.getOrNull(0),parts.getOrNull(1),parts.getOrNull(2),null) |
159 | } | 168 | } |
160 | val label = Label.html( | 169 | val hasNoCompexType = (mustTypes.empty) && (mayTypes.empty) |
170 | |||
171 | val label = if(hasNoCompexType) { | ||
172 | Label.html( | ||
173 | '''<TABLE«tableStyle»>'''+ | ||
174 | '''<TR><TD COLSPAN="2"> «mainLabel» </TD></TR>'''+ | ||
175 | '''</TABLE>''') | ||
176 | } else { | ||
177 | Label.html( | ||
161 | '''<TABLE«tableStyle»>'''+ | 178 | '''<TABLE«tableStyle»>'''+ |
162 | '''<TR><TD COLSPAN="2" BORDER="2" SIDES="B">«mainLabel»</TD></TR>'''+ | 179 | '''<TR><TD COLSPAN="2" BORDER="2" SIDES="B">«mainLabel»</TD></TR>'''+ |
163 | '''«FOR mustTypeName : mustTypes.map[it.name].sort»«typePredicateDescription(mustTypeName,true)»«ENDFOR»'''+ | 180 | '''«FOR mustTypeName : mustTypes.map[it.name].sort»«typePredicateDescription(mustTypeName,true)»«ENDFOR»'''+ |
164 | '''«FOR mayTypeName : mayTypes.map[it.name].sort»«typePredicateDescription(mayTypeName,false)»«ENDFOR»'''+ | 181 | '''«FOR mayTypeName : mayTypes.map[it.name].sort»«typePredicateDescription(mayTypeName,false)»«ENDFOR»'''+ |
165 | '''</TABLE>''') | 182 | '''</TABLE>''') |
166 | 183 | } | |
167 | val node = node(ID).with(label).with( | 184 | val node = node(ID).with(label).with( |
168 | Shape.NONE | 185 | Shape.NONE |
169 | //, | 186 | //, |