Mercurial > hg > STI-GWT
view war/scripts/sti/properties.js @ 41:90b7bbc9962f default
Merged the bugfixes
author | Sebastian Kruse <skruse@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 06 Dec 2012 18:09:00 +0100 |
parents | cf06b77a8bbd |
children |
line wrap: on
line source
/** * color array that stores predefined colors for color coding of the different searches. * the colors are given in array with 3 different values for rgb. * (r0,g0,b0) represents the color for an item, if it is unselected. * (r1,g1,b1) represents the color for an item, if it is selected. * (rt,gt,bt) represents the color for a selected item in the table (not so deep). * initial values are orange, green, blue and yellow */ var colors = [{ id: 1, r1: 245, g1: 70, b1: 0, r0: 250, g0: 212, b0: 169, rt: 255, gt: 101, bt: 41, hex: '#f54600' },{ id: 3, r1: 46, g1: 0, b1: 248, r0: 209, g0: 199, b0: 255, rt: 105, gt: 71, bt: 255, hex: '#2e00f8' }, { id: 2, r1: 0, g1: 214, b1: 0, r0: 194, g0: 255, b0: 194, rt: 70, gt: 221, bt: 70, hex: '#00D600' },{ id: 4, r1: 245, g1: 214, b1: 0, r0: 237, g0: 233, b0: 169, rt: 255, gt: 241, bt: 87, hex: '#FAE500' }]; /** * array that stores predefined colors for the table cells: * stored is rgb for background and border if an object is not selected */ var cellColor = { r: 255, g: 255, b: 255, rb: 187, gb: 187, bb: 187 }; /** * initial boundaries of the map. * stored in an array with minLon, maxLon, minLat and maxLat values. * initial values representing the boundaries of Europe. */ var boundaries = { minLon: -29, minLat: 35, maxLon: 44, maxLat: 67 }; /** * integer value for the maximum number of parellel data sets a user can handle, including individual objects * initial value is 4 (to handle a lower value is possible, a higher would cause complications yet). */ var parallelSearches = 4; /** * a value that determines the number of elements in a point class. * the smaller this value is, the faster the radii of point classes grow */ var classBase = 1.5; /** * a value, which defines the minimum radius of a point class that contains only one element */ var minimumRadius = 4; var maximumRadius, maximumPoints; var circleGap = 0; /** * maximum tag cloud labels */ var tagCloudLabels = 6; /** * returns the calculated cell color of an objects cell * @param {int} i the index of the dataset * @param {double} p the selection percentage value of the data object * @return the calculated cell color */ var getCellColor = function(i,p){ var r = cellColor.r + Math.round(p * (colors[i].rt - cellColor.r)); var g = cellColor.g + Math.round(p * (colors[i].gt - cellColor.g)); var b = cellColor.b + Math.round(p * (colors[i].bt - cellColor.b)); return "rgb("+r+","+g+","+b+")"; } /** * returns the border color of an objects cell * @param {int} i the index of the dataset * @param {boolean} selected if the object is selected or not * @return the border color of the cell */ var getBorderColor = function(i,selected){ if( selected ){ return "rgb("+colors[i].rt+","+colors[i].gt+","+colors[i].bt+")"; } else { return "rgb("+cellColor.rb+","+cellColor.gb+","+cellColor.bb+")"; } } /** * returns the actual mouse position * @param {Event} e the mouseevent * @return the top and left position on the screen */ var getMousePosition = function(e){ if (!e) e = window.event; var body = (window.document.compatMode && window.document.compatMode == "CSS1Compat") ? window.document.documentElement : window.document.body; return { top: e.pageY ? e.pageY : e.clientY, left: e.pageX ? e.pageX : e.clientX }; } /** * returns the id of the color * @param {int} index the index of a dataset * @return the id of the corresponding color */ var getColorId = function(index){ return colors[index].id; } var getRadius = function(size){ if( size == 0 ){ return 0; } var aMax = Math.PI * maximumRadius * maximumRadius; var aMin = Math.PI * minimumRadius * minimumRadius; if( this.maxPoints == 1 ){ return aMin; } return Math.sqrt( ( aMin + (aMax-aMin)/(maximumPoints-1)*(size-1) * Math.sqrt(Math.log(size)) )/Math.PI ); } var getDocHeight = function() { var D = document; return Math.max( Math.max(D.body.scrollHeight, D.documentElement.scrollHeight), Math.max(D.body.offsetHeight, D.documentElement.offsetHeight), Math.max(D.body.clientHeight, D.documentElement.clientHeight) ); }