1
- import { BoundingBox , Category , Edge , NetworkNode , Node , NodeType , Position } from "@model" ;
1
+ import { ArrowType , BoundingBox , Category , Edge , NetworkNode , Node , NodeType , Position } from "@model" ;
2
2
3
3
export class DgmlManager {
4
4
@@ -46,7 +46,7 @@ export class DgmlManager {
46
46
}
47
47
}
48
48
49
- private addLinkNode ( xmlDoc : Document , element : Element | null , source : string , target : string ) {
49
+ private addLinkNode ( xmlDoc : Document , element : Element | null , source : string , target : string , categoryId : string ) {
50
50
if ( element !== null ) {
51
51
let nodeAlreadyAdded = false ;
52
52
if ( element . childNodes . length > 0 ) {
@@ -65,6 +65,7 @@ export class DgmlManager {
65
65
const linkElement = xmlDoc . createElement ( "Link" ) ;
66
66
linkElement . setAttribute ( "Source" , source ) ;
67
67
linkElement . setAttribute ( "Target" , target ) ;
68
+ linkElement . setAttribute ( "Category" , categoryId ) ;
68
69
element . appendChild ( linkElement ) ;
69
70
}
70
71
}
@@ -82,10 +83,14 @@ export class DgmlManager {
82
83
this . generateDirectedGraphNodesXml ( xmlDoc , node , nodesElement ) ;
83
84
const categoryId = NodeType [ node . nodeType ] ;
84
85
if ( ! ( categoryId in categoryDictionary ) ) {
85
- categoryDictionary [ categoryId ] = new Category ( categoryId , categoryId , node . getNodeTypeColor ( node . nodeType ) ) ;
86
+ categoryDictionary [ categoryId ] = new Category ( categoryId , categoryId , node . getNodeTypeColor ( node . nodeType ) , '' ) ;
86
87
}
87
88
} ) ;
88
89
edges . forEach ( edge => {
90
+ const categoryId = ArrowType [ edge . arrowType ] ;
91
+ if ( ! ( categoryId in categoryDictionary ) ) {
92
+ categoryDictionary [ categoryId ] = new Category ( categoryId , categoryId , '' , edge . getEdgeTypeColor ( edge . arrowType ) ) ;
93
+ }
89
94
this . generateDirectedGraphLinksXml ( xmlDoc , edge , linksElement ) ;
90
95
} ) ;
91
96
this . addCategoriesAndStyles ( xmlDoc , categoryDictionary ) ;
@@ -128,15 +133,21 @@ export class DgmlManager {
128
133
}
129
134
130
135
private generateDirectedGraphLinksXml ( xmlDoc : Document , edge : Edge , linksElement : Element | null ) {
131
- this . addLinkNode ( xmlDoc , linksElement , edge . source , edge . target ) ;
136
+ const categoryId = ArrowType [ edge . arrowType ] ;
137
+ this . addLinkNode ( xmlDoc , linksElement , edge . source , edge . target , categoryId ) ;
132
138
}
133
139
134
140
private addCategory ( xmlDoc : Document , categoriesElement : Element | null , category : Category ) {
135
- if ( categoriesElement !== null ) {
141
+ if ( categoriesElement !== null && ( category . backgroundColor || category . stroke ) ) {
136
142
const categoryElement = xmlDoc . createElement ( "Category" ) ;
137
143
categoryElement . setAttribute ( "Id" , category . id ) ;
138
144
categoryElement . setAttribute ( "Label" , category . label ) ;
139
- categoryElement . setAttribute ( "Background" , category . backgroundColor ) ;
145
+ if ( category . backgroundColor ) {
146
+ categoryElement . setAttribute ( "Background" , category . backgroundColor ) ;
147
+ }
148
+ if ( category . stroke ) {
149
+ categoryElement . setAttribute ( "Stroke" , category . stroke ) ;
150
+ }
140
151
categoryElement . setAttribute ( "IsTag" , "True" ) ;
141
152
this . addNode ( categoriesElement , categoryElement ) ;
142
153
}
0 commit comments