Mercurial > hg > STI-GWT
view war/scripts/sti/DataObject.js @ 30:1e95995ddbb2
re-added the ability to refine the dataset by a (very simple) text search
author | Sebastian Kruse <skruse@mpiwg-berlin.mpg.de> |
---|---|
date | Wed, 28 Nov 2012 17:01:34 +0100 |
parents | 775477d89709 |
children | 8b58d9bc0bb6 |
line wrap: on
line source
/** * class that contains all needed information about an element of the resulting data set including time and place values * @param {String} name the name of the data object * @param {String} description description of the data object * @param {String} place the place, the data object corresponds to * @param {Date} time the time stamp, the data object corresponds to * @param {int} granularity the granularity of the given time * @param {float} lon the longitude value corresponding to the given place * @param {float} lat the latitude value corresponding to the given place * * @constructor */ DataObject = function(name, description, place, timeStamp, timeSpan, granularity, lon, lat){ this.name = name; this.description = description; this.timeStamp = timeStamp; this.timeSpan = timeSpan; this.granularity = granularity; this.longitude = lon; this.latitude = lat; this.setPlaces(place); this.status = false; this.percentage = 0; this.hoverSelect = false; }; DataObject.prototype = { /** * sets the selection-percentage of the data object * @param {float} percentage sets the percentage value (p); it describes the ratio to the actual selection <br> * p = 0 if this data object is unselected, p = 1 if it is selected and 0 < p < 1 if its in a feather range */ setPercentage: function(percentage){ if (this.percentage == percentage) this.status = false; else { this.percentage = percentage; this.status = true; } }, inTime: function( minTime, maxTime ){ if( this.timeStamp != undefined ){ if( this.timeStamp.getTime() >= minTime.getTime() && this.timeStamp.getTime() <= maxTime.getTime() ){ return true; } } else { if( this.timeSpan.start.getTime() >= minTime.getTime() && this.timeSpan.start.getTime() <= maxTime.getTime() ){ return true; } if( this.timeSpan.end.getTime() >= minTime.getTime() && this.timeSpan.end.getTime() <= maxTime.getTime() ){ return true; } } return false; }, /** * sets the object to a hover selection status * @param {boolean} hover bool value that tells if an object is hovered or not */ setHover: function(hover){ this.hoverSelect = hover; if( this.percentage != 1 ){ this.status = true; } }, /** * return the string representation of the objects time * @return the string representation of the objects time */ getTimeString: function(){ if( this.timeStamp != undefined ){ return SimileAjax.DateTime.getTimeString(this.granularity,this.timeStamp)+""; } else { return ( SimileAjax.DateTime.getTimeString(this.granularity,this.timeSpan.start)+" - "+SimileAjax.DateTime.getTimeString(this.granularity,this.timeSpan.end)); } }, /** * return the string representation of the timeStamp * @return the string representation of the timeStamp */ getTimeStampString: function(){ if( this.timeStamp != undefined ){ return SimileAjax.DateTime.getTimeString(this.granularity,this.timeStamp)+""; } return(undefined); }, /** * return the string representation of the timeStamp * @return the string representation of the timeStamp */ getTimeSpanStartString: function(){ if( this.timeSpan != undefined ){ return SimileAjax.DateTime.getTimeString(this.granularity,this.timeSpan.start)+""; } return(undefined); }, /** * return the string representation of the timeStamp * @return the string representation of the timeStamp */ getTimeSpanEndString: function(){ if( this.timeSpan != undefined ){ return SimileAjax.DateTime.getTimeString(this.granularity,this.timeSpan.end)+""; } return(undefined); }, isSelected: function(){ if( this.percentage > 0 || this.hoverSelect ){ return true; } return false; }, setPlaces: function(place){ this.placeDetail = place.split("/"); this.place = ""; for( var i=0; i<this.placeDetail.length; i++ ){ if( i>0 ){ this.place += ", "; } this.place += this.placeDetail[i]; } }, getPlace: function(level){ if( level >= this.placeDetail.length ){ return this.placeDetail[this.placeDetail.length-1]; } return this.placeDetail[level]; } };