/* IBM Confidential OCO Source Materials IBM Cognos Products: irot (C) Copyright IBM Corp. 2003, 2016 The source code for this program is not published or otherwise divested of its trade secrets, irrespective of what has been deposited with the U.S. Copyright Office. */ define([], function() { var G_Rave1Adapter = {}; /* * Custom adapter settings * checkSupportedConfig * * * Init status codes * checkSupportedConfigErrorCode * */ G_Rave1Adapter.Initialize = function(v_sAdapterId, v_sAdapterLocationFull, v_oAdapterSettings) { if (!this.m_oDeferredInitialize) { this.m_oDeferredInitialize = Q.defer(); this.m_oBundleLibrary = {}; this.m_oVisDataDefinition = {}; var v_sAdapterLocation = v_sAdapterLocationFull.substr(0, v_sAdapterLocationFull.lastIndexOf("/")); // Included for the RAVE charting engine. If a RAVE chart is not used, the server will put empty files in the MHT // dojo is included first so that we can overwrite their definitions and not them overwriting ours // Need to define the configuration as a module define("dojo/_base/config", { async : true, afterOnLoad: true, locale : 'en-us', gfxRenderer : 'canvas,silverlight', blankGif : 'hal/imagesirot/blank.gif' }); var v_oConfig = { waitSeconds : 60, paths : { "dojo" : v_sAdapterLocation + "/rave/dojo", "dojox" : v_sAdapterLocation + "/rave/dojox", "com" : v_sAdapterLocation + "/rave/com" } }; this.M_bIsIE = ( ( ( navigator.userAgent.toLowerCase().search(/trident\/([0-9]+\.[0-9]+)/) != -1 ) ? parseFloat( RegExp.$1 ) : 0 ) >= 7.0 ); var v_fnOnDojoLoaded = ( this.M_bIsIE ? this.f_onDojoLoadedIE : this.f_onDojoLoaded ).bind( this, v_sAdapterId, v_sAdapterLocation, v_oAdapterSettings ); require( v_oConfig, ["dojo/dojo"], v_fnOnDojoLoaded ); } return this.m_oDeferredInitialize.promise; }; G_Rave1Adapter.f_onDojoLoadedIE = function(v_sAdapterId, v_sAdapterLocation, v_oAdapterSettings) { var fn = this.f_onDojoLoaded.bind( this, v_sAdapterId, v_sAdapterLocation, v_oAdapterSettings ); // This block is required in IE to force dojo to the use the ActiveX XMLHttpRequest instead of the builtin XmlHttpRequest object. // The builtin XmlHttpRequest will return security errors for any files loaded from an MHT file when the MHT file is access through an HTTP url. require(["dojo/has", "dojo/sniff"], function(has) { has.add('activex', true, false, true); has.add('dojo-force-activex-xhr', true, false, true); has.add('native-xhr', false, false, true); has.add('native-xhr2', false, false, true); fn(); }); }; G_Rave1Adapter.f_onDojoLoaded = function(v_sAdapterId, v_sAdapterLocation, v_oAdapterSettings) { // Load RAVE and it's dependencies using dojo require(["dojo/dojo-core-layer"], function() { require(["com/ibm/vis/main"], function() { //once we have the rave layer loaded, we can use all rave modules require(["com/ibm/init/ready", "com/ibm/vis/widget/VisControl", "com/ibm/vis/widget/Environment", "com/ibm/vis/interaction/HighlightRepresentation", "com/ibm/vis/interaction/ChangeEffect", "com/ibm/vis/template/Template", "com/ibm/vis/interaction/SceneItemTypes"], function(v_fnReady, v_fnVisControl, v_fnVisEnvironment, v_fnVisHighlightRepresentation, v_fnVisChangeEffect, v_fnVisTemplate, v_fnSceneItemTypes) { //ready function is needed to ensure the rave system is properly loaded v_fnReady(function() { this.m_oRaveEnv = { M_fnVisControl : v_fnVisControl, M_fnVisHighlightRepresentation : v_fnVisHighlightRepresentation, M_fnVisChangeEffect : v_fnVisChangeEffect, M_fnVisTemplate : v_fnVisTemplate, M_fnSceneItemTypes : v_fnSceneItemTypes }; /* * * Environment.checkBrowserSupportedConfiguration() * * This is a browser sniffing API and checks if the current browser environment * is compatible with RAVE. It returns an Integer. The possible value of this * returned Integer is predefined and mapped to the specific environment setting. * * returnCode = 0 : Supported environment for RAVE * * All other return codes mean that the environment is not supported by RAVE. * [Requirement taken from the Acceptance Tests of the RTC Story #29082] * returnCode = 1 : Silverlight version 5 onwards not available on Internet Explorer * returnCode = 2 : Internet Explorer version prior to IE7 is found * returnCode = 3 : Firefox version prior to 3.6 is found * returnCode = 4 : Opera browser found * returnCode = 5 : Internet Explorer 9 in Quirks Mode without silverlight version >=5 * returnCode = 6 : Internet Explorer 10 in IE5 Quirks mode */ if (v_oAdapterSettings && v_oAdapterSettings.custom && v_oAdapterSettings.custom.checkSupportedConfig) { var v_iErrorCode = v_fnVisEnvironment.checkBrowserSupportedConfiguration(); //Only look for SV errors. ARs need to work in IE5 Quirks mode in IE 10 in AR Preview if ( v_iErrorCode == 1 || v_iErrorCode == 5) { this.m_oDeferredInitialize.reject({checkSupportedConfigErrorCode : v_iErrorCode}); return; } } this.m_oDeferredInitialize.resolve(true); }.bind(this)); }.bind(this)); }.bind(this)); }.bind(this)); }; G_Rave1Adapter.Destroy = function() { }; // cannot use the AMD text loader as it does not work on IE (access denied errors) when dealing with MHT files or file URL. G_Rave1Adapter.f_loadTextFile = function( v_sLocation ) { var v_sAgent = navigator.userAgent.toLowerCase(); var v_fIEVersion = ( v_sAgent.search(/trident\/([0-9]+\.[0-9]+)/) != -1 ) ? parseFloat( RegExp.$1 ) : 0; var v_bIsIE = (v_fIEVersion >= 7.0); var v_bIsFirefox = ( v_sAgent.match( /firefox|minefield|shiretoko|namoroka/ ) != null ); var v_oRequest = v_bIsIE ? new ActiveXObject( "MSXML2.XMLHTTP.3.0" ) : new XMLHttpRequest(); try { v_oRequest.open( "GET", v_sLocation, false ); if ( v_bIsFirefox ) { v_oRequest.overrideMimeType( "text/plain; charset=utf-8" ); } v_oRequest.send( null ); } catch ( e ) { // can't localize this message because it may be string file we are loading. alert( "Failed to load file:" + v_sLocation ); return ""; } return ( v_oRequest.status == 404 ) ? "" : v_oRequest.responseText; }; G_Rave1Adapter.LoadVisChartType = function(v_sBundleId, v_sBundleLocation, v_fnOnVisBundleLoaded) { if (this.m_oBundleLibrary[v_sBundleId]) { v_fnOnVisBundleLoaded(v_sBundleId); return; } var v_sUrl = v_sBundleLocation; // cannot use the AMD text loader as it does not work on IE (access denied errors) when dealing with MHT files or file URL. var v_sVisJSON = this.f_loadTextFile(v_sUrl); var v_oVisJSON = dojo.fromJson(v_sVisJSON); var v_oBundle = this.m_oBundleLibrary[v_sBundleId] = {}; v_oBundle.M_sBundleId = v_sBundleId; v_oBundle.M_oVisJSON = v_oVisJSON; v_oBundle.M_sVisJSON = v_sVisJSON; v_fnOnVisBundleLoaded(v_sBundleId); }; G_Rave1Adapter.CreateVis = function(v_sBundleId) { return new C_Rave1Viz(this.m_oRaveEnv, this.m_oBundleLibrary[v_sBundleId]); }; G_Rave1Adapter.GetVisDataDefinition = function(v_sBundleId) { var v_oVisJSON = this.m_oBundleLibrary[v_sBundleId].M_oVisJSON; if (!v_oVisJSON) { return null; } if (!v_oVisJSON.data) { return {}; } var v_oDef = this.m_oVisDataDefinition[v_sBundleId]; if (v_oDef) { return v_oDef; } // This should probably be generated from the chart type definition and not the visJSON v_oDef = {}; v_oDef.dataSets = []; v_oDef.M_oSlotDataSet = {}; for (var v_iData = 0; v_iData < v_oVisJSON.data.length; ++v_iData) { var v_oDataSet = v_oVisJSON.data[v_iData]; var v_oDataDef = {}; v_oDef.dataSets.push(v_oDataDef); v_oDataDef.id = v_oDataSet.id; v_oDataDef.slots = []; if ( v_oDataSet.fields ) { for (var i = 0; i < v_oDataSet.fields.length; ++i) { var v_oField = v_oDataSet.fields[i]; var v_oFieldDef = {}; v_oDataDef.slots.push(v_oFieldDef); v_oFieldDef.id = v_oField.id; v_oFieldDef.type = v_oField.categories ? "category" : "value"; v_oDef.M_oSlotDataSet[v_oField.id] = v_oDataSet.id; } } } this.m_oVisDataDefinition[v_sBundleId] = v_oDef; return v_oDef; }; //======================================= var C_Rave1Viz = function(v_oRaveEnv, v_oBundle) { this.m_oRaveEnv = v_oRaveEnv; // Each instance of Viz should keep a local copy of JSON from boundle. // Otherwise, the later setData would polute the template which is shared by other instants. this.m_oVisJSONBundle = dojo.clone(v_oBundle.M_oVisJSON); this.m_oVisJSON = null; this.m_sErrorMessage = ""; var v_oVisDef = G_Rave1Adapter.GetVisDataDefinition(v_oBundle.M_sBundleId); this.m_oSlotDataSet = v_oVisDef.M_oSlotDataSet; }; /* * Custom vis settings * properties, * validateJSON * */ C_Rave1Viz.prototype.Initialize = function(v_elContainerDiv, v_oVisSettings, v_fnOnInitializeComplete) { this.m_elContainerDiv = v_elContainerDiv; // RAVE is loaded, load the visualization this.m_oVisControl = new this.m_oRaveEnv.M_fnVisControl(); v_elContainerDiv.appendChild( this.m_oVisControl.domNode ); // hide the focus rect on IE if ( G_Rave1Adapter.M_bIsIE ) { this.m_oVisControl.domNode.hideFocus = true; } this.m_oVisControl.startup().then(dojo.hitch(this, this.f_onRaveStartupAsync, v_oVisSettings, v_fnOnInitializeComplete)); }; C_Rave1Viz.prototype.Destroy = function() { if (this.m_oVisControl) { this.m_oVisControl.destroy(); this.m_oVisControl = null; } }; /* * v_fnOnDrawComplete(v_oDrawStatus) * v_oDrawStatus = { * error * } */ C_Rave1Viz.prototype.Draw = function(v_fnOnDrawComplete) { if (this.m_sErrorMessage) { this.DrawBlank(); v_fnOnDrawComplete({ error : this.m_sErrorMessage }); return; } try { if ( this.m_bDrawWithTransition ) { this.m_oVisControl.setSpecWithTransition(this.m_oVisJSON, 1); } else { this.m_oVisControl.setSpec(this.m_oVisJSON); } } catch( e ) { this.DrawBlank(); var v_sMessage = ""; if (e.getMessage || e.getErrorDescription) { v_sMessage = (e.getMessage && e.getMessage()) ? e.getMessage() : ""; if (v_sMessage == "") { v_sMessage = (e.getErrorDescription && e.getErrorDescription()) ? e.getErrorDescription() : ""; } } v_fnOnDrawComplete({ error : v_sMessage }); return; } if ( !this.m_bDrawWithTransition ) { v_fnOnDrawComplete(); } this.m_fnOnDrawComplete = v_fnOnDrawComplete; }; C_Rave1Viz.prototype.DrawHighlights = function(v_aSelectionVisElements, v_aHoverVisElements) { var v_aSelections = (v_aSelectionVisElements && v_aSelectionVisElements.length) ? this.f_getSceneItemsFromVisElements(v_aSelectionVisElements) : null; var v_aHovers = (v_aHoverVisElements && v_aHoverVisElements.length) ? this.f_getSceneItemsFromVisElements(v_aHoverVisElements) : null; var o = this.m_oVisControl.interactivity().makeHighlightState(); if (v_aSelections) { o.setMultiple( v_aSelections, this.k_iHighlight_Selection ); } if (v_aHovers) { o.setMultiple( v_aHovers, this.k_iHighlight_Hover ); } o.apply(); }; C_Rave1Viz.prototype.DrawBlank = function() { var v_oBlank = { "grammar": [ ] }; if (this.m_oVisSettings.properties.width && this.m_oVisSettings.properties.height) { v_oBlank.size = { width : this.m_oVisSettings.properties.width, height : this.m_oVisSettings.properties.height }; } try { this.m_oVisControl.setSpec(v_oBlank); } catch(e) { } }; C_Rave1Viz.prototype.SetData = function(v_idxDataSet, v_oDataSetChanges) { var v_oDataSet = this.m_oVisJSON.data[v_idxDataSet]; v_oDataSet.rows = v_oDataSetChanges.rows || []; if (v_oDataSetChanges.fields) { for (var i = 0; i < v_oDataSetChanges.fields.length; ++i) { var v_oField = v_oDataSetChanges.fields[i]; var v_oTargetField = v_oDataSet.fields[i]; var v_aProps = ["label", "min", "max", "categories"]; for (var ip = 0; ip < v_aProps.length; ++ip) { var s = v_aProps[ip]; v_oTargetField[s] = v_oField[s]; } } } }; C_Rave1Viz.prototype.GetVisElementsAtPoint = function(v_iClientX, v_iClientY) { return this.f_createVisElementsForSceneItems(this.m_oVisControl.interactivity().getItemsAtPoint( v_iClientX, v_iClientY )); }; C_Rave1Viz.prototype.GetVisElementsAtTouchPoint = function(v_iClientX, v_iClientY) { // I believe that the accounting for scroll position is because on an iPad sometimes the body can be scrolled, which does not happen on desktop var x = v_iClientX + document.body.scrollLeft; var y = v_iClientY + document.body.scrollTop; var v_oVisElement = this.GetVisElementsAtPoint( x, y ); if ( v_oVisElement ) { return v_oVisElement; } for ( var v_iRadius = 3; v_iRadius <= 12; v_iRadius += 3 ) { var v_oVisElement = this.f_getVisElementInCircle( x, y, v_iRadius ); if ( v_oVisElement ) { //G_Debug.F_Print( "f_getVisElementInCircle(" + v_iRadius + ")" ); return v_oVisElement; } } return []; }; C_Rave1Viz.prototype.f_getVisElementInCircle = function( x, y, v_iRadius ) { var v_aXs = []; var v_aYs= []; var v_aRadians = [0.0, 0.25 * Math.PI, 0.5 * Math.PI, 0.75 * Math.PI, Math.PI, 1.25 * Math.PI, 1.5 * Math.PI, 1.75 * Math.PI]; for ( var i = 0; i < v_aRadians.length; i++ ) { v_aXs.push( x + Math.round( v_iRadius * Math.cos( v_aRadians[i] ) ) ); v_aYs.push( y + Math.round( v_iRadius * Math.sin( v_aRadians[i] ) ) ); } return this.f_createVisElementsForSceneItems(this.m_oVisControl.interactivity().getItemsInPolygon(v_aXs, v_aYs)); }; C_Rave1Viz.prototype.GetVisElementsForRows = function(v_idxDataSet, v_aRows) { var v_aSceneItems = this.m_oVisControl.interactivity().getItemsMatchingAnyRows(v_aRows); var v_aFilteredSceneItems = []; for ( var v_iSi = 0; v_iSi < v_aSceneItems.length; v_iSi++ ) { var v_oSceneItem = v_aSceneItems[v_iSi]; if (v_oSceneItem.getDataIndex() == v_idxDataSet) { var v_aSceneItemRows = v_oSceneItem.getRows(); var v_bAdd = true; for (var i = 0; i < v_aSceneItemRows.length; ++i) { if (v_aRows.indexOf(v_aSceneItemRows[i]) == -1) { v_bAdd = false; break; } } if (v_bAdd) { v_aFilteredSceneItems.push(v_oSceneItem); } } } return this.f_createVisElementsForSceneItems(v_aFilteredSceneItems); }; C_Rave1Viz.prototype.SetValueSlotFormatter = function(v_fnNumberFormatter) { this.m_oVisControl.setNumberFormatter({ formatNumber : this.f_numberFormatterCallback.bind(this, v_fnNumberFormatter) }); }; C_Rave1Viz.prototype.f_numberFormatterCallback = function(v_fnNumberFormatter, value, rowIndex, fieldId, min, max, unit, visId) { return v_fnNumberFormatter(value, rowIndex, fieldId, this.m_oSlotDataSet[fieldId]); }; C_Rave1Viz.prototype.GetCurrentVisualizationState = function() { return JSON.stringify(this.m_oVisJSON, null, "\t"); }; C_Rave1Viz.prototype.SetAccessibilityDescription = function(v_sDescription) { this.m_oVisJSON.description = v_sDescription; }; C_Rave1Viz.prototype.ApplySettings = function(v_oVisSettings) { this.m_oVisSettings = v_oVisSettings; this.m_oVisControl.setSpecificationValidation(Boolean(this.m_oVisSettings.custom ? this.m_oVisSettings.custom.validateJSON : false)); this.f_resolveParameters(); if (v_oVisSettings.properties.width || v_oVisSettings.properties.height) { if (!this.m_oVisJSON.size) { this.m_oVisJSON.size = {}; } this.m_oVisJSON.size.width = v_oVisSettings.properties.width; this.m_oVisJSON.size.height = v_oVisSettings.properties.height; // Explicitly setting the size avoids RAVE bugs with resizing in Silverlight this.m_oVisControl.domNode.style.width = this.m_oVisJSON.size.width; this.m_oVisControl.domNode.style.height = this.m_oVisJSON.size.height; } this.m_bDrawWithTransition = false; var v_sAnimationEffect = v_oVisSettings.properties.animationEffect; if (v_sAnimationEffect && v_sAnimationEffect != "none") { this.m_bDrawWithTransition = true; var v_oEffects = this.m_oVisControl.interactivity().getChangeEffects(); var v_oEffect; switch (v_sAnimationEffect) { case "transition": v_oEffect = v_oEffects.makeTransitionEffect( 500 ); v_oEffect.setFadeOutDuration(0.0, 1.0); v_oEffect.setMorphDuration(0.0, 1.0); v_oEffect.setFadeInDuration(0.0, 1.0); break; case "fadeIn": v_oEffect = v_oEffects.makeFadeInEffect( 500 ); break; case "flyIn": v_oEffect = v_oEffects.makeFlyInEffect( 500 ); break; case "grow": v_oEffect = v_oEffects.makeGrowEffect( 500 ); break; case "reveal": v_oEffect = v_oEffects.makeRevealEffect( 500 ); break; default: // unknow animation effect, ignore this.m_bDrawWithTransition = false; if (console && console.log) { console.log("Unknown animationEffect ignored: " + v_sAnimationEffect); } break; } v_oEffect.setTarget( this.m_oRaveEnv.M_fnVisChangeEffect.ELEMENT ); v_oEffects.setChangeEffect( v_oEffect, 1 ); // set up rave event handler so we can draw selections after animation effects this.update = dojo.hitch(this, this.f_onRaveEvent); this.m_oVisControl.addListener("EffectEndEvent", this); } // Setup highlights for selection and hovering var v_oSelectionHighlight = { fill : "rgba(242,188,102,0.4)", outline : "#F2BC66", stroke : { width : "1.75pt" } }; /* var v_oSelectionHighlight = { fill : "rgba(255,255,255,0.6)", outline : "rgba(255,255,255,0.6)", stroke : { width : "1.75pt" } }; */ var v_oHoverHighlight = { fill : "rgba(247,225,188,0.4)", outline : "#F2BC66", stroke : { width : "1.75pt" } }; var v_oInteractivity = this.m_oVisControl.interactivity(); v_oInteractivity.setHighlightRepresentation(this.k_iHighlight_Selection, new this.m_oRaveEnv.M_fnVisHighlightRepresentation( v_oSelectionHighlight )); v_oInteractivity.setHighlightRepresentation(this.k_iHighlight_Hover, new this.m_oRaveEnv.M_fnVisHighlightRepresentation( v_oHoverHighlight )); }; /** * @type Boolean Returns false if there was an error while applying the parameters */ C_Rave1Viz.prototype.f_resolveParameters = function() { var v_sVersion = this.m_oVisJSONBundle.version; if (!v_sVersion || parseFloat(v_sVersion) < 5.0) { if (this.m_oVisJSON == null) { this.m_oVisJSON = dojo.clone(this.m_oVisJSONBundle); } return; } //Logged https://rtc-rave.ottawa.ibm.com:9451/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/16859 //Add JSON interface to template constructor and return value of resolve method var v_sOriginalJSON = this.m_sVisJSON; var v_bResolvedTemplate = false; var v_oResolvedJSON = ""; try { //The object passed to createTemplateFromJSON will be modified var v_oClone = dojo.clone( this.m_oVisJSONBundle ); var v_oTemplate = this.m_oRaveEnv.M_fnVisTemplate.createTemplateFromJSON( v_oClone ); if (v_oTemplate.hasParameters()) { //Logged https://rtc-rave.ottawa.ibm.com:9451/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/16928 //RAVE should return an object of type Array directly var v_aParams = v_oTemplate.getParameters().toArray(); for (var i = 0; i < v_aParams.length; i++) { var v_oParam = v_aParams[i]; var v_sParamId = v_oParam.getId(); if (typeof this.m_oVisSettings.properties[v_sParamId] != "undefined") { v_oTemplate.setParameterValue(v_sParamId, this.m_oVisSettings.properties[v_sParamId]); } } if (v_oTemplate.canBeResolved()) { v_oResolvedJSON = v_oTemplate.resolveToJSON(); v_bResolvedTemplate = true; } } } catch(e) { var v_sMessage = ""; if (e.getMessage || e.getErrorDescription) { v_sMessage = (e.getMessage && e.getMessage()) ? e.getMessage() : ""; if (v_sMessage == "") { v_sMessage = (e.getErrorDescription && e.getErrorDescription()) ? e.getErrorDescription() : ""; } } this.m_sErrorMessage = v_sMessage; } if (v_bResolvedTemplate) { try { // The new JSON is the one after resolved, here we need to keep the data. if (this.m_oVisJSON != null) { var v_oData = this.m_oVisJSON.data; this.m_oVisJSON = v_oResolvedJSON; this.m_oVisJSON.data = v_oData; } else { this.m_oVisJSON = v_oResolvedJSON; } } catch(e) { this.m_sErrorMessage = e.message ? e.message : " "; } } else if (this.m_oVisJSON == null) { this.m_oVisJSON = dojo.clone(this.m_oVisJSONBundle); } }; C_Rave1Viz.prototype.f_onRaveStartupAsync = function(v_oVisSettings, v_fnOnInitializeComplete) { // The dojo 'then' introduces a try/catch block. This setTimeout prevent that block from interfering with subsequent exceptions. // The setTimeout should be removed if the defered dojo code is removed. setTimeout( dojo.hitch(this, this.f_onRaveStartup, v_oVisSettings, v_fnOnInitializeComplete), 0 ); }; C_Rave1Viz.prototype.k_iHighlight_Selection = 0; C_Rave1Viz.prototype.k_iHighlight_Hover = 1; C_Rave1Viz.prototype.f_onRaveStartup = function(v_oVisSettings, v_fnOnInitializeComplete) { this.ApplySettings(v_oVisSettings); v_fnOnInitializeComplete(); }; C_Rave1Viz.prototype.f_onRaveEvent = function(v_oEvent, v_oController) { if (this.m_fnOnDrawComplete && v_oEvent.getEventGroup() == "EffectEndEvent") { var v_fnOnDrawComplete = this.m_fnOnDrawComplete; this.m_fnOnDrawComplete = null; v_fnOnDrawComplete(); } }; C_Rave1Viz.prototype.f_getSceneItemsFromVisElements = function(v_aVisElements) { var a = []; for (var i = 0; i < v_aVisElements.length; ++i) { a.push(v_aVisElements[i].m_oSceneItem); } return a; }; C_Rave1Viz.prototype.f_createVisElementsForSceneItems = function(v_aSceneItems) { var a = []; for (var i = 0; i < v_aSceneItems.length; ++i) { a.push(new C_Rave1VizElement(v_aSceneItems[i], this.m_oRaveEnv)); } return a; }; C_Rave1Viz.prototype.IsEqualVisElement = function(v_oVisElement1, v_oVisElement2) { if (v_oVisElement1 && v_oVisElement2) { return (v_oVisElement1.m_oSceneItem == v_oVisElement2.m_oSceneItem); } // return true if both are null return (v_oVisElement1 == v_oVisElement2); }; //================================================================================== var C_Rave1VizElement = function(v_oSceneItem, v_oRaveEnv) { this.m_oSceneItem = v_oSceneItem; this.m_oRaveEnv = v_oRaveEnv; }; C_Rave1VizElement.prototype.GetType = function() { if (!this.m_sType) { var v_sType = this.m_oSceneItem.getType(); var v_sSubType = this.m_oSceneItem.subType(); if (v_sType == this.m_oRaveEnv.M_fnSceneItemTypes.TYPE_ELEMENT && v_sSubType != this.m_oRaveEnv.M_fnSceneItemTypes.SUBTYPE_LABEL) { this.m_sType = "intersection"; } else { this.m_sType = "category"; } } return this.m_sType; }; C_Rave1VizElement.prototype.GetDataSetIdx = function() { return this.m_oSceneItem.getDataIndex(); }; C_Rave1VizElement.prototype.GetRows = function() { return this.m_oSceneItem.getRowsWithoutAugmentedRows(); }; C_Rave1VizElement.prototype.GetFields = function() { // TBD }; C_Rave1VizElement.prototype.GetColor = function() { var v_oColor = this.f_getColorFromSceneItem(this.m_oSceneItem); if (!v_oColor) { var v_aChildren = this.m_oSceneItem.getHitChildren(); if (v_aChildren) { for (var i = 0; !v_oColor && (i < v_aChildren.length); ++i) { v_oColor = this.f_getColorFromSceneItem(v_aChildren[i]); } } } if (v_oColor != null) { var v_oJSColor = {}; var v_aColors = v_oColor.getRGBA(); if (v_aColors.length >= 3) { v_oJSColor.r = v_aColors[0]; v_oJSColor.g = v_aColors[1]; v_oJSColor.b = v_aColors[2]; return v_oJSColor; } } return v_oColor; }; C_Rave1VizElement.prototype.f_getColorFromSceneItem = function(v_oSceneItem) { var v_oStyle = v_oSceneItem.getSceneNode().getRenderStyleInfo(); // get the fill; if non-null, try first the gradient, then the solid var v_oFill = v_oStyle.getFillProperty(); if (v_oFill != null) { var v_aColors = v_oFill.getGradientColors(); // returns an array of colors if (v_aColors != null && v_aColors.length >= 1) { return v_aColors[0]; } var v_oSolid = v_oFill.getSolid(); // returns a single color if (v_oSolid != null) { return v_oSolid; } } // fill didn't work, try the outline var v_oOutline = v_oStyle.getOutlineProperty(); if (v_oOutline != null) { return v_oOutline; } return null; }; return G_Rave1Adapter; });