Open
Graph Drawing
Framework
v.2012.07
Overview
Class Hierarchy
Class Index
Class List
Members
Namespaces
Source Files
OgmlParser.h
Go to the documentation of this file.
1
/*
2
* $Revision: 2523 $
3
*
4
* last checkin:
5
* $Author: gutwenger $
6
* $Date: 2012-07-02 20:59:27 +0200 (Mon, 02 Jul 2012) $
7
***************************************************************/
8
45
#ifdef _MSC_VER
46
#pragma once
47
#endif
48
49
//KK: Commented out the constraint stuff using //o
50
//CG: compound graph stuff has been removed with commit 2465
51
52
#ifndef OGDF_OGML_PARSER_H
53
#define OGDF_OGML_PARSER_H
54
55
#include <
ogdf/fileformats/Ogml.h
>
56
#include <
ogdf/fileformats/DinoXmlParser.h
>
57
#include <
ogdf/basic/Hashing.h
>
58
#include <
ogdf/basic/String.h
>
59
#include <
ogdf/cluster/ClusterGraph.h
>
60
#include <
ogdf/cluster/ClusterGraphAttributes.h
>
61
62
// constraints
63
//o#include <ogdf/Constraints.h>
64
65
66
namespace
ogdf {
67
68
//
69
// ---------- O g m l P a r s e r ------------------------
70
//
71
74
class
OgmlParser
75
{
76
private
:
77
78
// struct definitions for mapping of templates
79
struct
OgmlNodeTemplate;
80
struct
OgmlEdgeTemplate;
81
//struct OgmlLabelTemplate;
82
83
struct
OgmlSegment;
84
85
class
OgmlAttributeValue;
86
class
OgmlAttribute;
87
class
OgmlTag;
88
89
friend
ostream&
operator<<
(ostream& os,
const
OgmlParser::OgmlAttribute& oa);
90
friend
ostream&
operator<<
(ostream& os,
const
OgmlParser::OgmlTag& ot);
91
92
static
Hashing<int, OgmlTag>
*
s_tags
;
93
static
Hashing<int, OgmlAttribute>
*
s_attributes
;
94
static
Hashing<int, OgmlAttributeValue>
*
s_attValues
;
95
96
98
static
void
buildHashTables
();
99
100
mutable
Ogml::GraphType
m_graphType
;
101
102
Hashing<String, const XmlTagObject*>
m_ids
;
103
112
int
validate
(
const
XmlTagObject
*xmlTag,
int
ogmlTag);
113
118
//bool validate(const char* fileName);
119
121
void
printValidityInfo
(
const
OgmlTag &ot,
122
const
XmlTagObject
&xto,
123
int
valStatus,
124
int
line);
125
132
//bool getXmlTagObjectById(XmlTagObject *recTag, String id, XmlTagObject *&xmlTag);
133
139
bool
checkGraphType
(
const
XmlTagObject
*xmlTag)
const
;
140
142
bool
isGraphHierarchical
(
const
XmlTagObject
*xmlTag)
const
;
143
145
bool
isNodeHierarchical
(
const
XmlTagObject
*xmlTag)
const
;
146
147
Ogml::GraphType
getGraphType
() {
return
m_graphType
; };
148
149
150
// id hash tables
151
// required variables for building
152
// hash table with id from file and node
153
Hashing<String, node>
m_nodes
;
154
Hashing<String, edge>
m_edges
;
155
Hashing<String, cluster>
m_clusters
;
156
// hash table for bend-points
157
Hashing<String, DPoint>
m_points
;
158
159
// hash table for checking uniqueness of ids
160
// (key:) int = id in the created graph
161
// (info:) String = id in the ogml file
162
Hashing<int, String>
m_nodeIds
;
163
Hashing<int, String>
m_edgeIds
;
164
Hashing<int, String>
m_clusterIds
;
165
166
// build methods
167
169
bool
buildGraph
(
Graph
&G);
170
172
bool
buildCluster
(
173
const
XmlTagObject
*rootTag,
174
Graph
&G,
175
ClusterGraph
&CG);
176
178
bool
buildClusterRecursive
(
179
const
XmlTagObject
*xmlTag,
180
cluster
parent,
181
Graph
&G,
182
ClusterGraph
&CG);
183
185
bool
buildAttributedClusterGraph
(
186
Graph
&G,
187
ClusterGraphAttributes
&CGA,
188
const
XmlTagObject
*root);
189
191
bool
setLabelsRecursive
(
192
Graph
&G,
193
ClusterGraphAttributes
&CGA,
194
XmlTagObject
*root);
195
196
// helping pointer for constraints-loading
197
// this pointer is set in the building methods
198
// so we don't have to traverse the tree in buildConstraints
199
XmlTagObject
*
m_constraintsTag
;
200
201
// hashing lists for templates
202
// string = id
203
Hashing<String, OgmlNodeTemplate*>
m_ogmlNodeTemplates
;
204
Hashing<String, OgmlEdgeTemplate*>
m_ogmlEdgeTemplates
;
205
//Hashing<String, OgmlLabelTemplate> m_ogmlLabelTemplates;
206
207
// auxiliary methods for mapping graph attributes
208
210
int
getBrushPatternAsInt
(
String
s);
211
213
int
getShapeAsInt
(
String
s);
214
216
String
getNodeTemplateFromOgmlValue
(
String
s);
217
219
int
getLineTypeAsInt
(
String
s);
220
222
int
getImageStyleAsInt
(
String
s);
223
225
int
getImageAlignmentAsInt
(
String
s);
226
227
// arrow style, actually a "boolean" function
228
// because it returns only 0 or 1 according to GDE
229
// sot <=> source or target
230
int
getArrowStyleAsInt
(
String
s,
String
sot);
231
232
// the matching method to getArrowStyleAsInt
233
GraphAttributes::EdgeArrow
getArrowStyle
(
int
i);
234
235
// function that operates on a string
236
// the input string contains "<" instead of "<"
237
// and ">" instead of ">"
238
// to disable interpreting the string as xml-tags (by DinoXmlParser)
239
// so this function substitutes "<" for "<"
240
String
getLabelCaptionFromString
(
String
str);
241
243
bool
getIdFromString
(
String
str,
int
&
id
);
244
246
void
validate
(
const
char
* fileName);
247
248
public
:
249
251
OgmlParser
() { }
252
253
~OgmlParser
() { }
254
255
257
263
bool
read
(
264
const
char
* fileName,
265
Graph
&G,
266
ClusterGraph
&CG);
267
269
276
bool
read
(
277
const
char
* fileName,
278
Graph
&G,
279
ClusterGraph
&CG,
280
ClusterGraphAttributes
&CGA);
281
282
};
//end class OGMLParser
283
284
}
//end namespace ogdf
285
286
#endif
287
ogdf
fileformats
OgmlParser.h
© 1999-2012 by
TU Dortmund
,
University of Jena
,
University of Cologne
,
University of Sydney
,
oreas GmbH