commit 918e91a9336fb7fbfee19fc284ad55c5610cbcba
Author: Tomáš Šimandl <tomas.simandl@gmail.com>
Date:   Fri Nov 23 12:51:54 2018 +0100

    Resolve exceptions when config file is not defined

diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/graph/filter/GraphFilter.java b/sources/src/main/java/cz/zcu/kiv/offscreen/graph/filter/GraphFilter.java
index ce36932..2d0b287 100644
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/graph/filter/GraphFilter.java
+++ b/sources/src/main/java/cz/zcu/kiv/offscreen/graph/filter/GraphFilter.java
@@ -3,6 +3,7 @@ package cz.zcu.kiv.offscreen.graph.filter;
 import cz.zcu.kiv.offscreen.graph.EdgeArchetypeInfo;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -88,8 +89,8 @@ public class GraphFilter {
         REGULAR_EXPRESSION
     }
 
-    private VertexArchetypeFilter vertexArchetypeFilter;
-    private EdgeArchetypeFilter edgeArchetypeFilter;
+    private VertexArchetypeFilter vertexArchetypeFilter = new VertexArchetypeFilter(new ArrayList<>(), ArchetypeMatchType.NON_MATCHING);
+    private EdgeArchetypeFilter edgeArchetypeFilter = new EdgeArchetypeFilter(new ArrayList<>(), ArchetypeMatchType.NON_MATCHING);
 
     /**
      * key is the vertex archetype index, value is the filter object
@@ -118,11 +119,15 @@ public class GraphFilter {
     }
 
     public void setVertexArchetypeFilter(List<Integer> archetypeIndices, ArchetypeMatchType matchType) {
-        vertexArchetypeFilter = new VertexArchetypeFilter(archetypeIndices, matchType);
+        vertexArchetypeFilter.archetypeIndeces.clear();
+        vertexArchetypeFilter.archetypeIndeces.addAll(archetypeIndices);
+        vertexArchetypeFilter.matchType = matchType;
     }
 
     public void setEdgeArchetypeFilter(List<EdgeArchetypeInfo> archetypeIndices, ArchetypeMatchType matchType) {
-        edgeArchetypeFilter = new EdgeArchetypeFilter(archetypeIndices, matchType);
+        edgeArchetypeFilter.archetypeIndeces.clear();
+        edgeArchetypeFilter.archetypeIndeces.addAll(archetypeIndices);
+        edgeArchetypeFilter.matchType = matchType;
     }
 
     public void setVertexNumberAttributeFilter(int archetypeIndex, int attributeTypeIndex, BigDecimal min, BigDecimal max, boolean minInclusive, boolean maxInclusive, NumberMatchType matchType) {
diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/graph/loader/JSONConfigLoader.java b/sources/src/main/java/cz/zcu/kiv/offscreen/graph/loader/JSONConfigLoader.java
index b74d077..e562190 100644
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/graph/loader/JSONConfigLoader.java
+++ b/sources/src/main/java/cz/zcu/kiv/offscreen/graph/loader/JSONConfigLoader.java
@@ -67,7 +67,7 @@ public class JSONConfigLoader {
 
             createEdgeAttributeFilters(filter, edgeAttributeFilterStrings);
 
-        } catch (IOException e) {
+        } catch (IOException | NullPointerException e) {
             e.printStackTrace();
         }
 
@@ -347,15 +347,16 @@ public class JSONConfigLoader {
     public Map<String, String> loadArchetypeIcons() {
         Map<String, String> archetypeIcons = new HashMap<>();
 
-        JSONArray archetypeIconsJson = json.getJSONArray("archetypeIcons");
-        for (int i = 0; i < archetypeIconsJson.size(); i++) {
-            JSONObject icon = archetypeIconsJson.getJSONObject(i);
-            String archetypeName = icon.getString("name");
-            String iconSvg = icon.getString("value");
+        if (json != null){
+            JSONArray archetypeIconsJson = json.getJSONArray("archetypeIcons");
+            for (int i = 0; i < archetypeIconsJson.size(); i++) {
+                JSONObject icon = archetypeIconsJson.getJSONObject(i);
+                String archetypeName = icon.getString("name");
+                String iconSvg = icon.getString("value");
 
-            archetypeIcons.put(archetypeName, iconSvg);
+                archetypeIcons.put(archetypeName, iconSvg);
+            }
         }
-
         return archetypeIcons;
     }
 
@@ -366,10 +367,12 @@ public class JSONConfigLoader {
     public List<Integer> loadGroupArchetypes() {
         List<Integer> defaultGroupArchetypes = new ArrayList<>();
 
-        JSONArray defaultGroupArchetypesJson = json.getJSONArray("defaultGroupArchetypes");
-        for (int i = 0; i < defaultGroupArchetypesJson.size(); i++) {
-            String archetype = defaultGroupArchetypesJson.get(i).toString();
-            defaultGroupArchetypes.add(graphManager.getVertexArchetypeIndex(archetype));
+        if(json != null) {
+            JSONArray defaultGroupArchetypesJson = json.getJSONArray("defaultGroupArchetypes");
+            for (int i = 0; i < defaultGroupArchetypesJson.size(); i++) {
+                String archetype = defaultGroupArchetypesJson.get(i).toString();
+                defaultGroupArchetypes.add(graphManager.getVertexArchetypeIndex(archetype));
+            }
         }
 
         return defaultGroupArchetypes;
@@ -382,9 +385,11 @@ public class JSONConfigLoader {
     public List<String> loadGroupArchetypesStrings(){
         List<String> groupArchetypes = new ArrayList<>();
 
-        JSONArray defaultGroupArchetypesJson = json.getJSONArray("defaultGroupArchetypes");
-        for (Object jsonItem : defaultGroupArchetypesJson) {
-            groupArchetypes.add(jsonItem.toString());
+        if (json != null) {
+            JSONArray defaultGroupArchetypesJson = json.getJSONArray("defaultGroupArchetypes");
+            for (Object jsonItem : defaultGroupArchetypesJson) {
+                groupArchetypes.add(jsonItem.toString());
+            }
         }
         return groupArchetypes;
     }
