Commit 42545bb4 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

layout renamed to overlay

parent 945048bf
Pipeline #4218 passed with stage
in 1 minute and 7 seconds
......@@ -136,9 +136,9 @@ GraphicsExportPanel.prototype._createDownloadButton = function () {
var identifier = null;
var defaultOverlayName = "Network";
for (var i = 0; i < self.getProject().getDataOverlays().length; i++) {
var layout = self.getProject().getDataOverlays()[i];
if (identifier === null || layout.getName() === defaultOverlayName) {
identifier = layout.getId();
var overlay = self.getProject().getDataOverlays()[i];
if (identifier === null || overlay.getName() === defaultOverlayName) {
identifier = overlay.getId();
}
}
......
......@@ -37,9 +37,9 @@ function AbstractCustomMap(model, options) {
this.setModel(model);
// this array contains elements that are presented on a specific layout (set
// this array contains elements that are presented on a specific overlay (set
// of google map object representing lines/areas that are associated with
// layout)
// overlay)
this.selectedLayoutOverlays = [];
// following fields are used in conversion between x,y coordinates and lat,lng
......@@ -90,8 +90,8 @@ AbstractCustomMap.prototype.getMarkerSurfaceCollection = function () {
return this._markerSurfaceCollection;
};
/**
* Assigns layouts with images to the google map (which set of images should be
* used by google maps api for which layout).
* Assigns overlays with images to the google map (which set of images should be
* used by google maps api for which overlay).
*
*/
AbstractCustomMap.prototype.setupLayouts = function () {
......@@ -157,10 +157,10 @@ AbstractCustomMap.prototype.createMapOptions = function () {
};
/**
* Create google maps configuration options object for a specific layout.
* Create google maps configuration options object for a specific overlay.
*
* @param param
* object with information about layout
* object with information about overlay
*/
AbstractCustomMap.prototype.createTypeOptions = function (param) {
var self = this;
......@@ -556,22 +556,22 @@ AbstractCustomMap.prototype.getTopMap = function () {
};
/**
* Method that should be called when number of layouts to visualize changed to
* modify boundaries of the elements to visualize. When few layouts are
* Method that should be called when number of overlays to visualize changed to
* modify boundaries of the elements to visualize. When few overlays are
* visualized at the same time then index contains information where this new
* layout is placed in the list (starting from 0) and length contains
* information how many layouts we visualize in total.
* overlay is placed in the list (starting from 0) and length contains
* information how many overlays we visualize in total.
*
* @param layoutId
* identifier of a layout
* @param overlayId
* identifier of a overlay
* @param index
* when visualizing more than one layout at the same time index
* contains information at which position in the list this layout is
* when visualizing more than one overlay at the same time index
* contains information at which position in the list this overlay is
* placed
* @param length
* number of layouts that are currently visualized
* number of overlays that are currently visualized
*/
AbstractCustomMap.prototype._resizeSelectedDataOverlay = function (layoutId, index, length) {
AbstractCustomMap.prototype._resizeSelectedDataOverlay = function (overlayId, index, length) {
var self = this;
return new Promise(function (resolve) {
// if map is not initialized then don't perform this operation
......@@ -579,35 +579,35 @@ AbstractCustomMap.prototype._resizeSelectedDataOverlay = function (layoutId, ind
logger.debug("Model " + self.getId() + " not initialized");
resolve();
}
logger.debug("Resize layout: " + layoutId);
logger.debug("Resize overlay: " + overlayId);
// start ratio
var startX = index * (1.0 / length);
// end ratio
var endX = (index + 1) * (1.0 / length);
for (var i = 0; i < self.selectedLayoutOverlays[layoutId].length; i++) {
self.selectedLayoutOverlays[layoutId][i].setBoundsForAlias(startX, endX);
for (var i = 0; i < self.selectedLayoutOverlays[overlayId].length; i++) {
self.selectedLayoutOverlays[overlayId][i].setBoundsForAlias(startX, endX);
}
resolve();
});
};
/**
* Shows all elements from a given layout. When few layouts are visualized at
* the same time then index contains information where this new layout is placed
* Shows all elements from a given overlay. When few overlays are visualized at
* the same time then index contains information where this new overlay is placed
* in the list (starting from 0) and length contains information how many
* layouts we visualize in total.
* overlays we visualize in total.
*
* @param layoutId
* identifier of a layout
* @param overlayId
* identifier of a overlay
* @param index
* when visualizing more than one layout at the same time index
* contains information at which position in the list this layout is
* when visualizing more than one overlay at the same time index
* contains information at which position in the list this overlay is
* placed
* @param length
* number of layouts that are currently visualized
* number of overlays that are currently visualized
*/
AbstractCustomMap.prototype._showSelectedDataOverlay = function (layoutId, index, length) {
AbstractCustomMap.prototype._showSelectedDataOverlay = function (overlayId, index, length) {
var self = this;
// if map is not initialized then don't perform this operation
return new Promise(function (resolve, reject) {
......@@ -619,43 +619,43 @@ AbstractCustomMap.prototype._showSelectedDataOverlay = function (layoutId, index
logger.debug("Showing model " + self.getId());
}
self.selectedLayoutOverlays[layoutId] = [];
self.selectedLayoutOverlays[overlayId] = [];
// start ratio
var startX = index * (1.0 / length);
// end ratio
var endX = (index + 1) * (1.0 / length);
var layoutAliases;
var layoutReactions;
var overlayAliases;
var overlayReactions;
return self.getProject().getDataOverlayById(layoutId).then(function (layout) {
layoutAliases = layout.getAliases();
layoutReactions = layout.getReactions();
return self.getProject().getDataOverlayById(overlayId).then(function (overlay) {
overlayAliases = overlay.getAliases();
overlayReactions = overlay.getReactions();
var identifiedElements = [];
var i;
for (i = 0; i < layoutAliases.length; i++) {
if (layoutAliases[i].getModelId() === self.getId()) {
identifiedElements.push(new IdentifiedElement(layoutAliases[i]));
for (i = 0; i < overlayAliases.length; i++) {
if (overlayAliases[i].getModelId() === self.getId()) {
identifiedElements.push(new IdentifiedElement(overlayAliases[i]));
}
}
var reactionIds = [];
for (i = 0; i < layoutReactions.length; i++) {
if (layoutReactions[i].getModelId() === self.getId()) {
identifiedElements.push(new IdentifiedElement(layoutReactions[i]));
for (i = 0; i < overlayReactions.length; i++) {
if (overlayReactions[i].getModelId() === self.getId()) {
identifiedElements.push(new IdentifiedElement(overlayReactions[i]));
}
}
return self.getModel().getByIdentifiedElements(identifiedElements, false);
}).then(function () {
return Promise.each(layoutAliases, function (layoutAlias) {
if (layoutAlias.getModelId() === self.getId()) {
return Promise.each(overlayAliases, function (overlayAlias) {
if (overlayAlias.getModelId() === self.getId()) {
var surface;
var element;
return self.getModel().getAliasById(layoutAlias.getId()).then(function (aliasData) {
return self.getModel().getAliasById(overlayAlias.getId()).then(function (aliasData) {
element = new IdentifiedElement(aliasData);
return AliasSurface.create({
overlayAlias: layoutAlias,
overlayAlias: overlayAlias,
alias: aliasData,
map: self,
startX: startX,
......@@ -668,18 +668,18 @@ AbstractCustomMap.prototype._showSelectedDataOverlay = function (layoutId, index
});
}).then(function (result) {
surface = result;
self.selectedLayoutOverlays[layoutId].push(surface);
self.selectedLayoutOverlays[overlayId].push(surface);
});
}
});
}).then(function () {
return Promise.each(layoutReactions, function (layoutReaction) {
if (layoutReaction.getModelId() === self.getId()) {
return self.getModel().getReactionById(layoutReaction.getId()).then(function (reactionData) {
return Promise.each(overlayReactions, function (overlayReaction) {
if (overlayReaction.getModelId() === self.getId()) {
return self.getModel().getReactionById(overlayReaction.getId()).then(function (reactionData) {
var surface;
var element = new IdentifiedElement(reactionData);
return ReactionSurface.create({
layoutReaction: layoutReaction,
layoutReaction: overlayReaction,
reaction: reactionData,
map: self,
onClick: [function () {
......@@ -690,7 +690,7 @@ AbstractCustomMap.prototype._showSelectedDataOverlay = function (layoutId, index
customized: (length === 1)
}).then(function (result) {
surface = result;
self.selectedLayoutOverlays[layoutId].push(surface);
self.selectedLayoutOverlays[overlayId].push(surface);
surface.show();
});
});
......@@ -703,21 +703,21 @@ AbstractCustomMap.prototype._showSelectedDataOverlay = function (layoutId, index
};
/**
* Hides all elements from layout.
* Hides all elements from overlay.
*
* @param layoutId
* identifier of a layout
* @param overlayId
* identifier of a overlay
*/
AbstractCustomMap.prototype._hideSelectedLayout = function (layoutId) {
AbstractCustomMap.prototype._hideSelectedLayout = function (overlayId) {
// if map is not initialized then don't perform this operation
if (!this.initialized) {
logger.debug("Model " + this.getId() + " not initialized");
return;
}
for (var i = 0; i < this.selectedLayoutOverlays[layoutId].length; i++) {
this.selectedLayoutOverlays[layoutId][i].setMap(null);
for (var i = 0; i < this.selectedLayoutOverlays[overlayId].length; i++) {
this.selectedLayoutOverlays[overlayId][i].setMap(null);
}
this.selectedLayoutOverlays[layoutId] = [];
this.selectedLayoutOverlays[overlayId] = [];
};
/**
......@@ -749,20 +749,20 @@ AbstractCustomMap.prototype._openInfoWindowForAlias = function (alias, googleMar
/**
* Returns promise of a list of {@link LayoutAlias} information for a given
* {@link Alias} in all currently visualized layouts.
* {@link Alias} in all currently visualized overlays.
*
* @param aliasId
* identifier of the {@link Alias}
* @returns promise of an {Array} with list of {@link LayoutAlias} information
* for a given {@link Alias} in all currently visualized layouts
* for a given {@link Alias} in all currently visualized overlays
*/
AbstractCustomMap.prototype.getAliasVisibleLayoutsData = function (aliasId) {
var self = this;
return self.getTopMap().getVisibleDataOverlays().then(function (visibleDataOverlays) {
var result = [];
for (var i = 0; i < visibleDataOverlays.length; i++) {
var layout = visibleDataOverlays[i];
result.push(layout.getFullAliasById(aliasId));
var overlay = visibleDataOverlays[i];
result.push(overlay.getFullAliasById(aliasId));
}
return Promise.all(result);
});
......@@ -987,13 +987,13 @@ AbstractCustomMap.prototype.getPictureSize = function () {
};
/**
* Returns array containing elements that are presented on a specific layout
* Returns array containing elements that are presented on a specific overlay
* (set of google map objects representing lines/areas that are associated with
* layout).
* overlay).
*
* @returns {Array} containing elements that are presented on a specific
* layout (set of google map objects representing lines/areas that are
* associated with layout).
* overlay (set of google map objects representing lines/areas that are
* associated with overlay).
*/
AbstractCustomMap.prototype.getSelectedLayoutOverlays = function () {
return this.selectedLayoutOverlays;
......
......@@ -415,20 +415,20 @@ CustomMap.prototype.openSubmap = function (id) {
// we have to perform it on top map, because on submaps id is different
return this.openDataOverlay(self.getGoogleMap().getMapTypeId()).then(function () {
if (!wasInitialized) {
// now we have to visualize layouts
var layouts = [];
// now we have to visualize overlays
var overlayIds = [];
// get list of layouts
// get list of overlays
for (var key in self._selectedOverlays) {
if (self._selectedOverlays.hasOwnProperty(key) && self._selectedOverlays[key] === true) {
layouts.push(key);
overlayIds.push(key);
}
}
// show layouts that should be visualized (resize or show them)
for (var i = 0; i < layouts.length; i++) {
var layoutId = layouts[i];
submap._showSelectedDataOverlay(layoutId, i, layouts.length);
// show overlays that should be visualized (resize or show them)
for (var i = 0; i < overlayIds.length; i++) {
var overlayId = overlayIds[i];
submap._showSelectedDataOverlay(overlayId, i, overlayIds.length);
}
return self.refreshMarkers(true);
}
......@@ -482,7 +482,7 @@ CustomMap.prototype.createMapChangedCallbacks = function () {
var self = this;
var sessionData = ServerConnector.getSessionData(self.getProject());
// listener for changing type of layout
// listener for changing type of background overlay
google.maps.event.addListener(self.getGoogleMap(), 'maptypeid_changed', function () {
sessionData.setSelectedBackgroundOverlay(self.getGoogleMap().getMapTypeId());
});
......@@ -520,15 +520,15 @@ CustomMap.prototype.removeSelection = function () {
};
/**
* Removes layout from visualization.
* Removes overlay from visualization.
*
* @param identifier
* identifier of layout to remove
* identifier of overlay to remove
*
*/
CustomMap.prototype.hideDataOverlay = function (identifier) {
var self = this;
logger.debug("Removing layout: " + identifier);
logger.debug("Hiding overlay: " + identifier);
if (this._selectedOverlays[identifier] !== true) {
logger.warn("Overlay " + identifier + " is not selected");
......@@ -553,7 +553,7 @@ CustomMap.prototype.hideDataOverlay = function (identifier) {
};
/**
* Refresh visualization of selected layouts.
* Redrawing selected overlays.
*/
CustomMap.prototype.redrawSelectedDataOverlays = function () {
logger.debug("Redrawing overlays");
......@@ -585,81 +585,81 @@ CustomMap.prototype.redrawSelectedDataOverlays = function () {
};
/**
* Hides layout from the map and all submaps
* Hides overlay on the map and all submaps
*
* @param layoutId
* identifier of a layout to hide
* @param overlayId
* identifier of a overlay to hide
*/
CustomMap.prototype.hideSelectedLayout = function (layoutId) {
this._hideSelectedLayout(layoutId);
CustomMap.prototype.hideSelectedLayout = function (overlayId) {
this._hideSelectedLayout(overlayId);
for (var i = 0; i < this.submaps.length; i++) {
this.submaps[i]._hideSelectedLayout(layoutId);
this.submaps[i]._hideSelectedLayout(overlayId);
}
};
/**
* Resize(refresh) layout on the map and all submaps. Resizing should be called
* when number of layouts to visualize change.
* Resize(refresh) overlay on the map and all submaps. Resizing should be called
* when number of overlays to visualize change.
*
* @param layoutId
* identifier of layout to refresh
* @param overlayId
* identifier of overlay to refresh
* @param index
* position of the layout in list of layouts that we visualize
* position of the overlay in list of overlays that we visualize
* @param length
* number of layouts that we currently visualize
* number of overlays that we currently visualize
*/
CustomMap.prototype.resizeSelectedDataOverlay = function (layoutId, index, length) {
logger.debug("Resize layout: " + layoutId);
CustomMap.prototype.resizeSelectedDataOverlay = function (overlayId, index, length) {
logger.debug("Resize overlay: " + overlayId);
var promises = [];
promises.push(this._resizeSelectedDataOverlay(layoutId, index, length));
promises.push(this._resizeSelectedDataOverlay(overlayId, index, length));
for (var i = 0; i < this.submaps.length; i++) {
promises.push(this.submaps[i]._resizeSelectedDataOverlay(layoutId, index, length));
promises.push(this.submaps[i]._resizeSelectedDataOverlay(overlayId, index, length));
}
return Promise.all(promises);
};
/**
* Show layout on the map and all submaps.
* Show overlay on the map and all submaps.
*
* @param layoutId
* identifier of layout to show
* @param overlayId
* identifier of overlay to show
* @param index
* position of the layout in list of layouts that we visualize
* position of the overlay in list of overlays that we visualize
* @param length
* number of layouts that we currently visualize
* number of overlays that we currently visualize
*/
CustomMap.prototype.showSelectedDataOverlay = function (layoutId, index, length) {
logger.debug("Resize layout: " + layoutId);
CustomMap.prototype.showSelectedDataOverlay = function (overlayId, index, length) {
logger.debug("Show overlay: " + overlayId);
var promises = [];
promises.push(this._showSelectedDataOverlay(layoutId, index, length));
promises.push(this._showSelectedDataOverlay(overlayId, index, length));
for (var i = 0; i < this.submaps.length; i++) {
promises.push(this.submaps[i]._showSelectedDataOverlay(layoutId, index, length));
promises.push(this.submaps[i]._showSelectedDataOverlay(overlayId, index, length));
}
return Promise.all(promises);
};
/**
* This method checks if the layout contains any overlays (like AliasSurface or
* This method checks if the overlay contains any overlays (like AliasSurface or
* ReactionSurface) that is currently visible on the map.
*
* @param layoutId
* identifier of the layout
* @returns {Boolean}: <code>true</code> if the layout contains overlays to
* @param overlayId
* identifier of the overlay
* @returns {Boolean}: <code>true</code> if the overlay contains overlays to
* visualize, <code>false</code> otherwise
*/
CustomMap.prototype.layoutContainsOverlays = function (layoutId) {
CustomMap.prototype.layoutContainsOverlays = function (overlayId) {
// first, check top map
if (this.selectedLayoutOverlays.hasOwnProperty(layoutId) && this.selectedLayoutOverlays[layoutId].length > 0) {
if (this.selectedLayoutOverlays.hasOwnProperty(overlayId) && this.selectedLayoutOverlays[overlayId].length > 0) {
return true;
}
// now check all submaps
for (var i = 0; i < this.submaps.length; i++) {
if (this.submaps[i].initialized) {
if (this.submaps[i].selectedLayoutOverlays.hasOwnProperty(layoutId)
&& this.submaps[i].selectedLayoutOverlays[layoutId].length > 0) {
if (this.submaps[i].selectedLayoutOverlays.hasOwnProperty(overlayId)
&& this.submaps[i].selectedLayoutOverlays[overlayId].length > 0) {
return true;
}
}
......
......@@ -8,14 +8,14 @@ var LayoutReaction = require('./LayoutReaction');
var logger = require('../../logger');
/**
* Class representing data in a specific layout.
* Class representing data in a specific overlay.
*/
function DataOverlay(layoutId, name) {
function DataOverlay(overlayId, name) {
this.setInitialized(false);
if (name === undefined) {
// from json structure
var object = layoutId;
var object = overlayId;
this.setId(object.idObject);
this.setOrder(object.order);
this.setName(object.name);
......@@ -33,7 +33,7 @@ function DataOverlay(layoutId, name) {
}
} else {
// default two param call
this.setId(layoutId);
this.setId(overlayId);
this.setName(name);
}
this.aliases = [];
......@@ -44,22 +44,22 @@ function DataOverlay(layoutId, name) {
/**
* Adds alias to the {@link DataOverlay}
*
* @param layoutAlias
* information about alias in a layout
* @param overlayAlias
* information about alias in the overlay
*/
DataOverlay.prototype.addAlias = function (layoutAlias) {
this.aliases.push(layoutAlias);
this.aliasById[layoutAlias.getId()] = layoutAlias;
DataOverlay.prototype.addAlias = function (overlayAlias) {
this.aliases.push(overlayAlias);
this.aliasById[overlayAlias.getId()] = overlayAlias;
};
/**
* Adds reaction to the {@link DataOverlay}
*
* @param layoutReaction
* information about reaction in a layout
* @param overlayReaction
* information about reaction in the overlay
*/
DataOverlay.prototype.addReaction = function (layoutReaction) {
this.reactions.push(layoutReaction);
DataOverlay.prototype.addReaction = function (overlayReaction) {
this.reactions.push(overlayReaction);
};
DataOverlay.prototype.getId = function () {
......@@ -126,11 +126,11 @@ DataOverlay.prototype.setImagesDirectory = function (imagesDirectory) {
this._imagesDirectory = imagesDirectory;
};
DataOverlay.prototype.updateAlias = function (layoutAlias) {
if (this.aliasById[layoutAlias.getId()] === undefined) {
logger.warn("Cannot update alias, it doesn't exist. Alias: ", layoutAlias.getId());
DataOverlay.prototype.updateAlias = function (overlayAlias) {
if (this.aliasById[overlayAlias.getId()] === undefined) {
logger.warn("Cannot update alias, it doesn't exist. Alias: ", overlayAlias.getId());
} else {
this.aliasById[layoutAlias.getId()].update(layoutAlias);
this.aliasById[overlayAlias.getId()].update(overlayAlias);
}
};
......
......@@ -3,8 +3,8 @@
var GeneVariant = require('./GeneVariant');
/**
* Class representing alias visualized in a layout.
*
* Class representing alias visualized in a overlay.
*
* @param javaObject
* object de-serialized ajax query to the server side
*/
......@@ -21,7 +21,7 @@ function LayoutAlias(javaObject) {
} else if (javaObject.type === LayoutAlias.GENERIC) {
this.setType(LayoutAlias.GENERIC);
} else {
throw new Error("Unknown type: ", javaObject.type);
throw new Error("Unknown type: " + javaObject.type);
}
this.setGeneVariants([]);
......@@ -36,55 +36,55 @@ LayoutAlias.LIGHT = "LIGHT";
LayoutAlias.GENETIC_VARIANT = "GENETIC_VARIANT";
LayoutAlias.GENERIC = "GENERIC";
LayoutAlias.prototype.getId = function() {
LayoutAlias.prototype.getId = function () {
return this.id;
};
LayoutAlias.prototype.setId = function(id) {
LayoutAlias.prototype.setId = function (id) {
this.id = parseInt(id);
};
LayoutAlias.prototype.getModelId = function() {
LayoutAlias.prototype.getModelId = function () {
return this._modelId;
};
LayoutAlias.prototype.setModelId = function(modelId) {