diff --git a/frontend-js/src/main/js/map/data/IdentifiedElement.js b/frontend-js/src/main/js/map/data/IdentifiedElement.js index 727425d6611892b1f64a0fee59f72e9d816bb65a..4b7f15df7b1ab78be0e9f2d8dea825201339fbf9 100644 --- a/frontend-js/src/main/js/map/data/IdentifiedElement.js +++ b/frontend-js/src/main/js/map/data/IdentifiedElement.js @@ -82,11 +82,11 @@ function IdentifiedElement(javaObject) { /** * Returns point where it should be visualized when the type of object is * "POINT". - * + * * @returns {@linke google.maps.Point} where it should be visualized when the * type of object is "POINT". */ -IdentifiedElement.prototype.getPoint = function () { +IdentifiedElement.prototype.getPoint = function() { if (this._point === undefined || this._point === null) { logger.warn("No point associated with IdentifiedElement"); return null; @@ -97,10 +97,10 @@ IdentifiedElement.prototype.getPoint = function () { /** * Returns element identifier. - * + * * @returns element identifier */ -IdentifiedElement.prototype.getId = function () { +IdentifiedElement.prototype.getId = function() { return this.id; }; @@ -113,7 +113,7 @@ IdentifiedElement.prototype.setId = function (id) { this.id = id; }; -IdentifiedElement.prototype.setModelId = function (modelId) { +IdentifiedElement.prototype.setModelId = function(modelId) { if (modelId === undefined || modelId === null) { throw new Error("ModelId is invalid"); } @@ -122,10 +122,10 @@ IdentifiedElement.prototype.setModelId = function (modelId) { /** * Returns model identifier where element is placed. - * + * * @returns model identifier */ -IdentifiedElement.prototype.getModelId = function () { +IdentifiedElement.prototype.getModelId = function() { return this.modelId; }; @@ -137,14 +137,14 @@ IdentifiedElement.prototype.getModelId = function () { * <li>"POINT" - for any point on the map, the data connected to this kind of * objects are stored in {@link PointData}</li> * </ul> - * + * * @returns type of the element */ -IdentifiedElement.prototype.getType = function () { +IdentifiedElement.prototype.getType = function() { return this.type; }; -IdentifiedElement.prototype.setType = function (type) { +IdentifiedElement.prototype.setType = function(type) { if (type === undefined || type === null) { throw new Error("Type not defined"); } diff --git a/frontend-js/src/main/js/map/window/AbstractInfoWindow.js b/frontend-js/src/main/js/map/window/AbstractInfoWindow.js index a9cb40dcbc89770769cb33d22c85d72ab60126e8..23ddf813c44a5fc24a5bcb90c43865617fbb07da 100644 --- a/frontend-js/src/main/js/map/window/AbstractInfoWindow.js +++ b/frontend-js/src/main/js/map/window/AbstractInfoWindow.js @@ -14,7 +14,7 @@ var TargettingStructure = require('../data/TargettingStructure'); /** * Class representing any info window in our map. - * + * * @param abstractMarker * {@link AbstractMarker} to which this window is pointing, can be null */ @@ -22,6 +22,8 @@ function AbstractInfoWindow(params) { // call super constructor ObjectWithListeners.call(this); + this.setIdentifiedElement(params.identifiedElement); + this.setCustomMap(params.map); this.setGoogleMarker(params.marker); @@ -32,15 +34,15 @@ function AbstractInfoWindow(params) { this.registerPropertyType("overlayFullView"); // listener called when user want to see all data about specific data overlay - var onOverlayFullViewChanged = function(e) { + var onOverlayFullViewChanged = function (e) { var self = e.object; // first change the content of the element - return self.update().then(function() { + return self.update().then(function () { if (e.newVal) { var element = new IdentifiedElement({ - objectId : self.getElementId(), - modelId : self.getCustomMap().getId(), - type : self.getElementType() + objectId: self.getElementId(), + modelId: self.getCustomMap().getId(), + type: self.getElementType() }); var topMap = self.getCustomMap().getTopMap(); return topMap.retrieveOverlayDetailDataForElement(element, self.getOverlayFullViewArray()); @@ -72,12 +74,12 @@ AbstractInfoWindow.prototype.constructor = AbstractInfoWindow; /** * Returns <code>true</code> if overlay should visualize all possible values. - * + * * @param overlayName * name of the overlay - * @returns <code>true</code> if overlay should visualize all possible values + * @returns boolean, <code>true</code> if overlay should visualize all possible values */ -AbstractInfoWindow.prototype.isOverlayFullView = function(overlayName) { +AbstractInfoWindow.prototype.isOverlayFullView = function (overlayName) { if (this._overlayFullView[overlayName] === undefined) { this._overlayFullView[overlayName] = false; } @@ -87,15 +89,15 @@ AbstractInfoWindow.prototype.isOverlayFullView = function(overlayName) { /** * Returns associative array with information if specific overlay should present * all possible results or only specified by the data searched by user. - * + * * @returns {Array} with information if specific overlay should present all * possible results or only specified by the data searched by user */ -AbstractInfoWindow.prototype.getOverlayFullViewArray = function() { +AbstractInfoWindow.prototype.getOverlayFullViewArray = function () { return this._overlayFullView; }; -AbstractInfoWindow.prototype.setOverlayFullView = function(overlayName, value) { +AbstractInfoWindow.prototype.setOverlayFullView = function (overlayName, value) { var oldVal = this._overlayFullView[overlayName]; this._overlayFullView[overlayName] = value; return this.firePropertyChangeListener("overlayFullView", overlayName + "," + oldVal, value); @@ -103,11 +105,11 @@ AbstractInfoWindow.prototype.setOverlayFullView = function(overlayName, value) { /** * This method checks if {@link AbstractInfoWindow} is opened. - * + * * @returns {Boolean} <code>true</code> if window is opened, * <code>false</code> otherwise */ -AbstractInfoWindow.prototype.isOpened = function() { +AbstractInfoWindow.prototype.isOpened = function () { if (this.googleInfowindow === undefined) { return false; } @@ -122,7 +124,7 @@ AbstractInfoWindow.prototype.isOpened = function() { /** * Opens Info Window. */ -AbstractInfoWindow.prototype.open = function(newMarker) { +AbstractInfoWindow.prototype.open = function (newMarker) { var self = this; if (self.googleInfowindow === null) { logger.warn("Cannot open window."); @@ -133,18 +135,18 @@ AbstractInfoWindow.prototype.open = function(newMarker) { } self.googleInfowindow.open(self.getCustomMap().getGoogleMap(), self.getGoogleMarker()); - return self.update().then(function() { + return self.update().then(function () { return self.callListeners("onShow"); }); }; /** * Sets new content of the info window. - * + * * @param content * new content of the window */ -AbstractInfoWindow.prototype.setContent = function(content) { +AbstractInfoWindow.prototype.setContent = function (content) { this._content = content; if (this.googleInfowindow !== undefined) { this.googleInfowindow.setContent(content); @@ -153,46 +155,46 @@ AbstractInfoWindow.prototype.setContent = function(content) { /** * Returns content visualized in the info window. - * + * * @returns {String} content visualized in the info window */ -AbstractInfoWindow.prototype.getContent = function() { +AbstractInfoWindow.prototype.getContent = function () { return this._content; }; /** * Creates div for an overlay data. - * + * * @param overlay * corresponding {@link OverlayCollection} * @param data * data taken from overlay * @returns string representing div for given overlay data */ -AbstractInfoWindow.prototype.createOverlayInfoDiv = function(overlay, data) { +AbstractInfoWindow.prototype.createOverlayInfoDiv = function (overlay, data) { var alias = this.alias; if (alias !== undefined) { if (alias.getType() !== undefined) { if (overlay.name === "drug") { if (alias.getType().toUpperCase() === "RNA" || // - alias.getType().toUpperCase() === "PROTEIN" || // - alias.getType().toUpperCase() === "GENE") { + alias.getType().toUpperCase() === "PROTEIN" || // + alias.getType().toUpperCase() === "GENE") { return this._createDrugInfoDiv(overlay, data); } else { return null; } } else if (overlay.name === "chemical") { if (this.alias.getType().toUpperCase() === "RNA" || // - alias.getType().toUpperCase() === "PROTEIN" || // - alias.getType().toUpperCase() === "GENE") { + alias.getType().toUpperCase() === "PROTEIN" || // + alias.getType().toUpperCase() === "GENE") { return this._createChemicalInfoDiv(overlay, data); } else { return null; } } else if (overlay.name === "mirna") { if (alias.getType().toUpperCase() === "RNA" || // - alias.getType().toUpperCase() === "PROTEIN" || // - alias.getType().toUpperCase() === "GENE") { + alias.getType().toUpperCase() === "PROTEIN" || // + alias.getType().toUpperCase() === "GENE") { return this._createMiRnaInfoDiv(overlay, data); } else { return null; @@ -220,27 +222,27 @@ AbstractInfoWindow.prototype.createOverlayInfoDiv = function(overlay, data) { /** * Creates and returns div for drug overlay information. - * + * * @param data * data taken from drug iverlay * @returns {String} with a div for drug overlay information */ -AbstractInfoWindow.prototype._createDrugInfoDiv = function(overlay, data) { +AbstractInfoWindow.prototype._createDrugInfoDiv = function (overlay, data) { return this._createTargetInfoDiv({ - overlay : overlay, - data : data, - name : "Interacting drugs" + overlay: overlay, + data: data, + name: "Interacting drugs" }); }; /** * Creates and returns div for comment overlay information. - * + * * @param data * data taken from comment iverlay * @returns {String} with a div for comment overlay information */ -AbstractInfoWindow.prototype._createCommentInfoDiv = function(overlay, data) { +AbstractInfoWindow.prototype._createCommentInfoDiv = function (overlay, data) { if (data.length === 0 || data[0] === undefined) { return null; } @@ -272,7 +274,7 @@ AbstractInfoWindow.prototype._createCommentInfoDiv = function(overlay, data) { /** * Creates and returns div for unknown overlay. - * + * * @param overlay * some {@link OverlayCollection} * @param data @@ -280,7 +282,7 @@ AbstractInfoWindow.prototype._createCommentInfoDiv = function(overlay, data) { * @returns Dom element with a div for overlay information */ -AbstractInfoWindow.prototype._createDefaultInfoDiv = function(overlay, data) { +AbstractInfoWindow.prototype._createDefaultInfoDiv = function (overlay, data) { var divElement = document.createElement("div"); var count = 0; @@ -288,7 +290,7 @@ AbstractInfoWindow.prototype._createDefaultInfoDiv = function(overlay, data) { var title = document.createTextNode(overlay.getName()); titleElement.appendChild(title); divElement.appendChild(titleElement); - for ( var searchId in data) { + for (var searchId in data) { if (data.hasOwnProperty(searchId) && data[searchId] !== undefined && data[searchId] !== null) { count++; var resultTitleElement = document.createElement("h4"); @@ -314,27 +316,27 @@ AbstractInfoWindow.prototype._createDefaultInfoDiv = function(overlay, data) { /** * Returns google.maps.Marker object where this info window is attached. - * + * * @returns google.maps.Marker object where this info window is attached */ -AbstractInfoWindow.prototype.getGoogleMarker = function() { +AbstractInfoWindow.prototype.getGoogleMarker = function () { return this._marker; }; -AbstractInfoWindow.prototype.setGoogleMarker = function(marker) { +AbstractInfoWindow.prototype.setGoogleMarker = function (marker) { this._marker = marker; }; /** * Returns {@link AbstractCustomMap} where this window is presented. - * + * * @returns {@link AbstractCustomMap} where this window is presented */ -AbstractInfoWindow.prototype.getCustomMap = function() { +AbstractInfoWindow.prototype.getCustomMap = function () { return this.customMap; }; -AbstractInfoWindow.prototype.setCustomMap = function(map) { +AbstractInfoWindow.prototype.setCustomMap = function (map) { if (map === undefined) { throw new Error("Map must be defined"); } @@ -344,11 +346,11 @@ AbstractInfoWindow.prototype.setCustomMap = function(map) { /** * Returns html DOM object with content that should presented when waiting for * some data from server. - * + * * @returns {String} html with content that should presented when waiting for * some data from server */ -AbstractInfoWindow.prototype.createWaitingContentDiv = function() { +AbstractInfoWindow.prototype.createWaitingContentDiv = function () { var result = document.createElement("div"); var img = document.createElement("img"); img.src = GuiConnector.getImgPrefix() + GuiConnector.getLoadingImg(); @@ -362,7 +364,7 @@ AbstractInfoWindow.prototype.createWaitingContentDiv = function() { /** * This is a generic method that updates content of the window. */ -AbstractInfoWindow.prototype._updateContent = function() { +AbstractInfoWindow.prototype._updateContent = function () { var contentDiv = null; var self = this; @@ -371,10 +373,10 @@ AbstractInfoWindow.prototype._updateContent = function() { } else { self.setContent(self.createWaitingContentDiv()); - return self.createContentDiv().then(function(content) { + return self.createContentDiv().then(function (content) { contentDiv = content; return self.createOverlaysDiv(); - }).then(function(overlaysDiv) { + }).then(function (overlaysDiv) { if (overlaysDiv !== undefined && overlaysDiv !== null) { contentDiv.appendChild(overlaysDiv); } @@ -389,14 +391,14 @@ AbstractInfoWindow.prototype._updateContent = function() { /** * Creates and returns div with overlays content. - * + * * @returns {String} with html representing data taken from * {@link OverlayCollection} for this window */ -AbstractInfoWindow.prototype.createOverlaysDiv = function() { +AbstractInfoWindow.prototype.createOverlaysDiv = function () { var self = this; var result = document.createElement("div"); - return this.getOverlaysData(self.getOverlayFullViewArray()).then(function(overlayData) { + return this.getOverlaysData(self.getOverlayFullViewArray()).then(function (overlayData) { for (var i = 0; i < overlayData.length; i++) { var overlay = overlayData[i].overlay; var data = overlayData[i].data; @@ -412,11 +414,11 @@ AbstractInfoWindow.prototype.createOverlaysDiv = function() { /** * Abstract method (to be implemented by subclasses) for updating content. */ -AbstractInfoWindow.prototype.update = function() { +AbstractInfoWindow.prototype.update = function () { return this._updateContent(); }; -AbstractInfoWindow.prototype._createTargetInfoDiv = function(params) { +AbstractInfoWindow.prototype._createTargetInfoDiv = function (params) { var overlay = params.overlay; var data = params.data; var name = params.name; @@ -437,7 +439,7 @@ AbstractInfoWindow.prototype._createTargetInfoDiv = function(params) { checkbox.id = "checkbox-" + name + "-" + this.getElementType() + "-" + this.getElementId(); checkbox.type = "checkbox"; checkbox.checked = self.isOverlayFullView(overlay.getName()); - var checkboxClickedFunction = function() { + var checkboxClickedFunction = function () { return self.setOverlayFullView(overlay.getName(), this.checked).then(null, GuiConnector.alert); }; checkbox.onclick = checkboxClickedFunction; @@ -451,7 +453,7 @@ AbstractInfoWindow.prototype._createTargetInfoDiv = function(params) { result.appendChild(checkboxDiv); } count = 0; - for ( var dataId in data) { + for (var dataId in data) { if (data.hasOwnProperty(dataId)) { count++; } @@ -468,7 +470,7 @@ AbstractInfoWindow.prototype._createTargetInfoDiv = function(params) { return result; }; -AbstractInfoWindow.prototype._createTableForTargetDiv = function(data, overlay) { +AbstractInfoWindow.prototype._createTableForTargetDiv = function (data, overlay) { var self = this; var table = document.createElement("table"); table.className = "minerva-window-drug-table"; @@ -484,13 +486,13 @@ AbstractInfoWindow.prototype._createTableForTargetDiv = function(data, overlay) table.appendChild(header); var row; - var onclick = function() { + var onclick = function () { // ';' enforces single query (in case there are ',' characters in the name) return overlay.searchByQuery(this.innerHTML + ";"); }; var count = 0; - for ( var searchId in data) { + for (var searchId in data) { if (data.hasOwnProperty(searchId)) { row = document.createElement("tr"); @@ -509,20 +511,20 @@ AbstractInfoWindow.prototype._createTableForTargetDiv = function(data, overlay) } } var link = Functions.createElement({ - type : "a", - onclick : onclick, - href : "#", - content : nameContent, + type: "a", + onclick: onclick, + href: "#", + content: nameContent, }); var nameTd = Functions.createElement({ - type : "td", + type: "td", }); nameTd.appendChild(link); row.appendChild(nameTd); var referencesCell = Functions.createElement({ - type : "td", + type: "td", }); referencesCell.appendChild(self.getGuiUtils().createAnnotationList(annotations)); @@ -553,73 +555,74 @@ AbstractInfoWindow.prototype._createTableForTargetDiv = function(data, overlay) return table; }; -AbstractInfoWindow.prototype.init = function() { +AbstractInfoWindow.prototype.init = function () { var self = this; - return ServerConnector.getConfiguration().then(function(configuration) { + return ServerConnector.getConfiguration().then(function (configuration) { self.getGuiUtils().setConfiguration(configuration); self.getGuiUtils().setMap(self.getCustomMap()); }); }; -AbstractInfoWindow.prototype.setGuiUtils = function(guiUtils) { +AbstractInfoWindow.prototype.setGuiUtils = function (guiUtils) { this._guiUtils = guiUtils; }; -AbstractInfoWindow.prototype.getGuiUtils = function() { +AbstractInfoWindow.prototype.getGuiUtils = function () { return this._guiUtils; }; /** * Creates and returns DOM div for chemical overlay information. - * + * * @param data * data taken from chemical overlay * @returns DOM element with a div for comment overlay information */ -AbstractInfoWindow.prototype._createChemicalInfoDiv = function(overlay, data) { +AbstractInfoWindow.prototype._createChemicalInfoDiv = function (overlay, data) { return this._createTargetInfoDiv({ - overlay : overlay, - data : data, - name : "Interacting chemicals", + overlay: overlay, + data: data, + name: "Interacting chemicals", }); }; /** * Creates and returns DOM div for mi rna overlay information. - * + * * @param data * data taken from mi rna overlay * @returns DOM element with a div for comment overlay information */ -AbstractInfoWindow.prototype._createMiRnaInfoDiv = function(overlay, data) { +AbstractInfoWindow.prototype._createMiRnaInfoDiv = function (overlay, data) { return this._createTargetInfoDiv({ - overlay : overlay, - data : data, - name : "Interacting Micro RNAs" + overlay: overlay, + data: data, + name: "Interacting Micro RNAs" }); }; -/** - * Abstract method returning identifier of the object for which this window was - * created. - */ -AbstractInfoWindow.prototype.getElementId = function() { - throw new Error("Not implemented"); +AbstractInfoWindow.prototype.setIdentifiedElement = function (identifiedElement) { + if (identifiedElement === undefined) { + throw new Error("identifiedElement cannot be undefined"); + } + this._identifiedElement = identifiedElement; +}; + +AbstractInfoWindow.prototype.getIdentifiedElement = function () { + return this._identifiedElement; }; + /** - * Abstract method returning type of the object for which this window was - * created. + * Method returning identifier of the object for which this window was created. */ -AbstractInfoWindow.prototype.getElementType = function() { - throw new Error("Not implemented"); +AbstractInfoWindow.prototype.getElementId = function () { + return this.getIdentifiedElement().getId(); }; -AbstractInfoWindow.prototype.getIdentifiedElement = function() { - var self = this; - return new IdentifiedElement({ - id : self.getElementId(), - type : self.getElementType(), - modelId : self.getCustomMap().getId() - }); +/** + * Method returning type of the object for which this window was created. + */ +AbstractInfoWindow.prototype.getElementType = function () { + return this.getIdentifiedElement().getType(); }; module.exports = AbstractInfoWindow; diff --git a/frontend-js/src/main/js/map/window/AliasInfoWindow.js b/frontend-js/src/main/js/map/window/AliasInfoWindow.js index 4fb18d9a557c48e5e46b237784ba0c8c480eea53..7edbbd32bd8b25d20a6865be01c67e4a975a03e3 100644 --- a/frontend-js/src/main/js/map/window/AliasInfoWindow.js +++ b/frontend-js/src/main/js/map/window/AliasInfoWindow.js @@ -5,7 +5,9 @@ var functions = require('../../Functions'); var AbstractInfoWindow = require('./AbstractInfoWindow'); var Alias = require('../data/Alias'); +var IdentifiedElement = require('../data/IdentifiedElement'); var LayoutAlias = require('../data/LayoutAlias'); + var pileup = require('pileup'); var Promise = require("bluebird"); @@ -14,6 +16,9 @@ var Promise = require("bluebird"); * Class representing info window that should be opened when clicking on alias. */ function AliasInfoWindow(params) { + if (params.identifiedElement === undefined) { + params.identifiedElement = new IdentifiedElement(params.alias); + } // call super constructor AbstractInfoWindow.call(this, params); @@ -24,8 +29,8 @@ function AliasInfoWindow(params) { var point = new google.maps.Point(alias.x + alias.width / 2, alias.y + alias.height / 2); var latLng = this.customMap.fromPointToLatLng(point); this.googleInfowindow = new google.maps.InfoWindow({ - content : this.content, - position : latLng + content: this.content, + position: latLng }); } @@ -37,26 +42,26 @@ AliasInfoWindow.prototype.constructor = AliasInfoWindow; * Updates content of info window. The content will be automatically obtained * from {@link CustomMap} instance. The only optional parameter is {@link Alias} * data. - * + * * @param newAlias * optional {@link Alias} data for which this {@link AliasInfoWindow} * was created */ -AliasInfoWindow.prototype.update = function(newAlias) { +AliasInfoWindow.prototype.update = function (newAlias) { if (this.alias === undefined && newAlias !== undefined) { this.alias = newAlias; } return this._updateContent(); }; -AliasInfoWindow.prototype.init = function() { +AliasInfoWindow.prototype.init = function () { var self = this; var alias = self.getAlias(); - return AbstractInfoWindow.prototype.init.call(self).then(function() { + return AbstractInfoWindow.prototype.init.call(self).then(function () { return self.getCustomMap().getModel().getAliasById(alias.getId(), true); - }).then(function(alias) { + }).then(function (alias) { return self.update(alias); - }).then(function(){ + }).then(function () { return self.open(); }); }; @@ -64,15 +69,15 @@ AliasInfoWindow.prototype.init = function() { /** * Creates and returns chart representing data related to alias on different * layouts. - * + * * @returns {String} html string representing chart with data related to alias * on different layouts */ -AliasInfoWindow.prototype.createChartDiv = function() { +AliasInfoWindow.prototype.createChartDiv = function () { var result = document.createElement("div"); var rows = []; var self = this; - return Promise.each(self.layoutAliases, function(data, i) { + return Promise.each(self.layoutAliases, function (data, i) { var rowDiv = document.createElement("div"); if (i % 2 === 0) { rowDiv.className = "mapChartRowEvenDiv"; @@ -87,7 +92,7 @@ AliasInfoWindow.prototype.createChartDiv = function() { rows[i] = rowDiv; if (data !== undefined && data !== null) { - return functions.overlayToColor(data).then(function(color) { + return functions.overlayToColor(data).then(function (color) { var value = parseFloat(data.value); var description = data.description; if (description === null || description === undefined || description === "") { @@ -157,7 +162,7 @@ AliasInfoWindow.prototype.createChartDiv = function() { rowDiv.appendChild(emptyDiv); return Promise.resolve(); } - }).then(function() { + }).then(function () { for (var i = 0; i < rows.length; i++) { result.appendChild(rows[i]); } @@ -167,10 +172,10 @@ AliasInfoWindow.prototype.createChartDiv = function() { /** * Methods that creates and return DOM object with the content of the window. - * + * * @returns DOM object representing html code for content of the info window */ -AliasInfoWindow.prototype.createContentDiv = function() { +AliasInfoWindow.prototype.createContentDiv = function () { var self = this; var alias = self.getAlias(); if (alias.isComplete()) { @@ -183,19 +188,19 @@ AliasInfoWindow.prototype.createContentDiv = function() { result.appendChild(layoutsDiv); - return self.getCustomMap().getAliasVisibleLayoutsData(alias.getId()).then(function(layoutAliases) { + return self.getCustomMap().getAliasVisibleLayoutsData(alias.getId()).then(function (layoutAliases) { self.layoutAliases = layoutAliases; return self.getCustomMap().getTopMap().getVisibleDataOverlays(); - }).then(function(dataOverlays) { + }).then(function (dataOverlays) { self.layoutNames = []; for (var i = 0; i < dataOverlays.length; i++) { self.layoutNames.push(dataOverlays[i].getName()); } return self.createChartDiv(); - }).then(function(chartDiv) { + }).then(function (chartDiv) { layoutsDiv.appendChild(chartDiv); return self.createGenomicDiv(); - }).then(function(genomicDiv) { + }).then(function (genomicDiv) { layoutsDiv.appendChild(genomicDiv); return result; }); @@ -206,32 +211,14 @@ AliasInfoWindow.prototype.createContentDiv = function() { /** * Returns array with data taken from all known {@link OverlayCollection}. - * + * * @returns array with data from {@link OverlayCollection} */ -AliasInfoWindow.prototype.getOverlaysData = function(general) { +AliasInfoWindow.prototype.getOverlaysData = function (general) { return this.getCustomMap().getTopMap().getOverlayDataForAlias(this.getAlias(), general); }; -/** - * Method returning identifier of the object for which this window was created. - */ -AliasInfoWindow.prototype.getElementId = function() { - if (this.alias !== undefined) { - return this.alias.getId(); - } else { - return null; - } -}; - -/** - * Method returning type of the object for which this window was created. - */ -AliasInfoWindow.prototype.getElementType = function() { - return "ALIAS"; -}; - -AliasInfoWindow.prototype.createGenomicDiv = function() { +AliasInfoWindow.prototype.createGenomicDiv = function () { var self = this; var result = document.createElement("div"); @@ -248,71 +235,71 @@ AliasInfoWindow.prototype.createGenomicDiv = function() { var genomes = []; var genomeUrls = []; - var pileupSource = [ { - viz : pileup.viz.scale(), - name : 'Scale' + var pileupSource = [{ + viz: pileup.viz.scale(), + name: 'Scale' }, { - viz : pileup.viz.location(), - name : 'Location' - } ]; + viz: pileup.viz.location(), + name: 'Location' + }]; var pileupRange = { - contig : 'chr1', - start : 3000000000, - stop : 0 + contig: 'chr1', + start: 3000000000, + stop: 0 }; var globalGeneVariants = []; return Promise.each( - self.layoutAliases, - function(data) { - if (data !== null && data !== undefined && data.getType() === LayoutAlias.GENETIC_VARIANT) { - geneticInformation = true; - return Promise.each(data.getGeneVariants(), function(variant) { - return self.getCustomMap().getReferenceGenome(variant.getReferenceGenomeType(), - variant.getReferenceGenomeVersion()).then( - function(genome) { - if (genome.getUrl() !== null && genome.getUrl() !== undefined) { - if (genomes[genome.getUrl()] === undefined) { - genomes[genome.getUrl()] = genome; - genomeUrls.push(genome.getUrl()); - } - } else { - logger.warn("Genome for " + variant.getReferenceGenomeType() + "," - + variant.getReferenceGenomeVersion() + " not loaded"); - } - }, - function() { - logger.warn("Genome for " + variant.getReferenceGenomeType() + "," - + variant.getReferenceGenomeVersion() + " not loaded"); - - }); - }); + self.layoutAliases, + function (data) { + if (data !== null && data !== undefined && data.getType() === LayoutAlias.GENETIC_VARIANT) { + geneticInformation = true; + return Promise.each(data.getGeneVariants(), function (variant) { + return self.getCustomMap().getReferenceGenome(variant.getReferenceGenomeType(), + variant.getReferenceGenomeVersion()).then( + function (genome) { + if (genome.getUrl() !== null && genome.getUrl() !== undefined) { + if (genomes[genome.getUrl()] === undefined) { + genomes[genome.getUrl()] = genome; + genomeUrls.push(genome.getUrl()); + } + } else { + logger.warn("Genome for " + variant.getReferenceGenomeType() + "," + + variant.getReferenceGenomeVersion() + " not loaded"); + } + }, + function () { + logger.warn("Genome for " + variant.getReferenceGenomeType() + "," + + variant.getReferenceGenomeVersion() + " not loaded"); - } - }).then(function() { + }); + }); + + } + }).then(function () { for (var i = 0; i < genomeUrls.length; i++) { var genome = genomes[genomeUrls[i]]; pileupSource.splice(0, 0, { - viz : pileup.viz.genome(), - isReference : pileupSource.length === 2, - data : pileup.formats.twoBit({ - url : genome.getUrl() + viz: pileup.viz.genome(), + isReference: pileupSource.length === 2, + data: pileup.formats.twoBit({ + url: genome.getUrl() }), - name : 'Reference ' + genome.getVersion() + name: 'Reference ' + genome.getVersion() }); for (var k = 0; k < genome.getGeneMappings().length; k++) { var mapping = genome.getGeneMappings()[k]; pileupSource.push({ - viz : pileup.viz.genes(), - data : pileup.formats.bigBed({ - url : mapping.getUrl() + viz: pileup.viz.genes(), + data: pileup.formats.bigBed({ + url: mapping.getUrl() }), - name : 'Genes ' + mapping.getName() + name: 'Genes ' + mapping.getName() }); } } - return Promise.each(self.layoutAliases, function(data, i) { + return Promise.each(self.layoutAliases, function (data, i) { globalGeneVariants[i] = []; if (data !== null && data !== undefined && data.getType() === LayoutAlias.GENETIC_VARIANT) { var geneVariants = data.getGeneVariants(); @@ -328,7 +315,7 @@ AliasInfoWindow.prototype.createGenomicDiv = function() { } } }); - }).then(function() { + }).then(function () { if (geneticInformation) { if (genomeUrls.length === 0) { contentElement.innerHTML = "No reference genome data available on minerva platform"; @@ -337,13 +324,13 @@ AliasInfoWindow.prototype.createGenomicDiv = function() { if (globalGeneVariants[iter].length > 0) { var vcfContent = self.createVcfString(globalGeneVariants[iter]); pileupSource.push({ - viz : pileup.viz.variants(), - data : pileup.formats.vcf({ - content : vcfContent + viz: pileup.viz.variants(), + data: pileup.formats.vcf({ + content: vcfContent }), - name : self.layoutNames[iter] + ' - Variants', - options : { - variantHeightByFrequency : true + name: self.layoutNames[iter] + ' - Variants', + options: { + variantHeightByFrequency: true }, }); } @@ -360,8 +347,8 @@ AliasInfoWindow.prototype.createGenomicDiv = function() { logger.debug("Pileup destroyed"); } self.pileup = pileup.create(contentElement, { - range : pileupRange, - tracks : pileupSource + range: pileupRange, + tracks: pileupSource }); } @@ -372,7 +359,7 @@ AliasInfoWindow.prototype.createGenomicDiv = function() { }); }; -AliasInfoWindow.prototype.createVcfString = function(geneVariants) { +AliasInfoWindow.prototype.createVcfString = function (geneVariants) { var result = ""; result += "##fileformat=VCFv4.0\n"; result += "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\n"; @@ -387,29 +374,29 @@ AliasInfoWindow.prototype.createVcfString = function(geneVariants) { variantId = variant.getVariantIdentifier(); } result += variant.getContig() + "\t" + // - variant.getPosition() + "\t" + // - variantId + "\t" + // - variant.getOriginalDna() + "\t" + // - variant.getModifiedDna() + "\t" + // - "100.0\t" + // - "PASS\t" + // - additionalInfo + "\n"; + variant.getPosition() + "\t" + // + variantId + "\t" + // + variant.getOriginalDna() + "\t" + // + variant.getModifiedDna() + "\t" + // + "100.0\t" + // + "PASS\t" + // + additionalInfo + "\n"; } return result; }; -AliasInfoWindow.prototype.setAlias = function(alias) { +AliasInfoWindow.prototype.setAlias = function (alias) { if (alias === undefined || alias === null || (!(alias instanceof Alias))) { throw new Error("invalid alias"); } this.alias = alias; }; -AliasInfoWindow.prototype.getAlias = function() { +AliasInfoWindow.prototype.getAlias = function () { return this.alias; }; -AliasInfoWindow.prototype.destroy = function() { +AliasInfoWindow.prototype.destroy = function () { if (this.pileup !== undefined) { this.pileup.destroy(); } diff --git a/frontend-js/src/main/js/map/window/PointInfoWindow.js b/frontend-js/src/main/js/map/window/PointInfoWindow.js index 7a32e32dd25bd592f7016d7f0142b20f1bc43151..c850896c7ab42a313eae7b6a9a593762edcc0d30 100644 --- a/frontend-js/src/main/js/map/window/PointInfoWindow.js +++ b/frontend-js/src/main/js/map/window/PointInfoWindow.js @@ -3,8 +3,12 @@ var Promise = require("bluebird"); var AbstractInfoWindow = require('./AbstractInfoWindow'); +var IdentifiedElement = require('../data/IdentifiedElement'); function PointInfoWindow(params) { + if (params.identifiedElement === undefined) { + params.identifiedElement = new IdentifiedElement(params.point); + } // call super constructor AbstractInfoWindow.call(this, params); @@ -13,8 +17,8 @@ function PointInfoWindow(params) { var point = this.pointData.getPoint(); var latLng = this.getCustomMap().fromPointToLatLng(point); this.googleInfowindow = new google.maps.InfoWindow({ - content : this.content, - position : latLng + content: this.content, + position: latLng }); this.googleInfowindow.open(this.getCustomMap().getGoogleMap(), this.getGoogleMarker()); this.update(); @@ -23,7 +27,7 @@ function PointInfoWindow(params) { PointInfoWindow.prototype = Object.create(AbstractInfoWindow.prototype); PointInfoWindow.prototype.constructor = PointInfoWindow; -PointInfoWindow.prototype.createContentDiv = function() { +PointInfoWindow.prototype.createContentDiv = function () { var result = document.createElement("div"); var title = document.createElement("h3"); title.innerHTML = "Point: " + this.pointData.getPoint(); @@ -32,26 +36,9 @@ PointInfoWindow.prototype.createContentDiv = function() { return Promise.resolve(result); }; -PointInfoWindow.prototype.getOverlaysData = function(general) { +PointInfoWindow.prototype.getOverlaysData = function (general) { return this.getCustomMap().getTopMap().getOverlayDataForPoint(this.pointData, general); }; -/** - * Method returning identifier of the object for which this window was created. - */ -PointInfoWindow.prototype.getElementId = function() { - if (this.pointData !== undefined) { - return this.pointData.getId(); - } else { - return null; - } -}; - -/** - * Method returning type of the object for which this window was created. - */ -PointInfoWindow.prototype.getElementType = function() { - return "POINT"; -}; module.exports = PointInfoWindow; diff --git a/frontend-js/src/main/js/map/window/ReactionInfoWindow.js b/frontend-js/src/main/js/map/window/ReactionInfoWindow.js index 1df46abffa587dc974b5a8ee2a5172b13762bc78..4ff09bae2ecad8450637938c3726dd6d6c97d9b4 100644 --- a/frontend-js/src/main/js/map/window/ReactionInfoWindow.js +++ b/frontend-js/src/main/js/map/window/ReactionInfoWindow.js @@ -3,6 +3,7 @@ var Promise = require("bluebird"); var AbstractInfoWindow = require('./AbstractInfoWindow'); +var IdentifiedElement = require('../data/IdentifiedElement'); var Reaction = require('../data/Reaction'); /** @@ -10,6 +11,9 @@ var Reaction = require('../data/Reaction'); * reaction. */ function ReactionInfoWindow(params) { + if (params.identifiedElement === undefined) { + params.identifiedElement = new IdentifiedElement(params.reaction); + } // call super constructor AbstractInfoWindow.call(this, params);