From fa70e9753d531714d1b80c0a56fa061d60f9a290 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Fri, 9 Jun 2017 17:10:45 +0200
Subject: [PATCH] allow user to set opacity

---
 frontend-js/src/main/js/map/data/IdentifiedElement.js | 8 ++++++++
 frontend-js/src/main/js/map/overlay/AliasOverlay.js   | 6 +++++-
 frontend-js/src/main/js/map/overlay/UserDbOverlay.js  | 1 +
 frontend-js/src/main/js/minerva.js                    | 3 ++-
 4 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/frontend-js/src/main/js/map/data/IdentifiedElement.js b/frontend-js/src/main/js/map/data/IdentifiedElement.js
index 608fbe3902..f2853a935f 100644
--- a/frontend-js/src/main/js/map/data/IdentifiedElement.js
+++ b/frontend-js/src/main/js/map/data/IdentifiedElement.js
@@ -168,6 +168,14 @@ IdentifiedElement.prototype.setColor = function(color) {
   this._visualizationdata._color = color;
 };
 
+IdentifiedElement.prototype.getOpacity = function() {
+  return this._visualizationdata._opacity;
+};
+
+IdentifiedElement.prototype.setOpacity = function(opacity) {
+  this._visualizationdata._opacity = opacity;
+};
+
 IdentifiedElement.prototype.getLineWidth = function() {
   return this._visualizationdata._lineWidth;
 };
diff --git a/frontend-js/src/main/js/map/overlay/AliasOverlay.js b/frontend-js/src/main/js/map/overlay/AliasOverlay.js
index 5eea128870..1caa514e90 100644
--- a/frontend-js/src/main/js/map/overlay/AliasOverlay.js
+++ b/frontend-js/src/main/js/map/overlay/AliasOverlay.js
@@ -137,8 +137,12 @@ AliasOverlay.createFromIdentifiedElement = function(element, map) {
     if (element.getColor() !== undefined) {
       color = element.getColor();
     }
+    var fillOpacity = 0.8;
+    if (element.getOpacity() !== undefined) {
+      fillOpacity = element.getOpacity();
+    }
     var rectangle = new google.maps.Rectangle({
-      fillOpacity : 0.8,
+      fillOpacity : fillOpacity,
       strokeWeight : 1,
       map : map.getGoogleMap(),
       bounds : bounds,
diff --git a/frontend-js/src/main/js/map/overlay/UserDbOverlay.js b/frontend-js/src/main/js/map/overlay/UserDbOverlay.js
index 7e299421fd..776ab7b925 100644
--- a/frontend-js/src/main/js/map/overlay/UserDbOverlay.js
+++ b/frontend-js/src/main/js/map/overlay/UserDbOverlay.js
@@ -81,6 +81,7 @@ UserDbOverlay.prototype.addSurface = function(params) {
     element = new IdentifiedElement(singleElementParam.element);
     if (singleElementParam.options !== undefined) {
       element.setColor(singleElementParam.options.color);
+      element.setOpacity(singleElementParam.options.opacity);
     }
     if (self._surfaceIdentifiedElements[element.getType()][element.getId()] !== undefined) {
       return Promise.reject(new Error("Element already highlighted: " + element.getId()));
diff --git a/frontend-js/src/main/js/minerva.js b/frontend-js/src/main/js/minerva.js
index 6b9e3d5a84..39e724ef4a 100644
--- a/frontend-js/src/main/js/minerva.js
+++ b/frontend-js/src/main/js/minerva.js
@@ -292,7 +292,8 @@ function createResult(customMap) {
             type : type,
             options : {
               icon : identifiedElements[i].getIcon(),
-              color : identifiedElements[i].getColor()
+              color : identifiedElements[i].getColor(),
+              opacity : identifiedElements[i].getOpacity(),
             }
           }
           result.push(row);
-- 
GitLab