/* 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.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}};