commit 7e9b305082cba9e82eda1eeee05548747a911770
Author: Patrik Harag <patrikharag@gmail.com>
Date:   Sun May 26 19:48:40 2019 +0200

    Make initial elimination optional (refs #7518)

diff --git a/sources/imiger-core/src/main/java/cz/zcu/kiv/offscreen/servlets/UploadFiles.java b/sources/imiger-core/src/main/java/cz/zcu/kiv/offscreen/servlets/UploadFiles.java
index 44bd59c..baca410 100644
--- a/sources/imiger-core/src/main/java/cz/zcu/kiv/offscreen/servlets/UploadFiles.java
+++ b/sources/imiger-core/src/main/java/cz/zcu/kiv/offscreen/servlets/UploadFiles.java
@@ -65,6 +65,7 @@ public class UploadFiles extends BaseServlet {
             Map<String, String> formFields = fileLoader.loadFormFields();
             String fileType = formFields.get("fileFormat");
             String fileName = formFields.get("filename");
+            String initialElimination = formFields.get("enableInitialElimination");
 
             if (fileType == null || fileName == null) {
                 throw new IllegalArgumentException("Missing parameter");
@@ -85,6 +86,8 @@ public class UploadFiles extends BaseServlet {
             request.getSession().setAttribute("diagram_string", fileContent);
             request.getSession().setAttribute("diagram_type", fileType);
             request.getSession().setAttribute("diagram_filename", fileName);
+            request.getSession().setAttribute("diagram_initial_elimination",
+                    initialElimination != null ? initialElimination : "false");
             response.sendRedirect(getServletContext().getInitParameter("APP_HOME_URL") + "graph");
             logger.debug("send redirect to /graph");
 
diff --git a/sources/imiger-core/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetSessionDiagram.java b/sources/imiger-core/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetSessionDiagram.java
index 25c5d8f..5694664 100644
--- a/sources/imiger-core/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetSessionDiagram.java
+++ b/sources/imiger-core/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetSessionDiagram.java
@@ -40,6 +40,7 @@ public class GetSessionDiagram extends BaseServlet {
         String diagramToDisplay = (String) request.getSession().getAttribute("diagram_string");
         String diagramType = (String) request.getSession().getAttribute("diagram_type");
         String filename = (String) request.getSession().getAttribute("diagram_filename");
+        String initialElimination = (String) request.getSession().getAttribute("diagram_initial_elimination");
 
         if (StringUtils.isNotBlank(diagramToDisplay) && diagramType != null) {
 
@@ -61,6 +62,7 @@ public class GetSessionDiagram extends BaseServlet {
             JsonObject jsonObject = new JsonObject();
             jsonObject.addProperty("graph_json", rawJson);
             jsonObject.addProperty("name", filename);
+            jsonObject.addProperty("initial_elimination", initialElimination);
 
             response.setStatus(HttpServletResponse.SC_OK);
             response.getWriter().write(jsonObject.toString());
diff --git a/sources/imiger-core/src/main/webapp/js/services/graphLoader.js b/sources/imiger-core/src/main/webapp/js/services/graphLoader.js
index 48d302d..42e81f5 100644
--- a/sources/imiger-core/src/main/webapp/js/services/graphLoader.js
+++ b/sources/imiger-core/src/main/webapp/js/services/graphLoader.js
@@ -9,9 +9,10 @@ class GraphLoader {
 	/**
 	 * Loads a new graph using graph data passed as parameters.
 	 * @param {object} data Data of the graph.
+	 * @param {boolean} enableInitialElimination Enable initial elimination
 	 * @throws {AJVValidationError} Thrown when graph data are incomplete.
 	 */
-	run(data) {
+	run(data, enableInitialElimination) {
 		let isValid = this._ajv.validate(GraphLoader.rawInputSchema, data);
 		if (isValid === false) {
 			throw new AJVValidationError(this._ajv.errorsText(), this._ajv.errors);
@@ -183,6 +184,11 @@ class GraphLoader {
 			});
 		}
 
+		if (enableInitialElimination) {
+			let MAX_VISIBLE_COMPONENTS = 20;
+			new InitialElimination(MAX_VISIBLE_COMPONENTS).run();
+        }
+
 		// center viewport
 		app.viewportComponent.center();
 
@@ -198,9 +204,6 @@ class GraphLoader {
 		if (Utils.isDefined(highlightedNode)) {
 			highlightedNode.highlightWithNeighbours(true);
 		}
-
-		let MAX_VISIBLE_COMPONENTS = 20;
-		new InitialElimination(MAX_VISIBLE_COMPONENTS).run();
 	}
 }
 
diff --git a/sources/imiger-core/src/main/webapp/js/showGraphApp.js b/sources/imiger-core/src/main/webapp/js/showGraphApp.js
index 1844ea2..e6a0f2e 100644
--- a/sources/imiger-core/src/main/webapp/js/showGraphApp.js
+++ b/sources/imiger-core/src/main/webapp/js/showGraphApp.js
@@ -253,7 +253,9 @@ class ShowGraphApp extends App {
 			document.dispatchEvent(new DiagramUpdatedEvent(graphData));
 
 			// construct graph
-			this.graphLoader.run(JSON.parse(graphData.graph_json));
+			let initialElimination = (graphData.initial_elimination === undefined)
+					? true : graphData.initial_elimination == 'true';
+			this.graphLoader.run(JSON.parse(graphData.graph_json), initialElimination);
 
 			this.spinLoaderComponent.disable();
 
diff --git a/sources/imiger-core/src/main/webapp/uploadFiles.jsp b/sources/imiger-core/src/main/webapp/uploadFiles.jsp
index 6bad979..af0755f 100644
--- a/sources/imiger-core/src/main/webapp/uploadFiles.jsp
+++ b/sources/imiger-core/src/main/webapp/uploadFiles.jsp
@@ -78,6 +78,11 @@
 						</c:forEach>
 					</div>
 
+					<div class="form-field">
+						<input type="checkbox" id="enableInitialElimination" name="enableInitialElimination" value="true" checked>
+						<label for="enableInitialElimination">Initial elimination</label><br>
+					</div>
+
 					<button id="btnLoad" type="submit">Start visualization</button>
 				</form>
 			</section>
