From 039954b96029564a24c6de0ca69b62cc70ef7c78 Mon Sep 17 00:00:00 2001 From: alfred Date: Mon, 2 Apr 2012 18:43:10 +0200 Subject: [PATCH 1/3] Adding version 0.94 and a subdirectory "latest" --- ajax/libs/jsxgraph/0.94/GeogebraReader.js | 2800 +++++++++++++++++++ ajax/libs/jsxgraph/0.94/GeonextReader.js | 1124 ++++++++ ajax/libs/jsxgraph/0.94/IntergeoReader.js | 967 +++++++ ajax/libs/jsxgraph/0.94/jsxgraphcore.js | 26 + ajax/libs/jsxgraph/latest/GeogebraReader.js | 2800 +++++++++++++++++++ ajax/libs/jsxgraph/latest/GeonextReader.js | 1124 ++++++++ ajax/libs/jsxgraph/latest/IntergeoReader.js | 967 +++++++ ajax/libs/jsxgraph/latest/jsxgraphcore.js | 26 + ajax/libs/jsxgraph/package.json | 2 +- 9 files changed, 9835 insertions(+), 1 deletion(-) create mode 100644 ajax/libs/jsxgraph/0.94/GeogebraReader.js create mode 100644 ajax/libs/jsxgraph/0.94/GeonextReader.js create mode 100644 ajax/libs/jsxgraph/0.94/IntergeoReader.js create mode 100644 ajax/libs/jsxgraph/0.94/jsxgraphcore.js create mode 100644 ajax/libs/jsxgraph/latest/GeogebraReader.js create mode 100644 ajax/libs/jsxgraph/latest/GeonextReader.js create mode 100644 ajax/libs/jsxgraph/latest/IntergeoReader.js create mode 100644 ajax/libs/jsxgraph/latest/jsxgraphcore.js diff --git a/ajax/libs/jsxgraph/0.94/GeogebraReader.js b/ajax/libs/jsxgraph/0.94/GeogebraReader.js new file mode 100644 index 000000000..4d8a0cc33 --- /dev/null +++ b/ajax/libs/jsxgraph/0.94/GeogebraReader.js @@ -0,0 +1,2800 @@ + JXG.GeogebraReader = new function() { +/** + * @param {String} type the type of expression + * @param {String} m first input value + * @param {String} n second input value + * @return {String} return the object, string or calculated value + */ +this.ggbAct = function(type, m, n) { + var v1 = m, v2 = n, s1, s2, a; + switch(type.toLowerCase()) { + case 'end': + // JXG.debug("end: "+ v1); + return v1; + break; + case 'coord': + s1 = (JXG.GeogebraReader.board.ggbElements[v1]) ? 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'")' : v1; + s2 = (JXG.GeogebraReader.board.ggbElements[v2]) ? 'JXG.getRef(JXG.GeogebraReader.board, "'+ v2 +'")' : v2; + return [s1, s2]; + break; + case 'le': // smaller then + return '( ('+ v1 +') <= ('+ v2 +') )'; + break; + case 'ge': // greater then + return '( ('+ v1 +') >= ('+ v2 +') )'; + break; + case 'eq': // equal + return '( ('+ v1 +') == ('+ v2 +') )'; + break; + case 'neq': // not equal + return '( ('+ v1 +') != ('+ v2 +') )'; + break; + case 'lt': // smaller + return '( ('+ v1 +') < ('+ v2 +') )'; + break; + case 'gt': // greater + return '( ('+ v1 +') > ('+ v2 +') )'; + break; + case 'add': + if (JXG.GeogebraReader.isGGBVector(v1) && JXG.GeogebraReader.isGGBVector(v2)){ //Add: Vector + Vector + return [1, v1[1] + '+' + v2[1], v1[2] + '+' + v2[2]]; + } + if( JXG.isString(v1) && !v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v1.match(/JXG\.getRef/) ) { + s1 = [v1+'.X()', v1+'.Y()']; + } else { + s1 = v1; + } + + if( JXG.isString(v2) && !v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v2.match(/JXG\.getRef/) ) { + s2 = [v2+'.X()', v2+'.Y()']; + } else { + s2 = v2; + } + + if (JXG.GeogebraReader.isGGBVector(s1) && JXG.isArray(s2)){ //Add: Vector + Point + return [s1[1] + '+' + s2[0], s1[2] + '+' + s2[1]]; + } + + if (JXG.GeogebraReader.isGGBVector(s2) && JXG.isArray(s1)){ //Add: Vector + Point + return [s2[1] + '+' + s1[0], s2[2] + '+' + s1[1]]; + } + + if( JXG.isArray(s1) && JXG.isArray(s2) ) { + return [ s1[0] +' + '+ s2[0], s1[1] +' + '+ s2[1] ]; + } + else if( (JXG.isNumber(s1) || JXG.isString(s1)) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { + return s1 +' + '+ s2; + } + else if( (JXG.isNumber(s1) || JXG.isString(s1)) && JXG.isArray(s2) ) { + return [ s1 +' + '+ s2[0], s1 +' + '+ s2[1] ]; + } + else if( JXG.isArray(s1) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { + return [ s1[0] +' + '+ s2, s1[1] +' + '+ s2 ]; + } + else { + return s1 +' + '+ s2; + } + break; + case 'sub': + if (JXG.GeogebraReader.isGGBVector(v1) && JXG.GeogebraReader.isGGBVector(v2)){ //Sub: Vector - Vector + return [1, v1[1] + '-' + v2[1], v1[2] + '-' + v2[2]]; + } + + if( JXG.isString(v1) && !v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v1.match(/JXG\.getRef/) ) { + s1 = [v1+'.X()', v1+'.Y()']; + } else { + s1 = v1; + } + + if( JXG.isString(v2) && !v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v2.match(/JXG\.getRef/) ) { + s2 = [v2+'.X()', v2+'.Y()']; + } else { + s2 = v2; + } + + if (JXG.GeogebraReader.isGGBVector(s1) && JXG.isArray(s2)){ //Add: Vector - Point + return [s1[1] + '-' + s2[0], s1[2] + '-' + s2[1]]; + } + + if (JXG.isArray(s1) && JXG.GeogebraReader.isGGBVector(s2)){ //Add: Punkt - Vector + return [s1[0] + '-(' + s2[1] + ')', s1[1] + '-(' + s2[2] +')']; + } + + if( JXG.isArray(s1) && JXG.isArray(s2) ) { + return [ s1[0] +' - '+ s2[0], s1[1] +' - '+ s2[1] ]; + } + else if( (JXG.isNumber(s1) || JXG.isString(s1)) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { + return s1 +' - '+ s2; + } + else if( (JXG.isNumber(s1) || JXG.isString(s1)) && JXG.isArray(s2) ) { + return [ s1 +' - '+ s2[0], s1 +' - '+ s2[1] ]; + } + else if( JXG.isArray(s1) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { + return [ s1[0] +' - '+ s2, s1[1] +' - '+ s2 ]; + } + else { + return s1 +' - '+ s2; + } + break; + case 'neg': + return '!('+ v1 +')'; + break; + case 'pow': + return 'Math.pow('+ v1 +', '+ v2 +')'; + break; + case 'or': + return '('+ v1 +'||'+ v2 +')'; + break; + case 'and': + return '('+ v1 +'&&'+ v2 +')'; + break; + case 'mul': + if (JXG.GeogebraReader.isGGBVector(v1) && !JXG.isArray(v2)){ // Mult: Vector * Skalar + return [1,'(' + v1[1] + ')*'+v2,'(' + v1[2] + ')*'+v2]; + } else if (!JXG.isArray(v1) && JXG.GeogebraReader.isGGBVector(v2)){ // Mult: Skalar * Vector + return new Array(1,'(' + v2[1] + ')*'+v1,'(' + v2[2] + ')*'+v1); + } else if (JXG.GeogebraReader.isGGBVector(v1) && JXG.GeogebraReader.isGGBVector(v2)){ //Mult: Vector * Vector + return '((' + v1[1] + ')*('+v2[1]+')+('+ v1[2] + ')*('+v2[2]+'))'; + } else { // Rest + if( JXG.isString(v1) && !v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v1.match(/JXG\.getRef/) ) { + s1 = [v1+'.X()', v1+'.Y()']; + } else { + s1 = v1; + } + + if( JXG.isString(v2) && !v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v2.match(/JXG\.getRef/) ) { + s2 = [v2+'.X()', v2+'.Y()']; + } else { + s2 = v2; + } + + if( JXG.isArray(s1) && JXG.isArray(s2) ) { + return [ s1[0] +' * '+ s2[0], s1[1] +' * '+ s2[1] ]; + } + else if( (JXG.isNumber(s1) || JXG.isString(s1)) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { + return s1 +' * '+ s2; + } + else if( (JXG.isNumber(s1) || JXG.isString(s1)) && JXG.isArray(s2) ) { + return [ s1 +' * '+ s2[0], s1 +' * '+ s2[1] ]; + } + else if( JXG.isArray(s1) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { + return [ s1[0] +' * '+ s2, s1[1] +' * '+ s2 ]; + } + else { + return s1 +' * '+ s2; + } + } + break; + case 'div': + if( JXG.isString(v1) && !v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v1.match(/JXG\.getRef/) ) { + s1 = [v1+'.X()', v1+'.Y()']; + } else { + s1 = v1; + } + + if( JXG.isString(v2) && !v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v2.match(/JXG\.getRef/) ) { + s2 = [v2+'.X()', v2+'.Y()']; + } else { + s2 = v2; + } + + if( JXG.isArray(s1) && JXG.isArray(s2) ) { + return [ s1[0] +' / '+ s2[0], s1[1] +' / '+ s2[1] ]; + } + else if( (JXG.isNumber(s1) || JXG.isString(s1)) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { + return s1 +' / '+ s2; + } + else if( (JXG.isNumber(s1) || JXG.isString(s1)) && JXG.isArray(s2) ) { + return [ s1 +' / '+ s2[0], s1 +' / '+ s2[1] ]; + } + else if( JXG.isArray(s1) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { + return [ s1[0] +' / '+ s2, s1[1] +' / '+ s2 ]; + } + else { + return s1 +' / '+ s2; + } + break; + case 'negmult': + if (JXG.GeogebraReader.isGGBVector(v1)) + return new Array(1, -1 + '*' + v1[1],-1 + '*' + v1[2]); + return -1 +'*'+ v1; + break; + case 'bra': + if (JXG.GeogebraReader.isGGBVector(v1)) + return new Array(1,'(' + v1[1] + ')','(' + v1[2] + ')'); + return '('+ v1 +')'; + break; + case 'int': + return parseInt(v1); + break; + case 'float': + return parseFloat(v1); + break; + case 'param': + return v1; + break; + case 'html': + return v1; + break; + case 'string': + if(v2) return [v1, v2]; + else return v1; + break; + case 'command': + v2 = v1.split('['); + s1 = v2[0]; + s2 = (v2[1].split(']'))[0]; + switch(s1.toLowerCase()) { + case 'name': + return 'JXG.getRef(JXG.GeogebraReader.board, "'+ s2 +'").getName()'; //TODO korrigiere getName() + break; + } + break; + case 'var': + if(v2) { + switch(v1.toLowerCase()) { + case 'x': + return v2 +'.X()'; + break; + case 'y': + return v2 +'.Y()'; + break; + case 'abs': + case 'acos': + case 'asin': + case 'atan': + case 'ceil': + case 'cos': + case 'exp': + case 'floor': + case 'log': + case 'max': + case 'min': + case 'pow': + case 'random': + case 'round': + case 'sin': + case 'sqrt': + case 'tan': + return 'Math.'+v1.toLowerCase()+'('+ v2 +')'; + break; + default: + return v1.toLowerCase()+'*('+ v2 +')'; + break; + } + } else { + + if(v1 == 'PI') { + return 'Math.PI'; + } else { + a = JXG.GeogebraReader.checkElement(v1); + if(typeof JXG.GeogebraReader.board.ggb[v1] != 'undefined') { + return 'JXG.GeogebraReader.board.ggb["'+ v1 +'"]()'; + } else if(typeof a.Value != 'undefined') { + return 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").Value()'; + } else if(typeof a.Area != 'undefined') { + return 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").Area()'; + } else if(typeof a.plaintextStr != 'undefined') { + return '1.0*JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").plaintextStr'; + } else if (a.type == JXG.OBJECT_TYPE_VECTOR){ + return new Array(1, 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point2.X()-JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point1.X()','JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point2.Y()-JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point1.Y()'); + }else if(a.elementClass == JXG.OBJECT_CLASS_LINE) { + return 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point1.Dist(JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point2)'; + } else { + return 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'")'; + } + } + } + break; + } +}; + +/** + * JS/CC parser to convert the input expression to a working javascript function. + * @param {Object} board object + * @param {Object} element Element that needs to be updated + * @param {String} exp String which contains the function, expression or information + */ +this.ggbParse = function(exp, element) { + var element = (element) ? JXG.getRef(JXG.GeogebraReader.board, JXG.GeogebraReader.board.ggbElements[element].id) : false; + if(element) JXG.debug("Zu aktualisierendes Element: "+ element.name + "("+ element.id +")"); + +/* + This parser was generated with: The LALR(1) parser and lexical analyzer generator for JavaScript, written in JavaScript + In the version 0.30 on http://jscc.jmksf.com/ + + It is based on the default template driver for JS/CC generated parsers running as + browser-based JavaScript/ECMAScript applications and was strongly modified. + + The parser was written 2007, 2008 by Jan Max Meyer, J.M.K S.F. Software Technologies + This is in the public domain. +*/ + +/***** begin replace *****/ + var _dbg_withtrace = false; + var _dbg_string = new String(); + + function __dbg_print( text ) { + _dbg_string += text + "\n"; + } + + function __lex( info ) { + var state = 0; + var match = -1; + var match_pos = 0; + var start = 0; + var pos = info.offset + 1; + + do + { + pos--; + state = 0; + match = -2; + start = pos; + + if( info.src.length <= start ) + return 28; + + do + { + + switch( state ) + { + case 0: + if( info.src.charCodeAt( pos ) == 9 || info.src.charCodeAt( pos ) == 32 ) state = 1; + else if( info.src.charCodeAt( pos ) == 33 ) state = 2; + else if( info.src.charCodeAt( pos ) == 40 ) state = 3; + else if( info.src.charCodeAt( pos ) == 41 ) state = 4; + else if( info.src.charCodeAt( pos ) == 42 ) state = 5; + else if( info.src.charCodeAt( pos ) == 43 ) state = 6; + else if( info.src.charCodeAt( pos ) == 44 ) state = 7; + else if( info.src.charCodeAt( pos ) == 45 ) state = 8; + else if( info.src.charCodeAt( pos ) == 47 ) state = 9; + else if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 10; + else if( info.src.charCodeAt( pos ) == 60 ) state = 11; + else if( info.src.charCodeAt( pos ) == 62 ) state = 12; + else if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 13; + else if( info.src.charCodeAt( pos ) == 94 ) state = 14; + else if( info.src.charCodeAt( pos ) == 34 ) state = 26; + else if( info.src.charCodeAt( pos ) == 38 ) state = 28; + else if( info.src.charCodeAt( pos ) == 46 ) state = 29; + else if( info.src.charCodeAt( pos ) == 61 ) state = 30; + else if( info.src.charCodeAt( pos ) == 95 ) state = 31; + else if( info.src.charCodeAt( pos ) == 124 ) state = 32; + else state = -1; + break; + + case 1: + state = -1; + match = 1; + match_pos = pos; + break; + + case 2: + if( info.src.charCodeAt( pos ) == 61 ) state = 15; + else state = -1; + match = 23; + match_pos = pos; + break; + + case 3: + state = -1; + match = 2; + match_pos = pos; + break; + + case 4: + state = -1; + match = 3; + match_pos = pos; + break; + + case 5: + state = -1; + match = 13; + match_pos = pos; + break; + + case 6: + state = -1; + match = 11; + match_pos = pos; + break; + + case 7: + state = -1; + match = 16; + match_pos = pos; + break; + + case 8: + state = -1; + match = 12; + match_pos = pos; + break; + + case 9: + state = -1; + match = 14; + match_pos = pos; + break; + + case 10: + if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 10; + else if( info.src.charCodeAt( pos ) == 46 ) state = 18; + else state = -1; + match = 4; + match_pos = pos; + break; + + case 11: + if( info.src.charCodeAt( pos ) == 61 ) state = 19; + else state = -1; + match = 21; + match_pos = pos; + break; + + case 12: + if( info.src.charCodeAt( pos ) == 61 ) state = 21; + else state = -1; + match = 22; + match_pos = pos; + break; + + case 13: + if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 13; + else if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 27; + else if( info.src.charCodeAt( pos ) == 91 ) state = 34; + else if( info.src.charCodeAt( pos ) == 95 ) state = 35; + else state = -1; + match = 7; + match_pos = pos; + break; + + case 14: + state = -1; + match = 15; + match_pos = pos; + break; + + case 15: + state = -1; + match = 20; + match_pos = pos; + break; + + case 16: + state = -1; + match = 9; + match_pos = pos; + break; + + case 17: + state = -1; + match = 25; + match_pos = pos; + break; + + case 18: + if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 18; + else state = -1; + match = 5; + match_pos = pos; + break; + + case 19: + state = -1; + match = 17; + match_pos = pos; + break; + + case 20: + state = -1; + match = 19; + match_pos = pos; + break; + + case 21: + state = -1; + match = 18; + match_pos = pos; + break; + + case 22: + state = -1; + match = 24; + match_pos = pos; + break; + + case 23: + state = -1; + match = 8; + match_pos = pos; + break; + + case 24: + if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 24; + else state = -1; + match = 6; + match_pos = pos; + break; + + case 25: + state = -1; + match = 10; + match_pos = pos; + break; + + case 26: + if( info.src.charCodeAt( pos ) == 34 ) state = 16; + else if( info.src.charCodeAt( pos ) == 32 || info.src.charCodeAt( pos ) == 46 || ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || info.src.charCodeAt( pos ) == 61 || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) || info.src.charCodeAt( pos ) == 223 || info.src.charCodeAt( pos ) == 228 || info.src.charCodeAt( pos ) == 246 || info.src.charCodeAt( pos ) == 252 ) state = 26; + else state = -1; + break; + + case 27: + if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 27; + else if( info.src.charCodeAt( pos ) == 95 ) state = 35; + else state = -1; + match = 7; + match_pos = pos; + break; + + case 28: + if( info.src.charCodeAt( pos ) == 38 ) state = 17; + else if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 33; + else state = -1; + break; + + case 29: + if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 18; + else state = -1; + break; + + case 30: + if( info.src.charCodeAt( pos ) == 61 ) state = 20; + else state = -1; + break; + + case 31: + if( info.src.charCodeAt( pos ) == 95 ) state = 36; + else state = -1; + break; + + case 32: + if( info.src.charCodeAt( pos ) == 124 ) state = 22; + else state = -1; + break; + + case 33: + if( info.src.charCodeAt( pos ) == 59 ) state = 23; + else if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 33; + else state = -1; + break; + + case 34: + if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 37; + else state = -1; + break; + + case 35: + if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 27; + else if( info.src.charCodeAt( pos ) == 95 ) state = 35; + else state = -1; + break; + + case 36: + if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 24; + else state = -1; + break; + + case 37: + if( info.src.charCodeAt( pos ) == 93 ) state = 25; + else if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 37; + else state = -1; + break; + + } + + + pos++; + + } + while( state > -1 ); + + } + while( 1 > -1 && match == 1 ); + + if( match > -1 ) + { + info.att = info.src.substr( start, match_pos - start ); + info.offset = match_pos; + + + } + else + { + info.att = new String(); + match = -1; + } + + return match; + } + + + function __parse( src, err_off, err_la ) { + var sstack = new Array(); + var vstack = new Array(); + var err_cnt = 0; + var act; + var go; + var la; + var rval; + var parseinfo = new Function( "", "var offset; var src; var att;" ); + var info = new parseinfo(); + + /* Pop-Table */ + var pop_tab = new Array( + new Array( 0/* p' */, 1 ), + new Array( 27/* p */, 1 ), + new Array( 26/* e */, 5 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 2 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 2 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 1 ), + new Array( 26/* e */, 1 ), + new Array( 26/* e */, 1 ), + new Array( 26/* e */, 1 ), + new Array( 26/* e */, 1 ), + new Array( 26/* e */, 1 ), + new Array( 26/* e */, 4 ), + new Array( 26/* e */, 1 ) + ); + + /* Action-Table */ + var act_tab = new Array( + /* State 0 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 1 */ new Array( 28/* "$" */,0 ), + /* State 2 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,18 , 11/* "+" */,19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-1 ), + /* State 3 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 4 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 5 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 6 */ new Array( 11/* "+" */,29 , 28/* "$" */,-24 , 17/* "<=" */,-24 , 18/* ">=" */,-24 , 19/* "==" */,-24 , 20/* "!=" */,-24 , 21/* "<" */,-24 , 22/* ">" */,-24 , 12/* "-" */,-24 , 15/* "^" */,-24 , 24/* "||" */,-24 , 25/* "&&" */,-24 , 13/* "*" */,-24 , 14/* "/" */,-24 , 16/* "," */,-24 , 3/* ")" */,-24 ), + /* State 7 */ new Array( 28/* "$" */,-20 , 17/* "<=" */,-20 , 18/* ">=" */,-20 , 19/* "==" */,-20 , 20/* "!=" */,-20 , 21/* "<" */,-20 , 22/* ">" */,-20 , 11/* "+" */,-20 , 12/* "-" */,-20 , 15/* "^" */,-20 , 24/* "||" */,-20 , 25/* "&&" */,-20 , 13/* "*" */,-20 , 14/* "/" */,-20 , 16/* "," */,-20 , 3/* ")" */,-20 ), + /* State 8 */ new Array( 28/* "$" */,-21 , 17/* "<=" */,-21 , 18/* ">=" */,-21 , 19/* "==" */,-21 , 20/* "!=" */,-21 , 21/* "<" */,-21 , 22/* ">" */,-21 , 11/* "+" */,-21 , 12/* "-" */,-21 , 15/* "^" */,-21 , 24/* "||" */,-21 , 25/* "&&" */,-21 , 13/* "*" */,-21 , 14/* "/" */,-21 , 16/* "," */,-21 , 3/* ")" */,-21 ), + /* State 9 */ new Array( 28/* "$" */,-22 , 17/* "<=" */,-22 , 18/* ">=" */,-22 , 19/* "==" */,-22 , 20/* "!=" */,-22 , 21/* "<" */,-22 , 22/* ">" */,-22 , 11/* "+" */,-22 , 12/* "-" */,-22 , 15/* "^" */,-22 , 24/* "||" */,-22 , 25/* "&&" */,-22 , 13/* "*" */,-22 , 14/* "/" */,-22 , 16/* "," */,-22 , 3/* ")" */,-22 ), + /* State 10 */ new Array( 28/* "$" */,-23 , 17/* "<=" */,-23 , 18/* ">=" */,-23 , 19/* "==" */,-23 , 20/* "!=" */,-23 , 21/* "<" */,-23 , 22/* ">" */,-23 , 11/* "+" */,-23 , 12/* "-" */,-23 , 15/* "^" */,-23 , 24/* "||" */,-23 , 25/* "&&" */,-23 , 13/* "*" */,-23 , 14/* "/" */,-23 , 16/* "," */,-23 , 3/* ")" */,-23 ), + /* State 11 */ new Array( 28/* "$" */,-25 , 17/* "<=" */,-25 , 18/* ">=" */,-25 , 19/* "==" */,-25 , 20/* "!=" */,-25 , 21/* "<" */,-25 , 22/* ">" */,-25 , 11/* "+" */,-25 , 12/* "-" */,-25 , 15/* "^" */,-25 , 24/* "||" */,-25 , 25/* "&&" */,-25 , 13/* "*" */,-25 , 14/* "/" */,-25 , 16/* "," */,-25 , 3/* ")" */,-25 ), + /* State 12 */ new Array( 2/* "(" */,30 , 28/* "$" */,-27 , 17/* "<=" */,-27 , 18/* ">=" */,-27 , 19/* "==" */,-27 , 20/* "!=" */,-27 , 21/* "<" */,-27 , 22/* ">" */,-27 , 11/* "+" */,-27 , 12/* "-" */,-27 , 15/* "^" */,-27 , 24/* "||" */,-27 , 25/* "&&" */,-27 , 13/* "*" */,-27 , 14/* "/" */,-27 , 16/* "," */,-27 , 3/* ")" */,-27 ), + /* State 13 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 14 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 15 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 16 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 17 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 18 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 19 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 20 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 21 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 22 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 23 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 24 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 25 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 26 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,18 , 11/* "+" */,19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 16/* "," */,44 , 3/* ")" */,45 ), + /* State 27 */ new Array( 14/* "/" */,-11 , 13/* "*" */,-11 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-11 , 12/* "-" */,-11 , 11/* "+" */,-11 , 22/* ">" */,-11 , 21/* "<" */,-11 , 20/* "!=" */,-11 , 19/* "==" */,-11 , 18/* ">=" */,-11 , 17/* "<=" */,-11 , 28/* "$" */,-11 , 16/* "," */,-11 , 3/* ")" */,-11 ), + /* State 28 */ new Array( 14/* "/" */,-17 , 13/* "*" */,-17 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-17 , 11/* "+" */,-17 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-17 , 16/* "," */,-17 , 3/* ")" */,-17 ), + /* State 29 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 30 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 31 */ new Array( 14/* "/" */,-16 , 13/* "*" */,-16 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-16 , 11/* "+" */,-16 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-16 , 16/* "," */,-16 , 3/* ")" */,-16 ), + /* State 32 */ new Array( 14/* "/" */,-15 , 13/* "*" */,-15 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-15 , 11/* "+" */,-15 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-15 , 16/* "," */,-15 , 3/* ")" */,-15 ), + /* State 33 */ new Array( 14/* "/" */,-14 , 13/* "*" */,-14 , 25/* "&&" */,-14 , 24/* "||" */,-14 , 15/* "^" */,-14 , 12/* "-" */,-14 , 11/* "+" */,-14 , 22/* ">" */,-14 , 21/* "<" */,-14 , 20/* "!=" */,-14 , 19/* "==" */,-14 , 18/* ">=" */,-14 , 17/* "<=" */,-14 , 28/* "$" */,-14 , 16/* "," */,-14 , 3/* ")" */,-14 ), + /* State 34 */ new Array( 14/* "/" */,-13 , 13/* "*" */,-13 , 25/* "&&" */,-13 , 24/* "||" */,-13 , 15/* "^" */,-13 , 12/* "-" */,-13 , 11/* "+" */,-13 , 22/* ">" */,-13 , 21/* "<" */,-13 , 20/* "!=" */,-13 , 19/* "==" */,-13 , 18/* ">=" */,-13 , 17/* "<=" */,-13 , 28/* "$" */,-13 , 16/* "," */,-13 , 3/* ")" */,-13 ), + /* State 35 */ new Array( 14/* "/" */,-12 , 13/* "*" */,-12 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-12 , 12/* "-" */,-12 , 11/* "+" */,-12 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-12 , 16/* "," */,-12 , 3/* ")" */,-12 ), + /* State 36 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-10 , 11/* "+" */,-10 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-10 , 16/* "," */,-10 , 3/* ")" */,-10 ), + /* State 37 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-9 , 11/* "+" */,-9 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-9 , 16/* "," */,-9 , 3/* ")" */,-9 ), + /* State 38 */ new Array( 14/* "/" */,-8 , 13/* "*" */,-8 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-8 , 12/* "-" */,-8 , 11/* "+" */,-8 , 22/* ">" */,-8 , 21/* "<" */,-8 , 20/* "!=" */,-8 , 19/* "==" */,-8 , 18/* ">=" */,-8 , 17/* "<=" */,-8 , 28/* "$" */,-8 , 16/* "," */,-8 , 3/* ")" */,-8 ), + /* State 39 */ new Array( 14/* "/" */,-7 , 13/* "*" */,-7 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-7 , 12/* "-" */,-7 , 11/* "+" */,-7 , 22/* ">" */,-7 , 21/* "<" */,-7 , 20/* "!=" */,-7 , 19/* "==" */,-7 , 18/* ">=" */,-7 , 17/* "<=" */,-7 , 28/* "$" */,-7 , 16/* "," */,-7 , 3/* ")" */,-7 ), + /* State 40 */ new Array( 14/* "/" */,-6 , 13/* "*" */,-6 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-6 , 12/* "-" */,-6 , 11/* "+" */,-6 , 22/* ">" */,-6 , 21/* "<" */,-6 , 20/* "!=" */,-6 , 19/* "==" */,-6 , 18/* ">=" */,-6 , 17/* "<=" */,-6 , 28/* "$" */,-6 , 16/* "," */,-6 , 3/* ")" */,-6 ), + /* State 41 */ new Array( 14/* "/" */,-5 , 13/* "*" */,-5 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-5 , 12/* "-" */,-5 , 11/* "+" */,-5 , 22/* ">" */,-5 , 21/* "<" */,-5 , 20/* "!=" */,-5 , 19/* "==" */,-5 , 18/* ">=" */,-5 , 17/* "<=" */,-5 , 28/* "$" */,-5 , 16/* "," */,-5 , 3/* ")" */,-5 ), + /* State 42 */ new Array( 14/* "/" */,-4 , 13/* "*" */,-4 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-4 , 12/* "-" */,-4 , 11/* "+" */,-4 , 22/* ">" */,-4 , 21/* "<" */,-4 , 20/* "!=" */,-4 , 19/* "==" */,-4 , 18/* ">=" */,-4 , 17/* "<=" */,-4 , 28/* "$" */,-4 , 16/* "," */,-4 , 3/* ")" */,-4 ), + /* State 43 */ new Array( 14/* "/" */,-3 , 13/* "*" */,-3 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-3 , 12/* "-" */,-3 , 11/* "+" */,-3 , 22/* ">" */,-3 , 21/* "<" */,-3 , 20/* "!=" */,-3 , 19/* "==" */,-3 , 18/* ">=" */,-3 , 17/* "<=" */,-3 , 28/* "$" */,-3 , 16/* "," */,-3 , 3/* ")" */,-3 ), + /* State 44 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 45 */ new Array( 28/* "$" */,-18 , 17/* "<=" */,-18 , 18/* ">=" */,-18 , 19/* "==" */,-18 , 20/* "!=" */,-18 , 21/* "<" */,-18 , 22/* ">" */,-18 , 11/* "+" */,-18 , 12/* "-" */,-18 , 15/* "^" */,-18 , 24/* "||" */,-18 , 25/* "&&" */,-18 , 13/* "*" */,-18 , 14/* "/" */,-18 , 16/* "," */,-18 , 3/* ")" */,-18 ), + /* State 46 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-19 , 11/* "+" */,-19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-19 , 16/* "," */,-19 , 3/* ")" */,-19 ), + /* State 47 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,18 , 11/* "+" */,19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 3/* ")" */,49 ), + /* State 48 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,18 , 11/* "+" */,19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 3/* ")" */,50 ), + /* State 49 */ new Array( 28/* "$" */,-26 , 17/* "<=" */,-26 , 18/* ">=" */,-26 , 19/* "==" */,-26 , 20/* "!=" */,-26 , 21/* "<" */,-26 , 22/* ">" */,-26 , 11/* "+" */,-26 , 12/* "-" */,-26 , 15/* "^" */,-26 , 24/* "||" */,-26 , 25/* "&&" */,-26 , 13/* "*" */,-26 , 14/* "/" */,-26 , 16/* "," */,-26 , 3/* ")" */,-26 ), + /* State 50 */ new Array( 28/* "$" */,-2 , 17/* "<=" */,-2 , 18/* ">=" */,-2 , 19/* "==" */,-2 , 20/* "!=" */,-2 , 21/* "<" */,-2 , 22/* ">" */,-2 , 11/* "+" */,-2 , 12/* "-" */,-2 , 15/* "^" */,-2 , 24/* "||" */,-2 , 25/* "&&" */,-2 , 13/* "*" */,-2 , 14/* "/" */,-2 , 16/* "," */,-2 , 3/* ")" */,-2 ) + ); + + /* Goto-Table */ + var goto_tab = new Array( + /* State 0 */ new Array( 27/* p */,1 , 26/* e */,2 ), + /* State 1 */ new Array( ), + /* State 2 */ new Array( ), + /* State 3 */ new Array( 26/* e */,26 ), + /* State 4 */ new Array( 26/* e */,27 ), + /* State 5 */ new Array( 26/* e */,28 ), + /* State 6 */ new Array( ), + /* State 7 */ new Array( ), + /* State 8 */ new Array( ), + /* State 9 */ new Array( ), + /* State 10 */ new Array( ), + /* State 11 */ new Array( ), + /* State 12 */ new Array( ), + /* State 13 */ new Array( 26/* e */,31 ), + /* State 14 */ new Array( 26/* e */,32 ), + /* State 15 */ new Array( 26/* e */,33 ), + /* State 16 */ new Array( 26/* e */,34 ), + /* State 17 */ new Array( 26/* e */,35 ), + /* State 18 */ new Array( 26/* e */,36 ), + /* State 19 */ new Array( 26/* e */,37 ), + /* State 20 */ new Array( 26/* e */,38 ), + /* State 21 */ new Array( 26/* e */,39 ), + /* State 22 */ new Array( 26/* e */,40 ), + /* State 23 */ new Array( 26/* e */,41 ), + /* State 24 */ new Array( 26/* e */,42 ), + /* State 25 */ new Array( 26/* e */,43 ), + /* State 26 */ new Array( ), + /* State 27 */ new Array( ), + /* State 28 */ new Array( ), + /* State 29 */ new Array( 26/* e */,46 ), + /* State 30 */ new Array( 26/* e */,47 ), + /* State 31 */ new Array( ), + /* State 32 */ new Array( ), + /* State 33 */ new Array( ), + /* State 34 */ new Array( ), + /* State 35 */ new Array( ), + /* State 36 */ new Array( ), + /* State 37 */ new Array( ), + /* State 38 */ new Array( ), + /* State 39 */ new Array( ), + /* State 40 */ new Array( ), + /* State 41 */ new Array( ), + /* State 42 */ new Array( ), + /* State 43 */ new Array( ), + /* State 44 */ new Array( 26/* e */,48 ), + /* State 45 */ new Array( ), + /* State 46 */ new Array( ), + /* State 47 */ new Array( ), + /* State 48 */ new Array( ), + /* State 49 */ new Array( ), + /* State 50 */ new Array( ) + ); + + + + /* Symbol labels */ + var labels = new Array( + "p'" /* Non-terminal symbol */, + "WHITESPACE" /* Terminal symbol */, + "(" /* Terminal symbol */, + ")" /* Terminal symbol */, + "INT" /* Terminal symbol */, + "FLOAT" /* Terminal symbol */, + "PARAM" /* Terminal symbol */, + "VAR" /* Terminal symbol */, + "HTML" /* Terminal symbol */, + "STRING" /* Terminal symbol */, + "COMMAND" /* Terminal symbol */, + "+" /* Terminal symbol */, + "-" /* Terminal symbol */, + "*" /* Terminal symbol */, + "/" /* Terminal symbol */, + "^" /* Terminal symbol */, + "," /* Terminal symbol */, + "<=" /* Terminal symbol */, + ">=" /* Terminal symbol */, + "==" /* Terminal symbol */, + "!=" /* Terminal symbol */, + "<" /* Terminal symbol */, + ">" /* Terminal symbol */, + "!" /* Terminal symbol */, + "||" /* Terminal symbol */, + "&&" /* Terminal symbol */, + "e" /* Non-terminal symbol */, + "p" /* Non-terminal symbol */, + "$" /* Terminal symbol */ + ); + + + + info.offset = 0; + info.src = src; + info.att = new String(); + + if( !err_off ) + err_off = new Array(); + if( !err_la ) + err_la = new Array(); + + sstack.push( 0 ); + vstack.push( 0 ); + + la = __lex( info ); + + while( true ) + { + act = 52; + for( var i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 ) + { + if( act_tab[sstack[sstack.length-1]][i] == la ) + { + act = act_tab[sstack[sstack.length-1]][i+1]; + break; + } + } + + if( _dbg_withtrace && sstack.length > 0 ) + { + __dbg_print( "\nState " + sstack[sstack.length-1] + "\n" + + "\tLookahead: " + labels[la] + " (\"" + info.att + "\")\n" + + "\tAction: " + act + "\n" + + "\tSource: \"" + info.src.substr( info.offset, 30 ) + ( ( info.offset + 30 < info.src.length ) ? + "..." : "" ) + "\"\n" + + "\tStack: " + sstack.join() + "\n" + + "\tValue stack: " + vstack.join() + "\n" ); + } + + + //Panic-mode: Try recovery when parse-error occurs! + if( act == 52 ) + { + if( _dbg_withtrace ) + __dbg_print( "Error detected: There is no reduce or shift on the symbol " + labels[la] ); + + err_cnt++; + err_off.push( info.offset - info.att.length ); + err_la.push( new Array() ); + for( var i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 ) + err_la[err_la.length-1].push( labels[act_tab[sstack[sstack.length-1]][i]] ); + + //Remember the original stack! + var rsstack = new Array(); + var rvstack = new Array(); + for( var i = 0; i < sstack.length; i++ ) + { + rsstack[i] = sstack[i]; + rvstack[i] = vstack[i]; + } + + while( act == 52 && la != 28 ) + { + if( _dbg_withtrace ) + __dbg_print( "\tError recovery\n" + + "Current lookahead: " + labels[la] + " (" + info.att + ")\n" + + "Action: " + act + "\n\n" ); + if( la == -1 ) + info.offset++; + + while( act == 52 && sstack.length > 0 ) + { + sstack.pop(); + vstack.pop(); + + if( sstack.length == 0 ) + break; + + act = 52; + for( var i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 ) + { + if( act_tab[sstack[sstack.length-1]][i] == la ) + { + act = act_tab[sstack[sstack.length-1]][i+1]; + break; + } + } + } + + if( act != 52 ) + break; + + for( var i = 0; i < rsstack.length; i++ ) + { + sstack.push( rsstack[i] ); + vstack.push( rvstack[i] ); + } + + la = __lex( info ); + } + + if( act == 52 ) + { + if( _dbg_withtrace ) + __dbg_print( "\tError recovery failed, terminating parse process..." ); + break; + } + + + if( _dbg_withtrace ) + __dbg_print( "\tError recovery succeeded, continuing" ); + } + + /* + if( act == 52 ) + break; + */ + + + //Shift + if( act > 0 ) + { + if( _dbg_withtrace ) + __dbg_print( "Shifting symbol: " + labels[la] + " (" + info.att + ")" ); + + sstack.push( act ); + vstack.push( info.att ); + + la = __lex( info ); + + if( _dbg_withtrace ) + __dbg_print( "\tNew lookahead symbol: " + labels[la] + " (" + info.att + ")" ); + } + //Reduce + else + { + act *= -1; + + if( _dbg_withtrace ) + __dbg_print( "Reducing by producution: " + act ); + + rval = void(0); + + if( _dbg_withtrace ) + __dbg_print( "\tPerforming semantic action..." ); + + switch( act ) + { + case 0: + { + rval = vstack[ vstack.length - 1 ]; + } + break; + case 1: + { + rval = JXG.GeogebraReader.ggbAct('end', vstack[ vstack.length - 1 ]); + } + break; + case 2: + { + rval = JXG.GeogebraReader.ggbAct('coord', vstack[ vstack.length - 4 ], vstack[ vstack.length - 2 ], element); + } + break; + case 3: + { + rval = JXG.GeogebraReader.ggbAct('le', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 4: + { + rval = JXG.GeogebraReader.ggbAct('ge', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 5: + { + rval = JXG.GeogebraReader.ggbAct('eq', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 6: + { + rval = JXG.GeogebraReader.ggbAct('neq', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 7: + { + rval = JXG.GeogebraReader.ggbAct('lt', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 8: + { + rval = JXG.GeogebraReader.ggbAct('gt', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 9: + { + rval = JXG.GeogebraReader.ggbAct('add', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 10: + { + rval = JXG.GeogebraReader.ggbAct('sub', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 11: + { + rval = JXG.GeogebraReader.ggbAct('neg', vstack[ vstack.length - 1 ]); + } + break; + case 12: + { + rval = JXG.GeogebraReader.ggbAct('pow', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 13: + { + rval = JXG.GeogebraReader.ggbAct('or', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 14: + { + rval = JXG.GeogebraReader.ggbAct('and', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 15: + { + rval = JXG.GeogebraReader.ggbAct('mul', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 16: + { + rval = JXG.GeogebraReader.ggbAct('div', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 17: + { + rval = JXG.GeogebraReader.ggbAct('negmult', vstack[ vstack.length - 1 ]); + } + break; + case 18: + { + rval = JXG.GeogebraReader.ggbAct('bra', vstack[ vstack.length - 2 ]); + } + break; + case 19: + { + rval = JXG.GeogebraReader.ggbAct('string', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 20: + { + rval = JXG.GeogebraReader.ggbAct('int', vstack[ vstack.length - 1 ]); + } + break; + case 21: + { + rval = JXG.GeogebraReader.ggbAct('float', vstack[ vstack.length - 1 ]); + } + break; + case 22: + { + rval = JXG.GeogebraReader.ggbAct('param', vstack[ vstack.length - 1 ]); + } + break; + case 23: + { + rval = JXG.GeogebraReader.ggbAct('html', vstack[ vstack.length - 1 ]); + } + break; + case 24: + { + rval = JXG.GeogebraReader.ggbAct('string', vstack[ vstack.length - 1 ]); + } + break; + case 25: + { + rval = JXG.GeogebraReader.ggbAct('command', vstack[ vstack.length - 1 ]); + } + break; + case 26: + { + rval = JXG.GeogebraReader.ggbAct('var', vstack[ vstack.length - 4 ], vstack[ vstack.length - 2 ]); + } + break; + case 27: + { + rval = JXG.GeogebraReader.ggbAct('var', vstack[ vstack.length - 1 ]); + } + break; + } + + + + if( _dbg_withtrace ) + __dbg_print( "\tPopping " + pop_tab[act][1] + " off the stack..." ); + + for( var i = 0; i < pop_tab[act][1]; i++ ) + { + sstack.pop(); + str = vstack.pop(); + } + + go = -1; + for( var i = 0; i < goto_tab[sstack[sstack.length-1]].length; i+=2 ) + { + if( goto_tab[sstack[sstack.length-1]][i] == pop_tab[act][0] ) + { + go = goto_tab[sstack[sstack.length-1]][i+1]; + break; + } + } + + if( act == 0 ) + break; + + if( _dbg_withtrace ) + __dbg_print( "\tPushing non-terminal " + labels[ pop_tab[act][0] ] ); + + sstack.push( go ); + vstack.push( rval ); + } + + if( _dbg_withtrace ) + { + JXG.debug( _dbg_string ); + _dbg_string = new String(); + } + } + + if( _dbg_withtrace ) + { + __dbg_print( "\nParse complete." ); + JXG.debug( _dbg_string ); + } + + return err_cnt; + } +/***** end replace *****/ + + var error_offsets = new Array(); + var error_lookaheads = new Array(); + var error_count = 0; + var str = exp; + if( ( error_count = __parse( str, error_offsets, error_lookaheads ) ) > 0 ) { + var errstr = new String(); + for( var i = 0; i < error_count; i++ ) + errstr += "Parse error in line " + ( str.substr( 0, error_offsets[i] ).match( /\n/g ) ? + str.substr( 0, error_offsets[i] ).match( /\n/g ).length : 1 ) + + " near \"" + str.substr( error_offsets[i] ) + "\", expecting \"" + error_lookaheads[i].join() + "\"\n" ; + JXG.debug( errstr ); + } + + return str; +}; //end: ggbParse() + + +/** + * Override JSxGraph defaults with Geogebra settings + * @param {Object} board object + * @return {Object} board oject + */ +this.setDefaultOptions = function(board){ + board.options.elements.strokeWidth = '1px'; // TODO: board.options.line.strokeWidth + board.options.elements.withLabel = true; + + board.options.point.face = 'circle'; + board.options.point.size = 3; + board.options.point.fillColor = 'blue'; + board.options.point.fillOpacity = 1; + board.options.point.highlightFillOpacity = 1; + board.options.point.strokeColor = 'black'; + board.options.point.highlightStrokeColor = 'black'; + board.options.point.strokeWidth = '2px'; + + board.options.line.strokeWidth = '1px'; + board.options.line.highlightStrokeColor = '#000000'; + board.options.line.strokeColor = '#000000'; + + board.options.polygon.fillColor = JXG.rgb2hex(153, 51, 0); + board.options.polygon.fillOpacity = 0.1; + board.options.polygon.highlightFillColor = board.options.polygon.fillColor; + board.options.polygon.highlightFillOpacity = 0.1; + + board.options.sector.fillColor = JXG.rgb2hex(153, 51, 0); + board.options.sector.fillOpacity = 0.1; + board.options.sector.highlightFillColor = board.options.sector.fillColor; + board.options.sector.highlightFillOpacity = 0.1; + + board.options.angle.fillColor = JXG.rgb2hex(0, 100, 0); + board.options.angle.fillOpacity = 0.1; + //board.options.angle.highlightFillColor = board.options.angle.fillColor; + board.options.angle.highlightFillOpacity = 0.1; + + return board; +}; + +/** + * Set color properties of a geogebra element. + * Set stroke, fill, lighting, label and draft color attributes. + * @param {Object} gxtEl element of which attributes are to set + * @param {Object} attr object carrying all necessary attribute values + * @return {Object} returning the updated attr-attributes object + */ +this.colorProperties = function(Data, attr) { + var a,r,g,b; + a = (Data.getElementsByTagName("objColor").length > 0 && Data.getElementsByTagName("objColor")[0].getAttribute("alpha")) ? parseFloat(Data.getElementsByTagName("objColor")[0].getAttribute("alpha")) : 0; + r = (Data.getElementsByTagName("objColor").length > 0 && Data.getElementsByTagName("objColor")[0].getAttribute("r")) ? parseInt(Data.getElementsByTagName("objColor")[0].getAttribute("r")).toString(16) : 0; + g = (Data.getElementsByTagName("objColor").length > 0 && Data.getElementsByTagName("objColor")[0].getAttribute("g")) ? parseInt(Data.getElementsByTagName("objColor")[0].getAttribute("g")).toString(16) : 0; + b = (Data.getElementsByTagName("objColor").length > 0 && Data.getElementsByTagName("objColor")[0].getAttribute("b")) ? parseInt(Data.getElementsByTagName("objColor")[0].getAttribute("b")).toString(16) : 0; + if (r.length == 1) r = '0' + r; + if (g.length == 1) g = '0' + g; + if (b.length == 1) b = '0' + b; + + attr.fillColor = '#'+ r + g + b; + attr.strokeColor = attr.fillColor; + attr.highlightFillColor = attr.fillColor; + attr.highlightStrokeColor = attr.strokeColor; + attr.fillOpacity = a; + attr.highlightFillOpacity = a; + attr.labelColor = attr.fillColor; + + return attr; +}; + +/** + * Set the board properties. + * Set active, area, dash, draft and showinfo attributes. + * @param {Object} gxtEl element of which attributes are to set + * @param {Object} Data element of which attributes are to set + * @param {Object} attr object containing the necessary attribute values + */ +this.boardProperties = function(gxtEl, Data, attr) { + return attr; +}; + +/** + * @param {Object} gxtEl element of which attributes are to set + * @param {Object} Data element of which attributes are to set + * @return {Object} updated element + */ +this.coordinates = function(gxtEl, Data) { + var labelOffset = {}, tmp; + labelOffset.x = 0; labelOffset.y = 0; labelOffset.z = 0; + + if(Data.getElementsByTagName('labelOffset')[0]) { + // tmp = new JXG.Coords(JXG.COORDS_BY_SCREEN, [, + // parseFloat(Data.getElementsByTagName("labelOffset")[0].attributes["y"].value)], JXG.GeogebraReader.board); + labelOffset.x = parseFloat(Data.getElementsByTagName("labelOffset")[0].getAttribute("x"))/JXG.GeogebraReader.board.unitX; + labelOffset.y = parseFloat(Data.getElementsByTagName("labelOffset")[0].getAttribute("y"))/JXG.GeogebraReader.board.unitY; + } + + if(Data.getElementsByTagName("coords")[0]) { + gxtEl.x = parseFloat(Data.getElementsByTagName("coords")[0].getAttribute("x")); + gxtEl.y = parseFloat(Data.getElementsByTagName("coords")[0].getAttribute("y")); + gxtEl.z = parseFloat(Data.getElementsByTagName("coords")[0].getAttribute("z")); + } else if(Data.getElementsByTagName("startPoint")[0]) { + if(Data.getElementsByTagName("startPoint")[0].getAttribute('exp')) { + var a = JXG.getRef(JXG.GeogebraReader.board, Data.getElementsByTagName("startPoint")[0].getAttribute('exp')); + gxtEl.x = function() {return a.X()+labelOffset.x;}; + gxtEl.y = function() {return a.Y()-labelOffset.y;}; // minus because geogebra starts on the other side + gxtEl.z = false; + } else { + gxtEl.x = parseFloat(Data.getElementsByTagName("startPoint")[0].getAttribute("x")); + gxtEl.y = parseFloat(Data.getElementsByTagName("startPoint")[0].getAttribute("y")); + gxtEl.z = parseFloat(Data.getElementsByTagName("startPoint")[0].getAttribute("z")); + } + } else if(Data.getElementsByTagName("absoluteScreenLocation")[0]) { + var tmp = new JXG.Coords(JXG.COORDS_BY_SCREEN, [parseFloat(Data.getElementsByTagName("absoluteScreenLocation")[0].getAttribute("x")), + parseFloat(Data.getElementsByTagName("absoluteScreenLocation")[0].getAttribute("y"))], JXG.GeogebraReader.board); + gxtEl.x = tmp.usrCoords[1]+labelOffset.x; + gxtEl.y = tmp.usrCoords[2]+labelOffset.y; + gxtEl.z = false; + } else { + return false; + } + + return gxtEl; +}; + +/** + * Writing element attributes to the given object + * @param {XMLNode} Data expects the content of the current element + * @return {Object} object with according attributes + */ +this.visualProperties = function(Data, attr) { + (Data.getElementsByTagName("show").length != 0 && Data.getElementsByTagName("show")[0].getAttribute("object")) ? attr.visible = Data.getElementsByTagName("show")[0].getAttribute("object") : false; + (Data.getElementsByTagName("show").length != 0 && Data.getElementsByTagName("show")[0].getAttribute("label")) ? attr.withLabel = Data.getElementsByTagName("show")[0].getAttribute("label") : true; + if(attr.withLabel == 'true') { + attr.withLabel = true; + } + else if(attr.withLabel == 'false') { + attr.withLabel = false; + } + (Data.getElementsByTagName('pointSize')[0]) ? attr.size = Data.getElementsByTagName('pointSize')[0].getAttribute("val") : false; + (Data.getElementsByTagName('pointStyle')[0]) ? attr.styleGGB = Data.getElementsByTagName('pointStyle')[0].getAttribute("val") : false; + if(attr.styleGGB == 0 || attr.styleGGB == 2) { + attr.face = 'circle'; + if(attr.styleGGB == 0) { + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + attr.highlightFillColor = attr.strokeColor; + attr.highlightFillOpacity = 1; + attr.strokeColor = 'black'; + attr.strokeWidth = '1px'; + } + else if(attr.styleGGB == 2) { + attr.fillColor = 'none'; + } + } + else if(attr.styleGGB == 1) { + attr.face = 'x'; + } + else if(attr.styleGGB == 3) { + attr.face = '+'; + attr.strokeOpacity = 1; + } + else if(attr.styleGGB == 4 || attr.styleGGB == 5) { + attr.face = 'diamond'; + if(attr.styleGGB == 4) { + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + } + else if(attr.styleGGB == 5) { + attr.fillColor = 'none'; + } + } + else if(attr.styleGGB == 6) { + attr.face = 'triangleUp'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + } + else if(attr.styleGGB == 7) { + attr.face = 'triangleDown'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + } + else if(attr.styleGGB == 8) { + attr.face = 'triangleRight'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + } + else if(attr.styleGGB == 9) { + attr.face = 'triangleLeft'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + } + (Data.getElementsByTagName('slopeTriangleSize')[0]) ? attr.slopeWidth = Data.getElementsByTagName('slopeTriangleSize')[0].getAttribute("val") : false; + (Data.getElementsByTagName('lineStyle')[0]) ? attr.strokeWidth = (Data.getElementsByTagName('lineStyle')[0].getAttribute("thickness")/2.0)+'px' : false; + if(attr.strokeWidth) { + attr.highlightStrokeWidth = (1*attr.strokeWidth.substr(0,attr.strokeWidth.length-2)+1)+'px'; + } + (Data.getElementsByTagName('lineStyle')[0]) ? attr.dashGGB = Data.getElementsByTagName('lineStyle')[0].getAttribute("type") : false; + + if(attr.dashGGB == 0) { + attr.dash = 0; + } + else if(attr.dashGGB == 10) { + attr.dash = 2; + } + else if(attr.dashGGB == 15) { + attr.dash = 3; + } + else if(attr.dashGGB == 20) { + attr.dash = 1; + } + else if(attr.dashGGB == 30) { + attr.dash = 6; + } + (Data.getElementsByTagName("labelOffset")[0]) ? attr.labelX = 1*Data.getElementsByTagName("labelOffset")[0].getAttribute("x") : false; + (Data.getElementsByTagName("labelOffset")[0]) ? attr.labelY = 1*Data.getElementsByTagName("labelOffset")[0].getAttribute("y") : false; + (Data.getElementsByTagName("trace")[0]) ? attr.trace = Data.getElementsByTagName("trace")[0].getAttribute("val") : false; + (Data.getElementsByTagName('fix')[0]) ? attr.fixed = Data.getElementsByTagName('fix')[0].getAttribute("val") : false; + return attr; +}; + +/** + * Searching for an element in the geogebra tree + * @param {String} the name of the element to search for + * @param {Boolean} whether it is search for an expression or not + * @return {Object} object with according label + */ +this.getElement = function(name, expr) { + var Data, i, j; + expr = expr || false; + for(i=0; i -1 || s[i].search(/[0-9]+$/) > -1 || s[i].search(/[a-zA-Z]+(\_*[a-zA-Z0-9]+)*$/) > -1) + if(s[i+1].search(/^\(/) > -1 || + s[i+1].search(/^[0-9]+/) > -1 || + s[i+1].search(/^[a-zA-Z]+(\_*[a-zA-Z0-9]+)*/) > -1 || + s[i+1].search(/\_\_[a-zA-Z0-9]+/) > -1) { + s[i] = s[i] + "*"; + } + o += s[i]; + }; + expr = o; + } + + output.push(expr); + return output; + } else { + return exp; + } + break; + case 's': + exp = exp.replace(/(?![e])x(?!\()(?![p])/g, '__x'); + return ['__x', exp]; + break; + default: + if(JXG.GeogebraReader.format <= 3.01) { + // prepare string: "solve" multiplications 'a b' to 'a*b' + s = exp.split(' '); + o = ''; + for(i=0; i -1 || s[i].search(/[0-9]+$/) > -1 || s[i].search(/[a-zA-Z]+(\_*[a-zA-Z0-9]+)*$/) > -1) + if(s[i+1].search(/^\(/) > -1 || + s[i+1].search(/^[0-9]+/) > -1 || + s[i+1].search(/^[a-zA-Z]+(\_*[a-zA-Z0-9]+)*/) > -1 || + s[i+1].search(/\_\_[a-zA-Z0-9]+/) > -1) { + s[i] = s[i] + "*"; + } + o += s[i]; + }; + exp = o; + } + return exp; + break; + } +}; + +/** + * Searching for an element in the geogebra tree + * @param {Object} board object + */ +this.writeBoard = function(board) { + var boardData = JXG.GeogebraReader.tree.getElementsByTagName("euclidianView")[0]; + + board.origin = {}; + board.origin.usrCoords = [1, 0, 0]; + board.origin.scrCoords = [1, 1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("xZero"), 1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("yZero")]; + board.unitX = (boardData.getElementsByTagName("coordSystem")[0].getAttribute("scale")) ? 1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("scale") : 1; + board.unitY = (boardData.getElementsByTagName("coordSystem")[0].getAttribute("yscale")) ? 1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("yscale") : board.unitX; + + board.fontSize = (JXG.GeogebraReader.tree.getElementsByTagName("gui")[0] && JXG.GeogebraReader.tree.getElementsByTagName("gui")[0].getElementsByTagName("font")[0]) ? 1*JXG.GeogebraReader.tree.getElementsByTagName("gui")[0].getElementsByTagName("font")[0].getAttribute("size") : '12px'; + + JXG.JSXGraph.boards[board.id] = board; + + // Update of properties during update() is not necessary in GEONExT files + board.renderer.enhancedRendering = true; + + // snap to point + var snapToPoint = (boardData.getElementsByTagName('evSettings')[0].getAttribute("pointCapturing") == "true"); + + var grid = (boardData.getElementsByTagName('evSettings')[0].getAttribute("grid") == "true") ? board.create('grid') : null; + + if(boardData.getElementsByTagName('evSettings')[0].getAttribute("axes") && boardData.getElementsByTagName('evSettings')[0].getAttribute("axes") == "true") { + board.ggbElements["xAxis"] = board.create('axis', [[0, 0], [1, 0]], {strokeColor:'black', minorTicks: 0}); + board.ggbElements["yAxis"] = board.create('axis', [[0, 0], [0, 1]], {strokeColor:'black', minorTicks: 0}); + } +}; + +/** + * Searching for an element in the geogebra tree + * @param {Object} board object + * @param {Object} ggb element whose attributes are to parse + * @param {Array} input list of all input elements + * @param {String} typeName output construction method + * @return {Object} return newly created element or false + */ +this.writeElement = function(board, output, input, cmd) { + var element, gxtEl, attr, p, exp, coord, type, points, border, length, m, s, e, sx, sy, ex, ey, func, range; + element = (JXG.isArray(output)) ? output[0] : output; + + gxtEl = {}; // geometric element + attr = {}; // Attributes of geometric elements + + JXG.debug(element); + + gxtEl.type = (element && element.attributes && typeof cmd === 'undefined') ? element.getAttribute('type').toLowerCase() : cmd; + gxtEl.label = element.getAttribute('label'); + attr.name = gxtEl.label; + + JXG.debug("
Konstruiere "+ attr.name +"("+ gxtEl.type +"):"); + + switch(gxtEl.type) { + case 'point': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + if(JXG.GeogebraReader.getElement(attr.name, true)) { + exp = JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp'); + coord = JXG.GeogebraReader.ggbParse(exp); + gxtEl.x = new Function('return '+ coord[0] +';'); + gxtEl.y = new Function('return '+ coord[1] +';'); + } else { + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + } + if(!JXG.exists(attr.styleGGB)) { + attr.face = 'circle'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + attr.highlightFillColor = attr.strokeColor; + attr.highlightFillOpacity = 1; + attr.strokeColor = 'black'; + attr.strokeWidth = '1px'; + } + + JXG.debug(gxtEl); + JXG.debug(input); + + try { + var ma = /Circle\[\s*(\w+)\s*,\s*([\d\.]+)\s*\]/.exec(input); + if(typeof input != 'undefined') { + if (ma!=null && ma.length==3) { + // from Circle[A, 5] take "A" and "5", stored in ma[1] and ma[2] + var q = JXG.GeogebraReader.checkElement(ma[1]); + var c = board.create('circle', [q, parseFloat(ma[2])], {fillColor:'none',visible:false,name:''}); + p = board.create('glider', [gxtEl.x, gxtEl.y, c], attr); + } else if(JXG.isArray(input)) { + p = board.create('glider', [gxtEl.x, gxtEl.y, input[0]], attr); + } else { + p = board.create('glider', [gxtEl.x, gxtEl.y, input], attr); + } + } else { + p = board.create('point', [gxtEl.x, gxtEl.y], attr); + } + return p; + } catch(e) { + JXG.debug("* Err: Point " + attr.name +"
\n"); + return false; + } + break; + case 'segment': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Segment: ("+ attr.name +") First: " + input[0].name + ", Last: " + input[1].name + "
\n"); + attr.straightFirst = false; + attr.straightLast = false; + p = board.create('line', input, attr); + return p; + } catch(e) { + JXG.debug("* Err: Segment " + attr.name +" First: " + input[0].name + ", Last: " + input[1].name + "
\n"); + return false; + } + break; + case 'line': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + type = 'line'; + if(!input) { + input = [ parseFloat(element.getElementsByTagName('coords')[0].getAttribute('z')), + parseFloat(element.getElementsByTagName('coords')[0].getAttribute('x')), + parseFloat(element.getElementsByTagName('coords')[0].getAttribute('y')) + ]; + } else if (JXG.getRef(board, input[1].id).elementClass == JXG.OBJECT_CLASS_LINE) { + type = 'parallel'; // Parallele durch Punkt + } + + try { + p = board.create(type, input, attr); + return p; + } catch(e) { + JXG.debug("* Err: Line " + attr.label +"
\n"); + return false; + } + break; + case "orthogonalline": + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Orthogonalline: First: " + input[0].id + ", Last: " + input[1].id + "
\n"); + p = board.create('normal', input, attr); + return p; + } catch(e) { + JXG.debug("* Err: Orthogonalline " + attr.label +"
\n"); + return false; + } + break; + case "polygon": + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + // test if polygon is regular + if(input.length == 3 && output.length != 4) { + input[2] = parseInt(input[2]); + type = 'regular'; + } + + try { + JXG.debug("* Polygon: First: " + input[0].name + ", Second: " + input[1].name + ", Third: " + input[2] + "
\n"); + + var borders = []; + var borderatts = []; + length = (type == 'regular') ? output.length-input[2]+2 : output.length; + + for(var i=1; iErr: Polygon " + attr.name +"
\n"); + return false; + } + break; + case 'intersect': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Intersection: First: " + input[0].name + ", Second: " + input[1].name + "
\n"); + if(!JXG.exists(attr.styleGGB)) { + attr.face = 'circle'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + attr.highlightFillColor = attr.strokeColor; + attr.highlightFillOpacity = 1; + attr.strokeColor = 'black'; + attr.strokeWidth = '1px'; + } + if(output.length == 1) { + p = board.create('intersection', [input[0], input[1], 0], attr); + } + else { + p = board.create('intersection', [input[0], input[1], 1], attr); + var attr2 = {}; + attr2 = JXG.GeogebraReader.colorProperties(output[1], attr2); + attr2 = JXG.GeogebraReader.visualProperties(output[1], attr2); + attr2.name = output[1].getAttribute('label'); + var p2 = board.create('otherintersection', [input[0], input[1], p], attr2); + board.ggbElements[attr2.name] = p2; + } + + return p; + } catch(e) { + JXG.debug("* Err: Intersection " + attr.name +"
\n"); + return false; + } + break; + case 'distance': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + + try { + JXG.debug("* Distance: First: " + input[0].name + ", Second: " + input[1].name + "
\n"); + + if(false && output[0].getAtribute('type') && output[0].getAttribute('type') == 'numeric') { + input[1].Value = function(){ return this.X(); }; + p = input[1]; + board.elementsByName[attr.name] = p; + } else { + m = board.create('midpoint', input, {visible: 'false'}); + attr.visible = 'true'; + p = board.create('text', [function(){return m.X();}, function(){return m.Y();}, function(){ + return ""+ input[0].name + input[1].name +" = " + + JXG.trimNumber(JXG.getRef(board, input[0].id).Dist(JXG.getRef(board, input[1].id)).toFixed(JXG.GeogebraReader.decimals)); + }], attr); + p.Value = function () { + return (JXG.getRef(board, input[0].id).Dist(JXG.getRef(board, input[1].id))); + } + } + return p; + } catch(e) { + JXG.debug("* Err: Distance " + attr.name +"
\n"); + return false; + } + break; + case 'vector': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + if(element.getElementsByTagName("startPoint")[0]) { + + if(input && input.length == 2) { + e = JXG.GeogebraReader.checkElement(input[1].name); + } else { + e = [parseFloat(element.getElementsByTagName("coords")[0].getAttribute("x")), parseFloat(element.getElementsByTagName("coords")[0].getAttribute("y"))]; + } + if(element.getElementsByTagName("startPoint")[0].getAttribute("x") && element.getElementsByTagName("startPoint")[0].getAttribute("y")) { + s = [parseFloat(element.getElementsByTagName("startPoint")[0].getAttribute("x")), parseFloat(element.getElementsByTagName("startPoint")[0].getAttribute("y"))]; + } else if(element.getElementsByTagName("startPoint")[0].getAttribute("exp")) { + var startpoint = element.getElementsByTagName("startPoint")[0].getAttribute("exp"); + s = JXG.GeogebraReader.checkElement(startpoint); + } + } else if(input && input.length != 0) { + s = input[0]; + e = input[1]; + } else { + exp = JXG.GeogebraReader.getElement(element.getAttribute('label'), true); + if(exp) {// experimental + exp = exp.getAttribute('exp'); + // exp = JXG.GeogebraReader.functionParse('', exp); + exp = JXG.GeogebraReader.ggbParse(exp); + if (JXG.isArray(exp)) + exp = new Array(new Function('return '+ exp[1] +';'), new Function('return '+ exp[2] +';')); + else + exp = new Function('return '+ exp +';'); + JXG.debug('exp: '+ exp); + p = board.create('arrow', [[0,0], [exp[0], exp[1]]], attr); + return p; + //t = JXG.getRef(board, 'a'); + //s = t.point1; + // var e = [-1*vector.point2.X(), -1*vector.point2.Y()]; + // attr.type = 'rotate'; + // var angle; + // if(exp < 0) { + // angle = Math.PI; + // } else if(exp == 0) { + // angle = 0; + // } else { + // angle = Math.PI/exp; + // } + // needed: a clean rotating based on factor 'exp' + + // priorization of expression like 't*a' --> a := startPoint + } + } + + try { + JXG.debug("* Vector: First: " + attr.name); + p = board.create('arrow', [s, e], attr); + return p; + } catch(e) { + JXG.debug("* Err: Vector " + attr.name + e +"
\n"); + return false; + } + break; + case 'rotate': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Rotate: First: " + input[0].name + ", Second: " + input[1] + "
\n"); + attr.type = 'rotate'; + + if(!JXG.exists(attr.styleGGB)) { + attr.face = 'circle'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + attr.highlightFillColor = attr.strokeColor; + attr.highlightFillOpacity = 1; + attr.strokeColor = 'black'; + attr.strokeWidth = '1px'; + } + + t = board.create('transform', [parseInt(input[1])*Math.PI/180, input[2]], {type:'rotate'}); + p = board.create('point', [input[0], t], attr); + return p; + } catch(e) { + JXG.debug("* Err: Rotate " + attr.name +"
\n"); + return false; + } + break; + case 'dilate': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Dilate: First: " + input[0].name + ", Second: " + input[1] + "
\n"); + attr.type = 'rotate'; + var d = parseInt(input[1]); + var d1 = board.create('transform', [d, d], {type:'scale'}); + var d2 = board.create('transform', [function() { return (1-d) * input[2].X(); }, + function() { return (1-d) * input[2].Y(); }], {type:'translate'}); + + if(!JXG.exists(attr.styleGGB)) { + attr.face = 'circle'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + attr.highlightFillColor = attr.strokeColor; + attr.highlightFillOpacity = 1; + attr.strokeColor = 'black'; + attr.strokeWidth = '1px'; + } + p = board.create('point', [input[0], [d1, d2]], attr); + + return p; + } catch(e) { + JXG.debug("* Err: Dilate " + attr.name +"
\n"); + return false; + } + break; + case 'translate': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + t = board.create('transform', [function() { return input[1].point2.X()-input[1].point1.X(); }, + function() { return input[1].point2.Y()-input[1].point1.Y(); }], {type:'translate'}); + if(!JXG.exists(attr.styleGGB)) { + attr.face = 'circle'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + attr.highlightFillColor = attr.strokeColor; + attr.highlightFillOpacity = 1; + attr.strokeColor = 'black'; + attr.strokeWidth = '1px'; + } + p = board.create('point', [input[0], t], attr); + return p; + } catch(e) { + JXG.debug("* Err: Translate " + attr.name +"
\n"); + return false; + } + break; + case 'mirror': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + if (JXG.isPoint(JXG.getRef(board, input[1].id))) var type = 'mirrorpoint'; // Punktspiegelung + else if(JXG.getRef(board, input[1].id).elementClass == JXG.OBJECT_CLASS_LINE) var type = 'reflection'; // Geradenspiegelung + + try { + JXG.debug("* Mirror: First: " + input[0].name + ", Second: " + input[1].name + "
\n"); + p = board.create(type, [input[1], input[0]], attr); + return p; + } catch(e) { + JXG.debug("* Err: Mirror " + attr.name +"
\n"); + return false; + } + break; + case 'circle': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Circle: First: " + input[0].name + ", Second: " + input[1] + "
\n"); + p = board.create('circle', input, attr); + return p; + } catch(e) { + JXG.debug("* Err: Circle " + attr.name +"
\n"); + return false; + } + break; + case 'circlearc': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* CircleArc: First: " + input[0].name + ", Second: " + input[1].name + "
\n"); + p = board.create('arc', input, attr); + return p; + } catch(e) { + JXG.debug("* Err: CircleArc " + attr.name +"
\n"); + return false; + } + break; + case 'ellipse': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Ellipse: First: " + input[0].name + ", Second: " + input[1].name + ", Third: "+ input[2] +"
\n"); + // if third parameters is the major axis, else the third parameter is a point + if(parseInt(input[2]) == input[2]) + input[2] = parseInt(input[2]*2); // Geogebra delivers the half major axis + + p = board.create('ellipse', input, attr); + return p; + } catch(e) { + JXG.debug("* Err: Ellipse " + attr.name +"
\n"); + return false; + } + break; + case 'conic': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + +// try { + /* + // is there an expression named like the conic? + var exp = JXG.GeogebraReader.getElement(attr.name, true); + + // then get the function parameteres + if(exp.attributes['exp']){ + // exp = JXG.GeogebraReader.functionParse(exp.attributes['exp'].value); + // exp = JXG.GeogebraReader.ggbParse(exp.attributes['exp'].value); + + + + // (exp.getElementsByTagName('value')) ? exp = parseFloat(exp.getElementsByTagName('value')[0].attributes['val'].value) : false; + + } else */ if(input && input.length == 5) { + p = board.create('conic', input, attr); + } else if(element.getElementsByTagName('matrix')) { + m = []; + for(var i=0; iErr: Conic " + attr.name +"
\n"); +// return false; +// } + break; + case 'circlesector': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + //attr.names = [attr.name,'','','']; + //attr2 = {}; + //attr2.names = attr.names; + try { + JXG.debug("* CircleSector: First: " + input[0].name + ", Second: " + input[1].name + ", Third: " + input[2].name + "
\n"); + p = board.create('sector', [input[0],input[1],input[2]], attr); + /* + p.point4.hideElement(); + p.arc.setProperty(attr); + p.arc.visProp.highlightstrokewidth = (1*p.arc.visProp.strokewidth.substr(0,p.arc.visProp.strokewidth.length-2)+1)+'px'; + p.lines[0].setProperty(attr); + p.lines[1].setProperty(attr); + p.lines[0].visProp.highlightstrokewidth = (1*p.lines[0].visProp.strokerwWidth.substr(0,p.lines[0].visProp.strokewidth.length-2)+1)+'px'; + p.lines[1].visProp.highlightstrokewidth = (1*p.lines[1].visProp.strokerwWidth.substr(0,p.lines[1].visProp.strokewidth.length-2)+1)+'px'; + p.arc.hasPoint = p.arc.hasPointSector; + p.arc.highlight = (function(el){ return function() { + this.board.renderer.highlight(this); + this.board.renderer.highlight(el.lines[0]); + this.board.renderer.highlight(el.lines[1]); + };})(p); + p.arc.noHighlight = (function(el){ return function() { + this.board.renderer.noHighlight(this); + this.board.renderer.noHighlight(el.lines[0]); + this.board.renderer.noHighlight(el.lines[1]); + };})(p); + p.lines[0].highlight = (function(el){ return function() { + this.board.renderer.highlight(this); + this.board.renderer.highlight(el.arc); + this.board.renderer.highlight(el.lines[1]); + };})(p); + p.lines[1].highlight = (function(el){ return function() { + this.board.renderer.highlight(this); + this.board.renderer.highlight(el.arc); + this.board.renderer.highlight(el.lines[0]); + };})(p); + p.lines[0].noHighlight = (function(el){ return function() { + this.board.renderer.noHighlight(this); + this.board.renderer.noHighlight(el.arc); + this.board.renderer.noHighlight(el.lines[1]); + };})(p); + p.lines[1].noHighlight = (function(el){ return function() { + this.board.renderer.noHighlight(this); + this.board.renderer.noHighlight(el.arc); + this.board.renderer.noHighlight(el.lines[0]); + };})(p); + */ + return p; + } catch(e) { + JXG.debug("* Err: CircleSector " + attr.name +"
\n"); + return false; + } + break; + case 'linebisector': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* LineBiSector (Mittelsenkrechte): First: " + input[0].name + "
\n"); + m = board.create('midpoint', input, {visible: false}); + if(JXG.isPoint(JXG.getRef(board, input[0].id)) && + JXG.isPoint(JXG.getRef(board, input[1].id))) { + t = board.create('line', input, {visible: 'false'}); + p = board.create('perpendicular', [m, t], attr); + // p.point.setProperty('visible:false'); + } else { + p = board.create('perpendicular', [m, input[0]], attr); + // p.point.setProperty('visible:false'); + } + return p; + } catch(e) { + JXG.debug("* Err: LineBiSector (Mittelsenkrechte) " + attr.name +"
\n"); + return false; + } + break; + case 'ray': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Ray: First: " + input[0].name + "
\n"); + attr.straightFirst = true; + attr.straightLast = false; + p = board.create('line', [input[1], input[0]], attr); + return p; + } catch(e) { + JXG.debug("* Err: Ray " + attr.name +"
\n"); + return false; + } + break; + case 'tangent': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Tangent: First: " + input[0].name + ", Sec.: "+ input[1].name +"("+ input[1].type +")
\n"); + switch(input[1].type) { + case 1330923344: // graph + input[0].makeGlider(input[1]); + p = board.create('tangent', [input[0]], attr); + return p; + break; + case 1330922316: // circle 0x4F54434C + case 1330922319: // conic 0x4F54434F + var pol = board.create('polar',[input[1],input[0]],{visible:false}); + var i1 = board.create('intersection', [input[1], pol, 0], {visible: false}); + var i2 = board.create('intersection', [input[1], pol, 1], {visible: false}); + var t1 = board.create('line', [input[0], i1], attr); + var attr2 = {}; + attr2 = JXG.GeogebraReader.colorProperties(output[1], attr2); + attr2 = JXG.GeogebraReader.visualProperties(output[1], attr2); + attr2.name = output[1].getAttribute('label'); + var t2 = board.create('line', [input[0], i2], attr2); + board.ggbElements[attr2.name] = t2; + return [t1, t2]; + break; + } + } catch(e) { + JXG.debug("* Err: Tangent " + attr.name +" "+ attr2.name + "
\n"); + return false; + } + break; + case 'circumcirclearc': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* CircumcircleArc: First: " + input[0].name + "
\n"); + p = board.create('circumcirclearc', input, attr); + return p; + } catch(e) { + JXG.debug("* Err: CircumcircleArc " + attr.name +"
\n"); + return false; + } + break; + case 'circumcirclesector': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* CircumcircleSector: First: " + input[0].name + "
\n"); + p = board.create('circumcirclesector', [input[0], input[1], input[2]], attr); //{name:attr['name']}); + /* + p.arc.setProperty(attr); + p.lines[0].setProperty(attr); + p.lines[1].setProperty(attr); + p.arc.visProp.highlightstrokewidth = (1*p.arc.visProp.strokewidth.substr(0,p.arc.visProp.strokewidth.length-2)+1)+'px'; + p.lines[0].visProp.highlightstrokewidth = (1*p.lines[0].visProp.strokewidth.substr(0,p.lines[0].visProp.strokewidth.length-2)+1)+'px'; + p.lines[1].visProp.highlightstrokewidth = (1*p.lines[1].visProp.strokewidth.substr(0,p.lines[1].visProp.strokewidth.length-2)+1)+'px'; + p.arc.hasPoint = p.arc.hasPointSector; + p.arc.highlight = (function(el){ return function() { + this.board.renderer.highlight(this); + this.board.renderer.highlight(el.lines[0]); + this.board.renderer.highlight(el.lines[1]); + };})(p); + p.arc.noHighlight = (function(el){ return function() { + this.board.renderer.noHighlight(this); + this.board.renderer.noHighlight(el.lines[0]); + this.board.renderer.noHighlight(el.lines[1]); + };})(p); + p.lines[0].highlight = (function(el){ return function() { + this.board.renderer.highlight(this); + this.board.renderer.highlight(el.arc); + this.board.renderer.highlight(el.lines[1]); + };})(p); + p.lines[1].highlight = (function(el){ return function() { + this.board.renderer.highlight(this); + this.board.renderer.highlight(el.arc); + this.board.renderer.highlight(el.lines[0]); + };})(p); + p.lines[0].noHighlight = (function(el){ return function() { + this.board.renderer.noHighlight(this); + this.board.renderer.noHighlight(el.arc); + this.board.renderer.noHighlight(el.lines[1]); + };})(p); + p.lines[1].noHighlight = (function(el){ return function() { + this.board.renderer.noHighlight(this); + this.board.renderer.noHighlight(el.arc); + this.board.renderer.noHighlight(el.lines[0]); + };})(p); + */ + return p; + } catch(e) { + JXG.debug("* Err: CircumcircleSector " + attr.name +"
\n"); + return false; + } + break; + case 'semicircle': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Semicircle: First: " + input[0].name + "
\n"); + p = board.create('semicircle', [input[0], input[1]], attr); + return p; + } catch(e) { + JXG.debug("* Err: Semicircle " + attr.name +"
\n"); + return false; + } + break; + case 'angle': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Angle: First: " + input[0].name + "
\n"); + p = board.create('angle', input, attr); + return p; + } catch(e) { + JXG.debug("* Err: Angle " + attr.name +"
\n"); + return false; + } + break; + case 'angularbisector': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + attr.straightFirst = true; + attr.straightLast = true; + + try { + JXG.debug("* Angularbisector: First: " + input[0].name + "
\n"); + p = board.create('bisector', input, attr); + return p; + } catch(e) { + JXG.debug("* Err: Angularbisector " + attr.name +"
\n"); + return false; + } + break; + case 'numeric': + if(element.getElementsByTagName('slider').length == 0) { + // auxiliary doesn't exist in every numeric + //element.getElementsByTagName('auxiliary').length != 0 && element.getElementsByTagName('auxiliary')[0].attributes['val'].value == 'true') { + exp = JXG.GeogebraReader.getElement(element.getAttribute('label'), true); + if(exp) { + exp = exp.getAttribute('exp'); + exp = JXG.GeogebraReader.functionParse('', exp); + exp = JXG.GeogebraReader.ggbParse(exp); + } + board.ggb[attr.name] = new Function('return '+ exp +';'); + JXG.debug('value: '+ board.ggb[attr.name]()); + return board.ggb[attr.name]; + } else { + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + // gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + if(element.getElementsByTagName('slider').length == 1) { // it's a slider + sx = parseFloat(element.getElementsByTagName('slider')[0].getAttribute('x')); + sy = parseFloat(element.getElementsByTagName('slider')[0].getAttribute('y')); + length = parseFloat(element.getElementsByTagName('slider')[0].getAttribute('width')); + // are coordinates absolut? + if(element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') && element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') == 'true') { + var tmp = new JXG.Coords(JXG.COORDS_BY_SCREEN, [sx, sy], board); + sx = tmp.usrCoords[1]; + sy = tmp.usrCoords[2]; + } + + if(element.getElementsByTagName('slider')[0].getAttribute('horizontal') == 'true') { + if(element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') && element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') == 'true') + length /= (board.unitX); //*board.zoomX); + ex = sx + length; + ey = sy; + } else { + if(element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') && element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') == 'true') + length /= (board.unitY); //*board.zoomY); + ex = sx; + ey = sy + length; + } + + (element.getElementsByTagName('animation')[0]) ? attr.snapWidth = parseFloat(element.getElementsByTagName('animation')[0].getAttribute('step')) : false; + + try { + JXG.debug("* Numeric: First: " + attr.name + "
\n"); + attr['withTicks'] = false; + p = board.create('slider', [[sx,sy], [ex,ey], [parseFloat(element.getElementsByTagName('slider')[0].getAttribute('min')), + parseFloat(element.getElementsByTagName('value')[0].getAttribute('val')), + parseFloat(element.getElementsByTagName('slider')[0].getAttribute('max'))]], attr); + p.setProperty({withLabel:false}); + return p; + } catch(e) { + JXG.debug("* Err: Numeric " + attr.name +"
\n"); + return false; + } + } + } + break; + case 'midpoint': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + if(!JXG.exists(attr.styleGGB)) { + attr.face = 'circle'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + attr.highlightFillColor = attr.strokeColor; + attr.highlightFillOpacity = 1; + attr.strokeColor = 'black'; + attr.strokeWidth = '1px'; + } + p = board.create('midpoint', input, attr); + JXG.debug("* Midpoint ("+ p.id +"): "+ attr.name + "("+ gxtEl.x +", "+ gxtEl.y +")
\n"); + return p; + } catch(e) { + JXG.debug("* Err: Midpoint " + attr.name +"
\n"); + return false; + } + break; + case 'center': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + try { + if(!JXG.exists(attr.styleGGB)) { + attr.face = 'circle'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + attr.highlightFillColor = attr.strokeColor; + attr.highlightFillOpacity = 1; + attr.strokeColor = 'black'; + attr.strokeWidth = '1px'; + } + p = board.create('point', [function() { return JXG.getRef(board, input[0].id).center.X(); }, + function() { return JXG.getRef(board, input[0].id).center.Y(); }], attr); + JXG.debug("* Center ("+ p.id +"): "+ attr.name + "("+ gxtEl.x +", "+ gxtEl.y +")
\n"); + return p; + } catch(e) { + JXG.debug("* Err: Center " + attr.name +"
\n"); + return false; + } + break; + case 'function': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + if(JXG.GeogebraReader.getElement(attr.name, true)) { + func = JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp'); + func = JXG.GeogebraReader.functionParse('c', func); + } else { + func = input[0]; + func = JXG.GeogebraReader.functionParse('s', func); + } + + JXG.debug(func); + + length = func.length; + func[func.length-1] = 'return '+ JXG.GeogebraReader.ggbParse(func[func.length-1]) +';'; + + JXG.debug(func); + + range = [(input && input[1]) ? input[1] : null, (input && input[2]) ? input[2] : null]; + + try { + if(length == 1) + p = board.create('functiongraph', [new Function(func[0]), range[0], range[1]], attr); + else if(length==2) + p = board.create('functiongraph', [new Function(func[0], func[1]), range[0], range[1]], attr); + else if(length==3) + p = board.create('functiongraph', [new Function(func[0], func[1], func[2]), range[0], range[1]], attr); + else if(length==4) + p = board.create('functiongraph', [new Function(func[0], func[1], func[2], func[3]), range[0], range[1]], attr); + else if(length==5) + p = board.create('functiongraph', [new Function(func[0], func[1], func[2], func[3], func[4]), range[0], range[1]], attr); + return p; + } catch(e) { + JXG.debug("* Err: Functiongraph " + attr.name +"
\n"); + return false; + } + + break; + case 'polar': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Polar: First: " + input[0].name + ", Sec.: "+ input[1].name +"
\n"); + p = board.create('polar', input, attr); + return p; + } catch(e) { + JXG.debug("* Err: Polar " + attr.name +"
\n"); + return false; + } + break; + case 'slope': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Slope ("+ attr.name +"): First: " + input[0].name +"
\n"); + var slopeWidth = parseInt(attr.slopeWidth) || 1.0; + var p1 = input[0].glider || input[0].point1; + var p2 = board.create('point',[function(){return (slopeWidth+p1.X());}, function(){return p1.Y();}], {visible: false}); + var l1 = board.create('segment', [p1, p2], {visible: false}); // visible: attr.visible + var l2 = board.create('normal', [l1, l1.point2], {visible: false}); // visible attr.visible + var i = board.create('intersection', [input[0], l2, 0], {visible: false}); + var m = board.create('midpoint', [l1.point2, i], {visible: false}); + + var t = board.create('text', [function(){return m.X();}, function(){return m.Y();}, + function(){ return "  " + (slopeWidth > 1 ? slopeWidth.toString() : "") + " " + this.name + " = " + JXG.trimNumber((slopeWidth * input[0].getSlope()).toFixed(JXG.GeogebraReader.decimals)); }], attr); + attr.name = ""; + var t2 = board.create('text', [function(){return (p1.X() + p2.X())/2.;}, function(){return p1.Y();}, + function(){ return "
" + slopeWidth; }], attr); + t.Value = (function() { return function(){ return input[0].getSlope(); }; })(); + var poly = board.create('polygon',[p1,p2,i], attr); + + poly.borders[2].setProperty({visible: false}); + poly.borders[0].setProperty({strokeColor: attr.fillColor, strokeWidth: attr.strokeWidth, highlightStrokeColor: attr.fillColor, dash:attr.dash}); + poly.borders[1].setProperty({strokeColor: attr.fillColor, strokeWidth: attr.strokeWidth, highlightStrokeColor: attr.fillColor, dash:attr.dash}); + return t; + } catch(e) { + JXG.debug("* Err: Slope " + attr.name +"
\n"); + return false; + } + break; + case 'text': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + var rx, res = ''; + + try { + if(element.getElementsByTagName('isLaTeX')[0] && element.getElementsByTagName('isLaTeX')[0].getAttribute('val') == 'true') { + JXG.GeogebraReader.board.options.text.useASCIIMathML = true; + t = JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp'); + + // here we're searching for patterns like + // " + ... + " + // ... will be sent to the ggbParser and a calculated text element is built from this. + while(rx = t.match(/(.*?)" \+ (.+) \+ "(.*)/)) { + var re2 = JXG.GeogebraReader.ggbParse(RegExp.$2); + if (typeof re2 == 'string') { + res = res + RegExp.$1 + re2; + } else { + res = res + RegExp.$1 + '" + JXG.trimNumber((' + re2 + ').toFixed(JXG.GeogebraReader.decimals)) + "'; + } + t = RegExp.$3; + } + // we have to look, if the string's ending with a string-part or a formula part: + if(rx = t.match(/(.*?)" \+ (.+)/)) { + res = res + RegExp.$1 + '" + JXG.trimNumber((' + JXG.GeogebraReader.ggbParse(RegExp.$2) + ').toFixed(JXG.GeogebraReader.decimals))'; + } else + res = res + t; + + JXG.debug("Text: "+res); + + p = board.create('text', [gxtEl.x, gxtEl.y, new Function('return ' + res + ';')], attr); + } else { + JXG.debug(JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp')); + t = JXG.GeogebraReader.ggbParse(JXG.GeogebraReader.functionParse(false, JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp'))); + JXG.debug(t[1]); + p = board.create('text', [gxtEl.x, gxtEl.y, new Function('return '+t[0]+' + " " + JXG.trimNumber(parseFloat(' + t[1] +').toFixed(JXG.GeogebraReader.decimals));') ], attr); + } + JXG.debug("* Text: " + t +"
\n"); + return p; + } catch(e) { + JXG.debug("* Err: Text: " + t +"
\n"); + return false; + } + break; + case 'root': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + //JXG.debug(JXG.getRef(board, gxtEl.id)); + + for(var i=0; iIntegral: First: " + input[0].name + ", Sec.: "+ input[1].name +", Thir.: "+ input[2].name +"
\n"); + JXG.debug([input[1](), input[2]()]); + var p = board.create('integral', [JXG.getRef(board, input[0]), [input[1], input[2]]], attr); + return p; + } catch(e) { + JXG.debug("* Err: Integral " + attr.name + e + "
\n"); + return false; + } + break; + +// case 'transform': +// break; +// case 'radius': +// break; +// case 'derivative': +// break; +// case 'root': +// break; +// case 'corner': +// break; +// case 'unitvector': +// break; +// case 'extremum': +// break; +// case 'turningpoint': +// break; +// case 'arc': +// break; +// case 'circlepart': +// break; +// case 'uppersum': +// break; +// case 'lowersum': +// break; +// case 'image': +// break; + default: + return false; + break; + } +}; + +/** + * Reading the elements of a geogebra file + * @param {Object} board board object + */ +this.readGeogebra = function(tree, board) { + var el, Data, i, els = [], expr; + + board.ggbElements = []; + board.ggb = {}; + JXG.GeogebraReader.tree = tree; + JXG.GeogebraReader.board = board; + JXG.GeogebraReader.format = parseFloat(JXG.GeogebraReader.tree.getElementsByTagName('geogebra')[0].getAttribute('format')); + JXG.GeogebraReader.decimals = parseInt(JXG.GeogebraReader.tree.getElementsByTagName('geogebra')[0].getElementsByTagName('kernel')[0].getElementsByTagName('decimals')[0].getAttribute('val')); + JXG.GeogebraReader.writeBoard(board); + board = JXG.GeogebraReader.setDefaultOptions(board); + + // speeding up the drawing process + //board.suspendUpdate(); + + var constructions = JXG.GeogebraReader.tree.getElementsByTagName("construction"); + for (var t=0; t"); + + /* register borders to according "parent" */ + if(board.ggbElements[elname].borders) + for(var i=0; i"); + }; + } + }; + + JXG.debug('Restesammler: '); + // create "single" elements which do not depend on any other + var elements = constructions[t].getElementsByTagName("element"); + for (var s=0; s=') : exp; + exp = (exp.match(/\u2227/)) ? exp.replace(/\u2227/g, '&&') : exp; + exp = (exp.match(/\u2228/)) ? exp.replace(/\u2228/g, '//') : exp; + return exp; +}; + +/** + * Extracting the packed geogebra file in order to return the "blank" xml-tree for further parsing. + * @param {String} archive containing geogebra.xml-file or raw input string (eg. xml-tree) + * @return {String} content of geogebra.xml-file if archive was passed in + */ +this.prepareString = function(fileStr, isString) { + var i, bA, len, fstr; + + // here we have to deal with two different base64 encoded streams + // first one: base64 encoded xml (geogebra's web export) + // second one: base64 encoded ggb file, this is our recommendation for an IE & Opera + // workaround, which can't deal with binary data transferred via AJAX. + + // first try to decode assuming we got a base64 encoded ggb file + if(isString) { + fstr = JXG.Util.Base64.decode(fileStr); + if(fstr.slice(0,2)!=="PK") { + // ooops, that was no ggb file. try again with utf8 parameter set. + fstr = JXG.Util.Base64.decode(fileStr, true); + } + fileStr = fstr; + } + + if (fileStr.indexOf('<') != 0) { + bA = []; + len = fileStr.length; + for (i=0;i. +*/ +JXG.debug = function() {}; +JXG.GeonextReader = { + + changeOriginIds: function (board, id) { + if ((id == 'gOOe0') || (id == 'gXOe0') || (id == 'gYOe0') || (id == 'gXLe0') || (id == 'gYLe0')) { + return board.id + id; + } else { + return id; + } + }, + + /** + * Retrieves data by TagName from an XML node. + * @param {Node} node The Node that contains the data we want to get. + * @param {String} tag The Name of the tag we are looking for. + * @param {Number} [idx=0] getElementsByTagName returns an array; This parameter decides which element to use. + * @param {Boolean} [fc=true] If True, the result will be the data of firstChild instead of the result node. + * @returns {String} The gathered data + */ + gEBTN: function (node, tag, idx, fc) { + var tmp; + + if (!JXG.exists(node || !node.getElementsByTagName )/* || !JXG.exists(node.getElementsByTagName)*/) { + return ''; + } + // Default values for optional parameters idx and fc + if (!JXG.exists(fc)) { + fc = true; + } + idx = idx || 0; + tmp = node.getElementsByTagName(tag); + if (tmp.length > 0) { + tmp = tmp[idx]; + if (fc && tmp.firstChild) { + tmp = tmp.firstChild.data; + } + } + return tmp; + }, + + /** + * Set color properties of a geonext element. + * Set stroke, fill, lighting, label and draft color attributes. + * @param {Object} gxtEl element of which attributes are to set + */ + colorProperties: function (gxtEl, Data) { + var color = this.gEBTN(Data, 'color', 0, false), + rgbo; + + //gxtEl.strokewidth = Data.getElementsByTagName('strokewidth')[0].firstChild.data; + // colorStroke = strokeColor etc. is here for downwards compatibility: + // once upon a time we used to create elements in here using the "new JXG.Element" constructor mechanism + // then we changed to board.create + setProperty afterwords + // now i want to use the board.create method with an appropriate attributes object to avoid setProperty calls + // and as gxtEl happens to be somewhat like an attributes object it's just slightly different so we adjust it + // for downwards compatibility during the transformation of this reader we use both properties + + rgbo = JXG.rgba2rgbo(this.gEBTN(color, 'stroke')); + gxtEl.strokeColor = rgbo[0]; + gxtEl.strokeOpacity = rgbo[1]; + + rgbo = JXG.rgba2rgbo(this.gEBTN(color, 'lighting')); + gxtEl.highlightStrokeColor = rgbo[0]; + gxtEl.highlightStrokeOpacity = rgbo[1]; + + rgbo = JXG.rgba2rgbo(this.gEBTN(color, 'fill')); + gxtEl.fillColor = rgbo[0]; + gxtEl.fillOpacity = rgbo[1]; + + gxtEl.highlightFillColor = gxtEl.fillColor; + gxtEl.highlightFillOpacity = gxtEl.fillOpacity; + + gxtEl.labelColor = JXG.rgba2rgbo(this.gEBTN(color, 'label'))[0]; + gxtEl.colorDraft = JXG.rgba2rgbo(this.gEBTN(color, 'draft'))[0]; + + // GEONExT hides labels by setting opacity to 0. + if (JXG.rgba2rgbo(this.gEBTN(color, 'label'))[1]==0) { + gxtEl.withLabel = false; + } else { + gxtEl.withLabel = true; + } + + // backwards compatibility + gxtEl.colorStroke = gxtEl.strokeColor; + gxtEl.colorFill = gxtEl.fillColor; + gxtEl.colorLabel = gxtEl.labelColor; + + return gxtEl; + }, + + firstLevelProperties: function (gxtEl, Data) { + if (!JXG.exists(Data) || !JXG.exists(Data.childNodes)) + return gxtEl; + + var arr = Data.childNodes, n, key; + + for (n = 0; n < arr.length; n++) { + if (JXG.exists(arr[n].firstChild) && arr[n].nodeName !== 'data' && arr[n].nodeName !== 'straight') { + key = arr[n].nodeName; + gxtEl[key] = arr[n].firstChild.data; + } + } + + return gxtEl; + }, + + /** + * Set the defining properties of a geonext element. + * Writing the nodeName to ident; setting the name attribute and defining the element id. + * @param {Object} gxtEl element of which attributes are to set + */ + defProperties: function (gxtEl, Data) { + // 3==TEXT_NODE, 8==COMMENT_NODE + if (Data.nodeType==3 || Data.nodeType==8 ) { + return null; + } + + gxtEl.ident = Data.nodeName; + + if(gxtEl.ident == "text" || gxtEl.ident == "intersection" || gxtEl.ident == "composition") { + gxtEl.name = ''; + } else { + gxtEl.name = this.gEBTN(Data, 'name'); + } + + gxtEl.id = this.gEBTN(Data, 'id'); + + return gxtEl; + }, + + visualProperties: function (gxtEl, Data) { + gxtEl.visible = JXG.str2Bool(this.gEBTN(Data, 'visible')); + gxtEl.trace = JXG.str2Bool(this.gEBTN(Data, 'trace')); + + return gxtEl; + }, + + transformProperties: function (gxtEl, type) { + var facemap = [ + // 0-2 + 'cross', 'cross', 'cross', + // 3-6 + 'circle', 'circle', 'circle', 'circle', + // 7-9 + 'square', 'square', 'square', + // 10-12 + 'plus', 'plus', 'plus' + ], sizemap = [ + // 0-2 + 2, 3, 4, + // 3-6 + 1, 2, 3, 4, + // 7-9 + 2, 3, 4, + // 10-12 + 2, 3, 4 + ]; + + gxtEl.strokeWidth = gxtEl.strokewidth; + gxtEl.face = facemap[parseInt(gxtEl.style, 10)] || 'cross'; + gxtEl.size = sizemap[parseInt(gxtEl.style, 10)] || 3; + + gxtEl.straightFirst = JXG.str2Bool(gxtEl.straightFirst); + gxtEl.straightLast = JXG.str2Bool(gxtEl.straightLast); + + gxtEl.visible = JXG.str2Bool(gxtEl.visible); + //gxtEl.withLabel = gxtEl.visible; // withLabel is set in colorProperties() + gxtEl.draft = JXG.str2Bool(gxtEl.draft); + gxtEl.trace = JXG.str2Bool(gxtEl.trace); + + if (type==='point') { + // Fill properties are ignored by GEONExT + gxtEl.fillColor = gxtEl.strokeColor; + gxtEl.highlightFillColor = gxtEl.highlightStrokeColor; + gxtEl.fillOpacity = gxtEl.strokeOpacity; + gxtEl.highlightFillOpacity = gxtEl.highlightStrokeOpacity; + } + + if (typeof(gxtEl.label === 'string')) { + delete(gxtEl.label); + } + + delete gxtEl.color; + return gxtEl; + }, + + readNodes: function (gxtEl, Data, nodeType, prefix) { + var arr = this.gEBTN(Data, nodeType, 0, false).childNodes, + key, n; + + for (n = 0; n < arr.length; n++) { + if (arr[n].firstChild != null) { + if (prefix != null) { + key = prefix + JXG.capitalize(arr[n].nodeName); + } else { + key = arr[n].nodeName; + } + gxtEl[key] = arr[n].firstChild.data; + } + } + return gxtEl; + }, + + subtreeToString: function (root) { + try { + // firefox + return (new XMLSerializer()).serializeToString(root); + } catch (e) { + // IE + return root.xml; + } + }, + + readImage: function (node) { + var pic = '', + nod = node; + + if (nod != null) { + pic = nod.data; + while (nod.nextSibling != null) { + nod = nod.nextSibling; + pic += nod.data; + } + } + return pic; + }, + + parseImage: function (board, fileNode, level, x, y, w, h, el) { + var tag, id, im, picStr, tmpImg; + + if (fileNode == null) { + return null; + } + + if (fileNode.getElementsByTagName('src')[0] != null) { // Background image + tag = 'src'; + } else if (fileNode.getElementsByTagName('image')[0] != null) { + tag = 'image'; + } else { + return null; + } + + picStr = this.readImage(this.gEBTN(fileNode, tag, 0, false).firstChild); + if (picStr!='') { + picStr = 'data:image/png;base64,' + picStr; + if (tag=='src') { // Background image + x = this.gEBTN(fileNode, 'x'); + y = this.gEBTN(fileNode, 'y'); + w = this.gEBTN(fileNode, 'width'); + h = this.gEBTN(fileNode, 'height'); + im = board.create('image', [picStr,[x, y],[w, h]], { + anchor: el, layer: level + }); + return im; + } else { + // Image bound to an element + // Read the original dimensions, i.e. the ratio h/w with the help of a temporary image. + // We have to wait until the image is loaded, therefore + // we need "onload". + tmpImg = new Image(); + tmpImg.src = picStr; + id = el.id + '_image'; + tmpImg.onload = function(){ + // Now, we can read the original dimensions of the image. + var wOrg = this.width, + hOrg = this.height, + xf, yf, wf, hf, im, tRot; + + if (el.elementClass == JXG.OBJECT_CLASS_LINE) { + // A line containing an image, runs through the horizontal middle + // of the image. + xf = function(){ return el.point1.X(); }; + wf = function(){ return el.point1.Dist(el.point2); }; + hf = function(){ return wf() * hOrg / wOrg; }; + yf = function(){ return el.point1.Y() - hf() * 0.5; }; + im = board.create('image', [picStr, [xf,yf], [wf,hf]], { + layer: level, + id: id, + anchor: el + }); + tRot = board.create('transform', [ + function () { + return Math.atan2(el.point2.Y()-el.point1.Y(), el.point2.X()-el.point1.X()) + }, + el.point1 + ], { + type:'rotate' + }); + tRot.bindTo(im); + el.image = im; + } else if (el.elementClass == JXG.OBJECT_CLASS_POINT) { + wf = function(){ return wOrg / board.unitX; }; + hf = function(){ return hOrg / board.unitY; }; + xf = function(){ return el.X() - wf() * 0.5; }; + yf = function(){ return el.Y() - hf() * 0.5; }; + + im = board.create('image', [picStr, [xf,yf], [wf,hf]], { + layer: level, + id: id, + anchor: el + }); + board.renderer.hide(el.label.content); + el.image = im; + } else if (el.elementClass == JXG.OBJECT_CLASS_CIRCLE) { + // A circle containing an image + wf = function(){ return 2.0 * el.Radius(); }; + hf = function(){ return wf() * hOrg / wOrg; }; + xf = function(){ return el.center.X() - wf() * 0.5; }; + yf = function(){ return el.center.Y() - hf() * 0.5; }; + im = board.create('image', [picStr, [xf,yf], [wf,hf]], { + layer: level, + id: id, + anchor: el + }); + el.image = im; + } else { + im = board.create('image', [picStr, [x, y], [w, h]], { + layer: level, + id: id, + anchor: el + }); + el.image = im; + } + }; + } + return im; + } + }, + + readConditions: function(node) { + var i, s, ob, + conditions = ''; + + if (JXG.exists(node)) { + for(i = 0; i < node.getElementsByTagName('data').length; i++) { + ob = node.getElementsByTagName('data')[i]; + s = this.subtreeToString(ob); + conditions += s; + } + } + + return conditions; + }, + + printDebugMessage: function(outputEl,gxtEl,nodetyp,success) { + JXG.debug("* " + success + ": " + nodetyp + " " + gxtEl.name + " " + gxtEl.id + "
\n"); + }, + + /** + * Reading the elements of a geonext file + * @param {XMLTree} tree expects the content of the parsed geonext file returned by function parseFF/parseIE + * @param {Object} board board object + */ + readGeonext: function(tree, board) { + var xmlNode, elChildNodes, + s, Data, inter, boardData, el, p, + conditions, tmp, strTrue = 'true', gxtReader = this; + + // maybe this is not necessary as we already provide layer options for sectors and circles via JXG.Options but + // maybe these have to be the same for geonext. + board.options.layer.sector = board.options.layer.angle; + board.options.layer.circle = board.options.layer.angle; + + board.options.line.label.position = 'top'; + + boardData = this.gEBTN(tree, 'board', 0, false); + conditions = this.readConditions(boardData.getElementsByTagName('conditions')[0]); + + // set the origin + xmlNode = this.gEBTN(boardData, 'coordinates', 0, false); + tmp = this.gEBTN(xmlNode, 'origin', 0, false); + board.origin = { + usrCoords: [1, 0, 0], + scrCoords: [1, parseFloat(this.gEBTN(tmp, 'x')), parseFloat(this.gEBTN(tmp, 'y'))] + }; + + // zoom level + tmp = this.gEBTN(xmlNode, 'zoom', 0, false); + board.zoomX = parseFloat(this.gEBTN(tmp, 'x')); + board.zoomY = parseFloat(this.gEBTN(tmp, 'y')); + + // screen to user coordinates conversion + tmp = this.gEBTN(xmlNode, 'unit', 0, false); + board.unitX = parseFloat(this.gEBTN(tmp, 'x')); + board.unitY = parseFloat(this.gEBTN(tmp, 'y')); + + // resize board + if (board.options.takeSizeFromFile) { + board.resizeContainer(this.gEBTN(boardData, 'width'), this.gEBTN(boardData, 'height')); + } + + // check and set fontSize + if (!(parseFloat(board.options.text.fontSize) > 0)) { + board.options.text.fontSize = 12; + } + + board.geonextCompatibilityMode = true; + + // jsxgraph chooses an id for the board but we don't want to use it, we want to use + // the id stored in the geonext file. if you know why this is required, please note it here. + delete(JXG.JSXGraph.boards[board.id]); + board.id = this.gEBTN(boardData, 'id'); + JXG.JSXGraph.boards[board.id] = board; + + // this creates some basic elements present in every geonext construction but not explicitly present in the file + board.initGeonextBoard(); + + // Update of properties during update() is not necessary in GEONExT files + // But it maybe necessary if we construct with JavaScript afterwards + board.renderer.enhancedRendering = true; + + // Read background image + this.parseImage(board, this.gEBTN(boardData, 'file', 0, false), board.options.layer['image']); + + board.options.point.snapToGrid = (this.gEBTN(this.gEBTN(boardData, 'coordinates', 0, false), 'snap') == strTrue); + // + // TODO: Missing jsxgraph feature snapToPoint + // If snapToGrid and snapToPoint are both true, point snapping is enabled + if (board.options.point.snapToGrid && this.gEBTN(this.gEBTN(boardData, 'grid', 1, false), 'pointsnap') == strTrue) { + board.options.point.snapToGrid = false; + board.options.point.snapToPoints = true; + board.options.point.attractorDistance = 0.5; + } + //board.options.grid.snapToGrid = false; + + xmlNode = this.gEBTN(boardData, 'grid', 1, false); + tmp = this.gEBTN(xmlNode, 'x'); + if (tmp) { + board.options.grid.gridX = 1 / parseFloat(tmp); + board.options.point.snapSizeX = parseFloat(tmp); + } + tmp = this.gEBTN(xmlNode, 'y'); + if (tmp) { + board.options.grid.gridY = 1 / parseFloat(tmp); + board.options.point.snapSizeY = parseFloat(tmp); + } + //board.calculateSnapSizes(); // Seems not to be correct + board.options.grid.gridDash = JXG.str2Bool(this.gEBTN(xmlNode, 'dash')); + + tmp = JXG.rgba2rgbo(this.gEBTN(xmlNode, 'color')); + board.options.grid.gridColor = tmp[0]; + board.options.grid.gridOpacity = tmp[1]; + + xmlNode = this.gEBTN(boardData, 'coordinates', 0, false); + if (this.gEBTN(xmlNode, 'grid') == strTrue) { + board.create('grid', []); + } + + if (this.gEBTN(xmlNode, 'coord') == strTrue) { + board.options.axis.ticks.majorHeight = 10; // Hard coded default option + board.options.axis.ticks.minorHeight = 4; // Hard coded default option + board.create('axis', [[0, 0], [1, 0]]); + board.create('axis', [[0, 0], [0, 1]]); + } + + board.containerObj.style.backgroundColor = JXG.rgba2rgbo(this.gEBTN(this.gEBTN(boardData, 'background', 0, false), 'color'))[0]; + + elChildNodes = tree.getElementsByTagName("elements")[0].childNodes; + for (s = 0; s < elChildNodes.length; s++) { + (function (s) { + var i, gxtEl = {}, + l, x, y, c, numberDefEls, + el, p, inter, rgbo, tmp; + + Data = elChildNodes[s]; + gxtEl = gxtReader.defProperties(gxtEl, Data); + + // Skip text nodes + if (!JXG.exists(gxtEl)) { + return; + } + + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName.toLowerCase, 'READ:'); + switch (Data.nodeName.toLowerCase()) { + case "point": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + gxtEl.fixed = JXG.str2Bool(gxtReader.gEBTN(Data, 'fix')); + gxtEl = gxtReader.transformProperties(gxtEl, 'point'); + + //try { + p = board.create('point', [parseFloat(gxtEl.x), parseFloat(gxtEl.y)], gxtEl); + + var v = function(){ return p.visProp.visible; }; + el = gxtReader.parseImage(board, Data, board.options.layer['image'], 0, 0, 0, 0, p); + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + /* + if (JXG.exists(el)) { + el.visProp.visible = function() { return p.visProp.visible; }; + alert(p.visProp.visible); + if (el.visProp.visible()) {el.showElement();} else {el.hideElement();} + } + */ + //} catch(e) { + // JXG.debug(e); + //} + break; + case "line": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + gxtEl = gxtReader.readNodes(gxtEl, Data, 'straight', 'straight'); + gxtEl = gxtReader.transformProperties(gxtEl); + + gxtEl.first = gxtReader.changeOriginIds(board, gxtEl.first); + gxtEl.last = gxtReader.changeOriginIds(board, gxtEl.last); + + l = board.create('line', [gxtEl.first, gxtEl.last], gxtEl); + + gxtReader.parseImage(board, Data, board.options.layer['image'], 0, 0, 0, 0, l); + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case "circle": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + + tmp = gxtReader.gEBTN(Data, 'data', 0, false); + gxtEl.center = gxtReader.changeOriginIds(board, gxtReader.gEBTN(tmp, 'midpoint')); + + if (tmp.getElementsByTagName('radius').length > 0) { + gxtEl.radius = gxtReader.changeOriginIds(board, gxtReader.gEBTN(tmp, 'radius')); + } else if (tmp.getElementsByTagName('radiusvalue').length > 0) { + gxtEl.radius = gxtReader.gEBTN(tmp, 'radiusvalue'); + } + gxtEl = gxtReader.transformProperties(gxtEl); + c = board.create('circle', [gxtEl.center, gxtEl.radius], gxtEl); + + gxtReader.parseImage(board, Data, board.options.layer['image'], 0, 0, 0, 0, c); + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case "slider": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + gxtEl.fixed = JXG.str2Bool(gxtReader.gEBTN(Data, 'fix')); + gxtEl = gxtReader.readNodes(gxtEl, Data, 'animate', 'animate'); + gxtEl = gxtReader.transformProperties(gxtEl, 'point'); + try { + gxtEl.parent = gxtReader.changeOriginIds(board, gxtEl.parent); + + // if (board.isSuspendedUpdate) { board.unsuspendUpdate().suspendUpdate(); } + p = board.create('glider', [parseFloat(gxtEl.x), parseFloat(gxtEl.y), gxtEl.parent], gxtEl); + p.onPolygon = JXG.exists(gxtEl.onpolygon) && JXG.str2Bool(gxtEl.onpolygon); + + gxtReader.parseImage(board, Data, board.options.layer['point'], 0, 0, 0, 0, p); + + //if (board.isSuspendedUpdate) { board.unsuspendUpdate().suspendUpdate(); } + + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + } catch(e) { + JXG.debug("* Err: Slider " + gxtEl.name + " " + gxtEl.id + ': '+ gxtEl.parent +"
\n"); + } + break; + case "cas": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl.fixed = JXG.str2Bool(Data.getElementsByTagName('fix')[0].firstChild.data); + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + gxtEl = gxtReader.transformProperties(gxtEl, 'point'); + + if (false) { // Handle weird element names + gxtEl.x = JXG.GeonextParser.gxt2jc(gxtEl.x, board); + gxtEl.y = JXG.GeonextParser.gxt2jc(gxtEl.y, board); + } else { // Workaround until the jessiecode compiler is 100% compatible + gxtEl.x = JXG.GeonextParser.geonext2JS(gxtEl.x, board); + gxtEl.x = new Function('return ' + gxtEl.x + ';'); + gxtEl.y = JXG.GeonextParser.geonext2JS(gxtEl.y, board); + gxtEl.y = new Function('return ' + gxtEl.y + ';'); + } + + /* + p = board.create('point', [parseFloat(gxtEl.xval), parseFloat(gxtEl.yval)], gxtEl); + p.addConstraint([gxtEl.x, gxtEl.y]); + p.type = JXG.OBJECT_TYPE_CAS; + */ + p = board.create('point', [gxtEl.x, gxtEl.y], gxtEl); + gxtReader.parseImage(board, Data, board.options.layer['point'], 0, 0, 0, 0, p); + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case "intersection": + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + xmlNode = Data.getElementsByTagName('first')[1]; + + gxtEl.outFirst = {}; + gxtEl.outFirst = gxtReader.colorProperties(gxtEl.outFirst, xmlNode); + gxtEl.outFirst = gxtReader.visualProperties(gxtEl.outFirst, xmlNode); + gxtEl.outFirst = gxtReader.firstLevelProperties(gxtEl.outFirst, xmlNode); + gxtEl.outFirst.fixed = JXG.str2Bool(xmlNode.getElementsByTagName('fix')[0].firstChild.data); + gxtEl.outFirst = gxtReader.transformProperties(gxtEl.outFirst, 'point'); + gxtEl.first = gxtReader.changeOriginIds(board, gxtEl.first); + gxtEl.last = gxtReader.changeOriginIds(board, gxtEl.last); + + //if ((board.objects[gxtEl.first].type == JXG.OBJECT_TYPE_LINE || board.objects[gxtEl.first].type == JXG.OBJECT_TYPE_ARROW) + // && (board.objects[gxtEl.last].type == JXG.OBJECT_TYPE_LINE || board.objects[gxtEl.last].type == JXG.OBJECT_TYPE_ARROW)) { + if ((JXG.getReference(board, gxtEl.first).elementClass == JXG.OBJECT_CLASS_LINE) + && (JXG.getReference(board, gxtEl.last).elementClass == JXG.OBJECT_CLASS_LINE)) { + /* + inter = new JXG.Intersection(board, gxtEl.id, board.objects[gxtEl.first], + board.objects[gxtEl.last], gxtEl.outFirst.id, '', + gxtEl.outFirst.name, ''); + inter.p.setProperty(gxtEl.outFirst); + */ + inter = board.create('intersection', [board.objects[gxtEl.first], board.objects[gxtEl.last], 0], gxtEl.outFirst); + /* offensichtlich braucht man dieses if doch */ + if (gxtEl.outFirst.visible == "false") { + inter.hideElement(); + } + } else { + xmlNode = Data.getElementsByTagName('last')[1]; + if (JXG.exists(xmlNode)) { + gxtEl.outLast = {}; + gxtEl.outLast = gxtReader.colorProperties(gxtEl.outLast, xmlNode); + gxtEl.outLast = gxtReader.visualProperties(gxtEl.outLast, xmlNode); + gxtEl.outLast = gxtReader.firstLevelProperties(gxtEl.outLast, xmlNode); + gxtEl.outLast.fixed = JXG.str2Bool(xmlNode.getElementsByTagName('fix')[0].firstChild.data); + gxtEl.outLast = gxtReader.transformProperties(gxtEl.outLast, 'point'); + /* + inter = new JXG.Intersection(board, gxtEl.id, board.objects[gxtEl.first], + board.objects[gxtEl.last], gxtEl.outFirst.id, gxtEl.outLast.id, + gxtEl.outFirst.name, gxtEl.outLast.name); + inter.p1.setProperty(gxtEl.outFirst); + inter.p2.setProperty(gxtEl.outLast); + */ + inter = board.create('intersection', [board.objects[gxtEl.first], board.objects[gxtEl.last], 0], gxtEl.outFirst); + inter = board.create('intersection', [board.objects[gxtEl.first], board.objects[gxtEl.last], 1], gxtEl.outLast); + } + } + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case "composition": + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl.defEl = []; + numberDefEls = 0; + xmlNode = Data.getElementsByTagName('data')[0].getElementsByTagName('input'); + for (i = 0; i < xmlNode.length; i++) { + gxtEl.defEl[i] = xmlNode[i].firstChild.data; + numberDefEls = i + 1; + } + + // every composition produces at least one element and the data for this element is stored + // in gxtEl.out. if additional elements are created their data is read in the according case. + xmlNode = Data.getElementsByTagName('output')[0]; + gxtEl.out = {}; + gxtEl.out = gxtReader.colorProperties(gxtEl.out, xmlNode); + gxtEl.out = gxtReader.visualProperties(gxtEl.out, xmlNode); + gxtEl.out = gxtReader.firstLevelProperties(gxtEl.out, xmlNode); + gxtEl.out = gxtReader.transformProperties(gxtEl.out); + + gxtEl.defEl[0] = gxtReader.changeOriginIds(board, gxtEl.defEl[0]); + gxtEl.defEl[1] = gxtReader.changeOriginIds(board, gxtEl.defEl[1]); + gxtEl.defEl[2] = gxtReader.changeOriginIds(board, gxtEl.defEl[2]); + + // if (board.isSuspendedUpdate) { board.unsuspendUpdate().suspendUpdate(); } + switch (gxtEl.type) { + // ARROW_PARALLEL + case "210070": + gxtEl.out.fixed = gxtReader.gEBTN(xmlNode, 'fix'); + + xmlNode = Data.getElementsByTagName('output')[1]; + gxtEl.outPoint = {}; + gxtEl.outPoint = gxtReader.defProperties(gxtEl.outPoint, xmlNode); + gxtEl.outPoint = gxtReader.colorProperties(gxtEl.outPoint, xmlNode); + gxtEl.outPoint = gxtReader.visualProperties(gxtEl.outPoint, xmlNode); + gxtEl.outPoint = gxtReader.firstLevelProperties(gxtEl.outPoint, xmlNode); + gxtEl.outPoint = gxtReader.transformProperties(gxtEl.outPoint); + gxtEl.out.point = gxtEl.outPoint; + + board.create('arrowparallel', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); + break; + + // BISECTOR + case "210080": + gxtEl.out.straightFirst = false; + board.create('bisector', [gxtEl.defEl[0], gxtEl.defEl[1], gxtEl.defEl[2]], gxtEl.out); + break; + + // CIRCUMCIRCLE + case "210090": + xmlNode = Data.getElementsByTagName('output')[1]; + gxtEl.outCircle = {}; + gxtEl.outCircle = gxtReader.defProperties(gxtEl.outCircle, xmlNode); + gxtEl.outCircle = gxtReader.colorProperties(gxtEl.outCircle, xmlNode); + gxtEl.outCircle = gxtReader.visualProperties(gxtEl.outCircle, xmlNode); + gxtEl.outCircle = gxtReader.firstLevelProperties(gxtEl.outCircle, xmlNode); + gxtEl.outCircle = gxtReader.transformProperties(gxtEl.outCircle); + gxtEl.outCircle.point = gxtEl.out; + board.create('circumcircle', [gxtEl.defEl[0], gxtEl.defEl[1], gxtEl.defEl[2]], gxtEl.outCircle); + break; + + // CIRCUMCIRCLE_CENTER + case "210100": + board.create('circumcenter', [gxtEl.defEl[0], gxtEl.defEl[1], gxtEl.defEl[2]], gxtEl.out); + break; + + // MIDPOINT + case "210110": + board.create('midpoint', gxtEl.defEl.slice(0, numberDefEls), gxtEl.out); + break; + + // MIRRORLINE + case "210120": + board.create('reflection', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); + break; + + // MIRROR_POINT + case "210125": + board.create('mirrorpoint', [gxtEl.defEl[0], gxtEl.defEl[1]], gxtEl.out); + break; + + // NORMAL + case "210130": + //board.create('normal', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); + board.create('perpendicularsegment', [gxtEl.defEl[0], gxtEl.defEl[1]], gxtEl.out); + break; + + // PARALLEL + case "210140": + p = board.create('parallelpoint', [gxtEl.defEl[1], gxtEl.defEl[0]], + {withLabel:false, visible:false, name:'', fixed:true}); + + // GEONExT uses its own parallel construction to make the order + // of intersection points compatible. + // el = board.create('parallel', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); + el = board.create('line', [gxtEl.defEl[0], p], gxtEl.out); + el.parallelpoint = p; + break; + + // PARALLELOGRAM_POINT + case "210150": + board.create('parallelpoint', gxtEl.defEl.slice(0, numberDefEls), gxtEl.out); + break; + + // PERPENDICULAR + case "210160": + // output[0] was already read and is stored in gxtEl.out + gxtEl.out.fixed = gxtReader.gEBTN(xmlNode, 'fix'); + + xmlNode = Data.getElementsByTagName('output')[1]; + gxtEl.outLine = {}; + gxtEl.outLine = gxtReader.defProperties(gxtEl.outLine, xmlNode); + gxtEl.outLine = gxtReader.colorProperties(gxtEl.outLine, xmlNode); + gxtEl.outLine = gxtReader.visualProperties(gxtEl.outLine, xmlNode); + gxtEl.outLine = gxtReader.firstLevelProperties(gxtEl.outLine, xmlNode); + gxtEl.outLine = gxtReader.readNodes(gxtEl.outLine, xmlNode, 'straight', 'straight'); + gxtEl.outLine = gxtReader.transformProperties(gxtEl.outLine); + gxtEl.outLine.point = gxtEl.out; + + board.create('perpendicularsegment', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.outLine); + break; + + // PERPENDICULAR_POINT + case "210170": + board.create('perpendicularpoint', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); + break; + + // ROTATION + case "210180": + throw new Error('JSXGraph: Element ROTATION not yet implemented.'); + break; + + // SECTOR + case "210190": + // sectors usually provide more than one output element but JSXGraph is not fully compatible + // to GEONExT sector elements. GEONExT sectors consist of two lines, a point, and a sector, + // JSXGraph uses a curve to display the sector incl. the borders, and + // a point and two lines. + // Gliders on sectors also run through the borders. + gxtEl.out = gxtReader.defProperties(gxtEl.out, xmlNode); + gxtEl.out.firstArrow = JXG.str2Bool(gxtReader.gEBTN(xmlNode, 'firstarrow')); + gxtEl.out.lastArrow = JXG.str2Bool(gxtReader.gEBTN(xmlNode, 'lastarrow')); + + // el = board.create('sector', gxtEl.defEl, gxtEl.out); + for (i=0; i<4;i++) { + xmlNode = Data.getElementsByTagName('output')[i]; + gxtEl.out = gxtReader.defProperties(gxtEl.out, xmlNode); + gxtEl.out = gxtReader.colorProperties(gxtEl.out, xmlNode); + gxtEl.out = gxtReader.visualProperties(gxtEl.out, xmlNode); + gxtEl.out = gxtReader.firstLevelProperties(gxtEl.out, xmlNode); + gxtEl.out = gxtReader.transformProperties(gxtEl.out); + + if (i==0) { + el = board.create('sector', gxtEl.defEl, gxtEl.out); + } else if (i==1) { + p = board.create('point', [ + function(){ + var p1 = JXG.getRef(board,gxtEl.defEl[1]), p2 = JXG.getRef(board,gxtEl.defEl[2]); + return p1.X() + (p2.X()-p1.X())*el.Radius/p1.Dist(p2); + }, + function(){ + var p1 = JXG.getRef(board,gxtEl.defEl[1]), p2 = JXG.getRef(board,gxtEl.defEl[2]); + return p1.Y() + (p2.Y()-p1.Y())*el.Radius/p1.Dist(p2); + }], gxtEl.out); + //p = JXG.getReference(board,gxtEl.defEl[2]); + } else if (i==2) { + el = board.create('segment', [gxtEl.defEl[0], gxtEl.defEl[1]], gxtEl.out); + } else if (i==3) { + el = board.create('segment', [gxtEl.defEl[1], p], gxtEl.out); + } + } + break; + default: + throw new Error("JSXGraph: GEONExT-Element " + gxtEl.type + ' not implemented.'); + break; + } + + // if (board.isSuspendedUpdate) { board.unsuspendUpdate().suspendUpdate(); } + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case "polygon": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + var dataVertex = []; + // In Geonext file format the first vertex is equal to the last vertex: + for (i = 0; i < Data.getElementsByTagName('data')[0].getElementsByTagName('vertex').length-1; i++) { + dataVertex[i] = Data.getElementsByTagName('data')[0].getElementsByTagName('vertex')[i].firstChild.data; + dataVertex[i] = gxtReader.changeOriginIds(board, dataVertex[i]); + } + gxtEl.border = []; + gxtEl.borders = { + ids: [] + }; + for (i = 0; i < Data.getElementsByTagName('border').length; i++) { + gxtEl.border[i] = {}; + xmlNode = Data.getElementsByTagName('border')[i]; + gxtEl.border[i].id = xmlNode.getElementsByTagName('id')[0].firstChild.data; + gxtEl.borders.ids.push(gxtEl.border[i].id); + gxtEl.border[i].name = xmlNode.getElementsByTagName('name')[0].firstChild.data; + gxtEl.border[i].straightFirst = JXG.str2Bool(xmlNode.getElementsByTagName('straight')[0].getElementsByTagName('first')[0].firstChild.data); + gxtEl.border[i].straightLast = JXG.str2Bool(xmlNode.getElementsByTagName('straight')[0].getElementsByTagName('last')[0].firstChild.data); + gxtEl.border[i].strokeWidth = xmlNode.getElementsByTagName('strokewidth')[0].firstChild.data; + gxtEl.border[i].dash = JXG.str2Bool(xmlNode.getElementsByTagName('dash')[0].firstChild.data); + gxtEl.border[i].visible = JXG.str2Bool(xmlNode.getElementsByTagName('visible')[0].firstChild.data); + gxtEl.border[i].draft = JXG.str2Bool(xmlNode.getElementsByTagName('draft')[0].firstChild.data); + gxtEl.border[i].trace = JXG.str2Bool(xmlNode.getElementsByTagName('trace')[0].firstChild.data); + + xmlNode = Data.getElementsByTagName('border')[i].getElementsByTagName('color')[0]; + rgbo = JXG.rgba2rgbo(xmlNode.getElementsByTagName('stroke')[0].firstChild.data); + gxtEl.border[i].strokeColor = rgbo[0]; + gxtEl.border[i].strokeOpacity = rgbo[1]; + + rgbo = JXG.rgba2rgbo(xmlNode.getElementsByTagName('lighting')[0].firstChild.data); + gxtEl.border[i].highlightStrokeColor = rgbo[0]; + gxtEl.border[i].highlightStrokeOpacity = rgbo[1]; + + rgbo = JXG.rgba2rgbo(xmlNode.getElementsByTagName('fill')[0].firstChild.data); + gxtEl.border[i].fillColor = rgbo[0]; + gxtEl.border[i].fillOpacity = rgbo[1]; + + gxtEl.border[i].highlightFillColor = gxtEl.border[i].fillColor; + gxtEl.border[i].highlightFillOpacity = gxtEl.border[i].fillOpacity; + + gxtEl.border[i].labelColor = xmlNode.getElementsByTagName('label')[0].firstChild.data; + gxtEl.border[i].colorDraft = xmlNode.getElementsByTagName('draft')[0].firstChild.data; + } + gxtEl = gxtReader.transformProperties(gxtEl); + p = board.create('polygon', dataVertex, gxtEl); + + // to emulate the geonext behaviour on invisible polygons + // A.W.: Why do we need this? +/* + if (!gxtEl.visible) { + p.setProperty({ + fillColor: 'none', + highlightFillColor: 'none' + }); + } +*/ + for (i = 0; i < p.borders.length; i++) { + p.borders[i].setProperty(gxtEl.border[i]); + } + + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case "graph": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl.funct = Data.getElementsByTagName('data')[0].getElementsByTagName('function')[0].firstChild.data; + if (false) { + gxtEl.funct = JXG.GeonextParser.gxt2jc(gxtEl.funct, board); // Handle weird element names + } else { // Workaround until the jessiecode compiler is 100% compatible + gxtEl.funct = JXG.GeonextParser.geonext2JS(gxtEl.funct, board); + gxtEl.funct = new Function('x', 'return ' + gxtEl.funct + ';'); + } + + c = board.create('curve', ['x', gxtEl.funct], { + id: gxtEl.id, + name: gxtEl.name, + strokeColor: gxtEl.strokeColor, + strokeWidth: gxtEl.strokeWidth, + fillColor: 'none', + highlightFillColor: 'none', + highlightStrokeColor: gxtEl.highlightStrokeColor, + visible: JXG.str2Bool(gxtEl.visible) + }); + + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case "arrow": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + gxtEl = gxtReader.readNodes(gxtEl, Data, 'straight', 'straight'); + + gxtEl = gxtReader.transformProperties(gxtEl); + gxtEl.first = gxtReader.changeOriginIds(board, gxtEl.first); + gxtEl.last = gxtReader.changeOriginIds(board, gxtEl.last); + + l = board.create('arrow', [gxtEl.first, gxtEl.last], gxtEl); + + gxtReader.printDebugMessage('debug', l, Data.nodeName, 'OK'); + break; + case "arc": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + + gxtEl.firstArrow = JXG.str2Bool(Data.getElementsByTagName('lastarrow')[0].firstChild.data); // It seems that JSXGraph and GEONExT + gxtEl.lastArrow = JXG.str2Bool(Data.getElementsByTagName('firstarrow')[0].firstChild.data); // use opposite directions. + + gxtEl = gxtReader.transformProperties(gxtEl); + + gxtEl.center = gxtReader.changeOriginIds(board, gxtEl.midpoint); + gxtEl.angle = gxtReader.changeOriginIds(board, gxtEl.angle); + gxtEl.radius = gxtReader.changeOriginIds(board, gxtEl.radius); + + c = board.create('arc', [gxtEl.center, gxtEl.radius, gxtEl.angle], gxtEl); + + gxtReader.printDebugMessage('debug', c, Data.nodeName, 'OK'); + break; + case "angle": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + gxtEl = gxtReader.transformProperties(gxtEl); + + tmp = gxtEl.name; + try { + gxtEl.name = Data.getElementsByTagName('text')[0].firstChild.data; + } catch (e) { + gxtEl.name = ''; + } + c = board.create('angle', [gxtEl.first, gxtEl.middle, gxtEl.last], gxtEl); + c.setProperty({name:tmp}); + + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case "text": + if (gxtEl.id.match(/oldVersion/)) { + break; + } + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + gxtEl.mpStr = gxtReader.subtreeToString(Data.getElementsByTagName('data')[0].getElementsByTagName('mp')[0]); + gxtEl.mpStr = gxtEl.mpStr.replace(/<\/?mp>/g, ''); + gxtEl.fixed = false; + try { + if (Data.getElementsByTagName('data')[0].getElementsByTagName('parent')[0].firstChild) { + gxtEl.parent = Data.getElementsByTagName('data')[0].getElementsByTagName('parent')[0].firstChild.data; + gxtEl.fixed = true; + } + } catch (e) { + } + + gxtEl.condition = Data.getElementsByTagName('condition')[0].firstChild.data; + gxtEl.content = Data.getElementsByTagName('content')[0].firstChild.data; + gxtEl.fix = Data.getElementsByTagName('fix')[0].firstChild.data; + // not used: gxtEl.digits = Data.getElementsByTagName('cs')[0].firstChild.data; + gxtEl.autodigits = Data.getElementsByTagName('digits')[0].firstChild.data; + gxtEl.parent = gxtReader.changeOriginIds(board, gxtEl.parent); + + c = board.create('text', [gxtEl.x, gxtEl.y, gxtEl.mpStr], { + anchor: gxtEl.parent, + id: gxtEl.id, + name: gxtEl.name, + digits: gxtEl.autodigits, + isLabel: false, + strokeColor: gxtEl.colorLabel, + fixed: gxtEl.fixed, + visible: JXG.str2Bool(gxtEl.visible) + }); + break; + case 'parametercurve': + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl = gxtReader.transformProperties(gxtEl); + gxtEl.functionx = Data.getElementsByTagName('functionx')[0].firstChild.data; + gxtEl.functiony = Data.getElementsByTagName('functiony')[0].firstChild.data; + gxtEl.min = Data.getElementsByTagName('min')[0].firstChild.data; + gxtEl.max = Data.getElementsByTagName('max')[0].firstChild.data; + /* + gxtEl.functionx = JXG.GeonextParser.gxt2jc(gxtEl.functionx, board); + gxtEl.functiony = JXG.GeonextParser.gxt2jc(gxtEl.functiony, board); + gxtEl.min = JXG.GeonextParser.gxt2jc(gxtEl.min, board); + gxtEl.max = JXG.GeonextParser.gxt2jc(gxtEl.max, board); + */ + gxtEl.fillColor = 'none'; + gxtEl.highlightFillColor = 'none'; + + board.create('curve', + [ new Function('t', 'return ' + JXG.GeonextParser.geonext2JS(gxtEl.functionx, board) + ';' ), + new Function('t', 'return ' + JXG.GeonextParser.geonext2JS(gxtEl.functiony, board) + ';' ), + new Function('return ' + JXG.GeonextParser.geonext2JS(gxtEl.min, board) + ';' ), + new Function('return ' + JXG.GeonextParser.geonext2JS(gxtEl.max, board) + ';' ) + ], gxtEl); + /* + c = new JXG.Curve(board, [ + 't',gxtEl.functionx,gxtEl.functiony,gxtEl.min,gxtEl.max + ], gxtEl.id, gxtEl.name); + c.setProperty('strokeColor:' + gxtEl.colorStroke, 'strokeWidth:' + gxtEl.strokewidth, 'fillColor:none', + 'highlightStrokeColor:' + gxtEl.highlightStrokeColor); + */ + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case 'tracecurve': + gxtEl.tracepoint = Data.getElementsByTagName('tracepoint')[0].firstChild.data; + gxtEl.traceslider = Data.getElementsByTagName('traceslider')[0].firstChild.data; + board.create('tracecurve', [gxtEl.traceslider, gxtEl.tracepoint], gxtEl); + // JXG.getRef(board, gxtEl.tracepoint).setProperty({trace:true}); + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case 'group': + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl.members = [ + ]; + for (i = 0; i < Data.getElementsByTagName('data')[0].getElementsByTagName('member').length; i++) { + gxtEl.members[i] = Data.getElementsByTagName('data')[0].getElementsByTagName('member')[i].firstChild.data; + gxtEl.members[i] = gxtReader.changeOriginIds(board, gxtEl.members[i]); + } + c = new JXG.Group(board, gxtEl.id, gxtEl.name, gxtEl.members); + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + default: + JXG.debug("* Err: " + Data.nodeName + " not yet implemented
\n"); + } + delete(gxtEl); + })(s); + } + board.addConditions(conditions); + }, + + decodeString: function(str) { + var unz; + if (str.indexOf("")<0){ + unz = (new JXG.Util.Unzip(JXG.Util.Base64.decodeAsArray(str))).unzip(); // war Gunzip ME + if (unz=="") + return str; + else + return unz; + } else { + return str; + } + }, + + prepareString: function(fileStr){ + try { + if (fileStr.indexOf('GEONEXT')<0) { + fileStr = (this.decodeString(fileStr))[0][0]; // Base64 decoding + } + // Hacks to enable not well formed XML. Will be redone in Algebra.geonext2JS and Board.addConditions + fileStr = this.fixXML(fileStr); + } catch(e) { + fileStr = ''; + } + return fileStr; + }, + + fixXML: function(str) { + var arr = ["active", "angle", "animate", "animated", "arc", "area", "arrow", "author", "autodigits", "axis", "back", "background", "board", "border", "bottom", "buttonsize", "cas", "circle", "color", "comment", "composition", "condition", "conditions", "content", "continuous", "control", "coord", "coordinates", "cross", "cs", "dash", "data", "description", "digits", "direction", "draft", "editable", "elements", "event", "file", "fill", "first", "firstarrow", "fix", "fontsize", "free", "full", "function", "functionx", "functiony", "GEONEXT", "graph", "grid", "group", "height", "id", "image", "info", "information", "input", "intersection", "item", "jsf", "label", "last", "lastarrow", "left", "lefttoolbar", "lighting", "line", "loop", "max", "maximized", "member", "middle", "midpoint", "min", "modifier", "modus", "mp", "mpx", "multi", "name", "onpolygon", "order", "origin", "output", "overline", "parametercurve", "parent", "point", "pointsnap", "polygon", "position", "radius", "radiusnum", "radiusvalue", "right", "section", "selectedlefttoolbar", "showconstruction", "showcoord", "showinfo", "showunit", "showx", "showy", "size", "slider", "snap", "speed", "src", "start", "stop", "straight", "stroke", "strokewidth", "style", "term", "text", "top", "trace", "tracecurve", "tracepoint", "traceslider", "type", "unit", "value", "VERSION", "vertex", "viewport", "visible", "width", "wot", "x", "xooy", "xval", "y", "yval", "zoom"], + list = arr.join('|'), + regex = '\<(/?('+list+'))\>', + expr = new RegExp(regex,'g'); + + // First, we convert all < to < and > to > + str = JXG.escapeHTML(str); + // Second, we convert all GEONExT tags of the form <tag> back to + str = str.replace(expr,'<$1>'); + + str = str.replace(/(.*)(.*<\/content>)/g,'$1<arc>$2'); + str = str.replace(/(.*)(.*<\/mpx>)/g,'$1<arc>$2'); + str = str.replace(/(.*)(.*<\/mpx>)/g,'$1<arc>$2'); + return str; + } + +}; // end: GeonextReader diff --git a/ajax/libs/jsxgraph/0.94/IntergeoReader.js b/ajax/libs/jsxgraph/0.94/IntergeoReader.js new file mode 100644 index 000000000..4a5aacaba --- /dev/null +++ b/ajax/libs/jsxgraph/0.94/IntergeoReader.js @@ -0,0 +1,967 @@ +/* + Copyright 2008,2009 + Matthias Ehmann, + Michael Gerhaeuser, + Carsten Miller, + Bianca Valentin, + Alfred Wassermann, + Peter Wilfahrt + + This file is part of JSXGraph. + + JSXGraph is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + JSXGraph is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with JSXGraph. If not, see . + +*/ + +/* Compatibility for <= 0.75.4 */ +/* +JXG.getReference = function(board, object) { + return JXG.GetReferenceFromParameter(board, object); +}; +*/ + +JXG.IntergeoReader = new function() { + this.board = null; + /** + * this.objects holds all objects from the XML file. + * Every object hets an attribute "exists" + */ + this.objects = {}; + + this.readIntergeo = function(tree,board) { + this.board = board; + this.board.origin = {}; + this.board.origin.usrCoords = [1, 0, 0]; + this.board.origin.scrCoords = [1, 400, 300]; + this.board.unitX = 30; + this.board.unitY = 30; + + this.readElements(tree.getElementsByTagName("elements")); + this.readConstraints(tree.getElementsByTagName("constraints")); + this.cleanUp(); + this.board.fullUpdate(); + this.readDisplay(tree.getElementsByTagName("display")); + this.board.fullUpdate(); + }; + + /** + * Element part + */ + this.readElements = function(tree) { + var s; + for (var s=0;s1) { return; } // not an element node + if (node.nodeName=='point') { + JXG.IntergeoReader.storePoint(node); //addPoint(node); + } + else if (node.nodeName=='line' + || node.nodeName=='line_segment' + || node.nodeName=='ray' + || node.nodeName=='vector' + ) { + JXG.IntergeoReader.storeLine(node); + } + else if (node.nodeName=='circle') { + JXG.IntergeoReader.storeConic(node); + } + else if (node.nodeName=='conic') { + JXG.IntergeoReader.storeConic(node); + } + else if (node.nodeName=='polygon') { + // ignore, see this.addPolygonByVertices + } + else { + JXG.debug('Not implemented: '+node.nodeName + ' ' + node.getAttribute('id')); + } + })(s); + }; + + /** + * Points are created instantly via create + */ + this.addPointOld = function(node) { + var i = 0, + j = 0, + l = 0, + el, + p = node.childNodes[i], + c = [], + attributes = {strokeColor:'red', fillColor:'red', withLabel:true}, + parents = []; + + while (p.nodeType>1) { // skip non element nodes + i++; + p = node.childNodes[i]; + } + + attributes['name'] = node.getAttribute('id'); + + if (p.nodeName == 'homogeneous_coordinates') { + for (j=0;j... + } else if (p.childNodes[j].nodeName=='complex') { + for (l=0;l + return; + } + } + } + for (j=0;j + return; + } + } else if (p.nodeName == 'euclidean_coordinates') { + for (j=0;j... + } + } + for (j=0;j... + } + } + for (j=0;j1) { // skip non element nodes + i++; + p = node.childNodes[i]; + } + + if (p.nodeName == 'homogeneous_coordinates') { + for (j=0;j... + } else if (p.childNodes[j].nodeName=='complex') { + for (l=0;l + return; + } + } + } + for (j=0;j + return; + } + } else if (p.nodeName == 'euclidean_coordinates' || p.nodeName == 'euclidian_coordinates') { // the latter one is a workaround for faulty i2g construction exported by DynaGeo + for (j=0;j... + } + } + for (j=0;j... + } + } + for (j=0;j1) { // skip non element nodes + i++; + p = node.childNodes[i]; + } + if (p.nodeName == 'homogeneous_coordinates') { + c = []; + for (j=0;j... + } else { + //$('debug').innerHTML += 'Not: '+ p.childNodes[j].nodeName + '
'; // + } + } + } + this.objects[node.getAttribute('id')].coords = c; + this.objects[node.getAttribute('id')].id = node.getAttribute('id'); + this.objects[node.getAttribute('id')].exists = false; + this.objects[node.getAttribute('id')].i2geoType = 'line'; + } + //this.addLine(node.getAttribute('id')); + }; + + /** + * Circle / conic data is stored in an array + * for further access during the reading of constraints. + * There, id and name are needed. + * Concretely, the circle (x-1)^2 + (y-3)^2 = 4 has matrix + * ( 1 0 -1 ) + * ( 0 1 -3 ) + * ( -1 -3 6 ) + * + * In general + * Ax^2+Bxy+Cy^2+Dx+Ey+F = 0 + * is stored as + * ( A B/2 D/2 ) + * ( B/2 C E/2 ) + * ( D/2 E/2 F ) + * + * Mx = D/A + * My = E/C + * r = A*Mx^2+B*My^2-F + **/ + this.storeConic = function(node) { + var i, j, p, c; + + this.objects[node.getAttribute('id')] = {'id':node.getAttribute('id'), 'coords':null}; + i = 0; + p = node.childNodes[i]; + while (p.nodeType>1) { // skip non element nodes + i++; + p = node.childNodes[i]; + } + if (p.nodeName == 'matrix') { + c = []; + for (j=0;j... + } else { + //$('debug').innerHTML += 'Not: '+ p.childNodes[j].nodeName + '
'; // + } + } + } + this.objects[node.getAttribute('id')].coords = c; + this.objects[node.getAttribute('id')].id = node.getAttribute('id'); + this.objects[node.getAttribute('id')].exists = false; + this.objects[node.getAttribute('id')].i2geoType = 'conic'; + } + }; + + /** + * Constraint part + */ + this.readConstraints = function(tree) { + var s, param; + + // Set the default colors of dependent elements + this.board.options.point.strokeColor = 'blue'; + this.board.options.point.fillColor = 'blue'; + + for (s=0;s1) { return; } // not an element node + if (node.nodeName=='line_through_two_points') { + JXG.IntergeoReader.addLineThroughTwoPoints(node, false); + } + else if (node.nodeName=='ray_from_point_through_point') { + JXG.IntergeoReader.addLineThroughTwoPoints(node, true); + } + else if (node.nodeName=='line_through_point') { + JXG.IntergeoReader.addLineThroughPoint(node); + } + else if (node.nodeName=='line_parallel_to_line_through_point') { + JXG.IntergeoReader.addLineParallelToLineThroughPoint(node, false); + } + else if (node.nodeName=='ray_from_point_and_vector') { + JXG.IntergeoReader.addLineParallelToLineThroughPoint(node, true); + } + else if (node.nodeName=='line_perpendicular_to_line_through_point') { + JXG.IntergeoReader.addLinePerpendicularToLineThroughPoint(node); + } + else if (node.nodeName=='line_segment_by_points') { + JXG.IntergeoReader.addLineSegmentByTwoPoints(node); + } + else if (node.nodeName=='vector_from_point_to_point') { + JXG.IntergeoReader.addVectorFromPointToPoint(node); + } + else if (node.nodeName=='endpoints_of_line_segment') { + JXG.IntergeoReader.addEndpointsOfLineSegment(node); + } + else if (node.nodeName=='free_point') { + // do nothing + } + else if (node.nodeName=='free_line') { + JXG.IntergeoReader.addFreeLine(node); + } + else if (node.nodeName=='point_on_line') { + JXG.IntergeoReader.addPointOnLine(node); + } + else if (node.nodeName=='point_on_line_segment') { + JXG.IntergeoReader.addPointOnLine(node); + } + else if (node.nodeName=='point_on_circle') { + JXG.IntergeoReader.addPointOnCircle(node); + } + else if (node.nodeName=='angular_bisector_of_three_points') { + JXG.IntergeoReader.addAngularBisectorOfThreePoints(node, false); + } + else if (node.nodeName=='angular_bisectors_of_two_lines') { + JXG.IntergeoReader.addAngularBisectorsOfTwoLines(node, false); + } + else if (node.nodeName=='line_angular_bisector_of_three_points') { + JXG.IntergeoReader.addAngularBisectorOfThreePoints(node, true); + } + else if (node.nodeName=='line_angular_bisectors_of_two_lines') { + JXG.IntergeoReader.addAngularBisectorsOfTwoLines(node, true); + } + else if (node.nodeName=='midpoint_of_two_points') { + JXG.IntergeoReader.addMidpointOfTwoPoints(node); + } + else if (node.nodeName=='midpoint') { + JXG.IntergeoReader.addMidpointOfTwoPoints(node); + } + else if (node.nodeName=='midpoint_of_line_segment' || node.nodeName=='midpoint_line_segment') { + JXG.IntergeoReader.addMidpointOfLineSegment(node); + } + else if (node.nodeName=='point_intersection_of_two_lines') { + JXG.IntergeoReader.addPointIntersectionOfTwoLines(node); + } + else if (node.nodeName=='locus_defined_by_point') { + JXG.IntergeoReader.addLocusDefinedByPoint(node); + } + else if (node.nodeName=='locus_defined_by_point_on_line') { + JXG.IntergeoReader.addLocusDefinedByPointOnLine(node); + } + else if (node.nodeName=='locus_defined_by_point_on_line_segment') { + JXG.IntergeoReader.addLocusDefinedByPointOnLine(node); + } + else if (node.nodeName=='locus_defined_by_line_through_point') { + JXG.IntergeoReader.addLocusDefinedByLineThroughPoint(node); + } + else if (node.nodeName=='locus_defined_by_point_on_circle') { + JXG.IntergeoReader.addLocusDefinedByPointOnCircle(node); + } + else if (node.nodeName=='circle_by_three_points') { + JXG.IntergeoReader.addCircleByThreePoints(node); + } + else if (node.nodeName=='circle_by_center_and_point') { + JXG.IntergeoReader.addCircleByCenterAndPoint(node); + } + else if (node.nodeName=='center_of_circle') { + JXG.IntergeoReader.addCenterOfCircle(node); + } + else if (node.nodeName=='intersection_points_of_two_circles') { + JXG.IntergeoReader.addIntersectionPointsOfTwoCircles(node); + } + else if (node.nodeName=='intersection_points_of_circle_and_line') { + JXG.IntergeoReader.addIntersectionPointsOfCircleAndLine(node); + } + else if (node.nodeName=='other_intersection_point_of_two_circles') { + JXG.IntergeoReader.addOtherIntersectionPointOfTwoCircles(node); + } + else if (node.nodeName=='other_intersection_point_of_circle_and_line') { + JXG.IntergeoReader.addOtherIntersectionPointOfCircleAndLine(node); + } + else if (node.nodeName=='circle_tangent_lines_by_point') { + JXG.IntergeoReader.addCircleTangentLinesByPoint(node); + } + else if (node.nodeName=='polygon_by_vertices') { + JXG.IntergeoReader.addPolygonByVertices(node); + } + else { + param = JXG.IntergeoReader.readParams(node); + JXG.debug('readConstraints: not implemented: ' + node.nodeName + ': ' + param[0]); + } + })(s); + }; + + this.setAttributes = function(o) { + o.setProperty({strokecolor:this.board.options.point.strokeColor,fillColor:this.board.options.point.fillColor}); + }; + + this.readParams = function(node) { + var param = [], j; + for (j=0;j1) { return; } // not an element node + if (node.nodeName=='background-color') { + this.board.containerObj.style.backgroundColor = node.firstChild.data; + } + else if (node.nodeName=='style') { + el = JXG.getReference(this.board,node.getAttribute('ref')); // get the element + var param = [], j; + for (j=0;j. +*/ + var JXG={};(function(){var e,f;JXG.countDrawings=0;JXG.countTime=0;JXG.require=function(g){};JXG.rendererFiles=[];JXG.rendererFiles.svg="SVGRenderer";JXG.rendererFiles.vml="VMLRenderer";JXG.rendererFiles.canvas="CanvasRenderer";JXG.baseFiles=null;JXG.requirePath="";for(e=0;e-1},isWebkitAndroid:function(){return this.isAndroid()&&navigator.userAgent.search(" AppleWebKit/")>-1},isApple:function(){return(navigator.userAgent.search(/iPad/)!=-1||navigator.userAgent.search(/iPhone/)!=-1)},isWebkitApple:function(){return this.isApple()&&(navigator.userAgent.search(/Mobile *.*Safari/)>-1)},clearVisPropOld:function(e){e.visPropOld={strokecolor:"",strokeopacity:"",strokewidth:"",fillcolor:"",fillopacity:"",shadow:false,firstarrow:false,lastarrow:false}},ieVersion:(function(){var g,e=3,h=document.createElement("div"),f=h.getElementsByTagName("i");while(h.innerHTML="",f[0]){}return e>4?e:g}()),getReference:function(f,e){if(typeof(e)=="string"){if(JXG.exists(f.objects[e])){e=f.objects[e]}else{if(JXG.exists(f.elementsByName[e])){e=f.elementsByName[e]}else{if(JXG.exists(f.groups[e])){e=f.groups[e]}}}}return e},getRef:JXG.shortcut(JXG,"getReference"),isId:function(f,e){return typeof(e)=="string"&&!!f.objects[e]},isName:function(f,e){return typeof(e)=="string"&&!!f.elementsByName[e]},isGroup:function(f,e){return typeof(e)=="string"&&!!f.groups[e]},isString:function(e){return typeof e==="string"},isNumber:function(e){return typeof e==="number"},isFunction:function(e){return typeof e==="function"},isArray:function(e){return e!==null&&typeof e==="object"&&"splice" in e&&"join" in e},isPoint:function(e){if(typeof e=="object"){return(e.elementClass==JXG.OBJECT_CLASS_POINT)}return false},exists:(function(e){return function(f){return !(f===e||f===null)}})(),def:function(e,f){if(JXG.exists(e)){return e}else{return f}},str2Bool:function(e){if(!JXG.exists(e)){return true}if(typeof e=="boolean"){return e}return(e.toLowerCase()=="true")},_board:function(f,e){return JXG.JSXGraph.initBoard(f,e)},createEvalFunction:function(g,k,l){var h=[],e,j;for(e=0;e=o[h].length;f++){e=0;while(e0){JXG.removeEvent(g,f,e["x_internal"+f][0].origin,e)}}},bind:function(f,e){return function(){return f.apply(e,arguments)}},removeElementFromArray:function(e,g){var f;for(f=0;f=9){e=g.currentStyle[f]}else{if(g.style){f=f.replace(/-([a-z]|[0-9])/ig,function(h,i){return(i+"").toUpperCase()});e=g.style[f]}}}return e},keys:function(e,f){var g=[],h;for(h in e){if(f){if(e.hasOwnProperty(h)){g.push(h)}}else{g.push(h)}}return g},indexOf:function(g,f){var e;if(Array.indexOf){return g.indexOf(f)}for(e=0;e/g,">")},unescapeHTML:function(e){return e.replace(/<\/?[^>]+>/gi,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")},clone:function(f){var e={};e.prototype=f;return e},cloneAndCopy:function(h,g){var e=function(){},f;e.prototype=h;for(f in g){e[f]=g[f]}return e},deepCopy:function(l,k,h){var n,f,m,e,g;h=h||false;if(typeof l!=="object"||l==null){return l}if(this.isArray(l)){n=[];for(f=0;f0&&(+new Date()-j<300));if(e.length>0){setTimeout(arguments.callee,1)}else{i(f)}},1)},trimNumber:function(e){e=e.replace(/^0+/,"");e=e.replace(/0+$/,"");if(e[e.length-1]=="."||e[e.length-1]==","){e=e.slice(0,-1)}if(e[0]=="."||e[0]==","){e="0"+e}return e},trim:function(e){e=e.replace(/^\s+/,"");e=e.replace(/\s+$/,"");return e},evaluate:function(e){if(JXG.isFunction(e)){return e()}else{return e}},eliminateDuplicates:function(g){var h,f=g.length,e=[],j={};for(h=0;h"}}}},debugWST:function(f){var g;JXG.debug(f);if(window.console&&console.log){g=new Error();if(g&&g.stack){console.log("stacktrace");console.log(g.stack.split("\n").slice(1).join("\n"))}}}});JXG.addEvent(window,"load",function(){var k=document.getElementsByTagName("script"),o,m,l,f,n,g,q,p,h,e;for(m=0;m0?l[0].length:0,w=l.length,v=this.matrix(q,p),u,t,z,r;for(u=0;u0?r[0].length:0;o=this.matrix(q,k);for(p=0;pC){C=e.abs(o[v][u]);l=v}}if(C<=f.Math.eps){return false}if(l>u){for(t=0;to||l<0){return NaN}l=e.round(l);o=e.round(o);if(l===0||l===o){return 1}j=1;for(m=0;m0){return e.exp(i*e.log(e.abs(j)))}else{return NaN}}},squampow:function(k,j){var i;if(e.floor(j)===j){i=1;if(j<0){k=1/k;j*=-1}while(j!=0){if(j&1){i*=k}j>>=1;k*=k}return i}else{return this.pow(k,j)}},normalize:function(k){var i=2*k[3],l=k[4]/(i),m,j;k[5]=l;k[6]=-k[1]/i;k[7]=-k[2]/i;if(l===Infinity||isNaN(l)){m=e.sqrt(k[1]*k[1]+k[2]*k[2]);k[0]/=m;k[1]/=m;k[2]/=m;k[3]=0;k[4]=1}else{if(e.abs(l)>=1){k[0]=(k[6]*k[6]+k[7]*k[7]-l*l)/(2*l);k[1]=-k[6]/l;k[2]=-k[7]/l;k[3]=1/(2*l);k[4]=1}else{j=(l<=0)?(-1):(1);k[0]=j*(k[6]*k[6]+k[7]*k[7]-l*l)*0.5;k[1]=-j*k[6];k[2]=-j*k[7];k[3]=j/2;k[4]=j*l}}return k},toGL:function(k){var l,o,n;if(typeof Float32Array!=="undefined"){l=new Float32Array(16)}else{l=new Array(16)}if(k.length!==4&&k[0].length!==4){return l}for(o=0;o<4;o++){for(n=0;n<4;n++){l[o+4*n]=k[o][n]}}return l}}})(JXG,Math);JXG.Math.Numerics=(function(f,e){var g={rk4:{s:4,A:[[0,0,0,0],[0.5,0,0,0],[0,0.5,0,0],[0,0,1,0]],b:[1/6,1/3,1/3,1/6],c:[0,0.5,0.5,1]},heun:{s:2,A:[[0,0],[1,0]],b:[0.5,0.5],c:[0,1]},euler:{s:1,A:[[0]],b:[1],c:[0]}};return{Gauss:function(h,s){var u=f.Math.eps,l=h.length>0?h[0].length:0,q,t,r,p,o,m=function(v,n){var k=this[v];this[v]=this[n];this[n]=k};if((l!==s.length)||(l!==h.length)){throw new Error("JXG.Math.Numerics.Gauss: Dimensions don't match. A must be a square matrix and b must be of the same length as A.")}q=new Array(l);t=s.slice(0,l);for(r=0;rp;r--){if(e.abs(q[r][p])>u){if(e.abs(q[p][p])0?r[0].length:0;for(p=h-1;p>=0;p--){for(o=s-1;o>p;o--){k[p]-=r[p][o]*k[o]}k[p]/=r[p][p]}return k},gaussBareiss:function(v){var m,u,A,q,o,h,l,r,w,z=f.Math.eps;l=v.length;if(l<=0){return 0}if(v[0].length=z){break}}if(q==l){return 0}for(o=m;or){r=h}v+=h;if(h>=D){h=e.atan2(2*l[s][q],l[s][s]-l[q][q])*0.5;t=e.sin(h);B=e.cos(h);for(p=0;pD&&u<2000);return[l,o]},NewtonCotes:function(h,l,j){var m=0,q=j&&typeof j.number_of_nodes==="number"?j.number_of_nodes:28,o={trapez:true,simpson:true,milne:true},r=j&&j.integration_type&&o.hasOwnProperty(j.integration_type)&&o[j.integration_type]?j.integration_type:"milne",p=(h[1]-h[0])/q,n,k,s;switch(r){case"trapez":m=(l(h[0])+l(h[1]))*0.5;n=h[0];for(k=0;k0){throw new Error("JSXGraph: INT_SIMPSON requires config.number_of_nodes dividable by 2.")}s=q/2;m=l(h[0])+l(h[1]);n=h[0];for(k=0;k0){throw new Error("JSXGraph: Error in INT_MILNE: config.number_of_nodes must be a multiple of 4")}s=q*0.25;m=7*(l(h[0])+l(h[1]));n=h[0];for(k=0;kn){q=this.D(p,k)(j);m+=2;if(e.abs(q)>n){j-=o/q}else{j+=(e.random()*0.2-1)}o=p.apply(k,[j]);m++;l++}return j},root:function(j,h,i){return this.fzero(j,h,i)},Neville:function(l){var i=[],h=function(m){return function(w,n){var p,v,z,A=f.Math.binomial,u=l.length,o=u-1,q=0,r=0;if(!n){z=1;for(p=0;p=0;o--){u[o]=(q[o]-(v[o+1]*u[o+1]))/p[o]}for(o=h-3;o>=0;o--){u[o+1]=u[o]}u[0]=0;u[h-1]=0;return u},splineEval:function(k,z,v,B){var m=e.min(z.length,v.length),p=1,o=false,A=[],r,q,w,u,t,s,h;if(f.isArray(k)){p=k.length;o=true}else{k=[k]}for(r=0;rz[m-1])){return NaN}for(q=1;q=0;l--){m=m.concat(["(",h[l].toPrecision(k),")"]);if(l>1){m=m.concat(["*",j,"",l,"<","/sup> + "])}else{if(l===1){m=m.concat(["*",j," + "])}}}return m.join("")},lagrangePolynomial:function(j){var h=[],i=function(v,l){var o,m,r,u,w,p=0,q=0,t,n;r=j.length;if(!l){for(o=0;o=o-3){return l[o-2][n]()}}r=e.floor(q);if(r==q){return l[r][n]()}q-=r;u=i[n][r];return 0.5*(((u[3]*q+u[2])*q+u[1])*q+u[0])}};return[h("X"),h("Y"),0,function(){return j.length-1}]},regressionPolynomial:function(l,p,o){var h,i,n,m,j,q,k="";if(f.isPoint(l)&&typeof l.Value=="function"){i=function(){return l.Value()}}else{if(f.isFunction(l)){i=l}else{if(f.isNumber(l)){i=function(){return l}}else{throw new Error("JSXGraph: Can't create regressionPolynomial from degree of type'"+(typeof l)+"'.")}}}if(arguments.length==3&&f.isArray(p)&&f.isArray(o)){j=0}else{if(arguments.length==2&&f.isArray(p)&&p.length>0&&f.isPoint(p[0])){j=1}else{throw new Error("JSXGraph: Can't create regressionPolynomial. Wrong parameters.")}}q=function(F,r){var v,u,C,z,E,t,D,G,A,w=p.length;A=e.floor(i());if(!r){if(j===1){n=[];m=[];for(v=0;v=0;v--){G=(G*F+h[v])}return G};q.getTerm=function(){return k};return q},bezier:function(j){var h,i=function(k){return function(m,l){var p=e.floor(m)*3,o=m%1,n=1-o;if(!l){h=e.floor(j.length/3)}if(m<0){return j[0][k]()}if(m>=h){return j[j.length-1][k]()}if(isNaN(m)){return NaN}return n*n*(n*j[p][k]()+3*o*j[p+1][k]())+(3*n*j[p+2][k]()+o*j[p+3][k]())*o*o}};return[i("X"),i("Y"),0,function(){return e.floor(j.length/3)}]},bspline:function(k,h){var l,n=[],m=function(r,o){var p,q=[];for(p=0;p=B){v=0}else{v=u[q+1]}z=C[q+r-1]-C[q];if(z==0){u[q]=0}else{u[q]=(A-C[q])/z*w}z=C[q+r]-C[q+1];if(z!=0){u[q]+=(C[q+r]-A)/z*v}}}return u},i=function(o){return function(v,q){var p=k.length,A,u,w,z=p-1,r=h;if(z<=0){return NaN}if(z+2<=r){r=z+1}if(v<=0){return k[0][o]()}if(v>=z-r+2){return k[z][o]()}l=m(z,r);w=e.floor(v)+r-1;n=j(v,l,z,r,w);A=0;for(u=w-r+1;u<=w;u++){if(u=0){A+=k[u][o]()*n[u]}}return A}};return[i("X"),i("Y"),0,function(){return k.length-1}]},D:function(k,l){var j=0.00001,i=1/(j*2);if(arguments.length==1||(arguments.length>1&&!f.exists(arguments[1]))){return function(h,m){return(k(h+j,m)-k(h-j,m))*i}}else{return function(h,m){return(k.apply(l,[h+j,m])-k.apply(l,[h-j,m]))*i}}},riemann:function(s,o,t,l,p){var m=[],A=[],r,q=0,z,w=l,u,k,v,h;o=e.round(o);m[q]=w;A[q]=0;if(o>0){z=(p-l)/o;h=z*0.01;for(r=0;ru){u=v}}}}}}q++;m[q]=w;A[q]=u;q++;w+=z;if(t==="trapezodial"){u=s(w)}m[q]=w;A[q]=u;q++;m[q]=w;A[q]=0}}return[m,A]},riemannsum:function(p,l,r,k,m){var q=0,o,v,u=k,s,j,t,h;l=e.floor(l);if(l>0){v=(m-k)/l;h=v*0.01;for(o=0;os){s=t}}}}}}}q+=v*s;u+=v}}return q},rungeKutta:function(m,H,p,n,G){var q=[],o=[],F=(p[1]-p[0])/n,v=p[0],J,E,D,B,A,C=H.length,w,u=[],z=0;if(f.isString(m)){m=g[m]||g.euler}w=m.s;for(J=0;J0){if(f.isArray(J)){return this.fminbr(I,[M,L],O)}else{return this.Newton(I,M,O)}}K=M;w=C;while(A=H&&e.abs(C)>e.abs(z)){t=K-L;if(M==K){m=z/C;v=t*m;s=1-m}else{s=C/w;m=z/w;l=z/C;v=l*(t*s*(s-m)-(L-M)*(m-1));s=(s-1)*(m-1)*(l-1)}if(v>0){s=-s}else{v=-v}if(v<(0.75*t*s-e.abs(H*s)*0.5)&&v0){n=H}else{n=-H}}M=L;C=z;L+=n;z=I.apply(O,[L]);D++;if((z>0&&w>0)||(z<0&&w<0)){K=M;w=C}A++}return L},fminbr:function(I,J,N){var M,K,m,s,o,i,k,j,A=(3-e.sqrt(5))*0.5,F=f.Math.eps,C=e.sqrt(f.Math.eps),h=this.maxIterationsMinimize,E=0,z,L,H,n,D,B,u,l,G=0;if(!f.isArray(J)||J.length<2){throw new Error("JXG.Math.Numerics.fminbr: length of array x0 has to be at least two.")}M=J[0];K=J[1];s=M+A*(K-M);k=I.apply(N,[s]);G++;m=s;o=s;i=k;j=k;while(E=H){u=(m-o)*(i-k);B=(m-s)*(i-j);D=(m-s)*B-(m-o)*u;B=2*(B-u);if(B>0){D=-D}else{B=-B}if(e.abs(D)B*(M-m+2*H)&&D0){n=H}else{n=-H}}u=m+n;l=I.apply(N,[u]);G++;if(l<=i){if(ur){l(v,u,k[1],r,s);l(v,k[1],t,r,s)}else{s.push(v[t])}},o=function(H,w,v){var B=0,z=w,A,u,I,G,F,t,E,s,C,D,r;if(v-w<2){return[-1,0]}I=H[w].scrCoords;G=H[v].scrCoords;if(isNaN(I[1]+I[2]+G[1]+G[2])){return[NaN,v]}for(u=w+1;u=f.Math.eps){r=(t*s+E*C)/D;if(r<0){r=0}else{if(r>1){r=1}}t=t-r*s;E=E-r*C;A=t*t+E*E}else{r=0;A=t*t+E*E}if(A>B){B=A;z=u}}return[e.sqrt(B),z]};h=q.length;p=0;while(pp&&isNaN(q[m].scrCoords[1]+q[m].scrCoords[2])){m--}if(!(p>m||p==h)){n[0]=q[p];l(q,p,m,j,n)}return n}}})(JXG,Math);JXG.Math.Statistics={sum:function(f){var h,e=f.length,g=0;for(h=0;h0){return this.sum(e)/e.length}else{return 0}},median:function(f){var g,e;if(f.length>0){g=f.slice(0);g.sort(function(i,h){return i-h});e=g.length;if(e%2==1){return g[parseInt(e*0.5)]}else{return(g[e*0.5-1]+g[e*0.5])*0.5}}else{return 0}},variance:function(g){var f,j,h,e=g.length;if(e>1){f=this.mean(g);j=0;for(h=0;h0){return this.mean(this.multiply(e,f))}else{return 0}},max:function(e){return Math.max.apply(this,e)},min:function(e){return Math.min.apply(this,e)},range:function(e){return[this.min(e),this.max(e)]},abs:function(f){var h,e,g;if(JXG.isArray(f)){e=f.length;g=[];for(h=0;h0){m=n[q].generatePolynomial();for(h=0;h0)){if((A.toOrigin!==f)&&(A.toOrigin!=null)&&E(A.toOrigin.id,o.listOfFreePoints)){l=A.toOrigin}else{l=o.listOfFreePoints[0]}v=l.symbolic.x;t=l.symbolic.y;for(F=0;F1)){if((A.to10!==f)&&(A.to10!=null)&&(A.to10.id!=A.toOrigin.id)&&E(A.to10.id,o.listOfFreePoints)){k=A.to10}else{if(o.listOfFreePoints[0].id==l.id){k=o.listOfFreePoints[1]}else{k=o.listOfFreePoints[0]}}p=e.Math.Geometry.rad([1,0],[0,0],[k.symbolic.x,k.symbolic.y]);G=Math.cos(-p);z=Math.sin(-p);for(F=0;Fe.Math.eps)){I=k.symbolic.x;for(F=0;Fq){k+=Math.PI}p=Math.cos(k)+o[1];n=Math.sin(k)+o[2];return new JXG.Coords(JXG.COORDS_BY_USER,[p,n],l)},reflection:function(p,m,g){var i=m.coords.usrCoords,q=p.point1.coords.usrCoords,h=p.point2.coords.usrCoords,f,l,e,j,n,k,o;if(!JXG.exists(g)){g=m.board}n=h[1]-q[1];k=h[2]-q[2];f=i[1]-q[1];l=i[2]-q[2];o=(n*l-k*f)/(n*n+k*k);e=i[1]+2*o*k;j=i[2]-2*o*n;return new JXG.Coords(JXG.COORDS_BY_USER,[e,j],g)},rotation:function(e,o,i,j){var l=o.coords.usrCoords,f=e.coords.usrCoords,h,n,k,p,g,m;if(!JXG.exists(j)){j=o.board}h=l[1]-f[1];n=l[2]-f[2];k=Math.cos(i);p=Math.sin(i);g=h*k-n*p+f[1];m=h*p+n*k+f[2];return new JXG.Coords(JXG.COORDS_BY_USER,[g,m],j)},perpendicular:function(r,p,j){var i=r.point1.coords.usrCoords,h=r.point2.coords.usrCoords,f=p.coords.usrCoords,n,m,l,q,k,g,e,o;if(!JXG.exists(j)){j=p.board}if(p==r.point1){n=i[1]+h[2]-i[2];m=i[2]-h[1]+i[1];l=true}else{if(p==r.point2){n=h[1]+i[2]-h[2];m=h[2]-i[1]+h[1];l=false}else{if(((Math.abs(i[1]-h[1])>JXG.Math.eps)&&(Math.abs(f[2]-(i[2]-h[2])*(f[1]-i[1])/(i[1]-h[1])-i[2])JXG.Math.eps&&(Math.abs(f[0])JXG.Math.eps){for(k=2;k>0;k--){v[m][k]/=v[m][0]}v[m][0]=1}}f=false;e=false;if(!r&&q.scrCoords[1]>=0&&q.scrCoords[1]<=h.board.canvasWidth&&q.scrCoords[2]>=0&&q.scrCoords[2]<=h.board.canvasHeight){f=true}if(!g&&p.scrCoords[1]>=0&&p.scrCoords[1]<=h.board.canvasWidth&&p.scrCoords[2]>=0&&p.scrCoords[2]<=h.board.canvasHeight){e=true}if(Math.abs(v[1][0])h.board.canvasHeight){l=v[2]}else{l=v[3]}}else{if(v[1][2]>h.board.canvasHeight){n=v[2];if(v[3][2]<0){l=v[0]}else{l=v[3]}}else{n=v[1];if(v[3][2]<0){l=v[0]}else{if(v[3][2]>h.board.canvasHeight){l=v[2]}else{l=v[3]}}}}}}n=new JXG.Coords(JXG.COORDS_BY_SCREEN,n.slice(1),h.board);l=new JXG.Coords(JXG.COORDS_BY_SCREEN,l.slice(1),h.board);if(!f&&!e){if(!r&&g&&!this.isSameDirection(q,p,n)&&!this.isSameDirection(q,p,l)){return}else{if(r&&!g&&!this.isSameDirection(p,q,n)&&!this.isSameDirection(p,q,l)){return}}}if(!f){if(!e){if(this.isSameDir(q,p,n,l)){u=n;t=l}else{t=n;u=l}}else{if(this.isSameDir(q,p,n,l)){u=n}else{u=l}}}else{if(!e){if(this.isSameDir(q,p,n,l)){t=l}else{t=n}}}if(u){q.setCoordinates(JXG.COORDS_BY_USER,u.usrCoords.slice(1))}if(t){p.setCoordinates(JXG.COORDS_BY_USER,t.usrCoords.slice(1))}},isSameDir:function(k,j,g,f){var e=j.usrCoords[1]-k.usrCoords[1],l=j.usrCoords[2]-k.usrCoords[2],i=f.usrCoords[1]-g.usrCoords[1],h=f.usrCoords[2]-g.usrCoords[2];return e*i+l*h>=0},isSameDirection:function(l,i,g){var f,e,k,j,h=false;f=i.usrCoords[1]-l.usrCoords[1];e=i.usrCoords[2]-l.usrCoords[2];k=g.usrCoords[1]-l.usrCoords[1];j=g.usrCoords[2]-l.usrCoords[2];if(Math.abs(f)=0&&k>=0){if((e>=0&&j>=0)||(e<=0&&j<=0)){h=true}}else{if(f<=0&&k<=0){if((e>=0&&j>=0)||(e<=0&&j<=0)){h=true}}}return h},intersectLineLine:function(p,o,k){var j=p.point1.coords.usrCoords,h=p.point2.coords.usrCoords,g=o.point1.coords.usrCoords,e=o.point2.coords.usrCoords,i,f,n,m,l;if(!JXG.exists(k)){k=p.board}i=j[1]*h[2]-j[2]*h[1];f=g[1]*e[2]-g[2]*e[1];n=(h[2]-j[2])*(g[1]-e[1])-(j[1]-h[1])*(e[2]-g[2]);if(Math.abs(n)0){e=k.center.Dist(u.point1);I=k.center.Dist(u.point2);G=((e*e)+(B*B)-(I*I))/(2*B);z=(e*e)-(G*G);z=(z<0)?0:z;E=Math.sqrt(z);C=k.Radius();n=Math.sqrt((C*C)-E*E);A=H[1]-J[1];v=H[2]-J[2];j=g[1]+(E/B)*v;i=g[2]-(E/B)*A;e=(H[1]*v)-(H[2]*A);I=(j*A)+(i*v);D=(v*v)+(A*A);if(Math.abs(D)q){return[0]}else{if(u=e&&Math.abs(f[3])=e){return this.meetLineCircle(h,f,g,j)}else{return this.meetCircleCircle(h,f,g,j)}}}},meetLineLine:function(f,e,g,j){var h=JXG.Math.crossProduct(f,e);if(Math.abs(h[0])>JXG.Math.eps){h[1]/=h[0];h[2]/=h[0];h[0]=1}return new JXG.Coords(JXG.COORDS_BY_USER,h,j)},meetLineCircle:function(j,e,o,p){var u,s,r,q,l,h,g,f,m,v;if(e[4]=0){m=Math.sqrt(m);v=[(-g+m)/(2*h),(-g-m)/(2*h)];return((o==0)?new JXG.Coords(JXG.COORDS_BY_USER,[-v[0]*(-l[1])-q*l[0],-v[0]*l[0]-q*l[1]],p):new JXG.Coords(JXG.COORDS_BY_USER,[-v[1]*(-l[1])-q*l[0],-v[1]*l[0]-q*l[1]],p))}else{return new JXG.Coords(JXG.COORDS_BY_USER,[0,0,0],p)}},meetCircleCircle:function(g,e,f,h){var j;if(g[4]JXG.Math.eps&&l<10){B=A(o);z=-w(n);v=j(o);u=-i(n);g=B*u-z*v;o-=(u*t-z*s)/g;n-=(B*s-v*t)/g;t=r.X(o)-q.X(n);s=r.Y(o)-q.Y(n);p=t*t+s*s;l++}arguments.callee.t1memo=o;arguments.callee.t2memo=n;if(Math.abs(o)0.1&&Math.abs(g-h.X(m))>0.1&&Math.abs(e-h.Y(m))>0.1)){v=20;w=(h.maxX()-h.minX())/v;A=h.minX();for(u=0;u0.1&&Math.abs(g-h.X(m))>0.1&&Math.abs(e-h.Y(m))>0.1){break}A+=w}}p=m;arguments.callee.t2memo=p}if(Math.abs(j(p))>JXG.Math.eps){l=0}else{l=1}return(new JXG.Coords(JXG.COORDS_BY_USER,[l,h.X(p),h.Y(p)],k))},projectPointToCircle:function(m,e,g){var j=m.coords.distance(JXG.COORDS_BY_USER,e.center.coords),f=m.coords.usrCoords,h=e.center.coords.usrCoords,l,k,i;if(!JXG.exists(g)){g=m.board}if(Math.abs(j)r.maxX()){q=r.minX()+q-r.maxX()}C=new JXG.Coords(JXG.COORDS_BY_USER,[r.X(q),r.Y(q)],k)}else{if(r.visProp.curvetype=="plot"){B=p;for(v=0;v=JXG.Math.eps){h=(A*z+f*e)/l;s=Math.sqrt(A*A+f*f-h*(A*z+f*e))}else{h=0;s=Math.sqrt(A*A+f*f)}if(h>=0&&h<=1&&s-1){this.monomials[f].coefficient+=g*e.coefficient}else{e.coefficient*=g;this.monomials.push(e)}},add:function(f){var e;if(JXG.exists(f)&&f.ring===this.ring){if(JXG.isArray(f.exponents)){this.addSubMonomial(f,1)}else{for(e=0;e0&&!isNaN(e+f.center.coords.scrCoords[1]+f.center.coords.scrCoords[2])&&e*f.board.unitX<20000){this.updateEllipsePrim(f.rendNode,f.center.coords.scrCoords[1],f.center.coords.scrCoords[2],(e*f.board.unitX),(e*f.board.unitY))}},drawPolygon:function(e){this.appendChildPrim(this.createPrim("polygon",e.id),e.visProp.layer);this.appendNodesToElement(e,"polygon");this.updatePolygon(e)},updatePolygon:function(e){this._updateVisual(e,{stroke:true,dash:true});this.updatePolygonPrim(e.rendNode,e)},displayCopyright:function(e,f){},drawInternalText:function(e){},updateInternalText:function(e){},drawText:function(e){var f,g;if(e.visProp.display==="html"){f=this.container.ownerDocument.createElement("div");f.style.position="absolute";f.className=e.visProp.cssclass;if(this.container.style.zIndex==""){g=0}else{g=parseInt(this.container.style.zIndex)}f.style.zIndex=g+e.board.options.layer.text;this.container.appendChild(f);f.setAttribute("id",this.container.id+"_"+e.id)}else{f=this.drawInternalText(e)}e.rendNode=f;e.htmlStr="";this.updateText(e)},updateText:function(e){var f=e.plaintext;if(e.visProp.visible){this.updateTextStyle(e);if(e.visProp.display==="html"){if(!isNaN(e.coords.scrCoords[1]+e.coords.scrCoords[2])){e.rendNode.style.left=parseInt(e.coords.scrCoords[1])+"px";e.rendNode.style.top=parseInt(e.coords.scrCoords[2]-parseInt(e.visProp.fontsize)+this.vOffsetText)+"px"}if(e.htmlStr!==f){e.rendNode.innerHTML=f;e.htmlStr=f;if(e.visProp.usemathjax){MathJax.Hub.Typeset(e.rendNode)}else{if(e.visProp.useasciimathml){AMprocessNode(e.rendNode,false)}}}this.transformImage(e,e.transformations)}else{this.updateInternalText(e)}}},updateTextStyle:function(g){var f=JXG.evaluate(g.visProp.fontsize);if(g.visProp.display==="html"||this.type!="canvas"){g.rendNode.className=g.visProp.cssclass;try{g.rendNode.style.fontSize=f+"px"}catch(h){g.rendNode.style.fontSize=f}}this.setObjectStrokeColor(g,g.visProp.strokecolor,g.visProp.strokeopacity)},drawImage:function(e){},updateImage:function(e){this.updateRectPrim(e.rendNode,e.coords.scrCoords[1],e.coords.scrCoords[2]-e.size[1],e.size[0],e.size[1]);this.updateImageURL(e);this.transformImage(e,e.transformations);this._updateVisual(e,{stroke:true,dash:true},true)},joinTransforms:function(o,p){var l=[[1,0,0],[0,1,0],[0,0,1]],h=o.board.origin.scrCoords[1],g=o.board.origin.scrCoords[2],f=o.board.unitX,e=o.board.unitY,s=[[1,0,0],[-h,1,0],[-g,0,1]],r=[[1,0,0],[0,1/f,0],[0,0,-1/e]],j=[[1,0,0],[0,f,0],[0,0,-e]],k=[[1,0,0],[h,1,0],[g,0,1]],n,q=p.length;for(n=0;n\nFunction Base64Encode(inData)\n Const Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"\n Dim cOut, sOut, I\n For I = 1 To LenB(inData) Step 3\n Dim nGroup, pOut, sGroup\n nGroup = &H10000 * AscB(MidB(inData, I, 1)) + _\n &H100 * MyASC(MidB(inData, I + 1, 1)) + MyASC(MidB(inData, I + 2, 1))\n nGroup = Oct(nGroup)\n nGroup = String(8 - Len(nGroup), "0") & nGroup\n pOut = Mid(Base64, CLng("&o" & Mid(nGroup, 1, 2)) + 1, 1) + _\n Mid(Base64, CLng("&o" & Mid(nGroup, 3, 2)) + 1, 1) + _\n Mid(Base64, CLng("&o" & Mid(nGroup, 5, 2)) + 1, 1) + _\n Mid(Base64, CLng("&o" & Mid(nGroup, 7, 2)) + 1, 1)\n sOut = sOut + pOut\n Next\n Select Case LenB(inData) Mod 3\n Case 1: \'8 bit final\n sOut = Left(sOut, Len(sOut) - 2) + "=="\n Case 2: \'16 bit final\n sOut = Left(sOut, Len(sOut) - 1) + "="\n End Select\n Base64Encode = sOut\nEnd Function\n\nFunction MyASC(OneChar)\n If OneChar = "" Then MyASC = 0 Else MyASC = AscB(OneChar)\nEnd Function\n\nFunction BinFileReader(xhr)\n Dim byteString\n Dim b64String\n Dim i\n byteString = xhr.responseBody\n ReDim byteArray(LenB(byteString))\n For i = 1 To LenB(byteString)\n byteArray(i-1) = AscB(MidB(byteString, i, 1))\n Next\n b64String = Base64Encode(byteString)\n BinFileReader = b64String\nEnd Function\n<\/script>\n')}JXG.GeonextParser={};JXG.GeonextParser.replacePow=function(g){var l,o,m,k,n,h,e,f,j,r,q;g=g.replace(/(\s*)\^(\s*)/g,"^");j=g.indexOf("^");while(j>=0){f=g.slice(0,j);r=g.slice(j+1);if(f.charAt(f.length-1)==")"){l=1;o=f.length-2;while(o>=0&&l>0){m=f.charAt(o);if(m==")"){l++}else{if(m=="("){l--}}o--}if(l==0){k="";h=f.substring(0,o+1);e=o;while(e>=0&&h.substr(e,1).match(/([\w\.]+)/)){k=RegExp.$1+k;e--}k+=f.substring(o+1,f.length);k=k.replace(/([\(\)\+\*\%\^\-\/\]\[])/g,"\\$1")}else{throw new Error("JSXGraph: Missing '(' in expression")}}else{k="[\\w\\.]+"}if(r.match(/^([\w\.]*\()/)){l=1;o=RegExp.$1.length;while(o0){m=r.charAt(o);if(m==")"){l--}else{if(m=="("){l++}}o++}if(l==0){n=r.substring(0,o);n=n.replace(/([\(\)\+\*\%\^\-\/\[\]])/g,"\\$1")}else{throw new Error("JSXGraph: Missing ')' in expression")}}else{n="[\\w\\.]+"}q=new RegExp("("+k+")\\^("+n+")");g=g.replace(q,"JXG.Math.pow($1,$2)");j=g.indexOf("^")}return g};JXG.GeonextParser.replaceIf=function(f){var t="",g,r,j=null,e=null,m=null,h,q,k,n,l,o,p;h=f.indexOf("If(");if(h<0){return f}f=f.replace(/""/g,"0");while(h>=0){g=f.slice(0,h);r=f.slice(h+3);k=1;q=0;n=-1;l=-1;while(q0){o=r.charAt(q);if(o==")"){k--}else{if(o=="("){k++}else{if(o==","&&k==1){if(n<0){n=q}else{l=q}}}}q++}p=r.slice(0,q-1);r=r.slice(q);if(n<0){return""}if(l<0){return""}j=p.slice(0,n);e=p.slice(n+1,l);m=p.slice(l+1);j=this.replaceIf(j);e=this.replaceIf(e);m=this.replaceIf(m);t+=g+"(("+j+")?("+e+"):("+m+"))";f=r;j=null;e=null;h=f.indexOf("If(")}t+=r;return t};JXG.GeonextParser.replaceSub=function(g){if(g.indexOf){}else{return g}var f=g.indexOf("_{"),e;while(f>=0){g=g.substr(0,f)+g.substr(f).replace(/_\{/,"");e=g.substr(f).indexOf("}");if(e>=0){g=g.substr(0,e)+g.substr(e).replace(/\}/,"")}f=g.indexOf("_{")}f=g.indexOf("_");while(f>=0){g=g.substr(0,f)+g.substr(f).replace(/_(.?)/,"$1");f=g.indexOf("_")}return g};JXG.GeonextParser.replaceSup=function(g){if(g.indexOf){}else{return g}var f=g.indexOf("^{"),e;while(f>=0){g=g.substr(0,f)+g.substr(f).replace(/\^\{/,"");e=g.substr(f).indexOf("}");if(e>=0){g=g.substr(0,e)+g.substr(e).replace(/\}/,"")}f=g.indexOf("^{")}f=g.indexOf("^");while(f>=0){g=g.substr(0,f)+g.substr(f).replace(/\^(.?)/,"$1");f=g.indexOf("^")}return g};JXG.GeonextParser.replaceNameById=function(h,k){var m=0,e,l,j,g,f=["X","Y","L","V"];for(g=0;g=0){if(m>=0){e=h.indexOf(")",m+2);if(e>=0){l=h.slice(m+2,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+2)+j.id+h.slice(e)}}e=h.indexOf(")",m+2);m=h.indexOf(f[g]+"(",e)}}m=h.indexOf("Dist(");while(m>=0){if(m>=0){e=h.indexOf(",",m+5);if(e>=0){l=h.slice(m+5,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+5)+j.id+h.slice(e)}}e=h.indexOf(",",m+5);m=h.indexOf(",",e);e=h.indexOf(")",m+1);if(e>=0){l=h.slice(m+1,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+1)+j.id+h.slice(e)}e=h.indexOf(")",m+1);m=h.indexOf("Dist(",e)}f=["Deg","Rad"];for(g=0;g=0){if(m>=0){e=h.indexOf(",",m+4);if(e>=0){l=h.slice(m+4,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+4)+j.id+h.slice(e)}}e=h.indexOf(",",m+4);m=h.indexOf(",",e);e=h.indexOf(",",m+1);if(e>=0){l=h.slice(m+1,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+1)+j.id+h.slice(e)}e=h.indexOf(",",m+1);m=h.indexOf(",",e);e=h.indexOf(")",m+1);if(e>=0){l=h.slice(m+1,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+1)+j.id+h.slice(e)}e=h.indexOf(")",m+1);m=h.indexOf(f[g]+"(",e)}}return h};JXG.GeonextParser.replaceIdByObj=function(e){var f=/(X|Y|L)\(([\w_]+)\)/g;e=e.replace(f,'this.board.objects["$2"].$1()');f=/(V)\(([\w_]+)\)/g;e=e.replace(f,'this.board.objects["$2"].Value()');f=/(Dist)\(([\w_]+),([\w_]+)\)/g;e=e.replace(f,'this.board.objects["$2"].Dist(this.board.objects["$3"])');f=/(Deg)\(([\w_]+),([ \w\[\w_]+),([\w_]+)\)/g;e=e.replace(f,'JXG.Math.Geometry.trueAngle(this.board.objects["$2"],this.board.objects["$3"],this.board.objects["$4"])');f=/Rad\(([\w_]+),([\w_]+),([\w_]+)\)/g;e=e.replace(f,'JXG.Math.Geometry.rad(this.board.objects["$1"],this.board.objects["$2"],this.board.objects["$3"])');return e};JXG.GeonextParser.geonext2JS=function(f,h){var j,g,e,l=["Abs","ACos","ASin","ATan","Ceil","Cos","Exp","Factorial","Floor","Log","Max","Min","Random","Round","Sin","Sqrt","Tan","Trunc"],k=["Math.abs","Math.acos","Math.asin","Math.atan","Math.ceil","Math.cos","Math.exp","JXG.Math.factorial","Math.floor","Math.log","Math.max","Math.min","Math.random","this.board.round","Math.sin","Math.sqrt","Math.tan","Math.ceil"];f=f.replace(/</g,"<");f=f.replace(/>/g,">");f=f.replace(/&/g,"&");g=f;g=this.replaceNameById(g,h);g=this.replaceIf(g);g=this.replacePow(g);g=this.replaceIdByObj(g);for(e=0;e=0){j[g].addChild(i)}}}else{e=g.replace(/\[/g,"\\[");e=e.replace(/\]/g,"\\]");k=new RegExp("\\(([\\w\\[\\]'_ ]+,)*("+e+")(,[\\w\\[\\]'_ ]+)*\\)","g");if(f.search(k)>=0){j[g].addChild(i)}}}}};JXG.GeonextParser.gxt2jc=function(e,g){var f,i=["Sqrt"],h=["sqrt"];e=e.replace(/</g,"<");e=e.replace(/>/g,">");e=e.replace(/&/g,"&");f=e;f=this.replaceNameById2(f,g);f=f.replace(/True/g,"true");f=f.replace(/False/g,"false");f=f.replace(/fasle/g,"false");return f};JXG.GeonextParser.replaceNameById2=function(h,k){var m=0,e,l,j,g,f=["X","Y","L","V"];for(g=0;g=0){if(m>=0){e=h.indexOf(")",m+2);if(e>=0){l=h.slice(m+2,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+2)+"$('"+j.id+"')"+h.slice(e)}}e=h.indexOf(")",m+2);m=h.indexOf(f[g]+"(",e)}}m=h.indexOf("Dist(");while(m>=0){if(m>=0){e=h.indexOf(",",m+5);if(e>=0){l=h.slice(m+5,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+5)+"$('"+j.id+"')"+h.slice(e)}}e=h.indexOf(",",m+5);m=h.indexOf(",",e);e=h.indexOf(")",m+1);if(e>=0){l=h.slice(m+1,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+1)+"$('"+j.id+"')"+h.slice(e)}e=h.indexOf(")",m+1);m=h.indexOf("Dist(",e)}f=["Deg","Rad"];for(g=0;g=0){if(m>=0){e=h.indexOf(",",m+4);if(e>=0){l=h.slice(m+4,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+4)+"$('"+j.id+"')"+h.slice(e)}}e=h.indexOf(",",m+4);m=h.indexOf(",",e);e=h.indexOf(",",m+1);if(e>=0){l=h.slice(m+1,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+1)+"$('"+j.id+"')"+h.slice(e)}e=h.indexOf(",",m+1);m=h.indexOf(",",e);e=h.indexOf(")",m+1);if(e>=0){l=h.slice(m+1,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+1)+"$('"+j.id+"')"+h.slice(e)}e=h.indexOf(")",m+1);m=h.indexOf(f[g]+"(",e)}}return h};JXG.Board=function(e,j,f,o,n,m,l,k,g,h,i){this.BOARD_MODE_NONE=0;this.BOARD_MODE_DRAG=1;this.BOARD_MODE_MOVE_ORIGIN=2;this.BOARD_QUALITY_LOW=1;this.BOARD_QUALITY_HIGH=2;this.BOARD_MODE_ZOOM=17;this.BOARD_MODE_CONSTRUCT=16;this.CONSTRUCTION_TYPE_POINT=1129599060;this.CONSTRUCTION_TYPE_CIRCLE=1129595724;this.CONSTRUCTION_TYPE_LINE=1129598030;this.CONSTRUCTION_TYPE_GLIDER=1129596740;this.CONSTRUCTION_TYPE_MIDPOINT=1129598288;this.CONSTRUCTION_TYPE_PERPENDICULAR=1129599044;this.CONSTRUCTION_TYPE_PARALLEL=1129599052;this.CONSTRUCTION_TYPE_INTERSECTION=1129597267;this.container=e;this.containerObj=document.getElementById(this.container);if(this.containerObj==null){throw new Error("\nJSXGraph: HTML container element '"+(e)+"' not found.")}this.renderer=j;this.grids=[];this.options=JXG.deepCopy(JXG.Options);this.dimension=2;this.jc=new JXG.JessieCode();this.jc.board=this;this.origin={};this.origin.usrCoords=[1,0,0];this.origin.scrCoords=[1,o[0],o[1]];this.zoomX=n;this.zoomY=m;this.unitX=l*this.zoomX;this.unitY=k*this.zoomY;this.canvasWidth=g;this.canvasHeight=h;if(JXG.exists(f)&&f!==""&&!JXG.exists(document.getElementById(f))){this.id=f}else{this.id=this.generateId()}this.hooks=[];this.dependentBoards=[];this.inUpdate=false;this.objects={};this.groups={};this.animationObjects={};this.highlightedObjects={};this.numObjects=0;this.elementsByName={};this.mode=this.BOARD_MODE_NONE;this.updateQuality=this.BOARD_QUALITY_HIGH;this.isSuspendedRedraw=false;this.calculateSnapSizes();this.drag_dx=0;this.drag_dy=0;this.mouse=null;this.touches=[];this.xmlString="";this.cPos=[];this.touchMoveLast=0;this.downObjects=[];this.showCopyright=false;if((i!=null&&i)||(i==null&&this.options.showCopyright)){this.showCopyright=true;this.renderer.displayCopyright(JXG.JSXGraph.licenseText,this.options.text.fontSize)}this.needsFullUpdate=false;this.reducedUpdate=false;this.currentCBDef="none";this.geonextCompatibilityMode=false;if(this.options.text.useASCIIMathML&&translateASCIIMath){init()}else{this.options.text.useASCIIMathML=false}this.hasMouseHandlers=false;this.hasTouchHandlers=false;this.addEventHandlers()};JXG.extend(JXG.Board.prototype,{generateName:function(g){if(g.type==JXG.OBJECT_TYPE_TICKS){return""}var m,k=3,f="",n="",o=[],e="",l,h;if(g.elementClass==JXG.OBJECT_CLASS_POINT){m=["","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]}else{m=["","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]}switch(g.type){case JXG.OBJECT_TYPE_POLYGON:f="P_{";n="}";break;case JXG.OBJECT_TYPE_CIRCLE:f="k_{";n="}";break;case JXG.OBJECT_TYPE_ANGLE:f="W_{";n="}";break;default:if(g.elementClass!=JXG.OBJECT_CLASS_POINT&&g.elementClass!=JXG.OBJECT_CLASS_LINE){f="s_{";n="}"}}for(l=0;l0;l--){e+=m[o[l-1]]}if(this.elementsByName[e+n]==null){return e+n}}o[0]=m.length;for(l=1;l=e.visProp.layer){if(JXG.exists(e.label)&&j==e.label.content){continue}e=j;i[0]=e}}}if(i.length>0){this.mode=this.BOARD_MODE_DRAG}if(this.options.takeFirst){i.length=1}return i},moveObject:function(e,j,i){var f=new JXG.Coords(JXG.COORDS_BY_SCREEN,this.getScrCoordsOfMouse(e,j),this),g=i.obj,h;if(g.type!=JXG.OBJECT_TYPE_GLIDER){if(!isNaN(i.targets[0].Xprev+i.targets[0].Yprev)){g.setPositionDirectly(JXG.COORDS_BY_SCREEN,f.scrCoords[1],f.scrCoords[2],i.targets[0].Xprev,i.targets[0].Yprev)}i.targets[0].Xprev=f.scrCoords[1];i.targets[0].Yprev=f.scrCoords[2];this.update(g)}else{if(g.type==JXG.OBJECT_TYPE_GLIDER){h=g.coords;g.setPositionDirectly(JXG.COORDS_BY_USER,f.usrCoords[1],f.usrCoords[2]);if(g.slideObject.elementClass==JXG.OBJECT_CLASS_CIRCLE){g.coords=JXG.Math.Geometry.projectPointToCircle(g,g.slideObject,this)}else{if(g.slideObject.elementClass==JXG.OBJECT_CLASS_LINE){g.coords=JXG.Math.Geometry.projectPointToLine(g,g.slideObject,this)}}if(g.group.length!=0){g.group[g.group.length-1].dX=g.coords.scrCoords[1]-h.scrCoords[1];g.group[g.group.length-1].dY=g.coords.scrCoords[2]-h.scrCoords[2];g.group[g.group.length-1].update(this)}else{this.update(g)}}}g.triggerEventHandlers("drag");this.updateInfobox(g);g.highlight()},moveLine:function(f,e,u){var B,i,C,A,t,s,j,r,k,v,z,w,g,h,q,p,n,m,l;if(JXG.exists(u)&&JXG.exists(u.obj)){w=u.obj}else{return}if(w.elementClass!=JXG.OBJECT_CLASS_LINE){return}B=new JXG.Coords(JXG.COORDS_BY_SCREEN,this.getScrCoordsOfMouse(f[0],f[1]),this);i=new JXG.Coords(JXG.COORDS_BY_SCREEN,this.getScrCoordsOfMouse(e[0],e[1]),this);if(JXG.exists(u.targets[0])&&JXG.exists(u.targets[1])&&!isNaN(u.targets[0].Xprev+u.targets[0].Yprev+u.targets[1].Xprev+u.targets[1].Yprev)){C=B.usrCoords;A=i.usrCoords;t=(new JXG.Coords(JXG.COORDS_BY_SCREEN,[u.targets[0].Xprev,u.targets[0].Yprev],this)).usrCoords;s=(new JXG.Coords(JXG.COORDS_BY_SCREEN,[u.targets[1].Xprev,u.targets[1].Yprev],this)).usrCoords;r=[1,(t[1]+s[1])*0.5,(t[2]+s[2])*0.5];j=[1,(C[1]+A[1])*0.5,(C[2]+A[2])*0.5];v=JXG.Math.crossProduct(t,s);k=JXG.Math.crossProduct(C,A);g=JXG.Math.crossProduct(v,k);if(Math.abs(g[0])-1&&this.touches[g].targets[1].num>-1){this.touches[g].targets[0].X=e.targetTouches[this.touches[g].targets[0].num].screenX;this.touches[g].targets[0].Y=e.targetTouches[this.touches[g].targets[0].num].screenY;this.touches[g].targets[1].X=e.targetTouches[this.touches[g].targets[1].num].screenX;this.touches[g].targets[1].Y=e.targetTouches[this.touches[g].targets[1].num].screenY;this.moveLine(this.getMousePosition(e,this.touches[g].targets[0].num),this.getMousePosition(e,this.touches[g].targets[1].num),this.touches[g])}}}}else{for(g=0;g0){for(m=0;m0){this.zoomIn(g.usrCoords[1],g.usrCoords[2])}else{this.zoomOut(g.usrCoords[1],g.usrCoords[2])}e.preventDefault();return false},updateInfobox:function(f){var e,i,g,h;if(!f.visProp.showinfobox){return this}if(f.elementClass==JXG.OBJECT_CLASS_POINT){g=f.coords.usrCoords[1];h=f.coords.usrCoords[2];this.infobox.setCoords(g+this.infobox.distanceX/(this.unitX),h+this.infobox.distanceY/(this.unitY));if(typeof(f.infoboxText)!="string"){e=Math.abs(g);if(e>0.1){e=g.toFixed(2)}else{if(e>=0.01){e=g.toFixed(4)}else{if(e>=0.0001){e=g.toFixed(6)}else{e=g}}}i=Math.abs(h);if(i>0.1){i=h.toFixed(2)}else{if(i>=0.01){i=h.toFixed(4)}else{if(i>=0.0001){i=h.toFixed(6)}else{i=h}}}this.highlightInfobox(e,i,f)}else{this.highlightCustomInfobox(f.infoboxText,f)}this.renderer.show(this.infobox);this.renderer.updateText(this.infobox)}return this},highlightCustomInfobox:function(e){this.infobox.setText(''+e+"");return this},highlightInfobox:function(e,g,f){this.highlightCustomInfobox("("+e+", "+g+")");return this},dehighlightAll:function(){var f,g,e=false;for(f in this.highlightedObjects){g=this.highlightedObjects[f];g.noHighlight();e=true}this.highlightedObjects={};if(this.options.renderer=="canvas"&&e){this.prepareUpdate();this.renderer.suspendRedraw(this);this.updateRenderer();this.renderer.unsuspendRedraw()}return this},getScrCoordsOfMouse:function(e,g){if(this.options.grid.snapToGrid){var f=new JXG.Coords(JXG.COORDS_BY_SCREEN,[e,g],this);f.setCoordinates(JXG.COORDS_BY_USER,[Math.round((f.usrCoords[1])*this.options.grid.snapSizeX)/this.options.grid.snapSizeX,Math.round((f.usrCoords[2])*this.options.grid.snapSizeY)/this.options.grid.snapSizeY]);return[f.scrCoords[1],f.scrCoords[2]]}else{return[e,g]}},getUsrCoordsOfMouse:function(i){var g=this.getCoordsTopLeftCorner(),f=JXG.getPosition(i),e=f[0]-g[0],j=f[1]-g[1],h=new JXG.Coords(JXG.COORDS_BY_SCREEN,[e,j],this);return h.usrCoords.slice(1)},getAllUnderMouse:function(f){var e=this.getAllObjectsUnderMouse();e.push(this.getUsrCoordsOfMouse(f));return e},getAllObjectsUnderMouse:function(k){var j=this.getCoordsTopLeftCorner(),e=JXG.getPosition(k),g=e[0]-j[0],f=e[1]-j[1],h=[];for(var i in this.objects){if(this.objects[i].visProp.visible&&this.objects[i].hasPoint&&this.objects[i].hasPoint(g,f)){h.push(this.objects[i])}}return h},moveOrigin:function(e,h){var g,f;if(JXG.exists(e)&&JXG.exists(h)){this.origin.scrCoords[1]=e;this.origin.scrCoords[2]=h}for(f in this.objects){g=this.objects[f];if(!g.visProp.frozen&&(g.elementClass==JXG.OBJECT_CLASS_POINT||g.elementClass==JXG.OBJECT_CLASS_CURVE||g.type==JXG.OBJECT_TYPE_AXIS||g.type==JXG.OBJECT_TYPE_TEXT)){if(g.elementClass!=JXG.OBJECT_CLASS_CURVE&&g.type!=JXG.OBJECT_TYPE_AXIS){g.coords.usr2screen()}}}this.clearTraces();this.fullUpdate();return this},addConditions:function(p){var f="var el, x, y, c, rgbo;\n",o=p.indexOf(""),n=p.indexOf(""),l,k,h,r,e,g;if(o<0){return}while(o>=0){l=p.slice(o+6,n);k=l.indexOf("=");h=l.slice(0,k);r=l.slice(k+1);k=h.indexOf(".");e=h.slice(0,k);g=this.elementsByName[JXG.unescapeHTML(e)];var q=h.slice(k+1).replace(/\s+/g,"").toLowerCase();r=JXG.GeonextParser.geonext2JS(r,this);r=r.replace(/this\.board\./g,"this.");if(!JXG.exists(this.elementsByName[e])){JXG.debug("debug conditions: |"+e+"| undefined")}f+='el = this.objects["'+g.id+'"];\n';switch(q){case"x":f+="var y=el.coords.usrCoords[2];\n";f+="el.setPositionDirectly(JXG.COORDS_BY_USER,"+(r)+",y);\n";f+="el.prepareUpdate().update();\n";break;case"y":f+="var x=el.coords.usrCoords[1];\n";f+="el.coords=new JXG.Coords(JXG.COORDS_BY_USER,[x,"+(r)+"],this);\n";f+="el.setPositionDirectly(JXG.COORDS_BY_USER,x,"+(r)+");\n";f+="el.prepareUpdate().update();\n";break;case"visible":f+="var c="+(r)+";\n";f+="el.visProp.visible = c;\n";f+="if (c) {el.showElement();} else {el.hideElement();}\n";break;case"position":f+="el.position = "+(r)+";\n";f+="el.prepareUpdate().update(true);\n";break;case"stroke":f+="rgbo = JXG.rgba2rgbo("+(r)+");\n";f+="el.visProp.strokecolor = rgbo[0];\n";f+="el.visProp.strokeopacity = rgbo[1];\n";break;case"style":f+="el.setStyle("+(r)+");\n";break;case"strokewidth":f+="el.strokeWidth = "+(r)+";\n";break;case"fill":f+="var rgbo = JXG.rgba2rgbo("+(r)+");\n";f+="el.visProp.fillcolor = rgbo[0];\n";f+="el.visProp.fillopacity = rgbo[1];\n";break;case"label":break;default:JXG.debug("property '"+q+"' in conditions not yet implemented:"+r);break}p=p.slice(n+7);o=p.indexOf("");n=p.indexOf("")}f+="this.prepareUpdate().updateElements();\n";f+="return true;\n";this.updateConditions=new Function(f);this.updateConditions()},updateConditions:function(){return false},calculateSnapSizes:function(){var g=new JXG.Coords(JXG.COORDS_BY_USER,[0,0],this),f=new JXG.Coords(JXG.COORDS_BY_USER,[this.options.grid.gridX,this.options.grid.gridY],this),e=g.scrCoords[1]-f.scrCoords[1],h=g.scrCoords[2]-f.scrCoords[2];this.options.grid.snapSizeX=this.options.grid.gridX;while(Math.abs(e)>25){this.options.grid.snapSizeX*=2;e/=2}this.options.grid.snapSizeY=this.options.grid.gridY;while(Math.abs(h)>25){this.options.grid.snapSizeY*=2;h/=2}return this},applyZoom:function(){var f,e;for(e in this.objects){f=this.objects[e];if(!f.visProp.frozen&&(f.elementClass==JXG.OBJECT_CLASS_POINT||f.elementClass==JXG.OBJECT_CLASS_CURVE||f.type==JXG.OBJECT_TYPE_AXIS||f.type==JXG.OBJECT_TYPE_TEXT)){if(f.elementClass!=JXG.OBJECT_CLASS_CURVE&&f.type!=JXG.OBJECT_TYPE_AXIS){f.coords.usr2screen()}}}this.calculateSnapSizes();this.clearTraces();this.fullUpdate();return this},zoomIn:function(m,k){var h=this.getBoundingBox(),l=this.options.zoom.factorX,j=this.options.zoom.factorY,f=(h[2]-h[0])*(1-1/l),e=(h[1]-h[3])*(1-1/j),g=0.5,i=0.5;if(typeof m==="number"&&typeof k==="number"){g=(m-h[0])/(h[2]-h[0]);i=(h[1]-k)/(h[1]-h[3])}this.setBoundingBox([h[0]+f*g,h[1]-e*i,h[2]-f*(1-g),h[3]+e*(1-i)],false);this.zoomX*=l;this.zoomY*=j;this.applyZoom();return this},zoomOut:function(m,k){var h=this.getBoundingBox(),l=this.options.zoom.factorX,j=this.options.zoom.factorY,f=(h[2]-h[0])*(1-l),e=(h[1]-h[3])*(1-j),g=0.5,i=0.5;if(typeof m==="number"&&typeof k==="number"){g=(m-h[0])/(h[2]-h[0]);i=(h[1]-k)/(h[1]-h[3])}this.setBoundingBox([h[0]+f*g,h[1]-e*i,h[2]-f*(1-g),h[3]+e*(1-i)],false);this.zoomX/=l;this.zoomY/=j;this.applyZoom();return this},zoom100:function(){var g=this.getBoundingBox(),f=(g[2]-g[0])*(1-this.zoomX)*0.5,e=(g[1]-g[3])*(1-this.zoomY)*0.5;this.setBoundingBox([g[0]+f,g[1]-e,g[2]-f,g[3]+e],false);this.zoomX=1;this.zoomY=1;this.applyZoom();return this},zoomAllPoints:function(){var e=0,k=0,l=0,j=0,i,h,g,f;for(i in this.objects){if(JXG.isPoint(this.objects[i])&&this.objects[i].visProp.visible){if(this.objects[i].coords.usrCoords[1]k){k=this.objects[i].coords.usrCoords[1]}}if(this.objects[i].coords.usrCoords[2]>j){j=this.objects[i].coords.usrCoords[2]}else{if(this.objects[i].coords.usrCoords[2]=0){g+=""+this.objects[h].id+": "}for(k in this.objects[h].childElements){g+=this.objects[h].childElements[k].id+"("+this.objects[h].childElements[k].name+"), "}g+="

\n"}g+="

\n";j=window.open();j.document.open();j.document.write(g);j.document.close();return this},showXML:function(){var e=window.open("");e.document.open();e.document.write("
"+JXG.escapeHTML(this.xmlString)+"
");e.document.close();return this},prepareUpdate:function(){var e,f;for(e in this.objects){f=this.objects[e];if(!this.needsFullUpdate&&!f.needsRegularUpdate){continue}f.needsUpdate=true}return this},updateElements:function(f){var e,g;f=JXG.getRef(this,f);for(e in this.objects){g=this.objects[e];if(f==null||g.id!=f.id){g.update(true)}else{g.update(false)}}return this},updateRenderer:function(f){var e,g;if(this.options.renderer=="canvas"){this.updateRendererCanvas(f)}else{for(e in this.objects){g=this.objects[e];g.updateRenderer()}}return this},updateRendererCanvas:function(j){var e,m,h,g=this.options.layer,l=this.options.layer.numlayers,n=Number.NEGATIVE_INFINITY,k,f;for(h=0;hn&&g[f]1?Array.prototype.slice.call(arguments,1):[];if(!JXG.exists(f)){f=["update"]}if(!JXG.isArray(f)){f=[f]}e=f.length;h=this.hooks.length;for(k=0;k=0;e--){if(this.dependentBoards[e]==f){this.dependentBoards.splice(e,1)}}return this},update:function(h){var g,f,j,e;if(this.inUpdate||this.isSuspendedUpdate){return this}this.inUpdate=true;this.prepareUpdate(h).updateElements(h).updateConditions();this.renderer.suspendRedraw(this);this.updateRenderer(h);this.renderer.unsuspendRedraw();this.updateHooks();f=this.dependentBoards.length;for(g=0;g-o){t=-B;p.applyOnce(k)}else{if(t>B&&t0){r=setInterval(this.rolling,f)}return this};this.stop=function(){clearInterval(r);return this};return this};return new e()}});JXG.Options={showCopyright:true,showNavigation:true,takeSizeFromFile:false,renderer:"svg",takeFirst:false,pan:true,zoom:{factorX:1.25,factorY:1.25,wheel:false},jc:{enabled:true,compile:true},navbar:{strokeColor:"#aaaaaa",fillColor:"#f5f5f5",padding:"2px",position:"absolute",fontSize:"10px",cursor:"pointer",zIndex:"100",right:"5px",bottom:"5px"},elements:{strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",fillColor:"red",highlightFillColor:"none",strokeOpacity:1,highlightStrokeOpacity:1,fillOpacity:1,highlightFillOpacity:1,strokeWidth:2,highlightStrokeWidth:2,fixed:false,frozen:false,withLabel:false,visible:true,layer:0,dash:0,shadow:false,trace:false,traceAttributes:{},highlight:true,needsRegularUpdate:true,draft:{draft:false,strokeColor:"#565656",fillColor:"#565656",strokeOpacity:0.8,fillOpacity:0.8,strokeWidth:1}},ticks:{drawLabels:false,drawZero:false,insertTicks:false,minTicksDistance:50,minorHeight:4,majorHeight:10,minorTicks:4,ticksDistance:1,strokeOpacity:1,strokeWidth:1,strokeColor:"black",highlightStrokeColor:"#888888"},precision:{touch:30,mouse:4,epsilon:0.0001,hasPoint:4},layer:{numlayers:20,text:9,point:9,arc:8,line:7,circle:6,curve:5,turtle:5,polygon:3,sector:3,angle:3,integral:3,axis:2,grid:1,image:0,trace:0},angle:{withLabel:true,radius:1,type:"auto",fillColor:"#FF7F00",highlightFillColor:"#FF7F00",strokeColor:"#FF7F00",fillOpacity:0.3,highlightFillOpacity:0.3,radiuspoint:{withLabel:false,visible:false,name:""},pointsquare:{withLabel:false,visible:false,name:""},dot:{visible:false,strokeColor:"none",fillColor:"black",size:2,face:"o",withLabel:false,name:""},label:{strokeColor:"#0000FF"}},arc:{firstArrow:false,lastArrow:false,fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",useDirection:false},axis:{needsRegularUpdate:false,strokeWidth:1,strokeColor:"#666666",highlightStrokeWidth:1,highlightStrokeColor:"#888888",withTicks:true,straightFirst:true,straightLast:true,lastArrow:true,withLabel:false,ticks:{needsRegularUpdate:false,strokeWidth:1,strokeColor:"#666666",highlightStrokeColor:"#888888",drawLabels:true,drawZero:false,insertTicks:true,minTicksDistance:10,minorHeight:4,majorHeight:-1,minorTicks:4,ticksDistance:1,strokeOpacity:0.25},point1:{needsRegularUpdate:false},point2:{needsRegularUpdate:false},label:{position:"lft",offsets:[10,-20]}},bisector:{strokeColor:"#000000",point:{visible:false,fixed:false,withLabel:false,name:""}},bisectorlines:{line1:{strokeColor:"red"},line2:{strokeColor:"black"}},chart:{chartStyle:"line",colors:["#B02B2C","#3F4C6B","#C79810","#D15600","#FFFF88","#C3D9FF","#4096EE","#008C00"],highlightcolors:null,fillcolor:null,highlightonsector:false,highlightbysize:false},circle:{fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",center:{visible:false,withLabel:false,fixed:false,name:""},label:{position:"ulft"}},circumcircle:{fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",center:{visible:false,fixed:false,withLabel:false,name:""}},circumcirclearc:{fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",center:{visible:false,withLabel:false,fixed:false,name:""}},circumcirclesector:{useDirection:true,fillColor:"#00FF00",highlightFillColor:"#00FF00",fillOpacity:0.3,highlightFillOpacity:0.3,strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",point:{visible:false,fixed:false,withLabel:false,name:""}},conic:{fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",foci:{fixed:false,visible:false,withLabel:false,name:""}},curve:{strokeWidth:1,strokeColor:"#0000ff",fillColor:"none",handDrawing:false,curveType:null,RDPsmoothing:false,numberPointsHigh:1600,numberPointsLow:400,doAdvancedPlot:true,label:{position:"lft"}},glider:{},grid:{needsRegularUpdate:false,hasGrid:false,gridX:1,gridY:1,strokeColor:"#C0C0C0",strokeOpacity:"0.5",strokeWidth:1,dash:0,snapToGrid:false,snapSizeX:10,snapSizeY:10},image:{imageString:null,fillOpacity:1},incircle:{fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",center:{visible:false,fixed:false,withLabel:false,name:""}},integral:{withLabel:true,strokeWidth:0,strokeOpacity:0,fillOpacity:0.8,curveLeft:{visible:true,layer:9},baseLeft:{visible:false,fixed:false,withLabel:false,name:""},curveRight:{visible:true,layer:9},baseRight:{visible:false,fixed:false,withLabel:false,name:""},label:{fontSize:20}},label:{strokeColor:"black",fixed:true,position:"urt",offsets:[10,10]},legend:{style:"vertical",labels:["1","2","3","4","5","6","7","8"],colors:["#B02B2C","#3F4C6B","#C79810","#D15600","#FFFF88","#C3D9FF","#4096EE","#008C00"]},line:{firstArrow:false,lastArrow:false,straightFirst:true,straightLast:true,fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#888888",withTicks:false,point1:{visible:false,withLabel:false,fixed:false,name:""},point2:{visible:false,withLabel:false,fixed:false,name:""},ticks:{drawLabels:true,drawZero:false,insertTicks:false,minTicksDistance:50,maxTicksDistance:300,minorHeight:4,majorHeight:-1,minorTicks:4,defaultDistance:1,strokeOpacity:0.3},label:{position:"llft"}},locus:{translateToOrigin:false,translateTo10:false,stretch:false,toOrigin:null,to10:null},normal:{strokeColor:"#000000",point:{visible:false,fixed:false,withLabel:false,name:""}},orthogonalprojection:{},parallel:{strokeColor:"#000000",point:{visible:false,fixed:false,withLabel:false,name:""}},perpendicular:{strokeColor:"#000000",straightFirst:true,straightLast:true},perpendicularsegment:{strokeColor:"#000000",straightFirst:false,straightLast:false,point:{visible:false,fixed:true,withLabel:false,name:""}},point:{withLabel:true,style:5,face:"o",size:3,fillColor:"#ff0000",highlightFillColor:"#EEEEEE",strokeWidth:2,strokeColor:"#ff0000",highlightStrokeColor:"#C3D9FF",zoom:false,showInfobox:true,draft:false,attractors:[],attractorDistance:0,snatchDistance:0,snapToGrid:false,snapSizeX:1,snapSizeY:1,snapToPoints:false},polygon:{hasInnerPoints:false,fillColor:"#00FF00",highlightFillColor:"#00FF00",fillOpacity:0.3,highlightFillOpacity:0.3,withLines:true,borders:{withLabel:false,strokeWidth:1,highlightStrokeWidth:1,layer:5},vertices:{withLabel:true,strokeColor:"#ff0000",fillColor:"#ff0000",fixed:true},label:{offsets:[0,0]}},riemannsum:{withLabel:false,fillOpacity:0.3,fillColor:"#ffff00"},sector:{fillColor:"#00FF00",highlightFillColor:"#00FF00",fillOpacity:0.3,highlightFillOpacity:0.3},semicircle:{midpoint:{visible:false,withLabel:false,fixed:false,name:""}},slider:{snapWidth:-1,precision:2,firstArrow:false,lastArrow:false,withTicks:true,withLabel:true,layer:9,showInfobox:false,name:"",visible:true,strokeColor:"#000000",highlightStrokeColor:"#888888",fillColor:"#ffffff",highlightFillColor:"none",size:6,point1:{needsRegularUpdate:false,showInfobox:false,withLabel:false,visible:false,fixed:true,name:""},point2:{needsRegularUpdate:false,showInfobox:false,withLabel:false,visible:false,fixed:true,name:""},baseline:{needsRegularUpdate:false,name:"",strokeWidth:1,strokeColor:"#000000",highlightStrokeColor:"#888888"},ticks:{needsRegularUpdate:false,drawLabels:false,drawZero:true,insertTicks:true,minorHeight:4,majorHeight:10,minorTicks:0,defaultDistance:1,strokeOpacity:1,strokeWidth:1,strokeColor:"#000000"},highline:{strokeWidth:3,name:"",strokeColor:"#000000",highlightStrokeColor:"#888888"},label:{strokeColor:"#000000"}},text:{fontSize:12,digits:2,isLabel:false,strokeColor:"#000000",useASCIIMathML:false,useMathJax:false,display:"html",cssClass:"JXGtext",highlightCssClass:"JXGtext",withLabel:false},tracecurve:{strokeColor:"#000000",fillColor:"none",numberPoints:100},turtle:{strokeWidth:1,fillColor:"none",strokeColor:"#000000",arrow:{strokeWidth:2,withLabel:false,strokeColor:"#ff0000"}},shortcuts:{color:["strokeColor","fillColor"],opacity:["strokeOpacity","fillOpacity"],highlightColor:["highlightStrokeColor","highlightFillColor"],highlightOpacity:["highlightStrokeOpacity","highlightFillOpacity"],strokeWidth:["strokeWidth","highlightStrokeWidth"]}};JXG.Validator=(function(){var l=function(i){return/^[0-9]+px$/.test(i)},n=function(i){return(i in {html:0,internal:0})},o=function(i){return JXG.isString(i)},m=function(i){return JXG.exists(JXG.Point.prototype.normalizeFace.call(this,i))},q=function(i){return(Math.abs(i-Math.round(i))0},j=function(i){return i.length>=2&&q(i[0])&&q(i[1])},e=function(i){return(i in {vml:0,svg:0,canvas:0})},k=function(i){return i>0},h=function(i){return !(i<0)},g,p={},f={attractorDistance:h,color:o,defaultDistance:JXG.isNumber,display:n,doAdvancedPlot:false,draft:false,drawLabels:false,drawZero:false,face:m,factor:JXG.isNumber,fillColor:o,fillOpacity:JXG.isNumber,firstArrow:false,fontSize:q,dash:q,gridX:JXG.isNumber,gridY:JXG.isNumber,hasGrid:false,highlightFillColor:o,highlightFillOpacity:JXG.isNumber,highlightStrokeColor:o,highlightStrokeOpacity:JXG.isNumber,insertTicks:false,lastArrow:false,majorHeight:q,maxTicksDistance:r,minorHeight:q,minorTicks:r,minTicksDistance:r,numberPointsHigh:r,numberPointsLow:r,opacity:JXG.isNumber,radius:JXG.isNumber,RDPsmoothing:false,renderer:e,right:l,showCopyright:false,showInfobox:false,showNavigation:false,size:q,snapSizeX:k,snapSizeY:k,snapWidth:JXG.isNumber,snapToGrid:false,snatchDistance:h,straightFirst:false,straightLast:false,stretch:false,strokeColor:o,strokeOpacity:JXG.isNumber,strokeWidth:q,takeFirst:false,takeSizeFromFile:false,to10:false,toOrigin:false,translateTo10:false,translateToOrigin:false,useASCIIMathML:false,useDirection:false,useMathJax:false,withLabel:false,withTicks:false,zoom:false};for(g in f){p[g.toLowerCase()]=f[g]}return p})();JXG.useStandardOptions=function(i){var k=JXG.Options,h=i.hasGrid,g,f,j,e;i.options.grid.hasGrid=k.grid.hasGrid;i.options.grid.gridX=k.grid.gridX;i.options.grid.gridY=k.grid.gridY;i.options.grid.gridColor=k.grid.gridColor;i.options.grid.gridOpacity=k.grid.gridOpacity;i.options.grid.gridDash=k.grid.gridDash;i.options.grid.snapToGrid=k.grid.snapToGrid;i.options.grid.snapSizeX=k.grid.SnapSizeX;i.options.grid.snapSizeY=k.grid.SnapSizeY;i.takeSizeFromFile=k.takeSizeFromFile;e=function(l,m){l.visProp.fillcolor=m.fillColor;l.visProp.highlightfillcolor=m.highlightFillColor;l.visProp.strokecolor=m.strokeColor;l.visProp.highlightstrokecolor=m.highlightStrokeColor};for(g in i.objects){j=i.objects[g];if(j.elementClass==JXG.OBJECT_CLASS_POINT){e(j,k.point)}else{if(j.elementClass==JXG.OBJECT_CLASS_LINE){e(j,k.line);for(f in j.ticks){f.majorTicks=k.line.ticks.majorTicks;f.minTicksDistance=k.line.ticks.minTicksDistance;f.visProp.minorheight=k.line.ticks.minorHeight;f.visProp.majorheight=k.line.ticks.majorHeight}}else{if(j.elementClass==JXG.OBJECT_CLASS_CIRCLE){e(j,k.circle)}else{if(j.type==JXG.OBJECT_TYPE_ANGLE){e(j,k.angle)}else{if(j.type==JXG.OBJECT_TYPE_ARC){e(j,k.arc)}else{if(j.type==JXG.OBJECT_TYPE_POLYGON){e(j,k.polygon)}else{if(j.type==JXG.OBJECT_TYPE_CONIC){e(j,k.conic)}else{if(j.type==JXG.OBJECT_TYPE_CURVE){e(j,k.curve)}else{if(j.type==JXG.OBJECT_TYPE_SECTOR){j.arc.visProp.fillcolor=k.sector.fillColor;j.arc.visProp.highlightfillcolor=k.sector.highlightFillColor;j.arc.visProp.fillopacity=k.sector.fillOpacity;j.arc.visProp.highlightfillopacity=k.sector.highlightFillOpacity}}}}}}}}}}i.fullUpdate();if(h&&!i.hasGrid){i.removeGrids(i)}else{if(!h&&i.hasGrid){i.create("grid",[])}}};JXG.useBlackWhiteOptions=function(e){var f=JXG.Options;f.point.fillColor=JXG.rgb2bw(f.point.fillColor);f.point.highlightFillColor=JXG.rgb2bw(f.point.highlightFillColor);f.point.strokeColor=JXG.rgb2bw(f.point.strokeColor);f.point.highlightStrokeColor=JXG.rgb2bw(f.point.highlightStrokeColor);f.line.fillColor=JXG.rgb2bw(f.line.fillColor);f.line.highlightFillColor=JXG.rgb2bw(f.line.highlightFillColor);f.line.strokeColor=JXG.rgb2bw(f.line.strokeColor);f.line.highlightStrokeColor=JXG.rgb2bw(f.line.highlightStrokeColor);f.circle.fillColor=JXG.rgb2bw(f.circle.fillColor);f.circle.highlightFillColor=JXG.rgb2bw(f.circle.highlightFillColor);f.circle.strokeColor=JXG.rgb2bw(f.circle.strokeColor);f.circle.highlightStrokeColor=JXG.rgb2bw(f.circle.highlightStrokeColor);f.arc.fillColor=JXG.rgb2bw(f.arc.fillColor);f.arc.highlightFillColor=JXG.rgb2bw(f.arc.highlightFillColor);f.arc.strokeColor=JXG.rgb2bw(f.arc.strokeColor);f.arc.highlightStrokeColor=JXG.rgb2bw(f.arc.highlightStrokeColor);f.polygon.fillColor=JXG.rgb2bw(f.polygon.fillColor);f.polygon.highlightFillColor=JXG.rgb2bw(f.polygon.highlightFillColor);f.sector.fillColor=JXG.rgb2bw(f.sector.fillColor);f.sector.highlightFillColor=JXG.rgb2bw(f.sector.highlightFillColor);f.curve.strokeColor=JXG.rgb2bw(f.curve.strokeColor);f.grid.gridColor=JXG.rgb2bw(f.grid.gridColor);JXG.useStandardOptions(e)};JXG.JSXGraph={licenseText:"JSXGraph v0.94 Copyright (C) see http://jsxgraph.org",boards:{},elements:{},rendererType:(function(){var g,e;if(JXG.supportsSVG()){JXG.Options.renderer="svg"}else{if(JXG.supportsVML()){JXG.Options.renderer="vml";function f(){document.body.scrollLeft;document.body.scrollTop}document.onmousemove=f}else{JXG.Options.renderer="canvas"}}e=JXG.rendererFiles[JXG.Options.renderer].split(",");for(g=0;g0){this.board=i;this.type=h;this.elementClass=j||JXG.OBJECT_CLASS_OTHER;this.id=e.id;f=e.name;if(!JXG.exists(f)){f=this.board.generateName(this)}this.board.elementsByName[f]=this;this.name=f;this.needsRegularUpdate=e.needsregularupdate;JXG.clearVisPropOld(this);e=this.resolveShortcuts(e);for(g in e){this._set(g,e[g])}this.visProp.draft=e.draft&&e.draft.draft;this.visProp.gradientangle="270";this.visProp.gradientsecondopacity=this.visProp.fillopacity;this.visProp.gradientpositionx=0.5;this.visProp.gradientpositiony=0.5}};JXG.extend(JXG.GeometryElement.prototype,{addChild:function(g){var f,e;this.childElements[g.id]=g;this.addDescendants(g);g.ancestors[this.id]=this;for(f in this.descendants){this.descendants[f].ancestors[this.id]=this;for(e in this.ancestors){this.descendants[f].ancestors[this.ancestors[e].id]=this.ancestors[e]}}for(f in this.ancestors){for(e in this.descendants){this.ancestors[f].descendants[this.descendants[e].id]=this.descendants[e]}}return this},addDescendants:function(f){var e;this.descendants[f.id]=f;for(e in f.childElements){this.addDescendants(f.childElements[e])}return this},countChildren:function(){var g,e=0,f;f=this.childElements;for(g in f){if(f.hasOwnProperty(g)&&g.indexOf("Label")<0){e++}}return e},getName:function(){return this.name},draggable:function(){return this.isDraggable&&!this.visProp.fixed&&!this.visProp.frozen&&this.type!=JXG.OBJECT_TYPE_GLIDER},generatePolynomial:function(){return[]},animate:function(h,g,q){q=q||{};var e,f,k=35,l=Math.ceil(g/(k*1)),j,n=this;this.animationData={};var o=function(w,v,t){var u,s,r,p,i;u=JXG.rgb2hsv(w);s=JXG.rgb2hsv(v);r=(s[0]-u[0])/(1*l);p=(s[1]-u[1])/(1*l);i=(s[2]-u[2])/(1*l);n.animationData[t]=new Array(l);for(j=0;j=0&&JXG.isString(e)&&e.length==9&&e.charAt(0)==="#"){e=JXG.rgba2rgbo(e);this.visProp[f]=e[0];this.visProp[f.replace("color","opacity")]=e[1]}else{this.visProp[f]=e}},resolveShortcuts:function(g){var f,e;for(f in JXG.Options.shortcuts){if(JXG.exists(g[f])){for(e=0;e/g,">");if(this.label!==null){this.label.content.setText(e)}return this},setAttribute:JXG.shortcut(JXG.GeometryElement.prototype,"setProperty"),setProperty:function(){var j,h,k,e,f,l,g={};for(j=0;j-1){this.eventHandlers[g].splice(e,1)}}else{this.eventHandlers[g].length=0}},removeEvent:JXG.shortcut(JXG.GeometryElement.prototype,"off")});JXG.COORDS_BY_USER=1;JXG.COORDS_BY_SCREEN=2;JXG.Coords=function(g,f,e){this.board=e;this.usrCoords=[];this.scrCoords=[];this.setCoordinates(g,f)};JXG.extend(JXG.Coords.prototype,{normalizeUsrCoords:function(){var e=JXG.Math.eps;if(Math.abs(this.usrCoords[0])>e){this.usrCoords[1]/=this.usrCoords[0];this.usrCoords[2]/=this.usrCoords[0];this.usrCoords[0]=1}},usr2screen:function(i){var h=Math.round,e=this.board,g=this.usrCoords,f=e.origin.scrCoords;if(i===null||i){this.scrCoords[0]=h(g[0]);this.scrCoords[1]=h(g[0]*f[1]+g[1]*e.unitX);this.scrCoords[2]=h(g[0]*f[2]-g[2]*e.unitY)}else{this.scrCoords[0]=g[0];this.scrCoords[1]=g[0]*f[1]+g[1]*e.unitX;this.scrCoords[2]=g[0]*f[2]-g[2]*e.unitY}},screen2usr:function(){var g=this.board.origin.scrCoords,f=this.scrCoords,e=this.board;this.usrCoords[0]=1;this.usrCoords[1]=(f[1]-g[1])/e.unitX;this.usrCoords[2]=(g[2]-f[2])/e.unitY},distance:function(g,k){var h=0,l,e=this.usrCoords,j=this.scrCoords,i;if(g===JXG.COORDS_BY_USER){l=k.usrCoords;i=e[0]-l[0];h=i*i;if(h>JXG.Math.eps){return Number.POSITIVE_INFINITY}i=e[1]-l[1];h+=i*i;i=e[2]-l[2];h+=i*i}else{l=k.scrCoords;i=j[1]-l[1];h+=i*i;i=j[2]-l[2];h+=i*i}return Math.sqrt(h)},setCoordinates:function(f,i,g){var e=this.usrCoords,h=this.scrCoords;if(f===JXG.COORDS_BY_USER){if(i.length===2){e[0]=1;e[1]=i[0];e[2]=i[1]}else{e[0]=i[0];e[1]=i[1];e[2]=i[2];this.normalizeUsrCoords()}this.usr2screen(g)}else{h[1]=i[0];h[2]=i[1];this.screen2usr()}return this}});JXG.Point=function(f,g,e){this.constructor(f,e,JXG.OBJECT_TYPE_POINT,JXG.OBJECT_CLASS_POINT);if(g==null){g=[0,0]}this.coords=new JXG.Coords(JXG.COORDS_BY_USER,g,this.board);this.initialCoords=new JXG.Coords(JXG.COORDS_BY_USER,g,this.board);this.position=null;this.onPolygon=false;this.slideObject=null;this.Xjc=null;this.Yjc=null;this.methodMap=JXG.deepCopy(this.methodMap,{move:"moveTo",glide:"makeGlider",X:"X",Y:"Y",free:"free",setPosition:"setGliderPosition"});this.group=[];this.elType="point";this.id=this.board.setId(this,"P");this.board.renderer.drawPoint(this);this.board.finalizeAdding(this);this.createLabel()};JXG.Point.prototype=new JXG.GeometryElement();JXG.extend(JXG.Point.prototype,{hasPoint:function(f,h){var e=this.coords.scrCoords,g;g=parseFloat(this.visProp.size);if(g1){for(h=0;h0&&Math.abs(this._smax-this._smin)>=JXG.Math.eps){if(this.position<0){this.position=0}if(this.position>1){this.position=1}f=this.position*(this._smax-this._smin)+this._smin;f=Math.round(f/this.visProp.snapwidth)*this.visProp.snapwidth;this.position=(f-this._smin)/(this._smax-this._smin);this.update(true)}e=this.slideObject.point1.coords.usrCoords;if(!this.slideObject.visProp.straightfirst&&Math.abs(e[0])>JXG.Math.eps&&this.position<0){this.coords.setCoordinates(JXG.COORDS_BY_USER,e);this.position=0}g=this.slideObject.point2.coords.usrCoords;if(!this.slideObject.visProp.straightlast&&Math.abs(g[0])>JXG.Math.eps&&this.position>1){this.coords.setCoordinates(JXG.COORDS_BY_USER,g);this.position=1}}else{if(this.slideObject.type==JXG.OBJECT_TYPE_TURTLE){this.updateConstraint();this.coords=JXG.Math.Geometry.projectPointToTurtle(this,this.slideObject,this.board)}else{if(this.slideObject.elementClass==JXG.OBJECT_CLASS_CURVE){this.updateConstraint();this.coords=JXG.Math.Geometry.projectPointToCurve(this,this.slideObject,this.board)}else{if(this.slideObject.elementClass==JXG.OBJECT_CLASS_POINT){this.coords=JXG.Math.Geometry.projectPointToPoint(this,this.slideObject,this.board)}}}}}},updateGliderFromParent:function(){var e,f,g,h;if(this.slideObject.elementClass==JXG.OBJECT_CLASS_CIRCLE){g=this.slideObject.Radius();this.coords.setCoordinates(JXG.COORDS_BY_USER,[this.slideObject.center.X()+g*Math.cos(this.position),this.slideObject.center.Y()+g*Math.sin(this.position)])}else{if(this.slideObject.elementClass==JXG.OBJECT_CLASS_LINE){e=this.slideObject.point1.coords;f=this.slideObject.point2.coords;h=e.distance(JXG.COORDS_BY_USER,f);e=e.usrCoords.slice(0);f=f.usrCoords.slice(0);if(h==Number.POSITIVE_INFINITY){h=1/JXG.Math.eps;if(Math.abs(f[0])JXG.Math.eps)?this.isReal:false;if(this.isReal){if(e!=this.isReal){this.board.renderer.show(this);if(this.hasLabel&&this.label.content.visProp.visible){this.board.renderer.show(this.label.content)}}this.board.renderer.updatePoint(this)}else{if(e!=this.isReal){this.board.renderer.hide(this);if(this.hasLabel&&this.label.content.visProp.visible){this.board.renderer.hide(this.label.content)}}}}if(this.hasLabel&&this.visProp.visible&&this.label.content&&this.label.content.visProp.visible&&this.isReal){this.label.content.update();this.board.renderer.updateText(this.label.content)}this.needsUpdate=false;return this},X:function(){return this.coords.usrCoords[1]},Y:function(){return this.coords.usrCoords[2]},Z:function(){return this.coords.usrCoords[0]},XEval:function(){return this.coords.usrCoords[1]},YEval:function(){return this.coords.usrCoords[2]},ZEval:function(){return this.coords.usrCoords[0]},bounds:function(){return this.coords.usrCoords.slice(1).concat(this.coords.usrCoords.slice(1))},Dist:function(g){var h,j=g.coords.usrCoords,e=this.coords.usrCoords,i;i=e[0]-j[0];h=i*i;i=e[1]-j[1];h+=i*i;i=e[2]-j[2];h+=i*i;return Math.sqrt(h)},handleSnapToGrid:function(){var e,h,g=this.visProp.snapsizex,f=this.visProp.snapsizey;if(this.visProp.snaptogrid){e=this.coords.usrCoords[1];h=this.coords.usrCoords[2];if(g<=0&&this.board.defaultAxes&&this.board.defaultAxes.x.defaultTicks){g=this.board.defaultAxes.x.defaultTicks.ticksDelta*(this.board.defaultAxes.x.defaultTicks.visProp.minorticks+1)}if(f<=0&&this.board.defaultAxes&&this.board.defaultAxes.y.defaultTicks){f=this.board.defaultAxes.y.defaultTicks.ticksDelta*(this.board.defaultAxes.y.defaultTicks.visProp.minorticks+1)}if(g>0&&f>0){this.coords=new JXG.Coords(JXG.COORDS_BY_USER,[Math.round(e/g)*g,Math.round(h/f)*f],this.board)}}return this},handleSnapToPoints:function(){var g,j,e,h=0,f=Infinity,i=null;if(this.visProp.snaptopoints){for(g in this.board.objects){j=this.board.objects[g];if(j.elementClass==JXG.OBJECT_CLASS_POINT&&j!==this&&j.visProp.visible){e=JXG.Math.Geometry.projectPointToPoint(this,j,this.board);h=e.distance(JXG.COORDS_BY_USER,this.coords);if(h=this.visProp.snatchdistance){this.type=JXG.OBJECT_TYPE_POINT}}}return this},setPositionDirectly:function(e,l,j){var h,o,n,g,f,k=this.coords,m;this.coords=new JXG.Coords(e,[l,j],this.board);this.handleSnapToGrid();this.handleSnapToPoints();this.handleAttractors();if(this.group.length!=0){o=this.coords.usrCoords[1]-k.usrCoords[1];n=this.coords.usrCoords[2]-k.usrCoords[2];for(h=0;h=0;h--){if(e==JXG.COORDS_BY_SCREEN){m=(new JXG.Coords(e,[l,j],this.board)).usrCoords}else{m=[1,l,j]}this.initialCoords=new JXG.Coords(JXG.COORDS_BY_USER,JXG.Math.matVecMult(JXG.Math.inverse(this.transformations[h].matrix),m),this.board)}this.update()}return this},setPositionByTransform:function(h,e,g){var f=this.board.create("transform",[e,g],{type:"translate"});if(this.transformations.length>0&&this.transformations[this.transformations.length-1].isNumericMatrix){this.transformations[this.transformations.length-1].melt(f)}else{this.addTransform(this,f)}if(this.group.length==0){this.update()}return this},setPosition:function(g,e,f){this.setPositionDirectly(g,e,f);return this},setGliderPosition:function(e){if(this.type=JXG.OBJECT_TYPE_GLIDER){this.position=e;this.board.update()}return this},makeGlider:function(e){this.slideObject=JXG.getRef(this.board,e);this.type=JXG.OBJECT_TYPE_GLIDER;this.elType="glider";this.visProp.snapwidth=-1;this.slideObject.addChild(this);this.isDraggable=true;this.generatePolynomial=function(){return this.slideObject.generatePolynomial(this)};this.updateGlider();return this},free:function(){var e;if(this.type!==JXG.OBJECT_TYPE_GLIDER){if(!this.isDraggable){this.isDraggable=true;this.type=JXG.OBJECT_TYPE_POINT;this.XEval=function(){return this.coords.usrCoords[1]};this.YEval=function(){return this.coords.usrCoords[2]};this.ZEval=function(){return this.coords.usrCoords[0]};this.Xjc=null;this.Yjc=null}else{return}}for(e in this.ancestors){delete this.ancestors[e].descendants[this.id];delete this.ancestors[e].childElements[this.id]}this.ancestors=[];this.slideObject=null;this.elType="point";this.type=JXG.OBJECT_TYPE_POINT},addConstraint:function(j){this.type=JXG.OBJECT_TYPE_CAS;var l=[],e,h,f,g,k=["X","Y"];this.isDraggable=false;for(h=0;h"){return Math.pow(Math.sin((r/(n*1))*Math.PI/2),2)}return r/n};if(Math.abs(j)=0;k--){o[n-k]=[f+j*p(k),e+h*p(k)]}this.animationPath=o;this.animationCallback=q.callback;this.board.addAnimation(this);return this},visit:function(n,g,s){if(typeof s=="number"){s={repeat:s}}else{s=s||{};if(typeof s.repeat=="undefined"){s.repeat=1}}var o=35,p=Math.ceil(g/(o*s.repeat)),q=new Array(s.repeat*(p+1)),f=this.coords.usrCoords[1],e=this.coords.usrCoords[2],l=(n[0]-f),h=(n[1]-e),m,k,r=function(t){var j=(t

"){return Math.pow(Math.sin((j)*Math.PI/2),2)}return j};for(k=0;k=0;m--){q[k*(p+1)+p-m]=[f+l*r(m),e+h*r(m)]}}this.animationPath=q;this.animationCallback=s.callback;this.board.addAnimation(this);return this},_anim:function(o,j){var f,m,k,i,h,g,n=1,e,l;this.intervalCount++;if(this.intervalCount>j){this.intervalCount=0}if(this.slideObject.elementClass==JXG.OBJECT_CLASS_LINE){f=this.slideObject.point1.coords.distance(JXG.COORDS_BY_SCREEN,this.slideObject.point2.coords);m=this.slideObject.getSlope();if(m!="INF"){h=Math.atan(m);k=Math.round((this.intervalCount/j)*f*Math.cos(h));i=Math.round((this.intervalCount/j)*f*Math.sin(h))}else{k=0;i=Math.round((this.intervalCount/j)*f)}if(o<0){g=this.slideObject.point2;if(this.slideObject.point2.coords.scrCoords[1]-this.slideObject.point1.coords.scrCoords[1]>0){n=-1}else{if(this.slideObject.point2.coords.scrCoords[1]-this.slideObject.point1.coords.scrCoords[1]==0){if(this.slideObject.point2.coords.scrCoords[2]-this.slideObject.point1.coords.scrCoords[2]>0){n=-1}}}}else{g=this.slideObject.point1;if(this.slideObject.point1.coords.scrCoords[1]-this.slideObject.point2.coords.scrCoords[1]>0){n=-1}else{if(this.slideObject.point1.coords.scrCoords[1]-this.slideObject.point2.coords.scrCoords[1]==0){if(this.slideObject.point1.coords.scrCoords[2]-this.slideObject.point2.coords.scrCoords[2]>0){n=-1}}}}this.coords.setCoordinates(JXG.COORDS_BY_SCREEN,[g.coords.scrCoords[1]+n*k,g.coords.scrCoords[2]+n*i])}else{if(this.slideObject.elementClass==JXG.OBJECT_CLASS_CURVE){if(o>0){e=Math.round(this.intervalCount/j*this.board.canvasWidth)}else{e=Math.round((j-this.intervalCount)/j*this.board.canvasWidth)}this.coords.setCoordinates(JXG.COORDS_BY_SCREEN,[e,0]);this.coords=JXG.Math.Geometry.projectPointToCurve(this,this.slideObject,this.board)}else{if(this.slideObject.elementClass==JXG.OBJECT_CLASS_CIRCLE){if(o<0){h=this.intervalCount/j*2*Math.PI}else{h=(j-this.intervalCount)/j*2*Math.PI}l=this.slideObject.Radius();this.coords.setCoordinates(JXG.COORDS_BY_USER,[this.slideObject.center.coords.usrCoords[1]+l*Math.cos(h),this.slideObject.center.coords.usrCoords[2]+l*Math.sin(h)])}}}this.board.update(this);return this},setStyle:function(e){var f=["cross","cross","cross","circle","circle","circle","circle","square","square","square","plus","plus","plus"],g=[2,3,4,1,2,3,4,2,3,4,2,3,4];this.visProp.face=f[e];this.visProp.size=g[e];this.board.renderer.changePointStyle(this);return this},normalizeFace:function(e){var f={cross:"x",x:"x",circle:"o",o:"o",square:"[]","[]":"[]",plus:"+","+":"+",diamond:"<>","<>":"<>",triangleup:"^",a:"^","^":"^",triangledown:"v",v:"v",triangleleft:"<","<":"<",triangleright:">",">":">"};return f[e]},remove:function(){if(this.hasLabel){this.board.renderer.remove(this.board.renderer.getElementById(this.label.content.id))}this.board.renderer.remove(this.board.renderer.getElementById(this.id))},getTextAnchor:function(){return this.coords},getLabelAnchor:function(){return this.coords},face:function(e){this.setProperty({face:e})},size:function(e){this.setProperty({size:e})},cloneToBackground:function(){var e={};e.id=this.id+"T"+this.numTraces;this.numTraces++;e.coords=this.coords;e.visProp=JXG.deepCopy(this.visProp,this.visProp.traceattributes,true);e.visProp.layer=this.board.options.layer.trace;e.elementClass=JXG.OBJECT_CLASS_POINT;e.board=this.board;JXG.clearVisPropOld(e);this.board.renderer.drawPoint(e);this.traces[e.id]=e.rendNode;return this},getParents:function(){var e=[this.Z(),this.X(),this.Y()];if(this.parents){e=this.parents}if(this.type==JXG.OBJECT_TYPE_GLIDER){e=[this.X(),this.Y(),this.slideObject.id]}return e}});JXG.createPoint=function(l,h,g){var k,f=false,j,e;e=JXG.copyAttributes(g,l.options,"point");for(j=0;j=3){if(f.length==3){f.push(null)}g=h.create("point",[h.intersection(f[0],f[1],f[2],f[3])],e)}f[0].addChild(g);f[1].addChild(g);g.elType="intersection";g.parents=[f[0].id,f[1].id,f[2]];if(f[3]!=null){g.parents.push(f[3])}g.generatePolynomial=function(){var i=f[0].generatePolynomial(g);var j=f[1].generatePolynomial(g);if((i.length==0)||(j.length==0)){return[]}else{return[i[0],j[0]]}};return g};JXG.createOtherIntersectionPoint=function(h,f,e){var g;if(f.length!=3||!JXG.isPoint(f[2])||(f[0].elementClass!=JXG.OBJECT_CLASS_LINE&&f[0].elementClass!=JXG.OBJECT_CLASS_CIRCLE)||(f[1].elementClass!=JXG.OBJECT_CLASS_LINE&&f[1].elementClass!=JXG.OBJECT_CLASS_CIRCLE)){throw new Error("JSXGraph: Can't create 'other intersection point' with parent types '"+(typeof f[0])+"', '"+(typeof f[1])+"'and '"+(typeof f[2])+"'.\nPossible parent types: [circle|line,circle|line,point]")}else{g=h.create("point",[h.otherIntersection(f[0],f[1],f[2])],e)}g.elType="otherintersection";g.parents=[f[0].id,f[1].id,f[2]];f[0].addChild(g);f[1].addChild(g);g.generatePolynomial=function(){var i=f[0].generatePolynomial(g);var j=f[1].generatePolynomial(g);if((i.length==0)||(j.length==0)){return[]}else{return[i[0],j[0]]}};return g};JXG.JSXGraph.registerElement("point",JXG.createPoint);JXG.JSXGraph.registerElement("glider",JXG.createGlider);JXG.JSXGraph.registerElement("intersection",JXG.createIntersectionPoint);JXG.JSXGraph.registerElement("otherintersection",JXG.createOtherIntersectionPoint);JXG.Line=function(f,h,g,e){this.constructor(f,e,JXG.OBJECT_TYPE_LINE,JXG.OBJECT_CLASS_LINE);this.point1=JXG.getReference(this.board,h);this.point2=JXG.getReference(this.board,g);this.ticks=[];this.defaultTicks=null;this.parentPolygon=null;this.id=this.board.setId(this,"L");this.board.renderer.drawLine(this);this.board.finalizeAdding(this);this.elType="line";this.createLabel();this.point1.addChild(this);this.point2.addChild(this);this.updateStdform()};JXG.Line.prototype=new JXG.GeometryElement;JXG.extend(JXG.Line.prototype,{hasPoint:function(l,k){var h=[],o,n=[1,l,k],m,p,g,f,j,e;h[0]=this.stdform[0]-this.stdform[1]*this.board.origin.scrCoords[1]/this.board.unitX+this.stdform[2]*this.board.origin.scrCoords[2]/this.board.unitY;h[1]=this.stdform[1]/this.board.unitX;h[2]=this.stdform[2]/(-this.board.unitY);m=[0,h[1],h[2]];m=JXG.Math.crossProduct(m,n);m=JXG.Math.crossProduct(m,h);m[1]/=m[0];m[2]/=m[0];m[0]=1;o=(n[1]-m[1])*(n[1]-m[1])+(n[2]-m[2])*(n[2]-m[2]);if(isNaN(o)||o>this.board.options.precision.hasPoint*this.board.options.precision.hasPoint){return false}if(this.visProp.straightfirst&&this.visProp.straightlast){return true}else{p=this.point1.coords;g=this.point2.coords;m=(new JXG.Coords(JXG.COORDS_BY_SCREEN,m.slice(1),this.board)).usrCoords;f=p.distance(JXG.COORDS_BY_USER,g);p=p.usrCoords.slice(0);g=g.usrCoords.slice(0);if(f1){return false}return true}},update:function(){var h,f,e,j,g,m,l,k,i;if(!this.needsUpdate){return this}if(this.constrained){if(typeof this.funps!="undefined"){h=this.funps();if(h&&h.length&&h.length===2){this.point1=h[0];this.point2=h[1]}}else{if(typeof this.funp1==="function"){h=this.funp1();if(JXG.isPoint(h)){this.point1=h}else{if(h&&h.length&&h.length===2){this.point1.setPositionDirectly(JXG.COORDS_BY_USER,h[0],h[1])}}}if(typeof this.funp2==="function"){h=this.funp2();if(JXG.isPoint(h)){this.point2=h}else{if(h&&h.length&&h.length===2){this.point2.setPositionDirectly(JXG.COORDS_BY_USER,h[0],h[1])}}}}}this.updateSegmentFixedLength();this.updateStdform();if(this.visProp.trace){this.cloneToBackground(true)}return this},updateSegmentFixedLength:function(){if(!this.hasFixedLength){return this}d=this.point1.Dist(this.point2);dnew=this.fixedLength();d1=this.fixedLengthOldCoords[0].distance(JXG.COORDS_BY_USER,this.point1.coords);d2=this.fixedLengthOldCoords[1].distance(JXG.COORDS_BY_USER,this.point2.coords);if(d1>JXG.Math.eps||d2>JXG.Math.eps||d!=dnew){drag1=this.point1.isDraggable&&(this.point1.type!=JXG.OBJECT_TYPE_GLIDER)&&!this.point1.visProp.fixed;drag2=this.point2.isDraggable&&(this.point2.type!=JXG.OBJECT_TYPE_GLIDER)&&!this.point2.visProp.fixed;if(d>JXG.Math.eps){if((d1>d2&&drag2)||(d1<=d2&&drag2&&!drag1)){this.point2.setPositionDirectly(JXG.COORDS_BY_USER,this.point1.X()+(this.point2.X()-this.point1.X())*dnew/d,this.point1.Y()+(this.point2.Y()-this.point1.Y())*dnew/d);this.point2.prepareUpdate().updateRenderer()}else{if((d1<=d2&&drag1)||(d1>d2&&drag1&&!drag2)){this.point1.setPositionDirectly(JXG.COORDS_BY_USER,this.point2.X()+(this.point1.X()-this.point2.X())*dnew/d,this.point2.Y()+(this.point1.Y()-this.point2.Y())*dnew/d);this.point1.prepareUpdate().updateRenderer()}}}else{x=Math.random()-0.5;y=Math.random()-0.5;d=Math.sqrt(x*x+y*y);if(drag2){this.point2.setPositionDirectly(JXG.COORDS_BY_USER,this.point1.X()+x*dnew/d,this.point1.Y()+y*dnew/d);this.point2.prepareUpdate().updateRenderer()}else{if(drag1){this.point1.setPositionDirectly(JXG.COORDS_BY_USER,this.point2.X()+x*dnew/d,this.point2.Y()+y*dnew/d);this.point1.prepareUpdate().updateRenderer()}}}this.fixedLengthOldCoords[0].setCoordinates(JXG.COORDS_BY_USER,this.point1.coords.usrCoords);this.fixedLengthOldCoords[1].setCoordinates(JXG.COORDS_BY_USER,this.point2.coords.usrCoords)}return this},updateStdform:function(){var e=JXG.Math.crossProduct(this.point1.coords.usrCoords,this.point2.coords.usrCoords);this.stdform[0]=e[0];this.stdform[1]=e[1];this.stdform[2]=e[2];this.stdform[3]=0;this.normalize()},updateRenderer:function(){var e;if(this.needsUpdate&&this.visProp.visible){e=this.isReal;this.isReal=(!isNaN(this.point1.coords.usrCoords[1]+this.point1.coords.usrCoords[2]+this.point2.coords.usrCoords[1]+this.point2.coords.usrCoords[2])&&(JXG.Math.innerProduct(this.stdform,this.stdform,3)>=JXG.Math.eps*JXG.Math.eps));if(this.isReal){if(e!=this.isReal){this.board.renderer.show(this);if(this.hasLabel&&this.label.content.visProp.visible){this.board.renderer.show(this.label.content)}}this.board.renderer.updateLine(this)}else{if(e!=this.isReal){this.board.renderer.hide(this);if(this.hasLabel&&this.label.content.visProp.visible){this.board.renderer.hide(this.label.content)}}}this.needsUpdate=false}if(this.hasLabel&&this.label.content.visProp.visible&&this.isReal){this.label.content.update();this.board.renderer.updateText(this.label.content)}return this},generatePolynomial:function(i){var h=this.point1.symbolic.x,g=this.point1.symbolic.y,k=this.point2.symbolic.x,j=this.point2.symbolic.y,f=i.symbolic.x,e=i.symbolic.y;return[["(",g,")*(",f,")-(",g,")*(",k,")+(",e,")*(",k,")-(",h,")*(",e,")+(",h,")*(",j,")-(",f,")*(",j,")"].join("")]},getRise:function(){if(Math.abs(this.stdform[2])>=JXG.Math.eps){return -this.stdform[0]/this.stdform[2]}else{return Infinity}},getSlope:function(){if(Math.abs(this.stdform[2])>=JXG.Math.eps){return -this.stdform[1]/this.stdform[2]}else{return Infinity}},getAngle:function(){return Math.atan2(this.point2.Y()-this.point1.Y(),this.point2.X()-this.point1.X())},setStraight:function(e,f){this.visProp.straightfirst=e;this.visProp.straightlast=f;this.board.renderer.updateLine(this);return this},getTextAnchor:function(){return new JXG.Coords(JXG.COORDS_BY_USER,[0.5*(this.point2.X()+this.point1.X()),0.5*(this.point2.Y()+this.point1.Y())],this.board)},setLabelRelativeCoords:function(e){if(JXG.exists(this.label.content)){this.label.content.relativeCoords=new JXG.Coords(JXG.COORDS_BY_SCREEN,[e[0],-e[1]],this.board)}},getLabelAnchor:function(){var g,f,e,j,i=0,h=0,g=new JXG.Coords(JXG.COORDS_BY_USER,this.point1.coords.usrCoords,this.board);f=new JXG.Coords(JXG.COORDS_BY_USER,this.point2.coords.usrCoords,this.board);if(this.visProp.straightfirst||this.visProp.straightlast){JXG.Math.Geometry.calcStraight(this,g,f)}g=g.scrCoords;f=f.scrCoords;switch(this.label.content.visProp.position){case"lft":case"llft":case"ulft":if(g[1]<=f[1]){e=g[1];j=g[2]}else{e=f[1];j=f[2]}break;case"rt":case"lrt":case"urt":if(g[1]>f[1]){e=g[1];j=g[2]}else{e=f[1];j=f[2]}break;default:e=0.5*(g[1]+f[1]);j=0.5*(g[2]+f[2])}if(this.visProp.straightfirst||this.visProp.straightlast){if(JXG.exists(this.label.content)){i=parseFloat(this.label.content.visProp.offsets[0]);h=parseFloat(this.label.content.visProp.offsets[1])}if(Math.abs(e)0&&this.point1.transformations[this.point1.transformations.length-1].isNumericMatrix){this.point1.transformations[this.point1.transformations.length-1].melt(f)}else{this.point1.addTransform(this.point1,f)}if(this.point2.transformations.length>0&&this.point2.transformations[this.point2.transformations.length-1].isNumericMatrix){this.point2.transformations[this.point2.transformations.length-1].melt(f)}else{this.point2.addTransform(this.point2,f)}return this},setPositionDirectly:function(l,e,k,j,i){var g=e-j,f=k-i;if(!this.point1.draggable()||!this.point2.draggable()){return this}g/=this.board.unitX;f/=-this.board.unitY;var h=this.board.create("transform",[g,f,0],{type:"translate"});h.applyOnce([this.point1,this.point2]);return this},X:function(g){var f=this.stdform[2],e;e=(Math.abs(this.point1.coords.usrCoords[0])>JXG.Math.eps)?this.point1.coords.usrCoords[1]:this.point2.coords.usrCoords[1];g=(g-0.5)*2;if(g<0){g*=(-1);return(1-g)*e+g*f}else{return(1-g)*e-g*f}},Y:function(f){var e=this.stdform[1],g;g=(Math.abs(this.point1.coords.usrCoords[0])>JXG.Math.eps)?this.point1.coords.usrCoords[2]:this.point2.coords.usrCoords[2];f=(f-0.5)*2;if(f<0){f*=(-1);return(1-f)*g-f*e}else{return(1-f)*g+f*e}},Z:function(e){var f=(Math.abs(this.point1.coords.usrCoords[0])>JXG.Math.eps)?this.point1.coords.usrCoords[0]:this.point2.coords.usrCoords[0];e=(e-0.5)*2;if(e<0){e*=(-1)}return(1-e)*f},L:function(){return this.point1.Dist(this.point2)},minX:function(){return 0},maxX:function(){return 1},bounds:function(){var e=this.point1.coords.usrCoords,f=this.point2.coords.usrCoords;return[Math.min(e[1],f[1]),Math.max(e[2],f[2]),Math.max(e[1],f[1]),Math.min(e[2],f[2])]},addTicks:function(e){if(e.id==""||typeof e.id=="undefined"){e.id=this.id+"_ticks_"+(this.ticks.length+1)}this.board.renderer.drawTicks(e);this.ticks.push(e);return e.id},removeAllTicks:function(){var f,e;for(e=this.ticks.length;e>0;e--){this.removeTicks(this.ticks[e-1])}this.ticks=new Array();this.board.update()},removeTicks:function(g){var f,e;if(this.defaultTicks!=null&&this.defaultTicks==g){this.defaultTicks=null}for(f=this.ticks.length;f>0;f--){if(this.ticks[f-1]==g){this.board.removeObject(this.ticks[f-1]);for(e=0;e1){m=JXG.copyAttributes(j,l.options,"line","point1");q=l.create("point",o[0],m)}else{if(JXG.isString(o[0])||o[0].elementClass==JXG.OBJECT_CLASS_POINT){q=JXG.getReference(l,o[0])}else{if((typeof o[0]=="function")&&(o[0]().elementClass==JXG.OBJECT_CLASS_POINT)){q=o[0]();h=true}else{if((typeof o[0]=="function")&&(o[0]().length&&o[0]().length===2)){m=JXG.copyAttributes(j,l.options,"line","point1");q=JXG.createPoint(l,o[0](),m);h=true}else{throw new Error("JSXGraph: Can't create line with parent types '"+(typeof o[0])+"' and '"+(typeof o[1])+"'.\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]")}}}}if(JXG.isArray(o[1])&&o[1].length>1){m=JXG.copyAttributes(j,l.options,"line","point2");p=l.create("point",o[1],m)}else{if(JXG.isString(o[1])||o[1].elementClass==JXG.OBJECT_CLASS_POINT){p=JXG.getReference(l,o[1])}else{if((typeof o[1]=="function")&&(o[1]().elementClass==JXG.OBJECT_CLASS_POINT)){p=o[1]();h=true}else{if((typeof o[1]=="function")&&(o[1]().length&&o[1]().length===2)){m=JXG.copyAttributes(j,l.options,"line","point2");p=JXG.createPoint(l,o[1](),m);h=true}else{throw new Error("JSXGraph: Can't create line with parent types '"+(typeof o[0])+"' and '"+(typeof o[1])+"'.\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]")}}}}m=JXG.copyAttributes(j,l.options,"line");g=new JXG.Line(l,q,p,m);if(h){g.constrained=true;g.funp1=o[0];g.funp2=o[1]}else{g.isDraggable=true}if(!g.constrained){g.parents=[q.id,p.id]}}else{if(o.length==3){f=true;for(k=0;k<3;k++){if(typeof o[k]=="number"){n[k]=function(i){return function(){return i}}(o[k])}else{if(typeof o[k]=="function"){n[k]=o[k];f=false}else{throw new Error("JSXGraph: Can't create line with parent types '"+(typeof o[0])+"' and '"+(typeof o[1])+"' and '"+(typeof o[2])+"'.\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]")}}}m=JXG.copyAttributes(j,l.options,"line","point1");if(f){q=l.create("point",[n[2]()*n[2]()+n[1]()*n[1](),n[2]()-n[1]()*n[0]()+n[2](),-n[1]()-n[2]()*n[0]()-n[1]()],m)}else{q=l.create("point",[function(){return(0+n[2]()*n[2]()+n[1]()*n[1]())*0.5},function(){return(n[2]()-n[1]()*n[0]()+n[2]())*0.5},function(){return(-n[1]()-n[2]()*n[0]()-n[1]())*0.5}],m)}m=JXG.copyAttributes(j,l.options,"line","point2");if(f){p=l.create("point",[n[2]()*n[2]()+n[1]()*n[1](),-n[1]()*n[0]()+n[2](),-n[2]()*n[0]()-n[1]()],m)}else{p=l.create("point",[function(){return n[2]()*n[2]()+n[1]()*n[1]()},function(){return -n[1]()*n[0]()+n[2]()},function(){return -n[2]()*n[0]()-n[1]()}],m)}q.prepareUpdate().update();p.prepareUpdate().update();m=JXG.copyAttributes(j,l.options,"line");g=new JXG.Line(l,q,p,m);g.isDraggable=f;if(f){g.parents=[n[0](),n[1](),n[2]()]}}else{if((o.length==1)&&(typeof o[0]=="function")&&(o[0]().length==2)&&(o[0]()[0].elementClass==JXG.OBJECT_CLASS_POINT)&&(o[0]()[1].elementClass==JXG.OBJECT_CLASS_POINT)){var e=o[0]();m=JXG.copyAttributes(j,l.options,"line");g=new JXG.Line(l,e[0],e[1],m);g.constrained=true;g.funps=o[0]}else{if((o.length==1)&&(typeof o[0]=="function")&&(o[0]().length==3)&&(typeof o[0]()[0]==="number")&&(typeof o[0]()[1]==="number")&&(typeof o[0]()[2]==="number")){e=o[0];m=JXG.copyAttributes(j,l.options,"line","point1");q=l.create("point",[function(){var i=e();return[(0+i[2]*i[2]+i[1]*i[1])*0.5,(i[2]-i[1]*i[0]+i[2])*0.5,(-i[1]-i[2]*i[0]-i[1])*0.5]}],m);m=JXG.copyAttributes(j,l.options,"line","point2");p=l.create("point",[function(){var i=e();return[i[2]*i[2]+i[1]*i[1],-i[1]*i[0]+i[2],-i[2]*i[0]-i[1]]}],m);m=JXG.copyAttributes(j,l.options,"line");g=new JXG.Line(l,q,p,m);g.constrained=true;g.funps=o[0]}else{throw new Error("JSXGraph: Can't create line with parent types '"+(typeof o[0])+"' and '"+(typeof o[1])+"'.\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]")}}}}return g};JXG.JSXGraph.registerElement("line",JXG.createLine);JXG.createSegment=function(j,f,e){var h,g;e.straightFirst=false;e.straightLast=false;h=j.create("line",f.slice(0,2),e);if(f.length==3){h.hasFixedLength=true;if(JXG.isNumber(f[2])){h.fixedLength=function(){return f[2]}}else{if(JXG.isFunction(f[2])){h.fixedLength=f[2]}else{throw new Error("JSXGraph: Can't create segment with third parent type '"+(typeof f[2])+"'.\nPossible third parent types: number or function")}}h.fixedLengthOldCoords=[];h.fixedLengthOldCoords[0]=new JXG.Coords(JXG.COORDS_BY_USER,h.point1.coords.usrCoords.slice(1,3),j);h.fixedLengthOldCoords[1]=new JXG.Coords(JXG.COORDS_BY_USER,h.point2.coords.usrCoords.slice(1,3),j)}h.elType="segment";return h};JXG.JSXGraph.registerElement("segment",JXG.createSegment);JXG.createArrow=function(h,f,e){var g;g=h.create("line",f,e).setStraight(false,false);g.setArrow(false,true);g.type=JXG.OBJECT_TYPE_VECTOR;g.elType="arrow";return g};JXG.JSXGraph.registerElement("arrow",JXG.createArrow);JXG.createAxis=function(j,g,f){var e,i,k;if((JXG.isArray(g[0])||JXG.isPoint(g[0]))&&(JXG.isArray(g[1])||JXG.isPoint(g[1]))){e=JXG.copyAttributes(f,j.options,"axis");i=j.create("line",g,e);i.type=JXG.OBJECT_TYPE_AXIS;i.isDraggable=false;i.point1.isDraggable=false;i.point2.isDraggable=false;for(var h in i.ancestors){i.ancestors[h].type=JXG.OBJECT_TYPE_AXISPOINT}e=JXG.copyAttributes(f,j.options,"axis","ticks");if(JXG.exists(e.ticksdistance)){k=e.ticksdistance}else{if(JXG.isArray(e.ticks)){k=e.ticks}else{k=1}}i.defaultTicks=j.create("ticks",[i,k],e);i.defaultTicks.dump=false;i.elType="axis";i.subs={ticks:i.defaultTicks}}else{throw new Error("JSXGraph: Can't create point with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"'.\nPossible parent types: [point,point], [[x1,y1],[x2,y2]]")}return i};JXG.JSXGraph.registerElement("axis",JXG.createAxis);JXG.createTangent=function(q,s,l){var e,r,n,o,m,k,h,t;if(s.length==1){e=s[0];r=e.slideObject}else{if(s.length==2){if(JXG.isPoint(s[0])){e=s[0];r=s[1]}else{if(JXG.isPoint(s[1])){r=s[0];e=s[1]}else{throw new Error("JSXGraph: Can't create tangent with parent types '"+(typeof s[0])+"' and '"+(typeof s[1])+"'.\nPossible parent types: [glider], [point,line|curve|circle|conic]")}}}else{throw new Error("JSXGraph: Can't create tangent with parent types '"+(typeof s[0])+"' and '"+(typeof s[1])+"'.\nPossible parent types: [glider], [point,line|curve|circle|conic]")}}if(r.elementClass==JXG.OBJECT_CLASS_LINE){t=q.create("line",[r.point1,r.point2],l)}else{if(r.elementClass==JXG.OBJECT_CLASS_CURVE&&!(r.type==JXG.OBJECT_TYPE_CONIC)){if(r.visProp.curvetype!="plot"){n=r.X;o=r.Y;t=q.create("line",[function(){return -e.X()*q.D(o)(e.position)+e.Y()*q.D(n)(e.position)},function(){return q.D(o)(e.position)},function(){return -q.D(n)(e.position)}],l);e.addChild(t);t.glider=e}else{t=q.create("line",[function(){m=Math.floor(e.position);if(m==r.numberPoints-1){m--}if(m<0){return 1}return r.Y(m)*r.X(m+1)-r.X(m)*r.Y(m+1)},function(){m=Math.floor(e.position);if(m==r.numberPoints-1){m--}if(m<0){return 0}return r.Y(m+1)-r.Y(m)},function(){m=Math.floor(e.position);if(m==r.numberPoints-1){m--}if(m<0){return 0}return r.X(m)-r.X(m+1)}],l);e.addChild(t);t.glider=e}}else{if(r.type==JXG.OBJECT_TYPE_TURTLE){t=q.create("line",[function(){m=Math.floor(e.position);for(k=0;k1){e=JXG.copyAttributes(f,l.options,"circle","center");m[j]=l.create("point",g[j],e)}else{m[j]=g[j]}}}e=JXG.copyAttributes(f,l.options,"circle");if(g.length==2&&JXG.isPoint(m[0])&&JXG.isPoint(m[1])){k=new JXG.Circle(l,"twoPoints",m[0],m[1],e)}else{if((JXG.isNumber(m[0])||JXG.isFunction(m[0])||JXG.isString(m[0]))&&JXG.isPoint(m[1])){k=new JXG.Circle(l,"pointRadius",m[1],m[0],e)}else{if((JXG.isNumber(m[1])||JXG.isFunction(m[1])||JXG.isString(m[1]))&&JXG.isPoint(m[0])){k=new JXG.Circle(l,"pointRadius",m[0],m[1],e)}else{if((m[0].elementClass==JXG.OBJECT_CLASS_CIRCLE)&&JXG.isPoint(m[1])){k=new JXG.Circle(l,"pointCircle",m[1],m[0],e)}else{if((m[1].elementClass==JXG.OBJECT_CLASS_CIRCLE)&&JXG.isPoint(m[0])){k=new JXG.Circle(l,"pointCircle",m[0],m[1],e)}else{if((m[0].elementClass==JXG.OBJECT_CLASS_LINE)&&JXG.isPoint(m[1])){k=new JXG.Circle(l,"pointLine",m[1],m[0],e)}else{if((m[1].elementClass==JXG.OBJECT_CLASS_LINE)&&JXG.isPoint(m[0])){k=new JXG.Circle(l,"pointLine",m[0],m[1],e)}else{if(g.length==3&&JXG.isPoint(m[0])&&JXG.isPoint(m[1])&&JXG.isPoint(m[2])){k=JXG.createCircumcircle(l,m,f)}else{throw new Error("JSXGraph: Can't create circle with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"'.\nPossible parent types: [point,point], [point,number], [point,function], [point,circle], [point,point,point]")}}}}}}}}k.isDraggable=h;k.parents=[];for(j=0;j1){s[l]=o.create("point",q[l],k)}else{if(JXG.isPoint(q[l])){s[l]=JXG.getReference(o,q[l])}else{if((typeof q[l]=="function")&&(q[l]().elementClass===JXG.OBJECT_CLASS_POINT)){s[l]=q[l]()}else{if(JXG.isString(q[l])){s[l]=JXG.getReference(o,q[l])}else{throw new Error("JSXGraph: Can't create Ellipse with parent types '"+(typeof q[0])+"' and '"+(typeof q[1])+"'.\nPossible parent types: [point,point,point], [point,point,number|function]")}}}}}if(JXG.isNumber(q[2])){e=JXG.createFunction(q[2],o)}else{if((typeof q[2]=="function")&&(JXG.isNumber(q[2]()))){e=q[2]}else{if(JXG.isPoint(q[2])){f=JXG.getReference(o,q[2])}else{if(q[2].length>1){f=o.create("point",q[2],k)}else{if((typeof q[2]=="function")&&(q[2]().elementClass==JXG.OBJECT_CLASS_POINT)){f=q[2]()}else{if(JXG.isString(q[2])){f=JXG.getReference(o,q[2])}else{throw new Error("JSXGraph: Can't create Ellipse with parent types '"+(typeof q[0])+"' and '"+(typeof q[1])+"' and '"+(typeof q[2])+"'.\nPossible parent types: [point,point,point], [point,point,number|function]")}}}}e=function(){return f.Dist(s[0])+f.Dist(s[1])}}}if(typeof q[4]=="undefined"){q[4]=1.0001*Math.PI}if(typeof q[3]=="undefined"){q[3]=-1.0001*Math.PI}var p=o.create("point",[function(){return(s[0].X()+s[1].X())*0.5},function(){return(s[0].Y()+s[1].Y())*0.5}],k);var r=function(){var i=s[0].X(),C=s[0].Y(),z=s[1].X(),w=s[1].Y(),B,A,v;var u=(z-i>0)?1:-1;if(Math.abs(z-i)>1e-7){B=Math.atan2(w-C,z-i)+((u<0)?Math.PI:0)}else{B=((w-C>0)?0.5:-0.5)*Math.PI}A=Math.cos(B);v=Math.sin(B);var t=[[1,0,0],[p.X(),A,-v],[p.Y(),v,A]];return t};var g=o.create("curve",[function(i){return 0},function(i){return 0},q[3],q[4]],n);var h=function(v,t){var B=e()*0.5,i=B*B,u=s[1].Dist(s[0])*0.5,w=i-u*u,A=Math.sqrt(w),z=[[1,0,0],[0,1,0],[0,0,1]],D,C;if(!t){m=r();D=p.X();C=p.Y();z[0][0]=m[0][0];z[0][1]=0;z[0][2]=0;z[1][0]=D*(1-m[1][1])+C*m[1][2];z[1][1]=m[1][1];z[1][2]=m[2][1];z[2][0]=C*(1-m[1][1])-D*m[1][2];z[2][1]=m[1][2];z[2][2]=m[2][2];g.quadraticform=JXG.Math.matMatMult(JXG.Math.transpose(z),JXG.Math.matMatMult([[-1+D*D/(B*B)+C*C/w,-D/i,-D/w],[-D/i,1/i,0],[-C/w,0,1/w]],z))}return JXG.Math.matVecMult(m,[1,B*Math.cos(v),A*Math.sin(v)])};g.X=function(i,t){return h(i,t)[1]};g.Y=function(i,t){return h(i,t)[2]};g.midpoint=p;g.type=JXG.OBJECT_TYPE_CONIC;return g};JXG.createHyperbola=function(o,q,j){var s=[],f,e,l,m,k=JXG.copyAttributes(j,o.options,"conic","foci"),n=JXG.copyAttributes(j,o.options,"conic");for(l=0;l<2;l++){if(q[l].length>1){s[l]=o.create("point",q[l],attr_focu)}else{if(JXG.isPoint(q[l])){s[l]=JXG.getReference(o,q[l])}else{if((typeof q[l]=="function")&&(q[l]().elementClass==JXG.OBJECT_CLASS_POINT)){s[l]=q[l]()}else{if(JXG.isString(q[l])){s[l]=JXG.getReference(o,q[l])}else{throw new Error("JSXGraph: Can't create Hyperbola with parent types '"+(typeof q[0])+"' and '"+(typeof q[1])+"'.\nPossible parent types: [point,point,point], [point,point,number|function]")}}}}}if(JXG.isNumber(q[2])){e=JXG.createFunction(q[2],o)}else{if((typeof q[2]=="function")&&(JXG.isNumber(q[2]()))){e=q[2]}else{if(JXG.isPoint(q[2])){f=JXG.getReference(o,q[2])}else{if(q[2].length>1){f=o.create("point",q[2],k)}else{if((typeof q[2]=="function")&&(q[2]().elementClass==JXG.OBJECT_CLASS_POINT)){f=q[2]()}else{if(JXG.isString(q[2])){f=JXG.getReference(o,q[2])}else{throw new Error("JSXGraph: Can't create Hyperbola with parent types '"+(typeof q[0])+"' and '"+(typeof q[1])+"' and '"+(typeof q[2])+"'.\nPossible parent types: [point,point,point], [point,point,number|function]")}}}}e=function(){return f.Dist(s[0])-f.Dist(s[1])}}}if(typeof q[4]=="undefined"){q[4]=1.0001*Math.PI}if(typeof q[3]=="undefined"){q[3]=-1.0001*Math.PI}var p=o.create("point",[function(){return(s[0].X()+s[1].X())*0.5},function(){return(s[0].Y()+s[1].Y())*0.5}],k);var r=function(){var u=s[0].X(),t=s[0].Y(),A=s[1].X(),w=s[1].Y(),v;var z=(A-u>0)?1:-1;if(Math.abs(A-u)>1e-7){v=Math.atan2(w-t,A-u)+((z<0)?Math.PI:0)}else{v=((w-t>0)?0.5:-0.5)*Math.PI}var i=[[1,0,0],[p.X(),Math.cos(v),-Math.sin(v)],[p.Y(),Math.sin(v),Math.cos(v)]];return i};var g=o.create("curve",[function(i){return 0},function(i){return 0},q[3],q[4]],n);var h=function(v,t){var B=e()*0.5,i=B*B,u=s[1].Dist(s[0])*0.5,A=Math.sqrt(-B*B+u*u),w=A*A,z=[[1,0,0],[0,1,0],[0,0,1]],D,C;if(!t){m=r();D=p.X();C=p.Y();z[0][0]=m[0][0];z[0][1]=0;z[0][2]=0;z[1][0]=D*(1-m[1][1])+C*m[1][2];z[1][1]=m[1][1];z[1][2]=m[2][1];z[2][0]=C*(1-m[1][1])-D*m[1][2];z[2][1]=m[1][2];z[2][2]=m[2][2];g.quadraticform=JXG.Math.matMatMult(JXG.Math.transpose(z),JXG.Math.matMatMult([[-1+D*D/i+C*C/w,-D/i,C/w],[-D/i,1/i,0],[C/w,0,-1/w]],z))}return JXG.Math.matVecMult(m,[1,B/Math.cos(v),A*Math.tan(v)])};g.X=function(i,t){return h(i,t)[1]};g.Y=function(i,t){return h(i,t)[2]};g.midpoint=p;g.type=JXG.OBJECT_TYPE_CONIC;return g};JXG.createParabola=function(n,p,h){var m=p[0],f=p[1],j,i=JXG.copyAttributes(h,n.options,"conic","foci"),k=JXG.copyAttributes(h,n.options,"conic");if(p[0].length>1){m=n.create("point",p[0],i)}else{if(JXG.isPoint(p[0])){m=JXG.getReference(n,p[0])}else{if((typeof p[0]=="function")&&(p[0]().elementClass==JXG.OBJECT_CLASS_POINT)){m=p[0]()}else{if(JXG.isString(p[0])){m=JXG.getReference(n,p[0])}else{throw new Error("JSXGraph: Can't create Parabola with parent types '"+(typeof p[0])+"' and '"+(typeof p[1])+"'.\nPossible parent types: [point,line]")}}}}if(typeof p[3]=="undefined"){p[3]=10}if(typeof p[2]=="undefined"){p[2]=-10}var o=n.create("point",[function(){var l=[0,f.stdform[1],f.stdform[2]];l=JXG.Math.crossProduct(l,m.coords.usrCoords);return JXG.Math.Geometry.meetLineLine(l,f.stdform,0,n).usrCoords}],i);var q=function(){var s=Math.atan(f.getSlope()),r=(o.X()+m.X())*0.5,t=(o.Y()+m.Y())*0.5;s+=(m.Y()-o.Y()<0||(m.Y()==o.Y()&&m.X()>o.X()))?Math.PI:0;var l=[[1,0,0],[r*(1-Math.cos(s))+t*Math.sin(s),Math.cos(s),-Math.sin(s)],[t*(1-Math.cos(s))-r*Math.sin(s),Math.sin(s),Math.cos(s)]];return l};var e=n.create("curve",[function(l){return 0},function(l){return 0},p[2],p[3]],k);var g=function(u,v){var w=o.Dist(m)*0.5,s=[[1,0,0],[0,1,0],[0,0,1]],r=(o.X()+m.X())*0.5,l=(o.Y()+m.Y())*0.5;if(!v){j=q();s[0][0]=j[0][0];s[0][1]=0;s[0][2]=0;s[1][0]=r*(1-j[1][1])+l*j[1][2];s[1][1]=j[1][1];s[1][2]=j[2][1];s[2][0]=l*(1-j[1][1])-r*j[1][2];s[2][1]=j[1][2];s[2][2]=j[2][2];e.quadraticform=JXG.Math.matMatMult(JXG.Math.transpose(s),JXG.Math.matMatMult([[-l*4*w-r*r,r,2*w],[r,-1,0],[2*w,0,0]],s))}return JXG.Math.matVecMult(j,[1,u+r,u*u/(w*4)+l])};e.X=function(l,r){return g(l,r)[1]};e.Y=function(l,r){return g(l,r)[2]};e.type=JXG.OBJECT_TYPE_CONIC;return e};JXG.createConic=function(f,z,h){var k=[[1,0,0],[0,1,0],[0,0,1]],E,C,B,A,g=[[1,0,0],[0,1,0],[0,0,1]],q,o,u=[],v,s,D,n=[],t=JXG.copyAttributes(h,f.options,"conic","foci"),r=JXG.copyAttributes(h,f.options,"conic");if(z.length==5){D=true}else{if(z.length==6){D=false}else{throw new Error("JSXGraph: Can't create generic Conic with "+parent.length+" parameters.")}}if(D){for(v=0;v<5;v++){if(z[v].length>1){u[v]=f.create("point",z[v],t)}else{if(JXG.isPoint(z[v])){u[v]=JXG.getReference(f,z[v])}else{if((typeof z[v]=="function")&&(z[v]().elementClass==JXG.OBJECT_CLASS_POINT)){u[v]=z[v]()}else{if(JXG.isString(z[v])){u[v]=JXG.getReference(f,z[v])}else{throw new Error("JSXGraph: Can't create Conic section with parent types '"+(typeof z[v])+"'.\nPossible parent types: [point,point,point,point,point], [a00,a11,a22,a01,a02,a12]")}}}}}}else{s=[[0,0,0],[0,0,0],[0,0,0]];s[0][0]=(JXG.isFunction(z[2]))?function(){return z[2]()}:function(){return z[2]};s[0][1]=(JXG.isFunction(z[4]))?function(){return z[4]()}:function(){return z[4]};s[0][2]=(JXG.isFunction(z[5]))?function(){return z[5]()}:function(){return z[5]};s[1][1]=(JXG.isFunction(z[0]))?function(){return z[0]()}:function(){return z[0]};s[1][2]=(JXG.isFunction(z[3]))?function(){return z[3]()}:function(){return z[3]};s[2][2]=(JXG.isFunction(z[1]))?function(){return z[1]()}:function(){return z[1]}}var j=function(p){var G,F;for(G=0;G<3;G++){for(F=G;F<3;F++){p[G][F]+=p[F][G]}}for(G=0;G<3;G++){for(F=0;FH){g[G][H]=g[H][G]}}}}l.quadraticform=g;E=JXG.Math.Numerics.Jacobi(g);if(E[0][0][0]<0){E[0][0][0]*=(-1);E[0][1][1]*=(-1);E[0][2][2]*=(-1)}for(H=0;H<3;H++){p=0;for(G=0;G<3;G++){p+=E[1][G][H]*E[1][G][H]}p=Math.sqrt(p);for(G=0;G<3;G++){}}k=E[1];A=Math.sqrt(Math.abs(E[0][0][0]));C=Math.sqrt(Math.abs(E[0][1][1]));B=Math.sqrt(Math.abs(E[0][2][2]))}if(E[0][1][1]<=0&&E[0][2][2]<=0){F=JXG.Math.matVecMult(k,[1/A,Math.cos(I)/C,Math.sin(I)/B])}else{if(E[0][1][1]<=0&&E[0][2][2]>0){F=JXG.Math.matVecMult(k,[Math.cos(I)/A,1/C,Math.sin(I)/B])}else{if(E[0][2][2]<0){F=JXG.Math.matVecMult(k,[Math.sin(I)/A,Math.cos(I)/C,1/B])}}}F[1]/=F[0];F[2]/=F[0];F[0]=1;return F};l.X=function(i,p){return e(i,p)[1]};l.Y=function(i,p){return e(i,p)[2]};l.midpoint=f.create("point",[function(){var i=l.quadraticform;return[i[1][1]*i[2][2]-i[1][2]*i[1][2],i[1][2]*i[0][2]-i[2][2]*i[0][1],i[0][1]*i[1][2]-i[1][1]*i[0][2]]}],t);l.type=JXG.OBJECT_TYPE_CONIC;return l};JXG.JSXGraph.registerElement("ellipse",JXG.createEllipse);JXG.JSXGraph.registerElement("hyperbola",JXG.createHyperbola);JXG.JSXGraph.registerElement("parabola",JXG.createParabola);JXG.JSXGraph.registerElement("conic",JXG.createConic);JXG.Polygon=function(j,g,f){this.constructor(j,f,JXG.OBJECT_TYPE_POLYGON,JXG.OBJECT_CLASS_AREA);var h,m,e,k=JXG.copyAttributes(f,j.options,"polygon","borders");this.withLines=f.withlines;this.attr_line=k;this.vertices=[];for(h=0;hl)!=(this.vertices[g].coords.scrCoords[2]>l))&&(f<(this.vertices[g].coords.scrCoords[1]-this.vertices[h].coords.scrCoords[1])*(l-this.vertices[h].coords.scrCoords[2])/(this.vertices[g].coords.scrCoords[2]-this.vertices[h].coords.scrCoords[2])+this.vertices[h].coords.scrCoords[1])){k=!k}}}else{e=this.borders.length;for(h=0;he){e=this.vertices[h].X()}if(this.vertices[h].Y()>f){f=this.vertices[h].Y()}if(this.vertices[h].Y()this.vertices.length-2){return this}for(g=1;g-1&&f-1;l--){k[e[l]]=-1;if(this.withLines&&(e[l]-1>e[l-1])){g[g.length-1][1]=e[l];g.push([e[l-1]])}}if(this.withLines){g[g.length-1][1]=e[0]}this.vertices=[];for(l=0;lm.length-1){h=m.length-1}}this.board.removeObject(this.borders[h]);m[h]=-1}if(g[l][1]!==0&&g[l][0]!==k.length-1){m[g[l][0]-1]=JXG.createSegment(this.board,[k[Math.max(g[l][1]-1,0)],k[Math.min(g[l][0]+1,this.vertices.length-1)]],this.attr_line)}}this.borders=[];for(l=0;l=h-2){m.id=m.ids[k-2]}e[k]=o.create("point",[e[k-2],f],m);e[k].type=JXG.OBJECT_TYPE_CAS}}m=JXG.copyAttributes(j,o.options,"polygon");g=o.create("polygon",e,m);g.elType="regularpolygon";return g};JXG.JSXGraph.registerElement("polygon",JXG.createPolygon);JXG.JSXGraph.registerElement("regularpolygon",JXG.createRegularPolygon);JXG.Curve=function(g,f,e){this.constructor(g,e,JXG.OBJECT_TYPE_CURVE,JXG.OBJECT_CLASS_CURVE);this.points=[];this.numberPoints=this.visProp.numberpointshigh;this.dataX=null;this.dataY=null;if(f[0]!=null){this.varname=f[0]}else{this.varname="x"}this.xterm=f[1];this.yterm=f[2];this.generateTerm(this.varname,this.xterm,this.yterm,f[3],f[4]);this.updateCurve();this.id=this.board.setId(this,"G");this.board.renderer.drawCurve(this);this.board.finalizeAdding(this);this.createGradient();this.elType="curve";this.createLabel();if(typeof this.xterm=="string"){this.notifyParents(this.xterm)}if(typeof this.yterm=="string"){this.notifyParents(this.yterm)}};JXG.Curve.prototype=new JXG.GeometryElement;JXG.extend(JXG.Curve.prototype,{minX:function(){if(this.visProp.curvetype=="polar"){return 0}else{var e=new JXG.Coords(JXG.COORDS_BY_SCREEN,[0,0],this.board);return e.usrCoords[1]}},maxX:function(){var e;if(this.visProp.curvetype=="polar"){return 2*Math.PI}else{e=new JXG.Coords(JXG.COORDS_BY_SCREEN,[this.board.canvasWidth,0],this.board);return e.usrCoords[1]}},Z:function(e){return 1},hasPoint:function(r,q){var s,A=Infinity,I,m,C,B,v,u,w,f,J,z,o,G,l,F,h,n,p,E=this.visProp.numberpointslow,H=(this.maxX()-this.minX())/E,e=this.board.options.precision.hasPoint/this.board.unitX,g,D,k=true;e=e*e;g=new JXG.Coords(JXG.COORDS_BY_SCREEN,[r,q],this.board);r=g.usrCoords[1];q=g.usrCoords[2];if(this.visProp.curvetype=="parameter"||this.visProp.curvetype=="polar"||this.visProp.curvetype=="functiongraph"){D=this.transformations.length;for(C=0,s=this.minX();C=JXG.Math.eps){n=G*F+l*h;o=n/p;A=G*G+l*l-o*n}else{o=0;A=G*G+l*l}if(o>=0&&o<=1&&A=JXG.Math.eps){i=(t*j+K*I)/J;if(i>0){if(i<=1){t-=i*j;K-=i*I}else{t-=j;K-=I}}}H=t*t+K*K;return Math.sqrt(H)};if(this.board.updateQuality==this.board.BOARD_QUALITY_LOW){F=15;s=10;k=10}else{F=21;s=0.7;k=0.7}A[0]=e-E;for(v=1;v1){C=l(this.points[u-2].scrCoords,[n,m],this.points[u-1].scrCoords);if(C<0.015){u--}}this.points[u]=new JXG.Coords(JXG.COORDS_BY_SCREEN,[n,m],this.board);this.updateTransform(this.points[u]);u++;B=n;f=m;o=p;q--;n=D[q][0];m=D[q][1];G=h[q]+1;v=w[q]*2}while(q>0&&u<500000);this.numberPoints=this.points.length;return this},isSegmentOutside:function(f,h,e,g){return(h<0&&g<0)||(h>this.board.canvasHeight&&g>this.board.canvasHeight)||(f<0&&e<0)||(f>this.board.canvasWidth&&e>this.board.canvasWidth)},isDistOK:function(g,e,h,f){return(Math.abs(g)0&&this.transformations[this.transformations.length-1].isNumericMatrix){this.transformations[this.transformations.length-1].melt(f)}else{this.addTransform(f)}return this},generateTerm:function(f,j,g,e,k){var i,h;if(JXG.isArray(j)){this.dataX=j;this.X=function(n){var m=parseInt(Math.floor(n)),l,o;if(n<0){m=0}else{if(n>this.dataX.length-2){m=this.dataX.length-2}}if(m==n){return this.dataX[m]}else{l=this.dataX[m];o=this.dataX[m+1];return l+(o-l)*(n-m)}};this.visProp.curvetype="plot";this.numberPoints=this.dataX.length}else{this.X=JXG.createFunction(j,this.board,f);if(JXG.isString(j)){this.visProp.curvetype="functiongraph"}else{if(JXG.isFunction(j)||JXG.isNumber(j)){this.visProp.curvetype="parameter"}}}if(JXG.isArray(g)){this.dataY=g;this.Y=function(n){var m=parseInt(Math.floor(n)),l,o;if(n<0){m=0}else{if(n>this.dataY.length-2){m=this.dataY.length-2}}if(m==n){if(JXG.isFunction(this.dataY[m])){return this.dataY[m]()}else{return this.dataY[m]}}else{if(JXG.isFunction(this.dataY[m])){l=this.dataY[m]()}else{l=this.dataY[m]}if(JXG.isFunction(this.dataY[m+1])){o=this.dataY[m+1]()}else{o=this.dataY[m+1]}return l+(o-l)*(n-m)}}}else{this.Y=JXG.createFunction(g,this.board,f)}if(JXG.isFunction(j)&&JXG.isArray(g)){i=JXG.createFunction(g[0],this.board,"");h=JXG.createFunction(g[1],this.board,"");this.X=function(l){return(j)(l)*Math.cos(l)+i()};this.Y=function(l){return(j)(l)*Math.sin(l)+h()};this.visProp.curvetype="polar"}if(e!=null){this.minX=JXG.createFunction(e,this.board,"")}if(k!=null){this.maxX=JXG.createFunction(k,this.board,"")}},notifyParents:function(e){JXG.GeonextParser.findDependencies(this,e,this.board)},getLabelAnchor:function(){var k,e,j,g=0.05*this.board.canvasWidth,f=0.05*this.board.canvasHeight,i=0.95*this.board.canvasWidth,h=0.95*this.board.canvasHeight;switch(this.visProp.label.position){case"ulft":e=g;j=f;break;case"llft":e=g;j=h;break;case"rt":e=i;j=0.5*h;break;case"lrt":e=i;j=h;break;case"urt":e=i;j=f;break;case"top":e=0.5*i;j=f;break;case"bot":e=0.5*i;j=h;break;case"lft":default:e=g;j=0.5*h;break}k=new JXG.Coords(JXG.COORDS_BY_SCREEN,[e,j],this.board);return JXG.Math.Geometry.projectCoordsToCurve(k.usrCoords[1],k.usrCoords[2],0,this,this.board)[0]},cloneToBackground:function(){var f={},e;f.id=this.id+"T"+this.numTraces;f.elementClass=JXG.OBJECT_CLASS_CURVE;this.numTraces++;f.points=this.points.slice(0);f.numberPoints=this.numberPoints;f.board=this.board;f.visProp=JXG.deepCopy(this.visProp,this.visProp.traceattributes,true);f.visProp.layer=this.board.options.layer.trace;f.visProp.curvetype=this.visProp.curvetype;JXG.clearVisPropOld(f);e=this.board.renderer.enhancedRendering;this.board.renderer.enhancedRendering=true;this.board.renderer.drawCurve(f);this.board.renderer.enhancedRendering=e;this.traces[f.id]=f.rendNode;return this},bounds:function(){var m=this.visProp.numberpointslow,k=(this.maxX()-this.minX())/m,f,e,q,p,l,h,o,n,g=[this.minX(),0,this.maxX(),0];if(this.visProp.curvetype=="parameter"||this.visProp.curvetype=="polar"||this.visProp.curvetype=="functiongraph"){h=this.transformations.length;p=this.minX();for(f=0;fn){g[3]=n}p+=k}}else{if(this.visProp.curvetype=="plot"){h=this.numberPoints;for(f=0;fn){g[3]=n}}}}return g}});JXG.createCurve=function(h,g,f){var e=JXG.copyAttributes(f,h.options,"curve");return new JXG.Curve(h,["x"].concat(g),e)};JXG.JSXGraph.registerElement("curve",JXG.createCurve);JXG.createFunctiongraph=function(i,g,f){var e,h=["x","x"].concat(g);e=JXG.copyAttributes(f,i.options,"curve");e.curvetype="functiongraph";return new JXG.Curve(i,h,e)};JXG.JSXGraph.registerElement("functiongraph",JXG.createFunctiongraph);JXG.JSXGraph.registerElement("plot",JXG.createFunctiongraph);JXG.createSpline=function(g,f,e){var h;h=function(){var k,i=[],l=[];var j=function(p,o){var n,m;if(!o){i=[];l=[];if(f.length==2&&JXG.isArray(f[0])&&JXG.isArray(f[1])&&f[0].length==f[1].length){for(n=0;nJXG.Math.Geometry.rad(this.radiuspoint,this.center,this.anglepoint)){l=false}}return l};j.hasPointSector=function(i,q){var p=new JXG.Coords(JXG.COORDS_BY_SCREEN,[i,q],this.board),m=this.Radius(),o=this.center.coords.distance(JXG.COORDS_BY_USER,p),l=(oJXG.Math.Geometry.rad(this.radiuspoint,this.center,this.anglepoint)){l=false}}return l};j.getTextAnchor=function(){return this.center.coords};j.getLabelAnchor=function(){var m=JXG.Math.Geometry.rad(this.radiuspoint,this.center,this.anglepoint),u=10/(this.board.unitX),s=10/(this.board.unitY),q=this.point2.coords.usrCoords,i=this.center.coords.usrCoords,l=q[1]-i[1],t=q[2]-i[2],r,o,n,p;if(this.label.content!=null){this.label.content.relativeCoords=new JXG.Coords(JXG.COORDS_BY_SCREEN,[0,0],this.board)}r=new JXG.Coords(JXG.COORDS_BY_USER,[i[1]+Math.cos(m*0.5)*l-Math.sin(m*0.5)*t,i[2]+Math.sin(m*0.5)*l+Math.cos(m*0.5)*t],this.board);o=r.usrCoords[1]-i[1];n=r.usrCoords[2]-i[2];p=Math.sqrt(o*o+n*n);o=o*(p+u)/p;n=n*(p+s)/p;return new JXG.Coords(JXG.COORDS_BY_USER,[i[1]+o,i[2]+n],this.board)};j.updateQuadraticform=function(){var i=this.center,o=i.X(),n=i.Y(),l=this.Radius();this.quadraticform=[[o*o+n*n-l*l,-o,-n],[-o,1,0],[-n,0,1]]};j.updateStdform=function(){this.stdform[3]=0.5;this.stdform[4]=this.Radius();this.stdform[1]=-this.center.coords.usrCoords[1];this.stdform[2]=-this.center.coords.usrCoords[2];this.normalize()};j.prepareUpdate().update();return j};JXG.JSXGraph.registerElement("arc",JXG.createArc);JXG.createSemicircle=function(i,g,f){var h,j,e;if((JXG.isPoint(g[0]))&&(JXG.isPoint(g[1]))){e=JXG.copyAttributes(f,i.options,"semicircle","midpoint");j=i.create("midpoint",[g[0],g[1]],e);j.dump=false;e=JXG.copyAttributes(f,i.options,"semicircle");h=i.create("arc",[j,g[1],g[0]],e);h.elType="semicircle";h.parents=[g[0].id,g[1].id];h.subs={midpoint:j};h.midpoint=j}else{throw new Error("JSXGraph: Can't create Semicircle with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"'.\nPossible parent types: [point,point]")}return h};JXG.JSXGraph.registerElement("semicircle",JXG.createSemicircle);JXG.createCircumcircleArc=function(i,g,f){var h,j,e;if((JXG.isPoint(g[0]))&&(JXG.isPoint(g[1]))&&(JXG.isPoint(g[2]))){e=JXG.copyAttributes(f,i.options,"circumcirclearc","center");j=i.create("circumcenter",[g[0],g[1],g[2]],e);j.dump=false;e=JXG.copyAttributes(f,i.options,"circumcirclearc");e.usedirection=true;h=i.create("arc",[j,g[0],g[2],g[1]],e);h.elType="circumcirclearc";h.parents=[g[0].id,g[1].id,g[2].id];h.subs={center:j};h.center=j}else{throw new Error("JSXGraph: create Circumcircle Arc with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"' and '"+(typeof g[2])+"'.\nPossible parent types: [point,point,point]")}return h};JXG.JSXGraph.registerElement("circumcirclearc",JXG.createCircumcircleArc);JXG.createSector=function(i,g,f){var h,e;if(!(JXG.isPoint(g[0])&&JXG.isPoint(g[1])&&JXG.isPoint(g[2]))){throw new Error("JSXGraph: Can't create Sector with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"' and '"+(typeof g[2])+"'.")}e=JXG.copyAttributes(f,i.options,"sector");h=i.create("curve",[[0],[0]],e);h.type=JXG.OBJECT_TYPE_SECTOR;h.elType="sector";h.parents=[g[0].id,g[1].id,g[2].id];h.point1=JXG.getReference(i,g[0]);h.point2=JXG.getReference(i,g[1]);h.point3=JXG.getReference(i,g[2]);h.point1.addChild(h);h.point2.addChild(h);h.point3.addChild(h);h.useDirection=f.usedirection;h.updateDataArray=function(){var u=this.point2,t=this.point1,s=this.point3,F,m,H,z,j=JXG.Math.Geometry.rad(u,t,s),D,w=Math.ceil(j/Math.PI*90)+1,G=j/w,p=t.X(),o=t.Y(),q,l,k,r,E;if(this.useDirection){k=g[1].coords.usrCoords,r=g[3].coords.usrCoords,E=g[2].coords.usrCoords;l=(k[1]-E[1])*(k[2]-r[2])-(k[2]-E[2])*(k[1]-r[1]);if(l<0){this.point2=g[1];this.point3=g[2]}else{this.point2=g[2];this.point3=g[1]}}this.dataX=[t.X(),u.X()];this.dataY=[t.Y(),u.Y()];for(F=G,D=1;D<=w;D++,F+=G){m=Math.cos(F);H=Math.sin(F);z=[[1,0,0],[p*(1-m)+o*H,m,-H],[o*(1-m)-p*H,H,m]];q=JXG.Math.matVecMult(z,u.coords.usrCoords);this.dataX.push(q[1]/q[0]);this.dataY.push(q[2]/q[0])}this.dataX.push(t.X());this.dataY.push(t.Y())};h.Radius=function(){return this.point2.Dist(this.point1)};h.getRadius=function(){return this.Radius()};h.hasPointSector=function(j,p){var o=new JXG.Coords(JXG.COORDS_BY_SCREEN,[j,p],this.board),l=this.Radius(),n=this.point1.coords.distance(JXG.COORDS_BY_USER,o),k=(nJXG.Math.Geometry.rad(this.point2,this.point1,this.point3)){k=false}}return k};h.getTextAnchor=function(){return this.point1.coords};h.getLabelAnchor=function(){var l=JXG.Math.Geometry.rad(this.point2,this.point1,this.point3),t=10/(this.board.unitX),r=10/(this.board.unitY),p=this.point2.coords.usrCoords,j=this.point1.coords.usrCoords,k=p[1]-j[1],s=p[2]-j[2],q,n,m,o;if(this.label.content!=null){this.label.content.relativeCoords=new JXG.Coords(JXG.COORDS_BY_SCREEN,[0,0],this.board)}q=new JXG.Coords(JXG.COORDS_BY_USER,[j[1]+Math.cos(l*0.5)*k-Math.sin(l*0.5)*s,j[2]+Math.sin(l*0.5)*k+Math.cos(l*0.5)*s],this.board);n=q.usrCoords[1]-j[1];m=q.usrCoords[2]-j[2];o=Math.sqrt(n*n+m*m);n=n*(o+t)/o;m=m*(o+r)/o;return new JXG.Coords(JXG.COORDS_BY_USER,[j[1]+n,j[2]+m],this.board)};h.prepareUpdate().update();return h};JXG.JSXGraph.registerElement("sector",JXG.createSector);JXG.createCircumcircleSector=function(i,g,f){var h,j,e;if((JXG.isPoint(g[0]))&&(JXG.isPoint(g[1]))&&(JXG.isPoint(g[2]))){e=JXG.copyAttributes(f,i.options,"circumcirclesector","center");j=i.create("circumcenter",[g[0],g[1],g[2]],e);j.dump=false;e=JXG.copyAttributes(f,i.options,"circumcirclesector");h=i.create("sector",[j,g[0],g[2],g[1]],e);h.elType="circumcirclesector";h.parents=[g[0].id,g[1].id,g[2].id];h.center=j;h.subs={center:j}}else{throw new Error("JSXGraph: Can't create circumcircle sector with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"' and '"+(typeof g[2])+"'.")}return h};JXG.JSXGraph.registerElement("circumcirclesector",JXG.createCircumcircleSector);JXG.createAngle=function(r,v,n){var h,g,f,z,s,m,u=["α","β","γ","δ","ε","ζ","&eta","θ","ι","κ","λ","μ","ν","ξ","ο","π","ρ","ς","σ","τ","υ","φ","χ","ψ","ω"],o=0,l,t,k,w,A,e;if((JXG.isPoint(v[0]))&&(JXG.isPoint(v[1]))&&(JXG.isPoint(v[2]))){s=JXG.copyAttributes(n,r.options,"angle");z=s.name;if(typeof z=="undefined"||z==""){while(o=3&&JXG.isPoint(g[0])&&JXG.isPoint(g[1])&&JXG.isPoint(g[2])){e=g[0];k=g[1];j=g[2];i=h.create("point",[function(){var n,m,o;n=Math.sqrt((k.X()-j.X())*(k.X()-j.X())+(k.Y()-j.Y())*(k.Y()-j.Y()));m=Math.sqrt((e.X()-j.X())*(e.X()-j.X())+(e.Y()-j.Y())*(e.Y()-j.Y()));o=Math.sqrt((k.X()-e.X())*(k.X()-e.X())+(k.Y()-e.Y())*(k.Y()-e.Y()));return new JXG.Coords(JXG.COORDS_BY_USER,[(n*e.X()+m*k.X()+o*j.X())/(n+m+o),(n*e.Y()+m*k.Y()+o*j.Y())/(n+m+o)],h)}],f);i.elType="incenter";i.parents=[g[0].id,g[1].id,g[2].id]}else{throw new Error("JSXGraph: Can't create incenter with parent types '"+(typeof g[0])+"', '"+(typeof g[1])+"' and '"+(typeof g[2])+"'.\nPossible parent types: [point,point,point]")}return i};JXG.createCircumcircle=function(i,h,g){var k,l,f;try{f=JXG.copyAttributes(g,i.options,"circumcircle","center");k=JXG.createCircumcircleMidpoint(i,h,f);k.dump=false;if(!JXG.exists(g.layer)){g.layer=i.options.layer.circle}f=JXG.copyAttributes(g,i.options,"circumcircle");l=JXG.createCircle(i,[k,h[0]],f);l.elType="circumcircle";l.parents=[h[0].id,h[1].id,h[2].id];l.subs={center:k}}catch(j){throw new Error("JSXGraph: Can't create circumcircle with parent types '"+(typeof h[0])+"', '"+(typeof h[1])+"' and '"+(typeof h[2])+"'.\nPossible parent types: [point,point,point]")}return l};JXG.createIncircle=function(j,i,g){var l,m,f,h;try{f=JXG.copyAttributes(g,j.options,"incircle","center");l=JXG.createIncenter(j,i,f);l.dump=false;if(!JXG.exists(g.layer)){g.layer=j.options.layer.circle}f=JXG.copyAttributes(g,j.options,"incircle");m=JXG.createCircle(j,[l,function(){var n=Math.sqrt((i[1].X()-i[2].X())*(i[1].X()-i[2].X())+(i[1].Y()-i[2].Y())*(i[1].Y()-i[2].Y())),e=Math.sqrt((i[0].X()-i[2].X())*(i[0].X()-i[2].X())+(i[0].Y()-i[2].Y())*(i[0].Y()-i[2].Y())),p=Math.sqrt((i[1].X()-i[0].X())*(i[1].X()-i[0].X())+(i[1].Y()-i[0].Y())*(i[1].Y()-i[0].Y())),o=(n+e+p)/2;return Math.sqrt(((o-n)*(o-e)*(o-p))/o)}],f);m.elType="incircle";m.parents=[i[0].id,i[1].id,i[2].id];m.center=l;m.subs={center:l}}catch(k){throw new Error("JSXGraph: Can't create circumcircle with parent types '"+(typeof i[0])+"', '"+(typeof i[1])+"' and '"+(typeof i[2])+"'.\nPossible parent types: [point,point,point]")}return m};JXG.createReflection=function(h,g,f){var e,j,i;if(g[0].elementClass==JXG.OBJECT_CLASS_POINT&&g[1].elementClass==JXG.OBJECT_CLASS_LINE){j=g[0];e=g[1]}else{if(g[1].elementClass==JXG.OBJECT_CLASS_POINT&&g[0].elementClass==JXG.OBJECT_CLASS_LINE){j=g[1];e=g[0]}else{throw new Error("JSXGraph: Can't create reflection point with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"'.\nPossible parent types: [line,point]")}}i=JXG.createPoint(h,[function(){return JXG.Math.Geometry.reflection(e,j,h)}],f);j.addChild(i);e.addChild(i);i.elType="reflection";i.parents=[g[0].id,g[1].id];i.prepareUpdate().update();i.generatePolynomial=function(){var l=e.point1.symbolic.x;var k=e.point1.symbolic.y;var r=e.point2.symbolic.x;var q=e.point2.symbolic.y;var t=j.symbolic.x;var s=j.symbolic.y;var n=i.symbolic.x;var m=i.symbolic.y;var p=["((",m,")-(",s,"))*((",k,")-(",q,"))+((",l,")-(",r,"))*((",n,")-(",t,"))"].join("");var o=["((",n,")-(",l,"))^2+((",m,")-(",k,"))^2-((",t,")-(",l,"))^2-((",s,")-(",k,"))^2"].join("");return[p,o]};return i};JXG.createMirrorPoint=function(h,f,e){var j,g;if(JXG.isPoint(f[0])&&JXG.isPoint(f[1])){j=JXG.createPoint(h,[function(){return JXG.Math.Geometry.rotation(f[0],f[1],Math.PI,h)}],e);for(g=0;g<2;g++){f[g].addChild(j)}j.elType="mirrorpoint";j.parents=[f[0].id,f[1].id]}else{throw new Error("JSXGraph: Can't create mirror point with parent types '"+(typeof f[0])+"' and '"+(typeof f[1])+"'.\nPossible parent types: [point,point]")}j.prepareUpdate().update();return j};JXG.createIntegral=function(j,A,n){var z,s,v,h=0,g=0,f,e,m,l,r=1,w,o,i,B,k,q,u;if(JXG.isArray(A[0])&&A[1].elementClass==JXG.OBJECT_CLASS_CURVE){z=A[0];s=A[1]}else{if(JXG.isArray(A[1])&&A[0].elementClass==JXG.OBJECT_CLASS_CURVE){z=A[1];s=A[0]}else{throw new Error("JSXGraph: Can't create integral with parent types '"+(typeof A[0])+"' and '"+(typeof A[1])+"'.\nPossible parent types: [[number|function,number|function],curve]")}}h=z[0];g=z[1];if(JXG.isFunction(h)){f=h;e=function(){return s.Y(f())};h=f()}else{f=h;e=s.Y(h)}if(JXG.isFunction(h)){m=g;l=function(){return s.Y(m())};g=m()}else{m=g;l=s.Y(g)}if(g0){return}var k=JXG.Math.Symbolic.generatePolynomials(g,h,true).join("|");if(k===i.spe){return}i.spe=k;var j=function(n,p,m,o){i.dataX=n;i.dataY=p;i.eq=m;i.ctime=o;i.generatePolynomial=(function(q){return function(s){var r="("+s.symbolic.x+")",v="("+s.symbolic.y+")",u=[],t;for(t=0;tl.usrCoords[2]-n;k-=n){i.dataX.push(m.usrCoords[1],l.usrCoords[1],NaN);i.dataY.push(k,k,NaN)}for(k=m.usrCoords[1];k=-h&&g<=2*h&&f>=-h&&f<=2*h},setTextJessieCode:function(f){var e;this.visProp.castext=f;if(typeof f==="function"){e=function(){return f().replace(//g,">")}}else{if(JXG.isNumber(f)){e=f}else{e=f.replace(//g,">")}}return this.setText(e)},setText:function(e){if(typeof e==="function"){this.updateText=function(){this.plaintext=e()}}else{if(JXG.isNumber(e)){this.content=(e).toFixed(this.visProp.digits)}else{if(this.visProp.useasciimathml){this.content="'`"+e+"`'"}else{this.content=this.generateTerm(e)}}this.updateText=new Function("this.plaintext = "+this.content+";")}this.updateText();this.updateSize();this.needsUpdate=true;this.update();this.updateRenderer();return this},updateSize:function(){if(this.visProp.display=="html"&&this.board.renderer.type!="vml"){this.size=[this.rendNode.offsetWidth,this.rendNode.offsetHeight]}else{if(this.visProp.display=="internal"&&this.board.renderer.type=="svg"){this.size=[this.rendNode.getBBox().width,this.rendNode.getBBox().height]}else{if(this.board.renderer.type=="vml"||(this.visProp.display=="internal"&&this.board.renderer.type=="canvas")){this.size=[parseFloat(this.visProp.fontsize)*this.plaintext.length*0.45,parseFloat(this.visProp.fontsize)*0.9]}}}return this},getSize:function(){return this.size},setCoords:function(e,f){if(JXG.isArray(e)&&e.length>1){f=e[1];e=e[0]}this.X=function(){return e};this.Y=function(){return f};this.coords=new JXG.Coords(JXG.COORDS_BY_USER,[e,f],this.board);this.board.update();return this},free:function(){this.X=JXG.createFunction(this.X(),this.board,"");this.Y=JXG.createFunction(this.Y(),this.board,"");this.isDraggable=true},update:function(){var e,g,f;if(this.needsUpdate){if(this.relativeCoords){if(this.visProp.islabel){g=parseFloat(this.visProp.offsets[0]);f=-parseFloat(this.visProp.offsets[1]);e=this.element.getLabelAnchor();this.coords.setCoordinates(JXG.COORDS_BY_SCREEN,[g+this.relativeCoords.scrCoords[1]+e.scrCoords[1],f+this.relativeCoords.scrCoords[2]+e.scrCoords[2]])}else{e=this.element.getTextAnchor();this.coords.setCoordinates(JXG.COORDS_BY_USER,[this.relativeCoords.usrCoords[1]+e.usrCoords[1],this.relativeCoords.usrCoords[2]+e.usrCoords[2]])}}else{this.updateCoords()}this.updateText();this.updateTransform()}return this},updateRenderer:function(){if(this.needsUpdate){this.board.renderer.updateText(this);this.needsUpdate=false}return this},updateTransform:function(){if(this.transformations.length==0){return}for(var e=0;e/g,"∠");k=k.replace(//g,"√");var f;f=k.indexOf("");var e=k.indexOf("");if(f>=0){while(f>=0){l+=' + "'+JXG.GeonextParser.replaceSub(JXG.GeonextParser.replaceSup(k.slice(0,f)))+'"';g=k.slice(f+7,e);h=JXG.GeonextParser.geonext2JS(g,this.board);h=h.replace(/\\"/g,'"');h=h.replace(/\\'/g,"'");if(h.indexOf("toFixed")<0){if(JXG.isNumber((JXG.bind(new Function("return "+h+";"),this))())){l+="+("+h+").toFixed("+(this.visProp.digits)+")"}else{l+="+("+h+")"}}else{l+="+("+h+")"}k=k.slice(e+8);f=k.indexOf("");e=k.indexOf("")}}l+=' + "'+JXG.GeonextParser.replaceSub(JXG.GeonextParser.replaceSup(k))+'"';l=l.replace(//g,"");l=l.replace(/<\/overline>/g,"");l=l.replace(//g,"");l=l.replace(/<\/arrow>/g,"");l=l.replace(/&/g,"&");return l},notifyParents:function(g){var f=null;do{var e=/([\w\s\*\/\^\-\+\(\)\[\],<>=!]+)<\/value>/;f=e.exec(g);if(f!=null){JXG.GeonextParser.findDependencies(this,f[1],this.board);g=g.substr(f.index);g=g.replace(e,"")}}while(f!=null);return this},bounds:function(){var e=this.coords.usrCoords;return this.visProp.islabel?[0,0,0,0]:[e[1],e[2]+this.size[1],e[1]+this.size[0],e[2]]},setPositionDirectly:function(e,l,j,h,g){var f,o,n,m,k;if(this.relativeCoords){if(this.visProp.islabel){if(e==JXG.COORDS_BY_USER){k=new JXG.Coords(JXG.COORDS_BY_USER,[h,g],this.board);m=new JXG.Coords(JXG.COORDS_BY_USER,[l,j],this.board);o=m.scrCoords[1]-k.scrCoords[1];n=m.scrCoords[2]-k.scrCoords[2]}else{o=l-h;n=j-g}this.relativeCoords.scrCoords[1]+=o;this.relativeCoords.scrCoords[2]+=n}else{if(e==JXG.COORDS_BY_SCREEN){k=new JXG.Coords(JXG.COORDS_BY_SCREEN,[h,g],this.board);m=new JXG.Coords(JXG.COORDS_BY_SCREEN,[l,j],this.board);o=m.usrCoords[1]-k.usrCoords[1];n=m.usrCoords[2]-k.usrCoords[2]}else{o=l-h;n=j-g}this.relativeCoords.usrCoords[1]+=o;this.relativeCoords.usrCoords[2]+=n}}else{if(e==JXG.COORDS_BY_SCREEN){m=new JXG.Coords(JXG.COORDS_BY_SCREEN,[l,j],this.board);l=m.usrCoords[1];j=m.usrCoords[2]}this.X=JXG.createFunction(l,this.board,"");this.Y=JXG.createFunction(j,this.board,"")}return this}});JXG.createText=function(i,g,f){var e,h;e=JXG.copyAttributes(f,i.options,"text");e.anchor=e.parent||e.anchor;h=new JXG.Text(i,g[g.length-1],g,e);if(typeof g[g.length-1]!=="function"){h.parents=g}return h};JXG.JSXGraph.registerElement("text",JXG.createText);JXG.Image=function(h,f,i,g,e){this.constructor(h,e,JXG.OBJECT_TYPE_IMAGE,JXG.OBJECT_CLASS_OTHER);this.initialCoords=new JXG.Coords(JXG.COORDS_BY_USER,i,this.board);if(!JXG.isFunction(i[0])&&!JXG.isFunction(i[1])){this.isDraggable=true}this.X=JXG.createFunction(i[0],this.board,"");this.Y=JXG.createFunction(i[1],this.board,"");this.W=JXG.createFunction(g[0],this.board,"");this.H=JXG.createFunction(g[1],this.board,"");this.coords=new JXG.Coords(JXG.COORDS_BY_USER,[this.X(),this.Y()],this.board);this.updateCoords=new Function("","this.coords.setCoordinates(JXG.COORDS_BY_USER,[this.X(),this.Y()]);");this.updateSize=new Function("","this.coords.setCoordinates(JXG.COORDS_BY_USER,[this.W(),this.H()]);");this.usrSize=[this.W(),this.H()];this.size=[this.usrSize[0]*h.unitX,this.usrSize[1]*h.unitY];this.url=f;this.parent=JXG.getRef(e.anchor);this.id=this.board.setId(this,"Im");this.board.renderer.drawImage(this);if(!this.visProp.visible){this.board.renderer.hide(this)}};JXG.Image.prototype=new JXG.GeometryElement;JXG.extend(JXG.Image.prototype,{hasPoint:function(e,i){var g=e-this.coords.scrCoords[1],f=this.coords.scrCoords[2]-i,h=this.board.options.precision.hasPoint;if(g>=-h&&g<=2*h&&f>=-h&&f<=h){return true}else{return false}},update:function(){if(this.needsUpdate){this.updateCoords();this.usrSize=[this.W(),this.H()];this.size=[this.usrSize[0]*this.board.unitX,this.usrSize[1]*this.board.unitY];this.updateTransform()}return this},updateRenderer:function(){if(this.needsUpdate){this.board.renderer.updateImage(this);this.needsUpdate=false}return this},updateTransform:function(){if(this.transformations.length==0){return}for(var e=0;e=0){z+=e*0.5/f.unitX}else{z-=e*s/f.unitX}n-=e*0.2/f.unitY;r=f.create("text",[z,n,g.labels[v]],g)}}else{t[0]=f.create("point",[q,0],A);t[1]=f.create("point",[q,z],A);t[2]=f.create("point",[l,z],A);t[3]=f.create("point",[l,0],A);if(JXG.exists(g.labels)&&JXG.exists(g.labels[v])){s=g.labels[v].toString().length;s=0.6*s*e/f.unitX;if(z>=0){z+=e*0.5/f.unitY}else{z-=e*1/f.unitY}r=f.create("text",[n-s*0.5,z,g.labels[v]],g)}}g.withlines=false;if(JXG.exists(g.colors)&&JXG.isArray(g.colors)){k=g.colors;g.fillcolor=k[v%k.length]}h[v]=f.create("polygon",t,g);if(JXG.exists(g.labels)&&JXG.exists(g.labels[v])){h[v].text=r}}return h},drawPoints:function(k,e,l,g){var h,j=[],f=g.infoboxarray;g.fixed=true;g.name="";for(h=0;hae[Z]){ae[Z]=S[ab][Z]}if(S[ab][Z]1){if(h.length==3){i=this.evalParam(1);m=this.evalParam(2)}else{i=h[1].X();m=h[1].Y()}this.matrix[1][0]=i*(1-l)+m*j;this.matrix[2][0]=m*(1-l)-i*j}}}else{if(f=="shear"){this.evalParam=JXG.createEvalFunction(g,h,1);this.update=function(){var i=this.evalParam(0);this.matrix[1][1]=Math.tan(i)}}else{if(f=="generic"){this.evalParam=JXG.createEvalFunction(g,h,9);this.update=function(){this.matrix[0][0]=this.evalParam(0);this.matrix[0][1]=this.evalParam(1);this.matrix[0][2]=this.evalParam(2);this.matrix[1][0]=this.evalParam(3);this.matrix[1][1]=this.evalParam(4);this.matrix[1][2]=this.evalParam(5);this.matrix[2][0]=this.evalParam(6);this.matrix[2][1]=this.evalParam(7);this.matrix[2][2]=this.evalParam(8)}}}}}}}},apply:function(e){this.update();if(arguments[1]!=null){return JXG.Math.matVecMult(this.matrix,e.initialCoords.usrCoords)}else{return JXG.Math.matVecMult(this.matrix,e.coords.usrCoords)}},applyOnce:function(g){var h,e,f;if(!JXG.isArray(g)){this.update();h=JXG.Math.matVecMult(this.matrix,g.coords.usrCoords);g.coords.setCoordinates(JXG.COORDS_BY_USER,h)}else{e=g.length;for(f=0;f=8192){this.curve=this.board.create("curve",[[this.pos[0]],[this.pos[1]]],this._attributes);this.objects.push(this.curve)}}this.pos[0]+=g;this.pos[1]+=f;if(this.isPenDown){this.curve.dataX.push(this.pos[0]);this.curve.dataY.push(this.pos[1])}this.board.update();return this},back:function(e){return this.forward(-e)},right:function(f){this.dir-=f;this.dir%=360;if(!this.turtleIsHidden){var e=this.board.create("transform",[-f*Math.PI/180,this.turtle],{type:"rotate"});e.applyOnce(this.turtle2)}this.board.update();return this},left:function(e){return this.right(-e)},penUp:function(){this.isPenDown=false;return this},penDown:function(){this.isPenDown=true;this.curve=this.board.create("curve",[[this.pos[0]],[this.pos[1]]],this._attributes);this.objects.push(this.curve);return this},clean:function(){for(var e=0;e=8192){this.curve=this.board.create("curve",[[this.pos[0]],[this.pos[1]]],this._attributes);this.objects.push(this.curve)}}this.pos[0]=h[0];this.pos[1]=h[1];if(this.isPenDown){this.curve.dataX.push(this.pos[0]);this.curve.dataY.push(this.pos[1])}this.board.update()}return this},fd:function(e){return this.forward(e)},bk:function(e){return this.back(e)},lt:function(e){return this.left(e)},rt:function(e){return this.right(e)},pu:function(){return this.penUp()},pd:function(){return this.penDown()},ht:function(){return this.hideTurtle()},st:function(){return this.showTurtle()},cs:function(){return this.clearScreen()},push:function(){return this.pushTurtle()},pop:function(){return this.popTurtle()},evalAt:function(k,m){var h,g,l,f,e=this.objects.length;for(h=0,g=0;h=3){arguments[0]=[arguments[0],arguments[1],arguments[2]];arguments.length=1}var o=arguments[0];if(JXG.isArray(o)){var f=false,k;for(k=0;k<3;k++){f|=/\./.test(arguments[0][k].toString())}for(k=0;k<3;k++){f&=(arguments[0][k]>=0)&(arguments[0][k]<=1)}if(f){return[Math.ceil(arguments[0][0]*255),Math.ceil(arguments[0][1]*255),Math.ceil(arguments[0][2]*255)]}else{arguments[0].length=3;return arguments[0]}}else{if(typeof arguments[0]=="string"){o=arguments[0]}}var e,m,p;if(o.charAt(0)=="#"){o=o.substr(1,6)}o=o.replace(/ /g,"");o=o.toLowerCase();var j={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};for(var q in j){if(o==q){o=j[q]}}var n=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(g){return[parseInt(g[1]),parseInt(g[2]),parseInt(g[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(g){return[parseInt(g[1],16),parseInt(g[2],16),parseInt(g[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(g){return[parseInt(g[1]+g[1],16),parseInt(g[2]+g[2],16),parseInt(g[3]+g[3],16)]}}];for(var k=0;k255)?255:e);m=(m<0||isNaN(m))?0:((m>255)?255:m);p=(p<0||isNaN(p))?0:((p>255)?255:p);return[e,m,p]};JXG.rgb2css=function(){var h,f,e;h=JXG.rgbParser.apply(JXG.rgbParser,arguments);f=h[1];e=h[2];h=h[0];return"rgb("+h+", "+f+", "+e+")"};JXG.rgb2hex=function(){var h,f,e;h=JXG.rgbParser.apply(JXG.rgbParser,arguments);f=h[1];e=h[2];h=h[0];h=h.toString(16);f=f.toString(16);e=e.toString(16);if(h.length==1){h="0"+h}if(f.length==1){f="0"+f}if(e.length==1){e="0"+e}return"#"+h+f+e};JXG.hex2rgb=function(i){var h,f,e;if(i.charAt(0)=="#"){i=i.slice(1)}h=parseInt(i.substr(0,2),16);f=parseInt(i.substr(2,2),16);e=parseInt(i.substr(4,2),16);return"rgb("+h+", "+f+", "+e+")"};JXG.hsv2rgb=function(r,l,k){var m,s,h,o,n,j,g,e,u;r=((r%360)+360)%360;if(l==0){if(isNaN(r)||r=360){j=0}else{j=r}j=j/60;n=Math.floor(j);o=j-n;g=k*(1-l);e=k*(1-(l*o));u=k*(1-(l*(1-o)));switch(n){case 0:m=k;s=u;h=g;break;case 1:m=e;s=k;h=g;break;case 2:m=g;s=k;h=u;break;case 3:m=g;s=e;h=k;break;case 4:m=u;s=g;h=k;break;case 5:m=k;s=g;h=e;break}}m=Math.round(m*255).toString(16);m=(m.length==2)?m:((m.length==1)?"0"+m:"00");s=Math.round(s*255).toString(16);s=(s.length==2)?s:((s.length==1)?"0"+s:"00");h=Math.round(h*255).toString(16);h=(h.length==2)?h:((h.length==1)?"0"+h:"00");return["#",m,s,h].join("")};JXG.rgb2hsv=function(){var e,n,q,o,f,j,i,t,m,w,u,p,k,l;e=JXG.rgbParser.apply(JXG.rgbParser,arguments);n=e[1];q=e[2];e=e[0];l=JXG.Math.Statistics;o=e/255;f=n/255;j=q/255;p=l.max([e,n,q]);k=l.min([e,n,q]);i=p/255;t=k/255;u=i;w=0;if(u>0){w=(u-t)/(u*1)}m=1/(i-t);if(w>0){if(p==e){m=(f-j)*m}else{if(p==n){m=2+(j-o)*m}else{m=4+(o-f)*m}}}m*=60;if(m<0){m+=360}if(p==k){m=0}return[m,w,u]};JXG.rgb2LMS=function(){var o,n,f,h,e,k,j,i=[[0.05059983,0.08585369,0.0095242],[0.01893033,0.08925308,0.01370054],[0.00292202,0.00975732,0.07145979]];o=JXG.rgbParser.apply(JXG.rgbParser,arguments);n=o[1];f=o[2];o=o[0];o=Math.pow(o,0.476190476);n=Math.pow(n,0.476190476);f=Math.pow(f,0.476190476);h=o*i[0][0]+n*i[0][1]+f*i[0][2];e=o*i[1][0]+n*i[1][1]+f*i[1][2];k=o*i[2][0]+n*i[2][1]+f*i[2][2];j=[h,e,k];j.l=h;j.m=e;j.s=k;return j};JXG.LMS2rgb=function(h,f,p){var e,i,k,j,n=[[30.830854,-29.832659,1.610474],[-6.481468,17.715578,-2.532642],[-0.37569,-1.199062,14.273846]];e=h*n[0][0]+f*n[0][1]+p*n[0][2];i=h*n[1][0]+f*n[1][1]+p*n[1][2];k=h*n[2][0]+f*n[2][1]+p*n[2][2];var o=function(l){var m=127,g=64;while(g>0){if(Math.pow(m,0.476190476)>l){m-=g}else{if(Math.pow(m+1,0.476190476)>l){return m}m+=g}g/=2}if(m==254&&13.994955247>4)&15)+i.charAt(f&15);g="#"+h+""+h+""+h;return g};JXG.rgb2cb=function(j,q){if(j=="none"){return j}var t,i,h,w,r,o,g,v,n,f,u,k,p;r=JXG.rgb2LMS(j);i=r.l;h=r.m;w=r.s;q=q.toLowerCase();switch(q){case"protanopia":g=-0.06150039994295001;v=0.08277001656812001;n=-0.013200141220000003;f=0.05858939668799999;u=-0.07934519995360001;k=0.013289415272000003;p=0.6903216543277437;o=w/h;if(o>4)&15)+e.charAt(t.r&15);j="#"+o;o=e.charAt((t.g>>4)&15)+e.charAt(t.g&15);j+=o;o=e.charAt((t.b>>4)&15)+e.charAt(t.b&15);j+=o;return j};JXG.extend(JXG.Board.prototype,{angle:function(e,g,f){return JXG.Math.Geometry.angle(e,g,f)},rad:function(e,g,f){return JXG.Math.Geometry.rad(e,g,f)},distance:function(f,e){return JXG.Math.Geometry.distance(f,e)},pow:function(f,e){return JXG.Math.pow(f,e)},round:function(e,f){return(e).toFixed(f)},cosh:function(e){return JXG.Math.cosh(e)},sinh:function(e){return JXG.Math.sinh(e)},sgn:function(e){return(e==0?0:e/(Math.abs(e)))},D:function(e,g){return JXG.Math.Numerics.D(e,g)},I:function(e,g){return JXG.Math.Numerics.I(e,g)},root:function(g,e,h){return JXG.Math.Numerics.root(g,e,h)},lagrangePolynomial:function(e){return JXG.Math.Numerics.lagrangePolynomial(e)},neville:function(e){return JXG.Math.Numerics.Neville(e)},riemannsum:function(h,j,g,i,e){return JXG.Math.Numerics.riemannsum(h,j,g,i,e)},abs:Math.abs,acos:Math.acos,asin:Math.asin,atan:Math.atan,ceil:Math.ceil,cos:Math.cos,exp:Math.exp,floor:Math.floor,log:Math.log,max:Math.max,min:Math.min,random:Math.random,sin:Math.sin,sqrt:Math.sqrt,tan:Math.tan,trunc:Math.ceil,factorial:function(e){return JXG.Math.factorial(e)},binomial:function(f,e){return JXG.Math.binomial(f,e)},getElement:function(e){return JXG.getReference(this,e)},intersectionOptions:["point",[[JXG.OBJECT_CLASS_LINE,JXG.OBJECT_CLASS_LINE],[JXG.OBJECT_CLASS_LINE,JXG.OBJECT_CLASS_CIRCLE],[JXG.OBJECT_CLASS_CIRCLE,JXG.OBJECT_CLASS_CIRCLE]]],intersection:function(h,f,g,e){h=JXG.getReference(this,h);f=JXG.getReference(this,f);if(h.elementClass==JXG.OBJECT_CLASS_CURVE&&f.elementClass==JXG.OBJECT_CLASS_CURVE){return function(){return JXG.Math.Geometry.meetCurveCurve(h,f,g,e,h.board)}}else{if((h.type==JXG.OBJECT_TYPE_ARC&&f.elementClass==JXG.OBJECT_CLASS_LINE)||(f.type==JXG.OBJECT_TYPE_ARC&&h.elementClass==JXG.OBJECT_CLASS_LINE)){return function(){return JXG.Math.Geometry.meet(h.stdform,f.stdform,g,h.board)}}else{if((h.elementClass==JXG.OBJECT_CLASS_CURVE&&f.elementClass==JXG.OBJECT_CLASS_LINE)||(f.elementClass==JXG.OBJECT_CLASS_CURVE&&h.elementClass==JXG.OBJECT_CLASS_LINE)){return function(){return JXG.Math.Geometry.meetCurveLine(h,f,g,h.board)}}else{return function(){return JXG.Math.Geometry.meet(h.stdform,f.stdform,g,h.board)}}}}},intersectionFunc:function(h,f,g,e){return this.intersection(h,f,g,e)},otherIntersection:function(f,e,g){f=JXG.getReference(this,f);e=JXG.getReference(this,e);return function(){var h=JXG.Math.Geometry.meet(f.stdform,e.stdform,0,f.board);if(Math.abs(g.X()-h.usrCoords[1])>JXG.Math.eps||Math.abs(g.Y()-h.usrCoords[2])>JXG.Math.eps||Math.abs(g.Z()-h.usrCoords[0])>JXG.Math.eps){return h}else{return JXG.Math.Geometry.meet(f.stdform,e.stdform,1,f.board)}}},pointFunc:function(){return[null]},pointOptions:["point",[[JXG.OBJECT_CLASS_POINT]]],lineFunc:function(){return arguments},lineOptions:["line",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],linesegmentFunc:function(){return arguments},linesegmentOptions:["line",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],linesegmentAtts:{straightFirst:false,straightLast:false},arrowFunc:function(){return arguments},arrowOptions:["arrow",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],circleFunc:function(){return arguments},circleOptions:["circle",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT],[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE],[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_CIRCLE]]],arrowparallelOptions:["arrowparallel",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]],arrowparallelFunc:function(){return arguments},bisectorOptions:["bisector",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],bisectorFunc:function(){return arguments},circumcircleOptions:["circumcircle",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],circumcircleFunc:function(){return arguments},circumcirclemidpointOptions:["circumcirclemidpoint",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],circumcirclemidpointFunc:function(){return arguments},integralOptions:["integral",[[]]],integralFunc:function(){return arguments},midpointOptions:["midpoint",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT],[JXG.OBJECT_CLASS_LINE]]],midpointFunc:function(){return arguments},mirrorpointOptions:["mirrorpoint",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],mirrorpointFunc:function(){return arguments},normalOptions:["normal",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]],normalFunc:function(){return arguments},parallelOptions:["parallel",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]],parallelFunc:function(){return arguments},parallelpointOptions:["parallelpoint",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],parallelpointFunc:function(){return arguments},perpendicularOptions:["perpendicular",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]],perpendicularFunc:function(){return arguments},perpendicularpointOptions:["perpendicularpoint",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]],perpendicularpointFunc:function(){return arguments},reflectionOptions:["reflection",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]],reflectionFunc:function(){return arguments}});JXG.Point.prototype.setPositionX=function(g,e){var f=(g==JXG.COORDS_BY_USER)?this.coords.usrCoords[2]:this.coords.scrCoords[2];this.setPosition(g,e,f)};JXG.Point.prototype.setPositionY=function(g,f){var e=(g==JXG.COORDS_BY_USER)?this.coords.usrCoords[1]:this.coords.scrCoords[1];this.setPosition(g,e,f)};JXG.Ticks=function(e,g,f){this.constructor(e.board,f,JXG.OBJECT_TYPE_TICKS,JXG.OBJECT_CLASS_OTHER);this.line=e;this.board=this.line.board;this.ticksFunction=null;this.fixedTicks=null;this.equidistant=false;if(JXG.isFunction(g)){this.ticksFunction=g;throw new Error("Function arguments are no longer supported.")}else{if(JXG.isArray(g)){this.fixedTicks=g}else{if(Math.abs(g)=w&&this.fixedTicks[C]JXG.Math.eps){D=this._adjustTickDistance(D,n,u,h.coords,L,J);this.ticksDelta=D}if(!this.visProp.insertticks){D/=this.visProp.minorticks+1}l=this.board.getBoundingBox();H=(l[0]+l[2])*0.5;G=(l[1]+l[3])*0.5;M=[H*this.line.stdform[2]-G*this.line.stdform[1],-this.line.stdform[2],this.line.stdform[1]];I=JXG.Math.crossProduct(this.line.stdform,M);I[1]/=I[0];I[2]/=I[0];I[0]=1;z=new JXG.Coords(JXG.COORDS_BY_USER,I.slice(1),this.board);F=h.coords.distance(JXG.COORDS_BY_USER,z);if((f.X()-h.X())*(I[1]-h.X())<0||(f.Y()-h.Y())*(I[2]-h.Y())<0){F*=-1}q=Math.round(F/D)*D;if(Math.abs(q)>JXG.Math.eps){v=Math.abs(q)/q}I[1]=h.coords.usrCoords[1]+L*q;I[2]=h.coords.usrCoords[2]+J*q;e=q;q=0;H=I[1];G=I[2];C=0;do{z=new JXG.Coords(JXG.COORDS_BY_USER,[H,G],this.board);if(Math.round((v*q+e)/D)%(this.visProp.minorticks+1)===0){z.major=true}else{z.major=false}k=this._tickEndings(z,K,g,t,A,z.major);if(k.length==2){m=v*q+e;if((Math.abs(m)<=s&&this.visProp.drawzero)||(m>w&&m0)},_adjustTickDistance:function(j,k,i,h,g,f){var e,l;while(k>4*this.minTicksDistance){j/=10;e=h.usrCoords[1]+g*j;l=h.usrCoords[2]+f*j;k=h.distance(JXG.COORDS_BY_SCREEN,new JXG.Coords(JXG.COORDS_BY_USER,[e,l],this.board))}while(k=0&&p[1]<=g){k[h]=p[1];j[h]=0;h++}p=JXG.Math.crossProduct([0,1,0],[-e*B[1]-t*B[2],e,t]);p[2]/=p[0];if(p[2]>=0&&p[2]<=n){k[h]=0;j[h]=p[2];h++}if(h<2){p=JXG.Math.crossProduct([n*n,0,-n],[-e*B[1]-t*B[2],e,t]);p[1]/=p[0];if(p[1]>=0&&p[1]<=g){k[h]=p[1];j[h]=n;h++}}if(h<2){p=JXG.Math.crossProduct([g*g,-g,0],[-e*B[1]-t*B[2],e,t]);p[2]/=p[0];if(p[2]>=0&&p[2]<=n){k[h]=g;j[h]=p[2]}}}}if((k[0]>=0&&k[0]<=g&&j[0]>=0&&j[0]<=n)||(k[1]>=0&&k[1]<=g&&j[1]>=0&&j[1]<=n)){o=true}else{o=false}if(z=="finite"){A=Math.sqrt(this.board.unitX*this.board.unitX+this.board.unitY*this.board.unitY);k[0]=B[1]+m*this.board.unitX/A;j[0]=B[2]-l*this.board.unitY/A;k[1]=B[1]-m*this.board.unitX/A;j[1]=B[2]+l*this.board.unitY/A}if(o){return[k,j]}else{return[]}},_makeLabel:function(m,e,j,g,l,h){var k,f;if(!g){return null}k=m.toString();if(Math.abs(m)5||k.indexOf("e")!=-1){k=m.toPrecision(3).toString()}if(k.indexOf(".")>-1){k=k.replace(/0+$/,"");k=k.replace(/\.$/,"")}f=JXG.createText(j,[e.usrCoords[1],e.usrCoords[2],k],{id:l+h+"Label",isLabel:true,layer:j.options.layer.line,highlightStrokeColor:j.options.text.strokeColor,highlightStrokeWidth:j.options.text.strokeWidth,highlightStrokeOpacity:j.options.text.strokeOpacity});f.isDraggable=false;f.dump=false;f.distanceX=4;f.distanceY=-parseInt(f.visProp.fontsize)+3;f.setCoords(e.usrCoords[1]+f.distanceX/(j.unitX),e.usrCoords[2]+f.distanceY/(j.unitY));f.visProp.visible=g;f.prepareUpdate().update().updateRenderer();return f},removeTickLabels:function(){var e;if(this.ticks!=null){if((this.board.needsFullUpdate||this.needsRegularUpdate)&&!(this.board.options.renderer=="canvas"&&this.board.options.text.display=="internal")){for(e=0;e>=1;if(af==0){af=h();ah=(af&1);af=(af>>1)|128}return ah}function X(ah){var aj=0,ai=ah;while(ai--){aj=(aj<<1)|Z()}if(ah){aj=aa[aj]>>(8-ah)}return aj}function g(){ab=0}function B(ah){L++;l[ab++]=ah;q.push(String.fromCharCode(ah));if(ab==32768){ab=0}}function p(){this.b0=0;this.b1=0;this.jump=null;this.jumppos=-1}var i=288;var z=new Array(i);var R=new Array(32);var M=0;var ac=null;var t=null;var Q=new Array(64);var N=new Array(64);var C=0;var G=new Array(17);G[0]=0;var S;var w;function m(){while(1){if(G[C]>=w){return -1}if(S[G[C]]==C){return G[C]++}G[C]++}}function I(){var ai=ac[M];var ah;if(H){document.write("
len:"+C+" treepos:"+M)}if(C==17){return -1}M++;C++;ah=m();if(H){document.write("
IsPat "+ah)}if(ah>=0){ai.b0=ah;if(H){document.write("
b0 "+ai.b0)}}else{ai.b0=32768;if(H){document.write("
b0 "+ai.b0)}if(I()){return -1}}ah=m();if(ah>=0){ai.b1=ah;if(H){document.write("
b1 "+ai.b1)}ai.jump=null}else{ai.b1=32768;if(H){document.write("
b1 "+ai.b1)}ai.jump=ac[M];ai.jumppos=M;if(I()){return -1}}C--;return 0}function o(al,aj,am,ai){var ak;if(H){document.write("currentTree "+al+" numval "+aj+" lengths "+am+" show "+ai)}ac=al;M=0;S=am;w=aj;for(ak=0;ak<17;ak++){G[ak]=0}C=0;if(I()){if(H){alert("invalid huffman tree\n")}return -1}if(H){document.write("
Tree: "+ac.length);for(var ah=0;ah<32;ah++){document.write("Places["+ah+"].b0="+ac[ah].b0+"
");document.write("Places["+ah+"].b1="+ac[ah].b1+"
")}}return 0}function F(ak){var ai,aj,am=0,al=ak[am],ah;while(1){ah=Z();if(H){document.write("b="+ah)}if(ah){if(!(al.b1&32768)){if(H){document.write("ret1")}return al.b1}al=al.jump;ai=ak.length;for(aj=0;aj>1);if(av>23){av=(av<<1)|Z();if(av>199){av-=128;av=(av<<1)|Z()}else{av-=48;if(av>143){av=av+136}}}else{av+=256}if(av<256){B(av)}else{if(av==256){break}else{var ax,aq;av-=256+1;ax=X(V[av])+ae[av];av=aa[X(5)]>>3;if(D[av]>8){aq=X(8);aq|=(X(D[av]-8)<<8)}else{aq=X(D[av])}aq+=P[av];for(av=0;avdistanceTree");for(var az=0;az"+R[az].b0+" "+R[az].b1+" "+R[az].jump+" "+R[az].jumppos)}}ar=aj+ao;aw=0;var ak=-1;if(H){document.write("
n="+ar+" bits: "+e+"
")}while(aw"+ak+" i:"+aw+" decode: "+av+" bits "+e+"
")}if(av<16){an[aw++]=av}else{if(av==16){var at;av=3+X(2);if(aw+av>ar){g();return 1}at=aw?an[aw-1]:0;while(av--){an[aw++]=at}}else{if(av==17){av=3+X(3)}else{av=11+X(7)}if(aw+av>ar){g();return 1}while(av--){an[aw++]=0}}}}ax=z.length;for(aw=0;awliteralTree")}while(1){av=F(z);if(av>=256){var ax,aq;av-=256;if(av==0){break}av--;ax=X(V[av])+ae[av];av=F(R);if(D[av]>8){aq=X(8);aq|=(X(D[av]-8)<<8)}else{aq=X(D[av])}aq+=P[av];while(ax--){var ay=l[(ab-aq)&32767];B(ay)}}else{B(av)}}}}}}while(!al);g();s();return 0}JXG.Util.Unzip.prototype.unzipFile=function(ah){var ai;this.unzip();for(ai=0;ai>2;l=((o&3)<<4)|(m>>4);j=((m&15)<<2)|(k>>6);h=k&63;if(isNaN(m)){j=h=64}else{if(isNaN(k)){h=64}}e.push([this._keyStr.charAt(n),this._keyStr.charAt(l),this._keyStr.charAt(j),this._keyStr.charAt(h)].join(""))}return e.join("")},decode:function(h,g){var e=[],p,n,l,o,m,k,j,f=0;h=h.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f>4);n=((m&15)<<4)|(k>>2);l=((k&3)<<6)|j;e.push(String.fromCharCode(p));if(k!=64){e.push(String.fromCharCode(n))}if(j!=64){e.push(String.fromCharCode(l))}}e=e.join("");if(g){e=JXG.Util.Base64._utf8_decode(e)}return e},_utf8_encode:function(f){f=f.replace(/\r\n/g,"\n");var e="";for(var h=0;h127)&&(g<2048)){e+=String.fromCharCode((g>>6)|192);e+=String.fromCharCode((g&63)|128)}else{e+=String.fromCharCode((g>>12)|224);e+=String.fromCharCode(((g>>6)&63)|128);e+=String.fromCharCode((g&63)|128)}}}return e},_utf8_decode:function(e){var g=[],j=0,k=0,h=0,f=0;while(j191)&&(k<224)){h=e.charCodeAt(j+1);g.push(String.fromCharCode(((k&31)<<6)|(h&63)));j+=2}else{h=e.charCodeAt(j+1);f=e.charCodeAt(j+2);g.push(String.fromCharCode(((k&15)<<12)|((h&63)<<6)|(f&63)));j+=3}}}return g.join("")},_destrip:function(k,h){var f=[],j,g,e=[];if(h==null){h=76}k.replace(/ /g,"");j=k.length/h;for(g=0;g255){switch(g){case 8364:g=128;break;case 8218:g=130;break;case 402:g=131;break;case 8222:g=132;break;case 8230:g=133;break;case 8224:g=134;break;case 8225:g=135;break;case 710:g=136;break;case 8240:g=137;break;case 352:g=138;break;case 8249:g=139;break;case 338:g=140;break;case 381:g=142;break;case 8216:g=145;break;case 8217:g=146;break;case 8220:g=147;break;case 8221:g=148;break;case 8226:g=149;break;case 8211:g=150;break;case 8212:g=151;break;case 732:g=152;break;case 8482:g=153;break;case 353:g=154;break;case 8250:g=155;break;case 339:g=156;break;case 382:g=158;break;case 376:g=159;break;default:break}}return g};JXG.Util.utf8Decode=function(e){var g=[];var j=0;var l=0,k=0,h=0,f;if(!JXG.exists(e)){return""}while(j191)&&(l<224)){h=e.charCodeAt(j+1);g.push(String.fromCharCode(((l&31)<<6)|(h&63)));j+=2}else{h=e.charCodeAt(j+1);f=e.charCodeAt(j+2);g.push(String.fromCharCode(((l&15)<<12)|((h&63)<<6)|(f&63)));j+=3}}}return g.join("")};JXG.Util.genUUID=function(){var j="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),g=new Array(36),f=0,h;for(var e=0;e<36;e++){if(e==8||e==13||e==18||e==23){g[e]="-"}else{if(e==14){g[e]="4"}else{if(f<=2){f=33554432+(Math.random()*16777216)|0}h=f&15;f=f>>4;g[e]=j[(e==19)?(h&3)|8:h]}}}return g.join("")};JXG.PsTricks={convert:function(h){var j=new JXG.Coords(JXG.COORDS_BY_SCREEN,[0,0],h),k=new JXG.Coords(JXG.COORDS_BY_SCREEN,[h.canvasWidth,h.canvasHeight],h),f,g,e=[];e.push("\\begin{pspicture*}("+j.usrCoords[1]+","+k.usrCoords[2]+")("+k.usrCoords[1]+","+j.usrCoords[2]+")\n");for(f in h.objects){g=h.objects[f];if(g.visProp.visible){switch(g.elementClass){case JXG.OBJECT_CLASS_CIRCLE:e.push(this.addCircle(g));break;case JXG.OBJECT_CLASS_LINE:e.push(this.addLine(g));break;case JXG.OBJECT_CLASS_POINT:e.push(this.addPoint(g));break;default:switch(g.type){case JXG.OBJECT_TYPE_ARC:e.push(this.addArc(g));break;case JXG.OBJECT_TYPE_SECTOR:e.push(this.addArc(g));e.push(this.addSector(g));break;case JXG.OBJECT_TYPE_POLYGON:e.push(this.addPolygon(g));break;case JXG.OBJECT_TYPE_ANGLE:e.push(this.addAngle(g));break}break}}}e.push("\\end{pspicture*}");return e.join("\n")},setArrows:function(f){var e="";if(f.visProp.firstarrow&&f.visProp.lastarrow){e="{<->}"}else{if(f.visProp.firstarrow){e="{<-}"}else{if(f.visProp.lastarrow){e="{->}"}}}return e},drawWedge:function(g,h,i,f,k,j){var e="";if(g!="none"&&h>0){e+="\\pswedge[linestyle=none, fillstyle=solid, fillcolor="+this.parseColor(g)+", opacity="+h.toFixed(5)+"]";e+="("+i.join(",")+"){"+f+"}{"+k+"}{"+j+"}\n"}return e},addPoint:function(g){var e="\\psdot[linecolor="+this.parseColor(g.visProp.strokecolor)+",dotstyle=",h=g.normalizeFace(g.visProp.face)||"o",f=g.visProp.size>4?4:g.visProp.size,i=[0,0,"2pt 2","5pt 2","5pt 3"];if(h=="x"){e+="x, dotsize="+i[f]}else{if(h=="o"){e+="*, dotsize=";if(f==1){e+="2pt 2"}else{if(f==2){e+="4pt 2"}else{if(f==3){e+="6pt 2"}else{if(f==4){e+="6pt 3"}}}}}else{if(h=="[]"){e+="square*, dotsize="+i[f]}else{if(h=="+"){e+="+, dotsize="+i[f]}}}}e+="]("+g.coords.usrCoords.slice(1).join(",")+")\n";e+="\\rput("+(g.coords.usrCoords[1]+15/g.board.unitY)+","+(g.coords.usrCoords[2]+15/g.board.unitY)+"){\\small $"+g.name+"$}\n";return e},addLine:function(h){var g=new JXG.Coords(JXG.COORDS_BY_USER,h.point1.coords.usrCoords,h.board),f=new JXG.Coords(JXG.COORDS_BY_USER,h.point2.coords.usrCoords,h.board),e="\\psline[linecolor="+this.parseColor(h.visProp.strokecolor)+", linewidth="+h.visProp.strokewidth+"px]";if(h.visProp.straightfirst||h.visProp.straightlast){JXG.Math.Geometry.calcStraight(h,g,f)}e+=this.setArrows(h);e+="("+g.usrCoords.slice(1).join(",")+")("+f.usrCoords.slice(2).join(",")+")\n";return e},addCircle:function(g){var f=g.Radius(),e="\\pscircle[linecolor="+this.parseColor(g.visProp.strokecolor)+", linewidth="+g.visProp.strokewidth+"px";if(g.visProp.fillcolor!="none"&&g.visProp.fillopacity!=0){e+=", fillstyle=solid, fillcolor="+this.parseColor(g.visProp.fillcolor)+", opacity="+g.visProp.fillopacity.toFixed(5)}e+="]("+g.center.coords.usrCoords.slice(1).join("1")+"){"+f+"}\n";return e},addPolygon:function(g){var e="\\pspolygon[linestyle=none, fillstyle=solid, fillcolor="+this.parseColor(g.visProp.fillcolor)+", opacity="+g.visProp.fillopacity.toFixed(5)+"]",f;for(f=0;f0){z=z[0][0]}if(typeof z!="string"){return}r=window.JSON&&window.JSON.parse?window.JSON.parse(z):(new Function("return "+z))();if(r.type=="error"){this.handleError(r)}else{if(r.type=="response"){k=r.id;for(t=0;tf){e[g]=parseFloat(this.data[g][f])}}return e},getRow:function(g){var e,f;if(typeof g=="string"){for(f=0;f-1;e--){if(JXG.exists(this.sstack[e][f])){return e}}return -1},isCreator:function(e){return !!JXG.JSXGraph.elements[e]},isMathMethod:function(e){return e!=="E"&&!!Math[e]},isBuiltIn:function(e){return !!this.builtIn[e]},getvar:function(h,e){var g,f;e=JXG.def(e,false);g=this.isLocalVariable(h);if(g>-1){return this.sstack[g][h]}if(this.isCreator(h)){return this.creator(h)}if(this.isMathMethod(h)){return Math[h]}if(this.isBuiltIn(h)){return this.builtIn[h]}if(!e){g=JXG.getRef(this.board,h);if(g!==h){return g}}return f},getvarJS:function(g,e){var f;e=JXG.def(e,false);if(JXG.indexOf(this.pstack[this.pscope],g)>-1){return g}f=this.isLocalVariable(g);if(f>-1){return"$jc$.sstack["+f+"]['"+g+"']"}if(this.isCreator(g)){return"(function () { var a = Array.prototype.slice.call(arguments, 0); return $jc$.board.create.apply(this, ['"+g+"'].concat(a)); })"}if(this.isMathMethod(g)){return"Math."+g}if(this.isBuiltIn(g)){return this.builtIn[g].src}if(!e){if(JXG.isId(this.board,g)){return"$jc$.board.objects['"+g+"']"}else{if(JXG.isName(this.board,g)){return"$jc$.board.elementsByName['"+g+"']"}else{if(JXG.isGroup(this.board,g)){return"$jc$.board.groups['"+g+"']"}}}}return""},setProp:function(i,h,g){var f={},e,j;if(i.elementClass===JXG.OBJECT_CLASS_POINT&&(h==="X"||h==="Y")){h=h.toLowerCase();if(i.isDraggable&&typeof g==="number"){e=h==="x"?g:i.X();j=h==="y"?g:i.Y();i.setPosition(JXG.COORDS_BY_USER,e,j)}else{if(i.isDraggable&&(typeof g==="function"||typeof g==="string")){e=h==="x"?g:i.coords.usrCoords[1];j=h==="y"?g:i.coords.usrCoords[2];i.addConstraint([e,j])}else{if(!i.isDraggable){e=h==="x"?g:i.XEval.origin;j=h==="y"?g:i.YEval.origin;i.addConstraint([e,j])}}}this.board.update()}else{if(i.type===JXG.OBJECT_TYPE_TEXT&&(h==="X"||h==="Y")){if(typeof g==="number"){i[h]=function(){return g}}else{if(typeof g==="function"){i.isDraggable=false;i[h]=g}else{if(typeof g==="string"){i.isDraggable=false;i[h]=JXG.createFunction(g,this.board,null,true);i[h+"jc"]=g}}}i[h].origin=g;this.board.update()}else{if(i.type&&i.elementClass&&i.visProp){f[h]=g;i.setProperty(f)}else{i[h]=g}}}},utf8_encode:function(f){var e=[],h,g;for(h=0;h0){for(k=0;k"+e.substr(q[k].offset,30)+'<, expecting "'+f[k].join()+'"')}}},snippet:function(j,g,f,i){var k,l,h,e;k="jxg__tmp__intern_"+JXG.Util.genUUID().replace(/\-/g,"");if(!JXG.exists(g)){g=true}if(!JXG.exists(f)){f=""}if(!JXG.exists(i)){i=false}h=this.sstack[0][k];this.countLines=false;l=k+" = "+(g?" function ("+f+") { return ":"")+j+(g?"; }":"")+";";this.parse(l,i);e=this.sstack[0][k];if(JXG.exists(h)){this.sstack[0][k]=h}else{delete this.sstack[0][k]}this.countLines=true;return e},replaceIDs:function(g){var f,e;if(g.replaced){e=this.board.objects[g.children[1].children[0].value];if(JXG.exists(e)&&JXG.exists(e)&&e.name!==""){g.type="node_var";g.value=e.name;g.children.length=0;delete g.replaced}}if(g.children){for(f=g.children.length;f>0;f--){if(JXG.exists(g.children[f-1])){g.children[f-1]=this.replaceIDs(g.children[f-1])}}}return g},replaceNames:function(g){var f,e;e=g.value;if(g.type=="node_op"&&e=="op_lhs"&&g.children.length===1){this.isLHS=true}else{if(g.type=="node_var"){if(this.isLHS){this.letvar(e,true)}else{if(!JXG.exists(this.getvar(e,true))&&JXG.exists(this.board.elementsByName[e])){g=this.createReplacementNode(g)}}}}if(g.children){for(f=g.children.length;f>0;f--){if(JXG.exists(g.children[f-1])){g.children[f-1]=this.replaceNames(g.children[f-1])}}}if(g.type=="node_op"&&g.value=="op_lhs"&&g.children.length===1){this.isLHS=false}return g},createReplacementNode:function(g){var e=g.value,f=this.board.elementsByName[e];g=this.createNode("node_op","op_execfun",this.createNode("node_var","$"),this.createNode("node_op","op_param",this.createNode("node_str",f.id)));g.replaced=true;return g},collectDependencies:function(j,f){var h,g,k;g=j.value;if(j.type=="node_var"){k=this.getvar(g);if(k&&k.visProp&&k.type&&k.elementClass&&k.id){f[k.id]=k}}if(j.type=="node_op"&&j.value=="op_execfun"&&j.children.length>1&&j.children[0].value=="$"&&j.children[1].children.length>0){k=j.children[1].children[0].value;f[k]=this.board.objects[k]}if(j.children){for(h=j.children.length;h>0;h--){if(JXG.exists(j.children[h-1])){this.collectDependencies(j.children[h-1],f)}}}},resolveProperty:function(h,f,g){g=JXG.def(g,false);if(h&&h.type&&h.elementClass&&h.methodMap){if(f==="label"){h=h.label;f="content"}else{if(JXG.exists(h.subs[f])){h=h.subs}else{if(JXG.exists(h.methodMap[f])){f=h.methodMap[f]}else{h=h.visProp;f=f.toLowerCase()}}}}if(!JXG.exists(h)){this._error(h+" is not an object.")}if(!JXG.exists(h[f])){this._error("unknown property "+f+".")}if(g&&typeof h[f]==="function"){return function(){return h[f].apply(h,arguments)}}return h[f]},execute:function(node){var ret,v,i,e,parents=[];ret=0;if(this.cancel){this._error("Max runtime exceeded")}if(!node){return ret}this.line=node.line;switch(node.type){case"node_op":switch(node.value){case"op_none":if(node.children[0]){this.execute(node.children[0])}if(node.children[1]){ret=this.execute(node.children[1])}break;case"op_assign":v=this.execute(node.children[0]);this.lhs[this.scope]=v[1];if(v[0].type&&v[0].elementClass&&v[0].methodMap&&v[1]==="label"){this._error("Left-hand side of assignment is read-only.")}if(v[0]!==this.sstack[this.scope]||(JXG.isArray(v[0])&&typeof v[1]==="number")){this.setProp(v[0],v[1],this.execute(node.children[1]))}else{this.letvar(v[1],this.execute(node.children[1]))}this.lhs[this.scope]=0;break;case"op_noassign":ret=this.execute(node.children[0]);break;case"op_if":if(this.execute(node.children[0])){ret=this.execute(node.children[1])}break;case"op_if_else":if(this.execute(node.children[0])){ret=this.execute(node.children[1])}else{ret=this.execute(node.children[2])}break;case"op_while":while(this.execute(node.children[0])){this.execute(node.children[1])}break;case"op_do":do{this.execute(node.children[0])}while(this.execute(node.children[1]));break;case"op_for":i=new Date().getTime();for(this.execute(node.children[0]);this.execute(node.children[1]);this.execute(node.children[2])){if(new Date().getTime()-i>this.maxRuntime||this.cancel){this._error("for: max runtime exceeded");break}this.execute(node.children[3])}break;case"op_param":if(node.children[1]){this.execute(node.children[1])}ret=node.children[0];this.pstack[this.pscope].push(ret);break;case"op_paramdef":if(node.children[1]){this.execute(node.children[1])}ret=node.children[0];this.pstack[this.pscope].push(ret);break;case"op_proplst":if(node.children[0]){this.execute(node.children[0])}if(node.children[1]){this.execute(node.children[1])}break;case"op_proplst_val":this.propstack.push({});this.propscope++;this.execute(node.children[0]);ret=this.propstack[this.propscope];this.propstack.pop();this.propscope--;break;case"op_prop":this.propstack[this.propscope][node.children[0]]=this.execute(node.children[1]);break;case"op_array":var l;this.pstack.push([]);this.pscope++;this.execute(node.children[0]);ret=[];l=this.pstack[this.pscope].length;for(i=0;ithis.execute(node.children[1]);break;case"op_lot":ret=this.execute(node.children[0])=this.execute(node.children[1]);break;case"op_loe":ret=this.execute(node.children[0])<=this.execute(node.children[1]);break;case"op_or":ret=this.execute(node.children[0])||this.execute(node.children[1]);break;case"op_and":ret=this.execute(node.children[0])&&this.execute(node.children[1]);break;case"op_not":ret=!this.execute(node.children[0]);break;case"op_add":ret=JXG.Math.Statistics.add(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_sub":ret=JXG.Math.Statistics.subtract(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_div":ret=JXG.Math.Statistics.div(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_mod":ret=JXG.Math.Statistics.mod(this.execute(node.children[0]),this.execute(node.children[1]),true);break;case"op_mul":ret=this.mul(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_exp":ret=Math.pow(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_neg":ret=this.execute(node.children[0])*-1;break}break;case"node_var":ret=this.getvar(node.value);break;case"node_const":ret=Number(node.value);break;case"node_const_bool":ret=node.value.toLowerCase()!=="false";break;case"node_str":ret=node.value;break}return ret},compile:function(j,l){var g,h,k,f;g="";if(!JXG.exists(l)){l=false}if(!j){return g}switch(j.type){case"node_op":switch(j.value){case"op_none":if(j.children[0]){g=this.compile(j.children[0],l)}if(j.children[1]){g+=this.compile(j.children[1],l)}break;case"op_assign":k=this.compile(j.children[0],l);if(l){if(JXG.isArray(k)){g="$jc$.setProp("+k[0]+", '"+k[1]+"', "+this.compile(j.children[1],l)+");\n"}else{if(this.isLocalVariable(k)!==this.scope){this.sstack[this.scope][k]=true}g="$jc$.sstack["+this.scope+"]['"+k+"'] = "+this.compile(j.children[1],l)+";\n"}}else{g=k+" = "+this.compile(j.children[1],l)+";\n"}break;case"op_noassign":g=this.compile(j.children[0],l);break;case"op_if":g=" if ("+this.compile(j.children[0],l)+") "+this.compile(j.children[1],l);break;case"op_if_else":g=" if ("+this.compile(j.children[0],l)+")"+this.compile(j.children[1],l);g+=" else "+this.compile(j.children[2],l);break;case"op_while":g=" while ("+this.compile(j.children[0],l)+") {\n"+this.compile(j.children[1],l)+"}\n";break;case"op_do":g=" do {\n"+this.compile(j.children[0],l)+"} while ("+this.compile(j.children[1],l)+");\n";break;case"op_for":g=" for ("+this.compile(j.children[0],l)+"; "+this.compile(j.children[1],l)+"; "+this.compile(j.children[2],l)+") {\n"+this.compile(j.children[3],l)+"\n}\n";break;case"op_param":if(j.children[1]){g=this.compile(j.children[1],l)+", "}g+=this.compile(j.children[0],l);break;case"op_paramdef":if(j.children[1]){g=this.compile(j.children[1],l)+", "}g+=j.children[0];break;case"op_proplst":if(j.children[0]){g=this.compile(j.children[0],l)+", "}g+=this.compile(j.children[1],l);break;case"op_prop":g=j.children[0]+": "+this.compile(j.children[1],l);break;case"op_proplst_val":g=(l?"{":"<<")+this.compile(j.children[0],l)+(l?"}":">>");break;case"op_array":g="["+this.compile(j.children[0],l)+"]";break;case"op_extvalue":g=this.compile(j.children[0],l)+"["+this.compile(j.children[1],l)+"]";break;case"op_return":g=" return "+this.compile(j.children[0],l)+";\n";break;case"op_function":g=" function ("+this.compile(j.children[0],l)+") {\n"+this.compile(j.children[1],l)+"}";break;case"op_execfun":if(j.children[2]){k=(l?"{":"<<")+this.compile(j.children[2],l)+(l?"}":">>")}g=this.compile(j.children[0],l)+"("+this.compile(j.children[1],l)+(j.children[2]?", "+k:"")+")";if(l&&j.children[0].value==="$"){g="$jc$.board.objects["+this.compile(j.children[1],l)+"]"}break;case"op_property":if(l&&j.children[1]!=="X"&&j.children[1]!=="Y"){g="$jc$.resolveProperty("+this.compile(j.children[0],l)+", '"+j.children[1]+"', true)"}else{g=this.compile(j.children[0],l)+"."+j.children[1]}break;case"op_lhs":if(j.children.length===1){g=j.children[0]}else{if(j.children[2]==="dot"){if(l){g=[this.compile(j.children[1],l),j.children[0]]}else{g=this.compile(j.children[1],l)+"."+j.children[0]}}else{if(j.children[2]==="bracket"){if(l){g=[this.compile(j.children[1],l),this.compile(j.children[0],l)]}else{g=this.compile(j.children[1],l)+"["+this.compile(j.children[0],l)+"]"}}}}break;case"op_use":if(l){g="$jc$.board = JXG.JSXGraph.boards['"+j.children[0]+"']"}else{g="use "+j.children[0]+";"}break;case"op_delete":g="delete "+j.children[0];break;case"op_equ":g="("+this.compile(j.children[0],l)+" == "+this.compile(j.children[1],l)+")";break;case"op_neq":g="("+this.compile(j.children[0],l)+" != "+this.compile(j.children[1],l)+")";break;case"op_approx":g="("+this.compile(j.children[0],l)+" ~= "+this.compile(j.children[1],l)+")";break;case"op_grt":g="("+this.compile(j.children[0],l)+" > "+this.compile(j.children[1],l)+")";break;case"op_lot":g="("+this.compile(j.children[0],l)+" < "+this.compile(j.children[1],l)+")";break;case"op_gre":g="("+this.compile(j.children[0],l)+" >= "+this.compile(j.children[1],l)+")";break;case"op_loe":g="("+this.compile(j.children[0],l)+" <= "+this.compile(j.children[1],l)+")";break;case"op_or":g="("+this.compile(j.children[0],l)+" || "+this.compile(j.children[1],l)+")";break;case"op_and":g="("+this.compile(j.children[0],l)+" && "+this.compile(j.children[1],l)+")";break;case"op_not":g="!("+this.compile(j.children[0],l)+")";break;case"op_add":if(l){g="JXG.Math.Statistics.add("+this.compile(j.children[0],l)+", "+this.compile(j.children[1],l)+")"}else{g="("+this.compile(j.children[0],l)+" + "+this.compile(j.children[1],l)+")"}break;case"op_sub":if(l){g="JXG.Math.Statistics.subtract("+this.compile(j.children[0],l)+", "+this.compile(j.children[1],l)+")"}else{g="("+this.compile(j.children[0],l)+" - "+this.compile(j.children[1],l)+")"}break;case"op_div":if(l){g="JXG.Math.Statistics.div("+this.compile(j.children[0],l)+", "+this.compile(j.children[1],l)+")"}else{g="("+this.compile(j.children[0],l)+" / "+this.compile(j.children[1],l)+")"}break;case"op_mod":if(l){g="JXG.Math.mod("+this.compile(j.children[0],l)+", "+this.compile(j.children[1],l)+", true)"}else{g="("+this.compile(j.children[0],l)+" % "+this.compile(j.children[1],l)+")"}break;case"op_mul":if(l){g="$jc$.mul("+this.compile(j.children[0],l)+", "+this.compile(j.children[1],l)+")"}else{g="("+this.compile(j.children[0],l)+" * "+this.compile(j.children[1],l)+")"}break;case"op_exp":if(l){g="Math.pow("+this.compile(j.children[0],l)+", "+this.compile(j.children[1],l)+")"}else{g="("+this.compile(j.children[0],l)+"^"+this.compile(j.children[1],l)+")"}break;case"op_neg":g="(-"+this.compile(j.children[0],l)+")";break}break;case"node_var":if(l){g=this.getvarJS(j.value)}else{g=j.value}break;case"node_const":g=j.value;break;case"node_const_bool":g=j.value;break;case"node_str":g="'"+j.value.replace(/'/g,"\\'")+"'";break}if(j.needsBrackets){g="{\n"+g+"}\n"}return g},X:function(f){return f.X()},Y:function(f){return f.Y()},V:function(f){return f.Value()},L:function(f){return f.L()},dist:function(f,e){if(!JXG.exists(f)||!JXG.exists(f.Dist)){this._error("Error: Can't calculate distance.")}return f.Dist(e)},mul:function(f,e){if(JXG.isArray(f)*JXG.isArray(e)){return JXG.Math.innerProduct(f,e,Math.min(f.length,e.length))}else{return JXG.Math.Statistics.multiply(f,e)}},defineBuiltIn:function(){var e=this,f={PI:Math.PI,EULER:Math.E,X:e.X,Y:e.Y,V:e.V,L:e.L,dist:e.dist,rad:JXG.Math.Geometry.rad,deg:JXG.Math.Geometry.trueAngle,factorial:JXG.Math.factorial,trunc:JXG.trunc,"$":e.getElementById};f.rad.sc=JXG.Math.Geometry;f.deg.sc=JXG.Math.Geometry;f.factorial.sc=JXG.Math;f.PI.src="Math.PI";f.EULER.src="Math.E";f.X.src="$jc$.X";f.Y.src="$jc$.Y";f.V.src="$jc$.V";f.L.src="$jc$.L";f.dist.src="$jc$.dist";f.rad.src="JXG.Math.Geometry.rad";f.deg.src="JXG.Math.Geometry.trueAngle";f.factorial.src="JXG.Math.factorial";f.trunc.src="JXG.trunc";f["$"].src="(function (n) { return JXG.getRef($jc$.board, n); })";return f},_debug:function(e){if(typeof console!=="undefined"){console.log(e)}else{if(document.getElementById("debug")!==null){document.getElementById("debug").innerHTML+=e+"
"}}},_error:function(g){var f=new Error("Error("+this.line+"): "+g);f.line=this.line;throw f},_warn:function(e){if(typeof console!=="undefined"){console.log("Warning("+this.line+"): "+e)}else{if(document.getElementById(this.warnLog)!==null){document.getElementById(this.warnLog).innerHTML+="Warning("+this.line+"): "+e+"
"}}}});JXG.extend(JXG.JessieCode.prototype,{_lex:function(e){var i,f=-1,h=0,k=0,j,g;while(1){i=0;f=-1;h=0;k=0;j=e.offset+1+(h-k);do{j--;i=0;f=-2;k=j;if(e.src.length<=k){return 66}do{g=e.src.charCodeAt(j);switch(i){case 0:if((g>=9&&g<=10)||g==13||g==32){i=1}else{if(g==33){i=2}else{if(g==35){i=3}else{if(g==36||(g>=65&&g<=67)||(g>=71&&g<=72)||(g>=74&&g<=81)||g==83||g==86||(g>=88&&g<=90)||g==95||(g>=97&&g<=99)||(g>=103&&g<=104)||(g>=106&&g<=113)||g==115||g==118||(g>=120&&g<=122)){i=4}else{if(g==37){i=5}else{if(g==40){i=6}else{if(g==41){i=7}else{if(g==42){i=8}else{if(g==43){i=9}else{if(g==44){i=10}else{if(g==45){i=11}else{if(g==46){i=12}else{if(g==47){i=13}else{if((g>=48&&g<=57)){i=14}else{if(g==58){i=15}else{if(g==59){i=16}else{if(g==60){i=17}else{if(g==61){i=18}else{if(g==62){i=19}else{if(g==91){i=20}else{if(g==93){i=21}else{if(g==94){i=22}else{if(g==123){i=23}else{if(g==124){i=24}else{if(g==125){i=25}else{if(g==38){i=48}else{if(g==68||g==100){i=49}else{if(g==39){i=51}else{if(g==73||g==105){i=52}else{if(g==126){i=53}else{if(g==70||g==102){i=64}else{if(g==85||g==117){i=65}else{if(g==69||g==101){i=73}else{if(g==84||g==116){i=74}else{if(g==87||g==119){i=80}else{if(g==82||g==114){i=84}else{i=-1}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}break;case 1:i=-1;f=2;h=j;break;case 2:if(g==61){i=26}else{i=-1}f=31;h=j;break;case 3:i=-1;f=41;h=j;break;case 4:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=45;h=j;break;case 5:i=-1;f=35;h=j;break;case 6:i=-1;f=38;h=j;break;case 7:i=-1;f=39;h=j;break;case 8:i=-1;f=36;h=j;break;case 9:i=-1;f=32;h=j;break;case 10:i=-1;f=40;h=j;break;case 11:i=-1;f=33;h=j;break;case 12:if((g>=48&&g<=57)){i=29}else{i=-1}f=44;h=j;break;case 13:i=-1;f=34;h=j;break;case 14:if((g>=48&&g<=57)){i=14}else{if(g==46){i=29}else{i=-1}}f=47;h=j;break;case 15:i=-1;f=42;h=j;break;case 16:i=-1;f=20;h=j;break;case 17:if(g==60){i=30}else{if(g==61){i=31}else{i=-1}}f=28;h=j;break;case 18:if(g==61){i=32}else{i=-1}f=21;h=j;break;case 19:if(g==61){i=33}else{if(g==62){i=34}else{i=-1}}f=27;h=j;break;case 20:i=-1;f=16;h=j;break;case 21:i=-1;f=17;h=j;break;case 22:i=-1;f=37;h=j;break;case 23:i=-1;f=18;h=j;break;case 24:if(g==124){i=37}else{i=-1}f=43;h=j;break;case 25:i=-1;f=19;h=j;break;case 26:i=-1;f=23;h=j;break;case 27:i=-1;f=30;h=j;break;case 28:i=-1;f=46;h=j;break;case 29:if((g>=48&&g<=57)){i=29}else{i=-1}f=48;h=j;break;case 30:i=-1;f=14;h=j;break;case 31:i=-1;f=25;h=j;break;case 32:i=-1;f=22;h=j;break;case 33:i=-1;f=26;h=j;break;case 34:i=-1;f=15;h=j;break;case 35:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=6;h=j;break;case 36:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=3;h=j;break;case 37:i=-1;f=29;h=j;break;case 38:i=-1;f=24;h=j;break;case 39:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=7;h=j;break;case 40:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=9;h=j;break;case 41:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=4;h=j;break;case 42:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=12;h=j;break;case 43:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=13;h=j;break;case 44:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=5;h=j;break;case 45:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=11;h=j;break;case 46:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=10;h=j;break;case 47:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=8;h=j;break;case 48:if(g==38){i=27}else{i=-1}break;case 49:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=78)||(g>=80&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=110)||(g>=112&&g<=122)){i=4}else{if(g==79||g==111){i=35}else{if(g==69||g==101){i=81}else{i=-1}}}f=45;h=j;break;case 50:if(g==39){i=28}else{if((g>=0&&g<=38)||(g>=40&&g<=91)||(g>=93&&g<=254)){i=51}else{if(g==92){i=55}else{i=-1}}}f=46;h=j;break;case 51:if(g==39){i=28}else{if((g>=0&&g<=38)||(g>=40&&g<=91)||(g>=93&&g<=254)){i=51}else{if(g==92){i=55}else{i=-1}}}break;case 52:if((g>=48&&g<=57)||(g>=65&&g<=69)||(g>=71&&g<=90)||g==95||(g>=97&&g<=101)||(g>=103&&g<=122)){i=4}else{if(g==70||g==102){i=36}else{i=-1}}f=45;h=j;break;case 53:if(g==61){i=38}else{i=-1}break;case 54:if((g>=48&&g<=57)||(g>=65&&g<=81)||(g>=83&&g<=90)||g==95||(g>=97&&g<=113)||(g>=115&&g<=122)){i=4}else{if(g==82||g==114){i=39}else{i=-1}}f=45;h=j;break;case 55:if(g==39){i=50}else{if((g>=0&&g<=38)||(g>=40&&g<=91)||(g>=93&&g<=254)){i=51}else{if(g==92){i=55}else{i=-1}}}break;case 56:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=40}else{i=-1}}f=45;h=j;break;case 57:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=41}else{i=-1}}f=45;h=j;break;case 58:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=42}else{i=-1}}f=45;h=j;break;case 59:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=43}else{i=-1}}f=45;h=j;break;case 60:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=44}else{i=-1}}f=45;h=j;break;case 61:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=45}else{i=-1}}f=45;h=j;break;case 62:if((g>=48&&g<=57)||(g>=65&&g<=77)||(g>=79&&g<=90)||g==95||(g>=97&&g<=109)||(g>=111&&g<=122)){i=4}else{if(g==78||g==110){i=46}else{i=-1}}f=45;h=j;break;case 63:if((g>=48&&g<=57)||(g>=65&&g<=77)||(g>=79&&g<=90)||g==95||(g>=97&&g<=109)||(g>=111&&g<=122)){i=4}else{if(g==78||g==110){i=47}else{i=-1}}f=45;h=j;break;case 64:if((g>=48&&g<=57)||(g>=66&&g<=78)||(g>=80&&g<=84)||(g>=86&&g<=90)||g==95||(g>=98&&g<=110)||(g>=112&&g<=116)||(g>=118&&g<=122)){i=4}else{if(g==79||g==111){i=54}else{if(g==65||g==97){i=75}else{if(g==85||g==117){i=86}else{i=-1}}}}f=45;h=j;break;case 65:if((g>=48&&g<=57)||(g>=65&&g<=82)||(g>=84&&g<=90)||g==95||(g>=97&&g<=114)||(g>=116&&g<=122)){i=4}else{if(g==83||g==115){i=56}else{i=-1}}f=45;h=j;break;case 66:if((g>=48&&g<=57)||(g>=65&&g<=82)||(g>=84&&g<=90)||g==95||(g>=97&&g<=114)||(g>=116&&g<=122)){i=4}else{if(g==83||g==115){i=57}else{i=-1}}f=45;h=j;break;case 67:if((g>=48&&g<=57)||(g>=65&&g<=84)||(g>=86&&g<=90)||g==95||(g>=97&&g<=116)||(g>=118&&g<=122)){i=4}else{if(g==85||g==117){i=58}else{i=-1}}f=45;h=j;break;case 68:if((g>=48&&g<=57)||(g>=65&&g<=82)||(g>=84&&g<=90)||g==95||(g>=97&&g<=114)||(g>=116&&g<=122)){i=4}else{if(g==83||g==115){i=59}else{i=-1}}f=45;h=j;break;case 69:if((g>=48&&g<=57)||(g>=65&&g<=75)||(g>=77&&g<=90)||g==95||(g>=97&&g<=107)||(g>=109&&g<=122)){i=4}else{if(g==76||g==108){i=60}else{i=-1}}f=45;h=j;break;case 70:if((g>=48&&g<=57)||(g>=65&&g<=83)||(g>=85&&g<=90)||g==95||(g>=97&&g<=115)||(g>=117&&g<=122)){i=4}else{if(g==84||g==116){i=61}else{i=-1}}f=45;h=j;break;case 71:if((g>=48&&g<=57)||(g>=65&&g<=81)||(g>=83&&g<=90)||g==95||(g>=97&&g<=113)||(g>=115&&g<=122)){i=4}else{if(g==82||g==114){i=62}else{i=-1}}f=45;h=j;break;case 72:if((g>=48&&g<=57)||(g>=65&&g<=78)||(g>=80&&g<=90)||g==95||(g>=97&&g<=110)||(g>=112&&g<=122)){i=4}else{if(g==79||g==111){i=63}else{i=-1}}f=45;h=j;break;case 73:if((g>=48&&g<=57)||(g>=65&&g<=75)||(g>=77&&g<=90)||g==95||(g>=97&&g<=107)||(g>=109&&g<=122)){i=4}else{if(g==76||g==108){i=66}else{i=-1}}f=45;h=j;break;case 74:if((g>=48&&g<=57)||(g>=65&&g<=81)||(g>=83&&g<=90)||g==95||(g>=97&&g<=113)||(g>=115&&g<=122)){i=4}else{if(g==82||g==114){i=67}else{i=-1}}f=45;h=j;break;case 75:if((g>=48&&g<=57)||(g>=65&&g<=75)||(g>=77&&g<=90)||g==95||(g>=97&&g<=107)||(g>=109&&g<=122)){i=4}else{if(g==76||g==108){i=68}else{i=-1}}f=45;h=j;break;case 76:if((g>=48&&g<=57)||(g>=65&&g<=72)||(g>=74&&g<=90)||g==95||(g>=97&&g<=104)||(g>=106&&g<=122)){i=4}else{if(g==73||g==105){i=69}else{i=-1}}f=45;h=j;break;case 77:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=70}else{i=-1}}f=45;h=j;break;case 78:if((g>=48&&g<=57)||(g>=65&&g<=84)||(g>=86&&g<=90)||g==95||(g>=97&&g<=116)||(g>=118&&g<=122)){i=4}else{if(g==85||g==117){i=71}else{i=-1}}f=45;h=j;break;case 79:if((g>=48&&g<=57)||(g>=65&&g<=72)||(g>=74&&g<=90)||g==95||(g>=97&&g<=104)||(g>=106&&g<=122)){i=4}else{if(g==73||g==105){i=72}else{i=-1}}f=45;h=j;break;case 80:if((g>=48&&g<=57)||(g>=65&&g<=71)||(g>=73&&g<=90)||g==95||(g>=97&&g<=103)||(g>=105&&g<=122)){i=4}else{if(g==72||g==104){i=76}else{i=-1}}f=45;h=j;break;case 81:if((g>=48&&g<=57)||(g>=65&&g<=75)||(g>=77&&g<=90)||g==95||(g>=97&&g<=107)||(g>=109&&g<=122)){i=4}else{if(g==76||g==108){i=77}else{i=-1}}f=45;h=j;break;case 82:if((g>=48&&g<=57)||(g>=65&&g<=83)||(g>=85&&g<=90)||g==95||(g>=97&&g<=115)||(g>=117&&g<=122)){i=4}else{if(g==84||g==116){i=78}else{i=-1}}f=45;h=j;break;case 83:if((g>=48&&g<=57)||(g>=65&&g<=83)||(g>=85&&g<=90)||g==95||(g>=97&&g<=115)||(g>=117&&g<=122)){i=4}else{if(g==84||g==116){i=79}else{i=-1}}f=45;h=j;break;case 84:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=82}else{i=-1}}f=45;h=j;break;case 85:if((g>=48&&g<=57)||(g>=65&&g<=66)||(g>=68&&g<=90)||g==95||(g>=97&&g<=98)||(g>=100&&g<=122)){i=4}else{if(g==67||g==99){i=83}else{i=-1}}f=45;h=j;break;case 86:if((g>=48&&g<=57)||(g>=65&&g<=77)||(g>=79&&g<=90)||g==95||(g>=97&&g<=109)||(g>=111&&g<=122)){i=4}else{if(g==78||g==110){i=85}else{i=-1}}f=45;h=j;break}if(i>-1){if(g==10){e.line++;e.column=0;if(this.countLines){this.parCurLine=e.line;this.parCurColumn=e.column}}e.column++}j++}while(i>-1)}while(2>-1&&f==2);if(f>-1){e.att=e.src.substr(k,h-k);e.offset=h;if(f==46){e.att=e.att.substr(1,e.att.length-2);e.att=e.att.replace(/\\\'/g,"'")}}else{e.att=new String();f=-1}break}return f},_parse:function(e,k,h){var t=[],s=[],l=0,q,o,n,g={la:0,act:0,offset:0,src:e,att:"",line:1,column:1,error_step:0};var m=new Array(new Array(0,1),new Array(49,2),new Array(49,0),new Array(51,2),new Array(51,0),new Array(52,3),new Array(52,1),new Array(52,0),new Array(54,3),new Array(54,1),new Array(54,0),new Array(55,3),new Array(56,3),new Array(56,1),new Array(56,0),new Array(58,3),new Array(50,3),new Array(50,5),new Array(50,3),new Array(50,5),new Array(50,9),new Array(50,3),new Array(50,2),new Array(50,2),new Array(50,2),new Array(50,2),new Array(50,3),new Array(50,1),new Array(57,3),new Array(57,4),new Array(57,1),new Array(53,3),new Array(53,3),new Array(53,3),new Array(53,3),new Array(53,3),new Array(53,3),new Array(53,3),new Array(53,1),new Array(61,3),new Array(61,3),new Array(61,2),new Array(61,1),new Array(60,3),new Array(60,3),new Array(60,1),new Array(62,3),new Array(62,3),new Array(62,3),new Array(62,1),new Array(63,3),new Array(63,1),new Array(64,2),new Array(64,2),new Array(64,1),new Array(59,4),new Array(59,4),new Array(59,5),new Array(59,3),new Array(59,1),new Array(65,1),new Array(65,1),new Array(65,1),new Array(65,3),new Array(65,1),new Array(65,7),new Array(65,3),new Array(65,3),new Array(65,1),new Array(65,1));var j=new Array(new Array(),new Array(3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(38,40),new Array(45,41),new Array(45,42),new Array(3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(20,44),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51,20,52),new Array(),new Array(),new Array(21,54),new Array(30,55,29,56),new Array(44,57,38,58,16,59),new Array(21,-30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(32,61,33,62),new Array(),new Array(35,63,34,64,36,65),new Array(),new Array(),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(),new Array(38,67),new Array(45,70),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(),new Array(),new Array(),new Array(37,73),new Array(47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51,3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(44,77,38,58,16,78),new Array(),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51,3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(5,80),new Array(45,17,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(20,83),new Array(),new Array(),new Array(),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(),new Array(19,91,3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(45,96),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(30,55,29,56),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(39,104,24,45,23,46,26,47,25,48,27,49,28,50,22,51),new Array(45,106),new Array(15,107,40,108),new Array(),new Array(42,109),new Array(17,110,40,111),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(44,77,38,58,16,78),new Array(44,77,38,58,16,78),new Array(4,113),new Array(45,114),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(20,117),new Array(44,57,38,58,16,59),new Array(),new Array(30,55,29,56),new Array(30,55,29,56),new Array(30,55,29,56),new Array(30,55,29,56),new Array(30,55,29,56),new Array(30,55,29,56),new Array(30,55,29,56),new Array(),new Array(),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51),new Array(32,61,33,62),new Array(32,61,33,62),new Array(21,-28),new Array(39,118,40,111),new Array(17,119,32,61,33,62),new Array(35,63,34,64,36,65),new Array(35,63,34,64,36,65),new Array(),new Array(),new Array(),new Array(),new Array(39,120,40,121),new Array(),new Array(),new Array(45,70),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(),new Array(3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(),new Array(17,126,32,61,33,62),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51,20,127),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(21,-29),new Array(18,130),new Array(45,131),new Array(),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51),new Array(),new Array(),new Array(),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51,20,132),new Array(44,77,38,58,16,78),new Array(),new Array(),new Array(45,17,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(19,135,3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(39,136),new Array(),new Array(3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array());var f=new Array(new Array(49,1),new Array(50,2,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(53,35,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(53,38,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(50,39,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(),new Array(),new Array(50,43,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(),new Array(51,53),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(61,60,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(53,66,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(),new Array(54,68,55,69),new Array(52,71,53,72,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(),new Array(),new Array(),new Array(59,74,65,20),new Array(59,75,65,20),new Array(50,76,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(),new Array(50,79,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(58,81,57,14,59,82,65,20),new Array(),new Array(),new Array(),new Array(),new Array(61,84,60,19,62,21,63,31,64,32,59,36,65,20),new Array(61,85,60,19,62,21,63,31,64,32,59,36,65,20),new Array(61,86,60,19,62,21,63,31,64,32,59,36,65,20),new Array(61,87,60,19,62,21,63,31,64,32,59,36,65,20),new Array(61,88,60,19,62,21,63,31,64,32,59,36,65,20),new Array(61,89,60,19,62,21,63,31,64,32,59,36,65,20),new Array(61,90,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(50,92,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(53,93,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(60,94,62,21,63,31,64,32,59,36,65,20),new Array(60,95,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(52,97,53,72,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(60,98,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(62,99,63,31,64,32,59,36,65,20),new Array(62,100,63,31,64,32,59,36,65,20),new Array(63,101,64,32,59,36,65,20),new Array(63,102,64,32,59,36,65,20),new Array(63,103,64,32,59,36,65,20),new Array(),new Array(56,105),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(63,112,64,32,59,36,65,20),new Array(),new Array(),new Array(),new Array(),new Array(60,115,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(53,116,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(55,122),new Array(53,123,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(53,124,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(50,125,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(),new Array(),new Array(53,128,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(59,129,65,20),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(51,133),new Array(),new Array(58,134,57,14,59,82,65,20),new Array(50,92,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(),new Array(50,137,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array());var r=new Array(2,0,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,27,-1,38,54,62,-1,42,59,45,60,61,-1,64,-1,10,7,68,69,49,51,-1,-1,-1,54,62,-1,-1,-1,-1,22,23,24,-1,-1,-1,-1,-1,-1,-1,25,-1,-1,-1,-1,-1,7,-1,41,-1,-1,-1,-1,-1,-1,14,-1,9,-1,-1,6,-1,52,53,16,-1,-1,18,-1,-1,-1,21,37,36,35,34,33,32,31,26,3,15,40,39,58,-1,-1,44,43,48,47,46,63,-1,13,66,-1,-1,67,-1,50,-1,58,-1,-1,-1,56,55,-1,-1,8,11,5,17,55,19,-1,57,4,12,-1,-1,-1,65,-1,20);var p=new Array("Program'","ERROR_RESYNC","WHITESPACE","IF","ELSE","WHILE","DO","FOR","FUNCTION","USE","RETURN","DELETE","TRUE","FALSE","<<",">>","[","]","{","}",";","=","==","!=","~=","<=",">=",">","<","||","&&","!","+","-","/","%","*","^","(",")",",","#",":","|",".","Identifier","String","Integer","Float","Program","Stmt","Stmt_List","Param_List","Expression","Prop_List","Prop","Param_Def_List","Lhs","Assign","ExtValue","AddSubExp","LogExp","MulDivExp","ExpExp","NegExp","Value","$");if(!k){k=[]}if(!h){h=[]}t.push(0);s.push(0);g.la=this._lex(g);while(true){g.act=139;for(n=0;n1&&g.act==139){t.pop();s.pop();for(n=0;n1&&g.act!=139){while(g.la!=66){g.act=139;for(n=0;n0){t.push(g.act);s.push(g.att);g.la=this._lex(g);if(g.error_step>0){g.error_step--}}else{q=g.act*-1;o=void (0);switch(q){case 0:o=s[s.length-1];break;case 1:this.execute(s[s.length-1]);break;case 2:o=s[s.length-0];break;case 3:o=this.createNode("node_op","op_none",s[s.length-2],s[s.length-1]);break;case 4:o=s[s.length-0];break;case 5:o=this.createNode("node_op","op_param",s[s.length-1],s[s.length-3]);break;case 6:o=this.createNode("node_op","op_param",s[s.length-1]);break;case 7:o=s[s.length-0];break;case 8:o=this.createNode("node_op","op_proplst",s[s.length-3],s[s.length-1]);break;case 9:o=s[s.length-1];break;case 10:o=s[s.length-0];break;case 11:o=this.createNode("node_op","op_prop",s[s.length-3],s[s.length-1]);break;case 12:o=this.createNode("node_op","op_paramdef",s[s.length-1],s[s.length-3]);break;case 13:o=this.createNode("node_op","op_paramdef",s[s.length-1]);break;case 14:o=s[s.length-0];break;case 15:o=this.createNode("node_op","op_assign",s[s.length-3],s[s.length-1]);break;case 16:o=this.createNode("node_op","op_if",s[s.length-2],s[s.length-1]);break;case 17:o=this.createNode("node_op","op_if_else",s[s.length-4],s[s.length-3],s[s.length-1]);break;case 18:o=this.createNode("node_op","op_while",s[s.length-2],s[s.length-1]);break;case 19:o=this.createNode("node_op","op_do",s[s.length-4],s[s.length-2]);break;case 20:o=this.createNode("node_op","op_for",s[s.length-7],s[s.length-5],s[s.length-3],s[s.length-1]);break;case 21:o=this.createNode("node_op","op_use",s[s.length-2]);break;case 22:o=this.createNode("node_op","op_delete",s[s.length-1]);break;case 23:o=this.createNode("node_op","op_return",s[s.length-1]);break;case 24:o=s[s.length-2];break;case 25:o=this.createNode("node_op","op_noassign",s[s.length-2]);break;case 26:o=s[s.length-2];o.needsBrackets=true;break;case 27:o=this.createNode("node_op","op_none");break;case 28:o=this.createNode("node_op","op_lhs",s[s.length-1],s[s.length-3],"dot");break;case 29:o=this.createNode("node_op","op_lhs",s[s.length-2],s[s.length-4],"bracket");break;case 30:o=this.createNode("node_op","op_lhs",s[s.length-1]);break;case 31:o=this.createNode("node_op","op_equ",s[s.length-3],s[s.length-1]);break;case 32:o=this.createNode("node_op","op_lot",s[s.length-3],s[s.length-1]);break;case 33:o=this.createNode("node_op","op_grt",s[s.length-3],s[s.length-1]);break;case 34:o=this.createNode("node_op","op_loe",s[s.length-3],s[s.length-1]);break;case 35:o=this.createNode("node_op","op_gre",s[s.length-3],s[s.length-1]);break;case 36:o=this.createNode("node_op","op_neq",s[s.length-3],s[s.length-1]);break;case 37:o=this.createNode("node_op","op_approx",s[s.length-3],s[s.length-1]);break;case 38:o=s[s.length-1];break;case 39:o=this.createNode("node_op","op_or",s[s.length-3],s[s.length-1]);break;case 40:o=this.createNode("node_op","op_and",s[s.length-3],s[s.length-1]);break;case 41:o=this.createNode("node_op","op_not",s[s.length-1]);break;case 42:o=s[s.length-1];break;case 43:o=this.createNode("node_op","op_sub",s[s.length-3],s[s.length-1]);break;case 44:o=this.createNode("node_op","op_add",s[s.length-3],s[s.length-1]);break;case 45:o=s[s.length-1];break;case 46:o=this.createNode("node_op","op_mul",s[s.length-3],s[s.length-1]);break;case 47:o=this.createNode("node_op","op_div",s[s.length-3],s[s.length-1]);break;case 48:o=this.createNode("node_op","op_mod",s[s.length-3],s[s.length-1]);break;case 49:o=s[s.length-1];break;case 50:o=this.createNode("node_op","op_exp",s[s.length-3],s[s.length-1]);break;case 51:o=s[s.length-1];break;case 52:o=this.createNode("node_op","op_neg",s[s.length-1]);break;case 53:o=s[s.length-1];break;case 54:o=s[s.length-1];break;case 55:o=this.createNode("node_op","op_extvalue",s[s.length-4],s[s.length-2]);break;case 56:o=this.createNode("node_op","op_execfun",s[s.length-4],s[s.length-2]);break;case 57:o=this.createNode("node_op","op_execfun",s[s.length-5],s[s.length-3],s[s.length-1]);break;case 58:o=this.createNode("node_op","op_property",s[s.length-3],s[s.length-1]);break;case 59:o=s[s.length-1];break;case 60:o=this.createNode("node_const",s[s.length-1]);break;case 61:o=this.createNode("node_const",s[s.length-1]);break;case 62:o=this.createNode("node_var",s[s.length-1]);break;case 63:o=s[s.length-2];break;case 64:o=this.createNode("node_str",s[s.length-1]);break;case 65:o=this.createNode("node_op","op_function",s[s.length-5],s[s.length-2]);break;case 66:o=this.createNode("node_op","op_proplst_val",s[s.length-2]);break;case 67:o=this.createNode("node_op","op_array",s[s.length-2]);break;case 68:o=this.createNode("node_const_bool",s[s.length-1]);break;case 69:o=this.createNode("node_const_bool",s[s.length-1]);break}for(n=0;n> "}}else{return"null"}case"string":return"'"+h.replace(/(["'])/g,"\\$1")+"'";case"number":case"boolean":return new String(h);case"null":return"null"}},toJessie:function(g){var h=this.dump(g),e=[],f;for(f=0;f0){e.push("// "+h[f].attributes.name)}e.push("s"+f+" = "+h[f].type+"("+h[f].parents.join(", ")+") "+this.toJSAN(h[f].attributes).replace(/\n/,"\\n")+";");e.push("")}return e.join("\n")},toJavaScript:function(g){var h=this.dump(g),e=[],f;for(f=0;f0){f=this.joinTransforms(i,g);h=[f[1][1],f[2][1],f[1][2],f[2][2],f[1][0],f[2][0]].join(",");k+=" matrix("+h+") ";j.setAttributeNS(null,"transform",k)}},updateImageURL:function(f){var e=JXG.evaluate(f.url);f.rendNode.setAttributeNS(this.xlinkNamespace,"xlink:href",e)},appendChildPrim:function(e,f){if(!JXG.exists(f)){f=0}else{if(f>=JXG.Options.layer.numlayers){f=JXG.Options.layer.numlayers-1}}this.layer[f].appendChild(e)},appendNodesToElement:function(e){e.rendNode=this.getElementById(e.id)},createPrim:function(e,g){var f=this.container.ownerDocument.createElementNS(this.svgNamespace,e);f.setAttributeNS(null,"id",this.container.id+"_"+g);f.style.position="absolute";if(e==="path"){f.setAttributeNS(null,"stroke-linecap","butt");f.setAttributeNS(null,"stroke-linejoin","round")}return f},remove:function(e){if(JXG.exists(e)&&JXG.exists(e.parentNode)){e.parentNode.removeChild(e)}},makeArrows:function(f){var e;if(f.visPropOld.firstarrow===f.visProp.firstarrow&&f.visPropOld.lastarrow===f.visProp.lastarrow){return}if(f.visProp.firstarrow){e=f.rendNodeTriangleStart;if(!JXG.exists(e)){e=this._createArrowHead(f,"End");this.defs.appendChild(e);f.rendNodeTriangleStart=e;f.rendNode.setAttributeNS(null,"marker-start","url(#"+this.container.id+"_"+f.id+"TriangleEnd)")}}else{e=f.rendNodeTriangleStart;if(JXG.exists(e)){this.remove(e)}}if(f.visProp.lastarrow){e=f.rendNodeTriangleEnd;if(!JXG.exists(e)){e=this._createArrowHead(f,"Start");this.defs.appendChild(e);f.rendNodeTriangleEnd=e;f.rendNode.setAttributeNS(null,"marker-end","url(#"+this.container.id+"_"+f.id+"TriangleStart)")}}else{e=f.rendNodeTriangleEnd;if(JXG.exists(e)){this.remove(e)}}f.visPropOld.firstarrow=f.visProp.firstarrow;f.visPropOld.lastarrow=f.visProp.lastarrow},updateEllipsePrim:function(f,e,i,h,g){f.setAttributeNS(null,"cx",e);f.setAttributeNS(null,"cy",i);f.setAttributeNS(null,"rx",Math.abs(h));f.setAttributeNS(null,"ry",Math.abs(g))},updateLinePrim:function(i,f,e,h,g){if(!isNaN(f+e+h+g)){i.setAttributeNS(null,"x1",f);i.setAttributeNS(null,"y1",e);i.setAttributeNS(null,"x2",h);i.setAttributeNS(null,"y2",g)}},updatePathPrim:function(e,f){if(f==""){f="M 0 0"}e.setAttributeNS(null,"d",f)},updatePathStringPoint:function(i,f,h){var g="",k=i.coords.scrCoords,j=f*Math.sqrt(3)*0.5,e=f*0.5;if(h==="x"){g=" M "+(k[1]-f)+" "+(k[2]-f)+" L "+(k[1]+f)+" "+(k[2]+f)+" M "+(k[1]+f)+" "+(k[2]-f)+" L "+(k[1]-f)+" "+(k[2]+f)}else{if(h==="+"){g=" M "+(k[1]-f)+" "+(k[2])+" L "+(k[1]+f)+" "+(k[2])+" M "+(k[1])+" "+(k[2]-f)+" L "+(k[1])+" "+(k[2]+f)}else{if(h==="<>"){g=" M "+(k[1]-f)+" "+(k[2])+" L "+(k[1])+" "+(k[2]+f)+" L "+(k[1]+f)+" "+(k[2])+" L "+(k[1])+" "+(k[2]-f)+" Z "}else{if(h==="^"){g=" M "+(k[1])+" "+(k[2]-f)+" L "+(k[1]-j)+" "+(k[2]+e)+" L "+(k[1]+j)+" "+(k[2]+e)+" Z "}else{if(h==="v"){g=" M "+(k[1])+" "+(k[2]+f)+" L "+(k[1]-j)+" "+(k[2]-e)+" L "+(k[1]+j)+" "+(k[2]-e)+" Z "}else{if(h===">"){g=" M "+(k[1]+f)+" "+(k[2])+" L "+(k[1]-e)+" "+(k[2]-j)+" L "+(k[1]-e)+" "+(k[2]+j)+" Z "}else{if(h==="<"){g=" M "+(k[1]-f)+" "+(k[2])+" L "+(k[1]+e)+" "+(k[2]-j)+" L "+(k[1]+e)+" "+(k[2]+j)+" Z "}}}}}}}return g},updatePathStringPrim:function(e){var g=" M ",h=" L ",f=g,n=5000,k="",j,m,o=(e.visProp.curvetype!=="plot"),l;if(e.numberPoints<=0){return""}if(o&&e.board.options.curve.RDPsmoothing){e.points=JXG.Math.Numerics.RamerDouglasPeuker(e.points,0.5)}l=Math.min(e.points.length,e.numberPoints);for(j=0;jn){m[1]=n}else{if(m[1]<-n){m[1]=-n}}if(m[2]>n){m[2]=n}else{if(m[2]<-n){m[2]=-n}}k+=[f,m[1]," ",m[2]].join("");f=h}}return k},updatePathStringBezierPrim:function(g){var l=" M ",m=" C ",k=l,u=5000,p="",o,n,s,h,e,r=g.visProp.strokewidth,t=(g.visProp.curvetype!=="plot"),q;if(g.numberPoints<=0){return""}if(t&&g.board.options.curve.RDPsmoothing){g.points=JXG.Math.Numerics.RamerDouglasPeuker(g.points,0.5)}q=Math.min(g.points.length,g.numberPoints);for(n=1;n<3;n++){k=l;for(o=0;ou){s[1]=u}else{if(s[1]<-u){s[1]=-u}}if(s[2]>u){s[2]=u}else{if(s[2]<-u){s[2]=-u}}if(k==l){p+=[k,s[1]+0*r*(2*n*Math.random()-n)," ",s[2]+0*r*(2*n*Math.random()-n)].join("")}else{p+=[k,(h+(s[1]-h)*0.333+r*(2*n*Math.random()-n))," ",(e+(s[2]-e)*0.333+r*(2*n*Math.random()-n))," ",(h+2*(s[1]-h)*0.333+r*(2*n*Math.random()-n))," ",(e+2*(s[2]-e)*0.333+r*(2*n*Math.random()-n))," ",s[1]," ",s[2]].join("")}k=m;h=s[1];e=s[2]}}}return p},updatePolygonPrim:function(j,h){var k="",f,g,e=h.vertices.length;j.setAttributeNS(null,"stroke","none");for(g=0;g0){f.setAttributeNS(null,"stroke-dasharray",this.dashArray[g-1])}else{if(f.hasAttributeNS(null,"stroke-dasharray")){f.removeAttributeNS(null,"stroke-dasharray")}}},setGradient:function(g){var o=g.rendNode,h,j,i,n,m,f,e,l,k;j=JXG.evaluate(g.visProp.fillopacity);j=(j>0)?j:0;h=JXG.evaluate(g.visProp.fillcolor);if(g.visProp.gradient==="linear"){i=this.createPrim("linearGradient",g.id+"_gradient");f="0%";e="100%";l="0%";k="0%";i.setAttributeNS(null,"x1",f);i.setAttributeNS(null,"x2",e);i.setAttributeNS(null,"y1",l);i.setAttributeNS(null,"y2",k);n=this.createPrim("stop",g.id+"_gradient1");n.setAttributeNS(null,"offset","0%");n.setAttributeNS(null,"style","stop-color:"+h+";stop-opacity:"+j);m=this.createPrim("stop",g.id+"_gradient2");m.setAttributeNS(null,"offset","100%");m.setAttributeNS(null,"style","stop-color:"+g.visProp.gradientsecondcolor+";stop-opacity:"+g.visProp.gradientsecondopacity);i.appendChild(n);i.appendChild(m);this.defs.appendChild(i);o.setAttributeNS(null,"style","fill:url(#"+this.container.id+"_"+g.id+"_gradient)");g.gradNode1=n;g.gradNode2=m}else{if(g.visProp.gradient==="radial"){i=this.createPrim("radialGradient",g.id+"_gradient");i.setAttributeNS(null,"cx","50%");i.setAttributeNS(null,"cy","50%");i.setAttributeNS(null,"r","50%");i.setAttributeNS(null,"fx",g.visProp.gradientpositionx*100+"%");i.setAttributeNS(null,"fy",g.visProp.gradientpositiony*100+"%");n=this.createPrim("stop",g.id+"_gradient1");n.setAttributeNS(null,"offset","0%");n.setAttributeNS(null,"style","stop-color:"+g.visProp.gradientsecondcolor+";stop-opacity:"+g.visProp.gradientsecondopacity);m=this.createPrim("stop",g.id+"_gradient2");m.setAttributeNS(null,"offset","100%");m.setAttributeNS(null,"style","stop-color:"+h+";stop-opacity:"+j);i.appendChild(n);i.appendChild(m);this.defs.appendChild(i);o.setAttributeNS(null,"style","fill:url(#"+this.container.id+"_"+g.id+"_gradient)");g.gradNode1=n;g.gradNode2=m}else{o.removeAttributeNS(null,"style")}}},updateGradient:function(h){var f=h.gradNode1,e=h.gradNode2,g,i;if(!JXG.exists(f)||!JXG.exists(e)){return}i=JXG.evaluate(h.visProp.fillopacity);i=(i>0)?i:0;g=JXG.evaluate(h.visProp.fillcolor);if(h.visProp.gradient==="linear"){f.setAttributeNS(null,"style","stop-color:"+g+";stop-opacity:"+i);e.setAttributeNS(null,"style","stop-color:"+h.visProp.gradientsecondcolor+";stop-opacity:"+h.visProp.gradientsecondopacity)}else{if(h.visProp.gradient==="radial"){f.setAttributeNS(null,"style","stop-color:"+h.visProp.gradientsecondcolor+";stop-opacity:"+h.visProp.gradientsecondopacity);e.setAttributeNS(null,"style","stop-color:"+g+";stop-opacity:"+i)}}},setObjectFillColor:function(f,i,k){var g,h=JXG.evaluate(i),l,m,e=JXG.evaluate(k),j;e=(e>0)?e:0;if(f.visPropOld.fillcolor===h&&f.visPropOld.fillopacity===e){return}if(JXG.exists(h)&&h!==false){if(h.length!=9){l=h;j=e}else{m=JXG.rgba2rgbo(h);l=m[0];j=e*m[1]}g=f.rendNode;g.setAttributeNS(null,"fill",l);if(f.type===JXG.OBJECT_TYPE_IMAGE){g.setAttributeNS(null,"opacity",j)}else{g.setAttributeNS(null,"fill-opacity",j)}if(JXG.exists(f.visProp.gradient)){this.updateGradient(f)}}f.visPropOld.fillcolor=h;f.visPropOld.fillopacity=e},setObjectStrokeColor:function(f,i,j){var h=JXG.evaluate(i),l,m,e=JXG.evaluate(j),k,g;e=(e>0)?e:0;if(f.visPropOld.strokecolor===h&&f.visPropOld.strokeopacity===e){return}if(JXG.exists(h)&&h!==false){if(h.length!=9){l=h;k=e}else{m=JXG.rgba2rgbo(h);l=m[0];k=e*m[1]}g=f.rendNode;if(f.type===JXG.OBJECT_TYPE_TEXT){if(f.visProp.display==="html"){g.style.color=l;g.style.opacity=k}else{g.setAttributeNS(null,"style","fill:"+l);g.setAttributeNS(null,"style","fill-opacity:"+k)}}else{g.setAttributeNS(null,"stroke",l);g.setAttributeNS(null,"stroke-opacity",k)}if(f.type===JXG.OBJECT_TYPE_ARROW){this._setArrowAtts(f.rendNodeTriangle,l,k)}else{if(f.elementClass===JXG.OBJECT_CLASS_CURVE||f.elementClass===JXG.OBJECT_CLASS_LINE){if(f.visProp.firstarrow){this._setArrowAtts(f.rendNodeTriangleStart,l,k)}if(f.visProp.lastarrow){this._setArrowAtts(f.rendNodeTriangleEnd,l,k)}}}}f.visPropOld.strokecolor=h;f.visPropOld.strokeopacity=e},setObjectStrokeWidth:function(g,f){var e=JXG.evaluate(f),h;if(g.visPropOld.strokewidth===e){return}h=g.rendNode;this.setPropertyPrim(h,"stroked","true");if(JXG.exists(e)){this.setPropertyPrim(h,"stroke-width",e+"px")}g.visPropOld.strokewidth=e},setShadow:function(e){if(e.visPropOld.shadow===e.visProp.shadow){return}if(JXG.exists(e.rendNode)){if(e.visProp.shadow){e.rendNode.setAttributeNS(null,"filter","url(#"+this.container.id+"_f1)")}else{e.rendNode.removeAttributeNS(null,"filter")}}e.visPropOld.shadow=e.visProp.shadow},suspendRedraw:function(){},unsuspendRedraw:function(){},resize:function(e,f){this.svgRoot.style.width=parseFloat(e)+"px";this.svgRoot.style.height=parseFloat(f)+"px"}});JXG.VMLRenderer=function(f){this.type="vml";this.container=f;this.container.style.overflow="hidden";this.container.onselectstart=function(){return false};this.resolution=10;if(!JXG.exists(JXG.vmlStylesheet)){f.ownerDocument.namespaces.add("jxgvml","urn:schemas-microsoft-com:vml");JXG.vmlStylesheet=this.container.ownerDocument.createStyleSheet();JXG.vmlStylesheet.addRule(".jxgvml","behavior:url(#default#VML)")}try{!f.ownerDocument.namespaces.jxgvml&&f.ownerDocument.namespaces.add("jxgvml","urn:schemas-microsoft-com:vml");this.createNode=function(e){return f.ownerDocument.createElement("')}}catch(g){this.createNode=function(e){return f.ownerDocument.createElement("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="jxgvml">')}}this.dashArray=["Solid","1 1","ShortDash","Dash","LongDash","ShortDashDot","LongDashDot"]};JXG.VMLRenderer.prototype=new JXG.AbstractRenderer();JXG.extend(JXG.VMLRenderer.prototype,{_setAttr:function(h,g,j,f){try{if(document.documentMode===8){h[g]=j}else{h.setAttribute(g,j,f)}}catch(i){JXG.debug("_setAttr: "+g+" "+j+"
\n")}},updateTicks:function(j,k,f,l,h){var g=[],m,n,o,p,e=this.resolution;n=j.ticks.length;for(m=0;m0){r=h.rendNode.style.filter.toString();if(!r.match(/DXImageTransform/)){k.style.filter="progid:DXImageTransform.Microsoft.Matrix(M11='1.0', sizingMethod='auto expand') "+r}l=this.joinTransforms(h,u);g[0]=JXG.Math.matVecMult(l,h.coords.scrCoords);g[0][1]/=g[0][0];g[0][2]/=g[0][0];g[1]=JXG.Math.matVecMult(l,[1,h.coords.scrCoords[1]+h.size[0],h.coords.scrCoords[2]]);g[1][1]/=g[1][0];g[1][2]/=g[1][0];g[2]=JXG.Math.matVecMult(l,[1,h.coords.scrCoords[1]+h.size[0],h.coords.scrCoords[2]-h.size[1]]);g[2][1]/=g[2][0];g[2][2]/=g[2][0];g[3]=JXG.Math.matVecMult(l,[1,h.coords.scrCoords[1],h.coords.scrCoords[2]-h.size[1]]);g[3][1]/=g[3][0];g[3][2]/=g[3][0];f=g[0][1];n=g[0][1];e=g[0][2];j=g[0][2];for(o=1;o<4;o++){f=Math.max(f,g[o][1]);n=Math.min(n,g[o][1]);e=Math.max(e,g[o][2]);j=Math.min(j,g[o][2])}k.style.left=parseInt(n)+"px";k.style.top=parseInt(j)+"px";k.filters.item(0).M11=l[1][1];k.filters.item(0).M12=l[1][2];k.filters.item(0).M21=l[2][1];k.filters.item(0).M22=l[2][2]}},updateImageURL:function(f){var e=JXG.evaluate(f.url);this._setAttr(f.rendNode,"src",e)},appendChildPrim:function(e,f){if(!JXG.exists(f)){f=0}e.style.zIndex=f;this.container.appendChild(e)},appendNodesToElement:function(e,f){if(f==="shape"||f==="path"||f==="polygon"){e.rendNodePath=this.getElementById(e.id+"_path")}e.rendNodeFill=this.getElementById(e.id+"_fill");e.rendNodeStroke=this.getElementById(e.id+"_stroke");e.rendNodeShadow=this.getElementById(e.id+"_shadow");e.rendNode=this.getElementById(e.id)},createPrim:function(f,k){var g,e=this.createNode("fill"),j=this.createNode("stroke"),i=this.createNode("shadow"),h;this._setAttr(e,"id",this.container.id+"_"+k+"_fill");this._setAttr(j,"id",this.container.id+"_"+k+"_stroke");this._setAttr(i,"id",this.container.id+"_"+k+"_shadow");if(f==="circle"||f==="ellipse"){g=this.createNode("oval");g.appendChild(e);g.appendChild(j);g.appendChild(i)}else{if(f==="polygon"||f==="path"||f==="shape"||f==="line"){g=this.createNode("shape");g.appendChild(e);g.appendChild(j);g.appendChild(i);h=this.createNode("path");this._setAttr(h,"id",this.container.id+"_"+k+"_path");g.appendChild(h)}else{g=this.createNode(f);g.appendChild(e);g.appendChild(j);g.appendChild(i)}}g.style.position="absolute";g.style.left="0px";g.style.top="0px";this._setAttr(g,"id",this.container.id+"_"+k);return g},remove:function(e){if(JXG.exists(e)){e.removeNode(true)}},makeArrows:function(f){var e;if(f.visPropOld.firstarrow===f.visProp.firstarrow&&f.visPropOld.lastarrow===f.visProp.lastarrow){return}if(f.visProp.firstarrow){e=f.rendNodeStroke;this._setAttr(e,"startarrow","block");this._setAttr(e,"startarrowlength","long")}else{e=f.rendNodeStroke;if(JXG.exists(e)){this._setAttr(e,"startarrow","none")}}if(f.visProp.lastarrow){e=f.rendNodeStroke;this._setAttr(e,"id",this.container.id+"_"+f.id+"stroke");this._setAttr(e,"endarrow","block");this._setAttr(e,"endarrowlength","long")}else{e=f.rendNodeStroke;if(JXG.exists(e)){this._setAttr(e,"endarrow","none")}}f.visPropOld.firstarrow=f.visProp.firstarrow;f.visPropOld.lastarrow=f.visProp.lastarrow},updateEllipsePrim:function(f,e,i,h,g){f.style.left=parseInt(e-h)+"px";f.style.top=parseInt(i-g)+"px";f.style.width=parseInt(Math.abs(h)*2)+"px";f.style.height=parseInt(Math.abs(g)*2)+"px"},updateLinePrim:function(l,f,e,h,g,j){var i,k=this.resolution;if(!isNaN(f+e+h+g)){i=["m ",parseInt(k*f),", ",parseInt(k*e)," l ",parseInt(k*h),", ",parseInt(k*g)];this.updatePathPrim(l,i,j)}},updatePathPrim:function(g,h,f){var e=f.canvasWidth,i=f.canvasHeight;if(h.length<=0){h=["m 0,0"]}g.style.width=e;g.style.height=i;this._setAttr(g,"coordsize",[parseInt(this.resolution*e),parseInt(this.resolution*i)].join(","));this._setAttr(g,"path",h.join(""))},updatePathStringPoint:function(f,l,i){var k=[],g=Math.round,h=f.coords.scrCoords,j=l*Math.sqrt(3)*0.5,m=l*0.5,e=this.resolution;if(i==="x"){k.push([" m ",g(e*(h[1]-l)),", ",g(e*(h[2]-l))," l ",g(e*(h[1]+l)),", ",g(e*(h[2]+l))," m ",g(e*(h[1]+l)),", ",g(e*(h[2]-l))," l ",g(e*(h[1]-l)),", ",g(e*(h[2]+l))].join(""))}else{if(i==="+"){k.push([" m ",g(e*(h[1]-l)),", ",g(e*(h[2]))," l ",g(e*(h[1]+l)),", ",g(e*(h[2]))," m ",g(e*(h[1])),", ",g(e*(h[2]-l))," l ",g(e*(h[1])),", ",g(e*(h[2]+l))].join(""))}else{if(i==="<>"){k.push([" m ",g(e*(h[1]-l)),", ",g(e*(h[2]))," l ",g(e*(h[1])),", ",g(e*(h[2]+l))," l ",g(e*(h[1]+l)),", ",g(e*(h[2]))," l ",g(e*(h[1])),", ",g(e*(h[2]-l))," x e "].join(""))}else{if(i==="^"){k.push([" m ",g(e*(h[1])),", ",g(e*(h[2]-l))," l ",g(e*(h[1]-j)),", ",g(e*(h[2]+m))," l ",g(e*(h[1]+j)),", ",g(e*(h[2]+m))," x e "].join(""))}else{if(i==="v"){k.push([" m ",g(e*(h[1])),", ",g(e*(h[2]+l))," l ",g(e*(h[1]-j)),", ",g(e*(h[2]-m))," l ",g(e*(h[1]+j)),", ",g(e*(h[2]-m))," x e "].join(""))}else{if(i===">"){k.push([" m ",g(e*(h[1]+l)),", ",g(e*(h[2]))," l ",g(e*(h[1]-m)),", ",g(e*(h[2]-j))," l ",g(e*(h[1]-m)),", ",g(e*(h[2]+j))," l ",g(e*(h[1]+l)),", ",g(e*(h[2]))].join(""))}else{if(i==="<"){k.push([" m ",g(e*(h[1]-l)),", ",g(e*(h[2]))," l ",g(e*(h[1]+m)),", ",g(e*(h[2]-j))," l ",g(e*(h[1]+m)),", ",g(e*(h[2]+j))," x e "].join(""))}}}}}}}return k},updatePathStringPrim:function(f){var m=[],l,o,e=this.resolution,k=Math.round,h=" m ",j=" l ",g=h,p=(f.visProp.curvetype!=="plot"),n=Math.min(f.numberPoints,8192);if(f.numberPoints<=0){return""}if(p&&f.board.options.curve.RDPsmoothing){f.points=JXG.Math.Numerics.RamerDouglasPeuker(f.points,1)}n=Math.min(n,f.points.length);for(l=0;l20000){o[1]=20000}else{if(o[1]<-20000){o[1]=-20000}}if(o[2]>20000){o[2]=20000}else{if(o[2]<-20000){o[2]=-20000}}m.push([g,k(e*o[1]),", ",k(e*o[2])].join(""));g=j}}m.push(" e");return m},updatePathStringBezierPrim:function(h){var s=[],q,p,v,l,g,u=h.visProp.strokewidth,e=this.resolution,o=Math.round,m=" m ",n=" c ",k=m,w=(h.visProp.curvetype!=="plot"),t=Math.min(h.numberPoints,8192);if(h.numberPoints<=0){return""}if(w&&h.board.options.curve.RDPsmoothing){h.points=JXG.Math.Numerics.RamerDouglasPeuker(h.points,1)}t=Math.min(t,h.points.length);for(p=1;p<3;p++){k=m;for(q=0;q20000){v[1]=20000}else{if(v[1]<-20000){v[1]=-20000}}if(v[2]>20000){v[2]=20000}else{if(v[2]<-20000){v[2]=-20000}}if(k==m){s.push([k,o(e*(v[1]+0*u*(2*p*Math.random()-p)))," ",o(e*(v[2]+0*u*(2*p*Math.random()-p)))].join(""))}else{s.push([k,o(e*(l+(v[1]-l)*0.333+u*(2*p*Math.random()-p)))," ",o(e*(g+(v[2]-g)*0.333+u*(2*p*Math.random()-p)))," ",o(e*(l+2*(v[1]-l)*0.333+u*(2*p*Math.random()-p)))," ",o(e*(g+2*(v[2]-g)*0.333+u*(2*p*Math.random()-p)))," ",o(e*v[1])," ",o(e*v[2])].join(""))}k=n;l=v[1];g=v[2]}}}s.push(" e");return s},updatePolygonPrim:function(j,g){var f,e=g.vertices.length,h=this.resolution,k,l=[];this._setAttr(j,"stroked","false");k=g.vertices[0].coords.scrCoords;if(isNaN(k[1]+k[2])){return}l.push(["m ",parseInt(h*k[1]),",",parseInt(h*k[2])," l "].join(""));for(f=1;f=0){i.style.width=f+"px"}if(g>=0){i.style.height=g+"px"}},setPropertyPrim:function(h,g,i){var f="",e;switch(g){case"stroke":f="strokecolor";break;case"stroke-width":f="strokeweight";break;case"stroke-dasharray":f="dashstyle";break}if(f!==""){e=JXG.evaluate(i);this._setAttr(h,f,e)}},show:function(e){if(e&&e.rendNode){e.rendNode.style.visibility="inherit"}},hide:function(e){if(e&&e.rendNode){e.rendNode.style.visibility="hidden"}},setDashStyle:function(f,e){var g;if(e.dash>=0){g=f.rendNodeStroke;this._setAttr(g,"dashstyle",this.dashArray[e.dash])}},setGradient:function(f){var e=f.rendNodeFill;if(f.visProp.gradient==="linear"){this._setAttr(e,"type","gradient");this._setAttr(e,"color2",f.visProp.gradientsecondcolor);this._setAttr(e,"opacity2",f.visProp.gradientsecondopacity);this._setAttr(e,"angle",f.visProp.gradientangle)}else{if(f.visProp.gradient==="radial"){this._setAttr(e,"type","gradientradial");this._setAttr(e,"color2",f.visProp.gradientsecondcolor);this._setAttr(e,"opacity2",f.visProp.gradientsecondopacity);this._setAttr(e,"focusposition",f.visProp.gradientpositionx*100+"%,"+f.visProp.gradientpositiony*100+"%");this._setAttr(e,"focussize","0,0")}else{this._setAttr(e,"type","solid")}}},setObjectFillColor:function(f,i,j){var h=JXG.evaluate(i),l,m,e=JXG.evaluate(j),k,g=f.rendNode,n;e=(e>0)?e:0;if(f.visPropOld.fillcolor===h&&f.visPropOld.fillopacity===e){return}if(JXG.exists(h)&&h!==false){if(h.length!=9){l=h;k=e}else{m=JXG.rgba2rgbo(h);l=m[0];k=e*m[1]}if(l==="none"||l===false){this._setAttr(f.rendNode,"filled","false")}else{this._setAttr(f.rendNode,"filled","true");this._setAttr(f.rendNode,"fillcolor",l);if(JXG.exists(k)&&f.rendNodeFill){this._setAttr(f.rendNodeFill,"opacity",(k*100)+"%")}}if(f.type===JXG.OBJECT_TYPE_IMAGE){n=f.rendNode.style.filter.toString();if(n.match(/alpha/)){f.rendNode.style.filter=n.replace(/alpha\(opacity *= *[0-9\.]+\)/,"alpha(opacity = "+(k*100)+")")}else{f.rendNode.style.filter+=" alpha(opacity = "+(k*100)+")"}}}f.visPropOld.fillcolor=h;f.visPropOld.fillopacity=e},setObjectStrokeColor:function(g,j,k){var i=JXG.evaluate(j),m,n,f=JXG.evaluate(k),l,h=g.rendNode,e;f=(f>0)?f:0;if(g.visPropOld.strokecolor===i&&g.visPropOld.strokeopacity===f){return}if(JXG.exists(i)&&i!==false){if(i.length!=9){m=i;l=f}else{n=JXG.rgba2rgbo(i);m=n[0];l=f*n[1]}if(g.type===JXG.OBJECT_TYPE_TEXT){l=Math.round(l*100);h.style.filter=" alpha(opacity = "+l+")";h.style.color=m}else{if(m!==false){this._setAttr(h,"stroked","true");this._setAttr(h,"strokecolor",m)}e=g.rendNodeStroke;if(JXG.exists(l)&&g.type!==JXG.OBJECT_TYPE_IMAGE){this._setAttr(e,"opacity",(l*100)+"%")}}}g.visPropOld.strokecolor=i;g.visPropOld.strokeopacity=f},setObjectStrokeWidth:function(g,f){var e=JXG.evaluate(f),h;if(g.visPropOld.strokewidth===e){return}h=g.rendNode;this.setPropertyPrim(h,"stroked","true");if(JXG.exists(e)){this.setPropertyPrim(h,"stroke-width",e)}g.visPropOld.strokewidth=e},setShadow:function(e){var f=e.rendNodeShadow;if(!f||e.visPropOld.shadow===e.visProp.shadow){return}if(e.visProp.shadow){this._setAttr(f,"On","True");this._setAttr(f,"Offset","3pt,3pt");this._setAttr(f,"Opacity","60%");this._setAttr(f,"Color","#aaaaaa")}else{this._setAttr(f,"On","False")}e.visPropOld.shadow=e.visProp.shadow},suspendRedraw:function(){this.container.style.display="none"},unsuspendRedraw:function(){this.container.style.display=""}});JXG.CanvasRenderer=function(e){var f;this.type="canvas";this.canvasRoot=null;this.suspendHandle=null;this.canvasId=JXG.Util.genUUID();this.canvasNamespace=null;this.container=e;this.container.style.MozUserSelect="none";this.container.style.overflow="hidden";if(this.container.style.position===""){this.container.style.position="relative"}this.container.innerHTML=['<',"/canvas>"].join("");this.canvasRoot=document.getElementById(this.canvasId);this.context=this.canvasRoot.getContext("2d");this.dashArray=[[2,2],[5,5],[10,10],[20,20],[20,10,10,10],[20,5,10,5]]};JXG.CanvasRenderer.prototype=new JXG.AbstractRenderer();JXG.extend(JXG.CanvasRenderer.prototype,{_drawFilledPolygon:function(f){var h,e=f.length,g=this.context;if(e>0){g.beginPath();g.moveTo(f[0][0],f[0][1]);for(h=0;h0){g.lineTo(f[h][0],f[h][1])}}g.lineTo(f[0][0],f[0][1]);g.fill()}},_fill:function(f){var e=this.context;e.save();if(this._setColor(f,"fill")){e.fill()}e.restore()},_rotatePoint:function(f,e,g){return[(e*Math.cos(f))-(g*Math.sin(f)),(e*Math.sin(f))+(g*Math.cos(f))]},_rotateShape:function(f,h){var g,j=[],e=f.length;if(e<=0){return f}for(g=0;g0)?g:0;if(i.length!=9){m=i;l=g}else{p=JXG.rgba2rgbo(i);m=p[0];l=g*p[1]}this.context.globalAlpha=l;this.context[e+"Style"]=m}else{k=false}if(n==="stroke"){this.context.lineWidth=parseFloat(q.strokewidth)}return k},_stroke:function(f){var e=this.context;e.save();if(f.visProp.dash>0){if(e.setLineDash){e.setLineDash(this.dashArray[f.visProp.dash])}}else{this.context.lineDashArray=[]}if(this._setColor(f,"stroke")){e.stroke()}e.restore()},_translateShape:function(g,f,k){var h,j=[],e=g.length;if(e<=0){return g}for(h=0;h":h.beginPath();h.moveTo(m[1]-i,m[2]);h.lineTo(m[1],m[2]+i);h.lineTo(m[1]+i,m[2]);h.lineTo(m[1],m[2]-i);h.closePath();this._fill(j);this._stroke(j);break;case"triangleup":case"a":case"^":h.beginPath();h.moveTo(m[1],m[2]-i);h.lineTo(m[1]-l,m[2]+e);h.lineTo(m[1]+l,m[2]+e);h.closePath();this._fill(j);this._stroke(j);break;case"triangledown":case"v":h.beginPath();h.moveTo(m[1],m[2]+i);h.lineTo(m[1]-l,m[2]-e);h.lineTo(m[1]+l,m[2]-e);h.closePath();this._fill(j);this._stroke(j);break;case"triangleleft":case"<":h.beginPath();h.moveTo(m[1]-i,m[2]);h.lineTo(m[1]+e,m[2]-l);h.lineTo(m[1]+e,m[2]+l);h.closePath();this.fill(j);this._stroke(j);break;case"triangleright":case">":h.beginPath();h.moveTo(m[1]+i,m[2]);h.lineTo(m[1]-e,m[2]-l);h.lineTo(m[1]-e,m[2]+l);h.closePath();this._fill(j);this._stroke(j);break}},updatePoint:function(e){this.drawPoint(e)},drawLine:function(e){var g=new JXG.Coords(JXG.COORDS_BY_USER,e.point1.coords.usrCoords,e.board),f=new JXG.Coords(JXG.COORDS_BY_USER,e.point2.coords.usrCoords,e.board);JXG.Math.Geometry.calcStraight(e,g,f);this.context.beginPath();this.context.moveTo(g.scrCoords[1],g.scrCoords[2]);this.context.lineTo(f.scrCoords[1],f.scrCoords[2]);this._stroke(e);this.makeArrows(e,g,f)},updateLine:function(e){this.drawLine(e)},drawTicks:function(){},updateTicks:function(h,j,f,k,g){var l,n,m=h.ticks.length,e=this.context;e.beginPath();for(l=0;l0&&t>0&&!isNaN(f+e)){h.beginPath();h.moveTo(j,k);h.bezierCurveTo(j,k-s,l-v,i,l,i);h.bezierCurveTo(l+v,i,q,k-s,q,k);h.bezierCurveTo(q,k+s,l+v,p,l,p);h.bezierCurveTo(l-v,p,j,k+s,j,k);h.closePath();this._fill(g);this._stroke(g)}},updateEllipse:function(e){return this.drawEllipse(e)},displayCopyright:function(g,f){var e=this.context;e.save();e.font=f+"px Arial";e.fillStyle="#aaa";e.lineWidth=0.5;e.fillText(g,10,2+f);e.restore()},drawInternalText:function(g){var e,f=this.context;f.save();if(this._setColor(g,"stroke","fill")&&!isNaN(g.coords.scrCoords[1]+g.coords.scrCoords[2])){if(g.visProp.fontsize){if(typeof g.visProp.fontsize==="function"){e=g.visProp.fontsize();f.font=(e>0?e:0)+"px Arial"}else{f.font=(g.visProp.fontsize)+"px Arial"}}this.transformImage(g,g.transformations);f.fillText(g.plaintext,g.coords.scrCoords[1],g.coords.scrCoords[2])}f.restore();return null},updateInternalText:function(e){this.drawInternalText(e)},setObjectStrokeColor:function(f,i,j){var h=JXG.evaluate(i),l,m,e=JXG.evaluate(j),k,g;e=(e>0)?e:0;if(f.visPropOld.strokecolor===h&&f.visPropOld.strokeopacity===e){return}if(JXG.exists(h)&&h!==false){if(h.length!=9){l=h;k=e}else{m=JXG.rgba2rgbo(h);l=m[0];k=e*m[1]}g=f.rendNode;if(f.type===JXG.OBJECT_TYPE_TEXT&&f.visProp.display==="html"){g.style.color=l;g.style.opacity=k}}f.visPropOld.strokecolor=h;f.visPropOld.strokeopacity=e},drawImage:function(e){e.rendNode=new Image();e._src="";this.updateImage(e)},updateImage:function(f){var e=this.context,g=JXG.evaluate(f.visProp.fillopacity),h=JXG.bind(function(){f.imgIsLoaded=true;if(f.size[0]<=0||f.size[1]<=0){return}e.save();e.globalAlpha=g;this.transformImage(f,f.transformations);e.drawImage(f.rendNode,f.coords.scrCoords[1],f.coords.scrCoords[2]-f.size[1],f.size[0],f.size[1]);e.restore()},this);if(this.updateImageURL(f)){f.rendNode.onload=h}else{if(f.imgIsLoaded){h()}}},transformImage:function(i,h){var f,e=h.length,g=this.context;if(e>0){f=this.joinTransforms(i,h);if(Math.abs(JXG.Math.Numerics.det(f))>=JXG.Math.eps){g.transform(f[1][1],f[2][1],f[1][2],f[2][2],f[1][0],f[2][0])}}},updateImageURL:function(f){var e;e=JXG.evaluate(f.url);if(f._src!==e){f.imgIsLoaded=false;f.rendNode.src=e;f._src=e;return true}return false},remove:function(e){if(JXG.exists(e)&&JXG.exists(e.parentNode)){e.parentNode.removeChild(e)}},makeArrows:function(i,m,k){var g=[[2,0],[-10,-4],[-10,4]],o=[[-2,0],[10,-4],[10,4]],h,n,e,l,j,f=this.context;if(i.visProp.strokecolor!=="none"&&(i.visProp.lastarrow||i.visProp.firstarrow)){if(i.elementClass===JXG.OBJECT_CLASS_LINE){h=m.scrCoords[1];n=m.scrCoords[2];e=k.scrCoords[1];l=k.scrCoords[2]}else{return}f.save();if(this._setColor(i,"stroke","fill")){j=Math.atan2(l-n,e-h);if(i.visProp.lastarrow){this._drawFilledPolygon(this._translateShape(this._rotateShape(g,j),e,l))}if(i.visProp.firstarrow){this._drawFilledPolygon(this._translateShape(this._rotateShape(o,j),h,n))}}f.restore()}},updatePathStringPrim:function(f){var h="M",j="L",g=h,n=5000,k,m,o=(f.visProp.curvetype!=="plot"),l,e=this.context;if(f.numberPoints<=0){return}if(o&&f.board.options.curve.RDPsmoothing){f.points=JXG.Math.Numerics.RamerDouglasPeuker(f.points,0.5)}l=Math.min(f.points.length,f.numberPoints);e.beginPath();for(k=0;kn){m[1]=n}else{if(m[1]<-n){m[1]=-n}}if(m[2]>n){m[2]=n}else{if(m[2]<-n){m[2]=-n}}if(g===h){e.moveTo(m[1],m[2])}else{e.lineTo(m[1],m[2])}g=j}}this._fill(f);this._stroke(f)},updatePathStringBezierPrim:function(h){var m="M",n="C",l=m,u=5000,p,o,s,k,g,r=h.visProp.strokewidth,t=(h.visProp.curvetype!=="plot"),q,e=this.context;if(h.numberPoints<=0){return}if(t&&h.board.options.curve.RDPsmoothing){h.points=JXG.Math.Numerics.RamerDouglasPeuker(h.points,0.5)}q=Math.min(h.points.length,h.numberPoints);e.beginPath();for(o=1;o<3;o++){l=m;for(p=0;pu){s[1]=u}else{if(s[1]<-u){s[1]=-u}}if(s[2]>u){s[2]=u}else{if(s[2]<-u){s[2]=-u}}if(l==m){e.moveTo(s[1]+0*r*(2*o*Math.random()-o),s[2]+0*r*(2*o*Math.random()-o))}else{e.bezierCurveTo((k+(s[1]-k)*0.333+r*(2*o*Math.random()-o)),(g+(s[2]-g)*0.333+r*(2*o*Math.random()-o)),(k+2*(s[1]-k)*0.333+r*(2*o*Math.random()-o)),(g+2*(s[2]-g)*0.333+r*(2*o*Math.random()-o)),s[1],s[2])}l=n;k=s[1];g=s[2]}}}this._fill(h);this._stroke(h)},updatePolygonPrim:function(k,j){var f,h,e=j.vertices.length,g=this.context;if(e<=0){return}g.beginPath();f=j.vertices[0].coords.scrCoords;g.moveTo(f[1],f[2]);for(h=1;h0)?g:0;e=JXG.evaluate(f.visProp.fillcolor)},setShadow:function(e){if(e.visPropOld.shadow===e.visProp.shadow){return}e.visPropOld.shadow=e.visProp.shadow},highlight:function(e){e.board.prepareUpdate();e.board.renderer.suspendRedraw(e.board);e.board.updateRenderer();e.board.renderer.unsuspendRedraw();return this},noHighlight:function(e){e.board.prepareUpdate();e.board.renderer.suspendRedraw(e.board);e.board.updateRenderer();e.board.renderer.unsuspendRedraw();return this},suspendRedraw:function(e){this.context.save();this.context.clearRect(0,0,this.canvasRoot.width,this.canvasRoot.height);if(e&&e.showCopyright){this.displayCopyright(JXG.JSXGraph.licenseText,12)}},unsuspendRedraw:function(){this.context.restore()},resize:function(e,f){this.canvasRoot.style.width=parseFloat(e)+"px";this.canvasRoot.style.height=parseFloat(f)+"px";this.canvasRoot.setAttribute("width",parseFloat(e)+"px");this.canvasRoot.setAttribute("height",parseFloat(f)+"px")}}); \ No newline at end of file diff --git a/ajax/libs/jsxgraph/latest/GeogebraReader.js b/ajax/libs/jsxgraph/latest/GeogebraReader.js new file mode 100644 index 000000000..4d8a0cc33 --- /dev/null +++ b/ajax/libs/jsxgraph/latest/GeogebraReader.js @@ -0,0 +1,2800 @@ + JXG.GeogebraReader = new function() { +/** + * @param {String} type the type of expression + * @param {String} m first input value + * @param {String} n second input value + * @return {String} return the object, string or calculated value + */ +this.ggbAct = function(type, m, n) { + var v1 = m, v2 = n, s1, s2, a; + switch(type.toLowerCase()) { + case 'end': + // JXG.debug("end: "+ v1); + return v1; + break; + case 'coord': + s1 = (JXG.GeogebraReader.board.ggbElements[v1]) ? 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'")' : v1; + s2 = (JXG.GeogebraReader.board.ggbElements[v2]) ? 'JXG.getRef(JXG.GeogebraReader.board, "'+ v2 +'")' : v2; + return [s1, s2]; + break; + case 'le': // smaller then + return '( ('+ v1 +') <= ('+ v2 +') )'; + break; + case 'ge': // greater then + return '( ('+ v1 +') >= ('+ v2 +') )'; + break; + case 'eq': // equal + return '( ('+ v1 +') == ('+ v2 +') )'; + break; + case 'neq': // not equal + return '( ('+ v1 +') != ('+ v2 +') )'; + break; + case 'lt': // smaller + return '( ('+ v1 +') < ('+ v2 +') )'; + break; + case 'gt': // greater + return '( ('+ v1 +') > ('+ v2 +') )'; + break; + case 'add': + if (JXG.GeogebraReader.isGGBVector(v1) && JXG.GeogebraReader.isGGBVector(v2)){ //Add: Vector + Vector + return [1, v1[1] + '+' + v2[1], v1[2] + '+' + v2[2]]; + } + if( JXG.isString(v1) && !v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v1.match(/JXG\.getRef/) ) { + s1 = [v1+'.X()', v1+'.Y()']; + } else { + s1 = v1; + } + + if( JXG.isString(v2) && !v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v2.match(/JXG\.getRef/) ) { + s2 = [v2+'.X()', v2+'.Y()']; + } else { + s2 = v2; + } + + if (JXG.GeogebraReader.isGGBVector(s1) && JXG.isArray(s2)){ //Add: Vector + Point + return [s1[1] + '+' + s2[0], s1[2] + '+' + s2[1]]; + } + + if (JXG.GeogebraReader.isGGBVector(s2) && JXG.isArray(s1)){ //Add: Vector + Point + return [s2[1] + '+' + s1[0], s2[2] + '+' + s1[1]]; + } + + if( JXG.isArray(s1) && JXG.isArray(s2) ) { + return [ s1[0] +' + '+ s2[0], s1[1] +' + '+ s2[1] ]; + } + else if( (JXG.isNumber(s1) || JXG.isString(s1)) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { + return s1 +' + '+ s2; + } + else if( (JXG.isNumber(s1) || JXG.isString(s1)) && JXG.isArray(s2) ) { + return [ s1 +' + '+ s2[0], s1 +' + '+ s2[1] ]; + } + else if( JXG.isArray(s1) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { + return [ s1[0] +' + '+ s2, s1[1] +' + '+ s2 ]; + } + else { + return s1 +' + '+ s2; + } + break; + case 'sub': + if (JXG.GeogebraReader.isGGBVector(v1) && JXG.GeogebraReader.isGGBVector(v2)){ //Sub: Vector - Vector + return [1, v1[1] + '-' + v2[1], v1[2] + '-' + v2[2]]; + } + + if( JXG.isString(v1) && !v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v1.match(/JXG\.getRef/) ) { + s1 = [v1+'.X()', v1+'.Y()']; + } else { + s1 = v1; + } + + if( JXG.isString(v2) && !v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v2.match(/JXG\.getRef/) ) { + s2 = [v2+'.X()', v2+'.Y()']; + } else { + s2 = v2; + } + + if (JXG.GeogebraReader.isGGBVector(s1) && JXG.isArray(s2)){ //Add: Vector - Point + return [s1[1] + '-' + s2[0], s1[2] + '-' + s2[1]]; + } + + if (JXG.isArray(s1) && JXG.GeogebraReader.isGGBVector(s2)){ //Add: Punkt - Vector + return [s1[0] + '-(' + s2[1] + ')', s1[1] + '-(' + s2[2] +')']; + } + + if( JXG.isArray(s1) && JXG.isArray(s2) ) { + return [ s1[0] +' - '+ s2[0], s1[1] +' - '+ s2[1] ]; + } + else if( (JXG.isNumber(s1) || JXG.isString(s1)) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { + return s1 +' - '+ s2; + } + else if( (JXG.isNumber(s1) || JXG.isString(s1)) && JXG.isArray(s2) ) { + return [ s1 +' - '+ s2[0], s1 +' - '+ s2[1] ]; + } + else if( JXG.isArray(s1) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { + return [ s1[0] +' - '+ s2, s1[1] +' - '+ s2 ]; + } + else { + return s1 +' - '+ s2; + } + break; + case 'neg': + return '!('+ v1 +')'; + break; + case 'pow': + return 'Math.pow('+ v1 +', '+ v2 +')'; + break; + case 'or': + return '('+ v1 +'||'+ v2 +')'; + break; + case 'and': + return '('+ v1 +'&&'+ v2 +')'; + break; + case 'mul': + if (JXG.GeogebraReader.isGGBVector(v1) && !JXG.isArray(v2)){ // Mult: Vector * Skalar + return [1,'(' + v1[1] + ')*'+v2,'(' + v1[2] + ')*'+v2]; + } else if (!JXG.isArray(v1) && JXG.GeogebraReader.isGGBVector(v2)){ // Mult: Skalar * Vector + return new Array(1,'(' + v2[1] + ')*'+v1,'(' + v2[2] + ')*'+v1); + } else if (JXG.GeogebraReader.isGGBVector(v1) && JXG.GeogebraReader.isGGBVector(v2)){ //Mult: Vector * Vector + return '((' + v1[1] + ')*('+v2[1]+')+('+ v1[2] + ')*('+v2[2]+'))'; + } else { // Rest + if( JXG.isString(v1) && !v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v1.match(/JXG\.getRef/) ) { + s1 = [v1+'.X()', v1+'.Y()']; + } else { + s1 = v1; + } + + if( JXG.isString(v2) && !v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v2.match(/JXG\.getRef/) ) { + s2 = [v2+'.X()', v2+'.Y()']; + } else { + s2 = v2; + } + + if( JXG.isArray(s1) && JXG.isArray(s2) ) { + return [ s1[0] +' * '+ s2[0], s1[1] +' * '+ s2[1] ]; + } + else if( (JXG.isNumber(s1) || JXG.isString(s1)) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { + return s1 +' * '+ s2; + } + else if( (JXG.isNumber(s1) || JXG.isString(s1)) && JXG.isArray(s2) ) { + return [ s1 +' * '+ s2[0], s1 +' * '+ s2[1] ]; + } + else if( JXG.isArray(s1) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { + return [ s1[0] +' * '+ s2, s1[1] +' * '+ s2 ]; + } + else { + return s1 +' * '+ s2; + } + } + break; + case 'div': + if( JXG.isString(v1) && !v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v1.match(/JXG\.getRef/) ) { + s1 = [v1+'.X()', v1+'.Y()']; + } else { + s1 = v1; + } + + if( JXG.isString(v2) && !v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v2.match(/JXG\.getRef/) ) { + s2 = [v2+'.X()', v2+'.Y()']; + } else { + s2 = v2; + } + + if( JXG.isArray(s1) && JXG.isArray(s2) ) { + return [ s1[0] +' / '+ s2[0], s1[1] +' / '+ s2[1] ]; + } + else if( (JXG.isNumber(s1) || JXG.isString(s1)) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { + return s1 +' / '+ s2; + } + else if( (JXG.isNumber(s1) || JXG.isString(s1)) && JXG.isArray(s2) ) { + return [ s1 +' / '+ s2[0], s1 +' / '+ s2[1] ]; + } + else if( JXG.isArray(s1) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { + return [ s1[0] +' / '+ s2, s1[1] +' / '+ s2 ]; + } + else { + return s1 +' / '+ s2; + } + break; + case 'negmult': + if (JXG.GeogebraReader.isGGBVector(v1)) + return new Array(1, -1 + '*' + v1[1],-1 + '*' + v1[2]); + return -1 +'*'+ v1; + break; + case 'bra': + if (JXG.GeogebraReader.isGGBVector(v1)) + return new Array(1,'(' + v1[1] + ')','(' + v1[2] + ')'); + return '('+ v1 +')'; + break; + case 'int': + return parseInt(v1); + break; + case 'float': + return parseFloat(v1); + break; + case 'param': + return v1; + break; + case 'html': + return v1; + break; + case 'string': + if(v2) return [v1, v2]; + else return v1; + break; + case 'command': + v2 = v1.split('['); + s1 = v2[0]; + s2 = (v2[1].split(']'))[0]; + switch(s1.toLowerCase()) { + case 'name': + return 'JXG.getRef(JXG.GeogebraReader.board, "'+ s2 +'").getName()'; //TODO korrigiere getName() + break; + } + break; + case 'var': + if(v2) { + switch(v1.toLowerCase()) { + case 'x': + return v2 +'.X()'; + break; + case 'y': + return v2 +'.Y()'; + break; + case 'abs': + case 'acos': + case 'asin': + case 'atan': + case 'ceil': + case 'cos': + case 'exp': + case 'floor': + case 'log': + case 'max': + case 'min': + case 'pow': + case 'random': + case 'round': + case 'sin': + case 'sqrt': + case 'tan': + return 'Math.'+v1.toLowerCase()+'('+ v2 +')'; + break; + default: + return v1.toLowerCase()+'*('+ v2 +')'; + break; + } + } else { + + if(v1 == 'PI') { + return 'Math.PI'; + } else { + a = JXG.GeogebraReader.checkElement(v1); + if(typeof JXG.GeogebraReader.board.ggb[v1] != 'undefined') { + return 'JXG.GeogebraReader.board.ggb["'+ v1 +'"]()'; + } else if(typeof a.Value != 'undefined') { + return 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").Value()'; + } else if(typeof a.Area != 'undefined') { + return 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").Area()'; + } else if(typeof a.plaintextStr != 'undefined') { + return '1.0*JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").plaintextStr'; + } else if (a.type == JXG.OBJECT_TYPE_VECTOR){ + return new Array(1, 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point2.X()-JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point1.X()','JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point2.Y()-JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point1.Y()'); + }else if(a.elementClass == JXG.OBJECT_CLASS_LINE) { + return 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point1.Dist(JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point2)'; + } else { + return 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'")'; + } + } + } + break; + } +}; + +/** + * JS/CC parser to convert the input expression to a working javascript function. + * @param {Object} board object + * @param {Object} element Element that needs to be updated + * @param {String} exp String which contains the function, expression or information + */ +this.ggbParse = function(exp, element) { + var element = (element) ? JXG.getRef(JXG.GeogebraReader.board, JXG.GeogebraReader.board.ggbElements[element].id) : false; + if(element) JXG.debug("Zu aktualisierendes Element: "+ element.name + "("+ element.id +")"); + +/* + This parser was generated with: The LALR(1) parser and lexical analyzer generator for JavaScript, written in JavaScript + In the version 0.30 on http://jscc.jmksf.com/ + + It is based on the default template driver for JS/CC generated parsers running as + browser-based JavaScript/ECMAScript applications and was strongly modified. + + The parser was written 2007, 2008 by Jan Max Meyer, J.M.K S.F. Software Technologies + This is in the public domain. +*/ + +/***** begin replace *****/ + var _dbg_withtrace = false; + var _dbg_string = new String(); + + function __dbg_print( text ) { + _dbg_string += text + "\n"; + } + + function __lex( info ) { + var state = 0; + var match = -1; + var match_pos = 0; + var start = 0; + var pos = info.offset + 1; + + do + { + pos--; + state = 0; + match = -2; + start = pos; + + if( info.src.length <= start ) + return 28; + + do + { + + switch( state ) + { + case 0: + if( info.src.charCodeAt( pos ) == 9 || info.src.charCodeAt( pos ) == 32 ) state = 1; + else if( info.src.charCodeAt( pos ) == 33 ) state = 2; + else if( info.src.charCodeAt( pos ) == 40 ) state = 3; + else if( info.src.charCodeAt( pos ) == 41 ) state = 4; + else if( info.src.charCodeAt( pos ) == 42 ) state = 5; + else if( info.src.charCodeAt( pos ) == 43 ) state = 6; + else if( info.src.charCodeAt( pos ) == 44 ) state = 7; + else if( info.src.charCodeAt( pos ) == 45 ) state = 8; + else if( info.src.charCodeAt( pos ) == 47 ) state = 9; + else if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 10; + else if( info.src.charCodeAt( pos ) == 60 ) state = 11; + else if( info.src.charCodeAt( pos ) == 62 ) state = 12; + else if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 13; + else if( info.src.charCodeAt( pos ) == 94 ) state = 14; + else if( info.src.charCodeAt( pos ) == 34 ) state = 26; + else if( info.src.charCodeAt( pos ) == 38 ) state = 28; + else if( info.src.charCodeAt( pos ) == 46 ) state = 29; + else if( info.src.charCodeAt( pos ) == 61 ) state = 30; + else if( info.src.charCodeAt( pos ) == 95 ) state = 31; + else if( info.src.charCodeAt( pos ) == 124 ) state = 32; + else state = -1; + break; + + case 1: + state = -1; + match = 1; + match_pos = pos; + break; + + case 2: + if( info.src.charCodeAt( pos ) == 61 ) state = 15; + else state = -1; + match = 23; + match_pos = pos; + break; + + case 3: + state = -1; + match = 2; + match_pos = pos; + break; + + case 4: + state = -1; + match = 3; + match_pos = pos; + break; + + case 5: + state = -1; + match = 13; + match_pos = pos; + break; + + case 6: + state = -1; + match = 11; + match_pos = pos; + break; + + case 7: + state = -1; + match = 16; + match_pos = pos; + break; + + case 8: + state = -1; + match = 12; + match_pos = pos; + break; + + case 9: + state = -1; + match = 14; + match_pos = pos; + break; + + case 10: + if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 10; + else if( info.src.charCodeAt( pos ) == 46 ) state = 18; + else state = -1; + match = 4; + match_pos = pos; + break; + + case 11: + if( info.src.charCodeAt( pos ) == 61 ) state = 19; + else state = -1; + match = 21; + match_pos = pos; + break; + + case 12: + if( info.src.charCodeAt( pos ) == 61 ) state = 21; + else state = -1; + match = 22; + match_pos = pos; + break; + + case 13: + if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 13; + else if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 27; + else if( info.src.charCodeAt( pos ) == 91 ) state = 34; + else if( info.src.charCodeAt( pos ) == 95 ) state = 35; + else state = -1; + match = 7; + match_pos = pos; + break; + + case 14: + state = -1; + match = 15; + match_pos = pos; + break; + + case 15: + state = -1; + match = 20; + match_pos = pos; + break; + + case 16: + state = -1; + match = 9; + match_pos = pos; + break; + + case 17: + state = -1; + match = 25; + match_pos = pos; + break; + + case 18: + if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 18; + else state = -1; + match = 5; + match_pos = pos; + break; + + case 19: + state = -1; + match = 17; + match_pos = pos; + break; + + case 20: + state = -1; + match = 19; + match_pos = pos; + break; + + case 21: + state = -1; + match = 18; + match_pos = pos; + break; + + case 22: + state = -1; + match = 24; + match_pos = pos; + break; + + case 23: + state = -1; + match = 8; + match_pos = pos; + break; + + case 24: + if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 24; + else state = -1; + match = 6; + match_pos = pos; + break; + + case 25: + state = -1; + match = 10; + match_pos = pos; + break; + + case 26: + if( info.src.charCodeAt( pos ) == 34 ) state = 16; + else if( info.src.charCodeAt( pos ) == 32 || info.src.charCodeAt( pos ) == 46 || ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || info.src.charCodeAt( pos ) == 61 || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) || info.src.charCodeAt( pos ) == 223 || info.src.charCodeAt( pos ) == 228 || info.src.charCodeAt( pos ) == 246 || info.src.charCodeAt( pos ) == 252 ) state = 26; + else state = -1; + break; + + case 27: + if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 27; + else if( info.src.charCodeAt( pos ) == 95 ) state = 35; + else state = -1; + match = 7; + match_pos = pos; + break; + + case 28: + if( info.src.charCodeAt( pos ) == 38 ) state = 17; + else if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 33; + else state = -1; + break; + + case 29: + if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 18; + else state = -1; + break; + + case 30: + if( info.src.charCodeAt( pos ) == 61 ) state = 20; + else state = -1; + break; + + case 31: + if( info.src.charCodeAt( pos ) == 95 ) state = 36; + else state = -1; + break; + + case 32: + if( info.src.charCodeAt( pos ) == 124 ) state = 22; + else state = -1; + break; + + case 33: + if( info.src.charCodeAt( pos ) == 59 ) state = 23; + else if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 33; + else state = -1; + break; + + case 34: + if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 37; + else state = -1; + break; + + case 35: + if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 27; + else if( info.src.charCodeAt( pos ) == 95 ) state = 35; + else state = -1; + break; + + case 36: + if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 24; + else state = -1; + break; + + case 37: + if( info.src.charCodeAt( pos ) == 93 ) state = 25; + else if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 37; + else state = -1; + break; + + } + + + pos++; + + } + while( state > -1 ); + + } + while( 1 > -1 && match == 1 ); + + if( match > -1 ) + { + info.att = info.src.substr( start, match_pos - start ); + info.offset = match_pos; + + + } + else + { + info.att = new String(); + match = -1; + } + + return match; + } + + + function __parse( src, err_off, err_la ) { + var sstack = new Array(); + var vstack = new Array(); + var err_cnt = 0; + var act; + var go; + var la; + var rval; + var parseinfo = new Function( "", "var offset; var src; var att;" ); + var info = new parseinfo(); + + /* Pop-Table */ + var pop_tab = new Array( + new Array( 0/* p' */, 1 ), + new Array( 27/* p */, 1 ), + new Array( 26/* e */, 5 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 2 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 2 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 3 ), + new Array( 26/* e */, 1 ), + new Array( 26/* e */, 1 ), + new Array( 26/* e */, 1 ), + new Array( 26/* e */, 1 ), + new Array( 26/* e */, 1 ), + new Array( 26/* e */, 1 ), + new Array( 26/* e */, 4 ), + new Array( 26/* e */, 1 ) + ); + + /* Action-Table */ + var act_tab = new Array( + /* State 0 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 1 */ new Array( 28/* "$" */,0 ), + /* State 2 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,18 , 11/* "+" */,19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-1 ), + /* State 3 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 4 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 5 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 6 */ new Array( 11/* "+" */,29 , 28/* "$" */,-24 , 17/* "<=" */,-24 , 18/* ">=" */,-24 , 19/* "==" */,-24 , 20/* "!=" */,-24 , 21/* "<" */,-24 , 22/* ">" */,-24 , 12/* "-" */,-24 , 15/* "^" */,-24 , 24/* "||" */,-24 , 25/* "&&" */,-24 , 13/* "*" */,-24 , 14/* "/" */,-24 , 16/* "," */,-24 , 3/* ")" */,-24 ), + /* State 7 */ new Array( 28/* "$" */,-20 , 17/* "<=" */,-20 , 18/* ">=" */,-20 , 19/* "==" */,-20 , 20/* "!=" */,-20 , 21/* "<" */,-20 , 22/* ">" */,-20 , 11/* "+" */,-20 , 12/* "-" */,-20 , 15/* "^" */,-20 , 24/* "||" */,-20 , 25/* "&&" */,-20 , 13/* "*" */,-20 , 14/* "/" */,-20 , 16/* "," */,-20 , 3/* ")" */,-20 ), + /* State 8 */ new Array( 28/* "$" */,-21 , 17/* "<=" */,-21 , 18/* ">=" */,-21 , 19/* "==" */,-21 , 20/* "!=" */,-21 , 21/* "<" */,-21 , 22/* ">" */,-21 , 11/* "+" */,-21 , 12/* "-" */,-21 , 15/* "^" */,-21 , 24/* "||" */,-21 , 25/* "&&" */,-21 , 13/* "*" */,-21 , 14/* "/" */,-21 , 16/* "," */,-21 , 3/* ")" */,-21 ), + /* State 9 */ new Array( 28/* "$" */,-22 , 17/* "<=" */,-22 , 18/* ">=" */,-22 , 19/* "==" */,-22 , 20/* "!=" */,-22 , 21/* "<" */,-22 , 22/* ">" */,-22 , 11/* "+" */,-22 , 12/* "-" */,-22 , 15/* "^" */,-22 , 24/* "||" */,-22 , 25/* "&&" */,-22 , 13/* "*" */,-22 , 14/* "/" */,-22 , 16/* "," */,-22 , 3/* ")" */,-22 ), + /* State 10 */ new Array( 28/* "$" */,-23 , 17/* "<=" */,-23 , 18/* ">=" */,-23 , 19/* "==" */,-23 , 20/* "!=" */,-23 , 21/* "<" */,-23 , 22/* ">" */,-23 , 11/* "+" */,-23 , 12/* "-" */,-23 , 15/* "^" */,-23 , 24/* "||" */,-23 , 25/* "&&" */,-23 , 13/* "*" */,-23 , 14/* "/" */,-23 , 16/* "," */,-23 , 3/* ")" */,-23 ), + /* State 11 */ new Array( 28/* "$" */,-25 , 17/* "<=" */,-25 , 18/* ">=" */,-25 , 19/* "==" */,-25 , 20/* "!=" */,-25 , 21/* "<" */,-25 , 22/* ">" */,-25 , 11/* "+" */,-25 , 12/* "-" */,-25 , 15/* "^" */,-25 , 24/* "||" */,-25 , 25/* "&&" */,-25 , 13/* "*" */,-25 , 14/* "/" */,-25 , 16/* "," */,-25 , 3/* ")" */,-25 ), + /* State 12 */ new Array( 2/* "(" */,30 , 28/* "$" */,-27 , 17/* "<=" */,-27 , 18/* ">=" */,-27 , 19/* "==" */,-27 , 20/* "!=" */,-27 , 21/* "<" */,-27 , 22/* ">" */,-27 , 11/* "+" */,-27 , 12/* "-" */,-27 , 15/* "^" */,-27 , 24/* "||" */,-27 , 25/* "&&" */,-27 , 13/* "*" */,-27 , 14/* "/" */,-27 , 16/* "," */,-27 , 3/* ")" */,-27 ), + /* State 13 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 14 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 15 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 16 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 17 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 18 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 19 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 20 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 21 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 22 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 23 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 24 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 25 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 26 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,18 , 11/* "+" */,19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 16/* "," */,44 , 3/* ")" */,45 ), + /* State 27 */ new Array( 14/* "/" */,-11 , 13/* "*" */,-11 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-11 , 12/* "-" */,-11 , 11/* "+" */,-11 , 22/* ">" */,-11 , 21/* "<" */,-11 , 20/* "!=" */,-11 , 19/* "==" */,-11 , 18/* ">=" */,-11 , 17/* "<=" */,-11 , 28/* "$" */,-11 , 16/* "," */,-11 , 3/* ")" */,-11 ), + /* State 28 */ new Array( 14/* "/" */,-17 , 13/* "*" */,-17 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-17 , 11/* "+" */,-17 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-17 , 16/* "," */,-17 , 3/* ")" */,-17 ), + /* State 29 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 30 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 31 */ new Array( 14/* "/" */,-16 , 13/* "*" */,-16 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-16 , 11/* "+" */,-16 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-16 , 16/* "," */,-16 , 3/* ")" */,-16 ), + /* State 32 */ new Array( 14/* "/" */,-15 , 13/* "*" */,-15 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-15 , 11/* "+" */,-15 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-15 , 16/* "," */,-15 , 3/* ")" */,-15 ), + /* State 33 */ new Array( 14/* "/" */,-14 , 13/* "*" */,-14 , 25/* "&&" */,-14 , 24/* "||" */,-14 , 15/* "^" */,-14 , 12/* "-" */,-14 , 11/* "+" */,-14 , 22/* ">" */,-14 , 21/* "<" */,-14 , 20/* "!=" */,-14 , 19/* "==" */,-14 , 18/* ">=" */,-14 , 17/* "<=" */,-14 , 28/* "$" */,-14 , 16/* "," */,-14 , 3/* ")" */,-14 ), + /* State 34 */ new Array( 14/* "/" */,-13 , 13/* "*" */,-13 , 25/* "&&" */,-13 , 24/* "||" */,-13 , 15/* "^" */,-13 , 12/* "-" */,-13 , 11/* "+" */,-13 , 22/* ">" */,-13 , 21/* "<" */,-13 , 20/* "!=" */,-13 , 19/* "==" */,-13 , 18/* ">=" */,-13 , 17/* "<=" */,-13 , 28/* "$" */,-13 , 16/* "," */,-13 , 3/* ")" */,-13 ), + /* State 35 */ new Array( 14/* "/" */,-12 , 13/* "*" */,-12 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-12 , 12/* "-" */,-12 , 11/* "+" */,-12 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-12 , 16/* "," */,-12 , 3/* ")" */,-12 ), + /* State 36 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-10 , 11/* "+" */,-10 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-10 , 16/* "," */,-10 , 3/* ")" */,-10 ), + /* State 37 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-9 , 11/* "+" */,-9 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-9 , 16/* "," */,-9 , 3/* ")" */,-9 ), + /* State 38 */ new Array( 14/* "/" */,-8 , 13/* "*" */,-8 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-8 , 12/* "-" */,-8 , 11/* "+" */,-8 , 22/* ">" */,-8 , 21/* "<" */,-8 , 20/* "!=" */,-8 , 19/* "==" */,-8 , 18/* ">=" */,-8 , 17/* "<=" */,-8 , 28/* "$" */,-8 , 16/* "," */,-8 , 3/* ")" */,-8 ), + /* State 39 */ new Array( 14/* "/" */,-7 , 13/* "*" */,-7 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-7 , 12/* "-" */,-7 , 11/* "+" */,-7 , 22/* ">" */,-7 , 21/* "<" */,-7 , 20/* "!=" */,-7 , 19/* "==" */,-7 , 18/* ">=" */,-7 , 17/* "<=" */,-7 , 28/* "$" */,-7 , 16/* "," */,-7 , 3/* ")" */,-7 ), + /* State 40 */ new Array( 14/* "/" */,-6 , 13/* "*" */,-6 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-6 , 12/* "-" */,-6 , 11/* "+" */,-6 , 22/* ">" */,-6 , 21/* "<" */,-6 , 20/* "!=" */,-6 , 19/* "==" */,-6 , 18/* ">=" */,-6 , 17/* "<=" */,-6 , 28/* "$" */,-6 , 16/* "," */,-6 , 3/* ")" */,-6 ), + /* State 41 */ new Array( 14/* "/" */,-5 , 13/* "*" */,-5 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-5 , 12/* "-" */,-5 , 11/* "+" */,-5 , 22/* ">" */,-5 , 21/* "<" */,-5 , 20/* "!=" */,-5 , 19/* "==" */,-5 , 18/* ">=" */,-5 , 17/* "<=" */,-5 , 28/* "$" */,-5 , 16/* "," */,-5 , 3/* ")" */,-5 ), + /* State 42 */ new Array( 14/* "/" */,-4 , 13/* "*" */,-4 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-4 , 12/* "-" */,-4 , 11/* "+" */,-4 , 22/* ">" */,-4 , 21/* "<" */,-4 , 20/* "!=" */,-4 , 19/* "==" */,-4 , 18/* ">=" */,-4 , 17/* "<=" */,-4 , 28/* "$" */,-4 , 16/* "," */,-4 , 3/* ")" */,-4 ), + /* State 43 */ new Array( 14/* "/" */,-3 , 13/* "*" */,-3 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-3 , 12/* "-" */,-3 , 11/* "+" */,-3 , 22/* ">" */,-3 , 21/* "<" */,-3 , 20/* "!=" */,-3 , 19/* "==" */,-3 , 18/* ">=" */,-3 , 17/* "<=" */,-3 , 28/* "$" */,-3 , 16/* "," */,-3 , 3/* ")" */,-3 ), + /* State 44 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), + /* State 45 */ new Array( 28/* "$" */,-18 , 17/* "<=" */,-18 , 18/* ">=" */,-18 , 19/* "==" */,-18 , 20/* "!=" */,-18 , 21/* "<" */,-18 , 22/* ">" */,-18 , 11/* "+" */,-18 , 12/* "-" */,-18 , 15/* "^" */,-18 , 24/* "||" */,-18 , 25/* "&&" */,-18 , 13/* "*" */,-18 , 14/* "/" */,-18 , 16/* "," */,-18 , 3/* ")" */,-18 ), + /* State 46 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-19 , 11/* "+" */,-19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-19 , 16/* "," */,-19 , 3/* ")" */,-19 ), + /* State 47 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,18 , 11/* "+" */,19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 3/* ")" */,49 ), + /* State 48 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,18 , 11/* "+" */,19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 3/* ")" */,50 ), + /* State 49 */ new Array( 28/* "$" */,-26 , 17/* "<=" */,-26 , 18/* ">=" */,-26 , 19/* "==" */,-26 , 20/* "!=" */,-26 , 21/* "<" */,-26 , 22/* ">" */,-26 , 11/* "+" */,-26 , 12/* "-" */,-26 , 15/* "^" */,-26 , 24/* "||" */,-26 , 25/* "&&" */,-26 , 13/* "*" */,-26 , 14/* "/" */,-26 , 16/* "," */,-26 , 3/* ")" */,-26 ), + /* State 50 */ new Array( 28/* "$" */,-2 , 17/* "<=" */,-2 , 18/* ">=" */,-2 , 19/* "==" */,-2 , 20/* "!=" */,-2 , 21/* "<" */,-2 , 22/* ">" */,-2 , 11/* "+" */,-2 , 12/* "-" */,-2 , 15/* "^" */,-2 , 24/* "||" */,-2 , 25/* "&&" */,-2 , 13/* "*" */,-2 , 14/* "/" */,-2 , 16/* "," */,-2 , 3/* ")" */,-2 ) + ); + + /* Goto-Table */ + var goto_tab = new Array( + /* State 0 */ new Array( 27/* p */,1 , 26/* e */,2 ), + /* State 1 */ new Array( ), + /* State 2 */ new Array( ), + /* State 3 */ new Array( 26/* e */,26 ), + /* State 4 */ new Array( 26/* e */,27 ), + /* State 5 */ new Array( 26/* e */,28 ), + /* State 6 */ new Array( ), + /* State 7 */ new Array( ), + /* State 8 */ new Array( ), + /* State 9 */ new Array( ), + /* State 10 */ new Array( ), + /* State 11 */ new Array( ), + /* State 12 */ new Array( ), + /* State 13 */ new Array( 26/* e */,31 ), + /* State 14 */ new Array( 26/* e */,32 ), + /* State 15 */ new Array( 26/* e */,33 ), + /* State 16 */ new Array( 26/* e */,34 ), + /* State 17 */ new Array( 26/* e */,35 ), + /* State 18 */ new Array( 26/* e */,36 ), + /* State 19 */ new Array( 26/* e */,37 ), + /* State 20 */ new Array( 26/* e */,38 ), + /* State 21 */ new Array( 26/* e */,39 ), + /* State 22 */ new Array( 26/* e */,40 ), + /* State 23 */ new Array( 26/* e */,41 ), + /* State 24 */ new Array( 26/* e */,42 ), + /* State 25 */ new Array( 26/* e */,43 ), + /* State 26 */ new Array( ), + /* State 27 */ new Array( ), + /* State 28 */ new Array( ), + /* State 29 */ new Array( 26/* e */,46 ), + /* State 30 */ new Array( 26/* e */,47 ), + /* State 31 */ new Array( ), + /* State 32 */ new Array( ), + /* State 33 */ new Array( ), + /* State 34 */ new Array( ), + /* State 35 */ new Array( ), + /* State 36 */ new Array( ), + /* State 37 */ new Array( ), + /* State 38 */ new Array( ), + /* State 39 */ new Array( ), + /* State 40 */ new Array( ), + /* State 41 */ new Array( ), + /* State 42 */ new Array( ), + /* State 43 */ new Array( ), + /* State 44 */ new Array( 26/* e */,48 ), + /* State 45 */ new Array( ), + /* State 46 */ new Array( ), + /* State 47 */ new Array( ), + /* State 48 */ new Array( ), + /* State 49 */ new Array( ), + /* State 50 */ new Array( ) + ); + + + + /* Symbol labels */ + var labels = new Array( + "p'" /* Non-terminal symbol */, + "WHITESPACE" /* Terminal symbol */, + "(" /* Terminal symbol */, + ")" /* Terminal symbol */, + "INT" /* Terminal symbol */, + "FLOAT" /* Terminal symbol */, + "PARAM" /* Terminal symbol */, + "VAR" /* Terminal symbol */, + "HTML" /* Terminal symbol */, + "STRING" /* Terminal symbol */, + "COMMAND" /* Terminal symbol */, + "+" /* Terminal symbol */, + "-" /* Terminal symbol */, + "*" /* Terminal symbol */, + "/" /* Terminal symbol */, + "^" /* Terminal symbol */, + "," /* Terminal symbol */, + "<=" /* Terminal symbol */, + ">=" /* Terminal symbol */, + "==" /* Terminal symbol */, + "!=" /* Terminal symbol */, + "<" /* Terminal symbol */, + ">" /* Terminal symbol */, + "!" /* Terminal symbol */, + "||" /* Terminal symbol */, + "&&" /* Terminal symbol */, + "e" /* Non-terminal symbol */, + "p" /* Non-terminal symbol */, + "$" /* Terminal symbol */ + ); + + + + info.offset = 0; + info.src = src; + info.att = new String(); + + if( !err_off ) + err_off = new Array(); + if( !err_la ) + err_la = new Array(); + + sstack.push( 0 ); + vstack.push( 0 ); + + la = __lex( info ); + + while( true ) + { + act = 52; + for( var i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 ) + { + if( act_tab[sstack[sstack.length-1]][i] == la ) + { + act = act_tab[sstack[sstack.length-1]][i+1]; + break; + } + } + + if( _dbg_withtrace && sstack.length > 0 ) + { + __dbg_print( "\nState " + sstack[sstack.length-1] + "\n" + + "\tLookahead: " + labels[la] + " (\"" + info.att + "\")\n" + + "\tAction: " + act + "\n" + + "\tSource: \"" + info.src.substr( info.offset, 30 ) + ( ( info.offset + 30 < info.src.length ) ? + "..." : "" ) + "\"\n" + + "\tStack: " + sstack.join() + "\n" + + "\tValue stack: " + vstack.join() + "\n" ); + } + + + //Panic-mode: Try recovery when parse-error occurs! + if( act == 52 ) + { + if( _dbg_withtrace ) + __dbg_print( "Error detected: There is no reduce or shift on the symbol " + labels[la] ); + + err_cnt++; + err_off.push( info.offset - info.att.length ); + err_la.push( new Array() ); + for( var i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 ) + err_la[err_la.length-1].push( labels[act_tab[sstack[sstack.length-1]][i]] ); + + //Remember the original stack! + var rsstack = new Array(); + var rvstack = new Array(); + for( var i = 0; i < sstack.length; i++ ) + { + rsstack[i] = sstack[i]; + rvstack[i] = vstack[i]; + } + + while( act == 52 && la != 28 ) + { + if( _dbg_withtrace ) + __dbg_print( "\tError recovery\n" + + "Current lookahead: " + labels[la] + " (" + info.att + ")\n" + + "Action: " + act + "\n\n" ); + if( la == -1 ) + info.offset++; + + while( act == 52 && sstack.length > 0 ) + { + sstack.pop(); + vstack.pop(); + + if( sstack.length == 0 ) + break; + + act = 52; + for( var i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 ) + { + if( act_tab[sstack[sstack.length-1]][i] == la ) + { + act = act_tab[sstack[sstack.length-1]][i+1]; + break; + } + } + } + + if( act != 52 ) + break; + + for( var i = 0; i < rsstack.length; i++ ) + { + sstack.push( rsstack[i] ); + vstack.push( rvstack[i] ); + } + + la = __lex( info ); + } + + if( act == 52 ) + { + if( _dbg_withtrace ) + __dbg_print( "\tError recovery failed, terminating parse process..." ); + break; + } + + + if( _dbg_withtrace ) + __dbg_print( "\tError recovery succeeded, continuing" ); + } + + /* + if( act == 52 ) + break; + */ + + + //Shift + if( act > 0 ) + { + if( _dbg_withtrace ) + __dbg_print( "Shifting symbol: " + labels[la] + " (" + info.att + ")" ); + + sstack.push( act ); + vstack.push( info.att ); + + la = __lex( info ); + + if( _dbg_withtrace ) + __dbg_print( "\tNew lookahead symbol: " + labels[la] + " (" + info.att + ")" ); + } + //Reduce + else + { + act *= -1; + + if( _dbg_withtrace ) + __dbg_print( "Reducing by producution: " + act ); + + rval = void(0); + + if( _dbg_withtrace ) + __dbg_print( "\tPerforming semantic action..." ); + + switch( act ) + { + case 0: + { + rval = vstack[ vstack.length - 1 ]; + } + break; + case 1: + { + rval = JXG.GeogebraReader.ggbAct('end', vstack[ vstack.length - 1 ]); + } + break; + case 2: + { + rval = JXG.GeogebraReader.ggbAct('coord', vstack[ vstack.length - 4 ], vstack[ vstack.length - 2 ], element); + } + break; + case 3: + { + rval = JXG.GeogebraReader.ggbAct('le', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 4: + { + rval = JXG.GeogebraReader.ggbAct('ge', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 5: + { + rval = JXG.GeogebraReader.ggbAct('eq', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 6: + { + rval = JXG.GeogebraReader.ggbAct('neq', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 7: + { + rval = JXG.GeogebraReader.ggbAct('lt', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 8: + { + rval = JXG.GeogebraReader.ggbAct('gt', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 9: + { + rval = JXG.GeogebraReader.ggbAct('add', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 10: + { + rval = JXG.GeogebraReader.ggbAct('sub', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 11: + { + rval = JXG.GeogebraReader.ggbAct('neg', vstack[ vstack.length - 1 ]); + } + break; + case 12: + { + rval = JXG.GeogebraReader.ggbAct('pow', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 13: + { + rval = JXG.GeogebraReader.ggbAct('or', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 14: + { + rval = JXG.GeogebraReader.ggbAct('and', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 15: + { + rval = JXG.GeogebraReader.ggbAct('mul', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 16: + { + rval = JXG.GeogebraReader.ggbAct('div', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 17: + { + rval = JXG.GeogebraReader.ggbAct('negmult', vstack[ vstack.length - 1 ]); + } + break; + case 18: + { + rval = JXG.GeogebraReader.ggbAct('bra', vstack[ vstack.length - 2 ]); + } + break; + case 19: + { + rval = JXG.GeogebraReader.ggbAct('string', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); + } + break; + case 20: + { + rval = JXG.GeogebraReader.ggbAct('int', vstack[ vstack.length - 1 ]); + } + break; + case 21: + { + rval = JXG.GeogebraReader.ggbAct('float', vstack[ vstack.length - 1 ]); + } + break; + case 22: + { + rval = JXG.GeogebraReader.ggbAct('param', vstack[ vstack.length - 1 ]); + } + break; + case 23: + { + rval = JXG.GeogebraReader.ggbAct('html', vstack[ vstack.length - 1 ]); + } + break; + case 24: + { + rval = JXG.GeogebraReader.ggbAct('string', vstack[ vstack.length - 1 ]); + } + break; + case 25: + { + rval = JXG.GeogebraReader.ggbAct('command', vstack[ vstack.length - 1 ]); + } + break; + case 26: + { + rval = JXG.GeogebraReader.ggbAct('var', vstack[ vstack.length - 4 ], vstack[ vstack.length - 2 ]); + } + break; + case 27: + { + rval = JXG.GeogebraReader.ggbAct('var', vstack[ vstack.length - 1 ]); + } + break; + } + + + + if( _dbg_withtrace ) + __dbg_print( "\tPopping " + pop_tab[act][1] + " off the stack..." ); + + for( var i = 0; i < pop_tab[act][1]; i++ ) + { + sstack.pop(); + str = vstack.pop(); + } + + go = -1; + for( var i = 0; i < goto_tab[sstack[sstack.length-1]].length; i+=2 ) + { + if( goto_tab[sstack[sstack.length-1]][i] == pop_tab[act][0] ) + { + go = goto_tab[sstack[sstack.length-1]][i+1]; + break; + } + } + + if( act == 0 ) + break; + + if( _dbg_withtrace ) + __dbg_print( "\tPushing non-terminal " + labels[ pop_tab[act][0] ] ); + + sstack.push( go ); + vstack.push( rval ); + } + + if( _dbg_withtrace ) + { + JXG.debug( _dbg_string ); + _dbg_string = new String(); + } + } + + if( _dbg_withtrace ) + { + __dbg_print( "\nParse complete." ); + JXG.debug( _dbg_string ); + } + + return err_cnt; + } +/***** end replace *****/ + + var error_offsets = new Array(); + var error_lookaheads = new Array(); + var error_count = 0; + var str = exp; + if( ( error_count = __parse( str, error_offsets, error_lookaheads ) ) > 0 ) { + var errstr = new String(); + for( var i = 0; i < error_count; i++ ) + errstr += "Parse error in line " + ( str.substr( 0, error_offsets[i] ).match( /\n/g ) ? + str.substr( 0, error_offsets[i] ).match( /\n/g ).length : 1 ) + + " near \"" + str.substr( error_offsets[i] ) + "\", expecting \"" + error_lookaheads[i].join() + "\"\n" ; + JXG.debug( errstr ); + } + + return str; +}; //end: ggbParse() + + +/** + * Override JSxGraph defaults with Geogebra settings + * @param {Object} board object + * @return {Object} board oject + */ +this.setDefaultOptions = function(board){ + board.options.elements.strokeWidth = '1px'; // TODO: board.options.line.strokeWidth + board.options.elements.withLabel = true; + + board.options.point.face = 'circle'; + board.options.point.size = 3; + board.options.point.fillColor = 'blue'; + board.options.point.fillOpacity = 1; + board.options.point.highlightFillOpacity = 1; + board.options.point.strokeColor = 'black'; + board.options.point.highlightStrokeColor = 'black'; + board.options.point.strokeWidth = '2px'; + + board.options.line.strokeWidth = '1px'; + board.options.line.highlightStrokeColor = '#000000'; + board.options.line.strokeColor = '#000000'; + + board.options.polygon.fillColor = JXG.rgb2hex(153, 51, 0); + board.options.polygon.fillOpacity = 0.1; + board.options.polygon.highlightFillColor = board.options.polygon.fillColor; + board.options.polygon.highlightFillOpacity = 0.1; + + board.options.sector.fillColor = JXG.rgb2hex(153, 51, 0); + board.options.sector.fillOpacity = 0.1; + board.options.sector.highlightFillColor = board.options.sector.fillColor; + board.options.sector.highlightFillOpacity = 0.1; + + board.options.angle.fillColor = JXG.rgb2hex(0, 100, 0); + board.options.angle.fillOpacity = 0.1; + //board.options.angle.highlightFillColor = board.options.angle.fillColor; + board.options.angle.highlightFillOpacity = 0.1; + + return board; +}; + +/** + * Set color properties of a geogebra element. + * Set stroke, fill, lighting, label and draft color attributes. + * @param {Object} gxtEl element of which attributes are to set + * @param {Object} attr object carrying all necessary attribute values + * @return {Object} returning the updated attr-attributes object + */ +this.colorProperties = function(Data, attr) { + var a,r,g,b; + a = (Data.getElementsByTagName("objColor").length > 0 && Data.getElementsByTagName("objColor")[0].getAttribute("alpha")) ? parseFloat(Data.getElementsByTagName("objColor")[0].getAttribute("alpha")) : 0; + r = (Data.getElementsByTagName("objColor").length > 0 && Data.getElementsByTagName("objColor")[0].getAttribute("r")) ? parseInt(Data.getElementsByTagName("objColor")[0].getAttribute("r")).toString(16) : 0; + g = (Data.getElementsByTagName("objColor").length > 0 && Data.getElementsByTagName("objColor")[0].getAttribute("g")) ? parseInt(Data.getElementsByTagName("objColor")[0].getAttribute("g")).toString(16) : 0; + b = (Data.getElementsByTagName("objColor").length > 0 && Data.getElementsByTagName("objColor")[0].getAttribute("b")) ? parseInt(Data.getElementsByTagName("objColor")[0].getAttribute("b")).toString(16) : 0; + if (r.length == 1) r = '0' + r; + if (g.length == 1) g = '0' + g; + if (b.length == 1) b = '0' + b; + + attr.fillColor = '#'+ r + g + b; + attr.strokeColor = attr.fillColor; + attr.highlightFillColor = attr.fillColor; + attr.highlightStrokeColor = attr.strokeColor; + attr.fillOpacity = a; + attr.highlightFillOpacity = a; + attr.labelColor = attr.fillColor; + + return attr; +}; + +/** + * Set the board properties. + * Set active, area, dash, draft and showinfo attributes. + * @param {Object} gxtEl element of which attributes are to set + * @param {Object} Data element of which attributes are to set + * @param {Object} attr object containing the necessary attribute values + */ +this.boardProperties = function(gxtEl, Data, attr) { + return attr; +}; + +/** + * @param {Object} gxtEl element of which attributes are to set + * @param {Object} Data element of which attributes are to set + * @return {Object} updated element + */ +this.coordinates = function(gxtEl, Data) { + var labelOffset = {}, tmp; + labelOffset.x = 0; labelOffset.y = 0; labelOffset.z = 0; + + if(Data.getElementsByTagName('labelOffset')[0]) { + // tmp = new JXG.Coords(JXG.COORDS_BY_SCREEN, [, + // parseFloat(Data.getElementsByTagName("labelOffset")[0].attributes["y"].value)], JXG.GeogebraReader.board); + labelOffset.x = parseFloat(Data.getElementsByTagName("labelOffset")[0].getAttribute("x"))/JXG.GeogebraReader.board.unitX; + labelOffset.y = parseFloat(Data.getElementsByTagName("labelOffset")[0].getAttribute("y"))/JXG.GeogebraReader.board.unitY; + } + + if(Data.getElementsByTagName("coords")[0]) { + gxtEl.x = parseFloat(Data.getElementsByTagName("coords")[0].getAttribute("x")); + gxtEl.y = parseFloat(Data.getElementsByTagName("coords")[0].getAttribute("y")); + gxtEl.z = parseFloat(Data.getElementsByTagName("coords")[0].getAttribute("z")); + } else if(Data.getElementsByTagName("startPoint")[0]) { + if(Data.getElementsByTagName("startPoint")[0].getAttribute('exp')) { + var a = JXG.getRef(JXG.GeogebraReader.board, Data.getElementsByTagName("startPoint")[0].getAttribute('exp')); + gxtEl.x = function() {return a.X()+labelOffset.x;}; + gxtEl.y = function() {return a.Y()-labelOffset.y;}; // minus because geogebra starts on the other side + gxtEl.z = false; + } else { + gxtEl.x = parseFloat(Data.getElementsByTagName("startPoint")[0].getAttribute("x")); + gxtEl.y = parseFloat(Data.getElementsByTagName("startPoint")[0].getAttribute("y")); + gxtEl.z = parseFloat(Data.getElementsByTagName("startPoint")[0].getAttribute("z")); + } + } else if(Data.getElementsByTagName("absoluteScreenLocation")[0]) { + var tmp = new JXG.Coords(JXG.COORDS_BY_SCREEN, [parseFloat(Data.getElementsByTagName("absoluteScreenLocation")[0].getAttribute("x")), + parseFloat(Data.getElementsByTagName("absoluteScreenLocation")[0].getAttribute("y"))], JXG.GeogebraReader.board); + gxtEl.x = tmp.usrCoords[1]+labelOffset.x; + gxtEl.y = tmp.usrCoords[2]+labelOffset.y; + gxtEl.z = false; + } else { + return false; + } + + return gxtEl; +}; + +/** + * Writing element attributes to the given object + * @param {XMLNode} Data expects the content of the current element + * @return {Object} object with according attributes + */ +this.visualProperties = function(Data, attr) { + (Data.getElementsByTagName("show").length != 0 && Data.getElementsByTagName("show")[0].getAttribute("object")) ? attr.visible = Data.getElementsByTagName("show")[0].getAttribute("object") : false; + (Data.getElementsByTagName("show").length != 0 && Data.getElementsByTagName("show")[0].getAttribute("label")) ? attr.withLabel = Data.getElementsByTagName("show")[0].getAttribute("label") : true; + if(attr.withLabel == 'true') { + attr.withLabel = true; + } + else if(attr.withLabel == 'false') { + attr.withLabel = false; + } + (Data.getElementsByTagName('pointSize')[0]) ? attr.size = Data.getElementsByTagName('pointSize')[0].getAttribute("val") : false; + (Data.getElementsByTagName('pointStyle')[0]) ? attr.styleGGB = Data.getElementsByTagName('pointStyle')[0].getAttribute("val") : false; + if(attr.styleGGB == 0 || attr.styleGGB == 2) { + attr.face = 'circle'; + if(attr.styleGGB == 0) { + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + attr.highlightFillColor = attr.strokeColor; + attr.highlightFillOpacity = 1; + attr.strokeColor = 'black'; + attr.strokeWidth = '1px'; + } + else if(attr.styleGGB == 2) { + attr.fillColor = 'none'; + } + } + else if(attr.styleGGB == 1) { + attr.face = 'x'; + } + else if(attr.styleGGB == 3) { + attr.face = '+'; + attr.strokeOpacity = 1; + } + else if(attr.styleGGB == 4 || attr.styleGGB == 5) { + attr.face = 'diamond'; + if(attr.styleGGB == 4) { + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + } + else if(attr.styleGGB == 5) { + attr.fillColor = 'none'; + } + } + else if(attr.styleGGB == 6) { + attr.face = 'triangleUp'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + } + else if(attr.styleGGB == 7) { + attr.face = 'triangleDown'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + } + else if(attr.styleGGB == 8) { + attr.face = 'triangleRight'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + } + else if(attr.styleGGB == 9) { + attr.face = 'triangleLeft'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + } + (Data.getElementsByTagName('slopeTriangleSize')[0]) ? attr.slopeWidth = Data.getElementsByTagName('slopeTriangleSize')[0].getAttribute("val") : false; + (Data.getElementsByTagName('lineStyle')[0]) ? attr.strokeWidth = (Data.getElementsByTagName('lineStyle')[0].getAttribute("thickness")/2.0)+'px' : false; + if(attr.strokeWidth) { + attr.highlightStrokeWidth = (1*attr.strokeWidth.substr(0,attr.strokeWidth.length-2)+1)+'px'; + } + (Data.getElementsByTagName('lineStyle')[0]) ? attr.dashGGB = Data.getElementsByTagName('lineStyle')[0].getAttribute("type") : false; + + if(attr.dashGGB == 0) { + attr.dash = 0; + } + else if(attr.dashGGB == 10) { + attr.dash = 2; + } + else if(attr.dashGGB == 15) { + attr.dash = 3; + } + else if(attr.dashGGB == 20) { + attr.dash = 1; + } + else if(attr.dashGGB == 30) { + attr.dash = 6; + } + (Data.getElementsByTagName("labelOffset")[0]) ? attr.labelX = 1*Data.getElementsByTagName("labelOffset")[0].getAttribute("x") : false; + (Data.getElementsByTagName("labelOffset")[0]) ? attr.labelY = 1*Data.getElementsByTagName("labelOffset")[0].getAttribute("y") : false; + (Data.getElementsByTagName("trace")[0]) ? attr.trace = Data.getElementsByTagName("trace")[0].getAttribute("val") : false; + (Data.getElementsByTagName('fix')[0]) ? attr.fixed = Data.getElementsByTagName('fix')[0].getAttribute("val") : false; + return attr; +}; + +/** + * Searching for an element in the geogebra tree + * @param {String} the name of the element to search for + * @param {Boolean} whether it is search for an expression or not + * @return {Object} object with according label + */ +this.getElement = function(name, expr) { + var Data, i, j; + expr = expr || false; + for(i=0; i -1 || s[i].search(/[0-9]+$/) > -1 || s[i].search(/[a-zA-Z]+(\_*[a-zA-Z0-9]+)*$/) > -1) + if(s[i+1].search(/^\(/) > -1 || + s[i+1].search(/^[0-9]+/) > -1 || + s[i+1].search(/^[a-zA-Z]+(\_*[a-zA-Z0-9]+)*/) > -1 || + s[i+1].search(/\_\_[a-zA-Z0-9]+/) > -1) { + s[i] = s[i] + "*"; + } + o += s[i]; + }; + expr = o; + } + + output.push(expr); + return output; + } else { + return exp; + } + break; + case 's': + exp = exp.replace(/(?![e])x(?!\()(?![p])/g, '__x'); + return ['__x', exp]; + break; + default: + if(JXG.GeogebraReader.format <= 3.01) { + // prepare string: "solve" multiplications 'a b' to 'a*b' + s = exp.split(' '); + o = ''; + for(i=0; i -1 || s[i].search(/[0-9]+$/) > -1 || s[i].search(/[a-zA-Z]+(\_*[a-zA-Z0-9]+)*$/) > -1) + if(s[i+1].search(/^\(/) > -1 || + s[i+1].search(/^[0-9]+/) > -1 || + s[i+1].search(/^[a-zA-Z]+(\_*[a-zA-Z0-9]+)*/) > -1 || + s[i+1].search(/\_\_[a-zA-Z0-9]+/) > -1) { + s[i] = s[i] + "*"; + } + o += s[i]; + }; + exp = o; + } + return exp; + break; + } +}; + +/** + * Searching for an element in the geogebra tree + * @param {Object} board object + */ +this.writeBoard = function(board) { + var boardData = JXG.GeogebraReader.tree.getElementsByTagName("euclidianView")[0]; + + board.origin = {}; + board.origin.usrCoords = [1, 0, 0]; + board.origin.scrCoords = [1, 1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("xZero"), 1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("yZero")]; + board.unitX = (boardData.getElementsByTagName("coordSystem")[0].getAttribute("scale")) ? 1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("scale") : 1; + board.unitY = (boardData.getElementsByTagName("coordSystem")[0].getAttribute("yscale")) ? 1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("yscale") : board.unitX; + + board.fontSize = (JXG.GeogebraReader.tree.getElementsByTagName("gui")[0] && JXG.GeogebraReader.tree.getElementsByTagName("gui")[0].getElementsByTagName("font")[0]) ? 1*JXG.GeogebraReader.tree.getElementsByTagName("gui")[0].getElementsByTagName("font")[0].getAttribute("size") : '12px'; + + JXG.JSXGraph.boards[board.id] = board; + + // Update of properties during update() is not necessary in GEONExT files + board.renderer.enhancedRendering = true; + + // snap to point + var snapToPoint = (boardData.getElementsByTagName('evSettings')[0].getAttribute("pointCapturing") == "true"); + + var grid = (boardData.getElementsByTagName('evSettings')[0].getAttribute("grid") == "true") ? board.create('grid') : null; + + if(boardData.getElementsByTagName('evSettings')[0].getAttribute("axes") && boardData.getElementsByTagName('evSettings')[0].getAttribute("axes") == "true") { + board.ggbElements["xAxis"] = board.create('axis', [[0, 0], [1, 0]], {strokeColor:'black', minorTicks: 0}); + board.ggbElements["yAxis"] = board.create('axis', [[0, 0], [0, 1]], {strokeColor:'black', minorTicks: 0}); + } +}; + +/** + * Searching for an element in the geogebra tree + * @param {Object} board object + * @param {Object} ggb element whose attributes are to parse + * @param {Array} input list of all input elements + * @param {String} typeName output construction method + * @return {Object} return newly created element or false + */ +this.writeElement = function(board, output, input, cmd) { + var element, gxtEl, attr, p, exp, coord, type, points, border, length, m, s, e, sx, sy, ex, ey, func, range; + element = (JXG.isArray(output)) ? output[0] : output; + + gxtEl = {}; // geometric element + attr = {}; // Attributes of geometric elements + + JXG.debug(element); + + gxtEl.type = (element && element.attributes && typeof cmd === 'undefined') ? element.getAttribute('type').toLowerCase() : cmd; + gxtEl.label = element.getAttribute('label'); + attr.name = gxtEl.label; + + JXG.debug("
Konstruiere "+ attr.name +"("+ gxtEl.type +"):"); + + switch(gxtEl.type) { + case 'point': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + if(JXG.GeogebraReader.getElement(attr.name, true)) { + exp = JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp'); + coord = JXG.GeogebraReader.ggbParse(exp); + gxtEl.x = new Function('return '+ coord[0] +';'); + gxtEl.y = new Function('return '+ coord[1] +';'); + } else { + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + } + if(!JXG.exists(attr.styleGGB)) { + attr.face = 'circle'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + attr.highlightFillColor = attr.strokeColor; + attr.highlightFillOpacity = 1; + attr.strokeColor = 'black'; + attr.strokeWidth = '1px'; + } + + JXG.debug(gxtEl); + JXG.debug(input); + + try { + var ma = /Circle\[\s*(\w+)\s*,\s*([\d\.]+)\s*\]/.exec(input); + if(typeof input != 'undefined') { + if (ma!=null && ma.length==3) { + // from Circle[A, 5] take "A" and "5", stored in ma[1] and ma[2] + var q = JXG.GeogebraReader.checkElement(ma[1]); + var c = board.create('circle', [q, parseFloat(ma[2])], {fillColor:'none',visible:false,name:''}); + p = board.create('glider', [gxtEl.x, gxtEl.y, c], attr); + } else if(JXG.isArray(input)) { + p = board.create('glider', [gxtEl.x, gxtEl.y, input[0]], attr); + } else { + p = board.create('glider', [gxtEl.x, gxtEl.y, input], attr); + } + } else { + p = board.create('point', [gxtEl.x, gxtEl.y], attr); + } + return p; + } catch(e) { + JXG.debug("* Err: Point " + attr.name +"
\n"); + return false; + } + break; + case 'segment': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Segment: ("+ attr.name +") First: " + input[0].name + ", Last: " + input[1].name + "
\n"); + attr.straightFirst = false; + attr.straightLast = false; + p = board.create('line', input, attr); + return p; + } catch(e) { + JXG.debug("* Err: Segment " + attr.name +" First: " + input[0].name + ", Last: " + input[1].name + "
\n"); + return false; + } + break; + case 'line': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + type = 'line'; + if(!input) { + input = [ parseFloat(element.getElementsByTagName('coords')[0].getAttribute('z')), + parseFloat(element.getElementsByTagName('coords')[0].getAttribute('x')), + parseFloat(element.getElementsByTagName('coords')[0].getAttribute('y')) + ]; + } else if (JXG.getRef(board, input[1].id).elementClass == JXG.OBJECT_CLASS_LINE) { + type = 'parallel'; // Parallele durch Punkt + } + + try { + p = board.create(type, input, attr); + return p; + } catch(e) { + JXG.debug("* Err: Line " + attr.label +"
\n"); + return false; + } + break; + case "orthogonalline": + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Orthogonalline: First: " + input[0].id + ", Last: " + input[1].id + "
\n"); + p = board.create('normal', input, attr); + return p; + } catch(e) { + JXG.debug("* Err: Orthogonalline " + attr.label +"
\n"); + return false; + } + break; + case "polygon": + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + // test if polygon is regular + if(input.length == 3 && output.length != 4) { + input[2] = parseInt(input[2]); + type = 'regular'; + } + + try { + JXG.debug("* Polygon: First: " + input[0].name + ", Second: " + input[1].name + ", Third: " + input[2] + "
\n"); + + var borders = []; + var borderatts = []; + length = (type == 'regular') ? output.length-input[2]+2 : output.length; + + for(var i=1; iErr: Polygon " + attr.name +"
\n"); + return false; + } + break; + case 'intersect': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Intersection: First: " + input[0].name + ", Second: " + input[1].name + "
\n"); + if(!JXG.exists(attr.styleGGB)) { + attr.face = 'circle'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + attr.highlightFillColor = attr.strokeColor; + attr.highlightFillOpacity = 1; + attr.strokeColor = 'black'; + attr.strokeWidth = '1px'; + } + if(output.length == 1) { + p = board.create('intersection', [input[0], input[1], 0], attr); + } + else { + p = board.create('intersection', [input[0], input[1], 1], attr); + var attr2 = {}; + attr2 = JXG.GeogebraReader.colorProperties(output[1], attr2); + attr2 = JXG.GeogebraReader.visualProperties(output[1], attr2); + attr2.name = output[1].getAttribute('label'); + var p2 = board.create('otherintersection', [input[0], input[1], p], attr2); + board.ggbElements[attr2.name] = p2; + } + + return p; + } catch(e) { + JXG.debug("* Err: Intersection " + attr.name +"
\n"); + return false; + } + break; + case 'distance': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + + try { + JXG.debug("* Distance: First: " + input[0].name + ", Second: " + input[1].name + "
\n"); + + if(false && output[0].getAtribute('type') && output[0].getAttribute('type') == 'numeric') { + input[1].Value = function(){ return this.X(); }; + p = input[1]; + board.elementsByName[attr.name] = p; + } else { + m = board.create('midpoint', input, {visible: 'false'}); + attr.visible = 'true'; + p = board.create('text', [function(){return m.X();}, function(){return m.Y();}, function(){ + return ""+ input[0].name + input[1].name +" = " + + JXG.trimNumber(JXG.getRef(board, input[0].id).Dist(JXG.getRef(board, input[1].id)).toFixed(JXG.GeogebraReader.decimals)); + }], attr); + p.Value = function () { + return (JXG.getRef(board, input[0].id).Dist(JXG.getRef(board, input[1].id))); + } + } + return p; + } catch(e) { + JXG.debug("* Err: Distance " + attr.name +"
\n"); + return false; + } + break; + case 'vector': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + if(element.getElementsByTagName("startPoint")[0]) { + + if(input && input.length == 2) { + e = JXG.GeogebraReader.checkElement(input[1].name); + } else { + e = [parseFloat(element.getElementsByTagName("coords")[0].getAttribute("x")), parseFloat(element.getElementsByTagName("coords")[0].getAttribute("y"))]; + } + if(element.getElementsByTagName("startPoint")[0].getAttribute("x") && element.getElementsByTagName("startPoint")[0].getAttribute("y")) { + s = [parseFloat(element.getElementsByTagName("startPoint")[0].getAttribute("x")), parseFloat(element.getElementsByTagName("startPoint")[0].getAttribute("y"))]; + } else if(element.getElementsByTagName("startPoint")[0].getAttribute("exp")) { + var startpoint = element.getElementsByTagName("startPoint")[0].getAttribute("exp"); + s = JXG.GeogebraReader.checkElement(startpoint); + } + } else if(input && input.length != 0) { + s = input[0]; + e = input[1]; + } else { + exp = JXG.GeogebraReader.getElement(element.getAttribute('label'), true); + if(exp) {// experimental + exp = exp.getAttribute('exp'); + // exp = JXG.GeogebraReader.functionParse('', exp); + exp = JXG.GeogebraReader.ggbParse(exp); + if (JXG.isArray(exp)) + exp = new Array(new Function('return '+ exp[1] +';'), new Function('return '+ exp[2] +';')); + else + exp = new Function('return '+ exp +';'); + JXG.debug('exp: '+ exp); + p = board.create('arrow', [[0,0], [exp[0], exp[1]]], attr); + return p; + //t = JXG.getRef(board, 'a'); + //s = t.point1; + // var e = [-1*vector.point2.X(), -1*vector.point2.Y()]; + // attr.type = 'rotate'; + // var angle; + // if(exp < 0) { + // angle = Math.PI; + // } else if(exp == 0) { + // angle = 0; + // } else { + // angle = Math.PI/exp; + // } + // needed: a clean rotating based on factor 'exp' + + // priorization of expression like 't*a' --> a := startPoint + } + } + + try { + JXG.debug("* Vector: First: " + attr.name); + p = board.create('arrow', [s, e], attr); + return p; + } catch(e) { + JXG.debug("* Err: Vector " + attr.name + e +"
\n"); + return false; + } + break; + case 'rotate': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Rotate: First: " + input[0].name + ", Second: " + input[1] + "
\n"); + attr.type = 'rotate'; + + if(!JXG.exists(attr.styleGGB)) { + attr.face = 'circle'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + attr.highlightFillColor = attr.strokeColor; + attr.highlightFillOpacity = 1; + attr.strokeColor = 'black'; + attr.strokeWidth = '1px'; + } + + t = board.create('transform', [parseInt(input[1])*Math.PI/180, input[2]], {type:'rotate'}); + p = board.create('point', [input[0], t], attr); + return p; + } catch(e) { + JXG.debug("* Err: Rotate " + attr.name +"
\n"); + return false; + } + break; + case 'dilate': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Dilate: First: " + input[0].name + ", Second: " + input[1] + "
\n"); + attr.type = 'rotate'; + var d = parseInt(input[1]); + var d1 = board.create('transform', [d, d], {type:'scale'}); + var d2 = board.create('transform', [function() { return (1-d) * input[2].X(); }, + function() { return (1-d) * input[2].Y(); }], {type:'translate'}); + + if(!JXG.exists(attr.styleGGB)) { + attr.face = 'circle'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + attr.highlightFillColor = attr.strokeColor; + attr.highlightFillOpacity = 1; + attr.strokeColor = 'black'; + attr.strokeWidth = '1px'; + } + p = board.create('point', [input[0], [d1, d2]], attr); + + return p; + } catch(e) { + JXG.debug("* Err: Dilate " + attr.name +"
\n"); + return false; + } + break; + case 'translate': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + t = board.create('transform', [function() { return input[1].point2.X()-input[1].point1.X(); }, + function() { return input[1].point2.Y()-input[1].point1.Y(); }], {type:'translate'}); + if(!JXG.exists(attr.styleGGB)) { + attr.face = 'circle'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + attr.highlightFillColor = attr.strokeColor; + attr.highlightFillOpacity = 1; + attr.strokeColor = 'black'; + attr.strokeWidth = '1px'; + } + p = board.create('point', [input[0], t], attr); + return p; + } catch(e) { + JXG.debug("* Err: Translate " + attr.name +"
\n"); + return false; + } + break; + case 'mirror': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + if (JXG.isPoint(JXG.getRef(board, input[1].id))) var type = 'mirrorpoint'; // Punktspiegelung + else if(JXG.getRef(board, input[1].id).elementClass == JXG.OBJECT_CLASS_LINE) var type = 'reflection'; // Geradenspiegelung + + try { + JXG.debug("* Mirror: First: " + input[0].name + ", Second: " + input[1].name + "
\n"); + p = board.create(type, [input[1], input[0]], attr); + return p; + } catch(e) { + JXG.debug("* Err: Mirror " + attr.name +"
\n"); + return false; + } + break; + case 'circle': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Circle: First: " + input[0].name + ", Second: " + input[1] + "
\n"); + p = board.create('circle', input, attr); + return p; + } catch(e) { + JXG.debug("* Err: Circle " + attr.name +"
\n"); + return false; + } + break; + case 'circlearc': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* CircleArc: First: " + input[0].name + ", Second: " + input[1].name + "
\n"); + p = board.create('arc', input, attr); + return p; + } catch(e) { + JXG.debug("* Err: CircleArc " + attr.name +"
\n"); + return false; + } + break; + case 'ellipse': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Ellipse: First: " + input[0].name + ", Second: " + input[1].name + ", Third: "+ input[2] +"
\n"); + // if third parameters is the major axis, else the third parameter is a point + if(parseInt(input[2]) == input[2]) + input[2] = parseInt(input[2]*2); // Geogebra delivers the half major axis + + p = board.create('ellipse', input, attr); + return p; + } catch(e) { + JXG.debug("* Err: Ellipse " + attr.name +"
\n"); + return false; + } + break; + case 'conic': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + +// try { + /* + // is there an expression named like the conic? + var exp = JXG.GeogebraReader.getElement(attr.name, true); + + // then get the function parameteres + if(exp.attributes['exp']){ + // exp = JXG.GeogebraReader.functionParse(exp.attributes['exp'].value); + // exp = JXG.GeogebraReader.ggbParse(exp.attributes['exp'].value); + + + + // (exp.getElementsByTagName('value')) ? exp = parseFloat(exp.getElementsByTagName('value')[0].attributes['val'].value) : false; + + } else */ if(input && input.length == 5) { + p = board.create('conic', input, attr); + } else if(element.getElementsByTagName('matrix')) { + m = []; + for(var i=0; iErr: Conic " + attr.name +"
\n"); +// return false; +// } + break; + case 'circlesector': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + //attr.names = [attr.name,'','','']; + //attr2 = {}; + //attr2.names = attr.names; + try { + JXG.debug("* CircleSector: First: " + input[0].name + ", Second: " + input[1].name + ", Third: " + input[2].name + "
\n"); + p = board.create('sector', [input[0],input[1],input[2]], attr); + /* + p.point4.hideElement(); + p.arc.setProperty(attr); + p.arc.visProp.highlightstrokewidth = (1*p.arc.visProp.strokewidth.substr(0,p.arc.visProp.strokewidth.length-2)+1)+'px'; + p.lines[0].setProperty(attr); + p.lines[1].setProperty(attr); + p.lines[0].visProp.highlightstrokewidth = (1*p.lines[0].visProp.strokerwWidth.substr(0,p.lines[0].visProp.strokewidth.length-2)+1)+'px'; + p.lines[1].visProp.highlightstrokewidth = (1*p.lines[1].visProp.strokerwWidth.substr(0,p.lines[1].visProp.strokewidth.length-2)+1)+'px'; + p.arc.hasPoint = p.arc.hasPointSector; + p.arc.highlight = (function(el){ return function() { + this.board.renderer.highlight(this); + this.board.renderer.highlight(el.lines[0]); + this.board.renderer.highlight(el.lines[1]); + };})(p); + p.arc.noHighlight = (function(el){ return function() { + this.board.renderer.noHighlight(this); + this.board.renderer.noHighlight(el.lines[0]); + this.board.renderer.noHighlight(el.lines[1]); + };})(p); + p.lines[0].highlight = (function(el){ return function() { + this.board.renderer.highlight(this); + this.board.renderer.highlight(el.arc); + this.board.renderer.highlight(el.lines[1]); + };})(p); + p.lines[1].highlight = (function(el){ return function() { + this.board.renderer.highlight(this); + this.board.renderer.highlight(el.arc); + this.board.renderer.highlight(el.lines[0]); + };})(p); + p.lines[0].noHighlight = (function(el){ return function() { + this.board.renderer.noHighlight(this); + this.board.renderer.noHighlight(el.arc); + this.board.renderer.noHighlight(el.lines[1]); + };})(p); + p.lines[1].noHighlight = (function(el){ return function() { + this.board.renderer.noHighlight(this); + this.board.renderer.noHighlight(el.arc); + this.board.renderer.noHighlight(el.lines[0]); + };})(p); + */ + return p; + } catch(e) { + JXG.debug("* Err: CircleSector " + attr.name +"
\n"); + return false; + } + break; + case 'linebisector': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* LineBiSector (Mittelsenkrechte): First: " + input[0].name + "
\n"); + m = board.create('midpoint', input, {visible: false}); + if(JXG.isPoint(JXG.getRef(board, input[0].id)) && + JXG.isPoint(JXG.getRef(board, input[1].id))) { + t = board.create('line', input, {visible: 'false'}); + p = board.create('perpendicular', [m, t], attr); + // p.point.setProperty('visible:false'); + } else { + p = board.create('perpendicular', [m, input[0]], attr); + // p.point.setProperty('visible:false'); + } + return p; + } catch(e) { + JXG.debug("* Err: LineBiSector (Mittelsenkrechte) " + attr.name +"
\n"); + return false; + } + break; + case 'ray': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Ray: First: " + input[0].name + "
\n"); + attr.straightFirst = true; + attr.straightLast = false; + p = board.create('line', [input[1], input[0]], attr); + return p; + } catch(e) { + JXG.debug("* Err: Ray " + attr.name +"
\n"); + return false; + } + break; + case 'tangent': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Tangent: First: " + input[0].name + ", Sec.: "+ input[1].name +"("+ input[1].type +")
\n"); + switch(input[1].type) { + case 1330923344: // graph + input[0].makeGlider(input[1]); + p = board.create('tangent', [input[0]], attr); + return p; + break; + case 1330922316: // circle 0x4F54434C + case 1330922319: // conic 0x4F54434F + var pol = board.create('polar',[input[1],input[0]],{visible:false}); + var i1 = board.create('intersection', [input[1], pol, 0], {visible: false}); + var i2 = board.create('intersection', [input[1], pol, 1], {visible: false}); + var t1 = board.create('line', [input[0], i1], attr); + var attr2 = {}; + attr2 = JXG.GeogebraReader.colorProperties(output[1], attr2); + attr2 = JXG.GeogebraReader.visualProperties(output[1], attr2); + attr2.name = output[1].getAttribute('label'); + var t2 = board.create('line', [input[0], i2], attr2); + board.ggbElements[attr2.name] = t2; + return [t1, t2]; + break; + } + } catch(e) { + JXG.debug("* Err: Tangent " + attr.name +" "+ attr2.name + "
\n"); + return false; + } + break; + case 'circumcirclearc': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* CircumcircleArc: First: " + input[0].name + "
\n"); + p = board.create('circumcirclearc', input, attr); + return p; + } catch(e) { + JXG.debug("* Err: CircumcircleArc " + attr.name +"
\n"); + return false; + } + break; + case 'circumcirclesector': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* CircumcircleSector: First: " + input[0].name + "
\n"); + p = board.create('circumcirclesector', [input[0], input[1], input[2]], attr); //{name:attr['name']}); + /* + p.arc.setProperty(attr); + p.lines[0].setProperty(attr); + p.lines[1].setProperty(attr); + p.arc.visProp.highlightstrokewidth = (1*p.arc.visProp.strokewidth.substr(0,p.arc.visProp.strokewidth.length-2)+1)+'px'; + p.lines[0].visProp.highlightstrokewidth = (1*p.lines[0].visProp.strokewidth.substr(0,p.lines[0].visProp.strokewidth.length-2)+1)+'px'; + p.lines[1].visProp.highlightstrokewidth = (1*p.lines[1].visProp.strokewidth.substr(0,p.lines[1].visProp.strokewidth.length-2)+1)+'px'; + p.arc.hasPoint = p.arc.hasPointSector; + p.arc.highlight = (function(el){ return function() { + this.board.renderer.highlight(this); + this.board.renderer.highlight(el.lines[0]); + this.board.renderer.highlight(el.lines[1]); + };})(p); + p.arc.noHighlight = (function(el){ return function() { + this.board.renderer.noHighlight(this); + this.board.renderer.noHighlight(el.lines[0]); + this.board.renderer.noHighlight(el.lines[1]); + };})(p); + p.lines[0].highlight = (function(el){ return function() { + this.board.renderer.highlight(this); + this.board.renderer.highlight(el.arc); + this.board.renderer.highlight(el.lines[1]); + };})(p); + p.lines[1].highlight = (function(el){ return function() { + this.board.renderer.highlight(this); + this.board.renderer.highlight(el.arc); + this.board.renderer.highlight(el.lines[0]); + };})(p); + p.lines[0].noHighlight = (function(el){ return function() { + this.board.renderer.noHighlight(this); + this.board.renderer.noHighlight(el.arc); + this.board.renderer.noHighlight(el.lines[1]); + };})(p); + p.lines[1].noHighlight = (function(el){ return function() { + this.board.renderer.noHighlight(this); + this.board.renderer.noHighlight(el.arc); + this.board.renderer.noHighlight(el.lines[0]); + };})(p); + */ + return p; + } catch(e) { + JXG.debug("* Err: CircumcircleSector " + attr.name +"
\n"); + return false; + } + break; + case 'semicircle': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Semicircle: First: " + input[0].name + "
\n"); + p = board.create('semicircle', [input[0], input[1]], attr); + return p; + } catch(e) { + JXG.debug("* Err: Semicircle " + attr.name +"
\n"); + return false; + } + break; + case 'angle': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Angle: First: " + input[0].name + "
\n"); + p = board.create('angle', input, attr); + return p; + } catch(e) { + JXG.debug("* Err: Angle " + attr.name +"
\n"); + return false; + } + break; + case 'angularbisector': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + attr.straightFirst = true; + attr.straightLast = true; + + try { + JXG.debug("* Angularbisector: First: " + input[0].name + "
\n"); + p = board.create('bisector', input, attr); + return p; + } catch(e) { + JXG.debug("* Err: Angularbisector " + attr.name +"
\n"); + return false; + } + break; + case 'numeric': + if(element.getElementsByTagName('slider').length == 0) { + // auxiliary doesn't exist in every numeric + //element.getElementsByTagName('auxiliary').length != 0 && element.getElementsByTagName('auxiliary')[0].attributes['val'].value == 'true') { + exp = JXG.GeogebraReader.getElement(element.getAttribute('label'), true); + if(exp) { + exp = exp.getAttribute('exp'); + exp = JXG.GeogebraReader.functionParse('', exp); + exp = JXG.GeogebraReader.ggbParse(exp); + } + board.ggb[attr.name] = new Function('return '+ exp +';'); + JXG.debug('value: '+ board.ggb[attr.name]()); + return board.ggb[attr.name]; + } else { + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + // gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + if(element.getElementsByTagName('slider').length == 1) { // it's a slider + sx = parseFloat(element.getElementsByTagName('slider')[0].getAttribute('x')); + sy = parseFloat(element.getElementsByTagName('slider')[0].getAttribute('y')); + length = parseFloat(element.getElementsByTagName('slider')[0].getAttribute('width')); + // are coordinates absolut? + if(element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') && element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') == 'true') { + var tmp = new JXG.Coords(JXG.COORDS_BY_SCREEN, [sx, sy], board); + sx = tmp.usrCoords[1]; + sy = tmp.usrCoords[2]; + } + + if(element.getElementsByTagName('slider')[0].getAttribute('horizontal') == 'true') { + if(element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') && element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') == 'true') + length /= (board.unitX); //*board.zoomX); + ex = sx + length; + ey = sy; + } else { + if(element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') && element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') == 'true') + length /= (board.unitY); //*board.zoomY); + ex = sx; + ey = sy + length; + } + + (element.getElementsByTagName('animation')[0]) ? attr.snapWidth = parseFloat(element.getElementsByTagName('animation')[0].getAttribute('step')) : false; + + try { + JXG.debug("* Numeric: First: " + attr.name + "
\n"); + attr['withTicks'] = false; + p = board.create('slider', [[sx,sy], [ex,ey], [parseFloat(element.getElementsByTagName('slider')[0].getAttribute('min')), + parseFloat(element.getElementsByTagName('value')[0].getAttribute('val')), + parseFloat(element.getElementsByTagName('slider')[0].getAttribute('max'))]], attr); + p.setProperty({withLabel:false}); + return p; + } catch(e) { + JXG.debug("* Err: Numeric " + attr.name +"
\n"); + return false; + } + } + } + break; + case 'midpoint': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + if(!JXG.exists(attr.styleGGB)) { + attr.face = 'circle'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + attr.highlightFillColor = attr.strokeColor; + attr.highlightFillOpacity = 1; + attr.strokeColor = 'black'; + attr.strokeWidth = '1px'; + } + p = board.create('midpoint', input, attr); + JXG.debug("* Midpoint ("+ p.id +"): "+ attr.name + "("+ gxtEl.x +", "+ gxtEl.y +")
\n"); + return p; + } catch(e) { + JXG.debug("* Err: Midpoint " + attr.name +"
\n"); + return false; + } + break; + case 'center': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + try { + if(!JXG.exists(attr.styleGGB)) { + attr.face = 'circle'; + attr.fillColor = attr.strokeColor; + attr.fillOpacity = 1; + attr.highlightFillColor = attr.strokeColor; + attr.highlightFillOpacity = 1; + attr.strokeColor = 'black'; + attr.strokeWidth = '1px'; + } + p = board.create('point', [function() { return JXG.getRef(board, input[0].id).center.X(); }, + function() { return JXG.getRef(board, input[0].id).center.Y(); }], attr); + JXG.debug("* Center ("+ p.id +"): "+ attr.name + "("+ gxtEl.x +", "+ gxtEl.y +")
\n"); + return p; + } catch(e) { + JXG.debug("* Err: Center " + attr.name +"
\n"); + return false; + } + break; + case 'function': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + if(JXG.GeogebraReader.getElement(attr.name, true)) { + func = JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp'); + func = JXG.GeogebraReader.functionParse('c', func); + } else { + func = input[0]; + func = JXG.GeogebraReader.functionParse('s', func); + } + + JXG.debug(func); + + length = func.length; + func[func.length-1] = 'return '+ JXG.GeogebraReader.ggbParse(func[func.length-1]) +';'; + + JXG.debug(func); + + range = [(input && input[1]) ? input[1] : null, (input && input[2]) ? input[2] : null]; + + try { + if(length == 1) + p = board.create('functiongraph', [new Function(func[0]), range[0], range[1]], attr); + else if(length==2) + p = board.create('functiongraph', [new Function(func[0], func[1]), range[0], range[1]], attr); + else if(length==3) + p = board.create('functiongraph', [new Function(func[0], func[1], func[2]), range[0], range[1]], attr); + else if(length==4) + p = board.create('functiongraph', [new Function(func[0], func[1], func[2], func[3]), range[0], range[1]], attr); + else if(length==5) + p = board.create('functiongraph', [new Function(func[0], func[1], func[2], func[3], func[4]), range[0], range[1]], attr); + return p; + } catch(e) { + JXG.debug("* Err: Functiongraph " + attr.name +"
\n"); + return false; + } + + break; + case 'polar': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Polar: First: " + input[0].name + ", Sec.: "+ input[1].name +"
\n"); + p = board.create('polar', input, attr); + return p; + } catch(e) { + JXG.debug("* Err: Polar " + attr.name +"
\n"); + return false; + } + break; + case 'slope': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + + try { + JXG.debug("* Slope ("+ attr.name +"): First: " + input[0].name +"
\n"); + var slopeWidth = parseInt(attr.slopeWidth) || 1.0; + var p1 = input[0].glider || input[0].point1; + var p2 = board.create('point',[function(){return (slopeWidth+p1.X());}, function(){return p1.Y();}], {visible: false}); + var l1 = board.create('segment', [p1, p2], {visible: false}); // visible: attr.visible + var l2 = board.create('normal', [l1, l1.point2], {visible: false}); // visible attr.visible + var i = board.create('intersection', [input[0], l2, 0], {visible: false}); + var m = board.create('midpoint', [l1.point2, i], {visible: false}); + + var t = board.create('text', [function(){return m.X();}, function(){return m.Y();}, + function(){ return "  " + (slopeWidth > 1 ? slopeWidth.toString() : "") + " " + this.name + " = " + JXG.trimNumber((slopeWidth * input[0].getSlope()).toFixed(JXG.GeogebraReader.decimals)); }], attr); + attr.name = ""; + var t2 = board.create('text', [function(){return (p1.X() + p2.X())/2.;}, function(){return p1.Y();}, + function(){ return "
" + slopeWidth; }], attr); + t.Value = (function() { return function(){ return input[0].getSlope(); }; })(); + var poly = board.create('polygon',[p1,p2,i], attr); + + poly.borders[2].setProperty({visible: false}); + poly.borders[0].setProperty({strokeColor: attr.fillColor, strokeWidth: attr.strokeWidth, highlightStrokeColor: attr.fillColor, dash:attr.dash}); + poly.borders[1].setProperty({strokeColor: attr.fillColor, strokeWidth: attr.strokeWidth, highlightStrokeColor: attr.fillColor, dash:attr.dash}); + return t; + } catch(e) { + JXG.debug("* Err: Slope " + attr.name +"
\n"); + return false; + } + break; + case 'text': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + var rx, res = ''; + + try { + if(element.getElementsByTagName('isLaTeX')[0] && element.getElementsByTagName('isLaTeX')[0].getAttribute('val') == 'true') { + JXG.GeogebraReader.board.options.text.useASCIIMathML = true; + t = JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp'); + + // here we're searching for patterns like + // " + ... + " + // ... will be sent to the ggbParser and a calculated text element is built from this. + while(rx = t.match(/(.*?)" \+ (.+) \+ "(.*)/)) { + var re2 = JXG.GeogebraReader.ggbParse(RegExp.$2); + if (typeof re2 == 'string') { + res = res + RegExp.$1 + re2; + } else { + res = res + RegExp.$1 + '" + JXG.trimNumber((' + re2 + ').toFixed(JXG.GeogebraReader.decimals)) + "'; + } + t = RegExp.$3; + } + // we have to look, if the string's ending with a string-part or a formula part: + if(rx = t.match(/(.*?)" \+ (.+)/)) { + res = res + RegExp.$1 + '" + JXG.trimNumber((' + JXG.GeogebraReader.ggbParse(RegExp.$2) + ').toFixed(JXG.GeogebraReader.decimals))'; + } else + res = res + t; + + JXG.debug("Text: "+res); + + p = board.create('text', [gxtEl.x, gxtEl.y, new Function('return ' + res + ';')], attr); + } else { + JXG.debug(JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp')); + t = JXG.GeogebraReader.ggbParse(JXG.GeogebraReader.functionParse(false, JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp'))); + JXG.debug(t[1]); + p = board.create('text', [gxtEl.x, gxtEl.y, new Function('return '+t[0]+' + " " + JXG.trimNumber(parseFloat(' + t[1] +').toFixed(JXG.GeogebraReader.decimals));') ], attr); + } + JXG.debug("* Text: " + t +"
\n"); + return p; + } catch(e) { + JXG.debug("* Err: Text: " + t +"
\n"); + return false; + } + break; + case 'root': + attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); + attr = JXG.GeogebraReader.colorProperties(element, attr); + gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); + attr = JXG.GeogebraReader.visualProperties(element, attr); + //JXG.debug(JXG.getRef(board, gxtEl.id)); + + for(var i=0; iIntegral: First: " + input[0].name + ", Sec.: "+ input[1].name +", Thir.: "+ input[2].name +"
\n"); + JXG.debug([input[1](), input[2]()]); + var p = board.create('integral', [JXG.getRef(board, input[0]), [input[1], input[2]]], attr); + return p; + } catch(e) { + JXG.debug("* Err: Integral " + attr.name + e + "
\n"); + return false; + } + break; + +// case 'transform': +// break; +// case 'radius': +// break; +// case 'derivative': +// break; +// case 'root': +// break; +// case 'corner': +// break; +// case 'unitvector': +// break; +// case 'extremum': +// break; +// case 'turningpoint': +// break; +// case 'arc': +// break; +// case 'circlepart': +// break; +// case 'uppersum': +// break; +// case 'lowersum': +// break; +// case 'image': +// break; + default: + return false; + break; + } +}; + +/** + * Reading the elements of a geogebra file + * @param {Object} board board object + */ +this.readGeogebra = function(tree, board) { + var el, Data, i, els = [], expr; + + board.ggbElements = []; + board.ggb = {}; + JXG.GeogebraReader.tree = tree; + JXG.GeogebraReader.board = board; + JXG.GeogebraReader.format = parseFloat(JXG.GeogebraReader.tree.getElementsByTagName('geogebra')[0].getAttribute('format')); + JXG.GeogebraReader.decimals = parseInt(JXG.GeogebraReader.tree.getElementsByTagName('geogebra')[0].getElementsByTagName('kernel')[0].getElementsByTagName('decimals')[0].getAttribute('val')); + JXG.GeogebraReader.writeBoard(board); + board = JXG.GeogebraReader.setDefaultOptions(board); + + // speeding up the drawing process + //board.suspendUpdate(); + + var constructions = JXG.GeogebraReader.tree.getElementsByTagName("construction"); + for (var t=0; t"); + + /* register borders to according "parent" */ + if(board.ggbElements[elname].borders) + for(var i=0; i"); + }; + } + }; + + JXG.debug('Restesammler: '); + // create "single" elements which do not depend on any other + var elements = constructions[t].getElementsByTagName("element"); + for (var s=0; s=') : exp; + exp = (exp.match(/\u2227/)) ? exp.replace(/\u2227/g, '&&') : exp; + exp = (exp.match(/\u2228/)) ? exp.replace(/\u2228/g, '//') : exp; + return exp; +}; + +/** + * Extracting the packed geogebra file in order to return the "blank" xml-tree for further parsing. + * @param {String} archive containing geogebra.xml-file or raw input string (eg. xml-tree) + * @return {String} content of geogebra.xml-file if archive was passed in + */ +this.prepareString = function(fileStr, isString) { + var i, bA, len, fstr; + + // here we have to deal with two different base64 encoded streams + // first one: base64 encoded xml (geogebra's web export) + // second one: base64 encoded ggb file, this is our recommendation for an IE & Opera + // workaround, which can't deal with binary data transferred via AJAX. + + // first try to decode assuming we got a base64 encoded ggb file + if(isString) { + fstr = JXG.Util.Base64.decode(fileStr); + if(fstr.slice(0,2)!=="PK") { + // ooops, that was no ggb file. try again with utf8 parameter set. + fstr = JXG.Util.Base64.decode(fileStr, true); + } + fileStr = fstr; + } + + if (fileStr.indexOf('<') != 0) { + bA = []; + len = fileStr.length; + for (i=0;i. +*/ +JXG.debug = function() {}; +JXG.GeonextReader = { + + changeOriginIds: function (board, id) { + if ((id == 'gOOe0') || (id == 'gXOe0') || (id == 'gYOe0') || (id == 'gXLe0') || (id == 'gYLe0')) { + return board.id + id; + } else { + return id; + } + }, + + /** + * Retrieves data by TagName from an XML node. + * @param {Node} node The Node that contains the data we want to get. + * @param {String} tag The Name of the tag we are looking for. + * @param {Number} [idx=0] getElementsByTagName returns an array; This parameter decides which element to use. + * @param {Boolean} [fc=true] If True, the result will be the data of firstChild instead of the result node. + * @returns {String} The gathered data + */ + gEBTN: function (node, tag, idx, fc) { + var tmp; + + if (!JXG.exists(node || !node.getElementsByTagName )/* || !JXG.exists(node.getElementsByTagName)*/) { + return ''; + } + // Default values for optional parameters idx and fc + if (!JXG.exists(fc)) { + fc = true; + } + idx = idx || 0; + tmp = node.getElementsByTagName(tag); + if (tmp.length > 0) { + tmp = tmp[idx]; + if (fc && tmp.firstChild) { + tmp = tmp.firstChild.data; + } + } + return tmp; + }, + + /** + * Set color properties of a geonext element. + * Set stroke, fill, lighting, label and draft color attributes. + * @param {Object} gxtEl element of which attributes are to set + */ + colorProperties: function (gxtEl, Data) { + var color = this.gEBTN(Data, 'color', 0, false), + rgbo; + + //gxtEl.strokewidth = Data.getElementsByTagName('strokewidth')[0].firstChild.data; + // colorStroke = strokeColor etc. is here for downwards compatibility: + // once upon a time we used to create elements in here using the "new JXG.Element" constructor mechanism + // then we changed to board.create + setProperty afterwords + // now i want to use the board.create method with an appropriate attributes object to avoid setProperty calls + // and as gxtEl happens to be somewhat like an attributes object it's just slightly different so we adjust it + // for downwards compatibility during the transformation of this reader we use both properties + + rgbo = JXG.rgba2rgbo(this.gEBTN(color, 'stroke')); + gxtEl.strokeColor = rgbo[0]; + gxtEl.strokeOpacity = rgbo[1]; + + rgbo = JXG.rgba2rgbo(this.gEBTN(color, 'lighting')); + gxtEl.highlightStrokeColor = rgbo[0]; + gxtEl.highlightStrokeOpacity = rgbo[1]; + + rgbo = JXG.rgba2rgbo(this.gEBTN(color, 'fill')); + gxtEl.fillColor = rgbo[0]; + gxtEl.fillOpacity = rgbo[1]; + + gxtEl.highlightFillColor = gxtEl.fillColor; + gxtEl.highlightFillOpacity = gxtEl.fillOpacity; + + gxtEl.labelColor = JXG.rgba2rgbo(this.gEBTN(color, 'label'))[0]; + gxtEl.colorDraft = JXG.rgba2rgbo(this.gEBTN(color, 'draft'))[0]; + + // GEONExT hides labels by setting opacity to 0. + if (JXG.rgba2rgbo(this.gEBTN(color, 'label'))[1]==0) { + gxtEl.withLabel = false; + } else { + gxtEl.withLabel = true; + } + + // backwards compatibility + gxtEl.colorStroke = gxtEl.strokeColor; + gxtEl.colorFill = gxtEl.fillColor; + gxtEl.colorLabel = gxtEl.labelColor; + + return gxtEl; + }, + + firstLevelProperties: function (gxtEl, Data) { + if (!JXG.exists(Data) || !JXG.exists(Data.childNodes)) + return gxtEl; + + var arr = Data.childNodes, n, key; + + for (n = 0; n < arr.length; n++) { + if (JXG.exists(arr[n].firstChild) && arr[n].nodeName !== 'data' && arr[n].nodeName !== 'straight') { + key = arr[n].nodeName; + gxtEl[key] = arr[n].firstChild.data; + } + } + + return gxtEl; + }, + + /** + * Set the defining properties of a geonext element. + * Writing the nodeName to ident; setting the name attribute and defining the element id. + * @param {Object} gxtEl element of which attributes are to set + */ + defProperties: function (gxtEl, Data) { + // 3==TEXT_NODE, 8==COMMENT_NODE + if (Data.nodeType==3 || Data.nodeType==8 ) { + return null; + } + + gxtEl.ident = Data.nodeName; + + if(gxtEl.ident == "text" || gxtEl.ident == "intersection" || gxtEl.ident == "composition") { + gxtEl.name = ''; + } else { + gxtEl.name = this.gEBTN(Data, 'name'); + } + + gxtEl.id = this.gEBTN(Data, 'id'); + + return gxtEl; + }, + + visualProperties: function (gxtEl, Data) { + gxtEl.visible = JXG.str2Bool(this.gEBTN(Data, 'visible')); + gxtEl.trace = JXG.str2Bool(this.gEBTN(Data, 'trace')); + + return gxtEl; + }, + + transformProperties: function (gxtEl, type) { + var facemap = [ + // 0-2 + 'cross', 'cross', 'cross', + // 3-6 + 'circle', 'circle', 'circle', 'circle', + // 7-9 + 'square', 'square', 'square', + // 10-12 + 'plus', 'plus', 'plus' + ], sizemap = [ + // 0-2 + 2, 3, 4, + // 3-6 + 1, 2, 3, 4, + // 7-9 + 2, 3, 4, + // 10-12 + 2, 3, 4 + ]; + + gxtEl.strokeWidth = gxtEl.strokewidth; + gxtEl.face = facemap[parseInt(gxtEl.style, 10)] || 'cross'; + gxtEl.size = sizemap[parseInt(gxtEl.style, 10)] || 3; + + gxtEl.straightFirst = JXG.str2Bool(gxtEl.straightFirst); + gxtEl.straightLast = JXG.str2Bool(gxtEl.straightLast); + + gxtEl.visible = JXG.str2Bool(gxtEl.visible); + //gxtEl.withLabel = gxtEl.visible; // withLabel is set in colorProperties() + gxtEl.draft = JXG.str2Bool(gxtEl.draft); + gxtEl.trace = JXG.str2Bool(gxtEl.trace); + + if (type==='point') { + // Fill properties are ignored by GEONExT + gxtEl.fillColor = gxtEl.strokeColor; + gxtEl.highlightFillColor = gxtEl.highlightStrokeColor; + gxtEl.fillOpacity = gxtEl.strokeOpacity; + gxtEl.highlightFillOpacity = gxtEl.highlightStrokeOpacity; + } + + if (typeof(gxtEl.label === 'string')) { + delete(gxtEl.label); + } + + delete gxtEl.color; + return gxtEl; + }, + + readNodes: function (gxtEl, Data, nodeType, prefix) { + var arr = this.gEBTN(Data, nodeType, 0, false).childNodes, + key, n; + + for (n = 0; n < arr.length; n++) { + if (arr[n].firstChild != null) { + if (prefix != null) { + key = prefix + JXG.capitalize(arr[n].nodeName); + } else { + key = arr[n].nodeName; + } + gxtEl[key] = arr[n].firstChild.data; + } + } + return gxtEl; + }, + + subtreeToString: function (root) { + try { + // firefox + return (new XMLSerializer()).serializeToString(root); + } catch (e) { + // IE + return root.xml; + } + }, + + readImage: function (node) { + var pic = '', + nod = node; + + if (nod != null) { + pic = nod.data; + while (nod.nextSibling != null) { + nod = nod.nextSibling; + pic += nod.data; + } + } + return pic; + }, + + parseImage: function (board, fileNode, level, x, y, w, h, el) { + var tag, id, im, picStr, tmpImg; + + if (fileNode == null) { + return null; + } + + if (fileNode.getElementsByTagName('src')[0] != null) { // Background image + tag = 'src'; + } else if (fileNode.getElementsByTagName('image')[0] != null) { + tag = 'image'; + } else { + return null; + } + + picStr = this.readImage(this.gEBTN(fileNode, tag, 0, false).firstChild); + if (picStr!='') { + picStr = 'data:image/png;base64,' + picStr; + if (tag=='src') { // Background image + x = this.gEBTN(fileNode, 'x'); + y = this.gEBTN(fileNode, 'y'); + w = this.gEBTN(fileNode, 'width'); + h = this.gEBTN(fileNode, 'height'); + im = board.create('image', [picStr,[x, y],[w, h]], { + anchor: el, layer: level + }); + return im; + } else { + // Image bound to an element + // Read the original dimensions, i.e. the ratio h/w with the help of a temporary image. + // We have to wait until the image is loaded, therefore + // we need "onload". + tmpImg = new Image(); + tmpImg.src = picStr; + id = el.id + '_image'; + tmpImg.onload = function(){ + // Now, we can read the original dimensions of the image. + var wOrg = this.width, + hOrg = this.height, + xf, yf, wf, hf, im, tRot; + + if (el.elementClass == JXG.OBJECT_CLASS_LINE) { + // A line containing an image, runs through the horizontal middle + // of the image. + xf = function(){ return el.point1.X(); }; + wf = function(){ return el.point1.Dist(el.point2); }; + hf = function(){ return wf() * hOrg / wOrg; }; + yf = function(){ return el.point1.Y() - hf() * 0.5; }; + im = board.create('image', [picStr, [xf,yf], [wf,hf]], { + layer: level, + id: id, + anchor: el + }); + tRot = board.create('transform', [ + function () { + return Math.atan2(el.point2.Y()-el.point1.Y(), el.point2.X()-el.point1.X()) + }, + el.point1 + ], { + type:'rotate' + }); + tRot.bindTo(im); + el.image = im; + } else if (el.elementClass == JXG.OBJECT_CLASS_POINT) { + wf = function(){ return wOrg / board.unitX; }; + hf = function(){ return hOrg / board.unitY; }; + xf = function(){ return el.X() - wf() * 0.5; }; + yf = function(){ return el.Y() - hf() * 0.5; }; + + im = board.create('image', [picStr, [xf,yf], [wf,hf]], { + layer: level, + id: id, + anchor: el + }); + board.renderer.hide(el.label.content); + el.image = im; + } else if (el.elementClass == JXG.OBJECT_CLASS_CIRCLE) { + // A circle containing an image + wf = function(){ return 2.0 * el.Radius(); }; + hf = function(){ return wf() * hOrg / wOrg; }; + xf = function(){ return el.center.X() - wf() * 0.5; }; + yf = function(){ return el.center.Y() - hf() * 0.5; }; + im = board.create('image', [picStr, [xf,yf], [wf,hf]], { + layer: level, + id: id, + anchor: el + }); + el.image = im; + } else { + im = board.create('image', [picStr, [x, y], [w, h]], { + layer: level, + id: id, + anchor: el + }); + el.image = im; + } + }; + } + return im; + } + }, + + readConditions: function(node) { + var i, s, ob, + conditions = ''; + + if (JXG.exists(node)) { + for(i = 0; i < node.getElementsByTagName('data').length; i++) { + ob = node.getElementsByTagName('data')[i]; + s = this.subtreeToString(ob); + conditions += s; + } + } + + return conditions; + }, + + printDebugMessage: function(outputEl,gxtEl,nodetyp,success) { + JXG.debug("* " + success + ": " + nodetyp + " " + gxtEl.name + " " + gxtEl.id + "
\n"); + }, + + /** + * Reading the elements of a geonext file + * @param {XMLTree} tree expects the content of the parsed geonext file returned by function parseFF/parseIE + * @param {Object} board board object + */ + readGeonext: function(tree, board) { + var xmlNode, elChildNodes, + s, Data, inter, boardData, el, p, + conditions, tmp, strTrue = 'true', gxtReader = this; + + // maybe this is not necessary as we already provide layer options for sectors and circles via JXG.Options but + // maybe these have to be the same for geonext. + board.options.layer.sector = board.options.layer.angle; + board.options.layer.circle = board.options.layer.angle; + + board.options.line.label.position = 'top'; + + boardData = this.gEBTN(tree, 'board', 0, false); + conditions = this.readConditions(boardData.getElementsByTagName('conditions')[0]); + + // set the origin + xmlNode = this.gEBTN(boardData, 'coordinates', 0, false); + tmp = this.gEBTN(xmlNode, 'origin', 0, false); + board.origin = { + usrCoords: [1, 0, 0], + scrCoords: [1, parseFloat(this.gEBTN(tmp, 'x')), parseFloat(this.gEBTN(tmp, 'y'))] + }; + + // zoom level + tmp = this.gEBTN(xmlNode, 'zoom', 0, false); + board.zoomX = parseFloat(this.gEBTN(tmp, 'x')); + board.zoomY = parseFloat(this.gEBTN(tmp, 'y')); + + // screen to user coordinates conversion + tmp = this.gEBTN(xmlNode, 'unit', 0, false); + board.unitX = parseFloat(this.gEBTN(tmp, 'x')); + board.unitY = parseFloat(this.gEBTN(tmp, 'y')); + + // resize board + if (board.options.takeSizeFromFile) { + board.resizeContainer(this.gEBTN(boardData, 'width'), this.gEBTN(boardData, 'height')); + } + + // check and set fontSize + if (!(parseFloat(board.options.text.fontSize) > 0)) { + board.options.text.fontSize = 12; + } + + board.geonextCompatibilityMode = true; + + // jsxgraph chooses an id for the board but we don't want to use it, we want to use + // the id stored in the geonext file. if you know why this is required, please note it here. + delete(JXG.JSXGraph.boards[board.id]); + board.id = this.gEBTN(boardData, 'id'); + JXG.JSXGraph.boards[board.id] = board; + + // this creates some basic elements present in every geonext construction but not explicitly present in the file + board.initGeonextBoard(); + + // Update of properties during update() is not necessary in GEONExT files + // But it maybe necessary if we construct with JavaScript afterwards + board.renderer.enhancedRendering = true; + + // Read background image + this.parseImage(board, this.gEBTN(boardData, 'file', 0, false), board.options.layer['image']); + + board.options.point.snapToGrid = (this.gEBTN(this.gEBTN(boardData, 'coordinates', 0, false), 'snap') == strTrue); + // + // TODO: Missing jsxgraph feature snapToPoint + // If snapToGrid and snapToPoint are both true, point snapping is enabled + if (board.options.point.snapToGrid && this.gEBTN(this.gEBTN(boardData, 'grid', 1, false), 'pointsnap') == strTrue) { + board.options.point.snapToGrid = false; + board.options.point.snapToPoints = true; + board.options.point.attractorDistance = 0.5; + } + //board.options.grid.snapToGrid = false; + + xmlNode = this.gEBTN(boardData, 'grid', 1, false); + tmp = this.gEBTN(xmlNode, 'x'); + if (tmp) { + board.options.grid.gridX = 1 / parseFloat(tmp); + board.options.point.snapSizeX = parseFloat(tmp); + } + tmp = this.gEBTN(xmlNode, 'y'); + if (tmp) { + board.options.grid.gridY = 1 / parseFloat(tmp); + board.options.point.snapSizeY = parseFloat(tmp); + } + //board.calculateSnapSizes(); // Seems not to be correct + board.options.grid.gridDash = JXG.str2Bool(this.gEBTN(xmlNode, 'dash')); + + tmp = JXG.rgba2rgbo(this.gEBTN(xmlNode, 'color')); + board.options.grid.gridColor = tmp[0]; + board.options.grid.gridOpacity = tmp[1]; + + xmlNode = this.gEBTN(boardData, 'coordinates', 0, false); + if (this.gEBTN(xmlNode, 'grid') == strTrue) { + board.create('grid', []); + } + + if (this.gEBTN(xmlNode, 'coord') == strTrue) { + board.options.axis.ticks.majorHeight = 10; // Hard coded default option + board.options.axis.ticks.minorHeight = 4; // Hard coded default option + board.create('axis', [[0, 0], [1, 0]]); + board.create('axis', [[0, 0], [0, 1]]); + } + + board.containerObj.style.backgroundColor = JXG.rgba2rgbo(this.gEBTN(this.gEBTN(boardData, 'background', 0, false), 'color'))[0]; + + elChildNodes = tree.getElementsByTagName("elements")[0].childNodes; + for (s = 0; s < elChildNodes.length; s++) { + (function (s) { + var i, gxtEl = {}, + l, x, y, c, numberDefEls, + el, p, inter, rgbo, tmp; + + Data = elChildNodes[s]; + gxtEl = gxtReader.defProperties(gxtEl, Data); + + // Skip text nodes + if (!JXG.exists(gxtEl)) { + return; + } + + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName.toLowerCase, 'READ:'); + switch (Data.nodeName.toLowerCase()) { + case "point": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + gxtEl.fixed = JXG.str2Bool(gxtReader.gEBTN(Data, 'fix')); + gxtEl = gxtReader.transformProperties(gxtEl, 'point'); + + //try { + p = board.create('point', [parseFloat(gxtEl.x), parseFloat(gxtEl.y)], gxtEl); + + var v = function(){ return p.visProp.visible; }; + el = gxtReader.parseImage(board, Data, board.options.layer['image'], 0, 0, 0, 0, p); + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + /* + if (JXG.exists(el)) { + el.visProp.visible = function() { return p.visProp.visible; }; + alert(p.visProp.visible); + if (el.visProp.visible()) {el.showElement();} else {el.hideElement();} + } + */ + //} catch(e) { + // JXG.debug(e); + //} + break; + case "line": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + gxtEl = gxtReader.readNodes(gxtEl, Data, 'straight', 'straight'); + gxtEl = gxtReader.transformProperties(gxtEl); + + gxtEl.first = gxtReader.changeOriginIds(board, gxtEl.first); + gxtEl.last = gxtReader.changeOriginIds(board, gxtEl.last); + + l = board.create('line', [gxtEl.first, gxtEl.last], gxtEl); + + gxtReader.parseImage(board, Data, board.options.layer['image'], 0, 0, 0, 0, l); + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case "circle": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + + tmp = gxtReader.gEBTN(Data, 'data', 0, false); + gxtEl.center = gxtReader.changeOriginIds(board, gxtReader.gEBTN(tmp, 'midpoint')); + + if (tmp.getElementsByTagName('radius').length > 0) { + gxtEl.radius = gxtReader.changeOriginIds(board, gxtReader.gEBTN(tmp, 'radius')); + } else if (tmp.getElementsByTagName('radiusvalue').length > 0) { + gxtEl.radius = gxtReader.gEBTN(tmp, 'radiusvalue'); + } + gxtEl = gxtReader.transformProperties(gxtEl); + c = board.create('circle', [gxtEl.center, gxtEl.radius], gxtEl); + + gxtReader.parseImage(board, Data, board.options.layer['image'], 0, 0, 0, 0, c); + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case "slider": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + gxtEl.fixed = JXG.str2Bool(gxtReader.gEBTN(Data, 'fix')); + gxtEl = gxtReader.readNodes(gxtEl, Data, 'animate', 'animate'); + gxtEl = gxtReader.transformProperties(gxtEl, 'point'); + try { + gxtEl.parent = gxtReader.changeOriginIds(board, gxtEl.parent); + + // if (board.isSuspendedUpdate) { board.unsuspendUpdate().suspendUpdate(); } + p = board.create('glider', [parseFloat(gxtEl.x), parseFloat(gxtEl.y), gxtEl.parent], gxtEl); + p.onPolygon = JXG.exists(gxtEl.onpolygon) && JXG.str2Bool(gxtEl.onpolygon); + + gxtReader.parseImage(board, Data, board.options.layer['point'], 0, 0, 0, 0, p); + + //if (board.isSuspendedUpdate) { board.unsuspendUpdate().suspendUpdate(); } + + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + } catch(e) { + JXG.debug("* Err: Slider " + gxtEl.name + " " + gxtEl.id + ': '+ gxtEl.parent +"
\n"); + } + break; + case "cas": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl.fixed = JXG.str2Bool(Data.getElementsByTagName('fix')[0].firstChild.data); + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + gxtEl = gxtReader.transformProperties(gxtEl, 'point'); + + if (false) { // Handle weird element names + gxtEl.x = JXG.GeonextParser.gxt2jc(gxtEl.x, board); + gxtEl.y = JXG.GeonextParser.gxt2jc(gxtEl.y, board); + } else { // Workaround until the jessiecode compiler is 100% compatible + gxtEl.x = JXG.GeonextParser.geonext2JS(gxtEl.x, board); + gxtEl.x = new Function('return ' + gxtEl.x + ';'); + gxtEl.y = JXG.GeonextParser.geonext2JS(gxtEl.y, board); + gxtEl.y = new Function('return ' + gxtEl.y + ';'); + } + + /* + p = board.create('point', [parseFloat(gxtEl.xval), parseFloat(gxtEl.yval)], gxtEl); + p.addConstraint([gxtEl.x, gxtEl.y]); + p.type = JXG.OBJECT_TYPE_CAS; + */ + p = board.create('point', [gxtEl.x, gxtEl.y], gxtEl); + gxtReader.parseImage(board, Data, board.options.layer['point'], 0, 0, 0, 0, p); + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case "intersection": + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + xmlNode = Data.getElementsByTagName('first')[1]; + + gxtEl.outFirst = {}; + gxtEl.outFirst = gxtReader.colorProperties(gxtEl.outFirst, xmlNode); + gxtEl.outFirst = gxtReader.visualProperties(gxtEl.outFirst, xmlNode); + gxtEl.outFirst = gxtReader.firstLevelProperties(gxtEl.outFirst, xmlNode); + gxtEl.outFirst.fixed = JXG.str2Bool(xmlNode.getElementsByTagName('fix')[0].firstChild.data); + gxtEl.outFirst = gxtReader.transformProperties(gxtEl.outFirst, 'point'); + gxtEl.first = gxtReader.changeOriginIds(board, gxtEl.first); + gxtEl.last = gxtReader.changeOriginIds(board, gxtEl.last); + + //if ((board.objects[gxtEl.first].type == JXG.OBJECT_TYPE_LINE || board.objects[gxtEl.first].type == JXG.OBJECT_TYPE_ARROW) + // && (board.objects[gxtEl.last].type == JXG.OBJECT_TYPE_LINE || board.objects[gxtEl.last].type == JXG.OBJECT_TYPE_ARROW)) { + if ((JXG.getReference(board, gxtEl.first).elementClass == JXG.OBJECT_CLASS_LINE) + && (JXG.getReference(board, gxtEl.last).elementClass == JXG.OBJECT_CLASS_LINE)) { + /* + inter = new JXG.Intersection(board, gxtEl.id, board.objects[gxtEl.first], + board.objects[gxtEl.last], gxtEl.outFirst.id, '', + gxtEl.outFirst.name, ''); + inter.p.setProperty(gxtEl.outFirst); + */ + inter = board.create('intersection', [board.objects[gxtEl.first], board.objects[gxtEl.last], 0], gxtEl.outFirst); + /* offensichtlich braucht man dieses if doch */ + if (gxtEl.outFirst.visible == "false") { + inter.hideElement(); + } + } else { + xmlNode = Data.getElementsByTagName('last')[1]; + if (JXG.exists(xmlNode)) { + gxtEl.outLast = {}; + gxtEl.outLast = gxtReader.colorProperties(gxtEl.outLast, xmlNode); + gxtEl.outLast = gxtReader.visualProperties(gxtEl.outLast, xmlNode); + gxtEl.outLast = gxtReader.firstLevelProperties(gxtEl.outLast, xmlNode); + gxtEl.outLast.fixed = JXG.str2Bool(xmlNode.getElementsByTagName('fix')[0].firstChild.data); + gxtEl.outLast = gxtReader.transformProperties(gxtEl.outLast, 'point'); + /* + inter = new JXG.Intersection(board, gxtEl.id, board.objects[gxtEl.first], + board.objects[gxtEl.last], gxtEl.outFirst.id, gxtEl.outLast.id, + gxtEl.outFirst.name, gxtEl.outLast.name); + inter.p1.setProperty(gxtEl.outFirst); + inter.p2.setProperty(gxtEl.outLast); + */ + inter = board.create('intersection', [board.objects[gxtEl.first], board.objects[gxtEl.last], 0], gxtEl.outFirst); + inter = board.create('intersection', [board.objects[gxtEl.first], board.objects[gxtEl.last], 1], gxtEl.outLast); + } + } + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case "composition": + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl.defEl = []; + numberDefEls = 0; + xmlNode = Data.getElementsByTagName('data')[0].getElementsByTagName('input'); + for (i = 0; i < xmlNode.length; i++) { + gxtEl.defEl[i] = xmlNode[i].firstChild.data; + numberDefEls = i + 1; + } + + // every composition produces at least one element and the data for this element is stored + // in gxtEl.out. if additional elements are created their data is read in the according case. + xmlNode = Data.getElementsByTagName('output')[0]; + gxtEl.out = {}; + gxtEl.out = gxtReader.colorProperties(gxtEl.out, xmlNode); + gxtEl.out = gxtReader.visualProperties(gxtEl.out, xmlNode); + gxtEl.out = gxtReader.firstLevelProperties(gxtEl.out, xmlNode); + gxtEl.out = gxtReader.transformProperties(gxtEl.out); + + gxtEl.defEl[0] = gxtReader.changeOriginIds(board, gxtEl.defEl[0]); + gxtEl.defEl[1] = gxtReader.changeOriginIds(board, gxtEl.defEl[1]); + gxtEl.defEl[2] = gxtReader.changeOriginIds(board, gxtEl.defEl[2]); + + // if (board.isSuspendedUpdate) { board.unsuspendUpdate().suspendUpdate(); } + switch (gxtEl.type) { + // ARROW_PARALLEL + case "210070": + gxtEl.out.fixed = gxtReader.gEBTN(xmlNode, 'fix'); + + xmlNode = Data.getElementsByTagName('output')[1]; + gxtEl.outPoint = {}; + gxtEl.outPoint = gxtReader.defProperties(gxtEl.outPoint, xmlNode); + gxtEl.outPoint = gxtReader.colorProperties(gxtEl.outPoint, xmlNode); + gxtEl.outPoint = gxtReader.visualProperties(gxtEl.outPoint, xmlNode); + gxtEl.outPoint = gxtReader.firstLevelProperties(gxtEl.outPoint, xmlNode); + gxtEl.outPoint = gxtReader.transformProperties(gxtEl.outPoint); + gxtEl.out.point = gxtEl.outPoint; + + board.create('arrowparallel', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); + break; + + // BISECTOR + case "210080": + gxtEl.out.straightFirst = false; + board.create('bisector', [gxtEl.defEl[0], gxtEl.defEl[1], gxtEl.defEl[2]], gxtEl.out); + break; + + // CIRCUMCIRCLE + case "210090": + xmlNode = Data.getElementsByTagName('output')[1]; + gxtEl.outCircle = {}; + gxtEl.outCircle = gxtReader.defProperties(gxtEl.outCircle, xmlNode); + gxtEl.outCircle = gxtReader.colorProperties(gxtEl.outCircle, xmlNode); + gxtEl.outCircle = gxtReader.visualProperties(gxtEl.outCircle, xmlNode); + gxtEl.outCircle = gxtReader.firstLevelProperties(gxtEl.outCircle, xmlNode); + gxtEl.outCircle = gxtReader.transformProperties(gxtEl.outCircle); + gxtEl.outCircle.point = gxtEl.out; + board.create('circumcircle', [gxtEl.defEl[0], gxtEl.defEl[1], gxtEl.defEl[2]], gxtEl.outCircle); + break; + + // CIRCUMCIRCLE_CENTER + case "210100": + board.create('circumcenter', [gxtEl.defEl[0], gxtEl.defEl[1], gxtEl.defEl[2]], gxtEl.out); + break; + + // MIDPOINT + case "210110": + board.create('midpoint', gxtEl.defEl.slice(0, numberDefEls), gxtEl.out); + break; + + // MIRRORLINE + case "210120": + board.create('reflection', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); + break; + + // MIRROR_POINT + case "210125": + board.create('mirrorpoint', [gxtEl.defEl[0], gxtEl.defEl[1]], gxtEl.out); + break; + + // NORMAL + case "210130": + //board.create('normal', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); + board.create('perpendicularsegment', [gxtEl.defEl[0], gxtEl.defEl[1]], gxtEl.out); + break; + + // PARALLEL + case "210140": + p = board.create('parallelpoint', [gxtEl.defEl[1], gxtEl.defEl[0]], + {withLabel:false, visible:false, name:'', fixed:true}); + + // GEONExT uses its own parallel construction to make the order + // of intersection points compatible. + // el = board.create('parallel', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); + el = board.create('line', [gxtEl.defEl[0], p], gxtEl.out); + el.parallelpoint = p; + break; + + // PARALLELOGRAM_POINT + case "210150": + board.create('parallelpoint', gxtEl.defEl.slice(0, numberDefEls), gxtEl.out); + break; + + // PERPENDICULAR + case "210160": + // output[0] was already read and is stored in gxtEl.out + gxtEl.out.fixed = gxtReader.gEBTN(xmlNode, 'fix'); + + xmlNode = Data.getElementsByTagName('output')[1]; + gxtEl.outLine = {}; + gxtEl.outLine = gxtReader.defProperties(gxtEl.outLine, xmlNode); + gxtEl.outLine = gxtReader.colorProperties(gxtEl.outLine, xmlNode); + gxtEl.outLine = gxtReader.visualProperties(gxtEl.outLine, xmlNode); + gxtEl.outLine = gxtReader.firstLevelProperties(gxtEl.outLine, xmlNode); + gxtEl.outLine = gxtReader.readNodes(gxtEl.outLine, xmlNode, 'straight', 'straight'); + gxtEl.outLine = gxtReader.transformProperties(gxtEl.outLine); + gxtEl.outLine.point = gxtEl.out; + + board.create('perpendicularsegment', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.outLine); + break; + + // PERPENDICULAR_POINT + case "210170": + board.create('perpendicularpoint', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); + break; + + // ROTATION + case "210180": + throw new Error('JSXGraph: Element ROTATION not yet implemented.'); + break; + + // SECTOR + case "210190": + // sectors usually provide more than one output element but JSXGraph is not fully compatible + // to GEONExT sector elements. GEONExT sectors consist of two lines, a point, and a sector, + // JSXGraph uses a curve to display the sector incl. the borders, and + // a point and two lines. + // Gliders on sectors also run through the borders. + gxtEl.out = gxtReader.defProperties(gxtEl.out, xmlNode); + gxtEl.out.firstArrow = JXG.str2Bool(gxtReader.gEBTN(xmlNode, 'firstarrow')); + gxtEl.out.lastArrow = JXG.str2Bool(gxtReader.gEBTN(xmlNode, 'lastarrow')); + + // el = board.create('sector', gxtEl.defEl, gxtEl.out); + for (i=0; i<4;i++) { + xmlNode = Data.getElementsByTagName('output')[i]; + gxtEl.out = gxtReader.defProperties(gxtEl.out, xmlNode); + gxtEl.out = gxtReader.colorProperties(gxtEl.out, xmlNode); + gxtEl.out = gxtReader.visualProperties(gxtEl.out, xmlNode); + gxtEl.out = gxtReader.firstLevelProperties(gxtEl.out, xmlNode); + gxtEl.out = gxtReader.transformProperties(gxtEl.out); + + if (i==0) { + el = board.create('sector', gxtEl.defEl, gxtEl.out); + } else if (i==1) { + p = board.create('point', [ + function(){ + var p1 = JXG.getRef(board,gxtEl.defEl[1]), p2 = JXG.getRef(board,gxtEl.defEl[2]); + return p1.X() + (p2.X()-p1.X())*el.Radius/p1.Dist(p2); + }, + function(){ + var p1 = JXG.getRef(board,gxtEl.defEl[1]), p2 = JXG.getRef(board,gxtEl.defEl[2]); + return p1.Y() + (p2.Y()-p1.Y())*el.Radius/p1.Dist(p2); + }], gxtEl.out); + //p = JXG.getReference(board,gxtEl.defEl[2]); + } else if (i==2) { + el = board.create('segment', [gxtEl.defEl[0], gxtEl.defEl[1]], gxtEl.out); + } else if (i==3) { + el = board.create('segment', [gxtEl.defEl[1], p], gxtEl.out); + } + } + break; + default: + throw new Error("JSXGraph: GEONExT-Element " + gxtEl.type + ' not implemented.'); + break; + } + + // if (board.isSuspendedUpdate) { board.unsuspendUpdate().suspendUpdate(); } + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case "polygon": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + var dataVertex = []; + // In Geonext file format the first vertex is equal to the last vertex: + for (i = 0; i < Data.getElementsByTagName('data')[0].getElementsByTagName('vertex').length-1; i++) { + dataVertex[i] = Data.getElementsByTagName('data')[0].getElementsByTagName('vertex')[i].firstChild.data; + dataVertex[i] = gxtReader.changeOriginIds(board, dataVertex[i]); + } + gxtEl.border = []; + gxtEl.borders = { + ids: [] + }; + for (i = 0; i < Data.getElementsByTagName('border').length; i++) { + gxtEl.border[i] = {}; + xmlNode = Data.getElementsByTagName('border')[i]; + gxtEl.border[i].id = xmlNode.getElementsByTagName('id')[0].firstChild.data; + gxtEl.borders.ids.push(gxtEl.border[i].id); + gxtEl.border[i].name = xmlNode.getElementsByTagName('name')[0].firstChild.data; + gxtEl.border[i].straightFirst = JXG.str2Bool(xmlNode.getElementsByTagName('straight')[0].getElementsByTagName('first')[0].firstChild.data); + gxtEl.border[i].straightLast = JXG.str2Bool(xmlNode.getElementsByTagName('straight')[0].getElementsByTagName('last')[0].firstChild.data); + gxtEl.border[i].strokeWidth = xmlNode.getElementsByTagName('strokewidth')[0].firstChild.data; + gxtEl.border[i].dash = JXG.str2Bool(xmlNode.getElementsByTagName('dash')[0].firstChild.data); + gxtEl.border[i].visible = JXG.str2Bool(xmlNode.getElementsByTagName('visible')[0].firstChild.data); + gxtEl.border[i].draft = JXG.str2Bool(xmlNode.getElementsByTagName('draft')[0].firstChild.data); + gxtEl.border[i].trace = JXG.str2Bool(xmlNode.getElementsByTagName('trace')[0].firstChild.data); + + xmlNode = Data.getElementsByTagName('border')[i].getElementsByTagName('color')[0]; + rgbo = JXG.rgba2rgbo(xmlNode.getElementsByTagName('stroke')[0].firstChild.data); + gxtEl.border[i].strokeColor = rgbo[0]; + gxtEl.border[i].strokeOpacity = rgbo[1]; + + rgbo = JXG.rgba2rgbo(xmlNode.getElementsByTagName('lighting')[0].firstChild.data); + gxtEl.border[i].highlightStrokeColor = rgbo[0]; + gxtEl.border[i].highlightStrokeOpacity = rgbo[1]; + + rgbo = JXG.rgba2rgbo(xmlNode.getElementsByTagName('fill')[0].firstChild.data); + gxtEl.border[i].fillColor = rgbo[0]; + gxtEl.border[i].fillOpacity = rgbo[1]; + + gxtEl.border[i].highlightFillColor = gxtEl.border[i].fillColor; + gxtEl.border[i].highlightFillOpacity = gxtEl.border[i].fillOpacity; + + gxtEl.border[i].labelColor = xmlNode.getElementsByTagName('label')[0].firstChild.data; + gxtEl.border[i].colorDraft = xmlNode.getElementsByTagName('draft')[0].firstChild.data; + } + gxtEl = gxtReader.transformProperties(gxtEl); + p = board.create('polygon', dataVertex, gxtEl); + + // to emulate the geonext behaviour on invisible polygons + // A.W.: Why do we need this? +/* + if (!gxtEl.visible) { + p.setProperty({ + fillColor: 'none', + highlightFillColor: 'none' + }); + } +*/ + for (i = 0; i < p.borders.length; i++) { + p.borders[i].setProperty(gxtEl.border[i]); + } + + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case "graph": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl.funct = Data.getElementsByTagName('data')[0].getElementsByTagName('function')[0].firstChild.data; + if (false) { + gxtEl.funct = JXG.GeonextParser.gxt2jc(gxtEl.funct, board); // Handle weird element names + } else { // Workaround until the jessiecode compiler is 100% compatible + gxtEl.funct = JXG.GeonextParser.geonext2JS(gxtEl.funct, board); + gxtEl.funct = new Function('x', 'return ' + gxtEl.funct + ';'); + } + + c = board.create('curve', ['x', gxtEl.funct], { + id: gxtEl.id, + name: gxtEl.name, + strokeColor: gxtEl.strokeColor, + strokeWidth: gxtEl.strokeWidth, + fillColor: 'none', + highlightFillColor: 'none', + highlightStrokeColor: gxtEl.highlightStrokeColor, + visible: JXG.str2Bool(gxtEl.visible) + }); + + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case "arrow": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + gxtEl = gxtReader.readNodes(gxtEl, Data, 'straight', 'straight'); + + gxtEl = gxtReader.transformProperties(gxtEl); + gxtEl.first = gxtReader.changeOriginIds(board, gxtEl.first); + gxtEl.last = gxtReader.changeOriginIds(board, gxtEl.last); + + l = board.create('arrow', [gxtEl.first, gxtEl.last], gxtEl); + + gxtReader.printDebugMessage('debug', l, Data.nodeName, 'OK'); + break; + case "arc": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + + gxtEl.firstArrow = JXG.str2Bool(Data.getElementsByTagName('lastarrow')[0].firstChild.data); // It seems that JSXGraph and GEONExT + gxtEl.lastArrow = JXG.str2Bool(Data.getElementsByTagName('firstarrow')[0].firstChild.data); // use opposite directions. + + gxtEl = gxtReader.transformProperties(gxtEl); + + gxtEl.center = gxtReader.changeOriginIds(board, gxtEl.midpoint); + gxtEl.angle = gxtReader.changeOriginIds(board, gxtEl.angle); + gxtEl.radius = gxtReader.changeOriginIds(board, gxtEl.radius); + + c = board.create('arc', [gxtEl.center, gxtEl.radius, gxtEl.angle], gxtEl); + + gxtReader.printDebugMessage('debug', c, Data.nodeName, 'OK'); + break; + case "angle": + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + gxtEl = gxtReader.transformProperties(gxtEl); + + tmp = gxtEl.name; + try { + gxtEl.name = Data.getElementsByTagName('text')[0].firstChild.data; + } catch (e) { + gxtEl.name = ''; + } + c = board.create('angle', [gxtEl.first, gxtEl.middle, gxtEl.last], gxtEl); + c.setProperty({name:tmp}); + + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case "text": + if (gxtEl.id.match(/oldVersion/)) { + break; + } + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + + gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); + gxtEl.mpStr = gxtReader.subtreeToString(Data.getElementsByTagName('data')[0].getElementsByTagName('mp')[0]); + gxtEl.mpStr = gxtEl.mpStr.replace(/<\/?mp>/g, ''); + gxtEl.fixed = false; + try { + if (Data.getElementsByTagName('data')[0].getElementsByTagName('parent')[0].firstChild) { + gxtEl.parent = Data.getElementsByTagName('data')[0].getElementsByTagName('parent')[0].firstChild.data; + gxtEl.fixed = true; + } + } catch (e) { + } + + gxtEl.condition = Data.getElementsByTagName('condition')[0].firstChild.data; + gxtEl.content = Data.getElementsByTagName('content')[0].firstChild.data; + gxtEl.fix = Data.getElementsByTagName('fix')[0].firstChild.data; + // not used: gxtEl.digits = Data.getElementsByTagName('cs')[0].firstChild.data; + gxtEl.autodigits = Data.getElementsByTagName('digits')[0].firstChild.data; + gxtEl.parent = gxtReader.changeOriginIds(board, gxtEl.parent); + + c = board.create('text', [gxtEl.x, gxtEl.y, gxtEl.mpStr], { + anchor: gxtEl.parent, + id: gxtEl.id, + name: gxtEl.name, + digits: gxtEl.autodigits, + isLabel: false, + strokeColor: gxtEl.colorLabel, + fixed: gxtEl.fixed, + visible: JXG.str2Bool(gxtEl.visible) + }); + break; + case 'parametercurve': + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.visualProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl = gxtReader.transformProperties(gxtEl); + gxtEl.functionx = Data.getElementsByTagName('functionx')[0].firstChild.data; + gxtEl.functiony = Data.getElementsByTagName('functiony')[0].firstChild.data; + gxtEl.min = Data.getElementsByTagName('min')[0].firstChild.data; + gxtEl.max = Data.getElementsByTagName('max')[0].firstChild.data; + /* + gxtEl.functionx = JXG.GeonextParser.gxt2jc(gxtEl.functionx, board); + gxtEl.functiony = JXG.GeonextParser.gxt2jc(gxtEl.functiony, board); + gxtEl.min = JXG.GeonextParser.gxt2jc(gxtEl.min, board); + gxtEl.max = JXG.GeonextParser.gxt2jc(gxtEl.max, board); + */ + gxtEl.fillColor = 'none'; + gxtEl.highlightFillColor = 'none'; + + board.create('curve', + [ new Function('t', 'return ' + JXG.GeonextParser.geonext2JS(gxtEl.functionx, board) + ';' ), + new Function('t', 'return ' + JXG.GeonextParser.geonext2JS(gxtEl.functiony, board) + ';' ), + new Function('return ' + JXG.GeonextParser.geonext2JS(gxtEl.min, board) + ';' ), + new Function('return ' + JXG.GeonextParser.geonext2JS(gxtEl.max, board) + ';' ) + ], gxtEl); + /* + c = new JXG.Curve(board, [ + 't',gxtEl.functionx,gxtEl.functiony,gxtEl.min,gxtEl.max + ], gxtEl.id, gxtEl.name); + c.setProperty('strokeColor:' + gxtEl.colorStroke, 'strokeWidth:' + gxtEl.strokewidth, 'fillColor:none', + 'highlightStrokeColor:' + gxtEl.highlightStrokeColor); + */ + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case 'tracecurve': + gxtEl.tracepoint = Data.getElementsByTagName('tracepoint')[0].firstChild.data; + gxtEl.traceslider = Data.getElementsByTagName('traceslider')[0].firstChild.data; + board.create('tracecurve', [gxtEl.traceslider, gxtEl.tracepoint], gxtEl); + // JXG.getRef(board, gxtEl.tracepoint).setProperty({trace:true}); + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + case 'group': + gxtEl = gxtReader.colorProperties(gxtEl, Data); + gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); + gxtEl.members = [ + ]; + for (i = 0; i < Data.getElementsByTagName('data')[0].getElementsByTagName('member').length; i++) { + gxtEl.members[i] = Data.getElementsByTagName('data')[0].getElementsByTagName('member')[i].firstChild.data; + gxtEl.members[i] = gxtReader.changeOriginIds(board, gxtEl.members[i]); + } + c = new JXG.Group(board, gxtEl.id, gxtEl.name, gxtEl.members); + gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); + break; + default: + JXG.debug("* Err: " + Data.nodeName + " not yet implemented
\n"); + } + delete(gxtEl); + })(s); + } + board.addConditions(conditions); + }, + + decodeString: function(str) { + var unz; + if (str.indexOf("")<0){ + unz = (new JXG.Util.Unzip(JXG.Util.Base64.decodeAsArray(str))).unzip(); // war Gunzip ME + if (unz=="") + return str; + else + return unz; + } else { + return str; + } + }, + + prepareString: function(fileStr){ + try { + if (fileStr.indexOf('GEONEXT')<0) { + fileStr = (this.decodeString(fileStr))[0][0]; // Base64 decoding + } + // Hacks to enable not well formed XML. Will be redone in Algebra.geonext2JS and Board.addConditions + fileStr = this.fixXML(fileStr); + } catch(e) { + fileStr = ''; + } + return fileStr; + }, + + fixXML: function(str) { + var arr = ["active", "angle", "animate", "animated", "arc", "area", "arrow", "author", "autodigits", "axis", "back", "background", "board", "border", "bottom", "buttonsize", "cas", "circle", "color", "comment", "composition", "condition", "conditions", "content", "continuous", "control", "coord", "coordinates", "cross", "cs", "dash", "data", "description", "digits", "direction", "draft", "editable", "elements", "event", "file", "fill", "first", "firstarrow", "fix", "fontsize", "free", "full", "function", "functionx", "functiony", "GEONEXT", "graph", "grid", "group", "height", "id", "image", "info", "information", "input", "intersection", "item", "jsf", "label", "last", "lastarrow", "left", "lefttoolbar", "lighting", "line", "loop", "max", "maximized", "member", "middle", "midpoint", "min", "modifier", "modus", "mp", "mpx", "multi", "name", "onpolygon", "order", "origin", "output", "overline", "parametercurve", "parent", "point", "pointsnap", "polygon", "position", "radius", "radiusnum", "radiusvalue", "right", "section", "selectedlefttoolbar", "showconstruction", "showcoord", "showinfo", "showunit", "showx", "showy", "size", "slider", "snap", "speed", "src", "start", "stop", "straight", "stroke", "strokewidth", "style", "term", "text", "top", "trace", "tracecurve", "tracepoint", "traceslider", "type", "unit", "value", "VERSION", "vertex", "viewport", "visible", "width", "wot", "x", "xooy", "xval", "y", "yval", "zoom"], + list = arr.join('|'), + regex = '\<(/?('+list+'))\>', + expr = new RegExp(regex,'g'); + + // First, we convert all < to < and > to > + str = JXG.escapeHTML(str); + // Second, we convert all GEONExT tags of the form <tag> back to + str = str.replace(expr,'<$1>'); + + str = str.replace(/(.*)(.*<\/content>)/g,'$1<arc>$2'); + str = str.replace(/(.*)(.*<\/mpx>)/g,'$1<arc>$2'); + str = str.replace(/(.*)(.*<\/mpx>)/g,'$1<arc>$2'); + return str; + } + +}; // end: GeonextReader diff --git a/ajax/libs/jsxgraph/latest/IntergeoReader.js b/ajax/libs/jsxgraph/latest/IntergeoReader.js new file mode 100644 index 000000000..4a5aacaba --- /dev/null +++ b/ajax/libs/jsxgraph/latest/IntergeoReader.js @@ -0,0 +1,967 @@ +/* + Copyright 2008,2009 + Matthias Ehmann, + Michael Gerhaeuser, + Carsten Miller, + Bianca Valentin, + Alfred Wassermann, + Peter Wilfahrt + + This file is part of JSXGraph. + + JSXGraph is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + JSXGraph is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with JSXGraph. If not, see . + +*/ + +/* Compatibility for <= 0.75.4 */ +/* +JXG.getReference = function(board, object) { + return JXG.GetReferenceFromParameter(board, object); +}; +*/ + +JXG.IntergeoReader = new function() { + this.board = null; + /** + * this.objects holds all objects from the XML file. + * Every object hets an attribute "exists" + */ + this.objects = {}; + + this.readIntergeo = function(tree,board) { + this.board = board; + this.board.origin = {}; + this.board.origin.usrCoords = [1, 0, 0]; + this.board.origin.scrCoords = [1, 400, 300]; + this.board.unitX = 30; + this.board.unitY = 30; + + this.readElements(tree.getElementsByTagName("elements")); + this.readConstraints(tree.getElementsByTagName("constraints")); + this.cleanUp(); + this.board.fullUpdate(); + this.readDisplay(tree.getElementsByTagName("display")); + this.board.fullUpdate(); + }; + + /** + * Element part + */ + this.readElements = function(tree) { + var s; + for (var s=0;s1) { return; } // not an element node + if (node.nodeName=='point') { + JXG.IntergeoReader.storePoint(node); //addPoint(node); + } + else if (node.nodeName=='line' + || node.nodeName=='line_segment' + || node.nodeName=='ray' + || node.nodeName=='vector' + ) { + JXG.IntergeoReader.storeLine(node); + } + else if (node.nodeName=='circle') { + JXG.IntergeoReader.storeConic(node); + } + else if (node.nodeName=='conic') { + JXG.IntergeoReader.storeConic(node); + } + else if (node.nodeName=='polygon') { + // ignore, see this.addPolygonByVertices + } + else { + JXG.debug('Not implemented: '+node.nodeName + ' ' + node.getAttribute('id')); + } + })(s); + }; + + /** + * Points are created instantly via create + */ + this.addPointOld = function(node) { + var i = 0, + j = 0, + l = 0, + el, + p = node.childNodes[i], + c = [], + attributes = {strokeColor:'red', fillColor:'red', withLabel:true}, + parents = []; + + while (p.nodeType>1) { // skip non element nodes + i++; + p = node.childNodes[i]; + } + + attributes['name'] = node.getAttribute('id'); + + if (p.nodeName == 'homogeneous_coordinates') { + for (j=0;j... + } else if (p.childNodes[j].nodeName=='complex') { + for (l=0;l + return; + } + } + } + for (j=0;j + return; + } + } else if (p.nodeName == 'euclidean_coordinates') { + for (j=0;j... + } + } + for (j=0;j... + } + } + for (j=0;j1) { // skip non element nodes + i++; + p = node.childNodes[i]; + } + + if (p.nodeName == 'homogeneous_coordinates') { + for (j=0;j... + } else if (p.childNodes[j].nodeName=='complex') { + for (l=0;l + return; + } + } + } + for (j=0;j + return; + } + } else if (p.nodeName == 'euclidean_coordinates' || p.nodeName == 'euclidian_coordinates') { // the latter one is a workaround for faulty i2g construction exported by DynaGeo + for (j=0;j... + } + } + for (j=0;j... + } + } + for (j=0;j1) { // skip non element nodes + i++; + p = node.childNodes[i]; + } + if (p.nodeName == 'homogeneous_coordinates') { + c = []; + for (j=0;j... + } else { + //$('debug').innerHTML += 'Not: '+ p.childNodes[j].nodeName + '
'; // + } + } + } + this.objects[node.getAttribute('id')].coords = c; + this.objects[node.getAttribute('id')].id = node.getAttribute('id'); + this.objects[node.getAttribute('id')].exists = false; + this.objects[node.getAttribute('id')].i2geoType = 'line'; + } + //this.addLine(node.getAttribute('id')); + }; + + /** + * Circle / conic data is stored in an array + * for further access during the reading of constraints. + * There, id and name are needed. + * Concretely, the circle (x-1)^2 + (y-3)^2 = 4 has matrix + * ( 1 0 -1 ) + * ( 0 1 -3 ) + * ( -1 -3 6 ) + * + * In general + * Ax^2+Bxy+Cy^2+Dx+Ey+F = 0 + * is stored as + * ( A B/2 D/2 ) + * ( B/2 C E/2 ) + * ( D/2 E/2 F ) + * + * Mx = D/A + * My = E/C + * r = A*Mx^2+B*My^2-F + **/ + this.storeConic = function(node) { + var i, j, p, c; + + this.objects[node.getAttribute('id')] = {'id':node.getAttribute('id'), 'coords':null}; + i = 0; + p = node.childNodes[i]; + while (p.nodeType>1) { // skip non element nodes + i++; + p = node.childNodes[i]; + } + if (p.nodeName == 'matrix') { + c = []; + for (j=0;j... + } else { + //$('debug').innerHTML += 'Not: '+ p.childNodes[j].nodeName + '
'; // + } + } + } + this.objects[node.getAttribute('id')].coords = c; + this.objects[node.getAttribute('id')].id = node.getAttribute('id'); + this.objects[node.getAttribute('id')].exists = false; + this.objects[node.getAttribute('id')].i2geoType = 'conic'; + } + }; + + /** + * Constraint part + */ + this.readConstraints = function(tree) { + var s, param; + + // Set the default colors of dependent elements + this.board.options.point.strokeColor = 'blue'; + this.board.options.point.fillColor = 'blue'; + + for (s=0;s1) { return; } // not an element node + if (node.nodeName=='line_through_two_points') { + JXG.IntergeoReader.addLineThroughTwoPoints(node, false); + } + else if (node.nodeName=='ray_from_point_through_point') { + JXG.IntergeoReader.addLineThroughTwoPoints(node, true); + } + else if (node.nodeName=='line_through_point') { + JXG.IntergeoReader.addLineThroughPoint(node); + } + else if (node.nodeName=='line_parallel_to_line_through_point') { + JXG.IntergeoReader.addLineParallelToLineThroughPoint(node, false); + } + else if (node.nodeName=='ray_from_point_and_vector') { + JXG.IntergeoReader.addLineParallelToLineThroughPoint(node, true); + } + else if (node.nodeName=='line_perpendicular_to_line_through_point') { + JXG.IntergeoReader.addLinePerpendicularToLineThroughPoint(node); + } + else if (node.nodeName=='line_segment_by_points') { + JXG.IntergeoReader.addLineSegmentByTwoPoints(node); + } + else if (node.nodeName=='vector_from_point_to_point') { + JXG.IntergeoReader.addVectorFromPointToPoint(node); + } + else if (node.nodeName=='endpoints_of_line_segment') { + JXG.IntergeoReader.addEndpointsOfLineSegment(node); + } + else if (node.nodeName=='free_point') { + // do nothing + } + else if (node.nodeName=='free_line') { + JXG.IntergeoReader.addFreeLine(node); + } + else if (node.nodeName=='point_on_line') { + JXG.IntergeoReader.addPointOnLine(node); + } + else if (node.nodeName=='point_on_line_segment') { + JXG.IntergeoReader.addPointOnLine(node); + } + else if (node.nodeName=='point_on_circle') { + JXG.IntergeoReader.addPointOnCircle(node); + } + else if (node.nodeName=='angular_bisector_of_three_points') { + JXG.IntergeoReader.addAngularBisectorOfThreePoints(node, false); + } + else if (node.nodeName=='angular_bisectors_of_two_lines') { + JXG.IntergeoReader.addAngularBisectorsOfTwoLines(node, false); + } + else if (node.nodeName=='line_angular_bisector_of_three_points') { + JXG.IntergeoReader.addAngularBisectorOfThreePoints(node, true); + } + else if (node.nodeName=='line_angular_bisectors_of_two_lines') { + JXG.IntergeoReader.addAngularBisectorsOfTwoLines(node, true); + } + else if (node.nodeName=='midpoint_of_two_points') { + JXG.IntergeoReader.addMidpointOfTwoPoints(node); + } + else if (node.nodeName=='midpoint') { + JXG.IntergeoReader.addMidpointOfTwoPoints(node); + } + else if (node.nodeName=='midpoint_of_line_segment' || node.nodeName=='midpoint_line_segment') { + JXG.IntergeoReader.addMidpointOfLineSegment(node); + } + else if (node.nodeName=='point_intersection_of_two_lines') { + JXG.IntergeoReader.addPointIntersectionOfTwoLines(node); + } + else if (node.nodeName=='locus_defined_by_point') { + JXG.IntergeoReader.addLocusDefinedByPoint(node); + } + else if (node.nodeName=='locus_defined_by_point_on_line') { + JXG.IntergeoReader.addLocusDefinedByPointOnLine(node); + } + else if (node.nodeName=='locus_defined_by_point_on_line_segment') { + JXG.IntergeoReader.addLocusDefinedByPointOnLine(node); + } + else if (node.nodeName=='locus_defined_by_line_through_point') { + JXG.IntergeoReader.addLocusDefinedByLineThroughPoint(node); + } + else if (node.nodeName=='locus_defined_by_point_on_circle') { + JXG.IntergeoReader.addLocusDefinedByPointOnCircle(node); + } + else if (node.nodeName=='circle_by_three_points') { + JXG.IntergeoReader.addCircleByThreePoints(node); + } + else if (node.nodeName=='circle_by_center_and_point') { + JXG.IntergeoReader.addCircleByCenterAndPoint(node); + } + else if (node.nodeName=='center_of_circle') { + JXG.IntergeoReader.addCenterOfCircle(node); + } + else if (node.nodeName=='intersection_points_of_two_circles') { + JXG.IntergeoReader.addIntersectionPointsOfTwoCircles(node); + } + else if (node.nodeName=='intersection_points_of_circle_and_line') { + JXG.IntergeoReader.addIntersectionPointsOfCircleAndLine(node); + } + else if (node.nodeName=='other_intersection_point_of_two_circles') { + JXG.IntergeoReader.addOtherIntersectionPointOfTwoCircles(node); + } + else if (node.nodeName=='other_intersection_point_of_circle_and_line') { + JXG.IntergeoReader.addOtherIntersectionPointOfCircleAndLine(node); + } + else if (node.nodeName=='circle_tangent_lines_by_point') { + JXG.IntergeoReader.addCircleTangentLinesByPoint(node); + } + else if (node.nodeName=='polygon_by_vertices') { + JXG.IntergeoReader.addPolygonByVertices(node); + } + else { + param = JXG.IntergeoReader.readParams(node); + JXG.debug('readConstraints: not implemented: ' + node.nodeName + ': ' + param[0]); + } + })(s); + }; + + this.setAttributes = function(o) { + o.setProperty({strokecolor:this.board.options.point.strokeColor,fillColor:this.board.options.point.fillColor}); + }; + + this.readParams = function(node) { + var param = [], j; + for (j=0;j1) { return; } // not an element node + if (node.nodeName=='background-color') { + this.board.containerObj.style.backgroundColor = node.firstChild.data; + } + else if (node.nodeName=='style') { + el = JXG.getReference(this.board,node.getAttribute('ref')); // get the element + var param = [], j; + for (j=0;j. +*/ + var JXG={};(function(){var e,f;JXG.countDrawings=0;JXG.countTime=0;JXG.require=function(g){};JXG.rendererFiles=[];JXG.rendererFiles.svg="SVGRenderer";JXG.rendererFiles.vml="VMLRenderer";JXG.rendererFiles.canvas="CanvasRenderer";JXG.baseFiles=null;JXG.requirePath="";for(e=0;e-1},isWebkitAndroid:function(){return this.isAndroid()&&navigator.userAgent.search(" AppleWebKit/")>-1},isApple:function(){return(navigator.userAgent.search(/iPad/)!=-1||navigator.userAgent.search(/iPhone/)!=-1)},isWebkitApple:function(){return this.isApple()&&(navigator.userAgent.search(/Mobile *.*Safari/)>-1)},clearVisPropOld:function(e){e.visPropOld={strokecolor:"",strokeopacity:"",strokewidth:"",fillcolor:"",fillopacity:"",shadow:false,firstarrow:false,lastarrow:false}},ieVersion:(function(){var g,e=3,h=document.createElement("div"),f=h.getElementsByTagName("i");while(h.innerHTML="",f[0]){}return e>4?e:g}()),getReference:function(f,e){if(typeof(e)=="string"){if(JXG.exists(f.objects[e])){e=f.objects[e]}else{if(JXG.exists(f.elementsByName[e])){e=f.elementsByName[e]}else{if(JXG.exists(f.groups[e])){e=f.groups[e]}}}}return e},getRef:JXG.shortcut(JXG,"getReference"),isId:function(f,e){return typeof(e)=="string"&&!!f.objects[e]},isName:function(f,e){return typeof(e)=="string"&&!!f.elementsByName[e]},isGroup:function(f,e){return typeof(e)=="string"&&!!f.groups[e]},isString:function(e){return typeof e==="string"},isNumber:function(e){return typeof e==="number"},isFunction:function(e){return typeof e==="function"},isArray:function(e){return e!==null&&typeof e==="object"&&"splice" in e&&"join" in e},isPoint:function(e){if(typeof e=="object"){return(e.elementClass==JXG.OBJECT_CLASS_POINT)}return false},exists:(function(e){return function(f){return !(f===e||f===null)}})(),def:function(e,f){if(JXG.exists(e)){return e}else{return f}},str2Bool:function(e){if(!JXG.exists(e)){return true}if(typeof e=="boolean"){return e}return(e.toLowerCase()=="true")},_board:function(f,e){return JXG.JSXGraph.initBoard(f,e)},createEvalFunction:function(g,k,l){var h=[],e,j;for(e=0;e=o[h].length;f++){e=0;while(e0){JXG.removeEvent(g,f,e["x_internal"+f][0].origin,e)}}},bind:function(f,e){return function(){return f.apply(e,arguments)}},removeElementFromArray:function(e,g){var f;for(f=0;f=9){e=g.currentStyle[f]}else{if(g.style){f=f.replace(/-([a-z]|[0-9])/ig,function(h,i){return(i+"").toUpperCase()});e=g.style[f]}}}return e},keys:function(e,f){var g=[],h;for(h in e){if(f){if(e.hasOwnProperty(h)){g.push(h)}}else{g.push(h)}}return g},indexOf:function(g,f){var e;if(Array.indexOf){return g.indexOf(f)}for(e=0;e/g,">")},unescapeHTML:function(e){return e.replace(/<\/?[^>]+>/gi,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")},clone:function(f){var e={};e.prototype=f;return e},cloneAndCopy:function(h,g){var e=function(){},f;e.prototype=h;for(f in g){e[f]=g[f]}return e},deepCopy:function(l,k,h){var n,f,m,e,g;h=h||false;if(typeof l!=="object"||l==null){return l}if(this.isArray(l)){n=[];for(f=0;f0&&(+new Date()-j<300));if(e.length>0){setTimeout(arguments.callee,1)}else{i(f)}},1)},trimNumber:function(e){e=e.replace(/^0+/,"");e=e.replace(/0+$/,"");if(e[e.length-1]=="."||e[e.length-1]==","){e=e.slice(0,-1)}if(e[0]=="."||e[0]==","){e="0"+e}return e},trim:function(e){e=e.replace(/^\s+/,"");e=e.replace(/\s+$/,"");return e},evaluate:function(e){if(JXG.isFunction(e)){return e()}else{return e}},eliminateDuplicates:function(g){var h,f=g.length,e=[],j={};for(h=0;h"}}}},debugWST:function(f){var g;JXG.debug(f);if(window.console&&console.log){g=new Error();if(g&&g.stack){console.log("stacktrace");console.log(g.stack.split("\n").slice(1).join("\n"))}}}});JXG.addEvent(window,"load",function(){var k=document.getElementsByTagName("script"),o,m,l,f,n,g,q,p,h,e;for(m=0;m0?l[0].length:0,w=l.length,v=this.matrix(q,p),u,t,z,r;for(u=0;u0?r[0].length:0;o=this.matrix(q,k);for(p=0;pC){C=e.abs(o[v][u]);l=v}}if(C<=f.Math.eps){return false}if(l>u){for(t=0;to||l<0){return NaN}l=e.round(l);o=e.round(o);if(l===0||l===o){return 1}j=1;for(m=0;m0){return e.exp(i*e.log(e.abs(j)))}else{return NaN}}},squampow:function(k,j){var i;if(e.floor(j)===j){i=1;if(j<0){k=1/k;j*=-1}while(j!=0){if(j&1){i*=k}j>>=1;k*=k}return i}else{return this.pow(k,j)}},normalize:function(k){var i=2*k[3],l=k[4]/(i),m,j;k[5]=l;k[6]=-k[1]/i;k[7]=-k[2]/i;if(l===Infinity||isNaN(l)){m=e.sqrt(k[1]*k[1]+k[2]*k[2]);k[0]/=m;k[1]/=m;k[2]/=m;k[3]=0;k[4]=1}else{if(e.abs(l)>=1){k[0]=(k[6]*k[6]+k[7]*k[7]-l*l)/(2*l);k[1]=-k[6]/l;k[2]=-k[7]/l;k[3]=1/(2*l);k[4]=1}else{j=(l<=0)?(-1):(1);k[0]=j*(k[6]*k[6]+k[7]*k[7]-l*l)*0.5;k[1]=-j*k[6];k[2]=-j*k[7];k[3]=j/2;k[4]=j*l}}return k},toGL:function(k){var l,o,n;if(typeof Float32Array!=="undefined"){l=new Float32Array(16)}else{l=new Array(16)}if(k.length!==4&&k[0].length!==4){return l}for(o=0;o<4;o++){for(n=0;n<4;n++){l[o+4*n]=k[o][n]}}return l}}})(JXG,Math);JXG.Math.Numerics=(function(f,e){var g={rk4:{s:4,A:[[0,0,0,0],[0.5,0,0,0],[0,0.5,0,0],[0,0,1,0]],b:[1/6,1/3,1/3,1/6],c:[0,0.5,0.5,1]},heun:{s:2,A:[[0,0],[1,0]],b:[0.5,0.5],c:[0,1]},euler:{s:1,A:[[0]],b:[1],c:[0]}};return{Gauss:function(h,s){var u=f.Math.eps,l=h.length>0?h[0].length:0,q,t,r,p,o,m=function(v,n){var k=this[v];this[v]=this[n];this[n]=k};if((l!==s.length)||(l!==h.length)){throw new Error("JXG.Math.Numerics.Gauss: Dimensions don't match. A must be a square matrix and b must be of the same length as A.")}q=new Array(l);t=s.slice(0,l);for(r=0;rp;r--){if(e.abs(q[r][p])>u){if(e.abs(q[p][p])0?r[0].length:0;for(p=h-1;p>=0;p--){for(o=s-1;o>p;o--){k[p]-=r[p][o]*k[o]}k[p]/=r[p][p]}return k},gaussBareiss:function(v){var m,u,A,q,o,h,l,r,w,z=f.Math.eps;l=v.length;if(l<=0){return 0}if(v[0].length=z){break}}if(q==l){return 0}for(o=m;or){r=h}v+=h;if(h>=D){h=e.atan2(2*l[s][q],l[s][s]-l[q][q])*0.5;t=e.sin(h);B=e.cos(h);for(p=0;pD&&u<2000);return[l,o]},NewtonCotes:function(h,l,j){var m=0,q=j&&typeof j.number_of_nodes==="number"?j.number_of_nodes:28,o={trapez:true,simpson:true,milne:true},r=j&&j.integration_type&&o.hasOwnProperty(j.integration_type)&&o[j.integration_type]?j.integration_type:"milne",p=(h[1]-h[0])/q,n,k,s;switch(r){case"trapez":m=(l(h[0])+l(h[1]))*0.5;n=h[0];for(k=0;k0){throw new Error("JSXGraph: INT_SIMPSON requires config.number_of_nodes dividable by 2.")}s=q/2;m=l(h[0])+l(h[1]);n=h[0];for(k=0;k0){throw new Error("JSXGraph: Error in INT_MILNE: config.number_of_nodes must be a multiple of 4")}s=q*0.25;m=7*(l(h[0])+l(h[1]));n=h[0];for(k=0;kn){q=this.D(p,k)(j);m+=2;if(e.abs(q)>n){j-=o/q}else{j+=(e.random()*0.2-1)}o=p.apply(k,[j]);m++;l++}return j},root:function(j,h,i){return this.fzero(j,h,i)},Neville:function(l){var i=[],h=function(m){return function(w,n){var p,v,z,A=f.Math.binomial,u=l.length,o=u-1,q=0,r=0;if(!n){z=1;for(p=0;p=0;o--){u[o]=(q[o]-(v[o+1]*u[o+1]))/p[o]}for(o=h-3;o>=0;o--){u[o+1]=u[o]}u[0]=0;u[h-1]=0;return u},splineEval:function(k,z,v,B){var m=e.min(z.length,v.length),p=1,o=false,A=[],r,q,w,u,t,s,h;if(f.isArray(k)){p=k.length;o=true}else{k=[k]}for(r=0;rz[m-1])){return NaN}for(q=1;q=0;l--){m=m.concat(["(",h[l].toPrecision(k),")"]);if(l>1){m=m.concat(["*",j,"",l,"<","/sup> + "])}else{if(l===1){m=m.concat(["*",j," + "])}}}return m.join("")},lagrangePolynomial:function(j){var h=[],i=function(v,l){var o,m,r,u,w,p=0,q=0,t,n;r=j.length;if(!l){for(o=0;o=o-3){return l[o-2][n]()}}r=e.floor(q);if(r==q){return l[r][n]()}q-=r;u=i[n][r];return 0.5*(((u[3]*q+u[2])*q+u[1])*q+u[0])}};return[h("X"),h("Y"),0,function(){return j.length-1}]},regressionPolynomial:function(l,p,o){var h,i,n,m,j,q,k="";if(f.isPoint(l)&&typeof l.Value=="function"){i=function(){return l.Value()}}else{if(f.isFunction(l)){i=l}else{if(f.isNumber(l)){i=function(){return l}}else{throw new Error("JSXGraph: Can't create regressionPolynomial from degree of type'"+(typeof l)+"'.")}}}if(arguments.length==3&&f.isArray(p)&&f.isArray(o)){j=0}else{if(arguments.length==2&&f.isArray(p)&&p.length>0&&f.isPoint(p[0])){j=1}else{throw new Error("JSXGraph: Can't create regressionPolynomial. Wrong parameters.")}}q=function(F,r){var v,u,C,z,E,t,D,G,A,w=p.length;A=e.floor(i());if(!r){if(j===1){n=[];m=[];for(v=0;v=0;v--){G=(G*F+h[v])}return G};q.getTerm=function(){return k};return q},bezier:function(j){var h,i=function(k){return function(m,l){var p=e.floor(m)*3,o=m%1,n=1-o;if(!l){h=e.floor(j.length/3)}if(m<0){return j[0][k]()}if(m>=h){return j[j.length-1][k]()}if(isNaN(m)){return NaN}return n*n*(n*j[p][k]()+3*o*j[p+1][k]())+(3*n*j[p+2][k]()+o*j[p+3][k]())*o*o}};return[i("X"),i("Y"),0,function(){return e.floor(j.length/3)}]},bspline:function(k,h){var l,n=[],m=function(r,o){var p,q=[];for(p=0;p=B){v=0}else{v=u[q+1]}z=C[q+r-1]-C[q];if(z==0){u[q]=0}else{u[q]=(A-C[q])/z*w}z=C[q+r]-C[q+1];if(z!=0){u[q]+=(C[q+r]-A)/z*v}}}return u},i=function(o){return function(v,q){var p=k.length,A,u,w,z=p-1,r=h;if(z<=0){return NaN}if(z+2<=r){r=z+1}if(v<=0){return k[0][o]()}if(v>=z-r+2){return k[z][o]()}l=m(z,r);w=e.floor(v)+r-1;n=j(v,l,z,r,w);A=0;for(u=w-r+1;u<=w;u++){if(u=0){A+=k[u][o]()*n[u]}}return A}};return[i("X"),i("Y"),0,function(){return k.length-1}]},D:function(k,l){var j=0.00001,i=1/(j*2);if(arguments.length==1||(arguments.length>1&&!f.exists(arguments[1]))){return function(h,m){return(k(h+j,m)-k(h-j,m))*i}}else{return function(h,m){return(k.apply(l,[h+j,m])-k.apply(l,[h-j,m]))*i}}},riemann:function(s,o,t,l,p){var m=[],A=[],r,q=0,z,w=l,u,k,v,h;o=e.round(o);m[q]=w;A[q]=0;if(o>0){z=(p-l)/o;h=z*0.01;for(r=0;ru){u=v}}}}}}q++;m[q]=w;A[q]=u;q++;w+=z;if(t==="trapezodial"){u=s(w)}m[q]=w;A[q]=u;q++;m[q]=w;A[q]=0}}return[m,A]},riemannsum:function(p,l,r,k,m){var q=0,o,v,u=k,s,j,t,h;l=e.floor(l);if(l>0){v=(m-k)/l;h=v*0.01;for(o=0;os){s=t}}}}}}}q+=v*s;u+=v}}return q},rungeKutta:function(m,H,p,n,G){var q=[],o=[],F=(p[1]-p[0])/n,v=p[0],J,E,D,B,A,C=H.length,w,u=[],z=0;if(f.isString(m)){m=g[m]||g.euler}w=m.s;for(J=0;J0){if(f.isArray(J)){return this.fminbr(I,[M,L],O)}else{return this.Newton(I,M,O)}}K=M;w=C;while(A=H&&e.abs(C)>e.abs(z)){t=K-L;if(M==K){m=z/C;v=t*m;s=1-m}else{s=C/w;m=z/w;l=z/C;v=l*(t*s*(s-m)-(L-M)*(m-1));s=(s-1)*(m-1)*(l-1)}if(v>0){s=-s}else{v=-v}if(v<(0.75*t*s-e.abs(H*s)*0.5)&&v0){n=H}else{n=-H}}M=L;C=z;L+=n;z=I.apply(O,[L]);D++;if((z>0&&w>0)||(z<0&&w<0)){K=M;w=C}A++}return L},fminbr:function(I,J,N){var M,K,m,s,o,i,k,j,A=(3-e.sqrt(5))*0.5,F=f.Math.eps,C=e.sqrt(f.Math.eps),h=this.maxIterationsMinimize,E=0,z,L,H,n,D,B,u,l,G=0;if(!f.isArray(J)||J.length<2){throw new Error("JXG.Math.Numerics.fminbr: length of array x0 has to be at least two.")}M=J[0];K=J[1];s=M+A*(K-M);k=I.apply(N,[s]);G++;m=s;o=s;i=k;j=k;while(E=H){u=(m-o)*(i-k);B=(m-s)*(i-j);D=(m-s)*B-(m-o)*u;B=2*(B-u);if(B>0){D=-D}else{B=-B}if(e.abs(D)B*(M-m+2*H)&&D0){n=H}else{n=-H}}u=m+n;l=I.apply(N,[u]);G++;if(l<=i){if(ur){l(v,u,k[1],r,s);l(v,k[1],t,r,s)}else{s.push(v[t])}},o=function(H,w,v){var B=0,z=w,A,u,I,G,F,t,E,s,C,D,r;if(v-w<2){return[-1,0]}I=H[w].scrCoords;G=H[v].scrCoords;if(isNaN(I[1]+I[2]+G[1]+G[2])){return[NaN,v]}for(u=w+1;u=f.Math.eps){r=(t*s+E*C)/D;if(r<0){r=0}else{if(r>1){r=1}}t=t-r*s;E=E-r*C;A=t*t+E*E}else{r=0;A=t*t+E*E}if(A>B){B=A;z=u}}return[e.sqrt(B),z]};h=q.length;p=0;while(pp&&isNaN(q[m].scrCoords[1]+q[m].scrCoords[2])){m--}if(!(p>m||p==h)){n[0]=q[p];l(q,p,m,j,n)}return n}}})(JXG,Math);JXG.Math.Statistics={sum:function(f){var h,e=f.length,g=0;for(h=0;h0){return this.sum(e)/e.length}else{return 0}},median:function(f){var g,e;if(f.length>0){g=f.slice(0);g.sort(function(i,h){return i-h});e=g.length;if(e%2==1){return g[parseInt(e*0.5)]}else{return(g[e*0.5-1]+g[e*0.5])*0.5}}else{return 0}},variance:function(g){var f,j,h,e=g.length;if(e>1){f=this.mean(g);j=0;for(h=0;h0){return this.mean(this.multiply(e,f))}else{return 0}},max:function(e){return Math.max.apply(this,e)},min:function(e){return Math.min.apply(this,e)},range:function(e){return[this.min(e),this.max(e)]},abs:function(f){var h,e,g;if(JXG.isArray(f)){e=f.length;g=[];for(h=0;h0){m=n[q].generatePolynomial();for(h=0;h0)){if((A.toOrigin!==f)&&(A.toOrigin!=null)&&E(A.toOrigin.id,o.listOfFreePoints)){l=A.toOrigin}else{l=o.listOfFreePoints[0]}v=l.symbolic.x;t=l.symbolic.y;for(F=0;F1)){if((A.to10!==f)&&(A.to10!=null)&&(A.to10.id!=A.toOrigin.id)&&E(A.to10.id,o.listOfFreePoints)){k=A.to10}else{if(o.listOfFreePoints[0].id==l.id){k=o.listOfFreePoints[1]}else{k=o.listOfFreePoints[0]}}p=e.Math.Geometry.rad([1,0],[0,0],[k.symbolic.x,k.symbolic.y]);G=Math.cos(-p);z=Math.sin(-p);for(F=0;Fe.Math.eps)){I=k.symbolic.x;for(F=0;Fq){k+=Math.PI}p=Math.cos(k)+o[1];n=Math.sin(k)+o[2];return new JXG.Coords(JXG.COORDS_BY_USER,[p,n],l)},reflection:function(p,m,g){var i=m.coords.usrCoords,q=p.point1.coords.usrCoords,h=p.point2.coords.usrCoords,f,l,e,j,n,k,o;if(!JXG.exists(g)){g=m.board}n=h[1]-q[1];k=h[2]-q[2];f=i[1]-q[1];l=i[2]-q[2];o=(n*l-k*f)/(n*n+k*k);e=i[1]+2*o*k;j=i[2]-2*o*n;return new JXG.Coords(JXG.COORDS_BY_USER,[e,j],g)},rotation:function(e,o,i,j){var l=o.coords.usrCoords,f=e.coords.usrCoords,h,n,k,p,g,m;if(!JXG.exists(j)){j=o.board}h=l[1]-f[1];n=l[2]-f[2];k=Math.cos(i);p=Math.sin(i);g=h*k-n*p+f[1];m=h*p+n*k+f[2];return new JXG.Coords(JXG.COORDS_BY_USER,[g,m],j)},perpendicular:function(r,p,j){var i=r.point1.coords.usrCoords,h=r.point2.coords.usrCoords,f=p.coords.usrCoords,n,m,l,q,k,g,e,o;if(!JXG.exists(j)){j=p.board}if(p==r.point1){n=i[1]+h[2]-i[2];m=i[2]-h[1]+i[1];l=true}else{if(p==r.point2){n=h[1]+i[2]-h[2];m=h[2]-i[1]+h[1];l=false}else{if(((Math.abs(i[1]-h[1])>JXG.Math.eps)&&(Math.abs(f[2]-(i[2]-h[2])*(f[1]-i[1])/(i[1]-h[1])-i[2])JXG.Math.eps&&(Math.abs(f[0])JXG.Math.eps){for(k=2;k>0;k--){v[m][k]/=v[m][0]}v[m][0]=1}}f=false;e=false;if(!r&&q.scrCoords[1]>=0&&q.scrCoords[1]<=h.board.canvasWidth&&q.scrCoords[2]>=0&&q.scrCoords[2]<=h.board.canvasHeight){f=true}if(!g&&p.scrCoords[1]>=0&&p.scrCoords[1]<=h.board.canvasWidth&&p.scrCoords[2]>=0&&p.scrCoords[2]<=h.board.canvasHeight){e=true}if(Math.abs(v[1][0])h.board.canvasHeight){l=v[2]}else{l=v[3]}}else{if(v[1][2]>h.board.canvasHeight){n=v[2];if(v[3][2]<0){l=v[0]}else{l=v[3]}}else{n=v[1];if(v[3][2]<0){l=v[0]}else{if(v[3][2]>h.board.canvasHeight){l=v[2]}else{l=v[3]}}}}}}n=new JXG.Coords(JXG.COORDS_BY_SCREEN,n.slice(1),h.board);l=new JXG.Coords(JXG.COORDS_BY_SCREEN,l.slice(1),h.board);if(!f&&!e){if(!r&&g&&!this.isSameDirection(q,p,n)&&!this.isSameDirection(q,p,l)){return}else{if(r&&!g&&!this.isSameDirection(p,q,n)&&!this.isSameDirection(p,q,l)){return}}}if(!f){if(!e){if(this.isSameDir(q,p,n,l)){u=n;t=l}else{t=n;u=l}}else{if(this.isSameDir(q,p,n,l)){u=n}else{u=l}}}else{if(!e){if(this.isSameDir(q,p,n,l)){t=l}else{t=n}}}if(u){q.setCoordinates(JXG.COORDS_BY_USER,u.usrCoords.slice(1))}if(t){p.setCoordinates(JXG.COORDS_BY_USER,t.usrCoords.slice(1))}},isSameDir:function(k,j,g,f){var e=j.usrCoords[1]-k.usrCoords[1],l=j.usrCoords[2]-k.usrCoords[2],i=f.usrCoords[1]-g.usrCoords[1],h=f.usrCoords[2]-g.usrCoords[2];return e*i+l*h>=0},isSameDirection:function(l,i,g){var f,e,k,j,h=false;f=i.usrCoords[1]-l.usrCoords[1];e=i.usrCoords[2]-l.usrCoords[2];k=g.usrCoords[1]-l.usrCoords[1];j=g.usrCoords[2]-l.usrCoords[2];if(Math.abs(f)=0&&k>=0){if((e>=0&&j>=0)||(e<=0&&j<=0)){h=true}}else{if(f<=0&&k<=0){if((e>=0&&j>=0)||(e<=0&&j<=0)){h=true}}}return h},intersectLineLine:function(p,o,k){var j=p.point1.coords.usrCoords,h=p.point2.coords.usrCoords,g=o.point1.coords.usrCoords,e=o.point2.coords.usrCoords,i,f,n,m,l;if(!JXG.exists(k)){k=p.board}i=j[1]*h[2]-j[2]*h[1];f=g[1]*e[2]-g[2]*e[1];n=(h[2]-j[2])*(g[1]-e[1])-(j[1]-h[1])*(e[2]-g[2]);if(Math.abs(n)0){e=k.center.Dist(u.point1);I=k.center.Dist(u.point2);G=((e*e)+(B*B)-(I*I))/(2*B);z=(e*e)-(G*G);z=(z<0)?0:z;E=Math.sqrt(z);C=k.Radius();n=Math.sqrt((C*C)-E*E);A=H[1]-J[1];v=H[2]-J[2];j=g[1]+(E/B)*v;i=g[2]-(E/B)*A;e=(H[1]*v)-(H[2]*A);I=(j*A)+(i*v);D=(v*v)+(A*A);if(Math.abs(D)q){return[0]}else{if(u=e&&Math.abs(f[3])=e){return this.meetLineCircle(h,f,g,j)}else{return this.meetCircleCircle(h,f,g,j)}}}},meetLineLine:function(f,e,g,j){var h=JXG.Math.crossProduct(f,e);if(Math.abs(h[0])>JXG.Math.eps){h[1]/=h[0];h[2]/=h[0];h[0]=1}return new JXG.Coords(JXG.COORDS_BY_USER,h,j)},meetLineCircle:function(j,e,o,p){var u,s,r,q,l,h,g,f,m,v;if(e[4]=0){m=Math.sqrt(m);v=[(-g+m)/(2*h),(-g-m)/(2*h)];return((o==0)?new JXG.Coords(JXG.COORDS_BY_USER,[-v[0]*(-l[1])-q*l[0],-v[0]*l[0]-q*l[1]],p):new JXG.Coords(JXG.COORDS_BY_USER,[-v[1]*(-l[1])-q*l[0],-v[1]*l[0]-q*l[1]],p))}else{return new JXG.Coords(JXG.COORDS_BY_USER,[0,0,0],p)}},meetCircleCircle:function(g,e,f,h){var j;if(g[4]JXG.Math.eps&&l<10){B=A(o);z=-w(n);v=j(o);u=-i(n);g=B*u-z*v;o-=(u*t-z*s)/g;n-=(B*s-v*t)/g;t=r.X(o)-q.X(n);s=r.Y(o)-q.Y(n);p=t*t+s*s;l++}arguments.callee.t1memo=o;arguments.callee.t2memo=n;if(Math.abs(o)0.1&&Math.abs(g-h.X(m))>0.1&&Math.abs(e-h.Y(m))>0.1)){v=20;w=(h.maxX()-h.minX())/v;A=h.minX();for(u=0;u0.1&&Math.abs(g-h.X(m))>0.1&&Math.abs(e-h.Y(m))>0.1){break}A+=w}}p=m;arguments.callee.t2memo=p}if(Math.abs(j(p))>JXG.Math.eps){l=0}else{l=1}return(new JXG.Coords(JXG.COORDS_BY_USER,[l,h.X(p),h.Y(p)],k))},projectPointToCircle:function(m,e,g){var j=m.coords.distance(JXG.COORDS_BY_USER,e.center.coords),f=m.coords.usrCoords,h=e.center.coords.usrCoords,l,k,i;if(!JXG.exists(g)){g=m.board}if(Math.abs(j)r.maxX()){q=r.minX()+q-r.maxX()}C=new JXG.Coords(JXG.COORDS_BY_USER,[r.X(q),r.Y(q)],k)}else{if(r.visProp.curvetype=="plot"){B=p;for(v=0;v=JXG.Math.eps){h=(A*z+f*e)/l;s=Math.sqrt(A*A+f*f-h*(A*z+f*e))}else{h=0;s=Math.sqrt(A*A+f*f)}if(h>=0&&h<=1&&s-1){this.monomials[f].coefficient+=g*e.coefficient}else{e.coefficient*=g;this.monomials.push(e)}},add:function(f){var e;if(JXG.exists(f)&&f.ring===this.ring){if(JXG.isArray(f.exponents)){this.addSubMonomial(f,1)}else{for(e=0;e0&&!isNaN(e+f.center.coords.scrCoords[1]+f.center.coords.scrCoords[2])&&e*f.board.unitX<20000){this.updateEllipsePrim(f.rendNode,f.center.coords.scrCoords[1],f.center.coords.scrCoords[2],(e*f.board.unitX),(e*f.board.unitY))}},drawPolygon:function(e){this.appendChildPrim(this.createPrim("polygon",e.id),e.visProp.layer);this.appendNodesToElement(e,"polygon");this.updatePolygon(e)},updatePolygon:function(e){this._updateVisual(e,{stroke:true,dash:true});this.updatePolygonPrim(e.rendNode,e)},displayCopyright:function(e,f){},drawInternalText:function(e){},updateInternalText:function(e){},drawText:function(e){var f,g;if(e.visProp.display==="html"){f=this.container.ownerDocument.createElement("div");f.style.position="absolute";f.className=e.visProp.cssclass;if(this.container.style.zIndex==""){g=0}else{g=parseInt(this.container.style.zIndex)}f.style.zIndex=g+e.board.options.layer.text;this.container.appendChild(f);f.setAttribute("id",this.container.id+"_"+e.id)}else{f=this.drawInternalText(e)}e.rendNode=f;e.htmlStr="";this.updateText(e)},updateText:function(e){var f=e.plaintext;if(e.visProp.visible){this.updateTextStyle(e);if(e.visProp.display==="html"){if(!isNaN(e.coords.scrCoords[1]+e.coords.scrCoords[2])){e.rendNode.style.left=parseInt(e.coords.scrCoords[1])+"px";e.rendNode.style.top=parseInt(e.coords.scrCoords[2]-parseInt(e.visProp.fontsize)+this.vOffsetText)+"px"}if(e.htmlStr!==f){e.rendNode.innerHTML=f;e.htmlStr=f;if(e.visProp.usemathjax){MathJax.Hub.Typeset(e.rendNode)}else{if(e.visProp.useasciimathml){AMprocessNode(e.rendNode,false)}}}this.transformImage(e,e.transformations)}else{this.updateInternalText(e)}}},updateTextStyle:function(g){var f=JXG.evaluate(g.visProp.fontsize);if(g.visProp.display==="html"||this.type!="canvas"){g.rendNode.className=g.visProp.cssclass;try{g.rendNode.style.fontSize=f+"px"}catch(h){g.rendNode.style.fontSize=f}}this.setObjectStrokeColor(g,g.visProp.strokecolor,g.visProp.strokeopacity)},drawImage:function(e){},updateImage:function(e){this.updateRectPrim(e.rendNode,e.coords.scrCoords[1],e.coords.scrCoords[2]-e.size[1],e.size[0],e.size[1]);this.updateImageURL(e);this.transformImage(e,e.transformations);this._updateVisual(e,{stroke:true,dash:true},true)},joinTransforms:function(o,p){var l=[[1,0,0],[0,1,0],[0,0,1]],h=o.board.origin.scrCoords[1],g=o.board.origin.scrCoords[2],f=o.board.unitX,e=o.board.unitY,s=[[1,0,0],[-h,1,0],[-g,0,1]],r=[[1,0,0],[0,1/f,0],[0,0,-1/e]],j=[[1,0,0],[0,f,0],[0,0,-e]],k=[[1,0,0],[h,1,0],[g,0,1]],n,q=p.length;for(n=0;n\nFunction Base64Encode(inData)\n Const Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"\n Dim cOut, sOut, I\n For I = 1 To LenB(inData) Step 3\n Dim nGroup, pOut, sGroup\n nGroup = &H10000 * AscB(MidB(inData, I, 1)) + _\n &H100 * MyASC(MidB(inData, I + 1, 1)) + MyASC(MidB(inData, I + 2, 1))\n nGroup = Oct(nGroup)\n nGroup = String(8 - Len(nGroup), "0") & nGroup\n pOut = Mid(Base64, CLng("&o" & Mid(nGroup, 1, 2)) + 1, 1) + _\n Mid(Base64, CLng("&o" & Mid(nGroup, 3, 2)) + 1, 1) + _\n Mid(Base64, CLng("&o" & Mid(nGroup, 5, 2)) + 1, 1) + _\n Mid(Base64, CLng("&o" & Mid(nGroup, 7, 2)) + 1, 1)\n sOut = sOut + pOut\n Next\n Select Case LenB(inData) Mod 3\n Case 1: \'8 bit final\n sOut = Left(sOut, Len(sOut) - 2) + "=="\n Case 2: \'16 bit final\n sOut = Left(sOut, Len(sOut) - 1) + "="\n End Select\n Base64Encode = sOut\nEnd Function\n\nFunction MyASC(OneChar)\n If OneChar = "" Then MyASC = 0 Else MyASC = AscB(OneChar)\nEnd Function\n\nFunction BinFileReader(xhr)\n Dim byteString\n Dim b64String\n Dim i\n byteString = xhr.responseBody\n ReDim byteArray(LenB(byteString))\n For i = 1 To LenB(byteString)\n byteArray(i-1) = AscB(MidB(byteString, i, 1))\n Next\n b64String = Base64Encode(byteString)\n BinFileReader = b64String\nEnd Function\n<\/script>\n')}JXG.GeonextParser={};JXG.GeonextParser.replacePow=function(g){var l,o,m,k,n,h,e,f,j,r,q;g=g.replace(/(\s*)\^(\s*)/g,"^");j=g.indexOf("^");while(j>=0){f=g.slice(0,j);r=g.slice(j+1);if(f.charAt(f.length-1)==")"){l=1;o=f.length-2;while(o>=0&&l>0){m=f.charAt(o);if(m==")"){l++}else{if(m=="("){l--}}o--}if(l==0){k="";h=f.substring(0,o+1);e=o;while(e>=0&&h.substr(e,1).match(/([\w\.]+)/)){k=RegExp.$1+k;e--}k+=f.substring(o+1,f.length);k=k.replace(/([\(\)\+\*\%\^\-\/\]\[])/g,"\\$1")}else{throw new Error("JSXGraph: Missing '(' in expression")}}else{k="[\\w\\.]+"}if(r.match(/^([\w\.]*\()/)){l=1;o=RegExp.$1.length;while(o0){m=r.charAt(o);if(m==")"){l--}else{if(m=="("){l++}}o++}if(l==0){n=r.substring(0,o);n=n.replace(/([\(\)\+\*\%\^\-\/\[\]])/g,"\\$1")}else{throw new Error("JSXGraph: Missing ')' in expression")}}else{n="[\\w\\.]+"}q=new RegExp("("+k+")\\^("+n+")");g=g.replace(q,"JXG.Math.pow($1,$2)");j=g.indexOf("^")}return g};JXG.GeonextParser.replaceIf=function(f){var t="",g,r,j=null,e=null,m=null,h,q,k,n,l,o,p;h=f.indexOf("If(");if(h<0){return f}f=f.replace(/""/g,"0");while(h>=0){g=f.slice(0,h);r=f.slice(h+3);k=1;q=0;n=-1;l=-1;while(q0){o=r.charAt(q);if(o==")"){k--}else{if(o=="("){k++}else{if(o==","&&k==1){if(n<0){n=q}else{l=q}}}}q++}p=r.slice(0,q-1);r=r.slice(q);if(n<0){return""}if(l<0){return""}j=p.slice(0,n);e=p.slice(n+1,l);m=p.slice(l+1);j=this.replaceIf(j);e=this.replaceIf(e);m=this.replaceIf(m);t+=g+"(("+j+")?("+e+"):("+m+"))";f=r;j=null;e=null;h=f.indexOf("If(")}t+=r;return t};JXG.GeonextParser.replaceSub=function(g){if(g.indexOf){}else{return g}var f=g.indexOf("_{"),e;while(f>=0){g=g.substr(0,f)+g.substr(f).replace(/_\{/,"");e=g.substr(f).indexOf("}");if(e>=0){g=g.substr(0,e)+g.substr(e).replace(/\}/,"")}f=g.indexOf("_{")}f=g.indexOf("_");while(f>=0){g=g.substr(0,f)+g.substr(f).replace(/_(.?)/,"$1");f=g.indexOf("_")}return g};JXG.GeonextParser.replaceSup=function(g){if(g.indexOf){}else{return g}var f=g.indexOf("^{"),e;while(f>=0){g=g.substr(0,f)+g.substr(f).replace(/\^\{/,"");e=g.substr(f).indexOf("}");if(e>=0){g=g.substr(0,e)+g.substr(e).replace(/\}/,"")}f=g.indexOf("^{")}f=g.indexOf("^");while(f>=0){g=g.substr(0,f)+g.substr(f).replace(/\^(.?)/,"$1");f=g.indexOf("^")}return g};JXG.GeonextParser.replaceNameById=function(h,k){var m=0,e,l,j,g,f=["X","Y","L","V"];for(g=0;g=0){if(m>=0){e=h.indexOf(")",m+2);if(e>=0){l=h.slice(m+2,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+2)+j.id+h.slice(e)}}e=h.indexOf(")",m+2);m=h.indexOf(f[g]+"(",e)}}m=h.indexOf("Dist(");while(m>=0){if(m>=0){e=h.indexOf(",",m+5);if(e>=0){l=h.slice(m+5,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+5)+j.id+h.slice(e)}}e=h.indexOf(",",m+5);m=h.indexOf(",",e);e=h.indexOf(")",m+1);if(e>=0){l=h.slice(m+1,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+1)+j.id+h.slice(e)}e=h.indexOf(")",m+1);m=h.indexOf("Dist(",e)}f=["Deg","Rad"];for(g=0;g=0){if(m>=0){e=h.indexOf(",",m+4);if(e>=0){l=h.slice(m+4,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+4)+j.id+h.slice(e)}}e=h.indexOf(",",m+4);m=h.indexOf(",",e);e=h.indexOf(",",m+1);if(e>=0){l=h.slice(m+1,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+1)+j.id+h.slice(e)}e=h.indexOf(",",m+1);m=h.indexOf(",",e);e=h.indexOf(")",m+1);if(e>=0){l=h.slice(m+1,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+1)+j.id+h.slice(e)}e=h.indexOf(")",m+1);m=h.indexOf(f[g]+"(",e)}}return h};JXG.GeonextParser.replaceIdByObj=function(e){var f=/(X|Y|L)\(([\w_]+)\)/g;e=e.replace(f,'this.board.objects["$2"].$1()');f=/(V)\(([\w_]+)\)/g;e=e.replace(f,'this.board.objects["$2"].Value()');f=/(Dist)\(([\w_]+),([\w_]+)\)/g;e=e.replace(f,'this.board.objects["$2"].Dist(this.board.objects["$3"])');f=/(Deg)\(([\w_]+),([ \w\[\w_]+),([\w_]+)\)/g;e=e.replace(f,'JXG.Math.Geometry.trueAngle(this.board.objects["$2"],this.board.objects["$3"],this.board.objects["$4"])');f=/Rad\(([\w_]+),([\w_]+),([\w_]+)\)/g;e=e.replace(f,'JXG.Math.Geometry.rad(this.board.objects["$1"],this.board.objects["$2"],this.board.objects["$3"])');return e};JXG.GeonextParser.geonext2JS=function(f,h){var j,g,e,l=["Abs","ACos","ASin","ATan","Ceil","Cos","Exp","Factorial","Floor","Log","Max","Min","Random","Round","Sin","Sqrt","Tan","Trunc"],k=["Math.abs","Math.acos","Math.asin","Math.atan","Math.ceil","Math.cos","Math.exp","JXG.Math.factorial","Math.floor","Math.log","Math.max","Math.min","Math.random","this.board.round","Math.sin","Math.sqrt","Math.tan","Math.ceil"];f=f.replace(/</g,"<");f=f.replace(/>/g,">");f=f.replace(/&/g,"&");g=f;g=this.replaceNameById(g,h);g=this.replaceIf(g);g=this.replacePow(g);g=this.replaceIdByObj(g);for(e=0;e=0){j[g].addChild(i)}}}else{e=g.replace(/\[/g,"\\[");e=e.replace(/\]/g,"\\]");k=new RegExp("\\(([\\w\\[\\]'_ ]+,)*("+e+")(,[\\w\\[\\]'_ ]+)*\\)","g");if(f.search(k)>=0){j[g].addChild(i)}}}}};JXG.GeonextParser.gxt2jc=function(e,g){var f,i=["Sqrt"],h=["sqrt"];e=e.replace(/</g,"<");e=e.replace(/>/g,">");e=e.replace(/&/g,"&");f=e;f=this.replaceNameById2(f,g);f=f.replace(/True/g,"true");f=f.replace(/False/g,"false");f=f.replace(/fasle/g,"false");return f};JXG.GeonextParser.replaceNameById2=function(h,k){var m=0,e,l,j,g,f=["X","Y","L","V"];for(g=0;g=0){if(m>=0){e=h.indexOf(")",m+2);if(e>=0){l=h.slice(m+2,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+2)+"$('"+j.id+"')"+h.slice(e)}}e=h.indexOf(")",m+2);m=h.indexOf(f[g]+"(",e)}}m=h.indexOf("Dist(");while(m>=0){if(m>=0){e=h.indexOf(",",m+5);if(e>=0){l=h.slice(m+5,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+5)+"$('"+j.id+"')"+h.slice(e)}}e=h.indexOf(",",m+5);m=h.indexOf(",",e);e=h.indexOf(")",m+1);if(e>=0){l=h.slice(m+1,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+1)+"$('"+j.id+"')"+h.slice(e)}e=h.indexOf(")",m+1);m=h.indexOf("Dist(",e)}f=["Deg","Rad"];for(g=0;g=0){if(m>=0){e=h.indexOf(",",m+4);if(e>=0){l=h.slice(m+4,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+4)+"$('"+j.id+"')"+h.slice(e)}}e=h.indexOf(",",m+4);m=h.indexOf(",",e);e=h.indexOf(",",m+1);if(e>=0){l=h.slice(m+1,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+1)+"$('"+j.id+"')"+h.slice(e)}e=h.indexOf(",",m+1);m=h.indexOf(",",e);e=h.indexOf(")",m+1);if(e>=0){l=h.slice(m+1,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+1)+"$('"+j.id+"')"+h.slice(e)}e=h.indexOf(")",m+1);m=h.indexOf(f[g]+"(",e)}}return h};JXG.Board=function(e,j,f,o,n,m,l,k,g,h,i){this.BOARD_MODE_NONE=0;this.BOARD_MODE_DRAG=1;this.BOARD_MODE_MOVE_ORIGIN=2;this.BOARD_QUALITY_LOW=1;this.BOARD_QUALITY_HIGH=2;this.BOARD_MODE_ZOOM=17;this.BOARD_MODE_CONSTRUCT=16;this.CONSTRUCTION_TYPE_POINT=1129599060;this.CONSTRUCTION_TYPE_CIRCLE=1129595724;this.CONSTRUCTION_TYPE_LINE=1129598030;this.CONSTRUCTION_TYPE_GLIDER=1129596740;this.CONSTRUCTION_TYPE_MIDPOINT=1129598288;this.CONSTRUCTION_TYPE_PERPENDICULAR=1129599044;this.CONSTRUCTION_TYPE_PARALLEL=1129599052;this.CONSTRUCTION_TYPE_INTERSECTION=1129597267;this.container=e;this.containerObj=document.getElementById(this.container);if(this.containerObj==null){throw new Error("\nJSXGraph: HTML container element '"+(e)+"' not found.")}this.renderer=j;this.grids=[];this.options=JXG.deepCopy(JXG.Options);this.dimension=2;this.jc=new JXG.JessieCode();this.jc.board=this;this.origin={};this.origin.usrCoords=[1,0,0];this.origin.scrCoords=[1,o[0],o[1]];this.zoomX=n;this.zoomY=m;this.unitX=l*this.zoomX;this.unitY=k*this.zoomY;this.canvasWidth=g;this.canvasHeight=h;if(JXG.exists(f)&&f!==""&&!JXG.exists(document.getElementById(f))){this.id=f}else{this.id=this.generateId()}this.hooks=[];this.dependentBoards=[];this.inUpdate=false;this.objects={};this.groups={};this.animationObjects={};this.highlightedObjects={};this.numObjects=0;this.elementsByName={};this.mode=this.BOARD_MODE_NONE;this.updateQuality=this.BOARD_QUALITY_HIGH;this.isSuspendedRedraw=false;this.calculateSnapSizes();this.drag_dx=0;this.drag_dy=0;this.mouse=null;this.touches=[];this.xmlString="";this.cPos=[];this.touchMoveLast=0;this.downObjects=[];this.showCopyright=false;if((i!=null&&i)||(i==null&&this.options.showCopyright)){this.showCopyright=true;this.renderer.displayCopyright(JXG.JSXGraph.licenseText,this.options.text.fontSize)}this.needsFullUpdate=false;this.reducedUpdate=false;this.currentCBDef="none";this.geonextCompatibilityMode=false;if(this.options.text.useASCIIMathML&&translateASCIIMath){init()}else{this.options.text.useASCIIMathML=false}this.hasMouseHandlers=false;this.hasTouchHandlers=false;this.addEventHandlers()};JXG.extend(JXG.Board.prototype,{generateName:function(g){if(g.type==JXG.OBJECT_TYPE_TICKS){return""}var m,k=3,f="",n="",o=[],e="",l,h;if(g.elementClass==JXG.OBJECT_CLASS_POINT){m=["","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]}else{m=["","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]}switch(g.type){case JXG.OBJECT_TYPE_POLYGON:f="P_{";n="}";break;case JXG.OBJECT_TYPE_CIRCLE:f="k_{";n="}";break;case JXG.OBJECT_TYPE_ANGLE:f="W_{";n="}";break;default:if(g.elementClass!=JXG.OBJECT_CLASS_POINT&&g.elementClass!=JXG.OBJECT_CLASS_LINE){f="s_{";n="}"}}for(l=0;l0;l--){e+=m[o[l-1]]}if(this.elementsByName[e+n]==null){return e+n}}o[0]=m.length;for(l=1;l=e.visProp.layer){if(JXG.exists(e.label)&&j==e.label.content){continue}e=j;i[0]=e}}}if(i.length>0){this.mode=this.BOARD_MODE_DRAG}if(this.options.takeFirst){i.length=1}return i},moveObject:function(e,j,i){var f=new JXG.Coords(JXG.COORDS_BY_SCREEN,this.getScrCoordsOfMouse(e,j),this),g=i.obj,h;if(g.type!=JXG.OBJECT_TYPE_GLIDER){if(!isNaN(i.targets[0].Xprev+i.targets[0].Yprev)){g.setPositionDirectly(JXG.COORDS_BY_SCREEN,f.scrCoords[1],f.scrCoords[2],i.targets[0].Xprev,i.targets[0].Yprev)}i.targets[0].Xprev=f.scrCoords[1];i.targets[0].Yprev=f.scrCoords[2];this.update(g)}else{if(g.type==JXG.OBJECT_TYPE_GLIDER){h=g.coords;g.setPositionDirectly(JXG.COORDS_BY_USER,f.usrCoords[1],f.usrCoords[2]);if(g.slideObject.elementClass==JXG.OBJECT_CLASS_CIRCLE){g.coords=JXG.Math.Geometry.projectPointToCircle(g,g.slideObject,this)}else{if(g.slideObject.elementClass==JXG.OBJECT_CLASS_LINE){g.coords=JXG.Math.Geometry.projectPointToLine(g,g.slideObject,this)}}if(g.group.length!=0){g.group[g.group.length-1].dX=g.coords.scrCoords[1]-h.scrCoords[1];g.group[g.group.length-1].dY=g.coords.scrCoords[2]-h.scrCoords[2];g.group[g.group.length-1].update(this)}else{this.update(g)}}}g.triggerEventHandlers("drag");this.updateInfobox(g);g.highlight()},moveLine:function(f,e,u){var B,i,C,A,t,s,j,r,k,v,z,w,g,h,q,p,n,m,l;if(JXG.exists(u)&&JXG.exists(u.obj)){w=u.obj}else{return}if(w.elementClass!=JXG.OBJECT_CLASS_LINE){return}B=new JXG.Coords(JXG.COORDS_BY_SCREEN,this.getScrCoordsOfMouse(f[0],f[1]),this);i=new JXG.Coords(JXG.COORDS_BY_SCREEN,this.getScrCoordsOfMouse(e[0],e[1]),this);if(JXG.exists(u.targets[0])&&JXG.exists(u.targets[1])&&!isNaN(u.targets[0].Xprev+u.targets[0].Yprev+u.targets[1].Xprev+u.targets[1].Yprev)){C=B.usrCoords;A=i.usrCoords;t=(new JXG.Coords(JXG.COORDS_BY_SCREEN,[u.targets[0].Xprev,u.targets[0].Yprev],this)).usrCoords;s=(new JXG.Coords(JXG.COORDS_BY_SCREEN,[u.targets[1].Xprev,u.targets[1].Yprev],this)).usrCoords;r=[1,(t[1]+s[1])*0.5,(t[2]+s[2])*0.5];j=[1,(C[1]+A[1])*0.5,(C[2]+A[2])*0.5];v=JXG.Math.crossProduct(t,s);k=JXG.Math.crossProduct(C,A);g=JXG.Math.crossProduct(v,k);if(Math.abs(g[0])-1&&this.touches[g].targets[1].num>-1){this.touches[g].targets[0].X=e.targetTouches[this.touches[g].targets[0].num].screenX;this.touches[g].targets[0].Y=e.targetTouches[this.touches[g].targets[0].num].screenY;this.touches[g].targets[1].X=e.targetTouches[this.touches[g].targets[1].num].screenX;this.touches[g].targets[1].Y=e.targetTouches[this.touches[g].targets[1].num].screenY;this.moveLine(this.getMousePosition(e,this.touches[g].targets[0].num),this.getMousePosition(e,this.touches[g].targets[1].num),this.touches[g])}}}}else{for(g=0;g0){for(m=0;m0){this.zoomIn(g.usrCoords[1],g.usrCoords[2])}else{this.zoomOut(g.usrCoords[1],g.usrCoords[2])}e.preventDefault();return false},updateInfobox:function(f){var e,i,g,h;if(!f.visProp.showinfobox){return this}if(f.elementClass==JXG.OBJECT_CLASS_POINT){g=f.coords.usrCoords[1];h=f.coords.usrCoords[2];this.infobox.setCoords(g+this.infobox.distanceX/(this.unitX),h+this.infobox.distanceY/(this.unitY));if(typeof(f.infoboxText)!="string"){e=Math.abs(g);if(e>0.1){e=g.toFixed(2)}else{if(e>=0.01){e=g.toFixed(4)}else{if(e>=0.0001){e=g.toFixed(6)}else{e=g}}}i=Math.abs(h);if(i>0.1){i=h.toFixed(2)}else{if(i>=0.01){i=h.toFixed(4)}else{if(i>=0.0001){i=h.toFixed(6)}else{i=h}}}this.highlightInfobox(e,i,f)}else{this.highlightCustomInfobox(f.infoboxText,f)}this.renderer.show(this.infobox);this.renderer.updateText(this.infobox)}return this},highlightCustomInfobox:function(e){this.infobox.setText(''+e+"");return this},highlightInfobox:function(e,g,f){this.highlightCustomInfobox("("+e+", "+g+")");return this},dehighlightAll:function(){var f,g,e=false;for(f in this.highlightedObjects){g=this.highlightedObjects[f];g.noHighlight();e=true}this.highlightedObjects={};if(this.options.renderer=="canvas"&&e){this.prepareUpdate();this.renderer.suspendRedraw(this);this.updateRenderer();this.renderer.unsuspendRedraw()}return this},getScrCoordsOfMouse:function(e,g){if(this.options.grid.snapToGrid){var f=new JXG.Coords(JXG.COORDS_BY_SCREEN,[e,g],this);f.setCoordinates(JXG.COORDS_BY_USER,[Math.round((f.usrCoords[1])*this.options.grid.snapSizeX)/this.options.grid.snapSizeX,Math.round((f.usrCoords[2])*this.options.grid.snapSizeY)/this.options.grid.snapSizeY]);return[f.scrCoords[1],f.scrCoords[2]]}else{return[e,g]}},getUsrCoordsOfMouse:function(i){var g=this.getCoordsTopLeftCorner(),f=JXG.getPosition(i),e=f[0]-g[0],j=f[1]-g[1],h=new JXG.Coords(JXG.COORDS_BY_SCREEN,[e,j],this);return h.usrCoords.slice(1)},getAllUnderMouse:function(f){var e=this.getAllObjectsUnderMouse();e.push(this.getUsrCoordsOfMouse(f));return e},getAllObjectsUnderMouse:function(k){var j=this.getCoordsTopLeftCorner(),e=JXG.getPosition(k),g=e[0]-j[0],f=e[1]-j[1],h=[];for(var i in this.objects){if(this.objects[i].visProp.visible&&this.objects[i].hasPoint&&this.objects[i].hasPoint(g,f)){h.push(this.objects[i])}}return h},moveOrigin:function(e,h){var g,f;if(JXG.exists(e)&&JXG.exists(h)){this.origin.scrCoords[1]=e;this.origin.scrCoords[2]=h}for(f in this.objects){g=this.objects[f];if(!g.visProp.frozen&&(g.elementClass==JXG.OBJECT_CLASS_POINT||g.elementClass==JXG.OBJECT_CLASS_CURVE||g.type==JXG.OBJECT_TYPE_AXIS||g.type==JXG.OBJECT_TYPE_TEXT)){if(g.elementClass!=JXG.OBJECT_CLASS_CURVE&&g.type!=JXG.OBJECT_TYPE_AXIS){g.coords.usr2screen()}}}this.clearTraces();this.fullUpdate();return this},addConditions:function(p){var f="var el, x, y, c, rgbo;\n",o=p.indexOf(""),n=p.indexOf(""),l,k,h,r,e,g;if(o<0){return}while(o>=0){l=p.slice(o+6,n);k=l.indexOf("=");h=l.slice(0,k);r=l.slice(k+1);k=h.indexOf(".");e=h.slice(0,k);g=this.elementsByName[JXG.unescapeHTML(e)];var q=h.slice(k+1).replace(/\s+/g,"").toLowerCase();r=JXG.GeonextParser.geonext2JS(r,this);r=r.replace(/this\.board\./g,"this.");if(!JXG.exists(this.elementsByName[e])){JXG.debug("debug conditions: |"+e+"| undefined")}f+='el = this.objects["'+g.id+'"];\n';switch(q){case"x":f+="var y=el.coords.usrCoords[2];\n";f+="el.setPositionDirectly(JXG.COORDS_BY_USER,"+(r)+",y);\n";f+="el.prepareUpdate().update();\n";break;case"y":f+="var x=el.coords.usrCoords[1];\n";f+="el.coords=new JXG.Coords(JXG.COORDS_BY_USER,[x,"+(r)+"],this);\n";f+="el.setPositionDirectly(JXG.COORDS_BY_USER,x,"+(r)+");\n";f+="el.prepareUpdate().update();\n";break;case"visible":f+="var c="+(r)+";\n";f+="el.visProp.visible = c;\n";f+="if (c) {el.showElement();} else {el.hideElement();}\n";break;case"position":f+="el.position = "+(r)+";\n";f+="el.prepareUpdate().update(true);\n";break;case"stroke":f+="rgbo = JXG.rgba2rgbo("+(r)+");\n";f+="el.visProp.strokecolor = rgbo[0];\n";f+="el.visProp.strokeopacity = rgbo[1];\n";break;case"style":f+="el.setStyle("+(r)+");\n";break;case"strokewidth":f+="el.strokeWidth = "+(r)+";\n";break;case"fill":f+="var rgbo = JXG.rgba2rgbo("+(r)+");\n";f+="el.visProp.fillcolor = rgbo[0];\n";f+="el.visProp.fillopacity = rgbo[1];\n";break;case"label":break;default:JXG.debug("property '"+q+"' in conditions not yet implemented:"+r);break}p=p.slice(n+7);o=p.indexOf("");n=p.indexOf("")}f+="this.prepareUpdate().updateElements();\n";f+="return true;\n";this.updateConditions=new Function(f);this.updateConditions()},updateConditions:function(){return false},calculateSnapSizes:function(){var g=new JXG.Coords(JXG.COORDS_BY_USER,[0,0],this),f=new JXG.Coords(JXG.COORDS_BY_USER,[this.options.grid.gridX,this.options.grid.gridY],this),e=g.scrCoords[1]-f.scrCoords[1],h=g.scrCoords[2]-f.scrCoords[2];this.options.grid.snapSizeX=this.options.grid.gridX;while(Math.abs(e)>25){this.options.grid.snapSizeX*=2;e/=2}this.options.grid.snapSizeY=this.options.grid.gridY;while(Math.abs(h)>25){this.options.grid.snapSizeY*=2;h/=2}return this},applyZoom:function(){var f,e;for(e in this.objects){f=this.objects[e];if(!f.visProp.frozen&&(f.elementClass==JXG.OBJECT_CLASS_POINT||f.elementClass==JXG.OBJECT_CLASS_CURVE||f.type==JXG.OBJECT_TYPE_AXIS||f.type==JXG.OBJECT_TYPE_TEXT)){if(f.elementClass!=JXG.OBJECT_CLASS_CURVE&&f.type!=JXG.OBJECT_TYPE_AXIS){f.coords.usr2screen()}}}this.calculateSnapSizes();this.clearTraces();this.fullUpdate();return this},zoomIn:function(m,k){var h=this.getBoundingBox(),l=this.options.zoom.factorX,j=this.options.zoom.factorY,f=(h[2]-h[0])*(1-1/l),e=(h[1]-h[3])*(1-1/j),g=0.5,i=0.5;if(typeof m==="number"&&typeof k==="number"){g=(m-h[0])/(h[2]-h[0]);i=(h[1]-k)/(h[1]-h[3])}this.setBoundingBox([h[0]+f*g,h[1]-e*i,h[2]-f*(1-g),h[3]+e*(1-i)],false);this.zoomX*=l;this.zoomY*=j;this.applyZoom();return this},zoomOut:function(m,k){var h=this.getBoundingBox(),l=this.options.zoom.factorX,j=this.options.zoom.factorY,f=(h[2]-h[0])*(1-l),e=(h[1]-h[3])*(1-j),g=0.5,i=0.5;if(typeof m==="number"&&typeof k==="number"){g=(m-h[0])/(h[2]-h[0]);i=(h[1]-k)/(h[1]-h[3])}this.setBoundingBox([h[0]+f*g,h[1]-e*i,h[2]-f*(1-g),h[3]+e*(1-i)],false);this.zoomX/=l;this.zoomY/=j;this.applyZoom();return this},zoom100:function(){var g=this.getBoundingBox(),f=(g[2]-g[0])*(1-this.zoomX)*0.5,e=(g[1]-g[3])*(1-this.zoomY)*0.5;this.setBoundingBox([g[0]+f,g[1]-e,g[2]-f,g[3]+e],false);this.zoomX=1;this.zoomY=1;this.applyZoom();return this},zoomAllPoints:function(){var e=0,k=0,l=0,j=0,i,h,g,f;for(i in this.objects){if(JXG.isPoint(this.objects[i])&&this.objects[i].visProp.visible){if(this.objects[i].coords.usrCoords[1]k){k=this.objects[i].coords.usrCoords[1]}}if(this.objects[i].coords.usrCoords[2]>j){j=this.objects[i].coords.usrCoords[2]}else{if(this.objects[i].coords.usrCoords[2]=0){g+=""+this.objects[h].id+": "}for(k in this.objects[h].childElements){g+=this.objects[h].childElements[k].id+"("+this.objects[h].childElements[k].name+"), "}g+="

\n"}g+="

\n";j=window.open();j.document.open();j.document.write(g);j.document.close();return this},showXML:function(){var e=window.open("");e.document.open();e.document.write("
"+JXG.escapeHTML(this.xmlString)+"
");e.document.close();return this},prepareUpdate:function(){var e,f;for(e in this.objects){f=this.objects[e];if(!this.needsFullUpdate&&!f.needsRegularUpdate){continue}f.needsUpdate=true}return this},updateElements:function(f){var e,g;f=JXG.getRef(this,f);for(e in this.objects){g=this.objects[e];if(f==null||g.id!=f.id){g.update(true)}else{g.update(false)}}return this},updateRenderer:function(f){var e,g;if(this.options.renderer=="canvas"){this.updateRendererCanvas(f)}else{for(e in this.objects){g=this.objects[e];g.updateRenderer()}}return this},updateRendererCanvas:function(j){var e,m,h,g=this.options.layer,l=this.options.layer.numlayers,n=Number.NEGATIVE_INFINITY,k,f;for(h=0;hn&&g[f]1?Array.prototype.slice.call(arguments,1):[];if(!JXG.exists(f)){f=["update"]}if(!JXG.isArray(f)){f=[f]}e=f.length;h=this.hooks.length;for(k=0;k=0;e--){if(this.dependentBoards[e]==f){this.dependentBoards.splice(e,1)}}return this},update:function(h){var g,f,j,e;if(this.inUpdate||this.isSuspendedUpdate){return this}this.inUpdate=true;this.prepareUpdate(h).updateElements(h).updateConditions();this.renderer.suspendRedraw(this);this.updateRenderer(h);this.renderer.unsuspendRedraw();this.updateHooks();f=this.dependentBoards.length;for(g=0;g-o){t=-B;p.applyOnce(k)}else{if(t>B&&t0){r=setInterval(this.rolling,f)}return this};this.stop=function(){clearInterval(r);return this};return this};return new e()}});JXG.Options={showCopyright:true,showNavigation:true,takeSizeFromFile:false,renderer:"svg",takeFirst:false,pan:true,zoom:{factorX:1.25,factorY:1.25,wheel:false},jc:{enabled:true,compile:true},navbar:{strokeColor:"#aaaaaa",fillColor:"#f5f5f5",padding:"2px",position:"absolute",fontSize:"10px",cursor:"pointer",zIndex:"100",right:"5px",bottom:"5px"},elements:{strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",fillColor:"red",highlightFillColor:"none",strokeOpacity:1,highlightStrokeOpacity:1,fillOpacity:1,highlightFillOpacity:1,strokeWidth:2,highlightStrokeWidth:2,fixed:false,frozen:false,withLabel:false,visible:true,layer:0,dash:0,shadow:false,trace:false,traceAttributes:{},highlight:true,needsRegularUpdate:true,draft:{draft:false,strokeColor:"#565656",fillColor:"#565656",strokeOpacity:0.8,fillOpacity:0.8,strokeWidth:1}},ticks:{drawLabels:false,drawZero:false,insertTicks:false,minTicksDistance:50,minorHeight:4,majorHeight:10,minorTicks:4,ticksDistance:1,strokeOpacity:1,strokeWidth:1,strokeColor:"black",highlightStrokeColor:"#888888"},precision:{touch:30,mouse:4,epsilon:0.0001,hasPoint:4},layer:{numlayers:20,text:9,point:9,arc:8,line:7,circle:6,curve:5,turtle:5,polygon:3,sector:3,angle:3,integral:3,axis:2,grid:1,image:0,trace:0},angle:{withLabel:true,radius:1,type:"auto",fillColor:"#FF7F00",highlightFillColor:"#FF7F00",strokeColor:"#FF7F00",fillOpacity:0.3,highlightFillOpacity:0.3,radiuspoint:{withLabel:false,visible:false,name:""},pointsquare:{withLabel:false,visible:false,name:""},dot:{visible:false,strokeColor:"none",fillColor:"black",size:2,face:"o",withLabel:false,name:""},label:{strokeColor:"#0000FF"}},arc:{firstArrow:false,lastArrow:false,fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",useDirection:false},axis:{needsRegularUpdate:false,strokeWidth:1,strokeColor:"#666666",highlightStrokeWidth:1,highlightStrokeColor:"#888888",withTicks:true,straightFirst:true,straightLast:true,lastArrow:true,withLabel:false,ticks:{needsRegularUpdate:false,strokeWidth:1,strokeColor:"#666666",highlightStrokeColor:"#888888",drawLabels:true,drawZero:false,insertTicks:true,minTicksDistance:10,minorHeight:4,majorHeight:-1,minorTicks:4,ticksDistance:1,strokeOpacity:0.25},point1:{needsRegularUpdate:false},point2:{needsRegularUpdate:false},label:{position:"lft",offsets:[10,-20]}},bisector:{strokeColor:"#000000",point:{visible:false,fixed:false,withLabel:false,name:""}},bisectorlines:{line1:{strokeColor:"red"},line2:{strokeColor:"black"}},chart:{chartStyle:"line",colors:["#B02B2C","#3F4C6B","#C79810","#D15600","#FFFF88","#C3D9FF","#4096EE","#008C00"],highlightcolors:null,fillcolor:null,highlightonsector:false,highlightbysize:false},circle:{fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",center:{visible:false,withLabel:false,fixed:false,name:""},label:{position:"ulft"}},circumcircle:{fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",center:{visible:false,fixed:false,withLabel:false,name:""}},circumcirclearc:{fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",center:{visible:false,withLabel:false,fixed:false,name:""}},circumcirclesector:{useDirection:true,fillColor:"#00FF00",highlightFillColor:"#00FF00",fillOpacity:0.3,highlightFillOpacity:0.3,strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",point:{visible:false,fixed:false,withLabel:false,name:""}},conic:{fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",foci:{fixed:false,visible:false,withLabel:false,name:""}},curve:{strokeWidth:1,strokeColor:"#0000ff",fillColor:"none",handDrawing:false,curveType:null,RDPsmoothing:false,numberPointsHigh:1600,numberPointsLow:400,doAdvancedPlot:true,label:{position:"lft"}},glider:{},grid:{needsRegularUpdate:false,hasGrid:false,gridX:1,gridY:1,strokeColor:"#C0C0C0",strokeOpacity:"0.5",strokeWidth:1,dash:0,snapToGrid:false,snapSizeX:10,snapSizeY:10},image:{imageString:null,fillOpacity:1},incircle:{fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",center:{visible:false,fixed:false,withLabel:false,name:""}},integral:{withLabel:true,strokeWidth:0,strokeOpacity:0,fillOpacity:0.8,curveLeft:{visible:true,layer:9},baseLeft:{visible:false,fixed:false,withLabel:false,name:""},curveRight:{visible:true,layer:9},baseRight:{visible:false,fixed:false,withLabel:false,name:""},label:{fontSize:20}},label:{strokeColor:"black",fixed:true,position:"urt",offsets:[10,10]},legend:{style:"vertical",labels:["1","2","3","4","5","6","7","8"],colors:["#B02B2C","#3F4C6B","#C79810","#D15600","#FFFF88","#C3D9FF","#4096EE","#008C00"]},line:{firstArrow:false,lastArrow:false,straightFirst:true,straightLast:true,fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#888888",withTicks:false,point1:{visible:false,withLabel:false,fixed:false,name:""},point2:{visible:false,withLabel:false,fixed:false,name:""},ticks:{drawLabels:true,drawZero:false,insertTicks:false,minTicksDistance:50,maxTicksDistance:300,minorHeight:4,majorHeight:-1,minorTicks:4,defaultDistance:1,strokeOpacity:0.3},label:{position:"llft"}},locus:{translateToOrigin:false,translateTo10:false,stretch:false,toOrigin:null,to10:null},normal:{strokeColor:"#000000",point:{visible:false,fixed:false,withLabel:false,name:""}},orthogonalprojection:{},parallel:{strokeColor:"#000000",point:{visible:false,fixed:false,withLabel:false,name:""}},perpendicular:{strokeColor:"#000000",straightFirst:true,straightLast:true},perpendicularsegment:{strokeColor:"#000000",straightFirst:false,straightLast:false,point:{visible:false,fixed:true,withLabel:false,name:""}},point:{withLabel:true,style:5,face:"o",size:3,fillColor:"#ff0000",highlightFillColor:"#EEEEEE",strokeWidth:2,strokeColor:"#ff0000",highlightStrokeColor:"#C3D9FF",zoom:false,showInfobox:true,draft:false,attractors:[],attractorDistance:0,snatchDistance:0,snapToGrid:false,snapSizeX:1,snapSizeY:1,snapToPoints:false},polygon:{hasInnerPoints:false,fillColor:"#00FF00",highlightFillColor:"#00FF00",fillOpacity:0.3,highlightFillOpacity:0.3,withLines:true,borders:{withLabel:false,strokeWidth:1,highlightStrokeWidth:1,layer:5},vertices:{withLabel:true,strokeColor:"#ff0000",fillColor:"#ff0000",fixed:true},label:{offsets:[0,0]}},riemannsum:{withLabel:false,fillOpacity:0.3,fillColor:"#ffff00"},sector:{fillColor:"#00FF00",highlightFillColor:"#00FF00",fillOpacity:0.3,highlightFillOpacity:0.3},semicircle:{midpoint:{visible:false,withLabel:false,fixed:false,name:""}},slider:{snapWidth:-1,precision:2,firstArrow:false,lastArrow:false,withTicks:true,withLabel:true,layer:9,showInfobox:false,name:"",visible:true,strokeColor:"#000000",highlightStrokeColor:"#888888",fillColor:"#ffffff",highlightFillColor:"none",size:6,point1:{needsRegularUpdate:false,showInfobox:false,withLabel:false,visible:false,fixed:true,name:""},point2:{needsRegularUpdate:false,showInfobox:false,withLabel:false,visible:false,fixed:true,name:""},baseline:{needsRegularUpdate:false,name:"",strokeWidth:1,strokeColor:"#000000",highlightStrokeColor:"#888888"},ticks:{needsRegularUpdate:false,drawLabels:false,drawZero:true,insertTicks:true,minorHeight:4,majorHeight:10,minorTicks:0,defaultDistance:1,strokeOpacity:1,strokeWidth:1,strokeColor:"#000000"},highline:{strokeWidth:3,name:"",strokeColor:"#000000",highlightStrokeColor:"#888888"},label:{strokeColor:"#000000"}},text:{fontSize:12,digits:2,isLabel:false,strokeColor:"#000000",useASCIIMathML:false,useMathJax:false,display:"html",cssClass:"JXGtext",highlightCssClass:"JXGtext",withLabel:false},tracecurve:{strokeColor:"#000000",fillColor:"none",numberPoints:100},turtle:{strokeWidth:1,fillColor:"none",strokeColor:"#000000",arrow:{strokeWidth:2,withLabel:false,strokeColor:"#ff0000"}},shortcuts:{color:["strokeColor","fillColor"],opacity:["strokeOpacity","fillOpacity"],highlightColor:["highlightStrokeColor","highlightFillColor"],highlightOpacity:["highlightStrokeOpacity","highlightFillOpacity"],strokeWidth:["strokeWidth","highlightStrokeWidth"]}};JXG.Validator=(function(){var l=function(i){return/^[0-9]+px$/.test(i)},n=function(i){return(i in {html:0,internal:0})},o=function(i){return JXG.isString(i)},m=function(i){return JXG.exists(JXG.Point.prototype.normalizeFace.call(this,i))},q=function(i){return(Math.abs(i-Math.round(i))0},j=function(i){return i.length>=2&&q(i[0])&&q(i[1])},e=function(i){return(i in {vml:0,svg:0,canvas:0})},k=function(i){return i>0},h=function(i){return !(i<0)},g,p={},f={attractorDistance:h,color:o,defaultDistance:JXG.isNumber,display:n,doAdvancedPlot:false,draft:false,drawLabels:false,drawZero:false,face:m,factor:JXG.isNumber,fillColor:o,fillOpacity:JXG.isNumber,firstArrow:false,fontSize:q,dash:q,gridX:JXG.isNumber,gridY:JXG.isNumber,hasGrid:false,highlightFillColor:o,highlightFillOpacity:JXG.isNumber,highlightStrokeColor:o,highlightStrokeOpacity:JXG.isNumber,insertTicks:false,lastArrow:false,majorHeight:q,maxTicksDistance:r,minorHeight:q,minorTicks:r,minTicksDistance:r,numberPointsHigh:r,numberPointsLow:r,opacity:JXG.isNumber,radius:JXG.isNumber,RDPsmoothing:false,renderer:e,right:l,showCopyright:false,showInfobox:false,showNavigation:false,size:q,snapSizeX:k,snapSizeY:k,snapWidth:JXG.isNumber,snapToGrid:false,snatchDistance:h,straightFirst:false,straightLast:false,stretch:false,strokeColor:o,strokeOpacity:JXG.isNumber,strokeWidth:q,takeFirst:false,takeSizeFromFile:false,to10:false,toOrigin:false,translateTo10:false,translateToOrigin:false,useASCIIMathML:false,useDirection:false,useMathJax:false,withLabel:false,withTicks:false,zoom:false};for(g in f){p[g.toLowerCase()]=f[g]}return p})();JXG.useStandardOptions=function(i){var k=JXG.Options,h=i.hasGrid,g,f,j,e;i.options.grid.hasGrid=k.grid.hasGrid;i.options.grid.gridX=k.grid.gridX;i.options.grid.gridY=k.grid.gridY;i.options.grid.gridColor=k.grid.gridColor;i.options.grid.gridOpacity=k.grid.gridOpacity;i.options.grid.gridDash=k.grid.gridDash;i.options.grid.snapToGrid=k.grid.snapToGrid;i.options.grid.snapSizeX=k.grid.SnapSizeX;i.options.grid.snapSizeY=k.grid.SnapSizeY;i.takeSizeFromFile=k.takeSizeFromFile;e=function(l,m){l.visProp.fillcolor=m.fillColor;l.visProp.highlightfillcolor=m.highlightFillColor;l.visProp.strokecolor=m.strokeColor;l.visProp.highlightstrokecolor=m.highlightStrokeColor};for(g in i.objects){j=i.objects[g];if(j.elementClass==JXG.OBJECT_CLASS_POINT){e(j,k.point)}else{if(j.elementClass==JXG.OBJECT_CLASS_LINE){e(j,k.line);for(f in j.ticks){f.majorTicks=k.line.ticks.majorTicks;f.minTicksDistance=k.line.ticks.minTicksDistance;f.visProp.minorheight=k.line.ticks.minorHeight;f.visProp.majorheight=k.line.ticks.majorHeight}}else{if(j.elementClass==JXG.OBJECT_CLASS_CIRCLE){e(j,k.circle)}else{if(j.type==JXG.OBJECT_TYPE_ANGLE){e(j,k.angle)}else{if(j.type==JXG.OBJECT_TYPE_ARC){e(j,k.arc)}else{if(j.type==JXG.OBJECT_TYPE_POLYGON){e(j,k.polygon)}else{if(j.type==JXG.OBJECT_TYPE_CONIC){e(j,k.conic)}else{if(j.type==JXG.OBJECT_TYPE_CURVE){e(j,k.curve)}else{if(j.type==JXG.OBJECT_TYPE_SECTOR){j.arc.visProp.fillcolor=k.sector.fillColor;j.arc.visProp.highlightfillcolor=k.sector.highlightFillColor;j.arc.visProp.fillopacity=k.sector.fillOpacity;j.arc.visProp.highlightfillopacity=k.sector.highlightFillOpacity}}}}}}}}}}i.fullUpdate();if(h&&!i.hasGrid){i.removeGrids(i)}else{if(!h&&i.hasGrid){i.create("grid",[])}}};JXG.useBlackWhiteOptions=function(e){var f=JXG.Options;f.point.fillColor=JXG.rgb2bw(f.point.fillColor);f.point.highlightFillColor=JXG.rgb2bw(f.point.highlightFillColor);f.point.strokeColor=JXG.rgb2bw(f.point.strokeColor);f.point.highlightStrokeColor=JXG.rgb2bw(f.point.highlightStrokeColor);f.line.fillColor=JXG.rgb2bw(f.line.fillColor);f.line.highlightFillColor=JXG.rgb2bw(f.line.highlightFillColor);f.line.strokeColor=JXG.rgb2bw(f.line.strokeColor);f.line.highlightStrokeColor=JXG.rgb2bw(f.line.highlightStrokeColor);f.circle.fillColor=JXG.rgb2bw(f.circle.fillColor);f.circle.highlightFillColor=JXG.rgb2bw(f.circle.highlightFillColor);f.circle.strokeColor=JXG.rgb2bw(f.circle.strokeColor);f.circle.highlightStrokeColor=JXG.rgb2bw(f.circle.highlightStrokeColor);f.arc.fillColor=JXG.rgb2bw(f.arc.fillColor);f.arc.highlightFillColor=JXG.rgb2bw(f.arc.highlightFillColor);f.arc.strokeColor=JXG.rgb2bw(f.arc.strokeColor);f.arc.highlightStrokeColor=JXG.rgb2bw(f.arc.highlightStrokeColor);f.polygon.fillColor=JXG.rgb2bw(f.polygon.fillColor);f.polygon.highlightFillColor=JXG.rgb2bw(f.polygon.highlightFillColor);f.sector.fillColor=JXG.rgb2bw(f.sector.fillColor);f.sector.highlightFillColor=JXG.rgb2bw(f.sector.highlightFillColor);f.curve.strokeColor=JXG.rgb2bw(f.curve.strokeColor);f.grid.gridColor=JXG.rgb2bw(f.grid.gridColor);JXG.useStandardOptions(e)};JXG.JSXGraph={licenseText:"JSXGraph v0.94 Copyright (C) see http://jsxgraph.org",boards:{},elements:{},rendererType:(function(){var g,e;if(JXG.supportsSVG()){JXG.Options.renderer="svg"}else{if(JXG.supportsVML()){JXG.Options.renderer="vml";function f(){document.body.scrollLeft;document.body.scrollTop}document.onmousemove=f}else{JXG.Options.renderer="canvas"}}e=JXG.rendererFiles[JXG.Options.renderer].split(",");for(g=0;g0){this.board=i;this.type=h;this.elementClass=j||JXG.OBJECT_CLASS_OTHER;this.id=e.id;f=e.name;if(!JXG.exists(f)){f=this.board.generateName(this)}this.board.elementsByName[f]=this;this.name=f;this.needsRegularUpdate=e.needsregularupdate;JXG.clearVisPropOld(this);e=this.resolveShortcuts(e);for(g in e){this._set(g,e[g])}this.visProp.draft=e.draft&&e.draft.draft;this.visProp.gradientangle="270";this.visProp.gradientsecondopacity=this.visProp.fillopacity;this.visProp.gradientpositionx=0.5;this.visProp.gradientpositiony=0.5}};JXG.extend(JXG.GeometryElement.prototype,{addChild:function(g){var f,e;this.childElements[g.id]=g;this.addDescendants(g);g.ancestors[this.id]=this;for(f in this.descendants){this.descendants[f].ancestors[this.id]=this;for(e in this.ancestors){this.descendants[f].ancestors[this.ancestors[e].id]=this.ancestors[e]}}for(f in this.ancestors){for(e in this.descendants){this.ancestors[f].descendants[this.descendants[e].id]=this.descendants[e]}}return this},addDescendants:function(f){var e;this.descendants[f.id]=f;for(e in f.childElements){this.addDescendants(f.childElements[e])}return this},countChildren:function(){var g,e=0,f;f=this.childElements;for(g in f){if(f.hasOwnProperty(g)&&g.indexOf("Label")<0){e++}}return e},getName:function(){return this.name},draggable:function(){return this.isDraggable&&!this.visProp.fixed&&!this.visProp.frozen&&this.type!=JXG.OBJECT_TYPE_GLIDER},generatePolynomial:function(){return[]},animate:function(h,g,q){q=q||{};var e,f,k=35,l=Math.ceil(g/(k*1)),j,n=this;this.animationData={};var o=function(w,v,t){var u,s,r,p,i;u=JXG.rgb2hsv(w);s=JXG.rgb2hsv(v);r=(s[0]-u[0])/(1*l);p=(s[1]-u[1])/(1*l);i=(s[2]-u[2])/(1*l);n.animationData[t]=new Array(l);for(j=0;j=0&&JXG.isString(e)&&e.length==9&&e.charAt(0)==="#"){e=JXG.rgba2rgbo(e);this.visProp[f]=e[0];this.visProp[f.replace("color","opacity")]=e[1]}else{this.visProp[f]=e}},resolveShortcuts:function(g){var f,e;for(f in JXG.Options.shortcuts){if(JXG.exists(g[f])){for(e=0;e/g,">");if(this.label!==null){this.label.content.setText(e)}return this},setAttribute:JXG.shortcut(JXG.GeometryElement.prototype,"setProperty"),setProperty:function(){var j,h,k,e,f,l,g={};for(j=0;j-1){this.eventHandlers[g].splice(e,1)}}else{this.eventHandlers[g].length=0}},removeEvent:JXG.shortcut(JXG.GeometryElement.prototype,"off")});JXG.COORDS_BY_USER=1;JXG.COORDS_BY_SCREEN=2;JXG.Coords=function(g,f,e){this.board=e;this.usrCoords=[];this.scrCoords=[];this.setCoordinates(g,f)};JXG.extend(JXG.Coords.prototype,{normalizeUsrCoords:function(){var e=JXG.Math.eps;if(Math.abs(this.usrCoords[0])>e){this.usrCoords[1]/=this.usrCoords[0];this.usrCoords[2]/=this.usrCoords[0];this.usrCoords[0]=1}},usr2screen:function(i){var h=Math.round,e=this.board,g=this.usrCoords,f=e.origin.scrCoords;if(i===null||i){this.scrCoords[0]=h(g[0]);this.scrCoords[1]=h(g[0]*f[1]+g[1]*e.unitX);this.scrCoords[2]=h(g[0]*f[2]-g[2]*e.unitY)}else{this.scrCoords[0]=g[0];this.scrCoords[1]=g[0]*f[1]+g[1]*e.unitX;this.scrCoords[2]=g[0]*f[2]-g[2]*e.unitY}},screen2usr:function(){var g=this.board.origin.scrCoords,f=this.scrCoords,e=this.board;this.usrCoords[0]=1;this.usrCoords[1]=(f[1]-g[1])/e.unitX;this.usrCoords[2]=(g[2]-f[2])/e.unitY},distance:function(g,k){var h=0,l,e=this.usrCoords,j=this.scrCoords,i;if(g===JXG.COORDS_BY_USER){l=k.usrCoords;i=e[0]-l[0];h=i*i;if(h>JXG.Math.eps){return Number.POSITIVE_INFINITY}i=e[1]-l[1];h+=i*i;i=e[2]-l[2];h+=i*i}else{l=k.scrCoords;i=j[1]-l[1];h+=i*i;i=j[2]-l[2];h+=i*i}return Math.sqrt(h)},setCoordinates:function(f,i,g){var e=this.usrCoords,h=this.scrCoords;if(f===JXG.COORDS_BY_USER){if(i.length===2){e[0]=1;e[1]=i[0];e[2]=i[1]}else{e[0]=i[0];e[1]=i[1];e[2]=i[2];this.normalizeUsrCoords()}this.usr2screen(g)}else{h[1]=i[0];h[2]=i[1];this.screen2usr()}return this}});JXG.Point=function(f,g,e){this.constructor(f,e,JXG.OBJECT_TYPE_POINT,JXG.OBJECT_CLASS_POINT);if(g==null){g=[0,0]}this.coords=new JXG.Coords(JXG.COORDS_BY_USER,g,this.board);this.initialCoords=new JXG.Coords(JXG.COORDS_BY_USER,g,this.board);this.position=null;this.onPolygon=false;this.slideObject=null;this.Xjc=null;this.Yjc=null;this.methodMap=JXG.deepCopy(this.methodMap,{move:"moveTo",glide:"makeGlider",X:"X",Y:"Y",free:"free",setPosition:"setGliderPosition"});this.group=[];this.elType="point";this.id=this.board.setId(this,"P");this.board.renderer.drawPoint(this);this.board.finalizeAdding(this);this.createLabel()};JXG.Point.prototype=new JXG.GeometryElement();JXG.extend(JXG.Point.prototype,{hasPoint:function(f,h){var e=this.coords.scrCoords,g;g=parseFloat(this.visProp.size);if(g1){for(h=0;h0&&Math.abs(this._smax-this._smin)>=JXG.Math.eps){if(this.position<0){this.position=0}if(this.position>1){this.position=1}f=this.position*(this._smax-this._smin)+this._smin;f=Math.round(f/this.visProp.snapwidth)*this.visProp.snapwidth;this.position=(f-this._smin)/(this._smax-this._smin);this.update(true)}e=this.slideObject.point1.coords.usrCoords;if(!this.slideObject.visProp.straightfirst&&Math.abs(e[0])>JXG.Math.eps&&this.position<0){this.coords.setCoordinates(JXG.COORDS_BY_USER,e);this.position=0}g=this.slideObject.point2.coords.usrCoords;if(!this.slideObject.visProp.straightlast&&Math.abs(g[0])>JXG.Math.eps&&this.position>1){this.coords.setCoordinates(JXG.COORDS_BY_USER,g);this.position=1}}else{if(this.slideObject.type==JXG.OBJECT_TYPE_TURTLE){this.updateConstraint();this.coords=JXG.Math.Geometry.projectPointToTurtle(this,this.slideObject,this.board)}else{if(this.slideObject.elementClass==JXG.OBJECT_CLASS_CURVE){this.updateConstraint();this.coords=JXG.Math.Geometry.projectPointToCurve(this,this.slideObject,this.board)}else{if(this.slideObject.elementClass==JXG.OBJECT_CLASS_POINT){this.coords=JXG.Math.Geometry.projectPointToPoint(this,this.slideObject,this.board)}}}}}},updateGliderFromParent:function(){var e,f,g,h;if(this.slideObject.elementClass==JXG.OBJECT_CLASS_CIRCLE){g=this.slideObject.Radius();this.coords.setCoordinates(JXG.COORDS_BY_USER,[this.slideObject.center.X()+g*Math.cos(this.position),this.slideObject.center.Y()+g*Math.sin(this.position)])}else{if(this.slideObject.elementClass==JXG.OBJECT_CLASS_LINE){e=this.slideObject.point1.coords;f=this.slideObject.point2.coords;h=e.distance(JXG.COORDS_BY_USER,f);e=e.usrCoords.slice(0);f=f.usrCoords.slice(0);if(h==Number.POSITIVE_INFINITY){h=1/JXG.Math.eps;if(Math.abs(f[0])JXG.Math.eps)?this.isReal:false;if(this.isReal){if(e!=this.isReal){this.board.renderer.show(this);if(this.hasLabel&&this.label.content.visProp.visible){this.board.renderer.show(this.label.content)}}this.board.renderer.updatePoint(this)}else{if(e!=this.isReal){this.board.renderer.hide(this);if(this.hasLabel&&this.label.content.visProp.visible){this.board.renderer.hide(this.label.content)}}}}if(this.hasLabel&&this.visProp.visible&&this.label.content&&this.label.content.visProp.visible&&this.isReal){this.label.content.update();this.board.renderer.updateText(this.label.content)}this.needsUpdate=false;return this},X:function(){return this.coords.usrCoords[1]},Y:function(){return this.coords.usrCoords[2]},Z:function(){return this.coords.usrCoords[0]},XEval:function(){return this.coords.usrCoords[1]},YEval:function(){return this.coords.usrCoords[2]},ZEval:function(){return this.coords.usrCoords[0]},bounds:function(){return this.coords.usrCoords.slice(1).concat(this.coords.usrCoords.slice(1))},Dist:function(g){var h,j=g.coords.usrCoords,e=this.coords.usrCoords,i;i=e[0]-j[0];h=i*i;i=e[1]-j[1];h+=i*i;i=e[2]-j[2];h+=i*i;return Math.sqrt(h)},handleSnapToGrid:function(){var e,h,g=this.visProp.snapsizex,f=this.visProp.snapsizey;if(this.visProp.snaptogrid){e=this.coords.usrCoords[1];h=this.coords.usrCoords[2];if(g<=0&&this.board.defaultAxes&&this.board.defaultAxes.x.defaultTicks){g=this.board.defaultAxes.x.defaultTicks.ticksDelta*(this.board.defaultAxes.x.defaultTicks.visProp.minorticks+1)}if(f<=0&&this.board.defaultAxes&&this.board.defaultAxes.y.defaultTicks){f=this.board.defaultAxes.y.defaultTicks.ticksDelta*(this.board.defaultAxes.y.defaultTicks.visProp.minorticks+1)}if(g>0&&f>0){this.coords=new JXG.Coords(JXG.COORDS_BY_USER,[Math.round(e/g)*g,Math.round(h/f)*f],this.board)}}return this},handleSnapToPoints:function(){var g,j,e,h=0,f=Infinity,i=null;if(this.visProp.snaptopoints){for(g in this.board.objects){j=this.board.objects[g];if(j.elementClass==JXG.OBJECT_CLASS_POINT&&j!==this&&j.visProp.visible){e=JXG.Math.Geometry.projectPointToPoint(this,j,this.board);h=e.distance(JXG.COORDS_BY_USER,this.coords);if(h=this.visProp.snatchdistance){this.type=JXG.OBJECT_TYPE_POINT}}}return this},setPositionDirectly:function(e,l,j){var h,o,n,g,f,k=this.coords,m;this.coords=new JXG.Coords(e,[l,j],this.board);this.handleSnapToGrid();this.handleSnapToPoints();this.handleAttractors();if(this.group.length!=0){o=this.coords.usrCoords[1]-k.usrCoords[1];n=this.coords.usrCoords[2]-k.usrCoords[2];for(h=0;h=0;h--){if(e==JXG.COORDS_BY_SCREEN){m=(new JXG.Coords(e,[l,j],this.board)).usrCoords}else{m=[1,l,j]}this.initialCoords=new JXG.Coords(JXG.COORDS_BY_USER,JXG.Math.matVecMult(JXG.Math.inverse(this.transformations[h].matrix),m),this.board)}this.update()}return this},setPositionByTransform:function(h,e,g){var f=this.board.create("transform",[e,g],{type:"translate"});if(this.transformations.length>0&&this.transformations[this.transformations.length-1].isNumericMatrix){this.transformations[this.transformations.length-1].melt(f)}else{this.addTransform(this,f)}if(this.group.length==0){this.update()}return this},setPosition:function(g,e,f){this.setPositionDirectly(g,e,f);return this},setGliderPosition:function(e){if(this.type=JXG.OBJECT_TYPE_GLIDER){this.position=e;this.board.update()}return this},makeGlider:function(e){this.slideObject=JXG.getRef(this.board,e);this.type=JXG.OBJECT_TYPE_GLIDER;this.elType="glider";this.visProp.snapwidth=-1;this.slideObject.addChild(this);this.isDraggable=true;this.generatePolynomial=function(){return this.slideObject.generatePolynomial(this)};this.updateGlider();return this},free:function(){var e;if(this.type!==JXG.OBJECT_TYPE_GLIDER){if(!this.isDraggable){this.isDraggable=true;this.type=JXG.OBJECT_TYPE_POINT;this.XEval=function(){return this.coords.usrCoords[1]};this.YEval=function(){return this.coords.usrCoords[2]};this.ZEval=function(){return this.coords.usrCoords[0]};this.Xjc=null;this.Yjc=null}else{return}}for(e in this.ancestors){delete this.ancestors[e].descendants[this.id];delete this.ancestors[e].childElements[this.id]}this.ancestors=[];this.slideObject=null;this.elType="point";this.type=JXG.OBJECT_TYPE_POINT},addConstraint:function(j){this.type=JXG.OBJECT_TYPE_CAS;var l=[],e,h,f,g,k=["X","Y"];this.isDraggable=false;for(h=0;h"){return Math.pow(Math.sin((r/(n*1))*Math.PI/2),2)}return r/n};if(Math.abs(j)=0;k--){o[n-k]=[f+j*p(k),e+h*p(k)]}this.animationPath=o;this.animationCallback=q.callback;this.board.addAnimation(this);return this},visit:function(n,g,s){if(typeof s=="number"){s={repeat:s}}else{s=s||{};if(typeof s.repeat=="undefined"){s.repeat=1}}var o=35,p=Math.ceil(g/(o*s.repeat)),q=new Array(s.repeat*(p+1)),f=this.coords.usrCoords[1],e=this.coords.usrCoords[2],l=(n[0]-f),h=(n[1]-e),m,k,r=function(t){var j=(t

"){return Math.pow(Math.sin((j)*Math.PI/2),2)}return j};for(k=0;k=0;m--){q[k*(p+1)+p-m]=[f+l*r(m),e+h*r(m)]}}this.animationPath=q;this.animationCallback=s.callback;this.board.addAnimation(this);return this},_anim:function(o,j){var f,m,k,i,h,g,n=1,e,l;this.intervalCount++;if(this.intervalCount>j){this.intervalCount=0}if(this.slideObject.elementClass==JXG.OBJECT_CLASS_LINE){f=this.slideObject.point1.coords.distance(JXG.COORDS_BY_SCREEN,this.slideObject.point2.coords);m=this.slideObject.getSlope();if(m!="INF"){h=Math.atan(m);k=Math.round((this.intervalCount/j)*f*Math.cos(h));i=Math.round((this.intervalCount/j)*f*Math.sin(h))}else{k=0;i=Math.round((this.intervalCount/j)*f)}if(o<0){g=this.slideObject.point2;if(this.slideObject.point2.coords.scrCoords[1]-this.slideObject.point1.coords.scrCoords[1]>0){n=-1}else{if(this.slideObject.point2.coords.scrCoords[1]-this.slideObject.point1.coords.scrCoords[1]==0){if(this.slideObject.point2.coords.scrCoords[2]-this.slideObject.point1.coords.scrCoords[2]>0){n=-1}}}}else{g=this.slideObject.point1;if(this.slideObject.point1.coords.scrCoords[1]-this.slideObject.point2.coords.scrCoords[1]>0){n=-1}else{if(this.slideObject.point1.coords.scrCoords[1]-this.slideObject.point2.coords.scrCoords[1]==0){if(this.slideObject.point1.coords.scrCoords[2]-this.slideObject.point2.coords.scrCoords[2]>0){n=-1}}}}this.coords.setCoordinates(JXG.COORDS_BY_SCREEN,[g.coords.scrCoords[1]+n*k,g.coords.scrCoords[2]+n*i])}else{if(this.slideObject.elementClass==JXG.OBJECT_CLASS_CURVE){if(o>0){e=Math.round(this.intervalCount/j*this.board.canvasWidth)}else{e=Math.round((j-this.intervalCount)/j*this.board.canvasWidth)}this.coords.setCoordinates(JXG.COORDS_BY_SCREEN,[e,0]);this.coords=JXG.Math.Geometry.projectPointToCurve(this,this.slideObject,this.board)}else{if(this.slideObject.elementClass==JXG.OBJECT_CLASS_CIRCLE){if(o<0){h=this.intervalCount/j*2*Math.PI}else{h=(j-this.intervalCount)/j*2*Math.PI}l=this.slideObject.Radius();this.coords.setCoordinates(JXG.COORDS_BY_USER,[this.slideObject.center.coords.usrCoords[1]+l*Math.cos(h),this.slideObject.center.coords.usrCoords[2]+l*Math.sin(h)])}}}this.board.update(this);return this},setStyle:function(e){var f=["cross","cross","cross","circle","circle","circle","circle","square","square","square","plus","plus","plus"],g=[2,3,4,1,2,3,4,2,3,4,2,3,4];this.visProp.face=f[e];this.visProp.size=g[e];this.board.renderer.changePointStyle(this);return this},normalizeFace:function(e){var f={cross:"x",x:"x",circle:"o",o:"o",square:"[]","[]":"[]",plus:"+","+":"+",diamond:"<>","<>":"<>",triangleup:"^",a:"^","^":"^",triangledown:"v",v:"v",triangleleft:"<","<":"<",triangleright:">",">":">"};return f[e]},remove:function(){if(this.hasLabel){this.board.renderer.remove(this.board.renderer.getElementById(this.label.content.id))}this.board.renderer.remove(this.board.renderer.getElementById(this.id))},getTextAnchor:function(){return this.coords},getLabelAnchor:function(){return this.coords},face:function(e){this.setProperty({face:e})},size:function(e){this.setProperty({size:e})},cloneToBackground:function(){var e={};e.id=this.id+"T"+this.numTraces;this.numTraces++;e.coords=this.coords;e.visProp=JXG.deepCopy(this.visProp,this.visProp.traceattributes,true);e.visProp.layer=this.board.options.layer.trace;e.elementClass=JXG.OBJECT_CLASS_POINT;e.board=this.board;JXG.clearVisPropOld(e);this.board.renderer.drawPoint(e);this.traces[e.id]=e.rendNode;return this},getParents:function(){var e=[this.Z(),this.X(),this.Y()];if(this.parents){e=this.parents}if(this.type==JXG.OBJECT_TYPE_GLIDER){e=[this.X(),this.Y(),this.slideObject.id]}return e}});JXG.createPoint=function(l,h,g){var k,f=false,j,e;e=JXG.copyAttributes(g,l.options,"point");for(j=0;j=3){if(f.length==3){f.push(null)}g=h.create("point",[h.intersection(f[0],f[1],f[2],f[3])],e)}f[0].addChild(g);f[1].addChild(g);g.elType="intersection";g.parents=[f[0].id,f[1].id,f[2]];if(f[3]!=null){g.parents.push(f[3])}g.generatePolynomial=function(){var i=f[0].generatePolynomial(g);var j=f[1].generatePolynomial(g);if((i.length==0)||(j.length==0)){return[]}else{return[i[0],j[0]]}};return g};JXG.createOtherIntersectionPoint=function(h,f,e){var g;if(f.length!=3||!JXG.isPoint(f[2])||(f[0].elementClass!=JXG.OBJECT_CLASS_LINE&&f[0].elementClass!=JXG.OBJECT_CLASS_CIRCLE)||(f[1].elementClass!=JXG.OBJECT_CLASS_LINE&&f[1].elementClass!=JXG.OBJECT_CLASS_CIRCLE)){throw new Error("JSXGraph: Can't create 'other intersection point' with parent types '"+(typeof f[0])+"', '"+(typeof f[1])+"'and '"+(typeof f[2])+"'.\nPossible parent types: [circle|line,circle|line,point]")}else{g=h.create("point",[h.otherIntersection(f[0],f[1],f[2])],e)}g.elType="otherintersection";g.parents=[f[0].id,f[1].id,f[2]];f[0].addChild(g);f[1].addChild(g);g.generatePolynomial=function(){var i=f[0].generatePolynomial(g);var j=f[1].generatePolynomial(g);if((i.length==0)||(j.length==0)){return[]}else{return[i[0],j[0]]}};return g};JXG.JSXGraph.registerElement("point",JXG.createPoint);JXG.JSXGraph.registerElement("glider",JXG.createGlider);JXG.JSXGraph.registerElement("intersection",JXG.createIntersectionPoint);JXG.JSXGraph.registerElement("otherintersection",JXG.createOtherIntersectionPoint);JXG.Line=function(f,h,g,e){this.constructor(f,e,JXG.OBJECT_TYPE_LINE,JXG.OBJECT_CLASS_LINE);this.point1=JXG.getReference(this.board,h);this.point2=JXG.getReference(this.board,g);this.ticks=[];this.defaultTicks=null;this.parentPolygon=null;this.id=this.board.setId(this,"L");this.board.renderer.drawLine(this);this.board.finalizeAdding(this);this.elType="line";this.createLabel();this.point1.addChild(this);this.point2.addChild(this);this.updateStdform()};JXG.Line.prototype=new JXG.GeometryElement;JXG.extend(JXG.Line.prototype,{hasPoint:function(l,k){var h=[],o,n=[1,l,k],m,p,g,f,j,e;h[0]=this.stdform[0]-this.stdform[1]*this.board.origin.scrCoords[1]/this.board.unitX+this.stdform[2]*this.board.origin.scrCoords[2]/this.board.unitY;h[1]=this.stdform[1]/this.board.unitX;h[2]=this.stdform[2]/(-this.board.unitY);m=[0,h[1],h[2]];m=JXG.Math.crossProduct(m,n);m=JXG.Math.crossProduct(m,h);m[1]/=m[0];m[2]/=m[0];m[0]=1;o=(n[1]-m[1])*(n[1]-m[1])+(n[2]-m[2])*(n[2]-m[2]);if(isNaN(o)||o>this.board.options.precision.hasPoint*this.board.options.precision.hasPoint){return false}if(this.visProp.straightfirst&&this.visProp.straightlast){return true}else{p=this.point1.coords;g=this.point2.coords;m=(new JXG.Coords(JXG.COORDS_BY_SCREEN,m.slice(1),this.board)).usrCoords;f=p.distance(JXG.COORDS_BY_USER,g);p=p.usrCoords.slice(0);g=g.usrCoords.slice(0);if(f1){return false}return true}},update:function(){var h,f,e,j,g,m,l,k,i;if(!this.needsUpdate){return this}if(this.constrained){if(typeof this.funps!="undefined"){h=this.funps();if(h&&h.length&&h.length===2){this.point1=h[0];this.point2=h[1]}}else{if(typeof this.funp1==="function"){h=this.funp1();if(JXG.isPoint(h)){this.point1=h}else{if(h&&h.length&&h.length===2){this.point1.setPositionDirectly(JXG.COORDS_BY_USER,h[0],h[1])}}}if(typeof this.funp2==="function"){h=this.funp2();if(JXG.isPoint(h)){this.point2=h}else{if(h&&h.length&&h.length===2){this.point2.setPositionDirectly(JXG.COORDS_BY_USER,h[0],h[1])}}}}}this.updateSegmentFixedLength();this.updateStdform();if(this.visProp.trace){this.cloneToBackground(true)}return this},updateSegmentFixedLength:function(){if(!this.hasFixedLength){return this}d=this.point1.Dist(this.point2);dnew=this.fixedLength();d1=this.fixedLengthOldCoords[0].distance(JXG.COORDS_BY_USER,this.point1.coords);d2=this.fixedLengthOldCoords[1].distance(JXG.COORDS_BY_USER,this.point2.coords);if(d1>JXG.Math.eps||d2>JXG.Math.eps||d!=dnew){drag1=this.point1.isDraggable&&(this.point1.type!=JXG.OBJECT_TYPE_GLIDER)&&!this.point1.visProp.fixed;drag2=this.point2.isDraggable&&(this.point2.type!=JXG.OBJECT_TYPE_GLIDER)&&!this.point2.visProp.fixed;if(d>JXG.Math.eps){if((d1>d2&&drag2)||(d1<=d2&&drag2&&!drag1)){this.point2.setPositionDirectly(JXG.COORDS_BY_USER,this.point1.X()+(this.point2.X()-this.point1.X())*dnew/d,this.point1.Y()+(this.point2.Y()-this.point1.Y())*dnew/d);this.point2.prepareUpdate().updateRenderer()}else{if((d1<=d2&&drag1)||(d1>d2&&drag1&&!drag2)){this.point1.setPositionDirectly(JXG.COORDS_BY_USER,this.point2.X()+(this.point1.X()-this.point2.X())*dnew/d,this.point2.Y()+(this.point1.Y()-this.point2.Y())*dnew/d);this.point1.prepareUpdate().updateRenderer()}}}else{x=Math.random()-0.5;y=Math.random()-0.5;d=Math.sqrt(x*x+y*y);if(drag2){this.point2.setPositionDirectly(JXG.COORDS_BY_USER,this.point1.X()+x*dnew/d,this.point1.Y()+y*dnew/d);this.point2.prepareUpdate().updateRenderer()}else{if(drag1){this.point1.setPositionDirectly(JXG.COORDS_BY_USER,this.point2.X()+x*dnew/d,this.point2.Y()+y*dnew/d);this.point1.prepareUpdate().updateRenderer()}}}this.fixedLengthOldCoords[0].setCoordinates(JXG.COORDS_BY_USER,this.point1.coords.usrCoords);this.fixedLengthOldCoords[1].setCoordinates(JXG.COORDS_BY_USER,this.point2.coords.usrCoords)}return this},updateStdform:function(){var e=JXG.Math.crossProduct(this.point1.coords.usrCoords,this.point2.coords.usrCoords);this.stdform[0]=e[0];this.stdform[1]=e[1];this.stdform[2]=e[2];this.stdform[3]=0;this.normalize()},updateRenderer:function(){var e;if(this.needsUpdate&&this.visProp.visible){e=this.isReal;this.isReal=(!isNaN(this.point1.coords.usrCoords[1]+this.point1.coords.usrCoords[2]+this.point2.coords.usrCoords[1]+this.point2.coords.usrCoords[2])&&(JXG.Math.innerProduct(this.stdform,this.stdform,3)>=JXG.Math.eps*JXG.Math.eps));if(this.isReal){if(e!=this.isReal){this.board.renderer.show(this);if(this.hasLabel&&this.label.content.visProp.visible){this.board.renderer.show(this.label.content)}}this.board.renderer.updateLine(this)}else{if(e!=this.isReal){this.board.renderer.hide(this);if(this.hasLabel&&this.label.content.visProp.visible){this.board.renderer.hide(this.label.content)}}}this.needsUpdate=false}if(this.hasLabel&&this.label.content.visProp.visible&&this.isReal){this.label.content.update();this.board.renderer.updateText(this.label.content)}return this},generatePolynomial:function(i){var h=this.point1.symbolic.x,g=this.point1.symbolic.y,k=this.point2.symbolic.x,j=this.point2.symbolic.y,f=i.symbolic.x,e=i.symbolic.y;return[["(",g,")*(",f,")-(",g,")*(",k,")+(",e,")*(",k,")-(",h,")*(",e,")+(",h,")*(",j,")-(",f,")*(",j,")"].join("")]},getRise:function(){if(Math.abs(this.stdform[2])>=JXG.Math.eps){return -this.stdform[0]/this.stdform[2]}else{return Infinity}},getSlope:function(){if(Math.abs(this.stdform[2])>=JXG.Math.eps){return -this.stdform[1]/this.stdform[2]}else{return Infinity}},getAngle:function(){return Math.atan2(this.point2.Y()-this.point1.Y(),this.point2.X()-this.point1.X())},setStraight:function(e,f){this.visProp.straightfirst=e;this.visProp.straightlast=f;this.board.renderer.updateLine(this);return this},getTextAnchor:function(){return new JXG.Coords(JXG.COORDS_BY_USER,[0.5*(this.point2.X()+this.point1.X()),0.5*(this.point2.Y()+this.point1.Y())],this.board)},setLabelRelativeCoords:function(e){if(JXG.exists(this.label.content)){this.label.content.relativeCoords=new JXG.Coords(JXG.COORDS_BY_SCREEN,[e[0],-e[1]],this.board)}},getLabelAnchor:function(){var g,f,e,j,i=0,h=0,g=new JXG.Coords(JXG.COORDS_BY_USER,this.point1.coords.usrCoords,this.board);f=new JXG.Coords(JXG.COORDS_BY_USER,this.point2.coords.usrCoords,this.board);if(this.visProp.straightfirst||this.visProp.straightlast){JXG.Math.Geometry.calcStraight(this,g,f)}g=g.scrCoords;f=f.scrCoords;switch(this.label.content.visProp.position){case"lft":case"llft":case"ulft":if(g[1]<=f[1]){e=g[1];j=g[2]}else{e=f[1];j=f[2]}break;case"rt":case"lrt":case"urt":if(g[1]>f[1]){e=g[1];j=g[2]}else{e=f[1];j=f[2]}break;default:e=0.5*(g[1]+f[1]);j=0.5*(g[2]+f[2])}if(this.visProp.straightfirst||this.visProp.straightlast){if(JXG.exists(this.label.content)){i=parseFloat(this.label.content.visProp.offsets[0]);h=parseFloat(this.label.content.visProp.offsets[1])}if(Math.abs(e)0&&this.point1.transformations[this.point1.transformations.length-1].isNumericMatrix){this.point1.transformations[this.point1.transformations.length-1].melt(f)}else{this.point1.addTransform(this.point1,f)}if(this.point2.transformations.length>0&&this.point2.transformations[this.point2.transformations.length-1].isNumericMatrix){this.point2.transformations[this.point2.transformations.length-1].melt(f)}else{this.point2.addTransform(this.point2,f)}return this},setPositionDirectly:function(l,e,k,j,i){var g=e-j,f=k-i;if(!this.point1.draggable()||!this.point2.draggable()){return this}g/=this.board.unitX;f/=-this.board.unitY;var h=this.board.create("transform",[g,f,0],{type:"translate"});h.applyOnce([this.point1,this.point2]);return this},X:function(g){var f=this.stdform[2],e;e=(Math.abs(this.point1.coords.usrCoords[0])>JXG.Math.eps)?this.point1.coords.usrCoords[1]:this.point2.coords.usrCoords[1];g=(g-0.5)*2;if(g<0){g*=(-1);return(1-g)*e+g*f}else{return(1-g)*e-g*f}},Y:function(f){var e=this.stdform[1],g;g=(Math.abs(this.point1.coords.usrCoords[0])>JXG.Math.eps)?this.point1.coords.usrCoords[2]:this.point2.coords.usrCoords[2];f=(f-0.5)*2;if(f<0){f*=(-1);return(1-f)*g-f*e}else{return(1-f)*g+f*e}},Z:function(e){var f=(Math.abs(this.point1.coords.usrCoords[0])>JXG.Math.eps)?this.point1.coords.usrCoords[0]:this.point2.coords.usrCoords[0];e=(e-0.5)*2;if(e<0){e*=(-1)}return(1-e)*f},L:function(){return this.point1.Dist(this.point2)},minX:function(){return 0},maxX:function(){return 1},bounds:function(){var e=this.point1.coords.usrCoords,f=this.point2.coords.usrCoords;return[Math.min(e[1],f[1]),Math.max(e[2],f[2]),Math.max(e[1],f[1]),Math.min(e[2],f[2])]},addTicks:function(e){if(e.id==""||typeof e.id=="undefined"){e.id=this.id+"_ticks_"+(this.ticks.length+1)}this.board.renderer.drawTicks(e);this.ticks.push(e);return e.id},removeAllTicks:function(){var f,e;for(e=this.ticks.length;e>0;e--){this.removeTicks(this.ticks[e-1])}this.ticks=new Array();this.board.update()},removeTicks:function(g){var f,e;if(this.defaultTicks!=null&&this.defaultTicks==g){this.defaultTicks=null}for(f=this.ticks.length;f>0;f--){if(this.ticks[f-1]==g){this.board.removeObject(this.ticks[f-1]);for(e=0;e1){m=JXG.copyAttributes(j,l.options,"line","point1");q=l.create("point",o[0],m)}else{if(JXG.isString(o[0])||o[0].elementClass==JXG.OBJECT_CLASS_POINT){q=JXG.getReference(l,o[0])}else{if((typeof o[0]=="function")&&(o[0]().elementClass==JXG.OBJECT_CLASS_POINT)){q=o[0]();h=true}else{if((typeof o[0]=="function")&&(o[0]().length&&o[0]().length===2)){m=JXG.copyAttributes(j,l.options,"line","point1");q=JXG.createPoint(l,o[0](),m);h=true}else{throw new Error("JSXGraph: Can't create line with parent types '"+(typeof o[0])+"' and '"+(typeof o[1])+"'.\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]")}}}}if(JXG.isArray(o[1])&&o[1].length>1){m=JXG.copyAttributes(j,l.options,"line","point2");p=l.create("point",o[1],m)}else{if(JXG.isString(o[1])||o[1].elementClass==JXG.OBJECT_CLASS_POINT){p=JXG.getReference(l,o[1])}else{if((typeof o[1]=="function")&&(o[1]().elementClass==JXG.OBJECT_CLASS_POINT)){p=o[1]();h=true}else{if((typeof o[1]=="function")&&(o[1]().length&&o[1]().length===2)){m=JXG.copyAttributes(j,l.options,"line","point2");p=JXG.createPoint(l,o[1](),m);h=true}else{throw new Error("JSXGraph: Can't create line with parent types '"+(typeof o[0])+"' and '"+(typeof o[1])+"'.\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]")}}}}m=JXG.copyAttributes(j,l.options,"line");g=new JXG.Line(l,q,p,m);if(h){g.constrained=true;g.funp1=o[0];g.funp2=o[1]}else{g.isDraggable=true}if(!g.constrained){g.parents=[q.id,p.id]}}else{if(o.length==3){f=true;for(k=0;k<3;k++){if(typeof o[k]=="number"){n[k]=function(i){return function(){return i}}(o[k])}else{if(typeof o[k]=="function"){n[k]=o[k];f=false}else{throw new Error("JSXGraph: Can't create line with parent types '"+(typeof o[0])+"' and '"+(typeof o[1])+"' and '"+(typeof o[2])+"'.\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]")}}}m=JXG.copyAttributes(j,l.options,"line","point1");if(f){q=l.create("point",[n[2]()*n[2]()+n[1]()*n[1](),n[2]()-n[1]()*n[0]()+n[2](),-n[1]()-n[2]()*n[0]()-n[1]()],m)}else{q=l.create("point",[function(){return(0+n[2]()*n[2]()+n[1]()*n[1]())*0.5},function(){return(n[2]()-n[1]()*n[0]()+n[2]())*0.5},function(){return(-n[1]()-n[2]()*n[0]()-n[1]())*0.5}],m)}m=JXG.copyAttributes(j,l.options,"line","point2");if(f){p=l.create("point",[n[2]()*n[2]()+n[1]()*n[1](),-n[1]()*n[0]()+n[2](),-n[2]()*n[0]()-n[1]()],m)}else{p=l.create("point",[function(){return n[2]()*n[2]()+n[1]()*n[1]()},function(){return -n[1]()*n[0]()+n[2]()},function(){return -n[2]()*n[0]()-n[1]()}],m)}q.prepareUpdate().update();p.prepareUpdate().update();m=JXG.copyAttributes(j,l.options,"line");g=new JXG.Line(l,q,p,m);g.isDraggable=f;if(f){g.parents=[n[0](),n[1](),n[2]()]}}else{if((o.length==1)&&(typeof o[0]=="function")&&(o[0]().length==2)&&(o[0]()[0].elementClass==JXG.OBJECT_CLASS_POINT)&&(o[0]()[1].elementClass==JXG.OBJECT_CLASS_POINT)){var e=o[0]();m=JXG.copyAttributes(j,l.options,"line");g=new JXG.Line(l,e[0],e[1],m);g.constrained=true;g.funps=o[0]}else{if((o.length==1)&&(typeof o[0]=="function")&&(o[0]().length==3)&&(typeof o[0]()[0]==="number")&&(typeof o[0]()[1]==="number")&&(typeof o[0]()[2]==="number")){e=o[0];m=JXG.copyAttributes(j,l.options,"line","point1");q=l.create("point",[function(){var i=e();return[(0+i[2]*i[2]+i[1]*i[1])*0.5,(i[2]-i[1]*i[0]+i[2])*0.5,(-i[1]-i[2]*i[0]-i[1])*0.5]}],m);m=JXG.copyAttributes(j,l.options,"line","point2");p=l.create("point",[function(){var i=e();return[i[2]*i[2]+i[1]*i[1],-i[1]*i[0]+i[2],-i[2]*i[0]-i[1]]}],m);m=JXG.copyAttributes(j,l.options,"line");g=new JXG.Line(l,q,p,m);g.constrained=true;g.funps=o[0]}else{throw new Error("JSXGraph: Can't create line with parent types '"+(typeof o[0])+"' and '"+(typeof o[1])+"'.\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]")}}}}return g};JXG.JSXGraph.registerElement("line",JXG.createLine);JXG.createSegment=function(j,f,e){var h,g;e.straightFirst=false;e.straightLast=false;h=j.create("line",f.slice(0,2),e);if(f.length==3){h.hasFixedLength=true;if(JXG.isNumber(f[2])){h.fixedLength=function(){return f[2]}}else{if(JXG.isFunction(f[2])){h.fixedLength=f[2]}else{throw new Error("JSXGraph: Can't create segment with third parent type '"+(typeof f[2])+"'.\nPossible third parent types: number or function")}}h.fixedLengthOldCoords=[];h.fixedLengthOldCoords[0]=new JXG.Coords(JXG.COORDS_BY_USER,h.point1.coords.usrCoords.slice(1,3),j);h.fixedLengthOldCoords[1]=new JXG.Coords(JXG.COORDS_BY_USER,h.point2.coords.usrCoords.slice(1,3),j)}h.elType="segment";return h};JXG.JSXGraph.registerElement("segment",JXG.createSegment);JXG.createArrow=function(h,f,e){var g;g=h.create("line",f,e).setStraight(false,false);g.setArrow(false,true);g.type=JXG.OBJECT_TYPE_VECTOR;g.elType="arrow";return g};JXG.JSXGraph.registerElement("arrow",JXG.createArrow);JXG.createAxis=function(j,g,f){var e,i,k;if((JXG.isArray(g[0])||JXG.isPoint(g[0]))&&(JXG.isArray(g[1])||JXG.isPoint(g[1]))){e=JXG.copyAttributes(f,j.options,"axis");i=j.create("line",g,e);i.type=JXG.OBJECT_TYPE_AXIS;i.isDraggable=false;i.point1.isDraggable=false;i.point2.isDraggable=false;for(var h in i.ancestors){i.ancestors[h].type=JXG.OBJECT_TYPE_AXISPOINT}e=JXG.copyAttributes(f,j.options,"axis","ticks");if(JXG.exists(e.ticksdistance)){k=e.ticksdistance}else{if(JXG.isArray(e.ticks)){k=e.ticks}else{k=1}}i.defaultTicks=j.create("ticks",[i,k],e);i.defaultTicks.dump=false;i.elType="axis";i.subs={ticks:i.defaultTicks}}else{throw new Error("JSXGraph: Can't create point with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"'.\nPossible parent types: [point,point], [[x1,y1],[x2,y2]]")}return i};JXG.JSXGraph.registerElement("axis",JXG.createAxis);JXG.createTangent=function(q,s,l){var e,r,n,o,m,k,h,t;if(s.length==1){e=s[0];r=e.slideObject}else{if(s.length==2){if(JXG.isPoint(s[0])){e=s[0];r=s[1]}else{if(JXG.isPoint(s[1])){r=s[0];e=s[1]}else{throw new Error("JSXGraph: Can't create tangent with parent types '"+(typeof s[0])+"' and '"+(typeof s[1])+"'.\nPossible parent types: [glider], [point,line|curve|circle|conic]")}}}else{throw new Error("JSXGraph: Can't create tangent with parent types '"+(typeof s[0])+"' and '"+(typeof s[1])+"'.\nPossible parent types: [glider], [point,line|curve|circle|conic]")}}if(r.elementClass==JXG.OBJECT_CLASS_LINE){t=q.create("line",[r.point1,r.point2],l)}else{if(r.elementClass==JXG.OBJECT_CLASS_CURVE&&!(r.type==JXG.OBJECT_TYPE_CONIC)){if(r.visProp.curvetype!="plot"){n=r.X;o=r.Y;t=q.create("line",[function(){return -e.X()*q.D(o)(e.position)+e.Y()*q.D(n)(e.position)},function(){return q.D(o)(e.position)},function(){return -q.D(n)(e.position)}],l);e.addChild(t);t.glider=e}else{t=q.create("line",[function(){m=Math.floor(e.position);if(m==r.numberPoints-1){m--}if(m<0){return 1}return r.Y(m)*r.X(m+1)-r.X(m)*r.Y(m+1)},function(){m=Math.floor(e.position);if(m==r.numberPoints-1){m--}if(m<0){return 0}return r.Y(m+1)-r.Y(m)},function(){m=Math.floor(e.position);if(m==r.numberPoints-1){m--}if(m<0){return 0}return r.X(m)-r.X(m+1)}],l);e.addChild(t);t.glider=e}}else{if(r.type==JXG.OBJECT_TYPE_TURTLE){t=q.create("line",[function(){m=Math.floor(e.position);for(k=0;k1){e=JXG.copyAttributes(f,l.options,"circle","center");m[j]=l.create("point",g[j],e)}else{m[j]=g[j]}}}e=JXG.copyAttributes(f,l.options,"circle");if(g.length==2&&JXG.isPoint(m[0])&&JXG.isPoint(m[1])){k=new JXG.Circle(l,"twoPoints",m[0],m[1],e)}else{if((JXG.isNumber(m[0])||JXG.isFunction(m[0])||JXG.isString(m[0]))&&JXG.isPoint(m[1])){k=new JXG.Circle(l,"pointRadius",m[1],m[0],e)}else{if((JXG.isNumber(m[1])||JXG.isFunction(m[1])||JXG.isString(m[1]))&&JXG.isPoint(m[0])){k=new JXG.Circle(l,"pointRadius",m[0],m[1],e)}else{if((m[0].elementClass==JXG.OBJECT_CLASS_CIRCLE)&&JXG.isPoint(m[1])){k=new JXG.Circle(l,"pointCircle",m[1],m[0],e)}else{if((m[1].elementClass==JXG.OBJECT_CLASS_CIRCLE)&&JXG.isPoint(m[0])){k=new JXG.Circle(l,"pointCircle",m[0],m[1],e)}else{if((m[0].elementClass==JXG.OBJECT_CLASS_LINE)&&JXG.isPoint(m[1])){k=new JXG.Circle(l,"pointLine",m[1],m[0],e)}else{if((m[1].elementClass==JXG.OBJECT_CLASS_LINE)&&JXG.isPoint(m[0])){k=new JXG.Circle(l,"pointLine",m[0],m[1],e)}else{if(g.length==3&&JXG.isPoint(m[0])&&JXG.isPoint(m[1])&&JXG.isPoint(m[2])){k=JXG.createCircumcircle(l,m,f)}else{throw new Error("JSXGraph: Can't create circle with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"'.\nPossible parent types: [point,point], [point,number], [point,function], [point,circle], [point,point,point]")}}}}}}}}k.isDraggable=h;k.parents=[];for(j=0;j1){s[l]=o.create("point",q[l],k)}else{if(JXG.isPoint(q[l])){s[l]=JXG.getReference(o,q[l])}else{if((typeof q[l]=="function")&&(q[l]().elementClass===JXG.OBJECT_CLASS_POINT)){s[l]=q[l]()}else{if(JXG.isString(q[l])){s[l]=JXG.getReference(o,q[l])}else{throw new Error("JSXGraph: Can't create Ellipse with parent types '"+(typeof q[0])+"' and '"+(typeof q[1])+"'.\nPossible parent types: [point,point,point], [point,point,number|function]")}}}}}if(JXG.isNumber(q[2])){e=JXG.createFunction(q[2],o)}else{if((typeof q[2]=="function")&&(JXG.isNumber(q[2]()))){e=q[2]}else{if(JXG.isPoint(q[2])){f=JXG.getReference(o,q[2])}else{if(q[2].length>1){f=o.create("point",q[2],k)}else{if((typeof q[2]=="function")&&(q[2]().elementClass==JXG.OBJECT_CLASS_POINT)){f=q[2]()}else{if(JXG.isString(q[2])){f=JXG.getReference(o,q[2])}else{throw new Error("JSXGraph: Can't create Ellipse with parent types '"+(typeof q[0])+"' and '"+(typeof q[1])+"' and '"+(typeof q[2])+"'.\nPossible parent types: [point,point,point], [point,point,number|function]")}}}}e=function(){return f.Dist(s[0])+f.Dist(s[1])}}}if(typeof q[4]=="undefined"){q[4]=1.0001*Math.PI}if(typeof q[3]=="undefined"){q[3]=-1.0001*Math.PI}var p=o.create("point",[function(){return(s[0].X()+s[1].X())*0.5},function(){return(s[0].Y()+s[1].Y())*0.5}],k);var r=function(){var i=s[0].X(),C=s[0].Y(),z=s[1].X(),w=s[1].Y(),B,A,v;var u=(z-i>0)?1:-1;if(Math.abs(z-i)>1e-7){B=Math.atan2(w-C,z-i)+((u<0)?Math.PI:0)}else{B=((w-C>0)?0.5:-0.5)*Math.PI}A=Math.cos(B);v=Math.sin(B);var t=[[1,0,0],[p.X(),A,-v],[p.Y(),v,A]];return t};var g=o.create("curve",[function(i){return 0},function(i){return 0},q[3],q[4]],n);var h=function(v,t){var B=e()*0.5,i=B*B,u=s[1].Dist(s[0])*0.5,w=i-u*u,A=Math.sqrt(w),z=[[1,0,0],[0,1,0],[0,0,1]],D,C;if(!t){m=r();D=p.X();C=p.Y();z[0][0]=m[0][0];z[0][1]=0;z[0][2]=0;z[1][0]=D*(1-m[1][1])+C*m[1][2];z[1][1]=m[1][1];z[1][2]=m[2][1];z[2][0]=C*(1-m[1][1])-D*m[1][2];z[2][1]=m[1][2];z[2][2]=m[2][2];g.quadraticform=JXG.Math.matMatMult(JXG.Math.transpose(z),JXG.Math.matMatMult([[-1+D*D/(B*B)+C*C/w,-D/i,-D/w],[-D/i,1/i,0],[-C/w,0,1/w]],z))}return JXG.Math.matVecMult(m,[1,B*Math.cos(v),A*Math.sin(v)])};g.X=function(i,t){return h(i,t)[1]};g.Y=function(i,t){return h(i,t)[2]};g.midpoint=p;g.type=JXG.OBJECT_TYPE_CONIC;return g};JXG.createHyperbola=function(o,q,j){var s=[],f,e,l,m,k=JXG.copyAttributes(j,o.options,"conic","foci"),n=JXG.copyAttributes(j,o.options,"conic");for(l=0;l<2;l++){if(q[l].length>1){s[l]=o.create("point",q[l],attr_focu)}else{if(JXG.isPoint(q[l])){s[l]=JXG.getReference(o,q[l])}else{if((typeof q[l]=="function")&&(q[l]().elementClass==JXG.OBJECT_CLASS_POINT)){s[l]=q[l]()}else{if(JXG.isString(q[l])){s[l]=JXG.getReference(o,q[l])}else{throw new Error("JSXGraph: Can't create Hyperbola with parent types '"+(typeof q[0])+"' and '"+(typeof q[1])+"'.\nPossible parent types: [point,point,point], [point,point,number|function]")}}}}}if(JXG.isNumber(q[2])){e=JXG.createFunction(q[2],o)}else{if((typeof q[2]=="function")&&(JXG.isNumber(q[2]()))){e=q[2]}else{if(JXG.isPoint(q[2])){f=JXG.getReference(o,q[2])}else{if(q[2].length>1){f=o.create("point",q[2],k)}else{if((typeof q[2]=="function")&&(q[2]().elementClass==JXG.OBJECT_CLASS_POINT)){f=q[2]()}else{if(JXG.isString(q[2])){f=JXG.getReference(o,q[2])}else{throw new Error("JSXGraph: Can't create Hyperbola with parent types '"+(typeof q[0])+"' and '"+(typeof q[1])+"' and '"+(typeof q[2])+"'.\nPossible parent types: [point,point,point], [point,point,number|function]")}}}}e=function(){return f.Dist(s[0])-f.Dist(s[1])}}}if(typeof q[4]=="undefined"){q[4]=1.0001*Math.PI}if(typeof q[3]=="undefined"){q[3]=-1.0001*Math.PI}var p=o.create("point",[function(){return(s[0].X()+s[1].X())*0.5},function(){return(s[0].Y()+s[1].Y())*0.5}],k);var r=function(){var u=s[0].X(),t=s[0].Y(),A=s[1].X(),w=s[1].Y(),v;var z=(A-u>0)?1:-1;if(Math.abs(A-u)>1e-7){v=Math.atan2(w-t,A-u)+((z<0)?Math.PI:0)}else{v=((w-t>0)?0.5:-0.5)*Math.PI}var i=[[1,0,0],[p.X(),Math.cos(v),-Math.sin(v)],[p.Y(),Math.sin(v),Math.cos(v)]];return i};var g=o.create("curve",[function(i){return 0},function(i){return 0},q[3],q[4]],n);var h=function(v,t){var B=e()*0.5,i=B*B,u=s[1].Dist(s[0])*0.5,A=Math.sqrt(-B*B+u*u),w=A*A,z=[[1,0,0],[0,1,0],[0,0,1]],D,C;if(!t){m=r();D=p.X();C=p.Y();z[0][0]=m[0][0];z[0][1]=0;z[0][2]=0;z[1][0]=D*(1-m[1][1])+C*m[1][2];z[1][1]=m[1][1];z[1][2]=m[2][1];z[2][0]=C*(1-m[1][1])-D*m[1][2];z[2][1]=m[1][2];z[2][2]=m[2][2];g.quadraticform=JXG.Math.matMatMult(JXG.Math.transpose(z),JXG.Math.matMatMult([[-1+D*D/i+C*C/w,-D/i,C/w],[-D/i,1/i,0],[C/w,0,-1/w]],z))}return JXG.Math.matVecMult(m,[1,B/Math.cos(v),A*Math.tan(v)])};g.X=function(i,t){return h(i,t)[1]};g.Y=function(i,t){return h(i,t)[2]};g.midpoint=p;g.type=JXG.OBJECT_TYPE_CONIC;return g};JXG.createParabola=function(n,p,h){var m=p[0],f=p[1],j,i=JXG.copyAttributes(h,n.options,"conic","foci"),k=JXG.copyAttributes(h,n.options,"conic");if(p[0].length>1){m=n.create("point",p[0],i)}else{if(JXG.isPoint(p[0])){m=JXG.getReference(n,p[0])}else{if((typeof p[0]=="function")&&(p[0]().elementClass==JXG.OBJECT_CLASS_POINT)){m=p[0]()}else{if(JXG.isString(p[0])){m=JXG.getReference(n,p[0])}else{throw new Error("JSXGraph: Can't create Parabola with parent types '"+(typeof p[0])+"' and '"+(typeof p[1])+"'.\nPossible parent types: [point,line]")}}}}if(typeof p[3]=="undefined"){p[3]=10}if(typeof p[2]=="undefined"){p[2]=-10}var o=n.create("point",[function(){var l=[0,f.stdform[1],f.stdform[2]];l=JXG.Math.crossProduct(l,m.coords.usrCoords);return JXG.Math.Geometry.meetLineLine(l,f.stdform,0,n).usrCoords}],i);var q=function(){var s=Math.atan(f.getSlope()),r=(o.X()+m.X())*0.5,t=(o.Y()+m.Y())*0.5;s+=(m.Y()-o.Y()<0||(m.Y()==o.Y()&&m.X()>o.X()))?Math.PI:0;var l=[[1,0,0],[r*(1-Math.cos(s))+t*Math.sin(s),Math.cos(s),-Math.sin(s)],[t*(1-Math.cos(s))-r*Math.sin(s),Math.sin(s),Math.cos(s)]];return l};var e=n.create("curve",[function(l){return 0},function(l){return 0},p[2],p[3]],k);var g=function(u,v){var w=o.Dist(m)*0.5,s=[[1,0,0],[0,1,0],[0,0,1]],r=(o.X()+m.X())*0.5,l=(o.Y()+m.Y())*0.5;if(!v){j=q();s[0][0]=j[0][0];s[0][1]=0;s[0][2]=0;s[1][0]=r*(1-j[1][1])+l*j[1][2];s[1][1]=j[1][1];s[1][2]=j[2][1];s[2][0]=l*(1-j[1][1])-r*j[1][2];s[2][1]=j[1][2];s[2][2]=j[2][2];e.quadraticform=JXG.Math.matMatMult(JXG.Math.transpose(s),JXG.Math.matMatMult([[-l*4*w-r*r,r,2*w],[r,-1,0],[2*w,0,0]],s))}return JXG.Math.matVecMult(j,[1,u+r,u*u/(w*4)+l])};e.X=function(l,r){return g(l,r)[1]};e.Y=function(l,r){return g(l,r)[2]};e.type=JXG.OBJECT_TYPE_CONIC;return e};JXG.createConic=function(f,z,h){var k=[[1,0,0],[0,1,0],[0,0,1]],E,C,B,A,g=[[1,0,0],[0,1,0],[0,0,1]],q,o,u=[],v,s,D,n=[],t=JXG.copyAttributes(h,f.options,"conic","foci"),r=JXG.copyAttributes(h,f.options,"conic");if(z.length==5){D=true}else{if(z.length==6){D=false}else{throw new Error("JSXGraph: Can't create generic Conic with "+parent.length+" parameters.")}}if(D){for(v=0;v<5;v++){if(z[v].length>1){u[v]=f.create("point",z[v],t)}else{if(JXG.isPoint(z[v])){u[v]=JXG.getReference(f,z[v])}else{if((typeof z[v]=="function")&&(z[v]().elementClass==JXG.OBJECT_CLASS_POINT)){u[v]=z[v]()}else{if(JXG.isString(z[v])){u[v]=JXG.getReference(f,z[v])}else{throw new Error("JSXGraph: Can't create Conic section with parent types '"+(typeof z[v])+"'.\nPossible parent types: [point,point,point,point,point], [a00,a11,a22,a01,a02,a12]")}}}}}}else{s=[[0,0,0],[0,0,0],[0,0,0]];s[0][0]=(JXG.isFunction(z[2]))?function(){return z[2]()}:function(){return z[2]};s[0][1]=(JXG.isFunction(z[4]))?function(){return z[4]()}:function(){return z[4]};s[0][2]=(JXG.isFunction(z[5]))?function(){return z[5]()}:function(){return z[5]};s[1][1]=(JXG.isFunction(z[0]))?function(){return z[0]()}:function(){return z[0]};s[1][2]=(JXG.isFunction(z[3]))?function(){return z[3]()}:function(){return z[3]};s[2][2]=(JXG.isFunction(z[1]))?function(){return z[1]()}:function(){return z[1]}}var j=function(p){var G,F;for(G=0;G<3;G++){for(F=G;F<3;F++){p[G][F]+=p[F][G]}}for(G=0;G<3;G++){for(F=0;FH){g[G][H]=g[H][G]}}}}l.quadraticform=g;E=JXG.Math.Numerics.Jacobi(g);if(E[0][0][0]<0){E[0][0][0]*=(-1);E[0][1][1]*=(-1);E[0][2][2]*=(-1)}for(H=0;H<3;H++){p=0;for(G=0;G<3;G++){p+=E[1][G][H]*E[1][G][H]}p=Math.sqrt(p);for(G=0;G<3;G++){}}k=E[1];A=Math.sqrt(Math.abs(E[0][0][0]));C=Math.sqrt(Math.abs(E[0][1][1]));B=Math.sqrt(Math.abs(E[0][2][2]))}if(E[0][1][1]<=0&&E[0][2][2]<=0){F=JXG.Math.matVecMult(k,[1/A,Math.cos(I)/C,Math.sin(I)/B])}else{if(E[0][1][1]<=0&&E[0][2][2]>0){F=JXG.Math.matVecMult(k,[Math.cos(I)/A,1/C,Math.sin(I)/B])}else{if(E[0][2][2]<0){F=JXG.Math.matVecMult(k,[Math.sin(I)/A,Math.cos(I)/C,1/B])}}}F[1]/=F[0];F[2]/=F[0];F[0]=1;return F};l.X=function(i,p){return e(i,p)[1]};l.Y=function(i,p){return e(i,p)[2]};l.midpoint=f.create("point",[function(){var i=l.quadraticform;return[i[1][1]*i[2][2]-i[1][2]*i[1][2],i[1][2]*i[0][2]-i[2][2]*i[0][1],i[0][1]*i[1][2]-i[1][1]*i[0][2]]}],t);l.type=JXG.OBJECT_TYPE_CONIC;return l};JXG.JSXGraph.registerElement("ellipse",JXG.createEllipse);JXG.JSXGraph.registerElement("hyperbola",JXG.createHyperbola);JXG.JSXGraph.registerElement("parabola",JXG.createParabola);JXG.JSXGraph.registerElement("conic",JXG.createConic);JXG.Polygon=function(j,g,f){this.constructor(j,f,JXG.OBJECT_TYPE_POLYGON,JXG.OBJECT_CLASS_AREA);var h,m,e,k=JXG.copyAttributes(f,j.options,"polygon","borders");this.withLines=f.withlines;this.attr_line=k;this.vertices=[];for(h=0;hl)!=(this.vertices[g].coords.scrCoords[2]>l))&&(f<(this.vertices[g].coords.scrCoords[1]-this.vertices[h].coords.scrCoords[1])*(l-this.vertices[h].coords.scrCoords[2])/(this.vertices[g].coords.scrCoords[2]-this.vertices[h].coords.scrCoords[2])+this.vertices[h].coords.scrCoords[1])){k=!k}}}else{e=this.borders.length;for(h=0;he){e=this.vertices[h].X()}if(this.vertices[h].Y()>f){f=this.vertices[h].Y()}if(this.vertices[h].Y()this.vertices.length-2){return this}for(g=1;g-1&&f-1;l--){k[e[l]]=-1;if(this.withLines&&(e[l]-1>e[l-1])){g[g.length-1][1]=e[l];g.push([e[l-1]])}}if(this.withLines){g[g.length-1][1]=e[0]}this.vertices=[];for(l=0;lm.length-1){h=m.length-1}}this.board.removeObject(this.borders[h]);m[h]=-1}if(g[l][1]!==0&&g[l][0]!==k.length-1){m[g[l][0]-1]=JXG.createSegment(this.board,[k[Math.max(g[l][1]-1,0)],k[Math.min(g[l][0]+1,this.vertices.length-1)]],this.attr_line)}}this.borders=[];for(l=0;l=h-2){m.id=m.ids[k-2]}e[k]=o.create("point",[e[k-2],f],m);e[k].type=JXG.OBJECT_TYPE_CAS}}m=JXG.copyAttributes(j,o.options,"polygon");g=o.create("polygon",e,m);g.elType="regularpolygon";return g};JXG.JSXGraph.registerElement("polygon",JXG.createPolygon);JXG.JSXGraph.registerElement("regularpolygon",JXG.createRegularPolygon);JXG.Curve=function(g,f,e){this.constructor(g,e,JXG.OBJECT_TYPE_CURVE,JXG.OBJECT_CLASS_CURVE);this.points=[];this.numberPoints=this.visProp.numberpointshigh;this.dataX=null;this.dataY=null;if(f[0]!=null){this.varname=f[0]}else{this.varname="x"}this.xterm=f[1];this.yterm=f[2];this.generateTerm(this.varname,this.xterm,this.yterm,f[3],f[4]);this.updateCurve();this.id=this.board.setId(this,"G");this.board.renderer.drawCurve(this);this.board.finalizeAdding(this);this.createGradient();this.elType="curve";this.createLabel();if(typeof this.xterm=="string"){this.notifyParents(this.xterm)}if(typeof this.yterm=="string"){this.notifyParents(this.yterm)}};JXG.Curve.prototype=new JXG.GeometryElement;JXG.extend(JXG.Curve.prototype,{minX:function(){if(this.visProp.curvetype=="polar"){return 0}else{var e=new JXG.Coords(JXG.COORDS_BY_SCREEN,[0,0],this.board);return e.usrCoords[1]}},maxX:function(){var e;if(this.visProp.curvetype=="polar"){return 2*Math.PI}else{e=new JXG.Coords(JXG.COORDS_BY_SCREEN,[this.board.canvasWidth,0],this.board);return e.usrCoords[1]}},Z:function(e){return 1},hasPoint:function(r,q){var s,A=Infinity,I,m,C,B,v,u,w,f,J,z,o,G,l,F,h,n,p,E=this.visProp.numberpointslow,H=(this.maxX()-this.minX())/E,e=this.board.options.precision.hasPoint/this.board.unitX,g,D,k=true;e=e*e;g=new JXG.Coords(JXG.COORDS_BY_SCREEN,[r,q],this.board);r=g.usrCoords[1];q=g.usrCoords[2];if(this.visProp.curvetype=="parameter"||this.visProp.curvetype=="polar"||this.visProp.curvetype=="functiongraph"){D=this.transformations.length;for(C=0,s=this.minX();C=JXG.Math.eps){n=G*F+l*h;o=n/p;A=G*G+l*l-o*n}else{o=0;A=G*G+l*l}if(o>=0&&o<=1&&A=JXG.Math.eps){i=(t*j+K*I)/J;if(i>0){if(i<=1){t-=i*j;K-=i*I}else{t-=j;K-=I}}}H=t*t+K*K;return Math.sqrt(H)};if(this.board.updateQuality==this.board.BOARD_QUALITY_LOW){F=15;s=10;k=10}else{F=21;s=0.7;k=0.7}A[0]=e-E;for(v=1;v1){C=l(this.points[u-2].scrCoords,[n,m],this.points[u-1].scrCoords);if(C<0.015){u--}}this.points[u]=new JXG.Coords(JXG.COORDS_BY_SCREEN,[n,m],this.board);this.updateTransform(this.points[u]);u++;B=n;f=m;o=p;q--;n=D[q][0];m=D[q][1];G=h[q]+1;v=w[q]*2}while(q>0&&u<500000);this.numberPoints=this.points.length;return this},isSegmentOutside:function(f,h,e,g){return(h<0&&g<0)||(h>this.board.canvasHeight&&g>this.board.canvasHeight)||(f<0&&e<0)||(f>this.board.canvasWidth&&e>this.board.canvasWidth)},isDistOK:function(g,e,h,f){return(Math.abs(g)0&&this.transformations[this.transformations.length-1].isNumericMatrix){this.transformations[this.transformations.length-1].melt(f)}else{this.addTransform(f)}return this},generateTerm:function(f,j,g,e,k){var i,h;if(JXG.isArray(j)){this.dataX=j;this.X=function(n){var m=parseInt(Math.floor(n)),l,o;if(n<0){m=0}else{if(n>this.dataX.length-2){m=this.dataX.length-2}}if(m==n){return this.dataX[m]}else{l=this.dataX[m];o=this.dataX[m+1];return l+(o-l)*(n-m)}};this.visProp.curvetype="plot";this.numberPoints=this.dataX.length}else{this.X=JXG.createFunction(j,this.board,f);if(JXG.isString(j)){this.visProp.curvetype="functiongraph"}else{if(JXG.isFunction(j)||JXG.isNumber(j)){this.visProp.curvetype="parameter"}}}if(JXG.isArray(g)){this.dataY=g;this.Y=function(n){var m=parseInt(Math.floor(n)),l,o;if(n<0){m=0}else{if(n>this.dataY.length-2){m=this.dataY.length-2}}if(m==n){if(JXG.isFunction(this.dataY[m])){return this.dataY[m]()}else{return this.dataY[m]}}else{if(JXG.isFunction(this.dataY[m])){l=this.dataY[m]()}else{l=this.dataY[m]}if(JXG.isFunction(this.dataY[m+1])){o=this.dataY[m+1]()}else{o=this.dataY[m+1]}return l+(o-l)*(n-m)}}}else{this.Y=JXG.createFunction(g,this.board,f)}if(JXG.isFunction(j)&&JXG.isArray(g)){i=JXG.createFunction(g[0],this.board,"");h=JXG.createFunction(g[1],this.board,"");this.X=function(l){return(j)(l)*Math.cos(l)+i()};this.Y=function(l){return(j)(l)*Math.sin(l)+h()};this.visProp.curvetype="polar"}if(e!=null){this.minX=JXG.createFunction(e,this.board,"")}if(k!=null){this.maxX=JXG.createFunction(k,this.board,"")}},notifyParents:function(e){JXG.GeonextParser.findDependencies(this,e,this.board)},getLabelAnchor:function(){var k,e,j,g=0.05*this.board.canvasWidth,f=0.05*this.board.canvasHeight,i=0.95*this.board.canvasWidth,h=0.95*this.board.canvasHeight;switch(this.visProp.label.position){case"ulft":e=g;j=f;break;case"llft":e=g;j=h;break;case"rt":e=i;j=0.5*h;break;case"lrt":e=i;j=h;break;case"urt":e=i;j=f;break;case"top":e=0.5*i;j=f;break;case"bot":e=0.5*i;j=h;break;case"lft":default:e=g;j=0.5*h;break}k=new JXG.Coords(JXG.COORDS_BY_SCREEN,[e,j],this.board);return JXG.Math.Geometry.projectCoordsToCurve(k.usrCoords[1],k.usrCoords[2],0,this,this.board)[0]},cloneToBackground:function(){var f={},e;f.id=this.id+"T"+this.numTraces;f.elementClass=JXG.OBJECT_CLASS_CURVE;this.numTraces++;f.points=this.points.slice(0);f.numberPoints=this.numberPoints;f.board=this.board;f.visProp=JXG.deepCopy(this.visProp,this.visProp.traceattributes,true);f.visProp.layer=this.board.options.layer.trace;f.visProp.curvetype=this.visProp.curvetype;JXG.clearVisPropOld(f);e=this.board.renderer.enhancedRendering;this.board.renderer.enhancedRendering=true;this.board.renderer.drawCurve(f);this.board.renderer.enhancedRendering=e;this.traces[f.id]=f.rendNode;return this},bounds:function(){var m=this.visProp.numberpointslow,k=(this.maxX()-this.minX())/m,f,e,q,p,l,h,o,n,g=[this.minX(),0,this.maxX(),0];if(this.visProp.curvetype=="parameter"||this.visProp.curvetype=="polar"||this.visProp.curvetype=="functiongraph"){h=this.transformations.length;p=this.minX();for(f=0;fn){g[3]=n}p+=k}}else{if(this.visProp.curvetype=="plot"){h=this.numberPoints;for(f=0;fn){g[3]=n}}}}return g}});JXG.createCurve=function(h,g,f){var e=JXG.copyAttributes(f,h.options,"curve");return new JXG.Curve(h,["x"].concat(g),e)};JXG.JSXGraph.registerElement("curve",JXG.createCurve);JXG.createFunctiongraph=function(i,g,f){var e,h=["x","x"].concat(g);e=JXG.copyAttributes(f,i.options,"curve");e.curvetype="functiongraph";return new JXG.Curve(i,h,e)};JXG.JSXGraph.registerElement("functiongraph",JXG.createFunctiongraph);JXG.JSXGraph.registerElement("plot",JXG.createFunctiongraph);JXG.createSpline=function(g,f,e){var h;h=function(){var k,i=[],l=[];var j=function(p,o){var n,m;if(!o){i=[];l=[];if(f.length==2&&JXG.isArray(f[0])&&JXG.isArray(f[1])&&f[0].length==f[1].length){for(n=0;nJXG.Math.Geometry.rad(this.radiuspoint,this.center,this.anglepoint)){l=false}}return l};j.hasPointSector=function(i,q){var p=new JXG.Coords(JXG.COORDS_BY_SCREEN,[i,q],this.board),m=this.Radius(),o=this.center.coords.distance(JXG.COORDS_BY_USER,p),l=(oJXG.Math.Geometry.rad(this.radiuspoint,this.center,this.anglepoint)){l=false}}return l};j.getTextAnchor=function(){return this.center.coords};j.getLabelAnchor=function(){var m=JXG.Math.Geometry.rad(this.radiuspoint,this.center,this.anglepoint),u=10/(this.board.unitX),s=10/(this.board.unitY),q=this.point2.coords.usrCoords,i=this.center.coords.usrCoords,l=q[1]-i[1],t=q[2]-i[2],r,o,n,p;if(this.label.content!=null){this.label.content.relativeCoords=new JXG.Coords(JXG.COORDS_BY_SCREEN,[0,0],this.board)}r=new JXG.Coords(JXG.COORDS_BY_USER,[i[1]+Math.cos(m*0.5)*l-Math.sin(m*0.5)*t,i[2]+Math.sin(m*0.5)*l+Math.cos(m*0.5)*t],this.board);o=r.usrCoords[1]-i[1];n=r.usrCoords[2]-i[2];p=Math.sqrt(o*o+n*n);o=o*(p+u)/p;n=n*(p+s)/p;return new JXG.Coords(JXG.COORDS_BY_USER,[i[1]+o,i[2]+n],this.board)};j.updateQuadraticform=function(){var i=this.center,o=i.X(),n=i.Y(),l=this.Radius();this.quadraticform=[[o*o+n*n-l*l,-o,-n],[-o,1,0],[-n,0,1]]};j.updateStdform=function(){this.stdform[3]=0.5;this.stdform[4]=this.Radius();this.stdform[1]=-this.center.coords.usrCoords[1];this.stdform[2]=-this.center.coords.usrCoords[2];this.normalize()};j.prepareUpdate().update();return j};JXG.JSXGraph.registerElement("arc",JXG.createArc);JXG.createSemicircle=function(i,g,f){var h,j,e;if((JXG.isPoint(g[0]))&&(JXG.isPoint(g[1]))){e=JXG.copyAttributes(f,i.options,"semicircle","midpoint");j=i.create("midpoint",[g[0],g[1]],e);j.dump=false;e=JXG.copyAttributes(f,i.options,"semicircle");h=i.create("arc",[j,g[1],g[0]],e);h.elType="semicircle";h.parents=[g[0].id,g[1].id];h.subs={midpoint:j};h.midpoint=j}else{throw new Error("JSXGraph: Can't create Semicircle with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"'.\nPossible parent types: [point,point]")}return h};JXG.JSXGraph.registerElement("semicircle",JXG.createSemicircle);JXG.createCircumcircleArc=function(i,g,f){var h,j,e;if((JXG.isPoint(g[0]))&&(JXG.isPoint(g[1]))&&(JXG.isPoint(g[2]))){e=JXG.copyAttributes(f,i.options,"circumcirclearc","center");j=i.create("circumcenter",[g[0],g[1],g[2]],e);j.dump=false;e=JXG.copyAttributes(f,i.options,"circumcirclearc");e.usedirection=true;h=i.create("arc",[j,g[0],g[2],g[1]],e);h.elType="circumcirclearc";h.parents=[g[0].id,g[1].id,g[2].id];h.subs={center:j};h.center=j}else{throw new Error("JSXGraph: create Circumcircle Arc with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"' and '"+(typeof g[2])+"'.\nPossible parent types: [point,point,point]")}return h};JXG.JSXGraph.registerElement("circumcirclearc",JXG.createCircumcircleArc);JXG.createSector=function(i,g,f){var h,e;if(!(JXG.isPoint(g[0])&&JXG.isPoint(g[1])&&JXG.isPoint(g[2]))){throw new Error("JSXGraph: Can't create Sector with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"' and '"+(typeof g[2])+"'.")}e=JXG.copyAttributes(f,i.options,"sector");h=i.create("curve",[[0],[0]],e);h.type=JXG.OBJECT_TYPE_SECTOR;h.elType="sector";h.parents=[g[0].id,g[1].id,g[2].id];h.point1=JXG.getReference(i,g[0]);h.point2=JXG.getReference(i,g[1]);h.point3=JXG.getReference(i,g[2]);h.point1.addChild(h);h.point2.addChild(h);h.point3.addChild(h);h.useDirection=f.usedirection;h.updateDataArray=function(){var u=this.point2,t=this.point1,s=this.point3,F,m,H,z,j=JXG.Math.Geometry.rad(u,t,s),D,w=Math.ceil(j/Math.PI*90)+1,G=j/w,p=t.X(),o=t.Y(),q,l,k,r,E;if(this.useDirection){k=g[1].coords.usrCoords,r=g[3].coords.usrCoords,E=g[2].coords.usrCoords;l=(k[1]-E[1])*(k[2]-r[2])-(k[2]-E[2])*(k[1]-r[1]);if(l<0){this.point2=g[1];this.point3=g[2]}else{this.point2=g[2];this.point3=g[1]}}this.dataX=[t.X(),u.X()];this.dataY=[t.Y(),u.Y()];for(F=G,D=1;D<=w;D++,F+=G){m=Math.cos(F);H=Math.sin(F);z=[[1,0,0],[p*(1-m)+o*H,m,-H],[o*(1-m)-p*H,H,m]];q=JXG.Math.matVecMult(z,u.coords.usrCoords);this.dataX.push(q[1]/q[0]);this.dataY.push(q[2]/q[0])}this.dataX.push(t.X());this.dataY.push(t.Y())};h.Radius=function(){return this.point2.Dist(this.point1)};h.getRadius=function(){return this.Radius()};h.hasPointSector=function(j,p){var o=new JXG.Coords(JXG.COORDS_BY_SCREEN,[j,p],this.board),l=this.Radius(),n=this.point1.coords.distance(JXG.COORDS_BY_USER,o),k=(nJXG.Math.Geometry.rad(this.point2,this.point1,this.point3)){k=false}}return k};h.getTextAnchor=function(){return this.point1.coords};h.getLabelAnchor=function(){var l=JXG.Math.Geometry.rad(this.point2,this.point1,this.point3),t=10/(this.board.unitX),r=10/(this.board.unitY),p=this.point2.coords.usrCoords,j=this.point1.coords.usrCoords,k=p[1]-j[1],s=p[2]-j[2],q,n,m,o;if(this.label.content!=null){this.label.content.relativeCoords=new JXG.Coords(JXG.COORDS_BY_SCREEN,[0,0],this.board)}q=new JXG.Coords(JXG.COORDS_BY_USER,[j[1]+Math.cos(l*0.5)*k-Math.sin(l*0.5)*s,j[2]+Math.sin(l*0.5)*k+Math.cos(l*0.5)*s],this.board);n=q.usrCoords[1]-j[1];m=q.usrCoords[2]-j[2];o=Math.sqrt(n*n+m*m);n=n*(o+t)/o;m=m*(o+r)/o;return new JXG.Coords(JXG.COORDS_BY_USER,[j[1]+n,j[2]+m],this.board)};h.prepareUpdate().update();return h};JXG.JSXGraph.registerElement("sector",JXG.createSector);JXG.createCircumcircleSector=function(i,g,f){var h,j,e;if((JXG.isPoint(g[0]))&&(JXG.isPoint(g[1]))&&(JXG.isPoint(g[2]))){e=JXG.copyAttributes(f,i.options,"circumcirclesector","center");j=i.create("circumcenter",[g[0],g[1],g[2]],e);j.dump=false;e=JXG.copyAttributes(f,i.options,"circumcirclesector");h=i.create("sector",[j,g[0],g[2],g[1]],e);h.elType="circumcirclesector";h.parents=[g[0].id,g[1].id,g[2].id];h.center=j;h.subs={center:j}}else{throw new Error("JSXGraph: Can't create circumcircle sector with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"' and '"+(typeof g[2])+"'.")}return h};JXG.JSXGraph.registerElement("circumcirclesector",JXG.createCircumcircleSector);JXG.createAngle=function(r,v,n){var h,g,f,z,s,m,u=["α","β","γ","δ","ε","ζ","&eta","θ","ι","κ","λ","μ","ν","ξ","ο","π","ρ","ς","σ","τ","υ","φ","χ","ψ","ω"],o=0,l,t,k,w,A,e;if((JXG.isPoint(v[0]))&&(JXG.isPoint(v[1]))&&(JXG.isPoint(v[2]))){s=JXG.copyAttributes(n,r.options,"angle");z=s.name;if(typeof z=="undefined"||z==""){while(o=3&&JXG.isPoint(g[0])&&JXG.isPoint(g[1])&&JXG.isPoint(g[2])){e=g[0];k=g[1];j=g[2];i=h.create("point",[function(){var n,m,o;n=Math.sqrt((k.X()-j.X())*(k.X()-j.X())+(k.Y()-j.Y())*(k.Y()-j.Y()));m=Math.sqrt((e.X()-j.X())*(e.X()-j.X())+(e.Y()-j.Y())*(e.Y()-j.Y()));o=Math.sqrt((k.X()-e.X())*(k.X()-e.X())+(k.Y()-e.Y())*(k.Y()-e.Y()));return new JXG.Coords(JXG.COORDS_BY_USER,[(n*e.X()+m*k.X()+o*j.X())/(n+m+o),(n*e.Y()+m*k.Y()+o*j.Y())/(n+m+o)],h)}],f);i.elType="incenter";i.parents=[g[0].id,g[1].id,g[2].id]}else{throw new Error("JSXGraph: Can't create incenter with parent types '"+(typeof g[0])+"', '"+(typeof g[1])+"' and '"+(typeof g[2])+"'.\nPossible parent types: [point,point,point]")}return i};JXG.createCircumcircle=function(i,h,g){var k,l,f;try{f=JXG.copyAttributes(g,i.options,"circumcircle","center");k=JXG.createCircumcircleMidpoint(i,h,f);k.dump=false;if(!JXG.exists(g.layer)){g.layer=i.options.layer.circle}f=JXG.copyAttributes(g,i.options,"circumcircle");l=JXG.createCircle(i,[k,h[0]],f);l.elType="circumcircle";l.parents=[h[0].id,h[1].id,h[2].id];l.subs={center:k}}catch(j){throw new Error("JSXGraph: Can't create circumcircle with parent types '"+(typeof h[0])+"', '"+(typeof h[1])+"' and '"+(typeof h[2])+"'.\nPossible parent types: [point,point,point]")}return l};JXG.createIncircle=function(j,i,g){var l,m,f,h;try{f=JXG.copyAttributes(g,j.options,"incircle","center");l=JXG.createIncenter(j,i,f);l.dump=false;if(!JXG.exists(g.layer)){g.layer=j.options.layer.circle}f=JXG.copyAttributes(g,j.options,"incircle");m=JXG.createCircle(j,[l,function(){var n=Math.sqrt((i[1].X()-i[2].X())*(i[1].X()-i[2].X())+(i[1].Y()-i[2].Y())*(i[1].Y()-i[2].Y())),e=Math.sqrt((i[0].X()-i[2].X())*(i[0].X()-i[2].X())+(i[0].Y()-i[2].Y())*(i[0].Y()-i[2].Y())),p=Math.sqrt((i[1].X()-i[0].X())*(i[1].X()-i[0].X())+(i[1].Y()-i[0].Y())*(i[1].Y()-i[0].Y())),o=(n+e+p)/2;return Math.sqrt(((o-n)*(o-e)*(o-p))/o)}],f);m.elType="incircle";m.parents=[i[0].id,i[1].id,i[2].id];m.center=l;m.subs={center:l}}catch(k){throw new Error("JSXGraph: Can't create circumcircle with parent types '"+(typeof i[0])+"', '"+(typeof i[1])+"' and '"+(typeof i[2])+"'.\nPossible parent types: [point,point,point]")}return m};JXG.createReflection=function(h,g,f){var e,j,i;if(g[0].elementClass==JXG.OBJECT_CLASS_POINT&&g[1].elementClass==JXG.OBJECT_CLASS_LINE){j=g[0];e=g[1]}else{if(g[1].elementClass==JXG.OBJECT_CLASS_POINT&&g[0].elementClass==JXG.OBJECT_CLASS_LINE){j=g[1];e=g[0]}else{throw new Error("JSXGraph: Can't create reflection point with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"'.\nPossible parent types: [line,point]")}}i=JXG.createPoint(h,[function(){return JXG.Math.Geometry.reflection(e,j,h)}],f);j.addChild(i);e.addChild(i);i.elType="reflection";i.parents=[g[0].id,g[1].id];i.prepareUpdate().update();i.generatePolynomial=function(){var l=e.point1.symbolic.x;var k=e.point1.symbolic.y;var r=e.point2.symbolic.x;var q=e.point2.symbolic.y;var t=j.symbolic.x;var s=j.symbolic.y;var n=i.symbolic.x;var m=i.symbolic.y;var p=["((",m,")-(",s,"))*((",k,")-(",q,"))+((",l,")-(",r,"))*((",n,")-(",t,"))"].join("");var o=["((",n,")-(",l,"))^2+((",m,")-(",k,"))^2-((",t,")-(",l,"))^2-((",s,")-(",k,"))^2"].join("");return[p,o]};return i};JXG.createMirrorPoint=function(h,f,e){var j,g;if(JXG.isPoint(f[0])&&JXG.isPoint(f[1])){j=JXG.createPoint(h,[function(){return JXG.Math.Geometry.rotation(f[0],f[1],Math.PI,h)}],e);for(g=0;g<2;g++){f[g].addChild(j)}j.elType="mirrorpoint";j.parents=[f[0].id,f[1].id]}else{throw new Error("JSXGraph: Can't create mirror point with parent types '"+(typeof f[0])+"' and '"+(typeof f[1])+"'.\nPossible parent types: [point,point]")}j.prepareUpdate().update();return j};JXG.createIntegral=function(j,A,n){var z,s,v,h=0,g=0,f,e,m,l,r=1,w,o,i,B,k,q,u;if(JXG.isArray(A[0])&&A[1].elementClass==JXG.OBJECT_CLASS_CURVE){z=A[0];s=A[1]}else{if(JXG.isArray(A[1])&&A[0].elementClass==JXG.OBJECT_CLASS_CURVE){z=A[1];s=A[0]}else{throw new Error("JSXGraph: Can't create integral with parent types '"+(typeof A[0])+"' and '"+(typeof A[1])+"'.\nPossible parent types: [[number|function,number|function],curve]")}}h=z[0];g=z[1];if(JXG.isFunction(h)){f=h;e=function(){return s.Y(f())};h=f()}else{f=h;e=s.Y(h)}if(JXG.isFunction(h)){m=g;l=function(){return s.Y(m())};g=m()}else{m=g;l=s.Y(g)}if(g0){return}var k=JXG.Math.Symbolic.generatePolynomials(g,h,true).join("|");if(k===i.spe){return}i.spe=k;var j=function(n,p,m,o){i.dataX=n;i.dataY=p;i.eq=m;i.ctime=o;i.generatePolynomial=(function(q){return function(s){var r="("+s.symbolic.x+")",v="("+s.symbolic.y+")",u=[],t;for(t=0;tl.usrCoords[2]-n;k-=n){i.dataX.push(m.usrCoords[1],l.usrCoords[1],NaN);i.dataY.push(k,k,NaN)}for(k=m.usrCoords[1];k=-h&&g<=2*h&&f>=-h&&f<=2*h},setTextJessieCode:function(f){var e;this.visProp.castext=f;if(typeof f==="function"){e=function(){return f().replace(//g,">")}}else{if(JXG.isNumber(f)){e=f}else{e=f.replace(//g,">")}}return this.setText(e)},setText:function(e){if(typeof e==="function"){this.updateText=function(){this.plaintext=e()}}else{if(JXG.isNumber(e)){this.content=(e).toFixed(this.visProp.digits)}else{if(this.visProp.useasciimathml){this.content="'`"+e+"`'"}else{this.content=this.generateTerm(e)}}this.updateText=new Function("this.plaintext = "+this.content+";")}this.updateText();this.updateSize();this.needsUpdate=true;this.update();this.updateRenderer();return this},updateSize:function(){if(this.visProp.display=="html"&&this.board.renderer.type!="vml"){this.size=[this.rendNode.offsetWidth,this.rendNode.offsetHeight]}else{if(this.visProp.display=="internal"&&this.board.renderer.type=="svg"){this.size=[this.rendNode.getBBox().width,this.rendNode.getBBox().height]}else{if(this.board.renderer.type=="vml"||(this.visProp.display=="internal"&&this.board.renderer.type=="canvas")){this.size=[parseFloat(this.visProp.fontsize)*this.plaintext.length*0.45,parseFloat(this.visProp.fontsize)*0.9]}}}return this},getSize:function(){return this.size},setCoords:function(e,f){if(JXG.isArray(e)&&e.length>1){f=e[1];e=e[0]}this.X=function(){return e};this.Y=function(){return f};this.coords=new JXG.Coords(JXG.COORDS_BY_USER,[e,f],this.board);this.board.update();return this},free:function(){this.X=JXG.createFunction(this.X(),this.board,"");this.Y=JXG.createFunction(this.Y(),this.board,"");this.isDraggable=true},update:function(){var e,g,f;if(this.needsUpdate){if(this.relativeCoords){if(this.visProp.islabel){g=parseFloat(this.visProp.offsets[0]);f=-parseFloat(this.visProp.offsets[1]);e=this.element.getLabelAnchor();this.coords.setCoordinates(JXG.COORDS_BY_SCREEN,[g+this.relativeCoords.scrCoords[1]+e.scrCoords[1],f+this.relativeCoords.scrCoords[2]+e.scrCoords[2]])}else{e=this.element.getTextAnchor();this.coords.setCoordinates(JXG.COORDS_BY_USER,[this.relativeCoords.usrCoords[1]+e.usrCoords[1],this.relativeCoords.usrCoords[2]+e.usrCoords[2]])}}else{this.updateCoords()}this.updateText();this.updateTransform()}return this},updateRenderer:function(){if(this.needsUpdate){this.board.renderer.updateText(this);this.needsUpdate=false}return this},updateTransform:function(){if(this.transformations.length==0){return}for(var e=0;e/g,"∠");k=k.replace(//g,"√");var f;f=k.indexOf("");var e=k.indexOf("");if(f>=0){while(f>=0){l+=' + "'+JXG.GeonextParser.replaceSub(JXG.GeonextParser.replaceSup(k.slice(0,f)))+'"';g=k.slice(f+7,e);h=JXG.GeonextParser.geonext2JS(g,this.board);h=h.replace(/\\"/g,'"');h=h.replace(/\\'/g,"'");if(h.indexOf("toFixed")<0){if(JXG.isNumber((JXG.bind(new Function("return "+h+";"),this))())){l+="+("+h+").toFixed("+(this.visProp.digits)+")"}else{l+="+("+h+")"}}else{l+="+("+h+")"}k=k.slice(e+8);f=k.indexOf("");e=k.indexOf("")}}l+=' + "'+JXG.GeonextParser.replaceSub(JXG.GeonextParser.replaceSup(k))+'"';l=l.replace(//g,"");l=l.replace(/<\/overline>/g,"");l=l.replace(//g,"");l=l.replace(/<\/arrow>/g,"");l=l.replace(/&/g,"&");return l},notifyParents:function(g){var f=null;do{var e=/([\w\s\*\/\^\-\+\(\)\[\],<>=!]+)<\/value>/;f=e.exec(g);if(f!=null){JXG.GeonextParser.findDependencies(this,f[1],this.board);g=g.substr(f.index);g=g.replace(e,"")}}while(f!=null);return this},bounds:function(){var e=this.coords.usrCoords;return this.visProp.islabel?[0,0,0,0]:[e[1],e[2]+this.size[1],e[1]+this.size[0],e[2]]},setPositionDirectly:function(e,l,j,h,g){var f,o,n,m,k;if(this.relativeCoords){if(this.visProp.islabel){if(e==JXG.COORDS_BY_USER){k=new JXG.Coords(JXG.COORDS_BY_USER,[h,g],this.board);m=new JXG.Coords(JXG.COORDS_BY_USER,[l,j],this.board);o=m.scrCoords[1]-k.scrCoords[1];n=m.scrCoords[2]-k.scrCoords[2]}else{o=l-h;n=j-g}this.relativeCoords.scrCoords[1]+=o;this.relativeCoords.scrCoords[2]+=n}else{if(e==JXG.COORDS_BY_SCREEN){k=new JXG.Coords(JXG.COORDS_BY_SCREEN,[h,g],this.board);m=new JXG.Coords(JXG.COORDS_BY_SCREEN,[l,j],this.board);o=m.usrCoords[1]-k.usrCoords[1];n=m.usrCoords[2]-k.usrCoords[2]}else{o=l-h;n=j-g}this.relativeCoords.usrCoords[1]+=o;this.relativeCoords.usrCoords[2]+=n}}else{if(e==JXG.COORDS_BY_SCREEN){m=new JXG.Coords(JXG.COORDS_BY_SCREEN,[l,j],this.board);l=m.usrCoords[1];j=m.usrCoords[2]}this.X=JXG.createFunction(l,this.board,"");this.Y=JXG.createFunction(j,this.board,"")}return this}});JXG.createText=function(i,g,f){var e,h;e=JXG.copyAttributes(f,i.options,"text");e.anchor=e.parent||e.anchor;h=new JXG.Text(i,g[g.length-1],g,e);if(typeof g[g.length-1]!=="function"){h.parents=g}return h};JXG.JSXGraph.registerElement("text",JXG.createText);JXG.Image=function(h,f,i,g,e){this.constructor(h,e,JXG.OBJECT_TYPE_IMAGE,JXG.OBJECT_CLASS_OTHER);this.initialCoords=new JXG.Coords(JXG.COORDS_BY_USER,i,this.board);if(!JXG.isFunction(i[0])&&!JXG.isFunction(i[1])){this.isDraggable=true}this.X=JXG.createFunction(i[0],this.board,"");this.Y=JXG.createFunction(i[1],this.board,"");this.W=JXG.createFunction(g[0],this.board,"");this.H=JXG.createFunction(g[1],this.board,"");this.coords=new JXG.Coords(JXG.COORDS_BY_USER,[this.X(),this.Y()],this.board);this.updateCoords=new Function("","this.coords.setCoordinates(JXG.COORDS_BY_USER,[this.X(),this.Y()]);");this.updateSize=new Function("","this.coords.setCoordinates(JXG.COORDS_BY_USER,[this.W(),this.H()]);");this.usrSize=[this.W(),this.H()];this.size=[this.usrSize[0]*h.unitX,this.usrSize[1]*h.unitY];this.url=f;this.parent=JXG.getRef(e.anchor);this.id=this.board.setId(this,"Im");this.board.renderer.drawImage(this);if(!this.visProp.visible){this.board.renderer.hide(this)}};JXG.Image.prototype=new JXG.GeometryElement;JXG.extend(JXG.Image.prototype,{hasPoint:function(e,i){var g=e-this.coords.scrCoords[1],f=this.coords.scrCoords[2]-i,h=this.board.options.precision.hasPoint;if(g>=-h&&g<=2*h&&f>=-h&&f<=h){return true}else{return false}},update:function(){if(this.needsUpdate){this.updateCoords();this.usrSize=[this.W(),this.H()];this.size=[this.usrSize[0]*this.board.unitX,this.usrSize[1]*this.board.unitY];this.updateTransform()}return this},updateRenderer:function(){if(this.needsUpdate){this.board.renderer.updateImage(this);this.needsUpdate=false}return this},updateTransform:function(){if(this.transformations.length==0){return}for(var e=0;e=0){z+=e*0.5/f.unitX}else{z-=e*s/f.unitX}n-=e*0.2/f.unitY;r=f.create("text",[z,n,g.labels[v]],g)}}else{t[0]=f.create("point",[q,0],A);t[1]=f.create("point",[q,z],A);t[2]=f.create("point",[l,z],A);t[3]=f.create("point",[l,0],A);if(JXG.exists(g.labels)&&JXG.exists(g.labels[v])){s=g.labels[v].toString().length;s=0.6*s*e/f.unitX;if(z>=0){z+=e*0.5/f.unitY}else{z-=e*1/f.unitY}r=f.create("text",[n-s*0.5,z,g.labels[v]],g)}}g.withlines=false;if(JXG.exists(g.colors)&&JXG.isArray(g.colors)){k=g.colors;g.fillcolor=k[v%k.length]}h[v]=f.create("polygon",t,g);if(JXG.exists(g.labels)&&JXG.exists(g.labels[v])){h[v].text=r}}return h},drawPoints:function(k,e,l,g){var h,j=[],f=g.infoboxarray;g.fixed=true;g.name="";for(h=0;hae[Z]){ae[Z]=S[ab][Z]}if(S[ab][Z]1){if(h.length==3){i=this.evalParam(1);m=this.evalParam(2)}else{i=h[1].X();m=h[1].Y()}this.matrix[1][0]=i*(1-l)+m*j;this.matrix[2][0]=m*(1-l)-i*j}}}else{if(f=="shear"){this.evalParam=JXG.createEvalFunction(g,h,1);this.update=function(){var i=this.evalParam(0);this.matrix[1][1]=Math.tan(i)}}else{if(f=="generic"){this.evalParam=JXG.createEvalFunction(g,h,9);this.update=function(){this.matrix[0][0]=this.evalParam(0);this.matrix[0][1]=this.evalParam(1);this.matrix[0][2]=this.evalParam(2);this.matrix[1][0]=this.evalParam(3);this.matrix[1][1]=this.evalParam(4);this.matrix[1][2]=this.evalParam(5);this.matrix[2][0]=this.evalParam(6);this.matrix[2][1]=this.evalParam(7);this.matrix[2][2]=this.evalParam(8)}}}}}}}},apply:function(e){this.update();if(arguments[1]!=null){return JXG.Math.matVecMult(this.matrix,e.initialCoords.usrCoords)}else{return JXG.Math.matVecMult(this.matrix,e.coords.usrCoords)}},applyOnce:function(g){var h,e,f;if(!JXG.isArray(g)){this.update();h=JXG.Math.matVecMult(this.matrix,g.coords.usrCoords);g.coords.setCoordinates(JXG.COORDS_BY_USER,h)}else{e=g.length;for(f=0;f=8192){this.curve=this.board.create("curve",[[this.pos[0]],[this.pos[1]]],this._attributes);this.objects.push(this.curve)}}this.pos[0]+=g;this.pos[1]+=f;if(this.isPenDown){this.curve.dataX.push(this.pos[0]);this.curve.dataY.push(this.pos[1])}this.board.update();return this},back:function(e){return this.forward(-e)},right:function(f){this.dir-=f;this.dir%=360;if(!this.turtleIsHidden){var e=this.board.create("transform",[-f*Math.PI/180,this.turtle],{type:"rotate"});e.applyOnce(this.turtle2)}this.board.update();return this},left:function(e){return this.right(-e)},penUp:function(){this.isPenDown=false;return this},penDown:function(){this.isPenDown=true;this.curve=this.board.create("curve",[[this.pos[0]],[this.pos[1]]],this._attributes);this.objects.push(this.curve);return this},clean:function(){for(var e=0;e=8192){this.curve=this.board.create("curve",[[this.pos[0]],[this.pos[1]]],this._attributes);this.objects.push(this.curve)}}this.pos[0]=h[0];this.pos[1]=h[1];if(this.isPenDown){this.curve.dataX.push(this.pos[0]);this.curve.dataY.push(this.pos[1])}this.board.update()}return this},fd:function(e){return this.forward(e)},bk:function(e){return this.back(e)},lt:function(e){return this.left(e)},rt:function(e){return this.right(e)},pu:function(){return this.penUp()},pd:function(){return this.penDown()},ht:function(){return this.hideTurtle()},st:function(){return this.showTurtle()},cs:function(){return this.clearScreen()},push:function(){return this.pushTurtle()},pop:function(){return this.popTurtle()},evalAt:function(k,m){var h,g,l,f,e=this.objects.length;for(h=0,g=0;h=3){arguments[0]=[arguments[0],arguments[1],arguments[2]];arguments.length=1}var o=arguments[0];if(JXG.isArray(o)){var f=false,k;for(k=0;k<3;k++){f|=/\./.test(arguments[0][k].toString())}for(k=0;k<3;k++){f&=(arguments[0][k]>=0)&(arguments[0][k]<=1)}if(f){return[Math.ceil(arguments[0][0]*255),Math.ceil(arguments[0][1]*255),Math.ceil(arguments[0][2]*255)]}else{arguments[0].length=3;return arguments[0]}}else{if(typeof arguments[0]=="string"){o=arguments[0]}}var e,m,p;if(o.charAt(0)=="#"){o=o.substr(1,6)}o=o.replace(/ /g,"");o=o.toLowerCase();var j={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};for(var q in j){if(o==q){o=j[q]}}var n=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(g){return[parseInt(g[1]),parseInt(g[2]),parseInt(g[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(g){return[parseInt(g[1],16),parseInt(g[2],16),parseInt(g[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(g){return[parseInt(g[1]+g[1],16),parseInt(g[2]+g[2],16),parseInt(g[3]+g[3],16)]}}];for(var k=0;k255)?255:e);m=(m<0||isNaN(m))?0:((m>255)?255:m);p=(p<0||isNaN(p))?0:((p>255)?255:p);return[e,m,p]};JXG.rgb2css=function(){var h,f,e;h=JXG.rgbParser.apply(JXG.rgbParser,arguments);f=h[1];e=h[2];h=h[0];return"rgb("+h+", "+f+", "+e+")"};JXG.rgb2hex=function(){var h,f,e;h=JXG.rgbParser.apply(JXG.rgbParser,arguments);f=h[1];e=h[2];h=h[0];h=h.toString(16);f=f.toString(16);e=e.toString(16);if(h.length==1){h="0"+h}if(f.length==1){f="0"+f}if(e.length==1){e="0"+e}return"#"+h+f+e};JXG.hex2rgb=function(i){var h,f,e;if(i.charAt(0)=="#"){i=i.slice(1)}h=parseInt(i.substr(0,2),16);f=parseInt(i.substr(2,2),16);e=parseInt(i.substr(4,2),16);return"rgb("+h+", "+f+", "+e+")"};JXG.hsv2rgb=function(r,l,k){var m,s,h,o,n,j,g,e,u;r=((r%360)+360)%360;if(l==0){if(isNaN(r)||r=360){j=0}else{j=r}j=j/60;n=Math.floor(j);o=j-n;g=k*(1-l);e=k*(1-(l*o));u=k*(1-(l*(1-o)));switch(n){case 0:m=k;s=u;h=g;break;case 1:m=e;s=k;h=g;break;case 2:m=g;s=k;h=u;break;case 3:m=g;s=e;h=k;break;case 4:m=u;s=g;h=k;break;case 5:m=k;s=g;h=e;break}}m=Math.round(m*255).toString(16);m=(m.length==2)?m:((m.length==1)?"0"+m:"00");s=Math.round(s*255).toString(16);s=(s.length==2)?s:((s.length==1)?"0"+s:"00");h=Math.round(h*255).toString(16);h=(h.length==2)?h:((h.length==1)?"0"+h:"00");return["#",m,s,h].join("")};JXG.rgb2hsv=function(){var e,n,q,o,f,j,i,t,m,w,u,p,k,l;e=JXG.rgbParser.apply(JXG.rgbParser,arguments);n=e[1];q=e[2];e=e[0];l=JXG.Math.Statistics;o=e/255;f=n/255;j=q/255;p=l.max([e,n,q]);k=l.min([e,n,q]);i=p/255;t=k/255;u=i;w=0;if(u>0){w=(u-t)/(u*1)}m=1/(i-t);if(w>0){if(p==e){m=(f-j)*m}else{if(p==n){m=2+(j-o)*m}else{m=4+(o-f)*m}}}m*=60;if(m<0){m+=360}if(p==k){m=0}return[m,w,u]};JXG.rgb2LMS=function(){var o,n,f,h,e,k,j,i=[[0.05059983,0.08585369,0.0095242],[0.01893033,0.08925308,0.01370054],[0.00292202,0.00975732,0.07145979]];o=JXG.rgbParser.apply(JXG.rgbParser,arguments);n=o[1];f=o[2];o=o[0];o=Math.pow(o,0.476190476);n=Math.pow(n,0.476190476);f=Math.pow(f,0.476190476);h=o*i[0][0]+n*i[0][1]+f*i[0][2];e=o*i[1][0]+n*i[1][1]+f*i[1][2];k=o*i[2][0]+n*i[2][1]+f*i[2][2];j=[h,e,k];j.l=h;j.m=e;j.s=k;return j};JXG.LMS2rgb=function(h,f,p){var e,i,k,j,n=[[30.830854,-29.832659,1.610474],[-6.481468,17.715578,-2.532642],[-0.37569,-1.199062,14.273846]];e=h*n[0][0]+f*n[0][1]+p*n[0][2];i=h*n[1][0]+f*n[1][1]+p*n[1][2];k=h*n[2][0]+f*n[2][1]+p*n[2][2];var o=function(l){var m=127,g=64;while(g>0){if(Math.pow(m,0.476190476)>l){m-=g}else{if(Math.pow(m+1,0.476190476)>l){return m}m+=g}g/=2}if(m==254&&13.994955247>4)&15)+i.charAt(f&15);g="#"+h+""+h+""+h;return g};JXG.rgb2cb=function(j,q){if(j=="none"){return j}var t,i,h,w,r,o,g,v,n,f,u,k,p;r=JXG.rgb2LMS(j);i=r.l;h=r.m;w=r.s;q=q.toLowerCase();switch(q){case"protanopia":g=-0.06150039994295001;v=0.08277001656812001;n=-0.013200141220000003;f=0.05858939668799999;u=-0.07934519995360001;k=0.013289415272000003;p=0.6903216543277437;o=w/h;if(o>4)&15)+e.charAt(t.r&15);j="#"+o;o=e.charAt((t.g>>4)&15)+e.charAt(t.g&15);j+=o;o=e.charAt((t.b>>4)&15)+e.charAt(t.b&15);j+=o;return j};JXG.extend(JXG.Board.prototype,{angle:function(e,g,f){return JXG.Math.Geometry.angle(e,g,f)},rad:function(e,g,f){return JXG.Math.Geometry.rad(e,g,f)},distance:function(f,e){return JXG.Math.Geometry.distance(f,e)},pow:function(f,e){return JXG.Math.pow(f,e)},round:function(e,f){return(e).toFixed(f)},cosh:function(e){return JXG.Math.cosh(e)},sinh:function(e){return JXG.Math.sinh(e)},sgn:function(e){return(e==0?0:e/(Math.abs(e)))},D:function(e,g){return JXG.Math.Numerics.D(e,g)},I:function(e,g){return JXG.Math.Numerics.I(e,g)},root:function(g,e,h){return JXG.Math.Numerics.root(g,e,h)},lagrangePolynomial:function(e){return JXG.Math.Numerics.lagrangePolynomial(e)},neville:function(e){return JXG.Math.Numerics.Neville(e)},riemannsum:function(h,j,g,i,e){return JXG.Math.Numerics.riemannsum(h,j,g,i,e)},abs:Math.abs,acos:Math.acos,asin:Math.asin,atan:Math.atan,ceil:Math.ceil,cos:Math.cos,exp:Math.exp,floor:Math.floor,log:Math.log,max:Math.max,min:Math.min,random:Math.random,sin:Math.sin,sqrt:Math.sqrt,tan:Math.tan,trunc:Math.ceil,factorial:function(e){return JXG.Math.factorial(e)},binomial:function(f,e){return JXG.Math.binomial(f,e)},getElement:function(e){return JXG.getReference(this,e)},intersectionOptions:["point",[[JXG.OBJECT_CLASS_LINE,JXG.OBJECT_CLASS_LINE],[JXG.OBJECT_CLASS_LINE,JXG.OBJECT_CLASS_CIRCLE],[JXG.OBJECT_CLASS_CIRCLE,JXG.OBJECT_CLASS_CIRCLE]]],intersection:function(h,f,g,e){h=JXG.getReference(this,h);f=JXG.getReference(this,f);if(h.elementClass==JXG.OBJECT_CLASS_CURVE&&f.elementClass==JXG.OBJECT_CLASS_CURVE){return function(){return JXG.Math.Geometry.meetCurveCurve(h,f,g,e,h.board)}}else{if((h.type==JXG.OBJECT_TYPE_ARC&&f.elementClass==JXG.OBJECT_CLASS_LINE)||(f.type==JXG.OBJECT_TYPE_ARC&&h.elementClass==JXG.OBJECT_CLASS_LINE)){return function(){return JXG.Math.Geometry.meet(h.stdform,f.stdform,g,h.board)}}else{if((h.elementClass==JXG.OBJECT_CLASS_CURVE&&f.elementClass==JXG.OBJECT_CLASS_LINE)||(f.elementClass==JXG.OBJECT_CLASS_CURVE&&h.elementClass==JXG.OBJECT_CLASS_LINE)){return function(){return JXG.Math.Geometry.meetCurveLine(h,f,g,h.board)}}else{return function(){return JXG.Math.Geometry.meet(h.stdform,f.stdform,g,h.board)}}}}},intersectionFunc:function(h,f,g,e){return this.intersection(h,f,g,e)},otherIntersection:function(f,e,g){f=JXG.getReference(this,f);e=JXG.getReference(this,e);return function(){var h=JXG.Math.Geometry.meet(f.stdform,e.stdform,0,f.board);if(Math.abs(g.X()-h.usrCoords[1])>JXG.Math.eps||Math.abs(g.Y()-h.usrCoords[2])>JXG.Math.eps||Math.abs(g.Z()-h.usrCoords[0])>JXG.Math.eps){return h}else{return JXG.Math.Geometry.meet(f.stdform,e.stdform,1,f.board)}}},pointFunc:function(){return[null]},pointOptions:["point",[[JXG.OBJECT_CLASS_POINT]]],lineFunc:function(){return arguments},lineOptions:["line",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],linesegmentFunc:function(){return arguments},linesegmentOptions:["line",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],linesegmentAtts:{straightFirst:false,straightLast:false},arrowFunc:function(){return arguments},arrowOptions:["arrow",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],circleFunc:function(){return arguments},circleOptions:["circle",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT],[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE],[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_CIRCLE]]],arrowparallelOptions:["arrowparallel",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]],arrowparallelFunc:function(){return arguments},bisectorOptions:["bisector",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],bisectorFunc:function(){return arguments},circumcircleOptions:["circumcircle",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],circumcircleFunc:function(){return arguments},circumcirclemidpointOptions:["circumcirclemidpoint",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],circumcirclemidpointFunc:function(){return arguments},integralOptions:["integral",[[]]],integralFunc:function(){return arguments},midpointOptions:["midpoint",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT],[JXG.OBJECT_CLASS_LINE]]],midpointFunc:function(){return arguments},mirrorpointOptions:["mirrorpoint",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],mirrorpointFunc:function(){return arguments},normalOptions:["normal",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]],normalFunc:function(){return arguments},parallelOptions:["parallel",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]],parallelFunc:function(){return arguments},parallelpointOptions:["parallelpoint",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],parallelpointFunc:function(){return arguments},perpendicularOptions:["perpendicular",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]],perpendicularFunc:function(){return arguments},perpendicularpointOptions:["perpendicularpoint",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]],perpendicularpointFunc:function(){return arguments},reflectionOptions:["reflection",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]],reflectionFunc:function(){return arguments}});JXG.Point.prototype.setPositionX=function(g,e){var f=(g==JXG.COORDS_BY_USER)?this.coords.usrCoords[2]:this.coords.scrCoords[2];this.setPosition(g,e,f)};JXG.Point.prototype.setPositionY=function(g,f){var e=(g==JXG.COORDS_BY_USER)?this.coords.usrCoords[1]:this.coords.scrCoords[1];this.setPosition(g,e,f)};JXG.Ticks=function(e,g,f){this.constructor(e.board,f,JXG.OBJECT_TYPE_TICKS,JXG.OBJECT_CLASS_OTHER);this.line=e;this.board=this.line.board;this.ticksFunction=null;this.fixedTicks=null;this.equidistant=false;if(JXG.isFunction(g)){this.ticksFunction=g;throw new Error("Function arguments are no longer supported.")}else{if(JXG.isArray(g)){this.fixedTicks=g}else{if(Math.abs(g)=w&&this.fixedTicks[C]JXG.Math.eps){D=this._adjustTickDistance(D,n,u,h.coords,L,J);this.ticksDelta=D}if(!this.visProp.insertticks){D/=this.visProp.minorticks+1}l=this.board.getBoundingBox();H=(l[0]+l[2])*0.5;G=(l[1]+l[3])*0.5;M=[H*this.line.stdform[2]-G*this.line.stdform[1],-this.line.stdform[2],this.line.stdform[1]];I=JXG.Math.crossProduct(this.line.stdform,M);I[1]/=I[0];I[2]/=I[0];I[0]=1;z=new JXG.Coords(JXG.COORDS_BY_USER,I.slice(1),this.board);F=h.coords.distance(JXG.COORDS_BY_USER,z);if((f.X()-h.X())*(I[1]-h.X())<0||(f.Y()-h.Y())*(I[2]-h.Y())<0){F*=-1}q=Math.round(F/D)*D;if(Math.abs(q)>JXG.Math.eps){v=Math.abs(q)/q}I[1]=h.coords.usrCoords[1]+L*q;I[2]=h.coords.usrCoords[2]+J*q;e=q;q=0;H=I[1];G=I[2];C=0;do{z=new JXG.Coords(JXG.COORDS_BY_USER,[H,G],this.board);if(Math.round((v*q+e)/D)%(this.visProp.minorticks+1)===0){z.major=true}else{z.major=false}k=this._tickEndings(z,K,g,t,A,z.major);if(k.length==2){m=v*q+e;if((Math.abs(m)<=s&&this.visProp.drawzero)||(m>w&&m0)},_adjustTickDistance:function(j,k,i,h,g,f){var e,l;while(k>4*this.minTicksDistance){j/=10;e=h.usrCoords[1]+g*j;l=h.usrCoords[2]+f*j;k=h.distance(JXG.COORDS_BY_SCREEN,new JXG.Coords(JXG.COORDS_BY_USER,[e,l],this.board))}while(k=0&&p[1]<=g){k[h]=p[1];j[h]=0;h++}p=JXG.Math.crossProduct([0,1,0],[-e*B[1]-t*B[2],e,t]);p[2]/=p[0];if(p[2]>=0&&p[2]<=n){k[h]=0;j[h]=p[2];h++}if(h<2){p=JXG.Math.crossProduct([n*n,0,-n],[-e*B[1]-t*B[2],e,t]);p[1]/=p[0];if(p[1]>=0&&p[1]<=g){k[h]=p[1];j[h]=n;h++}}if(h<2){p=JXG.Math.crossProduct([g*g,-g,0],[-e*B[1]-t*B[2],e,t]);p[2]/=p[0];if(p[2]>=0&&p[2]<=n){k[h]=g;j[h]=p[2]}}}}if((k[0]>=0&&k[0]<=g&&j[0]>=0&&j[0]<=n)||(k[1]>=0&&k[1]<=g&&j[1]>=0&&j[1]<=n)){o=true}else{o=false}if(z=="finite"){A=Math.sqrt(this.board.unitX*this.board.unitX+this.board.unitY*this.board.unitY);k[0]=B[1]+m*this.board.unitX/A;j[0]=B[2]-l*this.board.unitY/A;k[1]=B[1]-m*this.board.unitX/A;j[1]=B[2]+l*this.board.unitY/A}if(o){return[k,j]}else{return[]}},_makeLabel:function(m,e,j,g,l,h){var k,f;if(!g){return null}k=m.toString();if(Math.abs(m)5||k.indexOf("e")!=-1){k=m.toPrecision(3).toString()}if(k.indexOf(".")>-1){k=k.replace(/0+$/,"");k=k.replace(/\.$/,"")}f=JXG.createText(j,[e.usrCoords[1],e.usrCoords[2],k],{id:l+h+"Label",isLabel:true,layer:j.options.layer.line,highlightStrokeColor:j.options.text.strokeColor,highlightStrokeWidth:j.options.text.strokeWidth,highlightStrokeOpacity:j.options.text.strokeOpacity});f.isDraggable=false;f.dump=false;f.distanceX=4;f.distanceY=-parseInt(f.visProp.fontsize)+3;f.setCoords(e.usrCoords[1]+f.distanceX/(j.unitX),e.usrCoords[2]+f.distanceY/(j.unitY));f.visProp.visible=g;f.prepareUpdate().update().updateRenderer();return f},removeTickLabels:function(){var e;if(this.ticks!=null){if((this.board.needsFullUpdate||this.needsRegularUpdate)&&!(this.board.options.renderer=="canvas"&&this.board.options.text.display=="internal")){for(e=0;e>=1;if(af==0){af=h();ah=(af&1);af=(af>>1)|128}return ah}function X(ah){var aj=0,ai=ah;while(ai--){aj=(aj<<1)|Z()}if(ah){aj=aa[aj]>>(8-ah)}return aj}function g(){ab=0}function B(ah){L++;l[ab++]=ah;q.push(String.fromCharCode(ah));if(ab==32768){ab=0}}function p(){this.b0=0;this.b1=0;this.jump=null;this.jumppos=-1}var i=288;var z=new Array(i);var R=new Array(32);var M=0;var ac=null;var t=null;var Q=new Array(64);var N=new Array(64);var C=0;var G=new Array(17);G[0]=0;var S;var w;function m(){while(1){if(G[C]>=w){return -1}if(S[G[C]]==C){return G[C]++}G[C]++}}function I(){var ai=ac[M];var ah;if(H){document.write("
len:"+C+" treepos:"+M)}if(C==17){return -1}M++;C++;ah=m();if(H){document.write("
IsPat "+ah)}if(ah>=0){ai.b0=ah;if(H){document.write("
b0 "+ai.b0)}}else{ai.b0=32768;if(H){document.write("
b0 "+ai.b0)}if(I()){return -1}}ah=m();if(ah>=0){ai.b1=ah;if(H){document.write("
b1 "+ai.b1)}ai.jump=null}else{ai.b1=32768;if(H){document.write("
b1 "+ai.b1)}ai.jump=ac[M];ai.jumppos=M;if(I()){return -1}}C--;return 0}function o(al,aj,am,ai){var ak;if(H){document.write("currentTree "+al+" numval "+aj+" lengths "+am+" show "+ai)}ac=al;M=0;S=am;w=aj;for(ak=0;ak<17;ak++){G[ak]=0}C=0;if(I()){if(H){alert("invalid huffman tree\n")}return -1}if(H){document.write("
Tree: "+ac.length);for(var ah=0;ah<32;ah++){document.write("Places["+ah+"].b0="+ac[ah].b0+"
");document.write("Places["+ah+"].b1="+ac[ah].b1+"
")}}return 0}function F(ak){var ai,aj,am=0,al=ak[am],ah;while(1){ah=Z();if(H){document.write("b="+ah)}if(ah){if(!(al.b1&32768)){if(H){document.write("ret1")}return al.b1}al=al.jump;ai=ak.length;for(aj=0;aj>1);if(av>23){av=(av<<1)|Z();if(av>199){av-=128;av=(av<<1)|Z()}else{av-=48;if(av>143){av=av+136}}}else{av+=256}if(av<256){B(av)}else{if(av==256){break}else{var ax,aq;av-=256+1;ax=X(V[av])+ae[av];av=aa[X(5)]>>3;if(D[av]>8){aq=X(8);aq|=(X(D[av]-8)<<8)}else{aq=X(D[av])}aq+=P[av];for(av=0;avdistanceTree");for(var az=0;az"+R[az].b0+" "+R[az].b1+" "+R[az].jump+" "+R[az].jumppos)}}ar=aj+ao;aw=0;var ak=-1;if(H){document.write("
n="+ar+" bits: "+e+"
")}while(aw"+ak+" i:"+aw+" decode: "+av+" bits "+e+"
")}if(av<16){an[aw++]=av}else{if(av==16){var at;av=3+X(2);if(aw+av>ar){g();return 1}at=aw?an[aw-1]:0;while(av--){an[aw++]=at}}else{if(av==17){av=3+X(3)}else{av=11+X(7)}if(aw+av>ar){g();return 1}while(av--){an[aw++]=0}}}}ax=z.length;for(aw=0;awliteralTree")}while(1){av=F(z);if(av>=256){var ax,aq;av-=256;if(av==0){break}av--;ax=X(V[av])+ae[av];av=F(R);if(D[av]>8){aq=X(8);aq|=(X(D[av]-8)<<8)}else{aq=X(D[av])}aq+=P[av];while(ax--){var ay=l[(ab-aq)&32767];B(ay)}}else{B(av)}}}}}}while(!al);g();s();return 0}JXG.Util.Unzip.prototype.unzipFile=function(ah){var ai;this.unzip();for(ai=0;ai>2;l=((o&3)<<4)|(m>>4);j=((m&15)<<2)|(k>>6);h=k&63;if(isNaN(m)){j=h=64}else{if(isNaN(k)){h=64}}e.push([this._keyStr.charAt(n),this._keyStr.charAt(l),this._keyStr.charAt(j),this._keyStr.charAt(h)].join(""))}return e.join("")},decode:function(h,g){var e=[],p,n,l,o,m,k,j,f=0;h=h.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f>4);n=((m&15)<<4)|(k>>2);l=((k&3)<<6)|j;e.push(String.fromCharCode(p));if(k!=64){e.push(String.fromCharCode(n))}if(j!=64){e.push(String.fromCharCode(l))}}e=e.join("");if(g){e=JXG.Util.Base64._utf8_decode(e)}return e},_utf8_encode:function(f){f=f.replace(/\r\n/g,"\n");var e="";for(var h=0;h127)&&(g<2048)){e+=String.fromCharCode((g>>6)|192);e+=String.fromCharCode((g&63)|128)}else{e+=String.fromCharCode((g>>12)|224);e+=String.fromCharCode(((g>>6)&63)|128);e+=String.fromCharCode((g&63)|128)}}}return e},_utf8_decode:function(e){var g=[],j=0,k=0,h=0,f=0;while(j191)&&(k<224)){h=e.charCodeAt(j+1);g.push(String.fromCharCode(((k&31)<<6)|(h&63)));j+=2}else{h=e.charCodeAt(j+1);f=e.charCodeAt(j+2);g.push(String.fromCharCode(((k&15)<<12)|((h&63)<<6)|(f&63)));j+=3}}}return g.join("")},_destrip:function(k,h){var f=[],j,g,e=[];if(h==null){h=76}k.replace(/ /g,"");j=k.length/h;for(g=0;g255){switch(g){case 8364:g=128;break;case 8218:g=130;break;case 402:g=131;break;case 8222:g=132;break;case 8230:g=133;break;case 8224:g=134;break;case 8225:g=135;break;case 710:g=136;break;case 8240:g=137;break;case 352:g=138;break;case 8249:g=139;break;case 338:g=140;break;case 381:g=142;break;case 8216:g=145;break;case 8217:g=146;break;case 8220:g=147;break;case 8221:g=148;break;case 8226:g=149;break;case 8211:g=150;break;case 8212:g=151;break;case 732:g=152;break;case 8482:g=153;break;case 353:g=154;break;case 8250:g=155;break;case 339:g=156;break;case 382:g=158;break;case 376:g=159;break;default:break}}return g};JXG.Util.utf8Decode=function(e){var g=[];var j=0;var l=0,k=0,h=0,f;if(!JXG.exists(e)){return""}while(j191)&&(l<224)){h=e.charCodeAt(j+1);g.push(String.fromCharCode(((l&31)<<6)|(h&63)));j+=2}else{h=e.charCodeAt(j+1);f=e.charCodeAt(j+2);g.push(String.fromCharCode(((l&15)<<12)|((h&63)<<6)|(f&63)));j+=3}}}return g.join("")};JXG.Util.genUUID=function(){var j="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),g=new Array(36),f=0,h;for(var e=0;e<36;e++){if(e==8||e==13||e==18||e==23){g[e]="-"}else{if(e==14){g[e]="4"}else{if(f<=2){f=33554432+(Math.random()*16777216)|0}h=f&15;f=f>>4;g[e]=j[(e==19)?(h&3)|8:h]}}}return g.join("")};JXG.PsTricks={convert:function(h){var j=new JXG.Coords(JXG.COORDS_BY_SCREEN,[0,0],h),k=new JXG.Coords(JXG.COORDS_BY_SCREEN,[h.canvasWidth,h.canvasHeight],h),f,g,e=[];e.push("\\begin{pspicture*}("+j.usrCoords[1]+","+k.usrCoords[2]+")("+k.usrCoords[1]+","+j.usrCoords[2]+")\n");for(f in h.objects){g=h.objects[f];if(g.visProp.visible){switch(g.elementClass){case JXG.OBJECT_CLASS_CIRCLE:e.push(this.addCircle(g));break;case JXG.OBJECT_CLASS_LINE:e.push(this.addLine(g));break;case JXG.OBJECT_CLASS_POINT:e.push(this.addPoint(g));break;default:switch(g.type){case JXG.OBJECT_TYPE_ARC:e.push(this.addArc(g));break;case JXG.OBJECT_TYPE_SECTOR:e.push(this.addArc(g));e.push(this.addSector(g));break;case JXG.OBJECT_TYPE_POLYGON:e.push(this.addPolygon(g));break;case JXG.OBJECT_TYPE_ANGLE:e.push(this.addAngle(g));break}break}}}e.push("\\end{pspicture*}");return e.join("\n")},setArrows:function(f){var e="";if(f.visProp.firstarrow&&f.visProp.lastarrow){e="{<->}"}else{if(f.visProp.firstarrow){e="{<-}"}else{if(f.visProp.lastarrow){e="{->}"}}}return e},drawWedge:function(g,h,i,f,k,j){var e="";if(g!="none"&&h>0){e+="\\pswedge[linestyle=none, fillstyle=solid, fillcolor="+this.parseColor(g)+", opacity="+h.toFixed(5)+"]";e+="("+i.join(",")+"){"+f+"}{"+k+"}{"+j+"}\n"}return e},addPoint:function(g){var e="\\psdot[linecolor="+this.parseColor(g.visProp.strokecolor)+",dotstyle=",h=g.normalizeFace(g.visProp.face)||"o",f=g.visProp.size>4?4:g.visProp.size,i=[0,0,"2pt 2","5pt 2","5pt 3"];if(h=="x"){e+="x, dotsize="+i[f]}else{if(h=="o"){e+="*, dotsize=";if(f==1){e+="2pt 2"}else{if(f==2){e+="4pt 2"}else{if(f==3){e+="6pt 2"}else{if(f==4){e+="6pt 3"}}}}}else{if(h=="[]"){e+="square*, dotsize="+i[f]}else{if(h=="+"){e+="+, dotsize="+i[f]}}}}e+="]("+g.coords.usrCoords.slice(1).join(",")+")\n";e+="\\rput("+(g.coords.usrCoords[1]+15/g.board.unitY)+","+(g.coords.usrCoords[2]+15/g.board.unitY)+"){\\small $"+g.name+"$}\n";return e},addLine:function(h){var g=new JXG.Coords(JXG.COORDS_BY_USER,h.point1.coords.usrCoords,h.board),f=new JXG.Coords(JXG.COORDS_BY_USER,h.point2.coords.usrCoords,h.board),e="\\psline[linecolor="+this.parseColor(h.visProp.strokecolor)+", linewidth="+h.visProp.strokewidth+"px]";if(h.visProp.straightfirst||h.visProp.straightlast){JXG.Math.Geometry.calcStraight(h,g,f)}e+=this.setArrows(h);e+="("+g.usrCoords.slice(1).join(",")+")("+f.usrCoords.slice(2).join(",")+")\n";return e},addCircle:function(g){var f=g.Radius(),e="\\pscircle[linecolor="+this.parseColor(g.visProp.strokecolor)+", linewidth="+g.visProp.strokewidth+"px";if(g.visProp.fillcolor!="none"&&g.visProp.fillopacity!=0){e+=", fillstyle=solid, fillcolor="+this.parseColor(g.visProp.fillcolor)+", opacity="+g.visProp.fillopacity.toFixed(5)}e+="]("+g.center.coords.usrCoords.slice(1).join("1")+"){"+f+"}\n";return e},addPolygon:function(g){var e="\\pspolygon[linestyle=none, fillstyle=solid, fillcolor="+this.parseColor(g.visProp.fillcolor)+", opacity="+g.visProp.fillopacity.toFixed(5)+"]",f;for(f=0;f0){z=z[0][0]}if(typeof z!="string"){return}r=window.JSON&&window.JSON.parse?window.JSON.parse(z):(new Function("return "+z))();if(r.type=="error"){this.handleError(r)}else{if(r.type=="response"){k=r.id;for(t=0;tf){e[g]=parseFloat(this.data[g][f])}}return e},getRow:function(g){var e,f;if(typeof g=="string"){for(f=0;f-1;e--){if(JXG.exists(this.sstack[e][f])){return e}}return -1},isCreator:function(e){return !!JXG.JSXGraph.elements[e]},isMathMethod:function(e){return e!=="E"&&!!Math[e]},isBuiltIn:function(e){return !!this.builtIn[e]},getvar:function(h,e){var g,f;e=JXG.def(e,false);g=this.isLocalVariable(h);if(g>-1){return this.sstack[g][h]}if(this.isCreator(h)){return this.creator(h)}if(this.isMathMethod(h)){return Math[h]}if(this.isBuiltIn(h)){return this.builtIn[h]}if(!e){g=JXG.getRef(this.board,h);if(g!==h){return g}}return f},getvarJS:function(g,e){var f;e=JXG.def(e,false);if(JXG.indexOf(this.pstack[this.pscope],g)>-1){return g}f=this.isLocalVariable(g);if(f>-1){return"$jc$.sstack["+f+"]['"+g+"']"}if(this.isCreator(g)){return"(function () { var a = Array.prototype.slice.call(arguments, 0); return $jc$.board.create.apply(this, ['"+g+"'].concat(a)); })"}if(this.isMathMethod(g)){return"Math."+g}if(this.isBuiltIn(g)){return this.builtIn[g].src}if(!e){if(JXG.isId(this.board,g)){return"$jc$.board.objects['"+g+"']"}else{if(JXG.isName(this.board,g)){return"$jc$.board.elementsByName['"+g+"']"}else{if(JXG.isGroup(this.board,g)){return"$jc$.board.groups['"+g+"']"}}}}return""},setProp:function(i,h,g){var f={},e,j;if(i.elementClass===JXG.OBJECT_CLASS_POINT&&(h==="X"||h==="Y")){h=h.toLowerCase();if(i.isDraggable&&typeof g==="number"){e=h==="x"?g:i.X();j=h==="y"?g:i.Y();i.setPosition(JXG.COORDS_BY_USER,e,j)}else{if(i.isDraggable&&(typeof g==="function"||typeof g==="string")){e=h==="x"?g:i.coords.usrCoords[1];j=h==="y"?g:i.coords.usrCoords[2];i.addConstraint([e,j])}else{if(!i.isDraggable){e=h==="x"?g:i.XEval.origin;j=h==="y"?g:i.YEval.origin;i.addConstraint([e,j])}}}this.board.update()}else{if(i.type===JXG.OBJECT_TYPE_TEXT&&(h==="X"||h==="Y")){if(typeof g==="number"){i[h]=function(){return g}}else{if(typeof g==="function"){i.isDraggable=false;i[h]=g}else{if(typeof g==="string"){i.isDraggable=false;i[h]=JXG.createFunction(g,this.board,null,true);i[h+"jc"]=g}}}i[h].origin=g;this.board.update()}else{if(i.type&&i.elementClass&&i.visProp){f[h]=g;i.setProperty(f)}else{i[h]=g}}}},utf8_encode:function(f){var e=[],h,g;for(h=0;h0){for(k=0;k"+e.substr(q[k].offset,30)+'<, expecting "'+f[k].join()+'"')}}},snippet:function(j,g,f,i){var k,l,h,e;k="jxg__tmp__intern_"+JXG.Util.genUUID().replace(/\-/g,"");if(!JXG.exists(g)){g=true}if(!JXG.exists(f)){f=""}if(!JXG.exists(i)){i=false}h=this.sstack[0][k];this.countLines=false;l=k+" = "+(g?" function ("+f+") { return ":"")+j+(g?"; }":"")+";";this.parse(l,i);e=this.sstack[0][k];if(JXG.exists(h)){this.sstack[0][k]=h}else{delete this.sstack[0][k]}this.countLines=true;return e},replaceIDs:function(g){var f,e;if(g.replaced){e=this.board.objects[g.children[1].children[0].value];if(JXG.exists(e)&&JXG.exists(e)&&e.name!==""){g.type="node_var";g.value=e.name;g.children.length=0;delete g.replaced}}if(g.children){for(f=g.children.length;f>0;f--){if(JXG.exists(g.children[f-1])){g.children[f-1]=this.replaceIDs(g.children[f-1])}}}return g},replaceNames:function(g){var f,e;e=g.value;if(g.type=="node_op"&&e=="op_lhs"&&g.children.length===1){this.isLHS=true}else{if(g.type=="node_var"){if(this.isLHS){this.letvar(e,true)}else{if(!JXG.exists(this.getvar(e,true))&&JXG.exists(this.board.elementsByName[e])){g=this.createReplacementNode(g)}}}}if(g.children){for(f=g.children.length;f>0;f--){if(JXG.exists(g.children[f-1])){g.children[f-1]=this.replaceNames(g.children[f-1])}}}if(g.type=="node_op"&&g.value=="op_lhs"&&g.children.length===1){this.isLHS=false}return g},createReplacementNode:function(g){var e=g.value,f=this.board.elementsByName[e];g=this.createNode("node_op","op_execfun",this.createNode("node_var","$"),this.createNode("node_op","op_param",this.createNode("node_str",f.id)));g.replaced=true;return g},collectDependencies:function(j,f){var h,g,k;g=j.value;if(j.type=="node_var"){k=this.getvar(g);if(k&&k.visProp&&k.type&&k.elementClass&&k.id){f[k.id]=k}}if(j.type=="node_op"&&j.value=="op_execfun"&&j.children.length>1&&j.children[0].value=="$"&&j.children[1].children.length>0){k=j.children[1].children[0].value;f[k]=this.board.objects[k]}if(j.children){for(h=j.children.length;h>0;h--){if(JXG.exists(j.children[h-1])){this.collectDependencies(j.children[h-1],f)}}}},resolveProperty:function(h,f,g){g=JXG.def(g,false);if(h&&h.type&&h.elementClass&&h.methodMap){if(f==="label"){h=h.label;f="content"}else{if(JXG.exists(h.subs[f])){h=h.subs}else{if(JXG.exists(h.methodMap[f])){f=h.methodMap[f]}else{h=h.visProp;f=f.toLowerCase()}}}}if(!JXG.exists(h)){this._error(h+" is not an object.")}if(!JXG.exists(h[f])){this._error("unknown property "+f+".")}if(g&&typeof h[f]==="function"){return function(){return h[f].apply(h,arguments)}}return h[f]},execute:function(node){var ret,v,i,e,parents=[];ret=0;if(this.cancel){this._error("Max runtime exceeded")}if(!node){return ret}this.line=node.line;switch(node.type){case"node_op":switch(node.value){case"op_none":if(node.children[0]){this.execute(node.children[0])}if(node.children[1]){ret=this.execute(node.children[1])}break;case"op_assign":v=this.execute(node.children[0]);this.lhs[this.scope]=v[1];if(v[0].type&&v[0].elementClass&&v[0].methodMap&&v[1]==="label"){this._error("Left-hand side of assignment is read-only.")}if(v[0]!==this.sstack[this.scope]||(JXG.isArray(v[0])&&typeof v[1]==="number")){this.setProp(v[0],v[1],this.execute(node.children[1]))}else{this.letvar(v[1],this.execute(node.children[1]))}this.lhs[this.scope]=0;break;case"op_noassign":ret=this.execute(node.children[0]);break;case"op_if":if(this.execute(node.children[0])){ret=this.execute(node.children[1])}break;case"op_if_else":if(this.execute(node.children[0])){ret=this.execute(node.children[1])}else{ret=this.execute(node.children[2])}break;case"op_while":while(this.execute(node.children[0])){this.execute(node.children[1])}break;case"op_do":do{this.execute(node.children[0])}while(this.execute(node.children[1]));break;case"op_for":i=new Date().getTime();for(this.execute(node.children[0]);this.execute(node.children[1]);this.execute(node.children[2])){if(new Date().getTime()-i>this.maxRuntime||this.cancel){this._error("for: max runtime exceeded");break}this.execute(node.children[3])}break;case"op_param":if(node.children[1]){this.execute(node.children[1])}ret=node.children[0];this.pstack[this.pscope].push(ret);break;case"op_paramdef":if(node.children[1]){this.execute(node.children[1])}ret=node.children[0];this.pstack[this.pscope].push(ret);break;case"op_proplst":if(node.children[0]){this.execute(node.children[0])}if(node.children[1]){this.execute(node.children[1])}break;case"op_proplst_val":this.propstack.push({});this.propscope++;this.execute(node.children[0]);ret=this.propstack[this.propscope];this.propstack.pop();this.propscope--;break;case"op_prop":this.propstack[this.propscope][node.children[0]]=this.execute(node.children[1]);break;case"op_array":var l;this.pstack.push([]);this.pscope++;this.execute(node.children[0]);ret=[];l=this.pstack[this.pscope].length;for(i=0;ithis.execute(node.children[1]);break;case"op_lot":ret=this.execute(node.children[0])=this.execute(node.children[1]);break;case"op_loe":ret=this.execute(node.children[0])<=this.execute(node.children[1]);break;case"op_or":ret=this.execute(node.children[0])||this.execute(node.children[1]);break;case"op_and":ret=this.execute(node.children[0])&&this.execute(node.children[1]);break;case"op_not":ret=!this.execute(node.children[0]);break;case"op_add":ret=JXG.Math.Statistics.add(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_sub":ret=JXG.Math.Statistics.subtract(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_div":ret=JXG.Math.Statistics.div(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_mod":ret=JXG.Math.Statistics.mod(this.execute(node.children[0]),this.execute(node.children[1]),true);break;case"op_mul":ret=this.mul(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_exp":ret=Math.pow(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_neg":ret=this.execute(node.children[0])*-1;break}break;case"node_var":ret=this.getvar(node.value);break;case"node_const":ret=Number(node.value);break;case"node_const_bool":ret=node.value.toLowerCase()!=="false";break;case"node_str":ret=node.value;break}return ret},compile:function(j,l){var g,h,k,f;g="";if(!JXG.exists(l)){l=false}if(!j){return g}switch(j.type){case"node_op":switch(j.value){case"op_none":if(j.children[0]){g=this.compile(j.children[0],l)}if(j.children[1]){g+=this.compile(j.children[1],l)}break;case"op_assign":k=this.compile(j.children[0],l);if(l){if(JXG.isArray(k)){g="$jc$.setProp("+k[0]+", '"+k[1]+"', "+this.compile(j.children[1],l)+");\n"}else{if(this.isLocalVariable(k)!==this.scope){this.sstack[this.scope][k]=true}g="$jc$.sstack["+this.scope+"]['"+k+"'] = "+this.compile(j.children[1],l)+";\n"}}else{g=k+" = "+this.compile(j.children[1],l)+";\n"}break;case"op_noassign":g=this.compile(j.children[0],l);break;case"op_if":g=" if ("+this.compile(j.children[0],l)+") "+this.compile(j.children[1],l);break;case"op_if_else":g=" if ("+this.compile(j.children[0],l)+")"+this.compile(j.children[1],l);g+=" else "+this.compile(j.children[2],l);break;case"op_while":g=" while ("+this.compile(j.children[0],l)+") {\n"+this.compile(j.children[1],l)+"}\n";break;case"op_do":g=" do {\n"+this.compile(j.children[0],l)+"} while ("+this.compile(j.children[1],l)+");\n";break;case"op_for":g=" for ("+this.compile(j.children[0],l)+"; "+this.compile(j.children[1],l)+"; "+this.compile(j.children[2],l)+") {\n"+this.compile(j.children[3],l)+"\n}\n";break;case"op_param":if(j.children[1]){g=this.compile(j.children[1],l)+", "}g+=this.compile(j.children[0],l);break;case"op_paramdef":if(j.children[1]){g=this.compile(j.children[1],l)+", "}g+=j.children[0];break;case"op_proplst":if(j.children[0]){g=this.compile(j.children[0],l)+", "}g+=this.compile(j.children[1],l);break;case"op_prop":g=j.children[0]+": "+this.compile(j.children[1],l);break;case"op_proplst_val":g=(l?"{":"<<")+this.compile(j.children[0],l)+(l?"}":">>");break;case"op_array":g="["+this.compile(j.children[0],l)+"]";break;case"op_extvalue":g=this.compile(j.children[0],l)+"["+this.compile(j.children[1],l)+"]";break;case"op_return":g=" return "+this.compile(j.children[0],l)+";\n";break;case"op_function":g=" function ("+this.compile(j.children[0],l)+") {\n"+this.compile(j.children[1],l)+"}";break;case"op_execfun":if(j.children[2]){k=(l?"{":"<<")+this.compile(j.children[2],l)+(l?"}":">>")}g=this.compile(j.children[0],l)+"("+this.compile(j.children[1],l)+(j.children[2]?", "+k:"")+")";if(l&&j.children[0].value==="$"){g="$jc$.board.objects["+this.compile(j.children[1],l)+"]"}break;case"op_property":if(l&&j.children[1]!=="X"&&j.children[1]!=="Y"){g="$jc$.resolveProperty("+this.compile(j.children[0],l)+", '"+j.children[1]+"', true)"}else{g=this.compile(j.children[0],l)+"."+j.children[1]}break;case"op_lhs":if(j.children.length===1){g=j.children[0]}else{if(j.children[2]==="dot"){if(l){g=[this.compile(j.children[1],l),j.children[0]]}else{g=this.compile(j.children[1],l)+"."+j.children[0]}}else{if(j.children[2]==="bracket"){if(l){g=[this.compile(j.children[1],l),this.compile(j.children[0],l)]}else{g=this.compile(j.children[1],l)+"["+this.compile(j.children[0],l)+"]"}}}}break;case"op_use":if(l){g="$jc$.board = JXG.JSXGraph.boards['"+j.children[0]+"']"}else{g="use "+j.children[0]+";"}break;case"op_delete":g="delete "+j.children[0];break;case"op_equ":g="("+this.compile(j.children[0],l)+" == "+this.compile(j.children[1],l)+")";break;case"op_neq":g="("+this.compile(j.children[0],l)+" != "+this.compile(j.children[1],l)+")";break;case"op_approx":g="("+this.compile(j.children[0],l)+" ~= "+this.compile(j.children[1],l)+")";break;case"op_grt":g="("+this.compile(j.children[0],l)+" > "+this.compile(j.children[1],l)+")";break;case"op_lot":g="("+this.compile(j.children[0],l)+" < "+this.compile(j.children[1],l)+")";break;case"op_gre":g="("+this.compile(j.children[0],l)+" >= "+this.compile(j.children[1],l)+")";break;case"op_loe":g="("+this.compile(j.children[0],l)+" <= "+this.compile(j.children[1],l)+")";break;case"op_or":g="("+this.compile(j.children[0],l)+" || "+this.compile(j.children[1],l)+")";break;case"op_and":g="("+this.compile(j.children[0],l)+" && "+this.compile(j.children[1],l)+")";break;case"op_not":g="!("+this.compile(j.children[0],l)+")";break;case"op_add":if(l){g="JXG.Math.Statistics.add("+this.compile(j.children[0],l)+", "+this.compile(j.children[1],l)+")"}else{g="("+this.compile(j.children[0],l)+" + "+this.compile(j.children[1],l)+")"}break;case"op_sub":if(l){g="JXG.Math.Statistics.subtract("+this.compile(j.children[0],l)+", "+this.compile(j.children[1],l)+")"}else{g="("+this.compile(j.children[0],l)+" - "+this.compile(j.children[1],l)+")"}break;case"op_div":if(l){g="JXG.Math.Statistics.div("+this.compile(j.children[0],l)+", "+this.compile(j.children[1],l)+")"}else{g="("+this.compile(j.children[0],l)+" / "+this.compile(j.children[1],l)+")"}break;case"op_mod":if(l){g="JXG.Math.mod("+this.compile(j.children[0],l)+", "+this.compile(j.children[1],l)+", true)"}else{g="("+this.compile(j.children[0],l)+" % "+this.compile(j.children[1],l)+")"}break;case"op_mul":if(l){g="$jc$.mul("+this.compile(j.children[0],l)+", "+this.compile(j.children[1],l)+")"}else{g="("+this.compile(j.children[0],l)+" * "+this.compile(j.children[1],l)+")"}break;case"op_exp":if(l){g="Math.pow("+this.compile(j.children[0],l)+", "+this.compile(j.children[1],l)+")"}else{g="("+this.compile(j.children[0],l)+"^"+this.compile(j.children[1],l)+")"}break;case"op_neg":g="(-"+this.compile(j.children[0],l)+")";break}break;case"node_var":if(l){g=this.getvarJS(j.value)}else{g=j.value}break;case"node_const":g=j.value;break;case"node_const_bool":g=j.value;break;case"node_str":g="'"+j.value.replace(/'/g,"\\'")+"'";break}if(j.needsBrackets){g="{\n"+g+"}\n"}return g},X:function(f){return f.X()},Y:function(f){return f.Y()},V:function(f){return f.Value()},L:function(f){return f.L()},dist:function(f,e){if(!JXG.exists(f)||!JXG.exists(f.Dist)){this._error("Error: Can't calculate distance.")}return f.Dist(e)},mul:function(f,e){if(JXG.isArray(f)*JXG.isArray(e)){return JXG.Math.innerProduct(f,e,Math.min(f.length,e.length))}else{return JXG.Math.Statistics.multiply(f,e)}},defineBuiltIn:function(){var e=this,f={PI:Math.PI,EULER:Math.E,X:e.X,Y:e.Y,V:e.V,L:e.L,dist:e.dist,rad:JXG.Math.Geometry.rad,deg:JXG.Math.Geometry.trueAngle,factorial:JXG.Math.factorial,trunc:JXG.trunc,"$":e.getElementById};f.rad.sc=JXG.Math.Geometry;f.deg.sc=JXG.Math.Geometry;f.factorial.sc=JXG.Math;f.PI.src="Math.PI";f.EULER.src="Math.E";f.X.src="$jc$.X";f.Y.src="$jc$.Y";f.V.src="$jc$.V";f.L.src="$jc$.L";f.dist.src="$jc$.dist";f.rad.src="JXG.Math.Geometry.rad";f.deg.src="JXG.Math.Geometry.trueAngle";f.factorial.src="JXG.Math.factorial";f.trunc.src="JXG.trunc";f["$"].src="(function (n) { return JXG.getRef($jc$.board, n); })";return f},_debug:function(e){if(typeof console!=="undefined"){console.log(e)}else{if(document.getElementById("debug")!==null){document.getElementById("debug").innerHTML+=e+"
"}}},_error:function(g){var f=new Error("Error("+this.line+"): "+g);f.line=this.line;throw f},_warn:function(e){if(typeof console!=="undefined"){console.log("Warning("+this.line+"): "+e)}else{if(document.getElementById(this.warnLog)!==null){document.getElementById(this.warnLog).innerHTML+="Warning("+this.line+"): "+e+"
"}}}});JXG.extend(JXG.JessieCode.prototype,{_lex:function(e){var i,f=-1,h=0,k=0,j,g;while(1){i=0;f=-1;h=0;k=0;j=e.offset+1+(h-k);do{j--;i=0;f=-2;k=j;if(e.src.length<=k){return 66}do{g=e.src.charCodeAt(j);switch(i){case 0:if((g>=9&&g<=10)||g==13||g==32){i=1}else{if(g==33){i=2}else{if(g==35){i=3}else{if(g==36||(g>=65&&g<=67)||(g>=71&&g<=72)||(g>=74&&g<=81)||g==83||g==86||(g>=88&&g<=90)||g==95||(g>=97&&g<=99)||(g>=103&&g<=104)||(g>=106&&g<=113)||g==115||g==118||(g>=120&&g<=122)){i=4}else{if(g==37){i=5}else{if(g==40){i=6}else{if(g==41){i=7}else{if(g==42){i=8}else{if(g==43){i=9}else{if(g==44){i=10}else{if(g==45){i=11}else{if(g==46){i=12}else{if(g==47){i=13}else{if((g>=48&&g<=57)){i=14}else{if(g==58){i=15}else{if(g==59){i=16}else{if(g==60){i=17}else{if(g==61){i=18}else{if(g==62){i=19}else{if(g==91){i=20}else{if(g==93){i=21}else{if(g==94){i=22}else{if(g==123){i=23}else{if(g==124){i=24}else{if(g==125){i=25}else{if(g==38){i=48}else{if(g==68||g==100){i=49}else{if(g==39){i=51}else{if(g==73||g==105){i=52}else{if(g==126){i=53}else{if(g==70||g==102){i=64}else{if(g==85||g==117){i=65}else{if(g==69||g==101){i=73}else{if(g==84||g==116){i=74}else{if(g==87||g==119){i=80}else{if(g==82||g==114){i=84}else{i=-1}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}break;case 1:i=-1;f=2;h=j;break;case 2:if(g==61){i=26}else{i=-1}f=31;h=j;break;case 3:i=-1;f=41;h=j;break;case 4:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=45;h=j;break;case 5:i=-1;f=35;h=j;break;case 6:i=-1;f=38;h=j;break;case 7:i=-1;f=39;h=j;break;case 8:i=-1;f=36;h=j;break;case 9:i=-1;f=32;h=j;break;case 10:i=-1;f=40;h=j;break;case 11:i=-1;f=33;h=j;break;case 12:if((g>=48&&g<=57)){i=29}else{i=-1}f=44;h=j;break;case 13:i=-1;f=34;h=j;break;case 14:if((g>=48&&g<=57)){i=14}else{if(g==46){i=29}else{i=-1}}f=47;h=j;break;case 15:i=-1;f=42;h=j;break;case 16:i=-1;f=20;h=j;break;case 17:if(g==60){i=30}else{if(g==61){i=31}else{i=-1}}f=28;h=j;break;case 18:if(g==61){i=32}else{i=-1}f=21;h=j;break;case 19:if(g==61){i=33}else{if(g==62){i=34}else{i=-1}}f=27;h=j;break;case 20:i=-1;f=16;h=j;break;case 21:i=-1;f=17;h=j;break;case 22:i=-1;f=37;h=j;break;case 23:i=-1;f=18;h=j;break;case 24:if(g==124){i=37}else{i=-1}f=43;h=j;break;case 25:i=-1;f=19;h=j;break;case 26:i=-1;f=23;h=j;break;case 27:i=-1;f=30;h=j;break;case 28:i=-1;f=46;h=j;break;case 29:if((g>=48&&g<=57)){i=29}else{i=-1}f=48;h=j;break;case 30:i=-1;f=14;h=j;break;case 31:i=-1;f=25;h=j;break;case 32:i=-1;f=22;h=j;break;case 33:i=-1;f=26;h=j;break;case 34:i=-1;f=15;h=j;break;case 35:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=6;h=j;break;case 36:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=3;h=j;break;case 37:i=-1;f=29;h=j;break;case 38:i=-1;f=24;h=j;break;case 39:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=7;h=j;break;case 40:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=9;h=j;break;case 41:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=4;h=j;break;case 42:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=12;h=j;break;case 43:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=13;h=j;break;case 44:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=5;h=j;break;case 45:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=11;h=j;break;case 46:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=10;h=j;break;case 47:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=8;h=j;break;case 48:if(g==38){i=27}else{i=-1}break;case 49:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=78)||(g>=80&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=110)||(g>=112&&g<=122)){i=4}else{if(g==79||g==111){i=35}else{if(g==69||g==101){i=81}else{i=-1}}}f=45;h=j;break;case 50:if(g==39){i=28}else{if((g>=0&&g<=38)||(g>=40&&g<=91)||(g>=93&&g<=254)){i=51}else{if(g==92){i=55}else{i=-1}}}f=46;h=j;break;case 51:if(g==39){i=28}else{if((g>=0&&g<=38)||(g>=40&&g<=91)||(g>=93&&g<=254)){i=51}else{if(g==92){i=55}else{i=-1}}}break;case 52:if((g>=48&&g<=57)||(g>=65&&g<=69)||(g>=71&&g<=90)||g==95||(g>=97&&g<=101)||(g>=103&&g<=122)){i=4}else{if(g==70||g==102){i=36}else{i=-1}}f=45;h=j;break;case 53:if(g==61){i=38}else{i=-1}break;case 54:if((g>=48&&g<=57)||(g>=65&&g<=81)||(g>=83&&g<=90)||g==95||(g>=97&&g<=113)||(g>=115&&g<=122)){i=4}else{if(g==82||g==114){i=39}else{i=-1}}f=45;h=j;break;case 55:if(g==39){i=50}else{if((g>=0&&g<=38)||(g>=40&&g<=91)||(g>=93&&g<=254)){i=51}else{if(g==92){i=55}else{i=-1}}}break;case 56:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=40}else{i=-1}}f=45;h=j;break;case 57:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=41}else{i=-1}}f=45;h=j;break;case 58:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=42}else{i=-1}}f=45;h=j;break;case 59:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=43}else{i=-1}}f=45;h=j;break;case 60:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=44}else{i=-1}}f=45;h=j;break;case 61:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=45}else{i=-1}}f=45;h=j;break;case 62:if((g>=48&&g<=57)||(g>=65&&g<=77)||(g>=79&&g<=90)||g==95||(g>=97&&g<=109)||(g>=111&&g<=122)){i=4}else{if(g==78||g==110){i=46}else{i=-1}}f=45;h=j;break;case 63:if((g>=48&&g<=57)||(g>=65&&g<=77)||(g>=79&&g<=90)||g==95||(g>=97&&g<=109)||(g>=111&&g<=122)){i=4}else{if(g==78||g==110){i=47}else{i=-1}}f=45;h=j;break;case 64:if((g>=48&&g<=57)||(g>=66&&g<=78)||(g>=80&&g<=84)||(g>=86&&g<=90)||g==95||(g>=98&&g<=110)||(g>=112&&g<=116)||(g>=118&&g<=122)){i=4}else{if(g==79||g==111){i=54}else{if(g==65||g==97){i=75}else{if(g==85||g==117){i=86}else{i=-1}}}}f=45;h=j;break;case 65:if((g>=48&&g<=57)||(g>=65&&g<=82)||(g>=84&&g<=90)||g==95||(g>=97&&g<=114)||(g>=116&&g<=122)){i=4}else{if(g==83||g==115){i=56}else{i=-1}}f=45;h=j;break;case 66:if((g>=48&&g<=57)||(g>=65&&g<=82)||(g>=84&&g<=90)||g==95||(g>=97&&g<=114)||(g>=116&&g<=122)){i=4}else{if(g==83||g==115){i=57}else{i=-1}}f=45;h=j;break;case 67:if((g>=48&&g<=57)||(g>=65&&g<=84)||(g>=86&&g<=90)||g==95||(g>=97&&g<=116)||(g>=118&&g<=122)){i=4}else{if(g==85||g==117){i=58}else{i=-1}}f=45;h=j;break;case 68:if((g>=48&&g<=57)||(g>=65&&g<=82)||(g>=84&&g<=90)||g==95||(g>=97&&g<=114)||(g>=116&&g<=122)){i=4}else{if(g==83||g==115){i=59}else{i=-1}}f=45;h=j;break;case 69:if((g>=48&&g<=57)||(g>=65&&g<=75)||(g>=77&&g<=90)||g==95||(g>=97&&g<=107)||(g>=109&&g<=122)){i=4}else{if(g==76||g==108){i=60}else{i=-1}}f=45;h=j;break;case 70:if((g>=48&&g<=57)||(g>=65&&g<=83)||(g>=85&&g<=90)||g==95||(g>=97&&g<=115)||(g>=117&&g<=122)){i=4}else{if(g==84||g==116){i=61}else{i=-1}}f=45;h=j;break;case 71:if((g>=48&&g<=57)||(g>=65&&g<=81)||(g>=83&&g<=90)||g==95||(g>=97&&g<=113)||(g>=115&&g<=122)){i=4}else{if(g==82||g==114){i=62}else{i=-1}}f=45;h=j;break;case 72:if((g>=48&&g<=57)||(g>=65&&g<=78)||(g>=80&&g<=90)||g==95||(g>=97&&g<=110)||(g>=112&&g<=122)){i=4}else{if(g==79||g==111){i=63}else{i=-1}}f=45;h=j;break;case 73:if((g>=48&&g<=57)||(g>=65&&g<=75)||(g>=77&&g<=90)||g==95||(g>=97&&g<=107)||(g>=109&&g<=122)){i=4}else{if(g==76||g==108){i=66}else{i=-1}}f=45;h=j;break;case 74:if((g>=48&&g<=57)||(g>=65&&g<=81)||(g>=83&&g<=90)||g==95||(g>=97&&g<=113)||(g>=115&&g<=122)){i=4}else{if(g==82||g==114){i=67}else{i=-1}}f=45;h=j;break;case 75:if((g>=48&&g<=57)||(g>=65&&g<=75)||(g>=77&&g<=90)||g==95||(g>=97&&g<=107)||(g>=109&&g<=122)){i=4}else{if(g==76||g==108){i=68}else{i=-1}}f=45;h=j;break;case 76:if((g>=48&&g<=57)||(g>=65&&g<=72)||(g>=74&&g<=90)||g==95||(g>=97&&g<=104)||(g>=106&&g<=122)){i=4}else{if(g==73||g==105){i=69}else{i=-1}}f=45;h=j;break;case 77:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=70}else{i=-1}}f=45;h=j;break;case 78:if((g>=48&&g<=57)||(g>=65&&g<=84)||(g>=86&&g<=90)||g==95||(g>=97&&g<=116)||(g>=118&&g<=122)){i=4}else{if(g==85||g==117){i=71}else{i=-1}}f=45;h=j;break;case 79:if((g>=48&&g<=57)||(g>=65&&g<=72)||(g>=74&&g<=90)||g==95||(g>=97&&g<=104)||(g>=106&&g<=122)){i=4}else{if(g==73||g==105){i=72}else{i=-1}}f=45;h=j;break;case 80:if((g>=48&&g<=57)||(g>=65&&g<=71)||(g>=73&&g<=90)||g==95||(g>=97&&g<=103)||(g>=105&&g<=122)){i=4}else{if(g==72||g==104){i=76}else{i=-1}}f=45;h=j;break;case 81:if((g>=48&&g<=57)||(g>=65&&g<=75)||(g>=77&&g<=90)||g==95||(g>=97&&g<=107)||(g>=109&&g<=122)){i=4}else{if(g==76||g==108){i=77}else{i=-1}}f=45;h=j;break;case 82:if((g>=48&&g<=57)||(g>=65&&g<=83)||(g>=85&&g<=90)||g==95||(g>=97&&g<=115)||(g>=117&&g<=122)){i=4}else{if(g==84||g==116){i=78}else{i=-1}}f=45;h=j;break;case 83:if((g>=48&&g<=57)||(g>=65&&g<=83)||(g>=85&&g<=90)||g==95||(g>=97&&g<=115)||(g>=117&&g<=122)){i=4}else{if(g==84||g==116){i=79}else{i=-1}}f=45;h=j;break;case 84:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=82}else{i=-1}}f=45;h=j;break;case 85:if((g>=48&&g<=57)||(g>=65&&g<=66)||(g>=68&&g<=90)||g==95||(g>=97&&g<=98)||(g>=100&&g<=122)){i=4}else{if(g==67||g==99){i=83}else{i=-1}}f=45;h=j;break;case 86:if((g>=48&&g<=57)||(g>=65&&g<=77)||(g>=79&&g<=90)||g==95||(g>=97&&g<=109)||(g>=111&&g<=122)){i=4}else{if(g==78||g==110){i=85}else{i=-1}}f=45;h=j;break}if(i>-1){if(g==10){e.line++;e.column=0;if(this.countLines){this.parCurLine=e.line;this.parCurColumn=e.column}}e.column++}j++}while(i>-1)}while(2>-1&&f==2);if(f>-1){e.att=e.src.substr(k,h-k);e.offset=h;if(f==46){e.att=e.att.substr(1,e.att.length-2);e.att=e.att.replace(/\\\'/g,"'")}}else{e.att=new String();f=-1}break}return f},_parse:function(e,k,h){var t=[],s=[],l=0,q,o,n,g={la:0,act:0,offset:0,src:e,att:"",line:1,column:1,error_step:0};var m=new Array(new Array(0,1),new Array(49,2),new Array(49,0),new Array(51,2),new Array(51,0),new Array(52,3),new Array(52,1),new Array(52,0),new Array(54,3),new Array(54,1),new Array(54,0),new Array(55,3),new Array(56,3),new Array(56,1),new Array(56,0),new Array(58,3),new Array(50,3),new Array(50,5),new Array(50,3),new Array(50,5),new Array(50,9),new Array(50,3),new Array(50,2),new Array(50,2),new Array(50,2),new Array(50,2),new Array(50,3),new Array(50,1),new Array(57,3),new Array(57,4),new Array(57,1),new Array(53,3),new Array(53,3),new Array(53,3),new Array(53,3),new Array(53,3),new Array(53,3),new Array(53,3),new Array(53,1),new Array(61,3),new Array(61,3),new Array(61,2),new Array(61,1),new Array(60,3),new Array(60,3),new Array(60,1),new Array(62,3),new Array(62,3),new Array(62,3),new Array(62,1),new Array(63,3),new Array(63,1),new Array(64,2),new Array(64,2),new Array(64,1),new Array(59,4),new Array(59,4),new Array(59,5),new Array(59,3),new Array(59,1),new Array(65,1),new Array(65,1),new Array(65,1),new Array(65,3),new Array(65,1),new Array(65,7),new Array(65,3),new Array(65,3),new Array(65,1),new Array(65,1));var j=new Array(new Array(),new Array(3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(38,40),new Array(45,41),new Array(45,42),new Array(3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(20,44),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51,20,52),new Array(),new Array(),new Array(21,54),new Array(30,55,29,56),new Array(44,57,38,58,16,59),new Array(21,-30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(32,61,33,62),new Array(),new Array(35,63,34,64,36,65),new Array(),new Array(),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(),new Array(38,67),new Array(45,70),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(),new Array(),new Array(),new Array(37,73),new Array(47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51,3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(44,77,38,58,16,78),new Array(),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51,3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(5,80),new Array(45,17,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(20,83),new Array(),new Array(),new Array(),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(),new Array(19,91,3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(45,96),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(30,55,29,56),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(39,104,24,45,23,46,26,47,25,48,27,49,28,50,22,51),new Array(45,106),new Array(15,107,40,108),new Array(),new Array(42,109),new Array(17,110,40,111),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(44,77,38,58,16,78),new Array(44,77,38,58,16,78),new Array(4,113),new Array(45,114),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(20,117),new Array(44,57,38,58,16,59),new Array(),new Array(30,55,29,56),new Array(30,55,29,56),new Array(30,55,29,56),new Array(30,55,29,56),new Array(30,55,29,56),new Array(30,55,29,56),new Array(30,55,29,56),new Array(),new Array(),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51),new Array(32,61,33,62),new Array(32,61,33,62),new Array(21,-28),new Array(39,118,40,111),new Array(17,119,32,61,33,62),new Array(35,63,34,64,36,65),new Array(35,63,34,64,36,65),new Array(),new Array(),new Array(),new Array(),new Array(39,120,40,121),new Array(),new Array(),new Array(45,70),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(),new Array(3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(),new Array(17,126,32,61,33,62),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51,20,127),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(21,-29),new Array(18,130),new Array(45,131),new Array(),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51),new Array(),new Array(),new Array(),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51,20,132),new Array(44,77,38,58,16,78),new Array(),new Array(),new Array(45,17,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(19,135,3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(39,136),new Array(),new Array(3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array());var f=new Array(new Array(49,1),new Array(50,2,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(53,35,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(53,38,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(50,39,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(),new Array(),new Array(50,43,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(),new Array(51,53),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(61,60,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(53,66,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(),new Array(54,68,55,69),new Array(52,71,53,72,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(),new Array(),new Array(),new Array(59,74,65,20),new Array(59,75,65,20),new Array(50,76,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(),new Array(50,79,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(58,81,57,14,59,82,65,20),new Array(),new Array(),new Array(),new Array(),new Array(61,84,60,19,62,21,63,31,64,32,59,36,65,20),new Array(61,85,60,19,62,21,63,31,64,32,59,36,65,20),new Array(61,86,60,19,62,21,63,31,64,32,59,36,65,20),new Array(61,87,60,19,62,21,63,31,64,32,59,36,65,20),new Array(61,88,60,19,62,21,63,31,64,32,59,36,65,20),new Array(61,89,60,19,62,21,63,31,64,32,59,36,65,20),new Array(61,90,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(50,92,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(53,93,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(60,94,62,21,63,31,64,32,59,36,65,20),new Array(60,95,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(52,97,53,72,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(60,98,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(62,99,63,31,64,32,59,36,65,20),new Array(62,100,63,31,64,32,59,36,65,20),new Array(63,101,64,32,59,36,65,20),new Array(63,102,64,32,59,36,65,20),new Array(63,103,64,32,59,36,65,20),new Array(),new Array(56,105),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(63,112,64,32,59,36,65,20),new Array(),new Array(),new Array(),new Array(),new Array(60,115,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(53,116,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(55,122),new Array(53,123,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(53,124,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(50,125,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(),new Array(),new Array(53,128,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(59,129,65,20),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(51,133),new Array(),new Array(58,134,57,14,59,82,65,20),new Array(50,92,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(),new Array(50,137,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array());var r=new Array(2,0,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,27,-1,38,54,62,-1,42,59,45,60,61,-1,64,-1,10,7,68,69,49,51,-1,-1,-1,54,62,-1,-1,-1,-1,22,23,24,-1,-1,-1,-1,-1,-1,-1,25,-1,-1,-1,-1,-1,7,-1,41,-1,-1,-1,-1,-1,-1,14,-1,9,-1,-1,6,-1,52,53,16,-1,-1,18,-1,-1,-1,21,37,36,35,34,33,32,31,26,3,15,40,39,58,-1,-1,44,43,48,47,46,63,-1,13,66,-1,-1,67,-1,50,-1,58,-1,-1,-1,56,55,-1,-1,8,11,5,17,55,19,-1,57,4,12,-1,-1,-1,65,-1,20);var p=new Array("Program'","ERROR_RESYNC","WHITESPACE","IF","ELSE","WHILE","DO","FOR","FUNCTION","USE","RETURN","DELETE","TRUE","FALSE","<<",">>","[","]","{","}",";","=","==","!=","~=","<=",">=",">","<","||","&&","!","+","-","/","%","*","^","(",")",",","#",":","|",".","Identifier","String","Integer","Float","Program","Stmt","Stmt_List","Param_List","Expression","Prop_List","Prop","Param_Def_List","Lhs","Assign","ExtValue","AddSubExp","LogExp","MulDivExp","ExpExp","NegExp","Value","$");if(!k){k=[]}if(!h){h=[]}t.push(0);s.push(0);g.la=this._lex(g);while(true){g.act=139;for(n=0;n1&&g.act==139){t.pop();s.pop();for(n=0;n1&&g.act!=139){while(g.la!=66){g.act=139;for(n=0;n0){t.push(g.act);s.push(g.att);g.la=this._lex(g);if(g.error_step>0){g.error_step--}}else{q=g.act*-1;o=void (0);switch(q){case 0:o=s[s.length-1];break;case 1:this.execute(s[s.length-1]);break;case 2:o=s[s.length-0];break;case 3:o=this.createNode("node_op","op_none",s[s.length-2],s[s.length-1]);break;case 4:o=s[s.length-0];break;case 5:o=this.createNode("node_op","op_param",s[s.length-1],s[s.length-3]);break;case 6:o=this.createNode("node_op","op_param",s[s.length-1]);break;case 7:o=s[s.length-0];break;case 8:o=this.createNode("node_op","op_proplst",s[s.length-3],s[s.length-1]);break;case 9:o=s[s.length-1];break;case 10:o=s[s.length-0];break;case 11:o=this.createNode("node_op","op_prop",s[s.length-3],s[s.length-1]);break;case 12:o=this.createNode("node_op","op_paramdef",s[s.length-1],s[s.length-3]);break;case 13:o=this.createNode("node_op","op_paramdef",s[s.length-1]);break;case 14:o=s[s.length-0];break;case 15:o=this.createNode("node_op","op_assign",s[s.length-3],s[s.length-1]);break;case 16:o=this.createNode("node_op","op_if",s[s.length-2],s[s.length-1]);break;case 17:o=this.createNode("node_op","op_if_else",s[s.length-4],s[s.length-3],s[s.length-1]);break;case 18:o=this.createNode("node_op","op_while",s[s.length-2],s[s.length-1]);break;case 19:o=this.createNode("node_op","op_do",s[s.length-4],s[s.length-2]);break;case 20:o=this.createNode("node_op","op_for",s[s.length-7],s[s.length-5],s[s.length-3],s[s.length-1]);break;case 21:o=this.createNode("node_op","op_use",s[s.length-2]);break;case 22:o=this.createNode("node_op","op_delete",s[s.length-1]);break;case 23:o=this.createNode("node_op","op_return",s[s.length-1]);break;case 24:o=s[s.length-2];break;case 25:o=this.createNode("node_op","op_noassign",s[s.length-2]);break;case 26:o=s[s.length-2];o.needsBrackets=true;break;case 27:o=this.createNode("node_op","op_none");break;case 28:o=this.createNode("node_op","op_lhs",s[s.length-1],s[s.length-3],"dot");break;case 29:o=this.createNode("node_op","op_lhs",s[s.length-2],s[s.length-4],"bracket");break;case 30:o=this.createNode("node_op","op_lhs",s[s.length-1]);break;case 31:o=this.createNode("node_op","op_equ",s[s.length-3],s[s.length-1]);break;case 32:o=this.createNode("node_op","op_lot",s[s.length-3],s[s.length-1]);break;case 33:o=this.createNode("node_op","op_grt",s[s.length-3],s[s.length-1]);break;case 34:o=this.createNode("node_op","op_loe",s[s.length-3],s[s.length-1]);break;case 35:o=this.createNode("node_op","op_gre",s[s.length-3],s[s.length-1]);break;case 36:o=this.createNode("node_op","op_neq",s[s.length-3],s[s.length-1]);break;case 37:o=this.createNode("node_op","op_approx",s[s.length-3],s[s.length-1]);break;case 38:o=s[s.length-1];break;case 39:o=this.createNode("node_op","op_or",s[s.length-3],s[s.length-1]);break;case 40:o=this.createNode("node_op","op_and",s[s.length-3],s[s.length-1]);break;case 41:o=this.createNode("node_op","op_not",s[s.length-1]);break;case 42:o=s[s.length-1];break;case 43:o=this.createNode("node_op","op_sub",s[s.length-3],s[s.length-1]);break;case 44:o=this.createNode("node_op","op_add",s[s.length-3],s[s.length-1]);break;case 45:o=s[s.length-1];break;case 46:o=this.createNode("node_op","op_mul",s[s.length-3],s[s.length-1]);break;case 47:o=this.createNode("node_op","op_div",s[s.length-3],s[s.length-1]);break;case 48:o=this.createNode("node_op","op_mod",s[s.length-3],s[s.length-1]);break;case 49:o=s[s.length-1];break;case 50:o=this.createNode("node_op","op_exp",s[s.length-3],s[s.length-1]);break;case 51:o=s[s.length-1];break;case 52:o=this.createNode("node_op","op_neg",s[s.length-1]);break;case 53:o=s[s.length-1];break;case 54:o=s[s.length-1];break;case 55:o=this.createNode("node_op","op_extvalue",s[s.length-4],s[s.length-2]);break;case 56:o=this.createNode("node_op","op_execfun",s[s.length-4],s[s.length-2]);break;case 57:o=this.createNode("node_op","op_execfun",s[s.length-5],s[s.length-3],s[s.length-1]);break;case 58:o=this.createNode("node_op","op_property",s[s.length-3],s[s.length-1]);break;case 59:o=s[s.length-1];break;case 60:o=this.createNode("node_const",s[s.length-1]);break;case 61:o=this.createNode("node_const",s[s.length-1]);break;case 62:o=this.createNode("node_var",s[s.length-1]);break;case 63:o=s[s.length-2];break;case 64:o=this.createNode("node_str",s[s.length-1]);break;case 65:o=this.createNode("node_op","op_function",s[s.length-5],s[s.length-2]);break;case 66:o=this.createNode("node_op","op_proplst_val",s[s.length-2]);break;case 67:o=this.createNode("node_op","op_array",s[s.length-2]);break;case 68:o=this.createNode("node_const_bool",s[s.length-1]);break;case 69:o=this.createNode("node_const_bool",s[s.length-1]);break}for(n=0;n> "}}else{return"null"}case"string":return"'"+h.replace(/(["'])/g,"\\$1")+"'";case"number":case"boolean":return new String(h);case"null":return"null"}},toJessie:function(g){var h=this.dump(g),e=[],f;for(f=0;f0){e.push("// "+h[f].attributes.name)}e.push("s"+f+" = "+h[f].type+"("+h[f].parents.join(", ")+") "+this.toJSAN(h[f].attributes).replace(/\n/,"\\n")+";");e.push("")}return e.join("\n")},toJavaScript:function(g){var h=this.dump(g),e=[],f;for(f=0;f0){f=this.joinTransforms(i,g);h=[f[1][1],f[2][1],f[1][2],f[2][2],f[1][0],f[2][0]].join(",");k+=" matrix("+h+") ";j.setAttributeNS(null,"transform",k)}},updateImageURL:function(f){var e=JXG.evaluate(f.url);f.rendNode.setAttributeNS(this.xlinkNamespace,"xlink:href",e)},appendChildPrim:function(e,f){if(!JXG.exists(f)){f=0}else{if(f>=JXG.Options.layer.numlayers){f=JXG.Options.layer.numlayers-1}}this.layer[f].appendChild(e)},appendNodesToElement:function(e){e.rendNode=this.getElementById(e.id)},createPrim:function(e,g){var f=this.container.ownerDocument.createElementNS(this.svgNamespace,e);f.setAttributeNS(null,"id",this.container.id+"_"+g);f.style.position="absolute";if(e==="path"){f.setAttributeNS(null,"stroke-linecap","butt");f.setAttributeNS(null,"stroke-linejoin","round")}return f},remove:function(e){if(JXG.exists(e)&&JXG.exists(e.parentNode)){e.parentNode.removeChild(e)}},makeArrows:function(f){var e;if(f.visPropOld.firstarrow===f.visProp.firstarrow&&f.visPropOld.lastarrow===f.visProp.lastarrow){return}if(f.visProp.firstarrow){e=f.rendNodeTriangleStart;if(!JXG.exists(e)){e=this._createArrowHead(f,"End");this.defs.appendChild(e);f.rendNodeTriangleStart=e;f.rendNode.setAttributeNS(null,"marker-start","url(#"+this.container.id+"_"+f.id+"TriangleEnd)")}}else{e=f.rendNodeTriangleStart;if(JXG.exists(e)){this.remove(e)}}if(f.visProp.lastarrow){e=f.rendNodeTriangleEnd;if(!JXG.exists(e)){e=this._createArrowHead(f,"Start");this.defs.appendChild(e);f.rendNodeTriangleEnd=e;f.rendNode.setAttributeNS(null,"marker-end","url(#"+this.container.id+"_"+f.id+"TriangleStart)")}}else{e=f.rendNodeTriangleEnd;if(JXG.exists(e)){this.remove(e)}}f.visPropOld.firstarrow=f.visProp.firstarrow;f.visPropOld.lastarrow=f.visProp.lastarrow},updateEllipsePrim:function(f,e,i,h,g){f.setAttributeNS(null,"cx",e);f.setAttributeNS(null,"cy",i);f.setAttributeNS(null,"rx",Math.abs(h));f.setAttributeNS(null,"ry",Math.abs(g))},updateLinePrim:function(i,f,e,h,g){if(!isNaN(f+e+h+g)){i.setAttributeNS(null,"x1",f);i.setAttributeNS(null,"y1",e);i.setAttributeNS(null,"x2",h);i.setAttributeNS(null,"y2",g)}},updatePathPrim:function(e,f){if(f==""){f="M 0 0"}e.setAttributeNS(null,"d",f)},updatePathStringPoint:function(i,f,h){var g="",k=i.coords.scrCoords,j=f*Math.sqrt(3)*0.5,e=f*0.5;if(h==="x"){g=" M "+(k[1]-f)+" "+(k[2]-f)+" L "+(k[1]+f)+" "+(k[2]+f)+" M "+(k[1]+f)+" "+(k[2]-f)+" L "+(k[1]-f)+" "+(k[2]+f)}else{if(h==="+"){g=" M "+(k[1]-f)+" "+(k[2])+" L "+(k[1]+f)+" "+(k[2])+" M "+(k[1])+" "+(k[2]-f)+" L "+(k[1])+" "+(k[2]+f)}else{if(h==="<>"){g=" M "+(k[1]-f)+" "+(k[2])+" L "+(k[1])+" "+(k[2]+f)+" L "+(k[1]+f)+" "+(k[2])+" L "+(k[1])+" "+(k[2]-f)+" Z "}else{if(h==="^"){g=" M "+(k[1])+" "+(k[2]-f)+" L "+(k[1]-j)+" "+(k[2]+e)+" L "+(k[1]+j)+" "+(k[2]+e)+" Z "}else{if(h==="v"){g=" M "+(k[1])+" "+(k[2]+f)+" L "+(k[1]-j)+" "+(k[2]-e)+" L "+(k[1]+j)+" "+(k[2]-e)+" Z "}else{if(h===">"){g=" M "+(k[1]+f)+" "+(k[2])+" L "+(k[1]-e)+" "+(k[2]-j)+" L "+(k[1]-e)+" "+(k[2]+j)+" Z "}else{if(h==="<"){g=" M "+(k[1]-f)+" "+(k[2])+" L "+(k[1]+e)+" "+(k[2]-j)+" L "+(k[1]+e)+" "+(k[2]+j)+" Z "}}}}}}}return g},updatePathStringPrim:function(e){var g=" M ",h=" L ",f=g,n=5000,k="",j,m,o=(e.visProp.curvetype!=="plot"),l;if(e.numberPoints<=0){return""}if(o&&e.board.options.curve.RDPsmoothing){e.points=JXG.Math.Numerics.RamerDouglasPeuker(e.points,0.5)}l=Math.min(e.points.length,e.numberPoints);for(j=0;jn){m[1]=n}else{if(m[1]<-n){m[1]=-n}}if(m[2]>n){m[2]=n}else{if(m[2]<-n){m[2]=-n}}k+=[f,m[1]," ",m[2]].join("");f=h}}return k},updatePathStringBezierPrim:function(g){var l=" M ",m=" C ",k=l,u=5000,p="",o,n,s,h,e,r=g.visProp.strokewidth,t=(g.visProp.curvetype!=="plot"),q;if(g.numberPoints<=0){return""}if(t&&g.board.options.curve.RDPsmoothing){g.points=JXG.Math.Numerics.RamerDouglasPeuker(g.points,0.5)}q=Math.min(g.points.length,g.numberPoints);for(n=1;n<3;n++){k=l;for(o=0;ou){s[1]=u}else{if(s[1]<-u){s[1]=-u}}if(s[2]>u){s[2]=u}else{if(s[2]<-u){s[2]=-u}}if(k==l){p+=[k,s[1]+0*r*(2*n*Math.random()-n)," ",s[2]+0*r*(2*n*Math.random()-n)].join("")}else{p+=[k,(h+(s[1]-h)*0.333+r*(2*n*Math.random()-n))," ",(e+(s[2]-e)*0.333+r*(2*n*Math.random()-n))," ",(h+2*(s[1]-h)*0.333+r*(2*n*Math.random()-n))," ",(e+2*(s[2]-e)*0.333+r*(2*n*Math.random()-n))," ",s[1]," ",s[2]].join("")}k=m;h=s[1];e=s[2]}}}return p},updatePolygonPrim:function(j,h){var k="",f,g,e=h.vertices.length;j.setAttributeNS(null,"stroke","none");for(g=0;g0){f.setAttributeNS(null,"stroke-dasharray",this.dashArray[g-1])}else{if(f.hasAttributeNS(null,"stroke-dasharray")){f.removeAttributeNS(null,"stroke-dasharray")}}},setGradient:function(g){var o=g.rendNode,h,j,i,n,m,f,e,l,k;j=JXG.evaluate(g.visProp.fillopacity);j=(j>0)?j:0;h=JXG.evaluate(g.visProp.fillcolor);if(g.visProp.gradient==="linear"){i=this.createPrim("linearGradient",g.id+"_gradient");f="0%";e="100%";l="0%";k="0%";i.setAttributeNS(null,"x1",f);i.setAttributeNS(null,"x2",e);i.setAttributeNS(null,"y1",l);i.setAttributeNS(null,"y2",k);n=this.createPrim("stop",g.id+"_gradient1");n.setAttributeNS(null,"offset","0%");n.setAttributeNS(null,"style","stop-color:"+h+";stop-opacity:"+j);m=this.createPrim("stop",g.id+"_gradient2");m.setAttributeNS(null,"offset","100%");m.setAttributeNS(null,"style","stop-color:"+g.visProp.gradientsecondcolor+";stop-opacity:"+g.visProp.gradientsecondopacity);i.appendChild(n);i.appendChild(m);this.defs.appendChild(i);o.setAttributeNS(null,"style","fill:url(#"+this.container.id+"_"+g.id+"_gradient)");g.gradNode1=n;g.gradNode2=m}else{if(g.visProp.gradient==="radial"){i=this.createPrim("radialGradient",g.id+"_gradient");i.setAttributeNS(null,"cx","50%");i.setAttributeNS(null,"cy","50%");i.setAttributeNS(null,"r","50%");i.setAttributeNS(null,"fx",g.visProp.gradientpositionx*100+"%");i.setAttributeNS(null,"fy",g.visProp.gradientpositiony*100+"%");n=this.createPrim("stop",g.id+"_gradient1");n.setAttributeNS(null,"offset","0%");n.setAttributeNS(null,"style","stop-color:"+g.visProp.gradientsecondcolor+";stop-opacity:"+g.visProp.gradientsecondopacity);m=this.createPrim("stop",g.id+"_gradient2");m.setAttributeNS(null,"offset","100%");m.setAttributeNS(null,"style","stop-color:"+h+";stop-opacity:"+j);i.appendChild(n);i.appendChild(m);this.defs.appendChild(i);o.setAttributeNS(null,"style","fill:url(#"+this.container.id+"_"+g.id+"_gradient)");g.gradNode1=n;g.gradNode2=m}else{o.removeAttributeNS(null,"style")}}},updateGradient:function(h){var f=h.gradNode1,e=h.gradNode2,g,i;if(!JXG.exists(f)||!JXG.exists(e)){return}i=JXG.evaluate(h.visProp.fillopacity);i=(i>0)?i:0;g=JXG.evaluate(h.visProp.fillcolor);if(h.visProp.gradient==="linear"){f.setAttributeNS(null,"style","stop-color:"+g+";stop-opacity:"+i);e.setAttributeNS(null,"style","stop-color:"+h.visProp.gradientsecondcolor+";stop-opacity:"+h.visProp.gradientsecondopacity)}else{if(h.visProp.gradient==="radial"){f.setAttributeNS(null,"style","stop-color:"+h.visProp.gradientsecondcolor+";stop-opacity:"+h.visProp.gradientsecondopacity);e.setAttributeNS(null,"style","stop-color:"+g+";stop-opacity:"+i)}}},setObjectFillColor:function(f,i,k){var g,h=JXG.evaluate(i),l,m,e=JXG.evaluate(k),j;e=(e>0)?e:0;if(f.visPropOld.fillcolor===h&&f.visPropOld.fillopacity===e){return}if(JXG.exists(h)&&h!==false){if(h.length!=9){l=h;j=e}else{m=JXG.rgba2rgbo(h);l=m[0];j=e*m[1]}g=f.rendNode;g.setAttributeNS(null,"fill",l);if(f.type===JXG.OBJECT_TYPE_IMAGE){g.setAttributeNS(null,"opacity",j)}else{g.setAttributeNS(null,"fill-opacity",j)}if(JXG.exists(f.visProp.gradient)){this.updateGradient(f)}}f.visPropOld.fillcolor=h;f.visPropOld.fillopacity=e},setObjectStrokeColor:function(f,i,j){var h=JXG.evaluate(i),l,m,e=JXG.evaluate(j),k,g;e=(e>0)?e:0;if(f.visPropOld.strokecolor===h&&f.visPropOld.strokeopacity===e){return}if(JXG.exists(h)&&h!==false){if(h.length!=9){l=h;k=e}else{m=JXG.rgba2rgbo(h);l=m[0];k=e*m[1]}g=f.rendNode;if(f.type===JXG.OBJECT_TYPE_TEXT){if(f.visProp.display==="html"){g.style.color=l;g.style.opacity=k}else{g.setAttributeNS(null,"style","fill:"+l);g.setAttributeNS(null,"style","fill-opacity:"+k)}}else{g.setAttributeNS(null,"stroke",l);g.setAttributeNS(null,"stroke-opacity",k)}if(f.type===JXG.OBJECT_TYPE_ARROW){this._setArrowAtts(f.rendNodeTriangle,l,k)}else{if(f.elementClass===JXG.OBJECT_CLASS_CURVE||f.elementClass===JXG.OBJECT_CLASS_LINE){if(f.visProp.firstarrow){this._setArrowAtts(f.rendNodeTriangleStart,l,k)}if(f.visProp.lastarrow){this._setArrowAtts(f.rendNodeTriangleEnd,l,k)}}}}f.visPropOld.strokecolor=h;f.visPropOld.strokeopacity=e},setObjectStrokeWidth:function(g,f){var e=JXG.evaluate(f),h;if(g.visPropOld.strokewidth===e){return}h=g.rendNode;this.setPropertyPrim(h,"stroked","true");if(JXG.exists(e)){this.setPropertyPrim(h,"stroke-width",e+"px")}g.visPropOld.strokewidth=e},setShadow:function(e){if(e.visPropOld.shadow===e.visProp.shadow){return}if(JXG.exists(e.rendNode)){if(e.visProp.shadow){e.rendNode.setAttributeNS(null,"filter","url(#"+this.container.id+"_f1)")}else{e.rendNode.removeAttributeNS(null,"filter")}}e.visPropOld.shadow=e.visProp.shadow},suspendRedraw:function(){},unsuspendRedraw:function(){},resize:function(e,f){this.svgRoot.style.width=parseFloat(e)+"px";this.svgRoot.style.height=parseFloat(f)+"px"}});JXG.VMLRenderer=function(f){this.type="vml";this.container=f;this.container.style.overflow="hidden";this.container.onselectstart=function(){return false};this.resolution=10;if(!JXG.exists(JXG.vmlStylesheet)){f.ownerDocument.namespaces.add("jxgvml","urn:schemas-microsoft-com:vml");JXG.vmlStylesheet=this.container.ownerDocument.createStyleSheet();JXG.vmlStylesheet.addRule(".jxgvml","behavior:url(#default#VML)")}try{!f.ownerDocument.namespaces.jxgvml&&f.ownerDocument.namespaces.add("jxgvml","urn:schemas-microsoft-com:vml");this.createNode=function(e){return f.ownerDocument.createElement("')}}catch(g){this.createNode=function(e){return f.ownerDocument.createElement("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="jxgvml">')}}this.dashArray=["Solid","1 1","ShortDash","Dash","LongDash","ShortDashDot","LongDashDot"]};JXG.VMLRenderer.prototype=new JXG.AbstractRenderer();JXG.extend(JXG.VMLRenderer.prototype,{_setAttr:function(h,g,j,f){try{if(document.documentMode===8){h[g]=j}else{h.setAttribute(g,j,f)}}catch(i){JXG.debug("_setAttr: "+g+" "+j+"
\n")}},updateTicks:function(j,k,f,l,h){var g=[],m,n,o,p,e=this.resolution;n=j.ticks.length;for(m=0;m0){r=h.rendNode.style.filter.toString();if(!r.match(/DXImageTransform/)){k.style.filter="progid:DXImageTransform.Microsoft.Matrix(M11='1.0', sizingMethod='auto expand') "+r}l=this.joinTransforms(h,u);g[0]=JXG.Math.matVecMult(l,h.coords.scrCoords);g[0][1]/=g[0][0];g[0][2]/=g[0][0];g[1]=JXG.Math.matVecMult(l,[1,h.coords.scrCoords[1]+h.size[0],h.coords.scrCoords[2]]);g[1][1]/=g[1][0];g[1][2]/=g[1][0];g[2]=JXG.Math.matVecMult(l,[1,h.coords.scrCoords[1]+h.size[0],h.coords.scrCoords[2]-h.size[1]]);g[2][1]/=g[2][0];g[2][2]/=g[2][0];g[3]=JXG.Math.matVecMult(l,[1,h.coords.scrCoords[1],h.coords.scrCoords[2]-h.size[1]]);g[3][1]/=g[3][0];g[3][2]/=g[3][0];f=g[0][1];n=g[0][1];e=g[0][2];j=g[0][2];for(o=1;o<4;o++){f=Math.max(f,g[o][1]);n=Math.min(n,g[o][1]);e=Math.max(e,g[o][2]);j=Math.min(j,g[o][2])}k.style.left=parseInt(n)+"px";k.style.top=parseInt(j)+"px";k.filters.item(0).M11=l[1][1];k.filters.item(0).M12=l[1][2];k.filters.item(0).M21=l[2][1];k.filters.item(0).M22=l[2][2]}},updateImageURL:function(f){var e=JXG.evaluate(f.url);this._setAttr(f.rendNode,"src",e)},appendChildPrim:function(e,f){if(!JXG.exists(f)){f=0}e.style.zIndex=f;this.container.appendChild(e)},appendNodesToElement:function(e,f){if(f==="shape"||f==="path"||f==="polygon"){e.rendNodePath=this.getElementById(e.id+"_path")}e.rendNodeFill=this.getElementById(e.id+"_fill");e.rendNodeStroke=this.getElementById(e.id+"_stroke");e.rendNodeShadow=this.getElementById(e.id+"_shadow");e.rendNode=this.getElementById(e.id)},createPrim:function(f,k){var g,e=this.createNode("fill"),j=this.createNode("stroke"),i=this.createNode("shadow"),h;this._setAttr(e,"id",this.container.id+"_"+k+"_fill");this._setAttr(j,"id",this.container.id+"_"+k+"_stroke");this._setAttr(i,"id",this.container.id+"_"+k+"_shadow");if(f==="circle"||f==="ellipse"){g=this.createNode("oval");g.appendChild(e);g.appendChild(j);g.appendChild(i)}else{if(f==="polygon"||f==="path"||f==="shape"||f==="line"){g=this.createNode("shape");g.appendChild(e);g.appendChild(j);g.appendChild(i);h=this.createNode("path");this._setAttr(h,"id",this.container.id+"_"+k+"_path");g.appendChild(h)}else{g=this.createNode(f);g.appendChild(e);g.appendChild(j);g.appendChild(i)}}g.style.position="absolute";g.style.left="0px";g.style.top="0px";this._setAttr(g,"id",this.container.id+"_"+k);return g},remove:function(e){if(JXG.exists(e)){e.removeNode(true)}},makeArrows:function(f){var e;if(f.visPropOld.firstarrow===f.visProp.firstarrow&&f.visPropOld.lastarrow===f.visProp.lastarrow){return}if(f.visProp.firstarrow){e=f.rendNodeStroke;this._setAttr(e,"startarrow","block");this._setAttr(e,"startarrowlength","long")}else{e=f.rendNodeStroke;if(JXG.exists(e)){this._setAttr(e,"startarrow","none")}}if(f.visProp.lastarrow){e=f.rendNodeStroke;this._setAttr(e,"id",this.container.id+"_"+f.id+"stroke");this._setAttr(e,"endarrow","block");this._setAttr(e,"endarrowlength","long")}else{e=f.rendNodeStroke;if(JXG.exists(e)){this._setAttr(e,"endarrow","none")}}f.visPropOld.firstarrow=f.visProp.firstarrow;f.visPropOld.lastarrow=f.visProp.lastarrow},updateEllipsePrim:function(f,e,i,h,g){f.style.left=parseInt(e-h)+"px";f.style.top=parseInt(i-g)+"px";f.style.width=parseInt(Math.abs(h)*2)+"px";f.style.height=parseInt(Math.abs(g)*2)+"px"},updateLinePrim:function(l,f,e,h,g,j){var i,k=this.resolution;if(!isNaN(f+e+h+g)){i=["m ",parseInt(k*f),", ",parseInt(k*e)," l ",parseInt(k*h),", ",parseInt(k*g)];this.updatePathPrim(l,i,j)}},updatePathPrim:function(g,h,f){var e=f.canvasWidth,i=f.canvasHeight;if(h.length<=0){h=["m 0,0"]}g.style.width=e;g.style.height=i;this._setAttr(g,"coordsize",[parseInt(this.resolution*e),parseInt(this.resolution*i)].join(","));this._setAttr(g,"path",h.join(""))},updatePathStringPoint:function(f,l,i){var k=[],g=Math.round,h=f.coords.scrCoords,j=l*Math.sqrt(3)*0.5,m=l*0.5,e=this.resolution;if(i==="x"){k.push([" m ",g(e*(h[1]-l)),", ",g(e*(h[2]-l))," l ",g(e*(h[1]+l)),", ",g(e*(h[2]+l))," m ",g(e*(h[1]+l)),", ",g(e*(h[2]-l))," l ",g(e*(h[1]-l)),", ",g(e*(h[2]+l))].join(""))}else{if(i==="+"){k.push([" m ",g(e*(h[1]-l)),", ",g(e*(h[2]))," l ",g(e*(h[1]+l)),", ",g(e*(h[2]))," m ",g(e*(h[1])),", ",g(e*(h[2]-l))," l ",g(e*(h[1])),", ",g(e*(h[2]+l))].join(""))}else{if(i==="<>"){k.push([" m ",g(e*(h[1]-l)),", ",g(e*(h[2]))," l ",g(e*(h[1])),", ",g(e*(h[2]+l))," l ",g(e*(h[1]+l)),", ",g(e*(h[2]))," l ",g(e*(h[1])),", ",g(e*(h[2]-l))," x e "].join(""))}else{if(i==="^"){k.push([" m ",g(e*(h[1])),", ",g(e*(h[2]-l))," l ",g(e*(h[1]-j)),", ",g(e*(h[2]+m))," l ",g(e*(h[1]+j)),", ",g(e*(h[2]+m))," x e "].join(""))}else{if(i==="v"){k.push([" m ",g(e*(h[1])),", ",g(e*(h[2]+l))," l ",g(e*(h[1]-j)),", ",g(e*(h[2]-m))," l ",g(e*(h[1]+j)),", ",g(e*(h[2]-m))," x e "].join(""))}else{if(i===">"){k.push([" m ",g(e*(h[1]+l)),", ",g(e*(h[2]))," l ",g(e*(h[1]-m)),", ",g(e*(h[2]-j))," l ",g(e*(h[1]-m)),", ",g(e*(h[2]+j))," l ",g(e*(h[1]+l)),", ",g(e*(h[2]))].join(""))}else{if(i==="<"){k.push([" m ",g(e*(h[1]-l)),", ",g(e*(h[2]))," l ",g(e*(h[1]+m)),", ",g(e*(h[2]-j))," l ",g(e*(h[1]+m)),", ",g(e*(h[2]+j))," x e "].join(""))}}}}}}}return k},updatePathStringPrim:function(f){var m=[],l,o,e=this.resolution,k=Math.round,h=" m ",j=" l ",g=h,p=(f.visProp.curvetype!=="plot"),n=Math.min(f.numberPoints,8192);if(f.numberPoints<=0){return""}if(p&&f.board.options.curve.RDPsmoothing){f.points=JXG.Math.Numerics.RamerDouglasPeuker(f.points,1)}n=Math.min(n,f.points.length);for(l=0;l20000){o[1]=20000}else{if(o[1]<-20000){o[1]=-20000}}if(o[2]>20000){o[2]=20000}else{if(o[2]<-20000){o[2]=-20000}}m.push([g,k(e*o[1]),", ",k(e*o[2])].join(""));g=j}}m.push(" e");return m},updatePathStringBezierPrim:function(h){var s=[],q,p,v,l,g,u=h.visProp.strokewidth,e=this.resolution,o=Math.round,m=" m ",n=" c ",k=m,w=(h.visProp.curvetype!=="plot"),t=Math.min(h.numberPoints,8192);if(h.numberPoints<=0){return""}if(w&&h.board.options.curve.RDPsmoothing){h.points=JXG.Math.Numerics.RamerDouglasPeuker(h.points,1)}t=Math.min(t,h.points.length);for(p=1;p<3;p++){k=m;for(q=0;q20000){v[1]=20000}else{if(v[1]<-20000){v[1]=-20000}}if(v[2]>20000){v[2]=20000}else{if(v[2]<-20000){v[2]=-20000}}if(k==m){s.push([k,o(e*(v[1]+0*u*(2*p*Math.random()-p)))," ",o(e*(v[2]+0*u*(2*p*Math.random()-p)))].join(""))}else{s.push([k,o(e*(l+(v[1]-l)*0.333+u*(2*p*Math.random()-p)))," ",o(e*(g+(v[2]-g)*0.333+u*(2*p*Math.random()-p)))," ",o(e*(l+2*(v[1]-l)*0.333+u*(2*p*Math.random()-p)))," ",o(e*(g+2*(v[2]-g)*0.333+u*(2*p*Math.random()-p)))," ",o(e*v[1])," ",o(e*v[2])].join(""))}k=n;l=v[1];g=v[2]}}}s.push(" e");return s},updatePolygonPrim:function(j,g){var f,e=g.vertices.length,h=this.resolution,k,l=[];this._setAttr(j,"stroked","false");k=g.vertices[0].coords.scrCoords;if(isNaN(k[1]+k[2])){return}l.push(["m ",parseInt(h*k[1]),",",parseInt(h*k[2])," l "].join(""));for(f=1;f=0){i.style.width=f+"px"}if(g>=0){i.style.height=g+"px"}},setPropertyPrim:function(h,g,i){var f="",e;switch(g){case"stroke":f="strokecolor";break;case"stroke-width":f="strokeweight";break;case"stroke-dasharray":f="dashstyle";break}if(f!==""){e=JXG.evaluate(i);this._setAttr(h,f,e)}},show:function(e){if(e&&e.rendNode){e.rendNode.style.visibility="inherit"}},hide:function(e){if(e&&e.rendNode){e.rendNode.style.visibility="hidden"}},setDashStyle:function(f,e){var g;if(e.dash>=0){g=f.rendNodeStroke;this._setAttr(g,"dashstyle",this.dashArray[e.dash])}},setGradient:function(f){var e=f.rendNodeFill;if(f.visProp.gradient==="linear"){this._setAttr(e,"type","gradient");this._setAttr(e,"color2",f.visProp.gradientsecondcolor);this._setAttr(e,"opacity2",f.visProp.gradientsecondopacity);this._setAttr(e,"angle",f.visProp.gradientangle)}else{if(f.visProp.gradient==="radial"){this._setAttr(e,"type","gradientradial");this._setAttr(e,"color2",f.visProp.gradientsecondcolor);this._setAttr(e,"opacity2",f.visProp.gradientsecondopacity);this._setAttr(e,"focusposition",f.visProp.gradientpositionx*100+"%,"+f.visProp.gradientpositiony*100+"%");this._setAttr(e,"focussize","0,0")}else{this._setAttr(e,"type","solid")}}},setObjectFillColor:function(f,i,j){var h=JXG.evaluate(i),l,m,e=JXG.evaluate(j),k,g=f.rendNode,n;e=(e>0)?e:0;if(f.visPropOld.fillcolor===h&&f.visPropOld.fillopacity===e){return}if(JXG.exists(h)&&h!==false){if(h.length!=9){l=h;k=e}else{m=JXG.rgba2rgbo(h);l=m[0];k=e*m[1]}if(l==="none"||l===false){this._setAttr(f.rendNode,"filled","false")}else{this._setAttr(f.rendNode,"filled","true");this._setAttr(f.rendNode,"fillcolor",l);if(JXG.exists(k)&&f.rendNodeFill){this._setAttr(f.rendNodeFill,"opacity",(k*100)+"%")}}if(f.type===JXG.OBJECT_TYPE_IMAGE){n=f.rendNode.style.filter.toString();if(n.match(/alpha/)){f.rendNode.style.filter=n.replace(/alpha\(opacity *= *[0-9\.]+\)/,"alpha(opacity = "+(k*100)+")")}else{f.rendNode.style.filter+=" alpha(opacity = "+(k*100)+")"}}}f.visPropOld.fillcolor=h;f.visPropOld.fillopacity=e},setObjectStrokeColor:function(g,j,k){var i=JXG.evaluate(j),m,n,f=JXG.evaluate(k),l,h=g.rendNode,e;f=(f>0)?f:0;if(g.visPropOld.strokecolor===i&&g.visPropOld.strokeopacity===f){return}if(JXG.exists(i)&&i!==false){if(i.length!=9){m=i;l=f}else{n=JXG.rgba2rgbo(i);m=n[0];l=f*n[1]}if(g.type===JXG.OBJECT_TYPE_TEXT){l=Math.round(l*100);h.style.filter=" alpha(opacity = "+l+")";h.style.color=m}else{if(m!==false){this._setAttr(h,"stroked","true");this._setAttr(h,"strokecolor",m)}e=g.rendNodeStroke;if(JXG.exists(l)&&g.type!==JXG.OBJECT_TYPE_IMAGE){this._setAttr(e,"opacity",(l*100)+"%")}}}g.visPropOld.strokecolor=i;g.visPropOld.strokeopacity=f},setObjectStrokeWidth:function(g,f){var e=JXG.evaluate(f),h;if(g.visPropOld.strokewidth===e){return}h=g.rendNode;this.setPropertyPrim(h,"stroked","true");if(JXG.exists(e)){this.setPropertyPrim(h,"stroke-width",e)}g.visPropOld.strokewidth=e},setShadow:function(e){var f=e.rendNodeShadow;if(!f||e.visPropOld.shadow===e.visProp.shadow){return}if(e.visProp.shadow){this._setAttr(f,"On","True");this._setAttr(f,"Offset","3pt,3pt");this._setAttr(f,"Opacity","60%");this._setAttr(f,"Color","#aaaaaa")}else{this._setAttr(f,"On","False")}e.visPropOld.shadow=e.visProp.shadow},suspendRedraw:function(){this.container.style.display="none"},unsuspendRedraw:function(){this.container.style.display=""}});JXG.CanvasRenderer=function(e){var f;this.type="canvas";this.canvasRoot=null;this.suspendHandle=null;this.canvasId=JXG.Util.genUUID();this.canvasNamespace=null;this.container=e;this.container.style.MozUserSelect="none";this.container.style.overflow="hidden";if(this.container.style.position===""){this.container.style.position="relative"}this.container.innerHTML=['<',"/canvas>"].join("");this.canvasRoot=document.getElementById(this.canvasId);this.context=this.canvasRoot.getContext("2d");this.dashArray=[[2,2],[5,5],[10,10],[20,20],[20,10,10,10],[20,5,10,5]]};JXG.CanvasRenderer.prototype=new JXG.AbstractRenderer();JXG.extend(JXG.CanvasRenderer.prototype,{_drawFilledPolygon:function(f){var h,e=f.length,g=this.context;if(e>0){g.beginPath();g.moveTo(f[0][0],f[0][1]);for(h=0;h0){g.lineTo(f[h][0],f[h][1])}}g.lineTo(f[0][0],f[0][1]);g.fill()}},_fill:function(f){var e=this.context;e.save();if(this._setColor(f,"fill")){e.fill()}e.restore()},_rotatePoint:function(f,e,g){return[(e*Math.cos(f))-(g*Math.sin(f)),(e*Math.sin(f))+(g*Math.cos(f))]},_rotateShape:function(f,h){var g,j=[],e=f.length;if(e<=0){return f}for(g=0;g0)?g:0;if(i.length!=9){m=i;l=g}else{p=JXG.rgba2rgbo(i);m=p[0];l=g*p[1]}this.context.globalAlpha=l;this.context[e+"Style"]=m}else{k=false}if(n==="stroke"){this.context.lineWidth=parseFloat(q.strokewidth)}return k},_stroke:function(f){var e=this.context;e.save();if(f.visProp.dash>0){if(e.setLineDash){e.setLineDash(this.dashArray[f.visProp.dash])}}else{this.context.lineDashArray=[]}if(this._setColor(f,"stroke")){e.stroke()}e.restore()},_translateShape:function(g,f,k){var h,j=[],e=g.length;if(e<=0){return g}for(h=0;h":h.beginPath();h.moveTo(m[1]-i,m[2]);h.lineTo(m[1],m[2]+i);h.lineTo(m[1]+i,m[2]);h.lineTo(m[1],m[2]-i);h.closePath();this._fill(j);this._stroke(j);break;case"triangleup":case"a":case"^":h.beginPath();h.moveTo(m[1],m[2]-i);h.lineTo(m[1]-l,m[2]+e);h.lineTo(m[1]+l,m[2]+e);h.closePath();this._fill(j);this._stroke(j);break;case"triangledown":case"v":h.beginPath();h.moveTo(m[1],m[2]+i);h.lineTo(m[1]-l,m[2]-e);h.lineTo(m[1]+l,m[2]-e);h.closePath();this._fill(j);this._stroke(j);break;case"triangleleft":case"<":h.beginPath();h.moveTo(m[1]-i,m[2]);h.lineTo(m[1]+e,m[2]-l);h.lineTo(m[1]+e,m[2]+l);h.closePath();this.fill(j);this._stroke(j);break;case"triangleright":case">":h.beginPath();h.moveTo(m[1]+i,m[2]);h.lineTo(m[1]-e,m[2]-l);h.lineTo(m[1]-e,m[2]+l);h.closePath();this._fill(j);this._stroke(j);break}},updatePoint:function(e){this.drawPoint(e)},drawLine:function(e){var g=new JXG.Coords(JXG.COORDS_BY_USER,e.point1.coords.usrCoords,e.board),f=new JXG.Coords(JXG.COORDS_BY_USER,e.point2.coords.usrCoords,e.board);JXG.Math.Geometry.calcStraight(e,g,f);this.context.beginPath();this.context.moveTo(g.scrCoords[1],g.scrCoords[2]);this.context.lineTo(f.scrCoords[1],f.scrCoords[2]);this._stroke(e);this.makeArrows(e,g,f)},updateLine:function(e){this.drawLine(e)},drawTicks:function(){},updateTicks:function(h,j,f,k,g){var l,n,m=h.ticks.length,e=this.context;e.beginPath();for(l=0;l0&&t>0&&!isNaN(f+e)){h.beginPath();h.moveTo(j,k);h.bezierCurveTo(j,k-s,l-v,i,l,i);h.bezierCurveTo(l+v,i,q,k-s,q,k);h.bezierCurveTo(q,k+s,l+v,p,l,p);h.bezierCurveTo(l-v,p,j,k+s,j,k);h.closePath();this._fill(g);this._stroke(g)}},updateEllipse:function(e){return this.drawEllipse(e)},displayCopyright:function(g,f){var e=this.context;e.save();e.font=f+"px Arial";e.fillStyle="#aaa";e.lineWidth=0.5;e.fillText(g,10,2+f);e.restore()},drawInternalText:function(g){var e,f=this.context;f.save();if(this._setColor(g,"stroke","fill")&&!isNaN(g.coords.scrCoords[1]+g.coords.scrCoords[2])){if(g.visProp.fontsize){if(typeof g.visProp.fontsize==="function"){e=g.visProp.fontsize();f.font=(e>0?e:0)+"px Arial"}else{f.font=(g.visProp.fontsize)+"px Arial"}}this.transformImage(g,g.transformations);f.fillText(g.plaintext,g.coords.scrCoords[1],g.coords.scrCoords[2])}f.restore();return null},updateInternalText:function(e){this.drawInternalText(e)},setObjectStrokeColor:function(f,i,j){var h=JXG.evaluate(i),l,m,e=JXG.evaluate(j),k,g;e=(e>0)?e:0;if(f.visPropOld.strokecolor===h&&f.visPropOld.strokeopacity===e){return}if(JXG.exists(h)&&h!==false){if(h.length!=9){l=h;k=e}else{m=JXG.rgba2rgbo(h);l=m[0];k=e*m[1]}g=f.rendNode;if(f.type===JXG.OBJECT_TYPE_TEXT&&f.visProp.display==="html"){g.style.color=l;g.style.opacity=k}}f.visPropOld.strokecolor=h;f.visPropOld.strokeopacity=e},drawImage:function(e){e.rendNode=new Image();e._src="";this.updateImage(e)},updateImage:function(f){var e=this.context,g=JXG.evaluate(f.visProp.fillopacity),h=JXG.bind(function(){f.imgIsLoaded=true;if(f.size[0]<=0||f.size[1]<=0){return}e.save();e.globalAlpha=g;this.transformImage(f,f.transformations);e.drawImage(f.rendNode,f.coords.scrCoords[1],f.coords.scrCoords[2]-f.size[1],f.size[0],f.size[1]);e.restore()},this);if(this.updateImageURL(f)){f.rendNode.onload=h}else{if(f.imgIsLoaded){h()}}},transformImage:function(i,h){var f,e=h.length,g=this.context;if(e>0){f=this.joinTransforms(i,h);if(Math.abs(JXG.Math.Numerics.det(f))>=JXG.Math.eps){g.transform(f[1][1],f[2][1],f[1][2],f[2][2],f[1][0],f[2][0])}}},updateImageURL:function(f){var e;e=JXG.evaluate(f.url);if(f._src!==e){f.imgIsLoaded=false;f.rendNode.src=e;f._src=e;return true}return false},remove:function(e){if(JXG.exists(e)&&JXG.exists(e.parentNode)){e.parentNode.removeChild(e)}},makeArrows:function(i,m,k){var g=[[2,0],[-10,-4],[-10,4]],o=[[-2,0],[10,-4],[10,4]],h,n,e,l,j,f=this.context;if(i.visProp.strokecolor!=="none"&&(i.visProp.lastarrow||i.visProp.firstarrow)){if(i.elementClass===JXG.OBJECT_CLASS_LINE){h=m.scrCoords[1];n=m.scrCoords[2];e=k.scrCoords[1];l=k.scrCoords[2]}else{return}f.save();if(this._setColor(i,"stroke","fill")){j=Math.atan2(l-n,e-h);if(i.visProp.lastarrow){this._drawFilledPolygon(this._translateShape(this._rotateShape(g,j),e,l))}if(i.visProp.firstarrow){this._drawFilledPolygon(this._translateShape(this._rotateShape(o,j),h,n))}}f.restore()}},updatePathStringPrim:function(f){var h="M",j="L",g=h,n=5000,k,m,o=(f.visProp.curvetype!=="plot"),l,e=this.context;if(f.numberPoints<=0){return}if(o&&f.board.options.curve.RDPsmoothing){f.points=JXG.Math.Numerics.RamerDouglasPeuker(f.points,0.5)}l=Math.min(f.points.length,f.numberPoints);e.beginPath();for(k=0;kn){m[1]=n}else{if(m[1]<-n){m[1]=-n}}if(m[2]>n){m[2]=n}else{if(m[2]<-n){m[2]=-n}}if(g===h){e.moveTo(m[1],m[2])}else{e.lineTo(m[1],m[2])}g=j}}this._fill(f);this._stroke(f)},updatePathStringBezierPrim:function(h){var m="M",n="C",l=m,u=5000,p,o,s,k,g,r=h.visProp.strokewidth,t=(h.visProp.curvetype!=="plot"),q,e=this.context;if(h.numberPoints<=0){return}if(t&&h.board.options.curve.RDPsmoothing){h.points=JXG.Math.Numerics.RamerDouglasPeuker(h.points,0.5)}q=Math.min(h.points.length,h.numberPoints);e.beginPath();for(o=1;o<3;o++){l=m;for(p=0;pu){s[1]=u}else{if(s[1]<-u){s[1]=-u}}if(s[2]>u){s[2]=u}else{if(s[2]<-u){s[2]=-u}}if(l==m){e.moveTo(s[1]+0*r*(2*o*Math.random()-o),s[2]+0*r*(2*o*Math.random()-o))}else{e.bezierCurveTo((k+(s[1]-k)*0.333+r*(2*o*Math.random()-o)),(g+(s[2]-g)*0.333+r*(2*o*Math.random()-o)),(k+2*(s[1]-k)*0.333+r*(2*o*Math.random()-o)),(g+2*(s[2]-g)*0.333+r*(2*o*Math.random()-o)),s[1],s[2])}l=n;k=s[1];g=s[2]}}}this._fill(h);this._stroke(h)},updatePolygonPrim:function(k,j){var f,h,e=j.vertices.length,g=this.context;if(e<=0){return}g.beginPath();f=j.vertices[0].coords.scrCoords;g.moveTo(f[1],f[2]);for(h=1;h0)?g:0;e=JXG.evaluate(f.visProp.fillcolor)},setShadow:function(e){if(e.visPropOld.shadow===e.visProp.shadow){return}e.visPropOld.shadow=e.visProp.shadow},highlight:function(e){e.board.prepareUpdate();e.board.renderer.suspendRedraw(e.board);e.board.updateRenderer();e.board.renderer.unsuspendRedraw();return this},noHighlight:function(e){e.board.prepareUpdate();e.board.renderer.suspendRedraw(e.board);e.board.updateRenderer();e.board.renderer.unsuspendRedraw();return this},suspendRedraw:function(e){this.context.save();this.context.clearRect(0,0,this.canvasRoot.width,this.canvasRoot.height);if(e&&e.showCopyright){this.displayCopyright(JXG.JSXGraph.licenseText,12)}},unsuspendRedraw:function(){this.context.restore()},resize:function(e,f){this.canvasRoot.style.width=parseFloat(e)+"px";this.canvasRoot.style.height=parseFloat(f)+"px";this.canvasRoot.setAttribute("width",parseFloat(e)+"px");this.canvasRoot.setAttribute("height",parseFloat(f)+"px")}}); \ No newline at end of file diff --git a/ajax/libs/jsxgraph/package.json b/ajax/libs/jsxgraph/package.json index beb9f7bc0..b783a4621 100644 --- a/ajax/libs/jsxgraph/package.json +++ b/ajax/libs/jsxgraph/package.json @@ -1,7 +1,7 @@ { "name": "jsxgraph", "filename": "jsxgraphcore.js", - "version": "0.93", + "version": "0.94", "description": "JSXGraph is a cross-browser library for interactive geometry, function plotting, charting, and data visualization in a web browser.", "homepage": "http://jsxgraph.org/", "keywords": [ From f0368630e5aa30c3c915fb589e0819155aeb6360 Mon Sep 17 00:00:00 2001 From: alfred Date: Wed, 25 Apr 2012 16:11:56 +0200 Subject: [PATCH 2/3] * Replace the Reader files by their minified version * Remove directory "latest" --- ajax/libs/jsxgraph/0.94/GeogebraReader.js | 2800 ------------------- ajax/libs/jsxgraph/0.94/GeonextReader.js | 1124 -------- ajax/libs/jsxgraph/0.94/IntergeoReader.js | 967 ------- ajax/libs/jsxgraph/latest/GeogebraReader.js | 2800 ------------------- ajax/libs/jsxgraph/latest/GeonextReader.js | 1124 -------- ajax/libs/jsxgraph/latest/IntergeoReader.js | 967 ------- ajax/libs/jsxgraph/latest/jsxgraphcore.js | 26 - 7 files changed, 9808 deletions(-) delete mode 100644 ajax/libs/jsxgraph/0.94/GeogebraReader.js delete mode 100644 ajax/libs/jsxgraph/0.94/GeonextReader.js delete mode 100644 ajax/libs/jsxgraph/0.94/IntergeoReader.js delete mode 100644 ajax/libs/jsxgraph/latest/GeogebraReader.js delete mode 100644 ajax/libs/jsxgraph/latest/GeonextReader.js delete mode 100644 ajax/libs/jsxgraph/latest/IntergeoReader.js delete mode 100644 ajax/libs/jsxgraph/latest/jsxgraphcore.js diff --git a/ajax/libs/jsxgraph/0.94/GeogebraReader.js b/ajax/libs/jsxgraph/0.94/GeogebraReader.js deleted file mode 100644 index 4d8a0cc33..000000000 --- a/ajax/libs/jsxgraph/0.94/GeogebraReader.js +++ /dev/null @@ -1,2800 +0,0 @@ - JXG.GeogebraReader = new function() { -/** - * @param {String} type the type of expression - * @param {String} m first input value - * @param {String} n second input value - * @return {String} return the object, string or calculated value - */ -this.ggbAct = function(type, m, n) { - var v1 = m, v2 = n, s1, s2, a; - switch(type.toLowerCase()) { - case 'end': - // JXG.debug("end: "+ v1); - return v1; - break; - case 'coord': - s1 = (JXG.GeogebraReader.board.ggbElements[v1]) ? 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'")' : v1; - s2 = (JXG.GeogebraReader.board.ggbElements[v2]) ? 'JXG.getRef(JXG.GeogebraReader.board, "'+ v2 +'")' : v2; - return [s1, s2]; - break; - case 'le': // smaller then - return '( ('+ v1 +') <= ('+ v2 +') )'; - break; - case 'ge': // greater then - return '( ('+ v1 +') >= ('+ v2 +') )'; - break; - case 'eq': // equal - return '( ('+ v1 +') == ('+ v2 +') )'; - break; - case 'neq': // not equal - return '( ('+ v1 +') != ('+ v2 +') )'; - break; - case 'lt': // smaller - return '( ('+ v1 +') < ('+ v2 +') )'; - break; - case 'gt': // greater - return '( ('+ v1 +') > ('+ v2 +') )'; - break; - case 'add': - if (JXG.GeogebraReader.isGGBVector(v1) && JXG.GeogebraReader.isGGBVector(v2)){ //Add: Vector + Vector - return [1, v1[1] + '+' + v2[1], v1[2] + '+' + v2[2]]; - } - if( JXG.isString(v1) && !v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v1.match(/JXG\.getRef/) ) { - s1 = [v1+'.X()', v1+'.Y()']; - } else { - s1 = v1; - } - - if( JXG.isString(v2) && !v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v2.match(/JXG\.getRef/) ) { - s2 = [v2+'.X()', v2+'.Y()']; - } else { - s2 = v2; - } - - if (JXG.GeogebraReader.isGGBVector(s1) && JXG.isArray(s2)){ //Add: Vector + Point - return [s1[1] + '+' + s2[0], s1[2] + '+' + s2[1]]; - } - - if (JXG.GeogebraReader.isGGBVector(s2) && JXG.isArray(s1)){ //Add: Vector + Point - return [s2[1] + '+' + s1[0], s2[2] + '+' + s1[1]]; - } - - if( JXG.isArray(s1) && JXG.isArray(s2) ) { - return [ s1[0] +' + '+ s2[0], s1[1] +' + '+ s2[1] ]; - } - else if( (JXG.isNumber(s1) || JXG.isString(s1)) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { - return s1 +' + '+ s2; - } - else if( (JXG.isNumber(s1) || JXG.isString(s1)) && JXG.isArray(s2) ) { - return [ s1 +' + '+ s2[0], s1 +' + '+ s2[1] ]; - } - else if( JXG.isArray(s1) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { - return [ s1[0] +' + '+ s2, s1[1] +' + '+ s2 ]; - } - else { - return s1 +' + '+ s2; - } - break; - case 'sub': - if (JXG.GeogebraReader.isGGBVector(v1) && JXG.GeogebraReader.isGGBVector(v2)){ //Sub: Vector - Vector - return [1, v1[1] + '-' + v2[1], v1[2] + '-' + v2[2]]; - } - - if( JXG.isString(v1) && !v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v1.match(/JXG\.getRef/) ) { - s1 = [v1+'.X()', v1+'.Y()']; - } else { - s1 = v1; - } - - if( JXG.isString(v2) && !v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v2.match(/JXG\.getRef/) ) { - s2 = [v2+'.X()', v2+'.Y()']; - } else { - s2 = v2; - } - - if (JXG.GeogebraReader.isGGBVector(s1) && JXG.isArray(s2)){ //Add: Vector - Point - return [s1[1] + '-' + s2[0], s1[2] + '-' + s2[1]]; - } - - if (JXG.isArray(s1) && JXG.GeogebraReader.isGGBVector(s2)){ //Add: Punkt - Vector - return [s1[0] + '-(' + s2[1] + ')', s1[1] + '-(' + s2[2] +')']; - } - - if( JXG.isArray(s1) && JXG.isArray(s2) ) { - return [ s1[0] +' - '+ s2[0], s1[1] +' - '+ s2[1] ]; - } - else if( (JXG.isNumber(s1) || JXG.isString(s1)) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { - return s1 +' - '+ s2; - } - else if( (JXG.isNumber(s1) || JXG.isString(s1)) && JXG.isArray(s2) ) { - return [ s1 +' - '+ s2[0], s1 +' - '+ s2[1] ]; - } - else if( JXG.isArray(s1) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { - return [ s1[0] +' - '+ s2, s1[1] +' - '+ s2 ]; - } - else { - return s1 +' - '+ s2; - } - break; - case 'neg': - return '!('+ v1 +')'; - break; - case 'pow': - return 'Math.pow('+ v1 +', '+ v2 +')'; - break; - case 'or': - return '('+ v1 +'||'+ v2 +')'; - break; - case 'and': - return '('+ v1 +'&&'+ v2 +')'; - break; - case 'mul': - if (JXG.GeogebraReader.isGGBVector(v1) && !JXG.isArray(v2)){ // Mult: Vector * Skalar - return [1,'(' + v1[1] + ')*'+v2,'(' + v1[2] + ')*'+v2]; - } else if (!JXG.isArray(v1) && JXG.GeogebraReader.isGGBVector(v2)){ // Mult: Skalar * Vector - return new Array(1,'(' + v2[1] + ')*'+v1,'(' + v2[2] + ')*'+v1); - } else if (JXG.GeogebraReader.isGGBVector(v1) && JXG.GeogebraReader.isGGBVector(v2)){ //Mult: Vector * Vector - return '((' + v1[1] + ')*('+v2[1]+')+('+ v1[2] + ')*('+v2[2]+'))'; - } else { // Rest - if( JXG.isString(v1) && !v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v1.match(/JXG\.getRef/) ) { - s1 = [v1+'.X()', v1+'.Y()']; - } else { - s1 = v1; - } - - if( JXG.isString(v2) && !v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v2.match(/JXG\.getRef/) ) { - s2 = [v2+'.X()', v2+'.Y()']; - } else { - s2 = v2; - } - - if( JXG.isArray(s1) && JXG.isArray(s2) ) { - return [ s1[0] +' * '+ s2[0], s1[1] +' * '+ s2[1] ]; - } - else if( (JXG.isNumber(s1) || JXG.isString(s1)) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { - return s1 +' * '+ s2; - } - else if( (JXG.isNumber(s1) || JXG.isString(s1)) && JXG.isArray(s2) ) { - return [ s1 +' * '+ s2[0], s1 +' * '+ s2[1] ]; - } - else if( JXG.isArray(s1) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { - return [ s1[0] +' * '+ s2, s1[1] +' * '+ s2 ]; - } - else { - return s1 +' * '+ s2; - } - } - break; - case 'div': - if( JXG.isString(v1) && !v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v1.match(/JXG\.getRef/) ) { - s1 = [v1+'.X()', v1+'.Y()']; - } else { - s1 = v1; - } - - if( JXG.isString(v2) && !v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v2.match(/JXG\.getRef/) ) { - s2 = [v2+'.X()', v2+'.Y()']; - } else { - s2 = v2; - } - - if( JXG.isArray(s1) && JXG.isArray(s2) ) { - return [ s1[0] +' / '+ s2[0], s1[1] +' / '+ s2[1] ]; - } - else if( (JXG.isNumber(s1) || JXG.isString(s1)) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { - return s1 +' / '+ s2; - } - else if( (JXG.isNumber(s1) || JXG.isString(s1)) && JXG.isArray(s2) ) { - return [ s1 +' / '+ s2[0], s1 +' / '+ s2[1] ]; - } - else if( JXG.isArray(s1) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { - return [ s1[0] +' / '+ s2, s1[1] +' / '+ s2 ]; - } - else { - return s1 +' / '+ s2; - } - break; - case 'negmult': - if (JXG.GeogebraReader.isGGBVector(v1)) - return new Array(1, -1 + '*' + v1[1],-1 + '*' + v1[2]); - return -1 +'*'+ v1; - break; - case 'bra': - if (JXG.GeogebraReader.isGGBVector(v1)) - return new Array(1,'(' + v1[1] + ')','(' + v1[2] + ')'); - return '('+ v1 +')'; - break; - case 'int': - return parseInt(v1); - break; - case 'float': - return parseFloat(v1); - break; - case 'param': - return v1; - break; - case 'html': - return v1; - break; - case 'string': - if(v2) return [v1, v2]; - else return v1; - break; - case 'command': - v2 = v1.split('['); - s1 = v2[0]; - s2 = (v2[1].split(']'))[0]; - switch(s1.toLowerCase()) { - case 'name': - return 'JXG.getRef(JXG.GeogebraReader.board, "'+ s2 +'").getName()'; //TODO korrigiere getName() - break; - } - break; - case 'var': - if(v2) { - switch(v1.toLowerCase()) { - case 'x': - return v2 +'.X()'; - break; - case 'y': - return v2 +'.Y()'; - break; - case 'abs': - case 'acos': - case 'asin': - case 'atan': - case 'ceil': - case 'cos': - case 'exp': - case 'floor': - case 'log': - case 'max': - case 'min': - case 'pow': - case 'random': - case 'round': - case 'sin': - case 'sqrt': - case 'tan': - return 'Math.'+v1.toLowerCase()+'('+ v2 +')'; - break; - default: - return v1.toLowerCase()+'*('+ v2 +')'; - break; - } - } else { - - if(v1 == 'PI') { - return 'Math.PI'; - } else { - a = JXG.GeogebraReader.checkElement(v1); - if(typeof JXG.GeogebraReader.board.ggb[v1] != 'undefined') { - return 'JXG.GeogebraReader.board.ggb["'+ v1 +'"]()'; - } else if(typeof a.Value != 'undefined') { - return 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").Value()'; - } else if(typeof a.Area != 'undefined') { - return 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").Area()'; - } else if(typeof a.plaintextStr != 'undefined') { - return '1.0*JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").plaintextStr'; - } else if (a.type == JXG.OBJECT_TYPE_VECTOR){ - return new Array(1, 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point2.X()-JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point1.X()','JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point2.Y()-JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point1.Y()'); - }else if(a.elementClass == JXG.OBJECT_CLASS_LINE) { - return 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point1.Dist(JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point2)'; - } else { - return 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'")'; - } - } - } - break; - } -}; - -/** - * JS/CC parser to convert the input expression to a working javascript function. - * @param {Object} board object - * @param {Object} element Element that needs to be updated - * @param {String} exp String which contains the function, expression or information - */ -this.ggbParse = function(exp, element) { - var element = (element) ? JXG.getRef(JXG.GeogebraReader.board, JXG.GeogebraReader.board.ggbElements[element].id) : false; - if(element) JXG.debug("Zu aktualisierendes Element: "+ element.name + "("+ element.id +")"); - -/* - This parser was generated with: The LALR(1) parser and lexical analyzer generator for JavaScript, written in JavaScript - In the version 0.30 on http://jscc.jmksf.com/ - - It is based on the default template driver for JS/CC generated parsers running as - browser-based JavaScript/ECMAScript applications and was strongly modified. - - The parser was written 2007, 2008 by Jan Max Meyer, J.M.K S.F. Software Technologies - This is in the public domain. -*/ - -/***** begin replace *****/ - var _dbg_withtrace = false; - var _dbg_string = new String(); - - function __dbg_print( text ) { - _dbg_string += text + "\n"; - } - - function __lex( info ) { - var state = 0; - var match = -1; - var match_pos = 0; - var start = 0; - var pos = info.offset + 1; - - do - { - pos--; - state = 0; - match = -2; - start = pos; - - if( info.src.length <= start ) - return 28; - - do - { - - switch( state ) - { - case 0: - if( info.src.charCodeAt( pos ) == 9 || info.src.charCodeAt( pos ) == 32 ) state = 1; - else if( info.src.charCodeAt( pos ) == 33 ) state = 2; - else if( info.src.charCodeAt( pos ) == 40 ) state = 3; - else if( info.src.charCodeAt( pos ) == 41 ) state = 4; - else if( info.src.charCodeAt( pos ) == 42 ) state = 5; - else if( info.src.charCodeAt( pos ) == 43 ) state = 6; - else if( info.src.charCodeAt( pos ) == 44 ) state = 7; - else if( info.src.charCodeAt( pos ) == 45 ) state = 8; - else if( info.src.charCodeAt( pos ) == 47 ) state = 9; - else if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 10; - else if( info.src.charCodeAt( pos ) == 60 ) state = 11; - else if( info.src.charCodeAt( pos ) == 62 ) state = 12; - else if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 13; - else if( info.src.charCodeAt( pos ) == 94 ) state = 14; - else if( info.src.charCodeAt( pos ) == 34 ) state = 26; - else if( info.src.charCodeAt( pos ) == 38 ) state = 28; - else if( info.src.charCodeAt( pos ) == 46 ) state = 29; - else if( info.src.charCodeAt( pos ) == 61 ) state = 30; - else if( info.src.charCodeAt( pos ) == 95 ) state = 31; - else if( info.src.charCodeAt( pos ) == 124 ) state = 32; - else state = -1; - break; - - case 1: - state = -1; - match = 1; - match_pos = pos; - break; - - case 2: - if( info.src.charCodeAt( pos ) == 61 ) state = 15; - else state = -1; - match = 23; - match_pos = pos; - break; - - case 3: - state = -1; - match = 2; - match_pos = pos; - break; - - case 4: - state = -1; - match = 3; - match_pos = pos; - break; - - case 5: - state = -1; - match = 13; - match_pos = pos; - break; - - case 6: - state = -1; - match = 11; - match_pos = pos; - break; - - case 7: - state = -1; - match = 16; - match_pos = pos; - break; - - case 8: - state = -1; - match = 12; - match_pos = pos; - break; - - case 9: - state = -1; - match = 14; - match_pos = pos; - break; - - case 10: - if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 10; - else if( info.src.charCodeAt( pos ) == 46 ) state = 18; - else state = -1; - match = 4; - match_pos = pos; - break; - - case 11: - if( info.src.charCodeAt( pos ) == 61 ) state = 19; - else state = -1; - match = 21; - match_pos = pos; - break; - - case 12: - if( info.src.charCodeAt( pos ) == 61 ) state = 21; - else state = -1; - match = 22; - match_pos = pos; - break; - - case 13: - if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 13; - else if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 27; - else if( info.src.charCodeAt( pos ) == 91 ) state = 34; - else if( info.src.charCodeAt( pos ) == 95 ) state = 35; - else state = -1; - match = 7; - match_pos = pos; - break; - - case 14: - state = -1; - match = 15; - match_pos = pos; - break; - - case 15: - state = -1; - match = 20; - match_pos = pos; - break; - - case 16: - state = -1; - match = 9; - match_pos = pos; - break; - - case 17: - state = -1; - match = 25; - match_pos = pos; - break; - - case 18: - if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 18; - else state = -1; - match = 5; - match_pos = pos; - break; - - case 19: - state = -1; - match = 17; - match_pos = pos; - break; - - case 20: - state = -1; - match = 19; - match_pos = pos; - break; - - case 21: - state = -1; - match = 18; - match_pos = pos; - break; - - case 22: - state = -1; - match = 24; - match_pos = pos; - break; - - case 23: - state = -1; - match = 8; - match_pos = pos; - break; - - case 24: - if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 24; - else state = -1; - match = 6; - match_pos = pos; - break; - - case 25: - state = -1; - match = 10; - match_pos = pos; - break; - - case 26: - if( info.src.charCodeAt( pos ) == 34 ) state = 16; - else if( info.src.charCodeAt( pos ) == 32 || info.src.charCodeAt( pos ) == 46 || ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || info.src.charCodeAt( pos ) == 61 || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) || info.src.charCodeAt( pos ) == 223 || info.src.charCodeAt( pos ) == 228 || info.src.charCodeAt( pos ) == 246 || info.src.charCodeAt( pos ) == 252 ) state = 26; - else state = -1; - break; - - case 27: - if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 27; - else if( info.src.charCodeAt( pos ) == 95 ) state = 35; - else state = -1; - match = 7; - match_pos = pos; - break; - - case 28: - if( info.src.charCodeAt( pos ) == 38 ) state = 17; - else if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 33; - else state = -1; - break; - - case 29: - if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 18; - else state = -1; - break; - - case 30: - if( info.src.charCodeAt( pos ) == 61 ) state = 20; - else state = -1; - break; - - case 31: - if( info.src.charCodeAt( pos ) == 95 ) state = 36; - else state = -1; - break; - - case 32: - if( info.src.charCodeAt( pos ) == 124 ) state = 22; - else state = -1; - break; - - case 33: - if( info.src.charCodeAt( pos ) == 59 ) state = 23; - else if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 33; - else state = -1; - break; - - case 34: - if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 37; - else state = -1; - break; - - case 35: - if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 27; - else if( info.src.charCodeAt( pos ) == 95 ) state = 35; - else state = -1; - break; - - case 36: - if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 24; - else state = -1; - break; - - case 37: - if( info.src.charCodeAt( pos ) == 93 ) state = 25; - else if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 37; - else state = -1; - break; - - } - - - pos++; - - } - while( state > -1 ); - - } - while( 1 > -1 && match == 1 ); - - if( match > -1 ) - { - info.att = info.src.substr( start, match_pos - start ); - info.offset = match_pos; - - - } - else - { - info.att = new String(); - match = -1; - } - - return match; - } - - - function __parse( src, err_off, err_la ) { - var sstack = new Array(); - var vstack = new Array(); - var err_cnt = 0; - var act; - var go; - var la; - var rval; - var parseinfo = new Function( "", "var offset; var src; var att;" ); - var info = new parseinfo(); - - /* Pop-Table */ - var pop_tab = new Array( - new Array( 0/* p' */, 1 ), - new Array( 27/* p */, 1 ), - new Array( 26/* e */, 5 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 2 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 2 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 1 ), - new Array( 26/* e */, 1 ), - new Array( 26/* e */, 1 ), - new Array( 26/* e */, 1 ), - new Array( 26/* e */, 1 ), - new Array( 26/* e */, 1 ), - new Array( 26/* e */, 4 ), - new Array( 26/* e */, 1 ) - ); - - /* Action-Table */ - var act_tab = new Array( - /* State 0 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 1 */ new Array( 28/* "$" */,0 ), - /* State 2 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,18 , 11/* "+" */,19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-1 ), - /* State 3 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 4 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 5 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 6 */ new Array( 11/* "+" */,29 , 28/* "$" */,-24 , 17/* "<=" */,-24 , 18/* ">=" */,-24 , 19/* "==" */,-24 , 20/* "!=" */,-24 , 21/* "<" */,-24 , 22/* ">" */,-24 , 12/* "-" */,-24 , 15/* "^" */,-24 , 24/* "||" */,-24 , 25/* "&&" */,-24 , 13/* "*" */,-24 , 14/* "/" */,-24 , 16/* "," */,-24 , 3/* ")" */,-24 ), - /* State 7 */ new Array( 28/* "$" */,-20 , 17/* "<=" */,-20 , 18/* ">=" */,-20 , 19/* "==" */,-20 , 20/* "!=" */,-20 , 21/* "<" */,-20 , 22/* ">" */,-20 , 11/* "+" */,-20 , 12/* "-" */,-20 , 15/* "^" */,-20 , 24/* "||" */,-20 , 25/* "&&" */,-20 , 13/* "*" */,-20 , 14/* "/" */,-20 , 16/* "," */,-20 , 3/* ")" */,-20 ), - /* State 8 */ new Array( 28/* "$" */,-21 , 17/* "<=" */,-21 , 18/* ">=" */,-21 , 19/* "==" */,-21 , 20/* "!=" */,-21 , 21/* "<" */,-21 , 22/* ">" */,-21 , 11/* "+" */,-21 , 12/* "-" */,-21 , 15/* "^" */,-21 , 24/* "||" */,-21 , 25/* "&&" */,-21 , 13/* "*" */,-21 , 14/* "/" */,-21 , 16/* "," */,-21 , 3/* ")" */,-21 ), - /* State 9 */ new Array( 28/* "$" */,-22 , 17/* "<=" */,-22 , 18/* ">=" */,-22 , 19/* "==" */,-22 , 20/* "!=" */,-22 , 21/* "<" */,-22 , 22/* ">" */,-22 , 11/* "+" */,-22 , 12/* "-" */,-22 , 15/* "^" */,-22 , 24/* "||" */,-22 , 25/* "&&" */,-22 , 13/* "*" */,-22 , 14/* "/" */,-22 , 16/* "," */,-22 , 3/* ")" */,-22 ), - /* State 10 */ new Array( 28/* "$" */,-23 , 17/* "<=" */,-23 , 18/* ">=" */,-23 , 19/* "==" */,-23 , 20/* "!=" */,-23 , 21/* "<" */,-23 , 22/* ">" */,-23 , 11/* "+" */,-23 , 12/* "-" */,-23 , 15/* "^" */,-23 , 24/* "||" */,-23 , 25/* "&&" */,-23 , 13/* "*" */,-23 , 14/* "/" */,-23 , 16/* "," */,-23 , 3/* ")" */,-23 ), - /* State 11 */ new Array( 28/* "$" */,-25 , 17/* "<=" */,-25 , 18/* ">=" */,-25 , 19/* "==" */,-25 , 20/* "!=" */,-25 , 21/* "<" */,-25 , 22/* ">" */,-25 , 11/* "+" */,-25 , 12/* "-" */,-25 , 15/* "^" */,-25 , 24/* "||" */,-25 , 25/* "&&" */,-25 , 13/* "*" */,-25 , 14/* "/" */,-25 , 16/* "," */,-25 , 3/* ")" */,-25 ), - /* State 12 */ new Array( 2/* "(" */,30 , 28/* "$" */,-27 , 17/* "<=" */,-27 , 18/* ">=" */,-27 , 19/* "==" */,-27 , 20/* "!=" */,-27 , 21/* "<" */,-27 , 22/* ">" */,-27 , 11/* "+" */,-27 , 12/* "-" */,-27 , 15/* "^" */,-27 , 24/* "||" */,-27 , 25/* "&&" */,-27 , 13/* "*" */,-27 , 14/* "/" */,-27 , 16/* "," */,-27 , 3/* ")" */,-27 ), - /* State 13 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 14 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 15 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 16 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 17 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 18 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 19 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 20 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 21 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 22 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 23 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 24 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 25 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 26 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,18 , 11/* "+" */,19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 16/* "," */,44 , 3/* ")" */,45 ), - /* State 27 */ new Array( 14/* "/" */,-11 , 13/* "*" */,-11 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-11 , 12/* "-" */,-11 , 11/* "+" */,-11 , 22/* ">" */,-11 , 21/* "<" */,-11 , 20/* "!=" */,-11 , 19/* "==" */,-11 , 18/* ">=" */,-11 , 17/* "<=" */,-11 , 28/* "$" */,-11 , 16/* "," */,-11 , 3/* ")" */,-11 ), - /* State 28 */ new Array( 14/* "/" */,-17 , 13/* "*" */,-17 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-17 , 11/* "+" */,-17 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-17 , 16/* "," */,-17 , 3/* ")" */,-17 ), - /* State 29 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 30 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 31 */ new Array( 14/* "/" */,-16 , 13/* "*" */,-16 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-16 , 11/* "+" */,-16 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-16 , 16/* "," */,-16 , 3/* ")" */,-16 ), - /* State 32 */ new Array( 14/* "/" */,-15 , 13/* "*" */,-15 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-15 , 11/* "+" */,-15 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-15 , 16/* "," */,-15 , 3/* ")" */,-15 ), - /* State 33 */ new Array( 14/* "/" */,-14 , 13/* "*" */,-14 , 25/* "&&" */,-14 , 24/* "||" */,-14 , 15/* "^" */,-14 , 12/* "-" */,-14 , 11/* "+" */,-14 , 22/* ">" */,-14 , 21/* "<" */,-14 , 20/* "!=" */,-14 , 19/* "==" */,-14 , 18/* ">=" */,-14 , 17/* "<=" */,-14 , 28/* "$" */,-14 , 16/* "," */,-14 , 3/* ")" */,-14 ), - /* State 34 */ new Array( 14/* "/" */,-13 , 13/* "*" */,-13 , 25/* "&&" */,-13 , 24/* "||" */,-13 , 15/* "^" */,-13 , 12/* "-" */,-13 , 11/* "+" */,-13 , 22/* ">" */,-13 , 21/* "<" */,-13 , 20/* "!=" */,-13 , 19/* "==" */,-13 , 18/* ">=" */,-13 , 17/* "<=" */,-13 , 28/* "$" */,-13 , 16/* "," */,-13 , 3/* ")" */,-13 ), - /* State 35 */ new Array( 14/* "/" */,-12 , 13/* "*" */,-12 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-12 , 12/* "-" */,-12 , 11/* "+" */,-12 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-12 , 16/* "," */,-12 , 3/* ")" */,-12 ), - /* State 36 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-10 , 11/* "+" */,-10 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-10 , 16/* "," */,-10 , 3/* ")" */,-10 ), - /* State 37 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-9 , 11/* "+" */,-9 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-9 , 16/* "," */,-9 , 3/* ")" */,-9 ), - /* State 38 */ new Array( 14/* "/" */,-8 , 13/* "*" */,-8 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-8 , 12/* "-" */,-8 , 11/* "+" */,-8 , 22/* ">" */,-8 , 21/* "<" */,-8 , 20/* "!=" */,-8 , 19/* "==" */,-8 , 18/* ">=" */,-8 , 17/* "<=" */,-8 , 28/* "$" */,-8 , 16/* "," */,-8 , 3/* ")" */,-8 ), - /* State 39 */ new Array( 14/* "/" */,-7 , 13/* "*" */,-7 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-7 , 12/* "-" */,-7 , 11/* "+" */,-7 , 22/* ">" */,-7 , 21/* "<" */,-7 , 20/* "!=" */,-7 , 19/* "==" */,-7 , 18/* ">=" */,-7 , 17/* "<=" */,-7 , 28/* "$" */,-7 , 16/* "," */,-7 , 3/* ")" */,-7 ), - /* State 40 */ new Array( 14/* "/" */,-6 , 13/* "*" */,-6 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-6 , 12/* "-" */,-6 , 11/* "+" */,-6 , 22/* ">" */,-6 , 21/* "<" */,-6 , 20/* "!=" */,-6 , 19/* "==" */,-6 , 18/* ">=" */,-6 , 17/* "<=" */,-6 , 28/* "$" */,-6 , 16/* "," */,-6 , 3/* ")" */,-6 ), - /* State 41 */ new Array( 14/* "/" */,-5 , 13/* "*" */,-5 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-5 , 12/* "-" */,-5 , 11/* "+" */,-5 , 22/* ">" */,-5 , 21/* "<" */,-5 , 20/* "!=" */,-5 , 19/* "==" */,-5 , 18/* ">=" */,-5 , 17/* "<=" */,-5 , 28/* "$" */,-5 , 16/* "," */,-5 , 3/* ")" */,-5 ), - /* State 42 */ new Array( 14/* "/" */,-4 , 13/* "*" */,-4 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-4 , 12/* "-" */,-4 , 11/* "+" */,-4 , 22/* ">" */,-4 , 21/* "<" */,-4 , 20/* "!=" */,-4 , 19/* "==" */,-4 , 18/* ">=" */,-4 , 17/* "<=" */,-4 , 28/* "$" */,-4 , 16/* "," */,-4 , 3/* ")" */,-4 ), - /* State 43 */ new Array( 14/* "/" */,-3 , 13/* "*" */,-3 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-3 , 12/* "-" */,-3 , 11/* "+" */,-3 , 22/* ">" */,-3 , 21/* "<" */,-3 , 20/* "!=" */,-3 , 19/* "==" */,-3 , 18/* ">=" */,-3 , 17/* "<=" */,-3 , 28/* "$" */,-3 , 16/* "," */,-3 , 3/* ")" */,-3 ), - /* State 44 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 45 */ new Array( 28/* "$" */,-18 , 17/* "<=" */,-18 , 18/* ">=" */,-18 , 19/* "==" */,-18 , 20/* "!=" */,-18 , 21/* "<" */,-18 , 22/* ">" */,-18 , 11/* "+" */,-18 , 12/* "-" */,-18 , 15/* "^" */,-18 , 24/* "||" */,-18 , 25/* "&&" */,-18 , 13/* "*" */,-18 , 14/* "/" */,-18 , 16/* "," */,-18 , 3/* ")" */,-18 ), - /* State 46 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-19 , 11/* "+" */,-19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-19 , 16/* "," */,-19 , 3/* ")" */,-19 ), - /* State 47 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,18 , 11/* "+" */,19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 3/* ")" */,49 ), - /* State 48 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,18 , 11/* "+" */,19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 3/* ")" */,50 ), - /* State 49 */ new Array( 28/* "$" */,-26 , 17/* "<=" */,-26 , 18/* ">=" */,-26 , 19/* "==" */,-26 , 20/* "!=" */,-26 , 21/* "<" */,-26 , 22/* ">" */,-26 , 11/* "+" */,-26 , 12/* "-" */,-26 , 15/* "^" */,-26 , 24/* "||" */,-26 , 25/* "&&" */,-26 , 13/* "*" */,-26 , 14/* "/" */,-26 , 16/* "," */,-26 , 3/* ")" */,-26 ), - /* State 50 */ new Array( 28/* "$" */,-2 , 17/* "<=" */,-2 , 18/* ">=" */,-2 , 19/* "==" */,-2 , 20/* "!=" */,-2 , 21/* "<" */,-2 , 22/* ">" */,-2 , 11/* "+" */,-2 , 12/* "-" */,-2 , 15/* "^" */,-2 , 24/* "||" */,-2 , 25/* "&&" */,-2 , 13/* "*" */,-2 , 14/* "/" */,-2 , 16/* "," */,-2 , 3/* ")" */,-2 ) - ); - - /* Goto-Table */ - var goto_tab = new Array( - /* State 0 */ new Array( 27/* p */,1 , 26/* e */,2 ), - /* State 1 */ new Array( ), - /* State 2 */ new Array( ), - /* State 3 */ new Array( 26/* e */,26 ), - /* State 4 */ new Array( 26/* e */,27 ), - /* State 5 */ new Array( 26/* e */,28 ), - /* State 6 */ new Array( ), - /* State 7 */ new Array( ), - /* State 8 */ new Array( ), - /* State 9 */ new Array( ), - /* State 10 */ new Array( ), - /* State 11 */ new Array( ), - /* State 12 */ new Array( ), - /* State 13 */ new Array( 26/* e */,31 ), - /* State 14 */ new Array( 26/* e */,32 ), - /* State 15 */ new Array( 26/* e */,33 ), - /* State 16 */ new Array( 26/* e */,34 ), - /* State 17 */ new Array( 26/* e */,35 ), - /* State 18 */ new Array( 26/* e */,36 ), - /* State 19 */ new Array( 26/* e */,37 ), - /* State 20 */ new Array( 26/* e */,38 ), - /* State 21 */ new Array( 26/* e */,39 ), - /* State 22 */ new Array( 26/* e */,40 ), - /* State 23 */ new Array( 26/* e */,41 ), - /* State 24 */ new Array( 26/* e */,42 ), - /* State 25 */ new Array( 26/* e */,43 ), - /* State 26 */ new Array( ), - /* State 27 */ new Array( ), - /* State 28 */ new Array( ), - /* State 29 */ new Array( 26/* e */,46 ), - /* State 30 */ new Array( 26/* e */,47 ), - /* State 31 */ new Array( ), - /* State 32 */ new Array( ), - /* State 33 */ new Array( ), - /* State 34 */ new Array( ), - /* State 35 */ new Array( ), - /* State 36 */ new Array( ), - /* State 37 */ new Array( ), - /* State 38 */ new Array( ), - /* State 39 */ new Array( ), - /* State 40 */ new Array( ), - /* State 41 */ new Array( ), - /* State 42 */ new Array( ), - /* State 43 */ new Array( ), - /* State 44 */ new Array( 26/* e */,48 ), - /* State 45 */ new Array( ), - /* State 46 */ new Array( ), - /* State 47 */ new Array( ), - /* State 48 */ new Array( ), - /* State 49 */ new Array( ), - /* State 50 */ new Array( ) - ); - - - - /* Symbol labels */ - var labels = new Array( - "p'" /* Non-terminal symbol */, - "WHITESPACE" /* Terminal symbol */, - "(" /* Terminal symbol */, - ")" /* Terminal symbol */, - "INT" /* Terminal symbol */, - "FLOAT" /* Terminal symbol */, - "PARAM" /* Terminal symbol */, - "VAR" /* Terminal symbol */, - "HTML" /* Terminal symbol */, - "STRING" /* Terminal symbol */, - "COMMAND" /* Terminal symbol */, - "+" /* Terminal symbol */, - "-" /* Terminal symbol */, - "*" /* Terminal symbol */, - "/" /* Terminal symbol */, - "^" /* Terminal symbol */, - "," /* Terminal symbol */, - "<=" /* Terminal symbol */, - ">=" /* Terminal symbol */, - "==" /* Terminal symbol */, - "!=" /* Terminal symbol */, - "<" /* Terminal symbol */, - ">" /* Terminal symbol */, - "!" /* Terminal symbol */, - "||" /* Terminal symbol */, - "&&" /* Terminal symbol */, - "e" /* Non-terminal symbol */, - "p" /* Non-terminal symbol */, - "$" /* Terminal symbol */ - ); - - - - info.offset = 0; - info.src = src; - info.att = new String(); - - if( !err_off ) - err_off = new Array(); - if( !err_la ) - err_la = new Array(); - - sstack.push( 0 ); - vstack.push( 0 ); - - la = __lex( info ); - - while( true ) - { - act = 52; - for( var i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 ) - { - if( act_tab[sstack[sstack.length-1]][i] == la ) - { - act = act_tab[sstack[sstack.length-1]][i+1]; - break; - } - } - - if( _dbg_withtrace && sstack.length > 0 ) - { - __dbg_print( "\nState " + sstack[sstack.length-1] + "\n" + - "\tLookahead: " + labels[la] + " (\"" + info.att + "\")\n" + - "\tAction: " + act + "\n" + - "\tSource: \"" + info.src.substr( info.offset, 30 ) + ( ( info.offset + 30 < info.src.length ) ? - "..." : "" ) + "\"\n" + - "\tStack: " + sstack.join() + "\n" + - "\tValue stack: " + vstack.join() + "\n" ); - } - - - //Panic-mode: Try recovery when parse-error occurs! - if( act == 52 ) - { - if( _dbg_withtrace ) - __dbg_print( "Error detected: There is no reduce or shift on the symbol " + labels[la] ); - - err_cnt++; - err_off.push( info.offset - info.att.length ); - err_la.push( new Array() ); - for( var i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 ) - err_la[err_la.length-1].push( labels[act_tab[sstack[sstack.length-1]][i]] ); - - //Remember the original stack! - var rsstack = new Array(); - var rvstack = new Array(); - for( var i = 0; i < sstack.length; i++ ) - { - rsstack[i] = sstack[i]; - rvstack[i] = vstack[i]; - } - - while( act == 52 && la != 28 ) - { - if( _dbg_withtrace ) - __dbg_print( "\tError recovery\n" + - "Current lookahead: " + labels[la] + " (" + info.att + ")\n" + - "Action: " + act + "\n\n" ); - if( la == -1 ) - info.offset++; - - while( act == 52 && sstack.length > 0 ) - { - sstack.pop(); - vstack.pop(); - - if( sstack.length == 0 ) - break; - - act = 52; - for( var i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 ) - { - if( act_tab[sstack[sstack.length-1]][i] == la ) - { - act = act_tab[sstack[sstack.length-1]][i+1]; - break; - } - } - } - - if( act != 52 ) - break; - - for( var i = 0; i < rsstack.length; i++ ) - { - sstack.push( rsstack[i] ); - vstack.push( rvstack[i] ); - } - - la = __lex( info ); - } - - if( act == 52 ) - { - if( _dbg_withtrace ) - __dbg_print( "\tError recovery failed, terminating parse process..." ); - break; - } - - - if( _dbg_withtrace ) - __dbg_print( "\tError recovery succeeded, continuing" ); - } - - /* - if( act == 52 ) - break; - */ - - - //Shift - if( act > 0 ) - { - if( _dbg_withtrace ) - __dbg_print( "Shifting symbol: " + labels[la] + " (" + info.att + ")" ); - - sstack.push( act ); - vstack.push( info.att ); - - la = __lex( info ); - - if( _dbg_withtrace ) - __dbg_print( "\tNew lookahead symbol: " + labels[la] + " (" + info.att + ")" ); - } - //Reduce - else - { - act *= -1; - - if( _dbg_withtrace ) - __dbg_print( "Reducing by producution: " + act ); - - rval = void(0); - - if( _dbg_withtrace ) - __dbg_print( "\tPerforming semantic action..." ); - - switch( act ) - { - case 0: - { - rval = vstack[ vstack.length - 1 ]; - } - break; - case 1: - { - rval = JXG.GeogebraReader.ggbAct('end', vstack[ vstack.length - 1 ]); - } - break; - case 2: - { - rval = JXG.GeogebraReader.ggbAct('coord', vstack[ vstack.length - 4 ], vstack[ vstack.length - 2 ], element); - } - break; - case 3: - { - rval = JXG.GeogebraReader.ggbAct('le', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 4: - { - rval = JXG.GeogebraReader.ggbAct('ge', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 5: - { - rval = JXG.GeogebraReader.ggbAct('eq', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 6: - { - rval = JXG.GeogebraReader.ggbAct('neq', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 7: - { - rval = JXG.GeogebraReader.ggbAct('lt', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 8: - { - rval = JXG.GeogebraReader.ggbAct('gt', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 9: - { - rval = JXG.GeogebraReader.ggbAct('add', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 10: - { - rval = JXG.GeogebraReader.ggbAct('sub', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 11: - { - rval = JXG.GeogebraReader.ggbAct('neg', vstack[ vstack.length - 1 ]); - } - break; - case 12: - { - rval = JXG.GeogebraReader.ggbAct('pow', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 13: - { - rval = JXG.GeogebraReader.ggbAct('or', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 14: - { - rval = JXG.GeogebraReader.ggbAct('and', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 15: - { - rval = JXG.GeogebraReader.ggbAct('mul', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 16: - { - rval = JXG.GeogebraReader.ggbAct('div', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 17: - { - rval = JXG.GeogebraReader.ggbAct('negmult', vstack[ vstack.length - 1 ]); - } - break; - case 18: - { - rval = JXG.GeogebraReader.ggbAct('bra', vstack[ vstack.length - 2 ]); - } - break; - case 19: - { - rval = JXG.GeogebraReader.ggbAct('string', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 20: - { - rval = JXG.GeogebraReader.ggbAct('int', vstack[ vstack.length - 1 ]); - } - break; - case 21: - { - rval = JXG.GeogebraReader.ggbAct('float', vstack[ vstack.length - 1 ]); - } - break; - case 22: - { - rval = JXG.GeogebraReader.ggbAct('param', vstack[ vstack.length - 1 ]); - } - break; - case 23: - { - rval = JXG.GeogebraReader.ggbAct('html', vstack[ vstack.length - 1 ]); - } - break; - case 24: - { - rval = JXG.GeogebraReader.ggbAct('string', vstack[ vstack.length - 1 ]); - } - break; - case 25: - { - rval = JXG.GeogebraReader.ggbAct('command', vstack[ vstack.length - 1 ]); - } - break; - case 26: - { - rval = JXG.GeogebraReader.ggbAct('var', vstack[ vstack.length - 4 ], vstack[ vstack.length - 2 ]); - } - break; - case 27: - { - rval = JXG.GeogebraReader.ggbAct('var', vstack[ vstack.length - 1 ]); - } - break; - } - - - - if( _dbg_withtrace ) - __dbg_print( "\tPopping " + pop_tab[act][1] + " off the stack..." ); - - for( var i = 0; i < pop_tab[act][1]; i++ ) - { - sstack.pop(); - str = vstack.pop(); - } - - go = -1; - for( var i = 0; i < goto_tab[sstack[sstack.length-1]].length; i+=2 ) - { - if( goto_tab[sstack[sstack.length-1]][i] == pop_tab[act][0] ) - { - go = goto_tab[sstack[sstack.length-1]][i+1]; - break; - } - } - - if( act == 0 ) - break; - - if( _dbg_withtrace ) - __dbg_print( "\tPushing non-terminal " + labels[ pop_tab[act][0] ] ); - - sstack.push( go ); - vstack.push( rval ); - } - - if( _dbg_withtrace ) - { - JXG.debug( _dbg_string ); - _dbg_string = new String(); - } - } - - if( _dbg_withtrace ) - { - __dbg_print( "\nParse complete." ); - JXG.debug( _dbg_string ); - } - - return err_cnt; - } -/***** end replace *****/ - - var error_offsets = new Array(); - var error_lookaheads = new Array(); - var error_count = 0; - var str = exp; - if( ( error_count = __parse( str, error_offsets, error_lookaheads ) ) > 0 ) { - var errstr = new String(); - for( var i = 0; i < error_count; i++ ) - errstr += "Parse error in line " + ( str.substr( 0, error_offsets[i] ).match( /\n/g ) ? - str.substr( 0, error_offsets[i] ).match( /\n/g ).length : 1 ) - + " near \"" + str.substr( error_offsets[i] ) + "\", expecting \"" + error_lookaheads[i].join() + "\"\n" ; - JXG.debug( errstr ); - } - - return str; -}; //end: ggbParse() - - -/** - * Override JSxGraph defaults with Geogebra settings - * @param {Object} board object - * @return {Object} board oject - */ -this.setDefaultOptions = function(board){ - board.options.elements.strokeWidth = '1px'; // TODO: board.options.line.strokeWidth - board.options.elements.withLabel = true; - - board.options.point.face = 'circle'; - board.options.point.size = 3; - board.options.point.fillColor = 'blue'; - board.options.point.fillOpacity = 1; - board.options.point.highlightFillOpacity = 1; - board.options.point.strokeColor = 'black'; - board.options.point.highlightStrokeColor = 'black'; - board.options.point.strokeWidth = '2px'; - - board.options.line.strokeWidth = '1px'; - board.options.line.highlightStrokeColor = '#000000'; - board.options.line.strokeColor = '#000000'; - - board.options.polygon.fillColor = JXG.rgb2hex(153, 51, 0); - board.options.polygon.fillOpacity = 0.1; - board.options.polygon.highlightFillColor = board.options.polygon.fillColor; - board.options.polygon.highlightFillOpacity = 0.1; - - board.options.sector.fillColor = JXG.rgb2hex(153, 51, 0); - board.options.sector.fillOpacity = 0.1; - board.options.sector.highlightFillColor = board.options.sector.fillColor; - board.options.sector.highlightFillOpacity = 0.1; - - board.options.angle.fillColor = JXG.rgb2hex(0, 100, 0); - board.options.angle.fillOpacity = 0.1; - //board.options.angle.highlightFillColor = board.options.angle.fillColor; - board.options.angle.highlightFillOpacity = 0.1; - - return board; -}; - -/** - * Set color properties of a geogebra element. - * Set stroke, fill, lighting, label and draft color attributes. - * @param {Object} gxtEl element of which attributes are to set - * @param {Object} attr object carrying all necessary attribute values - * @return {Object} returning the updated attr-attributes object - */ -this.colorProperties = function(Data, attr) { - var a,r,g,b; - a = (Data.getElementsByTagName("objColor").length > 0 && Data.getElementsByTagName("objColor")[0].getAttribute("alpha")) ? parseFloat(Data.getElementsByTagName("objColor")[0].getAttribute("alpha")) : 0; - r = (Data.getElementsByTagName("objColor").length > 0 && Data.getElementsByTagName("objColor")[0].getAttribute("r")) ? parseInt(Data.getElementsByTagName("objColor")[0].getAttribute("r")).toString(16) : 0; - g = (Data.getElementsByTagName("objColor").length > 0 && Data.getElementsByTagName("objColor")[0].getAttribute("g")) ? parseInt(Data.getElementsByTagName("objColor")[0].getAttribute("g")).toString(16) : 0; - b = (Data.getElementsByTagName("objColor").length > 0 && Data.getElementsByTagName("objColor")[0].getAttribute("b")) ? parseInt(Data.getElementsByTagName("objColor")[0].getAttribute("b")).toString(16) : 0; - if (r.length == 1) r = '0' + r; - if (g.length == 1) g = '0' + g; - if (b.length == 1) b = '0' + b; - - attr.fillColor = '#'+ r + g + b; - attr.strokeColor = attr.fillColor; - attr.highlightFillColor = attr.fillColor; - attr.highlightStrokeColor = attr.strokeColor; - attr.fillOpacity = a; - attr.highlightFillOpacity = a; - attr.labelColor = attr.fillColor; - - return attr; -}; - -/** - * Set the board properties. - * Set active, area, dash, draft and showinfo attributes. - * @param {Object} gxtEl element of which attributes are to set - * @param {Object} Data element of which attributes are to set - * @param {Object} attr object containing the necessary attribute values - */ -this.boardProperties = function(gxtEl, Data, attr) { - return attr; -}; - -/** - * @param {Object} gxtEl element of which attributes are to set - * @param {Object} Data element of which attributes are to set - * @return {Object} updated element - */ -this.coordinates = function(gxtEl, Data) { - var labelOffset = {}, tmp; - labelOffset.x = 0; labelOffset.y = 0; labelOffset.z = 0; - - if(Data.getElementsByTagName('labelOffset')[0]) { - // tmp = new JXG.Coords(JXG.COORDS_BY_SCREEN, [, - // parseFloat(Data.getElementsByTagName("labelOffset")[0].attributes["y"].value)], JXG.GeogebraReader.board); - labelOffset.x = parseFloat(Data.getElementsByTagName("labelOffset")[0].getAttribute("x"))/JXG.GeogebraReader.board.unitX; - labelOffset.y = parseFloat(Data.getElementsByTagName("labelOffset")[0].getAttribute("y"))/JXG.GeogebraReader.board.unitY; - } - - if(Data.getElementsByTagName("coords")[0]) { - gxtEl.x = parseFloat(Data.getElementsByTagName("coords")[0].getAttribute("x")); - gxtEl.y = parseFloat(Data.getElementsByTagName("coords")[0].getAttribute("y")); - gxtEl.z = parseFloat(Data.getElementsByTagName("coords")[0].getAttribute("z")); - } else if(Data.getElementsByTagName("startPoint")[0]) { - if(Data.getElementsByTagName("startPoint")[0].getAttribute('exp')) { - var a = JXG.getRef(JXG.GeogebraReader.board, Data.getElementsByTagName("startPoint")[0].getAttribute('exp')); - gxtEl.x = function() {return a.X()+labelOffset.x;}; - gxtEl.y = function() {return a.Y()-labelOffset.y;}; // minus because geogebra starts on the other side - gxtEl.z = false; - } else { - gxtEl.x = parseFloat(Data.getElementsByTagName("startPoint")[0].getAttribute("x")); - gxtEl.y = parseFloat(Data.getElementsByTagName("startPoint")[0].getAttribute("y")); - gxtEl.z = parseFloat(Data.getElementsByTagName("startPoint")[0].getAttribute("z")); - } - } else if(Data.getElementsByTagName("absoluteScreenLocation")[0]) { - var tmp = new JXG.Coords(JXG.COORDS_BY_SCREEN, [parseFloat(Data.getElementsByTagName("absoluteScreenLocation")[0].getAttribute("x")), - parseFloat(Data.getElementsByTagName("absoluteScreenLocation")[0].getAttribute("y"))], JXG.GeogebraReader.board); - gxtEl.x = tmp.usrCoords[1]+labelOffset.x; - gxtEl.y = tmp.usrCoords[2]+labelOffset.y; - gxtEl.z = false; - } else { - return false; - } - - return gxtEl; -}; - -/** - * Writing element attributes to the given object - * @param {XMLNode} Data expects the content of the current element - * @return {Object} object with according attributes - */ -this.visualProperties = function(Data, attr) { - (Data.getElementsByTagName("show").length != 0 && Data.getElementsByTagName("show")[0].getAttribute("object")) ? attr.visible = Data.getElementsByTagName("show")[0].getAttribute("object") : false; - (Data.getElementsByTagName("show").length != 0 && Data.getElementsByTagName("show")[0].getAttribute("label")) ? attr.withLabel = Data.getElementsByTagName("show")[0].getAttribute("label") : true; - if(attr.withLabel == 'true') { - attr.withLabel = true; - } - else if(attr.withLabel == 'false') { - attr.withLabel = false; - } - (Data.getElementsByTagName('pointSize')[0]) ? attr.size = Data.getElementsByTagName('pointSize')[0].getAttribute("val") : false; - (Data.getElementsByTagName('pointStyle')[0]) ? attr.styleGGB = Data.getElementsByTagName('pointStyle')[0].getAttribute("val") : false; - if(attr.styleGGB == 0 || attr.styleGGB == 2) { - attr.face = 'circle'; - if(attr.styleGGB == 0) { - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - attr.highlightFillColor = attr.strokeColor; - attr.highlightFillOpacity = 1; - attr.strokeColor = 'black'; - attr.strokeWidth = '1px'; - } - else if(attr.styleGGB == 2) { - attr.fillColor = 'none'; - } - } - else if(attr.styleGGB == 1) { - attr.face = 'x'; - } - else if(attr.styleGGB == 3) { - attr.face = '+'; - attr.strokeOpacity = 1; - } - else if(attr.styleGGB == 4 || attr.styleGGB == 5) { - attr.face = 'diamond'; - if(attr.styleGGB == 4) { - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - } - else if(attr.styleGGB == 5) { - attr.fillColor = 'none'; - } - } - else if(attr.styleGGB == 6) { - attr.face = 'triangleUp'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - } - else if(attr.styleGGB == 7) { - attr.face = 'triangleDown'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - } - else if(attr.styleGGB == 8) { - attr.face = 'triangleRight'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - } - else if(attr.styleGGB == 9) { - attr.face = 'triangleLeft'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - } - (Data.getElementsByTagName('slopeTriangleSize')[0]) ? attr.slopeWidth = Data.getElementsByTagName('slopeTriangleSize')[0].getAttribute("val") : false; - (Data.getElementsByTagName('lineStyle')[0]) ? attr.strokeWidth = (Data.getElementsByTagName('lineStyle')[0].getAttribute("thickness")/2.0)+'px' : false; - if(attr.strokeWidth) { - attr.highlightStrokeWidth = (1*attr.strokeWidth.substr(0,attr.strokeWidth.length-2)+1)+'px'; - } - (Data.getElementsByTagName('lineStyle')[0]) ? attr.dashGGB = Data.getElementsByTagName('lineStyle')[0].getAttribute("type") : false; - - if(attr.dashGGB == 0) { - attr.dash = 0; - } - else if(attr.dashGGB == 10) { - attr.dash = 2; - } - else if(attr.dashGGB == 15) { - attr.dash = 3; - } - else if(attr.dashGGB == 20) { - attr.dash = 1; - } - else if(attr.dashGGB == 30) { - attr.dash = 6; - } - (Data.getElementsByTagName("labelOffset")[0]) ? attr.labelX = 1*Data.getElementsByTagName("labelOffset")[0].getAttribute("x") : false; - (Data.getElementsByTagName("labelOffset")[0]) ? attr.labelY = 1*Data.getElementsByTagName("labelOffset")[0].getAttribute("y") : false; - (Data.getElementsByTagName("trace")[0]) ? attr.trace = Data.getElementsByTagName("trace")[0].getAttribute("val") : false; - (Data.getElementsByTagName('fix')[0]) ? attr.fixed = Data.getElementsByTagName('fix')[0].getAttribute("val") : false; - return attr; -}; - -/** - * Searching for an element in the geogebra tree - * @param {String} the name of the element to search for - * @param {Boolean} whether it is search for an expression or not - * @return {Object} object with according label - */ -this.getElement = function(name, expr) { - var Data, i, j; - expr = expr || false; - for(i=0; i -1 || s[i].search(/[0-9]+$/) > -1 || s[i].search(/[a-zA-Z]+(\_*[a-zA-Z0-9]+)*$/) > -1) - if(s[i+1].search(/^\(/) > -1 || - s[i+1].search(/^[0-9]+/) > -1 || - s[i+1].search(/^[a-zA-Z]+(\_*[a-zA-Z0-9]+)*/) > -1 || - s[i+1].search(/\_\_[a-zA-Z0-9]+/) > -1) { - s[i] = s[i] + "*"; - } - o += s[i]; - }; - expr = o; - } - - output.push(expr); - return output; - } else { - return exp; - } - break; - case 's': - exp = exp.replace(/(?![e])x(?!\()(?![p])/g, '__x'); - return ['__x', exp]; - break; - default: - if(JXG.GeogebraReader.format <= 3.01) { - // prepare string: "solve" multiplications 'a b' to 'a*b' - s = exp.split(' '); - o = ''; - for(i=0; i -1 || s[i].search(/[0-9]+$/) > -1 || s[i].search(/[a-zA-Z]+(\_*[a-zA-Z0-9]+)*$/) > -1) - if(s[i+1].search(/^\(/) > -1 || - s[i+1].search(/^[0-9]+/) > -1 || - s[i+1].search(/^[a-zA-Z]+(\_*[a-zA-Z0-9]+)*/) > -1 || - s[i+1].search(/\_\_[a-zA-Z0-9]+/) > -1) { - s[i] = s[i] + "*"; - } - o += s[i]; - }; - exp = o; - } - return exp; - break; - } -}; - -/** - * Searching for an element in the geogebra tree - * @param {Object} board object - */ -this.writeBoard = function(board) { - var boardData = JXG.GeogebraReader.tree.getElementsByTagName("euclidianView")[0]; - - board.origin = {}; - board.origin.usrCoords = [1, 0, 0]; - board.origin.scrCoords = [1, 1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("xZero"), 1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("yZero")]; - board.unitX = (boardData.getElementsByTagName("coordSystem")[0].getAttribute("scale")) ? 1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("scale") : 1; - board.unitY = (boardData.getElementsByTagName("coordSystem")[0].getAttribute("yscale")) ? 1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("yscale") : board.unitX; - - board.fontSize = (JXG.GeogebraReader.tree.getElementsByTagName("gui")[0] && JXG.GeogebraReader.tree.getElementsByTagName("gui")[0].getElementsByTagName("font")[0]) ? 1*JXG.GeogebraReader.tree.getElementsByTagName("gui")[0].getElementsByTagName("font")[0].getAttribute("size") : '12px'; - - JXG.JSXGraph.boards[board.id] = board; - - // Update of properties during update() is not necessary in GEONExT files - board.renderer.enhancedRendering = true; - - // snap to point - var snapToPoint = (boardData.getElementsByTagName('evSettings')[0].getAttribute("pointCapturing") == "true"); - - var grid = (boardData.getElementsByTagName('evSettings')[0].getAttribute("grid") == "true") ? board.create('grid') : null; - - if(boardData.getElementsByTagName('evSettings')[0].getAttribute("axes") && boardData.getElementsByTagName('evSettings')[0].getAttribute("axes") == "true") { - board.ggbElements["xAxis"] = board.create('axis', [[0, 0], [1, 0]], {strokeColor:'black', minorTicks: 0}); - board.ggbElements["yAxis"] = board.create('axis', [[0, 0], [0, 1]], {strokeColor:'black', minorTicks: 0}); - } -}; - -/** - * Searching for an element in the geogebra tree - * @param {Object} board object - * @param {Object} ggb element whose attributes are to parse - * @param {Array} input list of all input elements - * @param {String} typeName output construction method - * @return {Object} return newly created element or false - */ -this.writeElement = function(board, output, input, cmd) { - var element, gxtEl, attr, p, exp, coord, type, points, border, length, m, s, e, sx, sy, ex, ey, func, range; - element = (JXG.isArray(output)) ? output[0] : output; - - gxtEl = {}; // geometric element - attr = {}; // Attributes of geometric elements - - JXG.debug(element); - - gxtEl.type = (element && element.attributes && typeof cmd === 'undefined') ? element.getAttribute('type').toLowerCase() : cmd; - gxtEl.label = element.getAttribute('label'); - attr.name = gxtEl.label; - - JXG.debug("
Konstruiere "+ attr.name +"("+ gxtEl.type +"):"); - - switch(gxtEl.type) { - case 'point': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - if(JXG.GeogebraReader.getElement(attr.name, true)) { - exp = JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp'); - coord = JXG.GeogebraReader.ggbParse(exp); - gxtEl.x = new Function('return '+ coord[0] +';'); - gxtEl.y = new Function('return '+ coord[1] +';'); - } else { - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - } - if(!JXG.exists(attr.styleGGB)) { - attr.face = 'circle'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - attr.highlightFillColor = attr.strokeColor; - attr.highlightFillOpacity = 1; - attr.strokeColor = 'black'; - attr.strokeWidth = '1px'; - } - - JXG.debug(gxtEl); - JXG.debug(input); - - try { - var ma = /Circle\[\s*(\w+)\s*,\s*([\d\.]+)\s*\]/.exec(input); - if(typeof input != 'undefined') { - if (ma!=null && ma.length==3) { - // from Circle[A, 5] take "A" and "5", stored in ma[1] and ma[2] - var q = JXG.GeogebraReader.checkElement(ma[1]); - var c = board.create('circle', [q, parseFloat(ma[2])], {fillColor:'none',visible:false,name:''}); - p = board.create('glider', [gxtEl.x, gxtEl.y, c], attr); - } else if(JXG.isArray(input)) { - p = board.create('glider', [gxtEl.x, gxtEl.y, input[0]], attr); - } else { - p = board.create('glider', [gxtEl.x, gxtEl.y, input], attr); - } - } else { - p = board.create('point', [gxtEl.x, gxtEl.y], attr); - } - return p; - } catch(e) { - JXG.debug("* Err: Point " + attr.name +"
\n"); - return false; - } - break; - case 'segment': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Segment: ("+ attr.name +") First: " + input[0].name + ", Last: " + input[1].name + "
\n"); - attr.straightFirst = false; - attr.straightLast = false; - p = board.create('line', input, attr); - return p; - } catch(e) { - JXG.debug("* Err: Segment " + attr.name +" First: " + input[0].name + ", Last: " + input[1].name + "
\n"); - return false; - } - break; - case 'line': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - type = 'line'; - if(!input) { - input = [ parseFloat(element.getElementsByTagName('coords')[0].getAttribute('z')), - parseFloat(element.getElementsByTagName('coords')[0].getAttribute('x')), - parseFloat(element.getElementsByTagName('coords')[0].getAttribute('y')) - ]; - } else if (JXG.getRef(board, input[1].id).elementClass == JXG.OBJECT_CLASS_LINE) { - type = 'parallel'; // Parallele durch Punkt - } - - try { - p = board.create(type, input, attr); - return p; - } catch(e) { - JXG.debug("* Err: Line " + attr.label +"
\n"); - return false; - } - break; - case "orthogonalline": - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Orthogonalline: First: " + input[0].id + ", Last: " + input[1].id + "
\n"); - p = board.create('normal', input, attr); - return p; - } catch(e) { - JXG.debug("* Err: Orthogonalline " + attr.label +"
\n"); - return false; - } - break; - case "polygon": - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - // test if polygon is regular - if(input.length == 3 && output.length != 4) { - input[2] = parseInt(input[2]); - type = 'regular'; - } - - try { - JXG.debug("* Polygon: First: " + input[0].name + ", Second: " + input[1].name + ", Third: " + input[2] + "
\n"); - - var borders = []; - var borderatts = []; - length = (type == 'regular') ? output.length-input[2]+2 : output.length; - - for(var i=1; iErr: Polygon " + attr.name +"
\n"); - return false; - } - break; - case 'intersect': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Intersection: First: " + input[0].name + ", Second: " + input[1].name + "
\n"); - if(!JXG.exists(attr.styleGGB)) { - attr.face = 'circle'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - attr.highlightFillColor = attr.strokeColor; - attr.highlightFillOpacity = 1; - attr.strokeColor = 'black'; - attr.strokeWidth = '1px'; - } - if(output.length == 1) { - p = board.create('intersection', [input[0], input[1], 0], attr); - } - else { - p = board.create('intersection', [input[0], input[1], 1], attr); - var attr2 = {}; - attr2 = JXG.GeogebraReader.colorProperties(output[1], attr2); - attr2 = JXG.GeogebraReader.visualProperties(output[1], attr2); - attr2.name = output[1].getAttribute('label'); - var p2 = board.create('otherintersection', [input[0], input[1], p], attr2); - board.ggbElements[attr2.name] = p2; - } - - return p; - } catch(e) { - JXG.debug("* Err: Intersection " + attr.name +"
\n"); - return false; - } - break; - case 'distance': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - - try { - JXG.debug("* Distance: First: " + input[0].name + ", Second: " + input[1].name + "
\n"); - - if(false && output[0].getAtribute('type') && output[0].getAttribute('type') == 'numeric') { - input[1].Value = function(){ return this.X(); }; - p = input[1]; - board.elementsByName[attr.name] = p; - } else { - m = board.create('midpoint', input, {visible: 'false'}); - attr.visible = 'true'; - p = board.create('text', [function(){return m.X();}, function(){return m.Y();}, function(){ - return ""+ input[0].name + input[1].name +" = " - + JXG.trimNumber(JXG.getRef(board, input[0].id).Dist(JXG.getRef(board, input[1].id)).toFixed(JXG.GeogebraReader.decimals)); - }], attr); - p.Value = function () { - return (JXG.getRef(board, input[0].id).Dist(JXG.getRef(board, input[1].id))); - } - } - return p; - } catch(e) { - JXG.debug("* Err: Distance " + attr.name +"
\n"); - return false; - } - break; - case 'vector': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - if(element.getElementsByTagName("startPoint")[0]) { - - if(input && input.length == 2) { - e = JXG.GeogebraReader.checkElement(input[1].name); - } else { - e = [parseFloat(element.getElementsByTagName("coords")[0].getAttribute("x")), parseFloat(element.getElementsByTagName("coords")[0].getAttribute("y"))]; - } - if(element.getElementsByTagName("startPoint")[0].getAttribute("x") && element.getElementsByTagName("startPoint")[0].getAttribute("y")) { - s = [parseFloat(element.getElementsByTagName("startPoint")[0].getAttribute("x")), parseFloat(element.getElementsByTagName("startPoint")[0].getAttribute("y"))]; - } else if(element.getElementsByTagName("startPoint")[0].getAttribute("exp")) { - var startpoint = element.getElementsByTagName("startPoint")[0].getAttribute("exp"); - s = JXG.GeogebraReader.checkElement(startpoint); - } - } else if(input && input.length != 0) { - s = input[0]; - e = input[1]; - } else { - exp = JXG.GeogebraReader.getElement(element.getAttribute('label'), true); - if(exp) {// experimental - exp = exp.getAttribute('exp'); - // exp = JXG.GeogebraReader.functionParse('', exp); - exp = JXG.GeogebraReader.ggbParse(exp); - if (JXG.isArray(exp)) - exp = new Array(new Function('return '+ exp[1] +';'), new Function('return '+ exp[2] +';')); - else - exp = new Function('return '+ exp +';'); - JXG.debug('exp: '+ exp); - p = board.create('arrow', [[0,0], [exp[0], exp[1]]], attr); - return p; - //t = JXG.getRef(board, 'a'); - //s = t.point1; - // var e = [-1*vector.point2.X(), -1*vector.point2.Y()]; - // attr.type = 'rotate'; - // var angle; - // if(exp < 0) { - // angle = Math.PI; - // } else if(exp == 0) { - // angle = 0; - // } else { - // angle = Math.PI/exp; - // } - // needed: a clean rotating based on factor 'exp' - - // priorization of expression like 't*a' --> a := startPoint - } - } - - try { - JXG.debug("* Vector: First: " + attr.name); - p = board.create('arrow', [s, e], attr); - return p; - } catch(e) { - JXG.debug("* Err: Vector " + attr.name + e +"
\n"); - return false; - } - break; - case 'rotate': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Rotate: First: " + input[0].name + ", Second: " + input[1] + "
\n"); - attr.type = 'rotate'; - - if(!JXG.exists(attr.styleGGB)) { - attr.face = 'circle'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - attr.highlightFillColor = attr.strokeColor; - attr.highlightFillOpacity = 1; - attr.strokeColor = 'black'; - attr.strokeWidth = '1px'; - } - - t = board.create('transform', [parseInt(input[1])*Math.PI/180, input[2]], {type:'rotate'}); - p = board.create('point', [input[0], t], attr); - return p; - } catch(e) { - JXG.debug("* Err: Rotate " + attr.name +"
\n"); - return false; - } - break; - case 'dilate': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Dilate: First: " + input[0].name + ", Second: " + input[1] + "
\n"); - attr.type = 'rotate'; - var d = parseInt(input[1]); - var d1 = board.create('transform', [d, d], {type:'scale'}); - var d2 = board.create('transform', [function() { return (1-d) * input[2].X(); }, - function() { return (1-d) * input[2].Y(); }], {type:'translate'}); - - if(!JXG.exists(attr.styleGGB)) { - attr.face = 'circle'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - attr.highlightFillColor = attr.strokeColor; - attr.highlightFillOpacity = 1; - attr.strokeColor = 'black'; - attr.strokeWidth = '1px'; - } - p = board.create('point', [input[0], [d1, d2]], attr); - - return p; - } catch(e) { - JXG.debug("* Err: Dilate " + attr.name +"
\n"); - return false; - } - break; - case 'translate': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - t = board.create('transform', [function() { return input[1].point2.X()-input[1].point1.X(); }, - function() { return input[1].point2.Y()-input[1].point1.Y(); }], {type:'translate'}); - if(!JXG.exists(attr.styleGGB)) { - attr.face = 'circle'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - attr.highlightFillColor = attr.strokeColor; - attr.highlightFillOpacity = 1; - attr.strokeColor = 'black'; - attr.strokeWidth = '1px'; - } - p = board.create('point', [input[0], t], attr); - return p; - } catch(e) { - JXG.debug("* Err: Translate " + attr.name +"
\n"); - return false; - } - break; - case 'mirror': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - if (JXG.isPoint(JXG.getRef(board, input[1].id))) var type = 'mirrorpoint'; // Punktspiegelung - else if(JXG.getRef(board, input[1].id).elementClass == JXG.OBJECT_CLASS_LINE) var type = 'reflection'; // Geradenspiegelung - - try { - JXG.debug("* Mirror: First: " + input[0].name + ", Second: " + input[1].name + "
\n"); - p = board.create(type, [input[1], input[0]], attr); - return p; - } catch(e) { - JXG.debug("* Err: Mirror " + attr.name +"
\n"); - return false; - } - break; - case 'circle': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Circle: First: " + input[0].name + ", Second: " + input[1] + "
\n"); - p = board.create('circle', input, attr); - return p; - } catch(e) { - JXG.debug("* Err: Circle " + attr.name +"
\n"); - return false; - } - break; - case 'circlearc': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* CircleArc: First: " + input[0].name + ", Second: " + input[1].name + "
\n"); - p = board.create('arc', input, attr); - return p; - } catch(e) { - JXG.debug("* Err: CircleArc " + attr.name +"
\n"); - return false; - } - break; - case 'ellipse': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Ellipse: First: " + input[0].name + ", Second: " + input[1].name + ", Third: "+ input[2] +"
\n"); - // if third parameters is the major axis, else the third parameter is a point - if(parseInt(input[2]) == input[2]) - input[2] = parseInt(input[2]*2); // Geogebra delivers the half major axis - - p = board.create('ellipse', input, attr); - return p; - } catch(e) { - JXG.debug("* Err: Ellipse " + attr.name +"
\n"); - return false; - } - break; - case 'conic': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - -// try { - /* - // is there an expression named like the conic? - var exp = JXG.GeogebraReader.getElement(attr.name, true); - - // then get the function parameteres - if(exp.attributes['exp']){ - // exp = JXG.GeogebraReader.functionParse(exp.attributes['exp'].value); - // exp = JXG.GeogebraReader.ggbParse(exp.attributes['exp'].value); - - - - // (exp.getElementsByTagName('value')) ? exp = parseFloat(exp.getElementsByTagName('value')[0].attributes['val'].value) : false; - - } else */ if(input && input.length == 5) { - p = board.create('conic', input, attr); - } else if(element.getElementsByTagName('matrix')) { - m = []; - for(var i=0; iErr: Conic " + attr.name +"
\n"); -// return false; -// } - break; - case 'circlesector': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - //attr.names = [attr.name,'','','']; - //attr2 = {}; - //attr2.names = attr.names; - try { - JXG.debug("* CircleSector: First: " + input[0].name + ", Second: " + input[1].name + ", Third: " + input[2].name + "
\n"); - p = board.create('sector', [input[0],input[1],input[2]], attr); - /* - p.point4.hideElement(); - p.arc.setProperty(attr); - p.arc.visProp.highlightstrokewidth = (1*p.arc.visProp.strokewidth.substr(0,p.arc.visProp.strokewidth.length-2)+1)+'px'; - p.lines[0].setProperty(attr); - p.lines[1].setProperty(attr); - p.lines[0].visProp.highlightstrokewidth = (1*p.lines[0].visProp.strokerwWidth.substr(0,p.lines[0].visProp.strokewidth.length-2)+1)+'px'; - p.lines[1].visProp.highlightstrokewidth = (1*p.lines[1].visProp.strokerwWidth.substr(0,p.lines[1].visProp.strokewidth.length-2)+1)+'px'; - p.arc.hasPoint = p.arc.hasPointSector; - p.arc.highlight = (function(el){ return function() { - this.board.renderer.highlight(this); - this.board.renderer.highlight(el.lines[0]); - this.board.renderer.highlight(el.lines[1]); - };})(p); - p.arc.noHighlight = (function(el){ return function() { - this.board.renderer.noHighlight(this); - this.board.renderer.noHighlight(el.lines[0]); - this.board.renderer.noHighlight(el.lines[1]); - };})(p); - p.lines[0].highlight = (function(el){ return function() { - this.board.renderer.highlight(this); - this.board.renderer.highlight(el.arc); - this.board.renderer.highlight(el.lines[1]); - };})(p); - p.lines[1].highlight = (function(el){ return function() { - this.board.renderer.highlight(this); - this.board.renderer.highlight(el.arc); - this.board.renderer.highlight(el.lines[0]); - };})(p); - p.lines[0].noHighlight = (function(el){ return function() { - this.board.renderer.noHighlight(this); - this.board.renderer.noHighlight(el.arc); - this.board.renderer.noHighlight(el.lines[1]); - };})(p); - p.lines[1].noHighlight = (function(el){ return function() { - this.board.renderer.noHighlight(this); - this.board.renderer.noHighlight(el.arc); - this.board.renderer.noHighlight(el.lines[0]); - };})(p); - */ - return p; - } catch(e) { - JXG.debug("* Err: CircleSector " + attr.name +"
\n"); - return false; - } - break; - case 'linebisector': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* LineBiSector (Mittelsenkrechte): First: " + input[0].name + "
\n"); - m = board.create('midpoint', input, {visible: false}); - if(JXG.isPoint(JXG.getRef(board, input[0].id)) && - JXG.isPoint(JXG.getRef(board, input[1].id))) { - t = board.create('line', input, {visible: 'false'}); - p = board.create('perpendicular', [m, t], attr); - // p.point.setProperty('visible:false'); - } else { - p = board.create('perpendicular', [m, input[0]], attr); - // p.point.setProperty('visible:false'); - } - return p; - } catch(e) { - JXG.debug("* Err: LineBiSector (Mittelsenkrechte) " + attr.name +"
\n"); - return false; - } - break; - case 'ray': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Ray: First: " + input[0].name + "
\n"); - attr.straightFirst = true; - attr.straightLast = false; - p = board.create('line', [input[1], input[0]], attr); - return p; - } catch(e) { - JXG.debug("* Err: Ray " + attr.name +"
\n"); - return false; - } - break; - case 'tangent': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Tangent: First: " + input[0].name + ", Sec.: "+ input[1].name +"("+ input[1].type +")
\n"); - switch(input[1].type) { - case 1330923344: // graph - input[0].makeGlider(input[1]); - p = board.create('tangent', [input[0]], attr); - return p; - break; - case 1330922316: // circle 0x4F54434C - case 1330922319: // conic 0x4F54434F - var pol = board.create('polar',[input[1],input[0]],{visible:false}); - var i1 = board.create('intersection', [input[1], pol, 0], {visible: false}); - var i2 = board.create('intersection', [input[1], pol, 1], {visible: false}); - var t1 = board.create('line', [input[0], i1], attr); - var attr2 = {}; - attr2 = JXG.GeogebraReader.colorProperties(output[1], attr2); - attr2 = JXG.GeogebraReader.visualProperties(output[1], attr2); - attr2.name = output[1].getAttribute('label'); - var t2 = board.create('line', [input[0], i2], attr2); - board.ggbElements[attr2.name] = t2; - return [t1, t2]; - break; - } - } catch(e) { - JXG.debug("* Err: Tangent " + attr.name +" "+ attr2.name + "
\n"); - return false; - } - break; - case 'circumcirclearc': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* CircumcircleArc: First: " + input[0].name + "
\n"); - p = board.create('circumcirclearc', input, attr); - return p; - } catch(e) { - JXG.debug("* Err: CircumcircleArc " + attr.name +"
\n"); - return false; - } - break; - case 'circumcirclesector': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* CircumcircleSector: First: " + input[0].name + "
\n"); - p = board.create('circumcirclesector', [input[0], input[1], input[2]], attr); //{name:attr['name']}); - /* - p.arc.setProperty(attr); - p.lines[0].setProperty(attr); - p.lines[1].setProperty(attr); - p.arc.visProp.highlightstrokewidth = (1*p.arc.visProp.strokewidth.substr(0,p.arc.visProp.strokewidth.length-2)+1)+'px'; - p.lines[0].visProp.highlightstrokewidth = (1*p.lines[0].visProp.strokewidth.substr(0,p.lines[0].visProp.strokewidth.length-2)+1)+'px'; - p.lines[1].visProp.highlightstrokewidth = (1*p.lines[1].visProp.strokewidth.substr(0,p.lines[1].visProp.strokewidth.length-2)+1)+'px'; - p.arc.hasPoint = p.arc.hasPointSector; - p.arc.highlight = (function(el){ return function() { - this.board.renderer.highlight(this); - this.board.renderer.highlight(el.lines[0]); - this.board.renderer.highlight(el.lines[1]); - };})(p); - p.arc.noHighlight = (function(el){ return function() { - this.board.renderer.noHighlight(this); - this.board.renderer.noHighlight(el.lines[0]); - this.board.renderer.noHighlight(el.lines[1]); - };})(p); - p.lines[0].highlight = (function(el){ return function() { - this.board.renderer.highlight(this); - this.board.renderer.highlight(el.arc); - this.board.renderer.highlight(el.lines[1]); - };})(p); - p.lines[1].highlight = (function(el){ return function() { - this.board.renderer.highlight(this); - this.board.renderer.highlight(el.arc); - this.board.renderer.highlight(el.lines[0]); - };})(p); - p.lines[0].noHighlight = (function(el){ return function() { - this.board.renderer.noHighlight(this); - this.board.renderer.noHighlight(el.arc); - this.board.renderer.noHighlight(el.lines[1]); - };})(p); - p.lines[1].noHighlight = (function(el){ return function() { - this.board.renderer.noHighlight(this); - this.board.renderer.noHighlight(el.arc); - this.board.renderer.noHighlight(el.lines[0]); - };})(p); - */ - return p; - } catch(e) { - JXG.debug("* Err: CircumcircleSector " + attr.name +"
\n"); - return false; - } - break; - case 'semicircle': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Semicircle: First: " + input[0].name + "
\n"); - p = board.create('semicircle', [input[0], input[1]], attr); - return p; - } catch(e) { - JXG.debug("* Err: Semicircle " + attr.name +"
\n"); - return false; - } - break; - case 'angle': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Angle: First: " + input[0].name + "
\n"); - p = board.create('angle', input, attr); - return p; - } catch(e) { - JXG.debug("* Err: Angle " + attr.name +"
\n"); - return false; - } - break; - case 'angularbisector': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - attr.straightFirst = true; - attr.straightLast = true; - - try { - JXG.debug("* Angularbisector: First: " + input[0].name + "
\n"); - p = board.create('bisector', input, attr); - return p; - } catch(e) { - JXG.debug("* Err: Angularbisector " + attr.name +"
\n"); - return false; - } - break; - case 'numeric': - if(element.getElementsByTagName('slider').length == 0) { - // auxiliary doesn't exist in every numeric - //element.getElementsByTagName('auxiliary').length != 0 && element.getElementsByTagName('auxiliary')[0].attributes['val'].value == 'true') { - exp = JXG.GeogebraReader.getElement(element.getAttribute('label'), true); - if(exp) { - exp = exp.getAttribute('exp'); - exp = JXG.GeogebraReader.functionParse('', exp); - exp = JXG.GeogebraReader.ggbParse(exp); - } - board.ggb[attr.name] = new Function('return '+ exp +';'); - JXG.debug('value: '+ board.ggb[attr.name]()); - return board.ggb[attr.name]; - } else { - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - // gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - if(element.getElementsByTagName('slider').length == 1) { // it's a slider - sx = parseFloat(element.getElementsByTagName('slider')[0].getAttribute('x')); - sy = parseFloat(element.getElementsByTagName('slider')[0].getAttribute('y')); - length = parseFloat(element.getElementsByTagName('slider')[0].getAttribute('width')); - // are coordinates absolut? - if(element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') && element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') == 'true') { - var tmp = new JXG.Coords(JXG.COORDS_BY_SCREEN, [sx, sy], board); - sx = tmp.usrCoords[1]; - sy = tmp.usrCoords[2]; - } - - if(element.getElementsByTagName('slider')[0].getAttribute('horizontal') == 'true') { - if(element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') && element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') == 'true') - length /= (board.unitX); //*board.zoomX); - ex = sx + length; - ey = sy; - } else { - if(element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') && element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') == 'true') - length /= (board.unitY); //*board.zoomY); - ex = sx; - ey = sy + length; - } - - (element.getElementsByTagName('animation')[0]) ? attr.snapWidth = parseFloat(element.getElementsByTagName('animation')[0].getAttribute('step')) : false; - - try { - JXG.debug("* Numeric: First: " + attr.name + "
\n"); - attr['withTicks'] = false; - p = board.create('slider', [[sx,sy], [ex,ey], [parseFloat(element.getElementsByTagName('slider')[0].getAttribute('min')), - parseFloat(element.getElementsByTagName('value')[0].getAttribute('val')), - parseFloat(element.getElementsByTagName('slider')[0].getAttribute('max'))]], attr); - p.setProperty({withLabel:false}); - return p; - } catch(e) { - JXG.debug("* Err: Numeric " + attr.name +"
\n"); - return false; - } - } - } - break; - case 'midpoint': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - if(!JXG.exists(attr.styleGGB)) { - attr.face = 'circle'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - attr.highlightFillColor = attr.strokeColor; - attr.highlightFillOpacity = 1; - attr.strokeColor = 'black'; - attr.strokeWidth = '1px'; - } - p = board.create('midpoint', input, attr); - JXG.debug("* Midpoint ("+ p.id +"): "+ attr.name + "("+ gxtEl.x +", "+ gxtEl.y +")
\n"); - return p; - } catch(e) { - JXG.debug("* Err: Midpoint " + attr.name +"
\n"); - return false; - } - break; - case 'center': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - try { - if(!JXG.exists(attr.styleGGB)) { - attr.face = 'circle'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - attr.highlightFillColor = attr.strokeColor; - attr.highlightFillOpacity = 1; - attr.strokeColor = 'black'; - attr.strokeWidth = '1px'; - } - p = board.create('point', [function() { return JXG.getRef(board, input[0].id).center.X(); }, - function() { return JXG.getRef(board, input[0].id).center.Y(); }], attr); - JXG.debug("* Center ("+ p.id +"): "+ attr.name + "("+ gxtEl.x +", "+ gxtEl.y +")
\n"); - return p; - } catch(e) { - JXG.debug("* Err: Center " + attr.name +"
\n"); - return false; - } - break; - case 'function': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - if(JXG.GeogebraReader.getElement(attr.name, true)) { - func = JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp'); - func = JXG.GeogebraReader.functionParse('c', func); - } else { - func = input[0]; - func = JXG.GeogebraReader.functionParse('s', func); - } - - JXG.debug(func); - - length = func.length; - func[func.length-1] = 'return '+ JXG.GeogebraReader.ggbParse(func[func.length-1]) +';'; - - JXG.debug(func); - - range = [(input && input[1]) ? input[1] : null, (input && input[2]) ? input[2] : null]; - - try { - if(length == 1) - p = board.create('functiongraph', [new Function(func[0]), range[0], range[1]], attr); - else if(length==2) - p = board.create('functiongraph', [new Function(func[0], func[1]), range[0], range[1]], attr); - else if(length==3) - p = board.create('functiongraph', [new Function(func[0], func[1], func[2]), range[0], range[1]], attr); - else if(length==4) - p = board.create('functiongraph', [new Function(func[0], func[1], func[2], func[3]), range[0], range[1]], attr); - else if(length==5) - p = board.create('functiongraph', [new Function(func[0], func[1], func[2], func[3], func[4]), range[0], range[1]], attr); - return p; - } catch(e) { - JXG.debug("* Err: Functiongraph " + attr.name +"
\n"); - return false; - } - - break; - case 'polar': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Polar: First: " + input[0].name + ", Sec.: "+ input[1].name +"
\n"); - p = board.create('polar', input, attr); - return p; - } catch(e) { - JXG.debug("* Err: Polar " + attr.name +"
\n"); - return false; - } - break; - case 'slope': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Slope ("+ attr.name +"): First: " + input[0].name +"
\n"); - var slopeWidth = parseInt(attr.slopeWidth) || 1.0; - var p1 = input[0].glider || input[0].point1; - var p2 = board.create('point',[function(){return (slopeWidth+p1.X());}, function(){return p1.Y();}], {visible: false}); - var l1 = board.create('segment', [p1, p2], {visible: false}); // visible: attr.visible - var l2 = board.create('normal', [l1, l1.point2], {visible: false}); // visible attr.visible - var i = board.create('intersection', [input[0], l2, 0], {visible: false}); - var m = board.create('midpoint', [l1.point2, i], {visible: false}); - - var t = board.create('text', [function(){return m.X();}, function(){return m.Y();}, - function(){ return "  " + (slopeWidth > 1 ? slopeWidth.toString() : "") + " " + this.name + " = " + JXG.trimNumber((slopeWidth * input[0].getSlope()).toFixed(JXG.GeogebraReader.decimals)); }], attr); - attr.name = ""; - var t2 = board.create('text', [function(){return (p1.X() + p2.X())/2.;}, function(){return p1.Y();}, - function(){ return "
" + slopeWidth; }], attr); - t.Value = (function() { return function(){ return input[0].getSlope(); }; })(); - var poly = board.create('polygon',[p1,p2,i], attr); - - poly.borders[2].setProperty({visible: false}); - poly.borders[0].setProperty({strokeColor: attr.fillColor, strokeWidth: attr.strokeWidth, highlightStrokeColor: attr.fillColor, dash:attr.dash}); - poly.borders[1].setProperty({strokeColor: attr.fillColor, strokeWidth: attr.strokeWidth, highlightStrokeColor: attr.fillColor, dash:attr.dash}); - return t; - } catch(e) { - JXG.debug("* Err: Slope " + attr.name +"
\n"); - return false; - } - break; - case 'text': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - var rx, res = ''; - - try { - if(element.getElementsByTagName('isLaTeX')[0] && element.getElementsByTagName('isLaTeX')[0].getAttribute('val') == 'true') { - JXG.GeogebraReader.board.options.text.useASCIIMathML = true; - t = JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp'); - - // here we're searching for patterns like - // " + ... + " - // ... will be sent to the ggbParser and a calculated text element is built from this. - while(rx = t.match(/(.*?)" \+ (.+) \+ "(.*)/)) { - var re2 = JXG.GeogebraReader.ggbParse(RegExp.$2); - if (typeof re2 == 'string') { - res = res + RegExp.$1 + re2; - } else { - res = res + RegExp.$1 + '" + JXG.trimNumber((' + re2 + ').toFixed(JXG.GeogebraReader.decimals)) + "'; - } - t = RegExp.$3; - } - // we have to look, if the string's ending with a string-part or a formula part: - if(rx = t.match(/(.*?)" \+ (.+)/)) { - res = res + RegExp.$1 + '" + JXG.trimNumber((' + JXG.GeogebraReader.ggbParse(RegExp.$2) + ').toFixed(JXG.GeogebraReader.decimals))'; - } else - res = res + t; - - JXG.debug("Text: "+res); - - p = board.create('text', [gxtEl.x, gxtEl.y, new Function('return ' + res + ';')], attr); - } else { - JXG.debug(JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp')); - t = JXG.GeogebraReader.ggbParse(JXG.GeogebraReader.functionParse(false, JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp'))); - JXG.debug(t[1]); - p = board.create('text', [gxtEl.x, gxtEl.y, new Function('return '+t[0]+' + " " + JXG.trimNumber(parseFloat(' + t[1] +').toFixed(JXG.GeogebraReader.decimals));') ], attr); - } - JXG.debug("* Text: " + t +"
\n"); - return p; - } catch(e) { - JXG.debug("* Err: Text: " + t +"
\n"); - return false; - } - break; - case 'root': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - //JXG.debug(JXG.getRef(board, gxtEl.id)); - - for(var i=0; iIntegral: First: " + input[0].name + ", Sec.: "+ input[1].name +", Thir.: "+ input[2].name +"
\n"); - JXG.debug([input[1](), input[2]()]); - var p = board.create('integral', [JXG.getRef(board, input[0]), [input[1], input[2]]], attr); - return p; - } catch(e) { - JXG.debug("* Err: Integral " + attr.name + e + "
\n"); - return false; - } - break; - -// case 'transform': -// break; -// case 'radius': -// break; -// case 'derivative': -// break; -// case 'root': -// break; -// case 'corner': -// break; -// case 'unitvector': -// break; -// case 'extremum': -// break; -// case 'turningpoint': -// break; -// case 'arc': -// break; -// case 'circlepart': -// break; -// case 'uppersum': -// break; -// case 'lowersum': -// break; -// case 'image': -// break; - default: - return false; - break; - } -}; - -/** - * Reading the elements of a geogebra file - * @param {Object} board board object - */ -this.readGeogebra = function(tree, board) { - var el, Data, i, els = [], expr; - - board.ggbElements = []; - board.ggb = {}; - JXG.GeogebraReader.tree = tree; - JXG.GeogebraReader.board = board; - JXG.GeogebraReader.format = parseFloat(JXG.GeogebraReader.tree.getElementsByTagName('geogebra')[0].getAttribute('format')); - JXG.GeogebraReader.decimals = parseInt(JXG.GeogebraReader.tree.getElementsByTagName('geogebra')[0].getElementsByTagName('kernel')[0].getElementsByTagName('decimals')[0].getAttribute('val')); - JXG.GeogebraReader.writeBoard(board); - board = JXG.GeogebraReader.setDefaultOptions(board); - - // speeding up the drawing process - //board.suspendUpdate(); - - var constructions = JXG.GeogebraReader.tree.getElementsByTagName("construction"); - for (var t=0; t"); - - /* register borders to according "parent" */ - if(board.ggbElements[elname].borders) - for(var i=0; i"); - }; - } - }; - - JXG.debug('Restesammler: '); - // create "single" elements which do not depend on any other - var elements = constructions[t].getElementsByTagName("element"); - for (var s=0; s=') : exp; - exp = (exp.match(/\u2227/)) ? exp.replace(/\u2227/g, '&&') : exp; - exp = (exp.match(/\u2228/)) ? exp.replace(/\u2228/g, '//') : exp; - return exp; -}; - -/** - * Extracting the packed geogebra file in order to return the "blank" xml-tree for further parsing. - * @param {String} archive containing geogebra.xml-file or raw input string (eg. xml-tree) - * @return {String} content of geogebra.xml-file if archive was passed in - */ -this.prepareString = function(fileStr, isString) { - var i, bA, len, fstr; - - // here we have to deal with two different base64 encoded streams - // first one: base64 encoded xml (geogebra's web export) - // second one: base64 encoded ggb file, this is our recommendation for an IE & Opera - // workaround, which can't deal with binary data transferred via AJAX. - - // first try to decode assuming we got a base64 encoded ggb file - if(isString) { - fstr = JXG.Util.Base64.decode(fileStr); - if(fstr.slice(0,2)!=="PK") { - // ooops, that was no ggb file. try again with utf8 parameter set. - fstr = JXG.Util.Base64.decode(fileStr, true); - } - fileStr = fstr; - } - - if (fileStr.indexOf('<') != 0) { - bA = []; - len = fileStr.length; - for (i=0;i. -*/ -JXG.debug = function() {}; -JXG.GeonextReader = { - - changeOriginIds: function (board, id) { - if ((id == 'gOOe0') || (id == 'gXOe0') || (id == 'gYOe0') || (id == 'gXLe0') || (id == 'gYLe0')) { - return board.id + id; - } else { - return id; - } - }, - - /** - * Retrieves data by TagName from an XML node. - * @param {Node} node The Node that contains the data we want to get. - * @param {String} tag The Name of the tag we are looking for. - * @param {Number} [idx=0] getElementsByTagName returns an array; This parameter decides which element to use. - * @param {Boolean} [fc=true] If True, the result will be the data of firstChild instead of the result node. - * @returns {String} The gathered data - */ - gEBTN: function (node, tag, idx, fc) { - var tmp; - - if (!JXG.exists(node || !node.getElementsByTagName )/* || !JXG.exists(node.getElementsByTagName)*/) { - return ''; - } - // Default values for optional parameters idx and fc - if (!JXG.exists(fc)) { - fc = true; - } - idx = idx || 0; - tmp = node.getElementsByTagName(tag); - if (tmp.length > 0) { - tmp = tmp[idx]; - if (fc && tmp.firstChild) { - tmp = tmp.firstChild.data; - } - } - return tmp; - }, - - /** - * Set color properties of a geonext element. - * Set stroke, fill, lighting, label and draft color attributes. - * @param {Object} gxtEl element of which attributes are to set - */ - colorProperties: function (gxtEl, Data) { - var color = this.gEBTN(Data, 'color', 0, false), - rgbo; - - //gxtEl.strokewidth = Data.getElementsByTagName('strokewidth')[0].firstChild.data; - // colorStroke = strokeColor etc. is here for downwards compatibility: - // once upon a time we used to create elements in here using the "new JXG.Element" constructor mechanism - // then we changed to board.create + setProperty afterwords - // now i want to use the board.create method with an appropriate attributes object to avoid setProperty calls - // and as gxtEl happens to be somewhat like an attributes object it's just slightly different so we adjust it - // for downwards compatibility during the transformation of this reader we use both properties - - rgbo = JXG.rgba2rgbo(this.gEBTN(color, 'stroke')); - gxtEl.strokeColor = rgbo[0]; - gxtEl.strokeOpacity = rgbo[1]; - - rgbo = JXG.rgba2rgbo(this.gEBTN(color, 'lighting')); - gxtEl.highlightStrokeColor = rgbo[0]; - gxtEl.highlightStrokeOpacity = rgbo[1]; - - rgbo = JXG.rgba2rgbo(this.gEBTN(color, 'fill')); - gxtEl.fillColor = rgbo[0]; - gxtEl.fillOpacity = rgbo[1]; - - gxtEl.highlightFillColor = gxtEl.fillColor; - gxtEl.highlightFillOpacity = gxtEl.fillOpacity; - - gxtEl.labelColor = JXG.rgba2rgbo(this.gEBTN(color, 'label'))[0]; - gxtEl.colorDraft = JXG.rgba2rgbo(this.gEBTN(color, 'draft'))[0]; - - // GEONExT hides labels by setting opacity to 0. - if (JXG.rgba2rgbo(this.gEBTN(color, 'label'))[1]==0) { - gxtEl.withLabel = false; - } else { - gxtEl.withLabel = true; - } - - // backwards compatibility - gxtEl.colorStroke = gxtEl.strokeColor; - gxtEl.colorFill = gxtEl.fillColor; - gxtEl.colorLabel = gxtEl.labelColor; - - return gxtEl; - }, - - firstLevelProperties: function (gxtEl, Data) { - if (!JXG.exists(Data) || !JXG.exists(Data.childNodes)) - return gxtEl; - - var arr = Data.childNodes, n, key; - - for (n = 0; n < arr.length; n++) { - if (JXG.exists(arr[n].firstChild) && arr[n].nodeName !== 'data' && arr[n].nodeName !== 'straight') { - key = arr[n].nodeName; - gxtEl[key] = arr[n].firstChild.data; - } - } - - return gxtEl; - }, - - /** - * Set the defining properties of a geonext element. - * Writing the nodeName to ident; setting the name attribute and defining the element id. - * @param {Object} gxtEl element of which attributes are to set - */ - defProperties: function (gxtEl, Data) { - // 3==TEXT_NODE, 8==COMMENT_NODE - if (Data.nodeType==3 || Data.nodeType==8 ) { - return null; - } - - gxtEl.ident = Data.nodeName; - - if(gxtEl.ident == "text" || gxtEl.ident == "intersection" || gxtEl.ident == "composition") { - gxtEl.name = ''; - } else { - gxtEl.name = this.gEBTN(Data, 'name'); - } - - gxtEl.id = this.gEBTN(Data, 'id'); - - return gxtEl; - }, - - visualProperties: function (gxtEl, Data) { - gxtEl.visible = JXG.str2Bool(this.gEBTN(Data, 'visible')); - gxtEl.trace = JXG.str2Bool(this.gEBTN(Data, 'trace')); - - return gxtEl; - }, - - transformProperties: function (gxtEl, type) { - var facemap = [ - // 0-2 - 'cross', 'cross', 'cross', - // 3-6 - 'circle', 'circle', 'circle', 'circle', - // 7-9 - 'square', 'square', 'square', - // 10-12 - 'plus', 'plus', 'plus' - ], sizemap = [ - // 0-2 - 2, 3, 4, - // 3-6 - 1, 2, 3, 4, - // 7-9 - 2, 3, 4, - // 10-12 - 2, 3, 4 - ]; - - gxtEl.strokeWidth = gxtEl.strokewidth; - gxtEl.face = facemap[parseInt(gxtEl.style, 10)] || 'cross'; - gxtEl.size = sizemap[parseInt(gxtEl.style, 10)] || 3; - - gxtEl.straightFirst = JXG.str2Bool(gxtEl.straightFirst); - gxtEl.straightLast = JXG.str2Bool(gxtEl.straightLast); - - gxtEl.visible = JXG.str2Bool(gxtEl.visible); - //gxtEl.withLabel = gxtEl.visible; // withLabel is set in colorProperties() - gxtEl.draft = JXG.str2Bool(gxtEl.draft); - gxtEl.trace = JXG.str2Bool(gxtEl.trace); - - if (type==='point') { - // Fill properties are ignored by GEONExT - gxtEl.fillColor = gxtEl.strokeColor; - gxtEl.highlightFillColor = gxtEl.highlightStrokeColor; - gxtEl.fillOpacity = gxtEl.strokeOpacity; - gxtEl.highlightFillOpacity = gxtEl.highlightStrokeOpacity; - } - - if (typeof(gxtEl.label === 'string')) { - delete(gxtEl.label); - } - - delete gxtEl.color; - return gxtEl; - }, - - readNodes: function (gxtEl, Data, nodeType, prefix) { - var arr = this.gEBTN(Data, nodeType, 0, false).childNodes, - key, n; - - for (n = 0; n < arr.length; n++) { - if (arr[n].firstChild != null) { - if (prefix != null) { - key = prefix + JXG.capitalize(arr[n].nodeName); - } else { - key = arr[n].nodeName; - } - gxtEl[key] = arr[n].firstChild.data; - } - } - return gxtEl; - }, - - subtreeToString: function (root) { - try { - // firefox - return (new XMLSerializer()).serializeToString(root); - } catch (e) { - // IE - return root.xml; - } - }, - - readImage: function (node) { - var pic = '', - nod = node; - - if (nod != null) { - pic = nod.data; - while (nod.nextSibling != null) { - nod = nod.nextSibling; - pic += nod.data; - } - } - return pic; - }, - - parseImage: function (board, fileNode, level, x, y, w, h, el) { - var tag, id, im, picStr, tmpImg; - - if (fileNode == null) { - return null; - } - - if (fileNode.getElementsByTagName('src')[0] != null) { // Background image - tag = 'src'; - } else if (fileNode.getElementsByTagName('image')[0] != null) { - tag = 'image'; - } else { - return null; - } - - picStr = this.readImage(this.gEBTN(fileNode, tag, 0, false).firstChild); - if (picStr!='') { - picStr = 'data:image/png;base64,' + picStr; - if (tag=='src') { // Background image - x = this.gEBTN(fileNode, 'x'); - y = this.gEBTN(fileNode, 'y'); - w = this.gEBTN(fileNode, 'width'); - h = this.gEBTN(fileNode, 'height'); - im = board.create('image', [picStr,[x, y],[w, h]], { - anchor: el, layer: level - }); - return im; - } else { - // Image bound to an element - // Read the original dimensions, i.e. the ratio h/w with the help of a temporary image. - // We have to wait until the image is loaded, therefore - // we need "onload". - tmpImg = new Image(); - tmpImg.src = picStr; - id = el.id + '_image'; - tmpImg.onload = function(){ - // Now, we can read the original dimensions of the image. - var wOrg = this.width, - hOrg = this.height, - xf, yf, wf, hf, im, tRot; - - if (el.elementClass == JXG.OBJECT_CLASS_LINE) { - // A line containing an image, runs through the horizontal middle - // of the image. - xf = function(){ return el.point1.X(); }; - wf = function(){ return el.point1.Dist(el.point2); }; - hf = function(){ return wf() * hOrg / wOrg; }; - yf = function(){ return el.point1.Y() - hf() * 0.5; }; - im = board.create('image', [picStr, [xf,yf], [wf,hf]], { - layer: level, - id: id, - anchor: el - }); - tRot = board.create('transform', [ - function () { - return Math.atan2(el.point2.Y()-el.point1.Y(), el.point2.X()-el.point1.X()) - }, - el.point1 - ], { - type:'rotate' - }); - tRot.bindTo(im); - el.image = im; - } else if (el.elementClass == JXG.OBJECT_CLASS_POINT) { - wf = function(){ return wOrg / board.unitX; }; - hf = function(){ return hOrg / board.unitY; }; - xf = function(){ return el.X() - wf() * 0.5; }; - yf = function(){ return el.Y() - hf() * 0.5; }; - - im = board.create('image', [picStr, [xf,yf], [wf,hf]], { - layer: level, - id: id, - anchor: el - }); - board.renderer.hide(el.label.content); - el.image = im; - } else if (el.elementClass == JXG.OBJECT_CLASS_CIRCLE) { - // A circle containing an image - wf = function(){ return 2.0 * el.Radius(); }; - hf = function(){ return wf() * hOrg / wOrg; }; - xf = function(){ return el.center.X() - wf() * 0.5; }; - yf = function(){ return el.center.Y() - hf() * 0.5; }; - im = board.create('image', [picStr, [xf,yf], [wf,hf]], { - layer: level, - id: id, - anchor: el - }); - el.image = im; - } else { - im = board.create('image', [picStr, [x, y], [w, h]], { - layer: level, - id: id, - anchor: el - }); - el.image = im; - } - }; - } - return im; - } - }, - - readConditions: function(node) { - var i, s, ob, - conditions = ''; - - if (JXG.exists(node)) { - for(i = 0; i < node.getElementsByTagName('data').length; i++) { - ob = node.getElementsByTagName('data')[i]; - s = this.subtreeToString(ob); - conditions += s; - } - } - - return conditions; - }, - - printDebugMessage: function(outputEl,gxtEl,nodetyp,success) { - JXG.debug("* " + success + ": " + nodetyp + " " + gxtEl.name + " " + gxtEl.id + "
\n"); - }, - - /** - * Reading the elements of a geonext file - * @param {XMLTree} tree expects the content of the parsed geonext file returned by function parseFF/parseIE - * @param {Object} board board object - */ - readGeonext: function(tree, board) { - var xmlNode, elChildNodes, - s, Data, inter, boardData, el, p, - conditions, tmp, strTrue = 'true', gxtReader = this; - - // maybe this is not necessary as we already provide layer options for sectors and circles via JXG.Options but - // maybe these have to be the same for geonext. - board.options.layer.sector = board.options.layer.angle; - board.options.layer.circle = board.options.layer.angle; - - board.options.line.label.position = 'top'; - - boardData = this.gEBTN(tree, 'board', 0, false); - conditions = this.readConditions(boardData.getElementsByTagName('conditions')[0]); - - // set the origin - xmlNode = this.gEBTN(boardData, 'coordinates', 0, false); - tmp = this.gEBTN(xmlNode, 'origin', 0, false); - board.origin = { - usrCoords: [1, 0, 0], - scrCoords: [1, parseFloat(this.gEBTN(tmp, 'x')), parseFloat(this.gEBTN(tmp, 'y'))] - }; - - // zoom level - tmp = this.gEBTN(xmlNode, 'zoom', 0, false); - board.zoomX = parseFloat(this.gEBTN(tmp, 'x')); - board.zoomY = parseFloat(this.gEBTN(tmp, 'y')); - - // screen to user coordinates conversion - tmp = this.gEBTN(xmlNode, 'unit', 0, false); - board.unitX = parseFloat(this.gEBTN(tmp, 'x')); - board.unitY = parseFloat(this.gEBTN(tmp, 'y')); - - // resize board - if (board.options.takeSizeFromFile) { - board.resizeContainer(this.gEBTN(boardData, 'width'), this.gEBTN(boardData, 'height')); - } - - // check and set fontSize - if (!(parseFloat(board.options.text.fontSize) > 0)) { - board.options.text.fontSize = 12; - } - - board.geonextCompatibilityMode = true; - - // jsxgraph chooses an id for the board but we don't want to use it, we want to use - // the id stored in the geonext file. if you know why this is required, please note it here. - delete(JXG.JSXGraph.boards[board.id]); - board.id = this.gEBTN(boardData, 'id'); - JXG.JSXGraph.boards[board.id] = board; - - // this creates some basic elements present in every geonext construction but not explicitly present in the file - board.initGeonextBoard(); - - // Update of properties during update() is not necessary in GEONExT files - // But it maybe necessary if we construct with JavaScript afterwards - board.renderer.enhancedRendering = true; - - // Read background image - this.parseImage(board, this.gEBTN(boardData, 'file', 0, false), board.options.layer['image']); - - board.options.point.snapToGrid = (this.gEBTN(this.gEBTN(boardData, 'coordinates', 0, false), 'snap') == strTrue); - // - // TODO: Missing jsxgraph feature snapToPoint - // If snapToGrid and snapToPoint are both true, point snapping is enabled - if (board.options.point.snapToGrid && this.gEBTN(this.gEBTN(boardData, 'grid', 1, false), 'pointsnap') == strTrue) { - board.options.point.snapToGrid = false; - board.options.point.snapToPoints = true; - board.options.point.attractorDistance = 0.5; - } - //board.options.grid.snapToGrid = false; - - xmlNode = this.gEBTN(boardData, 'grid', 1, false); - tmp = this.gEBTN(xmlNode, 'x'); - if (tmp) { - board.options.grid.gridX = 1 / parseFloat(tmp); - board.options.point.snapSizeX = parseFloat(tmp); - } - tmp = this.gEBTN(xmlNode, 'y'); - if (tmp) { - board.options.grid.gridY = 1 / parseFloat(tmp); - board.options.point.snapSizeY = parseFloat(tmp); - } - //board.calculateSnapSizes(); // Seems not to be correct - board.options.grid.gridDash = JXG.str2Bool(this.gEBTN(xmlNode, 'dash')); - - tmp = JXG.rgba2rgbo(this.gEBTN(xmlNode, 'color')); - board.options.grid.gridColor = tmp[0]; - board.options.grid.gridOpacity = tmp[1]; - - xmlNode = this.gEBTN(boardData, 'coordinates', 0, false); - if (this.gEBTN(xmlNode, 'grid') == strTrue) { - board.create('grid', []); - } - - if (this.gEBTN(xmlNode, 'coord') == strTrue) { - board.options.axis.ticks.majorHeight = 10; // Hard coded default option - board.options.axis.ticks.minorHeight = 4; // Hard coded default option - board.create('axis', [[0, 0], [1, 0]]); - board.create('axis', [[0, 0], [0, 1]]); - } - - board.containerObj.style.backgroundColor = JXG.rgba2rgbo(this.gEBTN(this.gEBTN(boardData, 'background', 0, false), 'color'))[0]; - - elChildNodes = tree.getElementsByTagName("elements")[0].childNodes; - for (s = 0; s < elChildNodes.length; s++) { - (function (s) { - var i, gxtEl = {}, - l, x, y, c, numberDefEls, - el, p, inter, rgbo, tmp; - - Data = elChildNodes[s]; - gxtEl = gxtReader.defProperties(gxtEl, Data); - - // Skip text nodes - if (!JXG.exists(gxtEl)) { - return; - } - - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName.toLowerCase, 'READ:'); - switch (Data.nodeName.toLowerCase()) { - case "point": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - gxtEl.fixed = JXG.str2Bool(gxtReader.gEBTN(Data, 'fix')); - gxtEl = gxtReader.transformProperties(gxtEl, 'point'); - - //try { - p = board.create('point', [parseFloat(gxtEl.x), parseFloat(gxtEl.y)], gxtEl); - - var v = function(){ return p.visProp.visible; }; - el = gxtReader.parseImage(board, Data, board.options.layer['image'], 0, 0, 0, 0, p); - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - /* - if (JXG.exists(el)) { - el.visProp.visible = function() { return p.visProp.visible; }; - alert(p.visProp.visible); - if (el.visProp.visible()) {el.showElement();} else {el.hideElement();} - } - */ - //} catch(e) { - // JXG.debug(e); - //} - break; - case "line": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - gxtEl = gxtReader.readNodes(gxtEl, Data, 'straight', 'straight'); - gxtEl = gxtReader.transformProperties(gxtEl); - - gxtEl.first = gxtReader.changeOriginIds(board, gxtEl.first); - gxtEl.last = gxtReader.changeOriginIds(board, gxtEl.last); - - l = board.create('line', [gxtEl.first, gxtEl.last], gxtEl); - - gxtReader.parseImage(board, Data, board.options.layer['image'], 0, 0, 0, 0, l); - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case "circle": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - - tmp = gxtReader.gEBTN(Data, 'data', 0, false); - gxtEl.center = gxtReader.changeOriginIds(board, gxtReader.gEBTN(tmp, 'midpoint')); - - if (tmp.getElementsByTagName('radius').length > 0) { - gxtEl.radius = gxtReader.changeOriginIds(board, gxtReader.gEBTN(tmp, 'radius')); - } else if (tmp.getElementsByTagName('radiusvalue').length > 0) { - gxtEl.radius = gxtReader.gEBTN(tmp, 'radiusvalue'); - } - gxtEl = gxtReader.transformProperties(gxtEl); - c = board.create('circle', [gxtEl.center, gxtEl.radius], gxtEl); - - gxtReader.parseImage(board, Data, board.options.layer['image'], 0, 0, 0, 0, c); - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case "slider": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - gxtEl.fixed = JXG.str2Bool(gxtReader.gEBTN(Data, 'fix')); - gxtEl = gxtReader.readNodes(gxtEl, Data, 'animate', 'animate'); - gxtEl = gxtReader.transformProperties(gxtEl, 'point'); - try { - gxtEl.parent = gxtReader.changeOriginIds(board, gxtEl.parent); - - // if (board.isSuspendedUpdate) { board.unsuspendUpdate().suspendUpdate(); } - p = board.create('glider', [parseFloat(gxtEl.x), parseFloat(gxtEl.y), gxtEl.parent], gxtEl); - p.onPolygon = JXG.exists(gxtEl.onpolygon) && JXG.str2Bool(gxtEl.onpolygon); - - gxtReader.parseImage(board, Data, board.options.layer['point'], 0, 0, 0, 0, p); - - //if (board.isSuspendedUpdate) { board.unsuspendUpdate().suspendUpdate(); } - - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - } catch(e) { - JXG.debug("* Err: Slider " + gxtEl.name + " " + gxtEl.id + ': '+ gxtEl.parent +"
\n"); - } - break; - case "cas": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl.fixed = JXG.str2Bool(Data.getElementsByTagName('fix')[0].firstChild.data); - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - gxtEl = gxtReader.transformProperties(gxtEl, 'point'); - - if (false) { // Handle weird element names - gxtEl.x = JXG.GeonextParser.gxt2jc(gxtEl.x, board); - gxtEl.y = JXG.GeonextParser.gxt2jc(gxtEl.y, board); - } else { // Workaround until the jessiecode compiler is 100% compatible - gxtEl.x = JXG.GeonextParser.geonext2JS(gxtEl.x, board); - gxtEl.x = new Function('return ' + gxtEl.x + ';'); - gxtEl.y = JXG.GeonextParser.geonext2JS(gxtEl.y, board); - gxtEl.y = new Function('return ' + gxtEl.y + ';'); - } - - /* - p = board.create('point', [parseFloat(gxtEl.xval), parseFloat(gxtEl.yval)], gxtEl); - p.addConstraint([gxtEl.x, gxtEl.y]); - p.type = JXG.OBJECT_TYPE_CAS; - */ - p = board.create('point', [gxtEl.x, gxtEl.y], gxtEl); - gxtReader.parseImage(board, Data, board.options.layer['point'], 0, 0, 0, 0, p); - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case "intersection": - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - xmlNode = Data.getElementsByTagName('first')[1]; - - gxtEl.outFirst = {}; - gxtEl.outFirst = gxtReader.colorProperties(gxtEl.outFirst, xmlNode); - gxtEl.outFirst = gxtReader.visualProperties(gxtEl.outFirst, xmlNode); - gxtEl.outFirst = gxtReader.firstLevelProperties(gxtEl.outFirst, xmlNode); - gxtEl.outFirst.fixed = JXG.str2Bool(xmlNode.getElementsByTagName('fix')[0].firstChild.data); - gxtEl.outFirst = gxtReader.transformProperties(gxtEl.outFirst, 'point'); - gxtEl.first = gxtReader.changeOriginIds(board, gxtEl.first); - gxtEl.last = gxtReader.changeOriginIds(board, gxtEl.last); - - //if ((board.objects[gxtEl.first].type == JXG.OBJECT_TYPE_LINE || board.objects[gxtEl.first].type == JXG.OBJECT_TYPE_ARROW) - // && (board.objects[gxtEl.last].type == JXG.OBJECT_TYPE_LINE || board.objects[gxtEl.last].type == JXG.OBJECT_TYPE_ARROW)) { - if ((JXG.getReference(board, gxtEl.first).elementClass == JXG.OBJECT_CLASS_LINE) - && (JXG.getReference(board, gxtEl.last).elementClass == JXG.OBJECT_CLASS_LINE)) { - /* - inter = new JXG.Intersection(board, gxtEl.id, board.objects[gxtEl.first], - board.objects[gxtEl.last], gxtEl.outFirst.id, '', - gxtEl.outFirst.name, ''); - inter.p.setProperty(gxtEl.outFirst); - */ - inter = board.create('intersection', [board.objects[gxtEl.first], board.objects[gxtEl.last], 0], gxtEl.outFirst); - /* offensichtlich braucht man dieses if doch */ - if (gxtEl.outFirst.visible == "false") { - inter.hideElement(); - } - } else { - xmlNode = Data.getElementsByTagName('last')[1]; - if (JXG.exists(xmlNode)) { - gxtEl.outLast = {}; - gxtEl.outLast = gxtReader.colorProperties(gxtEl.outLast, xmlNode); - gxtEl.outLast = gxtReader.visualProperties(gxtEl.outLast, xmlNode); - gxtEl.outLast = gxtReader.firstLevelProperties(gxtEl.outLast, xmlNode); - gxtEl.outLast.fixed = JXG.str2Bool(xmlNode.getElementsByTagName('fix')[0].firstChild.data); - gxtEl.outLast = gxtReader.transformProperties(gxtEl.outLast, 'point'); - /* - inter = new JXG.Intersection(board, gxtEl.id, board.objects[gxtEl.first], - board.objects[gxtEl.last], gxtEl.outFirst.id, gxtEl.outLast.id, - gxtEl.outFirst.name, gxtEl.outLast.name); - inter.p1.setProperty(gxtEl.outFirst); - inter.p2.setProperty(gxtEl.outLast); - */ - inter = board.create('intersection', [board.objects[gxtEl.first], board.objects[gxtEl.last], 0], gxtEl.outFirst); - inter = board.create('intersection', [board.objects[gxtEl.first], board.objects[gxtEl.last], 1], gxtEl.outLast); - } - } - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case "composition": - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl.defEl = []; - numberDefEls = 0; - xmlNode = Data.getElementsByTagName('data')[0].getElementsByTagName('input'); - for (i = 0; i < xmlNode.length; i++) { - gxtEl.defEl[i] = xmlNode[i].firstChild.data; - numberDefEls = i + 1; - } - - // every composition produces at least one element and the data for this element is stored - // in gxtEl.out. if additional elements are created their data is read in the according case. - xmlNode = Data.getElementsByTagName('output')[0]; - gxtEl.out = {}; - gxtEl.out = gxtReader.colorProperties(gxtEl.out, xmlNode); - gxtEl.out = gxtReader.visualProperties(gxtEl.out, xmlNode); - gxtEl.out = gxtReader.firstLevelProperties(gxtEl.out, xmlNode); - gxtEl.out = gxtReader.transformProperties(gxtEl.out); - - gxtEl.defEl[0] = gxtReader.changeOriginIds(board, gxtEl.defEl[0]); - gxtEl.defEl[1] = gxtReader.changeOriginIds(board, gxtEl.defEl[1]); - gxtEl.defEl[2] = gxtReader.changeOriginIds(board, gxtEl.defEl[2]); - - // if (board.isSuspendedUpdate) { board.unsuspendUpdate().suspendUpdate(); } - switch (gxtEl.type) { - // ARROW_PARALLEL - case "210070": - gxtEl.out.fixed = gxtReader.gEBTN(xmlNode, 'fix'); - - xmlNode = Data.getElementsByTagName('output')[1]; - gxtEl.outPoint = {}; - gxtEl.outPoint = gxtReader.defProperties(gxtEl.outPoint, xmlNode); - gxtEl.outPoint = gxtReader.colorProperties(gxtEl.outPoint, xmlNode); - gxtEl.outPoint = gxtReader.visualProperties(gxtEl.outPoint, xmlNode); - gxtEl.outPoint = gxtReader.firstLevelProperties(gxtEl.outPoint, xmlNode); - gxtEl.outPoint = gxtReader.transformProperties(gxtEl.outPoint); - gxtEl.out.point = gxtEl.outPoint; - - board.create('arrowparallel', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); - break; - - // BISECTOR - case "210080": - gxtEl.out.straightFirst = false; - board.create('bisector', [gxtEl.defEl[0], gxtEl.defEl[1], gxtEl.defEl[2]], gxtEl.out); - break; - - // CIRCUMCIRCLE - case "210090": - xmlNode = Data.getElementsByTagName('output')[1]; - gxtEl.outCircle = {}; - gxtEl.outCircle = gxtReader.defProperties(gxtEl.outCircle, xmlNode); - gxtEl.outCircle = gxtReader.colorProperties(gxtEl.outCircle, xmlNode); - gxtEl.outCircle = gxtReader.visualProperties(gxtEl.outCircle, xmlNode); - gxtEl.outCircle = gxtReader.firstLevelProperties(gxtEl.outCircle, xmlNode); - gxtEl.outCircle = gxtReader.transformProperties(gxtEl.outCircle); - gxtEl.outCircle.point = gxtEl.out; - board.create('circumcircle', [gxtEl.defEl[0], gxtEl.defEl[1], gxtEl.defEl[2]], gxtEl.outCircle); - break; - - // CIRCUMCIRCLE_CENTER - case "210100": - board.create('circumcenter', [gxtEl.defEl[0], gxtEl.defEl[1], gxtEl.defEl[2]], gxtEl.out); - break; - - // MIDPOINT - case "210110": - board.create('midpoint', gxtEl.defEl.slice(0, numberDefEls), gxtEl.out); - break; - - // MIRRORLINE - case "210120": - board.create('reflection', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); - break; - - // MIRROR_POINT - case "210125": - board.create('mirrorpoint', [gxtEl.defEl[0], gxtEl.defEl[1]], gxtEl.out); - break; - - // NORMAL - case "210130": - //board.create('normal', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); - board.create('perpendicularsegment', [gxtEl.defEl[0], gxtEl.defEl[1]], gxtEl.out); - break; - - // PARALLEL - case "210140": - p = board.create('parallelpoint', [gxtEl.defEl[1], gxtEl.defEl[0]], - {withLabel:false, visible:false, name:'', fixed:true}); - - // GEONExT uses its own parallel construction to make the order - // of intersection points compatible. - // el = board.create('parallel', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); - el = board.create('line', [gxtEl.defEl[0], p], gxtEl.out); - el.parallelpoint = p; - break; - - // PARALLELOGRAM_POINT - case "210150": - board.create('parallelpoint', gxtEl.defEl.slice(0, numberDefEls), gxtEl.out); - break; - - // PERPENDICULAR - case "210160": - // output[0] was already read and is stored in gxtEl.out - gxtEl.out.fixed = gxtReader.gEBTN(xmlNode, 'fix'); - - xmlNode = Data.getElementsByTagName('output')[1]; - gxtEl.outLine = {}; - gxtEl.outLine = gxtReader.defProperties(gxtEl.outLine, xmlNode); - gxtEl.outLine = gxtReader.colorProperties(gxtEl.outLine, xmlNode); - gxtEl.outLine = gxtReader.visualProperties(gxtEl.outLine, xmlNode); - gxtEl.outLine = gxtReader.firstLevelProperties(gxtEl.outLine, xmlNode); - gxtEl.outLine = gxtReader.readNodes(gxtEl.outLine, xmlNode, 'straight', 'straight'); - gxtEl.outLine = gxtReader.transformProperties(gxtEl.outLine); - gxtEl.outLine.point = gxtEl.out; - - board.create('perpendicularsegment', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.outLine); - break; - - // PERPENDICULAR_POINT - case "210170": - board.create('perpendicularpoint', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); - break; - - // ROTATION - case "210180": - throw new Error('JSXGraph: Element ROTATION not yet implemented.'); - break; - - // SECTOR - case "210190": - // sectors usually provide more than one output element but JSXGraph is not fully compatible - // to GEONExT sector elements. GEONExT sectors consist of two lines, a point, and a sector, - // JSXGraph uses a curve to display the sector incl. the borders, and - // a point and two lines. - // Gliders on sectors also run through the borders. - gxtEl.out = gxtReader.defProperties(gxtEl.out, xmlNode); - gxtEl.out.firstArrow = JXG.str2Bool(gxtReader.gEBTN(xmlNode, 'firstarrow')); - gxtEl.out.lastArrow = JXG.str2Bool(gxtReader.gEBTN(xmlNode, 'lastarrow')); - - // el = board.create('sector', gxtEl.defEl, gxtEl.out); - for (i=0; i<4;i++) { - xmlNode = Data.getElementsByTagName('output')[i]; - gxtEl.out = gxtReader.defProperties(gxtEl.out, xmlNode); - gxtEl.out = gxtReader.colorProperties(gxtEl.out, xmlNode); - gxtEl.out = gxtReader.visualProperties(gxtEl.out, xmlNode); - gxtEl.out = gxtReader.firstLevelProperties(gxtEl.out, xmlNode); - gxtEl.out = gxtReader.transformProperties(gxtEl.out); - - if (i==0) { - el = board.create('sector', gxtEl.defEl, gxtEl.out); - } else if (i==1) { - p = board.create('point', [ - function(){ - var p1 = JXG.getRef(board,gxtEl.defEl[1]), p2 = JXG.getRef(board,gxtEl.defEl[2]); - return p1.X() + (p2.X()-p1.X())*el.Radius/p1.Dist(p2); - }, - function(){ - var p1 = JXG.getRef(board,gxtEl.defEl[1]), p2 = JXG.getRef(board,gxtEl.defEl[2]); - return p1.Y() + (p2.Y()-p1.Y())*el.Radius/p1.Dist(p2); - }], gxtEl.out); - //p = JXG.getReference(board,gxtEl.defEl[2]); - } else if (i==2) { - el = board.create('segment', [gxtEl.defEl[0], gxtEl.defEl[1]], gxtEl.out); - } else if (i==3) { - el = board.create('segment', [gxtEl.defEl[1], p], gxtEl.out); - } - } - break; - default: - throw new Error("JSXGraph: GEONExT-Element " + gxtEl.type + ' not implemented.'); - break; - } - - // if (board.isSuspendedUpdate) { board.unsuspendUpdate().suspendUpdate(); } - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case "polygon": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - var dataVertex = []; - // In Geonext file format the first vertex is equal to the last vertex: - for (i = 0; i < Data.getElementsByTagName('data')[0].getElementsByTagName('vertex').length-1; i++) { - dataVertex[i] = Data.getElementsByTagName('data')[0].getElementsByTagName('vertex')[i].firstChild.data; - dataVertex[i] = gxtReader.changeOriginIds(board, dataVertex[i]); - } - gxtEl.border = []; - gxtEl.borders = { - ids: [] - }; - for (i = 0; i < Data.getElementsByTagName('border').length; i++) { - gxtEl.border[i] = {}; - xmlNode = Data.getElementsByTagName('border')[i]; - gxtEl.border[i].id = xmlNode.getElementsByTagName('id')[0].firstChild.data; - gxtEl.borders.ids.push(gxtEl.border[i].id); - gxtEl.border[i].name = xmlNode.getElementsByTagName('name')[0].firstChild.data; - gxtEl.border[i].straightFirst = JXG.str2Bool(xmlNode.getElementsByTagName('straight')[0].getElementsByTagName('first')[0].firstChild.data); - gxtEl.border[i].straightLast = JXG.str2Bool(xmlNode.getElementsByTagName('straight')[0].getElementsByTagName('last')[0].firstChild.data); - gxtEl.border[i].strokeWidth = xmlNode.getElementsByTagName('strokewidth')[0].firstChild.data; - gxtEl.border[i].dash = JXG.str2Bool(xmlNode.getElementsByTagName('dash')[0].firstChild.data); - gxtEl.border[i].visible = JXG.str2Bool(xmlNode.getElementsByTagName('visible')[0].firstChild.data); - gxtEl.border[i].draft = JXG.str2Bool(xmlNode.getElementsByTagName('draft')[0].firstChild.data); - gxtEl.border[i].trace = JXG.str2Bool(xmlNode.getElementsByTagName('trace')[0].firstChild.data); - - xmlNode = Data.getElementsByTagName('border')[i].getElementsByTagName('color')[0]; - rgbo = JXG.rgba2rgbo(xmlNode.getElementsByTagName('stroke')[0].firstChild.data); - gxtEl.border[i].strokeColor = rgbo[0]; - gxtEl.border[i].strokeOpacity = rgbo[1]; - - rgbo = JXG.rgba2rgbo(xmlNode.getElementsByTagName('lighting')[0].firstChild.data); - gxtEl.border[i].highlightStrokeColor = rgbo[0]; - gxtEl.border[i].highlightStrokeOpacity = rgbo[1]; - - rgbo = JXG.rgba2rgbo(xmlNode.getElementsByTagName('fill')[0].firstChild.data); - gxtEl.border[i].fillColor = rgbo[0]; - gxtEl.border[i].fillOpacity = rgbo[1]; - - gxtEl.border[i].highlightFillColor = gxtEl.border[i].fillColor; - gxtEl.border[i].highlightFillOpacity = gxtEl.border[i].fillOpacity; - - gxtEl.border[i].labelColor = xmlNode.getElementsByTagName('label')[0].firstChild.data; - gxtEl.border[i].colorDraft = xmlNode.getElementsByTagName('draft')[0].firstChild.data; - } - gxtEl = gxtReader.transformProperties(gxtEl); - p = board.create('polygon', dataVertex, gxtEl); - - // to emulate the geonext behaviour on invisible polygons - // A.W.: Why do we need this? -/* - if (!gxtEl.visible) { - p.setProperty({ - fillColor: 'none', - highlightFillColor: 'none' - }); - } -*/ - for (i = 0; i < p.borders.length; i++) { - p.borders[i].setProperty(gxtEl.border[i]); - } - - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case "graph": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl.funct = Data.getElementsByTagName('data')[0].getElementsByTagName('function')[0].firstChild.data; - if (false) { - gxtEl.funct = JXG.GeonextParser.gxt2jc(gxtEl.funct, board); // Handle weird element names - } else { // Workaround until the jessiecode compiler is 100% compatible - gxtEl.funct = JXG.GeonextParser.geonext2JS(gxtEl.funct, board); - gxtEl.funct = new Function('x', 'return ' + gxtEl.funct + ';'); - } - - c = board.create('curve', ['x', gxtEl.funct], { - id: gxtEl.id, - name: gxtEl.name, - strokeColor: gxtEl.strokeColor, - strokeWidth: gxtEl.strokeWidth, - fillColor: 'none', - highlightFillColor: 'none', - highlightStrokeColor: gxtEl.highlightStrokeColor, - visible: JXG.str2Bool(gxtEl.visible) - }); - - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case "arrow": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - gxtEl = gxtReader.readNodes(gxtEl, Data, 'straight', 'straight'); - - gxtEl = gxtReader.transformProperties(gxtEl); - gxtEl.first = gxtReader.changeOriginIds(board, gxtEl.first); - gxtEl.last = gxtReader.changeOriginIds(board, gxtEl.last); - - l = board.create('arrow', [gxtEl.first, gxtEl.last], gxtEl); - - gxtReader.printDebugMessage('debug', l, Data.nodeName, 'OK'); - break; - case "arc": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - - gxtEl.firstArrow = JXG.str2Bool(Data.getElementsByTagName('lastarrow')[0].firstChild.data); // It seems that JSXGraph and GEONExT - gxtEl.lastArrow = JXG.str2Bool(Data.getElementsByTagName('firstarrow')[0].firstChild.data); // use opposite directions. - - gxtEl = gxtReader.transformProperties(gxtEl); - - gxtEl.center = gxtReader.changeOriginIds(board, gxtEl.midpoint); - gxtEl.angle = gxtReader.changeOriginIds(board, gxtEl.angle); - gxtEl.radius = gxtReader.changeOriginIds(board, gxtEl.radius); - - c = board.create('arc', [gxtEl.center, gxtEl.radius, gxtEl.angle], gxtEl); - - gxtReader.printDebugMessage('debug', c, Data.nodeName, 'OK'); - break; - case "angle": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - gxtEl = gxtReader.transformProperties(gxtEl); - - tmp = gxtEl.name; - try { - gxtEl.name = Data.getElementsByTagName('text')[0].firstChild.data; - } catch (e) { - gxtEl.name = ''; - } - c = board.create('angle', [gxtEl.first, gxtEl.middle, gxtEl.last], gxtEl); - c.setProperty({name:tmp}); - - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case "text": - if (gxtEl.id.match(/oldVersion/)) { - break; - } - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - gxtEl.mpStr = gxtReader.subtreeToString(Data.getElementsByTagName('data')[0].getElementsByTagName('mp')[0]); - gxtEl.mpStr = gxtEl.mpStr.replace(/<\/?mp>/g, ''); - gxtEl.fixed = false; - try { - if (Data.getElementsByTagName('data')[0].getElementsByTagName('parent')[0].firstChild) { - gxtEl.parent = Data.getElementsByTagName('data')[0].getElementsByTagName('parent')[0].firstChild.data; - gxtEl.fixed = true; - } - } catch (e) { - } - - gxtEl.condition = Data.getElementsByTagName('condition')[0].firstChild.data; - gxtEl.content = Data.getElementsByTagName('content')[0].firstChild.data; - gxtEl.fix = Data.getElementsByTagName('fix')[0].firstChild.data; - // not used: gxtEl.digits = Data.getElementsByTagName('cs')[0].firstChild.data; - gxtEl.autodigits = Data.getElementsByTagName('digits')[0].firstChild.data; - gxtEl.parent = gxtReader.changeOriginIds(board, gxtEl.parent); - - c = board.create('text', [gxtEl.x, gxtEl.y, gxtEl.mpStr], { - anchor: gxtEl.parent, - id: gxtEl.id, - name: gxtEl.name, - digits: gxtEl.autodigits, - isLabel: false, - strokeColor: gxtEl.colorLabel, - fixed: gxtEl.fixed, - visible: JXG.str2Bool(gxtEl.visible) - }); - break; - case 'parametercurve': - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl = gxtReader.transformProperties(gxtEl); - gxtEl.functionx = Data.getElementsByTagName('functionx')[0].firstChild.data; - gxtEl.functiony = Data.getElementsByTagName('functiony')[0].firstChild.data; - gxtEl.min = Data.getElementsByTagName('min')[0].firstChild.data; - gxtEl.max = Data.getElementsByTagName('max')[0].firstChild.data; - /* - gxtEl.functionx = JXG.GeonextParser.gxt2jc(gxtEl.functionx, board); - gxtEl.functiony = JXG.GeonextParser.gxt2jc(gxtEl.functiony, board); - gxtEl.min = JXG.GeonextParser.gxt2jc(gxtEl.min, board); - gxtEl.max = JXG.GeonextParser.gxt2jc(gxtEl.max, board); - */ - gxtEl.fillColor = 'none'; - gxtEl.highlightFillColor = 'none'; - - board.create('curve', - [ new Function('t', 'return ' + JXG.GeonextParser.geonext2JS(gxtEl.functionx, board) + ';' ), - new Function('t', 'return ' + JXG.GeonextParser.geonext2JS(gxtEl.functiony, board) + ';' ), - new Function('return ' + JXG.GeonextParser.geonext2JS(gxtEl.min, board) + ';' ), - new Function('return ' + JXG.GeonextParser.geonext2JS(gxtEl.max, board) + ';' ) - ], gxtEl); - /* - c = new JXG.Curve(board, [ - 't',gxtEl.functionx,gxtEl.functiony,gxtEl.min,gxtEl.max - ], gxtEl.id, gxtEl.name); - c.setProperty('strokeColor:' + gxtEl.colorStroke, 'strokeWidth:' + gxtEl.strokewidth, 'fillColor:none', - 'highlightStrokeColor:' + gxtEl.highlightStrokeColor); - */ - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case 'tracecurve': - gxtEl.tracepoint = Data.getElementsByTagName('tracepoint')[0].firstChild.data; - gxtEl.traceslider = Data.getElementsByTagName('traceslider')[0].firstChild.data; - board.create('tracecurve', [gxtEl.traceslider, gxtEl.tracepoint], gxtEl); - // JXG.getRef(board, gxtEl.tracepoint).setProperty({trace:true}); - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case 'group': - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl.members = [ - ]; - for (i = 0; i < Data.getElementsByTagName('data')[0].getElementsByTagName('member').length; i++) { - gxtEl.members[i] = Data.getElementsByTagName('data')[0].getElementsByTagName('member')[i].firstChild.data; - gxtEl.members[i] = gxtReader.changeOriginIds(board, gxtEl.members[i]); - } - c = new JXG.Group(board, gxtEl.id, gxtEl.name, gxtEl.members); - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - default: - JXG.debug("* Err: " + Data.nodeName + " not yet implemented
\n"); - } - delete(gxtEl); - })(s); - } - board.addConditions(conditions); - }, - - decodeString: function(str) { - var unz; - if (str.indexOf("")<0){ - unz = (new JXG.Util.Unzip(JXG.Util.Base64.decodeAsArray(str))).unzip(); // war Gunzip ME - if (unz=="") - return str; - else - return unz; - } else { - return str; - } - }, - - prepareString: function(fileStr){ - try { - if (fileStr.indexOf('GEONEXT')<0) { - fileStr = (this.decodeString(fileStr))[0][0]; // Base64 decoding - } - // Hacks to enable not well formed XML. Will be redone in Algebra.geonext2JS and Board.addConditions - fileStr = this.fixXML(fileStr); - } catch(e) { - fileStr = ''; - } - return fileStr; - }, - - fixXML: function(str) { - var arr = ["active", "angle", "animate", "animated", "arc", "area", "arrow", "author", "autodigits", "axis", "back", "background", "board", "border", "bottom", "buttonsize", "cas", "circle", "color", "comment", "composition", "condition", "conditions", "content", "continuous", "control", "coord", "coordinates", "cross", "cs", "dash", "data", "description", "digits", "direction", "draft", "editable", "elements", "event", "file", "fill", "first", "firstarrow", "fix", "fontsize", "free", "full", "function", "functionx", "functiony", "GEONEXT", "graph", "grid", "group", "height", "id", "image", "info", "information", "input", "intersection", "item", "jsf", "label", "last", "lastarrow", "left", "lefttoolbar", "lighting", "line", "loop", "max", "maximized", "member", "middle", "midpoint", "min", "modifier", "modus", "mp", "mpx", "multi", "name", "onpolygon", "order", "origin", "output", "overline", "parametercurve", "parent", "point", "pointsnap", "polygon", "position", "radius", "radiusnum", "radiusvalue", "right", "section", "selectedlefttoolbar", "showconstruction", "showcoord", "showinfo", "showunit", "showx", "showy", "size", "slider", "snap", "speed", "src", "start", "stop", "straight", "stroke", "strokewidth", "style", "term", "text", "top", "trace", "tracecurve", "tracepoint", "traceslider", "type", "unit", "value", "VERSION", "vertex", "viewport", "visible", "width", "wot", "x", "xooy", "xval", "y", "yval", "zoom"], - list = arr.join('|'), - regex = '\<(/?('+list+'))\>', - expr = new RegExp(regex,'g'); - - // First, we convert all < to < and > to > - str = JXG.escapeHTML(str); - // Second, we convert all GEONExT tags of the form <tag> back to - str = str.replace(expr,'<$1>'); - - str = str.replace(/(.*)(.*<\/content>)/g,'$1<arc>$2'); - str = str.replace(/(.*)(.*<\/mpx>)/g,'$1<arc>$2'); - str = str.replace(/(.*)(.*<\/mpx>)/g,'$1<arc>$2'); - return str; - } - -}; // end: GeonextReader diff --git a/ajax/libs/jsxgraph/0.94/IntergeoReader.js b/ajax/libs/jsxgraph/0.94/IntergeoReader.js deleted file mode 100644 index 4a5aacaba..000000000 --- a/ajax/libs/jsxgraph/0.94/IntergeoReader.js +++ /dev/null @@ -1,967 +0,0 @@ -/* - Copyright 2008,2009 - Matthias Ehmann, - Michael Gerhaeuser, - Carsten Miller, - Bianca Valentin, - Alfred Wassermann, - Peter Wilfahrt - - This file is part of JSXGraph. - - JSXGraph is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - JSXGraph is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with JSXGraph. If not, see . - -*/ - -/* Compatibility for <= 0.75.4 */ -/* -JXG.getReference = function(board, object) { - return JXG.GetReferenceFromParameter(board, object); -}; -*/ - -JXG.IntergeoReader = new function() { - this.board = null; - /** - * this.objects holds all objects from the XML file. - * Every object hets an attribute "exists" - */ - this.objects = {}; - - this.readIntergeo = function(tree,board) { - this.board = board; - this.board.origin = {}; - this.board.origin.usrCoords = [1, 0, 0]; - this.board.origin.scrCoords = [1, 400, 300]; - this.board.unitX = 30; - this.board.unitY = 30; - - this.readElements(tree.getElementsByTagName("elements")); - this.readConstraints(tree.getElementsByTagName("constraints")); - this.cleanUp(); - this.board.fullUpdate(); - this.readDisplay(tree.getElementsByTagName("display")); - this.board.fullUpdate(); - }; - - /** - * Element part - */ - this.readElements = function(tree) { - var s; - for (var s=0;s1) { return; } // not an element node - if (node.nodeName=='point') { - JXG.IntergeoReader.storePoint(node); //addPoint(node); - } - else if (node.nodeName=='line' - || node.nodeName=='line_segment' - || node.nodeName=='ray' - || node.nodeName=='vector' - ) { - JXG.IntergeoReader.storeLine(node); - } - else if (node.nodeName=='circle') { - JXG.IntergeoReader.storeConic(node); - } - else if (node.nodeName=='conic') { - JXG.IntergeoReader.storeConic(node); - } - else if (node.nodeName=='polygon') { - // ignore, see this.addPolygonByVertices - } - else { - JXG.debug('Not implemented: '+node.nodeName + ' ' + node.getAttribute('id')); - } - })(s); - }; - - /** - * Points are created instantly via create - */ - this.addPointOld = function(node) { - var i = 0, - j = 0, - l = 0, - el, - p = node.childNodes[i], - c = [], - attributes = {strokeColor:'red', fillColor:'red', withLabel:true}, - parents = []; - - while (p.nodeType>1) { // skip non element nodes - i++; - p = node.childNodes[i]; - } - - attributes['name'] = node.getAttribute('id'); - - if (p.nodeName == 'homogeneous_coordinates') { - for (j=0;j... - } else if (p.childNodes[j].nodeName=='complex') { - for (l=0;l - return; - } - } - } - for (j=0;j - return; - } - } else if (p.nodeName == 'euclidean_coordinates') { - for (j=0;j... - } - } - for (j=0;j... - } - } - for (j=0;j1) { // skip non element nodes - i++; - p = node.childNodes[i]; - } - - if (p.nodeName == 'homogeneous_coordinates') { - for (j=0;j... - } else if (p.childNodes[j].nodeName=='complex') { - for (l=0;l - return; - } - } - } - for (j=0;j - return; - } - } else if (p.nodeName == 'euclidean_coordinates' || p.nodeName == 'euclidian_coordinates') { // the latter one is a workaround for faulty i2g construction exported by DynaGeo - for (j=0;j... - } - } - for (j=0;j... - } - } - for (j=0;j1) { // skip non element nodes - i++; - p = node.childNodes[i]; - } - if (p.nodeName == 'homogeneous_coordinates') { - c = []; - for (j=0;j... - } else { - //$('debug').innerHTML += 'Not: '+ p.childNodes[j].nodeName + '
'; // - } - } - } - this.objects[node.getAttribute('id')].coords = c; - this.objects[node.getAttribute('id')].id = node.getAttribute('id'); - this.objects[node.getAttribute('id')].exists = false; - this.objects[node.getAttribute('id')].i2geoType = 'line'; - } - //this.addLine(node.getAttribute('id')); - }; - - /** - * Circle / conic data is stored in an array - * for further access during the reading of constraints. - * There, id and name are needed. - * Concretely, the circle (x-1)^2 + (y-3)^2 = 4 has matrix - * ( 1 0 -1 ) - * ( 0 1 -3 ) - * ( -1 -3 6 ) - * - * In general - * Ax^2+Bxy+Cy^2+Dx+Ey+F = 0 - * is stored as - * ( A B/2 D/2 ) - * ( B/2 C E/2 ) - * ( D/2 E/2 F ) - * - * Mx = D/A - * My = E/C - * r = A*Mx^2+B*My^2-F - **/ - this.storeConic = function(node) { - var i, j, p, c; - - this.objects[node.getAttribute('id')] = {'id':node.getAttribute('id'), 'coords':null}; - i = 0; - p = node.childNodes[i]; - while (p.nodeType>1) { // skip non element nodes - i++; - p = node.childNodes[i]; - } - if (p.nodeName == 'matrix') { - c = []; - for (j=0;j... - } else { - //$('debug').innerHTML += 'Not: '+ p.childNodes[j].nodeName + '
'; // - } - } - } - this.objects[node.getAttribute('id')].coords = c; - this.objects[node.getAttribute('id')].id = node.getAttribute('id'); - this.objects[node.getAttribute('id')].exists = false; - this.objects[node.getAttribute('id')].i2geoType = 'conic'; - } - }; - - /** - * Constraint part - */ - this.readConstraints = function(tree) { - var s, param; - - // Set the default colors of dependent elements - this.board.options.point.strokeColor = 'blue'; - this.board.options.point.fillColor = 'blue'; - - for (s=0;s1) { return; } // not an element node - if (node.nodeName=='line_through_two_points') { - JXG.IntergeoReader.addLineThroughTwoPoints(node, false); - } - else if (node.nodeName=='ray_from_point_through_point') { - JXG.IntergeoReader.addLineThroughTwoPoints(node, true); - } - else if (node.nodeName=='line_through_point') { - JXG.IntergeoReader.addLineThroughPoint(node); - } - else if (node.nodeName=='line_parallel_to_line_through_point') { - JXG.IntergeoReader.addLineParallelToLineThroughPoint(node, false); - } - else if (node.nodeName=='ray_from_point_and_vector') { - JXG.IntergeoReader.addLineParallelToLineThroughPoint(node, true); - } - else if (node.nodeName=='line_perpendicular_to_line_through_point') { - JXG.IntergeoReader.addLinePerpendicularToLineThroughPoint(node); - } - else if (node.nodeName=='line_segment_by_points') { - JXG.IntergeoReader.addLineSegmentByTwoPoints(node); - } - else if (node.nodeName=='vector_from_point_to_point') { - JXG.IntergeoReader.addVectorFromPointToPoint(node); - } - else if (node.nodeName=='endpoints_of_line_segment') { - JXG.IntergeoReader.addEndpointsOfLineSegment(node); - } - else if (node.nodeName=='free_point') { - // do nothing - } - else if (node.nodeName=='free_line') { - JXG.IntergeoReader.addFreeLine(node); - } - else if (node.nodeName=='point_on_line') { - JXG.IntergeoReader.addPointOnLine(node); - } - else if (node.nodeName=='point_on_line_segment') { - JXG.IntergeoReader.addPointOnLine(node); - } - else if (node.nodeName=='point_on_circle') { - JXG.IntergeoReader.addPointOnCircle(node); - } - else if (node.nodeName=='angular_bisector_of_three_points') { - JXG.IntergeoReader.addAngularBisectorOfThreePoints(node, false); - } - else if (node.nodeName=='angular_bisectors_of_two_lines') { - JXG.IntergeoReader.addAngularBisectorsOfTwoLines(node, false); - } - else if (node.nodeName=='line_angular_bisector_of_three_points') { - JXG.IntergeoReader.addAngularBisectorOfThreePoints(node, true); - } - else if (node.nodeName=='line_angular_bisectors_of_two_lines') { - JXG.IntergeoReader.addAngularBisectorsOfTwoLines(node, true); - } - else if (node.nodeName=='midpoint_of_two_points') { - JXG.IntergeoReader.addMidpointOfTwoPoints(node); - } - else if (node.nodeName=='midpoint') { - JXG.IntergeoReader.addMidpointOfTwoPoints(node); - } - else if (node.nodeName=='midpoint_of_line_segment' || node.nodeName=='midpoint_line_segment') { - JXG.IntergeoReader.addMidpointOfLineSegment(node); - } - else if (node.nodeName=='point_intersection_of_two_lines') { - JXG.IntergeoReader.addPointIntersectionOfTwoLines(node); - } - else if (node.nodeName=='locus_defined_by_point') { - JXG.IntergeoReader.addLocusDefinedByPoint(node); - } - else if (node.nodeName=='locus_defined_by_point_on_line') { - JXG.IntergeoReader.addLocusDefinedByPointOnLine(node); - } - else if (node.nodeName=='locus_defined_by_point_on_line_segment') { - JXG.IntergeoReader.addLocusDefinedByPointOnLine(node); - } - else if (node.nodeName=='locus_defined_by_line_through_point') { - JXG.IntergeoReader.addLocusDefinedByLineThroughPoint(node); - } - else if (node.nodeName=='locus_defined_by_point_on_circle') { - JXG.IntergeoReader.addLocusDefinedByPointOnCircle(node); - } - else if (node.nodeName=='circle_by_three_points') { - JXG.IntergeoReader.addCircleByThreePoints(node); - } - else if (node.nodeName=='circle_by_center_and_point') { - JXG.IntergeoReader.addCircleByCenterAndPoint(node); - } - else if (node.nodeName=='center_of_circle') { - JXG.IntergeoReader.addCenterOfCircle(node); - } - else if (node.nodeName=='intersection_points_of_two_circles') { - JXG.IntergeoReader.addIntersectionPointsOfTwoCircles(node); - } - else if (node.nodeName=='intersection_points_of_circle_and_line') { - JXG.IntergeoReader.addIntersectionPointsOfCircleAndLine(node); - } - else if (node.nodeName=='other_intersection_point_of_two_circles') { - JXG.IntergeoReader.addOtherIntersectionPointOfTwoCircles(node); - } - else if (node.nodeName=='other_intersection_point_of_circle_and_line') { - JXG.IntergeoReader.addOtherIntersectionPointOfCircleAndLine(node); - } - else if (node.nodeName=='circle_tangent_lines_by_point') { - JXG.IntergeoReader.addCircleTangentLinesByPoint(node); - } - else if (node.nodeName=='polygon_by_vertices') { - JXG.IntergeoReader.addPolygonByVertices(node); - } - else { - param = JXG.IntergeoReader.readParams(node); - JXG.debug('readConstraints: not implemented: ' + node.nodeName + ': ' + param[0]); - } - })(s); - }; - - this.setAttributes = function(o) { - o.setProperty({strokecolor:this.board.options.point.strokeColor,fillColor:this.board.options.point.fillColor}); - }; - - this.readParams = function(node) { - var param = [], j; - for (j=0;j1) { return; } // not an element node - if (node.nodeName=='background-color') { - this.board.containerObj.style.backgroundColor = node.firstChild.data; - } - else if (node.nodeName=='style') { - el = JXG.getReference(this.board,node.getAttribute('ref')); // get the element - var param = [], j; - for (j=0;jend: "+ v1); - return v1; - break; - case 'coord': - s1 = (JXG.GeogebraReader.board.ggbElements[v1]) ? 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'")' : v1; - s2 = (JXG.GeogebraReader.board.ggbElements[v2]) ? 'JXG.getRef(JXG.GeogebraReader.board, "'+ v2 +'")' : v2; - return [s1, s2]; - break; - case 'le': // smaller then - return '( ('+ v1 +') <= ('+ v2 +') )'; - break; - case 'ge': // greater then - return '( ('+ v1 +') >= ('+ v2 +') )'; - break; - case 'eq': // equal - return '( ('+ v1 +') == ('+ v2 +') )'; - break; - case 'neq': // not equal - return '( ('+ v1 +') != ('+ v2 +') )'; - break; - case 'lt': // smaller - return '( ('+ v1 +') < ('+ v2 +') )'; - break; - case 'gt': // greater - return '( ('+ v1 +') > ('+ v2 +') )'; - break; - case 'add': - if (JXG.GeogebraReader.isGGBVector(v1) && JXG.GeogebraReader.isGGBVector(v2)){ //Add: Vector + Vector - return [1, v1[1] + '+' + v2[1], v1[2] + '+' + v2[2]]; - } - if( JXG.isString(v1) && !v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v1.match(/JXG\.getRef/) ) { - s1 = [v1+'.X()', v1+'.Y()']; - } else { - s1 = v1; - } - - if( JXG.isString(v2) && !v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v2.match(/JXG\.getRef/) ) { - s2 = [v2+'.X()', v2+'.Y()']; - } else { - s2 = v2; - } - - if (JXG.GeogebraReader.isGGBVector(s1) && JXG.isArray(s2)){ //Add: Vector + Point - return [s1[1] + '+' + s2[0], s1[2] + '+' + s2[1]]; - } - - if (JXG.GeogebraReader.isGGBVector(s2) && JXG.isArray(s1)){ //Add: Vector + Point - return [s2[1] + '+' + s1[0], s2[2] + '+' + s1[1]]; - } - - if( JXG.isArray(s1) && JXG.isArray(s2) ) { - return [ s1[0] +' + '+ s2[0], s1[1] +' + '+ s2[1] ]; - } - else if( (JXG.isNumber(s1) || JXG.isString(s1)) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { - return s1 +' + '+ s2; - } - else if( (JXG.isNumber(s1) || JXG.isString(s1)) && JXG.isArray(s2) ) { - return [ s1 +' + '+ s2[0], s1 +' + '+ s2[1] ]; - } - else if( JXG.isArray(s1) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { - return [ s1[0] +' + '+ s2, s1[1] +' + '+ s2 ]; - } - else { - return s1 +' + '+ s2; - } - break; - case 'sub': - if (JXG.GeogebraReader.isGGBVector(v1) && JXG.GeogebraReader.isGGBVector(v2)){ //Sub: Vector - Vector - return [1, v1[1] + '-' + v2[1], v1[2] + '-' + v2[2]]; - } - - if( JXG.isString(v1) && !v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v1.match(/JXG\.getRef/) ) { - s1 = [v1+'.X()', v1+'.Y()']; - } else { - s1 = v1; - } - - if( JXG.isString(v2) && !v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v2.match(/JXG\.getRef/) ) { - s2 = [v2+'.X()', v2+'.Y()']; - } else { - s2 = v2; - } - - if (JXG.GeogebraReader.isGGBVector(s1) && JXG.isArray(s2)){ //Add: Vector - Point - return [s1[1] + '-' + s2[0], s1[2] + '-' + s2[1]]; - } - - if (JXG.isArray(s1) && JXG.GeogebraReader.isGGBVector(s2)){ //Add: Punkt - Vector - return [s1[0] + '-(' + s2[1] + ')', s1[1] + '-(' + s2[2] +')']; - } - - if( JXG.isArray(s1) && JXG.isArray(s2) ) { - return [ s1[0] +' - '+ s2[0], s1[1] +' - '+ s2[1] ]; - } - else if( (JXG.isNumber(s1) || JXG.isString(s1)) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { - return s1 +' - '+ s2; - } - else if( (JXG.isNumber(s1) || JXG.isString(s1)) && JXG.isArray(s2) ) { - return [ s1 +' - '+ s2[0], s1 +' - '+ s2[1] ]; - } - else if( JXG.isArray(s1) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { - return [ s1[0] +' - '+ s2, s1[1] +' - '+ s2 ]; - } - else { - return s1 +' - '+ s2; - } - break; - case 'neg': - return '!('+ v1 +')'; - break; - case 'pow': - return 'Math.pow('+ v1 +', '+ v2 +')'; - break; - case 'or': - return '('+ v1 +'||'+ v2 +')'; - break; - case 'and': - return '('+ v1 +'&&'+ v2 +')'; - break; - case 'mul': - if (JXG.GeogebraReader.isGGBVector(v1) && !JXG.isArray(v2)){ // Mult: Vector * Skalar - return [1,'(' + v1[1] + ')*'+v2,'(' + v1[2] + ')*'+v2]; - } else if (!JXG.isArray(v1) && JXG.GeogebraReader.isGGBVector(v2)){ // Mult: Skalar * Vector - return new Array(1,'(' + v2[1] + ')*'+v1,'(' + v2[2] + ')*'+v1); - } else if (JXG.GeogebraReader.isGGBVector(v1) && JXG.GeogebraReader.isGGBVector(v2)){ //Mult: Vector * Vector - return '((' + v1[1] + ')*('+v2[1]+')+('+ v1[2] + ')*('+v2[2]+'))'; - } else { // Rest - if( JXG.isString(v1) && !v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v1.match(/JXG\.getRef/) ) { - s1 = [v1+'.X()', v1+'.Y()']; - } else { - s1 = v1; - } - - if( JXG.isString(v2) && !v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v2.match(/JXG\.getRef/) ) { - s2 = [v2+'.X()', v2+'.Y()']; - } else { - s2 = v2; - } - - if( JXG.isArray(s1) && JXG.isArray(s2) ) { - return [ s1[0] +' * '+ s2[0], s1[1] +' * '+ s2[1] ]; - } - else if( (JXG.isNumber(s1) || JXG.isString(s1)) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { - return s1 +' * '+ s2; - } - else if( (JXG.isNumber(s1) || JXG.isString(s1)) && JXG.isArray(s2) ) { - return [ s1 +' * '+ s2[0], s1 +' * '+ s2[1] ]; - } - else if( JXG.isArray(s1) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { - return [ s1[0] +' * '+ s2, s1[1] +' * '+ s2 ]; - } - else { - return s1 +' * '+ s2; - } - } - break; - case 'div': - if( JXG.isString(v1) && !v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v1.match(/JXG\.getRef/) ) { - s1 = [v1+'.X()', v1+'.Y()']; - } else { - s1 = v1; - } - - if( JXG.isString(v2) && !v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./) && v2.match(/JXG\.getRef/) ) { - s2 = [v2+'.X()', v2+'.Y()']; - } else { - s2 = v2; - } - - if( JXG.isArray(s1) && JXG.isArray(s2) ) { - return [ s1[0] +' / '+ s2[0], s1[1] +' / '+ s2[1] ]; - } - else if( (JXG.isNumber(s1) || JXG.isString(s1)) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { - return s1 +' / '+ s2; - } - else if( (JXG.isNumber(s1) || JXG.isString(s1)) && JXG.isArray(s2) ) { - return [ s1 +' / '+ s2[0], s1 +' / '+ s2[1] ]; - } - else if( JXG.isArray(s1) && (JXG.isNumber(s2) || JXG.isString(s2)) ) { - return [ s1[0] +' / '+ s2, s1[1] +' / '+ s2 ]; - } - else { - return s1 +' / '+ s2; - } - break; - case 'negmult': - if (JXG.GeogebraReader.isGGBVector(v1)) - return new Array(1, -1 + '*' + v1[1],-1 + '*' + v1[2]); - return -1 +'*'+ v1; - break; - case 'bra': - if (JXG.GeogebraReader.isGGBVector(v1)) - return new Array(1,'(' + v1[1] + ')','(' + v1[2] + ')'); - return '('+ v1 +')'; - break; - case 'int': - return parseInt(v1); - break; - case 'float': - return parseFloat(v1); - break; - case 'param': - return v1; - break; - case 'html': - return v1; - break; - case 'string': - if(v2) return [v1, v2]; - else return v1; - break; - case 'command': - v2 = v1.split('['); - s1 = v2[0]; - s2 = (v2[1].split(']'))[0]; - switch(s1.toLowerCase()) { - case 'name': - return 'JXG.getRef(JXG.GeogebraReader.board, "'+ s2 +'").getName()'; //TODO korrigiere getName() - break; - } - break; - case 'var': - if(v2) { - switch(v1.toLowerCase()) { - case 'x': - return v2 +'.X()'; - break; - case 'y': - return v2 +'.Y()'; - break; - case 'abs': - case 'acos': - case 'asin': - case 'atan': - case 'ceil': - case 'cos': - case 'exp': - case 'floor': - case 'log': - case 'max': - case 'min': - case 'pow': - case 'random': - case 'round': - case 'sin': - case 'sqrt': - case 'tan': - return 'Math.'+v1.toLowerCase()+'('+ v2 +')'; - break; - default: - return v1.toLowerCase()+'*('+ v2 +')'; - break; - } - } else { - - if(v1 == 'PI') { - return 'Math.PI'; - } else { - a = JXG.GeogebraReader.checkElement(v1); - if(typeof JXG.GeogebraReader.board.ggb[v1] != 'undefined') { - return 'JXG.GeogebraReader.board.ggb["'+ v1 +'"]()'; - } else if(typeof a.Value != 'undefined') { - return 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").Value()'; - } else if(typeof a.Area != 'undefined') { - return 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").Area()'; - } else if(typeof a.plaintextStr != 'undefined') { - return '1.0*JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").plaintextStr'; - } else if (a.type == JXG.OBJECT_TYPE_VECTOR){ - return new Array(1, 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point2.X()-JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point1.X()','JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point2.Y()-JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point1.Y()'); - }else if(a.elementClass == JXG.OBJECT_CLASS_LINE) { - return 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point1.Dist(JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'").point2)'; - } else { - return 'JXG.getRef(JXG.GeogebraReader.board, "'+ v1 +'")'; - } - } - } - break; - } -}; - -/** - * JS/CC parser to convert the input expression to a working javascript function. - * @param {Object} board object - * @param {Object} element Element that needs to be updated - * @param {String} exp String which contains the function, expression or information - */ -this.ggbParse = function(exp, element) { - var element = (element) ? JXG.getRef(JXG.GeogebraReader.board, JXG.GeogebraReader.board.ggbElements[element].id) : false; - if(element) JXG.debug("Zu aktualisierendes Element: "+ element.name + "("+ element.id +")"); - -/* - This parser was generated with: The LALR(1) parser and lexical analyzer generator for JavaScript, written in JavaScript - In the version 0.30 on http://jscc.jmksf.com/ - - It is based on the default template driver for JS/CC generated parsers running as - browser-based JavaScript/ECMAScript applications and was strongly modified. - - The parser was written 2007, 2008 by Jan Max Meyer, J.M.K S.F. Software Technologies - This is in the public domain. -*/ - -/***** begin replace *****/ - var _dbg_withtrace = false; - var _dbg_string = new String(); - - function __dbg_print( text ) { - _dbg_string += text + "\n"; - } - - function __lex( info ) { - var state = 0; - var match = -1; - var match_pos = 0; - var start = 0; - var pos = info.offset + 1; - - do - { - pos--; - state = 0; - match = -2; - start = pos; - - if( info.src.length <= start ) - return 28; - - do - { - - switch( state ) - { - case 0: - if( info.src.charCodeAt( pos ) == 9 || info.src.charCodeAt( pos ) == 32 ) state = 1; - else if( info.src.charCodeAt( pos ) == 33 ) state = 2; - else if( info.src.charCodeAt( pos ) == 40 ) state = 3; - else if( info.src.charCodeAt( pos ) == 41 ) state = 4; - else if( info.src.charCodeAt( pos ) == 42 ) state = 5; - else if( info.src.charCodeAt( pos ) == 43 ) state = 6; - else if( info.src.charCodeAt( pos ) == 44 ) state = 7; - else if( info.src.charCodeAt( pos ) == 45 ) state = 8; - else if( info.src.charCodeAt( pos ) == 47 ) state = 9; - else if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 10; - else if( info.src.charCodeAt( pos ) == 60 ) state = 11; - else if( info.src.charCodeAt( pos ) == 62 ) state = 12; - else if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 13; - else if( info.src.charCodeAt( pos ) == 94 ) state = 14; - else if( info.src.charCodeAt( pos ) == 34 ) state = 26; - else if( info.src.charCodeAt( pos ) == 38 ) state = 28; - else if( info.src.charCodeAt( pos ) == 46 ) state = 29; - else if( info.src.charCodeAt( pos ) == 61 ) state = 30; - else if( info.src.charCodeAt( pos ) == 95 ) state = 31; - else if( info.src.charCodeAt( pos ) == 124 ) state = 32; - else state = -1; - break; - - case 1: - state = -1; - match = 1; - match_pos = pos; - break; - - case 2: - if( info.src.charCodeAt( pos ) == 61 ) state = 15; - else state = -1; - match = 23; - match_pos = pos; - break; - - case 3: - state = -1; - match = 2; - match_pos = pos; - break; - - case 4: - state = -1; - match = 3; - match_pos = pos; - break; - - case 5: - state = -1; - match = 13; - match_pos = pos; - break; - - case 6: - state = -1; - match = 11; - match_pos = pos; - break; - - case 7: - state = -1; - match = 16; - match_pos = pos; - break; - - case 8: - state = -1; - match = 12; - match_pos = pos; - break; - - case 9: - state = -1; - match = 14; - match_pos = pos; - break; - - case 10: - if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 10; - else if( info.src.charCodeAt( pos ) == 46 ) state = 18; - else state = -1; - match = 4; - match_pos = pos; - break; - - case 11: - if( info.src.charCodeAt( pos ) == 61 ) state = 19; - else state = -1; - match = 21; - match_pos = pos; - break; - - case 12: - if( info.src.charCodeAt( pos ) == 61 ) state = 21; - else state = -1; - match = 22; - match_pos = pos; - break; - - case 13: - if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 13; - else if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 27; - else if( info.src.charCodeAt( pos ) == 91 ) state = 34; - else if( info.src.charCodeAt( pos ) == 95 ) state = 35; - else state = -1; - match = 7; - match_pos = pos; - break; - - case 14: - state = -1; - match = 15; - match_pos = pos; - break; - - case 15: - state = -1; - match = 20; - match_pos = pos; - break; - - case 16: - state = -1; - match = 9; - match_pos = pos; - break; - - case 17: - state = -1; - match = 25; - match_pos = pos; - break; - - case 18: - if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 18; - else state = -1; - match = 5; - match_pos = pos; - break; - - case 19: - state = -1; - match = 17; - match_pos = pos; - break; - - case 20: - state = -1; - match = 19; - match_pos = pos; - break; - - case 21: - state = -1; - match = 18; - match_pos = pos; - break; - - case 22: - state = -1; - match = 24; - match_pos = pos; - break; - - case 23: - state = -1; - match = 8; - match_pos = pos; - break; - - case 24: - if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 24; - else state = -1; - match = 6; - match_pos = pos; - break; - - case 25: - state = -1; - match = 10; - match_pos = pos; - break; - - case 26: - if( info.src.charCodeAt( pos ) == 34 ) state = 16; - else if( info.src.charCodeAt( pos ) == 32 || info.src.charCodeAt( pos ) == 46 || ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || info.src.charCodeAt( pos ) == 61 || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) || info.src.charCodeAt( pos ) == 223 || info.src.charCodeAt( pos ) == 228 || info.src.charCodeAt( pos ) == 246 || info.src.charCodeAt( pos ) == 252 ) state = 26; - else state = -1; - break; - - case 27: - if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 27; - else if( info.src.charCodeAt( pos ) == 95 ) state = 35; - else state = -1; - match = 7; - match_pos = pos; - break; - - case 28: - if( info.src.charCodeAt( pos ) == 38 ) state = 17; - else if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 33; - else state = -1; - break; - - case 29: - if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) ) state = 18; - else state = -1; - break; - - case 30: - if( info.src.charCodeAt( pos ) == 61 ) state = 20; - else state = -1; - break; - - case 31: - if( info.src.charCodeAt( pos ) == 95 ) state = 36; - else state = -1; - break; - - case 32: - if( info.src.charCodeAt( pos ) == 124 ) state = 22; - else state = -1; - break; - - case 33: - if( info.src.charCodeAt( pos ) == 59 ) state = 23; - else if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 33; - else state = -1; - break; - - case 34: - if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 37; - else state = -1; - break; - - case 35: - if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 27; - else if( info.src.charCodeAt( pos ) == 95 ) state = 35; - else state = -1; - break; - - case 36: - if( ( info.src.charCodeAt( pos ) >= 48 && info.src.charCodeAt( pos ) <= 57 ) || ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 24; - else state = -1; - break; - - case 37: - if( info.src.charCodeAt( pos ) == 93 ) state = 25; - else if( ( info.src.charCodeAt( pos ) >= 65 && info.src.charCodeAt( pos ) <= 90 ) || ( info.src.charCodeAt( pos ) >= 97 && info.src.charCodeAt( pos ) <= 122 ) ) state = 37; - else state = -1; - break; - - } - - - pos++; - - } - while( state > -1 ); - - } - while( 1 > -1 && match == 1 ); - - if( match > -1 ) - { - info.att = info.src.substr( start, match_pos - start ); - info.offset = match_pos; - - - } - else - { - info.att = new String(); - match = -1; - } - - return match; - } - - - function __parse( src, err_off, err_la ) { - var sstack = new Array(); - var vstack = new Array(); - var err_cnt = 0; - var act; - var go; - var la; - var rval; - var parseinfo = new Function( "", "var offset; var src; var att;" ); - var info = new parseinfo(); - - /* Pop-Table */ - var pop_tab = new Array( - new Array( 0/* p' */, 1 ), - new Array( 27/* p */, 1 ), - new Array( 26/* e */, 5 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 2 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 2 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 3 ), - new Array( 26/* e */, 1 ), - new Array( 26/* e */, 1 ), - new Array( 26/* e */, 1 ), - new Array( 26/* e */, 1 ), - new Array( 26/* e */, 1 ), - new Array( 26/* e */, 1 ), - new Array( 26/* e */, 4 ), - new Array( 26/* e */, 1 ) - ); - - /* Action-Table */ - var act_tab = new Array( - /* State 0 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 1 */ new Array( 28/* "$" */,0 ), - /* State 2 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,18 , 11/* "+" */,19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-1 ), - /* State 3 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 4 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 5 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 6 */ new Array( 11/* "+" */,29 , 28/* "$" */,-24 , 17/* "<=" */,-24 , 18/* ">=" */,-24 , 19/* "==" */,-24 , 20/* "!=" */,-24 , 21/* "<" */,-24 , 22/* ">" */,-24 , 12/* "-" */,-24 , 15/* "^" */,-24 , 24/* "||" */,-24 , 25/* "&&" */,-24 , 13/* "*" */,-24 , 14/* "/" */,-24 , 16/* "," */,-24 , 3/* ")" */,-24 ), - /* State 7 */ new Array( 28/* "$" */,-20 , 17/* "<=" */,-20 , 18/* ">=" */,-20 , 19/* "==" */,-20 , 20/* "!=" */,-20 , 21/* "<" */,-20 , 22/* ">" */,-20 , 11/* "+" */,-20 , 12/* "-" */,-20 , 15/* "^" */,-20 , 24/* "||" */,-20 , 25/* "&&" */,-20 , 13/* "*" */,-20 , 14/* "/" */,-20 , 16/* "," */,-20 , 3/* ")" */,-20 ), - /* State 8 */ new Array( 28/* "$" */,-21 , 17/* "<=" */,-21 , 18/* ">=" */,-21 , 19/* "==" */,-21 , 20/* "!=" */,-21 , 21/* "<" */,-21 , 22/* ">" */,-21 , 11/* "+" */,-21 , 12/* "-" */,-21 , 15/* "^" */,-21 , 24/* "||" */,-21 , 25/* "&&" */,-21 , 13/* "*" */,-21 , 14/* "/" */,-21 , 16/* "," */,-21 , 3/* ")" */,-21 ), - /* State 9 */ new Array( 28/* "$" */,-22 , 17/* "<=" */,-22 , 18/* ">=" */,-22 , 19/* "==" */,-22 , 20/* "!=" */,-22 , 21/* "<" */,-22 , 22/* ">" */,-22 , 11/* "+" */,-22 , 12/* "-" */,-22 , 15/* "^" */,-22 , 24/* "||" */,-22 , 25/* "&&" */,-22 , 13/* "*" */,-22 , 14/* "/" */,-22 , 16/* "," */,-22 , 3/* ")" */,-22 ), - /* State 10 */ new Array( 28/* "$" */,-23 , 17/* "<=" */,-23 , 18/* ">=" */,-23 , 19/* "==" */,-23 , 20/* "!=" */,-23 , 21/* "<" */,-23 , 22/* ">" */,-23 , 11/* "+" */,-23 , 12/* "-" */,-23 , 15/* "^" */,-23 , 24/* "||" */,-23 , 25/* "&&" */,-23 , 13/* "*" */,-23 , 14/* "/" */,-23 , 16/* "," */,-23 , 3/* ")" */,-23 ), - /* State 11 */ new Array( 28/* "$" */,-25 , 17/* "<=" */,-25 , 18/* ">=" */,-25 , 19/* "==" */,-25 , 20/* "!=" */,-25 , 21/* "<" */,-25 , 22/* ">" */,-25 , 11/* "+" */,-25 , 12/* "-" */,-25 , 15/* "^" */,-25 , 24/* "||" */,-25 , 25/* "&&" */,-25 , 13/* "*" */,-25 , 14/* "/" */,-25 , 16/* "," */,-25 , 3/* ")" */,-25 ), - /* State 12 */ new Array( 2/* "(" */,30 , 28/* "$" */,-27 , 17/* "<=" */,-27 , 18/* ">=" */,-27 , 19/* "==" */,-27 , 20/* "!=" */,-27 , 21/* "<" */,-27 , 22/* ">" */,-27 , 11/* "+" */,-27 , 12/* "-" */,-27 , 15/* "^" */,-27 , 24/* "||" */,-27 , 25/* "&&" */,-27 , 13/* "*" */,-27 , 14/* "/" */,-27 , 16/* "," */,-27 , 3/* ")" */,-27 ), - /* State 13 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 14 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 15 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 16 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 17 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 18 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 19 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 20 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 21 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 22 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 23 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 24 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 25 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 26 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,18 , 11/* "+" */,19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 16/* "," */,44 , 3/* ")" */,45 ), - /* State 27 */ new Array( 14/* "/" */,-11 , 13/* "*" */,-11 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-11 , 12/* "-" */,-11 , 11/* "+" */,-11 , 22/* ">" */,-11 , 21/* "<" */,-11 , 20/* "!=" */,-11 , 19/* "==" */,-11 , 18/* ">=" */,-11 , 17/* "<=" */,-11 , 28/* "$" */,-11 , 16/* "," */,-11 , 3/* ")" */,-11 ), - /* State 28 */ new Array( 14/* "/" */,-17 , 13/* "*" */,-17 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-17 , 11/* "+" */,-17 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-17 , 16/* "," */,-17 , 3/* ")" */,-17 ), - /* State 29 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 30 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 31 */ new Array( 14/* "/" */,-16 , 13/* "*" */,-16 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-16 , 11/* "+" */,-16 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-16 , 16/* "," */,-16 , 3/* ")" */,-16 ), - /* State 32 */ new Array( 14/* "/" */,-15 , 13/* "*" */,-15 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-15 , 11/* "+" */,-15 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-15 , 16/* "," */,-15 , 3/* ")" */,-15 ), - /* State 33 */ new Array( 14/* "/" */,-14 , 13/* "*" */,-14 , 25/* "&&" */,-14 , 24/* "||" */,-14 , 15/* "^" */,-14 , 12/* "-" */,-14 , 11/* "+" */,-14 , 22/* ">" */,-14 , 21/* "<" */,-14 , 20/* "!=" */,-14 , 19/* "==" */,-14 , 18/* ">=" */,-14 , 17/* "<=" */,-14 , 28/* "$" */,-14 , 16/* "," */,-14 , 3/* ")" */,-14 ), - /* State 34 */ new Array( 14/* "/" */,-13 , 13/* "*" */,-13 , 25/* "&&" */,-13 , 24/* "||" */,-13 , 15/* "^" */,-13 , 12/* "-" */,-13 , 11/* "+" */,-13 , 22/* ">" */,-13 , 21/* "<" */,-13 , 20/* "!=" */,-13 , 19/* "==" */,-13 , 18/* ">=" */,-13 , 17/* "<=" */,-13 , 28/* "$" */,-13 , 16/* "," */,-13 , 3/* ")" */,-13 ), - /* State 35 */ new Array( 14/* "/" */,-12 , 13/* "*" */,-12 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-12 , 12/* "-" */,-12 , 11/* "+" */,-12 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-12 , 16/* "," */,-12 , 3/* ")" */,-12 ), - /* State 36 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-10 , 11/* "+" */,-10 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-10 , 16/* "," */,-10 , 3/* ")" */,-10 ), - /* State 37 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-9 , 11/* "+" */,-9 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-9 , 16/* "," */,-9 , 3/* ")" */,-9 ), - /* State 38 */ new Array( 14/* "/" */,-8 , 13/* "*" */,-8 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-8 , 12/* "-" */,-8 , 11/* "+" */,-8 , 22/* ">" */,-8 , 21/* "<" */,-8 , 20/* "!=" */,-8 , 19/* "==" */,-8 , 18/* ">=" */,-8 , 17/* "<=" */,-8 , 28/* "$" */,-8 , 16/* "," */,-8 , 3/* ")" */,-8 ), - /* State 39 */ new Array( 14/* "/" */,-7 , 13/* "*" */,-7 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-7 , 12/* "-" */,-7 , 11/* "+" */,-7 , 22/* ">" */,-7 , 21/* "<" */,-7 , 20/* "!=" */,-7 , 19/* "==" */,-7 , 18/* ">=" */,-7 , 17/* "<=" */,-7 , 28/* "$" */,-7 , 16/* "," */,-7 , 3/* ")" */,-7 ), - /* State 40 */ new Array( 14/* "/" */,-6 , 13/* "*" */,-6 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-6 , 12/* "-" */,-6 , 11/* "+" */,-6 , 22/* ">" */,-6 , 21/* "<" */,-6 , 20/* "!=" */,-6 , 19/* "==" */,-6 , 18/* ">=" */,-6 , 17/* "<=" */,-6 , 28/* "$" */,-6 , 16/* "," */,-6 , 3/* ")" */,-6 ), - /* State 41 */ new Array( 14/* "/" */,-5 , 13/* "*" */,-5 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-5 , 12/* "-" */,-5 , 11/* "+" */,-5 , 22/* ">" */,-5 , 21/* "<" */,-5 , 20/* "!=" */,-5 , 19/* "==" */,-5 , 18/* ">=" */,-5 , 17/* "<=" */,-5 , 28/* "$" */,-5 , 16/* "," */,-5 , 3/* ")" */,-5 ), - /* State 42 */ new Array( 14/* "/" */,-4 , 13/* "*" */,-4 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-4 , 12/* "-" */,-4 , 11/* "+" */,-4 , 22/* ">" */,-4 , 21/* "<" */,-4 , 20/* "!=" */,-4 , 19/* "==" */,-4 , 18/* ">=" */,-4 , 17/* "<=" */,-4 , 28/* "$" */,-4 , 16/* "," */,-4 , 3/* ")" */,-4 ), - /* State 43 */ new Array( 14/* "/" */,-3 , 13/* "*" */,-3 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,-3 , 12/* "-" */,-3 , 11/* "+" */,-3 , 22/* ">" */,-3 , 21/* "<" */,-3 , 20/* "!=" */,-3 , 19/* "==" */,-3 , 18/* ">=" */,-3 , 17/* "<=" */,-3 , 28/* "$" */,-3 , 16/* "," */,-3 , 3/* ")" */,-3 ), - /* State 44 */ new Array( 2/* "(" */,3 , 23/* "!" */,4 , 12/* "-" */,5 , 9/* "STRING" */,6 , 4/* "INT" */,7 , 5/* "FLOAT" */,8 , 6/* "PARAM" */,9 , 8/* "HTML" */,10 , 10/* "COMMAND" */,11 , 7/* "VAR" */,12 ), - /* State 45 */ new Array( 28/* "$" */,-18 , 17/* "<=" */,-18 , 18/* ">=" */,-18 , 19/* "==" */,-18 , 20/* "!=" */,-18 , 21/* "<" */,-18 , 22/* ">" */,-18 , 11/* "+" */,-18 , 12/* "-" */,-18 , 15/* "^" */,-18 , 24/* "||" */,-18 , 25/* "&&" */,-18 , 13/* "*" */,-18 , 14/* "/" */,-18 , 16/* "," */,-18 , 3/* ")" */,-18 ), - /* State 46 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,-19 , 11/* "+" */,-19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 28/* "$" */,-19 , 16/* "," */,-19 , 3/* ")" */,-19 ), - /* State 47 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,18 , 11/* "+" */,19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 3/* ")" */,49 ), - /* State 48 */ new Array( 14/* "/" */,13 , 13/* "*" */,14 , 25/* "&&" */,15 , 24/* "||" */,16 , 15/* "^" */,17 , 12/* "-" */,18 , 11/* "+" */,19 , 22/* ">" */,20 , 21/* "<" */,21 , 20/* "!=" */,22 , 19/* "==" */,23 , 18/* ">=" */,24 , 17/* "<=" */,25 , 3/* ")" */,50 ), - /* State 49 */ new Array( 28/* "$" */,-26 , 17/* "<=" */,-26 , 18/* ">=" */,-26 , 19/* "==" */,-26 , 20/* "!=" */,-26 , 21/* "<" */,-26 , 22/* ">" */,-26 , 11/* "+" */,-26 , 12/* "-" */,-26 , 15/* "^" */,-26 , 24/* "||" */,-26 , 25/* "&&" */,-26 , 13/* "*" */,-26 , 14/* "/" */,-26 , 16/* "," */,-26 , 3/* ")" */,-26 ), - /* State 50 */ new Array( 28/* "$" */,-2 , 17/* "<=" */,-2 , 18/* ">=" */,-2 , 19/* "==" */,-2 , 20/* "!=" */,-2 , 21/* "<" */,-2 , 22/* ">" */,-2 , 11/* "+" */,-2 , 12/* "-" */,-2 , 15/* "^" */,-2 , 24/* "||" */,-2 , 25/* "&&" */,-2 , 13/* "*" */,-2 , 14/* "/" */,-2 , 16/* "," */,-2 , 3/* ")" */,-2 ) - ); - - /* Goto-Table */ - var goto_tab = new Array( - /* State 0 */ new Array( 27/* p */,1 , 26/* e */,2 ), - /* State 1 */ new Array( ), - /* State 2 */ new Array( ), - /* State 3 */ new Array( 26/* e */,26 ), - /* State 4 */ new Array( 26/* e */,27 ), - /* State 5 */ new Array( 26/* e */,28 ), - /* State 6 */ new Array( ), - /* State 7 */ new Array( ), - /* State 8 */ new Array( ), - /* State 9 */ new Array( ), - /* State 10 */ new Array( ), - /* State 11 */ new Array( ), - /* State 12 */ new Array( ), - /* State 13 */ new Array( 26/* e */,31 ), - /* State 14 */ new Array( 26/* e */,32 ), - /* State 15 */ new Array( 26/* e */,33 ), - /* State 16 */ new Array( 26/* e */,34 ), - /* State 17 */ new Array( 26/* e */,35 ), - /* State 18 */ new Array( 26/* e */,36 ), - /* State 19 */ new Array( 26/* e */,37 ), - /* State 20 */ new Array( 26/* e */,38 ), - /* State 21 */ new Array( 26/* e */,39 ), - /* State 22 */ new Array( 26/* e */,40 ), - /* State 23 */ new Array( 26/* e */,41 ), - /* State 24 */ new Array( 26/* e */,42 ), - /* State 25 */ new Array( 26/* e */,43 ), - /* State 26 */ new Array( ), - /* State 27 */ new Array( ), - /* State 28 */ new Array( ), - /* State 29 */ new Array( 26/* e */,46 ), - /* State 30 */ new Array( 26/* e */,47 ), - /* State 31 */ new Array( ), - /* State 32 */ new Array( ), - /* State 33 */ new Array( ), - /* State 34 */ new Array( ), - /* State 35 */ new Array( ), - /* State 36 */ new Array( ), - /* State 37 */ new Array( ), - /* State 38 */ new Array( ), - /* State 39 */ new Array( ), - /* State 40 */ new Array( ), - /* State 41 */ new Array( ), - /* State 42 */ new Array( ), - /* State 43 */ new Array( ), - /* State 44 */ new Array( 26/* e */,48 ), - /* State 45 */ new Array( ), - /* State 46 */ new Array( ), - /* State 47 */ new Array( ), - /* State 48 */ new Array( ), - /* State 49 */ new Array( ), - /* State 50 */ new Array( ) - ); - - - - /* Symbol labels */ - var labels = new Array( - "p'" /* Non-terminal symbol */, - "WHITESPACE" /* Terminal symbol */, - "(" /* Terminal symbol */, - ")" /* Terminal symbol */, - "INT" /* Terminal symbol */, - "FLOAT" /* Terminal symbol */, - "PARAM" /* Terminal symbol */, - "VAR" /* Terminal symbol */, - "HTML" /* Terminal symbol */, - "STRING" /* Terminal symbol */, - "COMMAND" /* Terminal symbol */, - "+" /* Terminal symbol */, - "-" /* Terminal symbol */, - "*" /* Terminal symbol */, - "/" /* Terminal symbol */, - "^" /* Terminal symbol */, - "," /* Terminal symbol */, - "<=" /* Terminal symbol */, - ">=" /* Terminal symbol */, - "==" /* Terminal symbol */, - "!=" /* Terminal symbol */, - "<" /* Terminal symbol */, - ">" /* Terminal symbol */, - "!" /* Terminal symbol */, - "||" /* Terminal symbol */, - "&&" /* Terminal symbol */, - "e" /* Non-terminal symbol */, - "p" /* Non-terminal symbol */, - "$" /* Terminal symbol */ - ); - - - - info.offset = 0; - info.src = src; - info.att = new String(); - - if( !err_off ) - err_off = new Array(); - if( !err_la ) - err_la = new Array(); - - sstack.push( 0 ); - vstack.push( 0 ); - - la = __lex( info ); - - while( true ) - { - act = 52; - for( var i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 ) - { - if( act_tab[sstack[sstack.length-1]][i] == la ) - { - act = act_tab[sstack[sstack.length-1]][i+1]; - break; - } - } - - if( _dbg_withtrace && sstack.length > 0 ) - { - __dbg_print( "\nState " + sstack[sstack.length-1] + "\n" + - "\tLookahead: " + labels[la] + " (\"" + info.att + "\")\n" + - "\tAction: " + act + "\n" + - "\tSource: \"" + info.src.substr( info.offset, 30 ) + ( ( info.offset + 30 < info.src.length ) ? - "..." : "" ) + "\"\n" + - "\tStack: " + sstack.join() + "\n" + - "\tValue stack: " + vstack.join() + "\n" ); - } - - - //Panic-mode: Try recovery when parse-error occurs! - if( act == 52 ) - { - if( _dbg_withtrace ) - __dbg_print( "Error detected: There is no reduce or shift on the symbol " + labels[la] ); - - err_cnt++; - err_off.push( info.offset - info.att.length ); - err_la.push( new Array() ); - for( var i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 ) - err_la[err_la.length-1].push( labels[act_tab[sstack[sstack.length-1]][i]] ); - - //Remember the original stack! - var rsstack = new Array(); - var rvstack = new Array(); - for( var i = 0; i < sstack.length; i++ ) - { - rsstack[i] = sstack[i]; - rvstack[i] = vstack[i]; - } - - while( act == 52 && la != 28 ) - { - if( _dbg_withtrace ) - __dbg_print( "\tError recovery\n" + - "Current lookahead: " + labels[la] + " (" + info.att + ")\n" + - "Action: " + act + "\n\n" ); - if( la == -1 ) - info.offset++; - - while( act == 52 && sstack.length > 0 ) - { - sstack.pop(); - vstack.pop(); - - if( sstack.length == 0 ) - break; - - act = 52; - for( var i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 ) - { - if( act_tab[sstack[sstack.length-1]][i] == la ) - { - act = act_tab[sstack[sstack.length-1]][i+1]; - break; - } - } - } - - if( act != 52 ) - break; - - for( var i = 0; i < rsstack.length; i++ ) - { - sstack.push( rsstack[i] ); - vstack.push( rvstack[i] ); - } - - la = __lex( info ); - } - - if( act == 52 ) - { - if( _dbg_withtrace ) - __dbg_print( "\tError recovery failed, terminating parse process..." ); - break; - } - - - if( _dbg_withtrace ) - __dbg_print( "\tError recovery succeeded, continuing" ); - } - - /* - if( act == 52 ) - break; - */ - - - //Shift - if( act > 0 ) - { - if( _dbg_withtrace ) - __dbg_print( "Shifting symbol: " + labels[la] + " (" + info.att + ")" ); - - sstack.push( act ); - vstack.push( info.att ); - - la = __lex( info ); - - if( _dbg_withtrace ) - __dbg_print( "\tNew lookahead symbol: " + labels[la] + " (" + info.att + ")" ); - } - //Reduce - else - { - act *= -1; - - if( _dbg_withtrace ) - __dbg_print( "Reducing by producution: " + act ); - - rval = void(0); - - if( _dbg_withtrace ) - __dbg_print( "\tPerforming semantic action..." ); - - switch( act ) - { - case 0: - { - rval = vstack[ vstack.length - 1 ]; - } - break; - case 1: - { - rval = JXG.GeogebraReader.ggbAct('end', vstack[ vstack.length - 1 ]); - } - break; - case 2: - { - rval = JXG.GeogebraReader.ggbAct('coord', vstack[ vstack.length - 4 ], vstack[ vstack.length - 2 ], element); - } - break; - case 3: - { - rval = JXG.GeogebraReader.ggbAct('le', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 4: - { - rval = JXG.GeogebraReader.ggbAct('ge', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 5: - { - rval = JXG.GeogebraReader.ggbAct('eq', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 6: - { - rval = JXG.GeogebraReader.ggbAct('neq', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 7: - { - rval = JXG.GeogebraReader.ggbAct('lt', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 8: - { - rval = JXG.GeogebraReader.ggbAct('gt', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 9: - { - rval = JXG.GeogebraReader.ggbAct('add', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 10: - { - rval = JXG.GeogebraReader.ggbAct('sub', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 11: - { - rval = JXG.GeogebraReader.ggbAct('neg', vstack[ vstack.length - 1 ]); - } - break; - case 12: - { - rval = JXG.GeogebraReader.ggbAct('pow', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 13: - { - rval = JXG.GeogebraReader.ggbAct('or', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 14: - { - rval = JXG.GeogebraReader.ggbAct('and', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 15: - { - rval = JXG.GeogebraReader.ggbAct('mul', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 16: - { - rval = JXG.GeogebraReader.ggbAct('div', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 17: - { - rval = JXG.GeogebraReader.ggbAct('negmult', vstack[ vstack.length - 1 ]); - } - break; - case 18: - { - rval = JXG.GeogebraReader.ggbAct('bra', vstack[ vstack.length - 2 ]); - } - break; - case 19: - { - rval = JXG.GeogebraReader.ggbAct('string', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); - } - break; - case 20: - { - rval = JXG.GeogebraReader.ggbAct('int', vstack[ vstack.length - 1 ]); - } - break; - case 21: - { - rval = JXG.GeogebraReader.ggbAct('float', vstack[ vstack.length - 1 ]); - } - break; - case 22: - { - rval = JXG.GeogebraReader.ggbAct('param', vstack[ vstack.length - 1 ]); - } - break; - case 23: - { - rval = JXG.GeogebraReader.ggbAct('html', vstack[ vstack.length - 1 ]); - } - break; - case 24: - { - rval = JXG.GeogebraReader.ggbAct('string', vstack[ vstack.length - 1 ]); - } - break; - case 25: - { - rval = JXG.GeogebraReader.ggbAct('command', vstack[ vstack.length - 1 ]); - } - break; - case 26: - { - rval = JXG.GeogebraReader.ggbAct('var', vstack[ vstack.length - 4 ], vstack[ vstack.length - 2 ]); - } - break; - case 27: - { - rval = JXG.GeogebraReader.ggbAct('var', vstack[ vstack.length - 1 ]); - } - break; - } - - - - if( _dbg_withtrace ) - __dbg_print( "\tPopping " + pop_tab[act][1] + " off the stack..." ); - - for( var i = 0; i < pop_tab[act][1]; i++ ) - { - sstack.pop(); - str = vstack.pop(); - } - - go = -1; - for( var i = 0; i < goto_tab[sstack[sstack.length-1]].length; i+=2 ) - { - if( goto_tab[sstack[sstack.length-1]][i] == pop_tab[act][0] ) - { - go = goto_tab[sstack[sstack.length-1]][i+1]; - break; - } - } - - if( act == 0 ) - break; - - if( _dbg_withtrace ) - __dbg_print( "\tPushing non-terminal " + labels[ pop_tab[act][0] ] ); - - sstack.push( go ); - vstack.push( rval ); - } - - if( _dbg_withtrace ) - { - JXG.debug( _dbg_string ); - _dbg_string = new String(); - } - } - - if( _dbg_withtrace ) - { - __dbg_print( "\nParse complete." ); - JXG.debug( _dbg_string ); - } - - return err_cnt; - } -/***** end replace *****/ - - var error_offsets = new Array(); - var error_lookaheads = new Array(); - var error_count = 0; - var str = exp; - if( ( error_count = __parse( str, error_offsets, error_lookaheads ) ) > 0 ) { - var errstr = new String(); - for( var i = 0; i < error_count; i++ ) - errstr += "Parse error in line " + ( str.substr( 0, error_offsets[i] ).match( /\n/g ) ? - str.substr( 0, error_offsets[i] ).match( /\n/g ).length : 1 ) - + " near \"" + str.substr( error_offsets[i] ) + "\", expecting \"" + error_lookaheads[i].join() + "\"\n" ; - JXG.debug( errstr ); - } - - return str; -}; //end: ggbParse() - - -/** - * Override JSxGraph defaults with Geogebra settings - * @param {Object} board object - * @return {Object} board oject - */ -this.setDefaultOptions = function(board){ - board.options.elements.strokeWidth = '1px'; // TODO: board.options.line.strokeWidth - board.options.elements.withLabel = true; - - board.options.point.face = 'circle'; - board.options.point.size = 3; - board.options.point.fillColor = 'blue'; - board.options.point.fillOpacity = 1; - board.options.point.highlightFillOpacity = 1; - board.options.point.strokeColor = 'black'; - board.options.point.highlightStrokeColor = 'black'; - board.options.point.strokeWidth = '2px'; - - board.options.line.strokeWidth = '1px'; - board.options.line.highlightStrokeColor = '#000000'; - board.options.line.strokeColor = '#000000'; - - board.options.polygon.fillColor = JXG.rgb2hex(153, 51, 0); - board.options.polygon.fillOpacity = 0.1; - board.options.polygon.highlightFillColor = board.options.polygon.fillColor; - board.options.polygon.highlightFillOpacity = 0.1; - - board.options.sector.fillColor = JXG.rgb2hex(153, 51, 0); - board.options.sector.fillOpacity = 0.1; - board.options.sector.highlightFillColor = board.options.sector.fillColor; - board.options.sector.highlightFillOpacity = 0.1; - - board.options.angle.fillColor = JXG.rgb2hex(0, 100, 0); - board.options.angle.fillOpacity = 0.1; - //board.options.angle.highlightFillColor = board.options.angle.fillColor; - board.options.angle.highlightFillOpacity = 0.1; - - return board; -}; - -/** - * Set color properties of a geogebra element. - * Set stroke, fill, lighting, label and draft color attributes. - * @param {Object} gxtEl element of which attributes are to set - * @param {Object} attr object carrying all necessary attribute values - * @return {Object} returning the updated attr-attributes object - */ -this.colorProperties = function(Data, attr) { - var a,r,g,b; - a = (Data.getElementsByTagName("objColor").length > 0 && Data.getElementsByTagName("objColor")[0].getAttribute("alpha")) ? parseFloat(Data.getElementsByTagName("objColor")[0].getAttribute("alpha")) : 0; - r = (Data.getElementsByTagName("objColor").length > 0 && Data.getElementsByTagName("objColor")[0].getAttribute("r")) ? parseInt(Data.getElementsByTagName("objColor")[0].getAttribute("r")).toString(16) : 0; - g = (Data.getElementsByTagName("objColor").length > 0 && Data.getElementsByTagName("objColor")[0].getAttribute("g")) ? parseInt(Data.getElementsByTagName("objColor")[0].getAttribute("g")).toString(16) : 0; - b = (Data.getElementsByTagName("objColor").length > 0 && Data.getElementsByTagName("objColor")[0].getAttribute("b")) ? parseInt(Data.getElementsByTagName("objColor")[0].getAttribute("b")).toString(16) : 0; - if (r.length == 1) r = '0' + r; - if (g.length == 1) g = '0' + g; - if (b.length == 1) b = '0' + b; - - attr.fillColor = '#'+ r + g + b; - attr.strokeColor = attr.fillColor; - attr.highlightFillColor = attr.fillColor; - attr.highlightStrokeColor = attr.strokeColor; - attr.fillOpacity = a; - attr.highlightFillOpacity = a; - attr.labelColor = attr.fillColor; - - return attr; -}; - -/** - * Set the board properties. - * Set active, area, dash, draft and showinfo attributes. - * @param {Object} gxtEl element of which attributes are to set - * @param {Object} Data element of which attributes are to set - * @param {Object} attr object containing the necessary attribute values - */ -this.boardProperties = function(gxtEl, Data, attr) { - return attr; -}; - -/** - * @param {Object} gxtEl element of which attributes are to set - * @param {Object} Data element of which attributes are to set - * @return {Object} updated element - */ -this.coordinates = function(gxtEl, Data) { - var labelOffset = {}, tmp; - labelOffset.x = 0; labelOffset.y = 0; labelOffset.z = 0; - - if(Data.getElementsByTagName('labelOffset')[0]) { - // tmp = new JXG.Coords(JXG.COORDS_BY_SCREEN, [, - // parseFloat(Data.getElementsByTagName("labelOffset")[0].attributes["y"].value)], JXG.GeogebraReader.board); - labelOffset.x = parseFloat(Data.getElementsByTagName("labelOffset")[0].getAttribute("x"))/JXG.GeogebraReader.board.unitX; - labelOffset.y = parseFloat(Data.getElementsByTagName("labelOffset")[0].getAttribute("y"))/JXG.GeogebraReader.board.unitY; - } - - if(Data.getElementsByTagName("coords")[0]) { - gxtEl.x = parseFloat(Data.getElementsByTagName("coords")[0].getAttribute("x")); - gxtEl.y = parseFloat(Data.getElementsByTagName("coords")[0].getAttribute("y")); - gxtEl.z = parseFloat(Data.getElementsByTagName("coords")[0].getAttribute("z")); - } else if(Data.getElementsByTagName("startPoint")[0]) { - if(Data.getElementsByTagName("startPoint")[0].getAttribute('exp')) { - var a = JXG.getRef(JXG.GeogebraReader.board, Data.getElementsByTagName("startPoint")[0].getAttribute('exp')); - gxtEl.x = function() {return a.X()+labelOffset.x;}; - gxtEl.y = function() {return a.Y()-labelOffset.y;}; // minus because geogebra starts on the other side - gxtEl.z = false; - } else { - gxtEl.x = parseFloat(Data.getElementsByTagName("startPoint")[0].getAttribute("x")); - gxtEl.y = parseFloat(Data.getElementsByTagName("startPoint")[0].getAttribute("y")); - gxtEl.z = parseFloat(Data.getElementsByTagName("startPoint")[0].getAttribute("z")); - } - } else if(Data.getElementsByTagName("absoluteScreenLocation")[0]) { - var tmp = new JXG.Coords(JXG.COORDS_BY_SCREEN, [parseFloat(Data.getElementsByTagName("absoluteScreenLocation")[0].getAttribute("x")), - parseFloat(Data.getElementsByTagName("absoluteScreenLocation")[0].getAttribute("y"))], JXG.GeogebraReader.board); - gxtEl.x = tmp.usrCoords[1]+labelOffset.x; - gxtEl.y = tmp.usrCoords[2]+labelOffset.y; - gxtEl.z = false; - } else { - return false; - } - - return gxtEl; -}; - -/** - * Writing element attributes to the given object - * @param {XMLNode} Data expects the content of the current element - * @return {Object} object with according attributes - */ -this.visualProperties = function(Data, attr) { - (Data.getElementsByTagName("show").length != 0 && Data.getElementsByTagName("show")[0].getAttribute("object")) ? attr.visible = Data.getElementsByTagName("show")[0].getAttribute("object") : false; - (Data.getElementsByTagName("show").length != 0 && Data.getElementsByTagName("show")[0].getAttribute("label")) ? attr.withLabel = Data.getElementsByTagName("show")[0].getAttribute("label") : true; - if(attr.withLabel == 'true') { - attr.withLabel = true; - } - else if(attr.withLabel == 'false') { - attr.withLabel = false; - } - (Data.getElementsByTagName('pointSize')[0]) ? attr.size = Data.getElementsByTagName('pointSize')[0].getAttribute("val") : false; - (Data.getElementsByTagName('pointStyle')[0]) ? attr.styleGGB = Data.getElementsByTagName('pointStyle')[0].getAttribute("val") : false; - if(attr.styleGGB == 0 || attr.styleGGB == 2) { - attr.face = 'circle'; - if(attr.styleGGB == 0) { - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - attr.highlightFillColor = attr.strokeColor; - attr.highlightFillOpacity = 1; - attr.strokeColor = 'black'; - attr.strokeWidth = '1px'; - } - else if(attr.styleGGB == 2) { - attr.fillColor = 'none'; - } - } - else if(attr.styleGGB == 1) { - attr.face = 'x'; - } - else if(attr.styleGGB == 3) { - attr.face = '+'; - attr.strokeOpacity = 1; - } - else if(attr.styleGGB == 4 || attr.styleGGB == 5) { - attr.face = 'diamond'; - if(attr.styleGGB == 4) { - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - } - else if(attr.styleGGB == 5) { - attr.fillColor = 'none'; - } - } - else if(attr.styleGGB == 6) { - attr.face = 'triangleUp'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - } - else if(attr.styleGGB == 7) { - attr.face = 'triangleDown'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - } - else if(attr.styleGGB == 8) { - attr.face = 'triangleRight'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - } - else if(attr.styleGGB == 9) { - attr.face = 'triangleLeft'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - } - (Data.getElementsByTagName('slopeTriangleSize')[0]) ? attr.slopeWidth = Data.getElementsByTagName('slopeTriangleSize')[0].getAttribute("val") : false; - (Data.getElementsByTagName('lineStyle')[0]) ? attr.strokeWidth = (Data.getElementsByTagName('lineStyle')[0].getAttribute("thickness")/2.0)+'px' : false; - if(attr.strokeWidth) { - attr.highlightStrokeWidth = (1*attr.strokeWidth.substr(0,attr.strokeWidth.length-2)+1)+'px'; - } - (Data.getElementsByTagName('lineStyle')[0]) ? attr.dashGGB = Data.getElementsByTagName('lineStyle')[0].getAttribute("type") : false; - - if(attr.dashGGB == 0) { - attr.dash = 0; - } - else if(attr.dashGGB == 10) { - attr.dash = 2; - } - else if(attr.dashGGB == 15) { - attr.dash = 3; - } - else if(attr.dashGGB == 20) { - attr.dash = 1; - } - else if(attr.dashGGB == 30) { - attr.dash = 6; - } - (Data.getElementsByTagName("labelOffset")[0]) ? attr.labelX = 1*Data.getElementsByTagName("labelOffset")[0].getAttribute("x") : false; - (Data.getElementsByTagName("labelOffset")[0]) ? attr.labelY = 1*Data.getElementsByTagName("labelOffset")[0].getAttribute("y") : false; - (Data.getElementsByTagName("trace")[0]) ? attr.trace = Data.getElementsByTagName("trace")[0].getAttribute("val") : false; - (Data.getElementsByTagName('fix')[0]) ? attr.fixed = Data.getElementsByTagName('fix')[0].getAttribute("val") : false; - return attr; -}; - -/** - * Searching for an element in the geogebra tree - * @param {String} the name of the element to search for - * @param {Boolean} whether it is search for an expression or not - * @return {Object} object with according label - */ -this.getElement = function(name, expr) { - var Data, i, j; - expr = expr || false; - for(i=0; i -1 || s[i].search(/[0-9]+$/) > -1 || s[i].search(/[a-zA-Z]+(\_*[a-zA-Z0-9]+)*$/) > -1) - if(s[i+1].search(/^\(/) > -1 || - s[i+1].search(/^[0-9]+/) > -1 || - s[i+1].search(/^[a-zA-Z]+(\_*[a-zA-Z0-9]+)*/) > -1 || - s[i+1].search(/\_\_[a-zA-Z0-9]+/) > -1) { - s[i] = s[i] + "*"; - } - o += s[i]; - }; - expr = o; - } - - output.push(expr); - return output; - } else { - return exp; - } - break; - case 's': - exp = exp.replace(/(?![e])x(?!\()(?![p])/g, '__x'); - return ['__x', exp]; - break; - default: - if(JXG.GeogebraReader.format <= 3.01) { - // prepare string: "solve" multiplications 'a b' to 'a*b' - s = exp.split(' '); - o = ''; - for(i=0; i -1 || s[i].search(/[0-9]+$/) > -1 || s[i].search(/[a-zA-Z]+(\_*[a-zA-Z0-9]+)*$/) > -1) - if(s[i+1].search(/^\(/) > -1 || - s[i+1].search(/^[0-9]+/) > -1 || - s[i+1].search(/^[a-zA-Z]+(\_*[a-zA-Z0-9]+)*/) > -1 || - s[i+1].search(/\_\_[a-zA-Z0-9]+/) > -1) { - s[i] = s[i] + "*"; - } - o += s[i]; - }; - exp = o; - } - return exp; - break; - } -}; - -/** - * Searching for an element in the geogebra tree - * @param {Object} board object - */ -this.writeBoard = function(board) { - var boardData = JXG.GeogebraReader.tree.getElementsByTagName("euclidianView")[0]; - - board.origin = {}; - board.origin.usrCoords = [1, 0, 0]; - board.origin.scrCoords = [1, 1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("xZero"), 1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("yZero")]; - board.unitX = (boardData.getElementsByTagName("coordSystem")[0].getAttribute("scale")) ? 1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("scale") : 1; - board.unitY = (boardData.getElementsByTagName("coordSystem")[0].getAttribute("yscale")) ? 1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("yscale") : board.unitX; - - board.fontSize = (JXG.GeogebraReader.tree.getElementsByTagName("gui")[0] && JXG.GeogebraReader.tree.getElementsByTagName("gui")[0].getElementsByTagName("font")[0]) ? 1*JXG.GeogebraReader.tree.getElementsByTagName("gui")[0].getElementsByTagName("font")[0].getAttribute("size") : '12px'; - - JXG.JSXGraph.boards[board.id] = board; - - // Update of properties during update() is not necessary in GEONExT files - board.renderer.enhancedRendering = true; - - // snap to point - var snapToPoint = (boardData.getElementsByTagName('evSettings')[0].getAttribute("pointCapturing") == "true"); - - var grid = (boardData.getElementsByTagName('evSettings')[0].getAttribute("grid") == "true") ? board.create('grid') : null; - - if(boardData.getElementsByTagName('evSettings')[0].getAttribute("axes") && boardData.getElementsByTagName('evSettings')[0].getAttribute("axes") == "true") { - board.ggbElements["xAxis"] = board.create('axis', [[0, 0], [1, 0]], {strokeColor:'black', minorTicks: 0}); - board.ggbElements["yAxis"] = board.create('axis', [[0, 0], [0, 1]], {strokeColor:'black', minorTicks: 0}); - } -}; - -/** - * Searching for an element in the geogebra tree - * @param {Object} board object - * @param {Object} ggb element whose attributes are to parse - * @param {Array} input list of all input elements - * @param {String} typeName output construction method - * @return {Object} return newly created element or false - */ -this.writeElement = function(board, output, input, cmd) { - var element, gxtEl, attr, p, exp, coord, type, points, border, length, m, s, e, sx, sy, ex, ey, func, range; - element = (JXG.isArray(output)) ? output[0] : output; - - gxtEl = {}; // geometric element - attr = {}; // Attributes of geometric elements - - JXG.debug(element); - - gxtEl.type = (element && element.attributes && typeof cmd === 'undefined') ? element.getAttribute('type').toLowerCase() : cmd; - gxtEl.label = element.getAttribute('label'); - attr.name = gxtEl.label; - - JXG.debug("
Konstruiere "+ attr.name +"("+ gxtEl.type +"):"); - - switch(gxtEl.type) { - case 'point': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - if(JXG.GeogebraReader.getElement(attr.name, true)) { - exp = JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp'); - coord = JXG.GeogebraReader.ggbParse(exp); - gxtEl.x = new Function('return '+ coord[0] +';'); - gxtEl.y = new Function('return '+ coord[1] +';'); - } else { - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - } - if(!JXG.exists(attr.styleGGB)) { - attr.face = 'circle'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - attr.highlightFillColor = attr.strokeColor; - attr.highlightFillOpacity = 1; - attr.strokeColor = 'black'; - attr.strokeWidth = '1px'; - } - - JXG.debug(gxtEl); - JXG.debug(input); - - try { - var ma = /Circle\[\s*(\w+)\s*,\s*([\d\.]+)\s*\]/.exec(input); - if(typeof input != 'undefined') { - if (ma!=null && ma.length==3) { - // from Circle[A, 5] take "A" and "5", stored in ma[1] and ma[2] - var q = JXG.GeogebraReader.checkElement(ma[1]); - var c = board.create('circle', [q, parseFloat(ma[2])], {fillColor:'none',visible:false,name:''}); - p = board.create('glider', [gxtEl.x, gxtEl.y, c], attr); - } else if(JXG.isArray(input)) { - p = board.create('glider', [gxtEl.x, gxtEl.y, input[0]], attr); - } else { - p = board.create('glider', [gxtEl.x, gxtEl.y, input], attr); - } - } else { - p = board.create('point', [gxtEl.x, gxtEl.y], attr); - } - return p; - } catch(e) { - JXG.debug("* Err: Point " + attr.name +"
\n"); - return false; - } - break; - case 'segment': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Segment: ("+ attr.name +") First: " + input[0].name + ", Last: " + input[1].name + "
\n"); - attr.straightFirst = false; - attr.straightLast = false; - p = board.create('line', input, attr); - return p; - } catch(e) { - JXG.debug("* Err: Segment " + attr.name +" First: " + input[0].name + ", Last: " + input[1].name + "
\n"); - return false; - } - break; - case 'line': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - type = 'line'; - if(!input) { - input = [ parseFloat(element.getElementsByTagName('coords')[0].getAttribute('z')), - parseFloat(element.getElementsByTagName('coords')[0].getAttribute('x')), - parseFloat(element.getElementsByTagName('coords')[0].getAttribute('y')) - ]; - } else if (JXG.getRef(board, input[1].id).elementClass == JXG.OBJECT_CLASS_LINE) { - type = 'parallel'; // Parallele durch Punkt - } - - try { - p = board.create(type, input, attr); - return p; - } catch(e) { - JXG.debug("* Err: Line " + attr.label +"
\n"); - return false; - } - break; - case "orthogonalline": - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Orthogonalline: First: " + input[0].id + ", Last: " + input[1].id + "
\n"); - p = board.create('normal', input, attr); - return p; - } catch(e) { - JXG.debug("* Err: Orthogonalline " + attr.label +"
\n"); - return false; - } - break; - case "polygon": - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - // test if polygon is regular - if(input.length == 3 && output.length != 4) { - input[2] = parseInt(input[2]); - type = 'regular'; - } - - try { - JXG.debug("* Polygon: First: " + input[0].name + ", Second: " + input[1].name + ", Third: " + input[2] + "
\n"); - - var borders = []; - var borderatts = []; - length = (type == 'regular') ? output.length-input[2]+2 : output.length; - - for(var i=1; iErr: Polygon " + attr.name +"
\n"); - return false; - } - break; - case 'intersect': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Intersection: First: " + input[0].name + ", Second: " + input[1].name + "
\n"); - if(!JXG.exists(attr.styleGGB)) { - attr.face = 'circle'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - attr.highlightFillColor = attr.strokeColor; - attr.highlightFillOpacity = 1; - attr.strokeColor = 'black'; - attr.strokeWidth = '1px'; - } - if(output.length == 1) { - p = board.create('intersection', [input[0], input[1], 0], attr); - } - else { - p = board.create('intersection', [input[0], input[1], 1], attr); - var attr2 = {}; - attr2 = JXG.GeogebraReader.colorProperties(output[1], attr2); - attr2 = JXG.GeogebraReader.visualProperties(output[1], attr2); - attr2.name = output[1].getAttribute('label'); - var p2 = board.create('otherintersection', [input[0], input[1], p], attr2); - board.ggbElements[attr2.name] = p2; - } - - return p; - } catch(e) { - JXG.debug("* Err: Intersection " + attr.name +"
\n"); - return false; - } - break; - case 'distance': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - - try { - JXG.debug("* Distance: First: " + input[0].name + ", Second: " + input[1].name + "
\n"); - - if(false && output[0].getAtribute('type') && output[0].getAttribute('type') == 'numeric') { - input[1].Value = function(){ return this.X(); }; - p = input[1]; - board.elementsByName[attr.name] = p; - } else { - m = board.create('midpoint', input, {visible: 'false'}); - attr.visible = 'true'; - p = board.create('text', [function(){return m.X();}, function(){return m.Y();}, function(){ - return ""+ input[0].name + input[1].name +" = " - + JXG.trimNumber(JXG.getRef(board, input[0].id).Dist(JXG.getRef(board, input[1].id)).toFixed(JXG.GeogebraReader.decimals)); - }], attr); - p.Value = function () { - return (JXG.getRef(board, input[0].id).Dist(JXG.getRef(board, input[1].id))); - } - } - return p; - } catch(e) { - JXG.debug("* Err: Distance " + attr.name +"
\n"); - return false; - } - break; - case 'vector': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - if(element.getElementsByTagName("startPoint")[0]) { - - if(input && input.length == 2) { - e = JXG.GeogebraReader.checkElement(input[1].name); - } else { - e = [parseFloat(element.getElementsByTagName("coords")[0].getAttribute("x")), parseFloat(element.getElementsByTagName("coords")[0].getAttribute("y"))]; - } - if(element.getElementsByTagName("startPoint")[0].getAttribute("x") && element.getElementsByTagName("startPoint")[0].getAttribute("y")) { - s = [parseFloat(element.getElementsByTagName("startPoint")[0].getAttribute("x")), parseFloat(element.getElementsByTagName("startPoint")[0].getAttribute("y"))]; - } else if(element.getElementsByTagName("startPoint")[0].getAttribute("exp")) { - var startpoint = element.getElementsByTagName("startPoint")[0].getAttribute("exp"); - s = JXG.GeogebraReader.checkElement(startpoint); - } - } else if(input && input.length != 0) { - s = input[0]; - e = input[1]; - } else { - exp = JXG.GeogebraReader.getElement(element.getAttribute('label'), true); - if(exp) {// experimental - exp = exp.getAttribute('exp'); - // exp = JXG.GeogebraReader.functionParse('', exp); - exp = JXG.GeogebraReader.ggbParse(exp); - if (JXG.isArray(exp)) - exp = new Array(new Function('return '+ exp[1] +';'), new Function('return '+ exp[2] +';')); - else - exp = new Function('return '+ exp +';'); - JXG.debug('exp: '+ exp); - p = board.create('arrow', [[0,0], [exp[0], exp[1]]], attr); - return p; - //t = JXG.getRef(board, 'a'); - //s = t.point1; - // var e = [-1*vector.point2.X(), -1*vector.point2.Y()]; - // attr.type = 'rotate'; - // var angle; - // if(exp < 0) { - // angle = Math.PI; - // } else if(exp == 0) { - // angle = 0; - // } else { - // angle = Math.PI/exp; - // } - // needed: a clean rotating based on factor 'exp' - - // priorization of expression like 't*a' --> a := startPoint - } - } - - try { - JXG.debug("* Vector: First: " + attr.name); - p = board.create('arrow', [s, e], attr); - return p; - } catch(e) { - JXG.debug("* Err: Vector " + attr.name + e +"
\n"); - return false; - } - break; - case 'rotate': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Rotate: First: " + input[0].name + ", Second: " + input[1] + "
\n"); - attr.type = 'rotate'; - - if(!JXG.exists(attr.styleGGB)) { - attr.face = 'circle'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - attr.highlightFillColor = attr.strokeColor; - attr.highlightFillOpacity = 1; - attr.strokeColor = 'black'; - attr.strokeWidth = '1px'; - } - - t = board.create('transform', [parseInt(input[1])*Math.PI/180, input[2]], {type:'rotate'}); - p = board.create('point', [input[0], t], attr); - return p; - } catch(e) { - JXG.debug("* Err: Rotate " + attr.name +"
\n"); - return false; - } - break; - case 'dilate': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Dilate: First: " + input[0].name + ", Second: " + input[1] + "
\n"); - attr.type = 'rotate'; - var d = parseInt(input[1]); - var d1 = board.create('transform', [d, d], {type:'scale'}); - var d2 = board.create('transform', [function() { return (1-d) * input[2].X(); }, - function() { return (1-d) * input[2].Y(); }], {type:'translate'}); - - if(!JXG.exists(attr.styleGGB)) { - attr.face = 'circle'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - attr.highlightFillColor = attr.strokeColor; - attr.highlightFillOpacity = 1; - attr.strokeColor = 'black'; - attr.strokeWidth = '1px'; - } - p = board.create('point', [input[0], [d1, d2]], attr); - - return p; - } catch(e) { - JXG.debug("* Err: Dilate " + attr.name +"
\n"); - return false; - } - break; - case 'translate': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - t = board.create('transform', [function() { return input[1].point2.X()-input[1].point1.X(); }, - function() { return input[1].point2.Y()-input[1].point1.Y(); }], {type:'translate'}); - if(!JXG.exists(attr.styleGGB)) { - attr.face = 'circle'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - attr.highlightFillColor = attr.strokeColor; - attr.highlightFillOpacity = 1; - attr.strokeColor = 'black'; - attr.strokeWidth = '1px'; - } - p = board.create('point', [input[0], t], attr); - return p; - } catch(e) { - JXG.debug("* Err: Translate " + attr.name +"
\n"); - return false; - } - break; - case 'mirror': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - if (JXG.isPoint(JXG.getRef(board, input[1].id))) var type = 'mirrorpoint'; // Punktspiegelung - else if(JXG.getRef(board, input[1].id).elementClass == JXG.OBJECT_CLASS_LINE) var type = 'reflection'; // Geradenspiegelung - - try { - JXG.debug("* Mirror: First: " + input[0].name + ", Second: " + input[1].name + "
\n"); - p = board.create(type, [input[1], input[0]], attr); - return p; - } catch(e) { - JXG.debug("* Err: Mirror " + attr.name +"
\n"); - return false; - } - break; - case 'circle': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Circle: First: " + input[0].name + ", Second: " + input[1] + "
\n"); - p = board.create('circle', input, attr); - return p; - } catch(e) { - JXG.debug("* Err: Circle " + attr.name +"
\n"); - return false; - } - break; - case 'circlearc': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* CircleArc: First: " + input[0].name + ", Second: " + input[1].name + "
\n"); - p = board.create('arc', input, attr); - return p; - } catch(e) { - JXG.debug("* Err: CircleArc " + attr.name +"
\n"); - return false; - } - break; - case 'ellipse': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Ellipse: First: " + input[0].name + ", Second: " + input[1].name + ", Third: "+ input[2] +"
\n"); - // if third parameters is the major axis, else the third parameter is a point - if(parseInt(input[2]) == input[2]) - input[2] = parseInt(input[2]*2); // Geogebra delivers the half major axis - - p = board.create('ellipse', input, attr); - return p; - } catch(e) { - JXG.debug("* Err: Ellipse " + attr.name +"
\n"); - return false; - } - break; - case 'conic': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - -// try { - /* - // is there an expression named like the conic? - var exp = JXG.GeogebraReader.getElement(attr.name, true); - - // then get the function parameteres - if(exp.attributes['exp']){ - // exp = JXG.GeogebraReader.functionParse(exp.attributes['exp'].value); - // exp = JXG.GeogebraReader.ggbParse(exp.attributes['exp'].value); - - - - // (exp.getElementsByTagName('value')) ? exp = parseFloat(exp.getElementsByTagName('value')[0].attributes['val'].value) : false; - - } else */ if(input && input.length == 5) { - p = board.create('conic', input, attr); - } else if(element.getElementsByTagName('matrix')) { - m = []; - for(var i=0; iErr: Conic " + attr.name +"
\n"); -// return false; -// } - break; - case 'circlesector': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - //attr.names = [attr.name,'','','']; - //attr2 = {}; - //attr2.names = attr.names; - try { - JXG.debug("* CircleSector: First: " + input[0].name + ", Second: " + input[1].name + ", Third: " + input[2].name + "
\n"); - p = board.create('sector', [input[0],input[1],input[2]], attr); - /* - p.point4.hideElement(); - p.arc.setProperty(attr); - p.arc.visProp.highlightstrokewidth = (1*p.arc.visProp.strokewidth.substr(0,p.arc.visProp.strokewidth.length-2)+1)+'px'; - p.lines[0].setProperty(attr); - p.lines[1].setProperty(attr); - p.lines[0].visProp.highlightstrokewidth = (1*p.lines[0].visProp.strokerwWidth.substr(0,p.lines[0].visProp.strokewidth.length-2)+1)+'px'; - p.lines[1].visProp.highlightstrokewidth = (1*p.lines[1].visProp.strokerwWidth.substr(0,p.lines[1].visProp.strokewidth.length-2)+1)+'px'; - p.arc.hasPoint = p.arc.hasPointSector; - p.arc.highlight = (function(el){ return function() { - this.board.renderer.highlight(this); - this.board.renderer.highlight(el.lines[0]); - this.board.renderer.highlight(el.lines[1]); - };})(p); - p.arc.noHighlight = (function(el){ return function() { - this.board.renderer.noHighlight(this); - this.board.renderer.noHighlight(el.lines[0]); - this.board.renderer.noHighlight(el.lines[1]); - };})(p); - p.lines[0].highlight = (function(el){ return function() { - this.board.renderer.highlight(this); - this.board.renderer.highlight(el.arc); - this.board.renderer.highlight(el.lines[1]); - };})(p); - p.lines[1].highlight = (function(el){ return function() { - this.board.renderer.highlight(this); - this.board.renderer.highlight(el.arc); - this.board.renderer.highlight(el.lines[0]); - };})(p); - p.lines[0].noHighlight = (function(el){ return function() { - this.board.renderer.noHighlight(this); - this.board.renderer.noHighlight(el.arc); - this.board.renderer.noHighlight(el.lines[1]); - };})(p); - p.lines[1].noHighlight = (function(el){ return function() { - this.board.renderer.noHighlight(this); - this.board.renderer.noHighlight(el.arc); - this.board.renderer.noHighlight(el.lines[0]); - };})(p); - */ - return p; - } catch(e) { - JXG.debug("* Err: CircleSector " + attr.name +"
\n"); - return false; - } - break; - case 'linebisector': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* LineBiSector (Mittelsenkrechte): First: " + input[0].name + "
\n"); - m = board.create('midpoint', input, {visible: false}); - if(JXG.isPoint(JXG.getRef(board, input[0].id)) && - JXG.isPoint(JXG.getRef(board, input[1].id))) { - t = board.create('line', input, {visible: 'false'}); - p = board.create('perpendicular', [m, t], attr); - // p.point.setProperty('visible:false'); - } else { - p = board.create('perpendicular', [m, input[0]], attr); - // p.point.setProperty('visible:false'); - } - return p; - } catch(e) { - JXG.debug("* Err: LineBiSector (Mittelsenkrechte) " + attr.name +"
\n"); - return false; - } - break; - case 'ray': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Ray: First: " + input[0].name + "
\n"); - attr.straightFirst = true; - attr.straightLast = false; - p = board.create('line', [input[1], input[0]], attr); - return p; - } catch(e) { - JXG.debug("* Err: Ray " + attr.name +"
\n"); - return false; - } - break; - case 'tangent': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Tangent: First: " + input[0].name + ", Sec.: "+ input[1].name +"("+ input[1].type +")
\n"); - switch(input[1].type) { - case 1330923344: // graph - input[0].makeGlider(input[1]); - p = board.create('tangent', [input[0]], attr); - return p; - break; - case 1330922316: // circle 0x4F54434C - case 1330922319: // conic 0x4F54434F - var pol = board.create('polar',[input[1],input[0]],{visible:false}); - var i1 = board.create('intersection', [input[1], pol, 0], {visible: false}); - var i2 = board.create('intersection', [input[1], pol, 1], {visible: false}); - var t1 = board.create('line', [input[0], i1], attr); - var attr2 = {}; - attr2 = JXG.GeogebraReader.colorProperties(output[1], attr2); - attr2 = JXG.GeogebraReader.visualProperties(output[1], attr2); - attr2.name = output[1].getAttribute('label'); - var t2 = board.create('line', [input[0], i2], attr2); - board.ggbElements[attr2.name] = t2; - return [t1, t2]; - break; - } - } catch(e) { - JXG.debug("* Err: Tangent " + attr.name +" "+ attr2.name + "
\n"); - return false; - } - break; - case 'circumcirclearc': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* CircumcircleArc: First: " + input[0].name + "
\n"); - p = board.create('circumcirclearc', input, attr); - return p; - } catch(e) { - JXG.debug("* Err: CircumcircleArc " + attr.name +"
\n"); - return false; - } - break; - case 'circumcirclesector': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* CircumcircleSector: First: " + input[0].name + "
\n"); - p = board.create('circumcirclesector', [input[0], input[1], input[2]], attr); //{name:attr['name']}); - /* - p.arc.setProperty(attr); - p.lines[0].setProperty(attr); - p.lines[1].setProperty(attr); - p.arc.visProp.highlightstrokewidth = (1*p.arc.visProp.strokewidth.substr(0,p.arc.visProp.strokewidth.length-2)+1)+'px'; - p.lines[0].visProp.highlightstrokewidth = (1*p.lines[0].visProp.strokewidth.substr(0,p.lines[0].visProp.strokewidth.length-2)+1)+'px'; - p.lines[1].visProp.highlightstrokewidth = (1*p.lines[1].visProp.strokewidth.substr(0,p.lines[1].visProp.strokewidth.length-2)+1)+'px'; - p.arc.hasPoint = p.arc.hasPointSector; - p.arc.highlight = (function(el){ return function() { - this.board.renderer.highlight(this); - this.board.renderer.highlight(el.lines[0]); - this.board.renderer.highlight(el.lines[1]); - };})(p); - p.arc.noHighlight = (function(el){ return function() { - this.board.renderer.noHighlight(this); - this.board.renderer.noHighlight(el.lines[0]); - this.board.renderer.noHighlight(el.lines[1]); - };})(p); - p.lines[0].highlight = (function(el){ return function() { - this.board.renderer.highlight(this); - this.board.renderer.highlight(el.arc); - this.board.renderer.highlight(el.lines[1]); - };})(p); - p.lines[1].highlight = (function(el){ return function() { - this.board.renderer.highlight(this); - this.board.renderer.highlight(el.arc); - this.board.renderer.highlight(el.lines[0]); - };})(p); - p.lines[0].noHighlight = (function(el){ return function() { - this.board.renderer.noHighlight(this); - this.board.renderer.noHighlight(el.arc); - this.board.renderer.noHighlight(el.lines[1]); - };})(p); - p.lines[1].noHighlight = (function(el){ return function() { - this.board.renderer.noHighlight(this); - this.board.renderer.noHighlight(el.arc); - this.board.renderer.noHighlight(el.lines[0]); - };})(p); - */ - return p; - } catch(e) { - JXG.debug("* Err: CircumcircleSector " + attr.name +"
\n"); - return false; - } - break; - case 'semicircle': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Semicircle: First: " + input[0].name + "
\n"); - p = board.create('semicircle', [input[0], input[1]], attr); - return p; - } catch(e) { - JXG.debug("* Err: Semicircle " + attr.name +"
\n"); - return false; - } - break; - case 'angle': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Angle: First: " + input[0].name + "
\n"); - p = board.create('angle', input, attr); - return p; - } catch(e) { - JXG.debug("* Err: Angle " + attr.name +"
\n"); - return false; - } - break; - case 'angularbisector': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - attr.straightFirst = true; - attr.straightLast = true; - - try { - JXG.debug("* Angularbisector: First: " + input[0].name + "
\n"); - p = board.create('bisector', input, attr); - return p; - } catch(e) { - JXG.debug("* Err: Angularbisector " + attr.name +"
\n"); - return false; - } - break; - case 'numeric': - if(element.getElementsByTagName('slider').length == 0) { - // auxiliary doesn't exist in every numeric - //element.getElementsByTagName('auxiliary').length != 0 && element.getElementsByTagName('auxiliary')[0].attributes['val'].value == 'true') { - exp = JXG.GeogebraReader.getElement(element.getAttribute('label'), true); - if(exp) { - exp = exp.getAttribute('exp'); - exp = JXG.GeogebraReader.functionParse('', exp); - exp = JXG.GeogebraReader.ggbParse(exp); - } - board.ggb[attr.name] = new Function('return '+ exp +';'); - JXG.debug('value: '+ board.ggb[attr.name]()); - return board.ggb[attr.name]; - } else { - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - // gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - if(element.getElementsByTagName('slider').length == 1) { // it's a slider - sx = parseFloat(element.getElementsByTagName('slider')[0].getAttribute('x')); - sy = parseFloat(element.getElementsByTagName('slider')[0].getAttribute('y')); - length = parseFloat(element.getElementsByTagName('slider')[0].getAttribute('width')); - // are coordinates absolut? - if(element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') && element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') == 'true') { - var tmp = new JXG.Coords(JXG.COORDS_BY_SCREEN, [sx, sy], board); - sx = tmp.usrCoords[1]; - sy = tmp.usrCoords[2]; - } - - if(element.getElementsByTagName('slider')[0].getAttribute('horizontal') == 'true') { - if(element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') && element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') == 'true') - length /= (board.unitX); //*board.zoomX); - ex = sx + length; - ey = sy; - } else { - if(element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') && element.getElementsByTagName('slider')[0].getAttribute('absoluteScreenLocation') == 'true') - length /= (board.unitY); //*board.zoomY); - ex = sx; - ey = sy + length; - } - - (element.getElementsByTagName('animation')[0]) ? attr.snapWidth = parseFloat(element.getElementsByTagName('animation')[0].getAttribute('step')) : false; - - try { - JXG.debug("* Numeric: First: " + attr.name + "
\n"); - attr['withTicks'] = false; - p = board.create('slider', [[sx,sy], [ex,ey], [parseFloat(element.getElementsByTagName('slider')[0].getAttribute('min')), - parseFloat(element.getElementsByTagName('value')[0].getAttribute('val')), - parseFloat(element.getElementsByTagName('slider')[0].getAttribute('max'))]], attr); - p.setProperty({withLabel:false}); - return p; - } catch(e) { - JXG.debug("* Err: Numeric " + attr.name +"
\n"); - return false; - } - } - } - break; - case 'midpoint': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - if(!JXG.exists(attr.styleGGB)) { - attr.face = 'circle'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - attr.highlightFillColor = attr.strokeColor; - attr.highlightFillOpacity = 1; - attr.strokeColor = 'black'; - attr.strokeWidth = '1px'; - } - p = board.create('midpoint', input, attr); - JXG.debug("* Midpoint ("+ p.id +"): "+ attr.name + "("+ gxtEl.x +", "+ gxtEl.y +")
\n"); - return p; - } catch(e) { - JXG.debug("* Err: Midpoint " + attr.name +"
\n"); - return false; - } - break; - case 'center': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - try { - if(!JXG.exists(attr.styleGGB)) { - attr.face = 'circle'; - attr.fillColor = attr.strokeColor; - attr.fillOpacity = 1; - attr.highlightFillColor = attr.strokeColor; - attr.highlightFillOpacity = 1; - attr.strokeColor = 'black'; - attr.strokeWidth = '1px'; - } - p = board.create('point', [function() { return JXG.getRef(board, input[0].id).center.X(); }, - function() { return JXG.getRef(board, input[0].id).center.Y(); }], attr); - JXG.debug("* Center ("+ p.id +"): "+ attr.name + "("+ gxtEl.x +", "+ gxtEl.y +")
\n"); - return p; - } catch(e) { - JXG.debug("* Err: Center " + attr.name +"
\n"); - return false; - } - break; - case 'function': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - if(JXG.GeogebraReader.getElement(attr.name, true)) { - func = JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp'); - func = JXG.GeogebraReader.functionParse('c', func); - } else { - func = input[0]; - func = JXG.GeogebraReader.functionParse('s', func); - } - - JXG.debug(func); - - length = func.length; - func[func.length-1] = 'return '+ JXG.GeogebraReader.ggbParse(func[func.length-1]) +';'; - - JXG.debug(func); - - range = [(input && input[1]) ? input[1] : null, (input && input[2]) ? input[2] : null]; - - try { - if(length == 1) - p = board.create('functiongraph', [new Function(func[0]), range[0], range[1]], attr); - else if(length==2) - p = board.create('functiongraph', [new Function(func[0], func[1]), range[0], range[1]], attr); - else if(length==3) - p = board.create('functiongraph', [new Function(func[0], func[1], func[2]), range[0], range[1]], attr); - else if(length==4) - p = board.create('functiongraph', [new Function(func[0], func[1], func[2], func[3]), range[0], range[1]], attr); - else if(length==5) - p = board.create('functiongraph', [new Function(func[0], func[1], func[2], func[3], func[4]), range[0], range[1]], attr); - return p; - } catch(e) { - JXG.debug("* Err: Functiongraph " + attr.name +"
\n"); - return false; - } - - break; - case 'polar': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Polar: First: " + input[0].name + ", Sec.: "+ input[1].name +"
\n"); - p = board.create('polar', input, attr); - return p; - } catch(e) { - JXG.debug("* Err: Polar " + attr.name +"
\n"); - return false; - } - break; - case 'slope': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - - try { - JXG.debug("* Slope ("+ attr.name +"): First: " + input[0].name +"
\n"); - var slopeWidth = parseInt(attr.slopeWidth) || 1.0; - var p1 = input[0].glider || input[0].point1; - var p2 = board.create('point',[function(){return (slopeWidth+p1.X());}, function(){return p1.Y();}], {visible: false}); - var l1 = board.create('segment', [p1, p2], {visible: false}); // visible: attr.visible - var l2 = board.create('normal', [l1, l1.point2], {visible: false}); // visible attr.visible - var i = board.create('intersection', [input[0], l2, 0], {visible: false}); - var m = board.create('midpoint', [l1.point2, i], {visible: false}); - - var t = board.create('text', [function(){return m.X();}, function(){return m.Y();}, - function(){ return "  " + (slopeWidth > 1 ? slopeWidth.toString() : "") + " " + this.name + " = " + JXG.trimNumber((slopeWidth * input[0].getSlope()).toFixed(JXG.GeogebraReader.decimals)); }], attr); - attr.name = ""; - var t2 = board.create('text', [function(){return (p1.X() + p2.X())/2.;}, function(){return p1.Y();}, - function(){ return "
" + slopeWidth; }], attr); - t.Value = (function() { return function(){ return input[0].getSlope(); }; })(); - var poly = board.create('polygon',[p1,p2,i], attr); - - poly.borders[2].setProperty({visible: false}); - poly.borders[0].setProperty({strokeColor: attr.fillColor, strokeWidth: attr.strokeWidth, highlightStrokeColor: attr.fillColor, dash:attr.dash}); - poly.borders[1].setProperty({strokeColor: attr.fillColor, strokeWidth: attr.strokeWidth, highlightStrokeColor: attr.fillColor, dash:attr.dash}); - return t; - } catch(e) { - JXG.debug("* Err: Slope " + attr.name +"
\n"); - return false; - } - break; - case 'text': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - var rx, res = ''; - - try { - if(element.getElementsByTagName('isLaTeX')[0] && element.getElementsByTagName('isLaTeX')[0].getAttribute('val') == 'true') { - JXG.GeogebraReader.board.options.text.useASCIIMathML = true; - t = JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp'); - - // here we're searching for patterns like - // " + ... + " - // ... will be sent to the ggbParser and a calculated text element is built from this. - while(rx = t.match(/(.*?)" \+ (.+) \+ "(.*)/)) { - var re2 = JXG.GeogebraReader.ggbParse(RegExp.$2); - if (typeof re2 == 'string') { - res = res + RegExp.$1 + re2; - } else { - res = res + RegExp.$1 + '" + JXG.trimNumber((' + re2 + ').toFixed(JXG.GeogebraReader.decimals)) + "'; - } - t = RegExp.$3; - } - // we have to look, if the string's ending with a string-part or a formula part: - if(rx = t.match(/(.*?)" \+ (.+)/)) { - res = res + RegExp.$1 + '" + JXG.trimNumber((' + JXG.GeogebraReader.ggbParse(RegExp.$2) + ').toFixed(JXG.GeogebraReader.decimals))'; - } else - res = res + t; - - JXG.debug("Text: "+res); - - p = board.create('text', [gxtEl.x, gxtEl.y, new Function('return ' + res + ';')], attr); - } else { - JXG.debug(JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp')); - t = JXG.GeogebraReader.ggbParse(JXG.GeogebraReader.functionParse(false, JXG.GeogebraReader.getElement(attr.name, true).getAttribute('exp'))); - JXG.debug(t[1]); - p = board.create('text', [gxtEl.x, gxtEl.y, new Function('return '+t[0]+' + " " + JXG.trimNumber(parseFloat(' + t[1] +').toFixed(JXG.GeogebraReader.decimals));') ], attr); - } - JXG.debug("* Text: " + t +"
\n"); - return p; - } catch(e) { - JXG.debug("* Err: Text: " + t +"
\n"); - return false; - } - break; - case 'root': - attr = JXG.GeogebraReader.boardProperties(gxtEl, element, attr); - attr = JXG.GeogebraReader.colorProperties(element, attr); - gxtEl = JXG.GeogebraReader.coordinates(gxtEl, element); - attr = JXG.GeogebraReader.visualProperties(element, attr); - //JXG.debug(JXG.getRef(board, gxtEl.id)); - - for(var i=0; iIntegral: First: " + input[0].name + ", Sec.: "+ input[1].name +", Thir.: "+ input[2].name +"
\n"); - JXG.debug([input[1](), input[2]()]); - var p = board.create('integral', [JXG.getRef(board, input[0]), [input[1], input[2]]], attr); - return p; - } catch(e) { - JXG.debug("* Err: Integral " + attr.name + e + "
\n"); - return false; - } - break; - -// case 'transform': -// break; -// case 'radius': -// break; -// case 'derivative': -// break; -// case 'root': -// break; -// case 'corner': -// break; -// case 'unitvector': -// break; -// case 'extremum': -// break; -// case 'turningpoint': -// break; -// case 'arc': -// break; -// case 'circlepart': -// break; -// case 'uppersum': -// break; -// case 'lowersum': -// break; -// case 'image': -// break; - default: - return false; - break; - } -}; - -/** - * Reading the elements of a geogebra file - * @param {Object} board board object - */ -this.readGeogebra = function(tree, board) { - var el, Data, i, els = [], expr; - - board.ggbElements = []; - board.ggb = {}; - JXG.GeogebraReader.tree = tree; - JXG.GeogebraReader.board = board; - JXG.GeogebraReader.format = parseFloat(JXG.GeogebraReader.tree.getElementsByTagName('geogebra')[0].getAttribute('format')); - JXG.GeogebraReader.decimals = parseInt(JXG.GeogebraReader.tree.getElementsByTagName('geogebra')[0].getElementsByTagName('kernel')[0].getElementsByTagName('decimals')[0].getAttribute('val')); - JXG.GeogebraReader.writeBoard(board); - board = JXG.GeogebraReader.setDefaultOptions(board); - - // speeding up the drawing process - //board.suspendUpdate(); - - var constructions = JXG.GeogebraReader.tree.getElementsByTagName("construction"); - for (var t=0; t"); - - /* register borders to according "parent" */ - if(board.ggbElements[elname].borders) - for(var i=0; i"); - }; - } - }; - - JXG.debug('Restesammler: '); - // create "single" elements which do not depend on any other - var elements = constructions[t].getElementsByTagName("element"); - for (var s=0; s=') : exp; - exp = (exp.match(/\u2227/)) ? exp.replace(/\u2227/g, '&&') : exp; - exp = (exp.match(/\u2228/)) ? exp.replace(/\u2228/g, '//') : exp; - return exp; -}; - -/** - * Extracting the packed geogebra file in order to return the "blank" xml-tree for further parsing. - * @param {String} archive containing geogebra.xml-file or raw input string (eg. xml-tree) - * @return {String} content of geogebra.xml-file if archive was passed in - */ -this.prepareString = function(fileStr, isString) { - var i, bA, len, fstr; - - // here we have to deal with two different base64 encoded streams - // first one: base64 encoded xml (geogebra's web export) - // second one: base64 encoded ggb file, this is our recommendation for an IE & Opera - // workaround, which can't deal with binary data transferred via AJAX. - - // first try to decode assuming we got a base64 encoded ggb file - if(isString) { - fstr = JXG.Util.Base64.decode(fileStr); - if(fstr.slice(0,2)!=="PK") { - // ooops, that was no ggb file. try again with utf8 parameter set. - fstr = JXG.Util.Base64.decode(fileStr, true); - } - fileStr = fstr; - } - - if (fileStr.indexOf('<') != 0) { - bA = []; - len = fileStr.length; - for (i=0;i. -*/ -JXG.debug = function() {}; -JXG.GeonextReader = { - - changeOriginIds: function (board, id) { - if ((id == 'gOOe0') || (id == 'gXOe0') || (id == 'gYOe0') || (id == 'gXLe0') || (id == 'gYLe0')) { - return board.id + id; - } else { - return id; - } - }, - - /** - * Retrieves data by TagName from an XML node. - * @param {Node} node The Node that contains the data we want to get. - * @param {String} tag The Name of the tag we are looking for. - * @param {Number} [idx=0] getElementsByTagName returns an array; This parameter decides which element to use. - * @param {Boolean} [fc=true] If True, the result will be the data of firstChild instead of the result node. - * @returns {String} The gathered data - */ - gEBTN: function (node, tag, idx, fc) { - var tmp; - - if (!JXG.exists(node || !node.getElementsByTagName )/* || !JXG.exists(node.getElementsByTagName)*/) { - return ''; - } - // Default values for optional parameters idx and fc - if (!JXG.exists(fc)) { - fc = true; - } - idx = idx || 0; - tmp = node.getElementsByTagName(tag); - if (tmp.length > 0) { - tmp = tmp[idx]; - if (fc && tmp.firstChild) { - tmp = tmp.firstChild.data; - } - } - return tmp; - }, - - /** - * Set color properties of a geonext element. - * Set stroke, fill, lighting, label and draft color attributes. - * @param {Object} gxtEl element of which attributes are to set - */ - colorProperties: function (gxtEl, Data) { - var color = this.gEBTN(Data, 'color', 0, false), - rgbo; - - //gxtEl.strokewidth = Data.getElementsByTagName('strokewidth')[0].firstChild.data; - // colorStroke = strokeColor etc. is here for downwards compatibility: - // once upon a time we used to create elements in here using the "new JXG.Element" constructor mechanism - // then we changed to board.create + setProperty afterwords - // now i want to use the board.create method with an appropriate attributes object to avoid setProperty calls - // and as gxtEl happens to be somewhat like an attributes object it's just slightly different so we adjust it - // for downwards compatibility during the transformation of this reader we use both properties - - rgbo = JXG.rgba2rgbo(this.gEBTN(color, 'stroke')); - gxtEl.strokeColor = rgbo[0]; - gxtEl.strokeOpacity = rgbo[1]; - - rgbo = JXG.rgba2rgbo(this.gEBTN(color, 'lighting')); - gxtEl.highlightStrokeColor = rgbo[0]; - gxtEl.highlightStrokeOpacity = rgbo[1]; - - rgbo = JXG.rgba2rgbo(this.gEBTN(color, 'fill')); - gxtEl.fillColor = rgbo[0]; - gxtEl.fillOpacity = rgbo[1]; - - gxtEl.highlightFillColor = gxtEl.fillColor; - gxtEl.highlightFillOpacity = gxtEl.fillOpacity; - - gxtEl.labelColor = JXG.rgba2rgbo(this.gEBTN(color, 'label'))[0]; - gxtEl.colorDraft = JXG.rgba2rgbo(this.gEBTN(color, 'draft'))[0]; - - // GEONExT hides labels by setting opacity to 0. - if (JXG.rgba2rgbo(this.gEBTN(color, 'label'))[1]==0) { - gxtEl.withLabel = false; - } else { - gxtEl.withLabel = true; - } - - // backwards compatibility - gxtEl.colorStroke = gxtEl.strokeColor; - gxtEl.colorFill = gxtEl.fillColor; - gxtEl.colorLabel = gxtEl.labelColor; - - return gxtEl; - }, - - firstLevelProperties: function (gxtEl, Data) { - if (!JXG.exists(Data) || !JXG.exists(Data.childNodes)) - return gxtEl; - - var arr = Data.childNodes, n, key; - - for (n = 0; n < arr.length; n++) { - if (JXG.exists(arr[n].firstChild) && arr[n].nodeName !== 'data' && arr[n].nodeName !== 'straight') { - key = arr[n].nodeName; - gxtEl[key] = arr[n].firstChild.data; - } - } - - return gxtEl; - }, - - /** - * Set the defining properties of a geonext element. - * Writing the nodeName to ident; setting the name attribute and defining the element id. - * @param {Object} gxtEl element of which attributes are to set - */ - defProperties: function (gxtEl, Data) { - // 3==TEXT_NODE, 8==COMMENT_NODE - if (Data.nodeType==3 || Data.nodeType==8 ) { - return null; - } - - gxtEl.ident = Data.nodeName; - - if(gxtEl.ident == "text" || gxtEl.ident == "intersection" || gxtEl.ident == "composition") { - gxtEl.name = ''; - } else { - gxtEl.name = this.gEBTN(Data, 'name'); - } - - gxtEl.id = this.gEBTN(Data, 'id'); - - return gxtEl; - }, - - visualProperties: function (gxtEl, Data) { - gxtEl.visible = JXG.str2Bool(this.gEBTN(Data, 'visible')); - gxtEl.trace = JXG.str2Bool(this.gEBTN(Data, 'trace')); - - return gxtEl; - }, - - transformProperties: function (gxtEl, type) { - var facemap = [ - // 0-2 - 'cross', 'cross', 'cross', - // 3-6 - 'circle', 'circle', 'circle', 'circle', - // 7-9 - 'square', 'square', 'square', - // 10-12 - 'plus', 'plus', 'plus' - ], sizemap = [ - // 0-2 - 2, 3, 4, - // 3-6 - 1, 2, 3, 4, - // 7-9 - 2, 3, 4, - // 10-12 - 2, 3, 4 - ]; - - gxtEl.strokeWidth = gxtEl.strokewidth; - gxtEl.face = facemap[parseInt(gxtEl.style, 10)] || 'cross'; - gxtEl.size = sizemap[parseInt(gxtEl.style, 10)] || 3; - - gxtEl.straightFirst = JXG.str2Bool(gxtEl.straightFirst); - gxtEl.straightLast = JXG.str2Bool(gxtEl.straightLast); - - gxtEl.visible = JXG.str2Bool(gxtEl.visible); - //gxtEl.withLabel = gxtEl.visible; // withLabel is set in colorProperties() - gxtEl.draft = JXG.str2Bool(gxtEl.draft); - gxtEl.trace = JXG.str2Bool(gxtEl.trace); - - if (type==='point') { - // Fill properties are ignored by GEONExT - gxtEl.fillColor = gxtEl.strokeColor; - gxtEl.highlightFillColor = gxtEl.highlightStrokeColor; - gxtEl.fillOpacity = gxtEl.strokeOpacity; - gxtEl.highlightFillOpacity = gxtEl.highlightStrokeOpacity; - } - - if (typeof(gxtEl.label === 'string')) { - delete(gxtEl.label); - } - - delete gxtEl.color; - return gxtEl; - }, - - readNodes: function (gxtEl, Data, nodeType, prefix) { - var arr = this.gEBTN(Data, nodeType, 0, false).childNodes, - key, n; - - for (n = 0; n < arr.length; n++) { - if (arr[n].firstChild != null) { - if (prefix != null) { - key = prefix + JXG.capitalize(arr[n].nodeName); - } else { - key = arr[n].nodeName; - } - gxtEl[key] = arr[n].firstChild.data; - } - } - return gxtEl; - }, - - subtreeToString: function (root) { - try { - // firefox - return (new XMLSerializer()).serializeToString(root); - } catch (e) { - // IE - return root.xml; - } - }, - - readImage: function (node) { - var pic = '', - nod = node; - - if (nod != null) { - pic = nod.data; - while (nod.nextSibling != null) { - nod = nod.nextSibling; - pic += nod.data; - } - } - return pic; - }, - - parseImage: function (board, fileNode, level, x, y, w, h, el) { - var tag, id, im, picStr, tmpImg; - - if (fileNode == null) { - return null; - } - - if (fileNode.getElementsByTagName('src')[0] != null) { // Background image - tag = 'src'; - } else if (fileNode.getElementsByTagName('image')[0] != null) { - tag = 'image'; - } else { - return null; - } - - picStr = this.readImage(this.gEBTN(fileNode, tag, 0, false).firstChild); - if (picStr!='') { - picStr = 'data:image/png;base64,' + picStr; - if (tag=='src') { // Background image - x = this.gEBTN(fileNode, 'x'); - y = this.gEBTN(fileNode, 'y'); - w = this.gEBTN(fileNode, 'width'); - h = this.gEBTN(fileNode, 'height'); - im = board.create('image', [picStr,[x, y],[w, h]], { - anchor: el, layer: level - }); - return im; - } else { - // Image bound to an element - // Read the original dimensions, i.e. the ratio h/w with the help of a temporary image. - // We have to wait until the image is loaded, therefore - // we need "onload". - tmpImg = new Image(); - tmpImg.src = picStr; - id = el.id + '_image'; - tmpImg.onload = function(){ - // Now, we can read the original dimensions of the image. - var wOrg = this.width, - hOrg = this.height, - xf, yf, wf, hf, im, tRot; - - if (el.elementClass == JXG.OBJECT_CLASS_LINE) { - // A line containing an image, runs through the horizontal middle - // of the image. - xf = function(){ return el.point1.X(); }; - wf = function(){ return el.point1.Dist(el.point2); }; - hf = function(){ return wf() * hOrg / wOrg; }; - yf = function(){ return el.point1.Y() - hf() * 0.5; }; - im = board.create('image', [picStr, [xf,yf], [wf,hf]], { - layer: level, - id: id, - anchor: el - }); - tRot = board.create('transform', [ - function () { - return Math.atan2(el.point2.Y()-el.point1.Y(), el.point2.X()-el.point1.X()) - }, - el.point1 - ], { - type:'rotate' - }); - tRot.bindTo(im); - el.image = im; - } else if (el.elementClass == JXG.OBJECT_CLASS_POINT) { - wf = function(){ return wOrg / board.unitX; }; - hf = function(){ return hOrg / board.unitY; }; - xf = function(){ return el.X() - wf() * 0.5; }; - yf = function(){ return el.Y() - hf() * 0.5; }; - - im = board.create('image', [picStr, [xf,yf], [wf,hf]], { - layer: level, - id: id, - anchor: el - }); - board.renderer.hide(el.label.content); - el.image = im; - } else if (el.elementClass == JXG.OBJECT_CLASS_CIRCLE) { - // A circle containing an image - wf = function(){ return 2.0 * el.Radius(); }; - hf = function(){ return wf() * hOrg / wOrg; }; - xf = function(){ return el.center.X() - wf() * 0.5; }; - yf = function(){ return el.center.Y() - hf() * 0.5; }; - im = board.create('image', [picStr, [xf,yf], [wf,hf]], { - layer: level, - id: id, - anchor: el - }); - el.image = im; - } else { - im = board.create('image', [picStr, [x, y], [w, h]], { - layer: level, - id: id, - anchor: el - }); - el.image = im; - } - }; - } - return im; - } - }, - - readConditions: function(node) { - var i, s, ob, - conditions = ''; - - if (JXG.exists(node)) { - for(i = 0; i < node.getElementsByTagName('data').length; i++) { - ob = node.getElementsByTagName('data')[i]; - s = this.subtreeToString(ob); - conditions += s; - } - } - - return conditions; - }, - - printDebugMessage: function(outputEl,gxtEl,nodetyp,success) { - JXG.debug("* " + success + ": " + nodetyp + " " + gxtEl.name + " " + gxtEl.id + "
\n"); - }, - - /** - * Reading the elements of a geonext file - * @param {XMLTree} tree expects the content of the parsed geonext file returned by function parseFF/parseIE - * @param {Object} board board object - */ - readGeonext: function(tree, board) { - var xmlNode, elChildNodes, - s, Data, inter, boardData, el, p, - conditions, tmp, strTrue = 'true', gxtReader = this; - - // maybe this is not necessary as we already provide layer options for sectors and circles via JXG.Options but - // maybe these have to be the same for geonext. - board.options.layer.sector = board.options.layer.angle; - board.options.layer.circle = board.options.layer.angle; - - board.options.line.label.position = 'top'; - - boardData = this.gEBTN(tree, 'board', 0, false); - conditions = this.readConditions(boardData.getElementsByTagName('conditions')[0]); - - // set the origin - xmlNode = this.gEBTN(boardData, 'coordinates', 0, false); - tmp = this.gEBTN(xmlNode, 'origin', 0, false); - board.origin = { - usrCoords: [1, 0, 0], - scrCoords: [1, parseFloat(this.gEBTN(tmp, 'x')), parseFloat(this.gEBTN(tmp, 'y'))] - }; - - // zoom level - tmp = this.gEBTN(xmlNode, 'zoom', 0, false); - board.zoomX = parseFloat(this.gEBTN(tmp, 'x')); - board.zoomY = parseFloat(this.gEBTN(tmp, 'y')); - - // screen to user coordinates conversion - tmp = this.gEBTN(xmlNode, 'unit', 0, false); - board.unitX = parseFloat(this.gEBTN(tmp, 'x')); - board.unitY = parseFloat(this.gEBTN(tmp, 'y')); - - // resize board - if (board.options.takeSizeFromFile) { - board.resizeContainer(this.gEBTN(boardData, 'width'), this.gEBTN(boardData, 'height')); - } - - // check and set fontSize - if (!(parseFloat(board.options.text.fontSize) > 0)) { - board.options.text.fontSize = 12; - } - - board.geonextCompatibilityMode = true; - - // jsxgraph chooses an id for the board but we don't want to use it, we want to use - // the id stored in the geonext file. if you know why this is required, please note it here. - delete(JXG.JSXGraph.boards[board.id]); - board.id = this.gEBTN(boardData, 'id'); - JXG.JSXGraph.boards[board.id] = board; - - // this creates some basic elements present in every geonext construction but not explicitly present in the file - board.initGeonextBoard(); - - // Update of properties during update() is not necessary in GEONExT files - // But it maybe necessary if we construct with JavaScript afterwards - board.renderer.enhancedRendering = true; - - // Read background image - this.parseImage(board, this.gEBTN(boardData, 'file', 0, false), board.options.layer['image']); - - board.options.point.snapToGrid = (this.gEBTN(this.gEBTN(boardData, 'coordinates', 0, false), 'snap') == strTrue); - // - // TODO: Missing jsxgraph feature snapToPoint - // If snapToGrid and snapToPoint are both true, point snapping is enabled - if (board.options.point.snapToGrid && this.gEBTN(this.gEBTN(boardData, 'grid', 1, false), 'pointsnap') == strTrue) { - board.options.point.snapToGrid = false; - board.options.point.snapToPoints = true; - board.options.point.attractorDistance = 0.5; - } - //board.options.grid.snapToGrid = false; - - xmlNode = this.gEBTN(boardData, 'grid', 1, false); - tmp = this.gEBTN(xmlNode, 'x'); - if (tmp) { - board.options.grid.gridX = 1 / parseFloat(tmp); - board.options.point.snapSizeX = parseFloat(tmp); - } - tmp = this.gEBTN(xmlNode, 'y'); - if (tmp) { - board.options.grid.gridY = 1 / parseFloat(tmp); - board.options.point.snapSizeY = parseFloat(tmp); - } - //board.calculateSnapSizes(); // Seems not to be correct - board.options.grid.gridDash = JXG.str2Bool(this.gEBTN(xmlNode, 'dash')); - - tmp = JXG.rgba2rgbo(this.gEBTN(xmlNode, 'color')); - board.options.grid.gridColor = tmp[0]; - board.options.grid.gridOpacity = tmp[1]; - - xmlNode = this.gEBTN(boardData, 'coordinates', 0, false); - if (this.gEBTN(xmlNode, 'grid') == strTrue) { - board.create('grid', []); - } - - if (this.gEBTN(xmlNode, 'coord') == strTrue) { - board.options.axis.ticks.majorHeight = 10; // Hard coded default option - board.options.axis.ticks.minorHeight = 4; // Hard coded default option - board.create('axis', [[0, 0], [1, 0]]); - board.create('axis', [[0, 0], [0, 1]]); - } - - board.containerObj.style.backgroundColor = JXG.rgba2rgbo(this.gEBTN(this.gEBTN(boardData, 'background', 0, false), 'color'))[0]; - - elChildNodes = tree.getElementsByTagName("elements")[0].childNodes; - for (s = 0; s < elChildNodes.length; s++) { - (function (s) { - var i, gxtEl = {}, - l, x, y, c, numberDefEls, - el, p, inter, rgbo, tmp; - - Data = elChildNodes[s]; - gxtEl = gxtReader.defProperties(gxtEl, Data); - - // Skip text nodes - if (!JXG.exists(gxtEl)) { - return; - } - - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName.toLowerCase, 'READ:'); - switch (Data.nodeName.toLowerCase()) { - case "point": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - gxtEl.fixed = JXG.str2Bool(gxtReader.gEBTN(Data, 'fix')); - gxtEl = gxtReader.transformProperties(gxtEl, 'point'); - - //try { - p = board.create('point', [parseFloat(gxtEl.x), parseFloat(gxtEl.y)], gxtEl); - - var v = function(){ return p.visProp.visible; }; - el = gxtReader.parseImage(board, Data, board.options.layer['image'], 0, 0, 0, 0, p); - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - /* - if (JXG.exists(el)) { - el.visProp.visible = function() { return p.visProp.visible; }; - alert(p.visProp.visible); - if (el.visProp.visible()) {el.showElement();} else {el.hideElement();} - } - */ - //} catch(e) { - // JXG.debug(e); - //} - break; - case "line": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - gxtEl = gxtReader.readNodes(gxtEl, Data, 'straight', 'straight'); - gxtEl = gxtReader.transformProperties(gxtEl); - - gxtEl.first = gxtReader.changeOriginIds(board, gxtEl.first); - gxtEl.last = gxtReader.changeOriginIds(board, gxtEl.last); - - l = board.create('line', [gxtEl.first, gxtEl.last], gxtEl); - - gxtReader.parseImage(board, Data, board.options.layer['image'], 0, 0, 0, 0, l); - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case "circle": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - - tmp = gxtReader.gEBTN(Data, 'data', 0, false); - gxtEl.center = gxtReader.changeOriginIds(board, gxtReader.gEBTN(tmp, 'midpoint')); - - if (tmp.getElementsByTagName('radius').length > 0) { - gxtEl.radius = gxtReader.changeOriginIds(board, gxtReader.gEBTN(tmp, 'radius')); - } else if (tmp.getElementsByTagName('radiusvalue').length > 0) { - gxtEl.radius = gxtReader.gEBTN(tmp, 'radiusvalue'); - } - gxtEl = gxtReader.transformProperties(gxtEl); - c = board.create('circle', [gxtEl.center, gxtEl.radius], gxtEl); - - gxtReader.parseImage(board, Data, board.options.layer['image'], 0, 0, 0, 0, c); - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case "slider": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - gxtEl.fixed = JXG.str2Bool(gxtReader.gEBTN(Data, 'fix')); - gxtEl = gxtReader.readNodes(gxtEl, Data, 'animate', 'animate'); - gxtEl = gxtReader.transformProperties(gxtEl, 'point'); - try { - gxtEl.parent = gxtReader.changeOriginIds(board, gxtEl.parent); - - // if (board.isSuspendedUpdate) { board.unsuspendUpdate().suspendUpdate(); } - p = board.create('glider', [parseFloat(gxtEl.x), parseFloat(gxtEl.y), gxtEl.parent], gxtEl); - p.onPolygon = JXG.exists(gxtEl.onpolygon) && JXG.str2Bool(gxtEl.onpolygon); - - gxtReader.parseImage(board, Data, board.options.layer['point'], 0, 0, 0, 0, p); - - //if (board.isSuspendedUpdate) { board.unsuspendUpdate().suspendUpdate(); } - - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - } catch(e) { - JXG.debug("* Err: Slider " + gxtEl.name + " " + gxtEl.id + ': '+ gxtEl.parent +"
\n"); - } - break; - case "cas": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl.fixed = JXG.str2Bool(Data.getElementsByTagName('fix')[0].firstChild.data); - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - gxtEl = gxtReader.transformProperties(gxtEl, 'point'); - - if (false) { // Handle weird element names - gxtEl.x = JXG.GeonextParser.gxt2jc(gxtEl.x, board); - gxtEl.y = JXG.GeonextParser.gxt2jc(gxtEl.y, board); - } else { // Workaround until the jessiecode compiler is 100% compatible - gxtEl.x = JXG.GeonextParser.geonext2JS(gxtEl.x, board); - gxtEl.x = new Function('return ' + gxtEl.x + ';'); - gxtEl.y = JXG.GeonextParser.geonext2JS(gxtEl.y, board); - gxtEl.y = new Function('return ' + gxtEl.y + ';'); - } - - /* - p = board.create('point', [parseFloat(gxtEl.xval), parseFloat(gxtEl.yval)], gxtEl); - p.addConstraint([gxtEl.x, gxtEl.y]); - p.type = JXG.OBJECT_TYPE_CAS; - */ - p = board.create('point', [gxtEl.x, gxtEl.y], gxtEl); - gxtReader.parseImage(board, Data, board.options.layer['point'], 0, 0, 0, 0, p); - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case "intersection": - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - xmlNode = Data.getElementsByTagName('first')[1]; - - gxtEl.outFirst = {}; - gxtEl.outFirst = gxtReader.colorProperties(gxtEl.outFirst, xmlNode); - gxtEl.outFirst = gxtReader.visualProperties(gxtEl.outFirst, xmlNode); - gxtEl.outFirst = gxtReader.firstLevelProperties(gxtEl.outFirst, xmlNode); - gxtEl.outFirst.fixed = JXG.str2Bool(xmlNode.getElementsByTagName('fix')[0].firstChild.data); - gxtEl.outFirst = gxtReader.transformProperties(gxtEl.outFirst, 'point'); - gxtEl.first = gxtReader.changeOriginIds(board, gxtEl.first); - gxtEl.last = gxtReader.changeOriginIds(board, gxtEl.last); - - //if ((board.objects[gxtEl.first].type == JXG.OBJECT_TYPE_LINE || board.objects[gxtEl.first].type == JXG.OBJECT_TYPE_ARROW) - // && (board.objects[gxtEl.last].type == JXG.OBJECT_TYPE_LINE || board.objects[gxtEl.last].type == JXG.OBJECT_TYPE_ARROW)) { - if ((JXG.getReference(board, gxtEl.first).elementClass == JXG.OBJECT_CLASS_LINE) - && (JXG.getReference(board, gxtEl.last).elementClass == JXG.OBJECT_CLASS_LINE)) { - /* - inter = new JXG.Intersection(board, gxtEl.id, board.objects[gxtEl.first], - board.objects[gxtEl.last], gxtEl.outFirst.id, '', - gxtEl.outFirst.name, ''); - inter.p.setProperty(gxtEl.outFirst); - */ - inter = board.create('intersection', [board.objects[gxtEl.first], board.objects[gxtEl.last], 0], gxtEl.outFirst); - /* offensichtlich braucht man dieses if doch */ - if (gxtEl.outFirst.visible == "false") { - inter.hideElement(); - } - } else { - xmlNode = Data.getElementsByTagName('last')[1]; - if (JXG.exists(xmlNode)) { - gxtEl.outLast = {}; - gxtEl.outLast = gxtReader.colorProperties(gxtEl.outLast, xmlNode); - gxtEl.outLast = gxtReader.visualProperties(gxtEl.outLast, xmlNode); - gxtEl.outLast = gxtReader.firstLevelProperties(gxtEl.outLast, xmlNode); - gxtEl.outLast.fixed = JXG.str2Bool(xmlNode.getElementsByTagName('fix')[0].firstChild.data); - gxtEl.outLast = gxtReader.transformProperties(gxtEl.outLast, 'point'); - /* - inter = new JXG.Intersection(board, gxtEl.id, board.objects[gxtEl.first], - board.objects[gxtEl.last], gxtEl.outFirst.id, gxtEl.outLast.id, - gxtEl.outFirst.name, gxtEl.outLast.name); - inter.p1.setProperty(gxtEl.outFirst); - inter.p2.setProperty(gxtEl.outLast); - */ - inter = board.create('intersection', [board.objects[gxtEl.first], board.objects[gxtEl.last], 0], gxtEl.outFirst); - inter = board.create('intersection', [board.objects[gxtEl.first], board.objects[gxtEl.last], 1], gxtEl.outLast); - } - } - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case "composition": - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl.defEl = []; - numberDefEls = 0; - xmlNode = Data.getElementsByTagName('data')[0].getElementsByTagName('input'); - for (i = 0; i < xmlNode.length; i++) { - gxtEl.defEl[i] = xmlNode[i].firstChild.data; - numberDefEls = i + 1; - } - - // every composition produces at least one element and the data for this element is stored - // in gxtEl.out. if additional elements are created their data is read in the according case. - xmlNode = Data.getElementsByTagName('output')[0]; - gxtEl.out = {}; - gxtEl.out = gxtReader.colorProperties(gxtEl.out, xmlNode); - gxtEl.out = gxtReader.visualProperties(gxtEl.out, xmlNode); - gxtEl.out = gxtReader.firstLevelProperties(gxtEl.out, xmlNode); - gxtEl.out = gxtReader.transformProperties(gxtEl.out); - - gxtEl.defEl[0] = gxtReader.changeOriginIds(board, gxtEl.defEl[0]); - gxtEl.defEl[1] = gxtReader.changeOriginIds(board, gxtEl.defEl[1]); - gxtEl.defEl[2] = gxtReader.changeOriginIds(board, gxtEl.defEl[2]); - - // if (board.isSuspendedUpdate) { board.unsuspendUpdate().suspendUpdate(); } - switch (gxtEl.type) { - // ARROW_PARALLEL - case "210070": - gxtEl.out.fixed = gxtReader.gEBTN(xmlNode, 'fix'); - - xmlNode = Data.getElementsByTagName('output')[1]; - gxtEl.outPoint = {}; - gxtEl.outPoint = gxtReader.defProperties(gxtEl.outPoint, xmlNode); - gxtEl.outPoint = gxtReader.colorProperties(gxtEl.outPoint, xmlNode); - gxtEl.outPoint = gxtReader.visualProperties(gxtEl.outPoint, xmlNode); - gxtEl.outPoint = gxtReader.firstLevelProperties(gxtEl.outPoint, xmlNode); - gxtEl.outPoint = gxtReader.transformProperties(gxtEl.outPoint); - gxtEl.out.point = gxtEl.outPoint; - - board.create('arrowparallel', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); - break; - - // BISECTOR - case "210080": - gxtEl.out.straightFirst = false; - board.create('bisector', [gxtEl.defEl[0], gxtEl.defEl[1], gxtEl.defEl[2]], gxtEl.out); - break; - - // CIRCUMCIRCLE - case "210090": - xmlNode = Data.getElementsByTagName('output')[1]; - gxtEl.outCircle = {}; - gxtEl.outCircle = gxtReader.defProperties(gxtEl.outCircle, xmlNode); - gxtEl.outCircle = gxtReader.colorProperties(gxtEl.outCircle, xmlNode); - gxtEl.outCircle = gxtReader.visualProperties(gxtEl.outCircle, xmlNode); - gxtEl.outCircle = gxtReader.firstLevelProperties(gxtEl.outCircle, xmlNode); - gxtEl.outCircle = gxtReader.transformProperties(gxtEl.outCircle); - gxtEl.outCircle.point = gxtEl.out; - board.create('circumcircle', [gxtEl.defEl[0], gxtEl.defEl[1], gxtEl.defEl[2]], gxtEl.outCircle); - break; - - // CIRCUMCIRCLE_CENTER - case "210100": - board.create('circumcenter', [gxtEl.defEl[0], gxtEl.defEl[1], gxtEl.defEl[2]], gxtEl.out); - break; - - // MIDPOINT - case "210110": - board.create('midpoint', gxtEl.defEl.slice(0, numberDefEls), gxtEl.out); - break; - - // MIRRORLINE - case "210120": - board.create('reflection', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); - break; - - // MIRROR_POINT - case "210125": - board.create('mirrorpoint', [gxtEl.defEl[0], gxtEl.defEl[1]], gxtEl.out); - break; - - // NORMAL - case "210130": - //board.create('normal', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); - board.create('perpendicularsegment', [gxtEl.defEl[0], gxtEl.defEl[1]], gxtEl.out); - break; - - // PARALLEL - case "210140": - p = board.create('parallelpoint', [gxtEl.defEl[1], gxtEl.defEl[0]], - {withLabel:false, visible:false, name:'', fixed:true}); - - // GEONExT uses its own parallel construction to make the order - // of intersection points compatible. - // el = board.create('parallel', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); - el = board.create('line', [gxtEl.defEl[0], p], gxtEl.out); - el.parallelpoint = p; - break; - - // PARALLELOGRAM_POINT - case "210150": - board.create('parallelpoint', gxtEl.defEl.slice(0, numberDefEls), gxtEl.out); - break; - - // PERPENDICULAR - case "210160": - // output[0] was already read and is stored in gxtEl.out - gxtEl.out.fixed = gxtReader.gEBTN(xmlNode, 'fix'); - - xmlNode = Data.getElementsByTagName('output')[1]; - gxtEl.outLine = {}; - gxtEl.outLine = gxtReader.defProperties(gxtEl.outLine, xmlNode); - gxtEl.outLine = gxtReader.colorProperties(gxtEl.outLine, xmlNode); - gxtEl.outLine = gxtReader.visualProperties(gxtEl.outLine, xmlNode); - gxtEl.outLine = gxtReader.firstLevelProperties(gxtEl.outLine, xmlNode); - gxtEl.outLine = gxtReader.readNodes(gxtEl.outLine, xmlNode, 'straight', 'straight'); - gxtEl.outLine = gxtReader.transformProperties(gxtEl.outLine); - gxtEl.outLine.point = gxtEl.out; - - board.create('perpendicularsegment', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.outLine); - break; - - // PERPENDICULAR_POINT - case "210170": - board.create('perpendicularpoint', [gxtEl.defEl[1], gxtEl.defEl[0]], gxtEl.out); - break; - - // ROTATION - case "210180": - throw new Error('JSXGraph: Element ROTATION not yet implemented.'); - break; - - // SECTOR - case "210190": - // sectors usually provide more than one output element but JSXGraph is not fully compatible - // to GEONExT sector elements. GEONExT sectors consist of two lines, a point, and a sector, - // JSXGraph uses a curve to display the sector incl. the borders, and - // a point and two lines. - // Gliders on sectors also run through the borders. - gxtEl.out = gxtReader.defProperties(gxtEl.out, xmlNode); - gxtEl.out.firstArrow = JXG.str2Bool(gxtReader.gEBTN(xmlNode, 'firstarrow')); - gxtEl.out.lastArrow = JXG.str2Bool(gxtReader.gEBTN(xmlNode, 'lastarrow')); - - // el = board.create('sector', gxtEl.defEl, gxtEl.out); - for (i=0; i<4;i++) { - xmlNode = Data.getElementsByTagName('output')[i]; - gxtEl.out = gxtReader.defProperties(gxtEl.out, xmlNode); - gxtEl.out = gxtReader.colorProperties(gxtEl.out, xmlNode); - gxtEl.out = gxtReader.visualProperties(gxtEl.out, xmlNode); - gxtEl.out = gxtReader.firstLevelProperties(gxtEl.out, xmlNode); - gxtEl.out = gxtReader.transformProperties(gxtEl.out); - - if (i==0) { - el = board.create('sector', gxtEl.defEl, gxtEl.out); - } else if (i==1) { - p = board.create('point', [ - function(){ - var p1 = JXG.getRef(board,gxtEl.defEl[1]), p2 = JXG.getRef(board,gxtEl.defEl[2]); - return p1.X() + (p2.X()-p1.X())*el.Radius/p1.Dist(p2); - }, - function(){ - var p1 = JXG.getRef(board,gxtEl.defEl[1]), p2 = JXG.getRef(board,gxtEl.defEl[2]); - return p1.Y() + (p2.Y()-p1.Y())*el.Radius/p1.Dist(p2); - }], gxtEl.out); - //p = JXG.getReference(board,gxtEl.defEl[2]); - } else if (i==2) { - el = board.create('segment', [gxtEl.defEl[0], gxtEl.defEl[1]], gxtEl.out); - } else if (i==3) { - el = board.create('segment', [gxtEl.defEl[1], p], gxtEl.out); - } - } - break; - default: - throw new Error("JSXGraph: GEONExT-Element " + gxtEl.type + ' not implemented.'); - break; - } - - // if (board.isSuspendedUpdate) { board.unsuspendUpdate().suspendUpdate(); } - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case "polygon": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - var dataVertex = []; - // In Geonext file format the first vertex is equal to the last vertex: - for (i = 0; i < Data.getElementsByTagName('data')[0].getElementsByTagName('vertex').length-1; i++) { - dataVertex[i] = Data.getElementsByTagName('data')[0].getElementsByTagName('vertex')[i].firstChild.data; - dataVertex[i] = gxtReader.changeOriginIds(board, dataVertex[i]); - } - gxtEl.border = []; - gxtEl.borders = { - ids: [] - }; - for (i = 0; i < Data.getElementsByTagName('border').length; i++) { - gxtEl.border[i] = {}; - xmlNode = Data.getElementsByTagName('border')[i]; - gxtEl.border[i].id = xmlNode.getElementsByTagName('id')[0].firstChild.data; - gxtEl.borders.ids.push(gxtEl.border[i].id); - gxtEl.border[i].name = xmlNode.getElementsByTagName('name')[0].firstChild.data; - gxtEl.border[i].straightFirst = JXG.str2Bool(xmlNode.getElementsByTagName('straight')[0].getElementsByTagName('first')[0].firstChild.data); - gxtEl.border[i].straightLast = JXG.str2Bool(xmlNode.getElementsByTagName('straight')[0].getElementsByTagName('last')[0].firstChild.data); - gxtEl.border[i].strokeWidth = xmlNode.getElementsByTagName('strokewidth')[0].firstChild.data; - gxtEl.border[i].dash = JXG.str2Bool(xmlNode.getElementsByTagName('dash')[0].firstChild.data); - gxtEl.border[i].visible = JXG.str2Bool(xmlNode.getElementsByTagName('visible')[0].firstChild.data); - gxtEl.border[i].draft = JXG.str2Bool(xmlNode.getElementsByTagName('draft')[0].firstChild.data); - gxtEl.border[i].trace = JXG.str2Bool(xmlNode.getElementsByTagName('trace')[0].firstChild.data); - - xmlNode = Data.getElementsByTagName('border')[i].getElementsByTagName('color')[0]; - rgbo = JXG.rgba2rgbo(xmlNode.getElementsByTagName('stroke')[0].firstChild.data); - gxtEl.border[i].strokeColor = rgbo[0]; - gxtEl.border[i].strokeOpacity = rgbo[1]; - - rgbo = JXG.rgba2rgbo(xmlNode.getElementsByTagName('lighting')[0].firstChild.data); - gxtEl.border[i].highlightStrokeColor = rgbo[0]; - gxtEl.border[i].highlightStrokeOpacity = rgbo[1]; - - rgbo = JXG.rgba2rgbo(xmlNode.getElementsByTagName('fill')[0].firstChild.data); - gxtEl.border[i].fillColor = rgbo[0]; - gxtEl.border[i].fillOpacity = rgbo[1]; - - gxtEl.border[i].highlightFillColor = gxtEl.border[i].fillColor; - gxtEl.border[i].highlightFillOpacity = gxtEl.border[i].fillOpacity; - - gxtEl.border[i].labelColor = xmlNode.getElementsByTagName('label')[0].firstChild.data; - gxtEl.border[i].colorDraft = xmlNode.getElementsByTagName('draft')[0].firstChild.data; - } - gxtEl = gxtReader.transformProperties(gxtEl); - p = board.create('polygon', dataVertex, gxtEl); - - // to emulate the geonext behaviour on invisible polygons - // A.W.: Why do we need this? -/* - if (!gxtEl.visible) { - p.setProperty({ - fillColor: 'none', - highlightFillColor: 'none' - }); - } -*/ - for (i = 0; i < p.borders.length; i++) { - p.borders[i].setProperty(gxtEl.border[i]); - } - - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case "graph": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl.funct = Data.getElementsByTagName('data')[0].getElementsByTagName('function')[0].firstChild.data; - if (false) { - gxtEl.funct = JXG.GeonextParser.gxt2jc(gxtEl.funct, board); // Handle weird element names - } else { // Workaround until the jessiecode compiler is 100% compatible - gxtEl.funct = JXG.GeonextParser.geonext2JS(gxtEl.funct, board); - gxtEl.funct = new Function('x', 'return ' + gxtEl.funct + ';'); - } - - c = board.create('curve', ['x', gxtEl.funct], { - id: gxtEl.id, - name: gxtEl.name, - strokeColor: gxtEl.strokeColor, - strokeWidth: gxtEl.strokeWidth, - fillColor: 'none', - highlightFillColor: 'none', - highlightStrokeColor: gxtEl.highlightStrokeColor, - visible: JXG.str2Bool(gxtEl.visible) - }); - - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case "arrow": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - gxtEl = gxtReader.readNodes(gxtEl, Data, 'straight', 'straight'); - - gxtEl = gxtReader.transformProperties(gxtEl); - gxtEl.first = gxtReader.changeOriginIds(board, gxtEl.first); - gxtEl.last = gxtReader.changeOriginIds(board, gxtEl.last); - - l = board.create('arrow', [gxtEl.first, gxtEl.last], gxtEl); - - gxtReader.printDebugMessage('debug', l, Data.nodeName, 'OK'); - break; - case "arc": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - - gxtEl.firstArrow = JXG.str2Bool(Data.getElementsByTagName('lastarrow')[0].firstChild.data); // It seems that JSXGraph and GEONExT - gxtEl.lastArrow = JXG.str2Bool(Data.getElementsByTagName('firstarrow')[0].firstChild.data); // use opposite directions. - - gxtEl = gxtReader.transformProperties(gxtEl); - - gxtEl.center = gxtReader.changeOriginIds(board, gxtEl.midpoint); - gxtEl.angle = gxtReader.changeOriginIds(board, gxtEl.angle); - gxtEl.radius = gxtReader.changeOriginIds(board, gxtEl.radius); - - c = board.create('arc', [gxtEl.center, gxtEl.radius, gxtEl.angle], gxtEl); - - gxtReader.printDebugMessage('debug', c, Data.nodeName, 'OK'); - break; - case "angle": - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - gxtEl = gxtReader.transformProperties(gxtEl); - - tmp = gxtEl.name; - try { - gxtEl.name = Data.getElementsByTagName('text')[0].firstChild.data; - } catch (e) { - gxtEl.name = ''; - } - c = board.create('angle', [gxtEl.first, gxtEl.middle, gxtEl.last], gxtEl); - c.setProperty({name:tmp}); - - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case "text": - if (gxtEl.id.match(/oldVersion/)) { - break; - } - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - - gxtEl = gxtReader.readNodes(gxtEl, Data, 'data'); - gxtEl.mpStr = gxtReader.subtreeToString(Data.getElementsByTagName('data')[0].getElementsByTagName('mp')[0]); - gxtEl.mpStr = gxtEl.mpStr.replace(/<\/?mp>/g, ''); - gxtEl.fixed = false; - try { - if (Data.getElementsByTagName('data')[0].getElementsByTagName('parent')[0].firstChild) { - gxtEl.parent = Data.getElementsByTagName('data')[0].getElementsByTagName('parent')[0].firstChild.data; - gxtEl.fixed = true; - } - } catch (e) { - } - - gxtEl.condition = Data.getElementsByTagName('condition')[0].firstChild.data; - gxtEl.content = Data.getElementsByTagName('content')[0].firstChild.data; - gxtEl.fix = Data.getElementsByTagName('fix')[0].firstChild.data; - // not used: gxtEl.digits = Data.getElementsByTagName('cs')[0].firstChild.data; - gxtEl.autodigits = Data.getElementsByTagName('digits')[0].firstChild.data; - gxtEl.parent = gxtReader.changeOriginIds(board, gxtEl.parent); - - c = board.create('text', [gxtEl.x, gxtEl.y, gxtEl.mpStr], { - anchor: gxtEl.parent, - id: gxtEl.id, - name: gxtEl.name, - digits: gxtEl.autodigits, - isLabel: false, - strokeColor: gxtEl.colorLabel, - fixed: gxtEl.fixed, - visible: JXG.str2Bool(gxtEl.visible) - }); - break; - case 'parametercurve': - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.visualProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl = gxtReader.transformProperties(gxtEl); - gxtEl.functionx = Data.getElementsByTagName('functionx')[0].firstChild.data; - gxtEl.functiony = Data.getElementsByTagName('functiony')[0].firstChild.data; - gxtEl.min = Data.getElementsByTagName('min')[0].firstChild.data; - gxtEl.max = Data.getElementsByTagName('max')[0].firstChild.data; - /* - gxtEl.functionx = JXG.GeonextParser.gxt2jc(gxtEl.functionx, board); - gxtEl.functiony = JXG.GeonextParser.gxt2jc(gxtEl.functiony, board); - gxtEl.min = JXG.GeonextParser.gxt2jc(gxtEl.min, board); - gxtEl.max = JXG.GeonextParser.gxt2jc(gxtEl.max, board); - */ - gxtEl.fillColor = 'none'; - gxtEl.highlightFillColor = 'none'; - - board.create('curve', - [ new Function('t', 'return ' + JXG.GeonextParser.geonext2JS(gxtEl.functionx, board) + ';' ), - new Function('t', 'return ' + JXG.GeonextParser.geonext2JS(gxtEl.functiony, board) + ';' ), - new Function('return ' + JXG.GeonextParser.geonext2JS(gxtEl.min, board) + ';' ), - new Function('return ' + JXG.GeonextParser.geonext2JS(gxtEl.max, board) + ';' ) - ], gxtEl); - /* - c = new JXG.Curve(board, [ - 't',gxtEl.functionx,gxtEl.functiony,gxtEl.min,gxtEl.max - ], gxtEl.id, gxtEl.name); - c.setProperty('strokeColor:' + gxtEl.colorStroke, 'strokeWidth:' + gxtEl.strokewidth, 'fillColor:none', - 'highlightStrokeColor:' + gxtEl.highlightStrokeColor); - */ - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case 'tracecurve': - gxtEl.tracepoint = Data.getElementsByTagName('tracepoint')[0].firstChild.data; - gxtEl.traceslider = Data.getElementsByTagName('traceslider')[0].firstChild.data; - board.create('tracecurve', [gxtEl.traceslider, gxtEl.tracepoint], gxtEl); - // JXG.getRef(board, gxtEl.tracepoint).setProperty({trace:true}); - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - case 'group': - gxtEl = gxtReader.colorProperties(gxtEl, Data); - gxtEl = gxtReader.firstLevelProperties(gxtEl, Data); - gxtEl.members = [ - ]; - for (i = 0; i < Data.getElementsByTagName('data')[0].getElementsByTagName('member').length; i++) { - gxtEl.members[i] = Data.getElementsByTagName('data')[0].getElementsByTagName('member')[i].firstChild.data; - gxtEl.members[i] = gxtReader.changeOriginIds(board, gxtEl.members[i]); - } - c = new JXG.Group(board, gxtEl.id, gxtEl.name, gxtEl.members); - gxtReader.printDebugMessage('debug', gxtEl, Data.nodeName, 'OK'); - break; - default: - JXG.debug("* Err: " + Data.nodeName + " not yet implemented
\n"); - } - delete(gxtEl); - })(s); - } - board.addConditions(conditions); - }, - - decodeString: function(str) { - var unz; - if (str.indexOf("")<0){ - unz = (new JXG.Util.Unzip(JXG.Util.Base64.decodeAsArray(str))).unzip(); // war Gunzip ME - if (unz=="") - return str; - else - return unz; - } else { - return str; - } - }, - - prepareString: function(fileStr){ - try { - if (fileStr.indexOf('GEONEXT')<0) { - fileStr = (this.decodeString(fileStr))[0][0]; // Base64 decoding - } - // Hacks to enable not well formed XML. Will be redone in Algebra.geonext2JS and Board.addConditions - fileStr = this.fixXML(fileStr); - } catch(e) { - fileStr = ''; - } - return fileStr; - }, - - fixXML: function(str) { - var arr = ["active", "angle", "animate", "animated", "arc", "area", "arrow", "author", "autodigits", "axis", "back", "background", "board", "border", "bottom", "buttonsize", "cas", "circle", "color", "comment", "composition", "condition", "conditions", "content", "continuous", "control", "coord", "coordinates", "cross", "cs", "dash", "data", "description", "digits", "direction", "draft", "editable", "elements", "event", "file", "fill", "first", "firstarrow", "fix", "fontsize", "free", "full", "function", "functionx", "functiony", "GEONEXT", "graph", "grid", "group", "height", "id", "image", "info", "information", "input", "intersection", "item", "jsf", "label", "last", "lastarrow", "left", "lefttoolbar", "lighting", "line", "loop", "max", "maximized", "member", "middle", "midpoint", "min", "modifier", "modus", "mp", "mpx", "multi", "name", "onpolygon", "order", "origin", "output", "overline", "parametercurve", "parent", "point", "pointsnap", "polygon", "position", "radius", "radiusnum", "radiusvalue", "right", "section", "selectedlefttoolbar", "showconstruction", "showcoord", "showinfo", "showunit", "showx", "showy", "size", "slider", "snap", "speed", "src", "start", "stop", "straight", "stroke", "strokewidth", "style", "term", "text", "top", "trace", "tracecurve", "tracepoint", "traceslider", "type", "unit", "value", "VERSION", "vertex", "viewport", "visible", "width", "wot", "x", "xooy", "xval", "y", "yval", "zoom"], - list = arr.join('|'), - regex = '\<(/?('+list+'))\>', - expr = new RegExp(regex,'g'); - - // First, we convert all < to < and > to > - str = JXG.escapeHTML(str); - // Second, we convert all GEONExT tags of the form <tag> back to - str = str.replace(expr,'<$1>'); - - str = str.replace(/(.*)(.*<\/content>)/g,'$1<arc>$2'); - str = str.replace(/(.*)(.*<\/mpx>)/g,'$1<arc>$2'); - str = str.replace(/(.*)(.*<\/mpx>)/g,'$1<arc>$2'); - return str; - } - -}; // end: GeonextReader diff --git a/ajax/libs/jsxgraph/latest/IntergeoReader.js b/ajax/libs/jsxgraph/latest/IntergeoReader.js deleted file mode 100644 index 4a5aacaba..000000000 --- a/ajax/libs/jsxgraph/latest/IntergeoReader.js +++ /dev/null @@ -1,967 +0,0 @@ -/* - Copyright 2008,2009 - Matthias Ehmann, - Michael Gerhaeuser, - Carsten Miller, - Bianca Valentin, - Alfred Wassermann, - Peter Wilfahrt - - This file is part of JSXGraph. - - JSXGraph is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - JSXGraph is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with JSXGraph. If not, see . - -*/ - -/* Compatibility for <= 0.75.4 */ -/* -JXG.getReference = function(board, object) { - return JXG.GetReferenceFromParameter(board, object); -}; -*/ - -JXG.IntergeoReader = new function() { - this.board = null; - /** - * this.objects holds all objects from the XML file. - * Every object hets an attribute "exists" - */ - this.objects = {}; - - this.readIntergeo = function(tree,board) { - this.board = board; - this.board.origin = {}; - this.board.origin.usrCoords = [1, 0, 0]; - this.board.origin.scrCoords = [1, 400, 300]; - this.board.unitX = 30; - this.board.unitY = 30; - - this.readElements(tree.getElementsByTagName("elements")); - this.readConstraints(tree.getElementsByTagName("constraints")); - this.cleanUp(); - this.board.fullUpdate(); - this.readDisplay(tree.getElementsByTagName("display")); - this.board.fullUpdate(); - }; - - /** - * Element part - */ - this.readElements = function(tree) { - var s; - for (var s=0;s1) { return; } // not an element node - if (node.nodeName=='point') { - JXG.IntergeoReader.storePoint(node); //addPoint(node); - } - else if (node.nodeName=='line' - || node.nodeName=='line_segment' - || node.nodeName=='ray' - || node.nodeName=='vector' - ) { - JXG.IntergeoReader.storeLine(node); - } - else if (node.nodeName=='circle') { - JXG.IntergeoReader.storeConic(node); - } - else if (node.nodeName=='conic') { - JXG.IntergeoReader.storeConic(node); - } - else if (node.nodeName=='polygon') { - // ignore, see this.addPolygonByVertices - } - else { - JXG.debug('Not implemented: '+node.nodeName + ' ' + node.getAttribute('id')); - } - })(s); - }; - - /** - * Points are created instantly via create - */ - this.addPointOld = function(node) { - var i = 0, - j = 0, - l = 0, - el, - p = node.childNodes[i], - c = [], - attributes = {strokeColor:'red', fillColor:'red', withLabel:true}, - parents = []; - - while (p.nodeType>1) { // skip non element nodes - i++; - p = node.childNodes[i]; - } - - attributes['name'] = node.getAttribute('id'); - - if (p.nodeName == 'homogeneous_coordinates') { - for (j=0;j... - } else if (p.childNodes[j].nodeName=='complex') { - for (l=0;l - return; - } - } - } - for (j=0;j - return; - } - } else if (p.nodeName == 'euclidean_coordinates') { - for (j=0;j... - } - } - for (j=0;j... - } - } - for (j=0;j1) { // skip non element nodes - i++; - p = node.childNodes[i]; - } - - if (p.nodeName == 'homogeneous_coordinates') { - for (j=0;j... - } else if (p.childNodes[j].nodeName=='complex') { - for (l=0;l - return; - } - } - } - for (j=0;j - return; - } - } else if (p.nodeName == 'euclidean_coordinates' || p.nodeName == 'euclidian_coordinates') { // the latter one is a workaround for faulty i2g construction exported by DynaGeo - for (j=0;j... - } - } - for (j=0;j... - } - } - for (j=0;j1) { // skip non element nodes - i++; - p = node.childNodes[i]; - } - if (p.nodeName == 'homogeneous_coordinates') { - c = []; - for (j=0;j... - } else { - //$('debug').innerHTML += 'Not: '+ p.childNodes[j].nodeName + '
'; // - } - } - } - this.objects[node.getAttribute('id')].coords = c; - this.objects[node.getAttribute('id')].id = node.getAttribute('id'); - this.objects[node.getAttribute('id')].exists = false; - this.objects[node.getAttribute('id')].i2geoType = 'line'; - } - //this.addLine(node.getAttribute('id')); - }; - - /** - * Circle / conic data is stored in an array - * for further access during the reading of constraints. - * There, id and name are needed. - * Concretely, the circle (x-1)^2 + (y-3)^2 = 4 has matrix - * ( 1 0 -1 ) - * ( 0 1 -3 ) - * ( -1 -3 6 ) - * - * In general - * Ax^2+Bxy+Cy^2+Dx+Ey+F = 0 - * is stored as - * ( A B/2 D/2 ) - * ( B/2 C E/2 ) - * ( D/2 E/2 F ) - * - * Mx = D/A - * My = E/C - * r = A*Mx^2+B*My^2-F - **/ - this.storeConic = function(node) { - var i, j, p, c; - - this.objects[node.getAttribute('id')] = {'id':node.getAttribute('id'), 'coords':null}; - i = 0; - p = node.childNodes[i]; - while (p.nodeType>1) { // skip non element nodes - i++; - p = node.childNodes[i]; - } - if (p.nodeName == 'matrix') { - c = []; - for (j=0;j... - } else { - //$('debug').innerHTML += 'Not: '+ p.childNodes[j].nodeName + '
'; // - } - } - } - this.objects[node.getAttribute('id')].coords = c; - this.objects[node.getAttribute('id')].id = node.getAttribute('id'); - this.objects[node.getAttribute('id')].exists = false; - this.objects[node.getAttribute('id')].i2geoType = 'conic'; - } - }; - - /** - * Constraint part - */ - this.readConstraints = function(tree) { - var s, param; - - // Set the default colors of dependent elements - this.board.options.point.strokeColor = 'blue'; - this.board.options.point.fillColor = 'blue'; - - for (s=0;s1) { return; } // not an element node - if (node.nodeName=='line_through_two_points') { - JXG.IntergeoReader.addLineThroughTwoPoints(node, false); - } - else if (node.nodeName=='ray_from_point_through_point') { - JXG.IntergeoReader.addLineThroughTwoPoints(node, true); - } - else if (node.nodeName=='line_through_point') { - JXG.IntergeoReader.addLineThroughPoint(node); - } - else if (node.nodeName=='line_parallel_to_line_through_point') { - JXG.IntergeoReader.addLineParallelToLineThroughPoint(node, false); - } - else if (node.nodeName=='ray_from_point_and_vector') { - JXG.IntergeoReader.addLineParallelToLineThroughPoint(node, true); - } - else if (node.nodeName=='line_perpendicular_to_line_through_point') { - JXG.IntergeoReader.addLinePerpendicularToLineThroughPoint(node); - } - else if (node.nodeName=='line_segment_by_points') { - JXG.IntergeoReader.addLineSegmentByTwoPoints(node); - } - else if (node.nodeName=='vector_from_point_to_point') { - JXG.IntergeoReader.addVectorFromPointToPoint(node); - } - else if (node.nodeName=='endpoints_of_line_segment') { - JXG.IntergeoReader.addEndpointsOfLineSegment(node); - } - else if (node.nodeName=='free_point') { - // do nothing - } - else if (node.nodeName=='free_line') { - JXG.IntergeoReader.addFreeLine(node); - } - else if (node.nodeName=='point_on_line') { - JXG.IntergeoReader.addPointOnLine(node); - } - else if (node.nodeName=='point_on_line_segment') { - JXG.IntergeoReader.addPointOnLine(node); - } - else if (node.nodeName=='point_on_circle') { - JXG.IntergeoReader.addPointOnCircle(node); - } - else if (node.nodeName=='angular_bisector_of_three_points') { - JXG.IntergeoReader.addAngularBisectorOfThreePoints(node, false); - } - else if (node.nodeName=='angular_bisectors_of_two_lines') { - JXG.IntergeoReader.addAngularBisectorsOfTwoLines(node, false); - } - else if (node.nodeName=='line_angular_bisector_of_three_points') { - JXG.IntergeoReader.addAngularBisectorOfThreePoints(node, true); - } - else if (node.nodeName=='line_angular_bisectors_of_two_lines') { - JXG.IntergeoReader.addAngularBisectorsOfTwoLines(node, true); - } - else if (node.nodeName=='midpoint_of_two_points') { - JXG.IntergeoReader.addMidpointOfTwoPoints(node); - } - else if (node.nodeName=='midpoint') { - JXG.IntergeoReader.addMidpointOfTwoPoints(node); - } - else if (node.nodeName=='midpoint_of_line_segment' || node.nodeName=='midpoint_line_segment') { - JXG.IntergeoReader.addMidpointOfLineSegment(node); - } - else if (node.nodeName=='point_intersection_of_two_lines') { - JXG.IntergeoReader.addPointIntersectionOfTwoLines(node); - } - else if (node.nodeName=='locus_defined_by_point') { - JXG.IntergeoReader.addLocusDefinedByPoint(node); - } - else if (node.nodeName=='locus_defined_by_point_on_line') { - JXG.IntergeoReader.addLocusDefinedByPointOnLine(node); - } - else if (node.nodeName=='locus_defined_by_point_on_line_segment') { - JXG.IntergeoReader.addLocusDefinedByPointOnLine(node); - } - else if (node.nodeName=='locus_defined_by_line_through_point') { - JXG.IntergeoReader.addLocusDefinedByLineThroughPoint(node); - } - else if (node.nodeName=='locus_defined_by_point_on_circle') { - JXG.IntergeoReader.addLocusDefinedByPointOnCircle(node); - } - else if (node.nodeName=='circle_by_three_points') { - JXG.IntergeoReader.addCircleByThreePoints(node); - } - else if (node.nodeName=='circle_by_center_and_point') { - JXG.IntergeoReader.addCircleByCenterAndPoint(node); - } - else if (node.nodeName=='center_of_circle') { - JXG.IntergeoReader.addCenterOfCircle(node); - } - else if (node.nodeName=='intersection_points_of_two_circles') { - JXG.IntergeoReader.addIntersectionPointsOfTwoCircles(node); - } - else if (node.nodeName=='intersection_points_of_circle_and_line') { - JXG.IntergeoReader.addIntersectionPointsOfCircleAndLine(node); - } - else if (node.nodeName=='other_intersection_point_of_two_circles') { - JXG.IntergeoReader.addOtherIntersectionPointOfTwoCircles(node); - } - else if (node.nodeName=='other_intersection_point_of_circle_and_line') { - JXG.IntergeoReader.addOtherIntersectionPointOfCircleAndLine(node); - } - else if (node.nodeName=='circle_tangent_lines_by_point') { - JXG.IntergeoReader.addCircleTangentLinesByPoint(node); - } - else if (node.nodeName=='polygon_by_vertices') { - JXG.IntergeoReader.addPolygonByVertices(node); - } - else { - param = JXG.IntergeoReader.readParams(node); - JXG.debug('readConstraints: not implemented: ' + node.nodeName + ': ' + param[0]); - } - })(s); - }; - - this.setAttributes = function(o) { - o.setProperty({strokecolor:this.board.options.point.strokeColor,fillColor:this.board.options.point.fillColor}); - }; - - this.readParams = function(node) { - var param = [], j; - for (j=0;j1) { return; } // not an element node - if (node.nodeName=='background-color') { - this.board.containerObj.style.backgroundColor = node.firstChild.data; - } - else if (node.nodeName=='style') { - el = JXG.getReference(this.board,node.getAttribute('ref')); // get the element - var param = [], j; - for (j=0;j. -*/ - var JXG={};(function(){var e,f;JXG.countDrawings=0;JXG.countTime=0;JXG.require=function(g){};JXG.rendererFiles=[];JXG.rendererFiles.svg="SVGRenderer";JXG.rendererFiles.vml="VMLRenderer";JXG.rendererFiles.canvas="CanvasRenderer";JXG.baseFiles=null;JXG.requirePath="";for(e=0;e-1},isWebkitAndroid:function(){return this.isAndroid()&&navigator.userAgent.search(" AppleWebKit/")>-1},isApple:function(){return(navigator.userAgent.search(/iPad/)!=-1||navigator.userAgent.search(/iPhone/)!=-1)},isWebkitApple:function(){return this.isApple()&&(navigator.userAgent.search(/Mobile *.*Safari/)>-1)},clearVisPropOld:function(e){e.visPropOld={strokecolor:"",strokeopacity:"",strokewidth:"",fillcolor:"",fillopacity:"",shadow:false,firstarrow:false,lastarrow:false}},ieVersion:(function(){var g,e=3,h=document.createElement("div"),f=h.getElementsByTagName("i");while(h.innerHTML="",f[0]){}return e>4?e:g}()),getReference:function(f,e){if(typeof(e)=="string"){if(JXG.exists(f.objects[e])){e=f.objects[e]}else{if(JXG.exists(f.elementsByName[e])){e=f.elementsByName[e]}else{if(JXG.exists(f.groups[e])){e=f.groups[e]}}}}return e},getRef:JXG.shortcut(JXG,"getReference"),isId:function(f,e){return typeof(e)=="string"&&!!f.objects[e]},isName:function(f,e){return typeof(e)=="string"&&!!f.elementsByName[e]},isGroup:function(f,e){return typeof(e)=="string"&&!!f.groups[e]},isString:function(e){return typeof e==="string"},isNumber:function(e){return typeof e==="number"},isFunction:function(e){return typeof e==="function"},isArray:function(e){return e!==null&&typeof e==="object"&&"splice" in e&&"join" in e},isPoint:function(e){if(typeof e=="object"){return(e.elementClass==JXG.OBJECT_CLASS_POINT)}return false},exists:(function(e){return function(f){return !(f===e||f===null)}})(),def:function(e,f){if(JXG.exists(e)){return e}else{return f}},str2Bool:function(e){if(!JXG.exists(e)){return true}if(typeof e=="boolean"){return e}return(e.toLowerCase()=="true")},_board:function(f,e){return JXG.JSXGraph.initBoard(f,e)},createEvalFunction:function(g,k,l){var h=[],e,j;for(e=0;e=o[h].length;f++){e=0;while(e0){JXG.removeEvent(g,f,e["x_internal"+f][0].origin,e)}}},bind:function(f,e){return function(){return f.apply(e,arguments)}},removeElementFromArray:function(e,g){var f;for(f=0;f=9){e=g.currentStyle[f]}else{if(g.style){f=f.replace(/-([a-z]|[0-9])/ig,function(h,i){return(i+"").toUpperCase()});e=g.style[f]}}}return e},keys:function(e,f){var g=[],h;for(h in e){if(f){if(e.hasOwnProperty(h)){g.push(h)}}else{g.push(h)}}return g},indexOf:function(g,f){var e;if(Array.indexOf){return g.indexOf(f)}for(e=0;e/g,">")},unescapeHTML:function(e){return e.replace(/<\/?[^>]+>/gi,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")},clone:function(f){var e={};e.prototype=f;return e},cloneAndCopy:function(h,g){var e=function(){},f;e.prototype=h;for(f in g){e[f]=g[f]}return e},deepCopy:function(l,k,h){var n,f,m,e,g;h=h||false;if(typeof l!=="object"||l==null){return l}if(this.isArray(l)){n=[];for(f=0;f0&&(+new Date()-j<300));if(e.length>0){setTimeout(arguments.callee,1)}else{i(f)}},1)},trimNumber:function(e){e=e.replace(/^0+/,"");e=e.replace(/0+$/,"");if(e[e.length-1]=="."||e[e.length-1]==","){e=e.slice(0,-1)}if(e[0]=="."||e[0]==","){e="0"+e}return e},trim:function(e){e=e.replace(/^\s+/,"");e=e.replace(/\s+$/,"");return e},evaluate:function(e){if(JXG.isFunction(e)){return e()}else{return e}},eliminateDuplicates:function(g){var h,f=g.length,e=[],j={};for(h=0;h"}}}},debugWST:function(f){var g;JXG.debug(f);if(window.console&&console.log){g=new Error();if(g&&g.stack){console.log("stacktrace");console.log(g.stack.split("\n").slice(1).join("\n"))}}}});JXG.addEvent(window,"load",function(){var k=document.getElementsByTagName("script"),o,m,l,f,n,g,q,p,h,e;for(m=0;m0?l[0].length:0,w=l.length,v=this.matrix(q,p),u,t,z,r;for(u=0;u0?r[0].length:0;o=this.matrix(q,k);for(p=0;pC){C=e.abs(o[v][u]);l=v}}if(C<=f.Math.eps){return false}if(l>u){for(t=0;to||l<0){return NaN}l=e.round(l);o=e.round(o);if(l===0||l===o){return 1}j=1;for(m=0;m0){return e.exp(i*e.log(e.abs(j)))}else{return NaN}}},squampow:function(k,j){var i;if(e.floor(j)===j){i=1;if(j<0){k=1/k;j*=-1}while(j!=0){if(j&1){i*=k}j>>=1;k*=k}return i}else{return this.pow(k,j)}},normalize:function(k){var i=2*k[3],l=k[4]/(i),m,j;k[5]=l;k[6]=-k[1]/i;k[7]=-k[2]/i;if(l===Infinity||isNaN(l)){m=e.sqrt(k[1]*k[1]+k[2]*k[2]);k[0]/=m;k[1]/=m;k[2]/=m;k[3]=0;k[4]=1}else{if(e.abs(l)>=1){k[0]=(k[6]*k[6]+k[7]*k[7]-l*l)/(2*l);k[1]=-k[6]/l;k[2]=-k[7]/l;k[3]=1/(2*l);k[4]=1}else{j=(l<=0)?(-1):(1);k[0]=j*(k[6]*k[6]+k[7]*k[7]-l*l)*0.5;k[1]=-j*k[6];k[2]=-j*k[7];k[3]=j/2;k[4]=j*l}}return k},toGL:function(k){var l,o,n;if(typeof Float32Array!=="undefined"){l=new Float32Array(16)}else{l=new Array(16)}if(k.length!==4&&k[0].length!==4){return l}for(o=0;o<4;o++){for(n=0;n<4;n++){l[o+4*n]=k[o][n]}}return l}}})(JXG,Math);JXG.Math.Numerics=(function(f,e){var g={rk4:{s:4,A:[[0,0,0,0],[0.5,0,0,0],[0,0.5,0,0],[0,0,1,0]],b:[1/6,1/3,1/3,1/6],c:[0,0.5,0.5,1]},heun:{s:2,A:[[0,0],[1,0]],b:[0.5,0.5],c:[0,1]},euler:{s:1,A:[[0]],b:[1],c:[0]}};return{Gauss:function(h,s){var u=f.Math.eps,l=h.length>0?h[0].length:0,q,t,r,p,o,m=function(v,n){var k=this[v];this[v]=this[n];this[n]=k};if((l!==s.length)||(l!==h.length)){throw new Error("JXG.Math.Numerics.Gauss: Dimensions don't match. A must be a square matrix and b must be of the same length as A.")}q=new Array(l);t=s.slice(0,l);for(r=0;rp;r--){if(e.abs(q[r][p])>u){if(e.abs(q[p][p])0?r[0].length:0;for(p=h-1;p>=0;p--){for(o=s-1;o>p;o--){k[p]-=r[p][o]*k[o]}k[p]/=r[p][p]}return k},gaussBareiss:function(v){var m,u,A,q,o,h,l,r,w,z=f.Math.eps;l=v.length;if(l<=0){return 0}if(v[0].length=z){break}}if(q==l){return 0}for(o=m;or){r=h}v+=h;if(h>=D){h=e.atan2(2*l[s][q],l[s][s]-l[q][q])*0.5;t=e.sin(h);B=e.cos(h);for(p=0;pD&&u<2000);return[l,o]},NewtonCotes:function(h,l,j){var m=0,q=j&&typeof j.number_of_nodes==="number"?j.number_of_nodes:28,o={trapez:true,simpson:true,milne:true},r=j&&j.integration_type&&o.hasOwnProperty(j.integration_type)&&o[j.integration_type]?j.integration_type:"milne",p=(h[1]-h[0])/q,n,k,s;switch(r){case"trapez":m=(l(h[0])+l(h[1]))*0.5;n=h[0];for(k=0;k0){throw new Error("JSXGraph: INT_SIMPSON requires config.number_of_nodes dividable by 2.")}s=q/2;m=l(h[0])+l(h[1]);n=h[0];for(k=0;k0){throw new Error("JSXGraph: Error in INT_MILNE: config.number_of_nodes must be a multiple of 4")}s=q*0.25;m=7*(l(h[0])+l(h[1]));n=h[0];for(k=0;kn){q=this.D(p,k)(j);m+=2;if(e.abs(q)>n){j-=o/q}else{j+=(e.random()*0.2-1)}o=p.apply(k,[j]);m++;l++}return j},root:function(j,h,i){return this.fzero(j,h,i)},Neville:function(l){var i=[],h=function(m){return function(w,n){var p,v,z,A=f.Math.binomial,u=l.length,o=u-1,q=0,r=0;if(!n){z=1;for(p=0;p=0;o--){u[o]=(q[o]-(v[o+1]*u[o+1]))/p[o]}for(o=h-3;o>=0;o--){u[o+1]=u[o]}u[0]=0;u[h-1]=0;return u},splineEval:function(k,z,v,B){var m=e.min(z.length,v.length),p=1,o=false,A=[],r,q,w,u,t,s,h;if(f.isArray(k)){p=k.length;o=true}else{k=[k]}for(r=0;rz[m-1])){return NaN}for(q=1;q=0;l--){m=m.concat(["(",h[l].toPrecision(k),")"]);if(l>1){m=m.concat(["*",j,"",l,"<","/sup> + "])}else{if(l===1){m=m.concat(["*",j," + "])}}}return m.join("")},lagrangePolynomial:function(j){var h=[],i=function(v,l){var o,m,r,u,w,p=0,q=0,t,n;r=j.length;if(!l){for(o=0;o=o-3){return l[o-2][n]()}}r=e.floor(q);if(r==q){return l[r][n]()}q-=r;u=i[n][r];return 0.5*(((u[3]*q+u[2])*q+u[1])*q+u[0])}};return[h("X"),h("Y"),0,function(){return j.length-1}]},regressionPolynomial:function(l,p,o){var h,i,n,m,j,q,k="";if(f.isPoint(l)&&typeof l.Value=="function"){i=function(){return l.Value()}}else{if(f.isFunction(l)){i=l}else{if(f.isNumber(l)){i=function(){return l}}else{throw new Error("JSXGraph: Can't create regressionPolynomial from degree of type'"+(typeof l)+"'.")}}}if(arguments.length==3&&f.isArray(p)&&f.isArray(o)){j=0}else{if(arguments.length==2&&f.isArray(p)&&p.length>0&&f.isPoint(p[0])){j=1}else{throw new Error("JSXGraph: Can't create regressionPolynomial. Wrong parameters.")}}q=function(F,r){var v,u,C,z,E,t,D,G,A,w=p.length;A=e.floor(i());if(!r){if(j===1){n=[];m=[];for(v=0;v=0;v--){G=(G*F+h[v])}return G};q.getTerm=function(){return k};return q},bezier:function(j){var h,i=function(k){return function(m,l){var p=e.floor(m)*3,o=m%1,n=1-o;if(!l){h=e.floor(j.length/3)}if(m<0){return j[0][k]()}if(m>=h){return j[j.length-1][k]()}if(isNaN(m)){return NaN}return n*n*(n*j[p][k]()+3*o*j[p+1][k]())+(3*n*j[p+2][k]()+o*j[p+3][k]())*o*o}};return[i("X"),i("Y"),0,function(){return e.floor(j.length/3)}]},bspline:function(k,h){var l,n=[],m=function(r,o){var p,q=[];for(p=0;p=B){v=0}else{v=u[q+1]}z=C[q+r-1]-C[q];if(z==0){u[q]=0}else{u[q]=(A-C[q])/z*w}z=C[q+r]-C[q+1];if(z!=0){u[q]+=(C[q+r]-A)/z*v}}}return u},i=function(o){return function(v,q){var p=k.length,A,u,w,z=p-1,r=h;if(z<=0){return NaN}if(z+2<=r){r=z+1}if(v<=0){return k[0][o]()}if(v>=z-r+2){return k[z][o]()}l=m(z,r);w=e.floor(v)+r-1;n=j(v,l,z,r,w);A=0;for(u=w-r+1;u<=w;u++){if(u=0){A+=k[u][o]()*n[u]}}return A}};return[i("X"),i("Y"),0,function(){return k.length-1}]},D:function(k,l){var j=0.00001,i=1/(j*2);if(arguments.length==1||(arguments.length>1&&!f.exists(arguments[1]))){return function(h,m){return(k(h+j,m)-k(h-j,m))*i}}else{return function(h,m){return(k.apply(l,[h+j,m])-k.apply(l,[h-j,m]))*i}}},riemann:function(s,o,t,l,p){var m=[],A=[],r,q=0,z,w=l,u,k,v,h;o=e.round(o);m[q]=w;A[q]=0;if(o>0){z=(p-l)/o;h=z*0.01;for(r=0;ru){u=v}}}}}}q++;m[q]=w;A[q]=u;q++;w+=z;if(t==="trapezodial"){u=s(w)}m[q]=w;A[q]=u;q++;m[q]=w;A[q]=0}}return[m,A]},riemannsum:function(p,l,r,k,m){var q=0,o,v,u=k,s,j,t,h;l=e.floor(l);if(l>0){v=(m-k)/l;h=v*0.01;for(o=0;os){s=t}}}}}}}q+=v*s;u+=v}}return q},rungeKutta:function(m,H,p,n,G){var q=[],o=[],F=(p[1]-p[0])/n,v=p[0],J,E,D,B,A,C=H.length,w,u=[],z=0;if(f.isString(m)){m=g[m]||g.euler}w=m.s;for(J=0;J0){if(f.isArray(J)){return this.fminbr(I,[M,L],O)}else{return this.Newton(I,M,O)}}K=M;w=C;while(A=H&&e.abs(C)>e.abs(z)){t=K-L;if(M==K){m=z/C;v=t*m;s=1-m}else{s=C/w;m=z/w;l=z/C;v=l*(t*s*(s-m)-(L-M)*(m-1));s=(s-1)*(m-1)*(l-1)}if(v>0){s=-s}else{v=-v}if(v<(0.75*t*s-e.abs(H*s)*0.5)&&v0){n=H}else{n=-H}}M=L;C=z;L+=n;z=I.apply(O,[L]);D++;if((z>0&&w>0)||(z<0&&w<0)){K=M;w=C}A++}return L},fminbr:function(I,J,N){var M,K,m,s,o,i,k,j,A=(3-e.sqrt(5))*0.5,F=f.Math.eps,C=e.sqrt(f.Math.eps),h=this.maxIterationsMinimize,E=0,z,L,H,n,D,B,u,l,G=0;if(!f.isArray(J)||J.length<2){throw new Error("JXG.Math.Numerics.fminbr: length of array x0 has to be at least two.")}M=J[0];K=J[1];s=M+A*(K-M);k=I.apply(N,[s]);G++;m=s;o=s;i=k;j=k;while(E=H){u=(m-o)*(i-k);B=(m-s)*(i-j);D=(m-s)*B-(m-o)*u;B=2*(B-u);if(B>0){D=-D}else{B=-B}if(e.abs(D)B*(M-m+2*H)&&D0){n=H}else{n=-H}}u=m+n;l=I.apply(N,[u]);G++;if(l<=i){if(ur){l(v,u,k[1],r,s);l(v,k[1],t,r,s)}else{s.push(v[t])}},o=function(H,w,v){var B=0,z=w,A,u,I,G,F,t,E,s,C,D,r;if(v-w<2){return[-1,0]}I=H[w].scrCoords;G=H[v].scrCoords;if(isNaN(I[1]+I[2]+G[1]+G[2])){return[NaN,v]}for(u=w+1;u=f.Math.eps){r=(t*s+E*C)/D;if(r<0){r=0}else{if(r>1){r=1}}t=t-r*s;E=E-r*C;A=t*t+E*E}else{r=0;A=t*t+E*E}if(A>B){B=A;z=u}}return[e.sqrt(B),z]};h=q.length;p=0;while(pp&&isNaN(q[m].scrCoords[1]+q[m].scrCoords[2])){m--}if(!(p>m||p==h)){n[0]=q[p];l(q,p,m,j,n)}return n}}})(JXG,Math);JXG.Math.Statistics={sum:function(f){var h,e=f.length,g=0;for(h=0;h0){return this.sum(e)/e.length}else{return 0}},median:function(f){var g,e;if(f.length>0){g=f.slice(0);g.sort(function(i,h){return i-h});e=g.length;if(e%2==1){return g[parseInt(e*0.5)]}else{return(g[e*0.5-1]+g[e*0.5])*0.5}}else{return 0}},variance:function(g){var f,j,h,e=g.length;if(e>1){f=this.mean(g);j=0;for(h=0;h0){return this.mean(this.multiply(e,f))}else{return 0}},max:function(e){return Math.max.apply(this,e)},min:function(e){return Math.min.apply(this,e)},range:function(e){return[this.min(e),this.max(e)]},abs:function(f){var h,e,g;if(JXG.isArray(f)){e=f.length;g=[];for(h=0;h0){m=n[q].generatePolynomial();for(h=0;h0)){if((A.toOrigin!==f)&&(A.toOrigin!=null)&&E(A.toOrigin.id,o.listOfFreePoints)){l=A.toOrigin}else{l=o.listOfFreePoints[0]}v=l.symbolic.x;t=l.symbolic.y;for(F=0;F1)){if((A.to10!==f)&&(A.to10!=null)&&(A.to10.id!=A.toOrigin.id)&&E(A.to10.id,o.listOfFreePoints)){k=A.to10}else{if(o.listOfFreePoints[0].id==l.id){k=o.listOfFreePoints[1]}else{k=o.listOfFreePoints[0]}}p=e.Math.Geometry.rad([1,0],[0,0],[k.symbolic.x,k.symbolic.y]);G=Math.cos(-p);z=Math.sin(-p);for(F=0;Fe.Math.eps)){I=k.symbolic.x;for(F=0;Fq){k+=Math.PI}p=Math.cos(k)+o[1];n=Math.sin(k)+o[2];return new JXG.Coords(JXG.COORDS_BY_USER,[p,n],l)},reflection:function(p,m,g){var i=m.coords.usrCoords,q=p.point1.coords.usrCoords,h=p.point2.coords.usrCoords,f,l,e,j,n,k,o;if(!JXG.exists(g)){g=m.board}n=h[1]-q[1];k=h[2]-q[2];f=i[1]-q[1];l=i[2]-q[2];o=(n*l-k*f)/(n*n+k*k);e=i[1]+2*o*k;j=i[2]-2*o*n;return new JXG.Coords(JXG.COORDS_BY_USER,[e,j],g)},rotation:function(e,o,i,j){var l=o.coords.usrCoords,f=e.coords.usrCoords,h,n,k,p,g,m;if(!JXG.exists(j)){j=o.board}h=l[1]-f[1];n=l[2]-f[2];k=Math.cos(i);p=Math.sin(i);g=h*k-n*p+f[1];m=h*p+n*k+f[2];return new JXG.Coords(JXG.COORDS_BY_USER,[g,m],j)},perpendicular:function(r,p,j){var i=r.point1.coords.usrCoords,h=r.point2.coords.usrCoords,f=p.coords.usrCoords,n,m,l,q,k,g,e,o;if(!JXG.exists(j)){j=p.board}if(p==r.point1){n=i[1]+h[2]-i[2];m=i[2]-h[1]+i[1];l=true}else{if(p==r.point2){n=h[1]+i[2]-h[2];m=h[2]-i[1]+h[1];l=false}else{if(((Math.abs(i[1]-h[1])>JXG.Math.eps)&&(Math.abs(f[2]-(i[2]-h[2])*(f[1]-i[1])/(i[1]-h[1])-i[2])JXG.Math.eps&&(Math.abs(f[0])JXG.Math.eps){for(k=2;k>0;k--){v[m][k]/=v[m][0]}v[m][0]=1}}f=false;e=false;if(!r&&q.scrCoords[1]>=0&&q.scrCoords[1]<=h.board.canvasWidth&&q.scrCoords[2]>=0&&q.scrCoords[2]<=h.board.canvasHeight){f=true}if(!g&&p.scrCoords[1]>=0&&p.scrCoords[1]<=h.board.canvasWidth&&p.scrCoords[2]>=0&&p.scrCoords[2]<=h.board.canvasHeight){e=true}if(Math.abs(v[1][0])h.board.canvasHeight){l=v[2]}else{l=v[3]}}else{if(v[1][2]>h.board.canvasHeight){n=v[2];if(v[3][2]<0){l=v[0]}else{l=v[3]}}else{n=v[1];if(v[3][2]<0){l=v[0]}else{if(v[3][2]>h.board.canvasHeight){l=v[2]}else{l=v[3]}}}}}}n=new JXG.Coords(JXG.COORDS_BY_SCREEN,n.slice(1),h.board);l=new JXG.Coords(JXG.COORDS_BY_SCREEN,l.slice(1),h.board);if(!f&&!e){if(!r&&g&&!this.isSameDirection(q,p,n)&&!this.isSameDirection(q,p,l)){return}else{if(r&&!g&&!this.isSameDirection(p,q,n)&&!this.isSameDirection(p,q,l)){return}}}if(!f){if(!e){if(this.isSameDir(q,p,n,l)){u=n;t=l}else{t=n;u=l}}else{if(this.isSameDir(q,p,n,l)){u=n}else{u=l}}}else{if(!e){if(this.isSameDir(q,p,n,l)){t=l}else{t=n}}}if(u){q.setCoordinates(JXG.COORDS_BY_USER,u.usrCoords.slice(1))}if(t){p.setCoordinates(JXG.COORDS_BY_USER,t.usrCoords.slice(1))}},isSameDir:function(k,j,g,f){var e=j.usrCoords[1]-k.usrCoords[1],l=j.usrCoords[2]-k.usrCoords[2],i=f.usrCoords[1]-g.usrCoords[1],h=f.usrCoords[2]-g.usrCoords[2];return e*i+l*h>=0},isSameDirection:function(l,i,g){var f,e,k,j,h=false;f=i.usrCoords[1]-l.usrCoords[1];e=i.usrCoords[2]-l.usrCoords[2];k=g.usrCoords[1]-l.usrCoords[1];j=g.usrCoords[2]-l.usrCoords[2];if(Math.abs(f)=0&&k>=0){if((e>=0&&j>=0)||(e<=0&&j<=0)){h=true}}else{if(f<=0&&k<=0){if((e>=0&&j>=0)||(e<=0&&j<=0)){h=true}}}return h},intersectLineLine:function(p,o,k){var j=p.point1.coords.usrCoords,h=p.point2.coords.usrCoords,g=o.point1.coords.usrCoords,e=o.point2.coords.usrCoords,i,f,n,m,l;if(!JXG.exists(k)){k=p.board}i=j[1]*h[2]-j[2]*h[1];f=g[1]*e[2]-g[2]*e[1];n=(h[2]-j[2])*(g[1]-e[1])-(j[1]-h[1])*(e[2]-g[2]);if(Math.abs(n)0){e=k.center.Dist(u.point1);I=k.center.Dist(u.point2);G=((e*e)+(B*B)-(I*I))/(2*B);z=(e*e)-(G*G);z=(z<0)?0:z;E=Math.sqrt(z);C=k.Radius();n=Math.sqrt((C*C)-E*E);A=H[1]-J[1];v=H[2]-J[2];j=g[1]+(E/B)*v;i=g[2]-(E/B)*A;e=(H[1]*v)-(H[2]*A);I=(j*A)+(i*v);D=(v*v)+(A*A);if(Math.abs(D)q){return[0]}else{if(u=e&&Math.abs(f[3])=e){return this.meetLineCircle(h,f,g,j)}else{return this.meetCircleCircle(h,f,g,j)}}}},meetLineLine:function(f,e,g,j){var h=JXG.Math.crossProduct(f,e);if(Math.abs(h[0])>JXG.Math.eps){h[1]/=h[0];h[2]/=h[0];h[0]=1}return new JXG.Coords(JXG.COORDS_BY_USER,h,j)},meetLineCircle:function(j,e,o,p){var u,s,r,q,l,h,g,f,m,v;if(e[4]=0){m=Math.sqrt(m);v=[(-g+m)/(2*h),(-g-m)/(2*h)];return((o==0)?new JXG.Coords(JXG.COORDS_BY_USER,[-v[0]*(-l[1])-q*l[0],-v[0]*l[0]-q*l[1]],p):new JXG.Coords(JXG.COORDS_BY_USER,[-v[1]*(-l[1])-q*l[0],-v[1]*l[0]-q*l[1]],p))}else{return new JXG.Coords(JXG.COORDS_BY_USER,[0,0,0],p)}},meetCircleCircle:function(g,e,f,h){var j;if(g[4]JXG.Math.eps&&l<10){B=A(o);z=-w(n);v=j(o);u=-i(n);g=B*u-z*v;o-=(u*t-z*s)/g;n-=(B*s-v*t)/g;t=r.X(o)-q.X(n);s=r.Y(o)-q.Y(n);p=t*t+s*s;l++}arguments.callee.t1memo=o;arguments.callee.t2memo=n;if(Math.abs(o)0.1&&Math.abs(g-h.X(m))>0.1&&Math.abs(e-h.Y(m))>0.1)){v=20;w=(h.maxX()-h.minX())/v;A=h.minX();for(u=0;u0.1&&Math.abs(g-h.X(m))>0.1&&Math.abs(e-h.Y(m))>0.1){break}A+=w}}p=m;arguments.callee.t2memo=p}if(Math.abs(j(p))>JXG.Math.eps){l=0}else{l=1}return(new JXG.Coords(JXG.COORDS_BY_USER,[l,h.X(p),h.Y(p)],k))},projectPointToCircle:function(m,e,g){var j=m.coords.distance(JXG.COORDS_BY_USER,e.center.coords),f=m.coords.usrCoords,h=e.center.coords.usrCoords,l,k,i;if(!JXG.exists(g)){g=m.board}if(Math.abs(j)r.maxX()){q=r.minX()+q-r.maxX()}C=new JXG.Coords(JXG.COORDS_BY_USER,[r.X(q),r.Y(q)],k)}else{if(r.visProp.curvetype=="plot"){B=p;for(v=0;v=JXG.Math.eps){h=(A*z+f*e)/l;s=Math.sqrt(A*A+f*f-h*(A*z+f*e))}else{h=0;s=Math.sqrt(A*A+f*f)}if(h>=0&&h<=1&&s-1){this.monomials[f].coefficient+=g*e.coefficient}else{e.coefficient*=g;this.monomials.push(e)}},add:function(f){var e;if(JXG.exists(f)&&f.ring===this.ring){if(JXG.isArray(f.exponents)){this.addSubMonomial(f,1)}else{for(e=0;e0&&!isNaN(e+f.center.coords.scrCoords[1]+f.center.coords.scrCoords[2])&&e*f.board.unitX<20000){this.updateEllipsePrim(f.rendNode,f.center.coords.scrCoords[1],f.center.coords.scrCoords[2],(e*f.board.unitX),(e*f.board.unitY))}},drawPolygon:function(e){this.appendChildPrim(this.createPrim("polygon",e.id),e.visProp.layer);this.appendNodesToElement(e,"polygon");this.updatePolygon(e)},updatePolygon:function(e){this._updateVisual(e,{stroke:true,dash:true});this.updatePolygonPrim(e.rendNode,e)},displayCopyright:function(e,f){},drawInternalText:function(e){},updateInternalText:function(e){},drawText:function(e){var f,g;if(e.visProp.display==="html"){f=this.container.ownerDocument.createElement("div");f.style.position="absolute";f.className=e.visProp.cssclass;if(this.container.style.zIndex==""){g=0}else{g=parseInt(this.container.style.zIndex)}f.style.zIndex=g+e.board.options.layer.text;this.container.appendChild(f);f.setAttribute("id",this.container.id+"_"+e.id)}else{f=this.drawInternalText(e)}e.rendNode=f;e.htmlStr="";this.updateText(e)},updateText:function(e){var f=e.plaintext;if(e.visProp.visible){this.updateTextStyle(e);if(e.visProp.display==="html"){if(!isNaN(e.coords.scrCoords[1]+e.coords.scrCoords[2])){e.rendNode.style.left=parseInt(e.coords.scrCoords[1])+"px";e.rendNode.style.top=parseInt(e.coords.scrCoords[2]-parseInt(e.visProp.fontsize)+this.vOffsetText)+"px"}if(e.htmlStr!==f){e.rendNode.innerHTML=f;e.htmlStr=f;if(e.visProp.usemathjax){MathJax.Hub.Typeset(e.rendNode)}else{if(e.visProp.useasciimathml){AMprocessNode(e.rendNode,false)}}}this.transformImage(e,e.transformations)}else{this.updateInternalText(e)}}},updateTextStyle:function(g){var f=JXG.evaluate(g.visProp.fontsize);if(g.visProp.display==="html"||this.type!="canvas"){g.rendNode.className=g.visProp.cssclass;try{g.rendNode.style.fontSize=f+"px"}catch(h){g.rendNode.style.fontSize=f}}this.setObjectStrokeColor(g,g.visProp.strokecolor,g.visProp.strokeopacity)},drawImage:function(e){},updateImage:function(e){this.updateRectPrim(e.rendNode,e.coords.scrCoords[1],e.coords.scrCoords[2]-e.size[1],e.size[0],e.size[1]);this.updateImageURL(e);this.transformImage(e,e.transformations);this._updateVisual(e,{stroke:true,dash:true},true)},joinTransforms:function(o,p){var l=[[1,0,0],[0,1,0],[0,0,1]],h=o.board.origin.scrCoords[1],g=o.board.origin.scrCoords[2],f=o.board.unitX,e=o.board.unitY,s=[[1,0,0],[-h,1,0],[-g,0,1]],r=[[1,0,0],[0,1/f,0],[0,0,-1/e]],j=[[1,0,0],[0,f,0],[0,0,-e]],k=[[1,0,0],[h,1,0],[g,0,1]],n,q=p.length;for(n=0;n\nFunction Base64Encode(inData)\n Const Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"\n Dim cOut, sOut, I\n For I = 1 To LenB(inData) Step 3\n Dim nGroup, pOut, sGroup\n nGroup = &H10000 * AscB(MidB(inData, I, 1)) + _\n &H100 * MyASC(MidB(inData, I + 1, 1)) + MyASC(MidB(inData, I + 2, 1))\n nGroup = Oct(nGroup)\n nGroup = String(8 - Len(nGroup), "0") & nGroup\n pOut = Mid(Base64, CLng("&o" & Mid(nGroup, 1, 2)) + 1, 1) + _\n Mid(Base64, CLng("&o" & Mid(nGroup, 3, 2)) + 1, 1) + _\n Mid(Base64, CLng("&o" & Mid(nGroup, 5, 2)) + 1, 1) + _\n Mid(Base64, CLng("&o" & Mid(nGroup, 7, 2)) + 1, 1)\n sOut = sOut + pOut\n Next\n Select Case LenB(inData) Mod 3\n Case 1: \'8 bit final\n sOut = Left(sOut, Len(sOut) - 2) + "=="\n Case 2: \'16 bit final\n sOut = Left(sOut, Len(sOut) - 1) + "="\n End Select\n Base64Encode = sOut\nEnd Function\n\nFunction MyASC(OneChar)\n If OneChar = "" Then MyASC = 0 Else MyASC = AscB(OneChar)\nEnd Function\n\nFunction BinFileReader(xhr)\n Dim byteString\n Dim b64String\n Dim i\n byteString = xhr.responseBody\n ReDim byteArray(LenB(byteString))\n For i = 1 To LenB(byteString)\n byteArray(i-1) = AscB(MidB(byteString, i, 1))\n Next\n b64String = Base64Encode(byteString)\n BinFileReader = b64String\nEnd Function\n<\/script>\n')}JXG.GeonextParser={};JXG.GeonextParser.replacePow=function(g){var l,o,m,k,n,h,e,f,j,r,q;g=g.replace(/(\s*)\^(\s*)/g,"^");j=g.indexOf("^");while(j>=0){f=g.slice(0,j);r=g.slice(j+1);if(f.charAt(f.length-1)==")"){l=1;o=f.length-2;while(o>=0&&l>0){m=f.charAt(o);if(m==")"){l++}else{if(m=="("){l--}}o--}if(l==0){k="";h=f.substring(0,o+1);e=o;while(e>=0&&h.substr(e,1).match(/([\w\.]+)/)){k=RegExp.$1+k;e--}k+=f.substring(o+1,f.length);k=k.replace(/([\(\)\+\*\%\^\-\/\]\[])/g,"\\$1")}else{throw new Error("JSXGraph: Missing '(' in expression")}}else{k="[\\w\\.]+"}if(r.match(/^([\w\.]*\()/)){l=1;o=RegExp.$1.length;while(o0){m=r.charAt(o);if(m==")"){l--}else{if(m=="("){l++}}o++}if(l==0){n=r.substring(0,o);n=n.replace(/([\(\)\+\*\%\^\-\/\[\]])/g,"\\$1")}else{throw new Error("JSXGraph: Missing ')' in expression")}}else{n="[\\w\\.]+"}q=new RegExp("("+k+")\\^("+n+")");g=g.replace(q,"JXG.Math.pow($1,$2)");j=g.indexOf("^")}return g};JXG.GeonextParser.replaceIf=function(f){var t="",g,r,j=null,e=null,m=null,h,q,k,n,l,o,p;h=f.indexOf("If(");if(h<0){return f}f=f.replace(/""/g,"0");while(h>=0){g=f.slice(0,h);r=f.slice(h+3);k=1;q=0;n=-1;l=-1;while(q0){o=r.charAt(q);if(o==")"){k--}else{if(o=="("){k++}else{if(o==","&&k==1){if(n<0){n=q}else{l=q}}}}q++}p=r.slice(0,q-1);r=r.slice(q);if(n<0){return""}if(l<0){return""}j=p.slice(0,n);e=p.slice(n+1,l);m=p.slice(l+1);j=this.replaceIf(j);e=this.replaceIf(e);m=this.replaceIf(m);t+=g+"(("+j+")?("+e+"):("+m+"))";f=r;j=null;e=null;h=f.indexOf("If(")}t+=r;return t};JXG.GeonextParser.replaceSub=function(g){if(g.indexOf){}else{return g}var f=g.indexOf("_{"),e;while(f>=0){g=g.substr(0,f)+g.substr(f).replace(/_\{/,"");e=g.substr(f).indexOf("}");if(e>=0){g=g.substr(0,e)+g.substr(e).replace(/\}/,"")}f=g.indexOf("_{")}f=g.indexOf("_");while(f>=0){g=g.substr(0,f)+g.substr(f).replace(/_(.?)/,"$1");f=g.indexOf("_")}return g};JXG.GeonextParser.replaceSup=function(g){if(g.indexOf){}else{return g}var f=g.indexOf("^{"),e;while(f>=0){g=g.substr(0,f)+g.substr(f).replace(/\^\{/,"");e=g.substr(f).indexOf("}");if(e>=0){g=g.substr(0,e)+g.substr(e).replace(/\}/,"")}f=g.indexOf("^{")}f=g.indexOf("^");while(f>=0){g=g.substr(0,f)+g.substr(f).replace(/\^(.?)/,"$1");f=g.indexOf("^")}return g};JXG.GeonextParser.replaceNameById=function(h,k){var m=0,e,l,j,g,f=["X","Y","L","V"];for(g=0;g=0){if(m>=0){e=h.indexOf(")",m+2);if(e>=0){l=h.slice(m+2,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+2)+j.id+h.slice(e)}}e=h.indexOf(")",m+2);m=h.indexOf(f[g]+"(",e)}}m=h.indexOf("Dist(");while(m>=0){if(m>=0){e=h.indexOf(",",m+5);if(e>=0){l=h.slice(m+5,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+5)+j.id+h.slice(e)}}e=h.indexOf(",",m+5);m=h.indexOf(",",e);e=h.indexOf(")",m+1);if(e>=0){l=h.slice(m+1,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+1)+j.id+h.slice(e)}e=h.indexOf(")",m+1);m=h.indexOf("Dist(",e)}f=["Deg","Rad"];for(g=0;g=0){if(m>=0){e=h.indexOf(",",m+4);if(e>=0){l=h.slice(m+4,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+4)+j.id+h.slice(e)}}e=h.indexOf(",",m+4);m=h.indexOf(",",e);e=h.indexOf(",",m+1);if(e>=0){l=h.slice(m+1,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+1)+j.id+h.slice(e)}e=h.indexOf(",",m+1);m=h.indexOf(",",e);e=h.indexOf(")",m+1);if(e>=0){l=h.slice(m+1,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+1)+j.id+h.slice(e)}e=h.indexOf(")",m+1);m=h.indexOf(f[g]+"(",e)}}return h};JXG.GeonextParser.replaceIdByObj=function(e){var f=/(X|Y|L)\(([\w_]+)\)/g;e=e.replace(f,'this.board.objects["$2"].$1()');f=/(V)\(([\w_]+)\)/g;e=e.replace(f,'this.board.objects["$2"].Value()');f=/(Dist)\(([\w_]+),([\w_]+)\)/g;e=e.replace(f,'this.board.objects["$2"].Dist(this.board.objects["$3"])');f=/(Deg)\(([\w_]+),([ \w\[\w_]+),([\w_]+)\)/g;e=e.replace(f,'JXG.Math.Geometry.trueAngle(this.board.objects["$2"],this.board.objects["$3"],this.board.objects["$4"])');f=/Rad\(([\w_]+),([\w_]+),([\w_]+)\)/g;e=e.replace(f,'JXG.Math.Geometry.rad(this.board.objects["$1"],this.board.objects["$2"],this.board.objects["$3"])');return e};JXG.GeonextParser.geonext2JS=function(f,h){var j,g,e,l=["Abs","ACos","ASin","ATan","Ceil","Cos","Exp","Factorial","Floor","Log","Max","Min","Random","Round","Sin","Sqrt","Tan","Trunc"],k=["Math.abs","Math.acos","Math.asin","Math.atan","Math.ceil","Math.cos","Math.exp","JXG.Math.factorial","Math.floor","Math.log","Math.max","Math.min","Math.random","this.board.round","Math.sin","Math.sqrt","Math.tan","Math.ceil"];f=f.replace(/</g,"<");f=f.replace(/>/g,">");f=f.replace(/&/g,"&");g=f;g=this.replaceNameById(g,h);g=this.replaceIf(g);g=this.replacePow(g);g=this.replaceIdByObj(g);for(e=0;e=0){j[g].addChild(i)}}}else{e=g.replace(/\[/g,"\\[");e=e.replace(/\]/g,"\\]");k=new RegExp("\\(([\\w\\[\\]'_ ]+,)*("+e+")(,[\\w\\[\\]'_ ]+)*\\)","g");if(f.search(k)>=0){j[g].addChild(i)}}}}};JXG.GeonextParser.gxt2jc=function(e,g){var f,i=["Sqrt"],h=["sqrt"];e=e.replace(/</g,"<");e=e.replace(/>/g,">");e=e.replace(/&/g,"&");f=e;f=this.replaceNameById2(f,g);f=f.replace(/True/g,"true");f=f.replace(/False/g,"false");f=f.replace(/fasle/g,"false");return f};JXG.GeonextParser.replaceNameById2=function(h,k){var m=0,e,l,j,g,f=["X","Y","L","V"];for(g=0;g=0){if(m>=0){e=h.indexOf(")",m+2);if(e>=0){l=h.slice(m+2,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+2)+"$('"+j.id+"')"+h.slice(e)}}e=h.indexOf(")",m+2);m=h.indexOf(f[g]+"(",e)}}m=h.indexOf("Dist(");while(m>=0){if(m>=0){e=h.indexOf(",",m+5);if(e>=0){l=h.slice(m+5,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+5)+"$('"+j.id+"')"+h.slice(e)}}e=h.indexOf(",",m+5);m=h.indexOf(",",e);e=h.indexOf(")",m+1);if(e>=0){l=h.slice(m+1,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+1)+"$('"+j.id+"')"+h.slice(e)}e=h.indexOf(")",m+1);m=h.indexOf("Dist(",e)}f=["Deg","Rad"];for(g=0;g=0){if(m>=0){e=h.indexOf(",",m+4);if(e>=0){l=h.slice(m+4,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+4)+"$('"+j.id+"')"+h.slice(e)}}e=h.indexOf(",",m+4);m=h.indexOf(",",e);e=h.indexOf(",",m+1);if(e>=0){l=h.slice(m+1,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+1)+"$('"+j.id+"')"+h.slice(e)}e=h.indexOf(",",m+1);m=h.indexOf(",",e);e=h.indexOf(")",m+1);if(e>=0){l=h.slice(m+1,e);l=l.replace(/\\(['"])?/g,"$1");j=k.elementsByName[l];h=h.slice(0,m+1)+"$('"+j.id+"')"+h.slice(e)}e=h.indexOf(")",m+1);m=h.indexOf(f[g]+"(",e)}}return h};JXG.Board=function(e,j,f,o,n,m,l,k,g,h,i){this.BOARD_MODE_NONE=0;this.BOARD_MODE_DRAG=1;this.BOARD_MODE_MOVE_ORIGIN=2;this.BOARD_QUALITY_LOW=1;this.BOARD_QUALITY_HIGH=2;this.BOARD_MODE_ZOOM=17;this.BOARD_MODE_CONSTRUCT=16;this.CONSTRUCTION_TYPE_POINT=1129599060;this.CONSTRUCTION_TYPE_CIRCLE=1129595724;this.CONSTRUCTION_TYPE_LINE=1129598030;this.CONSTRUCTION_TYPE_GLIDER=1129596740;this.CONSTRUCTION_TYPE_MIDPOINT=1129598288;this.CONSTRUCTION_TYPE_PERPENDICULAR=1129599044;this.CONSTRUCTION_TYPE_PARALLEL=1129599052;this.CONSTRUCTION_TYPE_INTERSECTION=1129597267;this.container=e;this.containerObj=document.getElementById(this.container);if(this.containerObj==null){throw new Error("\nJSXGraph: HTML container element '"+(e)+"' not found.")}this.renderer=j;this.grids=[];this.options=JXG.deepCopy(JXG.Options);this.dimension=2;this.jc=new JXG.JessieCode();this.jc.board=this;this.origin={};this.origin.usrCoords=[1,0,0];this.origin.scrCoords=[1,o[0],o[1]];this.zoomX=n;this.zoomY=m;this.unitX=l*this.zoomX;this.unitY=k*this.zoomY;this.canvasWidth=g;this.canvasHeight=h;if(JXG.exists(f)&&f!==""&&!JXG.exists(document.getElementById(f))){this.id=f}else{this.id=this.generateId()}this.hooks=[];this.dependentBoards=[];this.inUpdate=false;this.objects={};this.groups={};this.animationObjects={};this.highlightedObjects={};this.numObjects=0;this.elementsByName={};this.mode=this.BOARD_MODE_NONE;this.updateQuality=this.BOARD_QUALITY_HIGH;this.isSuspendedRedraw=false;this.calculateSnapSizes();this.drag_dx=0;this.drag_dy=0;this.mouse=null;this.touches=[];this.xmlString="";this.cPos=[];this.touchMoveLast=0;this.downObjects=[];this.showCopyright=false;if((i!=null&&i)||(i==null&&this.options.showCopyright)){this.showCopyright=true;this.renderer.displayCopyright(JXG.JSXGraph.licenseText,this.options.text.fontSize)}this.needsFullUpdate=false;this.reducedUpdate=false;this.currentCBDef="none";this.geonextCompatibilityMode=false;if(this.options.text.useASCIIMathML&&translateASCIIMath){init()}else{this.options.text.useASCIIMathML=false}this.hasMouseHandlers=false;this.hasTouchHandlers=false;this.addEventHandlers()};JXG.extend(JXG.Board.prototype,{generateName:function(g){if(g.type==JXG.OBJECT_TYPE_TICKS){return""}var m,k=3,f="",n="",o=[],e="",l,h;if(g.elementClass==JXG.OBJECT_CLASS_POINT){m=["","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]}else{m=["","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]}switch(g.type){case JXG.OBJECT_TYPE_POLYGON:f="P_{";n="}";break;case JXG.OBJECT_TYPE_CIRCLE:f="k_{";n="}";break;case JXG.OBJECT_TYPE_ANGLE:f="W_{";n="}";break;default:if(g.elementClass!=JXG.OBJECT_CLASS_POINT&&g.elementClass!=JXG.OBJECT_CLASS_LINE){f="s_{";n="}"}}for(l=0;l0;l--){e+=m[o[l-1]]}if(this.elementsByName[e+n]==null){return e+n}}o[0]=m.length;for(l=1;l=e.visProp.layer){if(JXG.exists(e.label)&&j==e.label.content){continue}e=j;i[0]=e}}}if(i.length>0){this.mode=this.BOARD_MODE_DRAG}if(this.options.takeFirst){i.length=1}return i},moveObject:function(e,j,i){var f=new JXG.Coords(JXG.COORDS_BY_SCREEN,this.getScrCoordsOfMouse(e,j),this),g=i.obj,h;if(g.type!=JXG.OBJECT_TYPE_GLIDER){if(!isNaN(i.targets[0].Xprev+i.targets[0].Yprev)){g.setPositionDirectly(JXG.COORDS_BY_SCREEN,f.scrCoords[1],f.scrCoords[2],i.targets[0].Xprev,i.targets[0].Yprev)}i.targets[0].Xprev=f.scrCoords[1];i.targets[0].Yprev=f.scrCoords[2];this.update(g)}else{if(g.type==JXG.OBJECT_TYPE_GLIDER){h=g.coords;g.setPositionDirectly(JXG.COORDS_BY_USER,f.usrCoords[1],f.usrCoords[2]);if(g.slideObject.elementClass==JXG.OBJECT_CLASS_CIRCLE){g.coords=JXG.Math.Geometry.projectPointToCircle(g,g.slideObject,this)}else{if(g.slideObject.elementClass==JXG.OBJECT_CLASS_LINE){g.coords=JXG.Math.Geometry.projectPointToLine(g,g.slideObject,this)}}if(g.group.length!=0){g.group[g.group.length-1].dX=g.coords.scrCoords[1]-h.scrCoords[1];g.group[g.group.length-1].dY=g.coords.scrCoords[2]-h.scrCoords[2];g.group[g.group.length-1].update(this)}else{this.update(g)}}}g.triggerEventHandlers("drag");this.updateInfobox(g);g.highlight()},moveLine:function(f,e,u){var B,i,C,A,t,s,j,r,k,v,z,w,g,h,q,p,n,m,l;if(JXG.exists(u)&&JXG.exists(u.obj)){w=u.obj}else{return}if(w.elementClass!=JXG.OBJECT_CLASS_LINE){return}B=new JXG.Coords(JXG.COORDS_BY_SCREEN,this.getScrCoordsOfMouse(f[0],f[1]),this);i=new JXG.Coords(JXG.COORDS_BY_SCREEN,this.getScrCoordsOfMouse(e[0],e[1]),this);if(JXG.exists(u.targets[0])&&JXG.exists(u.targets[1])&&!isNaN(u.targets[0].Xprev+u.targets[0].Yprev+u.targets[1].Xprev+u.targets[1].Yprev)){C=B.usrCoords;A=i.usrCoords;t=(new JXG.Coords(JXG.COORDS_BY_SCREEN,[u.targets[0].Xprev,u.targets[0].Yprev],this)).usrCoords;s=(new JXG.Coords(JXG.COORDS_BY_SCREEN,[u.targets[1].Xprev,u.targets[1].Yprev],this)).usrCoords;r=[1,(t[1]+s[1])*0.5,(t[2]+s[2])*0.5];j=[1,(C[1]+A[1])*0.5,(C[2]+A[2])*0.5];v=JXG.Math.crossProduct(t,s);k=JXG.Math.crossProduct(C,A);g=JXG.Math.crossProduct(v,k);if(Math.abs(g[0])-1&&this.touches[g].targets[1].num>-1){this.touches[g].targets[0].X=e.targetTouches[this.touches[g].targets[0].num].screenX;this.touches[g].targets[0].Y=e.targetTouches[this.touches[g].targets[0].num].screenY;this.touches[g].targets[1].X=e.targetTouches[this.touches[g].targets[1].num].screenX;this.touches[g].targets[1].Y=e.targetTouches[this.touches[g].targets[1].num].screenY;this.moveLine(this.getMousePosition(e,this.touches[g].targets[0].num),this.getMousePosition(e,this.touches[g].targets[1].num),this.touches[g])}}}}else{for(g=0;g0){for(m=0;m0){this.zoomIn(g.usrCoords[1],g.usrCoords[2])}else{this.zoomOut(g.usrCoords[1],g.usrCoords[2])}e.preventDefault();return false},updateInfobox:function(f){var e,i,g,h;if(!f.visProp.showinfobox){return this}if(f.elementClass==JXG.OBJECT_CLASS_POINT){g=f.coords.usrCoords[1];h=f.coords.usrCoords[2];this.infobox.setCoords(g+this.infobox.distanceX/(this.unitX),h+this.infobox.distanceY/(this.unitY));if(typeof(f.infoboxText)!="string"){e=Math.abs(g);if(e>0.1){e=g.toFixed(2)}else{if(e>=0.01){e=g.toFixed(4)}else{if(e>=0.0001){e=g.toFixed(6)}else{e=g}}}i=Math.abs(h);if(i>0.1){i=h.toFixed(2)}else{if(i>=0.01){i=h.toFixed(4)}else{if(i>=0.0001){i=h.toFixed(6)}else{i=h}}}this.highlightInfobox(e,i,f)}else{this.highlightCustomInfobox(f.infoboxText,f)}this.renderer.show(this.infobox);this.renderer.updateText(this.infobox)}return this},highlightCustomInfobox:function(e){this.infobox.setText(''+e+"");return this},highlightInfobox:function(e,g,f){this.highlightCustomInfobox("("+e+", "+g+")");return this},dehighlightAll:function(){var f,g,e=false;for(f in this.highlightedObjects){g=this.highlightedObjects[f];g.noHighlight();e=true}this.highlightedObjects={};if(this.options.renderer=="canvas"&&e){this.prepareUpdate();this.renderer.suspendRedraw(this);this.updateRenderer();this.renderer.unsuspendRedraw()}return this},getScrCoordsOfMouse:function(e,g){if(this.options.grid.snapToGrid){var f=new JXG.Coords(JXG.COORDS_BY_SCREEN,[e,g],this);f.setCoordinates(JXG.COORDS_BY_USER,[Math.round((f.usrCoords[1])*this.options.grid.snapSizeX)/this.options.grid.snapSizeX,Math.round((f.usrCoords[2])*this.options.grid.snapSizeY)/this.options.grid.snapSizeY]);return[f.scrCoords[1],f.scrCoords[2]]}else{return[e,g]}},getUsrCoordsOfMouse:function(i){var g=this.getCoordsTopLeftCorner(),f=JXG.getPosition(i),e=f[0]-g[0],j=f[1]-g[1],h=new JXG.Coords(JXG.COORDS_BY_SCREEN,[e,j],this);return h.usrCoords.slice(1)},getAllUnderMouse:function(f){var e=this.getAllObjectsUnderMouse();e.push(this.getUsrCoordsOfMouse(f));return e},getAllObjectsUnderMouse:function(k){var j=this.getCoordsTopLeftCorner(),e=JXG.getPosition(k),g=e[0]-j[0],f=e[1]-j[1],h=[];for(var i in this.objects){if(this.objects[i].visProp.visible&&this.objects[i].hasPoint&&this.objects[i].hasPoint(g,f)){h.push(this.objects[i])}}return h},moveOrigin:function(e,h){var g,f;if(JXG.exists(e)&&JXG.exists(h)){this.origin.scrCoords[1]=e;this.origin.scrCoords[2]=h}for(f in this.objects){g=this.objects[f];if(!g.visProp.frozen&&(g.elementClass==JXG.OBJECT_CLASS_POINT||g.elementClass==JXG.OBJECT_CLASS_CURVE||g.type==JXG.OBJECT_TYPE_AXIS||g.type==JXG.OBJECT_TYPE_TEXT)){if(g.elementClass!=JXG.OBJECT_CLASS_CURVE&&g.type!=JXG.OBJECT_TYPE_AXIS){g.coords.usr2screen()}}}this.clearTraces();this.fullUpdate();return this},addConditions:function(p){var f="var el, x, y, c, rgbo;\n",o=p.indexOf(""),n=p.indexOf(""),l,k,h,r,e,g;if(o<0){return}while(o>=0){l=p.slice(o+6,n);k=l.indexOf("=");h=l.slice(0,k);r=l.slice(k+1);k=h.indexOf(".");e=h.slice(0,k);g=this.elementsByName[JXG.unescapeHTML(e)];var q=h.slice(k+1).replace(/\s+/g,"").toLowerCase();r=JXG.GeonextParser.geonext2JS(r,this);r=r.replace(/this\.board\./g,"this.");if(!JXG.exists(this.elementsByName[e])){JXG.debug("debug conditions: |"+e+"| undefined")}f+='el = this.objects["'+g.id+'"];\n';switch(q){case"x":f+="var y=el.coords.usrCoords[2];\n";f+="el.setPositionDirectly(JXG.COORDS_BY_USER,"+(r)+",y);\n";f+="el.prepareUpdate().update();\n";break;case"y":f+="var x=el.coords.usrCoords[1];\n";f+="el.coords=new JXG.Coords(JXG.COORDS_BY_USER,[x,"+(r)+"],this);\n";f+="el.setPositionDirectly(JXG.COORDS_BY_USER,x,"+(r)+");\n";f+="el.prepareUpdate().update();\n";break;case"visible":f+="var c="+(r)+";\n";f+="el.visProp.visible = c;\n";f+="if (c) {el.showElement();} else {el.hideElement();}\n";break;case"position":f+="el.position = "+(r)+";\n";f+="el.prepareUpdate().update(true);\n";break;case"stroke":f+="rgbo = JXG.rgba2rgbo("+(r)+");\n";f+="el.visProp.strokecolor = rgbo[0];\n";f+="el.visProp.strokeopacity = rgbo[1];\n";break;case"style":f+="el.setStyle("+(r)+");\n";break;case"strokewidth":f+="el.strokeWidth = "+(r)+";\n";break;case"fill":f+="var rgbo = JXG.rgba2rgbo("+(r)+");\n";f+="el.visProp.fillcolor = rgbo[0];\n";f+="el.visProp.fillopacity = rgbo[1];\n";break;case"label":break;default:JXG.debug("property '"+q+"' in conditions not yet implemented:"+r);break}p=p.slice(n+7);o=p.indexOf("");n=p.indexOf("")}f+="this.prepareUpdate().updateElements();\n";f+="return true;\n";this.updateConditions=new Function(f);this.updateConditions()},updateConditions:function(){return false},calculateSnapSizes:function(){var g=new JXG.Coords(JXG.COORDS_BY_USER,[0,0],this),f=new JXG.Coords(JXG.COORDS_BY_USER,[this.options.grid.gridX,this.options.grid.gridY],this),e=g.scrCoords[1]-f.scrCoords[1],h=g.scrCoords[2]-f.scrCoords[2];this.options.grid.snapSizeX=this.options.grid.gridX;while(Math.abs(e)>25){this.options.grid.snapSizeX*=2;e/=2}this.options.grid.snapSizeY=this.options.grid.gridY;while(Math.abs(h)>25){this.options.grid.snapSizeY*=2;h/=2}return this},applyZoom:function(){var f,e;for(e in this.objects){f=this.objects[e];if(!f.visProp.frozen&&(f.elementClass==JXG.OBJECT_CLASS_POINT||f.elementClass==JXG.OBJECT_CLASS_CURVE||f.type==JXG.OBJECT_TYPE_AXIS||f.type==JXG.OBJECT_TYPE_TEXT)){if(f.elementClass!=JXG.OBJECT_CLASS_CURVE&&f.type!=JXG.OBJECT_TYPE_AXIS){f.coords.usr2screen()}}}this.calculateSnapSizes();this.clearTraces();this.fullUpdate();return this},zoomIn:function(m,k){var h=this.getBoundingBox(),l=this.options.zoom.factorX,j=this.options.zoom.factorY,f=(h[2]-h[0])*(1-1/l),e=(h[1]-h[3])*(1-1/j),g=0.5,i=0.5;if(typeof m==="number"&&typeof k==="number"){g=(m-h[0])/(h[2]-h[0]);i=(h[1]-k)/(h[1]-h[3])}this.setBoundingBox([h[0]+f*g,h[1]-e*i,h[2]-f*(1-g),h[3]+e*(1-i)],false);this.zoomX*=l;this.zoomY*=j;this.applyZoom();return this},zoomOut:function(m,k){var h=this.getBoundingBox(),l=this.options.zoom.factorX,j=this.options.zoom.factorY,f=(h[2]-h[0])*(1-l),e=(h[1]-h[3])*(1-j),g=0.5,i=0.5;if(typeof m==="number"&&typeof k==="number"){g=(m-h[0])/(h[2]-h[0]);i=(h[1]-k)/(h[1]-h[3])}this.setBoundingBox([h[0]+f*g,h[1]-e*i,h[2]-f*(1-g),h[3]+e*(1-i)],false);this.zoomX/=l;this.zoomY/=j;this.applyZoom();return this},zoom100:function(){var g=this.getBoundingBox(),f=(g[2]-g[0])*(1-this.zoomX)*0.5,e=(g[1]-g[3])*(1-this.zoomY)*0.5;this.setBoundingBox([g[0]+f,g[1]-e,g[2]-f,g[3]+e],false);this.zoomX=1;this.zoomY=1;this.applyZoom();return this},zoomAllPoints:function(){var e=0,k=0,l=0,j=0,i,h,g,f;for(i in this.objects){if(JXG.isPoint(this.objects[i])&&this.objects[i].visProp.visible){if(this.objects[i].coords.usrCoords[1]k){k=this.objects[i].coords.usrCoords[1]}}if(this.objects[i].coords.usrCoords[2]>j){j=this.objects[i].coords.usrCoords[2]}else{if(this.objects[i].coords.usrCoords[2]=0){g+=""+this.objects[h].id+": "}for(k in this.objects[h].childElements){g+=this.objects[h].childElements[k].id+"("+this.objects[h].childElements[k].name+"), "}g+="

\n"}g+="

\n";j=window.open();j.document.open();j.document.write(g);j.document.close();return this},showXML:function(){var e=window.open("");e.document.open();e.document.write("
"+JXG.escapeHTML(this.xmlString)+"
");e.document.close();return this},prepareUpdate:function(){var e,f;for(e in this.objects){f=this.objects[e];if(!this.needsFullUpdate&&!f.needsRegularUpdate){continue}f.needsUpdate=true}return this},updateElements:function(f){var e,g;f=JXG.getRef(this,f);for(e in this.objects){g=this.objects[e];if(f==null||g.id!=f.id){g.update(true)}else{g.update(false)}}return this},updateRenderer:function(f){var e,g;if(this.options.renderer=="canvas"){this.updateRendererCanvas(f)}else{for(e in this.objects){g=this.objects[e];g.updateRenderer()}}return this},updateRendererCanvas:function(j){var e,m,h,g=this.options.layer,l=this.options.layer.numlayers,n=Number.NEGATIVE_INFINITY,k,f;for(h=0;hn&&g[f]1?Array.prototype.slice.call(arguments,1):[];if(!JXG.exists(f)){f=["update"]}if(!JXG.isArray(f)){f=[f]}e=f.length;h=this.hooks.length;for(k=0;k=0;e--){if(this.dependentBoards[e]==f){this.dependentBoards.splice(e,1)}}return this},update:function(h){var g,f,j,e;if(this.inUpdate||this.isSuspendedUpdate){return this}this.inUpdate=true;this.prepareUpdate(h).updateElements(h).updateConditions();this.renderer.suspendRedraw(this);this.updateRenderer(h);this.renderer.unsuspendRedraw();this.updateHooks();f=this.dependentBoards.length;for(g=0;g-o){t=-B;p.applyOnce(k)}else{if(t>B&&t0){r=setInterval(this.rolling,f)}return this};this.stop=function(){clearInterval(r);return this};return this};return new e()}});JXG.Options={showCopyright:true,showNavigation:true,takeSizeFromFile:false,renderer:"svg",takeFirst:false,pan:true,zoom:{factorX:1.25,factorY:1.25,wheel:false},jc:{enabled:true,compile:true},navbar:{strokeColor:"#aaaaaa",fillColor:"#f5f5f5",padding:"2px",position:"absolute",fontSize:"10px",cursor:"pointer",zIndex:"100",right:"5px",bottom:"5px"},elements:{strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",fillColor:"red",highlightFillColor:"none",strokeOpacity:1,highlightStrokeOpacity:1,fillOpacity:1,highlightFillOpacity:1,strokeWidth:2,highlightStrokeWidth:2,fixed:false,frozen:false,withLabel:false,visible:true,layer:0,dash:0,shadow:false,trace:false,traceAttributes:{},highlight:true,needsRegularUpdate:true,draft:{draft:false,strokeColor:"#565656",fillColor:"#565656",strokeOpacity:0.8,fillOpacity:0.8,strokeWidth:1}},ticks:{drawLabels:false,drawZero:false,insertTicks:false,minTicksDistance:50,minorHeight:4,majorHeight:10,minorTicks:4,ticksDistance:1,strokeOpacity:1,strokeWidth:1,strokeColor:"black",highlightStrokeColor:"#888888"},precision:{touch:30,mouse:4,epsilon:0.0001,hasPoint:4},layer:{numlayers:20,text:9,point:9,arc:8,line:7,circle:6,curve:5,turtle:5,polygon:3,sector:3,angle:3,integral:3,axis:2,grid:1,image:0,trace:0},angle:{withLabel:true,radius:1,type:"auto",fillColor:"#FF7F00",highlightFillColor:"#FF7F00",strokeColor:"#FF7F00",fillOpacity:0.3,highlightFillOpacity:0.3,radiuspoint:{withLabel:false,visible:false,name:""},pointsquare:{withLabel:false,visible:false,name:""},dot:{visible:false,strokeColor:"none",fillColor:"black",size:2,face:"o",withLabel:false,name:""},label:{strokeColor:"#0000FF"}},arc:{firstArrow:false,lastArrow:false,fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",useDirection:false},axis:{needsRegularUpdate:false,strokeWidth:1,strokeColor:"#666666",highlightStrokeWidth:1,highlightStrokeColor:"#888888",withTicks:true,straightFirst:true,straightLast:true,lastArrow:true,withLabel:false,ticks:{needsRegularUpdate:false,strokeWidth:1,strokeColor:"#666666",highlightStrokeColor:"#888888",drawLabels:true,drawZero:false,insertTicks:true,minTicksDistance:10,minorHeight:4,majorHeight:-1,minorTicks:4,ticksDistance:1,strokeOpacity:0.25},point1:{needsRegularUpdate:false},point2:{needsRegularUpdate:false},label:{position:"lft",offsets:[10,-20]}},bisector:{strokeColor:"#000000",point:{visible:false,fixed:false,withLabel:false,name:""}},bisectorlines:{line1:{strokeColor:"red"},line2:{strokeColor:"black"}},chart:{chartStyle:"line",colors:["#B02B2C","#3F4C6B","#C79810","#D15600","#FFFF88","#C3D9FF","#4096EE","#008C00"],highlightcolors:null,fillcolor:null,highlightonsector:false,highlightbysize:false},circle:{fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",center:{visible:false,withLabel:false,fixed:false,name:""},label:{position:"ulft"}},circumcircle:{fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",center:{visible:false,fixed:false,withLabel:false,name:""}},circumcirclearc:{fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",center:{visible:false,withLabel:false,fixed:false,name:""}},circumcirclesector:{useDirection:true,fillColor:"#00FF00",highlightFillColor:"#00FF00",fillOpacity:0.3,highlightFillOpacity:0.3,strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",point:{visible:false,fixed:false,withLabel:false,name:""}},conic:{fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",foci:{fixed:false,visible:false,withLabel:false,name:""}},curve:{strokeWidth:1,strokeColor:"#0000ff",fillColor:"none",handDrawing:false,curveType:null,RDPsmoothing:false,numberPointsHigh:1600,numberPointsLow:400,doAdvancedPlot:true,label:{position:"lft"}},glider:{},grid:{needsRegularUpdate:false,hasGrid:false,gridX:1,gridY:1,strokeColor:"#C0C0C0",strokeOpacity:"0.5",strokeWidth:1,dash:0,snapToGrid:false,snapSizeX:10,snapSizeY:10},image:{imageString:null,fillOpacity:1},incircle:{fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#C3D9FF",center:{visible:false,fixed:false,withLabel:false,name:""}},integral:{withLabel:true,strokeWidth:0,strokeOpacity:0,fillOpacity:0.8,curveLeft:{visible:true,layer:9},baseLeft:{visible:false,fixed:false,withLabel:false,name:""},curveRight:{visible:true,layer:9},baseRight:{visible:false,fixed:false,withLabel:false,name:""},label:{fontSize:20}},label:{strokeColor:"black",fixed:true,position:"urt",offsets:[10,10]},legend:{style:"vertical",labels:["1","2","3","4","5","6","7","8"],colors:["#B02B2C","#3F4C6B","#C79810","#D15600","#FFFF88","#C3D9FF","#4096EE","#008C00"]},line:{firstArrow:false,lastArrow:false,straightFirst:true,straightLast:true,fillColor:"none",highlightFillColor:"none",strokeColor:"#0000ff",highlightStrokeColor:"#888888",withTicks:false,point1:{visible:false,withLabel:false,fixed:false,name:""},point2:{visible:false,withLabel:false,fixed:false,name:""},ticks:{drawLabels:true,drawZero:false,insertTicks:false,minTicksDistance:50,maxTicksDistance:300,minorHeight:4,majorHeight:-1,minorTicks:4,defaultDistance:1,strokeOpacity:0.3},label:{position:"llft"}},locus:{translateToOrigin:false,translateTo10:false,stretch:false,toOrigin:null,to10:null},normal:{strokeColor:"#000000",point:{visible:false,fixed:false,withLabel:false,name:""}},orthogonalprojection:{},parallel:{strokeColor:"#000000",point:{visible:false,fixed:false,withLabel:false,name:""}},perpendicular:{strokeColor:"#000000",straightFirst:true,straightLast:true},perpendicularsegment:{strokeColor:"#000000",straightFirst:false,straightLast:false,point:{visible:false,fixed:true,withLabel:false,name:""}},point:{withLabel:true,style:5,face:"o",size:3,fillColor:"#ff0000",highlightFillColor:"#EEEEEE",strokeWidth:2,strokeColor:"#ff0000",highlightStrokeColor:"#C3D9FF",zoom:false,showInfobox:true,draft:false,attractors:[],attractorDistance:0,snatchDistance:0,snapToGrid:false,snapSizeX:1,snapSizeY:1,snapToPoints:false},polygon:{hasInnerPoints:false,fillColor:"#00FF00",highlightFillColor:"#00FF00",fillOpacity:0.3,highlightFillOpacity:0.3,withLines:true,borders:{withLabel:false,strokeWidth:1,highlightStrokeWidth:1,layer:5},vertices:{withLabel:true,strokeColor:"#ff0000",fillColor:"#ff0000",fixed:true},label:{offsets:[0,0]}},riemannsum:{withLabel:false,fillOpacity:0.3,fillColor:"#ffff00"},sector:{fillColor:"#00FF00",highlightFillColor:"#00FF00",fillOpacity:0.3,highlightFillOpacity:0.3},semicircle:{midpoint:{visible:false,withLabel:false,fixed:false,name:""}},slider:{snapWidth:-1,precision:2,firstArrow:false,lastArrow:false,withTicks:true,withLabel:true,layer:9,showInfobox:false,name:"",visible:true,strokeColor:"#000000",highlightStrokeColor:"#888888",fillColor:"#ffffff",highlightFillColor:"none",size:6,point1:{needsRegularUpdate:false,showInfobox:false,withLabel:false,visible:false,fixed:true,name:""},point2:{needsRegularUpdate:false,showInfobox:false,withLabel:false,visible:false,fixed:true,name:""},baseline:{needsRegularUpdate:false,name:"",strokeWidth:1,strokeColor:"#000000",highlightStrokeColor:"#888888"},ticks:{needsRegularUpdate:false,drawLabels:false,drawZero:true,insertTicks:true,minorHeight:4,majorHeight:10,minorTicks:0,defaultDistance:1,strokeOpacity:1,strokeWidth:1,strokeColor:"#000000"},highline:{strokeWidth:3,name:"",strokeColor:"#000000",highlightStrokeColor:"#888888"},label:{strokeColor:"#000000"}},text:{fontSize:12,digits:2,isLabel:false,strokeColor:"#000000",useASCIIMathML:false,useMathJax:false,display:"html",cssClass:"JXGtext",highlightCssClass:"JXGtext",withLabel:false},tracecurve:{strokeColor:"#000000",fillColor:"none",numberPoints:100},turtle:{strokeWidth:1,fillColor:"none",strokeColor:"#000000",arrow:{strokeWidth:2,withLabel:false,strokeColor:"#ff0000"}},shortcuts:{color:["strokeColor","fillColor"],opacity:["strokeOpacity","fillOpacity"],highlightColor:["highlightStrokeColor","highlightFillColor"],highlightOpacity:["highlightStrokeOpacity","highlightFillOpacity"],strokeWidth:["strokeWidth","highlightStrokeWidth"]}};JXG.Validator=(function(){var l=function(i){return/^[0-9]+px$/.test(i)},n=function(i){return(i in {html:0,internal:0})},o=function(i){return JXG.isString(i)},m=function(i){return JXG.exists(JXG.Point.prototype.normalizeFace.call(this,i))},q=function(i){return(Math.abs(i-Math.round(i))0},j=function(i){return i.length>=2&&q(i[0])&&q(i[1])},e=function(i){return(i in {vml:0,svg:0,canvas:0})},k=function(i){return i>0},h=function(i){return !(i<0)},g,p={},f={attractorDistance:h,color:o,defaultDistance:JXG.isNumber,display:n,doAdvancedPlot:false,draft:false,drawLabels:false,drawZero:false,face:m,factor:JXG.isNumber,fillColor:o,fillOpacity:JXG.isNumber,firstArrow:false,fontSize:q,dash:q,gridX:JXG.isNumber,gridY:JXG.isNumber,hasGrid:false,highlightFillColor:o,highlightFillOpacity:JXG.isNumber,highlightStrokeColor:o,highlightStrokeOpacity:JXG.isNumber,insertTicks:false,lastArrow:false,majorHeight:q,maxTicksDistance:r,minorHeight:q,minorTicks:r,minTicksDistance:r,numberPointsHigh:r,numberPointsLow:r,opacity:JXG.isNumber,radius:JXG.isNumber,RDPsmoothing:false,renderer:e,right:l,showCopyright:false,showInfobox:false,showNavigation:false,size:q,snapSizeX:k,snapSizeY:k,snapWidth:JXG.isNumber,snapToGrid:false,snatchDistance:h,straightFirst:false,straightLast:false,stretch:false,strokeColor:o,strokeOpacity:JXG.isNumber,strokeWidth:q,takeFirst:false,takeSizeFromFile:false,to10:false,toOrigin:false,translateTo10:false,translateToOrigin:false,useASCIIMathML:false,useDirection:false,useMathJax:false,withLabel:false,withTicks:false,zoom:false};for(g in f){p[g.toLowerCase()]=f[g]}return p})();JXG.useStandardOptions=function(i){var k=JXG.Options,h=i.hasGrid,g,f,j,e;i.options.grid.hasGrid=k.grid.hasGrid;i.options.grid.gridX=k.grid.gridX;i.options.grid.gridY=k.grid.gridY;i.options.grid.gridColor=k.grid.gridColor;i.options.grid.gridOpacity=k.grid.gridOpacity;i.options.grid.gridDash=k.grid.gridDash;i.options.grid.snapToGrid=k.grid.snapToGrid;i.options.grid.snapSizeX=k.grid.SnapSizeX;i.options.grid.snapSizeY=k.grid.SnapSizeY;i.takeSizeFromFile=k.takeSizeFromFile;e=function(l,m){l.visProp.fillcolor=m.fillColor;l.visProp.highlightfillcolor=m.highlightFillColor;l.visProp.strokecolor=m.strokeColor;l.visProp.highlightstrokecolor=m.highlightStrokeColor};for(g in i.objects){j=i.objects[g];if(j.elementClass==JXG.OBJECT_CLASS_POINT){e(j,k.point)}else{if(j.elementClass==JXG.OBJECT_CLASS_LINE){e(j,k.line);for(f in j.ticks){f.majorTicks=k.line.ticks.majorTicks;f.minTicksDistance=k.line.ticks.minTicksDistance;f.visProp.minorheight=k.line.ticks.minorHeight;f.visProp.majorheight=k.line.ticks.majorHeight}}else{if(j.elementClass==JXG.OBJECT_CLASS_CIRCLE){e(j,k.circle)}else{if(j.type==JXG.OBJECT_TYPE_ANGLE){e(j,k.angle)}else{if(j.type==JXG.OBJECT_TYPE_ARC){e(j,k.arc)}else{if(j.type==JXG.OBJECT_TYPE_POLYGON){e(j,k.polygon)}else{if(j.type==JXG.OBJECT_TYPE_CONIC){e(j,k.conic)}else{if(j.type==JXG.OBJECT_TYPE_CURVE){e(j,k.curve)}else{if(j.type==JXG.OBJECT_TYPE_SECTOR){j.arc.visProp.fillcolor=k.sector.fillColor;j.arc.visProp.highlightfillcolor=k.sector.highlightFillColor;j.arc.visProp.fillopacity=k.sector.fillOpacity;j.arc.visProp.highlightfillopacity=k.sector.highlightFillOpacity}}}}}}}}}}i.fullUpdate();if(h&&!i.hasGrid){i.removeGrids(i)}else{if(!h&&i.hasGrid){i.create("grid",[])}}};JXG.useBlackWhiteOptions=function(e){var f=JXG.Options;f.point.fillColor=JXG.rgb2bw(f.point.fillColor);f.point.highlightFillColor=JXG.rgb2bw(f.point.highlightFillColor);f.point.strokeColor=JXG.rgb2bw(f.point.strokeColor);f.point.highlightStrokeColor=JXG.rgb2bw(f.point.highlightStrokeColor);f.line.fillColor=JXG.rgb2bw(f.line.fillColor);f.line.highlightFillColor=JXG.rgb2bw(f.line.highlightFillColor);f.line.strokeColor=JXG.rgb2bw(f.line.strokeColor);f.line.highlightStrokeColor=JXG.rgb2bw(f.line.highlightStrokeColor);f.circle.fillColor=JXG.rgb2bw(f.circle.fillColor);f.circle.highlightFillColor=JXG.rgb2bw(f.circle.highlightFillColor);f.circle.strokeColor=JXG.rgb2bw(f.circle.strokeColor);f.circle.highlightStrokeColor=JXG.rgb2bw(f.circle.highlightStrokeColor);f.arc.fillColor=JXG.rgb2bw(f.arc.fillColor);f.arc.highlightFillColor=JXG.rgb2bw(f.arc.highlightFillColor);f.arc.strokeColor=JXG.rgb2bw(f.arc.strokeColor);f.arc.highlightStrokeColor=JXG.rgb2bw(f.arc.highlightStrokeColor);f.polygon.fillColor=JXG.rgb2bw(f.polygon.fillColor);f.polygon.highlightFillColor=JXG.rgb2bw(f.polygon.highlightFillColor);f.sector.fillColor=JXG.rgb2bw(f.sector.fillColor);f.sector.highlightFillColor=JXG.rgb2bw(f.sector.highlightFillColor);f.curve.strokeColor=JXG.rgb2bw(f.curve.strokeColor);f.grid.gridColor=JXG.rgb2bw(f.grid.gridColor);JXG.useStandardOptions(e)};JXG.JSXGraph={licenseText:"JSXGraph v0.94 Copyright (C) see http://jsxgraph.org",boards:{},elements:{},rendererType:(function(){var g,e;if(JXG.supportsSVG()){JXG.Options.renderer="svg"}else{if(JXG.supportsVML()){JXG.Options.renderer="vml";function f(){document.body.scrollLeft;document.body.scrollTop}document.onmousemove=f}else{JXG.Options.renderer="canvas"}}e=JXG.rendererFiles[JXG.Options.renderer].split(",");for(g=0;g0){this.board=i;this.type=h;this.elementClass=j||JXG.OBJECT_CLASS_OTHER;this.id=e.id;f=e.name;if(!JXG.exists(f)){f=this.board.generateName(this)}this.board.elementsByName[f]=this;this.name=f;this.needsRegularUpdate=e.needsregularupdate;JXG.clearVisPropOld(this);e=this.resolveShortcuts(e);for(g in e){this._set(g,e[g])}this.visProp.draft=e.draft&&e.draft.draft;this.visProp.gradientangle="270";this.visProp.gradientsecondopacity=this.visProp.fillopacity;this.visProp.gradientpositionx=0.5;this.visProp.gradientpositiony=0.5}};JXG.extend(JXG.GeometryElement.prototype,{addChild:function(g){var f,e;this.childElements[g.id]=g;this.addDescendants(g);g.ancestors[this.id]=this;for(f in this.descendants){this.descendants[f].ancestors[this.id]=this;for(e in this.ancestors){this.descendants[f].ancestors[this.ancestors[e].id]=this.ancestors[e]}}for(f in this.ancestors){for(e in this.descendants){this.ancestors[f].descendants[this.descendants[e].id]=this.descendants[e]}}return this},addDescendants:function(f){var e;this.descendants[f.id]=f;for(e in f.childElements){this.addDescendants(f.childElements[e])}return this},countChildren:function(){var g,e=0,f;f=this.childElements;for(g in f){if(f.hasOwnProperty(g)&&g.indexOf("Label")<0){e++}}return e},getName:function(){return this.name},draggable:function(){return this.isDraggable&&!this.visProp.fixed&&!this.visProp.frozen&&this.type!=JXG.OBJECT_TYPE_GLIDER},generatePolynomial:function(){return[]},animate:function(h,g,q){q=q||{};var e,f,k=35,l=Math.ceil(g/(k*1)),j,n=this;this.animationData={};var o=function(w,v,t){var u,s,r,p,i;u=JXG.rgb2hsv(w);s=JXG.rgb2hsv(v);r=(s[0]-u[0])/(1*l);p=(s[1]-u[1])/(1*l);i=(s[2]-u[2])/(1*l);n.animationData[t]=new Array(l);for(j=0;j=0&&JXG.isString(e)&&e.length==9&&e.charAt(0)==="#"){e=JXG.rgba2rgbo(e);this.visProp[f]=e[0];this.visProp[f.replace("color","opacity")]=e[1]}else{this.visProp[f]=e}},resolveShortcuts:function(g){var f,e;for(f in JXG.Options.shortcuts){if(JXG.exists(g[f])){for(e=0;e/g,">");if(this.label!==null){this.label.content.setText(e)}return this},setAttribute:JXG.shortcut(JXG.GeometryElement.prototype,"setProperty"),setProperty:function(){var j,h,k,e,f,l,g={};for(j=0;j-1){this.eventHandlers[g].splice(e,1)}}else{this.eventHandlers[g].length=0}},removeEvent:JXG.shortcut(JXG.GeometryElement.prototype,"off")});JXG.COORDS_BY_USER=1;JXG.COORDS_BY_SCREEN=2;JXG.Coords=function(g,f,e){this.board=e;this.usrCoords=[];this.scrCoords=[];this.setCoordinates(g,f)};JXG.extend(JXG.Coords.prototype,{normalizeUsrCoords:function(){var e=JXG.Math.eps;if(Math.abs(this.usrCoords[0])>e){this.usrCoords[1]/=this.usrCoords[0];this.usrCoords[2]/=this.usrCoords[0];this.usrCoords[0]=1}},usr2screen:function(i){var h=Math.round,e=this.board,g=this.usrCoords,f=e.origin.scrCoords;if(i===null||i){this.scrCoords[0]=h(g[0]);this.scrCoords[1]=h(g[0]*f[1]+g[1]*e.unitX);this.scrCoords[2]=h(g[0]*f[2]-g[2]*e.unitY)}else{this.scrCoords[0]=g[0];this.scrCoords[1]=g[0]*f[1]+g[1]*e.unitX;this.scrCoords[2]=g[0]*f[2]-g[2]*e.unitY}},screen2usr:function(){var g=this.board.origin.scrCoords,f=this.scrCoords,e=this.board;this.usrCoords[0]=1;this.usrCoords[1]=(f[1]-g[1])/e.unitX;this.usrCoords[2]=(g[2]-f[2])/e.unitY},distance:function(g,k){var h=0,l,e=this.usrCoords,j=this.scrCoords,i;if(g===JXG.COORDS_BY_USER){l=k.usrCoords;i=e[0]-l[0];h=i*i;if(h>JXG.Math.eps){return Number.POSITIVE_INFINITY}i=e[1]-l[1];h+=i*i;i=e[2]-l[2];h+=i*i}else{l=k.scrCoords;i=j[1]-l[1];h+=i*i;i=j[2]-l[2];h+=i*i}return Math.sqrt(h)},setCoordinates:function(f,i,g){var e=this.usrCoords,h=this.scrCoords;if(f===JXG.COORDS_BY_USER){if(i.length===2){e[0]=1;e[1]=i[0];e[2]=i[1]}else{e[0]=i[0];e[1]=i[1];e[2]=i[2];this.normalizeUsrCoords()}this.usr2screen(g)}else{h[1]=i[0];h[2]=i[1];this.screen2usr()}return this}});JXG.Point=function(f,g,e){this.constructor(f,e,JXG.OBJECT_TYPE_POINT,JXG.OBJECT_CLASS_POINT);if(g==null){g=[0,0]}this.coords=new JXG.Coords(JXG.COORDS_BY_USER,g,this.board);this.initialCoords=new JXG.Coords(JXG.COORDS_BY_USER,g,this.board);this.position=null;this.onPolygon=false;this.slideObject=null;this.Xjc=null;this.Yjc=null;this.methodMap=JXG.deepCopy(this.methodMap,{move:"moveTo",glide:"makeGlider",X:"X",Y:"Y",free:"free",setPosition:"setGliderPosition"});this.group=[];this.elType="point";this.id=this.board.setId(this,"P");this.board.renderer.drawPoint(this);this.board.finalizeAdding(this);this.createLabel()};JXG.Point.prototype=new JXG.GeometryElement();JXG.extend(JXG.Point.prototype,{hasPoint:function(f,h){var e=this.coords.scrCoords,g;g=parseFloat(this.visProp.size);if(g1){for(h=0;h0&&Math.abs(this._smax-this._smin)>=JXG.Math.eps){if(this.position<0){this.position=0}if(this.position>1){this.position=1}f=this.position*(this._smax-this._smin)+this._smin;f=Math.round(f/this.visProp.snapwidth)*this.visProp.snapwidth;this.position=(f-this._smin)/(this._smax-this._smin);this.update(true)}e=this.slideObject.point1.coords.usrCoords;if(!this.slideObject.visProp.straightfirst&&Math.abs(e[0])>JXG.Math.eps&&this.position<0){this.coords.setCoordinates(JXG.COORDS_BY_USER,e);this.position=0}g=this.slideObject.point2.coords.usrCoords;if(!this.slideObject.visProp.straightlast&&Math.abs(g[0])>JXG.Math.eps&&this.position>1){this.coords.setCoordinates(JXG.COORDS_BY_USER,g);this.position=1}}else{if(this.slideObject.type==JXG.OBJECT_TYPE_TURTLE){this.updateConstraint();this.coords=JXG.Math.Geometry.projectPointToTurtle(this,this.slideObject,this.board)}else{if(this.slideObject.elementClass==JXG.OBJECT_CLASS_CURVE){this.updateConstraint();this.coords=JXG.Math.Geometry.projectPointToCurve(this,this.slideObject,this.board)}else{if(this.slideObject.elementClass==JXG.OBJECT_CLASS_POINT){this.coords=JXG.Math.Geometry.projectPointToPoint(this,this.slideObject,this.board)}}}}}},updateGliderFromParent:function(){var e,f,g,h;if(this.slideObject.elementClass==JXG.OBJECT_CLASS_CIRCLE){g=this.slideObject.Radius();this.coords.setCoordinates(JXG.COORDS_BY_USER,[this.slideObject.center.X()+g*Math.cos(this.position),this.slideObject.center.Y()+g*Math.sin(this.position)])}else{if(this.slideObject.elementClass==JXG.OBJECT_CLASS_LINE){e=this.slideObject.point1.coords;f=this.slideObject.point2.coords;h=e.distance(JXG.COORDS_BY_USER,f);e=e.usrCoords.slice(0);f=f.usrCoords.slice(0);if(h==Number.POSITIVE_INFINITY){h=1/JXG.Math.eps;if(Math.abs(f[0])JXG.Math.eps)?this.isReal:false;if(this.isReal){if(e!=this.isReal){this.board.renderer.show(this);if(this.hasLabel&&this.label.content.visProp.visible){this.board.renderer.show(this.label.content)}}this.board.renderer.updatePoint(this)}else{if(e!=this.isReal){this.board.renderer.hide(this);if(this.hasLabel&&this.label.content.visProp.visible){this.board.renderer.hide(this.label.content)}}}}if(this.hasLabel&&this.visProp.visible&&this.label.content&&this.label.content.visProp.visible&&this.isReal){this.label.content.update();this.board.renderer.updateText(this.label.content)}this.needsUpdate=false;return this},X:function(){return this.coords.usrCoords[1]},Y:function(){return this.coords.usrCoords[2]},Z:function(){return this.coords.usrCoords[0]},XEval:function(){return this.coords.usrCoords[1]},YEval:function(){return this.coords.usrCoords[2]},ZEval:function(){return this.coords.usrCoords[0]},bounds:function(){return this.coords.usrCoords.slice(1).concat(this.coords.usrCoords.slice(1))},Dist:function(g){var h,j=g.coords.usrCoords,e=this.coords.usrCoords,i;i=e[0]-j[0];h=i*i;i=e[1]-j[1];h+=i*i;i=e[2]-j[2];h+=i*i;return Math.sqrt(h)},handleSnapToGrid:function(){var e,h,g=this.visProp.snapsizex,f=this.visProp.snapsizey;if(this.visProp.snaptogrid){e=this.coords.usrCoords[1];h=this.coords.usrCoords[2];if(g<=0&&this.board.defaultAxes&&this.board.defaultAxes.x.defaultTicks){g=this.board.defaultAxes.x.defaultTicks.ticksDelta*(this.board.defaultAxes.x.defaultTicks.visProp.minorticks+1)}if(f<=0&&this.board.defaultAxes&&this.board.defaultAxes.y.defaultTicks){f=this.board.defaultAxes.y.defaultTicks.ticksDelta*(this.board.defaultAxes.y.defaultTicks.visProp.minorticks+1)}if(g>0&&f>0){this.coords=new JXG.Coords(JXG.COORDS_BY_USER,[Math.round(e/g)*g,Math.round(h/f)*f],this.board)}}return this},handleSnapToPoints:function(){var g,j,e,h=0,f=Infinity,i=null;if(this.visProp.snaptopoints){for(g in this.board.objects){j=this.board.objects[g];if(j.elementClass==JXG.OBJECT_CLASS_POINT&&j!==this&&j.visProp.visible){e=JXG.Math.Geometry.projectPointToPoint(this,j,this.board);h=e.distance(JXG.COORDS_BY_USER,this.coords);if(h=this.visProp.snatchdistance){this.type=JXG.OBJECT_TYPE_POINT}}}return this},setPositionDirectly:function(e,l,j){var h,o,n,g,f,k=this.coords,m;this.coords=new JXG.Coords(e,[l,j],this.board);this.handleSnapToGrid();this.handleSnapToPoints();this.handleAttractors();if(this.group.length!=0){o=this.coords.usrCoords[1]-k.usrCoords[1];n=this.coords.usrCoords[2]-k.usrCoords[2];for(h=0;h=0;h--){if(e==JXG.COORDS_BY_SCREEN){m=(new JXG.Coords(e,[l,j],this.board)).usrCoords}else{m=[1,l,j]}this.initialCoords=new JXG.Coords(JXG.COORDS_BY_USER,JXG.Math.matVecMult(JXG.Math.inverse(this.transformations[h].matrix),m),this.board)}this.update()}return this},setPositionByTransform:function(h,e,g){var f=this.board.create("transform",[e,g],{type:"translate"});if(this.transformations.length>0&&this.transformations[this.transformations.length-1].isNumericMatrix){this.transformations[this.transformations.length-1].melt(f)}else{this.addTransform(this,f)}if(this.group.length==0){this.update()}return this},setPosition:function(g,e,f){this.setPositionDirectly(g,e,f);return this},setGliderPosition:function(e){if(this.type=JXG.OBJECT_TYPE_GLIDER){this.position=e;this.board.update()}return this},makeGlider:function(e){this.slideObject=JXG.getRef(this.board,e);this.type=JXG.OBJECT_TYPE_GLIDER;this.elType="glider";this.visProp.snapwidth=-1;this.slideObject.addChild(this);this.isDraggable=true;this.generatePolynomial=function(){return this.slideObject.generatePolynomial(this)};this.updateGlider();return this},free:function(){var e;if(this.type!==JXG.OBJECT_TYPE_GLIDER){if(!this.isDraggable){this.isDraggable=true;this.type=JXG.OBJECT_TYPE_POINT;this.XEval=function(){return this.coords.usrCoords[1]};this.YEval=function(){return this.coords.usrCoords[2]};this.ZEval=function(){return this.coords.usrCoords[0]};this.Xjc=null;this.Yjc=null}else{return}}for(e in this.ancestors){delete this.ancestors[e].descendants[this.id];delete this.ancestors[e].childElements[this.id]}this.ancestors=[];this.slideObject=null;this.elType="point";this.type=JXG.OBJECT_TYPE_POINT},addConstraint:function(j){this.type=JXG.OBJECT_TYPE_CAS;var l=[],e,h,f,g,k=["X","Y"];this.isDraggable=false;for(h=0;h"){return Math.pow(Math.sin((r/(n*1))*Math.PI/2),2)}return r/n};if(Math.abs(j)=0;k--){o[n-k]=[f+j*p(k),e+h*p(k)]}this.animationPath=o;this.animationCallback=q.callback;this.board.addAnimation(this);return this},visit:function(n,g,s){if(typeof s=="number"){s={repeat:s}}else{s=s||{};if(typeof s.repeat=="undefined"){s.repeat=1}}var o=35,p=Math.ceil(g/(o*s.repeat)),q=new Array(s.repeat*(p+1)),f=this.coords.usrCoords[1],e=this.coords.usrCoords[2],l=(n[0]-f),h=(n[1]-e),m,k,r=function(t){var j=(t

"){return Math.pow(Math.sin((j)*Math.PI/2),2)}return j};for(k=0;k=0;m--){q[k*(p+1)+p-m]=[f+l*r(m),e+h*r(m)]}}this.animationPath=q;this.animationCallback=s.callback;this.board.addAnimation(this);return this},_anim:function(o,j){var f,m,k,i,h,g,n=1,e,l;this.intervalCount++;if(this.intervalCount>j){this.intervalCount=0}if(this.slideObject.elementClass==JXG.OBJECT_CLASS_LINE){f=this.slideObject.point1.coords.distance(JXG.COORDS_BY_SCREEN,this.slideObject.point2.coords);m=this.slideObject.getSlope();if(m!="INF"){h=Math.atan(m);k=Math.round((this.intervalCount/j)*f*Math.cos(h));i=Math.round((this.intervalCount/j)*f*Math.sin(h))}else{k=0;i=Math.round((this.intervalCount/j)*f)}if(o<0){g=this.slideObject.point2;if(this.slideObject.point2.coords.scrCoords[1]-this.slideObject.point1.coords.scrCoords[1]>0){n=-1}else{if(this.slideObject.point2.coords.scrCoords[1]-this.slideObject.point1.coords.scrCoords[1]==0){if(this.slideObject.point2.coords.scrCoords[2]-this.slideObject.point1.coords.scrCoords[2]>0){n=-1}}}}else{g=this.slideObject.point1;if(this.slideObject.point1.coords.scrCoords[1]-this.slideObject.point2.coords.scrCoords[1]>0){n=-1}else{if(this.slideObject.point1.coords.scrCoords[1]-this.slideObject.point2.coords.scrCoords[1]==0){if(this.slideObject.point1.coords.scrCoords[2]-this.slideObject.point2.coords.scrCoords[2]>0){n=-1}}}}this.coords.setCoordinates(JXG.COORDS_BY_SCREEN,[g.coords.scrCoords[1]+n*k,g.coords.scrCoords[2]+n*i])}else{if(this.slideObject.elementClass==JXG.OBJECT_CLASS_CURVE){if(o>0){e=Math.round(this.intervalCount/j*this.board.canvasWidth)}else{e=Math.round((j-this.intervalCount)/j*this.board.canvasWidth)}this.coords.setCoordinates(JXG.COORDS_BY_SCREEN,[e,0]);this.coords=JXG.Math.Geometry.projectPointToCurve(this,this.slideObject,this.board)}else{if(this.slideObject.elementClass==JXG.OBJECT_CLASS_CIRCLE){if(o<0){h=this.intervalCount/j*2*Math.PI}else{h=(j-this.intervalCount)/j*2*Math.PI}l=this.slideObject.Radius();this.coords.setCoordinates(JXG.COORDS_BY_USER,[this.slideObject.center.coords.usrCoords[1]+l*Math.cos(h),this.slideObject.center.coords.usrCoords[2]+l*Math.sin(h)])}}}this.board.update(this);return this},setStyle:function(e){var f=["cross","cross","cross","circle","circle","circle","circle","square","square","square","plus","plus","plus"],g=[2,3,4,1,2,3,4,2,3,4,2,3,4];this.visProp.face=f[e];this.visProp.size=g[e];this.board.renderer.changePointStyle(this);return this},normalizeFace:function(e){var f={cross:"x",x:"x",circle:"o",o:"o",square:"[]","[]":"[]",plus:"+","+":"+",diamond:"<>","<>":"<>",triangleup:"^",a:"^","^":"^",triangledown:"v",v:"v",triangleleft:"<","<":"<",triangleright:">",">":">"};return f[e]},remove:function(){if(this.hasLabel){this.board.renderer.remove(this.board.renderer.getElementById(this.label.content.id))}this.board.renderer.remove(this.board.renderer.getElementById(this.id))},getTextAnchor:function(){return this.coords},getLabelAnchor:function(){return this.coords},face:function(e){this.setProperty({face:e})},size:function(e){this.setProperty({size:e})},cloneToBackground:function(){var e={};e.id=this.id+"T"+this.numTraces;this.numTraces++;e.coords=this.coords;e.visProp=JXG.deepCopy(this.visProp,this.visProp.traceattributes,true);e.visProp.layer=this.board.options.layer.trace;e.elementClass=JXG.OBJECT_CLASS_POINT;e.board=this.board;JXG.clearVisPropOld(e);this.board.renderer.drawPoint(e);this.traces[e.id]=e.rendNode;return this},getParents:function(){var e=[this.Z(),this.X(),this.Y()];if(this.parents){e=this.parents}if(this.type==JXG.OBJECT_TYPE_GLIDER){e=[this.X(),this.Y(),this.slideObject.id]}return e}});JXG.createPoint=function(l,h,g){var k,f=false,j,e;e=JXG.copyAttributes(g,l.options,"point");for(j=0;j=3){if(f.length==3){f.push(null)}g=h.create("point",[h.intersection(f[0],f[1],f[2],f[3])],e)}f[0].addChild(g);f[1].addChild(g);g.elType="intersection";g.parents=[f[0].id,f[1].id,f[2]];if(f[3]!=null){g.parents.push(f[3])}g.generatePolynomial=function(){var i=f[0].generatePolynomial(g);var j=f[1].generatePolynomial(g);if((i.length==0)||(j.length==0)){return[]}else{return[i[0],j[0]]}};return g};JXG.createOtherIntersectionPoint=function(h,f,e){var g;if(f.length!=3||!JXG.isPoint(f[2])||(f[0].elementClass!=JXG.OBJECT_CLASS_LINE&&f[0].elementClass!=JXG.OBJECT_CLASS_CIRCLE)||(f[1].elementClass!=JXG.OBJECT_CLASS_LINE&&f[1].elementClass!=JXG.OBJECT_CLASS_CIRCLE)){throw new Error("JSXGraph: Can't create 'other intersection point' with parent types '"+(typeof f[0])+"', '"+(typeof f[1])+"'and '"+(typeof f[2])+"'.\nPossible parent types: [circle|line,circle|line,point]")}else{g=h.create("point",[h.otherIntersection(f[0],f[1],f[2])],e)}g.elType="otherintersection";g.parents=[f[0].id,f[1].id,f[2]];f[0].addChild(g);f[1].addChild(g);g.generatePolynomial=function(){var i=f[0].generatePolynomial(g);var j=f[1].generatePolynomial(g);if((i.length==0)||(j.length==0)){return[]}else{return[i[0],j[0]]}};return g};JXG.JSXGraph.registerElement("point",JXG.createPoint);JXG.JSXGraph.registerElement("glider",JXG.createGlider);JXG.JSXGraph.registerElement("intersection",JXG.createIntersectionPoint);JXG.JSXGraph.registerElement("otherintersection",JXG.createOtherIntersectionPoint);JXG.Line=function(f,h,g,e){this.constructor(f,e,JXG.OBJECT_TYPE_LINE,JXG.OBJECT_CLASS_LINE);this.point1=JXG.getReference(this.board,h);this.point2=JXG.getReference(this.board,g);this.ticks=[];this.defaultTicks=null;this.parentPolygon=null;this.id=this.board.setId(this,"L");this.board.renderer.drawLine(this);this.board.finalizeAdding(this);this.elType="line";this.createLabel();this.point1.addChild(this);this.point2.addChild(this);this.updateStdform()};JXG.Line.prototype=new JXG.GeometryElement;JXG.extend(JXG.Line.prototype,{hasPoint:function(l,k){var h=[],o,n=[1,l,k],m,p,g,f,j,e;h[0]=this.stdform[0]-this.stdform[1]*this.board.origin.scrCoords[1]/this.board.unitX+this.stdform[2]*this.board.origin.scrCoords[2]/this.board.unitY;h[1]=this.stdform[1]/this.board.unitX;h[2]=this.stdform[2]/(-this.board.unitY);m=[0,h[1],h[2]];m=JXG.Math.crossProduct(m,n);m=JXG.Math.crossProduct(m,h);m[1]/=m[0];m[2]/=m[0];m[0]=1;o=(n[1]-m[1])*(n[1]-m[1])+(n[2]-m[2])*(n[2]-m[2]);if(isNaN(o)||o>this.board.options.precision.hasPoint*this.board.options.precision.hasPoint){return false}if(this.visProp.straightfirst&&this.visProp.straightlast){return true}else{p=this.point1.coords;g=this.point2.coords;m=(new JXG.Coords(JXG.COORDS_BY_SCREEN,m.slice(1),this.board)).usrCoords;f=p.distance(JXG.COORDS_BY_USER,g);p=p.usrCoords.slice(0);g=g.usrCoords.slice(0);if(f1){return false}return true}},update:function(){var h,f,e,j,g,m,l,k,i;if(!this.needsUpdate){return this}if(this.constrained){if(typeof this.funps!="undefined"){h=this.funps();if(h&&h.length&&h.length===2){this.point1=h[0];this.point2=h[1]}}else{if(typeof this.funp1==="function"){h=this.funp1();if(JXG.isPoint(h)){this.point1=h}else{if(h&&h.length&&h.length===2){this.point1.setPositionDirectly(JXG.COORDS_BY_USER,h[0],h[1])}}}if(typeof this.funp2==="function"){h=this.funp2();if(JXG.isPoint(h)){this.point2=h}else{if(h&&h.length&&h.length===2){this.point2.setPositionDirectly(JXG.COORDS_BY_USER,h[0],h[1])}}}}}this.updateSegmentFixedLength();this.updateStdform();if(this.visProp.trace){this.cloneToBackground(true)}return this},updateSegmentFixedLength:function(){if(!this.hasFixedLength){return this}d=this.point1.Dist(this.point2);dnew=this.fixedLength();d1=this.fixedLengthOldCoords[0].distance(JXG.COORDS_BY_USER,this.point1.coords);d2=this.fixedLengthOldCoords[1].distance(JXG.COORDS_BY_USER,this.point2.coords);if(d1>JXG.Math.eps||d2>JXG.Math.eps||d!=dnew){drag1=this.point1.isDraggable&&(this.point1.type!=JXG.OBJECT_TYPE_GLIDER)&&!this.point1.visProp.fixed;drag2=this.point2.isDraggable&&(this.point2.type!=JXG.OBJECT_TYPE_GLIDER)&&!this.point2.visProp.fixed;if(d>JXG.Math.eps){if((d1>d2&&drag2)||(d1<=d2&&drag2&&!drag1)){this.point2.setPositionDirectly(JXG.COORDS_BY_USER,this.point1.X()+(this.point2.X()-this.point1.X())*dnew/d,this.point1.Y()+(this.point2.Y()-this.point1.Y())*dnew/d);this.point2.prepareUpdate().updateRenderer()}else{if((d1<=d2&&drag1)||(d1>d2&&drag1&&!drag2)){this.point1.setPositionDirectly(JXG.COORDS_BY_USER,this.point2.X()+(this.point1.X()-this.point2.X())*dnew/d,this.point2.Y()+(this.point1.Y()-this.point2.Y())*dnew/d);this.point1.prepareUpdate().updateRenderer()}}}else{x=Math.random()-0.5;y=Math.random()-0.5;d=Math.sqrt(x*x+y*y);if(drag2){this.point2.setPositionDirectly(JXG.COORDS_BY_USER,this.point1.X()+x*dnew/d,this.point1.Y()+y*dnew/d);this.point2.prepareUpdate().updateRenderer()}else{if(drag1){this.point1.setPositionDirectly(JXG.COORDS_BY_USER,this.point2.X()+x*dnew/d,this.point2.Y()+y*dnew/d);this.point1.prepareUpdate().updateRenderer()}}}this.fixedLengthOldCoords[0].setCoordinates(JXG.COORDS_BY_USER,this.point1.coords.usrCoords);this.fixedLengthOldCoords[1].setCoordinates(JXG.COORDS_BY_USER,this.point2.coords.usrCoords)}return this},updateStdform:function(){var e=JXG.Math.crossProduct(this.point1.coords.usrCoords,this.point2.coords.usrCoords);this.stdform[0]=e[0];this.stdform[1]=e[1];this.stdform[2]=e[2];this.stdform[3]=0;this.normalize()},updateRenderer:function(){var e;if(this.needsUpdate&&this.visProp.visible){e=this.isReal;this.isReal=(!isNaN(this.point1.coords.usrCoords[1]+this.point1.coords.usrCoords[2]+this.point2.coords.usrCoords[1]+this.point2.coords.usrCoords[2])&&(JXG.Math.innerProduct(this.stdform,this.stdform,3)>=JXG.Math.eps*JXG.Math.eps));if(this.isReal){if(e!=this.isReal){this.board.renderer.show(this);if(this.hasLabel&&this.label.content.visProp.visible){this.board.renderer.show(this.label.content)}}this.board.renderer.updateLine(this)}else{if(e!=this.isReal){this.board.renderer.hide(this);if(this.hasLabel&&this.label.content.visProp.visible){this.board.renderer.hide(this.label.content)}}}this.needsUpdate=false}if(this.hasLabel&&this.label.content.visProp.visible&&this.isReal){this.label.content.update();this.board.renderer.updateText(this.label.content)}return this},generatePolynomial:function(i){var h=this.point1.symbolic.x,g=this.point1.symbolic.y,k=this.point2.symbolic.x,j=this.point2.symbolic.y,f=i.symbolic.x,e=i.symbolic.y;return[["(",g,")*(",f,")-(",g,")*(",k,")+(",e,")*(",k,")-(",h,")*(",e,")+(",h,")*(",j,")-(",f,")*(",j,")"].join("")]},getRise:function(){if(Math.abs(this.stdform[2])>=JXG.Math.eps){return -this.stdform[0]/this.stdform[2]}else{return Infinity}},getSlope:function(){if(Math.abs(this.stdform[2])>=JXG.Math.eps){return -this.stdform[1]/this.stdform[2]}else{return Infinity}},getAngle:function(){return Math.atan2(this.point2.Y()-this.point1.Y(),this.point2.X()-this.point1.X())},setStraight:function(e,f){this.visProp.straightfirst=e;this.visProp.straightlast=f;this.board.renderer.updateLine(this);return this},getTextAnchor:function(){return new JXG.Coords(JXG.COORDS_BY_USER,[0.5*(this.point2.X()+this.point1.X()),0.5*(this.point2.Y()+this.point1.Y())],this.board)},setLabelRelativeCoords:function(e){if(JXG.exists(this.label.content)){this.label.content.relativeCoords=new JXG.Coords(JXG.COORDS_BY_SCREEN,[e[0],-e[1]],this.board)}},getLabelAnchor:function(){var g,f,e,j,i=0,h=0,g=new JXG.Coords(JXG.COORDS_BY_USER,this.point1.coords.usrCoords,this.board);f=new JXG.Coords(JXG.COORDS_BY_USER,this.point2.coords.usrCoords,this.board);if(this.visProp.straightfirst||this.visProp.straightlast){JXG.Math.Geometry.calcStraight(this,g,f)}g=g.scrCoords;f=f.scrCoords;switch(this.label.content.visProp.position){case"lft":case"llft":case"ulft":if(g[1]<=f[1]){e=g[1];j=g[2]}else{e=f[1];j=f[2]}break;case"rt":case"lrt":case"urt":if(g[1]>f[1]){e=g[1];j=g[2]}else{e=f[1];j=f[2]}break;default:e=0.5*(g[1]+f[1]);j=0.5*(g[2]+f[2])}if(this.visProp.straightfirst||this.visProp.straightlast){if(JXG.exists(this.label.content)){i=parseFloat(this.label.content.visProp.offsets[0]);h=parseFloat(this.label.content.visProp.offsets[1])}if(Math.abs(e)0&&this.point1.transformations[this.point1.transformations.length-1].isNumericMatrix){this.point1.transformations[this.point1.transformations.length-1].melt(f)}else{this.point1.addTransform(this.point1,f)}if(this.point2.transformations.length>0&&this.point2.transformations[this.point2.transformations.length-1].isNumericMatrix){this.point2.transformations[this.point2.transformations.length-1].melt(f)}else{this.point2.addTransform(this.point2,f)}return this},setPositionDirectly:function(l,e,k,j,i){var g=e-j,f=k-i;if(!this.point1.draggable()||!this.point2.draggable()){return this}g/=this.board.unitX;f/=-this.board.unitY;var h=this.board.create("transform",[g,f,0],{type:"translate"});h.applyOnce([this.point1,this.point2]);return this},X:function(g){var f=this.stdform[2],e;e=(Math.abs(this.point1.coords.usrCoords[0])>JXG.Math.eps)?this.point1.coords.usrCoords[1]:this.point2.coords.usrCoords[1];g=(g-0.5)*2;if(g<0){g*=(-1);return(1-g)*e+g*f}else{return(1-g)*e-g*f}},Y:function(f){var e=this.stdform[1],g;g=(Math.abs(this.point1.coords.usrCoords[0])>JXG.Math.eps)?this.point1.coords.usrCoords[2]:this.point2.coords.usrCoords[2];f=(f-0.5)*2;if(f<0){f*=(-1);return(1-f)*g-f*e}else{return(1-f)*g+f*e}},Z:function(e){var f=(Math.abs(this.point1.coords.usrCoords[0])>JXG.Math.eps)?this.point1.coords.usrCoords[0]:this.point2.coords.usrCoords[0];e=(e-0.5)*2;if(e<0){e*=(-1)}return(1-e)*f},L:function(){return this.point1.Dist(this.point2)},minX:function(){return 0},maxX:function(){return 1},bounds:function(){var e=this.point1.coords.usrCoords,f=this.point2.coords.usrCoords;return[Math.min(e[1],f[1]),Math.max(e[2],f[2]),Math.max(e[1],f[1]),Math.min(e[2],f[2])]},addTicks:function(e){if(e.id==""||typeof e.id=="undefined"){e.id=this.id+"_ticks_"+(this.ticks.length+1)}this.board.renderer.drawTicks(e);this.ticks.push(e);return e.id},removeAllTicks:function(){var f,e;for(e=this.ticks.length;e>0;e--){this.removeTicks(this.ticks[e-1])}this.ticks=new Array();this.board.update()},removeTicks:function(g){var f,e;if(this.defaultTicks!=null&&this.defaultTicks==g){this.defaultTicks=null}for(f=this.ticks.length;f>0;f--){if(this.ticks[f-1]==g){this.board.removeObject(this.ticks[f-1]);for(e=0;e1){m=JXG.copyAttributes(j,l.options,"line","point1");q=l.create("point",o[0],m)}else{if(JXG.isString(o[0])||o[0].elementClass==JXG.OBJECT_CLASS_POINT){q=JXG.getReference(l,o[0])}else{if((typeof o[0]=="function")&&(o[0]().elementClass==JXG.OBJECT_CLASS_POINT)){q=o[0]();h=true}else{if((typeof o[0]=="function")&&(o[0]().length&&o[0]().length===2)){m=JXG.copyAttributes(j,l.options,"line","point1");q=JXG.createPoint(l,o[0](),m);h=true}else{throw new Error("JSXGraph: Can't create line with parent types '"+(typeof o[0])+"' and '"+(typeof o[1])+"'.\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]")}}}}if(JXG.isArray(o[1])&&o[1].length>1){m=JXG.copyAttributes(j,l.options,"line","point2");p=l.create("point",o[1],m)}else{if(JXG.isString(o[1])||o[1].elementClass==JXG.OBJECT_CLASS_POINT){p=JXG.getReference(l,o[1])}else{if((typeof o[1]=="function")&&(o[1]().elementClass==JXG.OBJECT_CLASS_POINT)){p=o[1]();h=true}else{if((typeof o[1]=="function")&&(o[1]().length&&o[1]().length===2)){m=JXG.copyAttributes(j,l.options,"line","point2");p=JXG.createPoint(l,o[1](),m);h=true}else{throw new Error("JSXGraph: Can't create line with parent types '"+(typeof o[0])+"' and '"+(typeof o[1])+"'.\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]")}}}}m=JXG.copyAttributes(j,l.options,"line");g=new JXG.Line(l,q,p,m);if(h){g.constrained=true;g.funp1=o[0];g.funp2=o[1]}else{g.isDraggable=true}if(!g.constrained){g.parents=[q.id,p.id]}}else{if(o.length==3){f=true;for(k=0;k<3;k++){if(typeof o[k]=="number"){n[k]=function(i){return function(){return i}}(o[k])}else{if(typeof o[k]=="function"){n[k]=o[k];f=false}else{throw new Error("JSXGraph: Can't create line with parent types '"+(typeof o[0])+"' and '"+(typeof o[1])+"' and '"+(typeof o[2])+"'.\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]")}}}m=JXG.copyAttributes(j,l.options,"line","point1");if(f){q=l.create("point",[n[2]()*n[2]()+n[1]()*n[1](),n[2]()-n[1]()*n[0]()+n[2](),-n[1]()-n[2]()*n[0]()-n[1]()],m)}else{q=l.create("point",[function(){return(0+n[2]()*n[2]()+n[1]()*n[1]())*0.5},function(){return(n[2]()-n[1]()*n[0]()+n[2]())*0.5},function(){return(-n[1]()-n[2]()*n[0]()-n[1]())*0.5}],m)}m=JXG.copyAttributes(j,l.options,"line","point2");if(f){p=l.create("point",[n[2]()*n[2]()+n[1]()*n[1](),-n[1]()*n[0]()+n[2](),-n[2]()*n[0]()-n[1]()],m)}else{p=l.create("point",[function(){return n[2]()*n[2]()+n[1]()*n[1]()},function(){return -n[1]()*n[0]()+n[2]()},function(){return -n[2]()*n[0]()-n[1]()}],m)}q.prepareUpdate().update();p.prepareUpdate().update();m=JXG.copyAttributes(j,l.options,"line");g=new JXG.Line(l,q,p,m);g.isDraggable=f;if(f){g.parents=[n[0](),n[1](),n[2]()]}}else{if((o.length==1)&&(typeof o[0]=="function")&&(o[0]().length==2)&&(o[0]()[0].elementClass==JXG.OBJECT_CLASS_POINT)&&(o[0]()[1].elementClass==JXG.OBJECT_CLASS_POINT)){var e=o[0]();m=JXG.copyAttributes(j,l.options,"line");g=new JXG.Line(l,e[0],e[1],m);g.constrained=true;g.funps=o[0]}else{if((o.length==1)&&(typeof o[0]=="function")&&(o[0]().length==3)&&(typeof o[0]()[0]==="number")&&(typeof o[0]()[1]==="number")&&(typeof o[0]()[2]==="number")){e=o[0];m=JXG.copyAttributes(j,l.options,"line","point1");q=l.create("point",[function(){var i=e();return[(0+i[2]*i[2]+i[1]*i[1])*0.5,(i[2]-i[1]*i[0]+i[2])*0.5,(-i[1]-i[2]*i[0]-i[1])*0.5]}],m);m=JXG.copyAttributes(j,l.options,"line","point2");p=l.create("point",[function(){var i=e();return[i[2]*i[2]+i[1]*i[1],-i[1]*i[0]+i[2],-i[2]*i[0]-i[1]]}],m);m=JXG.copyAttributes(j,l.options,"line");g=new JXG.Line(l,q,p,m);g.constrained=true;g.funps=o[0]}else{throw new Error("JSXGraph: Can't create line with parent types '"+(typeof o[0])+"' and '"+(typeof o[1])+"'.\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]")}}}}return g};JXG.JSXGraph.registerElement("line",JXG.createLine);JXG.createSegment=function(j,f,e){var h,g;e.straightFirst=false;e.straightLast=false;h=j.create("line",f.slice(0,2),e);if(f.length==3){h.hasFixedLength=true;if(JXG.isNumber(f[2])){h.fixedLength=function(){return f[2]}}else{if(JXG.isFunction(f[2])){h.fixedLength=f[2]}else{throw new Error("JSXGraph: Can't create segment with third parent type '"+(typeof f[2])+"'.\nPossible third parent types: number or function")}}h.fixedLengthOldCoords=[];h.fixedLengthOldCoords[0]=new JXG.Coords(JXG.COORDS_BY_USER,h.point1.coords.usrCoords.slice(1,3),j);h.fixedLengthOldCoords[1]=new JXG.Coords(JXG.COORDS_BY_USER,h.point2.coords.usrCoords.slice(1,3),j)}h.elType="segment";return h};JXG.JSXGraph.registerElement("segment",JXG.createSegment);JXG.createArrow=function(h,f,e){var g;g=h.create("line",f,e).setStraight(false,false);g.setArrow(false,true);g.type=JXG.OBJECT_TYPE_VECTOR;g.elType="arrow";return g};JXG.JSXGraph.registerElement("arrow",JXG.createArrow);JXG.createAxis=function(j,g,f){var e,i,k;if((JXG.isArray(g[0])||JXG.isPoint(g[0]))&&(JXG.isArray(g[1])||JXG.isPoint(g[1]))){e=JXG.copyAttributes(f,j.options,"axis");i=j.create("line",g,e);i.type=JXG.OBJECT_TYPE_AXIS;i.isDraggable=false;i.point1.isDraggable=false;i.point2.isDraggable=false;for(var h in i.ancestors){i.ancestors[h].type=JXG.OBJECT_TYPE_AXISPOINT}e=JXG.copyAttributes(f,j.options,"axis","ticks");if(JXG.exists(e.ticksdistance)){k=e.ticksdistance}else{if(JXG.isArray(e.ticks)){k=e.ticks}else{k=1}}i.defaultTicks=j.create("ticks",[i,k],e);i.defaultTicks.dump=false;i.elType="axis";i.subs={ticks:i.defaultTicks}}else{throw new Error("JSXGraph: Can't create point with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"'.\nPossible parent types: [point,point], [[x1,y1],[x2,y2]]")}return i};JXG.JSXGraph.registerElement("axis",JXG.createAxis);JXG.createTangent=function(q,s,l){var e,r,n,o,m,k,h,t;if(s.length==1){e=s[0];r=e.slideObject}else{if(s.length==2){if(JXG.isPoint(s[0])){e=s[0];r=s[1]}else{if(JXG.isPoint(s[1])){r=s[0];e=s[1]}else{throw new Error("JSXGraph: Can't create tangent with parent types '"+(typeof s[0])+"' and '"+(typeof s[1])+"'.\nPossible parent types: [glider], [point,line|curve|circle|conic]")}}}else{throw new Error("JSXGraph: Can't create tangent with parent types '"+(typeof s[0])+"' and '"+(typeof s[1])+"'.\nPossible parent types: [glider], [point,line|curve|circle|conic]")}}if(r.elementClass==JXG.OBJECT_CLASS_LINE){t=q.create("line",[r.point1,r.point2],l)}else{if(r.elementClass==JXG.OBJECT_CLASS_CURVE&&!(r.type==JXG.OBJECT_TYPE_CONIC)){if(r.visProp.curvetype!="plot"){n=r.X;o=r.Y;t=q.create("line",[function(){return -e.X()*q.D(o)(e.position)+e.Y()*q.D(n)(e.position)},function(){return q.D(o)(e.position)},function(){return -q.D(n)(e.position)}],l);e.addChild(t);t.glider=e}else{t=q.create("line",[function(){m=Math.floor(e.position);if(m==r.numberPoints-1){m--}if(m<0){return 1}return r.Y(m)*r.X(m+1)-r.X(m)*r.Y(m+1)},function(){m=Math.floor(e.position);if(m==r.numberPoints-1){m--}if(m<0){return 0}return r.Y(m+1)-r.Y(m)},function(){m=Math.floor(e.position);if(m==r.numberPoints-1){m--}if(m<0){return 0}return r.X(m)-r.X(m+1)}],l);e.addChild(t);t.glider=e}}else{if(r.type==JXG.OBJECT_TYPE_TURTLE){t=q.create("line",[function(){m=Math.floor(e.position);for(k=0;k1){e=JXG.copyAttributes(f,l.options,"circle","center");m[j]=l.create("point",g[j],e)}else{m[j]=g[j]}}}e=JXG.copyAttributes(f,l.options,"circle");if(g.length==2&&JXG.isPoint(m[0])&&JXG.isPoint(m[1])){k=new JXG.Circle(l,"twoPoints",m[0],m[1],e)}else{if((JXG.isNumber(m[0])||JXG.isFunction(m[0])||JXG.isString(m[0]))&&JXG.isPoint(m[1])){k=new JXG.Circle(l,"pointRadius",m[1],m[0],e)}else{if((JXG.isNumber(m[1])||JXG.isFunction(m[1])||JXG.isString(m[1]))&&JXG.isPoint(m[0])){k=new JXG.Circle(l,"pointRadius",m[0],m[1],e)}else{if((m[0].elementClass==JXG.OBJECT_CLASS_CIRCLE)&&JXG.isPoint(m[1])){k=new JXG.Circle(l,"pointCircle",m[1],m[0],e)}else{if((m[1].elementClass==JXG.OBJECT_CLASS_CIRCLE)&&JXG.isPoint(m[0])){k=new JXG.Circle(l,"pointCircle",m[0],m[1],e)}else{if((m[0].elementClass==JXG.OBJECT_CLASS_LINE)&&JXG.isPoint(m[1])){k=new JXG.Circle(l,"pointLine",m[1],m[0],e)}else{if((m[1].elementClass==JXG.OBJECT_CLASS_LINE)&&JXG.isPoint(m[0])){k=new JXG.Circle(l,"pointLine",m[0],m[1],e)}else{if(g.length==3&&JXG.isPoint(m[0])&&JXG.isPoint(m[1])&&JXG.isPoint(m[2])){k=JXG.createCircumcircle(l,m,f)}else{throw new Error("JSXGraph: Can't create circle with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"'.\nPossible parent types: [point,point], [point,number], [point,function], [point,circle], [point,point,point]")}}}}}}}}k.isDraggable=h;k.parents=[];for(j=0;j1){s[l]=o.create("point",q[l],k)}else{if(JXG.isPoint(q[l])){s[l]=JXG.getReference(o,q[l])}else{if((typeof q[l]=="function")&&(q[l]().elementClass===JXG.OBJECT_CLASS_POINT)){s[l]=q[l]()}else{if(JXG.isString(q[l])){s[l]=JXG.getReference(o,q[l])}else{throw new Error("JSXGraph: Can't create Ellipse with parent types '"+(typeof q[0])+"' and '"+(typeof q[1])+"'.\nPossible parent types: [point,point,point], [point,point,number|function]")}}}}}if(JXG.isNumber(q[2])){e=JXG.createFunction(q[2],o)}else{if((typeof q[2]=="function")&&(JXG.isNumber(q[2]()))){e=q[2]}else{if(JXG.isPoint(q[2])){f=JXG.getReference(o,q[2])}else{if(q[2].length>1){f=o.create("point",q[2],k)}else{if((typeof q[2]=="function")&&(q[2]().elementClass==JXG.OBJECT_CLASS_POINT)){f=q[2]()}else{if(JXG.isString(q[2])){f=JXG.getReference(o,q[2])}else{throw new Error("JSXGraph: Can't create Ellipse with parent types '"+(typeof q[0])+"' and '"+(typeof q[1])+"' and '"+(typeof q[2])+"'.\nPossible parent types: [point,point,point], [point,point,number|function]")}}}}e=function(){return f.Dist(s[0])+f.Dist(s[1])}}}if(typeof q[4]=="undefined"){q[4]=1.0001*Math.PI}if(typeof q[3]=="undefined"){q[3]=-1.0001*Math.PI}var p=o.create("point",[function(){return(s[0].X()+s[1].X())*0.5},function(){return(s[0].Y()+s[1].Y())*0.5}],k);var r=function(){var i=s[0].X(),C=s[0].Y(),z=s[1].X(),w=s[1].Y(),B,A,v;var u=(z-i>0)?1:-1;if(Math.abs(z-i)>1e-7){B=Math.atan2(w-C,z-i)+((u<0)?Math.PI:0)}else{B=((w-C>0)?0.5:-0.5)*Math.PI}A=Math.cos(B);v=Math.sin(B);var t=[[1,0,0],[p.X(),A,-v],[p.Y(),v,A]];return t};var g=o.create("curve",[function(i){return 0},function(i){return 0},q[3],q[4]],n);var h=function(v,t){var B=e()*0.5,i=B*B,u=s[1].Dist(s[0])*0.5,w=i-u*u,A=Math.sqrt(w),z=[[1,0,0],[0,1,0],[0,0,1]],D,C;if(!t){m=r();D=p.X();C=p.Y();z[0][0]=m[0][0];z[0][1]=0;z[0][2]=0;z[1][0]=D*(1-m[1][1])+C*m[1][2];z[1][1]=m[1][1];z[1][2]=m[2][1];z[2][0]=C*(1-m[1][1])-D*m[1][2];z[2][1]=m[1][2];z[2][2]=m[2][2];g.quadraticform=JXG.Math.matMatMult(JXG.Math.transpose(z),JXG.Math.matMatMult([[-1+D*D/(B*B)+C*C/w,-D/i,-D/w],[-D/i,1/i,0],[-C/w,0,1/w]],z))}return JXG.Math.matVecMult(m,[1,B*Math.cos(v),A*Math.sin(v)])};g.X=function(i,t){return h(i,t)[1]};g.Y=function(i,t){return h(i,t)[2]};g.midpoint=p;g.type=JXG.OBJECT_TYPE_CONIC;return g};JXG.createHyperbola=function(o,q,j){var s=[],f,e,l,m,k=JXG.copyAttributes(j,o.options,"conic","foci"),n=JXG.copyAttributes(j,o.options,"conic");for(l=0;l<2;l++){if(q[l].length>1){s[l]=o.create("point",q[l],attr_focu)}else{if(JXG.isPoint(q[l])){s[l]=JXG.getReference(o,q[l])}else{if((typeof q[l]=="function")&&(q[l]().elementClass==JXG.OBJECT_CLASS_POINT)){s[l]=q[l]()}else{if(JXG.isString(q[l])){s[l]=JXG.getReference(o,q[l])}else{throw new Error("JSXGraph: Can't create Hyperbola with parent types '"+(typeof q[0])+"' and '"+(typeof q[1])+"'.\nPossible parent types: [point,point,point], [point,point,number|function]")}}}}}if(JXG.isNumber(q[2])){e=JXG.createFunction(q[2],o)}else{if((typeof q[2]=="function")&&(JXG.isNumber(q[2]()))){e=q[2]}else{if(JXG.isPoint(q[2])){f=JXG.getReference(o,q[2])}else{if(q[2].length>1){f=o.create("point",q[2],k)}else{if((typeof q[2]=="function")&&(q[2]().elementClass==JXG.OBJECT_CLASS_POINT)){f=q[2]()}else{if(JXG.isString(q[2])){f=JXG.getReference(o,q[2])}else{throw new Error("JSXGraph: Can't create Hyperbola with parent types '"+(typeof q[0])+"' and '"+(typeof q[1])+"' and '"+(typeof q[2])+"'.\nPossible parent types: [point,point,point], [point,point,number|function]")}}}}e=function(){return f.Dist(s[0])-f.Dist(s[1])}}}if(typeof q[4]=="undefined"){q[4]=1.0001*Math.PI}if(typeof q[3]=="undefined"){q[3]=-1.0001*Math.PI}var p=o.create("point",[function(){return(s[0].X()+s[1].X())*0.5},function(){return(s[0].Y()+s[1].Y())*0.5}],k);var r=function(){var u=s[0].X(),t=s[0].Y(),A=s[1].X(),w=s[1].Y(),v;var z=(A-u>0)?1:-1;if(Math.abs(A-u)>1e-7){v=Math.atan2(w-t,A-u)+((z<0)?Math.PI:0)}else{v=((w-t>0)?0.5:-0.5)*Math.PI}var i=[[1,0,0],[p.X(),Math.cos(v),-Math.sin(v)],[p.Y(),Math.sin(v),Math.cos(v)]];return i};var g=o.create("curve",[function(i){return 0},function(i){return 0},q[3],q[4]],n);var h=function(v,t){var B=e()*0.5,i=B*B,u=s[1].Dist(s[0])*0.5,A=Math.sqrt(-B*B+u*u),w=A*A,z=[[1,0,0],[0,1,0],[0,0,1]],D,C;if(!t){m=r();D=p.X();C=p.Y();z[0][0]=m[0][0];z[0][1]=0;z[0][2]=0;z[1][0]=D*(1-m[1][1])+C*m[1][2];z[1][1]=m[1][1];z[1][2]=m[2][1];z[2][0]=C*(1-m[1][1])-D*m[1][2];z[2][1]=m[1][2];z[2][2]=m[2][2];g.quadraticform=JXG.Math.matMatMult(JXG.Math.transpose(z),JXG.Math.matMatMult([[-1+D*D/i+C*C/w,-D/i,C/w],[-D/i,1/i,0],[C/w,0,-1/w]],z))}return JXG.Math.matVecMult(m,[1,B/Math.cos(v),A*Math.tan(v)])};g.X=function(i,t){return h(i,t)[1]};g.Y=function(i,t){return h(i,t)[2]};g.midpoint=p;g.type=JXG.OBJECT_TYPE_CONIC;return g};JXG.createParabola=function(n,p,h){var m=p[0],f=p[1],j,i=JXG.copyAttributes(h,n.options,"conic","foci"),k=JXG.copyAttributes(h,n.options,"conic");if(p[0].length>1){m=n.create("point",p[0],i)}else{if(JXG.isPoint(p[0])){m=JXG.getReference(n,p[0])}else{if((typeof p[0]=="function")&&(p[0]().elementClass==JXG.OBJECT_CLASS_POINT)){m=p[0]()}else{if(JXG.isString(p[0])){m=JXG.getReference(n,p[0])}else{throw new Error("JSXGraph: Can't create Parabola with parent types '"+(typeof p[0])+"' and '"+(typeof p[1])+"'.\nPossible parent types: [point,line]")}}}}if(typeof p[3]=="undefined"){p[3]=10}if(typeof p[2]=="undefined"){p[2]=-10}var o=n.create("point",[function(){var l=[0,f.stdform[1],f.stdform[2]];l=JXG.Math.crossProduct(l,m.coords.usrCoords);return JXG.Math.Geometry.meetLineLine(l,f.stdform,0,n).usrCoords}],i);var q=function(){var s=Math.atan(f.getSlope()),r=(o.X()+m.X())*0.5,t=(o.Y()+m.Y())*0.5;s+=(m.Y()-o.Y()<0||(m.Y()==o.Y()&&m.X()>o.X()))?Math.PI:0;var l=[[1,0,0],[r*(1-Math.cos(s))+t*Math.sin(s),Math.cos(s),-Math.sin(s)],[t*(1-Math.cos(s))-r*Math.sin(s),Math.sin(s),Math.cos(s)]];return l};var e=n.create("curve",[function(l){return 0},function(l){return 0},p[2],p[3]],k);var g=function(u,v){var w=o.Dist(m)*0.5,s=[[1,0,0],[0,1,0],[0,0,1]],r=(o.X()+m.X())*0.5,l=(o.Y()+m.Y())*0.5;if(!v){j=q();s[0][0]=j[0][0];s[0][1]=0;s[0][2]=0;s[1][0]=r*(1-j[1][1])+l*j[1][2];s[1][1]=j[1][1];s[1][2]=j[2][1];s[2][0]=l*(1-j[1][1])-r*j[1][2];s[2][1]=j[1][2];s[2][2]=j[2][2];e.quadraticform=JXG.Math.matMatMult(JXG.Math.transpose(s),JXG.Math.matMatMult([[-l*4*w-r*r,r,2*w],[r,-1,0],[2*w,0,0]],s))}return JXG.Math.matVecMult(j,[1,u+r,u*u/(w*4)+l])};e.X=function(l,r){return g(l,r)[1]};e.Y=function(l,r){return g(l,r)[2]};e.type=JXG.OBJECT_TYPE_CONIC;return e};JXG.createConic=function(f,z,h){var k=[[1,0,0],[0,1,0],[0,0,1]],E,C,B,A,g=[[1,0,0],[0,1,0],[0,0,1]],q,o,u=[],v,s,D,n=[],t=JXG.copyAttributes(h,f.options,"conic","foci"),r=JXG.copyAttributes(h,f.options,"conic");if(z.length==5){D=true}else{if(z.length==6){D=false}else{throw new Error("JSXGraph: Can't create generic Conic with "+parent.length+" parameters.")}}if(D){for(v=0;v<5;v++){if(z[v].length>1){u[v]=f.create("point",z[v],t)}else{if(JXG.isPoint(z[v])){u[v]=JXG.getReference(f,z[v])}else{if((typeof z[v]=="function")&&(z[v]().elementClass==JXG.OBJECT_CLASS_POINT)){u[v]=z[v]()}else{if(JXG.isString(z[v])){u[v]=JXG.getReference(f,z[v])}else{throw new Error("JSXGraph: Can't create Conic section with parent types '"+(typeof z[v])+"'.\nPossible parent types: [point,point,point,point,point], [a00,a11,a22,a01,a02,a12]")}}}}}}else{s=[[0,0,0],[0,0,0],[0,0,0]];s[0][0]=(JXG.isFunction(z[2]))?function(){return z[2]()}:function(){return z[2]};s[0][1]=(JXG.isFunction(z[4]))?function(){return z[4]()}:function(){return z[4]};s[0][2]=(JXG.isFunction(z[5]))?function(){return z[5]()}:function(){return z[5]};s[1][1]=(JXG.isFunction(z[0]))?function(){return z[0]()}:function(){return z[0]};s[1][2]=(JXG.isFunction(z[3]))?function(){return z[3]()}:function(){return z[3]};s[2][2]=(JXG.isFunction(z[1]))?function(){return z[1]()}:function(){return z[1]}}var j=function(p){var G,F;for(G=0;G<3;G++){for(F=G;F<3;F++){p[G][F]+=p[F][G]}}for(G=0;G<3;G++){for(F=0;FH){g[G][H]=g[H][G]}}}}l.quadraticform=g;E=JXG.Math.Numerics.Jacobi(g);if(E[0][0][0]<0){E[0][0][0]*=(-1);E[0][1][1]*=(-1);E[0][2][2]*=(-1)}for(H=0;H<3;H++){p=0;for(G=0;G<3;G++){p+=E[1][G][H]*E[1][G][H]}p=Math.sqrt(p);for(G=0;G<3;G++){}}k=E[1];A=Math.sqrt(Math.abs(E[0][0][0]));C=Math.sqrt(Math.abs(E[0][1][1]));B=Math.sqrt(Math.abs(E[0][2][2]))}if(E[0][1][1]<=0&&E[0][2][2]<=0){F=JXG.Math.matVecMult(k,[1/A,Math.cos(I)/C,Math.sin(I)/B])}else{if(E[0][1][1]<=0&&E[0][2][2]>0){F=JXG.Math.matVecMult(k,[Math.cos(I)/A,1/C,Math.sin(I)/B])}else{if(E[0][2][2]<0){F=JXG.Math.matVecMult(k,[Math.sin(I)/A,Math.cos(I)/C,1/B])}}}F[1]/=F[0];F[2]/=F[0];F[0]=1;return F};l.X=function(i,p){return e(i,p)[1]};l.Y=function(i,p){return e(i,p)[2]};l.midpoint=f.create("point",[function(){var i=l.quadraticform;return[i[1][1]*i[2][2]-i[1][2]*i[1][2],i[1][2]*i[0][2]-i[2][2]*i[0][1],i[0][1]*i[1][2]-i[1][1]*i[0][2]]}],t);l.type=JXG.OBJECT_TYPE_CONIC;return l};JXG.JSXGraph.registerElement("ellipse",JXG.createEllipse);JXG.JSXGraph.registerElement("hyperbola",JXG.createHyperbola);JXG.JSXGraph.registerElement("parabola",JXG.createParabola);JXG.JSXGraph.registerElement("conic",JXG.createConic);JXG.Polygon=function(j,g,f){this.constructor(j,f,JXG.OBJECT_TYPE_POLYGON,JXG.OBJECT_CLASS_AREA);var h,m,e,k=JXG.copyAttributes(f,j.options,"polygon","borders");this.withLines=f.withlines;this.attr_line=k;this.vertices=[];for(h=0;hl)!=(this.vertices[g].coords.scrCoords[2]>l))&&(f<(this.vertices[g].coords.scrCoords[1]-this.vertices[h].coords.scrCoords[1])*(l-this.vertices[h].coords.scrCoords[2])/(this.vertices[g].coords.scrCoords[2]-this.vertices[h].coords.scrCoords[2])+this.vertices[h].coords.scrCoords[1])){k=!k}}}else{e=this.borders.length;for(h=0;he){e=this.vertices[h].X()}if(this.vertices[h].Y()>f){f=this.vertices[h].Y()}if(this.vertices[h].Y()this.vertices.length-2){return this}for(g=1;g-1&&f-1;l--){k[e[l]]=-1;if(this.withLines&&(e[l]-1>e[l-1])){g[g.length-1][1]=e[l];g.push([e[l-1]])}}if(this.withLines){g[g.length-1][1]=e[0]}this.vertices=[];for(l=0;lm.length-1){h=m.length-1}}this.board.removeObject(this.borders[h]);m[h]=-1}if(g[l][1]!==0&&g[l][0]!==k.length-1){m[g[l][0]-1]=JXG.createSegment(this.board,[k[Math.max(g[l][1]-1,0)],k[Math.min(g[l][0]+1,this.vertices.length-1)]],this.attr_line)}}this.borders=[];for(l=0;l=h-2){m.id=m.ids[k-2]}e[k]=o.create("point",[e[k-2],f],m);e[k].type=JXG.OBJECT_TYPE_CAS}}m=JXG.copyAttributes(j,o.options,"polygon");g=o.create("polygon",e,m);g.elType="regularpolygon";return g};JXG.JSXGraph.registerElement("polygon",JXG.createPolygon);JXG.JSXGraph.registerElement("regularpolygon",JXG.createRegularPolygon);JXG.Curve=function(g,f,e){this.constructor(g,e,JXG.OBJECT_TYPE_CURVE,JXG.OBJECT_CLASS_CURVE);this.points=[];this.numberPoints=this.visProp.numberpointshigh;this.dataX=null;this.dataY=null;if(f[0]!=null){this.varname=f[0]}else{this.varname="x"}this.xterm=f[1];this.yterm=f[2];this.generateTerm(this.varname,this.xterm,this.yterm,f[3],f[4]);this.updateCurve();this.id=this.board.setId(this,"G");this.board.renderer.drawCurve(this);this.board.finalizeAdding(this);this.createGradient();this.elType="curve";this.createLabel();if(typeof this.xterm=="string"){this.notifyParents(this.xterm)}if(typeof this.yterm=="string"){this.notifyParents(this.yterm)}};JXG.Curve.prototype=new JXG.GeometryElement;JXG.extend(JXG.Curve.prototype,{minX:function(){if(this.visProp.curvetype=="polar"){return 0}else{var e=new JXG.Coords(JXG.COORDS_BY_SCREEN,[0,0],this.board);return e.usrCoords[1]}},maxX:function(){var e;if(this.visProp.curvetype=="polar"){return 2*Math.PI}else{e=new JXG.Coords(JXG.COORDS_BY_SCREEN,[this.board.canvasWidth,0],this.board);return e.usrCoords[1]}},Z:function(e){return 1},hasPoint:function(r,q){var s,A=Infinity,I,m,C,B,v,u,w,f,J,z,o,G,l,F,h,n,p,E=this.visProp.numberpointslow,H=(this.maxX()-this.minX())/E,e=this.board.options.precision.hasPoint/this.board.unitX,g,D,k=true;e=e*e;g=new JXG.Coords(JXG.COORDS_BY_SCREEN,[r,q],this.board);r=g.usrCoords[1];q=g.usrCoords[2];if(this.visProp.curvetype=="parameter"||this.visProp.curvetype=="polar"||this.visProp.curvetype=="functiongraph"){D=this.transformations.length;for(C=0,s=this.minX();C=JXG.Math.eps){n=G*F+l*h;o=n/p;A=G*G+l*l-o*n}else{o=0;A=G*G+l*l}if(o>=0&&o<=1&&A=JXG.Math.eps){i=(t*j+K*I)/J;if(i>0){if(i<=1){t-=i*j;K-=i*I}else{t-=j;K-=I}}}H=t*t+K*K;return Math.sqrt(H)};if(this.board.updateQuality==this.board.BOARD_QUALITY_LOW){F=15;s=10;k=10}else{F=21;s=0.7;k=0.7}A[0]=e-E;for(v=1;v1){C=l(this.points[u-2].scrCoords,[n,m],this.points[u-1].scrCoords);if(C<0.015){u--}}this.points[u]=new JXG.Coords(JXG.COORDS_BY_SCREEN,[n,m],this.board);this.updateTransform(this.points[u]);u++;B=n;f=m;o=p;q--;n=D[q][0];m=D[q][1];G=h[q]+1;v=w[q]*2}while(q>0&&u<500000);this.numberPoints=this.points.length;return this},isSegmentOutside:function(f,h,e,g){return(h<0&&g<0)||(h>this.board.canvasHeight&&g>this.board.canvasHeight)||(f<0&&e<0)||(f>this.board.canvasWidth&&e>this.board.canvasWidth)},isDistOK:function(g,e,h,f){return(Math.abs(g)0&&this.transformations[this.transformations.length-1].isNumericMatrix){this.transformations[this.transformations.length-1].melt(f)}else{this.addTransform(f)}return this},generateTerm:function(f,j,g,e,k){var i,h;if(JXG.isArray(j)){this.dataX=j;this.X=function(n){var m=parseInt(Math.floor(n)),l,o;if(n<0){m=0}else{if(n>this.dataX.length-2){m=this.dataX.length-2}}if(m==n){return this.dataX[m]}else{l=this.dataX[m];o=this.dataX[m+1];return l+(o-l)*(n-m)}};this.visProp.curvetype="plot";this.numberPoints=this.dataX.length}else{this.X=JXG.createFunction(j,this.board,f);if(JXG.isString(j)){this.visProp.curvetype="functiongraph"}else{if(JXG.isFunction(j)||JXG.isNumber(j)){this.visProp.curvetype="parameter"}}}if(JXG.isArray(g)){this.dataY=g;this.Y=function(n){var m=parseInt(Math.floor(n)),l,o;if(n<0){m=0}else{if(n>this.dataY.length-2){m=this.dataY.length-2}}if(m==n){if(JXG.isFunction(this.dataY[m])){return this.dataY[m]()}else{return this.dataY[m]}}else{if(JXG.isFunction(this.dataY[m])){l=this.dataY[m]()}else{l=this.dataY[m]}if(JXG.isFunction(this.dataY[m+1])){o=this.dataY[m+1]()}else{o=this.dataY[m+1]}return l+(o-l)*(n-m)}}}else{this.Y=JXG.createFunction(g,this.board,f)}if(JXG.isFunction(j)&&JXG.isArray(g)){i=JXG.createFunction(g[0],this.board,"");h=JXG.createFunction(g[1],this.board,"");this.X=function(l){return(j)(l)*Math.cos(l)+i()};this.Y=function(l){return(j)(l)*Math.sin(l)+h()};this.visProp.curvetype="polar"}if(e!=null){this.minX=JXG.createFunction(e,this.board,"")}if(k!=null){this.maxX=JXG.createFunction(k,this.board,"")}},notifyParents:function(e){JXG.GeonextParser.findDependencies(this,e,this.board)},getLabelAnchor:function(){var k,e,j,g=0.05*this.board.canvasWidth,f=0.05*this.board.canvasHeight,i=0.95*this.board.canvasWidth,h=0.95*this.board.canvasHeight;switch(this.visProp.label.position){case"ulft":e=g;j=f;break;case"llft":e=g;j=h;break;case"rt":e=i;j=0.5*h;break;case"lrt":e=i;j=h;break;case"urt":e=i;j=f;break;case"top":e=0.5*i;j=f;break;case"bot":e=0.5*i;j=h;break;case"lft":default:e=g;j=0.5*h;break}k=new JXG.Coords(JXG.COORDS_BY_SCREEN,[e,j],this.board);return JXG.Math.Geometry.projectCoordsToCurve(k.usrCoords[1],k.usrCoords[2],0,this,this.board)[0]},cloneToBackground:function(){var f={},e;f.id=this.id+"T"+this.numTraces;f.elementClass=JXG.OBJECT_CLASS_CURVE;this.numTraces++;f.points=this.points.slice(0);f.numberPoints=this.numberPoints;f.board=this.board;f.visProp=JXG.deepCopy(this.visProp,this.visProp.traceattributes,true);f.visProp.layer=this.board.options.layer.trace;f.visProp.curvetype=this.visProp.curvetype;JXG.clearVisPropOld(f);e=this.board.renderer.enhancedRendering;this.board.renderer.enhancedRendering=true;this.board.renderer.drawCurve(f);this.board.renderer.enhancedRendering=e;this.traces[f.id]=f.rendNode;return this},bounds:function(){var m=this.visProp.numberpointslow,k=(this.maxX()-this.minX())/m,f,e,q,p,l,h,o,n,g=[this.minX(),0,this.maxX(),0];if(this.visProp.curvetype=="parameter"||this.visProp.curvetype=="polar"||this.visProp.curvetype=="functiongraph"){h=this.transformations.length;p=this.minX();for(f=0;fn){g[3]=n}p+=k}}else{if(this.visProp.curvetype=="plot"){h=this.numberPoints;for(f=0;fn){g[3]=n}}}}return g}});JXG.createCurve=function(h,g,f){var e=JXG.copyAttributes(f,h.options,"curve");return new JXG.Curve(h,["x"].concat(g),e)};JXG.JSXGraph.registerElement("curve",JXG.createCurve);JXG.createFunctiongraph=function(i,g,f){var e,h=["x","x"].concat(g);e=JXG.copyAttributes(f,i.options,"curve");e.curvetype="functiongraph";return new JXG.Curve(i,h,e)};JXG.JSXGraph.registerElement("functiongraph",JXG.createFunctiongraph);JXG.JSXGraph.registerElement("plot",JXG.createFunctiongraph);JXG.createSpline=function(g,f,e){var h;h=function(){var k,i=[],l=[];var j=function(p,o){var n,m;if(!o){i=[];l=[];if(f.length==2&&JXG.isArray(f[0])&&JXG.isArray(f[1])&&f[0].length==f[1].length){for(n=0;nJXG.Math.Geometry.rad(this.radiuspoint,this.center,this.anglepoint)){l=false}}return l};j.hasPointSector=function(i,q){var p=new JXG.Coords(JXG.COORDS_BY_SCREEN,[i,q],this.board),m=this.Radius(),o=this.center.coords.distance(JXG.COORDS_BY_USER,p),l=(oJXG.Math.Geometry.rad(this.radiuspoint,this.center,this.anglepoint)){l=false}}return l};j.getTextAnchor=function(){return this.center.coords};j.getLabelAnchor=function(){var m=JXG.Math.Geometry.rad(this.radiuspoint,this.center,this.anglepoint),u=10/(this.board.unitX),s=10/(this.board.unitY),q=this.point2.coords.usrCoords,i=this.center.coords.usrCoords,l=q[1]-i[1],t=q[2]-i[2],r,o,n,p;if(this.label.content!=null){this.label.content.relativeCoords=new JXG.Coords(JXG.COORDS_BY_SCREEN,[0,0],this.board)}r=new JXG.Coords(JXG.COORDS_BY_USER,[i[1]+Math.cos(m*0.5)*l-Math.sin(m*0.5)*t,i[2]+Math.sin(m*0.5)*l+Math.cos(m*0.5)*t],this.board);o=r.usrCoords[1]-i[1];n=r.usrCoords[2]-i[2];p=Math.sqrt(o*o+n*n);o=o*(p+u)/p;n=n*(p+s)/p;return new JXG.Coords(JXG.COORDS_BY_USER,[i[1]+o,i[2]+n],this.board)};j.updateQuadraticform=function(){var i=this.center,o=i.X(),n=i.Y(),l=this.Radius();this.quadraticform=[[o*o+n*n-l*l,-o,-n],[-o,1,0],[-n,0,1]]};j.updateStdform=function(){this.stdform[3]=0.5;this.stdform[4]=this.Radius();this.stdform[1]=-this.center.coords.usrCoords[1];this.stdform[2]=-this.center.coords.usrCoords[2];this.normalize()};j.prepareUpdate().update();return j};JXG.JSXGraph.registerElement("arc",JXG.createArc);JXG.createSemicircle=function(i,g,f){var h,j,e;if((JXG.isPoint(g[0]))&&(JXG.isPoint(g[1]))){e=JXG.copyAttributes(f,i.options,"semicircle","midpoint");j=i.create("midpoint",[g[0],g[1]],e);j.dump=false;e=JXG.copyAttributes(f,i.options,"semicircle");h=i.create("arc",[j,g[1],g[0]],e);h.elType="semicircle";h.parents=[g[0].id,g[1].id];h.subs={midpoint:j};h.midpoint=j}else{throw new Error("JSXGraph: Can't create Semicircle with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"'.\nPossible parent types: [point,point]")}return h};JXG.JSXGraph.registerElement("semicircle",JXG.createSemicircle);JXG.createCircumcircleArc=function(i,g,f){var h,j,e;if((JXG.isPoint(g[0]))&&(JXG.isPoint(g[1]))&&(JXG.isPoint(g[2]))){e=JXG.copyAttributes(f,i.options,"circumcirclearc","center");j=i.create("circumcenter",[g[0],g[1],g[2]],e);j.dump=false;e=JXG.copyAttributes(f,i.options,"circumcirclearc");e.usedirection=true;h=i.create("arc",[j,g[0],g[2],g[1]],e);h.elType="circumcirclearc";h.parents=[g[0].id,g[1].id,g[2].id];h.subs={center:j};h.center=j}else{throw new Error("JSXGraph: create Circumcircle Arc with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"' and '"+(typeof g[2])+"'.\nPossible parent types: [point,point,point]")}return h};JXG.JSXGraph.registerElement("circumcirclearc",JXG.createCircumcircleArc);JXG.createSector=function(i,g,f){var h,e;if(!(JXG.isPoint(g[0])&&JXG.isPoint(g[1])&&JXG.isPoint(g[2]))){throw new Error("JSXGraph: Can't create Sector with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"' and '"+(typeof g[2])+"'.")}e=JXG.copyAttributes(f,i.options,"sector");h=i.create("curve",[[0],[0]],e);h.type=JXG.OBJECT_TYPE_SECTOR;h.elType="sector";h.parents=[g[0].id,g[1].id,g[2].id];h.point1=JXG.getReference(i,g[0]);h.point2=JXG.getReference(i,g[1]);h.point3=JXG.getReference(i,g[2]);h.point1.addChild(h);h.point2.addChild(h);h.point3.addChild(h);h.useDirection=f.usedirection;h.updateDataArray=function(){var u=this.point2,t=this.point1,s=this.point3,F,m,H,z,j=JXG.Math.Geometry.rad(u,t,s),D,w=Math.ceil(j/Math.PI*90)+1,G=j/w,p=t.X(),o=t.Y(),q,l,k,r,E;if(this.useDirection){k=g[1].coords.usrCoords,r=g[3].coords.usrCoords,E=g[2].coords.usrCoords;l=(k[1]-E[1])*(k[2]-r[2])-(k[2]-E[2])*(k[1]-r[1]);if(l<0){this.point2=g[1];this.point3=g[2]}else{this.point2=g[2];this.point3=g[1]}}this.dataX=[t.X(),u.X()];this.dataY=[t.Y(),u.Y()];for(F=G,D=1;D<=w;D++,F+=G){m=Math.cos(F);H=Math.sin(F);z=[[1,0,0],[p*(1-m)+o*H,m,-H],[o*(1-m)-p*H,H,m]];q=JXG.Math.matVecMult(z,u.coords.usrCoords);this.dataX.push(q[1]/q[0]);this.dataY.push(q[2]/q[0])}this.dataX.push(t.X());this.dataY.push(t.Y())};h.Radius=function(){return this.point2.Dist(this.point1)};h.getRadius=function(){return this.Radius()};h.hasPointSector=function(j,p){var o=new JXG.Coords(JXG.COORDS_BY_SCREEN,[j,p],this.board),l=this.Radius(),n=this.point1.coords.distance(JXG.COORDS_BY_USER,o),k=(nJXG.Math.Geometry.rad(this.point2,this.point1,this.point3)){k=false}}return k};h.getTextAnchor=function(){return this.point1.coords};h.getLabelAnchor=function(){var l=JXG.Math.Geometry.rad(this.point2,this.point1,this.point3),t=10/(this.board.unitX),r=10/(this.board.unitY),p=this.point2.coords.usrCoords,j=this.point1.coords.usrCoords,k=p[1]-j[1],s=p[2]-j[2],q,n,m,o;if(this.label.content!=null){this.label.content.relativeCoords=new JXG.Coords(JXG.COORDS_BY_SCREEN,[0,0],this.board)}q=new JXG.Coords(JXG.COORDS_BY_USER,[j[1]+Math.cos(l*0.5)*k-Math.sin(l*0.5)*s,j[2]+Math.sin(l*0.5)*k+Math.cos(l*0.5)*s],this.board);n=q.usrCoords[1]-j[1];m=q.usrCoords[2]-j[2];o=Math.sqrt(n*n+m*m);n=n*(o+t)/o;m=m*(o+r)/o;return new JXG.Coords(JXG.COORDS_BY_USER,[j[1]+n,j[2]+m],this.board)};h.prepareUpdate().update();return h};JXG.JSXGraph.registerElement("sector",JXG.createSector);JXG.createCircumcircleSector=function(i,g,f){var h,j,e;if((JXG.isPoint(g[0]))&&(JXG.isPoint(g[1]))&&(JXG.isPoint(g[2]))){e=JXG.copyAttributes(f,i.options,"circumcirclesector","center");j=i.create("circumcenter",[g[0],g[1],g[2]],e);j.dump=false;e=JXG.copyAttributes(f,i.options,"circumcirclesector");h=i.create("sector",[j,g[0],g[2],g[1]],e);h.elType="circumcirclesector";h.parents=[g[0].id,g[1].id,g[2].id];h.center=j;h.subs={center:j}}else{throw new Error("JSXGraph: Can't create circumcircle sector with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"' and '"+(typeof g[2])+"'.")}return h};JXG.JSXGraph.registerElement("circumcirclesector",JXG.createCircumcircleSector);JXG.createAngle=function(r,v,n){var h,g,f,z,s,m,u=["α","β","γ","δ","ε","ζ","&eta","θ","ι","κ","λ","μ","ν","ξ","ο","π","ρ","ς","σ","τ","υ","φ","χ","ψ","ω"],o=0,l,t,k,w,A,e;if((JXG.isPoint(v[0]))&&(JXG.isPoint(v[1]))&&(JXG.isPoint(v[2]))){s=JXG.copyAttributes(n,r.options,"angle");z=s.name;if(typeof z=="undefined"||z==""){while(o=3&&JXG.isPoint(g[0])&&JXG.isPoint(g[1])&&JXG.isPoint(g[2])){e=g[0];k=g[1];j=g[2];i=h.create("point",[function(){var n,m,o;n=Math.sqrt((k.X()-j.X())*(k.X()-j.X())+(k.Y()-j.Y())*(k.Y()-j.Y()));m=Math.sqrt((e.X()-j.X())*(e.X()-j.X())+(e.Y()-j.Y())*(e.Y()-j.Y()));o=Math.sqrt((k.X()-e.X())*(k.X()-e.X())+(k.Y()-e.Y())*(k.Y()-e.Y()));return new JXG.Coords(JXG.COORDS_BY_USER,[(n*e.X()+m*k.X()+o*j.X())/(n+m+o),(n*e.Y()+m*k.Y()+o*j.Y())/(n+m+o)],h)}],f);i.elType="incenter";i.parents=[g[0].id,g[1].id,g[2].id]}else{throw new Error("JSXGraph: Can't create incenter with parent types '"+(typeof g[0])+"', '"+(typeof g[1])+"' and '"+(typeof g[2])+"'.\nPossible parent types: [point,point,point]")}return i};JXG.createCircumcircle=function(i,h,g){var k,l,f;try{f=JXG.copyAttributes(g,i.options,"circumcircle","center");k=JXG.createCircumcircleMidpoint(i,h,f);k.dump=false;if(!JXG.exists(g.layer)){g.layer=i.options.layer.circle}f=JXG.copyAttributes(g,i.options,"circumcircle");l=JXG.createCircle(i,[k,h[0]],f);l.elType="circumcircle";l.parents=[h[0].id,h[1].id,h[2].id];l.subs={center:k}}catch(j){throw new Error("JSXGraph: Can't create circumcircle with parent types '"+(typeof h[0])+"', '"+(typeof h[1])+"' and '"+(typeof h[2])+"'.\nPossible parent types: [point,point,point]")}return l};JXG.createIncircle=function(j,i,g){var l,m,f,h;try{f=JXG.copyAttributes(g,j.options,"incircle","center");l=JXG.createIncenter(j,i,f);l.dump=false;if(!JXG.exists(g.layer)){g.layer=j.options.layer.circle}f=JXG.copyAttributes(g,j.options,"incircle");m=JXG.createCircle(j,[l,function(){var n=Math.sqrt((i[1].X()-i[2].X())*(i[1].X()-i[2].X())+(i[1].Y()-i[2].Y())*(i[1].Y()-i[2].Y())),e=Math.sqrt((i[0].X()-i[2].X())*(i[0].X()-i[2].X())+(i[0].Y()-i[2].Y())*(i[0].Y()-i[2].Y())),p=Math.sqrt((i[1].X()-i[0].X())*(i[1].X()-i[0].X())+(i[1].Y()-i[0].Y())*(i[1].Y()-i[0].Y())),o=(n+e+p)/2;return Math.sqrt(((o-n)*(o-e)*(o-p))/o)}],f);m.elType="incircle";m.parents=[i[0].id,i[1].id,i[2].id];m.center=l;m.subs={center:l}}catch(k){throw new Error("JSXGraph: Can't create circumcircle with parent types '"+(typeof i[0])+"', '"+(typeof i[1])+"' and '"+(typeof i[2])+"'.\nPossible parent types: [point,point,point]")}return m};JXG.createReflection=function(h,g,f){var e,j,i;if(g[0].elementClass==JXG.OBJECT_CLASS_POINT&&g[1].elementClass==JXG.OBJECT_CLASS_LINE){j=g[0];e=g[1]}else{if(g[1].elementClass==JXG.OBJECT_CLASS_POINT&&g[0].elementClass==JXG.OBJECT_CLASS_LINE){j=g[1];e=g[0]}else{throw new Error("JSXGraph: Can't create reflection point with parent types '"+(typeof g[0])+"' and '"+(typeof g[1])+"'.\nPossible parent types: [line,point]")}}i=JXG.createPoint(h,[function(){return JXG.Math.Geometry.reflection(e,j,h)}],f);j.addChild(i);e.addChild(i);i.elType="reflection";i.parents=[g[0].id,g[1].id];i.prepareUpdate().update();i.generatePolynomial=function(){var l=e.point1.symbolic.x;var k=e.point1.symbolic.y;var r=e.point2.symbolic.x;var q=e.point2.symbolic.y;var t=j.symbolic.x;var s=j.symbolic.y;var n=i.symbolic.x;var m=i.symbolic.y;var p=["((",m,")-(",s,"))*((",k,")-(",q,"))+((",l,")-(",r,"))*((",n,")-(",t,"))"].join("");var o=["((",n,")-(",l,"))^2+((",m,")-(",k,"))^2-((",t,")-(",l,"))^2-((",s,")-(",k,"))^2"].join("");return[p,o]};return i};JXG.createMirrorPoint=function(h,f,e){var j,g;if(JXG.isPoint(f[0])&&JXG.isPoint(f[1])){j=JXG.createPoint(h,[function(){return JXG.Math.Geometry.rotation(f[0],f[1],Math.PI,h)}],e);for(g=0;g<2;g++){f[g].addChild(j)}j.elType="mirrorpoint";j.parents=[f[0].id,f[1].id]}else{throw new Error("JSXGraph: Can't create mirror point with parent types '"+(typeof f[0])+"' and '"+(typeof f[1])+"'.\nPossible parent types: [point,point]")}j.prepareUpdate().update();return j};JXG.createIntegral=function(j,A,n){var z,s,v,h=0,g=0,f,e,m,l,r=1,w,o,i,B,k,q,u;if(JXG.isArray(A[0])&&A[1].elementClass==JXG.OBJECT_CLASS_CURVE){z=A[0];s=A[1]}else{if(JXG.isArray(A[1])&&A[0].elementClass==JXG.OBJECT_CLASS_CURVE){z=A[1];s=A[0]}else{throw new Error("JSXGraph: Can't create integral with parent types '"+(typeof A[0])+"' and '"+(typeof A[1])+"'.\nPossible parent types: [[number|function,number|function],curve]")}}h=z[0];g=z[1];if(JXG.isFunction(h)){f=h;e=function(){return s.Y(f())};h=f()}else{f=h;e=s.Y(h)}if(JXG.isFunction(h)){m=g;l=function(){return s.Y(m())};g=m()}else{m=g;l=s.Y(g)}if(g0){return}var k=JXG.Math.Symbolic.generatePolynomials(g,h,true).join("|");if(k===i.spe){return}i.spe=k;var j=function(n,p,m,o){i.dataX=n;i.dataY=p;i.eq=m;i.ctime=o;i.generatePolynomial=(function(q){return function(s){var r="("+s.symbolic.x+")",v="("+s.symbolic.y+")",u=[],t;for(t=0;tl.usrCoords[2]-n;k-=n){i.dataX.push(m.usrCoords[1],l.usrCoords[1],NaN);i.dataY.push(k,k,NaN)}for(k=m.usrCoords[1];k=-h&&g<=2*h&&f>=-h&&f<=2*h},setTextJessieCode:function(f){var e;this.visProp.castext=f;if(typeof f==="function"){e=function(){return f().replace(//g,">")}}else{if(JXG.isNumber(f)){e=f}else{e=f.replace(//g,">")}}return this.setText(e)},setText:function(e){if(typeof e==="function"){this.updateText=function(){this.plaintext=e()}}else{if(JXG.isNumber(e)){this.content=(e).toFixed(this.visProp.digits)}else{if(this.visProp.useasciimathml){this.content="'`"+e+"`'"}else{this.content=this.generateTerm(e)}}this.updateText=new Function("this.plaintext = "+this.content+";")}this.updateText();this.updateSize();this.needsUpdate=true;this.update();this.updateRenderer();return this},updateSize:function(){if(this.visProp.display=="html"&&this.board.renderer.type!="vml"){this.size=[this.rendNode.offsetWidth,this.rendNode.offsetHeight]}else{if(this.visProp.display=="internal"&&this.board.renderer.type=="svg"){this.size=[this.rendNode.getBBox().width,this.rendNode.getBBox().height]}else{if(this.board.renderer.type=="vml"||(this.visProp.display=="internal"&&this.board.renderer.type=="canvas")){this.size=[parseFloat(this.visProp.fontsize)*this.plaintext.length*0.45,parseFloat(this.visProp.fontsize)*0.9]}}}return this},getSize:function(){return this.size},setCoords:function(e,f){if(JXG.isArray(e)&&e.length>1){f=e[1];e=e[0]}this.X=function(){return e};this.Y=function(){return f};this.coords=new JXG.Coords(JXG.COORDS_BY_USER,[e,f],this.board);this.board.update();return this},free:function(){this.X=JXG.createFunction(this.X(),this.board,"");this.Y=JXG.createFunction(this.Y(),this.board,"");this.isDraggable=true},update:function(){var e,g,f;if(this.needsUpdate){if(this.relativeCoords){if(this.visProp.islabel){g=parseFloat(this.visProp.offsets[0]);f=-parseFloat(this.visProp.offsets[1]);e=this.element.getLabelAnchor();this.coords.setCoordinates(JXG.COORDS_BY_SCREEN,[g+this.relativeCoords.scrCoords[1]+e.scrCoords[1],f+this.relativeCoords.scrCoords[2]+e.scrCoords[2]])}else{e=this.element.getTextAnchor();this.coords.setCoordinates(JXG.COORDS_BY_USER,[this.relativeCoords.usrCoords[1]+e.usrCoords[1],this.relativeCoords.usrCoords[2]+e.usrCoords[2]])}}else{this.updateCoords()}this.updateText();this.updateTransform()}return this},updateRenderer:function(){if(this.needsUpdate){this.board.renderer.updateText(this);this.needsUpdate=false}return this},updateTransform:function(){if(this.transformations.length==0){return}for(var e=0;e/g,"∠");k=k.replace(//g,"√");var f;f=k.indexOf("");var e=k.indexOf("");if(f>=0){while(f>=0){l+=' + "'+JXG.GeonextParser.replaceSub(JXG.GeonextParser.replaceSup(k.slice(0,f)))+'"';g=k.slice(f+7,e);h=JXG.GeonextParser.geonext2JS(g,this.board);h=h.replace(/\\"/g,'"');h=h.replace(/\\'/g,"'");if(h.indexOf("toFixed")<0){if(JXG.isNumber((JXG.bind(new Function("return "+h+";"),this))())){l+="+("+h+").toFixed("+(this.visProp.digits)+")"}else{l+="+("+h+")"}}else{l+="+("+h+")"}k=k.slice(e+8);f=k.indexOf("");e=k.indexOf("")}}l+=' + "'+JXG.GeonextParser.replaceSub(JXG.GeonextParser.replaceSup(k))+'"';l=l.replace(//g,"");l=l.replace(/<\/overline>/g,"");l=l.replace(//g,"");l=l.replace(/<\/arrow>/g,"");l=l.replace(/&/g,"&");return l},notifyParents:function(g){var f=null;do{var e=/([\w\s\*\/\^\-\+\(\)\[\],<>=!]+)<\/value>/;f=e.exec(g);if(f!=null){JXG.GeonextParser.findDependencies(this,f[1],this.board);g=g.substr(f.index);g=g.replace(e,"")}}while(f!=null);return this},bounds:function(){var e=this.coords.usrCoords;return this.visProp.islabel?[0,0,0,0]:[e[1],e[2]+this.size[1],e[1]+this.size[0],e[2]]},setPositionDirectly:function(e,l,j,h,g){var f,o,n,m,k;if(this.relativeCoords){if(this.visProp.islabel){if(e==JXG.COORDS_BY_USER){k=new JXG.Coords(JXG.COORDS_BY_USER,[h,g],this.board);m=new JXG.Coords(JXG.COORDS_BY_USER,[l,j],this.board);o=m.scrCoords[1]-k.scrCoords[1];n=m.scrCoords[2]-k.scrCoords[2]}else{o=l-h;n=j-g}this.relativeCoords.scrCoords[1]+=o;this.relativeCoords.scrCoords[2]+=n}else{if(e==JXG.COORDS_BY_SCREEN){k=new JXG.Coords(JXG.COORDS_BY_SCREEN,[h,g],this.board);m=new JXG.Coords(JXG.COORDS_BY_SCREEN,[l,j],this.board);o=m.usrCoords[1]-k.usrCoords[1];n=m.usrCoords[2]-k.usrCoords[2]}else{o=l-h;n=j-g}this.relativeCoords.usrCoords[1]+=o;this.relativeCoords.usrCoords[2]+=n}}else{if(e==JXG.COORDS_BY_SCREEN){m=new JXG.Coords(JXG.COORDS_BY_SCREEN,[l,j],this.board);l=m.usrCoords[1];j=m.usrCoords[2]}this.X=JXG.createFunction(l,this.board,"");this.Y=JXG.createFunction(j,this.board,"")}return this}});JXG.createText=function(i,g,f){var e,h;e=JXG.copyAttributes(f,i.options,"text");e.anchor=e.parent||e.anchor;h=new JXG.Text(i,g[g.length-1],g,e);if(typeof g[g.length-1]!=="function"){h.parents=g}return h};JXG.JSXGraph.registerElement("text",JXG.createText);JXG.Image=function(h,f,i,g,e){this.constructor(h,e,JXG.OBJECT_TYPE_IMAGE,JXG.OBJECT_CLASS_OTHER);this.initialCoords=new JXG.Coords(JXG.COORDS_BY_USER,i,this.board);if(!JXG.isFunction(i[0])&&!JXG.isFunction(i[1])){this.isDraggable=true}this.X=JXG.createFunction(i[0],this.board,"");this.Y=JXG.createFunction(i[1],this.board,"");this.W=JXG.createFunction(g[0],this.board,"");this.H=JXG.createFunction(g[1],this.board,"");this.coords=new JXG.Coords(JXG.COORDS_BY_USER,[this.X(),this.Y()],this.board);this.updateCoords=new Function("","this.coords.setCoordinates(JXG.COORDS_BY_USER,[this.X(),this.Y()]);");this.updateSize=new Function("","this.coords.setCoordinates(JXG.COORDS_BY_USER,[this.W(),this.H()]);");this.usrSize=[this.W(),this.H()];this.size=[this.usrSize[0]*h.unitX,this.usrSize[1]*h.unitY];this.url=f;this.parent=JXG.getRef(e.anchor);this.id=this.board.setId(this,"Im");this.board.renderer.drawImage(this);if(!this.visProp.visible){this.board.renderer.hide(this)}};JXG.Image.prototype=new JXG.GeometryElement;JXG.extend(JXG.Image.prototype,{hasPoint:function(e,i){var g=e-this.coords.scrCoords[1],f=this.coords.scrCoords[2]-i,h=this.board.options.precision.hasPoint;if(g>=-h&&g<=2*h&&f>=-h&&f<=h){return true}else{return false}},update:function(){if(this.needsUpdate){this.updateCoords();this.usrSize=[this.W(),this.H()];this.size=[this.usrSize[0]*this.board.unitX,this.usrSize[1]*this.board.unitY];this.updateTransform()}return this},updateRenderer:function(){if(this.needsUpdate){this.board.renderer.updateImage(this);this.needsUpdate=false}return this},updateTransform:function(){if(this.transformations.length==0){return}for(var e=0;e=0){z+=e*0.5/f.unitX}else{z-=e*s/f.unitX}n-=e*0.2/f.unitY;r=f.create("text",[z,n,g.labels[v]],g)}}else{t[0]=f.create("point",[q,0],A);t[1]=f.create("point",[q,z],A);t[2]=f.create("point",[l,z],A);t[3]=f.create("point",[l,0],A);if(JXG.exists(g.labels)&&JXG.exists(g.labels[v])){s=g.labels[v].toString().length;s=0.6*s*e/f.unitX;if(z>=0){z+=e*0.5/f.unitY}else{z-=e*1/f.unitY}r=f.create("text",[n-s*0.5,z,g.labels[v]],g)}}g.withlines=false;if(JXG.exists(g.colors)&&JXG.isArray(g.colors)){k=g.colors;g.fillcolor=k[v%k.length]}h[v]=f.create("polygon",t,g);if(JXG.exists(g.labels)&&JXG.exists(g.labels[v])){h[v].text=r}}return h},drawPoints:function(k,e,l,g){var h,j=[],f=g.infoboxarray;g.fixed=true;g.name="";for(h=0;hae[Z]){ae[Z]=S[ab][Z]}if(S[ab][Z]1){if(h.length==3){i=this.evalParam(1);m=this.evalParam(2)}else{i=h[1].X();m=h[1].Y()}this.matrix[1][0]=i*(1-l)+m*j;this.matrix[2][0]=m*(1-l)-i*j}}}else{if(f=="shear"){this.evalParam=JXG.createEvalFunction(g,h,1);this.update=function(){var i=this.evalParam(0);this.matrix[1][1]=Math.tan(i)}}else{if(f=="generic"){this.evalParam=JXG.createEvalFunction(g,h,9);this.update=function(){this.matrix[0][0]=this.evalParam(0);this.matrix[0][1]=this.evalParam(1);this.matrix[0][2]=this.evalParam(2);this.matrix[1][0]=this.evalParam(3);this.matrix[1][1]=this.evalParam(4);this.matrix[1][2]=this.evalParam(5);this.matrix[2][0]=this.evalParam(6);this.matrix[2][1]=this.evalParam(7);this.matrix[2][2]=this.evalParam(8)}}}}}}}},apply:function(e){this.update();if(arguments[1]!=null){return JXG.Math.matVecMult(this.matrix,e.initialCoords.usrCoords)}else{return JXG.Math.matVecMult(this.matrix,e.coords.usrCoords)}},applyOnce:function(g){var h,e,f;if(!JXG.isArray(g)){this.update();h=JXG.Math.matVecMult(this.matrix,g.coords.usrCoords);g.coords.setCoordinates(JXG.COORDS_BY_USER,h)}else{e=g.length;for(f=0;f=8192){this.curve=this.board.create("curve",[[this.pos[0]],[this.pos[1]]],this._attributes);this.objects.push(this.curve)}}this.pos[0]+=g;this.pos[1]+=f;if(this.isPenDown){this.curve.dataX.push(this.pos[0]);this.curve.dataY.push(this.pos[1])}this.board.update();return this},back:function(e){return this.forward(-e)},right:function(f){this.dir-=f;this.dir%=360;if(!this.turtleIsHidden){var e=this.board.create("transform",[-f*Math.PI/180,this.turtle],{type:"rotate"});e.applyOnce(this.turtle2)}this.board.update();return this},left:function(e){return this.right(-e)},penUp:function(){this.isPenDown=false;return this},penDown:function(){this.isPenDown=true;this.curve=this.board.create("curve",[[this.pos[0]],[this.pos[1]]],this._attributes);this.objects.push(this.curve);return this},clean:function(){for(var e=0;e=8192){this.curve=this.board.create("curve",[[this.pos[0]],[this.pos[1]]],this._attributes);this.objects.push(this.curve)}}this.pos[0]=h[0];this.pos[1]=h[1];if(this.isPenDown){this.curve.dataX.push(this.pos[0]);this.curve.dataY.push(this.pos[1])}this.board.update()}return this},fd:function(e){return this.forward(e)},bk:function(e){return this.back(e)},lt:function(e){return this.left(e)},rt:function(e){return this.right(e)},pu:function(){return this.penUp()},pd:function(){return this.penDown()},ht:function(){return this.hideTurtle()},st:function(){return this.showTurtle()},cs:function(){return this.clearScreen()},push:function(){return this.pushTurtle()},pop:function(){return this.popTurtle()},evalAt:function(k,m){var h,g,l,f,e=this.objects.length;for(h=0,g=0;h=3){arguments[0]=[arguments[0],arguments[1],arguments[2]];arguments.length=1}var o=arguments[0];if(JXG.isArray(o)){var f=false,k;for(k=0;k<3;k++){f|=/\./.test(arguments[0][k].toString())}for(k=0;k<3;k++){f&=(arguments[0][k]>=0)&(arguments[0][k]<=1)}if(f){return[Math.ceil(arguments[0][0]*255),Math.ceil(arguments[0][1]*255),Math.ceil(arguments[0][2]*255)]}else{arguments[0].length=3;return arguments[0]}}else{if(typeof arguments[0]=="string"){o=arguments[0]}}var e,m,p;if(o.charAt(0)=="#"){o=o.substr(1,6)}o=o.replace(/ /g,"");o=o.toLowerCase();var j={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};for(var q in j){if(o==q){o=j[q]}}var n=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(g){return[parseInt(g[1]),parseInt(g[2]),parseInt(g[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(g){return[parseInt(g[1],16),parseInt(g[2],16),parseInt(g[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(g){return[parseInt(g[1]+g[1],16),parseInt(g[2]+g[2],16),parseInt(g[3]+g[3],16)]}}];for(var k=0;k255)?255:e);m=(m<0||isNaN(m))?0:((m>255)?255:m);p=(p<0||isNaN(p))?0:((p>255)?255:p);return[e,m,p]};JXG.rgb2css=function(){var h,f,e;h=JXG.rgbParser.apply(JXG.rgbParser,arguments);f=h[1];e=h[2];h=h[0];return"rgb("+h+", "+f+", "+e+")"};JXG.rgb2hex=function(){var h,f,e;h=JXG.rgbParser.apply(JXG.rgbParser,arguments);f=h[1];e=h[2];h=h[0];h=h.toString(16);f=f.toString(16);e=e.toString(16);if(h.length==1){h="0"+h}if(f.length==1){f="0"+f}if(e.length==1){e="0"+e}return"#"+h+f+e};JXG.hex2rgb=function(i){var h,f,e;if(i.charAt(0)=="#"){i=i.slice(1)}h=parseInt(i.substr(0,2),16);f=parseInt(i.substr(2,2),16);e=parseInt(i.substr(4,2),16);return"rgb("+h+", "+f+", "+e+")"};JXG.hsv2rgb=function(r,l,k){var m,s,h,o,n,j,g,e,u;r=((r%360)+360)%360;if(l==0){if(isNaN(r)||r=360){j=0}else{j=r}j=j/60;n=Math.floor(j);o=j-n;g=k*(1-l);e=k*(1-(l*o));u=k*(1-(l*(1-o)));switch(n){case 0:m=k;s=u;h=g;break;case 1:m=e;s=k;h=g;break;case 2:m=g;s=k;h=u;break;case 3:m=g;s=e;h=k;break;case 4:m=u;s=g;h=k;break;case 5:m=k;s=g;h=e;break}}m=Math.round(m*255).toString(16);m=(m.length==2)?m:((m.length==1)?"0"+m:"00");s=Math.round(s*255).toString(16);s=(s.length==2)?s:((s.length==1)?"0"+s:"00");h=Math.round(h*255).toString(16);h=(h.length==2)?h:((h.length==1)?"0"+h:"00");return["#",m,s,h].join("")};JXG.rgb2hsv=function(){var e,n,q,o,f,j,i,t,m,w,u,p,k,l;e=JXG.rgbParser.apply(JXG.rgbParser,arguments);n=e[1];q=e[2];e=e[0];l=JXG.Math.Statistics;o=e/255;f=n/255;j=q/255;p=l.max([e,n,q]);k=l.min([e,n,q]);i=p/255;t=k/255;u=i;w=0;if(u>0){w=(u-t)/(u*1)}m=1/(i-t);if(w>0){if(p==e){m=(f-j)*m}else{if(p==n){m=2+(j-o)*m}else{m=4+(o-f)*m}}}m*=60;if(m<0){m+=360}if(p==k){m=0}return[m,w,u]};JXG.rgb2LMS=function(){var o,n,f,h,e,k,j,i=[[0.05059983,0.08585369,0.0095242],[0.01893033,0.08925308,0.01370054],[0.00292202,0.00975732,0.07145979]];o=JXG.rgbParser.apply(JXG.rgbParser,arguments);n=o[1];f=o[2];o=o[0];o=Math.pow(o,0.476190476);n=Math.pow(n,0.476190476);f=Math.pow(f,0.476190476);h=o*i[0][0]+n*i[0][1]+f*i[0][2];e=o*i[1][0]+n*i[1][1]+f*i[1][2];k=o*i[2][0]+n*i[2][1]+f*i[2][2];j=[h,e,k];j.l=h;j.m=e;j.s=k;return j};JXG.LMS2rgb=function(h,f,p){var e,i,k,j,n=[[30.830854,-29.832659,1.610474],[-6.481468,17.715578,-2.532642],[-0.37569,-1.199062,14.273846]];e=h*n[0][0]+f*n[0][1]+p*n[0][2];i=h*n[1][0]+f*n[1][1]+p*n[1][2];k=h*n[2][0]+f*n[2][1]+p*n[2][2];var o=function(l){var m=127,g=64;while(g>0){if(Math.pow(m,0.476190476)>l){m-=g}else{if(Math.pow(m+1,0.476190476)>l){return m}m+=g}g/=2}if(m==254&&13.994955247>4)&15)+i.charAt(f&15);g="#"+h+""+h+""+h;return g};JXG.rgb2cb=function(j,q){if(j=="none"){return j}var t,i,h,w,r,o,g,v,n,f,u,k,p;r=JXG.rgb2LMS(j);i=r.l;h=r.m;w=r.s;q=q.toLowerCase();switch(q){case"protanopia":g=-0.06150039994295001;v=0.08277001656812001;n=-0.013200141220000003;f=0.05858939668799999;u=-0.07934519995360001;k=0.013289415272000003;p=0.6903216543277437;o=w/h;if(o>4)&15)+e.charAt(t.r&15);j="#"+o;o=e.charAt((t.g>>4)&15)+e.charAt(t.g&15);j+=o;o=e.charAt((t.b>>4)&15)+e.charAt(t.b&15);j+=o;return j};JXG.extend(JXG.Board.prototype,{angle:function(e,g,f){return JXG.Math.Geometry.angle(e,g,f)},rad:function(e,g,f){return JXG.Math.Geometry.rad(e,g,f)},distance:function(f,e){return JXG.Math.Geometry.distance(f,e)},pow:function(f,e){return JXG.Math.pow(f,e)},round:function(e,f){return(e).toFixed(f)},cosh:function(e){return JXG.Math.cosh(e)},sinh:function(e){return JXG.Math.sinh(e)},sgn:function(e){return(e==0?0:e/(Math.abs(e)))},D:function(e,g){return JXG.Math.Numerics.D(e,g)},I:function(e,g){return JXG.Math.Numerics.I(e,g)},root:function(g,e,h){return JXG.Math.Numerics.root(g,e,h)},lagrangePolynomial:function(e){return JXG.Math.Numerics.lagrangePolynomial(e)},neville:function(e){return JXG.Math.Numerics.Neville(e)},riemannsum:function(h,j,g,i,e){return JXG.Math.Numerics.riemannsum(h,j,g,i,e)},abs:Math.abs,acos:Math.acos,asin:Math.asin,atan:Math.atan,ceil:Math.ceil,cos:Math.cos,exp:Math.exp,floor:Math.floor,log:Math.log,max:Math.max,min:Math.min,random:Math.random,sin:Math.sin,sqrt:Math.sqrt,tan:Math.tan,trunc:Math.ceil,factorial:function(e){return JXG.Math.factorial(e)},binomial:function(f,e){return JXG.Math.binomial(f,e)},getElement:function(e){return JXG.getReference(this,e)},intersectionOptions:["point",[[JXG.OBJECT_CLASS_LINE,JXG.OBJECT_CLASS_LINE],[JXG.OBJECT_CLASS_LINE,JXG.OBJECT_CLASS_CIRCLE],[JXG.OBJECT_CLASS_CIRCLE,JXG.OBJECT_CLASS_CIRCLE]]],intersection:function(h,f,g,e){h=JXG.getReference(this,h);f=JXG.getReference(this,f);if(h.elementClass==JXG.OBJECT_CLASS_CURVE&&f.elementClass==JXG.OBJECT_CLASS_CURVE){return function(){return JXG.Math.Geometry.meetCurveCurve(h,f,g,e,h.board)}}else{if((h.type==JXG.OBJECT_TYPE_ARC&&f.elementClass==JXG.OBJECT_CLASS_LINE)||(f.type==JXG.OBJECT_TYPE_ARC&&h.elementClass==JXG.OBJECT_CLASS_LINE)){return function(){return JXG.Math.Geometry.meet(h.stdform,f.stdform,g,h.board)}}else{if((h.elementClass==JXG.OBJECT_CLASS_CURVE&&f.elementClass==JXG.OBJECT_CLASS_LINE)||(f.elementClass==JXG.OBJECT_CLASS_CURVE&&h.elementClass==JXG.OBJECT_CLASS_LINE)){return function(){return JXG.Math.Geometry.meetCurveLine(h,f,g,h.board)}}else{return function(){return JXG.Math.Geometry.meet(h.stdform,f.stdform,g,h.board)}}}}},intersectionFunc:function(h,f,g,e){return this.intersection(h,f,g,e)},otherIntersection:function(f,e,g){f=JXG.getReference(this,f);e=JXG.getReference(this,e);return function(){var h=JXG.Math.Geometry.meet(f.stdform,e.stdform,0,f.board);if(Math.abs(g.X()-h.usrCoords[1])>JXG.Math.eps||Math.abs(g.Y()-h.usrCoords[2])>JXG.Math.eps||Math.abs(g.Z()-h.usrCoords[0])>JXG.Math.eps){return h}else{return JXG.Math.Geometry.meet(f.stdform,e.stdform,1,f.board)}}},pointFunc:function(){return[null]},pointOptions:["point",[[JXG.OBJECT_CLASS_POINT]]],lineFunc:function(){return arguments},lineOptions:["line",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],linesegmentFunc:function(){return arguments},linesegmentOptions:["line",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],linesegmentAtts:{straightFirst:false,straightLast:false},arrowFunc:function(){return arguments},arrowOptions:["arrow",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],circleFunc:function(){return arguments},circleOptions:["circle",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT],[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE],[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_CIRCLE]]],arrowparallelOptions:["arrowparallel",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]],arrowparallelFunc:function(){return arguments},bisectorOptions:["bisector",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],bisectorFunc:function(){return arguments},circumcircleOptions:["circumcircle",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],circumcircleFunc:function(){return arguments},circumcirclemidpointOptions:["circumcirclemidpoint",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],circumcirclemidpointFunc:function(){return arguments},integralOptions:["integral",[[]]],integralFunc:function(){return arguments},midpointOptions:["midpoint",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT],[JXG.OBJECT_CLASS_LINE]]],midpointFunc:function(){return arguments},mirrorpointOptions:["mirrorpoint",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],mirrorpointFunc:function(){return arguments},normalOptions:["normal",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]],normalFunc:function(){return arguments},parallelOptions:["parallel",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]],parallelFunc:function(){return arguments},parallelpointOptions:["parallelpoint",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]],parallelpointFunc:function(){return arguments},perpendicularOptions:["perpendicular",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]],perpendicularFunc:function(){return arguments},perpendicularpointOptions:["perpendicularpoint",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]],perpendicularpointFunc:function(){return arguments},reflectionOptions:["reflection",[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]],reflectionFunc:function(){return arguments}});JXG.Point.prototype.setPositionX=function(g,e){var f=(g==JXG.COORDS_BY_USER)?this.coords.usrCoords[2]:this.coords.scrCoords[2];this.setPosition(g,e,f)};JXG.Point.prototype.setPositionY=function(g,f){var e=(g==JXG.COORDS_BY_USER)?this.coords.usrCoords[1]:this.coords.scrCoords[1];this.setPosition(g,e,f)};JXG.Ticks=function(e,g,f){this.constructor(e.board,f,JXG.OBJECT_TYPE_TICKS,JXG.OBJECT_CLASS_OTHER);this.line=e;this.board=this.line.board;this.ticksFunction=null;this.fixedTicks=null;this.equidistant=false;if(JXG.isFunction(g)){this.ticksFunction=g;throw new Error("Function arguments are no longer supported.")}else{if(JXG.isArray(g)){this.fixedTicks=g}else{if(Math.abs(g)=w&&this.fixedTicks[C]JXG.Math.eps){D=this._adjustTickDistance(D,n,u,h.coords,L,J);this.ticksDelta=D}if(!this.visProp.insertticks){D/=this.visProp.minorticks+1}l=this.board.getBoundingBox();H=(l[0]+l[2])*0.5;G=(l[1]+l[3])*0.5;M=[H*this.line.stdform[2]-G*this.line.stdform[1],-this.line.stdform[2],this.line.stdform[1]];I=JXG.Math.crossProduct(this.line.stdform,M);I[1]/=I[0];I[2]/=I[0];I[0]=1;z=new JXG.Coords(JXG.COORDS_BY_USER,I.slice(1),this.board);F=h.coords.distance(JXG.COORDS_BY_USER,z);if((f.X()-h.X())*(I[1]-h.X())<0||(f.Y()-h.Y())*(I[2]-h.Y())<0){F*=-1}q=Math.round(F/D)*D;if(Math.abs(q)>JXG.Math.eps){v=Math.abs(q)/q}I[1]=h.coords.usrCoords[1]+L*q;I[2]=h.coords.usrCoords[2]+J*q;e=q;q=0;H=I[1];G=I[2];C=0;do{z=new JXG.Coords(JXG.COORDS_BY_USER,[H,G],this.board);if(Math.round((v*q+e)/D)%(this.visProp.minorticks+1)===0){z.major=true}else{z.major=false}k=this._tickEndings(z,K,g,t,A,z.major);if(k.length==2){m=v*q+e;if((Math.abs(m)<=s&&this.visProp.drawzero)||(m>w&&m0)},_adjustTickDistance:function(j,k,i,h,g,f){var e,l;while(k>4*this.minTicksDistance){j/=10;e=h.usrCoords[1]+g*j;l=h.usrCoords[2]+f*j;k=h.distance(JXG.COORDS_BY_SCREEN,new JXG.Coords(JXG.COORDS_BY_USER,[e,l],this.board))}while(k=0&&p[1]<=g){k[h]=p[1];j[h]=0;h++}p=JXG.Math.crossProduct([0,1,0],[-e*B[1]-t*B[2],e,t]);p[2]/=p[0];if(p[2]>=0&&p[2]<=n){k[h]=0;j[h]=p[2];h++}if(h<2){p=JXG.Math.crossProduct([n*n,0,-n],[-e*B[1]-t*B[2],e,t]);p[1]/=p[0];if(p[1]>=0&&p[1]<=g){k[h]=p[1];j[h]=n;h++}}if(h<2){p=JXG.Math.crossProduct([g*g,-g,0],[-e*B[1]-t*B[2],e,t]);p[2]/=p[0];if(p[2]>=0&&p[2]<=n){k[h]=g;j[h]=p[2]}}}}if((k[0]>=0&&k[0]<=g&&j[0]>=0&&j[0]<=n)||(k[1]>=0&&k[1]<=g&&j[1]>=0&&j[1]<=n)){o=true}else{o=false}if(z=="finite"){A=Math.sqrt(this.board.unitX*this.board.unitX+this.board.unitY*this.board.unitY);k[0]=B[1]+m*this.board.unitX/A;j[0]=B[2]-l*this.board.unitY/A;k[1]=B[1]-m*this.board.unitX/A;j[1]=B[2]+l*this.board.unitY/A}if(o){return[k,j]}else{return[]}},_makeLabel:function(m,e,j,g,l,h){var k,f;if(!g){return null}k=m.toString();if(Math.abs(m)5||k.indexOf("e")!=-1){k=m.toPrecision(3).toString()}if(k.indexOf(".")>-1){k=k.replace(/0+$/,"");k=k.replace(/\.$/,"")}f=JXG.createText(j,[e.usrCoords[1],e.usrCoords[2],k],{id:l+h+"Label",isLabel:true,layer:j.options.layer.line,highlightStrokeColor:j.options.text.strokeColor,highlightStrokeWidth:j.options.text.strokeWidth,highlightStrokeOpacity:j.options.text.strokeOpacity});f.isDraggable=false;f.dump=false;f.distanceX=4;f.distanceY=-parseInt(f.visProp.fontsize)+3;f.setCoords(e.usrCoords[1]+f.distanceX/(j.unitX),e.usrCoords[2]+f.distanceY/(j.unitY));f.visProp.visible=g;f.prepareUpdate().update().updateRenderer();return f},removeTickLabels:function(){var e;if(this.ticks!=null){if((this.board.needsFullUpdate||this.needsRegularUpdate)&&!(this.board.options.renderer=="canvas"&&this.board.options.text.display=="internal")){for(e=0;e>=1;if(af==0){af=h();ah=(af&1);af=(af>>1)|128}return ah}function X(ah){var aj=0,ai=ah;while(ai--){aj=(aj<<1)|Z()}if(ah){aj=aa[aj]>>(8-ah)}return aj}function g(){ab=0}function B(ah){L++;l[ab++]=ah;q.push(String.fromCharCode(ah));if(ab==32768){ab=0}}function p(){this.b0=0;this.b1=0;this.jump=null;this.jumppos=-1}var i=288;var z=new Array(i);var R=new Array(32);var M=0;var ac=null;var t=null;var Q=new Array(64);var N=new Array(64);var C=0;var G=new Array(17);G[0]=0;var S;var w;function m(){while(1){if(G[C]>=w){return -1}if(S[G[C]]==C){return G[C]++}G[C]++}}function I(){var ai=ac[M];var ah;if(H){document.write("
len:"+C+" treepos:"+M)}if(C==17){return -1}M++;C++;ah=m();if(H){document.write("
IsPat "+ah)}if(ah>=0){ai.b0=ah;if(H){document.write("
b0 "+ai.b0)}}else{ai.b0=32768;if(H){document.write("
b0 "+ai.b0)}if(I()){return -1}}ah=m();if(ah>=0){ai.b1=ah;if(H){document.write("
b1 "+ai.b1)}ai.jump=null}else{ai.b1=32768;if(H){document.write("
b1 "+ai.b1)}ai.jump=ac[M];ai.jumppos=M;if(I()){return -1}}C--;return 0}function o(al,aj,am,ai){var ak;if(H){document.write("currentTree "+al+" numval "+aj+" lengths "+am+" show "+ai)}ac=al;M=0;S=am;w=aj;for(ak=0;ak<17;ak++){G[ak]=0}C=0;if(I()){if(H){alert("invalid huffman tree\n")}return -1}if(H){document.write("
Tree: "+ac.length);for(var ah=0;ah<32;ah++){document.write("Places["+ah+"].b0="+ac[ah].b0+"
");document.write("Places["+ah+"].b1="+ac[ah].b1+"
")}}return 0}function F(ak){var ai,aj,am=0,al=ak[am],ah;while(1){ah=Z();if(H){document.write("b="+ah)}if(ah){if(!(al.b1&32768)){if(H){document.write("ret1")}return al.b1}al=al.jump;ai=ak.length;for(aj=0;aj>1);if(av>23){av=(av<<1)|Z();if(av>199){av-=128;av=(av<<1)|Z()}else{av-=48;if(av>143){av=av+136}}}else{av+=256}if(av<256){B(av)}else{if(av==256){break}else{var ax,aq;av-=256+1;ax=X(V[av])+ae[av];av=aa[X(5)]>>3;if(D[av]>8){aq=X(8);aq|=(X(D[av]-8)<<8)}else{aq=X(D[av])}aq+=P[av];for(av=0;avdistanceTree");for(var az=0;az"+R[az].b0+" "+R[az].b1+" "+R[az].jump+" "+R[az].jumppos)}}ar=aj+ao;aw=0;var ak=-1;if(H){document.write("
n="+ar+" bits: "+e+"
")}while(aw"+ak+" i:"+aw+" decode: "+av+" bits "+e+"
")}if(av<16){an[aw++]=av}else{if(av==16){var at;av=3+X(2);if(aw+av>ar){g();return 1}at=aw?an[aw-1]:0;while(av--){an[aw++]=at}}else{if(av==17){av=3+X(3)}else{av=11+X(7)}if(aw+av>ar){g();return 1}while(av--){an[aw++]=0}}}}ax=z.length;for(aw=0;awliteralTree")}while(1){av=F(z);if(av>=256){var ax,aq;av-=256;if(av==0){break}av--;ax=X(V[av])+ae[av];av=F(R);if(D[av]>8){aq=X(8);aq|=(X(D[av]-8)<<8)}else{aq=X(D[av])}aq+=P[av];while(ax--){var ay=l[(ab-aq)&32767];B(ay)}}else{B(av)}}}}}}while(!al);g();s();return 0}JXG.Util.Unzip.prototype.unzipFile=function(ah){var ai;this.unzip();for(ai=0;ai>2;l=((o&3)<<4)|(m>>4);j=((m&15)<<2)|(k>>6);h=k&63;if(isNaN(m)){j=h=64}else{if(isNaN(k)){h=64}}e.push([this._keyStr.charAt(n),this._keyStr.charAt(l),this._keyStr.charAt(j),this._keyStr.charAt(h)].join(""))}return e.join("")},decode:function(h,g){var e=[],p,n,l,o,m,k,j,f=0;h=h.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f>4);n=((m&15)<<4)|(k>>2);l=((k&3)<<6)|j;e.push(String.fromCharCode(p));if(k!=64){e.push(String.fromCharCode(n))}if(j!=64){e.push(String.fromCharCode(l))}}e=e.join("");if(g){e=JXG.Util.Base64._utf8_decode(e)}return e},_utf8_encode:function(f){f=f.replace(/\r\n/g,"\n");var e="";for(var h=0;h127)&&(g<2048)){e+=String.fromCharCode((g>>6)|192);e+=String.fromCharCode((g&63)|128)}else{e+=String.fromCharCode((g>>12)|224);e+=String.fromCharCode(((g>>6)&63)|128);e+=String.fromCharCode((g&63)|128)}}}return e},_utf8_decode:function(e){var g=[],j=0,k=0,h=0,f=0;while(j191)&&(k<224)){h=e.charCodeAt(j+1);g.push(String.fromCharCode(((k&31)<<6)|(h&63)));j+=2}else{h=e.charCodeAt(j+1);f=e.charCodeAt(j+2);g.push(String.fromCharCode(((k&15)<<12)|((h&63)<<6)|(f&63)));j+=3}}}return g.join("")},_destrip:function(k,h){var f=[],j,g,e=[];if(h==null){h=76}k.replace(/ /g,"");j=k.length/h;for(g=0;g255){switch(g){case 8364:g=128;break;case 8218:g=130;break;case 402:g=131;break;case 8222:g=132;break;case 8230:g=133;break;case 8224:g=134;break;case 8225:g=135;break;case 710:g=136;break;case 8240:g=137;break;case 352:g=138;break;case 8249:g=139;break;case 338:g=140;break;case 381:g=142;break;case 8216:g=145;break;case 8217:g=146;break;case 8220:g=147;break;case 8221:g=148;break;case 8226:g=149;break;case 8211:g=150;break;case 8212:g=151;break;case 732:g=152;break;case 8482:g=153;break;case 353:g=154;break;case 8250:g=155;break;case 339:g=156;break;case 382:g=158;break;case 376:g=159;break;default:break}}return g};JXG.Util.utf8Decode=function(e){var g=[];var j=0;var l=0,k=0,h=0,f;if(!JXG.exists(e)){return""}while(j191)&&(l<224)){h=e.charCodeAt(j+1);g.push(String.fromCharCode(((l&31)<<6)|(h&63)));j+=2}else{h=e.charCodeAt(j+1);f=e.charCodeAt(j+2);g.push(String.fromCharCode(((l&15)<<12)|((h&63)<<6)|(f&63)));j+=3}}}return g.join("")};JXG.Util.genUUID=function(){var j="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),g=new Array(36),f=0,h;for(var e=0;e<36;e++){if(e==8||e==13||e==18||e==23){g[e]="-"}else{if(e==14){g[e]="4"}else{if(f<=2){f=33554432+(Math.random()*16777216)|0}h=f&15;f=f>>4;g[e]=j[(e==19)?(h&3)|8:h]}}}return g.join("")};JXG.PsTricks={convert:function(h){var j=new JXG.Coords(JXG.COORDS_BY_SCREEN,[0,0],h),k=new JXG.Coords(JXG.COORDS_BY_SCREEN,[h.canvasWidth,h.canvasHeight],h),f,g,e=[];e.push("\\begin{pspicture*}("+j.usrCoords[1]+","+k.usrCoords[2]+")("+k.usrCoords[1]+","+j.usrCoords[2]+")\n");for(f in h.objects){g=h.objects[f];if(g.visProp.visible){switch(g.elementClass){case JXG.OBJECT_CLASS_CIRCLE:e.push(this.addCircle(g));break;case JXG.OBJECT_CLASS_LINE:e.push(this.addLine(g));break;case JXG.OBJECT_CLASS_POINT:e.push(this.addPoint(g));break;default:switch(g.type){case JXG.OBJECT_TYPE_ARC:e.push(this.addArc(g));break;case JXG.OBJECT_TYPE_SECTOR:e.push(this.addArc(g));e.push(this.addSector(g));break;case JXG.OBJECT_TYPE_POLYGON:e.push(this.addPolygon(g));break;case JXG.OBJECT_TYPE_ANGLE:e.push(this.addAngle(g));break}break}}}e.push("\\end{pspicture*}");return e.join("\n")},setArrows:function(f){var e="";if(f.visProp.firstarrow&&f.visProp.lastarrow){e="{<->}"}else{if(f.visProp.firstarrow){e="{<-}"}else{if(f.visProp.lastarrow){e="{->}"}}}return e},drawWedge:function(g,h,i,f,k,j){var e="";if(g!="none"&&h>0){e+="\\pswedge[linestyle=none, fillstyle=solid, fillcolor="+this.parseColor(g)+", opacity="+h.toFixed(5)+"]";e+="("+i.join(",")+"){"+f+"}{"+k+"}{"+j+"}\n"}return e},addPoint:function(g){var e="\\psdot[linecolor="+this.parseColor(g.visProp.strokecolor)+",dotstyle=",h=g.normalizeFace(g.visProp.face)||"o",f=g.visProp.size>4?4:g.visProp.size,i=[0,0,"2pt 2","5pt 2","5pt 3"];if(h=="x"){e+="x, dotsize="+i[f]}else{if(h=="o"){e+="*, dotsize=";if(f==1){e+="2pt 2"}else{if(f==2){e+="4pt 2"}else{if(f==3){e+="6pt 2"}else{if(f==4){e+="6pt 3"}}}}}else{if(h=="[]"){e+="square*, dotsize="+i[f]}else{if(h=="+"){e+="+, dotsize="+i[f]}}}}e+="]("+g.coords.usrCoords.slice(1).join(",")+")\n";e+="\\rput("+(g.coords.usrCoords[1]+15/g.board.unitY)+","+(g.coords.usrCoords[2]+15/g.board.unitY)+"){\\small $"+g.name+"$}\n";return e},addLine:function(h){var g=new JXG.Coords(JXG.COORDS_BY_USER,h.point1.coords.usrCoords,h.board),f=new JXG.Coords(JXG.COORDS_BY_USER,h.point2.coords.usrCoords,h.board),e="\\psline[linecolor="+this.parseColor(h.visProp.strokecolor)+", linewidth="+h.visProp.strokewidth+"px]";if(h.visProp.straightfirst||h.visProp.straightlast){JXG.Math.Geometry.calcStraight(h,g,f)}e+=this.setArrows(h);e+="("+g.usrCoords.slice(1).join(",")+")("+f.usrCoords.slice(2).join(",")+")\n";return e},addCircle:function(g){var f=g.Radius(),e="\\pscircle[linecolor="+this.parseColor(g.visProp.strokecolor)+", linewidth="+g.visProp.strokewidth+"px";if(g.visProp.fillcolor!="none"&&g.visProp.fillopacity!=0){e+=", fillstyle=solid, fillcolor="+this.parseColor(g.visProp.fillcolor)+", opacity="+g.visProp.fillopacity.toFixed(5)}e+="]("+g.center.coords.usrCoords.slice(1).join("1")+"){"+f+"}\n";return e},addPolygon:function(g){var e="\\pspolygon[linestyle=none, fillstyle=solid, fillcolor="+this.parseColor(g.visProp.fillcolor)+", opacity="+g.visProp.fillopacity.toFixed(5)+"]",f;for(f=0;f0){z=z[0][0]}if(typeof z!="string"){return}r=window.JSON&&window.JSON.parse?window.JSON.parse(z):(new Function("return "+z))();if(r.type=="error"){this.handleError(r)}else{if(r.type=="response"){k=r.id;for(t=0;tf){e[g]=parseFloat(this.data[g][f])}}return e},getRow:function(g){var e,f;if(typeof g=="string"){for(f=0;f-1;e--){if(JXG.exists(this.sstack[e][f])){return e}}return -1},isCreator:function(e){return !!JXG.JSXGraph.elements[e]},isMathMethod:function(e){return e!=="E"&&!!Math[e]},isBuiltIn:function(e){return !!this.builtIn[e]},getvar:function(h,e){var g,f;e=JXG.def(e,false);g=this.isLocalVariable(h);if(g>-1){return this.sstack[g][h]}if(this.isCreator(h)){return this.creator(h)}if(this.isMathMethod(h)){return Math[h]}if(this.isBuiltIn(h)){return this.builtIn[h]}if(!e){g=JXG.getRef(this.board,h);if(g!==h){return g}}return f},getvarJS:function(g,e){var f;e=JXG.def(e,false);if(JXG.indexOf(this.pstack[this.pscope],g)>-1){return g}f=this.isLocalVariable(g);if(f>-1){return"$jc$.sstack["+f+"]['"+g+"']"}if(this.isCreator(g)){return"(function () { var a = Array.prototype.slice.call(arguments, 0); return $jc$.board.create.apply(this, ['"+g+"'].concat(a)); })"}if(this.isMathMethod(g)){return"Math."+g}if(this.isBuiltIn(g)){return this.builtIn[g].src}if(!e){if(JXG.isId(this.board,g)){return"$jc$.board.objects['"+g+"']"}else{if(JXG.isName(this.board,g)){return"$jc$.board.elementsByName['"+g+"']"}else{if(JXG.isGroup(this.board,g)){return"$jc$.board.groups['"+g+"']"}}}}return""},setProp:function(i,h,g){var f={},e,j;if(i.elementClass===JXG.OBJECT_CLASS_POINT&&(h==="X"||h==="Y")){h=h.toLowerCase();if(i.isDraggable&&typeof g==="number"){e=h==="x"?g:i.X();j=h==="y"?g:i.Y();i.setPosition(JXG.COORDS_BY_USER,e,j)}else{if(i.isDraggable&&(typeof g==="function"||typeof g==="string")){e=h==="x"?g:i.coords.usrCoords[1];j=h==="y"?g:i.coords.usrCoords[2];i.addConstraint([e,j])}else{if(!i.isDraggable){e=h==="x"?g:i.XEval.origin;j=h==="y"?g:i.YEval.origin;i.addConstraint([e,j])}}}this.board.update()}else{if(i.type===JXG.OBJECT_TYPE_TEXT&&(h==="X"||h==="Y")){if(typeof g==="number"){i[h]=function(){return g}}else{if(typeof g==="function"){i.isDraggable=false;i[h]=g}else{if(typeof g==="string"){i.isDraggable=false;i[h]=JXG.createFunction(g,this.board,null,true);i[h+"jc"]=g}}}i[h].origin=g;this.board.update()}else{if(i.type&&i.elementClass&&i.visProp){f[h]=g;i.setProperty(f)}else{i[h]=g}}}},utf8_encode:function(f){var e=[],h,g;for(h=0;h0){for(k=0;k"+e.substr(q[k].offset,30)+'<, expecting "'+f[k].join()+'"')}}},snippet:function(j,g,f,i){var k,l,h,e;k="jxg__tmp__intern_"+JXG.Util.genUUID().replace(/\-/g,"");if(!JXG.exists(g)){g=true}if(!JXG.exists(f)){f=""}if(!JXG.exists(i)){i=false}h=this.sstack[0][k];this.countLines=false;l=k+" = "+(g?" function ("+f+") { return ":"")+j+(g?"; }":"")+";";this.parse(l,i);e=this.sstack[0][k];if(JXG.exists(h)){this.sstack[0][k]=h}else{delete this.sstack[0][k]}this.countLines=true;return e},replaceIDs:function(g){var f,e;if(g.replaced){e=this.board.objects[g.children[1].children[0].value];if(JXG.exists(e)&&JXG.exists(e)&&e.name!==""){g.type="node_var";g.value=e.name;g.children.length=0;delete g.replaced}}if(g.children){for(f=g.children.length;f>0;f--){if(JXG.exists(g.children[f-1])){g.children[f-1]=this.replaceIDs(g.children[f-1])}}}return g},replaceNames:function(g){var f,e;e=g.value;if(g.type=="node_op"&&e=="op_lhs"&&g.children.length===1){this.isLHS=true}else{if(g.type=="node_var"){if(this.isLHS){this.letvar(e,true)}else{if(!JXG.exists(this.getvar(e,true))&&JXG.exists(this.board.elementsByName[e])){g=this.createReplacementNode(g)}}}}if(g.children){for(f=g.children.length;f>0;f--){if(JXG.exists(g.children[f-1])){g.children[f-1]=this.replaceNames(g.children[f-1])}}}if(g.type=="node_op"&&g.value=="op_lhs"&&g.children.length===1){this.isLHS=false}return g},createReplacementNode:function(g){var e=g.value,f=this.board.elementsByName[e];g=this.createNode("node_op","op_execfun",this.createNode("node_var","$"),this.createNode("node_op","op_param",this.createNode("node_str",f.id)));g.replaced=true;return g},collectDependencies:function(j,f){var h,g,k;g=j.value;if(j.type=="node_var"){k=this.getvar(g);if(k&&k.visProp&&k.type&&k.elementClass&&k.id){f[k.id]=k}}if(j.type=="node_op"&&j.value=="op_execfun"&&j.children.length>1&&j.children[0].value=="$"&&j.children[1].children.length>0){k=j.children[1].children[0].value;f[k]=this.board.objects[k]}if(j.children){for(h=j.children.length;h>0;h--){if(JXG.exists(j.children[h-1])){this.collectDependencies(j.children[h-1],f)}}}},resolveProperty:function(h,f,g){g=JXG.def(g,false);if(h&&h.type&&h.elementClass&&h.methodMap){if(f==="label"){h=h.label;f="content"}else{if(JXG.exists(h.subs[f])){h=h.subs}else{if(JXG.exists(h.methodMap[f])){f=h.methodMap[f]}else{h=h.visProp;f=f.toLowerCase()}}}}if(!JXG.exists(h)){this._error(h+" is not an object.")}if(!JXG.exists(h[f])){this._error("unknown property "+f+".")}if(g&&typeof h[f]==="function"){return function(){return h[f].apply(h,arguments)}}return h[f]},execute:function(node){var ret,v,i,e,parents=[];ret=0;if(this.cancel){this._error("Max runtime exceeded")}if(!node){return ret}this.line=node.line;switch(node.type){case"node_op":switch(node.value){case"op_none":if(node.children[0]){this.execute(node.children[0])}if(node.children[1]){ret=this.execute(node.children[1])}break;case"op_assign":v=this.execute(node.children[0]);this.lhs[this.scope]=v[1];if(v[0].type&&v[0].elementClass&&v[0].methodMap&&v[1]==="label"){this._error("Left-hand side of assignment is read-only.")}if(v[0]!==this.sstack[this.scope]||(JXG.isArray(v[0])&&typeof v[1]==="number")){this.setProp(v[0],v[1],this.execute(node.children[1]))}else{this.letvar(v[1],this.execute(node.children[1]))}this.lhs[this.scope]=0;break;case"op_noassign":ret=this.execute(node.children[0]);break;case"op_if":if(this.execute(node.children[0])){ret=this.execute(node.children[1])}break;case"op_if_else":if(this.execute(node.children[0])){ret=this.execute(node.children[1])}else{ret=this.execute(node.children[2])}break;case"op_while":while(this.execute(node.children[0])){this.execute(node.children[1])}break;case"op_do":do{this.execute(node.children[0])}while(this.execute(node.children[1]));break;case"op_for":i=new Date().getTime();for(this.execute(node.children[0]);this.execute(node.children[1]);this.execute(node.children[2])){if(new Date().getTime()-i>this.maxRuntime||this.cancel){this._error("for: max runtime exceeded");break}this.execute(node.children[3])}break;case"op_param":if(node.children[1]){this.execute(node.children[1])}ret=node.children[0];this.pstack[this.pscope].push(ret);break;case"op_paramdef":if(node.children[1]){this.execute(node.children[1])}ret=node.children[0];this.pstack[this.pscope].push(ret);break;case"op_proplst":if(node.children[0]){this.execute(node.children[0])}if(node.children[1]){this.execute(node.children[1])}break;case"op_proplst_val":this.propstack.push({});this.propscope++;this.execute(node.children[0]);ret=this.propstack[this.propscope];this.propstack.pop();this.propscope--;break;case"op_prop":this.propstack[this.propscope][node.children[0]]=this.execute(node.children[1]);break;case"op_array":var l;this.pstack.push([]);this.pscope++;this.execute(node.children[0]);ret=[];l=this.pstack[this.pscope].length;for(i=0;ithis.execute(node.children[1]);break;case"op_lot":ret=this.execute(node.children[0])=this.execute(node.children[1]);break;case"op_loe":ret=this.execute(node.children[0])<=this.execute(node.children[1]);break;case"op_or":ret=this.execute(node.children[0])||this.execute(node.children[1]);break;case"op_and":ret=this.execute(node.children[0])&&this.execute(node.children[1]);break;case"op_not":ret=!this.execute(node.children[0]);break;case"op_add":ret=JXG.Math.Statistics.add(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_sub":ret=JXG.Math.Statistics.subtract(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_div":ret=JXG.Math.Statistics.div(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_mod":ret=JXG.Math.Statistics.mod(this.execute(node.children[0]),this.execute(node.children[1]),true);break;case"op_mul":ret=this.mul(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_exp":ret=Math.pow(this.execute(node.children[0]),this.execute(node.children[1]));break;case"op_neg":ret=this.execute(node.children[0])*-1;break}break;case"node_var":ret=this.getvar(node.value);break;case"node_const":ret=Number(node.value);break;case"node_const_bool":ret=node.value.toLowerCase()!=="false";break;case"node_str":ret=node.value;break}return ret},compile:function(j,l){var g,h,k,f;g="";if(!JXG.exists(l)){l=false}if(!j){return g}switch(j.type){case"node_op":switch(j.value){case"op_none":if(j.children[0]){g=this.compile(j.children[0],l)}if(j.children[1]){g+=this.compile(j.children[1],l)}break;case"op_assign":k=this.compile(j.children[0],l);if(l){if(JXG.isArray(k)){g="$jc$.setProp("+k[0]+", '"+k[1]+"', "+this.compile(j.children[1],l)+");\n"}else{if(this.isLocalVariable(k)!==this.scope){this.sstack[this.scope][k]=true}g="$jc$.sstack["+this.scope+"]['"+k+"'] = "+this.compile(j.children[1],l)+";\n"}}else{g=k+" = "+this.compile(j.children[1],l)+";\n"}break;case"op_noassign":g=this.compile(j.children[0],l);break;case"op_if":g=" if ("+this.compile(j.children[0],l)+") "+this.compile(j.children[1],l);break;case"op_if_else":g=" if ("+this.compile(j.children[0],l)+")"+this.compile(j.children[1],l);g+=" else "+this.compile(j.children[2],l);break;case"op_while":g=" while ("+this.compile(j.children[0],l)+") {\n"+this.compile(j.children[1],l)+"}\n";break;case"op_do":g=" do {\n"+this.compile(j.children[0],l)+"} while ("+this.compile(j.children[1],l)+");\n";break;case"op_for":g=" for ("+this.compile(j.children[0],l)+"; "+this.compile(j.children[1],l)+"; "+this.compile(j.children[2],l)+") {\n"+this.compile(j.children[3],l)+"\n}\n";break;case"op_param":if(j.children[1]){g=this.compile(j.children[1],l)+", "}g+=this.compile(j.children[0],l);break;case"op_paramdef":if(j.children[1]){g=this.compile(j.children[1],l)+", "}g+=j.children[0];break;case"op_proplst":if(j.children[0]){g=this.compile(j.children[0],l)+", "}g+=this.compile(j.children[1],l);break;case"op_prop":g=j.children[0]+": "+this.compile(j.children[1],l);break;case"op_proplst_val":g=(l?"{":"<<")+this.compile(j.children[0],l)+(l?"}":">>");break;case"op_array":g="["+this.compile(j.children[0],l)+"]";break;case"op_extvalue":g=this.compile(j.children[0],l)+"["+this.compile(j.children[1],l)+"]";break;case"op_return":g=" return "+this.compile(j.children[0],l)+";\n";break;case"op_function":g=" function ("+this.compile(j.children[0],l)+") {\n"+this.compile(j.children[1],l)+"}";break;case"op_execfun":if(j.children[2]){k=(l?"{":"<<")+this.compile(j.children[2],l)+(l?"}":">>")}g=this.compile(j.children[0],l)+"("+this.compile(j.children[1],l)+(j.children[2]?", "+k:"")+")";if(l&&j.children[0].value==="$"){g="$jc$.board.objects["+this.compile(j.children[1],l)+"]"}break;case"op_property":if(l&&j.children[1]!=="X"&&j.children[1]!=="Y"){g="$jc$.resolveProperty("+this.compile(j.children[0],l)+", '"+j.children[1]+"', true)"}else{g=this.compile(j.children[0],l)+"."+j.children[1]}break;case"op_lhs":if(j.children.length===1){g=j.children[0]}else{if(j.children[2]==="dot"){if(l){g=[this.compile(j.children[1],l),j.children[0]]}else{g=this.compile(j.children[1],l)+"."+j.children[0]}}else{if(j.children[2]==="bracket"){if(l){g=[this.compile(j.children[1],l),this.compile(j.children[0],l)]}else{g=this.compile(j.children[1],l)+"["+this.compile(j.children[0],l)+"]"}}}}break;case"op_use":if(l){g="$jc$.board = JXG.JSXGraph.boards['"+j.children[0]+"']"}else{g="use "+j.children[0]+";"}break;case"op_delete":g="delete "+j.children[0];break;case"op_equ":g="("+this.compile(j.children[0],l)+" == "+this.compile(j.children[1],l)+")";break;case"op_neq":g="("+this.compile(j.children[0],l)+" != "+this.compile(j.children[1],l)+")";break;case"op_approx":g="("+this.compile(j.children[0],l)+" ~= "+this.compile(j.children[1],l)+")";break;case"op_grt":g="("+this.compile(j.children[0],l)+" > "+this.compile(j.children[1],l)+")";break;case"op_lot":g="("+this.compile(j.children[0],l)+" < "+this.compile(j.children[1],l)+")";break;case"op_gre":g="("+this.compile(j.children[0],l)+" >= "+this.compile(j.children[1],l)+")";break;case"op_loe":g="("+this.compile(j.children[0],l)+" <= "+this.compile(j.children[1],l)+")";break;case"op_or":g="("+this.compile(j.children[0],l)+" || "+this.compile(j.children[1],l)+")";break;case"op_and":g="("+this.compile(j.children[0],l)+" && "+this.compile(j.children[1],l)+")";break;case"op_not":g="!("+this.compile(j.children[0],l)+")";break;case"op_add":if(l){g="JXG.Math.Statistics.add("+this.compile(j.children[0],l)+", "+this.compile(j.children[1],l)+")"}else{g="("+this.compile(j.children[0],l)+" + "+this.compile(j.children[1],l)+")"}break;case"op_sub":if(l){g="JXG.Math.Statistics.subtract("+this.compile(j.children[0],l)+", "+this.compile(j.children[1],l)+")"}else{g="("+this.compile(j.children[0],l)+" - "+this.compile(j.children[1],l)+")"}break;case"op_div":if(l){g="JXG.Math.Statistics.div("+this.compile(j.children[0],l)+", "+this.compile(j.children[1],l)+")"}else{g="("+this.compile(j.children[0],l)+" / "+this.compile(j.children[1],l)+")"}break;case"op_mod":if(l){g="JXG.Math.mod("+this.compile(j.children[0],l)+", "+this.compile(j.children[1],l)+", true)"}else{g="("+this.compile(j.children[0],l)+" % "+this.compile(j.children[1],l)+")"}break;case"op_mul":if(l){g="$jc$.mul("+this.compile(j.children[0],l)+", "+this.compile(j.children[1],l)+")"}else{g="("+this.compile(j.children[0],l)+" * "+this.compile(j.children[1],l)+")"}break;case"op_exp":if(l){g="Math.pow("+this.compile(j.children[0],l)+", "+this.compile(j.children[1],l)+")"}else{g="("+this.compile(j.children[0],l)+"^"+this.compile(j.children[1],l)+")"}break;case"op_neg":g="(-"+this.compile(j.children[0],l)+")";break}break;case"node_var":if(l){g=this.getvarJS(j.value)}else{g=j.value}break;case"node_const":g=j.value;break;case"node_const_bool":g=j.value;break;case"node_str":g="'"+j.value.replace(/'/g,"\\'")+"'";break}if(j.needsBrackets){g="{\n"+g+"}\n"}return g},X:function(f){return f.X()},Y:function(f){return f.Y()},V:function(f){return f.Value()},L:function(f){return f.L()},dist:function(f,e){if(!JXG.exists(f)||!JXG.exists(f.Dist)){this._error("Error: Can't calculate distance.")}return f.Dist(e)},mul:function(f,e){if(JXG.isArray(f)*JXG.isArray(e)){return JXG.Math.innerProduct(f,e,Math.min(f.length,e.length))}else{return JXG.Math.Statistics.multiply(f,e)}},defineBuiltIn:function(){var e=this,f={PI:Math.PI,EULER:Math.E,X:e.X,Y:e.Y,V:e.V,L:e.L,dist:e.dist,rad:JXG.Math.Geometry.rad,deg:JXG.Math.Geometry.trueAngle,factorial:JXG.Math.factorial,trunc:JXG.trunc,"$":e.getElementById};f.rad.sc=JXG.Math.Geometry;f.deg.sc=JXG.Math.Geometry;f.factorial.sc=JXG.Math;f.PI.src="Math.PI";f.EULER.src="Math.E";f.X.src="$jc$.X";f.Y.src="$jc$.Y";f.V.src="$jc$.V";f.L.src="$jc$.L";f.dist.src="$jc$.dist";f.rad.src="JXG.Math.Geometry.rad";f.deg.src="JXG.Math.Geometry.trueAngle";f.factorial.src="JXG.Math.factorial";f.trunc.src="JXG.trunc";f["$"].src="(function (n) { return JXG.getRef($jc$.board, n); })";return f},_debug:function(e){if(typeof console!=="undefined"){console.log(e)}else{if(document.getElementById("debug")!==null){document.getElementById("debug").innerHTML+=e+"
"}}},_error:function(g){var f=new Error("Error("+this.line+"): "+g);f.line=this.line;throw f},_warn:function(e){if(typeof console!=="undefined"){console.log("Warning("+this.line+"): "+e)}else{if(document.getElementById(this.warnLog)!==null){document.getElementById(this.warnLog).innerHTML+="Warning("+this.line+"): "+e+"
"}}}});JXG.extend(JXG.JessieCode.prototype,{_lex:function(e){var i,f=-1,h=0,k=0,j,g;while(1){i=0;f=-1;h=0;k=0;j=e.offset+1+(h-k);do{j--;i=0;f=-2;k=j;if(e.src.length<=k){return 66}do{g=e.src.charCodeAt(j);switch(i){case 0:if((g>=9&&g<=10)||g==13||g==32){i=1}else{if(g==33){i=2}else{if(g==35){i=3}else{if(g==36||(g>=65&&g<=67)||(g>=71&&g<=72)||(g>=74&&g<=81)||g==83||g==86||(g>=88&&g<=90)||g==95||(g>=97&&g<=99)||(g>=103&&g<=104)||(g>=106&&g<=113)||g==115||g==118||(g>=120&&g<=122)){i=4}else{if(g==37){i=5}else{if(g==40){i=6}else{if(g==41){i=7}else{if(g==42){i=8}else{if(g==43){i=9}else{if(g==44){i=10}else{if(g==45){i=11}else{if(g==46){i=12}else{if(g==47){i=13}else{if((g>=48&&g<=57)){i=14}else{if(g==58){i=15}else{if(g==59){i=16}else{if(g==60){i=17}else{if(g==61){i=18}else{if(g==62){i=19}else{if(g==91){i=20}else{if(g==93){i=21}else{if(g==94){i=22}else{if(g==123){i=23}else{if(g==124){i=24}else{if(g==125){i=25}else{if(g==38){i=48}else{if(g==68||g==100){i=49}else{if(g==39){i=51}else{if(g==73||g==105){i=52}else{if(g==126){i=53}else{if(g==70||g==102){i=64}else{if(g==85||g==117){i=65}else{if(g==69||g==101){i=73}else{if(g==84||g==116){i=74}else{if(g==87||g==119){i=80}else{if(g==82||g==114){i=84}else{i=-1}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}break;case 1:i=-1;f=2;h=j;break;case 2:if(g==61){i=26}else{i=-1}f=31;h=j;break;case 3:i=-1;f=41;h=j;break;case 4:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=45;h=j;break;case 5:i=-1;f=35;h=j;break;case 6:i=-1;f=38;h=j;break;case 7:i=-1;f=39;h=j;break;case 8:i=-1;f=36;h=j;break;case 9:i=-1;f=32;h=j;break;case 10:i=-1;f=40;h=j;break;case 11:i=-1;f=33;h=j;break;case 12:if((g>=48&&g<=57)){i=29}else{i=-1}f=44;h=j;break;case 13:i=-1;f=34;h=j;break;case 14:if((g>=48&&g<=57)){i=14}else{if(g==46){i=29}else{i=-1}}f=47;h=j;break;case 15:i=-1;f=42;h=j;break;case 16:i=-1;f=20;h=j;break;case 17:if(g==60){i=30}else{if(g==61){i=31}else{i=-1}}f=28;h=j;break;case 18:if(g==61){i=32}else{i=-1}f=21;h=j;break;case 19:if(g==61){i=33}else{if(g==62){i=34}else{i=-1}}f=27;h=j;break;case 20:i=-1;f=16;h=j;break;case 21:i=-1;f=17;h=j;break;case 22:i=-1;f=37;h=j;break;case 23:i=-1;f=18;h=j;break;case 24:if(g==124){i=37}else{i=-1}f=43;h=j;break;case 25:i=-1;f=19;h=j;break;case 26:i=-1;f=23;h=j;break;case 27:i=-1;f=30;h=j;break;case 28:i=-1;f=46;h=j;break;case 29:if((g>=48&&g<=57)){i=29}else{i=-1}f=48;h=j;break;case 30:i=-1;f=14;h=j;break;case 31:i=-1;f=25;h=j;break;case 32:i=-1;f=22;h=j;break;case 33:i=-1;f=26;h=j;break;case 34:i=-1;f=15;h=j;break;case 35:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=6;h=j;break;case 36:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=3;h=j;break;case 37:i=-1;f=29;h=j;break;case 38:i=-1;f=24;h=j;break;case 39:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=7;h=j;break;case 40:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=9;h=j;break;case 41:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=4;h=j;break;case 42:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=12;h=j;break;case 43:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=13;h=j;break;case 44:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=5;h=j;break;case 45:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=11;h=j;break;case 46:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=10;h=j;break;case 47:if((g>=48&&g<=57)||(g>=65&&g<=90)||g==95||(g>=97&&g<=122)){i=4}else{i=-1}f=8;h=j;break;case 48:if(g==38){i=27}else{i=-1}break;case 49:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=78)||(g>=80&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=110)||(g>=112&&g<=122)){i=4}else{if(g==79||g==111){i=35}else{if(g==69||g==101){i=81}else{i=-1}}}f=45;h=j;break;case 50:if(g==39){i=28}else{if((g>=0&&g<=38)||(g>=40&&g<=91)||(g>=93&&g<=254)){i=51}else{if(g==92){i=55}else{i=-1}}}f=46;h=j;break;case 51:if(g==39){i=28}else{if((g>=0&&g<=38)||(g>=40&&g<=91)||(g>=93&&g<=254)){i=51}else{if(g==92){i=55}else{i=-1}}}break;case 52:if((g>=48&&g<=57)||(g>=65&&g<=69)||(g>=71&&g<=90)||g==95||(g>=97&&g<=101)||(g>=103&&g<=122)){i=4}else{if(g==70||g==102){i=36}else{i=-1}}f=45;h=j;break;case 53:if(g==61){i=38}else{i=-1}break;case 54:if((g>=48&&g<=57)||(g>=65&&g<=81)||(g>=83&&g<=90)||g==95||(g>=97&&g<=113)||(g>=115&&g<=122)){i=4}else{if(g==82||g==114){i=39}else{i=-1}}f=45;h=j;break;case 55:if(g==39){i=50}else{if((g>=0&&g<=38)||(g>=40&&g<=91)||(g>=93&&g<=254)){i=51}else{if(g==92){i=55}else{i=-1}}}break;case 56:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=40}else{i=-1}}f=45;h=j;break;case 57:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=41}else{i=-1}}f=45;h=j;break;case 58:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=42}else{i=-1}}f=45;h=j;break;case 59:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=43}else{i=-1}}f=45;h=j;break;case 60:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=44}else{i=-1}}f=45;h=j;break;case 61:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=45}else{i=-1}}f=45;h=j;break;case 62:if((g>=48&&g<=57)||(g>=65&&g<=77)||(g>=79&&g<=90)||g==95||(g>=97&&g<=109)||(g>=111&&g<=122)){i=4}else{if(g==78||g==110){i=46}else{i=-1}}f=45;h=j;break;case 63:if((g>=48&&g<=57)||(g>=65&&g<=77)||(g>=79&&g<=90)||g==95||(g>=97&&g<=109)||(g>=111&&g<=122)){i=4}else{if(g==78||g==110){i=47}else{i=-1}}f=45;h=j;break;case 64:if((g>=48&&g<=57)||(g>=66&&g<=78)||(g>=80&&g<=84)||(g>=86&&g<=90)||g==95||(g>=98&&g<=110)||(g>=112&&g<=116)||(g>=118&&g<=122)){i=4}else{if(g==79||g==111){i=54}else{if(g==65||g==97){i=75}else{if(g==85||g==117){i=86}else{i=-1}}}}f=45;h=j;break;case 65:if((g>=48&&g<=57)||(g>=65&&g<=82)||(g>=84&&g<=90)||g==95||(g>=97&&g<=114)||(g>=116&&g<=122)){i=4}else{if(g==83||g==115){i=56}else{i=-1}}f=45;h=j;break;case 66:if((g>=48&&g<=57)||(g>=65&&g<=82)||(g>=84&&g<=90)||g==95||(g>=97&&g<=114)||(g>=116&&g<=122)){i=4}else{if(g==83||g==115){i=57}else{i=-1}}f=45;h=j;break;case 67:if((g>=48&&g<=57)||(g>=65&&g<=84)||(g>=86&&g<=90)||g==95||(g>=97&&g<=116)||(g>=118&&g<=122)){i=4}else{if(g==85||g==117){i=58}else{i=-1}}f=45;h=j;break;case 68:if((g>=48&&g<=57)||(g>=65&&g<=82)||(g>=84&&g<=90)||g==95||(g>=97&&g<=114)||(g>=116&&g<=122)){i=4}else{if(g==83||g==115){i=59}else{i=-1}}f=45;h=j;break;case 69:if((g>=48&&g<=57)||(g>=65&&g<=75)||(g>=77&&g<=90)||g==95||(g>=97&&g<=107)||(g>=109&&g<=122)){i=4}else{if(g==76||g==108){i=60}else{i=-1}}f=45;h=j;break;case 70:if((g>=48&&g<=57)||(g>=65&&g<=83)||(g>=85&&g<=90)||g==95||(g>=97&&g<=115)||(g>=117&&g<=122)){i=4}else{if(g==84||g==116){i=61}else{i=-1}}f=45;h=j;break;case 71:if((g>=48&&g<=57)||(g>=65&&g<=81)||(g>=83&&g<=90)||g==95||(g>=97&&g<=113)||(g>=115&&g<=122)){i=4}else{if(g==82||g==114){i=62}else{i=-1}}f=45;h=j;break;case 72:if((g>=48&&g<=57)||(g>=65&&g<=78)||(g>=80&&g<=90)||g==95||(g>=97&&g<=110)||(g>=112&&g<=122)){i=4}else{if(g==79||g==111){i=63}else{i=-1}}f=45;h=j;break;case 73:if((g>=48&&g<=57)||(g>=65&&g<=75)||(g>=77&&g<=90)||g==95||(g>=97&&g<=107)||(g>=109&&g<=122)){i=4}else{if(g==76||g==108){i=66}else{i=-1}}f=45;h=j;break;case 74:if((g>=48&&g<=57)||(g>=65&&g<=81)||(g>=83&&g<=90)||g==95||(g>=97&&g<=113)||(g>=115&&g<=122)){i=4}else{if(g==82||g==114){i=67}else{i=-1}}f=45;h=j;break;case 75:if((g>=48&&g<=57)||(g>=65&&g<=75)||(g>=77&&g<=90)||g==95||(g>=97&&g<=107)||(g>=109&&g<=122)){i=4}else{if(g==76||g==108){i=68}else{i=-1}}f=45;h=j;break;case 76:if((g>=48&&g<=57)||(g>=65&&g<=72)||(g>=74&&g<=90)||g==95||(g>=97&&g<=104)||(g>=106&&g<=122)){i=4}else{if(g==73||g==105){i=69}else{i=-1}}f=45;h=j;break;case 77:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=70}else{i=-1}}f=45;h=j;break;case 78:if((g>=48&&g<=57)||(g>=65&&g<=84)||(g>=86&&g<=90)||g==95||(g>=97&&g<=116)||(g>=118&&g<=122)){i=4}else{if(g==85||g==117){i=71}else{i=-1}}f=45;h=j;break;case 79:if((g>=48&&g<=57)||(g>=65&&g<=72)||(g>=74&&g<=90)||g==95||(g>=97&&g<=104)||(g>=106&&g<=122)){i=4}else{if(g==73||g==105){i=72}else{i=-1}}f=45;h=j;break;case 80:if((g>=48&&g<=57)||(g>=65&&g<=71)||(g>=73&&g<=90)||g==95||(g>=97&&g<=103)||(g>=105&&g<=122)){i=4}else{if(g==72||g==104){i=76}else{i=-1}}f=45;h=j;break;case 81:if((g>=48&&g<=57)||(g>=65&&g<=75)||(g>=77&&g<=90)||g==95||(g>=97&&g<=107)||(g>=109&&g<=122)){i=4}else{if(g==76||g==108){i=77}else{i=-1}}f=45;h=j;break;case 82:if((g>=48&&g<=57)||(g>=65&&g<=83)||(g>=85&&g<=90)||g==95||(g>=97&&g<=115)||(g>=117&&g<=122)){i=4}else{if(g==84||g==116){i=78}else{i=-1}}f=45;h=j;break;case 83:if((g>=48&&g<=57)||(g>=65&&g<=83)||(g>=85&&g<=90)||g==95||(g>=97&&g<=115)||(g>=117&&g<=122)){i=4}else{if(g==84||g==116){i=79}else{i=-1}}f=45;h=j;break;case 84:if((g>=48&&g<=57)||(g>=65&&g<=68)||(g>=70&&g<=90)||g==95||(g>=97&&g<=100)||(g>=102&&g<=122)){i=4}else{if(g==69||g==101){i=82}else{i=-1}}f=45;h=j;break;case 85:if((g>=48&&g<=57)||(g>=65&&g<=66)||(g>=68&&g<=90)||g==95||(g>=97&&g<=98)||(g>=100&&g<=122)){i=4}else{if(g==67||g==99){i=83}else{i=-1}}f=45;h=j;break;case 86:if((g>=48&&g<=57)||(g>=65&&g<=77)||(g>=79&&g<=90)||g==95||(g>=97&&g<=109)||(g>=111&&g<=122)){i=4}else{if(g==78||g==110){i=85}else{i=-1}}f=45;h=j;break}if(i>-1){if(g==10){e.line++;e.column=0;if(this.countLines){this.parCurLine=e.line;this.parCurColumn=e.column}}e.column++}j++}while(i>-1)}while(2>-1&&f==2);if(f>-1){e.att=e.src.substr(k,h-k);e.offset=h;if(f==46){e.att=e.att.substr(1,e.att.length-2);e.att=e.att.replace(/\\\'/g,"'")}}else{e.att=new String();f=-1}break}return f},_parse:function(e,k,h){var t=[],s=[],l=0,q,o,n,g={la:0,act:0,offset:0,src:e,att:"",line:1,column:1,error_step:0};var m=new Array(new Array(0,1),new Array(49,2),new Array(49,0),new Array(51,2),new Array(51,0),new Array(52,3),new Array(52,1),new Array(52,0),new Array(54,3),new Array(54,1),new Array(54,0),new Array(55,3),new Array(56,3),new Array(56,1),new Array(56,0),new Array(58,3),new Array(50,3),new Array(50,5),new Array(50,3),new Array(50,5),new Array(50,9),new Array(50,3),new Array(50,2),new Array(50,2),new Array(50,2),new Array(50,2),new Array(50,3),new Array(50,1),new Array(57,3),new Array(57,4),new Array(57,1),new Array(53,3),new Array(53,3),new Array(53,3),new Array(53,3),new Array(53,3),new Array(53,3),new Array(53,3),new Array(53,1),new Array(61,3),new Array(61,3),new Array(61,2),new Array(61,1),new Array(60,3),new Array(60,3),new Array(60,1),new Array(62,3),new Array(62,3),new Array(62,3),new Array(62,1),new Array(63,3),new Array(63,1),new Array(64,2),new Array(64,2),new Array(64,1),new Array(59,4),new Array(59,4),new Array(59,5),new Array(59,3),new Array(59,1),new Array(65,1),new Array(65,1),new Array(65,1),new Array(65,3),new Array(65,1),new Array(65,7),new Array(65,3),new Array(65,3),new Array(65,1),new Array(65,1));var j=new Array(new Array(),new Array(3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(38,40),new Array(45,41),new Array(45,42),new Array(3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(20,44),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51,20,52),new Array(),new Array(),new Array(21,54),new Array(30,55,29,56),new Array(44,57,38,58,16,59),new Array(21,-30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(32,61,33,62),new Array(),new Array(35,63,34,64,36,65),new Array(),new Array(),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(),new Array(38,67),new Array(45,70),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(),new Array(),new Array(),new Array(37,73),new Array(47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51,3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(44,77,38,58,16,78),new Array(),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51,3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(5,80),new Array(45,17,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(20,83),new Array(),new Array(),new Array(),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(),new Array(19,91,3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(45,96),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(30,55,29,56),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(39,104,24,45,23,46,26,47,25,48,27,49,28,50,22,51),new Array(45,106),new Array(15,107,40,108),new Array(),new Array(42,109),new Array(17,110,40,111),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(44,77,38,58,16,78),new Array(44,77,38,58,16,78),new Array(4,113),new Array(45,114),new Array(33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(20,117),new Array(44,57,38,58,16,59),new Array(),new Array(30,55,29,56),new Array(30,55,29,56),new Array(30,55,29,56),new Array(30,55,29,56),new Array(30,55,29,56),new Array(30,55,29,56),new Array(30,55,29,56),new Array(),new Array(),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51),new Array(32,61,33,62),new Array(32,61,33,62),new Array(21,-28),new Array(39,118,40,111),new Array(17,119,32,61,33,62),new Array(35,63,34,64,36,65),new Array(35,63,34,64,36,65),new Array(),new Array(),new Array(),new Array(),new Array(39,120,40,121),new Array(),new Array(),new Array(45,70),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(),new Array(3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(),new Array(17,126,32,61,33,62),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51,20,127),new Array(31,18,33,33,32,34,47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(47,22,48,23,45,37,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(21,-29),new Array(18,130),new Array(45,131),new Array(),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51),new Array(),new Array(),new Array(),new Array(24,45,23,46,26,47,25,48,27,49,28,50,22,51,20,132),new Array(44,77,38,58,16,78),new Array(),new Array(),new Array(45,17,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30),new Array(19,135,3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array(39,136),new Array(),new Array(3,3,5,4,6,5,7,6,9,7,11,8,10,9,18,12,20,13,45,17,31,18,47,22,48,23,38,24,46,25,8,26,14,27,16,28,12,29,13,30,33,33,32,34),new Array());var f=new Array(new Array(49,1),new Array(50,2,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(53,35,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(53,38,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(50,39,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(),new Array(),new Array(50,43,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(),new Array(51,53),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(61,60,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(53,66,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(),new Array(54,68,55,69),new Array(52,71,53,72,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(),new Array(),new Array(),new Array(59,74,65,20),new Array(59,75,65,20),new Array(50,76,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(),new Array(50,79,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(58,81,57,14,59,82,65,20),new Array(),new Array(),new Array(),new Array(),new Array(61,84,60,19,62,21,63,31,64,32,59,36,65,20),new Array(61,85,60,19,62,21,63,31,64,32,59,36,65,20),new Array(61,86,60,19,62,21,63,31,64,32,59,36,65,20),new Array(61,87,60,19,62,21,63,31,64,32,59,36,65,20),new Array(61,88,60,19,62,21,63,31,64,32,59,36,65,20),new Array(61,89,60,19,62,21,63,31,64,32,59,36,65,20),new Array(61,90,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(50,92,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(53,93,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(60,94,62,21,63,31,64,32,59,36,65,20),new Array(60,95,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(52,97,53,72,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(60,98,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(62,99,63,31,64,32,59,36,65,20),new Array(62,100,63,31,64,32,59,36,65,20),new Array(63,101,64,32,59,36,65,20),new Array(63,102,64,32,59,36,65,20),new Array(63,103,64,32,59,36,65,20),new Array(),new Array(56,105),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(63,112,64,32,59,36,65,20),new Array(),new Array(),new Array(),new Array(),new Array(60,115,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(53,116,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(55,122),new Array(53,123,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(53,124,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(),new Array(50,125,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(),new Array(),new Array(53,128,61,15,60,19,62,21,63,31,64,32,59,36,65,20),new Array(59,129,65,20),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(51,133),new Array(),new Array(58,134,57,14,59,82,65,20),new Array(50,92,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array(),new Array(),new Array(50,137,58,10,53,11,57,14,61,15,59,16,60,19,65,20,62,21,63,31,64,32),new Array());var r=new Array(2,0,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,27,-1,38,54,62,-1,42,59,45,60,61,-1,64,-1,10,7,68,69,49,51,-1,-1,-1,54,62,-1,-1,-1,-1,22,23,24,-1,-1,-1,-1,-1,-1,-1,25,-1,-1,-1,-1,-1,7,-1,41,-1,-1,-1,-1,-1,-1,14,-1,9,-1,-1,6,-1,52,53,16,-1,-1,18,-1,-1,-1,21,37,36,35,34,33,32,31,26,3,15,40,39,58,-1,-1,44,43,48,47,46,63,-1,13,66,-1,-1,67,-1,50,-1,58,-1,-1,-1,56,55,-1,-1,8,11,5,17,55,19,-1,57,4,12,-1,-1,-1,65,-1,20);var p=new Array("Program'","ERROR_RESYNC","WHITESPACE","IF","ELSE","WHILE","DO","FOR","FUNCTION","USE","RETURN","DELETE","TRUE","FALSE","<<",">>","[","]","{","}",";","=","==","!=","~=","<=",">=",">","<","||","&&","!","+","-","/","%","*","^","(",")",",","#",":","|",".","Identifier","String","Integer","Float","Program","Stmt","Stmt_List","Param_List","Expression","Prop_List","Prop","Param_Def_List","Lhs","Assign","ExtValue","AddSubExp","LogExp","MulDivExp","ExpExp","NegExp","Value","$");if(!k){k=[]}if(!h){h=[]}t.push(0);s.push(0);g.la=this._lex(g);while(true){g.act=139;for(n=0;n1&&g.act==139){t.pop();s.pop();for(n=0;n1&&g.act!=139){while(g.la!=66){g.act=139;for(n=0;n0){t.push(g.act);s.push(g.att);g.la=this._lex(g);if(g.error_step>0){g.error_step--}}else{q=g.act*-1;o=void (0);switch(q){case 0:o=s[s.length-1];break;case 1:this.execute(s[s.length-1]);break;case 2:o=s[s.length-0];break;case 3:o=this.createNode("node_op","op_none",s[s.length-2],s[s.length-1]);break;case 4:o=s[s.length-0];break;case 5:o=this.createNode("node_op","op_param",s[s.length-1],s[s.length-3]);break;case 6:o=this.createNode("node_op","op_param",s[s.length-1]);break;case 7:o=s[s.length-0];break;case 8:o=this.createNode("node_op","op_proplst",s[s.length-3],s[s.length-1]);break;case 9:o=s[s.length-1];break;case 10:o=s[s.length-0];break;case 11:o=this.createNode("node_op","op_prop",s[s.length-3],s[s.length-1]);break;case 12:o=this.createNode("node_op","op_paramdef",s[s.length-1],s[s.length-3]);break;case 13:o=this.createNode("node_op","op_paramdef",s[s.length-1]);break;case 14:o=s[s.length-0];break;case 15:o=this.createNode("node_op","op_assign",s[s.length-3],s[s.length-1]);break;case 16:o=this.createNode("node_op","op_if",s[s.length-2],s[s.length-1]);break;case 17:o=this.createNode("node_op","op_if_else",s[s.length-4],s[s.length-3],s[s.length-1]);break;case 18:o=this.createNode("node_op","op_while",s[s.length-2],s[s.length-1]);break;case 19:o=this.createNode("node_op","op_do",s[s.length-4],s[s.length-2]);break;case 20:o=this.createNode("node_op","op_for",s[s.length-7],s[s.length-5],s[s.length-3],s[s.length-1]);break;case 21:o=this.createNode("node_op","op_use",s[s.length-2]);break;case 22:o=this.createNode("node_op","op_delete",s[s.length-1]);break;case 23:o=this.createNode("node_op","op_return",s[s.length-1]);break;case 24:o=s[s.length-2];break;case 25:o=this.createNode("node_op","op_noassign",s[s.length-2]);break;case 26:o=s[s.length-2];o.needsBrackets=true;break;case 27:o=this.createNode("node_op","op_none");break;case 28:o=this.createNode("node_op","op_lhs",s[s.length-1],s[s.length-3],"dot");break;case 29:o=this.createNode("node_op","op_lhs",s[s.length-2],s[s.length-4],"bracket");break;case 30:o=this.createNode("node_op","op_lhs",s[s.length-1]);break;case 31:o=this.createNode("node_op","op_equ",s[s.length-3],s[s.length-1]);break;case 32:o=this.createNode("node_op","op_lot",s[s.length-3],s[s.length-1]);break;case 33:o=this.createNode("node_op","op_grt",s[s.length-3],s[s.length-1]);break;case 34:o=this.createNode("node_op","op_loe",s[s.length-3],s[s.length-1]);break;case 35:o=this.createNode("node_op","op_gre",s[s.length-3],s[s.length-1]);break;case 36:o=this.createNode("node_op","op_neq",s[s.length-3],s[s.length-1]);break;case 37:o=this.createNode("node_op","op_approx",s[s.length-3],s[s.length-1]);break;case 38:o=s[s.length-1];break;case 39:o=this.createNode("node_op","op_or",s[s.length-3],s[s.length-1]);break;case 40:o=this.createNode("node_op","op_and",s[s.length-3],s[s.length-1]);break;case 41:o=this.createNode("node_op","op_not",s[s.length-1]);break;case 42:o=s[s.length-1];break;case 43:o=this.createNode("node_op","op_sub",s[s.length-3],s[s.length-1]);break;case 44:o=this.createNode("node_op","op_add",s[s.length-3],s[s.length-1]);break;case 45:o=s[s.length-1];break;case 46:o=this.createNode("node_op","op_mul",s[s.length-3],s[s.length-1]);break;case 47:o=this.createNode("node_op","op_div",s[s.length-3],s[s.length-1]);break;case 48:o=this.createNode("node_op","op_mod",s[s.length-3],s[s.length-1]);break;case 49:o=s[s.length-1];break;case 50:o=this.createNode("node_op","op_exp",s[s.length-3],s[s.length-1]);break;case 51:o=s[s.length-1];break;case 52:o=this.createNode("node_op","op_neg",s[s.length-1]);break;case 53:o=s[s.length-1];break;case 54:o=s[s.length-1];break;case 55:o=this.createNode("node_op","op_extvalue",s[s.length-4],s[s.length-2]);break;case 56:o=this.createNode("node_op","op_execfun",s[s.length-4],s[s.length-2]);break;case 57:o=this.createNode("node_op","op_execfun",s[s.length-5],s[s.length-3],s[s.length-1]);break;case 58:o=this.createNode("node_op","op_property",s[s.length-3],s[s.length-1]);break;case 59:o=s[s.length-1];break;case 60:o=this.createNode("node_const",s[s.length-1]);break;case 61:o=this.createNode("node_const",s[s.length-1]);break;case 62:o=this.createNode("node_var",s[s.length-1]);break;case 63:o=s[s.length-2];break;case 64:o=this.createNode("node_str",s[s.length-1]);break;case 65:o=this.createNode("node_op","op_function",s[s.length-5],s[s.length-2]);break;case 66:o=this.createNode("node_op","op_proplst_val",s[s.length-2]);break;case 67:o=this.createNode("node_op","op_array",s[s.length-2]);break;case 68:o=this.createNode("node_const_bool",s[s.length-1]);break;case 69:o=this.createNode("node_const_bool",s[s.length-1]);break}for(n=0;n> "}}else{return"null"}case"string":return"'"+h.replace(/(["'])/g,"\\$1")+"'";case"number":case"boolean":return new String(h);case"null":return"null"}},toJessie:function(g){var h=this.dump(g),e=[],f;for(f=0;f0){e.push("// "+h[f].attributes.name)}e.push("s"+f+" = "+h[f].type+"("+h[f].parents.join(", ")+") "+this.toJSAN(h[f].attributes).replace(/\n/,"\\n")+";");e.push("")}return e.join("\n")},toJavaScript:function(g){var h=this.dump(g),e=[],f;for(f=0;f0){f=this.joinTransforms(i,g);h=[f[1][1],f[2][1],f[1][2],f[2][2],f[1][0],f[2][0]].join(",");k+=" matrix("+h+") ";j.setAttributeNS(null,"transform",k)}},updateImageURL:function(f){var e=JXG.evaluate(f.url);f.rendNode.setAttributeNS(this.xlinkNamespace,"xlink:href",e)},appendChildPrim:function(e,f){if(!JXG.exists(f)){f=0}else{if(f>=JXG.Options.layer.numlayers){f=JXG.Options.layer.numlayers-1}}this.layer[f].appendChild(e)},appendNodesToElement:function(e){e.rendNode=this.getElementById(e.id)},createPrim:function(e,g){var f=this.container.ownerDocument.createElementNS(this.svgNamespace,e);f.setAttributeNS(null,"id",this.container.id+"_"+g);f.style.position="absolute";if(e==="path"){f.setAttributeNS(null,"stroke-linecap","butt");f.setAttributeNS(null,"stroke-linejoin","round")}return f},remove:function(e){if(JXG.exists(e)&&JXG.exists(e.parentNode)){e.parentNode.removeChild(e)}},makeArrows:function(f){var e;if(f.visPropOld.firstarrow===f.visProp.firstarrow&&f.visPropOld.lastarrow===f.visProp.lastarrow){return}if(f.visProp.firstarrow){e=f.rendNodeTriangleStart;if(!JXG.exists(e)){e=this._createArrowHead(f,"End");this.defs.appendChild(e);f.rendNodeTriangleStart=e;f.rendNode.setAttributeNS(null,"marker-start","url(#"+this.container.id+"_"+f.id+"TriangleEnd)")}}else{e=f.rendNodeTriangleStart;if(JXG.exists(e)){this.remove(e)}}if(f.visProp.lastarrow){e=f.rendNodeTriangleEnd;if(!JXG.exists(e)){e=this._createArrowHead(f,"Start");this.defs.appendChild(e);f.rendNodeTriangleEnd=e;f.rendNode.setAttributeNS(null,"marker-end","url(#"+this.container.id+"_"+f.id+"TriangleStart)")}}else{e=f.rendNodeTriangleEnd;if(JXG.exists(e)){this.remove(e)}}f.visPropOld.firstarrow=f.visProp.firstarrow;f.visPropOld.lastarrow=f.visProp.lastarrow},updateEllipsePrim:function(f,e,i,h,g){f.setAttributeNS(null,"cx",e);f.setAttributeNS(null,"cy",i);f.setAttributeNS(null,"rx",Math.abs(h));f.setAttributeNS(null,"ry",Math.abs(g))},updateLinePrim:function(i,f,e,h,g){if(!isNaN(f+e+h+g)){i.setAttributeNS(null,"x1",f);i.setAttributeNS(null,"y1",e);i.setAttributeNS(null,"x2",h);i.setAttributeNS(null,"y2",g)}},updatePathPrim:function(e,f){if(f==""){f="M 0 0"}e.setAttributeNS(null,"d",f)},updatePathStringPoint:function(i,f,h){var g="",k=i.coords.scrCoords,j=f*Math.sqrt(3)*0.5,e=f*0.5;if(h==="x"){g=" M "+(k[1]-f)+" "+(k[2]-f)+" L "+(k[1]+f)+" "+(k[2]+f)+" M "+(k[1]+f)+" "+(k[2]-f)+" L "+(k[1]-f)+" "+(k[2]+f)}else{if(h==="+"){g=" M "+(k[1]-f)+" "+(k[2])+" L "+(k[1]+f)+" "+(k[2])+" M "+(k[1])+" "+(k[2]-f)+" L "+(k[1])+" "+(k[2]+f)}else{if(h==="<>"){g=" M "+(k[1]-f)+" "+(k[2])+" L "+(k[1])+" "+(k[2]+f)+" L "+(k[1]+f)+" "+(k[2])+" L "+(k[1])+" "+(k[2]-f)+" Z "}else{if(h==="^"){g=" M "+(k[1])+" "+(k[2]-f)+" L "+(k[1]-j)+" "+(k[2]+e)+" L "+(k[1]+j)+" "+(k[2]+e)+" Z "}else{if(h==="v"){g=" M "+(k[1])+" "+(k[2]+f)+" L "+(k[1]-j)+" "+(k[2]-e)+" L "+(k[1]+j)+" "+(k[2]-e)+" Z "}else{if(h===">"){g=" M "+(k[1]+f)+" "+(k[2])+" L "+(k[1]-e)+" "+(k[2]-j)+" L "+(k[1]-e)+" "+(k[2]+j)+" Z "}else{if(h==="<"){g=" M "+(k[1]-f)+" "+(k[2])+" L "+(k[1]+e)+" "+(k[2]-j)+" L "+(k[1]+e)+" "+(k[2]+j)+" Z "}}}}}}}return g},updatePathStringPrim:function(e){var g=" M ",h=" L ",f=g,n=5000,k="",j,m,o=(e.visProp.curvetype!=="plot"),l;if(e.numberPoints<=0){return""}if(o&&e.board.options.curve.RDPsmoothing){e.points=JXG.Math.Numerics.RamerDouglasPeuker(e.points,0.5)}l=Math.min(e.points.length,e.numberPoints);for(j=0;jn){m[1]=n}else{if(m[1]<-n){m[1]=-n}}if(m[2]>n){m[2]=n}else{if(m[2]<-n){m[2]=-n}}k+=[f,m[1]," ",m[2]].join("");f=h}}return k},updatePathStringBezierPrim:function(g){var l=" M ",m=" C ",k=l,u=5000,p="",o,n,s,h,e,r=g.visProp.strokewidth,t=(g.visProp.curvetype!=="plot"),q;if(g.numberPoints<=0){return""}if(t&&g.board.options.curve.RDPsmoothing){g.points=JXG.Math.Numerics.RamerDouglasPeuker(g.points,0.5)}q=Math.min(g.points.length,g.numberPoints);for(n=1;n<3;n++){k=l;for(o=0;ou){s[1]=u}else{if(s[1]<-u){s[1]=-u}}if(s[2]>u){s[2]=u}else{if(s[2]<-u){s[2]=-u}}if(k==l){p+=[k,s[1]+0*r*(2*n*Math.random()-n)," ",s[2]+0*r*(2*n*Math.random()-n)].join("")}else{p+=[k,(h+(s[1]-h)*0.333+r*(2*n*Math.random()-n))," ",(e+(s[2]-e)*0.333+r*(2*n*Math.random()-n))," ",(h+2*(s[1]-h)*0.333+r*(2*n*Math.random()-n))," ",(e+2*(s[2]-e)*0.333+r*(2*n*Math.random()-n))," ",s[1]," ",s[2]].join("")}k=m;h=s[1];e=s[2]}}}return p},updatePolygonPrim:function(j,h){var k="",f,g,e=h.vertices.length;j.setAttributeNS(null,"stroke","none");for(g=0;g0){f.setAttributeNS(null,"stroke-dasharray",this.dashArray[g-1])}else{if(f.hasAttributeNS(null,"stroke-dasharray")){f.removeAttributeNS(null,"stroke-dasharray")}}},setGradient:function(g){var o=g.rendNode,h,j,i,n,m,f,e,l,k;j=JXG.evaluate(g.visProp.fillopacity);j=(j>0)?j:0;h=JXG.evaluate(g.visProp.fillcolor);if(g.visProp.gradient==="linear"){i=this.createPrim("linearGradient",g.id+"_gradient");f="0%";e="100%";l="0%";k="0%";i.setAttributeNS(null,"x1",f);i.setAttributeNS(null,"x2",e);i.setAttributeNS(null,"y1",l);i.setAttributeNS(null,"y2",k);n=this.createPrim("stop",g.id+"_gradient1");n.setAttributeNS(null,"offset","0%");n.setAttributeNS(null,"style","stop-color:"+h+";stop-opacity:"+j);m=this.createPrim("stop",g.id+"_gradient2");m.setAttributeNS(null,"offset","100%");m.setAttributeNS(null,"style","stop-color:"+g.visProp.gradientsecondcolor+";stop-opacity:"+g.visProp.gradientsecondopacity);i.appendChild(n);i.appendChild(m);this.defs.appendChild(i);o.setAttributeNS(null,"style","fill:url(#"+this.container.id+"_"+g.id+"_gradient)");g.gradNode1=n;g.gradNode2=m}else{if(g.visProp.gradient==="radial"){i=this.createPrim("radialGradient",g.id+"_gradient");i.setAttributeNS(null,"cx","50%");i.setAttributeNS(null,"cy","50%");i.setAttributeNS(null,"r","50%");i.setAttributeNS(null,"fx",g.visProp.gradientpositionx*100+"%");i.setAttributeNS(null,"fy",g.visProp.gradientpositiony*100+"%");n=this.createPrim("stop",g.id+"_gradient1");n.setAttributeNS(null,"offset","0%");n.setAttributeNS(null,"style","stop-color:"+g.visProp.gradientsecondcolor+";stop-opacity:"+g.visProp.gradientsecondopacity);m=this.createPrim("stop",g.id+"_gradient2");m.setAttributeNS(null,"offset","100%");m.setAttributeNS(null,"style","stop-color:"+h+";stop-opacity:"+j);i.appendChild(n);i.appendChild(m);this.defs.appendChild(i);o.setAttributeNS(null,"style","fill:url(#"+this.container.id+"_"+g.id+"_gradient)");g.gradNode1=n;g.gradNode2=m}else{o.removeAttributeNS(null,"style")}}},updateGradient:function(h){var f=h.gradNode1,e=h.gradNode2,g,i;if(!JXG.exists(f)||!JXG.exists(e)){return}i=JXG.evaluate(h.visProp.fillopacity);i=(i>0)?i:0;g=JXG.evaluate(h.visProp.fillcolor);if(h.visProp.gradient==="linear"){f.setAttributeNS(null,"style","stop-color:"+g+";stop-opacity:"+i);e.setAttributeNS(null,"style","stop-color:"+h.visProp.gradientsecondcolor+";stop-opacity:"+h.visProp.gradientsecondopacity)}else{if(h.visProp.gradient==="radial"){f.setAttributeNS(null,"style","stop-color:"+h.visProp.gradientsecondcolor+";stop-opacity:"+h.visProp.gradientsecondopacity);e.setAttributeNS(null,"style","stop-color:"+g+";stop-opacity:"+i)}}},setObjectFillColor:function(f,i,k){var g,h=JXG.evaluate(i),l,m,e=JXG.evaluate(k),j;e=(e>0)?e:0;if(f.visPropOld.fillcolor===h&&f.visPropOld.fillopacity===e){return}if(JXG.exists(h)&&h!==false){if(h.length!=9){l=h;j=e}else{m=JXG.rgba2rgbo(h);l=m[0];j=e*m[1]}g=f.rendNode;g.setAttributeNS(null,"fill",l);if(f.type===JXG.OBJECT_TYPE_IMAGE){g.setAttributeNS(null,"opacity",j)}else{g.setAttributeNS(null,"fill-opacity",j)}if(JXG.exists(f.visProp.gradient)){this.updateGradient(f)}}f.visPropOld.fillcolor=h;f.visPropOld.fillopacity=e},setObjectStrokeColor:function(f,i,j){var h=JXG.evaluate(i),l,m,e=JXG.evaluate(j),k,g;e=(e>0)?e:0;if(f.visPropOld.strokecolor===h&&f.visPropOld.strokeopacity===e){return}if(JXG.exists(h)&&h!==false){if(h.length!=9){l=h;k=e}else{m=JXG.rgba2rgbo(h);l=m[0];k=e*m[1]}g=f.rendNode;if(f.type===JXG.OBJECT_TYPE_TEXT){if(f.visProp.display==="html"){g.style.color=l;g.style.opacity=k}else{g.setAttributeNS(null,"style","fill:"+l);g.setAttributeNS(null,"style","fill-opacity:"+k)}}else{g.setAttributeNS(null,"stroke",l);g.setAttributeNS(null,"stroke-opacity",k)}if(f.type===JXG.OBJECT_TYPE_ARROW){this._setArrowAtts(f.rendNodeTriangle,l,k)}else{if(f.elementClass===JXG.OBJECT_CLASS_CURVE||f.elementClass===JXG.OBJECT_CLASS_LINE){if(f.visProp.firstarrow){this._setArrowAtts(f.rendNodeTriangleStart,l,k)}if(f.visProp.lastarrow){this._setArrowAtts(f.rendNodeTriangleEnd,l,k)}}}}f.visPropOld.strokecolor=h;f.visPropOld.strokeopacity=e},setObjectStrokeWidth:function(g,f){var e=JXG.evaluate(f),h;if(g.visPropOld.strokewidth===e){return}h=g.rendNode;this.setPropertyPrim(h,"stroked","true");if(JXG.exists(e)){this.setPropertyPrim(h,"stroke-width",e+"px")}g.visPropOld.strokewidth=e},setShadow:function(e){if(e.visPropOld.shadow===e.visProp.shadow){return}if(JXG.exists(e.rendNode)){if(e.visProp.shadow){e.rendNode.setAttributeNS(null,"filter","url(#"+this.container.id+"_f1)")}else{e.rendNode.removeAttributeNS(null,"filter")}}e.visPropOld.shadow=e.visProp.shadow},suspendRedraw:function(){},unsuspendRedraw:function(){},resize:function(e,f){this.svgRoot.style.width=parseFloat(e)+"px";this.svgRoot.style.height=parseFloat(f)+"px"}});JXG.VMLRenderer=function(f){this.type="vml";this.container=f;this.container.style.overflow="hidden";this.container.onselectstart=function(){return false};this.resolution=10;if(!JXG.exists(JXG.vmlStylesheet)){f.ownerDocument.namespaces.add("jxgvml","urn:schemas-microsoft-com:vml");JXG.vmlStylesheet=this.container.ownerDocument.createStyleSheet();JXG.vmlStylesheet.addRule(".jxgvml","behavior:url(#default#VML)")}try{!f.ownerDocument.namespaces.jxgvml&&f.ownerDocument.namespaces.add("jxgvml","urn:schemas-microsoft-com:vml");this.createNode=function(e){return f.ownerDocument.createElement("')}}catch(g){this.createNode=function(e){return f.ownerDocument.createElement("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="jxgvml">')}}this.dashArray=["Solid","1 1","ShortDash","Dash","LongDash","ShortDashDot","LongDashDot"]};JXG.VMLRenderer.prototype=new JXG.AbstractRenderer();JXG.extend(JXG.VMLRenderer.prototype,{_setAttr:function(h,g,j,f){try{if(document.documentMode===8){h[g]=j}else{h.setAttribute(g,j,f)}}catch(i){JXG.debug("_setAttr: "+g+" "+j+"
\n")}},updateTicks:function(j,k,f,l,h){var g=[],m,n,o,p,e=this.resolution;n=j.ticks.length;for(m=0;m0){r=h.rendNode.style.filter.toString();if(!r.match(/DXImageTransform/)){k.style.filter="progid:DXImageTransform.Microsoft.Matrix(M11='1.0', sizingMethod='auto expand') "+r}l=this.joinTransforms(h,u);g[0]=JXG.Math.matVecMult(l,h.coords.scrCoords);g[0][1]/=g[0][0];g[0][2]/=g[0][0];g[1]=JXG.Math.matVecMult(l,[1,h.coords.scrCoords[1]+h.size[0],h.coords.scrCoords[2]]);g[1][1]/=g[1][0];g[1][2]/=g[1][0];g[2]=JXG.Math.matVecMult(l,[1,h.coords.scrCoords[1]+h.size[0],h.coords.scrCoords[2]-h.size[1]]);g[2][1]/=g[2][0];g[2][2]/=g[2][0];g[3]=JXG.Math.matVecMult(l,[1,h.coords.scrCoords[1],h.coords.scrCoords[2]-h.size[1]]);g[3][1]/=g[3][0];g[3][2]/=g[3][0];f=g[0][1];n=g[0][1];e=g[0][2];j=g[0][2];for(o=1;o<4;o++){f=Math.max(f,g[o][1]);n=Math.min(n,g[o][1]);e=Math.max(e,g[o][2]);j=Math.min(j,g[o][2])}k.style.left=parseInt(n)+"px";k.style.top=parseInt(j)+"px";k.filters.item(0).M11=l[1][1];k.filters.item(0).M12=l[1][2];k.filters.item(0).M21=l[2][1];k.filters.item(0).M22=l[2][2]}},updateImageURL:function(f){var e=JXG.evaluate(f.url);this._setAttr(f.rendNode,"src",e)},appendChildPrim:function(e,f){if(!JXG.exists(f)){f=0}e.style.zIndex=f;this.container.appendChild(e)},appendNodesToElement:function(e,f){if(f==="shape"||f==="path"||f==="polygon"){e.rendNodePath=this.getElementById(e.id+"_path")}e.rendNodeFill=this.getElementById(e.id+"_fill");e.rendNodeStroke=this.getElementById(e.id+"_stroke");e.rendNodeShadow=this.getElementById(e.id+"_shadow");e.rendNode=this.getElementById(e.id)},createPrim:function(f,k){var g,e=this.createNode("fill"),j=this.createNode("stroke"),i=this.createNode("shadow"),h;this._setAttr(e,"id",this.container.id+"_"+k+"_fill");this._setAttr(j,"id",this.container.id+"_"+k+"_stroke");this._setAttr(i,"id",this.container.id+"_"+k+"_shadow");if(f==="circle"||f==="ellipse"){g=this.createNode("oval");g.appendChild(e);g.appendChild(j);g.appendChild(i)}else{if(f==="polygon"||f==="path"||f==="shape"||f==="line"){g=this.createNode("shape");g.appendChild(e);g.appendChild(j);g.appendChild(i);h=this.createNode("path");this._setAttr(h,"id",this.container.id+"_"+k+"_path");g.appendChild(h)}else{g=this.createNode(f);g.appendChild(e);g.appendChild(j);g.appendChild(i)}}g.style.position="absolute";g.style.left="0px";g.style.top="0px";this._setAttr(g,"id",this.container.id+"_"+k);return g},remove:function(e){if(JXG.exists(e)){e.removeNode(true)}},makeArrows:function(f){var e;if(f.visPropOld.firstarrow===f.visProp.firstarrow&&f.visPropOld.lastarrow===f.visProp.lastarrow){return}if(f.visProp.firstarrow){e=f.rendNodeStroke;this._setAttr(e,"startarrow","block");this._setAttr(e,"startarrowlength","long")}else{e=f.rendNodeStroke;if(JXG.exists(e)){this._setAttr(e,"startarrow","none")}}if(f.visProp.lastarrow){e=f.rendNodeStroke;this._setAttr(e,"id",this.container.id+"_"+f.id+"stroke");this._setAttr(e,"endarrow","block");this._setAttr(e,"endarrowlength","long")}else{e=f.rendNodeStroke;if(JXG.exists(e)){this._setAttr(e,"endarrow","none")}}f.visPropOld.firstarrow=f.visProp.firstarrow;f.visPropOld.lastarrow=f.visProp.lastarrow},updateEllipsePrim:function(f,e,i,h,g){f.style.left=parseInt(e-h)+"px";f.style.top=parseInt(i-g)+"px";f.style.width=parseInt(Math.abs(h)*2)+"px";f.style.height=parseInt(Math.abs(g)*2)+"px"},updateLinePrim:function(l,f,e,h,g,j){var i,k=this.resolution;if(!isNaN(f+e+h+g)){i=["m ",parseInt(k*f),", ",parseInt(k*e)," l ",parseInt(k*h),", ",parseInt(k*g)];this.updatePathPrim(l,i,j)}},updatePathPrim:function(g,h,f){var e=f.canvasWidth,i=f.canvasHeight;if(h.length<=0){h=["m 0,0"]}g.style.width=e;g.style.height=i;this._setAttr(g,"coordsize",[parseInt(this.resolution*e),parseInt(this.resolution*i)].join(","));this._setAttr(g,"path",h.join(""))},updatePathStringPoint:function(f,l,i){var k=[],g=Math.round,h=f.coords.scrCoords,j=l*Math.sqrt(3)*0.5,m=l*0.5,e=this.resolution;if(i==="x"){k.push([" m ",g(e*(h[1]-l)),", ",g(e*(h[2]-l))," l ",g(e*(h[1]+l)),", ",g(e*(h[2]+l))," m ",g(e*(h[1]+l)),", ",g(e*(h[2]-l))," l ",g(e*(h[1]-l)),", ",g(e*(h[2]+l))].join(""))}else{if(i==="+"){k.push([" m ",g(e*(h[1]-l)),", ",g(e*(h[2]))," l ",g(e*(h[1]+l)),", ",g(e*(h[2]))," m ",g(e*(h[1])),", ",g(e*(h[2]-l))," l ",g(e*(h[1])),", ",g(e*(h[2]+l))].join(""))}else{if(i==="<>"){k.push([" m ",g(e*(h[1]-l)),", ",g(e*(h[2]))," l ",g(e*(h[1])),", ",g(e*(h[2]+l))," l ",g(e*(h[1]+l)),", ",g(e*(h[2]))," l ",g(e*(h[1])),", ",g(e*(h[2]-l))," x e "].join(""))}else{if(i==="^"){k.push([" m ",g(e*(h[1])),", ",g(e*(h[2]-l))," l ",g(e*(h[1]-j)),", ",g(e*(h[2]+m))," l ",g(e*(h[1]+j)),", ",g(e*(h[2]+m))," x e "].join(""))}else{if(i==="v"){k.push([" m ",g(e*(h[1])),", ",g(e*(h[2]+l))," l ",g(e*(h[1]-j)),", ",g(e*(h[2]-m))," l ",g(e*(h[1]+j)),", ",g(e*(h[2]-m))," x e "].join(""))}else{if(i===">"){k.push([" m ",g(e*(h[1]+l)),", ",g(e*(h[2]))," l ",g(e*(h[1]-m)),", ",g(e*(h[2]-j))," l ",g(e*(h[1]-m)),", ",g(e*(h[2]+j))," l ",g(e*(h[1]+l)),", ",g(e*(h[2]))].join(""))}else{if(i==="<"){k.push([" m ",g(e*(h[1]-l)),", ",g(e*(h[2]))," l ",g(e*(h[1]+m)),", ",g(e*(h[2]-j))," l ",g(e*(h[1]+m)),", ",g(e*(h[2]+j))," x e "].join(""))}}}}}}}return k},updatePathStringPrim:function(f){var m=[],l,o,e=this.resolution,k=Math.round,h=" m ",j=" l ",g=h,p=(f.visProp.curvetype!=="plot"),n=Math.min(f.numberPoints,8192);if(f.numberPoints<=0){return""}if(p&&f.board.options.curve.RDPsmoothing){f.points=JXG.Math.Numerics.RamerDouglasPeuker(f.points,1)}n=Math.min(n,f.points.length);for(l=0;l20000){o[1]=20000}else{if(o[1]<-20000){o[1]=-20000}}if(o[2]>20000){o[2]=20000}else{if(o[2]<-20000){o[2]=-20000}}m.push([g,k(e*o[1]),", ",k(e*o[2])].join(""));g=j}}m.push(" e");return m},updatePathStringBezierPrim:function(h){var s=[],q,p,v,l,g,u=h.visProp.strokewidth,e=this.resolution,o=Math.round,m=" m ",n=" c ",k=m,w=(h.visProp.curvetype!=="plot"),t=Math.min(h.numberPoints,8192);if(h.numberPoints<=0){return""}if(w&&h.board.options.curve.RDPsmoothing){h.points=JXG.Math.Numerics.RamerDouglasPeuker(h.points,1)}t=Math.min(t,h.points.length);for(p=1;p<3;p++){k=m;for(q=0;q20000){v[1]=20000}else{if(v[1]<-20000){v[1]=-20000}}if(v[2]>20000){v[2]=20000}else{if(v[2]<-20000){v[2]=-20000}}if(k==m){s.push([k,o(e*(v[1]+0*u*(2*p*Math.random()-p)))," ",o(e*(v[2]+0*u*(2*p*Math.random()-p)))].join(""))}else{s.push([k,o(e*(l+(v[1]-l)*0.333+u*(2*p*Math.random()-p)))," ",o(e*(g+(v[2]-g)*0.333+u*(2*p*Math.random()-p)))," ",o(e*(l+2*(v[1]-l)*0.333+u*(2*p*Math.random()-p)))," ",o(e*(g+2*(v[2]-g)*0.333+u*(2*p*Math.random()-p)))," ",o(e*v[1])," ",o(e*v[2])].join(""))}k=n;l=v[1];g=v[2]}}}s.push(" e");return s},updatePolygonPrim:function(j,g){var f,e=g.vertices.length,h=this.resolution,k,l=[];this._setAttr(j,"stroked","false");k=g.vertices[0].coords.scrCoords;if(isNaN(k[1]+k[2])){return}l.push(["m ",parseInt(h*k[1]),",",parseInt(h*k[2])," l "].join(""));for(f=1;f=0){i.style.width=f+"px"}if(g>=0){i.style.height=g+"px"}},setPropertyPrim:function(h,g,i){var f="",e;switch(g){case"stroke":f="strokecolor";break;case"stroke-width":f="strokeweight";break;case"stroke-dasharray":f="dashstyle";break}if(f!==""){e=JXG.evaluate(i);this._setAttr(h,f,e)}},show:function(e){if(e&&e.rendNode){e.rendNode.style.visibility="inherit"}},hide:function(e){if(e&&e.rendNode){e.rendNode.style.visibility="hidden"}},setDashStyle:function(f,e){var g;if(e.dash>=0){g=f.rendNodeStroke;this._setAttr(g,"dashstyle",this.dashArray[e.dash])}},setGradient:function(f){var e=f.rendNodeFill;if(f.visProp.gradient==="linear"){this._setAttr(e,"type","gradient");this._setAttr(e,"color2",f.visProp.gradientsecondcolor);this._setAttr(e,"opacity2",f.visProp.gradientsecondopacity);this._setAttr(e,"angle",f.visProp.gradientangle)}else{if(f.visProp.gradient==="radial"){this._setAttr(e,"type","gradientradial");this._setAttr(e,"color2",f.visProp.gradientsecondcolor);this._setAttr(e,"opacity2",f.visProp.gradientsecondopacity);this._setAttr(e,"focusposition",f.visProp.gradientpositionx*100+"%,"+f.visProp.gradientpositiony*100+"%");this._setAttr(e,"focussize","0,0")}else{this._setAttr(e,"type","solid")}}},setObjectFillColor:function(f,i,j){var h=JXG.evaluate(i),l,m,e=JXG.evaluate(j),k,g=f.rendNode,n;e=(e>0)?e:0;if(f.visPropOld.fillcolor===h&&f.visPropOld.fillopacity===e){return}if(JXG.exists(h)&&h!==false){if(h.length!=9){l=h;k=e}else{m=JXG.rgba2rgbo(h);l=m[0];k=e*m[1]}if(l==="none"||l===false){this._setAttr(f.rendNode,"filled","false")}else{this._setAttr(f.rendNode,"filled","true");this._setAttr(f.rendNode,"fillcolor",l);if(JXG.exists(k)&&f.rendNodeFill){this._setAttr(f.rendNodeFill,"opacity",(k*100)+"%")}}if(f.type===JXG.OBJECT_TYPE_IMAGE){n=f.rendNode.style.filter.toString();if(n.match(/alpha/)){f.rendNode.style.filter=n.replace(/alpha\(opacity *= *[0-9\.]+\)/,"alpha(opacity = "+(k*100)+")")}else{f.rendNode.style.filter+=" alpha(opacity = "+(k*100)+")"}}}f.visPropOld.fillcolor=h;f.visPropOld.fillopacity=e},setObjectStrokeColor:function(g,j,k){var i=JXG.evaluate(j),m,n,f=JXG.evaluate(k),l,h=g.rendNode,e;f=(f>0)?f:0;if(g.visPropOld.strokecolor===i&&g.visPropOld.strokeopacity===f){return}if(JXG.exists(i)&&i!==false){if(i.length!=9){m=i;l=f}else{n=JXG.rgba2rgbo(i);m=n[0];l=f*n[1]}if(g.type===JXG.OBJECT_TYPE_TEXT){l=Math.round(l*100);h.style.filter=" alpha(opacity = "+l+")";h.style.color=m}else{if(m!==false){this._setAttr(h,"stroked","true");this._setAttr(h,"strokecolor",m)}e=g.rendNodeStroke;if(JXG.exists(l)&&g.type!==JXG.OBJECT_TYPE_IMAGE){this._setAttr(e,"opacity",(l*100)+"%")}}}g.visPropOld.strokecolor=i;g.visPropOld.strokeopacity=f},setObjectStrokeWidth:function(g,f){var e=JXG.evaluate(f),h;if(g.visPropOld.strokewidth===e){return}h=g.rendNode;this.setPropertyPrim(h,"stroked","true");if(JXG.exists(e)){this.setPropertyPrim(h,"stroke-width",e)}g.visPropOld.strokewidth=e},setShadow:function(e){var f=e.rendNodeShadow;if(!f||e.visPropOld.shadow===e.visProp.shadow){return}if(e.visProp.shadow){this._setAttr(f,"On","True");this._setAttr(f,"Offset","3pt,3pt");this._setAttr(f,"Opacity","60%");this._setAttr(f,"Color","#aaaaaa")}else{this._setAttr(f,"On","False")}e.visPropOld.shadow=e.visProp.shadow},suspendRedraw:function(){this.container.style.display="none"},unsuspendRedraw:function(){this.container.style.display=""}});JXG.CanvasRenderer=function(e){var f;this.type="canvas";this.canvasRoot=null;this.suspendHandle=null;this.canvasId=JXG.Util.genUUID();this.canvasNamespace=null;this.container=e;this.container.style.MozUserSelect="none";this.container.style.overflow="hidden";if(this.container.style.position===""){this.container.style.position="relative"}this.container.innerHTML=['<',"/canvas>"].join("");this.canvasRoot=document.getElementById(this.canvasId);this.context=this.canvasRoot.getContext("2d");this.dashArray=[[2,2],[5,5],[10,10],[20,20],[20,10,10,10],[20,5,10,5]]};JXG.CanvasRenderer.prototype=new JXG.AbstractRenderer();JXG.extend(JXG.CanvasRenderer.prototype,{_drawFilledPolygon:function(f){var h,e=f.length,g=this.context;if(e>0){g.beginPath();g.moveTo(f[0][0],f[0][1]);for(h=0;h0){g.lineTo(f[h][0],f[h][1])}}g.lineTo(f[0][0],f[0][1]);g.fill()}},_fill:function(f){var e=this.context;e.save();if(this._setColor(f,"fill")){e.fill()}e.restore()},_rotatePoint:function(f,e,g){return[(e*Math.cos(f))-(g*Math.sin(f)),(e*Math.sin(f))+(g*Math.cos(f))]},_rotateShape:function(f,h){var g,j=[],e=f.length;if(e<=0){return f}for(g=0;g0)?g:0;if(i.length!=9){m=i;l=g}else{p=JXG.rgba2rgbo(i);m=p[0];l=g*p[1]}this.context.globalAlpha=l;this.context[e+"Style"]=m}else{k=false}if(n==="stroke"){this.context.lineWidth=parseFloat(q.strokewidth)}return k},_stroke:function(f){var e=this.context;e.save();if(f.visProp.dash>0){if(e.setLineDash){e.setLineDash(this.dashArray[f.visProp.dash])}}else{this.context.lineDashArray=[]}if(this._setColor(f,"stroke")){e.stroke()}e.restore()},_translateShape:function(g,f,k){var h,j=[],e=g.length;if(e<=0){return g}for(h=0;h":h.beginPath();h.moveTo(m[1]-i,m[2]);h.lineTo(m[1],m[2]+i);h.lineTo(m[1]+i,m[2]);h.lineTo(m[1],m[2]-i);h.closePath();this._fill(j);this._stroke(j);break;case"triangleup":case"a":case"^":h.beginPath();h.moveTo(m[1],m[2]-i);h.lineTo(m[1]-l,m[2]+e);h.lineTo(m[1]+l,m[2]+e);h.closePath();this._fill(j);this._stroke(j);break;case"triangledown":case"v":h.beginPath();h.moveTo(m[1],m[2]+i);h.lineTo(m[1]-l,m[2]-e);h.lineTo(m[1]+l,m[2]-e);h.closePath();this._fill(j);this._stroke(j);break;case"triangleleft":case"<":h.beginPath();h.moveTo(m[1]-i,m[2]);h.lineTo(m[1]+e,m[2]-l);h.lineTo(m[1]+e,m[2]+l);h.closePath();this.fill(j);this._stroke(j);break;case"triangleright":case">":h.beginPath();h.moveTo(m[1]+i,m[2]);h.lineTo(m[1]-e,m[2]-l);h.lineTo(m[1]-e,m[2]+l);h.closePath();this._fill(j);this._stroke(j);break}},updatePoint:function(e){this.drawPoint(e)},drawLine:function(e){var g=new JXG.Coords(JXG.COORDS_BY_USER,e.point1.coords.usrCoords,e.board),f=new JXG.Coords(JXG.COORDS_BY_USER,e.point2.coords.usrCoords,e.board);JXG.Math.Geometry.calcStraight(e,g,f);this.context.beginPath();this.context.moveTo(g.scrCoords[1],g.scrCoords[2]);this.context.lineTo(f.scrCoords[1],f.scrCoords[2]);this._stroke(e);this.makeArrows(e,g,f)},updateLine:function(e){this.drawLine(e)},drawTicks:function(){},updateTicks:function(h,j,f,k,g){var l,n,m=h.ticks.length,e=this.context;e.beginPath();for(l=0;l0&&t>0&&!isNaN(f+e)){h.beginPath();h.moveTo(j,k);h.bezierCurveTo(j,k-s,l-v,i,l,i);h.bezierCurveTo(l+v,i,q,k-s,q,k);h.bezierCurveTo(q,k+s,l+v,p,l,p);h.bezierCurveTo(l-v,p,j,k+s,j,k);h.closePath();this._fill(g);this._stroke(g)}},updateEllipse:function(e){return this.drawEllipse(e)},displayCopyright:function(g,f){var e=this.context;e.save();e.font=f+"px Arial";e.fillStyle="#aaa";e.lineWidth=0.5;e.fillText(g,10,2+f);e.restore()},drawInternalText:function(g){var e,f=this.context;f.save();if(this._setColor(g,"stroke","fill")&&!isNaN(g.coords.scrCoords[1]+g.coords.scrCoords[2])){if(g.visProp.fontsize){if(typeof g.visProp.fontsize==="function"){e=g.visProp.fontsize();f.font=(e>0?e:0)+"px Arial"}else{f.font=(g.visProp.fontsize)+"px Arial"}}this.transformImage(g,g.transformations);f.fillText(g.plaintext,g.coords.scrCoords[1],g.coords.scrCoords[2])}f.restore();return null},updateInternalText:function(e){this.drawInternalText(e)},setObjectStrokeColor:function(f,i,j){var h=JXG.evaluate(i),l,m,e=JXG.evaluate(j),k,g;e=(e>0)?e:0;if(f.visPropOld.strokecolor===h&&f.visPropOld.strokeopacity===e){return}if(JXG.exists(h)&&h!==false){if(h.length!=9){l=h;k=e}else{m=JXG.rgba2rgbo(h);l=m[0];k=e*m[1]}g=f.rendNode;if(f.type===JXG.OBJECT_TYPE_TEXT&&f.visProp.display==="html"){g.style.color=l;g.style.opacity=k}}f.visPropOld.strokecolor=h;f.visPropOld.strokeopacity=e},drawImage:function(e){e.rendNode=new Image();e._src="";this.updateImage(e)},updateImage:function(f){var e=this.context,g=JXG.evaluate(f.visProp.fillopacity),h=JXG.bind(function(){f.imgIsLoaded=true;if(f.size[0]<=0||f.size[1]<=0){return}e.save();e.globalAlpha=g;this.transformImage(f,f.transformations);e.drawImage(f.rendNode,f.coords.scrCoords[1],f.coords.scrCoords[2]-f.size[1],f.size[0],f.size[1]);e.restore()},this);if(this.updateImageURL(f)){f.rendNode.onload=h}else{if(f.imgIsLoaded){h()}}},transformImage:function(i,h){var f,e=h.length,g=this.context;if(e>0){f=this.joinTransforms(i,h);if(Math.abs(JXG.Math.Numerics.det(f))>=JXG.Math.eps){g.transform(f[1][1],f[2][1],f[1][2],f[2][2],f[1][0],f[2][0])}}},updateImageURL:function(f){var e;e=JXG.evaluate(f.url);if(f._src!==e){f.imgIsLoaded=false;f.rendNode.src=e;f._src=e;return true}return false},remove:function(e){if(JXG.exists(e)&&JXG.exists(e.parentNode)){e.parentNode.removeChild(e)}},makeArrows:function(i,m,k){var g=[[2,0],[-10,-4],[-10,4]],o=[[-2,0],[10,-4],[10,4]],h,n,e,l,j,f=this.context;if(i.visProp.strokecolor!=="none"&&(i.visProp.lastarrow||i.visProp.firstarrow)){if(i.elementClass===JXG.OBJECT_CLASS_LINE){h=m.scrCoords[1];n=m.scrCoords[2];e=k.scrCoords[1];l=k.scrCoords[2]}else{return}f.save();if(this._setColor(i,"stroke","fill")){j=Math.atan2(l-n,e-h);if(i.visProp.lastarrow){this._drawFilledPolygon(this._translateShape(this._rotateShape(g,j),e,l))}if(i.visProp.firstarrow){this._drawFilledPolygon(this._translateShape(this._rotateShape(o,j),h,n))}}f.restore()}},updatePathStringPrim:function(f){var h="M",j="L",g=h,n=5000,k,m,o=(f.visProp.curvetype!=="plot"),l,e=this.context;if(f.numberPoints<=0){return}if(o&&f.board.options.curve.RDPsmoothing){f.points=JXG.Math.Numerics.RamerDouglasPeuker(f.points,0.5)}l=Math.min(f.points.length,f.numberPoints);e.beginPath();for(k=0;kn){m[1]=n}else{if(m[1]<-n){m[1]=-n}}if(m[2]>n){m[2]=n}else{if(m[2]<-n){m[2]=-n}}if(g===h){e.moveTo(m[1],m[2])}else{e.lineTo(m[1],m[2])}g=j}}this._fill(f);this._stroke(f)},updatePathStringBezierPrim:function(h){var m="M",n="C",l=m,u=5000,p,o,s,k,g,r=h.visProp.strokewidth,t=(h.visProp.curvetype!=="plot"),q,e=this.context;if(h.numberPoints<=0){return}if(t&&h.board.options.curve.RDPsmoothing){h.points=JXG.Math.Numerics.RamerDouglasPeuker(h.points,0.5)}q=Math.min(h.points.length,h.numberPoints);e.beginPath();for(o=1;o<3;o++){l=m;for(p=0;pu){s[1]=u}else{if(s[1]<-u){s[1]=-u}}if(s[2]>u){s[2]=u}else{if(s[2]<-u){s[2]=-u}}if(l==m){e.moveTo(s[1]+0*r*(2*o*Math.random()-o),s[2]+0*r*(2*o*Math.random()-o))}else{e.bezierCurveTo((k+(s[1]-k)*0.333+r*(2*o*Math.random()-o)),(g+(s[2]-g)*0.333+r*(2*o*Math.random()-o)),(k+2*(s[1]-k)*0.333+r*(2*o*Math.random()-o)),(g+2*(s[2]-g)*0.333+r*(2*o*Math.random()-o)),s[1],s[2])}l=n;k=s[1];g=s[2]}}}this._fill(h);this._stroke(h)},updatePolygonPrim:function(k,j){var f,h,e=j.vertices.length,g=this.context;if(e<=0){return}g.beginPath();f=j.vertices[0].coords.scrCoords;g.moveTo(f[1],f[2]);for(h=1;h0)?g:0;e=JXG.evaluate(f.visProp.fillcolor)},setShadow:function(e){if(e.visPropOld.shadow===e.visProp.shadow){return}e.visPropOld.shadow=e.visProp.shadow},highlight:function(e){e.board.prepareUpdate();e.board.renderer.suspendRedraw(e.board);e.board.updateRenderer();e.board.renderer.unsuspendRedraw();return this},noHighlight:function(e){e.board.prepareUpdate();e.board.renderer.suspendRedraw(e.board);e.board.updateRenderer();e.board.renderer.unsuspendRedraw();return this},suspendRedraw:function(e){this.context.save();this.context.clearRect(0,0,this.canvasRoot.width,this.canvasRoot.height);if(e&&e.showCopyright){this.displayCopyright(JXG.JSXGraph.licenseText,12)}},unsuspendRedraw:function(){this.context.restore()},resize:function(e,f){this.canvasRoot.style.width=parseFloat(e)+"px";this.canvasRoot.style.height=parseFloat(f)+"px";this.canvasRoot.setAttribute("width",parseFloat(e)+"px");this.canvasRoot.setAttribute("height",parseFloat(f)+"px")}}); \ No newline at end of file From f285ab74eee5fd6354d827b8fe40b11cb164a3ce Mon Sep 17 00:00:00 2001 From: alfred Date: Wed, 25 Apr 2012 18:55:45 +0200 Subject: [PATCH 3/3] Added the minified readers. --- .../jsxgraph/0.94/CinderellaReader.min.js | 26 +++++++++++++++++++ ajax/libs/jsxgraph/0.94/GeogebraReader.min.js | 26 +++++++++++++++++++ ajax/libs/jsxgraph/0.94/GeonextReader.min.js | 26 +++++++++++++++++++ ajax/libs/jsxgraph/0.94/IntergeoReader.min.js | 26 +++++++++++++++++++ 4 files changed, 104 insertions(+) create mode 100644 ajax/libs/jsxgraph/0.94/CinderellaReader.min.js create mode 100644 ajax/libs/jsxgraph/0.94/GeogebraReader.min.js create mode 100644 ajax/libs/jsxgraph/0.94/GeonextReader.min.js create mode 100644 ajax/libs/jsxgraph/0.94/IntergeoReader.min.js diff --git a/ajax/libs/jsxgraph/0.94/CinderellaReader.min.js b/ajax/libs/jsxgraph/0.94/CinderellaReader.min.js new file mode 100644 index 000000000..ce3f38408 --- /dev/null +++ b/ajax/libs/jsxgraph/0.94/CinderellaReader.min.js @@ -0,0 +1,26 @@ +/* Version 0.94 */ +/* + Copyright 2008-2012 + Matthias Ehmann, + Michael Gerhaeuser, + Carsten Miller, + Bianca Valentin, + Alfred Wassermann, + Peter Wilfahrt + + This file is part of JSXGraph. + + JSXGraph is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + JSXGraph is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with JSXGraph. If not, see . +*/ + JXG.CinderellaReader=new function(){this.parseData=function(l){var t,v,u,s,n,p,m,d,b,q,f,o,h,r,g,c,a,e,x,w,y;t=this.data.split("\n");for(v=0;v. +*/ + JXG.GeogebraReader=new function(){this.ggbAct=function(type,m,n){var v1=m,v2=n,s1,s2,a;switch(type.toLowerCase()){case"end":return v1;break;case"coord":s1=(JXG.GeogebraReader.board.ggbElements[v1])?'JXG.getRef(JXG.GeogebraReader.board, "'+v1+'")':v1;s2=(JXG.GeogebraReader.board.ggbElements[v2])?'JXG.getRef(JXG.GeogebraReader.board, "'+v2+'")':v2;return[s1,s2];break;case"le":return"( ("+v1+") <= ("+v2+") )";break;case"ge":return"( ("+v1+") >= ("+v2+") )";break;case"eq":return"( ("+v1+") == ("+v2+") )";break;case"neq":return"( ("+v1+") != ("+v2+") )";break;case"lt":return"( ("+v1+") < ("+v2+") )";break;case"gt":return"( ("+v1+") > ("+v2+") )";break;case"add":if(JXG.GeogebraReader.isGGBVector(v1)&&JXG.GeogebraReader.isGGBVector(v2)){return[1,v1[1]+"+"+v2[1],v1[2]+"+"+v2[2]]}if(JXG.isString(v1)&&!v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./)&&v1.match(/JXG\.getRef/)){s1=[v1+".X()",v1+".Y()"]}else{s1=v1}if(JXG.isString(v2)&&!v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./)&&v2.match(/JXG\.getRef/)){s2=[v2+".X()",v2+".Y()"]}else{s2=v2}if(JXG.GeogebraReader.isGGBVector(s1)&&JXG.isArray(s2)){return[s1[1]+"+"+s2[0],s1[2]+"+"+s2[1]]}if(JXG.GeogebraReader.isGGBVector(s2)&&JXG.isArray(s1)){return[s2[1]+"+"+s1[0],s2[2]+"+"+s1[1]]}if(JXG.isArray(s1)&&JXG.isArray(s2)){return[s1[0]+" + "+s2[0],s1[1]+" + "+s2[1]]}else{if((JXG.isNumber(s1)||JXG.isString(s1))&&(JXG.isNumber(s2)||JXG.isString(s2))){return s1+" + "+s2}else{if((JXG.isNumber(s1)||JXG.isString(s1))&&JXG.isArray(s2)){return[s1+" + "+s2[0],s1+" + "+s2[1]]}else{if(JXG.isArray(s1)&&(JXG.isNumber(s2)||JXG.isString(s2))){return[s1[0]+" + "+s2,s1[1]+" + "+s2]}else{return s1+" + "+s2}}}}break;case"sub":if(JXG.GeogebraReader.isGGBVector(v1)&&JXG.GeogebraReader.isGGBVector(v2)){return[1,v1[1]+"-"+v2[1],v1[2]+"-"+v2[2]]}if(JXG.isString(v1)&&!v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./)&&v1.match(/JXG\.getRef/)){s1=[v1+".X()",v1+".Y()"]}else{s1=v1}if(JXG.isString(v2)&&!v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./)&&v2.match(/JXG\.getRef/)){s2=[v2+".X()",v2+".Y()"]}else{s2=v2}if(JXG.GeogebraReader.isGGBVector(s1)&&JXG.isArray(s2)){return[s1[1]+"-"+s2[0],s1[2]+"-"+s2[1]]}if(JXG.isArray(s1)&&JXG.GeogebraReader.isGGBVector(s2)){return[s1[0]+"-("+s2[1]+")",s1[1]+"-("+s2[2]+")"]}if(JXG.isArray(s1)&&JXG.isArray(s2)){return[s1[0]+" - "+s2[0],s1[1]+" - "+s2[1]]}else{if((JXG.isNumber(s1)||JXG.isString(s1))&&(JXG.isNumber(s2)||JXG.isString(s2))){return s1+" - "+s2}else{if((JXG.isNumber(s1)||JXG.isString(s1))&&JXG.isArray(s2)){return[s1+" - "+s2[0],s1+" - "+s2[1]]}else{if(JXG.isArray(s1)&&(JXG.isNumber(s2)||JXG.isString(s2))){return[s1[0]+" - "+s2,s1[1]+" - "+s2]}else{return s1+" - "+s2}}}}break;case"neg":return"!("+v1+")";break;case"pow":return"Math.pow("+v1+", "+v2+")";break;case"or":return"("+v1+"||"+v2+")";break;case"and":return"("+v1+"&&"+v2+")";break;case"mul":if(JXG.GeogebraReader.isGGBVector(v1)&&!JXG.isArray(v2)){return[1,"("+v1[1]+")*"+v2,"("+v1[2]+")*"+v2]}else{if(!JXG.isArray(v1)&&JXG.GeogebraReader.isGGBVector(v2)){return new Array(1,"("+v2[1]+")*"+v1,"("+v2[2]+")*"+v1)}else{if(JXG.GeogebraReader.isGGBVector(v1)&&JXG.GeogebraReader.isGGBVector(v2)){return"(("+v1[1]+")*("+v2[1]+")+("+v1[2]+")*("+v2[2]+"))"}else{if(JXG.isString(v1)&&!v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./)&&v1.match(/JXG\.getRef/)){s1=[v1+".X()",v1+".Y()"]}else{s1=v1}if(JXG.isString(v2)&&!v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./)&&v2.match(/JXG\.getRef/)){s2=[v2+".X()",v2+".Y()"]}else{s2=v2}if(JXG.isArray(s1)&&JXG.isArray(s2)){return[s1[0]+" * "+s2[0],s1[1]+" * "+s2[1]]}else{if((JXG.isNumber(s1)||JXG.isString(s1))&&(JXG.isNumber(s2)||JXG.isString(s2))){return s1+" * "+s2}else{if((JXG.isNumber(s1)||JXG.isString(s1))&&JXG.isArray(s2)){return[s1+" * "+s2[0],s1+" * "+s2[1]]}else{if(JXG.isArray(s1)&&(JXG.isNumber(s2)||JXG.isString(s2))){return[s1[0]+" * "+s2,s1[1]+" * "+s2]}else{return s1+" * "+s2}}}}}}}break;case"div":if(JXG.isString(v1)&&!v1.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./)&&v1.match(/JXG\.getRef/)){s1=[v1+".X()",v1+".Y()"]}else{s1=v1}if(JXG.isString(v2)&&!v2.match(/JXG\.getRef\(JXG\.GeogebraReader\.board, "(.+?)"\)\./)&&v2.match(/JXG\.getRef/)){s2=[v2+".X()",v2+".Y()"]}else{s2=v2}if(JXG.isArray(s1)&&JXG.isArray(s2)){return[s1[0]+" / "+s2[0],s1[1]+" / "+s2[1]]}else{if((JXG.isNumber(s1)||JXG.isString(s1))&&(JXG.isNumber(s2)||JXG.isString(s2))){return s1+" / "+s2}else{if((JXG.isNumber(s1)||JXG.isString(s1))&&JXG.isArray(s2)){return[s1+" / "+s2[0],s1+" / "+s2[1]]}else{if(JXG.isArray(s1)&&(JXG.isNumber(s2)||JXG.isString(s2))){return[s1[0]+" / "+s2,s1[1]+" / "+s2]}else{return s1+" / "+s2}}}}break;case"negmult":if(JXG.GeogebraReader.isGGBVector(v1)){return new Array(1,-1+"*"+v1[1],-1+"*"+v1[2])}return -1+"*"+v1;break;case"bra":if(JXG.GeogebraReader.isGGBVector(v1)){return new Array(1,"("+v1[1]+")","("+v1[2]+")")}return"("+v1+")";break;case"int":return parseInt(v1);break;case"float":return parseFloat(v1);break;case"param":return v1;break;case"html":return v1;break;case"string":if(v2){return[v1,v2]}else{return v1}break;case"command":v2=v1.split("[");s1=v2[0];s2=(v2[1].split("]"))[0];switch(s1.toLowerCase()){case"name":return'JXG.getRef(JXG.GeogebraReader.board, "'+s2+'").getName()';break}break;case"var":if(v2){switch(v1.toLowerCase()){case"x":return v2+".X()";break;case"y":return v2+".Y()";break;case"abs":case"acos":case"asin":case"atan":case"ceil":case"cos":case"exp":case"floor":case"log":case"max":case"min":case"pow":case"random":case"round":case"sin":case"sqrt":case"tan":return"Math."+v1.toLowerCase()+"("+v2+")";break;default:return v1.toLowerCase()+"*("+v2+")";break}}else{if(v1=="PI"){return"Math.PI"}else{a=JXG.GeogebraReader.checkElement(v1);if(typeof JXG.GeogebraReader.board.ggb[v1]!="undefined"){return'JXG.GeogebraReader.board.ggb["'+v1+'"]()'}else{if(typeof a.Value!="undefined"){return'JXG.getRef(JXG.GeogebraReader.board, "'+v1+'").Value()'}else{if(typeof a.Area!="undefined"){return'JXG.getRef(JXG.GeogebraReader.board, "'+v1+'").Area()'}else{if(typeof a.plaintextStr!="undefined"){return'1.0*JXG.getRef(JXG.GeogebraReader.board, "'+v1+'").plaintextStr'}else{if(a.type==JXG.OBJECT_TYPE_VECTOR){return new Array(1,'JXG.getRef(JXG.GeogebraReader.board, "'+v1+'").point2.X()-JXG.getRef(JXG.GeogebraReader.board, "'+v1+'").point1.X()','JXG.getRef(JXG.GeogebraReader.board, "'+v1+'").point2.Y()-JXG.getRef(JXG.GeogebraReader.board, "'+v1+'").point1.Y()')}else{if(a.elementClass==JXG.OBJECT_CLASS_LINE){return'JXG.getRef(JXG.GeogebraReader.board, "'+v1+'").point1.Dist(JXG.getRef(JXG.GeogebraReader.board, "'+v1+'").point2)'}else{return'JXG.getRef(JXG.GeogebraReader.board, "'+v1+'")'}}}}}}}}break}};this.ggbParse=function(exp,element){var element=(element)?JXG.getRef(JXG.GeogebraReader.board,JXG.GeogebraReader.board.ggbElements[element].id):false;if(element){JXG.debug("Zu aktualisierendes Element: "+element.name+"("+element.id+")")}var _dbg_withtrace=false;var _dbg_string=new String();function __dbg_print(text){_dbg_string+=text+"\n"}function __lex(info){var state=0;var match=-1;var match_pos=0;var start=0;var pos=info.offset+1;do{pos--;state=0;match=-2;start=pos;if(info.src.length<=start){return 28}do{switch(state){case 0:if(info.src.charCodeAt(pos)==9||info.src.charCodeAt(pos)==32){state=1}else{if(info.src.charCodeAt(pos)==33){state=2}else{if(info.src.charCodeAt(pos)==40){state=3}else{if(info.src.charCodeAt(pos)==41){state=4}else{if(info.src.charCodeAt(pos)==42){state=5}else{if(info.src.charCodeAt(pos)==43){state=6}else{if(info.src.charCodeAt(pos)==44){state=7}else{if(info.src.charCodeAt(pos)==45){state=8}else{if(info.src.charCodeAt(pos)==47){state=9}else{if((info.src.charCodeAt(pos)>=48&&info.src.charCodeAt(pos)<=57)){state=10}else{if(info.src.charCodeAt(pos)==60){state=11}else{if(info.src.charCodeAt(pos)==62){state=12}else{if((info.src.charCodeAt(pos)>=65&&info.src.charCodeAt(pos)<=90)||(info.src.charCodeAt(pos)>=97&&info.src.charCodeAt(pos)<=122)){state=13}else{if(info.src.charCodeAt(pos)==94){state=14}else{if(info.src.charCodeAt(pos)==34){state=26}else{if(info.src.charCodeAt(pos)==38){state=28}else{if(info.src.charCodeAt(pos)==46){state=29}else{if(info.src.charCodeAt(pos)==61){state=30}else{if(info.src.charCodeAt(pos)==95){state=31}else{if(info.src.charCodeAt(pos)==124){state=32}else{state=-1}}}}}}}}}}}}}}}}}}}}break;case 1:state=-1;match=1;match_pos=pos;break;case 2:if(info.src.charCodeAt(pos)==61){state=15}else{state=-1}match=23;match_pos=pos;break;case 3:state=-1;match=2;match_pos=pos;break;case 4:state=-1;match=3;match_pos=pos;break;case 5:state=-1;match=13;match_pos=pos;break;case 6:state=-1;match=11;match_pos=pos;break;case 7:state=-1;match=16;match_pos=pos;break;case 8:state=-1;match=12;match_pos=pos;break;case 9:state=-1;match=14;match_pos=pos;break;case 10:if((info.src.charCodeAt(pos)>=48&&info.src.charCodeAt(pos)<=57)){state=10}else{if(info.src.charCodeAt(pos)==46){state=18}else{state=-1}}match=4;match_pos=pos;break;case 11:if(info.src.charCodeAt(pos)==61){state=19}else{state=-1}match=21;match_pos=pos;break;case 12:if(info.src.charCodeAt(pos)==61){state=21}else{state=-1}match=22;match_pos=pos;break;case 13:if((info.src.charCodeAt(pos)>=65&&info.src.charCodeAt(pos)<=90)||(info.src.charCodeAt(pos)>=97&&info.src.charCodeAt(pos)<=122)){state=13}else{if((info.src.charCodeAt(pos)>=48&&info.src.charCodeAt(pos)<=57)){state=27}else{if(info.src.charCodeAt(pos)==91){state=34}else{if(info.src.charCodeAt(pos)==95){state=35}else{state=-1}}}}match=7;match_pos=pos;break;case 14:state=-1;match=15;match_pos=pos;break;case 15:state=-1;match=20;match_pos=pos;break;case 16:state=-1;match=9;match_pos=pos;break;case 17:state=-1;match=25;match_pos=pos;break;case 18:if((info.src.charCodeAt(pos)>=48&&info.src.charCodeAt(pos)<=57)){state=18}else{state=-1}match=5;match_pos=pos;break;case 19:state=-1;match=17;match_pos=pos;break;case 20:state=-1;match=19;match_pos=pos;break;case 21:state=-1;match=18;match_pos=pos;break;case 22:state=-1;match=24;match_pos=pos;break;case 23:state=-1;match=8;match_pos=pos;break;case 24:if((info.src.charCodeAt(pos)>=48&&info.src.charCodeAt(pos)<=57)||(info.src.charCodeAt(pos)>=65&&info.src.charCodeAt(pos)<=90)||(info.src.charCodeAt(pos)>=97&&info.src.charCodeAt(pos)<=122)){state=24}else{state=-1}match=6;match_pos=pos;break;case 25:state=-1;match=10;match_pos=pos;break;case 26:if(info.src.charCodeAt(pos)==34){state=16}else{if(info.src.charCodeAt(pos)==32||info.src.charCodeAt(pos)==46||(info.src.charCodeAt(pos)>=48&&info.src.charCodeAt(pos)<=57)||info.src.charCodeAt(pos)==61||(info.src.charCodeAt(pos)>=65&&info.src.charCodeAt(pos)<=90)||(info.src.charCodeAt(pos)>=97&&info.src.charCodeAt(pos)<=122)||info.src.charCodeAt(pos)==223||info.src.charCodeAt(pos)==228||info.src.charCodeAt(pos)==246||info.src.charCodeAt(pos)==252){state=26}else{state=-1}}break;case 27:if((info.src.charCodeAt(pos)>=48&&info.src.charCodeAt(pos)<=57)||(info.src.charCodeAt(pos)>=65&&info.src.charCodeAt(pos)<=90)||(info.src.charCodeAt(pos)>=97&&info.src.charCodeAt(pos)<=122)){state=27}else{if(info.src.charCodeAt(pos)==95){state=35}else{state=-1}}match=7;match_pos=pos;break;case 28:if(info.src.charCodeAt(pos)==38){state=17}else{if((info.src.charCodeAt(pos)>=65&&info.src.charCodeAt(pos)<=90)||(info.src.charCodeAt(pos)>=97&&info.src.charCodeAt(pos)<=122)){state=33}else{state=-1}}break;case 29:if((info.src.charCodeAt(pos)>=48&&info.src.charCodeAt(pos)<=57)){state=18}else{state=-1}break;case 30:if(info.src.charCodeAt(pos)==61){state=20}else{state=-1}break;case 31:if(info.src.charCodeAt(pos)==95){state=36}else{state=-1}break;case 32:if(info.src.charCodeAt(pos)==124){state=22}else{state=-1}break;case 33:if(info.src.charCodeAt(pos)==59){state=23}else{if((info.src.charCodeAt(pos)>=65&&info.src.charCodeAt(pos)<=90)||(info.src.charCodeAt(pos)>=97&&info.src.charCodeAt(pos)<=122)){state=33}else{state=-1}}break;case 34:if((info.src.charCodeAt(pos)>=65&&info.src.charCodeAt(pos)<=90)||(info.src.charCodeAt(pos)>=97&&info.src.charCodeAt(pos)<=122)){state=37}else{state=-1}break;case 35:if((info.src.charCodeAt(pos)>=48&&info.src.charCodeAt(pos)<=57)||(info.src.charCodeAt(pos)>=65&&info.src.charCodeAt(pos)<=90)||(info.src.charCodeAt(pos)>=97&&info.src.charCodeAt(pos)<=122)){state=27}else{if(info.src.charCodeAt(pos)==95){state=35}else{state=-1}}break;case 36:if((info.src.charCodeAt(pos)>=48&&info.src.charCodeAt(pos)<=57)||(info.src.charCodeAt(pos)>=65&&info.src.charCodeAt(pos)<=90)||(info.src.charCodeAt(pos)>=97&&info.src.charCodeAt(pos)<=122)){state=24}else{state=-1}break;case 37:if(info.src.charCodeAt(pos)==93){state=25}else{if((info.src.charCodeAt(pos)>=65&&info.src.charCodeAt(pos)<=90)||(info.src.charCodeAt(pos)>=97&&info.src.charCodeAt(pos)<=122)){state=37}else{state=-1}}break}pos++}while(state>-1)}while(1>-1&&match==1);if(match>-1){info.att=info.src.substr(start,match_pos-start);info.offset=match_pos}else{info.att=new String();match=-1}return match}function __parse(src,err_off,err_la){var sstack=new Array();var vstack=new Array();var err_cnt=0;var act;var go;var la;var rval;var parseinfo=new Function("","var offset; var src; var att;");var info=new parseinfo();var pop_tab=new Array(new Array(0,1),new Array(27,1),new Array(26,5),new Array(26,3),new Array(26,3),new Array(26,3),new Array(26,3),new Array(26,3),new Array(26,3),new Array(26,3),new Array(26,3),new Array(26,2),new Array(26,3),new Array(26,3),new Array(26,3),new Array(26,3),new Array(26,3),new Array(26,2),new Array(26,3),new Array(26,3),new Array(26,1),new Array(26,1),new Array(26,1),new Array(26,1),new Array(26,1),new Array(26,1),new Array(26,4),new Array(26,1));var act_tab=new Array(new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(28,0),new Array(14,13,13,14,25,15,24,16,15,17,12,18,11,19,22,20,21,21,20,22,19,23,18,24,17,25,28,-1),new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(11,29,28,-24,17,-24,18,-24,19,-24,20,-24,21,-24,22,-24,12,-24,15,-24,24,-24,25,-24,13,-24,14,-24,16,-24,3,-24),new Array(28,-20,17,-20,18,-20,19,-20,20,-20,21,-20,22,-20,11,-20,12,-20,15,-20,24,-20,25,-20,13,-20,14,-20,16,-20,3,-20),new Array(28,-21,17,-21,18,-21,19,-21,20,-21,21,-21,22,-21,11,-21,12,-21,15,-21,24,-21,25,-21,13,-21,14,-21,16,-21,3,-21),new Array(28,-22,17,-22,18,-22,19,-22,20,-22,21,-22,22,-22,11,-22,12,-22,15,-22,24,-22,25,-22,13,-22,14,-22,16,-22,3,-22),new Array(28,-23,17,-23,18,-23,19,-23,20,-23,21,-23,22,-23,11,-23,12,-23,15,-23,24,-23,25,-23,13,-23,14,-23,16,-23,3,-23),new Array(28,-25,17,-25,18,-25,19,-25,20,-25,21,-25,22,-25,11,-25,12,-25,15,-25,24,-25,25,-25,13,-25,14,-25,16,-25,3,-25),new Array(2,30,28,-27,17,-27,18,-27,19,-27,20,-27,21,-27,22,-27,11,-27,12,-27,15,-27,24,-27,25,-27,13,-27,14,-27,16,-27,3,-27),new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(14,13,13,14,25,15,24,16,15,17,12,18,11,19,22,20,21,21,20,22,19,23,18,24,17,25,16,44,3,45),new Array(14,-11,13,-11,25,15,24,16,15,-11,12,-11,11,-11,22,-11,21,-11,20,-11,19,-11,18,-11,17,-11,28,-11,16,-11,3,-11),new Array(14,-17,13,-17,25,15,24,16,15,17,12,-17,11,-17,22,20,21,21,20,22,19,23,18,24,17,25,28,-17,16,-17,3,-17),new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(14,-16,13,-16,25,15,24,16,15,17,12,-16,11,-16,22,20,21,21,20,22,19,23,18,24,17,25,28,-16,16,-16,3,-16),new Array(14,-15,13,-15,25,15,24,16,15,17,12,-15,11,-15,22,20,21,21,20,22,19,23,18,24,17,25,28,-15,16,-15,3,-15),new Array(14,-14,13,-14,25,-14,24,-14,15,-14,12,-14,11,-14,22,-14,21,-14,20,-14,19,-14,18,-14,17,-14,28,-14,16,-14,3,-14),new Array(14,-13,13,-13,25,-13,24,-13,15,-13,12,-13,11,-13,22,-13,21,-13,20,-13,19,-13,18,-13,17,-13,28,-13,16,-13,3,-13),new Array(14,-12,13,-12,25,15,24,16,15,-12,12,-12,11,-12,22,20,21,21,20,22,19,23,18,24,17,25,28,-12,16,-12,3,-12),new Array(14,13,13,14,25,15,24,16,15,17,12,-10,11,-10,22,20,21,21,20,22,19,23,18,24,17,25,28,-10,16,-10,3,-10),new Array(14,13,13,14,25,15,24,16,15,17,12,-9,11,-9,22,20,21,21,20,22,19,23,18,24,17,25,28,-9,16,-9,3,-9),new Array(14,-8,13,-8,25,15,24,16,15,-8,12,-8,11,-8,22,-8,21,-8,20,-8,19,-8,18,-8,17,-8,28,-8,16,-8,3,-8),new Array(14,-7,13,-7,25,15,24,16,15,-7,12,-7,11,-7,22,-7,21,-7,20,-7,19,-7,18,-7,17,-7,28,-7,16,-7,3,-7),new Array(14,-6,13,-6,25,15,24,16,15,-6,12,-6,11,-6,22,-6,21,-6,20,-6,19,-6,18,-6,17,-6,28,-6,16,-6,3,-6),new Array(14,-5,13,-5,25,15,24,16,15,-5,12,-5,11,-5,22,-5,21,-5,20,-5,19,-5,18,-5,17,-5,28,-5,16,-5,3,-5),new Array(14,-4,13,-4,25,15,24,16,15,-4,12,-4,11,-4,22,-4,21,-4,20,-4,19,-4,18,-4,17,-4,28,-4,16,-4,3,-4),new Array(14,-3,13,-3,25,15,24,16,15,-3,12,-3,11,-3,22,-3,21,-3,20,-3,19,-3,18,-3,17,-3,28,-3,16,-3,3,-3),new Array(2,3,23,4,12,5,9,6,4,7,5,8,6,9,8,10,10,11,7,12),new Array(28,-18,17,-18,18,-18,19,-18,20,-18,21,-18,22,-18,11,-18,12,-18,15,-18,24,-18,25,-18,13,-18,14,-18,16,-18,3,-18),new Array(14,13,13,14,25,15,24,16,15,17,12,-19,11,-19,22,20,21,21,20,22,19,23,18,24,17,25,28,-19,16,-19,3,-19),new Array(14,13,13,14,25,15,24,16,15,17,12,18,11,19,22,20,21,21,20,22,19,23,18,24,17,25,3,49),new Array(14,13,13,14,25,15,24,16,15,17,12,18,11,19,22,20,21,21,20,22,19,23,18,24,17,25,3,50),new Array(28,-26,17,-26,18,-26,19,-26,20,-26,21,-26,22,-26,11,-26,12,-26,15,-26,24,-26,25,-26,13,-26,14,-26,16,-26,3,-26),new Array(28,-2,17,-2,18,-2,19,-2,20,-2,21,-2,22,-2,11,-2,12,-2,15,-2,24,-2,25,-2,13,-2,14,-2,16,-2,3,-2));var goto_tab=new Array(new Array(27,1,26,2),new Array(),new Array(),new Array(26,26),new Array(26,27),new Array(26,28),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(26,31),new Array(26,32),new Array(26,33),new Array(26,34),new Array(26,35),new Array(26,36),new Array(26,37),new Array(26,38),new Array(26,39),new Array(26,40),new Array(26,41),new Array(26,42),new Array(26,43),new Array(),new Array(),new Array(),new Array(26,46),new Array(26,47),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(26,48),new Array(),new Array(),new Array(),new Array(),new Array(),new Array());var labels=new Array("p'","WHITESPACE","(",")","INT","FLOAT","PARAM","VAR","HTML","STRING","COMMAND","+","-","*","/","^",",","<=",">=","==","!=","<",">","!","||","&&","e","p","$");info.offset=0;info.src=src;info.att=new String();if(!err_off){err_off=new Array()}if(!err_la){err_la=new Array()}sstack.push(0);vstack.push(0);la=__lex(info);while(true){act=52;for(var i=0;i0){__dbg_print("\nState "+sstack[sstack.length-1]+"\n\tLookahead: "+labels[la]+' ("'+info.att+'")\n\tAction: '+act+'\n\tSource: "'+info.src.substr(info.offset,30)+((info.offset+300){sstack.pop();vstack.pop();if(sstack.length==0){break}act=52;for(var i=0;i0){if(_dbg_withtrace){__dbg_print("Shifting symbol: "+labels[la]+" ("+info.att+")")}sstack.push(act);vstack.push(info.att);la=__lex(info);if(_dbg_withtrace){__dbg_print("\tNew lookahead symbol: "+labels[la]+" ("+info.att+")")}}else{act*=-1;if(_dbg_withtrace){__dbg_print("Reducing by producution: "+act)}rval=void (0);if(_dbg_withtrace){__dbg_print("\tPerforming semantic action...")}switch(act){case 0:rval=vstack[vstack.length-1];break;case 1:rval=JXG.GeogebraReader.ggbAct("end",vstack[vstack.length-1]);break;case 2:rval=JXG.GeogebraReader.ggbAct("coord",vstack[vstack.length-4],vstack[vstack.length-2],element);break;case 3:rval=JXG.GeogebraReader.ggbAct("le",vstack[vstack.length-3],vstack[vstack.length-1]);break;case 4:rval=JXG.GeogebraReader.ggbAct("ge",vstack[vstack.length-3],vstack[vstack.length-1]);break;case 5:rval=JXG.GeogebraReader.ggbAct("eq",vstack[vstack.length-3],vstack[vstack.length-1]);break;case 6:rval=JXG.GeogebraReader.ggbAct("neq",vstack[vstack.length-3],vstack[vstack.length-1]);break;case 7:rval=JXG.GeogebraReader.ggbAct("lt",vstack[vstack.length-3],vstack[vstack.length-1]);break;case 8:rval=JXG.GeogebraReader.ggbAct("gt",vstack[vstack.length-3],vstack[vstack.length-1]);break;case 9:rval=JXG.GeogebraReader.ggbAct("add",vstack[vstack.length-3],vstack[vstack.length-1]);break;case 10:rval=JXG.GeogebraReader.ggbAct("sub",vstack[vstack.length-3],vstack[vstack.length-1]);break;case 11:rval=JXG.GeogebraReader.ggbAct("neg",vstack[vstack.length-1]);break;case 12:rval=JXG.GeogebraReader.ggbAct("pow",vstack[vstack.length-3],vstack[vstack.length-1]);break;case 13:rval=JXG.GeogebraReader.ggbAct("or",vstack[vstack.length-3],vstack[vstack.length-1]);break;case 14:rval=JXG.GeogebraReader.ggbAct("and",vstack[vstack.length-3],vstack[vstack.length-1]);break;case 15:rval=JXG.GeogebraReader.ggbAct("mul",vstack[vstack.length-3],vstack[vstack.length-1]);break;case 16:rval=JXG.GeogebraReader.ggbAct("div",vstack[vstack.length-3],vstack[vstack.length-1]);break;case 17:rval=JXG.GeogebraReader.ggbAct("negmult",vstack[vstack.length-1]);break;case 18:rval=JXG.GeogebraReader.ggbAct("bra",vstack[vstack.length-2]);break;case 19:rval=JXG.GeogebraReader.ggbAct("string",vstack[vstack.length-3],vstack[vstack.length-1]);break;case 20:rval=JXG.GeogebraReader.ggbAct("int",vstack[vstack.length-1]);break;case 21:rval=JXG.GeogebraReader.ggbAct("float",vstack[vstack.length-1]);break;case 22:rval=JXG.GeogebraReader.ggbAct("param",vstack[vstack.length-1]);break;case 23:rval=JXG.GeogebraReader.ggbAct("html",vstack[vstack.length-1]);break;case 24:rval=JXG.GeogebraReader.ggbAct("string",vstack[vstack.length-1]);break;case 25:rval=JXG.GeogebraReader.ggbAct("command",vstack[vstack.length-1]);break;case 26:rval=JXG.GeogebraReader.ggbAct("var",vstack[vstack.length-4],vstack[vstack.length-2]);break;case 27:rval=JXG.GeogebraReader.ggbAct("var",vstack[vstack.length-1]);break}if(_dbg_withtrace){__dbg_print("\tPopping "+pop_tab[act][1]+" off the stack...")}for(var i=0;i0){var errstr=new String();for(var i=0;i0&&Data.getElementsByTagName("objColor")[0].getAttribute("alpha"))?parseFloat(Data.getElementsByTagName("objColor")[0].getAttribute("alpha")):0;r=(Data.getElementsByTagName("objColor").length>0&&Data.getElementsByTagName("objColor")[0].getAttribute("r"))?parseInt(Data.getElementsByTagName("objColor")[0].getAttribute("r")).toString(16):0;g=(Data.getElementsByTagName("objColor").length>0&&Data.getElementsByTagName("objColor")[0].getAttribute("g"))?parseInt(Data.getElementsByTagName("objColor")[0].getAttribute("g")).toString(16):0;b=(Data.getElementsByTagName("objColor").length>0&&Data.getElementsByTagName("objColor")[0].getAttribute("b"))?parseInt(Data.getElementsByTagName("objColor")[0].getAttribute("b")).toString(16):0;if(r.length==1){r="0"+r}if(g.length==1){g="0"+g}if(b.length==1){b="0"+b}attr.fillColor="#"+r+g+b;attr.strokeColor=attr.fillColor;attr.highlightFillColor=attr.fillColor;attr.highlightStrokeColor=attr.strokeColor;attr.fillOpacity=a;attr.highlightFillOpacity=a;attr.labelColor=attr.fillColor;return attr};this.boardProperties=function(gxtEl,Data,attr){return attr};this.coordinates=function(gxtEl,Data){var labelOffset={},tmp;labelOffset.x=0;labelOffset.y=0;labelOffset.z=0;if(Data.getElementsByTagName("labelOffset")[0]){labelOffset.x=parseFloat(Data.getElementsByTagName("labelOffset")[0].getAttribute("x"))/JXG.GeogebraReader.board.unitX;labelOffset.y=parseFloat(Data.getElementsByTagName("labelOffset")[0].getAttribute("y"))/JXG.GeogebraReader.board.unitY}if(Data.getElementsByTagName("coords")[0]){gxtEl.x=parseFloat(Data.getElementsByTagName("coords")[0].getAttribute("x"));gxtEl.y=parseFloat(Data.getElementsByTagName("coords")[0].getAttribute("y"));gxtEl.z=parseFloat(Data.getElementsByTagName("coords")[0].getAttribute("z"))}else{if(Data.getElementsByTagName("startPoint")[0]){if(Data.getElementsByTagName("startPoint")[0].getAttribute("exp")){var a=JXG.getRef(JXG.GeogebraReader.board,Data.getElementsByTagName("startPoint")[0].getAttribute("exp"));gxtEl.x=function(){return a.X()+labelOffset.x};gxtEl.y=function(){return a.Y()-labelOffset.y};gxtEl.z=false}else{gxtEl.x=parseFloat(Data.getElementsByTagName("startPoint")[0].getAttribute("x"));gxtEl.y=parseFloat(Data.getElementsByTagName("startPoint")[0].getAttribute("y"));gxtEl.z=parseFloat(Data.getElementsByTagName("startPoint")[0].getAttribute("z"))}}else{if(Data.getElementsByTagName("absoluteScreenLocation")[0]){var tmp=new JXG.Coords(JXG.COORDS_BY_SCREEN,[parseFloat(Data.getElementsByTagName("absoluteScreenLocation")[0].getAttribute("x")),parseFloat(Data.getElementsByTagName("absoluteScreenLocation")[0].getAttribute("y"))],JXG.GeogebraReader.board);gxtEl.x=tmp.usrCoords[1]+labelOffset.x;gxtEl.y=tmp.usrCoords[2]+labelOffset.y;gxtEl.z=false}else{return false}}}return gxtEl};this.visualProperties=function(Data,attr){(Data.getElementsByTagName("show").length!=0&&Data.getElementsByTagName("show")[0].getAttribute("object"))?attr.visible=Data.getElementsByTagName("show")[0].getAttribute("object"):false;(Data.getElementsByTagName("show").length!=0&&Data.getElementsByTagName("show")[0].getAttribute("label"))?attr.withLabel=Data.getElementsByTagName("show")[0].getAttribute("label"):true;if(attr.withLabel=="true"){attr.withLabel=true}else{if(attr.withLabel=="false"){attr.withLabel=false}}(Data.getElementsByTagName("pointSize")[0])?attr.size=Data.getElementsByTagName("pointSize")[0].getAttribute("val"):false;(Data.getElementsByTagName("pointStyle")[0])?attr.styleGGB=Data.getElementsByTagName("pointStyle")[0].getAttribute("val"):false;if(attr.styleGGB==0||attr.styleGGB==2){attr.face="circle";if(attr.styleGGB==0){attr.fillColor=attr.strokeColor;attr.fillOpacity=1;attr.highlightFillColor=attr.strokeColor;attr.highlightFillOpacity=1;attr.strokeColor="black";attr.strokeWidth="1px"}else{if(attr.styleGGB==2){attr.fillColor="none"}}}else{if(attr.styleGGB==1){attr.face="x"}else{if(attr.styleGGB==3){attr.face="+";attr.strokeOpacity=1}else{if(attr.styleGGB==4||attr.styleGGB==5){attr.face="diamond";if(attr.styleGGB==4){attr.fillColor=attr.strokeColor;attr.fillOpacity=1}else{if(attr.styleGGB==5){attr.fillColor="none"}}}else{if(attr.styleGGB==6){attr.face="triangleUp";attr.fillColor=attr.strokeColor;attr.fillOpacity=1}else{if(attr.styleGGB==7){attr.face="triangleDown";attr.fillColor=attr.strokeColor;attr.fillOpacity=1}else{if(attr.styleGGB==8){attr.face="triangleRight";attr.fillColor=attr.strokeColor;attr.fillOpacity=1}else{if(attr.styleGGB==9){attr.face="triangleLeft";attr.fillColor=attr.strokeColor;attr.fillOpacity=1}}}}}}}}(Data.getElementsByTagName("slopeTriangleSize")[0])?attr.slopeWidth=Data.getElementsByTagName("slopeTriangleSize")[0].getAttribute("val"):false;(Data.getElementsByTagName("lineStyle")[0])?attr.strokeWidth=(Data.getElementsByTagName("lineStyle")[0].getAttribute("thickness")/2)+"px":false;if(attr.strokeWidth){attr.highlightStrokeWidth=(1*attr.strokeWidth.substr(0,attr.strokeWidth.length-2)+1)+"px"}(Data.getElementsByTagName("lineStyle")[0])?attr.dashGGB=Data.getElementsByTagName("lineStyle")[0].getAttribute("type"):false;if(attr.dashGGB==0){attr.dash=0}else{if(attr.dashGGB==10){attr.dash=2}else{if(attr.dashGGB==15){attr.dash=3}else{if(attr.dashGGB==20){attr.dash=1}else{if(attr.dashGGB==30){attr.dash=6}}}}}(Data.getElementsByTagName("labelOffset")[0])?attr.labelX=1*Data.getElementsByTagName("labelOffset")[0].getAttribute("x"):false;(Data.getElementsByTagName("labelOffset")[0])?attr.labelY=1*Data.getElementsByTagName("labelOffset")[0].getAttribute("y"):false;(Data.getElementsByTagName("trace")[0])?attr.trace=Data.getElementsByTagName("trace")[0].getAttribute("val"):false;(Data.getElementsByTagName("fix")[0])?attr.fixed=Data.getElementsByTagName("fix")[0].getAttribute("val"):false;return attr};this.getElement=function(name,expr){var Data,i,j;expr=expr||false;for(i=0;i-1||s[i].search(/[0-9]+$/)>-1||s[i].search(/[a-zA-Z]+(\_*[a-zA-Z0-9]+)*$/)>-1){if(s[i+1].search(/^\(/)>-1||s[i+1].search(/^[0-9]+/)>-1||s[i+1].search(/^[a-zA-Z]+(\_*[a-zA-Z0-9]+)*/)>-1||s[i+1].search(/\_\_[a-zA-Z0-9]+/)>-1){s[i]=s[i]+"*"}}}o+=s[i]}expr=o}output.push(expr);return output}else{return exp}break;case"s":exp=exp.replace(/(?![e])x(?!\()(?![p])/g,"__x");return["__x",exp];break;default:if(JXG.GeogebraReader.format<=3.01){s=exp.split(" ");o="";for(i=0;i-1||s[i].search(/[0-9]+$/)>-1||s[i].search(/[a-zA-Z]+(\_*[a-zA-Z0-9]+)*$/)>-1){if(s[i+1].search(/^\(/)>-1||s[i+1].search(/^[0-9]+/)>-1||s[i+1].search(/^[a-zA-Z]+(\_*[a-zA-Z0-9]+)*/)>-1||s[i+1].search(/\_\_[a-zA-Z0-9]+/)>-1){s[i]=s[i]+"*"}}}o+=s[i]}exp=o}return exp;break}};this.writeBoard=function(board){var boardData=JXG.GeogebraReader.tree.getElementsByTagName("euclidianView")[0];board.origin={};board.origin.usrCoords=[1,0,0];board.origin.scrCoords=[1,1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("xZero"),1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("yZero")];board.unitX=(boardData.getElementsByTagName("coordSystem")[0].getAttribute("scale"))?1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("scale"):1;board.unitY=(boardData.getElementsByTagName("coordSystem")[0].getAttribute("yscale"))?1*boardData.getElementsByTagName("coordSystem")[0].getAttribute("yscale"):board.unitX;board.fontSize=(JXG.GeogebraReader.tree.getElementsByTagName("gui")[0]&&JXG.GeogebraReader.tree.getElementsByTagName("gui")[0].getElementsByTagName("font")[0])?1*JXG.GeogebraReader.tree.getElementsByTagName("gui")[0].getElementsByTagName("font")[0].getAttribute("size"):"12px";JXG.JSXGraph.boards[board.id]=board;board.renderer.enhancedRendering=true;var snapToPoint=(boardData.getElementsByTagName("evSettings")[0].getAttribute("pointCapturing")=="true");var grid=(boardData.getElementsByTagName("evSettings")[0].getAttribute("grid")=="true")?board.create("grid"):null;if(boardData.getElementsByTagName("evSettings")[0].getAttribute("axes")&&boardData.getElementsByTagName("evSettings")[0].getAttribute("axes")=="true"){board.ggbElements.xAxis=board.create("axis",[[0,0],[1,0]],{strokeColor:"black",minorTicks:0});board.ggbElements.yAxis=board.create("axis",[[0,0],[0,1]],{strokeColor:"black",minorTicks:0})}};this.writeElement=function(board,output,input,cmd){var element,gxtEl,attr,p,exp,coord,type,points,border,length,m,s,e,sx,sy,ex,ey,func,range;element=(JXG.isArray(output))?output[0]:output;gxtEl={};attr={};JXG.debug(element);gxtEl.type=(element&&element.attributes&&typeof cmd==="undefined")?element.getAttribute("type").toLowerCase():cmd;gxtEl.label=element.getAttribute("label");attr.name=gxtEl.label;JXG.debug("
Konstruiere "+attr.name+"("+gxtEl.type+"):");switch(gxtEl.type){case"point":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);attr=JXG.GeogebraReader.visualProperties(element,attr);if(JXG.GeogebraReader.getElement(attr.name,true)){exp=JXG.GeogebraReader.getElement(attr.name,true).getAttribute("exp");coord=JXG.GeogebraReader.ggbParse(exp);gxtEl.x=new Function("return "+coord[0]+";");gxtEl.y=new Function("return "+coord[1]+";")}else{gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element)}if(!JXG.exists(attr.styleGGB)){attr.face="circle";attr.fillColor=attr.strokeColor;attr.fillOpacity=1;attr.highlightFillColor=attr.strokeColor;attr.highlightFillOpacity=1;attr.strokeColor="black";attr.strokeWidth="1px"}JXG.debug(gxtEl);JXG.debug(input);try{var ma=/Circle\[\s*(\w+)\s*,\s*([\d\.]+)\s*\]/.exec(input);if(typeof input!="undefined"){if(ma!=null&&ma.length==3){var q=JXG.GeogebraReader.checkElement(ma[1]);var c=board.create("circle",[q,parseFloat(ma[2])],{fillColor:"none",visible:false,name:""});p=board.create("glider",[gxtEl.x,gxtEl.y,c],attr)}else{if(JXG.isArray(input)){p=board.create("glider",[gxtEl.x,gxtEl.y,input[0]],attr)}else{p=board.create("glider",[gxtEl.x,gxtEl.y,input],attr)}}}else{p=board.create("point",[gxtEl.x,gxtEl.y],attr)}return p}catch(e){JXG.debug("* Err: Point "+attr.name+"
\n");return false}break;case"segment":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{JXG.debug("* Segment: ("+attr.name+") First: "+input[0].name+", Last: "+input[1].name+"
\n");attr.straightFirst=false;attr.straightLast=false;p=board.create("line",input,attr);return p}catch(e){JXG.debug("* Err: Segment "+attr.name+" First: "+input[0].name+", Last: "+input[1].name+"
\n");return false}break;case"line":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);type="line";if(!input){input=[parseFloat(element.getElementsByTagName("coords")[0].getAttribute("z")),parseFloat(element.getElementsByTagName("coords")[0].getAttribute("x")),parseFloat(element.getElementsByTagName("coords")[0].getAttribute("y"))]}else{if(JXG.getRef(board,input[1].id).elementClass==JXG.OBJECT_CLASS_LINE){type="parallel"}}try{p=board.create(type,input,attr);return p}catch(e){JXG.debug("* Err: Line "+attr.label+"
\n");return false}break;case"orthogonalline":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{JXG.debug("* Orthogonalline: First: "+input[0].id+", Last: "+input[1].id+"
\n");p=board.create("normal",input,attr);return p}catch(e){JXG.debug("* Err: Orthogonalline "+attr.label+"
\n");return false}break;case"polygon":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);if(input.length==3&&output.length!=4){input[2]=parseInt(input[2]);type="regular"}try{JXG.debug("* Polygon: First: "+input[0].name+", Second: "+input[1].name+", Third: "+input[2]+"
\n");var borders=[];var borderatts=[];length=(type=="regular")?output.length-input[2]+2:output.length;for(var i=1;iErr: Polygon "+attr.name+"
\n");return false}break;case"intersect":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{JXG.debug("* Intersection: First: "+input[0].name+", Second: "+input[1].name+"
\n");if(!JXG.exists(attr.styleGGB)){attr.face="circle";attr.fillColor=attr.strokeColor;attr.fillOpacity=1;attr.highlightFillColor=attr.strokeColor;attr.highlightFillOpacity=1;attr.strokeColor="black";attr.strokeWidth="1px"}if(output.length==1){p=board.create("intersection",[input[0],input[1],0],attr)}else{p=board.create("intersection",[input[0],input[1],1],attr);var attr2={};attr2=JXG.GeogebraReader.colorProperties(output[1],attr2);attr2=JXG.GeogebraReader.visualProperties(output[1],attr2);attr2.name=output[1].getAttribute("label");var p2=board.create("otherintersection",[input[0],input[1],p],attr2);board.ggbElements[attr2.name]=p2}return p}catch(e){JXG.debug("* Err: Intersection "+attr.name+"
\n");return false}break;case"distance":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{JXG.debug("* Distance: First: "+input[0].name+", Second: "+input[1].name+"
\n");if(false&&output[0].getAtribute("type")&&output[0].getAttribute("type")=="numeric"){input[1].Value=function(){return this.X()};p=input[1];board.elementsByName[attr.name]=p}else{m=board.create("midpoint",input,{visible:"false"});attr.visible="true";p=board.create("text",[function(){return m.X()},function(){return m.Y()},function(){return""+input[0].name+input[1].name+" = "+JXG.trimNumber(JXG.getRef(board,input[0].id).Dist(JXG.getRef(board,input[1].id)).toFixed(JXG.GeogebraReader.decimals))}],attr);p.Value=function(){return(JXG.getRef(board,input[0].id).Dist(JXG.getRef(board,input[1].id)))}}return p}catch(e){JXG.debug("* Err: Distance "+attr.name+"
\n");return false}break;case"vector":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);if(element.getElementsByTagName("startPoint")[0]){if(input&&input.length==2){e=JXG.GeogebraReader.checkElement(input[1].name)}else{e=[parseFloat(element.getElementsByTagName("coords")[0].getAttribute("x")),parseFloat(element.getElementsByTagName("coords")[0].getAttribute("y"))]}if(element.getElementsByTagName("startPoint")[0].getAttribute("x")&&element.getElementsByTagName("startPoint")[0].getAttribute("y")){s=[parseFloat(element.getElementsByTagName("startPoint")[0].getAttribute("x")),parseFloat(element.getElementsByTagName("startPoint")[0].getAttribute("y"))]}else{if(element.getElementsByTagName("startPoint")[0].getAttribute("exp")){var startpoint=element.getElementsByTagName("startPoint")[0].getAttribute("exp");s=JXG.GeogebraReader.checkElement(startpoint)}}}else{if(input&&input.length!=0){s=input[0];e=input[1]}else{exp=JXG.GeogebraReader.getElement(element.getAttribute("label"),true);if(exp){exp=exp.getAttribute("exp");exp=JXG.GeogebraReader.ggbParse(exp);if(JXG.isArray(exp)){exp=new Array(new Function("return "+exp[1]+";"),new Function("return "+exp[2]+";"))}else{exp=new Function("return "+exp+";")}JXG.debug("exp: "+exp);p=board.create("arrow",[[0,0],[exp[0],exp[1]]],attr);return p}}}try{JXG.debug("* Vector: First: "+attr.name);p=board.create("arrow",[s,e],attr);return p}catch(e){JXG.debug("* Err: Vector "+attr.name+e+"
\n");return false}break;case"rotate":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{JXG.debug("* Rotate: First: "+input[0].name+", Second: "+input[1]+"
\n");attr.type="rotate";if(!JXG.exists(attr.styleGGB)){attr.face="circle";attr.fillColor=attr.strokeColor;attr.fillOpacity=1;attr.highlightFillColor=attr.strokeColor;attr.highlightFillOpacity=1;attr.strokeColor="black";attr.strokeWidth="1px"}t=board.create("transform",[parseInt(input[1])*Math.PI/180,input[2]],{type:"rotate"});p=board.create("point",[input[0],t],attr);return p}catch(e){JXG.debug("* Err: Rotate "+attr.name+"
\n");return false}break;case"dilate":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{JXG.debug("* Dilate: First: "+input[0].name+", Second: "+input[1]+"
\n");attr.type="rotate";var d=parseInt(input[1]);var d1=board.create("transform",[d,d],{type:"scale"});var d2=board.create("transform",[function(){return(1-d)*input[2].X()},function(){return(1-d)*input[2].Y()}],{type:"translate"});if(!JXG.exists(attr.styleGGB)){attr.face="circle";attr.fillColor=attr.strokeColor;attr.fillOpacity=1;attr.highlightFillColor=attr.strokeColor;attr.highlightFillOpacity=1;attr.strokeColor="black";attr.strokeWidth="1px"}p=board.create("point",[input[0],[d1,d2]],attr);return p}catch(e){JXG.debug("* Err: Dilate "+attr.name+"
\n");return false}break;case"translate":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{t=board.create("transform",[function(){return input[1].point2.X()-input[1].point1.X()},function(){return input[1].point2.Y()-input[1].point1.Y()}],{type:"translate"});if(!JXG.exists(attr.styleGGB)){attr.face="circle";attr.fillColor=attr.strokeColor;attr.fillOpacity=1;attr.highlightFillColor=attr.strokeColor;attr.highlightFillOpacity=1;attr.strokeColor="black";attr.strokeWidth="1px"}p=board.create("point",[input[0],t],attr);return p}catch(e){JXG.debug("* Err: Translate "+attr.name+"
\n");return false}break;case"mirror":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);if(JXG.isPoint(JXG.getRef(board,input[1].id))){var type="mirrorpoint"}else{if(JXG.getRef(board,input[1].id).elementClass==JXG.OBJECT_CLASS_LINE){var type="reflection"}}try{JXG.debug("* Mirror: First: "+input[0].name+", Second: "+input[1].name+"
\n");p=board.create(type,[input[1],input[0]],attr);return p}catch(e){JXG.debug("* Err: Mirror "+attr.name+"
\n");return false}break;case"circle":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{JXG.debug("* Circle: First: "+input[0].name+", Second: "+input[1]+"
\n");p=board.create("circle",input,attr);return p}catch(e){JXG.debug("* Err: Circle "+attr.name+"
\n");return false}break;case"circlearc":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{JXG.debug("* CircleArc: First: "+input[0].name+", Second: "+input[1].name+"
\n");p=board.create("arc",input,attr);return p}catch(e){JXG.debug("* Err: CircleArc "+attr.name+"
\n");return false}break;case"ellipse":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{JXG.debug("* Ellipse: First: "+input[0].name+", Second: "+input[1].name+", Third: "+input[2]+"
\n");if(parseInt(input[2])==input[2]){input[2]=parseInt(input[2]*2)}p=board.create("ellipse",input,attr);return p}catch(e){JXG.debug("* Err: Ellipse "+attr.name+"
\n");return false}break;case"conic":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);if(input&&input.length==5){p=board.create("conic",input,attr)}else{if(element.getElementsByTagName("matrix")){m=[];for(var i=0;iCircleSector: First: "+input[0].name+", Second: "+input[1].name+", Third: "+input[2].name+"
\n");p=board.create("sector",[input[0],input[1],input[2]],attr);return p}catch(e){JXG.debug("* Err: CircleSector "+attr.name+"
\n");return false}break;case"linebisector":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{JXG.debug("* LineBiSector (Mittelsenkrechte): First: "+input[0].name+"
\n");m=board.create("midpoint",input,{visible:false});if(JXG.isPoint(JXG.getRef(board,input[0].id))&&JXG.isPoint(JXG.getRef(board,input[1].id))){t=board.create("line",input,{visible:"false"});p=board.create("perpendicular",[m,t],attr)}else{p=board.create("perpendicular",[m,input[0]],attr)}return p}catch(e){JXG.debug("* Err: LineBiSector (Mittelsenkrechte) "+attr.name+"
\n");return false}break;case"ray":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{JXG.debug("* Ray: First: "+input[0].name+"
\n");attr.straightFirst=true;attr.straightLast=false;p=board.create("line",[input[1],input[0]],attr);return p}catch(e){JXG.debug("* Err: Ray "+attr.name+"
\n");return false}break;case"tangent":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{JXG.debug("* Tangent: First: "+input[0].name+", Sec.: "+input[1].name+"("+input[1].type+")
\n");switch(input[1].type){case 1330923344:input[0].makeGlider(input[1]);p=board.create("tangent",[input[0]],attr);return p;break;case 1330922316:case 1330922319:var pol=board.create("polar",[input[1],input[0]],{visible:false});var i1=board.create("intersection",[input[1],pol,0],{visible:false});var i2=board.create("intersection",[input[1],pol,1],{visible:false});var t1=board.create("line",[input[0],i1],attr);var attr2={};attr2=JXG.GeogebraReader.colorProperties(output[1],attr2);attr2=JXG.GeogebraReader.visualProperties(output[1],attr2);attr2.name=output[1].getAttribute("label");var t2=board.create("line",[input[0],i2],attr2);board.ggbElements[attr2.name]=t2;return[t1,t2];break}}catch(e){JXG.debug("* Err: Tangent "+attr.name+" "+attr2.name+"
\n");return false}break;case"circumcirclearc":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{JXG.debug("* CircumcircleArc: First: "+input[0].name+"
\n");p=board.create("circumcirclearc",input,attr);return p}catch(e){JXG.debug("* Err: CircumcircleArc "+attr.name+"
\n");return false}break;case"circumcirclesector":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{JXG.debug("* CircumcircleSector: First: "+input[0].name+"
\n");p=board.create("circumcirclesector",[input[0],input[1],input[2]],attr);return p}catch(e){JXG.debug("* Err: CircumcircleSector "+attr.name+"
\n");return false}break;case"semicircle":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{JXG.debug("* Semicircle: First: "+input[0].name+"
\n");p=board.create("semicircle",[input[0],input[1]],attr);return p}catch(e){JXG.debug("* Err: Semicircle "+attr.name+"
\n");return false}break;case"angle":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{JXG.debug("* Angle: First: "+input[0].name+"
\n");p=board.create("angle",input,attr);return p}catch(e){JXG.debug("* Err: Angle "+attr.name+"
\n");return false}break;case"angularbisector":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);attr.straightFirst=true;attr.straightLast=true;try{JXG.debug("* Angularbisector: First: "+input[0].name+"
\n");p=board.create("bisector",input,attr);return p}catch(e){JXG.debug("* Err: Angularbisector "+attr.name+"
\n");return false}break;case"numeric":if(element.getElementsByTagName("slider").length==0){exp=JXG.GeogebraReader.getElement(element.getAttribute("label"),true);if(exp){exp=exp.getAttribute("exp");exp=JXG.GeogebraReader.functionParse("",exp);exp=JXG.GeogebraReader.ggbParse(exp)}board.ggb[attr.name]=new Function("return "+exp+";");JXG.debug("value: "+board.ggb[attr.name]());return board.ggb[attr.name]}else{attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);attr=JXG.GeogebraReader.visualProperties(element,attr);if(element.getElementsByTagName("slider").length==1){sx=parseFloat(element.getElementsByTagName("slider")[0].getAttribute("x"));sy=parseFloat(element.getElementsByTagName("slider")[0].getAttribute("y"));length=parseFloat(element.getElementsByTagName("slider")[0].getAttribute("width"));if(element.getElementsByTagName("slider")[0].getAttribute("absoluteScreenLocation")&&element.getElementsByTagName("slider")[0].getAttribute("absoluteScreenLocation")=="true"){var tmp=new JXG.Coords(JXG.COORDS_BY_SCREEN,[sx,sy],board);sx=tmp.usrCoords[1];sy=tmp.usrCoords[2]}if(element.getElementsByTagName("slider")[0].getAttribute("horizontal")=="true"){if(element.getElementsByTagName("slider")[0].getAttribute("absoluteScreenLocation")&&element.getElementsByTagName("slider")[0].getAttribute("absoluteScreenLocation")=="true"){length/=(board.unitX)}ex=sx+length;ey=sy}else{if(element.getElementsByTagName("slider")[0].getAttribute("absoluteScreenLocation")&&element.getElementsByTagName("slider")[0].getAttribute("absoluteScreenLocation")=="true"){length/=(board.unitY)}ex=sx;ey=sy+length}(element.getElementsByTagName("animation")[0])?attr.snapWidth=parseFloat(element.getElementsByTagName("animation")[0].getAttribute("step")):false;try{JXG.debug("* Numeric: First: "+attr.name+"
\n");attr.withTicks=false;p=board.create("slider",[[sx,sy],[ex,ey],[parseFloat(element.getElementsByTagName("slider")[0].getAttribute("min")),parseFloat(element.getElementsByTagName("value")[0].getAttribute("val")),parseFloat(element.getElementsByTagName("slider")[0].getAttribute("max"))]],attr);p.setProperty({withLabel:false});return p}catch(e){JXG.debug("* Err: Numeric "+attr.name+"
\n");return false}}}break;case"midpoint":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{if(!JXG.exists(attr.styleGGB)){attr.face="circle";attr.fillColor=attr.strokeColor;attr.fillOpacity=1;attr.highlightFillColor=attr.strokeColor;attr.highlightFillOpacity=1;attr.strokeColor="black";attr.strokeWidth="1px"}p=board.create("midpoint",input,attr);JXG.debug("* Midpoint ("+p.id+"): "+attr.name+"("+gxtEl.x+", "+gxtEl.y+")
\n");return p}catch(e){JXG.debug("* Err: Midpoint "+attr.name+"
\n");return false}break;case"center":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{if(!JXG.exists(attr.styleGGB)){attr.face="circle";attr.fillColor=attr.strokeColor;attr.fillOpacity=1;attr.highlightFillColor=attr.strokeColor;attr.highlightFillOpacity=1;attr.strokeColor="black";attr.strokeWidth="1px"}p=board.create("point",[function(){return JXG.getRef(board,input[0].id).center.X()},function(){return JXG.getRef(board,input[0].id).center.Y()}],attr);JXG.debug("* Center ("+p.id+"): "+attr.name+"("+gxtEl.x+", "+gxtEl.y+")
\n");return p}catch(e){JXG.debug("* Err: Center "+attr.name+"
\n");return false}break;case"function":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);if(JXG.GeogebraReader.getElement(attr.name,true)){func=JXG.GeogebraReader.getElement(attr.name,true).getAttribute("exp");func=JXG.GeogebraReader.functionParse("c",func)}else{func=input[0];func=JXG.GeogebraReader.functionParse("s",func)}JXG.debug(func);length=func.length;func[func.length-1]="return "+JXG.GeogebraReader.ggbParse(func[func.length-1])+";";JXG.debug(func);range=[(input&&input[1])?input[1]:null,(input&&input[2])?input[2]:null];try{if(length==1){p=board.create("functiongraph",[new Function(func[0]),range[0],range[1]],attr)}else{if(length==2){p=board.create("functiongraph",[new Function(func[0],func[1]),range[0],range[1]],attr)}else{if(length==3){p=board.create("functiongraph",[new Function(func[0],func[1],func[2]),range[0],range[1]],attr)}else{if(length==4){p=board.create("functiongraph",[new Function(func[0],func[1],func[2],func[3]),range[0],range[1]],attr)}else{if(length==5){p=board.create("functiongraph",[new Function(func[0],func[1],func[2],func[3],func[4]),range[0],range[1]],attr)}}}}}return p}catch(e){JXG.debug("* Err: Functiongraph "+attr.name+"
\n");return false}break;case"polar":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{JXG.debug("* Polar: First: "+input[0].name+", Sec.: "+input[1].name+"
\n");p=board.create("polar",input,attr);return p}catch(e){JXG.debug("* Err: Polar "+attr.name+"
\n");return false}break;case"slope":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);try{JXG.debug("* Slope ("+attr.name+"): First: "+input[0].name+"
\n");var slopeWidth=parseInt(attr.slopeWidth)||1;var p1=input[0].glider||input[0].point1;var p2=board.create("point",[function(){return(slopeWidth+p1.X())},function(){return p1.Y()}],{visible:false});var l1=board.create("segment",[p1,p2],{visible:false});var l2=board.create("normal",[l1,l1.point2],{visible:false});var i=board.create("intersection",[input[0],l2,0],{visible:false});var m=board.create("midpoint",[l1.point2,i],{visible:false});var t=board.create("text",[function(){return m.X()},function(){return m.Y()},function(){return"  "+(slopeWidth>1?slopeWidth.toString():"")+" "+this.name+" = "+JXG.trimNumber((slopeWidth*input[0].getSlope()).toFixed(JXG.GeogebraReader.decimals))}],attr);attr.name="";var t2=board.create("text",[function(){return(p1.X()+p2.X())/2},function(){return p1.Y()},function(){return"
"+slopeWidth}],attr);t.Value=(function(){return function(){return input[0].getSlope()}})();var poly=board.create("polygon",[p1,p2,i],attr);poly.borders[2].setProperty({visible:false});poly.borders[0].setProperty({strokeColor:attr.fillColor,strokeWidth:attr.strokeWidth,highlightStrokeColor:attr.fillColor,dash:attr.dash});poly.borders[1].setProperty({strokeColor:attr.fillColor,strokeWidth:attr.strokeWidth,highlightStrokeColor:attr.fillColor,dash:attr.dash});return t}catch(e){JXG.debug("* Err: Slope "+attr.name+"
\n");return false}break;case"text":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);var rx,res="";try{if(element.getElementsByTagName("isLaTeX")[0]&&element.getElementsByTagName("isLaTeX")[0].getAttribute("val")=="true"){JXG.GeogebraReader.board.options.text.useASCIIMathML=true;t=JXG.GeogebraReader.getElement(attr.name,true).getAttribute("exp");while(rx=t.match(/(.*?)" \+ (.+) \+ "(.*)/)){var re2=JXG.GeogebraReader.ggbParse(RegExp.$2);if(typeof re2=="string"){res=res+RegExp.$1+re2}else{res=res+RegExp.$1+'" + JXG.trimNumber(('+re2+').toFixed(JXG.GeogebraReader.decimals)) + "'}t=RegExp.$3}if(rx=t.match(/(.*?)" \+ (.+)/)){res=res+RegExp.$1+'" + JXG.trimNumber(('+JXG.GeogebraReader.ggbParse(RegExp.$2)+").toFixed(JXG.GeogebraReader.decimals))"}else{res=res+t}JXG.debug("Text: "+res);p=board.create("text",[gxtEl.x,gxtEl.y,new Function("return "+res+";")],attr)}else{JXG.debug(JXG.GeogebraReader.getElement(attr.name,true).getAttribute("exp"));t=JXG.GeogebraReader.ggbParse(JXG.GeogebraReader.functionParse(false,JXG.GeogebraReader.getElement(attr.name,true).getAttribute("exp")));JXG.debug(t[1]);p=board.create("text",[gxtEl.x,gxtEl.y,new Function("return "+t[0]+' + " " + JXG.trimNumber(parseFloat('+t[1]+").toFixed(JXG.GeogebraReader.decimals));")],attr)}JXG.debug("* Text: "+t+"
\n");return p}catch(e){JXG.debug("* Err: Text: "+t+"
\n");return false}break;case"root":attr=JXG.GeogebraReader.boardProperties(gxtEl,element,attr);attr=JXG.GeogebraReader.colorProperties(element,attr);gxtEl=JXG.GeogebraReader.coordinates(gxtEl,element);attr=JXG.GeogebraReader.visualProperties(element,attr);for(var i=0;iIntegral: First: "+input[0].name+", Sec.: "+input[1].name+", Thir.: "+input[2].name+"
\n");JXG.debug([input[1](),input[2]()]);var p=board.create("integral",[JXG.getRef(board,input[0]),[input[1],input[2]]],attr);return p}catch(e){JXG.debug("* Err: Integral "+attr.name+e+"
\n");return false}break;default:return false;break}};this.readGeogebra=function(tree,board){var el,Data,i,els=[],expr;board.ggbElements=[];board.ggb={};JXG.GeogebraReader.tree=tree;JXG.GeogebraReader.board=board;JXG.GeogebraReader.format=parseFloat(JXG.GeogebraReader.tree.getElementsByTagName("geogebra")[0].getAttribute("format"));JXG.GeogebraReader.decimals=parseInt(JXG.GeogebraReader.tree.getElementsByTagName("geogebra")[0].getElementsByTagName("kernel")[0].getElementsByTagName("decimals")[0].getAttribute("val"));JXG.GeogebraReader.writeBoard(board);board=JXG.GeogebraReader.setDefaultOptions(board);var constructions=JXG.GeogebraReader.tree.getElementsByTagName("construction");for(var t=0;t="):exp;exp=(exp.match(/\u2227/))?exp.replace(/\u2227/g,"&&"):exp;exp=(exp.match(/\u2228/))?exp.replace(/\u2228/g,"//"):exp;return exp};this.prepareString=function(fileStr,isString){var i,bA,len,fstr;if(isString){fstr=JXG.Util.Base64.decode(fileStr);if(fstr.slice(0,2)!=="PK"){fstr=JXG.Util.Base64.decode(fileStr,true)}fileStr=fstr}if(fileStr.indexOf("<")!=0){bA=[];len=fileStr.length;for(i=0;i. +*/ + JXG.debug=function(){};JXG.GeonextReader={changeOriginIds:function(a,b){if((b=="gOOe0")||(b=="gXOe0")||(b=="gYOe0")||(b=="gXLe0")||(b=="gYLe0")){return a.id+b}else{return b}},gEBTN:function(e,b,a,d){var c;if(!JXG.exists(e||!e.getElementsByTagName)){return""}if(!JXG.exists(d)){d=true}a=a||0;c=e.getElementsByTagName(b);if(c.length>0){c=c[a];if(d&&c.firstChild){c=c.firstChild.data}}return c},colorProperties:function(d,c){var b=this.gEBTN(c,"color",0,false),a;a=JXG.rgba2rgbo(this.gEBTN(b,"stroke"));d.strokeColor=a[0];d.strokeOpacity=a[1];a=JXG.rgba2rgbo(this.gEBTN(b,"lighting"));d.highlightStrokeColor=a[0];d.highlightStrokeOpacity=a[1];a=JXG.rgba2rgbo(this.gEBTN(b,"fill"));d.fillColor=a[0];d.fillOpacity=a[1];d.highlightFillColor=d.fillColor;d.highlightFillOpacity=d.fillOpacity;d.labelColor=JXG.rgba2rgbo(this.gEBTN(b,"label"))[0];d.colorDraft=JXG.rgba2rgbo(this.gEBTN(b,"draft"))[0];if(JXG.rgba2rgbo(this.gEBTN(b,"label"))[1]==0){d.withLabel=false}else{d.withLabel=true}d.colorStroke=d.strokeColor;d.colorFill=d.fillColor;d.colorLabel=d.labelColor;return d},firstLevelProperties:function(e,c){if(!JXG.exists(c)||!JXG.exists(c.childNodes)){return e}var a=c.childNodes,d,b;for(d=0;d\n")},readGeonext:function(m,g){var j,n,l,i,d,c,b,a,h,e,k="true",f=this;g.options.layer.sector=g.options.layer.angle;g.options.layer.circle=g.options.layer.angle;g.options.line.label.position="top";c=this.gEBTN(m,"board",0,false);h=this.readConditions(c.getElementsByTagName("conditions")[0]);j=this.gEBTN(c,"coordinates",0,false);e=this.gEBTN(j,"origin",0,false);g.origin={usrCoords:[1,0,0],scrCoords:[1,parseFloat(this.gEBTN(e,"x")),parseFloat(this.gEBTN(e,"y"))]};e=this.gEBTN(j,"zoom",0,false);g.zoomX=parseFloat(this.gEBTN(e,"x"));g.zoomY=parseFloat(this.gEBTN(e,"y"));e=this.gEBTN(j,"unit",0,false);g.unitX=parseFloat(this.gEBTN(e,"x"));g.unitY=parseFloat(this.gEBTN(e,"y"));if(g.options.takeSizeFromFile){g.resizeContainer(this.gEBTN(c,"width"),this.gEBTN(c,"height"))}if(!(parseFloat(g.options.text.fontSize)>0)){g.options.text.fontSize=12}g.geonextCompatibilityMode=true;delete (JXG.JSXGraph.boards[g.id]);g.id=this.gEBTN(c,"id");JXG.JSXGraph.boards[g.id]=g;g.initGeonextBoard();g.renderer.enhancedRendering=true;this.parseImage(g,this.gEBTN(c,"file",0,false),g.options.layer.image);g.options.point.snapToGrid=(this.gEBTN(this.gEBTN(c,"coordinates",0,false),"snap")==k);if(g.options.point.snapToGrid&&this.gEBTN(this.gEBTN(c,"grid",1,false),"pointsnap")==k){g.options.point.snapToGrid=false;g.options.point.snapToPoints=true;g.options.point.attractorDistance=0.5}j=this.gEBTN(c,"grid",1,false);e=this.gEBTN(j,"x");if(e){g.options.grid.gridX=1/parseFloat(e);g.options.point.snapSizeX=parseFloat(e)}e=this.gEBTN(j,"y");if(e){g.options.grid.gridY=1/parseFloat(e);g.options.point.snapSizeY=parseFloat(e)}g.options.grid.gridDash=JXG.str2Bool(this.gEBTN(j,"dash"));e=JXG.rgba2rgbo(this.gEBTN(j,"color"));g.options.grid.gridColor=e[0];g.options.grid.gridOpacity=e[1];j=this.gEBTN(c,"coordinates",0,false);if(this.gEBTN(j,"grid")==k){g.create("grid",[])}if(this.gEBTN(j,"coord")==k){g.options.axis.ticks.majorHeight=10;g.options.axis.ticks.minorHeight=4;g.create("axis",[[0,0],[1,0]]);g.create("axis",[[0,0],[0,1]])}g.containerObj.style.backgroundColor=JXG.rgba2rgbo(this.gEBTN(this.gEBTN(c,"background",0,false),"color"))[0];n=m.getElementsByTagName("elements")[0].childNodes;for(l=0;l0){r.radius=f.changeOriginIds(g,f.gEBTN(w,"radius"))}else{if(w.getElementsByTagName("radiusvalue").length>0){r.radius=f.gEBTN(w,"radiusvalue")}}r=f.transformProperties(r);D=g.create("circle",[r.center,r.radius],r);f.parseImage(g,i,g.options.layer.image,0,0,0,0,D);f.printDebugMessage("debug",r,i.nodeName,"OK");break;case"slider":r=f.colorProperties(r,i);r=f.visualProperties(r,i);r=f.firstLevelProperties(r,i);r=f.readNodes(r,i,"data");r.fixed=JXG.str2Bool(f.gEBTN(i,"fix"));r=f.readNodes(r,i,"animate","animate");r=f.transformProperties(r,"point");try{r.parent=f.changeOriginIds(g,r.parent);o=g.create("glider",[parseFloat(r.x),parseFloat(r.y),r.parent],r);o.onPolygon=JXG.exists(r.onpolygon)&&JXG.str2Bool(r.onpolygon);f.parseImage(g,i,g.options.layer.point,0,0,0,0,o);f.printDebugMessage("debug",r,i.nodeName,"OK")}catch(C){JXG.debug("* Err: Slider "+r.name+" "+r.id+": "+r.parent+"
\n")}break;case"cas":r=f.colorProperties(r,i);r=f.visualProperties(r,i);r=f.firstLevelProperties(r,i);r.fixed=JXG.str2Bool(i.getElementsByTagName("fix")[0].firstChild.data);r=f.readNodes(r,i,"data");r=f.transformProperties(r,"point");if(false){r.x=JXG.GeonextParser.gxt2jc(r.x,g);r.y=JXG.GeonextParser.gxt2jc(r.y,g)}else{r.x=JXG.GeonextParser.geonext2JS(r.x,g);r.x=new Function("return "+r.x+";");r.y=JXG.GeonextParser.geonext2JS(r.y,g);r.y=new Function("return "+r.y+";")}o=g.create("point",[r.x,r.y],r);f.parseImage(g,i,g.options.layer.point,0,0,0,0,o);f.printDebugMessage("debug",r,i.nodeName,"OK");break;case"intersection":r=f.readNodes(r,i,"data");j=i.getElementsByTagName("first")[1];r.outFirst={};r.outFirst=f.colorProperties(r.outFirst,j);r.outFirst=f.visualProperties(r.outFirst,j);r.outFirst=f.firstLevelProperties(r.outFirst,j);r.outFirst.fixed=JXG.str2Bool(j.getElementsByTagName("fix")[0].firstChild.data);r.outFirst=f.transformProperties(r.outFirst,"point");r.first=f.changeOriginIds(g,r.first);r.last=f.changeOriginIds(g,r.last);if((JXG.getReference(g,r.first).elementClass==JXG.OBJECT_CLASS_LINE)&&(JXG.getReference(g,r.last).elementClass==JXG.OBJECT_CLASS_LINE)){t=g.create("intersection",[g.objects[r.first],g.objects[r.last],0],r.outFirst);if(r.outFirst.visible=="false"){t.hideElement()}}else{j=i.getElementsByTagName("last")[1];if(JXG.exists(j)){r.outLast={};r.outLast=f.colorProperties(r.outLast,j);r.outLast=f.visualProperties(r.outLast,j);r.outLast=f.firstLevelProperties(r.outLast,j);r.outLast.fixed=JXG.str2Bool(j.getElementsByTagName("fix")[0].firstChild.data);r.outLast=f.transformProperties(r.outLast,"point");t=g.create("intersection",[g.objects[r.first],g.objects[r.last],0],r.outFirst);t=g.create("intersection",[g.objects[r.first],g.objects[r.last],1],r.outLast)}}f.printDebugMessage("debug",r,i.nodeName,"OK");break;case"composition":r=f.readNodes(r,i,"data");r=f.firstLevelProperties(r,i);r.defEl=[];B=0;j=i.getElementsByTagName("data")[0].getElementsByTagName("input");for(z=0;z/g,"");r.fixed=false;try{if(i.getElementsByTagName("data")[0].getElementsByTagName("parent")[0].firstChild){r.parent=i.getElementsByTagName("data")[0].getElementsByTagName("parent")[0].firstChild.data;r.fixed=true}}catch(C){}r.condition=i.getElementsByTagName("condition")[0].firstChild.data;r.content=i.getElementsByTagName("content")[0].firstChild.data;r.fix=i.getElementsByTagName("fix")[0].firstChild.data;r.autodigits=i.getElementsByTagName("digits")[0].firstChild.data;r.parent=f.changeOriginIds(g,r.parent);D=g.create("text",[r.x,r.y,r.mpStr],{anchor:r.parent,id:r.id,name:r.name,digits:r.autodigits,isLabel:false,strokeColor:r.colorLabel,fixed:r.fixed,visible:JXG.str2Bool(r.visible)});break;case"parametercurve":r=f.colorProperties(r,i);r=f.visualProperties(r,i);r=f.firstLevelProperties(r,i);r=f.transformProperties(r);r.functionx=i.getElementsByTagName("functionx")[0].firstChild.data;r.functiony=i.getElementsByTagName("functiony")[0].firstChild.data;r.min=i.getElementsByTagName("min")[0].firstChild.data;r.max=i.getElementsByTagName("max")[0].firstChild.data;r.fillColor="none";r.highlightFillColor="none";g.create("curve",[new Function("t","return "+JXG.GeonextParser.geonext2JS(r.functionx,g)+";"),new Function("t","return "+JXG.GeonextParser.geonext2JS(r.functiony,g)+";"),new Function("return "+JXG.GeonextParser.geonext2JS(r.min,g)+";"),new Function("return "+JXG.GeonextParser.geonext2JS(r.max,g)+";")],r);f.printDebugMessage("debug",r,i.nodeName,"OK");break;case"tracecurve":r.tracepoint=i.getElementsByTagName("tracepoint")[0].firstChild.data;r.traceslider=i.getElementsByTagName("traceslider")[0].firstChild.data;g.create("tracecurve",[r.traceslider,r.tracepoint],r);f.printDebugMessage("debug",r,i.nodeName,"OK");break;case"group":r=f.colorProperties(r,i);r=f.firstLevelProperties(r,i);r.members=[];for(z=0;zErr: "+i.nodeName+" not yet implemented
\n")}delete (r)})(l)}g.addConditions(h)},decodeString:function(b){var a;if(b.indexOf("")<0){a=(new JXG.Util.Unzip(JXG.Util.Base64.decodeAsArray(b))).unzip();if(a==""){return b}else{return a}}else{return b}},prepareString:function(a){try{if(a.indexOf("GEONEXT")<0){a=(this.decodeString(a))[0][0]}a=this.fixXML(a)}catch(b){a=""}return a},fixXML:function(e){var a=["active","angle","animate","animated","arc","area","arrow","author","autodigits","axis","back","background","board","border","bottom","buttonsize","cas","circle","color","comment","composition","condition","conditions","content","continuous","control","coord","coordinates","cross","cs","dash","data","description","digits","direction","draft","editable","elements","event","file","fill","first","firstarrow","fix","fontsize","free","full","function","functionx","functiony","GEONEXT","graph","grid","group","height","id","image","info","information","input","intersection","item","jsf","label","last","lastarrow","left","lefttoolbar","lighting","line","loop","max","maximized","member","middle","midpoint","min","modifier","modus","mp","mpx","multi","name","onpolygon","order","origin","output","overline","parametercurve","parent","point","pointsnap","polygon","position","radius","radiusnum","radiusvalue","right","section","selectedlefttoolbar","showconstruction","showcoord","showinfo","showunit","showx","showy","size","slider","snap","speed","src","start","stop","straight","stroke","strokewidth","style","term","text","top","trace","tracecurve","tracepoint","traceslider","type","unit","value","VERSION","vertex","viewport","visible","width","wot","x","xooy","xval","y","yval","zoom"],c=a.join("|"),b="<(/?("+c+"))>",d=new RegExp(b,"g");e=JXG.escapeHTML(e);e=e.replace(d,"<$1>");e=e.replace(/(.*)(.*<\/content>)/g,"$1<arc>$2");e=e.replace(/(.*)(.*<\/mpx>)/g,"$1<arc>$2");e=e.replace(/(.*)(.*<\/mpx>)/g,"$1<arc>$2");return e}}; \ No newline at end of file diff --git a/ajax/libs/jsxgraph/0.94/IntergeoReader.min.js b/ajax/libs/jsxgraph/0.94/IntergeoReader.min.js new file mode 100644 index 000000000..a7caeb685 --- /dev/null +++ b/ajax/libs/jsxgraph/0.94/IntergeoReader.min.js @@ -0,0 +1,26 @@ +/* Version 0.94 */ +/* + Copyright 2008-2012 + Matthias Ehmann, + Michael Gerhaeuser, + Carsten Miller, + Bianca Valentin, + Alfred Wassermann, + Peter Wilfahrt + + This file is part of JSXGraph. + + JSXGraph is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + JSXGraph is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with JSXGraph. If not, see . +*/ + JXG.IntergeoReader=new function(){this.board=null;this.objects={};this.readIntergeo=function(a,b){this.board=b;this.board.origin={};this.board.origin.usrCoords=[1,0,0];this.board.origin.scrCoords=[1,400,300];this.board.unitX=30;this.board.unitY=30;this.readElements(a.getElementsByTagName("elements"));this.readConstraints(a.getElementsByTagName("constraints"));this.cleanUp();this.board.fullUpdate();this.readDisplay(a.getElementsByTagName("display"));this.board.fullUpdate()};this.readElements=function(a){var b;for(var b=0;b1){return}if(d.nodeName=="point"){JXG.IntergeoReader.storePoint(d)}else{if(d.nodeName=="line"||d.nodeName=="line_segment"||d.nodeName=="ray"||d.nodeName=="vector"){JXG.IntergeoReader.storeLine(d)}else{if(d.nodeName=="circle"){JXG.IntergeoReader.storeConic(d)}else{if(d.nodeName=="conic"){JXG.IntergeoReader.storeConic(d)}else{if(d.nodeName=="polygon"){}else{JXG.debug("Not implemented: "+d.nodeName+" "+d.getAttribute("id"))}}}}}})(b)}};this.addPointOld=function(d){var h=0,f=0,e=0,b,a=d.childNodes[h],k=[],g={strokeColor:"red",fillColor:"red",withLabel:true},m=[];while(a.nodeType>1){h++;a=d.childNodes[h]}g.name=d.getAttribute("id");if(a.nodeName=="homogeneous_coordinates"){for(f=0;f1){e++;g=f.childNodes[e]}if(g.nodeName=="homogeneous_coordinates"){for(d=0;d1){b++;e=d.childNodes[b]}if(e.nodeName=="homogeneous_coordinates"){f=[];for(a=0;a1){b++;e=d.childNodes[b]}if(e.nodeName=="matrix"){f=[];for(a=0;a1){return}if(e.nodeName=="line_through_two_points"){JXG.IntergeoReader.addLineThroughTwoPoints(e,false)}else{if(e.nodeName=="ray_from_point_through_point"){JXG.IntergeoReader.addLineThroughTwoPoints(e,true)}else{if(e.nodeName=="line_through_point"){JXG.IntergeoReader.addLineThroughPoint(e)}else{if(e.nodeName=="line_parallel_to_line_through_point"){JXG.IntergeoReader.addLineParallelToLineThroughPoint(e,false)}else{if(e.nodeName=="ray_from_point_and_vector"){JXG.IntergeoReader.addLineParallelToLineThroughPoint(e,true)}else{if(e.nodeName=="line_perpendicular_to_line_through_point"){JXG.IntergeoReader.addLinePerpendicularToLineThroughPoint(e)}else{if(e.nodeName=="line_segment_by_points"){JXG.IntergeoReader.addLineSegmentByTwoPoints(e)}else{if(e.nodeName=="vector_from_point_to_point"){JXG.IntergeoReader.addVectorFromPointToPoint(e)}else{if(e.nodeName=="endpoints_of_line_segment"){JXG.IntergeoReader.addEndpointsOfLineSegment(e)}else{if(e.nodeName=="free_point"){}else{if(e.nodeName=="free_line"){JXG.IntergeoReader.addFreeLine(e)}else{if(e.nodeName=="point_on_line"){JXG.IntergeoReader.addPointOnLine(e)}else{if(e.nodeName=="point_on_line_segment"){JXG.IntergeoReader.addPointOnLine(e)}else{if(e.nodeName=="point_on_circle"){JXG.IntergeoReader.addPointOnCircle(e)}else{if(e.nodeName=="angular_bisector_of_three_points"){JXG.IntergeoReader.addAngularBisectorOfThreePoints(e,false)}else{if(e.nodeName=="angular_bisectors_of_two_lines"){JXG.IntergeoReader.addAngularBisectorsOfTwoLines(e,false)}else{if(e.nodeName=="line_angular_bisector_of_three_points"){JXG.IntergeoReader.addAngularBisectorOfThreePoints(e,true)}else{if(e.nodeName=="line_angular_bisectors_of_two_lines"){JXG.IntergeoReader.addAngularBisectorsOfTwoLines(e,true)}else{if(e.nodeName=="midpoint_of_two_points"){JXG.IntergeoReader.addMidpointOfTwoPoints(e)}else{if(e.nodeName=="midpoint"){JXG.IntergeoReader.addMidpointOfTwoPoints(e)}else{if(e.nodeName=="midpoint_of_line_segment"||e.nodeName=="midpoint_line_segment"){JXG.IntergeoReader.addMidpointOfLineSegment(e)}else{if(e.nodeName=="point_intersection_of_two_lines"){JXG.IntergeoReader.addPointIntersectionOfTwoLines(e)}else{if(e.nodeName=="locus_defined_by_point"){JXG.IntergeoReader.addLocusDefinedByPoint(e)}else{if(e.nodeName=="locus_defined_by_point_on_line"){JXG.IntergeoReader.addLocusDefinedByPointOnLine(e)}else{if(e.nodeName=="locus_defined_by_point_on_line_segment"){JXG.IntergeoReader.addLocusDefinedByPointOnLine(e)}else{if(e.nodeName=="locus_defined_by_line_through_point"){JXG.IntergeoReader.addLocusDefinedByLineThroughPoint(e)}else{if(e.nodeName=="locus_defined_by_point_on_circle"){JXG.IntergeoReader.addLocusDefinedByPointOnCircle(e)}else{if(e.nodeName=="circle_by_three_points"){JXG.IntergeoReader.addCircleByThreePoints(e)}else{if(e.nodeName=="circle_by_center_and_point"){JXG.IntergeoReader.addCircleByCenterAndPoint(e)}else{if(e.nodeName=="center_of_circle"){JXG.IntergeoReader.addCenterOfCircle(e)}else{if(e.nodeName=="intersection_points_of_two_circles"){JXG.IntergeoReader.addIntersectionPointsOfTwoCircles(e)}else{if(e.nodeName=="intersection_points_of_circle_and_line"){JXG.IntergeoReader.addIntersectionPointsOfCircleAndLine(e)}else{if(e.nodeName=="other_intersection_point_of_two_circles"){JXG.IntergeoReader.addOtherIntersectionPointOfTwoCircles(e)}else{if(e.nodeName=="other_intersection_point_of_circle_and_line"){JXG.IntergeoReader.addOtherIntersectionPointOfCircleAndLine(e)}else{if(e.nodeName=="circle_tangent_lines_by_point"){JXG.IntergeoReader.addCircleTangentLinesByPoint(e)}else{if(e.nodeName=="polygon_by_vertices"){JXG.IntergeoReader.addPolygonByVertices(e)}else{c=JXG.IntergeoReader.readParams(e);JXG.debug("readConstraints: not implemented: "+e.nodeName+": "+c[0])}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}})(b)}};this.setAttributes=function(a){a.setProperty({strokecolor:this.board.options.point.strokeColor,fillColor:this.board.options.point.fillColor})};this.readParams=function(b){var c=[],a;for(a=0;a1){return}if(h.nodeName=="background-color"){this.board.containerObj.style.backgroundColor=h.firstChild.data}else{if(h.nodeName=="style"){f=JXG.getReference(this.board,h.getAttribute("ref"));var i=[],d;for(d=0;d