1 /*
  2     Copyright 2008-2021
  3         Matthias Ehmann,
  4         Michael Gerhaeuser,
  5         Carsten Miller,
  6         Bianca Valentin,
  7         Alfred Wassermann,
  8         Peter Wilfahrt
  9 
 10     This file is part of JSXGraph.
 11 
 12     JSXGraph is free software dual licensed under the GNU LGPL or MIT License.
 13 
 14     You can redistribute it and/or modify it under the terms of the
 15 
 16       * GNU Lesser General Public License as published by
 17         the Free Software Foundation, either version 3 of the License, or
 18         (at your option) any later version
 19       OR
 20       * MIT License: https://github.com/jsxgraph/jsxgraph/blob/master/LICENSE.MIT
 21 
 22     JSXGraph is distributed in the hope that it will be useful,
 23     but WITHOUT ANY WARRANTY; without even the implied warranty of
 24     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 25     GNU Lesser General Public License for more details.
 26 
 27     You should have received a copy of the GNU Lesser General Public License and
 28     the MIT License along with JSXGraph. If not, see <http://www.gnu.org/licenses/>
 29     and <http://opensource.org/licenses/MIT/>.
 30  */
 31 
 32 
 33 /*global JXG: true, define: true*/
 34 /*jslint nomen: true, plusplus: true*/
 35 
 36 /* depends:
 37  jxg
 38  base/constants
 39  base/coords
 40  math/math
 41  options
 42  parser/geonext
 43  utils/event
 44  utils/color
 45  utils/type
 46  */
 47 
 48 define([
 49     'jxg', 'base/constants', 'base/coords', 'math/math', 'math/statistics', 'options', 'parser/geonext', 'utils/event', 'utils/color', 'utils/type'
 50 ], function (JXG, Const, Coords, Mat, Statistics, Options, GeonextParser, EventEmitter, Color, Type) {
 51 
 52     "use strict";
 53 
 54     /**
 55      * Constructs a new GeometryElement object.
 56      * @class This is the basic class for geometry elements like points, circles and lines.
 57      * @constructor
 58      * @param {JXG.Board} board Reference to the board the element is constructed on.
 59      * @param {Object} attributes Hash of attributes and their values.
 60      * @param {Number} type Element type (a <tt>JXG.OBJECT_TYPE_</tt> value).
 61      * @param {Number} oclass The element's class (a <tt>JXG.OBJECT_CLASS_</tt> value).
 62      * @borrows JXG.EventEmitter#on as this.on
 63      * @borrows JXG.EventEmitter#off as this.off
 64      * @borrows JXG.EventEmitter#triggerEventHandlers as this.triggerEventHandlers
 65      * @borrows JXG.EventEmitter#eventHandlers as this.eventHandlers
 66      */
 67     JXG.GeometryElement = function (board, attributes, type, oclass) {
 68         var name, key, attr;
 69 
 70         /**
 71          * Controls if updates are necessary
 72          * @type Boolean
 73          * @default true
 74          */
 75         this.needsUpdate = true;
 76 
 77         /**
 78          * Controls if this element can be dragged. In GEONExT only
 79          * free points and gliders can be dragged.
 80          * @type Boolean
 81          * @default false
 82          */
 83         this.isDraggable = false;
 84 
 85         /**
 86          * If element is in two dimensional real space this is true, else false.
 87          * @type Boolean
 88          * @default true
 89          */
 90         this.isReal = true;
 91 
 92         /**
 93          * Stores all dependent objects to be updated when this point is moved.
 94          * @type Object
 95          */
 96         this.childElements = {};
 97 
 98         /**
 99          * If element has a label subelement then this property will be set to true.
100          * @type Boolean
101          * @default false
102          */
103         this.hasLabel = false;
104 
105         /**
106          * True, if the element is currently highlighted.
107          * @type Boolean
108          * @default false
109          */
110         this.highlighted = false;
111 
112         /**
113          * Stores all Intersection Objects which in this moment are not real and
114          * so hide this element.
115          * @type Object
116          */
117         this.notExistingParents = {};
118 
119         /**
120          * Keeps track of all objects drawn as part of the trace of the element.
121          * @see JXG.GeometryElement#clearTrace
122          * @see JXG.GeometryElement#numTraces
123          * @type Object
124          */
125         this.traces = {};
126 
127         /**
128          * Counts the number of objects drawn as part of the trace of the element.
129          * @see JXG.GeometryElement#clearTrace
130          * @see JXG.GeometryElement#traces
131          * @type Number
132          */
133         this.numTraces = 0;
134 
135         /**
136          * Stores the  transformations which are applied during update in an array
137          * @type Array
138          * @see JXG.Transformation
139          */
140         this.transformations = [];
141 
142         /**
143          * @type JXG.GeometryElement
144          * @default null
145          * @private
146          */
147         this.baseElement = null;
148 
149         /**
150          * Elements depending on this element are stored here.
151          * @type Object
152          */
153         this.descendants = {};
154 
155         /**
156          * Elements on which this element depends on are stored here.
157          * @type Object
158          */
159         this.ancestors = {};
160 
161         /**
162          * Ids of elements on which this element depends directly are stored here.
163          * @type Object
164          */
165         this.parents = [];
166 
167         /**
168          * Stores variables for symbolic computations
169          * @type Object
170          */
171         this.symbolic = {};
172 
173         /**
174          * Stores the SVG (or VML) rendering node for the element. This enables low-level
175          * access to SVG nodes. The properties of such an SVG node can then be changed
176          * by calling setAttribute(). Note that there are a few elements which consist
177          * of more than one SVG nodes:
178          * <ul>
179          * <li> Elements with arrow tail or head: rendNodeTriangleStart, rendNodeTriangleEnd
180          * <li> SVG (or VML) texts: rendNodeText
181          * <li> Button: rendNodeForm, rendNodeButton, rendNodeTag
182          * <li> Checkbox: rendNodeForm, rendNodeCheckbox, rendNodeLabel, rendNodeTag
183          * <li> Input: rendNodeForm, rendNodeInput, rendNodeLabel, rendNodeTag
184          * </ul>
185          *
186          * Here is are two examples: The first example shows how to access the SVG node,
187          * the second example demonstrates how to change SVG attributes.
188          * @example
189          *     var p1 = board.create('point', [0, 0]);
190          *     console.log(p1.rendNode);
191          *     // returns the full SVG node details of the point p1, something like:
192          *     // <ellipse id='box_jxgBoard1P6' stroke='#ff0000' stroke-opacity='1' stroke-width='2px'
193          *     //   fill='#ff0000' fill-opacity='1' cx='250' cy='250' rx='4' ry='4'
194          *     //   style='position: absolute;'>
195          *     // </ellipse>
196          *
197          * @example
198          *     var s = board.create('segment', [p1, p2], {strokeWidth: 60});
199          *     s.rendNode.setAttribute('stroke-linecap', 'round');
200          *
201          * @type Object
202          */
203         this.rendNode = null;
204 
205         /**
206          * The string used with {@link JXG.Board#create}
207          * @type String
208          */
209         this.elType = '';
210 
211         /**
212          * The element is saved with an explicit entry in the file (<tt>true</tt>) or implicitly
213          * via a composition.
214          * @type Boolean
215          * @default true
216          */
217         this.dump = true;
218 
219         /**
220          * Subs contains the subelements, created during the create method.
221          * @type Object
222          */
223         this.subs = {};
224 
225         /**
226          * Inherits contains the subelements, which may have an attribute
227          * (in partuclar the attribute "visible") having value 'inherit'.
228          * @type Object
229          */
230         this.inherits = [];
231 
232         /**
233          * The position of this element inside the {@link JXG.Board#objectsList}.
234          * @type {Number}
235          * @default -1
236          * @private
237          */
238         this._pos = -1;
239 
240         /**
241          * [c, b0, b1, a, k, r, q0, q1]
242          *
243          * See
244          * A.E. Middleditch, T.W. Stacey, and S.B. Tor:
245          * "Intersection Algorithms for Lines and Circles",
246          * ACM Transactions on Graphics, Vol. 8, 1, 1989, pp 25-40.
247          *
248          * The meaning of the parameters is:
249          * Circle: points p=[p0, p1] on the circle fulfill
250          *  a<p, p> + <b, p> + c = 0
251          * For convenience we also store
252          *  r: radius
253          *  k: discriminant = sqrt(<b,b>-4ac)
254          *  q=[q0, q1] center
255          *
256          * Points have radius = 0.
257          * Lines have radius = infinity.
258          * b: normalized vector, representing the direction of the line.
259          *
260          * Should be put into Coords, when all elements possess Coords.
261          * @type Array
262          * @default [1, 0, 0, 0, 1, 1, 0, 0]
263          */
264         this.stdform = [1, 0, 0, 0, 1, 1, 0, 0];
265 
266         /**
267          * The methodMap determines which methods can be called from within JessieCode and under which name it
268          * can be used. The map is saved in an object, the name of a property is the name of the method used in JessieCode,
269          * the value of a property is the name of the method in JavaScript.
270          * @type Object
271          */
272         this.methodMap = {
273             setLabel: 'setLabel',
274             label: 'label',
275             setName: 'setName',
276             getName: 'getName',
277             addTransform: 'addTransform',
278             setProperty: 'setAttribute',
279             setAttribute: 'setAttribute',
280             addChild: 'addChild',
281             animate: 'animate',
282             on: 'on',
283             off: 'off',
284             trigger: 'trigger',
285             addTicks: 'addTicks',
286             removeTicks: 'removeTicks',
287             removeAllTicks: 'removeAllTicks'
288         };
289 
290         /**
291          * Quadratic form representation of circles (and conics)
292          * @type Array
293          * @default [[1,0,0],[0,1,0],[0,0,1]]
294          */
295         this.quadraticform = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
296 
297         /**
298          * An associative array containing all visual properties.
299          * @type Object
300          * @default empty object
301          */
302         this.visProp = {};
303 
304         /**
305          * An associative array containing visual properties which are calculated from
306          * the attribute values (i.e. visProp) and from other constraints.
307          * An example: if an intersection point does not have real coordinates,
308          * visPropCalc.visible is set to false.
309          * Additionally, the user can control visibility with the attribute "visible",
310          * even by supplying a functions as value.
311          *
312          * @type Object
313          * @default empty object
314          */
315         this.visPropCalc = {
316             visible: false
317         };
318 
319         EventEmitter.eventify(this);
320 
321         /**
322          * Is the mouse over this element?
323          * @type Boolean
324          * @default false
325          */
326         this.mouseover = false;
327 
328         /**
329          * Time stamp containing the last time this element has been dragged.
330          * @type Date
331          * @default creation time
332          */
333         this.lastDragTime = new Date();
334 
335         if (arguments.length > 0) {
336             /**
337              * Reference to the board associated with the element.
338              * @type JXG.Board
339              */
340             this.board = board;
341 
342             /**
343              * Type of the element.
344              * @constant
345              * @type Number
346              */
347             this.type = type;
348 
349             /**
350              * Original type of the element at construction time. Used for removing glider property.
351              * @constant
352              * @type Number
353              */
354             this._org_type = type;
355 
356             /**
357              * The element's class.
358              * @constant
359              * @type Number
360              */
361             this.elementClass = oclass || Const.OBJECT_CLASS_OTHER;
362 
363             /**
364              * Unique identifier for the element. Equivalent to id-attribute of renderer element.
365              * @type String
366              */
367             this.id = attributes.id;
368 
369             name = attributes.name;
370             /* If name is not set or null or even undefined, generate an unique name for this object */
371             if (!Type.exists(name)) {
372                 name = this.board.generateName(this);
373             }
374 
375             if (name !== '') {
376                 this.board.elementsByName[name] = this;
377             }
378 
379             /**
380              * Not necessarily unique name for the element.
381              * @type String
382              * @default Name generated by {@link JXG.Board#generateName}.
383              * @see JXG.Board#generateName
384              */
385             this.name = name;
386 
387             this.needsRegularUpdate = attributes.needsregularupdate;
388 
389             // create this.visPropOld and set default values
390             Type.clearVisPropOld(this);
391 
392             attr = this.resolveShortcuts(attributes);
393             for (key in attr) {
394                 if (attr.hasOwnProperty(key)) {
395                     this._set(key, attr[key]);
396                 }
397             }
398 
399             this.visProp.draft = attr.draft && attr.draft.draft;
400             //this.visProp.gradientangle = '270';
401             // this.visProp.gradientsecondopacity = Type.evaluate(this.visProp.fillopacity);
402             //this.visProp.gradientpositionx = 0.5;
403             //this.visProp.gradientpositiony = 0.5;
404         }
405     };
406 
407     JXG.extend(JXG.GeometryElement.prototype, /** @lends JXG.GeometryElement.prototype */ {
408         /**
409          * Add an element as a child to the current element. Can be used to model dependencies between geometry elements.
410          * @param {JXG.GeometryElement} obj The dependent object.
411          */
412         addChild: function (obj) {
413             var el, el2;
414 
415             this.childElements[obj.id] = obj;
416             this.addDescendants(obj);
417             obj.ancestors[this.id] = this;
418 
419             for (el in this.descendants) {
420                 if (this.descendants.hasOwnProperty(el)) {
421                     this.descendants[el].ancestors[this.id] = this;
422 
423                     for (el2 in this.ancestors) {
424                         if (this.ancestors.hasOwnProperty(el2)) {
425                             this.descendants[el].ancestors[this.ancestors[el2].id] = this.ancestors[el2];
426                         }
427                     }
428                 }
429             }
430 
431             for (el in this.ancestors) {
432                 if (this.ancestors.hasOwnProperty(el)) {
433                     for (el2 in this.descendants) {
434                         if (this.descendants.hasOwnProperty(el2)) {
435                             this.ancestors[el].descendants[this.descendants[el2].id] = this.descendants[el2];
436                         }
437                     }
438                 }
439             }
440             return this;
441         },
442 
443         /**
444          * Adds the given object to the descendants list of this object and all its child objects.
445          * @param {JXG.GeometryElement} obj The element that is to be added to the descendants list.
446          * @private
447          * @return
448          */
449         addDescendants: function (obj) {
450             var el;
451 
452             this.descendants[obj.id] = obj;
453             for (el in obj.childElements) {
454                 if (obj.childElements.hasOwnProperty(el)) {
455                     this.addDescendants(obj.childElements[el]);
456                 }
457             }
458             return this;
459         },
460 
461         /**
462          * Adds ids of elements to the array this.parents. This method needs to be called if some dependencies
463          * can not be detected automatically by JSXGraph. For example if a function graph is given by a function
464          * which referes to coordinates of a point, calling addParents() is necessary.
465          *
466          * @param {Array} parents Array of elements or ids of elements.
467          * Alternatively, one can give a list of objects as parameters.
468          * @returns {JXG.Object} reference to the object itself.
469          *
470          * @example
471          * // Movable function graph
472          * var A = board.create('point', [1, 0], {name:'A'}),
473          *     B = board.create('point', [3, 1], {name:'B'}),
474          *     f = board.create('functiongraph', function(x) {
475          *          var ax = A.X(),
476          *              ay = A.Y(),
477          *              bx = B.X(),
478          *              by = B.Y(),
479          *              a = (by - ay) / ( (bx - ax) * (bx - ax) );
480          *           return a * (x - ax) * (x - ax) + ay;
481          *      }, {fixed: false});
482          * f.addParents([A, B]);
483          * </pre><div class="jxgbox" id="JXG7c91d4d2-986c-4378-8135-24505027f251" style="width: 400px; height: 400px;"></div>
484          * <script type="text/javascript">
485          * (function() {
486          *   var board = JXG.JSXGraph.initBoard('JXG7c91d4d2-986c-4378-8135-24505027f251', {boundingbox: [-1, 9, 9, -1], axis: true, showcopyright: false, shownavigation: false});
487          *   var A = board.create('point', [1, 0], {name:'A'}),
488          *       B = board.create('point', [3, 1], {name:'B'}),
489          *       f = board.create('functiongraph', function(x) {
490          *            var ax = A.X(),
491          *                ay = A.Y(),
492          *                bx = B.X(),
493          *                by = B.Y(),
494          *                a = (by - ay) / ( (bx - ax) * (bx - ax) );
495          *             return a * (x - ax) * (x - ax) + ay;
496          *        }, {fixed: false});
497          *   f.addParents([A, B]);
498          * })();
499          * </script><pre>
500          *
501          **/
502         addParents: function (parents) {
503             var i, len, par;
504 
505             if (Type.isArray(parents)) {
506                 par = parents;
507             } else {
508                 par = arguments;
509             }
510 
511             len = par.length;
512             for (i = 0; i < len; ++i) {
513                 if (!Type.exists(par[i])) {
514                     continue;
515                 }
516                 if (Type.isId(this.board, par[i])) {
517                     this.parents.push(par[i]);
518                 } else if (Type.exists(par[i].id)) {
519                     this.parents.push(par[i].id);
520                 }
521             }
522             this.parents = Type.uniqueArray(this.parents);
523         },
524 
525         /**
526          * Sets ids of elements to the array this.parents.
527          * First, this.parents is cleared. See {@link JXG.GeometryElement#addParents}.
528          * @param {Array} parents Array of elements or ids of elements.
529          * Alternatively, one can give a list of objects as parameters.
530          * @returns {JXG.Object} reference to the object itself.
531          **/
532         setParents: function(parents) {
533             this.parents = [];
534             this.addParents(parents);
535         },
536 
537         /**
538          * Remove an element as a child from the current element.
539          * @param {JXG.GeometryElement} obj The dependent object.
540          */
541         removeChild: function (obj) {
542             //var el, el2;
543 
544             delete this.childElements[obj.id];
545             this.removeDescendants(obj);
546             delete obj.ancestors[this.id];
547 
548             /*
549              // I do not know if these addDescendants stuff has to be adapted to removeChild. A.W.
550             for (el in this.descendants) {
551                 if (this.descendants.hasOwnProperty(el)) {
552                     delete this.descendants[el].ancestors[this.id];
553 
554                     for (el2 in this.ancestors) {
555                         if (this.ancestors.hasOwnProperty(el2)) {
556                             this.descendants[el].ancestors[this.ancestors[el2].id] = this.ancestors[el2];
557                         }
558                     }
559                 }
560             }
561 
562             for (el in this.ancestors) {
563                 if (this.ancestors.hasOwnProperty(el)) {
564                     for (el2 in this.descendants) {
565                         if (this.descendants.hasOwnProperty(el2)) {
566                             this.ancestors[el].descendants[this.descendants[el2].id] = this.descendants[el2];
567                         }
568                     }
569                 }
570             }
571             */
572             return this;
573         },
574 
575         /**
576          * Removes the given object from the descendants list of this object and all its child objects.
577          * @param {JXG.GeometryElement} obj The element that is to be removed from the descendants list.
578          * @private
579          * @return
580          */
581         removeDescendants: function (obj) {
582             var el;
583 
584             delete this.descendants[obj.id];
585             for (el in obj.childElements) {
586                 if (obj.childElements.hasOwnProperty(el)) {
587                     this.removeDescendants(obj.childElements[el]);
588                 }
589             }
590             return this;
591         },
592 
593         /**
594          * Counts the direct children of an object without counting labels.
595          * @private
596          * @returns {number} Number of children
597          */
598         countChildren: function () {
599             var prop, d,
600                 s = 0;
601 
602             d = this.childElements;
603             for (prop in d) {
604                 if (d.hasOwnProperty(prop) && prop.indexOf('Label') < 0) {
605                     s++;
606                 }
607             }
608             return s;
609         },
610 
611         /**
612          * Returns the elements name. Used in JessieCode.
613          * @returns {String}
614          */
615         getName: function () {
616             return this.name;
617         },
618 
619         /**
620          * Add transformations to this element.
621          * @param {JXG.Transformation|Array} transform Either one {@link JXG.Transformation}
622          * or an array of {@link JXG.Transformation}s.
623          * @returns {JXG.GeometryElement} Reference to the element.
624          */
625         addTransform: function (transform) {
626             return this;
627         },
628 
629         /**
630          * Decides whether an element can be dragged. This is used in
631          * {@link JXG.GeometryElement#setPositionDirectly} methods
632          * where all parent elements are checked if they may be dragged, too.
633          * @private
634          * @returns {boolean}
635          */
636         draggable: function () {
637             return this.isDraggable && !Type.evaluate(this.visProp.fixed) &&
638                 /*!this.visProp.frozen &&*/ this.type !== Const.OBJECT_TYPE_GLIDER;
639         },
640 
641         /**
642          * Translates the object by <tt>(x, y)</tt>. In case the element is defined by points, the defining points are
643          * translated, e.g. a circle constructed by a center point and a point on the circle line.
644          * @param {Number} method The type of coordinates used here.
645          * Possible values are {@link JXG.COORDS_BY_USER} and {@link JXG.COORDS_BY_SCREEN}.
646          * @param {Array} coords array of translation vector.
647          * @returns {JXG.GeometryElement} Reference to the element object.
648          */
649         setPosition: function (method, coords) {
650             var parents = [],
651                 el, i, len, t;
652 
653             if (!Type.exists(this.parents)) {
654                 return this;
655             }
656 
657             len = this.parents.length;
658             for (i = 0; i < len; ++i) {
659                 el = this.board.select(this.parents[i]);
660                 if (Type.isPoint(el)) {
661                     if (!el.draggable()) {
662                         return this;
663                     }
664                     parents.push(el);
665                 }
666             }
667 
668             if (coords.length === 3) {
669                 coords = coords.slice(1);
670             }
671 
672             t = this.board.create('transform', coords, {type: 'translate'});
673 
674             // We distinguish two cases:
675             // 1) elements which depend on free elements, i.e. arcs and sectors
676             // 2) other elements
677             //
678             // In the first case we simply transform the parents elements
679             // In the second case we add a transform to the element.
680             //
681             len = parents.length;
682             if (len > 0) {
683                 t.applyOnce(parents);
684             } else {
685                 if (this.transformations.length > 0 &&
686                         this.transformations[this.transformations.length - 1].isNumericMatrix) {
687                     this.transformations[this.transformations.length - 1].melt(t);
688                 } else {
689                     this.addTransform(t);
690                 }
691             }
692 
693             /*
694              * If - against the default configuration - defining gliders are marked as
695              * draggable, then their position has to be updated now.
696              */
697             for (i = 0; i < len; ++i) {
698                 if (parents[i].type === Const.OBJECT_TYPE_GLIDER) {
699                     parents[i].updateGlider();
700                 }
701             }
702 
703             return this;
704         },
705 
706         /**
707          * Moves an element by the difference of two coordinates.
708          * @param {Number} method The type of coordinates used here.
709          * Possible values are {@link JXG.COORDS_BY_USER} and {@link JXG.COORDS_BY_SCREEN}.
710          * @param {Array} coords coordinates in screen/user units
711          * @param {Array} oldcoords previous coordinates in screen/user units
712          * @returns {JXG.GeometryElement} this element
713          */
714         setPositionDirectly: function (method, coords, oldcoords) {
715             var c = new Coords(method, coords, this.board, false),
716                 oldc = new Coords(method, oldcoords, this.board, false),
717                 dc = Statistics.subtract(c.usrCoords, oldc.usrCoords);
718 
719             this.setPosition(Const.COORDS_BY_USER, dc);
720 
721             return this;
722         },
723 
724         /**
725          * Array of strings containing the polynomials defining the element.
726          * Used for determining geometric loci the groebner way.
727          * @returns {Array} An array containing polynomials describing the locus of the current object.
728          * @public
729          */
730         generatePolynomial: function () {
731             return [];
732         },
733 
734         /**
735          * Animates properties for that object like stroke or fill color, opacity and maybe
736          * even more later.
737          * @param {Object} hash Object containing properties with target values for the animation.
738          * @param {number} time Number of milliseconds to complete the animation.
739          * @param {Object} [options] Optional settings for the animation:<ul><li>callback: A function that is called as soon as the animation is finished.</li></ul>
740          * @returns {JXG.GeometryElement} A reference to the object
741          */
742         animate: function (hash, time, options) {
743             options = options || {};
744             var r, p, i,
745                 delay = this.board.attr.animationdelay,
746                 steps = Math.ceil(time / delay),
747                 self = this,
748 
749                 animateColor = function (startRGB, endRGB, property) {
750                     var hsv1, hsv2, sh, ss, sv;
751                     hsv1 = Color.rgb2hsv(startRGB);
752                     hsv2 = Color.rgb2hsv(endRGB);
753 
754                     sh = (hsv2[0] - hsv1[0]) / steps;
755                     ss = (hsv2[1] - hsv1[1]) / steps;
756                     sv = (hsv2[2] - hsv1[2]) / steps;
757                     self.animationData[property] = [];
758 
759                     for (i = 0; i < steps; i++) {
760                         self.animationData[property][steps - i - 1] = Color.hsv2rgb(hsv1[0] + (i + 1) * sh, hsv1[1] + (i + 1) * ss, hsv1[2] + (i + 1) * sv);
761                     }
762                 },
763 
764                 animateFloat = function (start, end, property, round) {
765                     var tmp, s;
766 
767                     start = parseFloat(start);
768                     end = parseFloat(end);
769 
770                     // we can't animate without having valid numbers.
771                     // And parseFloat returns NaN if the given string doesn't contain
772                     // a valid float number.
773                     if (isNaN(start) || isNaN(end)) {
774                         return;
775                     }
776 
777                     s = (end - start) / steps;
778                     self.animationData[property] = [];
779 
780                     for (i = 0; i < steps; i++) {
781                         tmp = start + (i + 1) * s;
782                         self.animationData[property][steps - i - 1] = round ? Math.floor(tmp) : tmp;
783                     }
784                 };
785 
786             this.animationData = {};
787 
788             for (r in hash) {
789                 if (hash.hasOwnProperty(r)) {
790                     p = r.toLowerCase();
791 
792                     switch (p) {
793                     case 'strokecolor':
794                     case 'fillcolor':
795                         animateColor(this.visProp[p], hash[r], p);
796                         break;
797                     case 'size':
798                         if (!Type.isPoint(this)) {
799                             break;
800                         }
801                         animateFloat(this.visProp[p], hash[r], p, true);
802                         break;
803                     case 'strokeopacity':
804                     case 'strokewidth':
805                     case 'fillopacity':
806                         animateFloat(this.visProp[p], hash[r], p, false);
807                         break;
808                     }
809                 }
810             }
811 
812             this.animationCallback = options.callback;
813             this.board.addAnimation(this);
814             return this;
815         },
816 
817         /**
818          * General update method. Should be overwritten by the element itself.
819          * Can be used sometimes to commit changes to the object.
820          * @return {JXG.GeometryElement} Reference to the element
821          */
822         update: function () {
823             if (Type.evaluate(this.visProp.trace)) {
824                 this.cloneToBackground();
825             }
826             return this;
827         },
828 
829         /**
830          * Provide updateRenderer method.
831          * @return {JXG.GeometryElement} Reference to the element
832          * @private
833          */
834         updateRenderer: function () {
835             return this;
836         },
837 
838         /**
839          * Run through the full update chain of an element.
840          * @param  {Boolean} visible Set visibility in case the elements attribute value is 'inherit'. null is allowed.
841          * @return {JXG.GeometryElement} Reference to the element
842          * @private
843          */
844         fullUpdate: function(visible) {
845             return this.prepareUpdate()
846                 .update()
847                 .updateVisibility(visible)
848                 .updateRenderer();
849         },
850 
851         /**
852          * Show the element or hide it. If hidden, it will still exist but not be
853          * visible on the board.
854          * @param  {Boolean} val true: show the element, false: hide the element
855          * @return {JXG.GeometryElement} Reference to the element
856          * @private
857          */
858         setDisplayRendNode: function(val) {
859             var i, len, s, len_s, obj;
860 
861             if (val === undefined) {
862                 val = this.visPropCalc.visible;
863             }
864 
865             if (val === this.visPropOld.visible) {
866                 return this;
867             }
868 
869             // Set display of the element itself
870             this.board.renderer.display(this, val);
871 
872             // Set the visibility of elements which inherit the attribute 'visible'
873             len = this.inherits.length;
874             for (s = 0; s < len; s++) {
875                 obj = this.inherits[s];
876                 if (Type.isArray(obj)) {
877                     len_s = obj.length;
878                     for (i = 0; i < len_s; i++) {
879                         if (Type.exists(obj[i]) && Type.exists(obj[i].rendNode) &&
880                             Type.evaluate(obj[i].visProp.visible) === 'inherit') {
881                             obj[i].setDisplayRendNode(val);
882                         }
883                     }
884                 } else {
885                     if (Type.exists(obj) && Type.exists(obj.rendNode) &&
886                         Type.evaluate(obj.visProp.visible) === 'inherit') {
887                             obj.setDisplayRendNode(val);
888                     }
889                 }
890             }
891 
892             // Set the visibility of the label if it inherits the attribute 'visible'
893             if (this.hasLabel && Type.exists(this.label) && Type.exists(this.label.rendNode)) {
894                 if (Type.evaluate(this.label.visProp.visible) === 'inherit') {
895                     this.label.setDisplayRendNode(val);
896                 }
897             }
898 
899             return this;
900         },
901 
902         /**
903          * Hide the element. It will still exist but not be visible on the board.
904          * Alias for "element.setAttribute({visible: false});"
905          * @return {JXG.GeometryElement} Reference to the element
906          */
907         hide: function () {
908             this.setAttribute({visible: false});
909             return this;
910         },
911 
912         /**
913          * Hide the element. It will still exist but not be visible on the board.
914          * Alias for {@link JXG.GeometryElement#hide}
915          * @returns {JXG.GeometryElement} Reference to the element
916          */
917         hideElement: function() {
918             this.hide();
919             return this;
920         },
921 
922         /**
923          * Make the element visible.
924          * Alias for "element.setAttribute({visible: true});"
925          * @return {JXG.GeometryElement} Reference to the element
926          */
927         show: function () {
928             this.setAttribute({visible: true});
929             return this;
930         },
931 
932         /**
933          * Make the element visible.
934          * Alias for {@link JXG.GeometryElement#show}
935          * @returns {JXG.GeometryElement} Reference to the element
936          */
937         showElement: function() {
938             this.show();
939             return this;
940         },
941 
942         /**
943          * Set the visibility of an element. The visibility is influenced by
944          * (listed in ascending priority):
945          * <ol>
946          * <li> The value of the element's attribute 'visible'
947          * <li> The visibility of a parent element. (Example: label)
948          * This overrules the value of the element's attribute value only if
949          * this attribute value of the element is 'inherit'.
950          * <li> being inside of the canvas
951          * </ol>
952          * <p>
953          * This method is called three times for most elements:
954          * <ol>
955          * <li> between {@link JXG.GeometryElement#update}
956          * and {@link JXG.GeometryElement#updateRenderer}. In case the value is 'inherit', nothing is done.
957          * <li> Recursively, called by itself for child elements. Here, 'inherit' is overruled by the parent's value.
958          * <li> In {@link JXG.GeometryElement#updateRenderer}, if the element is outside of the canvas.
959          * </ol>
960          *
961          * @param  {Boolean} parent_val Visibility of the parent element.
962          * @return {JXG.GeometryElement} Reference to the element.
963          * @private
964          */
965         updateVisibility: function(parent_val) {
966             var i, len, s, len_s, obj, val;
967 
968             if (this.needsUpdate) {
969                 // Handle the element
970                 if (parent_val !== undefined) {
971                     this.visPropCalc.visible = parent_val;
972                 } else {
973                     val = Type.evaluate(this.visProp.visible);
974 
975                     // infobox uses hiddenByParent
976                     if (Type.exists(this.hiddenByParent) && this.hiddenByParent) {
977                         val = false;
978                     }
979                     if (val !== 'inherit') {
980                         this.visPropCalc.visible = val;
981                     }
982                 }
983 
984                 // Handle elements which inherit the visibility
985                 len = this.inherits.length;
986                 for (s = 0; s < len; s++) {
987                     obj = this.inherits[s];
988                     if (Type.isArray(obj)) {
989                         len_s = obj.length;
990                         for (i = 0; i < len_s; i++) {
991                             if (Type.exists(obj[i]) /*&& Type.exists(obj[i].rendNode)*/ &&
992                                 Type.evaluate(obj[i].visProp.visible) === 'inherit') {
993                                 obj[i].prepareUpdate().updateVisibility(this.visPropCalc.visible);
994                             }
995                         }
996                     } else {
997                         if (Type.exists(obj) /*&& Type.exists(obj.rendNode)*/ &&
998                             Type.evaluate(obj.visProp.visible) === 'inherit') {
999                             obj.prepareUpdate().updateVisibility(this.visPropCalc.visible);
1000                         }
1001                     }
1002                 }
1003 
1004                 // Handle the label if it inherits the visibility
1005                 if (Type.exists(this.label) && Type.exists(this.label.visProp) &&
1006                     Type.evaluate(this.label.visProp.visible)) {
1007                     this.label.prepareUpdate().updateVisibility(this.visPropCalc.visible);
1008                 }
1009             }
1010             return this;
1011         },
1012 
1013         /**
1014          * Sets the value of property <tt>property</tt> to <tt>value</tt>.
1015          * @param {String} property The property's name.
1016          * @param value The new value
1017          * @private
1018          */
1019         _set: function (property, value) {
1020             var el;
1021 
1022             property = property.toLocaleLowerCase();
1023 
1024             // Search for entries in visProp with "color" as part of the property name
1025             // and containing a RGBA string
1026             if (this.visProp.hasOwnProperty(property) &&
1027                   property.indexOf('color') >= 0 &&
1028                   Type.isString(value) &&
1029                   value.length === 9 &&
1030                   value.charAt(0) === '#') {
1031 
1032                 value = Color.rgba2rgbo(value);
1033                 this.visProp[property] = value[0];
1034                 // Previously: *=. But then, we can only decrease opacity.
1035                 this.visProp[property.replace('color', 'opacity')] = value[1];
1036             } else {
1037                 if (value !== null &&Type.isObject(value) &&
1038                     !Type.exists(value.id) &&
1039                     !Type.exists(value.name)) {
1040                     // value is of type {prop: val, prop: val,...}
1041                     // Convert these attributes to lowercase, too
1042                     this.visProp[property] = {};
1043                     for (el in value) {
1044                         if (value.hasOwnProperty(el)) {
1045                             this.visProp[property][el.toLocaleLowerCase()] = value[el];
1046                         }
1047                     }
1048                 } else {
1049                     this.visProp[property] = value;
1050                 }
1051             }
1052         },
1053 
1054         /**
1055          * Resolves property shortcuts like <tt>color</tt> and expands them, e.g. <tt>strokeColor</tt> and <tt>fillColor</tt>.
1056          * Writes the expanded properties back to the given <tt>properties</tt>.
1057          * @param {Object} properties
1058          * @returns {Object} The given parameter with shortcuts expanded.
1059          */
1060         resolveShortcuts: function (properties) {
1061             var key, i;
1062 
1063             for (key in Options.shortcuts) {
1064                 if (Options.shortcuts.hasOwnProperty(key)) {
1065                     if (Type.exists(properties[key])) {
1066                         for (i = 0; i < Options.shortcuts[key].length; i++) {
1067                             if (!Type.exists(properties[Options.shortcuts[key][i]])) {
1068                                 properties[Options.shortcuts[key][i]] = properties[key];
1069                             }
1070                         }
1071                     }
1072                 }
1073             }
1074             return properties;
1075         },
1076 
1077         /**
1078          * Sets a label and its text
1079          * If label doesn't exist, it creates one
1080          * @param {String} str
1081          */
1082         setLabel: function (str) {
1083             if (!this.hasLabel) {
1084                 this.setAttribute({'withlabel': true});
1085             }
1086             this.setLabelText(str);
1087         },
1088 
1089         /**
1090          * Updates the element's label text, strips all html.
1091          * @param {String} str
1092          */
1093         setLabelText: function (str) {
1094 
1095             if (Type.exists(this.label)) {
1096                 str = str.replace(/</g, '<').replace(/>/g, '>');
1097                 this.label.setText(str);
1098             }
1099 
1100             return this;
1101         },
1102 
1103         /**
1104          * Updates the element's label text and the element's attribute "name", strips all html.
1105          * @param {String} str
1106          */
1107         setName: function (str) {
1108             str = str.replace(/</g, '<').replace(/>/g, '>');
1109             if (this.elType !== 'slider') {
1110                 this.setLabelText(str);
1111             }
1112             this.setAttribute({name: str});
1113         },
1114 
1115         /**
1116          * Deprecated alias for {@link JXG.GeometryElement#setAttribute}.
1117          * @deprecated Use {@link JXG.GeometryElement#setAttribute}.
1118          */
1119         setProperty: function () {
1120             JXG.deprecated('setProperty()', 'setAttribute()');
1121             this.setAttribute.apply(this, arguments);
1122         },
1123 
1124         /**
1125          * Sets an arbitrary number of attributes. This method has one or more
1126          * parameters of the following types:
1127          * <ul>
1128          * <li> object: {key1:value1,key2:value2,...}
1129          * <li> string: "key1:value"
1130          * <li> array: [key, value]
1131          * </ul>
1132          * @param {Object} attributes An object with attributes.
1133          * @returns {JXG.GeometryElement} A reference to the element.
1134          *
1135          * @function
1136          * @example
1137          * // Set property directly on creation of an element using the attributes object parameter
1138          * var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-1, 5, 5, 1]};
1139          * var p = board.create('point', [2, 2], {visible: false});
1140          *
1141          * // Now make this point visible and fixed:
1142          * p.setAttribute({
1143          *     fixed: true,
1144          *     visible: true
1145          * });
1146          */
1147         setAttribute: function (attributes) {
1148             var i, j, le, key, value, arg, opacity, pair, oldvalue,
1149                 properties = {};
1150 
1151             // Normalize the user input
1152             for (i = 0; i < arguments.length; i++) {
1153                 arg = arguments[i];
1154                 if (Type.isString(arg)) {
1155                     // pairRaw is string of the form 'key:value'
1156                     pair = arg.split(':');
1157                     properties[Type.trim(pair[0])] = Type.trim(pair[1]);
1158                 } else if (!Type.isArray(arg)) {
1159                     // pairRaw consists of objects of the form {key1:value1,key2:value2,...}
1160                     JXG.extend(properties, arg);
1161                 } else {
1162                     // pairRaw consists of array [key,value]
1163                     properties[arg[0]] = arg[1];
1164                 }
1165             }
1166 
1167             // Handle shortcuts
1168             properties = this.resolveShortcuts(properties);
1169 
1170             for (i in properties) {
1171                 if (properties.hasOwnProperty(i)) {
1172                     key = i.replace(/\s+/g, '').toLowerCase();
1173                     value = properties[i];
1174 
1175                     // This handles the subobjects, if the key:value pairs are contained in an object.
1176                     // Example:
1177                     // ticks.setAttribute({
1178                     //      strokeColor: 'blue',
1179                     //      label: {
1180                     //          visible: false
1181                     //      }
1182                     // })
1183                     // Now, only the supplied label attributes are overwritten.
1184                     // Otherwise, the value of label would be {visible:false} only.
1185                     if (Type.isObject(value) &&
1186                         Type.exists(this.visProp[key])) {
1187 
1188                         this.visProp[key] = Type.merge(this.visProp[key], value);
1189 
1190                         // First, handle the special case
1191                         // ticks.setAttribute({label: {anchorX: "right", ..., visible: true});
1192                         if (this.type === Const.OBJECT_TYPE_TICKS && Type.exists(this.labels)) {
1193                             le = this.labels.length;
1194                             for (j = 0; j < le; j++) {
1195                                 this.labels[j].setAttribute(value);
1196                             }
1197                         } else if (Type.exists(this[key])) {
1198                             if (Type.isArray(this[key])) {
1199                                 for (j = 0; j < this[key].length; j++) {
1200                                     this[key][j].setAttribute(value);
1201                                 }
1202                             } else {
1203                                 this[key].setAttribute(value);
1204                             }
1205                         }
1206                         continue;
1207                     }
1208 
1209                     oldvalue = this.visProp[key];
1210                     switch (key) {
1211                     case 'name':
1212                         oldvalue = this.name;
1213                         delete this.board.elementsByName[this.name];
1214                         this.name = value;
1215                         this.board.elementsByName[this.name] = this;
1216                         break;
1217                     case 'needsregularupdate':
1218                         this.needsRegularUpdate = !(value === 'false' || value === false);
1219                         this.board.renderer.setBuffering(this, this.needsRegularUpdate ? 'auto' : 'static');
1220                         break;
1221                     case 'labelcolor':
1222                         value = Color.rgba2rgbo(value);
1223                         opacity = value[1];
1224                         value = value[0];
1225                         if (opacity === 0) {
1226                             if (Type.exists(this.label) && this.hasLabel) {
1227                                 this.label.hideElement();
1228                             }
1229                         }
1230                         if (Type.exists(this.label) && this.hasLabel) {
1231                             this.label.visProp.strokecolor = value;
1232                             this.board.renderer.setObjectStrokeColor(this.label,
1233                                 value, opacity);
1234                         }
1235                         if (this.elementClass === Const.OBJECT_CLASS_TEXT) {
1236                             this.visProp.strokecolor = value;
1237                             this.visProp.strokeopacity = opacity;
1238                             this.board.renderer.setObjectStrokeColor(this,
1239                                 value, opacity);
1240                         }
1241                         break;
1242                     case 'infoboxtext':
1243                         if (Type.isString(value)) {
1244                             this.infoboxText = value;
1245                         } else {
1246                             this.infoboxText = false;
1247                         }
1248                         break;
1249                     case 'visible':
1250                         if (value === 'false') {
1251                             this.visProp.visible = false;
1252                         } else if (value === 'true') {
1253                             this.visProp.visible = true;
1254                         } else {
1255                             this.visProp.visible = value;
1256                         }
1257 
1258                         this.setDisplayRendNode(Type.evaluate(this.visProp.visible));
1259                         if (Type.evaluate(this.visProp.visible) && Type.exists(this.updateSize)) {
1260                             this.updateSize();
1261                         }
1262 
1263                         break;
1264                     case 'face':
1265                         if (Type.isPoint(this)) {
1266                             this.visProp.face = value;
1267                             this.board.renderer.changePointStyle(this);
1268                         }
1269                         break;
1270                     case 'trace':
1271                         if (value === 'false' || value === false) {
1272                             this.clearTrace();
1273                             this.visProp.trace = false;
1274                         } else if (value === 'pause') {
1275                                 this.visProp.trace = false;
1276                         } else {
1277                             this.visProp.trace = true;
1278                         }
1279                         break;
1280                     case 'gradient':
1281                         this.visProp.gradient = value;
1282                         this.board.renderer.setGradient(this);
1283                         break;
1284                     case 'gradientsecondcolor':
1285                         value = Color.rgba2rgbo(value);
1286                         this.visProp.gradientsecondcolor = value[0];
1287                         this.visProp.gradientsecondopacity = value[1];
1288                         this.board.renderer.updateGradient(this);
1289                         break;
1290                     case 'gradientsecondopacity':
1291                         this.visProp.gradientsecondopacity = value;
1292                         this.board.renderer.updateGradient(this);
1293                         break;
1294                     case 'withlabel':
1295                         this.visProp.withlabel = value;
1296                         if (!Type.evaluate(value)) {
1297                             if (this.label && this.hasLabel) {
1298                                 //this.label.hideElement();
1299                                 this.label.setAttribute({visible: false});
1300                             }
1301                         } else {
1302                             if (!this.label) {
1303                                 this.createLabel();
1304                             }
1305                             //this.label.showElement();
1306                             this.label.setAttribute({visible: 'inherit'});
1307                             //this.label.setDisplayRendNode(Type.evaluate(this.visProp.visible));
1308                         }
1309                         this.hasLabel = value;
1310                         break;
1311                     case 'radius':
1312                         if (this.type === Const.OBJECT_TYPE_ANGLE || this.type === Const.OBJECT_TYPE_SECTOR) {
1313                             this.setRadius(value);
1314                         }
1315                         break;
1316                     case 'rotate':
1317                         if ((this.elementClass === Const.OBJECT_CLASS_TEXT &&
1318                              Type.evaluate(this.visProp.display) === 'internal') ||
1319                             this.type === Const.OBJECT_TYPE_IMAGE) {
1320                             this.addRotation(value);
1321                         }
1322                         break;
1323                     case 'ticksdistance':
1324                         if (this.type === Const.OBJECT_TYPE_TICKS && Type.isNumber(value)) {
1325                             this.ticksFunction = this.makeTicksFunction(value);
1326                         }
1327                         break;
1328                     case 'generatelabelvalue':
1329                         if (this.type === Const.OBJECT_TYPE_TICKS && Type.isFunction(value)) {
1330                             this.generateLabelValue = value;
1331                         }
1332                         break;
1333                     case 'onpolygon':
1334                         if (this.type === Const.OBJECT_TYPE_GLIDER) {
1335                             this.onPolygon = !!value;
1336                         }
1337                         break;
1338                     case 'disabled':
1339                         // button, checkbox, input. Is not available on initial call.
1340                         if (Type.exists(this.rendNodeTag)) {
1341                             this.rendNodeTag.disabled = !!value;
1342                         }
1343                         break;
1344                     case 'checked':
1345                         // checkbox Is not available on initial call.
1346                         if (Type.exists(this.rendNodeTag)) {
1347                             this.rendNodeCheckbox.checked = !!value;
1348                         }
1349                         break;
1350                     case 'maxlength':
1351                         // input. Is not available on initial call.
1352                         if (Type.exists(this.rendNodeTag)) {
1353                             this.rendNodeTag.maxlength = !!value;
1354                         }
1355                         break;
1356                     case 'layer':
1357                         this.board.renderer.setLayer(this, Type.evaluate(value));
1358                         this._set(key, value);
1359                         break;
1360                     default:
1361                         if (Type.exists(this.visProp[key]) &&
1362                             (!JXG.Validator[key] ||
1363                                 (JXG.Validator[key] && JXG.Validator[key](value)) ||
1364                                 (JXG.Validator[key] && Type.isFunction(value) && JXG.Validator[key](value()))
1365                             )
1366                         ) {
1367                             value = (value.toLowerCase && value.toLowerCase() === 'false') ? false : value;
1368                             this._set(key, value);
1369                         }
1370                         break;
1371                     }
1372                     this.triggerEventHandlers(['attribute:' + key], [oldvalue, value, this]);
1373                 }
1374             }
1375 
1376             this.triggerEventHandlers(['attribute'], [properties, this]);
1377 
1378             if (!Type.evaluate(this.visProp.needsregularupdate)) {
1379                 this.board.fullUpdate();
1380             } else {
1381                 this.board.update(this);
1382             }
1383 
1384             return this;
1385         },
1386 
1387         /**
1388          * Deprecated alias for {@link JXG.GeometryElement#getAttribute}.
1389          * @deprecated Use {@link JXG.GeometryElement#getAttribute}.
1390          */
1391         getProperty: function () {
1392             JXG.deprecated('getProperty()', 'getAttribute()');
1393             this.getProperty.apply(this, arguments);
1394         },
1395 
1396         /**
1397          * Get the value of the property <tt>key</tt>.
1398          * @param {String} key The name of the property you are looking for
1399          * @returns The value of the property
1400          */
1401         getAttribute: function (key) {
1402             var result;
1403             key = key.toLowerCase();
1404 
1405             switch (key) {
1406             case 'needsregularupdate':
1407                 result = this.needsRegularUpdate;
1408                 break;
1409             case 'labelcolor':
1410                 result = this.label.visProp.strokecolor;
1411                 break;
1412             case 'infoboxtext':
1413                 result = this.infoboxText;
1414                 break;
1415             case 'withlabel':
1416                 result = this.hasLabel;
1417                 break;
1418             default:
1419                 result = this.visProp[key];
1420                 break;
1421             }
1422 
1423             return result;
1424         },
1425 
1426         /**
1427          * Set the dash style of an object. See {@link JXG.GeometryElement#dash}
1428          * for a list of available dash styles.
1429          * You should use {@link JXG.GeometryElement#setAttribute} instead of this method.
1430          *
1431          * @param {number} dash Indicates the new dash style
1432          * @private
1433          */
1434         setDash: function (dash) {
1435             this.setAttribute({dash: dash});
1436             return this;
1437         },
1438 
1439         /**
1440          * Notify all child elements for updates.
1441          * @private
1442          */
1443         prepareUpdate: function () {
1444             this.needsUpdate = true;
1445             return this;
1446         },
1447 
1448         /**
1449          * Removes the element from the construction.  This only removes the SVG or VML node of the element and its label (if available) from
1450          * the renderer, to remove the element completely you should use {@link JXG.Board#removeObject}.
1451          */
1452         remove: function () {
1453             this.board.renderer.remove(this.board.renderer.getElementById(this.id));
1454 
1455             if (this.hasLabel) {
1456                 this.board.renderer.remove(this.board.renderer.getElementById(this.label.id));
1457             }
1458             return this;
1459         },
1460 
1461         /**
1462          * Returns the coords object where a text that is bound to the element shall be drawn.
1463          * Differs in some cases from the values that getLabelAnchor returns.
1464          * @returns {JXG.Coords} JXG.Coords Place where the text shall be drawn.
1465          * @see JXG.GeometryElement#getLabelAnchor
1466          */
1467         getTextAnchor: function () {
1468             return new Coords(Const.COORDS_BY_USER, [0, 0], this.board);
1469         },
1470 
1471         /**
1472          * Returns the coords object where the label of the element shall be drawn.
1473          * Differs in some cases from the values that getTextAnchor returns.
1474          * @returns {JXG.Coords} JXG.Coords Place where the text shall be drawn.
1475          * @see JXG.GeometryElement#getTextAnchor
1476          */
1477         getLabelAnchor: function () {
1478             return new Coords(Const.COORDS_BY_USER, [0, 0], this.board);
1479         },
1480 
1481         /**
1482          * Determines whether the element has arrows at start or end of the arc.
1483          * If it is set to be a "typical" vector, ie lastArrow == true,
1484          * then the element.type is set to VECTOR.
1485          * @param {Boolean} firstArrow True if there is an arrow at the start of the arc, false otherwise.
1486          * @param {Boolean} lastArrow True if there is an arrow at the end of the arc, false otherwise.
1487          */
1488         setArrow: function (firstArrow, lastArrow) {
1489             this.visProp.firstarrow = firstArrow;
1490             this.visProp.lastarrow = lastArrow;
1491             if (lastArrow) {
1492                 this.type = Const.OBJECT_TYPE_VECTOR;
1493                 this.elType = 'arrow';
1494             }
1495 
1496             this.prepareUpdate().update().updateVisibility().updateRenderer();
1497             return this;
1498         },
1499 
1500         /**
1501          * Creates a gradient nodes in the renderer.
1502          * @see JXG.SVGRenderer#setGradient
1503          * @private
1504          */
1505         createGradient: function () {
1506             var ev_g = Type.evaluate(this.visProp.gradient);
1507             if (ev_g === 'linear' || ev_g === 'radial') {
1508                 this.board.renderer.setGradient(this);
1509             }
1510         },
1511 
1512          /**
1513          * Creates a label element for this geometry element.
1514          * @see #addLabelToElement
1515          */
1516         createLabel: function () {
1517             var attr,
1518                 that = this;
1519 
1520             // this is a dirty hack to resolve the text-dependency. If there is no text element available,
1521             // just don't create a label. This method is usually not called by a user, so we won't throw
1522             // an exception here and simply output a warning via JXG.debug.
1523             if (JXG.elements.text) {
1524                 attr =  Type.deepCopy(this.visProp.label, null);
1525                 attr.id = this.id + 'Label';
1526                 attr.isLabel = true;
1527                 attr.anchor = this;
1528                 attr.priv = this.visProp.priv;
1529 
1530                 if (this.visProp.withlabel) {
1531                     this.label = JXG.elements.text(this.board, [0, 0, function () {
1532                         if (Type.isFunction(that.name)) {
1533                             return that.name();
1534                         }
1535                         return that.name;
1536                     }], attr);
1537                     this.label.needsUpdate = true;
1538                     this.label.dump = false;
1539                     this.label.fullUpdate();
1540 
1541                     this.hasLabel = true;
1542                 }
1543             } else {
1544                 JXG.debug('JSXGraph: Can\'t create label: text element is not available. Make sure you include base/text');
1545             }
1546 
1547             return this;
1548         },
1549 
1550         /**
1551          * Highlights the element.
1552          * @param {Boolean} [force=false] Force the highlighting
1553          * @returns {JXG.Board}
1554          */
1555         highlight: function (force) {
1556             force = Type.def(force, false);
1557             // I know, we have the JXG.Board.highlightedObjects AND JXG.GeometryElement.highlighted and YES we need both.
1558             // Board.highlightedObjects is for the internal highlighting and GeometryElement.highlighted is for user highlighting
1559             // initiated by the user, e.g. through custom DOM events. We can't just pick one because this would break user
1560             // defined highlighting in many ways:
1561             //  * if overriding the highlight() methods the user had to handle the highlightedObjects stuff, otherwise he'd break
1562             //    everything (e.g. the pie chart example http://jsxgraph.uni-bayreuth.de/wiki/index.php/Pie_chart (not exactly
1563             //    user defined but for this type of chart the highlight method was overridden and not adjusted to the changes in here)
1564             //    where it just kept highlighting until the radius of the pie was far beyond infinity...
1565             //  * user defined highlighting would get pointless, everytime the user highlights something using .highlight(), it would get
1566             //    dehighlighted immediately, because highlight puts the element into highlightedObjects and from there it gets dehighlighted
1567             //    through dehighlightAll.
1568 
1569             // highlight only if not highlighted
1570             if (Type.evaluate(this.visProp.highlight) && (!this.highlighted || force)) {
1571                 this.highlighted = true;
1572                 this.board.highlightedObjects[this.id] = this;
1573                 this.board.renderer.highlight(this);
1574             }
1575             return this;
1576         },
1577 
1578         /**
1579          * Uses the "normal" properties of the element.
1580          * @returns {JXG.Board}
1581          */
1582         noHighlight: function () {
1583             // see comment in JXG.GeometryElement.highlight()
1584 
1585             // dehighlight only if not highlighted
1586             if (this.highlighted) {
1587                 this.highlighted = false;
1588                 delete this.board.highlightedObjects[this.id];
1589                 this.board.renderer.noHighlight(this);
1590             }
1591             return this;
1592         },
1593 
1594         /**
1595          * Removes all objects generated by the trace function.
1596          */
1597         clearTrace: function () {
1598             var obj;
1599 
1600             for (obj in this.traces) {
1601                 if (this.traces.hasOwnProperty(obj)) {
1602                     this.board.renderer.remove(this.traces[obj]);
1603                 }
1604             }
1605 
1606             this.numTraces = 0;
1607             return this;
1608         },
1609 
1610         /**
1611          * Copy the element to background. This is used for tracing elements.
1612          * @returns {JXG.GeometryElement} A reference to the element
1613          */
1614         cloneToBackground: function () {
1615             return this;
1616         },
1617 
1618         /**
1619          * Dimensions of the smallest rectangle enclosing the element.
1620          * @returns {Array} The coordinates of the enclosing rectangle in a format
1621          * like the bounding box in {@link JXG.Board#setBoundingBox}.
1622          */
1623         bounds: function () {
1624             return [0, 0, 0, 0];
1625         },
1626 
1627         /**
1628          * Normalize the element's standard form.
1629          * @private
1630          */
1631         normalize: function () {
1632             this.stdform = Mat.normalize(this.stdform);
1633             return this;
1634         },
1635 
1636         /**
1637          * EXPERIMENTAL. Generate JSON object code of visProp and other properties.
1638          * @type String
1639          * @private
1640          * @ignore
1641          * @returns JSON string containing element's properties.
1642          */
1643         toJSON: function () {
1644             var vis, key,
1645                 json = ['{"name":', this.name];
1646 
1647             json.push(', ' + '"id":' + this.id);
1648 
1649             vis = [];
1650             for (key in this.visProp) {
1651                 if (this.visProp.hasOwnProperty(key)) {
1652                     if (Type.exists(this.visProp[key])) {
1653                         vis.push('"' + key + '":' + this.visProp[key]);
1654                     }
1655                 }
1656             }
1657             json.push(', "visProp":{' + vis.toString() + '}');
1658             json.push('}');
1659 
1660             return json.join('');
1661         },
1662 
1663         /**
1664          * Rotate texts or images by a given degree. Works only for texts where JXG.Text#display equal to "internal".
1665          * @param {number} angle The degree of the rotation (90 means vertical text).
1666          * @see JXG.GeometryElement#rotate
1667          */
1668         addRotation: function (angle) {
1669             var tOffInv, tOff, tS, tSInv, tRot,
1670                 that = this;
1671 
1672             if (((this.elementClass === Const.OBJECT_CLASS_TEXT &&
1673                     Type.evaluate(this.visProp.display) === 'internal') ||
1674                     this.type === Const.OBJECT_TYPE_IMAGE) && angle !== 0) {
1675 
1676                 tOffInv = this.board.create('transform', [
1677                     function () {
1678                         return -that.X();
1679                     }, function () {
1680                         return -that.Y();
1681                     }
1682                 ], {type: 'translate'});
1683 
1684                 tOff = this.board.create('transform', [
1685                     function () {
1686                         return that.X();
1687                     }, function () {
1688                         return that.Y();
1689                     }
1690                 ], {type: 'translate'});
1691 
1692                 tS = this.board.create('transform', [
1693                     function () {
1694                         return that.board.unitX / that.board.unitY;
1695                     }, function () {
1696                         return 1;
1697                     }
1698                 ], {type: 'scale'});
1699 
1700                 tSInv = this.board.create('transform', [
1701                     function () {
1702                         return that.board.unitY / that.board.unitX;
1703                     }, function () {
1704                         return 1;
1705                     }
1706                 ], {type: 'scale'});
1707 
1708                 tRot = this.board.create('transform', [
1709                         function() { return Type.evaluate(angle) * Math.PI / 180; }
1710                     ], {type: 'rotate'});
1711 
1712                 tOffInv.bindTo(this);
1713                 tS.bindTo(this);
1714                 tRot.bindTo(this);
1715                 tSInv.bindTo(this);
1716                 tOff.bindTo(this);
1717             }
1718 
1719             return this;
1720         },
1721 
1722         /**
1723          * Set the highlightStrokeColor of an element
1724          * @param {String} sColor String which determines the stroke color of an object when its highlighted.
1725          * @see JXG.GeometryElement#highlightStrokeColor
1726          * @deprecated Use {@link JXG.GeometryElement#setAttribute}
1727          */
1728         highlightStrokeColor: function (sColor) {
1729             JXG.deprecated('highlightStrokeColor()', 'setAttribute()');
1730             this.setAttribute({highlightStrokeColor: sColor});
1731             return this;
1732         },
1733 
1734         /**
1735          * Set the strokeColor of an element
1736          * @param {String} sColor String which determines the stroke color of an object.
1737          * @see JXG.GeometryElement#strokeColor
1738          * @deprecated Use {@link JXG.GeometryElement#setAttribute}
1739          */
1740         strokeColor: function (sColor) {
1741             JXG.deprecated('strokeColor()', 'setAttribute()');
1742             this.setAttribute({strokeColor: sColor});
1743             return this;
1744         },
1745 
1746         /**
1747          * Set the strokeWidth of an element
1748          * @param {Number} width Integer which determines the stroke width of an outline.
1749          * @see JXG.GeometryElement#strokeWidth
1750          * @deprecated Use {@link JXG.GeometryElement#setAttribute}
1751          */
1752         strokeWidth: function (width) {
1753             JXG.deprecated('strokeWidth()', 'setAttribute()');
1754             this.setAttribute({strokeWidth: width});
1755             return this;
1756         },
1757 
1758         /**
1759          * Set the fillColor of an element
1760          * @param {String} fColor String which determines the fill color of an object.
1761          * @see JXG.GeometryElement#fillColor
1762          * @deprecated Use {@link JXG.GeometryElement#setAttribute}
1763          */
1764         fillColor: function (fColor) {
1765             JXG.deprecated('fillColor()', 'setAttribute()');
1766             this.setAttribute({fillColor: fColor});
1767             return this;
1768         },
1769 
1770         /**
1771          * Set the highlightFillColor of an element
1772          * @param {String} fColor String which determines the fill color of an object when its highlighted.
1773          * @see JXG.GeometryElement#highlightFillColor
1774          * @deprecated Use {@link JXG.GeometryElement#setAttribute}
1775          */
1776         highlightFillColor: function (fColor) {
1777             JXG.deprecated('highlightFillColor()', 'setAttribute()');
1778             this.setAttribute({highlightFillColor: fColor});
1779             return this;
1780         },
1781 
1782         /**
1783          * Set the labelColor of an element
1784          * @param {String} lColor String which determines the text color of an object's label.
1785          * @see JXG.GeometryElement#labelColor
1786          * @deprecated Use {@link JXG.GeometryElement#setAttribute}
1787          */
1788         labelColor: function (lColor) {
1789             JXG.deprecated('labelColor()', 'setAttribute()');
1790             this.setAttribute({labelColor: lColor});
1791             return this;
1792         },
1793 
1794         /**
1795          * Set the dash type of an element
1796          * @param {Number} d Integer which determines the way of dashing an element's outline.
1797          * @see JXG.GeometryElement#dash
1798          * @deprecated Use {@link JXG.GeometryElement#setAttribute}
1799          */
1800         dash: function (d) {
1801             JXG.deprecated('dash()', 'setAttribute()');
1802             this.setAttribute({dash: d});
1803             return this;
1804         },
1805 
1806         /**
1807          * Set the visibility of an element
1808          * @param {Boolean} v Boolean which determines whether the element is drawn.
1809          * @see JXG.GeometryElement#visible
1810          * @deprecated Use {@link JXG.GeometryElement#setAttribute}
1811          */
1812         visible: function (v) {
1813             JXG.deprecated('visible()', 'setAttribute()');
1814             this.setAttribute({visible: v});
1815             return this;
1816         },
1817 
1818         /**
1819          * Set the shadow of an element
1820          * @param {Boolean} s Boolean which determines whether the element has a shadow or not.
1821          * @see JXG.GeometryElement#shadow
1822          * @deprecated Use {@link JXG.GeometryElement#setAttribute}
1823          */
1824         shadow: function (s) {
1825             JXG.deprecated('shadow()', 'setAttribute()');
1826             this.setAttribute({shadow: s});
1827             return this;
1828         },
1829 
1830         /**
1831          * The type of the element as used in {@link JXG.Board#create}.
1832          * @returns {String}
1833          */
1834         getType: function () {
1835             return this.elType;
1836         },
1837 
1838         /**
1839          * List of the element ids resp. values used as parents in {@link JXG.Board#create}.
1840          * @returns {Array}
1841          */
1842         getParents: function () {
1843             return Type.isArray(this.parents) ? this.parents : [];
1844         },
1845 
1846         /**
1847          * Snaps the element to the grid. Only works for points, lines and circles. Points will snap to the grid
1848          * as defined in their properties {@link JXG.Point#snapSizeX} and {@link JXG.Point#snapSizeY}. Lines and circles
1849          * will snap their parent points to the grid, if they have {@link JXG.Point#snapToGrid} set to true.
1850          * @returns {JXG.GeometryElement} Reference to the element.
1851          */
1852         snapToGrid: function () {
1853             return this;
1854         },
1855 
1856         /**
1857          * Snaps the element to points. Only works for points. Points will snap to the next point
1858          * as defined in their properties {@link JXG.Point#attractorDistance} and {@link JXG.Point#attractorUnit}.
1859          * Lines and circles
1860          * will snap their parent points to points.
1861          * @returns {JXG.GeometryElement} Reference to the element.
1862          */
1863         snapToPoints: function () {
1864             return this;
1865         },
1866 
1867         /**
1868          * Retrieve a copy of the current visProp.
1869          * @returns {Object}
1870          */
1871         getAttributes: function () {
1872             var attributes = Type.deepCopy(this.visProp),
1873                 /*
1874                 cleanThis = ['attractors', 'snatchdistance', 'traceattributes', 'frozen',
1875                     'shadow', 'gradientangle', 'gradientsecondopacity', 'gradientpositionx', 'gradientpositiony',
1876                     'needsregularupdate', 'zoom', 'layer', 'offset'],
1877                 */
1878                 cleanThis = [],
1879                 i, len = cleanThis.length;
1880 
1881             attributes.id = this.id;
1882             attributes.name = this.name;
1883 
1884             for (i = 0; i < len; i++) {
1885                 delete attributes[cleanThis[i]];
1886             }
1887 
1888             return attributes;
1889         },
1890 
1891         /**
1892          * Checks whether (x,y) is near the element.
1893          * @param {Number} x Coordinate in x direction, screen coordinates.
1894          * @param {Number} y Coordinate in y direction, screen coordinates.
1895          * @returns {Boolean} True if (x,y) is near the element, False otherwise.
1896          */
1897         hasPoint: function (x, y) {
1898             return false;
1899         },
1900 
1901         /**
1902          * Adds ticks to this line or curve. Ticks can be added to a curve or any kind of line: line, arrow, and axis.
1903          * @param {JXG.Ticks} ticks Reference to a ticks object which is describing the ticks (color, distance, how many, etc.).
1904          * @returns {String} Id of the ticks object.
1905          */
1906         addTicks: function (ticks) {
1907             if (ticks.id === '' || !Type.exists(ticks.id)) {
1908                 ticks.id = this.id + '_ticks_' + (this.ticks.length + 1);
1909             }
1910 
1911             this.board.renderer.drawTicks(ticks);
1912             this.ticks.push(ticks);
1913 
1914             return ticks.id;
1915         },
1916 
1917         /**
1918          * Removes all ticks from a line or curve.
1919          */
1920         removeAllTicks: function () {
1921             var t;
1922 
1923             if (Type.exists(this.ticks)) {
1924                 for (t = this.ticks.length; t > 0; t--) {
1925                     this.removeTicks(this.ticks[t - 1]);
1926                 }
1927                 this.ticks = [];
1928                 this.board.update();
1929             }
1930         },
1931 
1932         /**
1933          * Removes ticks identified by parameter named tick from this line or curve.
1934          * @param {JXG.Ticks} tick Reference to tick object to remove.
1935          */
1936         removeTicks: function (tick) {
1937             var t, j;
1938 
1939             if (Type.exists(this.defaultTicks) && this.defaultTicks === tick) {
1940                 this.defaultTicks = null;
1941             }
1942 
1943             if (Type.exists(this.ticks)) {
1944                 for (t = this.ticks.length; t > 0; t--) {
1945                     if (this.ticks[t - 1] === tick) {
1946                         this.board.removeObject(this.ticks[t - 1]);
1947 
1948                         if (this.ticks[t - 1].ticks) {
1949                             for (j = 0; j < this.ticks[t - 1].ticks.length; j++) {
1950                                 if (Type.exists(this.ticks[t - 1].labels[j])) {
1951                                     this.board.removeObject(this.ticks[t - 1].labels[j]);
1952                                 }
1953                             }
1954                         }
1955 
1956                         delete this.ticks[t - 1];
1957                         break;
1958                     }
1959                 }
1960             }
1961         },
1962 
1963         /**
1964          * Move an element to its nearest grid point.
1965          * The function uses the coords object of the element as
1966          * its actual position. If there is no coords object, nothing is done.
1967          * @param {Boolean} force force snapping independent from what the snaptogrid attribute says
1968          * @param {Boolean} fromParent True if the drag comes from a child element. This is the case if a line
1969          *    through two points is dragged. In this case we do not try to force the points to stay inside of
1970          *    the visible board, but the distance between the two points stays constant.
1971          * @returns {JXG.GeometryElement} Reference to this element
1972          */
1973         handleSnapToGrid: function (force, fromParent) {
1974             var x, y, ticks,
1975                 //i, len, g, el, p,
1976                 boardBB,
1977                 needsSnapToGrid = false,
1978                 sX = Type.evaluate(this.visProp.snapsizex),
1979                 sY = Type.evaluate(this.visProp.snapsizey);
1980 
1981             if (!Type.exists(this.coords)) {
1982                 return this;
1983             }
1984 
1985             needsSnapToGrid = Type.evaluate(this.visProp.snaptogrid) || force === true;
1986 
1987             if (needsSnapToGrid) {
1988                 x = this.coords.usrCoords[1];
1989                 y = this.coords.usrCoords[2];
1990 
1991                 if (sX <= 0 && this.board.defaultAxes && this.board.defaultAxes.x.defaultTicks) {
1992                     ticks = this.board.defaultAxes.x.defaultTicks;
1993                     sX = ticks.ticksDelta * (Type.evaluate(ticks.visProp.minorticks) + 1);
1994                 }
1995 
1996                 if (sY <= 0 && this.board.defaultAxes && this.board.defaultAxes.y.defaultTicks) {
1997                     ticks = this.board.defaultAxes.y.defaultTicks;
1998                     sY = ticks.ticksDelta * (Type.evaluate(ticks.visProp.minorticks) + 1);
1999                 }
2000 
2001                 // if no valid snap sizes are available, don't change the coords.
2002                 if (sX > 0 && sY > 0) {
2003                     boardBB = this.board.getBoundingBox();
2004                     x = Math.round(x / sX) * sX;
2005                     y = Math.round(y / sY) * sY;
2006 
2007                     // checking whether x and y are still within boundingBox,
2008                     // if not, adjust them to remain within the board
2009                     if (!fromParent) {
2010                         if (x < boardBB[0]) {
2011                             x += sX;
2012                         } else if (x > boardBB[2]) {
2013                             x -= sX;
2014                         }
2015 
2016                         if (y < boardBB[3]) {
2017                             y += sY;
2018                         } else if (y > boardBB[1]) {
2019                             y -= sY;
2020                         }
2021                     }
2022                     this.coords.setCoordinates(Const.COORDS_BY_USER, [x, y]);
2023                 }
2024             }
2025             return this;
2026         },
2027 
2028         getBoundingBox: function() {
2029             var i, le, v, x, y,
2030                 bb = [Infinity, Infinity, -Infinity, -Infinity];
2031 
2032             if (this.type === Const.OBJECT_TYPE_POLYGON) {
2033                 le = this.vertices.length - 1;
2034                 if (le <= 0) {
2035                     return bb;
2036                 }
2037                 for (i = 0; i < le; i++) {
2038                     v = this.vertices[i].X();
2039                     bb[0] = (v < bb[0]) ? v : bb[0];
2040                     bb[2] = (v > bb[2]) ? v : bb[2];
2041                     v = this.vertices[i].Y();
2042                     bb[1] = (v < bb[1]) ? v : bb[1];
2043                     bb[3] = (v > bb[3]) ? v : bb[3];
2044                 }
2045             } else if (this.elementClass === Const.OBJECT_CLASS_CIRCLE) {
2046                 x = this.center.X();
2047                 y = this.center.Y();
2048                 bb = [x - this.radius, y + this.radius, x + this.radius, y - this.radius];
2049             } else if (this.elementClass === Const.OBJECT_CLASS_CURVE) {
2050                 le = this.vertices.length;
2051                 if (le === 0) {
2052                     return bb;
2053                 }
2054                 for (i = 0; i < le; i++) {
2055                     v = this.points[i].coords.usrCoords[1];
2056                     bb[0] = (v < bb[0]) ? v : bb[0];
2057                     bb[2] = (v > bb[2]) ? v : bb[2];
2058                     v = this.points[i].coords.usrCoords[1];
2059                     bb[1] = (v < bb[1]) ? v : bb[1];
2060                     bb[3] = (v > bb[3]) ? v : bb[3];
2061                 }
2062             }
2063 
2064             return bb;
2065         },
2066 
2067         /**
2068          * Alias of {@link JXG.EventEmitter.on}.
2069          *
2070          * @name addEvent
2071          * @memberof JXG.GeometryElement
2072          * @function
2073          */
2074         addEvent: JXG.shortcut(JXG.GeometryElement.prototype, 'on'),
2075 
2076         /**
2077          * Alias of {@link JXG.EventEmitter.off}.
2078          *
2079          * @name removeEvent
2080          * @memberof JXG.GeometryElement
2081          * @function
2082          */
2083         removeEvent: JXG.shortcut(JXG.GeometryElement.prototype, 'off'),
2084 
2085         /* **************************
2086          *     EVENT DEFINITION
2087          * for documentation purposes
2088          * ************************** */
2089 
2090         //region Event handler documentation
2091         /**
2092          * @event
2093          * @description This event is fired whenever the user is hovering over an element.
2094          * @name JXG.GeometryElement#over
2095          * @param {Event} e The browser's event object.
2096          */
2097         __evt__over: function (e) { },
2098 
2099         /**
2100          * @event
2101          * @description This event is fired whenever the user puts the mouse over an element.
2102          * @name JXG.GeometryElement#mouseover
2103          * @param {Event} e The browser's event object.
2104          */
2105         __evt__mouseover: function (e) { },
2106 
2107         /**
2108          * @event
2109          * @description This event is fired whenever the user is leaving an element.
2110          * @name JXG.GeometryElement#out
2111          * @param {Event} e The browser's event object.
2112          */
2113         __evt__out: function (e) { },
2114 
2115         /**
2116          * @event
2117          * @description This event is fired whenever the user puts the mouse away from an element.
2118          * @name JXG.GeometryElement#mouseout
2119          * @param {Event} e The browser's event object.
2120          */
2121         __evt__mouseout: function (e) { },
2122 
2123         /**
2124          * @event
2125          * @description This event is fired whenever the user is moving over an element.
2126          * @name JXG.GeometryElement#move
2127          * @param {Event} e The browser's event object.
2128          */
2129         __evt__move: function (e) { },
2130 
2131         /**
2132          * @event
2133          * @description This event is fired whenever the user is moving the mouse over an element.
2134          * @name JXG.GeometryElement#mousemove
2135          * @param {Event} e The browser's event object.
2136          */
2137         __evt__mousemove: function (e) { },
2138 
2139         /**
2140          * @event
2141          * @description This event is fired whenever the user drags an element.
2142          * @name JXG.GeometryElement#drag
2143          * @param {Event} e The browser's event object.
2144          */
2145         __evt__drag: function (e) { },
2146 
2147         /**
2148          * @event
2149          * @description This event is fired whenever the user drags the element with a mouse.
2150          * @name JXG.GeometryElement#mousedrag
2151          * @param {Event} e The browser's event object.
2152          */
2153         __evt__mousedrag: function (e) { },
2154 
2155         /**
2156          * @event
2157          * @description This event is fired whenever the user drags the element with a pen.
2158          * @name JXG.GeometryElement#pendrag
2159          * @param {Event} e The browser's event object.
2160          */
2161         __evt__pendrag: function (e) { },
2162 
2163         /**
2164          * @event
2165          * @description This event is fired whenever the user drags the element on a touch device.
2166          * @name JXG.GeometryElement#touchdrag
2167          * @param {Event} e The browser's event object.
2168          */
2169         __evt__touchdrag: function (e) { },
2170 
2171         /**
2172          * @event
2173          * @description Whenever the user starts to touch or click an element.
2174          * @name JXG.GeometryElement#down
2175          * @param {Event} e The browser's event object.
2176          */
2177         __evt__down: function (e) { },
2178 
2179         /**
2180          * @event
2181          * @description Whenever the user starts to click an element.
2182          * @name JXG.GeometryElement#mousedown
2183          * @param {Event} e The browser's event object.
2184          */
2185         __evt__mousedown: function (e) { },
2186 
2187         /**
2188          * @event
2189          * @description Whenever the user taps an element with the pen.
2190          * @name JXG.GeometryElement#pendown
2191          * @param {Event} e The browser's event object.
2192          */
2193         __evt__pendown: function (e) { },
2194 
2195         /**
2196          * @event
2197          * @description Whenever the user starts to touch an element.
2198          * @name JXG.GeometryElement#touchdown
2199          * @param {Event} e The browser's event object.
2200          */
2201         __evt__touchdown: function (e) { },
2202 
2203         /**
2204          * @event
2205          * @description Whenever the user stops to touch or click an element.
2206          * @name JXG.GeometryElement#up
2207          * @param {Event} e The browser's event object.
2208          */
2209         __evt__up: function (e) { },
2210 
2211         /**
2212          * @event
2213          * @description Whenever the user releases the mousebutton over an element.
2214          * @name JXG.GeometryElement#mouseup
2215          * @param {Event} e The browser's event object.
2216          */
2217         __evt__mouseup: function (e) { },
2218 
2219         /**
2220          * @event
2221          * @description Whenever the user lifts the pen over an element.
2222          * @name JXG.GeometryElement#penup
2223          * @param {Event} e The browser's event object.
2224          */
2225         __evt__penup: function (e) { },
2226 
2227         /**
2228          * @event
2229          * @description Whenever the user stops touching an element.
2230          * @name JXG.GeometryElement#touchup
2231          * @param {Event} e The browser's event object.
2232          */
2233         __evt__touchup: function (e) {},
2234 
2235         /**
2236          * @event
2237          * @description Notify every time an attribute is changed.
2238          * @name JXG.GeometryElement#attribute
2239          * @param {Object} o A list of changed attributes and their new value.
2240          * @param {Object} el Reference to the element
2241          */
2242         __evt__attribute: function (o, el) {},
2243 
2244         /**
2245          * @event
2246          * @description This is a generic event handler. It exists for every possible attribute that can be set for
2247          * any element, e.g. if you want to be notified everytime an element's strokecolor is changed, is the event
2248          * <tt>attribute:strokecolor</tt>.
2249          * @name JXG.GeometryElement#attribute:key
2250          * @param val The old value.
2251          * @param nval The new value
2252          * @param {Object} el Reference to the element
2253          */
2254         __evt__attribute_: function (val, nval, el) {},
2255 
2256         /**
2257          * @ignore
2258          */
2259         __evt: function () {}
2260         //endregion
2261 
2262     });
2263 
2264     return JXG.GeometryElement;
2265 });
2266