Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 407673fa

Přidáno uživatelem Tomáš Šimandl před asi 6 roky(ů)

api.GraphExport rename

Zobrazit rozdíly:

sources/src/main/java/cz/zcu/kiv/offscreen/api/Graph.java
1
package cz.zcu.kiv.offscreen.api;
2

  
3
import cz.zcu.kiv.offscreen.graph.*;
4

  
5
import java.util.List;
6
import java.util.Map;
7
import java.util.Set;
8

  
9
import org.apache.log4j.Logger;
10

  
11
/**
12
 * Class represents graph with all information about graph plus information about state in which used store graph.
13
 * Class is used for creating of JSON which is send to frontend.
14
 */
15
public class Graph {
16

  
17
    private Set<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

  
24
    private List<Group> groups;
25
    private List<SideBar> sideBar;
26
    private int selectedVertex;
27
    private int selectedEdge;
28

  
29
    private Logger logger = Logger.getLogger(Graph.class);
30

  
31
    public Graph(cz.zcu.kiv.offscreen.graph.Graph graph) {
32
        logger.trace("ENTRY");
33
        this.vertices = graph.getVertices();
34
        this.edges = graph.getEdges();
35
        this.vertexArchetypes = graph.getVertexArchetypes();
36
        this.edgeArchetypes = graph.getEdgeArchetypes();
37
        this.attributeTypes = graph.getAttributeTypes();
38
        this.possibleEnumValues = graph.getPossibleEnumValues();
39
        this.groups = graph.getGraphState().getGroups();
40
        this.sideBar = graph.getGraphState().getSideBar();
41
        this.selectedVertex = graph.getGraphState().getSelectedVertex();
42
        this.selectedEdge = graph.getGraphState().getSelectedEdge();
43
        logger.trace("EXIT");
44
    }
45

  
46
    public List<Edge> getEdges() {
47
        logger.trace("ENTRY");
48
        logger.trace("EXIT");
49
        return edges;
50
    }
51

  
52
    public Set<Vertex> getVertices() {
53
        logger.trace("ENTRY");
54
        logger.trace("EXIT");
55
        return vertices;
56
    }
57

  
58
    public List<VertexArchetype> getVertexArchetypes() {
59
        return vertexArchetypes;
60
    }
61

  
62
    public List<EdgeArchetype> getEdgeArchetypes() {
63
        return edgeArchetypes;
64
    }
65

  
66
    public List<AttributeType> getAttributeTypes() {
67
        return attributeTypes;
68
    }
69

  
70
    public Map<String, List<String>> getPossibleEnumValues() {
71
        return possibleEnumValues;
72
    }
73

  
74
    public List<Group> getGroups() {
75
        return groups;
76
    }
77

  
78
    public List<SideBar> getSideBar() {
79
        return sideBar;
80
    }
81

  
82
    public int getSelectedVertex() {
83
        return selectedVertex;
84
    }
85

  
86
    public int getSelectedEdge() {
87
        return selectedEdge;
88
    }
89
}
sources/src/main/java/cz/zcu/kiv/offscreen/api/GraphExport.java
1
package cz.zcu.kiv.offscreen.api;
2

  
3
import cz.zcu.kiv.offscreen.graph.*;
4

  
5
import java.util.ArrayList;
6
import java.util.List;
7
import java.util.Map;
8
import java.util.Set;
9

  
10
import org.apache.log4j.Logger;
11

  
12
/**
13
 * Class represents graph with all information about graph plus information about state in which used store graph.
14
 * Class is used for creating of JSON which is send to frontend.
15
 */
16
public class GraphExport {
17

  
18
    private Set<Vertex> vertices;
19
    private List<Edge> edges;
20
    private List<VertexArchetype> vertexArchetypes;
21
    private List<EdgeArchetype> edgeArchetypes;
22
    private List<AttributeType> attributeTypes;
23
    private Map<String, List<String>> possibleEnumValues;
24

  
25
    private List<Group> groups;
26
    private List<SideBar> sideBar;
27
    private int selectedVertex;
28
    private int selectedEdge;
29

  
30
    private Logger logger = Logger.getLogger(GraphExport.class);
31

  
32
    public GraphExport(Graph graph) {
33
        logger.trace("ENTRY");
34
        this.vertices = graph.getVertices();
35
        this.edges = graph.getEdges();
36
        this.vertexArchetypes = graph.getVertexArchetypes();
37
        this.edgeArchetypes = graph.getEdgeArchetypes();
38
        this.attributeTypes = graph.getAttributeTypes();
39
        this.possibleEnumValues = graph.getPossibleEnumValues();
40
        this.groups = graph.getGraphState().getGroups();
41
        this.sideBar = graph.getGraphState().getSideBar();
42
        this.selectedVertex = graph.getGraphState().getSelectedVertex();
43
        this.selectedEdge = graph.getGraphState().getSelectedEdge();
44
        logger.trace("EXIT");
45
    }
46

  
47
    public List<Edge> getEdges() {
48
        logger.trace("ENTRY");
49
        logger.trace("EXIT");
50
        return edges;
51
    }
52

  
53
    public Set<Vertex> 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 List<Group> getGroups() {
76
        return groups;
77
    }
78

  
79
    public List<SideBar> getSideBar() {
80
        return sideBar;
81
    }
82

  
83
    public int getSelectedVertex() {
84
        return selectedVertex;
85
    }
86

  
87
    public int getSelectedEdge() {
88
        return selectedEdge;
89
    }
90
}
sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/LoadGraphData.java
1 1
package cz.zcu.kiv.offscreen.servlets.api;
2 2

  
3 3
import com.google.common.base.Strings;
4
import cz.zcu.kiv.offscreen.api.GraphExport;
5
import cz.zcu.kiv.offscreen.graph.Graph;
4
import cz.zcu.kiv.offscreen.api.Graph;
6 5
import cz.zcu.kiv.offscreen.graph.GraphManager;
7 6
import cz.zcu.kiv.offscreen.graph.loader.DemoDiagramLoader;
8 7
import cz.zcu.kiv.offscreen.graph.loader.GraphJSONDataLoader;
......
56 55
            GraphManager graphManager = new GraphJSONDataLoader(jsonToDisplay).LoadData();
57 56
            String configLocation = ConfigurationLoader.getConfigLocation(request.getServletContext());
58 57
            JSONConfigLoader configLoader = new JSONConfigLoader(graphManager, configLocation);
59
            Graph graph = graphManager.createGraph(configLoader);
60
            GraphExport export = new GraphExport(graph);
58
            cz.zcu.kiv.offscreen.graph.Graph graph = graphManager.createGraph(configLoader);
59
            Graph export = new Graph(graph);
61 60
            JSONObject json = JSONObject.fromObject(export);
62 61

  
63 62
            response.setStatus(HttpServletResponse.SC_OK);

Také k dispozici: Unified diff