Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50641 views
1
/*
2
JSXGraph 0.99.1
3
4
Copyright 2008-2014
5
Matthias Ehmann,
6
Michael Gerhaeuser,
7
Carsten Miller,
8
Bianca Valentin,
9
Alfred Wassermann,
10
Peter Wilfahrt
11
12
This file is part of JSXGraph.
13
14
JSXGraph is free software dual licensed under the GNU LGPL or MIT License.
15
16
You can redistribute it and/or modify it under the terms of the
17
18
* GNU Lesser General Public License as published by
19
the Free Software Foundation, either version 3 of the License, or
20
(at your option) any later version
21
OR
22
* MIT License: https://github.com/jsxgraph/jsxgraph/blob/master/LICENSE.MIT
23
24
JSXGraph is distributed in the hope that it will be useful,
25
but WITHOUT ANY WARRANTY; without even the implied warranty of
26
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
GNU Lesser General Public License for more details.
28
29
You should have received a copy of the GNU Lesser General Public License and
30
the MIT License along with JSXGraph. If not, see <http://www.gnu.org/licenses/>
31
and <http://opensource.org/licenses/MIT/>.
32
*/
33
34
/**
35
* almond 0.2.5 Copyright (c) 2011-2012, The Dojo Foundation All Rights Reserved.
36
* Available via the MIT or new BSD license.
37
* see: http://github.com/jrburke/almond for details
38
*/
39
40
/**
41
* UTF-8 Decoder by Bjoern Hoehrmann
42
*
43
* Copyright (c) 2008-2009 Bjoern Hoehrmann <[email protected]>
44
*
45
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
46
* software and associated documentation files (the "Software"), to deal in the Software
47
* without restriction, including without limitation the rights to use, copy, modify, merge,
48
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
49
* to whom the Software is furnished to do so, subject to the following conditions:
50
*
51
* The above copyright notice and this permission notice shall be included in all copies or
52
* substantial portions of the Software.
53
*
54
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
55
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
56
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
57
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
58
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
59
*/
60
(function(){"use strict";JXG.GeonextReader=function(board,str){var content;this.board=board;content=this.prepareString(str);this.tree=JXG.XML.parse(content)};JXG.extend(JXG.GeonextReader.prototype,{changeOriginIds:function(board,id){if(id==="gOOe0"||id==="gXOe0"||id==="gYOe0"||id==="gXLe0"||id==="gYLe0"){return board.id+id}return id},gEBTN:function(node,tag,idx,fc){var tmp;if(!JXG.exists(node||!node.getElementsByTagName)){return node}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},colorProperties:function(gxtEl,Data){var rgbo,color=this.gEBTN(Data,"color",0,false);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;rgbo=JXG.rgba2rgbo(this.gEBTN(color,"label"));gxtEl.labelColor=rgbo[0];gxtEl.withLabel=rgbo[1]>0;gxtEl.labelOpacity=rgbo[1];gxtEl.colorDraft=JXG.rgba2rgbo(this.gEBTN(color,"draft"))[0];gxtEl.colorStroke=gxtEl.strokeColor;gxtEl.colorFill=gxtEl.fillColor;gxtEl.colorLabel=gxtEl.labelColor;return gxtEl},firstLevelProperties:function(gxtEl,Data){var n,key,arr;if(!JXG.exists(Data)||!JXG.exists(Data.childNodes)){return gxtEl}arr=Data.childNodes;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;if(key==="width"){key="strokewidth"}gxtEl[key]=arr[n].firstChild.data}}return gxtEl},defProperties:function(gxtEl,Data){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 i,facemap=["cross","cross","cross","circle","circle","circle","circle","square","square","square","plus","plus","plus"],sizemap=[2,3,4,1,2,3,4,2,3,4,2,3,4],remove=["color","dash","style","style","ident","colordraft","colorstroke","colorfill","colorlabel","active","area","showinfo","showcoord","fix"];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.draft=JXG.str2Bool(gxtEl.draft);gxtEl.trace=JXG.str2Bool(gxtEl.trace);if(type==="point"){gxtEl.fillColor=gxtEl.strokeColor;gxtEl.highlightFillColor=gxtEl.highlightStrokeColor;gxtEl.fillOpacity=gxtEl.strokeOpacity;gxtEl.highlightFillOpacity=gxtEl.highlightStrokeOpacity}if(typeof gxtEl.label==="string"){delete gxtEl.label}gxtEl.label=gxtEl.label||{opacity:gxtEl.labelOpacity};for(i=0;i<remove.length;i++){delete gxtEl[remove[i]]}return gxtEl},readNodes:function(gxtEl,Data,nodeType,prefix){var key,n,arr=this.gEBTN(Data,nodeType,0,false).childNodes;for(n=0;n<arr.length;n++){if(JXG.exists(arr[n].firstChild)){if(JXG.exists(prefix)){key=prefix+JXG.capitalize(arr[n].nodeName)}else{key=arr[n].nodeName}gxtEl[key]=arr[n].firstChild.data}}return gxtEl},subtreeToString:function(root){try{return(new XMLSerializer).serializeToString(root)}catch(e){return root.xml}},readImage:function(node){var pic="",nod=node;if(JXG.exists(nod)){pic=nod.data;while(JXG.exists(nod.nextSibling)){nod=nod.nextSibling;pic+=nod.data}}return pic},parseImage:function(board,fileNode,level,x,y,w,h,el){var tag,id,picStr,tmpImg,im=null;if(fileNode===null){return im}if(JXG.exists(fileNode.getElementsByTagName("src")[0])){tag="src"}else if(JXG.exists(fileNode.getElementsByTagName("image")[0])&&JXG.exists(this.gEBTN(fileNode,"image"))){tag="image"}else{return im}picStr=this.readImage(this.gEBTN(fileNode,tag,0,false).firstChild);if(picStr!==""){picStr="data:image/png;base64,"+picStr;if(tag==="src"){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}tmpImg=new Image;tmpImg.src=picStr;id=el.id+"_image";tmpImg.onload=function(){var xf,yf,wf,hf,im,tRot,wOrg=this.width,hOrg=this.height;if(el.elementClass===JXG.OBJECT_CLASS_LINE){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()*.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()*.5};yf=function(){return el.Y()-hf()*.5};im=board.create("image",[picStr,[xf,yf],[wf,hf]],{layer:level,id:id,anchor:el});board.renderer.hide(el.label);el.image=im}else if(el.elementClass===JXG.OBJECT_CLASS_CIRCLE){wf=function(){return 2*el.Radius()};hf=function(){return wf()*hOrg/wOrg};xf=function(){return el.center.X()-wf()*.5};yf=function(){return el.center.Y()-hf()*.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},readViewPort:function(node){var no,arr=[];no=this.gEBTN(node,"viewport",0,false);if(no){arr[0]=parseFloat(this.gEBTN(no,"left"));arr[1]=parseFloat(this.gEBTN(no,"top"));arr[2]=parseFloat(this.gEBTN(no,"right"));arr[3]=parseFloat(this.gEBTN(no,"bottom"));return arr}return[]},printDebugMessage:function(outputEl,gxtEl,nodetyp,success){JXG.debug("* "+success+": "+nodetyp+" "+gxtEl.name+" "+gxtEl.id)},readNode:function(elChildNodes,s,board){var dataVertex,i,l,x,c,numberDefEls,el,p,inter,rgbo,tmp,v,Data,xmlNode,gxtEl={};Data=elChildNodes[s];gxtEl=this.defProperties(gxtEl,Data);if(!JXG.exists(gxtEl)){return}this.printDebugMessage("debug",gxtEl,Data.nodeName.toLowerCase(),"READ:");switch(Data.nodeName.toLowerCase()){case"point":gxtEl.strokewidth=1;gxtEl=this.colorProperties(gxtEl,Data);gxtEl=this.visualProperties(gxtEl,Data);gxtEl=this.firstLevelProperties(gxtEl,Data);gxtEl=this.readNodes(gxtEl,Data,"data");gxtEl.fixed=JXG.str2Bool(this.gEBTN(Data,"fix"));gxtEl=this.transformProperties(gxtEl,"point");p=board.create("point",[parseFloat(gxtEl.x),parseFloat(gxtEl.y)],gxtEl);v=function(){return p.visProp.visible};el=this.parseImage(board,Data,board.options.layer.image,0,0,0,0,p);this.printDebugMessage("debug",gxtEl,Data.nodeName,"OK");break;case"line":gxtEl=this.colorProperties(gxtEl,Data);gxtEl=this.visualProperties(gxtEl,Data);gxtEl=this.firstLevelProperties(gxtEl,Data);gxtEl=this.readNodes(gxtEl,Data,"data");gxtEl=this.readNodes(gxtEl,Data,"straight","straight");gxtEl=this.transformProperties(gxtEl);gxtEl.first=this.changeOriginIds(board,gxtEl.first);gxtEl.last=this.changeOriginIds(board,gxtEl.last);l=board.create("line",[gxtEl.first,gxtEl.last],gxtEl);this.parseImage(board,Data,board.options.layer.image,0,0,0,0,l);this.printDebugMessage("debug",gxtEl,Data.nodeName,"OK");break;case"circle":gxtEl=this.colorProperties(gxtEl,Data);gxtEl=this.visualProperties(gxtEl,Data);gxtEl=this.firstLevelProperties(gxtEl,Data);tmp=this.gEBTN(Data,"data",0,false);gxtEl.center=this.changeOriginIds(board,this.gEBTN(tmp,"midpoint"));if(tmp.getElementsByTagName("radius").length>0){gxtEl.radius=this.changeOriginIds(board,this.gEBTN(tmp,"radius"))}else if(tmp.getElementsByTagName("radiusvalue").length>0){gxtEl.radius=this.gEBTN(tmp,"radiusvalue")}gxtEl=this.transformProperties(gxtEl);c=board.create("circle",[gxtEl.center,gxtEl.radius],gxtEl);this.parseImage(board,Data,board.options.layer.image,0,0,0,0,c);this.printDebugMessage("debug",gxtEl,Data.nodeName,"OK");break;case"slider":gxtEl.strokewidth=1;gxtEl=this.colorProperties(gxtEl,Data);gxtEl=this.visualProperties(gxtEl,Data);gxtEl=this.firstLevelProperties(gxtEl,Data);gxtEl=this.readNodes(gxtEl,Data,"data");gxtEl.fixed=JXG.str2Bool(this.gEBTN(Data,"fix"));gxtEl=this.readNodes(gxtEl,Data,"animate","animate");gxtEl=this.transformProperties(gxtEl,"point");try{gxtEl.parent=this.changeOriginIds(board,gxtEl.parent);p=board.create("glider",[parseFloat(gxtEl.x),parseFloat(gxtEl.y),gxtEl.parent],gxtEl);p.onPolygon=JXG.exists(gxtEl.onpolygon)&&JXG.str2Bool(gxtEl.onpolygon);this.parseImage(board,Data,board.options.layer.point,0,0,0,0,p);this.printDebugMessage("debug",gxtEl,Data.nodeName,"OK")}catch(e){JXG.debug("* Err: Slider "+gxtEl.name+" "+gxtEl.id+": "+gxtEl.parent)}break;case"cas":gxtEl=this.colorProperties(gxtEl,Data);gxtEl=this.visualProperties(gxtEl,Data);gxtEl=this.firstLevelProperties(gxtEl,Data);gxtEl.fixed=JXG.str2Bool(Data.getElementsByTagName("fix")[0].firstChild.data);gxtEl=this.readNodes(gxtEl,Data,"data");gxtEl=this.transformProperties(gxtEl,"point");p=board.create("point",[gxtEl.x,gxtEl.y],gxtEl);this.parseImage(board,Data,board.options.layer.point,0,0,0,0,p);this.printDebugMessage("debug",gxtEl,Data.nodeName,"OK");break;case"intersection":gxtEl.strokewidth=1;gxtEl=this.readNodes(gxtEl,Data,"data");xmlNode=Data.getElementsByTagName("first")[1];gxtEl.outFirst={};gxtEl.outFirst=this.colorProperties(gxtEl.outFirst,xmlNode);gxtEl.outFirst=this.visualProperties(gxtEl.outFirst,xmlNode);gxtEl.outFirst=this.firstLevelProperties(gxtEl.outFirst,xmlNode);gxtEl.outFirst.fixed=JXG.str2Bool(xmlNode.getElementsByTagName("fix")[0].firstChild.data);gxtEl.outFirst=this.transformProperties(gxtEl.outFirst,"point");gxtEl.first=this.changeOriginIds(board,gxtEl.first);gxtEl.last=this.changeOriginIds(board,gxtEl.last);if(board.select(gxtEl.first).elementClass===JXG.OBJECT_CLASS_LINE&&board.select(gxtEl.last).elementClass===JXG.OBJECT_CLASS_LINE){inter=board.create("intersection",[board.objects[gxtEl.first],board.objects[gxtEl.last],0],gxtEl.outFirst);if(gxtEl.outFirst.visible==="false"){inter.hideElement()}}else{xmlNode=Data.getElementsByTagName("last")[1];if(JXG.exists(xmlNode)){gxtEl.outLast={};gxtEl.outLast=this.colorProperties(gxtEl.outLast,xmlNode);gxtEl.outLast=this.visualProperties(gxtEl.outLast,xmlNode);gxtEl.outLast=this.firstLevelProperties(gxtEl.outLast,xmlNode);gxtEl.outLast.fixed=JXG.str2Bool(xmlNode.getElementsByTagName("fix")[0].firstChild.data);gxtEl.outLast=this.transformProperties(gxtEl.outLast,"point");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)}}this.printDebugMessage("debug",gxtEl,Data.nodeName,"OK");break;case"composition":gxtEl=this.readNodes(gxtEl,Data,"data");gxtEl=this.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}xmlNode=Data.getElementsByTagName("output")[0];gxtEl.out={};gxtEl.out=this.colorProperties(gxtEl.out,xmlNode);gxtEl.out=this.visualProperties(gxtEl.out,xmlNode);gxtEl.out=this.firstLevelProperties(gxtEl.out,xmlNode);gxtEl.out=this.transformProperties(gxtEl.out);gxtEl.defEl[0]=this.changeOriginIds(board,gxtEl.defEl[0]);gxtEl.defEl[1]=this.changeOriginIds(board,gxtEl.defEl[1]);gxtEl.defEl[2]=this.changeOriginIds(board,gxtEl.defEl[2]);switch(gxtEl.type){case"210070":gxtEl.out.fixed=this.gEBTN(xmlNode,"fix");xmlNode=Data.getElementsByTagName("output")[1];gxtEl.outPoint={};gxtEl.outPoint=this.defProperties(gxtEl.outPoint,xmlNode);gxtEl.outPoint=this.colorProperties(gxtEl.outPoint,xmlNode);gxtEl.outPoint=this.visualProperties(gxtEl.outPoint,xmlNode);gxtEl.outPoint=this.firstLevelProperties(gxtEl.outPoint,xmlNode);gxtEl.outPoint=this.transformProperties(gxtEl.outPoint);p=board.create("parallelpoint",[gxtEl.defEl[1],gxtEl.defEl[0]],gxtEl.outPoint);gxtEl.out.firstArrow=false;gxtEl.out.lastArrow=true;el=board.create("segment",[gxtEl.defEl[0],p],gxtEl.out);el.parallelpoint=p;break;case"210080":gxtEl.out.straightFirst=false;board.create("bisector",[gxtEl.defEl[0],gxtEl.defEl[1],gxtEl.defEl[2]],gxtEl.out);break;case"210090":xmlNode=Data.getElementsByTagName("output")[1];gxtEl.outCircle={};gxtEl.outCircle=this.defProperties(gxtEl.outCircle,xmlNode);gxtEl.outCircle=this.colorProperties(gxtEl.outCircle,xmlNode);gxtEl.outCircle=this.visualProperties(gxtEl.outCircle,xmlNode);gxtEl.outCircle=this.firstLevelProperties(gxtEl.outCircle,xmlNode);gxtEl.outCircle=this.transformProperties(gxtEl.outCircle);gxtEl.outCircle.point=gxtEl.out;board.create("circumcircle",[gxtEl.defEl[0],gxtEl.defEl[1],gxtEl.defEl[2]],gxtEl.outCircle);break;case"210100":board.create("circumcenter",[gxtEl.defEl[0],gxtEl.defEl[1],gxtEl.defEl[2]],gxtEl.out);break;case"210110":board.create("midpoint",gxtEl.defEl.slice(0,numberDefEls),gxtEl.out);break;case"210120":board.create("reflection",[gxtEl.defEl[1],gxtEl.defEl[0]],gxtEl.out);break;case"210125":board.create("mirrorpoint",[gxtEl.defEl[0],gxtEl.defEl[1]],gxtEl.out);break;case"210130":board.create("perpendicularsegment",[gxtEl.defEl[0],gxtEl.defEl[1]],gxtEl.out);break;case"210140":p=board.create("parallelpoint",[gxtEl.defEl[1],gxtEl.defEl[0]],{withLabel:false,visible:false,name:"",fixed:true});el=board.create("line",[gxtEl.defEl[0],p],gxtEl.out);el.parallelpoint=p;break;case"210150":board.create("parallelpoint",gxtEl.defEl.slice(0,numberDefEls),gxtEl.out);break;case"210160":gxtEl.out.fixed=this.gEBTN(xmlNode,"fix");xmlNode=Data.getElementsByTagName("output")[1];gxtEl.outLine={};gxtEl.outLine=this.defProperties(gxtEl.outLine,xmlNode);gxtEl.outLine=this.colorProperties(gxtEl.outLine,xmlNode);gxtEl.outLine=this.visualProperties(gxtEl.outLine,xmlNode);gxtEl.outLine=this.firstLevelProperties(gxtEl.outLine,xmlNode);gxtEl.outLine=this.readNodes(gxtEl.outLine,xmlNode,"straight","straight");gxtEl.outLine=this.transformProperties(gxtEl.outLine);gxtEl.outLine.point=gxtEl.out;board.create("perpendicularsegment",[gxtEl.defEl[1],gxtEl.defEl[0]],gxtEl.outLine);break;case"210170":board.create("perpendicularpoint",[gxtEl.defEl[1],gxtEl.defEl[0]],gxtEl.out);break;case"210180":throw new Error("JSXGraph: Element ROTATION not yet implemented.");case"210190":gxtEl.out=this.defProperties(gxtEl.out,xmlNode);gxtEl.out.firstArrow=JXG.str2Bool(this.gEBTN(xmlNode,"firstarrow"));gxtEl.out.lastArrow=JXG.str2Bool(this.gEBTN(xmlNode,"lastarrow"));xmlNode=[];c=[];for(i=0;i<4;i++){xmlNode[i]=Data.getElementsByTagName("output")[i];gxtEl.out={};gxtEl.out=this.defProperties(gxtEl.out,xmlNode[i]);gxtEl.out=this.colorProperties(gxtEl.out,xmlNode[i]);gxtEl.out=this.visualProperties(gxtEl.out,xmlNode[i]);gxtEl.out=this.firstLevelProperties(gxtEl.out,xmlNode[i]);gxtEl.out=this.transformProperties(gxtEl.out);c[i]=gxtEl.out}el=board.create("sector",gxtEl.defEl,c[0]);p=board.create("point",[function(){var p1=board.select(gxtEl.defEl[1]),p2=board.select(gxtEl.defEl[2]);return p1.X()+(p2.X()-p1.X())*el.Radius/p1.Dist(p2)},function(){var p1=board.select(gxtEl.defEl[1]),p2=board.select(gxtEl.defEl[2]);return p1.Y()+(p2.Y()-p1.Y())*el.Radius/p1.Dist(p2)}],c[1]);el=board.create("segment",[gxtEl.defEl[0],gxtEl.defEl[1]],c[2]);el=board.create("segment",[gxtEl.defEl[1],p],c[3]);break;default:throw new Error("JSXGraph: GEONExT -- element "+gxtEl.type+" not implemented.")}this.printDebugMessage("debug",gxtEl,Data.nodeName,"OK");break;case"polygon":gxtEl=this.colorProperties(gxtEl,Data);gxtEl=this.firstLevelProperties(gxtEl,Data);dataVertex=[];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]=this.changeOriginIds(board,dataVertex[i])}gxtEl.border=[];gxtEl.borders={ids:[],names:[]};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.borders.names.push(gxtEl.border[i].name);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);try{gxtEl.border[i].strokeWidth=xmlNode.getElementsByTagName("strokewidth")[0].firstChild.data}catch(ex){gxtEl.border[i].strokeWidth=xmlNode.getElementsByTagName("width")[0].firstChild.data}try{gxtEl.border[i].dash=JXG.str2Bool(xmlNode.getElementsByTagName("dash")[0].firstChild.data)}catch(exc){}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=this.transformProperties(gxtEl);p=board.create("polygon",dataVertex,gxtEl);for(i=0;i<p.borders.length;i++){p.borders[i].setProperty(gxtEl.border[i])}this.printDebugMessage("debug",gxtEl,Data.nodeName,"OK");break;case"graph":gxtEl=this.colorProperties(gxtEl,Data);gxtEl=this.firstLevelProperties(gxtEl,Data);gxtEl.funct=Data.getElementsByTagName("data")[0].getElementsByTagName("function")[0].firstChild.data;gxtEl.funct=board.jc.snippet(gxtEl.funct,true,"x",true);c=board.create("plot",[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)});this.printDebugMessage("debug",gxtEl,Data.nodeName,"OK");break;case"arrow":gxtEl=this.colorProperties(gxtEl,Data);gxtEl=this.visualProperties(gxtEl,Data);gxtEl=this.firstLevelProperties(gxtEl,Data);gxtEl=this.readNodes(gxtEl,Data,"data");gxtEl=this.readNodes(gxtEl,Data,"straight","straight");gxtEl=this.transformProperties(gxtEl);gxtEl.first=this.changeOriginIds(board,gxtEl.first);gxtEl.last=this.changeOriginIds(board,gxtEl.last);l=board.create("arrow",[gxtEl.first,gxtEl.last],gxtEl);this.printDebugMessage("debug",l,Data.nodeName,"OK");break;case"arc":gxtEl=this.colorProperties(gxtEl,Data);gxtEl=this.visualProperties(gxtEl,Data);gxtEl=this.firstLevelProperties(gxtEl,Data);gxtEl=this.readNodes(gxtEl,Data,"data");gxtEl.firstArrow=JXG.str2Bool(Data.getElementsByTagName("lastarrow")[0].firstChild.data);gxtEl.lastArrow=JXG.str2Bool(Data.getElementsByTagName("firstarrow")[0].firstChild.data);gxtEl=this.transformProperties(gxtEl);gxtEl.center=this.changeOriginIds(board,gxtEl.midpoint);gxtEl.angle=this.changeOriginIds(board,gxtEl.angle);gxtEl.radius=this.changeOriginIds(board,gxtEl.radius);c=board.create("arc",[gxtEl.center,gxtEl.radius,gxtEl.angle],gxtEl);this.printDebugMessage("debug",c,Data.nodeName,"OK");break;case"angle":gxtEl=this.colorProperties(gxtEl,Data);gxtEl=this.visualProperties(gxtEl,Data);gxtEl=this.firstLevelProperties(gxtEl,Data);gxtEl=this.readNodes(gxtEl,Data,"data");gxtEl=this.transformProperties(gxtEl);c=board.create("angle",[gxtEl.first,gxtEl.middle,gxtEl.last],gxtEl);this.printDebugMessage("debug",gxtEl,Data.nodeName,"OK");break;case"text":if(gxtEl.id.match(/oldVersion/)){break}gxtEl=this.colorProperties(gxtEl,Data);gxtEl=this.visualProperties(gxtEl,Data);gxtEl=this.firstLevelProperties(gxtEl,Data);gxtEl=this.readNodes(gxtEl,Data,"data");try{gxtEl.mpStr=this.subtreeToString(Data.getElementsByTagName("data")[0].getElementsByTagName("mp")[0]);gxtEl.mpStr=gxtEl.mpStr.replace(/<\/?mp>/g,"")}catch(ex1){gxtEl.mpStr=this.subtreeToString(Data.getElementsByTagName("data")[0].getElementsByTagName("content")[0]);gxtEl.mpStr=gxtEl.mpStr.replace(/<\/?content>/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(ex2){}try{gxtEl.condition=Data.getElementsByTagName("condition")[0].firstChild.data}catch(ex3){gxtEl.condition=""}gxtEl.content=Data.getElementsByTagName("content")[0].firstChild.data;try{gxtEl.fixed=Data.getElementsByTagName("fix")[0].firstChild.data}catch(ex4){gxtEl.fixed=false}try{gxtEl.autodigits=Data.getElementsByTagName("digits")[0].firstChild.data}catch(ex5){gxtEl.autodigits=2}gxtEl.parent=this.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=this.colorProperties(gxtEl,Data);gxtEl=this.visualProperties(gxtEl,Data);gxtEl=this.firstLevelProperties(gxtEl,Data);gxtEl=this.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.fillColor="none";gxtEl.highlightFillColor="none";board.create("curve",[board.jc.snippet(gxtEl.functionx,true,"t",true),board.jc.snippet(gxtEl.functiony,true,"t",true),board.jc.snippet(gxtEl.min,true,"",true),board.jc.snippet(gxtEl.max,true,"",true)],gxtEl);this.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);this.printDebugMessage("debug",gxtEl,Data.nodeName,"OK");break;case"group":gxtEl=this.colorProperties(gxtEl,Data);gxtEl=this.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]=this.changeOriginIds(board,gxtEl.members[i])}c=new JXG.Group(board,gxtEl.id,gxtEl.name,gxtEl.members);this.printDebugMessage("debug",gxtEl,Data.nodeName,"OK");break;default:JXG.debug("* Err: "+Data.nodeName+" not yet implemented")}},read:function(){var xmlNode,elChildNodes,s,boardData,conditions,tmp,tree=this.tree,board=this.board,strTrue="true";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]);s=this.gEBTN(boardData,"background",0,false);s=this.gEBTN(s,"color",0,true);tmp=JXG.rgba2rgbo(s);s=JXG.rgbParser(tmp[0]);board.containerObj.style.backgroundColor="rgba("+s[0]+", "+s[1]+", "+s[2]+", "+tmp[1]+")";if(board.attr.takeSizeFromFile){board.resizeContainer(this.gEBTN(boardData,"width"),this.gEBTN(boardData,"height"))}xmlNode=this.gEBTN(boardData,"coordinates",0,false);tmp=this.readViewPort(xmlNode);if(tmp.length===4){board.setBoundingBox(tmp,true)}else{tmp=this.gEBTN(xmlNode,"zoom",0,false);board.zoomX=parseFloat(this.gEBTN(tmp,"x"));board.zoomY=parseFloat(this.gEBTN(tmp,"y"));tmp=this.gEBTN(xmlNode,"origin",0,false);board.origin={usrCoords:[1,0,0],scrCoords:[1,parseFloat(this.gEBTN(tmp,"x"))*board.zoomX,parseFloat(this.gEBTN(tmp,"y"))*board.zoomY]};tmp=this.gEBTN(xmlNode,"unit",0,false);board.unitX=parseFloat(this.gEBTN(tmp,"x"))*board.zoomX;board.unitY=parseFloat(this.gEBTN(tmp,"y"))*board.zoomY}if(board.attr.takeSizeFromFile){board.resizeContainer(this.gEBTN(boardData,"width"),this.gEBTN(boardData,"height"))}if(parseFloat(board.options.text.fontSize)<0){board.options.text.fontSize=12}board.geonextCompatibilityMode=true;delete JXG.boards[board.id];board.id=this.gEBTN(boardData,"id");JXG.boards[board.id]=board;board.initGeonextBoard();board.renderer.enhancedRendering=true;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;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=.5}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=1/parseFloat(tmp)}tmp=this.gEBTN(xmlNode,"y");if(tmp){board.options.grid.gridY=1/parseFloat(tmp);board.options.point.snapSizeY=1/parseFloat(tmp)}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;board.options.axis.ticks.minorHeight=4;board.create("axis",[[0,0],[1,0]]);board.create("axis",[[0,0],[0,1]])}tmp=this.gEBTN(this.gEBTN(boardData,"background",0,false),"color");if(tmp.length===8){tmp="#"+tmp}board.containerObj.style.backgroundColor=JXG.rgba2rgbo(tmp)[0];elChildNodes=tree.getElementsByTagName("elements")[0].childNodes;for(s=0;s<elChildNodes.length;s++){this.readNode(elChildNodes,s,board)}board.addConditions(conditions)},decodeString:function(str){var unz;if(str.indexOf("<GEONEXT>")<0){unz=new JXG.Util.Unzip(JXG.Util.Base64.decodeAsArray(str)).unzip();if(unz===""){return str}return unz}return str},prepareString:function(fileStr){try{if(fileStr.indexOf("GEONEXT")<0){fileStr=this.decodeString(fileStr)[0][0]}fileStr=this.fixXML(fileStr)}catch(exc2){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="&lt;(/?("+list+"))&gt;",expr=new RegExp(regex,"g");str=JXG.escapeHTML(str);str=str.replace(expr,"<$1>");str=str.replace(/(<content>.*)<arc>(.*<\/content>)/g,"$1&lt;arc&gt;$2");str=str.replace(/(<mp>.*)<arc>(.*<\/mpx>)/g,"$1&lt;arc&gt;$2");str=str.replace(/(<mpx>.*)<arc>(.*<\/mpx>)/g,"$1&lt;arc&gt;$2");return str}});JXG.registerReader(JXG.GeonextReader,["gxt","geonext"])})();
61