Revize acbc9fff
Přidáno uživatelem Tomáš Šimandl před více než 6 roky(ů)
documents/backend2frontend.json | ||
---|---|---|
1 |
Návrh JSONu |
|
2 |
{ |
|
3 |
"attributeTypes": [ |
|
4 |
{ |
|
5 |
"dataType": <string>, //datový typ atributu (number, string, enum, ...) |
|
6 |
"name": <string>, //název atributu |
|
7 |
"text": <string> //může sloužit jako popisek atributu, nemusí být použit |
|
8 |
}, |
|
9 |
... |
|
10 |
], |
|
11 | ||
12 |
"edgeArchetypes": [ //možné archetypy hran |
|
13 |
{ |
|
14 |
"name": <string>, //název archetypu |
|
15 |
"text": <string> //může sloužit jako popisek archetypu, nemusí být použit |
|
16 |
}, |
|
17 |
... |
|
18 |
], |
|
19 | ||
20 |
"vertexArchetypes": [ //možné archetypy vrcholů |
|
21 |
{ |
|
22 |
"name": <string>, //název archetypu |
|
23 |
"text": <string> //může sloužit jako popisek archetypu, nemusí být použit |
|
24 |
}, |
|
25 |
... |
|
26 |
], |
|
27 | ||
28 |
"vertices": [ //vrcholy |
|
29 |
{ |
|
30 |
"archetype": <int>, //typ vrcholu (index v poli vertexArchetypes) |
|
31 |
"attributes": [ |
|
32 |
[ |
|
33 |
<string-key> |
|
34 |
<string-value> |
|
35 |
], |
|
36 |
... |
|
37 |
], |
|
38 |
"id": <int>, //identifikátor vrcholu - použito např. při definici odkud kam vede hrana |
|
39 |
"originalId": <int>, //identifikátor vrcholu, který byl použit před zpracováním(filtrací) v backendu |
|
40 |
"text": <string>, //text pro případné dodatečné info mimo atributy - nemusí být použito, může sloužit jako popisek vrcholu, např. když si uživatel zobrazí jeho detaily, nejdříve se zobrazí tento popisek a až pak hodnoty atributů, může sloužit i jen jako nosič informace, která nebude uživateli přístupná |
|
41 |
"title": <string>, //jméno vrcholu |
|
42 |
}, |
|
43 |
... |
|
44 |
], |
|
45 | ||
46 |
"edges": [ //hrany |
|
47 |
{ |
|
48 |
"subedgeInfo": [ |
|
49 |
{ |
|
50 |
"originalId": <int>, //identifikátor hrany, který byl použit před zpracováním(filtrací) v backendu |
|
51 |
"archetype": <int>, //typ hrany (index v poli edgeArchetypes) |
|
52 |
"attributes": [ //struktura atributu je vzdy klic - hodnota |
|
53 |
[ |
|
54 |
<string-key> |
|
55 |
<string-value> |
|
56 |
], |
|
57 |
... |
|
58 |
] |
|
59 |
}, |
|
60 |
... |
|
61 |
], |
|
62 |
"from": <int>, //orignal id počátečního vrcholu |
|
63 |
"id": <int>, //identifikátor hrany |
|
64 |
"text": <string>, //podobně jako text u vertices |
|
65 |
"to": <int>, //original id koncového vrcholu |
|
66 |
}, |
|
67 |
... |
|
68 |
], |
|
69 | ||
70 |
"possibleEnumValues": { |
|
71 |
<attribute idx>: [ |
|
72 |
<string>, |
|
73 |
<string>, |
|
74 |
... |
|
75 |
], |
|
76 |
... |
|
77 |
}, |
|
78 | ||
79 |
"archetypeIcons": [ //Definice archetypových ikon |
|
80 |
{ |
|
81 |
"name": "archetypeName", //ikony identifikovány pomocí jmén |
|
82 |
"value": "archetype svg" //dát pozor na escapování uvozovek |
|
83 |
|
|
84 |
//svg musí být pro správnou vizualizaci definován tak, aby obsahoval objekty, které leží uvnitř obdélníka [0; 0] až [12; 15] |
|
85 |
}, |
|
86 |
... |
|
87 |
], |
|
88 | ||
89 |
"groups": [ //obsahuje jednotlivé skupiny uzlů |
|
90 |
{ |
|
91 |
"groupId": <int>, //identifikátor skupiny |
|
92 |
"id": <int>, //identifikátor, který je jedinečný v rámci skupin i všech uzlů |
|
93 |
"name": <string>, //název skupiny |
|
94 |
"verticesId": [<int>, <int>, ...], //identifikátory uzlů, které jsou ve skupině |
|
95 |
"verticesEdgeFromId": [<int>, <int>, ...], //identifikátory uzlů, jejichž odchozí hrany jsou viditelné v grafu |
|
96 |
"verticesEdgeToId": [<int>, <int>, ...] //identifikátory uzlů, jejichž příchozí hrany jsou viditelné v grafu |
|
97 |
}, |
|
98 |
... |
|
99 |
], |
|
100 | ||
101 |
"positions": [ //obsahuje relativní pozice uzlů a skupin v grafu |
|
102 |
{ |
|
103 |
"id": <int>, //identifikátor uzlu nebo skupiny |
|
104 |
"x": <int>, //X-ová pozice v grafu |
|
105 |
"y": <int> //Y-ová pozice v grafu |
|
106 |
}, |
|
107 |
... |
|
108 |
], |
|
109 | ||
110 |
"sideBar": [ //obsahuje seznam uzlů a skupin, které jsou umístěné v postraním panelu |
|
111 |
{ |
|
112 |
"id": <int>, //identifikátor uzlu nebo skupiny |
|
113 |
"isHighlighted": <bool> //identifikuje, zda budou u sousedů zobrazeny ikony |
|
114 |
}, |
|
115 |
... |
|
116 |
], |
|
117 | ||
118 |
"selectedVertex": <int>, //identifikátor uzlu nebo skupiny, který je zvýrazněn |
|
119 |
"selectedEdge": <int> //identifikátor hrany, která je zvýrazněna |
|
120 |
} |
sources/src/cz/zcu/kiv/offscreen/AttributeType.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen; |
|
2 | ||
3 |
import cz.zcu.kiv.offscreen.graph.GraphManager; |
|
4 | ||
5 |
public class AttributeType { |
|
6 |
public String name; |
|
7 |
public GraphManager.AttributeDataType dataType; |
|
8 |
public String text; |
|
9 | ||
10 |
public AttributeType(String name, GraphManager.AttributeDataType dataType, String text) { |
|
11 |
this.name = name; |
|
12 |
this.dataType = dataType; |
|
13 |
this.text = text; |
|
14 |
} |
|
15 | ||
16 |
public String getName() { |
|
17 |
return name; |
|
18 |
} |
|
19 | ||
20 |
public GraphManager.AttributeDataType getDataType() { |
|
21 |
return dataType; |
|
22 |
} |
|
23 |
} |
sources/src/cz/zcu/kiv/offscreen/api/BaseEdge.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.api; |
|
2 | ||
3 |
/** |
|
4 |
* Class represents edge. Class contains attributes which are common for input JSON format and for |
|
5 |
* output JSON format (JSON between frontend and backend) |
|
6 |
*/ |
|
7 |
public class BaseEdge { |
|
8 |
/** identification number of edge */ |
|
9 |
private int id; |
|
10 |
/** original ID of vertex from edge leads */ |
|
11 |
private int from; |
|
12 |
/** original ID of vertex where edge leads */ |
|
13 |
private int to; |
|
14 |
/** additional info */ |
|
15 |
private String text; |
|
16 | ||
17 |
public BaseEdge(int id, int from, int to, String text) { |
|
18 |
this.id = id; |
|
19 |
this.from = from; |
|
20 |
this.to = to; |
|
21 |
this.text = text; |
|
22 |
} |
|
23 | ||
24 |
public int getId() { |
|
25 |
return id; |
|
26 |
} |
|
27 | ||
28 |
public void setId(int id) { |
|
29 |
this.id = id; |
|
30 |
} |
|
31 | ||
32 |
public int getFrom() { |
|
33 |
return from; |
|
34 |
} |
|
35 | ||
36 |
public void setFrom(int from) { |
|
37 |
this.from = from; |
|
38 |
} |
|
39 | ||
40 |
public int getTo() { |
|
41 |
return to; |
|
42 |
} |
|
43 | ||
44 |
public void setTo(int to) { |
|
45 |
this.to = to; |
|
46 |
} |
|
47 | ||
48 |
public String getText() { |
|
49 |
return text; |
|
50 |
} |
|
51 | ||
52 |
public void setText(String text) { |
|
53 |
this.text = text; |
|
54 |
} |
|
55 | ||
56 |
/** |
|
57 |
* Generate hash code based on attributes {@code from} and {@code to}. |
|
58 |
* @return generated hash code. |
|
59 |
*/ |
|
60 |
@Override |
|
61 |
public int hashCode() { |
|
62 |
return from * 100000 + to; |
|
63 |
} |
|
64 | ||
65 |
/** |
|
66 |
* Two edges are equals where their {@code from} and {@code to} are equals. |
|
67 |
* |
|
68 |
* @param edge which will be compared with this instance |
|
69 |
* @return tru if edges are equal, false otherwise |
|
70 |
*/ |
|
71 |
@Override |
|
72 |
public boolean equals(Object edge) { |
|
73 |
if (!(edge instanceof BaseEdge)) return false; |
|
74 | ||
75 |
BaseEdge cmpEdge = (BaseEdge) edge; |
|
76 |
return from == cmpEdge.from && to == cmpEdge.to; |
|
77 |
} |
|
78 |
} |
sources/src/cz/zcu/kiv/offscreen/api/BaseVertex.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.api; |
|
2 | ||
3 |
/** |
|
4 |
* Class represents vertex. Class contains attributes which are common for input JSON format and for |
|
5 |
* output JSON format (JSON between frontend and backend) |
|
6 |
*/ |
|
7 |
public class BaseVertex { |
|
8 | ||
9 |
/** New generated identification number. */ |
|
10 |
private int id; |
|
11 |
/** Identification number which is in input file. */ |
|
12 |
private int originalId; |
|
13 |
/** Title of vertex. */ |
|
14 |
private String title; |
|
15 |
/** Index of vertex archetype. */ |
|
16 |
private int archetypeIndex; |
|
17 |
/** Additional info. */ |
|
18 |
private String text; |
|
19 | ||
20 |
public BaseVertex(int id, int originalId, String title, int archetypeIndex, String text) { |
|
21 |
this.id = id; |
|
22 |
this.originalId = originalId; |
|
23 |
this.title = title; |
|
24 |
this.archetypeIndex = archetypeIndex; |
|
25 |
this.text = text; |
|
26 |
} |
|
27 | ||
28 |
public int getId() { |
|
29 |
return id; |
|
30 |
} |
|
31 | ||
32 |
public void setId(int id) { |
|
33 |
this.id = id; |
|
34 |
} |
|
35 | ||
36 |
public int getOriginalId() { |
|
37 |
return originalId; |
|
38 |
} |
|
39 | ||
40 |
public void setOriginalId(int originalId) { |
|
41 |
this.originalId = originalId; |
|
42 |
} |
|
43 | ||
44 |
public String getTitle() { |
|
45 |
return title; |
|
46 |
} |
|
47 | ||
48 |
public void setTitle(String title) { |
|
49 |
this.title = title; |
|
50 |
} |
|
51 | ||
52 |
public int getArchetype() { |
|
53 |
return archetypeIndex; |
|
54 |
} |
|
55 | ||
56 |
public void setArchetype(int archetypeIndex) { |
|
57 |
this.archetypeIndex = archetypeIndex; |
|
58 |
} |
|
59 | ||
60 |
public String getText() { |
|
61 |
return text; |
|
62 |
} |
|
63 | ||
64 |
public void setText(String text) { |
|
65 |
this.text = text; |
|
66 |
} |
|
67 | ||
68 |
/** |
|
69 |
* Generate hash code which is based on {@code originalId}. |
|
70 |
* @return generated has code |
|
71 |
*/ |
|
72 |
@Override |
|
73 |
public int hashCode() { |
|
74 |
return originalId; |
|
75 |
} |
|
76 | ||
77 |
/** |
|
78 |
* Two vertices are equals when their {@code originalId} is equals. |
|
79 |
* @param edge which will be compared with this instance |
|
80 |
* @return true if vertices are equal, false otherwise |
|
81 |
*/ |
|
82 |
@Override |
|
83 |
public boolean equals(Object edge) { |
|
84 |
if (!(edge instanceof BaseVertex)) return false; |
|
85 |
return originalId == ((BaseVertex) edge).originalId; |
|
86 |
} |
|
87 |
} |
sources/src/cz/zcu/kiv/offscreen/api/Edge.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.api; |
|
2 | ||
3 |
import java.util.List; |
|
4 | ||
5 |
/** |
|
6 |
* Class represents edge which is used for output JSON format (JSON between frontend and backend). |
|
7 |
*/ |
|
8 |
public class Edge extends BaseEdge { |
|
9 | ||
10 |
/** |
|
11 |
* List of subedgeInfo. |
|
12 |
* When two input edges are equals, in output their are in one record and their differences are in subedgeInfo. |
|
13 |
*/ |
|
14 |
private List<SubedgeInfo> subedgeInfo; |
|
15 | ||
16 |
/** |
|
17 |
* Create new edge. |
|
18 |
* @param id new generated identification number |
|
19 |
* @param from original ID of vertex from edge leads |
|
20 |
* @param to original ID of vertex where edge leads |
|
21 |
* @param text additional info |
|
22 |
* @param subedgeInfo list which contains differences between equals edges |
|
23 |
*/ |
|
24 |
public Edge(int id, int from, int to, String text, List<SubedgeInfo> subedgeInfo) { |
|
25 |
super(id, from, to, text); |
|
26 |
this.subedgeInfo = subedgeInfo; |
|
27 |
} |
|
28 | ||
29 |
public List<SubedgeInfo> getSubedgeInfo(){ |
|
30 |
return subedgeInfo; |
|
31 |
} |
|
32 | ||
33 |
public void setSubedgeInfo(List<SubedgeInfo> subedgeInfo) { |
|
34 |
this.subedgeInfo = subedgeInfo; |
|
35 |
} |
|
36 |
} |
sources/src/cz/zcu/kiv/offscreen/api/EdgeInterface.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this template, choose Tools | Templates |
|
3 |
* and open the template in the editor. |
|
4 |
*/ |
|
5 |
package cz.zcu.kiv.offscreen.api; |
|
6 | ||
7 |
import cz.zcu.kiv.offscreen.graph.SubedgeInfo; |
|
8 | ||
9 |
import java.util.List; |
|
10 | ||
11 |
/** |
|
12 |
* |
|
13 |
* @author Jindra Pavlíková <jindra.pav2@seznam.cz> |
|
14 |
*/ |
|
15 |
public interface EdgeInterface { |
|
16 | ||
17 |
public String getFrom(); |
|
18 | ||
19 |
public String getTo(); |
|
20 | ||
21 |
public int getId(); |
|
22 | ||
23 |
public List<SubedgeInfo> getSubedgeInfo(); |
|
24 | ||
25 |
public void setSubedgeInfo(List<SubedgeInfo> subedgeInfo); |
|
26 |
} |
sources/src/cz/zcu/kiv/offscreen/api/GraphExport.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.api; |
|
2 | ||
3 |
import cz.zcu.kiv.offscreen.graph.EdgeArchetype; |
|
4 |
import cz.zcu.kiv.offscreen.graph.Graph; |
|
5 |
import cz.zcu.kiv.offscreen.graph.VertexArchetype; |
|
6 |
import cz.zcu.kiv.offscreen.graph.AttributeType; |
|
7 | ||
8 |
import java.util.ArrayList; |
|
9 |
import java.util.List; |
|
10 |
import java.util.Map; |
|
11 | ||
12 |
import org.apache.log4j.Logger; |
|
13 | ||
14 |
/** |
|
15 |
* Class represents graph with all information about graph plus information about state in which used store graph. |
|
16 |
* Class is used for creating of JSON which is send to frontend. |
|
17 |
*/ |
|
18 |
public class GraphExport { |
|
19 | ||
20 |
private List<Vertex> vertices; |
|
21 |
private List<Edge> edges; |
|
22 |
private List<VertexArchetype> vertexArchetypes; |
|
23 |
private List<EdgeArchetype> edgeArchetypes; |
|
24 |
private List<AttributeType> attributeTypes; |
|
25 |
private Map<String, List<String>> possibleEnumValues; |
|
26 |
private Map<String, String> archetypeIcons; |
|
27 | ||
28 |
private List<Group> groups; |
|
29 |
private List<Position> positions; |
|
30 |
private List<SideBar> sideBar; |
|
31 |
private int selectedVertex; |
|
32 |
private int selectedEdge; |
|
33 | ||
34 |
private Logger logger = Logger.getLogger(GraphExport.class); |
|
35 | ||
36 |
public GraphExport(Graph graph) { |
|
37 |
logger.trace("ENTRY"); |
|
38 |
this.vertices = new ArrayList<Vertex>(graph.getVertices().values()); |
|
39 |
this.edges = new ArrayList<Edge>(graph.getEdges()); |
|
40 |
this.vertexArchetypes = new ArrayList<VertexArchetype>(graph.getVertexArchetypes()); |
|
41 |
this.edgeArchetypes = new ArrayList<EdgeArchetype>(graph.getEdgeArchetypes()); |
|
42 |
this.attributeTypes = new ArrayList<>(graph.getAttributeTypes()); |
|
43 |
this.possibleEnumValues = graph.getPossibleEnumValues(); |
|
44 |
this.archetypeIcons = graph.getArchetypeIcons(); |
|
45 |
logger.trace("EXIT"); |
|
46 |
} |
|
47 | ||
48 |
public List<Edge> getEdges() { |
|
49 |
logger.trace("ENTRY"); |
|
50 |
logger.trace("EXIT"); |
|
51 |
return edges; |
|
52 |
} |
|
53 | ||
54 |
public List<Vertex> getVertices() { |
|
55 |
logger.trace("ENTRY"); |
|
56 |
logger.trace("EXIT"); |
|
57 |
return vertices; |
|
58 |
} |
|
59 | ||
60 |
public List<VertexArchetype> getVertexArchetypes() { |
|
61 |
return vertexArchetypes; |
|
62 |
} |
|
63 | ||
64 |
public List<EdgeArchetype> getEdgeArchetypes() { |
|
65 |
return edgeArchetypes; |
|
66 |
} |
|
67 | ||
68 |
public List<AttributeType> getAttributeTypes() { |
|
69 |
return attributeTypes; |
|
70 |
} |
|
71 | ||
72 |
public Map<String, List<String>> getPossibleEnumValues() { |
|
73 |
return possibleEnumValues; |
|
74 |
} |
|
75 | ||
76 |
public Map<String, String> getArchetypeIcons() { |
|
77 |
return archetypeIcons; |
|
78 |
} |
|
79 | ||
80 |
public List<Group> getGroups() { |
|
81 |
return groups; |
|
82 |
} |
|
83 | ||
84 |
public List<Position> getPositions() { |
|
85 |
return positions; |
|
86 |
} |
|
87 | ||
88 |
public List<SideBar> getSideBar() { |
|
89 |
return sideBar; |
|
90 |
} |
|
91 | ||
92 |
public int getSelectedVertex() { |
|
93 |
return selectedVertex; |
|
94 |
} |
|
95 | ||
96 |
public int getSelectedEdge() { |
|
97 |
return selectedEdge; |
|
98 |
} |
|
99 |
} |
sources/src/cz/zcu/kiv/offscreen/api/GraphInterface.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this template, choose Tools | Templates |
|
3 |
* and open the template in the editor. |
|
4 |
*/ |
|
5 |
package cz.zcu.kiv.offscreen.api; |
|
6 | ||
7 |
import cz.zcu.kiv.offscreen.AttributeType; |
|
8 |
import cz.zcu.kiv.offscreen.graph.EdgeArchetype; |
|
9 |
import cz.zcu.kiv.offscreen.graph.VertexArchetype; |
|
10 | ||
11 |
import java.util.List; |
|
12 |
import java.util.Map; |
|
13 | ||
14 |
/** |
|
15 |
* |
|
16 |
* @author Jindra Pavlíková <jindra.pav2@seznam.cz> |
|
17 |
*/ |
|
18 |
public interface GraphInterface { |
|
19 |
|
|
20 |
public void addEdge(EdgeInterface edge); |
|
21 |
public void addVertex(String name, VertexInterface vertex); |
|
22 |
public Map<String, VertexInterface> getVertices(); |
|
23 |
public List<EdgeInterface> getEdges(); |
|
24 |
public List<VertexArchetype> getVertexArchetypes(); |
|
25 |
public List<EdgeArchetype> getEdgeArchetypes(); |
|
26 |
public void setVertexArchetypes(List<VertexArchetype> vertexArchetypes); |
|
27 |
public void setEdgeArchetypes(List<EdgeArchetype> edgeArchetypes); |
|
28 |
public void setAttributeTypes(List<AttributeType> attributeTypes); |
|
29 |
public void setPossibleEnumValues(Map<Integer, List<String>> possibleEnumValues); |
|
30 |
public List<AttributeType> getAttributeTypes(); |
|
31 |
public Map<String, List<String>> getPossibleEnumValues(); |
|
32 |
void setArchetypeIcons(Map<String, String> archetypeIcons); |
|
33 |
Map<String, String> getArchetypeIcons(); |
|
34 |
List<Integer> getDefaultGroupArchetypes(); |
|
35 |
void setDefaultGroupArchetypes(List<Integer> defaultGroupArchetypes); |
|
36 |
} |
sources/src/cz/zcu/kiv/offscreen/api/Group.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.api; |
|
2 | ||
3 |
import java.util.List; |
|
4 | ||
5 |
/** |
|
6 |
* Class represents group of edges and their settings. Used in JSON between frontend and backend. |
|
7 |
*/ |
|
8 |
public class Group { |
|
9 | ||
10 |
/** Generated id of group which is unique only in groups. */ |
|
11 |
private int groupId; |
|
12 |
/** Generated if of group which is unique in groups and vertexes. */ |
|
13 |
private int id; |
|
14 |
/** Name of group */ |
|
15 |
private String name; |
|
16 |
/** List of vertices id which belongs to this group */ |
|
17 |
private List<Integer> verticesId; |
|
18 |
/** List of vertices id whose outgoing edges are visible. */ |
|
19 |
private List<Integer> verticesEdgeFromId; |
|
20 |
/** List of vertices id whose incoming edges are visible. */ |
|
21 |
private List<Integer> verticesEdgeToId; |
|
22 | ||
23 |
public Group(int groupId, int id, String name, List<Integer> verticesId, List<Integer> verticesEdgeFromId, List<Integer> verticesEdgeToId) { |
|
24 |
this.groupId = groupId; |
|
25 |
this.id = id; |
|
26 |
this.name = name; |
|
27 |
this.verticesId = verticesId; |
|
28 |
this.verticesEdgeFromId = verticesEdgeFromId; |
|
29 |
this.verticesEdgeToId = verticesEdgeToId; |
|
30 |
} |
|
31 | ||
32 |
public int getGroupId() { |
|
33 |
return groupId; |
|
34 |
} |
|
35 | ||
36 |
public void setGroupId(int groupId) { |
|
37 |
this.groupId = groupId; |
|
38 |
} |
|
39 | ||
40 |
public int getId() { |
|
41 |
return id; |
|
42 |
} |
|
43 | ||
44 |
public void setId(int id) { |
|
45 |
this.id = id; |
|
46 |
} |
|
47 | ||
48 |
public String getName() { |
|
49 |
return name; |
|
50 |
} |
|
51 | ||
52 |
public void setName(String name) { |
|
53 |
this.name = name; |
|
54 |
} |
|
55 | ||
56 |
public List<Integer> getVerticesId() { |
|
57 |
return verticesId; |
|
58 |
} |
|
59 | ||
60 |
public void setVerticesId(List<Integer> verticesId) { |
|
61 |
this.verticesId = verticesId; |
|
62 |
} |
|
63 | ||
64 |
public List<Integer> getVerticesEdgeFromId() { |
|
65 |
return verticesEdgeFromId; |
|
66 |
} |
|
67 | ||
68 |
public void setVerticesEdgeFromId(List<Integer> verticesEdgeFromId) { |
|
69 |
this.verticesEdgeFromId = verticesEdgeFromId; |
|
70 |
} |
|
71 | ||
72 |
public List<Integer> getVerticesEdgeToId() { |
|
73 |
return verticesEdgeToId; |
|
74 |
} |
|
75 | ||
76 |
public void setVerticesEdgeToId(List<Integer> verticesEdgeToId) { |
|
77 |
this.verticesEdgeToId = verticesEdgeToId; |
|
78 |
} |
|
79 |
} |
sources/src/cz/zcu/kiv/offscreen/api/Position.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.api; |
|
2 | ||
3 |
/** |
|
4 |
* Class is used for storing information about vertex/group relative position. |
|
5 |
*/ |
|
6 |
public class Position { |
|
7 | ||
8 |
/** Identification number of vertex or group which was generated in application. */ |
|
9 |
private int vertexId; |
|
10 |
/** Relative X position. */ |
|
11 |
private float x; |
|
12 |
/** Relative Y position */ |
|
13 |
private float y; |
|
14 | ||
15 |
public Position(int vertexId, float x, float y) { |
|
16 |
this.vertexId = vertexId; |
|
17 |
this.x = x; |
|
18 |
this.y = y; |
|
19 |
} |
|
20 | ||
21 |
public int getVertexId() { |
|
22 |
return vertexId; |
|
23 |
} |
|
24 | ||
25 |
public void setVertexId(int vertexId) { |
|
26 |
this.vertexId = vertexId; |
|
27 |
} |
|
28 | ||
29 |
public float getX() { |
|
30 |
return x; |
|
31 |
} |
|
32 | ||
33 |
public void setX(float x) { |
|
34 |
this.x = x; |
|
35 |
} |
|
36 | ||
37 |
public float getY() { |
|
38 |
return y; |
|
39 |
} |
|
40 | ||
41 |
public void setY(float y) { |
|
42 |
this.y = y; |
|
43 |
} |
|
44 |
} |
sources/src/cz/zcu/kiv/offscreen/api/SideBar.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.api; |
|
2 | ||
3 |
/** |
|
4 |
* Class store information about item in side bar. |
|
5 |
*/ |
|
6 |
public class SideBar { |
|
7 | ||
8 |
/** Identification number of vertex or group which was generated in application. */ |
|
9 |
private int vertexId; |
|
10 |
/** Indicates if related vertexes of this item have visible icon which shows relation with this item. */ |
|
11 |
private boolean highlighted; |
|
12 | ||
13 |
public SideBar(int vertexId, boolean highlighted) { |
|
14 |
this.vertexId = vertexId; |
|
15 |
this.highlighted = highlighted; |
|
16 |
} |
|
17 | ||
18 |
public int getVertexId() { |
|
19 |
return vertexId; |
|
20 |
} |
|
21 | ||
22 |
public void setVertexId(int vertexId) { |
|
23 |
this.vertexId = vertexId; |
|
24 |
} |
|
25 | ||
26 |
public boolean isHighlighted() { |
|
27 |
return highlighted; |
|
28 |
} |
|
29 | ||
30 |
public void setHighlighted(boolean highlighted) { |
|
31 |
this.highlighted = highlighted; |
|
32 |
} |
|
33 |
} |
sources/src/cz/zcu/kiv/offscreen/api/SubedgeInfo.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.api; |
|
2 | ||
3 |
import java.util.List; |
|
4 | ||
5 |
public class SubedgeInfo { |
|
6 | ||
7 |
/** Edge archetype index. */ |
|
8 |
private int archetype; |
|
9 |
/** Original id of edge which is taken from input JSON file. */ |
|
10 |
private int originalId; |
|
11 |
/** List of all tributes. Every attribute is stored in String array in pair as {attribute name, attribute value}. */ |
|
12 |
private List<String[]> attributes; |
|
13 | ||
14 |
/** |
|
15 |
* Create new subedgeInfo |
|
16 |
* @param originalId Original id of edge which is taken from input JSON file. |
|
17 |
* @param archetype Edge archetype index. |
|
18 |
* @param attributes List of all tributes. Every attribute is stored in String array in pair as {attribute name, attribute value}. |
|
19 |
*/ |
|
20 |
public SubedgeInfo(int originalId, int archetype, List<String[]> attributes) { |
|
21 |
this.originalId = originalId; |
|
22 |
this.archetype = archetype; |
|
23 |
this.attributes = attributes; |
|
24 |
} |
|
25 | ||
26 |
public int getOriginalId() { |
|
27 |
return originalId; |
|
28 |
} |
|
29 | ||
30 |
public int getArchetype() { |
|
31 |
return archetype; |
|
32 |
} |
|
33 | ||
34 |
public List<String[]> getAttributes() { |
|
35 |
return attributes; |
|
36 |
} |
|
37 |
} |
sources/src/cz/zcu/kiv/offscreen/api/Vertex.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.api; |
|
2 | ||
3 |
import java.util.List; |
|
4 | ||
5 |
/** |
|
6 |
* Class represents vertex which is used for output JSON format (JSON between frontend and backend) |
|
7 |
*/ |
|
8 |
public class Vertex extends BaseVertex { |
|
9 | ||
10 |
/** List of all tributes. Every attribute is stored in String array in pair as {attribute name, attribute value}. */ |
|
11 |
private List<String[]> attributes; |
|
12 | ||
13 |
/** |
|
14 |
* Create new vertex. |
|
15 |
* @param id new generated identification number. |
|
16 |
* @param originalId original identification number from input file |
|
17 |
* @param title title of vertex |
|
18 |
* @param archetypeIndex index of vertex archetype |
|
19 |
* @param text additional info |
|
20 |
* @param attributes List of all attributes. Every attribute is stored in String array in pair as {attribute name, attribute value}. |
|
21 |
*/ |
|
22 |
public Vertex(int id, int originalId, String title, int archetypeIndex, String text, List<String[]> attributes) { |
|
23 |
super(id, originalId, title, archetypeIndex, text); |
|
24 |
this.attributes = attributes; |
|
25 |
} |
|
26 | ||
27 |
public List<String[]> getAttributes() { |
|
28 |
return attributes; |
|
29 |
} |
|
30 | ||
31 |
public void setAttributes(List<String[]> attributes) { |
|
32 |
this.attributes = attributes; |
|
33 |
} |
|
34 |
} |
sources/src/cz/zcu/kiv/offscreen/api/VertexInterface.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this template, choose Tools | Templates |
|
3 |
* and open the template in the editor. |
|
4 |
*/ |
|
5 |
package cz.zcu.kiv.offscreen.api; |
|
6 | ||
7 |
import java.util.List; |
|
8 | ||
9 |
/** |
|
10 |
* |
|
11 |
* @author Jindra Pavlíková <jindra.pav2@seznam.cz> |
|
12 |
*/ |
|
13 |
public interface VertexInterface { |
|
14 | ||
15 |
public int getId(); |
|
16 | ||
17 |
public String getName(); |
|
18 | ||
19 |
public String getSymbolicName(); |
|
20 | ||
21 |
public List<String> getExportedPackages(); |
|
22 | ||
23 |
public List<String> getImportedPackages(); |
|
24 | ||
25 |
public void setExportedPackages(List<String> exportedPackages); |
|
26 | ||
27 |
public void setImportedPackages(List<String> importedPackages); |
|
28 | ||
29 |
public int getArchetype(); |
|
30 | ||
31 |
public void setArchetype(int archetype); |
|
32 | ||
33 |
public void setAttributes(List<String[]> attributes); |
|
34 | ||
35 |
public List<String[]> getAttributes(); |
|
36 |
} |
sources/src/cz/zcu/kiv/offscreen/graph/Attribute.java | ||
---|---|---|
1 | 1 |
package cz.zcu.kiv.offscreen.graph; |
2 | 2 | |
3 |
/** |
|
4 |
* This class represents attribute of edge or vertex. |
|
5 |
*/ |
|
3 | 6 |
public class Attribute { |
4 |
int typeIndex; |
|
5 |
Object value; |
|
7 |
/** Index to array of attribute types which is defined in input JSON file */ |
|
8 |
private int typeIndex; |
|
9 |
/** Value of attribute */ |
|
10 |
private Object value; |
|
6 | 11 | |
7 | 12 |
public Attribute(int typeIndex, Object value) { |
8 | 13 |
this.typeIndex = typeIndex; |
9 | 14 |
this.value = value; |
10 | 15 |
} |
16 | ||
17 |
public int getTypeIndex() { |
|
18 |
return typeIndex; |
|
19 |
} |
|
20 | ||
21 |
public void setTypeIndex(int typeIndex) { |
|
22 |
this.typeIndex = typeIndex; |
|
23 |
} |
|
24 | ||
25 |
public Object getValue() { |
|
26 |
return value; |
|
27 |
} |
|
28 | ||
29 |
public void setValue(Object value) { |
|
30 |
this.value = value; |
|
31 |
} |
|
11 | 32 |
} |
sources/src/cz/zcu/kiv/offscreen/graph/AttributeType.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.graph; |
|
2 | ||
3 |
/** |
|
4 |
* Class represents one attribute type which is used in input JSON file and in output JSON file (file between frontend |
|
5 |
* and backend). |
|
6 |
*/ |
|
7 |
public class AttributeType { |
|
8 |
/** name of attribute */ |
|
9 |
public String name; |
|
10 |
/** data type of attribute */ |
|
11 |
public GraphManager.AttributeDataType dataType; |
|
12 |
/** additional info */ |
|
13 |
public String text; |
|
14 | ||
15 |
public AttributeType(String name, GraphManager.AttributeDataType dataType, String text) { |
|
16 |
this.name = name; |
|
17 |
this.dataType = dataType; |
|
18 |
this.text = text; |
|
19 |
} |
|
20 | ||
21 |
public String getName() { |
|
22 |
return name; |
|
23 |
} |
|
24 | ||
25 |
public GraphManager.AttributeDataType getDataType() { |
|
26 |
return dataType; |
|
27 |
} |
|
28 | ||
29 |
public String getText() { |
|
30 |
return text; |
|
31 |
} |
|
32 |
} |
sources/src/cz/zcu/kiv/offscreen/graph/EdgeArchetype.java | ||
---|---|---|
12 | 12 |
public String getName() { |
13 | 13 |
return name; |
14 | 14 |
} |
15 | ||
16 |
public String getText() { |
|
17 |
return text; |
|
18 |
} |
|
15 | 19 |
} |
sources/src/cz/zcu/kiv/offscreen/graph/EdgeData.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.graph; |
|
2 | ||
3 |
import java.util.*; |
|
4 | ||
5 |
public class EdgeData { |
|
6 |
public int id; |
|
7 |
public int from; |
|
8 |
public int to; |
|
9 |
public String text; |
|
10 |
public int archetypeIndex; |
|
11 |
public Map<Integer, Attribute> attributes = new HashMap<>(); |
|
12 | ||
13 |
public EdgeData(int id, int from, int to, String text, int archetypeIndex) { |
|
14 |
this.id = id; |
|
15 |
this.from = from; |
|
16 |
this.to = to; |
|
17 |
this.text = text; |
|
18 |
this.archetypeIndex = archetypeIndex; |
|
19 |
} |
|
20 | ||
21 |
public void addAttribute(int attrTypeIndex, Object value) { |
|
22 |
Attribute attr = new Attribute(attrTypeIndex, value); |
|
23 |
attributes.put(attrTypeIndex, attr); |
|
24 |
} |
|
25 | ||
26 |
public void addAttributes(Map<Integer, Attribute> attributes) { |
|
27 |
this.attributes.putAll(attributes); |
|
28 |
} |
|
29 | ||
30 |
public Attribute getAttribute(int attrTypeIndex) { |
|
31 |
return attributes.get(attrTypeIndex); |
|
32 |
} |
|
33 | ||
34 |
@Override |
|
35 |
public int hashCode() { |
|
36 |
return from * 100000 + to; |
|
37 |
} |
|
38 | ||
39 |
@Override |
|
40 |
public boolean equals(Object edge) { |
|
41 |
return from == ((EdgeData) edge).from && to == ((EdgeData) edge).to; |
|
42 |
} |
|
43 | ||
44 |
public List<Attribute> getSortedAttributes() { |
|
45 |
List<Attribute> list = new ArrayList<>(); |
|
46 |
ArrayList<Integer> indices = new ArrayList<>(attributes.keySet()); |
|
47 |
//indices.sort(Integer::compareTo); |
|
48 |
Collections.sort(indices); // TODO check correct order |
|
49 |
for (int i = 0; i < indices.size(); i++) { |
|
50 |
list.add(attributes.get(indices.get(i))); |
|
51 |
} |
|
52 |
return list; |
|
53 |
} |
|
54 |
} |
sources/src/cz/zcu/kiv/offscreen/graph/EdgeEfp.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.graph; |
|
2 | ||
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 | ||
6 |
import org.apache.log4j.Logger; |
|
7 | ||
8 |
import cz.zcu.kiv.offscreen.api.EdgeInterface; |
|
9 |
import cz.zcu.kiv.offscreen.graph.efp.EfpFeature; |
|
10 | ||
11 |
/** |
|
12 |
* |
|
13 |
* @author Jiri Loudil |
|
14 |
* |
|
15 |
*/ |
|
16 |
public class EdgeEfp implements EdgeInterface { |
|
17 |
private int edgeId; |
|
18 |
private String from; |
|
19 |
private String to; |
|
20 |
|
|
21 |
private boolean edgeStatusOk; |
|
22 |
private ArrayList<EfpFeature> features; |
|
23 | ||
24 |
private Logger logger = Logger.getLogger(EdgeEfp.class); |
|
25 | ||
26 |
/** |
|
27 |
* Inicialization of edge. |
|
28 |
* |
|
29 |
* @param edgeId |
|
30 |
* id of edge |
|
31 |
* @param from |
|
32 |
* name of vertex which leads from the edge |
|
33 |
* @param to |
|
34 |
* name of vertex which leads to the edge |
|
35 |
*/ |
|
36 |
public EdgeEfp(int edgeId, String from, String to) { |
|
37 |
logger.trace("ENTRY"); |
|
38 |
this.edgeId = edgeId; |
|
39 |
this.from = from; |
|
40 |
this.to = to; |
|
41 |
|
|
42 |
this.edgeStatusOk = true; |
|
43 |
this.features = new ArrayList<EfpFeature>(); |
|
44 |
logger.trace("EXIT"); |
|
45 |
} |
|
46 | ||
47 |
@Override |
|
48 |
public String getFrom() { |
|
49 |
logger.trace("ENTRY"); |
|
50 |
logger.trace("EXIT"); |
|
51 |
return from; |
|
52 | ||
53 |
} |
|
54 | ||
55 |
@Override |
|
56 |
public String getTo() { |
|
57 |
logger.trace("ENTRY"); |
|
58 |
logger.trace("EXIT"); |
|
59 |
return to; |
|
60 |
} |
|
61 | ||
62 |
@Override |
|
63 |
public int getId() { |
|
64 |
logger.trace("ENTRY"); |
|
65 |
logger.trace("EXIT"); |
|
66 |
return edgeId; |
|
67 |
} |
|
68 | ||
69 |
@Override |
|
70 |
public List<SubedgeInfo> getSubedgeInfo() { |
|
71 |
return null; |
|
72 |
} |
|
73 | ||
74 |
@Override |
|
75 |
public void setSubedgeInfo(List<SubedgeInfo> subedgeInfo) { |
|
76 |
// TODO 30.7.2018 empty body (copy from CoCaEx ASWI) |
|
77 |
} |
|
78 | ||
79 |
public ArrayList<EfpFeature> getFeatures() { |
|
80 |
return features; |
|
81 |
} |
|
82 | ||
83 |
public boolean isEdgeStatusOk() { |
|
84 |
return edgeStatusOk; |
|
85 |
} |
|
86 | ||
87 |
public void setEdgeStatusOk(boolean edgeStatusOk) { |
|
88 |
this.edgeStatusOk = edgeStatusOk; |
|
89 |
} |
|
90 | ||
91 |
} |
sources/src/cz/zcu/kiv/offscreen/graph/EdgeImpl.java | ||
---|---|---|
1 | 1 |
package cz.zcu.kiv.offscreen.graph; |
2 | 2 | |
3 |
import cz.zcu.kiv.offscreen.api.EdgeInterface; |
|
4 |
import java.util.LinkedList; |
|
5 |
import java.util.List; |
|
6 |
import org.apache.log4j.Logger; |
|
3 |
import cz.zcu.kiv.offscreen.api.BaseEdge; |
|
4 | ||
5 |
import java.util.*; |
|
7 | 6 | |
8 | 7 |
/** |
9 |
* This class represents edge. |
|
10 |
* |
|
11 |
* @author Jindra Pavlíková |
|
8 |
* Class represents edge which is used for input JSON format. |
|
12 | 9 |
*/ |
13 |
public class EdgeImpl implements EdgeInterface {
|
|
10 |
public class EdgeImpl extends BaseEdge {
|
|
14 | 11 | |
15 |
private int edgeId; |
|
16 |
private String from; |
|
17 |
private String to; |
|
18 |
private List<String> packageConnections; |
|
19 |
private boolean isCompatible; |
|
20 |
private List<SubedgeInfo> subedgeInfo; |
|
21 |
private String compInfoJSON; |
|
22 |
private Logger logger = Logger.getLogger(EdgeImpl.class); |
|
12 |
/** original identification number which is defined in input file */ |
|
13 |
private int originalId; |
|
14 |
/** index of edge archetype */ |
|
15 |
private int archetypeIndex; |
|
16 |
/** Map contains attributes stored in key value format. Key is index to array of attribute types defined in input file */ |
|
17 |
private Map<Integer, Attribute> attributesMap; |
|
23 | 18 | |
24 | 19 |
/** |
25 |
* Inicialization of edge. |
|
26 |
* |
|
27 |
* @param edgeId id of edge |
|
28 |
* @param from name of vertex which leads from the edge |
|
29 |
* @param to name of vertex which leads to the edge |
|
20 |
* Create new edge. |
|
21 |
* @param id new generated identification number |
|
22 |
* @param from original ID of vertex from edge leads |
|
23 |
* @param to original ID of vertex where edge leads |
|
24 |
* @param text additional info |
|
25 |
* @param originalId original identification number which is defined in input file |
|
26 |
* @param archetypeIndex index of edge archetype |
|
30 | 27 |
*/ |
31 |
public EdgeImpl(int edgeId, String from, String to, boolean isCompatible, String compInfoJSON) { |
|
32 |
logger.trace("ENTRY"); |
|
33 |
this.edgeId = edgeId; |
|
34 |
this.from = from; |
|
35 |
this.to = to; |
|
36 |
this.packageConnections = new LinkedList<String>(); |
|
37 |
this.isCompatible = isCompatible; |
|
38 |
this.compInfoJSON = compInfoJSON; |
|
39 |
logger.trace("EXIT"); |
|
28 |
public EdgeImpl(int id, int from, int to, String text, int originalId, int archetypeIndex) { |
|
29 |
super(id, from, to, text); |
|
30 |
this.originalId = originalId; |
|
31 |
this.archetypeIndex = archetypeIndex; |
|
32 |
this.attributesMap = new HashMap<>(); |
|
40 | 33 |
} |
41 | 34 | |
42 |
@Override |
|
43 |
public String getFrom() { |
|
44 |
logger.trace("ENTRY"); |
|
45 |
logger.trace("EXIT"); |
|
46 |
return from; |
|
47 | ||
35 |
public Attribute getAttribute(int attrTypeIndex) { |
|
36 |
return attributesMap.get(attrTypeIndex); |
|
48 | 37 |
} |
49 | 38 | |
50 |
@Override |
|
51 |
public String getTo() { |
|
52 |
logger.trace("ENTRY"); |
|
53 |
logger.trace("EXIT"); |
|
54 |
return to; |
|
39 |
public Map<Integer, Attribute> getAttributesMap() { |
|
40 |
return attributesMap; |
|
55 | 41 |
} |
56 | 42 | |
57 |
@Override |
|
58 |
public int getId() { |
|
59 |
logger.trace("ENTRY"); |
|
60 |
logger.trace("EXIT"); |
|
61 |
return edgeId; |
|
62 |
} |
|
63 | 43 | |
64 |
@Override |
|
65 |
public List<SubedgeInfo> getSubedgeInfo() { |
|
66 |
return subedgeInfo; |
|
44 |
public int getOriginalId() { |
|
45 |
return originalId; |
|
67 | 46 |
} |
68 | 47 | |
69 |
@Override |
|
70 |
public void setSubedgeInfo(List<SubedgeInfo> subedgeInfo) {
|
|
71 |
this.subedgeInfo = subedgeInfo;
|
|
48 | ||
49 |
public int getArchetype() {
|
|
50 |
return archetypeIndex;
|
|
72 | 51 |
} |
73 | 52 | |
74 |
@Override |
|
75 |
public boolean equals(Object edge) { |
|
76 |
if (!(edge instanceof EdgeImpl)) return false; |
|
77 |
EdgeImpl cmpEdge = (EdgeImpl) edge; |
|
78 |
return from.equals(cmpEdge.from) && to.equals(cmpEdge.to); |
|
53 | ||
54 |
public void addAttribute(int attrTypeIndex, Object value) { |
|
55 |
Attribute attr = new Attribute(attrTypeIndex, value); |
|
56 |
attributesMap.put(attrTypeIndex, attr); |
|
79 | 57 |
} |
80 | 58 | |
81 |
public List<String> getPackageConnections() { |
|
82 |
logger.trace("ENTRY"); |
|
83 |
logger.trace("EXIT"); |
|
84 |
return this.packageConnections; |
|
59 |
public void addAttributes(Map<Integer, Attribute> attributes) { |
|
60 |
this.attributesMap.putAll(attributes); |
|
85 | 61 |
} |
86 | 62 | |
87 |
public void setPackageConnections(List<String> packageConnections) { |
|
88 |
logger.trace("ENTRY"); |
|
89 |
this.packageConnections = packageConnections; |
|
90 |
logger.trace("EXIT"); |
|
63 |
public void setOriginalId(int originalId) { |
|
64 |
this.originalId = originalId; |
|
91 | 65 |
} |
92 |
|
|
93 |
public boolean getIsCompatible() {
|
|
94 |
return isCompatible;
|
|
66 | ||
67 |
public void setArchetypeIndex(int archetypeIndex) {
|
|
68 |
this.archetypeIndex = archetypeIndex;
|
|
95 | 69 |
} |
96 |
|
|
97 |
public String getCompInfoJSON() { |
|
98 |
return compInfoJSON; |
|
70 | ||
71 |
/** |
|
72 |
* Return list of attributes sorted by their key value in {@code attributeMap} |
|
73 |
* @return sorted list |
|
74 |
*/ |
|
75 |
public List<Attribute> getSortedAttributes() { |
|
76 |
List<Attribute> list = new ArrayList<>(); |
|
77 |
ArrayList<Integer> indices = new ArrayList<>(attributesMap.keySet()); |
|
78 |
//indices.sort(Integer::compareTo); |
|
79 |
Collections.sort(indices); |
|
80 |
for (Integer index : indices) { |
|
81 |
list.add(attributesMap.get(index)); |
|
82 |
} |
|
83 |
return list; |
|
99 | 84 |
} |
100 |
|
|
101 | 85 |
} |
sources/src/cz/zcu/kiv/offscreen/graph/Graph.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.graph; |
|
2 | ||
3 |
import cz.zcu.kiv.offscreen.api.Edge; |
|
4 |
import cz.zcu.kiv.offscreen.api.Vertex; |
|
5 |
import org.apache.log4j.Logger; |
|
6 | ||
7 |
import java.util.HashMap; |
|
8 |
import java.util.LinkedList; |
|
9 |
import java.util.List; |
|
10 |
import java.util.Map; |
|
11 | ||
12 |
/** |
|
13 |
* Class represents graph which is loaded from input JSON file. |
|
14 |
*/ |
|
15 |
public class Graph { |
|
16 | ||
17 |
private Map<String, Vertex> vertices; |
|
18 |
private List<Edge> edges; |
|
19 |
private List<VertexArchetype> vertexArchetypes; |
|
20 |
private List<EdgeArchetype> edgeArchetypes; |
|
21 |
private List<AttributeType> attributeTypes; |
|
22 |
private Map<String, List<String>> possibleEnumValues; |
|
23 |
private List<String> defaultGroupArchetypes; |
|
24 | ||
25 |
private Map<String, String> archetypeIcons; |
|
26 |
private Logger logger = Logger.getLogger(Graph.class); |
|
27 | ||
28 |
public Graph() { |
|
29 |
logger.trace("ENTRY"); |
|
30 |
this.vertices = new HashMap<String, Vertex>(); |
|
31 |
this.edges = new LinkedList<Edge>(); |
|
32 |
logger.trace("EXIT"); |
|
33 |
} |
|
34 | ||
35 |
public List<Edge> getEdges() { |
|
36 |
logger.trace("ENTRY"); |
|
37 |
logger.trace("EXIT"); |
|
38 |
return edges; |
|
39 |
} |
|
40 | ||
41 |
public List<VertexArchetype> getVertexArchetypes() { |
|
42 |
return vertexArchetypes; |
|
43 |
} |
|
44 | ||
45 |
public List<EdgeArchetype> getEdgeArchetypes() { |
|
46 |
return edgeArchetypes; |
|
47 |
} |
|
48 | ||
49 |
public void setVertexArchetypes(List<VertexArchetype> vertexArchetypes) { |
|
50 |
this.vertexArchetypes = vertexArchetypes; |
|
51 |
} |
|
52 | ||
53 |
public void setEdgeArchetypes(List<EdgeArchetype> edgeArchetypes) { |
|
54 |
this.edgeArchetypes = edgeArchetypes; |
|
55 |
} |
|
56 | ||
57 |
public void setAttributeTypes(List<AttributeType> attributeTypes) { |
|
58 |
this.attributeTypes = attributeTypes; |
|
59 |
} |
|
60 | ||
61 |
public void setPossibleEnumValues(Map<Integer, List<String>> possibleEnumValues) { |
|
62 |
this.possibleEnumValues = new HashMap<>(); |
|
63 |
for (Integer index : possibleEnumValues.keySet()) { |
|
64 |
this.possibleEnumValues.put("" + index, possibleEnumValues.get(index)); |
|
65 |
} |
|
66 |
} |
|
67 | ||
68 |
public void setArchetypeIcons(Map<String, String> archetypeIcons) { |
|
69 |
this.archetypeIcons = archetypeIcons; |
|
70 |
} |
|
71 | ||
72 |
public List<String> getDefaultGroupArchetypes() { |
|
73 |
return defaultGroupArchetypes; |
|
74 |
} |
|
75 | ||
76 |
public void setDefaultGroupArchetypes(List<String> defaultGroupArchetypes) { |
|
77 |
this.defaultGroupArchetypes = defaultGroupArchetypes; |
|
78 |
} |
|
79 | ||
80 |
public List<AttributeType> getAttributeTypes() { |
|
81 |
return attributeTypes; |
|
82 |
} |
|
83 | ||
84 |
public Map<String, List<String>> getPossibleEnumValues() { |
|
85 |
return possibleEnumValues; |
|
86 |
} |
|
87 | ||
88 |
public Map<String, String> getArchetypeIcons() { |
|
89 |
return archetypeIcons; |
|
90 |
} |
|
91 | ||
92 |
public Map<String, Vertex> getVertices() { |
|
93 |
logger.trace("ENTRY"); |
|
94 |
logger.trace("EXIT"); |
|
95 |
return vertices; |
|
96 |
} |
|
97 | ||
98 |
public void addEdge(Edge edge) { |
|
99 |
logger.trace("ENTRY"); |
|
100 |
this.edges.add(edge); |
|
101 |
logger.trace("EXIT"); |
|
102 |
} |
|
103 | ||
104 |
public void addVertex(String name, Vertex vertex) { |
|
105 |
logger.trace("ENTRY"); |
|
106 |
this.vertices.put(name, vertex); |
|
107 |
logger.trace("EXIT"); |
|
108 |
} |
|
109 |
} |
sources/src/cz/zcu/kiv/offscreen/graph/GraphExport.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.graph; |
|
2 | ||
3 |
import cz.zcu.kiv.offscreen.AttributeType; |
|
4 |
import cz.zcu.kiv.offscreen.api.EdgeInterface; |
|
5 |
import cz.zcu.kiv.offscreen.api.GraphInterface; |
|
6 |
import cz.zcu.kiv.offscreen.api.VertexInterface; |
|
7 |
import java.util.ArrayList; |
|
8 |
import java.util.List; |
|
9 |
import java.util.Map; |
|
10 | ||
11 |
import org.apache.log4j.Logger; |
|
12 | ||
13 |
/* |
|
14 |
* To change this template, choose Tools | Templates and open the template in |
|
15 |
* the editor. |
|
16 |
*/ |
|
17 |
/** |
|
18 |
* |
|
19 |
* @author Jindra Pavlíková <jindra.pav2@seznam.cz> |
|
20 |
*/ |
|
21 |
public class GraphExport { |
|
22 | ||
23 |
private List<VertexInterface> vertices; |
|
24 |
private List<EdgeInterface> edges; |
|
25 |
private List<VertexArchetype> vertexArchetypes; |
|
26 |
private List<EdgeArchetype> edgeArchetypes; |
|
27 |
private List<AttributeType> attributeTypes; |
|
28 |
private Map<String, List<String>> possibleEnumValues; |
|
29 |
private Map<String, String> archetypeIcons; |
|
30 |
private List<Integer> defaultGroupArchetypes; |
|
31 | ||
32 |
private Logger logger = Logger.getLogger(GraphExport.class); |
|
33 | ||
34 |
public GraphExport(GraphInterface graph) { |
|
35 |
logger.trace("ENTRY"); |
|
36 |
this.vertices = new ArrayList<VertexInterface>(graph.getVertices().values()); |
|
37 |
this.edges = new ArrayList<EdgeInterface>(graph.getEdges()); |
|
38 |
this.vertexArchetypes = new ArrayList<VertexArchetype>(graph.getVertexArchetypes()); |
|
39 |
this.edgeArchetypes = new ArrayList<EdgeArchetype>(graph.getEdgeArchetypes()); |
|
40 |
this.attributeTypes = new ArrayList<>(graph.getAttributeTypes()); |
|
41 |
this.possibleEnumValues = graph.getPossibleEnumValues(); |
|
42 |
this.archetypeIcons = graph.getArchetypeIcons(); |
|
43 |
this.defaultGroupArchetypes = graph.getDefaultGroupArchetypes(); |
|
44 |
logger.trace("EXIT"); |
|
45 |
} |
|
46 | ||
47 |
public List<EdgeInterface> getEdges() { |
|
48 |
logger.trace("ENTRY"); |
|
49 |
logger.trace("EXIT"); |
|
50 |
return edges; |
|
51 |
} |
|
52 | ||
53 |
public List<VertexInterface> getVertices() { |
|
54 |
logger.trace("ENTRY"); |
|
55 |
logger.trace("EXIT"); |
|
56 |
return vertices; |
|
57 |
} |
|
58 | ||
59 |
public List<VertexArchetype> getVertexArchetypes() { |
|
60 |
return vertexArchetypes; |
|
61 |
} |
|
62 | ||
63 |
public List<EdgeArchetype> getEdgeArchetypes() { |
|
64 |
return edgeArchetypes; |
|
65 |
} |
|
66 | ||
67 |
public List<AttributeType> getAttributeTypes() { |
|
68 |
return attributeTypes; |
|
69 |
} |
|
70 | ||
71 |
public Map<String, List<String>> getPossibleEnumValues() { |
|
72 |
return possibleEnumValues; |
|
73 |
} |
|
74 | ||
75 |
public Map<String, String> getArchetypeIcons() { |
|
76 |
return archetypeIcons; |
|
77 |
} |
|
78 | ||
79 |
public List<Integer> getDefaultGroupArchetypes() { |
|
80 |
return defaultGroupArchetypes; |
|
81 |
} |
|
82 |
} |
sources/src/cz/zcu/kiv/offscreen/graph/GraphImpl.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.graph; |
|
2 | ||
3 |
import cz.zcu.kiv.offscreen.AttributeType; |
|
4 |
import cz.zcu.kiv.offscreen.api.EdgeInterface; |
|
5 |
import cz.zcu.kiv.offscreen.api.GraphInterface; |
|
6 |
import cz.zcu.kiv.offscreen.api.VertexInterface; |
|
7 |
import java.util.HashMap; |
|
8 |
import java.util.LinkedList; |
|
9 |
import java.util.List; |
|
10 |
import java.util.Map; |
|
11 |
import org.apache.log4j.Logger; |
|
12 | ||
13 |
/** |
|
14 |
* |
|
15 |
* @author Jindra Pavlíková |
|
16 |
*/ |
|
17 |
public class GraphImpl implements GraphInterface { |
|
18 | ||
19 |
private Map<String, VertexInterface> vertices; |
|
20 |
private List<EdgeInterface> edges; |
|
21 |
private Logger logger = Logger.getLogger(GraphImpl.class); |
|
22 |
private List<VertexArchetype> vertexArchetypes; |
Také k dispozici: Unified diff
Changed format of JSON between frontend and backend.