comparison war/scripts/sti/DataObject.js @ 3:cf06b77a8bbd

Committed branch of the e4D repos sti-gwt branch 16384. git-svn-id: http://dev.dariah.eu/svn/repos/eu.dariah.de/ap1/sti-gwt-dariah-geobrowser@36 f2b5be40-def6-11e0-8a09-b3c1cc336c6b
author StefanFunk <StefanFunk@f2b5be40-def6-11e0-8a09-b3c1cc336c6b>
date Tue, 17 Jul 2012 13:34:40 +0000
parents
children 775477d89709
comparison
equal deleted inserted replaced
2:2897af43ccc6 3:cf06b77a8bbd
1 /**
2 * class that contains all needed information about an element of the resulting data set including time and place values
3 * @param {String} name the name of the data object
4 * @param {String} description description of the data object
5 * @param {String} place the place, the data object corresponds to
6 * @param {Date} time the time stamp, the data object corresponds to
7 * @param {int} granularity the granularity of the given time
8 * @param {float} lon the longitude value corresponding to the given place
9 * @param {float} lat the latitude value corresponding to the given place
10 *
11 * @constructor
12 */
13 DataObject = function(name, description, place, timeStamp, timeSpan, granularity, lon, lat){
14
15 this.name = name;
16 this.description = description;
17 this.timeStamp = timeStamp;
18 this.timeSpan = timeSpan;
19 this.granularity = granularity;
20 this.longitude = lon;
21 this.latitude = lat;
22
23 this.setPlaces(place);
24 this.status = false;
25 this.percentage = 0;
26 this.hoverSelect = false;
27
28 };
29
30 DataObject.prototype = {
31
32 /**
33 * sets the selection-percentage of the data object
34 * @param {float} percentage sets the percentage value (p); it describes the ratio to the actual selection <br>
35 * p = 0 if this data object is unselected, p = 1 if it is selected and 0 < p < 1 if its in a feather range
36 */
37 setPercentage: function(percentage){
38 if (this.percentage == percentage)
39 this.status = false;
40 else {
41 this.percentage = percentage;
42 this.status = true;
43 }
44 },
45
46 inTime: function( minTime, maxTime ){
47 if( this.timeStamp != undefined ){
48 if( this.timeStamp.getTime() >= minTime.getTime() && this.timeStamp.getTime() <= maxTime.getTime() ){
49 return true;
50 }
51 }
52 else {
53 if( this.timeSpan.start.getTime() >= minTime.getTime() && this.timeSpan.start.getTime() <= maxTime.getTime() ){
54 return true;
55 }
56 if( this.timeSpan.end.getTime() >= minTime.getTime() && this.timeSpan.end.getTime() <= maxTime.getTime() ){
57 return true;
58 }
59 }
60 return false;
61 },
62
63 /**
64 * sets the object to a hover selection status
65 * @param {boolean} hover bool value that tells if an object is hovered or not
66 */
67 setHover: function(hover){
68 this.hoverSelect = hover;
69 if( this.percentage != 1 ){
70 this.status = true;
71 }
72 },
73
74 /**
75 * return the string representation of the objects time
76 * @return the string representation of the objects time
77 */
78 getTimeString: function(){
79 if( this.timeStamp != undefined ){
80 return SimileAjax.DateTime.getTimeString(this.granularity,this.timeStamp)+"";
81 }
82 else {
83 return ( SimileAjax.DateTime.getTimeString(this.granularity,this.timeSpan.start)+" - "+SimileAjax.DateTime.getTimeString(this.granularity,this.timeSpan.end));
84 }
85 },
86
87 isSelected: function(){
88 if( this.percentage > 0 || this.hoverSelect ){
89 return true;
90 }
91 return false;
92 },
93
94 setPlaces: function(place){
95 this.placeDetail = place.split("/");
96 this.place = "";
97 for( var i=0; i<this.placeDetail.length; i++ ){
98 if( i>0 ){
99 this.place += ", ";
100 }
101 this.place += this.placeDetail[i];
102 }
103 },
104
105 getPlace: function(level){
106 if( level >= this.placeDetail.length ){
107 return this.placeDetail[this.placeDetail.length-1];
108 }
109 return this.placeDetail[level];
110 }
111
112 };