[Mapbender-commits] r1175 - trunk/mapbender/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Mar 2 13:04:46 EST 2007


Author: christoph
Date: 2007-03-02 13:04:46 -0500 (Fri, 02 Mar 2007)
New Revision: 1175

Modified:
   trunk/mapbender/http/javascripts/geometry.js
Log:
documentation

Modified: trunk/mapbender/http/javascripts/geometry.js
===================================================================
--- trunk/mapbender/http/javascripts/geometry.js	2007-03-02 18:03:55 UTC (rev 1174)
+++ trunk/mapbender/http/javascripts/geometry.js	2007-03-02 18:04:46 UTC (rev 1175)
@@ -10,26 +10,44 @@
 var nameMultiGeometry = "MultiGeometry";
 var nameGeometry = "Geometry";
 
-var geomType = (
-	function () {
-		function ConstructorFunction(){
-			this.polygon = "polygon";
-			this.line = "line";
-			this.point = "point";
-		}
-		return new ConstructorFunction();
-	}
-) ();
 
+/**
+ * @class A class representing geometry types.
+ *
+ * @constructor
+ */
+function GeomType(){
+	this.polygon = "polygon";
+	this.line = "line";
+	this.point = "point";
+}
+var geomType = new GeomType();
 
-// ----------------------------------------------------------------------------------------------------
-// List: a template for geometry data structures
-// ----------------------------------------------------------------------------------------------------
 
+/**
+ * @class A List object is an array of arbitrary objects with additional methods. 
+ *
+ * @constructor
+ */
 var List = function() {
+	
+	/**
+	 * gets the number of elements in this {@link List}
+	 *
+	 * @member List
+	 * @returns number of elements in this {@link List}
+	 * @type Integer
+	 */
 	this.count = function() {
 		return this.list.length;
 	};
+
+	/**
+	 * deletes the object at index i; -1 refers to the last object in this {@link List}
+	 *
+	 * @member List
+	 * @param {Integer} i index
+	 */
 	this.del = function(i){
 		i = this.getIndex(i);
 		for(var z = i; z < this.count() - 1; z++){
@@ -37,29 +55,67 @@
 		}
 		this.list.length -= 1;
 	};
+
+	/**
+	 * @member List
+	 * @param {Integer} i index
+	 * @returns the object at index i; -1 refers to the last object in this {@link List}
+	 * @type Integer or false
+	 */
 	this.get = function(i) {
 		i = this.getIndex(i);
-		if (i !== null) {return this.list[i];}
+		if (i !== false) {return this.list[i];}
 		return false;		
 	};
+	/**
+	 * adds a reference to item to this {@link List}.
+	 *
+	 * @member List
+	 * @param {Object} item an object
+	 */
 	this.add = function(item) {
 		this.list.push(item);
 	};
+	/**
+	 * adds a copy of item to this {@link List}.
+	 *
+	 * @member List
+	 * @param {Object} item an object
+	 */
 	this.addCopy = function(item) {
 		this.list.push(cloneObject(item));
 	};
+	/**
+	 * attaches the {@link List} aList to this {@link List}
+	 *
+	 * @member List
+	 * @param {List} aList another list
+	 */
 	this.union = function(aList) {
 		for (var i=0; i < aList.count(); i++) {this.addCopy(aList.get(i));}
 	};
+	/**
+	 * checks if the index is valid and returns it if it is; if i == -1, the correct index is retrieved.
+	 *
+	 * @member List
+	 * @private
+	 * @return Integer or false
+	 * @type Integer
+	 */
 	this.getIndex = function(i){ 
 		if ((i >= 0 && i < this.list.length) || (i*(-1)>0 && i*(-1) <= this.list.length)){
 			if (i >= 0) {return i;} else {return this.list.length+i;}
 		}
 		else {
-			alert("exception: member index " + i + " is not valid");
-			return null;
+			var e = new Mb_exception("class List: function getIndex: member index " + i + " is not valid");
+			return false;
 		}
 	};
+	/**
+	 * @member List
+	 * @returns a {String} representation of this List
+	 * @type String
+	 */
 	this.toString = function(){
 		var str = "";
 		for (var i =0 ; i < this.count() ; i++){
@@ -71,20 +127,23 @@
 	this.list = null;
 };
 
-// ----------------------------------------------------------------------------------------------------
-// GeometryArray
-// ----------------------------------------------------------------------------------------------------
-
+/**
+ * @class a {@link GeometryArray} is a {@link List} of {@link MultiGeometry} objects
+ *
+ * @ extends List
+ * @ requires MultiGeometry 
+ * @ requires Geometry
+ * @ requires Point
+ * @ constructor
+ */
 function GeometryArray(){
 
-	this.del = function(i){
-		i = this.getIndex(i);
-		for(var z = i; z < this.count() - 1; z++){
-			this.list[z] = this.list[z+1];
-		}
-		this.list.length -= 1;
-	};
-
+	/*
+	 * creates a new, empty Multigeometry and adds it to this GeometryArray
+	 *
+	 * @member GeometryArray
+	 * @param {String} geomType a {@link GeomType}
+	 */
 	this.addMember = function(geomType){
 		this.add(new MultiGeometry(geomType));
 	};
@@ -96,14 +155,40 @@
 
 GeometryArray.prototype = new List();
 	
+/**
+ * gets the j-th {link Geometry} object of the i-th {@link MultiGeometry} object
+ *
+ * @member GeometryArray
+ * @param {Integer} i index of the MultiGeometry
+ * @param {Integer} j index of the Geometry
+ * @type Geometry 
+ */
 GeometryArray.prototype.getGeometry = function(i,j){
 	return this.get(i).get(j);
 };
 
+/**
+ * gets the k-th Point of the j-th {@link Geometry} object of the i-th {@link MultiGeometry} object
+ *
+ * @member GeometryArray
+ * @param {Integer} i index of the MultiGeometry
+ * @param {Integer} j index of the Geometry
+ * @param {Integer} k index of the Point
+ * @type Point
+ * @returns the Point object at the given indices
+ */
 GeometryArray.prototype.getPoint = function(i,j,k){
 	return this.get(i).get(j).get(k);
 };
 
+/**
+ * gets an Array of indices; the {@link MultiGeometry} objects at these indices are equal to geom
+ *
+ * @member GeometryArray
+ * @type Array of Integer
+ * @param {MultiGeometry} geom 
+ * @returns an Array of indices
+ */
 GeometryArray.prototype.findMultiGeometry = function(geom) {
 	var a = [];
 	for (var i=0; i < this.count(); i++) {
@@ -112,15 +197,35 @@
 	return a;
 };
 	
+/**
+ * deletes the j-th {@link Geometry} object of the i-th {@link MultiGeometry} object
+ *
+ * @member GeometryArray
+ * @param {Integer} i index of the MultiGeometry
+ * @param {Integer} j index of the Geometry
+ */
 GeometryArray.prototype.delGeometry = function(i,j){
 	if (this.get(i).del(j) === false) {this.del(i);}
 };
 	
+/**
+ * deletes the k-th {@link Point} of the j-th {@link Geometry} object of the i-th {@link MultiGeometry} object
+ *
+ * @member GeometryArray
+ * @param {Integer} i index of the MultiGeometry
+ * @param {Integer} j index of the Geometry
+ * @param {Integer} k index of the Point
+ */
 GeometryArray.prototype.delPoint = function (i,j,k){
 	var res = this.get(i).delPoint(j,k);
 	if (res === false) {this.del(i);}
 };
 	
+/**
+ * closes the current {@link MultiGeometry}. Calls {@link Geometry#close}.
+ *
+ * @member GeometryArray
+ */
 GeometryArray.prototype.close = function(){
 	if (!this.get(-1).get(-1).close()) {
 		this.delGeometry(-1, -1);
@@ -131,6 +236,12 @@
 	}
 };
 
+/**
+ * deletes all {@link Point} objects of this {@link GeometryArray} that equal point
+ *
+ * @member GeometryArray
+ * @param {Point} point
+ */
 GeometryArray.prototype.delAllPointsLike = function(point){
 	var finished = false;
 	while (finished === false){
@@ -148,27 +259,49 @@
 	}
 };
 	
+/**
+ * updates all {@link Point} objects of this {@link GeometryArray} that equal oldP to newP
+ *
+ * @member GeometryArray
+ * @param {Point} oldP
+ * @param {Point} newP
+ */
 GeometryArray.prototype.updateAllPointsLike = function(oldP, newP){
 	for (var i = 0; i < this.count(); i++){
 		this.get(i).updateAllPointsLike(oldP, newP);
 	}
 };
 	
-
-
-// ----------------------------------------------------------------------------------------------------
-// MultiGeometry
-// ----------------------------------------------------------------------------------------------------
-
+/**
+ * @class a MultiGeometry is a List of Geometry objects
+ *
+ * @ extends List
+ * @ requires Geometry
+ * @ requires Point
+ * @ constructor
+ * @ param {String} geomType a geomType
+ */
 function MultiGeometry(geomType){
 
+	/*
+	 * creates a new, empty {@link Geometry} object and adds it to this {@link MultiGeometry}
+	 *
+	 * @member MultiGeometry
+	 */
 	this.addGeometry = function(){
 		this.add(new Geometry(this.geomType));
 	};
 	
+	/**
+	 * deletes the {@link Geometry} object at index i; -1 refers to the last {@link Geometry object in the list
+	 * overwrites the del function of {@link List}.
+	 *
+	 * @member MultiGeometry
+	 * @param {Integer} i index
+	 */
 	this.del = function(i){
 		i = this.getIndex(i);
-		if (i !== null){
+		if (i !== false){
 			var tmpLength = this.count() - 1;
 			for (var z = i; z < tmpLength ; z ++){
 				this.list[z] = this.list[z+1];
@@ -188,10 +321,26 @@
 
 MultiGeometry.prototype = new List();
 
+/**
+ * updates all {@link Point} objects of this {@link MultiGeometry} that equal oldP to newP
+ *
+ * @member MultiGeometry
+ * @param {Point} oldP
+ * @param {Point} newP
+ */
 MultiGeometry.prototype.updateAllPointsLike = function(oldP, newP){
-	for (var i = 0; i < this.count(); i++) {this.get(i).updateAllPointsLike(oldP, newP);}
+	for (var i = 0; i < this.count(); i++) {
+		this.get(i).updateAllPointsLike(oldP, newP);
+	}
 };
 
+/**
+ * gets the bounding box of this {@link MultiGeometry}
+ *
+ * @member MultiGeometry
+ * @return the bounding box
+ * @type Array of two Point objects
+ */
 MultiGeometry.prototype.getBBox = function(){
 	var q = this.get(0).get(0);
 	var min = cloneObject(q);
@@ -205,7 +354,13 @@
 	}
 	return [min, max];
 };
-
+/**
+ * gets the center of the bounding box of this {@link MultiGeometry}.
+ *
+ * @member MultiGeometry
+ * @return the center of the bounding box
+ * @type Point
+ */
 MultiGeometry.prototype.getCenter = function(){
 	var tmp = this.getBBox();
 	var x = parseFloat(tmp[0].x) + parseFloat((tmp[1].x - tmp[0].x)/2);
@@ -213,16 +368,40 @@
 	return new Point(x,y);
 };
 
+/**
+ * gets the total number of {@link Point} objects of this {@link MultiGeometry}.
+ *
+ * @member MultiGeometry
+ * @return number of points
+ * @type Integer
+ */
 MultiGeometry.prototype.getTotalPointCount = function(){ 
 	var c = 0;
-	for (var i = 0 ; i < this.count(); i++)	{c += this.get(i).count();}
+	for (var i = 0 ; i < this.count(); i++)	{
+		c += this.get(i).count();
+	}
 	return c;
 };
 
+/**
+ * gets the total number of {@link Point} objects of this {@link MultiGeometry}.
+ *
+ * @member MultiGeometry
+ * @return number of points
+ * @type Integer
+ */
 MultiGeometry.prototype.getPoint = function(j,k){
 	return this.get(j).get(k);
 };
 
+/**
+ * compares this {@link MultiGeometry} object with the {@link MultiGeometry} object multigeom.
+ *
+ * @member MultiGeometry
+ * @param {MultiGeometry} multigeom another multigeometry
+ * @return true if he multigeometries match; else false 
+ * @type Boolean
+ */
 MultiGeometry.prototype.equals = function(multigeom) {
 	if (this.geomType != multigeom.geomType) {return false;}
 	if (this.count() != multigeom.count()) {return false;}
@@ -233,22 +412,41 @@
 	return true;
 };
 
-MultiGeometry.prototype.delPoint = function(i,j){ // public
+/**
+ * deletes the j-th {@link Point} object of the i-th {@link Geometry} object of this {@link MultiGeometry} object.
+ *
+ * @member MultiGeometry
+ * @param {Integer} i geometry index
+ * @param {Integer} j point index
+ * @return true if the deletion succeded; else false.
+ * @type Boolean
+ */
+MultiGeometry.prototype.delPoint = function(i,j){
 	var res = this.get(i).del(j);
 	if (res === false) {return this.del(i);}
 	return true;
 };
 
 
-// ----------------------------------------------------------------------------------------------------
-// Geometry
-// ----------------------------------------------------------------------------------------------------
-
+/**
+ * @class a Geometry is a List of Point objects. If it is a polygon, the last point has to equal the first point.
+ *
+ * @ extends List
+ * @ requires Point
+ * @ constructor
+ */
 function Geometry(aGeomtype){
 
+	/**
+	 * deletes the {@link Point} object at index i; -1 refers to the last {@link Point} object in the list
+	 * overwrites the del function of {@link List}.
+	 *
+	 * @member Geometry
+	 * @param {Integer} i index
+	 */
 	this.del = function(i){
 		i = this.getIndex(i);
-		if (i !== null) {
+		if (i !== false) {
 			var tmpLength = this.count()-1;
 			
 			for (var z = i; z < tmpLength ; z ++){
@@ -267,20 +465,40 @@
 		}
 		return false;
 	};
-	
+
+	/**
+	 * adds a {@link Point} object to this {@link Geometry} object.
+	 *
+	 * @member Geometry
+	 * @param {Float} x x value of the point
+	 * @param {Float} y y value of the point
+	 */	
 	this.addPointByCoordinates = function(x,y){
 		this.add(new Point(x,y));
 		updateDist();
 	};
 
+	/**
+	 * adds a {@link Point} object to this {@link Geometry} object.
+	 *
+	 * @member Geometry
+	 * @param {Point} aPoint another point
+	 */	
 	this.addPoint = function(aPoint){
 		this.add(new Point(aPoint.x, aPoint.y));
 		updateDist();
 	};
 
+	/**
+	 * inserts a {@link Point} object at index i of this {@link Geometry} object.
+	 *
+	 * @member Geometry
+	 * @param {Point} p another point
+	 * @param {Integer} i index
+	 */	
 	this.addPointAtIndex = function(p,i){
 		i = this.getIndex(i);
-		if (i !== null){
+		if (i !== false){
 			for(var z = this.count(); z > i; z--){
 				this.list[z] = this.list[z-1];
 			}
@@ -289,7 +507,15 @@
 		}
 	};
 	
-	this.updateGeometry = function(p, i){
+	/**
+	 * Overwrites the {@link Point) object at index i with the {@link Point} object p.
+	 *
+	 * @private
+	 * @member Geometry
+	 * @param {Point} p another point
+	 * @param {Integer} i index
+	 */	
+	this.updatePointAtIndex = function(p, i){
 		i = this.getIndex(i);
 		if ((i === 0 || i == this.count()-1) && this.geomType == geomType.polygon){
 			this.list[0] = p;
@@ -299,6 +525,12 @@
 		updateDist();
 	};
 	
+	/**
+	 * Updates the {@link Geometry#dist} and {@link Geometry#totaldist}
+	 *
+	 * @private
+	 * @member Geometry
+	 */	
 	var updateDist = function(){
 		dist[0] = 0;		
 		totaldist[0] = 0;		
@@ -307,6 +539,14 @@
 			totaldist[i] = totaldist[i-1] + dist[i];
 		}
 	};
+	/**
+	 * gets the distance between the last and last but one point of this {@link Geometry}.
+	 *
+	 * @member Geometry
+	 * @param {Integer} numberOfDigitis round to numberOfDigits (optional)
+	 * @return the distance
+	 * @type Float
+	 */	
 	this.getCurrentDist = function(numberOfDigits) {
 		if (typeof(numberOfDigits) == "number") {
 			return roundToDigits(dist[this.count()-1], numberOfDigits);
@@ -314,12 +554,27 @@
 		return dist[this.count()-1];
 		
 	};
+	/**
+	 * gets the length of the outer rim of this {@link Geometry}.
+	 *
+	 * @member Geometry
+	 * @param {Integer} numberOfDigitis round to numberOfDigits (optional)
+	 * @return the distance
+	 * @type Float
+	 */	
 	this.getTotalDist = function(numberOfDigits) {
 		if (typeof(numberOfDigits) == "number") {
 			return roundToDigits(totaldist[this.count()-1], numberOfDigits);
 		}
 		return totaldist[this.count()-1];
 	};
+	/**
+	 * closes this {@link Geometry}. 
+	 *
+	 * @member Geometry
+	 * @return true if the geometry could be closed; otherwise false
+	 * @type Boolean
+	 */	
 	this.close = function(){
 		complete = true;
 		if (this.geomType == geomType.polygon){
@@ -335,6 +590,13 @@
 		}
 		return true;
 	};
+	/**
+	 * checks if this {@link Geometry} has been closed. 
+	 *
+	 * @member Geometry
+	 * @return true if the geometry is closed; otherwise false
+	 * @type Boolean
+	 */	
 	this.isComplete = function() { 
 		return complete;
 	};
@@ -352,6 +614,13 @@
 
 Geometry.prototype = new List();
 
+/**
+ * gets the bounding box of this {@link Geometry}
+ *
+ * @member Geometry
+ * @return the bounding box
+ * @type Array of two Point objects
+ */
 Geometry.prototype.getBBox = function(){
 	var q = this.get(0);
 	var min = cloneObject(q);
@@ -367,6 +636,13 @@
 	return [min, max];
 };
 
+/**
+ * updates all {@link Point} objects of this {@link Geometry} that equal oldP to newP
+ *
+ * @member Geometry
+ * @param {Point} oldP
+ * @param {Point} newP
+ */
 Geometry.prototype.updateAllPointsLike = function(oldP, newP){
 	var len = this.count();
 	for (var i = 0; i < len ; i++){
@@ -376,11 +652,19 @@
 				len--;
 				i--;
 			}
-			else {this.updateGeometry(newP, i);}
+			else {this.updatePointAtIndex(newP, i);}
 		}
 	}
 };
 
+/**
+ * compares this {@link Geometry} object with the {@link Geometry} object geom point by point.
+ *
+ * @member Geometry
+ * @param {Geometry} geom another geometry
+ * @return true if he geometries match; else false 
+ * @type Boolean
+ */
 Geometry.prototype.equals = function(geom) {
 	if (this.geomType != geom.geomType) {return false;}
 	if (this.count() != geom.count()) {return false;}
@@ -391,38 +675,75 @@
 };
 
 
-
-
-
-// ----------------------------------------------------------------------------------------------------
-// Wfs_element (FIXME)
-// ----------------------------------------------------------------------------------------------------
-
+/**
+ * @class an array of elements, each consisting of a name/value pair
+ *
+ * @ constructor
+ */
 function Wfs_element(){
 
-	this.count = function(){return name.length;};
+	/**
+	 * returns the number of elements of this {@link Wfs_element} object.
+	 *
+	 * @member Wfs_element
+	 * @return the number of elements
+	 * @type Integer
+	 */
+	this.count = function(){
+		return name.length;
+	};
 
+	/**
+	 * returns the name of the element at index i.
+	 *
+	 * @member Wfs_element
+	 * @param {Integer} i index
+	 * @return the name
+	 * @type String
+	 */
 	this.getName = function(i){ 
 		if (isValidElementIndex(i)) {return name[i];}
 		return false;
 	};
 	
+	/**
+	 * returns the value of the element at index i.
+	 *
+	 * @member Wfs_element
+	 * @param {Integer} i index
+	 * @return the value
+	 */
 	this.getValue = function(i){ 
 		if (isValidElementIndex(i)) {return value[i];}
 		return false;
 	};
 
+	/**
+	 * appends a new element with a given name. If an element with this name exists, it is overwritten.
+	 *
+	 * @member Wfs_element
+	 * @param {String} aName the name of the new element
+	 * @param {String} aValue the value of the new element
+	 */
 	this.setElement = function(aName, aValue){ 
 		var i = this.getElementIndexByName(aName);
 		if (i === false) {i = this.count();}
 		name[i] = aName;
 		value[i] = aValue;
-		return true;
 	};
 
+	/**
+	 * checks if an index is valid
+	 *
+	 * @member Wfs_element
+	 * @private
+	 * @param {Integer} i an index
+	 * @return true if the index is valid; otherwise false
+	 * @type Boolean
+	 */
 	var isValidElementIndex = function(i){ 
 		if (i>=0 && i<name.length) {return true;}
-		alert("exception: illegal element index");
+		var e = new Mb_exception("class Wfs_element: function isValidElementIndex: illegal element index");
 		return false;
 	};
 	
@@ -430,6 +751,14 @@
 	var value = [];
 }
 
+/**
+ * gets the index of the element with a given name.
+ *
+ * @member Wfs_element
+ * @param {String} elementName a name
+ * @return the index of the element; if no element with this name exists, false
+ * @type Integer, Boolean
+ */
 Wfs_element.prototype.getElementIndexByName = function(elementName){
 	for (var j = 0 ; j < this.count() ; j++){
 		if (this.getName(j) == elementName) {return j;}
@@ -437,6 +766,14 @@
 	return false;
 };
 
+/**
+ * gets the value of the element with a given name.
+ *
+ * @member Wfs_element
+ * @param {String} elementName a name
+ * @return the value of the element; if no element with this name exists, false
+ * @type String, Boolean
+ */
 Wfs_element.prototype.getElementValueByName = function(elementName){
 	var i = this.getElementIndexByName(elementName);
 	if (i === false) {return false;}
@@ -444,15 +781,31 @@
 };
 
 
-
-// ----------------------------------------------------------------------------------------------------
-// Canvas
-// ----------------------------------------------------------------------------------------------------
-
-
+/**
+ * @class a {@link Canvas} is a {@link DivTag} that contains graphics rendered by {@link jsGraphics}
+ *
+ * @constructor
+ * @requires DivTag
+ * @requires jsGraphics
+ * @requires MultiGeometry
+ * @requires Geometry
+ * @param {String} aMapFrame name of the target mapframe
+ * @param {String} aTagName name of the target div tag
+ * @param {String} aStyle style of the div tag
+ * @param {Integer} aLineWidth the line width of the jsGraphics output
+ */
 function Canvas(aMapframe, aTagName, aStyle, aLineWidth) {
 	
-	this.drawGeometry = function(t,g,col){ 
+	/**
+	 * draws the geometry of the canvas
+	 *
+	 * @member Canvas
+	 * @private
+	 * @param {String} t geometry type
+	 * @param {MultiGeometry} g a MultiGeometry object
+	 * @param {String} col a color
+	 */
+ 	this.drawGeometry = function(t,g,col){ 
 		var mapObjInd = getMapObjIndexByName(mapframe);
 		width = mb_mapObj[mapObjInd].width;
 		height = mb_mapObj[mapObjInd].height;
@@ -473,11 +826,18 @@
 				}
 			}
 			else {
-				alert('unknown geomType ' + t);
+				var e = new Mb_exception("class Canvas: function drawGeometry: unknown geomType " + t);
 			}
 		}
 	};
 	
+	/**
+	 * checks if the MultiGeometry's bounding box width and height is smaller than minWidth
+	 *
+	 * @member Canvas
+	 * @private
+	 * @param {MultiGeometry} g a MultiGeometry object
+	 */
 	this.isTooSmall = function(g){
 		var tmp = g.getBBox();
 		var min = realToMap(mapframe,tmp[0]);
@@ -488,17 +848,46 @@
 		return false;
 	};
 	
+	/**
+	 * draws a circle with {@link jsGraphics}.
+	 *
+	 * @member Canvas
+	 * @private
+	 * @param {Float} x x value of the center
+	 * @param {Float} y y value of the center
+	 * @param {Float} diameter diameter of the circle
+	 * @param {String} color the color of the circle in hex format
+	 */
 	var drawCircle = function(x, y, diameter, color) {
 		canvas.setColor(color);
 		canvas.drawEllipse(x-diameter/2,y-diameter/2,diameter,diameter);
 	};
 
+	/**
+	 * draws a polyline with {@link jsGraphics}.
+	 *
+	 * @member Canvas
+	 * @private
+	 * @param {Array} x_array array of x values
+	 * @param {Array} y_array array of y values
+	 * @param {String} color the color of the polyline in hex format
+	 */
 	var drawLine = function(x_array, y_array, color) {
 		canvas.setColor(color);
 		canvas.drawPolyline(x_array, y_array);
 	};
 
-	this.getCanvas = function(){return canvas;};
+	/**
+	 * gets the jsGraphics.
+	 *
+	 * @member Canvas
+	 * @private
+	 * @return teh jsGraphics
+	 * @type jsGraphics
+	 */
+	this.getCanvas = function(){
+		return canvas;
+	};
 	
 	var diameter = 8;
 	var minWidth = 8;
@@ -513,10 +902,21 @@
 	mb_registerPanSubElement(aTagName);
 }
 
+/**
+ * cleans the canvas by emptying the canvas {@link DivTag}.
+ *
+ * @member Canvas
+ */
 Canvas.prototype.clean = function () {
 	this.canvasDivTag.clean();
 };
 
+/**
+ * paints all geometries.
+ *
+ * @member Canvas
+ * @param {GeometryArray} gA the geometries that will be drawn
+ */
 Canvas.prototype.paint = function(gA) {
 	for (var q = 0; q < gA.count(); q++) {
 		var m = gA.get(q);
@@ -533,18 +933,34 @@
 			else{
 				if(t == geomType.line) {this.drawGeometry(t,m, col);}
 				else if(t == geomType.polygon) {this.drawGeometry(t,m,col);}
-				else {alert("unknown geomType");}
+				else {
+					var e = new Mb_exception("class Canvas: function paint: unknown geomType" + t);				
+				}
 			}
 		}
 	}
 	this.getCanvas().paint();
 };
 
-// ----------------------------------------------------------------------------------------------------
-// Highlight
-// ----------------------------------------------------------------------------------------------------
-
+/**
+ * @class a {@link Highlight} object is {@link jsGraphics} rendering of a {@link GeometryArray} in various mapframes.
+ *
+ * @constructor
+ * @requires Canvas
+ * @requires GeometryArray
+ * @param {Array} aTargetArray an array of Strings referring to mapframes
+ * @param {String} aTagName the name of the div tags
+ * @param {Object} aStyle the style of the div tags
+ * @param {Integer} the line width of the jsGraphics lines
+ */
 function Highlight(aTargetArray, aTagName, aStyle, aLineWidth) {
+	/**
+	 * removes a {@link MultiGeometry} object from the geometry Array
+	 *
+	 * @member Highlight
+	 * @param {MultiGeometry} m a MultiGeometry
+	 * @param {String} color a color
+	 */	
 	this.del = function(m, color) {
 		var a = gA.findMultiGeometry(m);
 		var del = false;
@@ -557,6 +973,13 @@
 		this.paint();
 	};
 
+	/**
+	 * adds a {@link MultiGeometry} object to the geometry Array
+	 *
+	 * @member Highlight
+	 * @param {MultiGeometry} m a MultiGeometry
+	 * @param {String} color the color of the highlight
+	 */	
 	this.add = function(m, color) {
 		gA.addCopy(m);
 		if (typeof(color) != 'undefined') {gA.get(-1).color = color;} 
@@ -564,6 +987,11 @@
 		this.paint();
 	};
 	
+	/**
+	 * removes all MultiGeometries.
+	 *
+	 * @member Highlight
+	 */	
 	this.clean = function() {
 		if (gA.count() > 0) {
 			gA = new GeometryArray();
@@ -571,6 +999,11 @@
 		}
 	};
 
+	/**
+	 * displays the highlight
+	 *
+	 * @member Highlight
+	 */	
 	this.paint = function() {
 		for (var i=0; i < canvas.length; i++) {
 			if (typeof(canvas[i]) == "object") {canvas[i].clean();}



More information about the Mapbender_commits mailing list