Projekt

Obecné

Profil

« Předchozí | Další » 

Revize bb5a2d83

Přidáno uživatelem Tomáš Šimandl před více než 6 roky(ů)

Removed archetypeIcons array and added icon to vertexArchetypes

Zobrazit rozdíly:

sources/src/main/java/cz/zcu/kiv/offscreen/api/GraphExport.java
20 20
    private List<EdgeArchetype> edgeArchetypes;
21 21
    private List<AttributeType> attributeTypes;
22 22
    private Map<String, List<String>> possibleEnumValues;
23
    private Map<String, String> archetypeIcons;
24 23

  
25 24
    private List<Group> groups;
26 25
    private List<Position> positions;
......
38 37
        this.edgeArchetypes = new ArrayList<>(graph.getEdgeArchetypes());
39 38
        this.attributeTypes = new ArrayList<>(graph.getAttributeTypes());
40 39
        this.possibleEnumValues = graph.getPossibleEnumValues();
41
        this.archetypeIcons = graph.getArchetypeIcons();
42 40
        this.groups = graph.getGraphState().getGroups();
43 41
        this.positions = graph.getGraphState().getPositions();
44 42
        this.sideBar = graph.getGraphState().getSideBar();
......
75 73
        return possibleEnumValues;
76 74
    }
77 75

  
78
    public Map<String, String> getArchetypeIcons() {
79
        return archetypeIcons;
80
    }
81

  
82 76
    public List<Group> getGroups() {
83 77
        return groups;
84 78
    }
sources/src/main/java/cz/zcu/kiv/offscreen/graph/Graph.java
21 21
    private List<AttributeType> attributeTypes;
22 22
    private Map<String, List<String>> possibleEnumValues;
23 23
    private List<String> defaultGroupArchetypes;
24
    private Map<String, String> archetypeIcons;
25 24

  
26 25
    private GraphState graphState;
27 26

  
......
67 66
        }
68 67
    }
69 68

  
70
    public void setArchetypeIcons(Map<String, String> archetypeIcons) {
71
        this.archetypeIcons = archetypeIcons;
72
    }
73

  
74 69
    public List<String> getDefaultGroupArchetypes() {
75 70
        return defaultGroupArchetypes;
76 71
    }
......
87 82
        return possibleEnumValues;
88 83
    }
89 84

  
90
    public Map<String, String> getArchetypeIcons() {
91
        return archetypeIcons;
92
    }
93

  
94 85
    public Map<Integer, Vertex> getVertices() {
95 86
        logger.trace("ENTRY");
96 87
        logger.trace("EXIT");
sources/src/main/java/cz/zcu/kiv/offscreen/graph/GraphManager.java
266 266
        if (filter == null) {
267 267
            // To Enable Everything
268 268
            filter = new GraphFilter();
269
            filter.setVertexArchetypeFilter(new ArrayList<Integer>(), GraphFilter.ArchetypeMatchType.NON_MATCHING);
270
            filter.setEdgeArchetypeFilter(new ArrayList<EdgeArchetypeInfo>(), GraphFilter.ArchetypeMatchType.NON_MATCHING);
269
            filter.setVertexArchetypeFilter(new ArrayList<>(), GraphFilter.ArchetypeMatchType.NON_MATCHING);
270
            filter.setEdgeArchetypeFilter(new ArrayList<>(), GraphFilter.ArchetypeMatchType.NON_MATCHING);
271 271
        }
272 272

  
273
        Map<String, String> archetypeIcons = configLoader.loadArchetypeIcons();
274
        graph.setArchetypeIcons(archetypeIcons);
275 273

  
276 274
        List<String> defaultGroupArchetypes = configLoader.loadGroupArchetypesStrings();
277 275
        graph.setDefaultGroupArchetypes(defaultGroupArchetypes);
278 276

  
279

  
280

  
281

  
282 277
        Set<VertexImpl> resultVertices = getVerticesByArchetypeFilter(filter);
283

  
284 278
        resultVertices = getVerticesByAttributeFilter(filter, resultVertices);
285

  
286 279
        List<EdgeImpl> resultEdges = getEdgesByArchetypeFilter(filter, resultVertices);
287

  
288 280
        resultEdges = getEdgesByAttributeFilter(filter, resultEdges);
289 281

  
290 282
        addVerticesToGraph(graph, resultVertices);
291

  
292 283
        addEdgesToGraph(graph, resultEdges);
293 284

  
285
        Map<String, String> archetypeIcons = configLoader.loadArchetypeIcons();
286
        addVertexArchetypes(graph, archetypeIcons);
287
        graph.setEdgeArchetypes(edgeArchetypes);
288

  
294 289
        graph.setAttributeTypes(attributeTypes);
295 290
        graph.setPossibleEnumValues(possibleEnumValues);
296 291

  
......
493 488
            Edge edge = new Edge(idCounter++, edgeImpl.getFrom(), edgeImpl.getTo(), edgeImpl.getText(), edgeSet.get(edgeImpl));
494 489
            graph.addEdge(edge);
495 490
        }
491
    }
492

  
493
    /**
494
     * Adds icons from input map to vertexArchetypes and add archetypes to graph.
495
     *
496
     * @param graph - Graph in which will be set vertex archetypes
497
     * @param archetypeIcons Map where key is archetype name and value is svg icon.
498
     */
499
    private void addVertexArchetypes(Graph graph, Map<String, String> archetypeIcons){
500

  
501
        for(VertexArchetype archetype : vertexArchetypes){
502
            for(String archetypeName : archetypeIcons.keySet()){
503

  
504
                if(archetype.name.equals(archetypeName)){
505
                    archetype.icon = archetypeIcons.get(archetypeName);
506
                    break;
507
                }
508
            }
509
        }
496 510
        graph.setVertexArchetypes(vertexArchetypes);
497
        graph.setEdgeArchetypes(edgeArchetypes);
498 511
    }
499 512

  
500 513
    /**
sources/src/main/java/cz/zcu/kiv/offscreen/graph/VertexArchetype.java
3 3
public class VertexArchetype {
4 4
    public String name;
5 5
    public String text;
6
    public String icon;
6 7

  
7
    VertexArchetype(String name, String text) {
8
    VertexArchetype(String name, String text, String icon) {
8 9
        this.name = name;
9 10
        this.text = text;
11
        this.icon = icon;
12
    }
13

  
14
    VertexArchetype(String name, String text) {
15
        this(name, text, "");
10 16
    }
11 17

  
12 18
    public String getName() {
......
16 22
    public String getText() {
17 23
        return text;
18 24
    }
25

  
26
    public String getIcon() {
27
        return icon;
28
    }
19 29
}

Také k dispozici: Unified diff