From 90b13a97ec2dfa2125238608ff7981045d3c38fa Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Mon, 3 Jul 2017 15:50:26 +0200 Subject: [PATCH] create method has single dist param --- .../src/main/js/map/AbstractCustomMap.js | 8 ++++- .../src/main/js/map/surface/AliasSurface.js | 35 ++++++++++--------- .../test/js/map/surface/AliasSurface-test.js | 10 ++++-- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/frontend-js/src/main/js/map/AbstractCustomMap.js b/frontend-js/src/main/js/map/AbstractCustomMap.js index eecfc22814..9d43336a1e 100644 --- a/frontend-js/src/main/js/map/AbstractCustomMap.js +++ b/frontend-js/src/main/js/map/AbstractCustomMap.js @@ -595,7 +595,13 @@ AbstractCustomMap.prototype._showSelectedLayout = function(layoutId, index, leng return Promise.each(layoutAliases, function(layoutAlias) { if (layoutAlias.getModelId() === self.getId()) { return self.getModel().getAliasById(layoutAlias.getId()).then(function(aliasData) { - return AliasSurface.create(layoutAlias, aliasData, self, startX, endX); + return AliasSurface.create({ + overlayAlias : layoutAlias, + alias : aliasData, + map : self, + startX : startX, + endX : endX + }); }).then(function(overlay) { self.selectedLayoutOverlays[layoutId].push(overlay); }); diff --git a/frontend-js/src/main/js/map/surface/AliasSurface.js b/frontend-js/src/main/js/map/surface/AliasSurface.js index cafd56053a..1f5112879b 100644 --- a/frontend-js/src/main/js/map/surface/AliasSurface.js +++ b/frontend-js/src/main/js/map/surface/AliasSurface.js @@ -61,29 +61,32 @@ AliasSurface.prototype.setBoundsForAlias = function(startX, endX) { }; /** - * Creates {@link AliasSurface} from input data. + * Creates {@link AliasSurface}. * - * @param layoutAlias - * {@link LayoutAlias} for which overlay is created - * @param alias - * {@link Alias data} of the alias - * @param map - * {@link AbstractCustomMap} where overlay should be placed - * @param startX - * this is the ratio on OX axis that should be use as a starting point - * of the overlay. For instance when there are three layouts to - * visualize then + * @param params + * dict containing set of information required for surface creation: + * <li>overlayAlias - {@link LayoutAlias} for which overlay is created + * <li>alias - {@link Alias data} of the alias + * <li>map - {@link AbstractCustomMap} where overlay should be placed + * <li> startX - this is the ratio on OX axis that should be use as a + * starting point of the overlay. For instance when there are three + * layouts to visualize then * <ul> * <li>the first layout have startX=0.0; endX=0.33333</li> * <li>second layout have startX=0.33333; endX=0.66666</li> * <li>the last layout have startX=0.66666; endX=1.0</li> * </ul> - * @param endX - * this is the ratio on OX axis that should be use as a starting point - * of the overlay + * <li>endX this is the ratio on OX axis that should be use as a + * starting point of the overlay * @returns {AliasSurface} */ -AliasSurface.create = function(layoutAlias, alias, map, startX, endX) { +AliasSurface.create = function(params) { + var overlayAlias = params.overlayAlias; + var alias = params.alias; + var map = params.map; + var startX = params.startX; + var endX = params.endX; + var pointA = new google.maps.Point(alias.x + startX * alias.width, alias.y); var pointB = new google.maps.Point(alias.x + endX * alias.width, alias.y + alias.height); var latLngA = map.fromPointToLatLng(pointA); @@ -99,7 +102,7 @@ AliasSurface.create = function(layoutAlias, alias, map, startX, endX) { bounds : bounds }); - return functions.overlayToColor(layoutAlias).then(function(color) { + return functions.overlayToColor(overlayAlias).then(function(color) { rectangle.setOptions({ fillColor : color, }); diff --git a/frontend-js/src/test/js/map/surface/AliasSurface-test.js b/frontend-js/src/test/js/map/surface/AliasSurface-test.js index 7835fc84d1..793ea329ba 100644 --- a/frontend-js/src/test/js/map/surface/AliasSurface-test.js +++ b/frontend-js/src/test/js/map/surface/AliasSurface-test.js @@ -20,7 +20,13 @@ describe('AliasSurface', function() { var alias = helper.createAlias(map); var layoutAlias = helper.createLayoutAlias(alias); - return AliasSurface.create(layoutAlias, alias, map, 1, 2).then(function(result) { + return AliasSurface.create({ + overlayAlias : layoutAlias, + alias : alias, + map : map, + startX : 1, + endX : 2 + }).then(function(result) { assert.ok(result instanceof AliasSurface); assert.equal(logger.getWarnings.length, 0); }); @@ -57,7 +63,7 @@ describe('AliasSurface', function() { return result.onClickHandler(); }); }); - + }); }); -- GitLab