Différences entre versions de « Référence:JavaScript »

De GeoGebra Manual
Aller à : navigation, rechercher
(Page créée avec « GeoGebra 3.2, May 2009 Markus Hohenwarter, Michael Borcherds This document describes public methods available in geogebra.GeoGebraApplet to be used from an HTML page via Ja... »)
 
 
(67 versions intermédiaires par 4 utilisateurs non affichées)
Ligne 1 : Ligne 1 :
GeoGebra 3.2, May 2009
+
Cette page vous explique comment vous pouvez interagir avec l'appliquette GeoGebra en utilisant JavaScript.  
  
Markus Hohenwarter, Michael Borcherds
+
L'appliquette GeoGebra est considérée comme un objet JavaScript, dans cette page, nous supposons que l'objet est enregistré dans la variable nommée ''ggbApplet''.
  
This document describes public methods available in geogebra.GeoGebraApplet to be used from an HTML page via JavaScript.
+
Ce qui est le cas si vous utilisez JavaScript depuis GeoGebra ou dans une page web  contenant une seule appliquette GeoGebra  exportée
 +
* soit directement depuis GeoGebra  ({{KeyCode|Ctrl + Maj+M}})
 +
* soit en utilisant le lien dans le dossier complet (hors ligne) fourni  par GeoGebra.
  
= Examples =
+
Les scripts '''ne sont pas'''  activables pour les appliquettes exportées depuis GeoGebra via la fonctionnalité ''Insérer''.
Example 1: the following HTML code fragment adds a "Reset" button to an HTML page that lets the user reset the construction shown in the GeoGebraApplet to its initial state:
 
  
  <form>
+
Dans le cas où sont intégrées plusieurs appliquettes, consultez la section [[#Obtenir_Objet_Appliquette|Obtenir Objet Appliquette]] .
    <input type="button" value="Reset" onclick="document.applets[0].reset();">
 
  </form>
 
  
Example 2: this adds two buttons "Hide A" and "Show A" change the visibility state of an object named "A" in the construction
+
__NOTOC__
  
  <form>
+
= Exemples =
    <input type="button" value="Hide A" onclick="document.applets[0].setVisible('A', false);">
 
    <input type="button" value="Show A" onclick="document.applets[0].setVisible('A', true);">
 
  </form>
 
  
Example 3: a JavaScript function "myLittleConstruction()" is used to call several methods of the GeoGebraApplet. Note: the language is set to German ("de") with the applet parameter "language" in the applet tag in order to make sure that the German command "Gerade" (line) will work.
+
{{Exemple| 1 =  le fragment de code HTML suivant ajoute un bouton "Réinitialiser" dans une page HTML, ce qui permet à l’utilisateur de ramener la  construction affichée par GeoGebra dans son état initial :<br/>
  
  <applet name="ggbApplet" code="geogebra.GeoGebraApplet"
+
<code> <form><br/><input type="button" value="Réinitialiser" onclick="ggbApplet.reset();"><br/></form></code>}}
    archive="geogebra.jar"
 
    width=200 height=40>
 
  <param name="filename" value="circle.ggb">
 
  <param name="framePossible" value="false">
 
  <param name="language" value="de">
 
  Please <a href="http://www.java.com">install Java 1.4.2</a> (or later) to use this page.
 
  </applet>
 
  <script type="text/javascript">
 
    function myLittelConstruction() {
 
      var applet = document.ggbApplet;
 
      applet.evalCommand("A = (1,1)");
 
      applet.evalCommand("B = (3,2)");  
 
      applet.evalCommand("s = Gerade[A, B]");
 
    }
 
  </script>
 
  <form>
 
    <input type="button" value="Do construction" onclick="myLittelConstruction();">
 
  </form>
 
  
Example 4: Have a look at the source code of the following example worksheet that uses JavaScript.
+
{{Exemple| 1 = celui-ci ajoute deux boutons "Cacher A" et " Afficher A" pour changer l’état d’affichage de l’objet nommé “A" dans la construction<br/>
  http://www.geogebra.org/source/program/applet/geogebra_applet_javascript_test.htm
+
<code> <form><br/><input type="button" value="Cacher A" onclick="ggbApplet.setVisible('A', false);"><br/><input type="button" value="Afficher A" onclick="ggbApplet.setVisible('A', true);"><br/></form></code>}}
  
Example 5: This is an example worksheet that uses an ''add listener'' to check when a particular construction has been completed (and then says "Well done").
+
{{Exemple| 1 =Une fonction JavaScript "maConstruction()" est utilisée pour appeler plusieurs méthodes de l’appliquette GeoGebra.
  http://www.geogebra.org/en/examples/javascriptAutomaticCheckingExercise.html
+
{{ Note| La langue est fixée à Français ("fr") avec le paramètre "language" dans la balise de l’appliquette afin de faire en sorte que la commande française "Droite" fonctionne.}}
 +
<code><nowiki> <script type="text/javascript" language="javascript" src="http://www.geogebra.org/web/4.4/web/web.nocache.js"></script><article class="geogebraweb" data-param-width="500" data-param-height="500" data-param-ggbbase64="UEsDBBQACAgIAM1CWUMAAAAAAAAAAAAAAAAWAAAAZ2VvZ2VicmFfamF2YXNjcmlwdC5qc0srzUsuyczPU0hPT/LP88zLLNHQVKiuBQBQSwcI1je9uRkAAAAXAAAAUEsDBBQACAgIAM1CWUMAAAAAAAAAAAAAAAAMAAAAZ2VvZ2VicmEueG1svVZtb9s2EP6c/oqDPicxSVGyHMgp1gIFCmTdgHTDsG+URMtcZFEQKb8M/fE7kpIjpy/o0GFB7CN5D++5O96Rzl8fdw3sZW+UbtcRvSURyLbUlWrrdTTYzU0Wvb5/lddS17LoBWx0vxN2HXGHVNU62iSblBPGbgou0hu+yuKbjONXucrKpCJVma14BHA06q7VH8ROmk6U8rHcyp140KWwnnhrbXe3WBwOh9uJ6lb39aKui9ujqSJAN1uzjsbBHZq72HSIPZwRQhd//PwQzN+o1ljRljICF8Kg7l9d5QfVVvoAB1XZ7TrKCIaxlareYkypmywcqMOEdLK0ai8Nbp1Nfcx210UeJlqnvwojaM7hRFCpvapkv47ILUsi0L2SrR21dGRZTPvzvZKHYMiNPAcmzWrdFMLZgE+fgBFG4NoJGgRDkaZBRcIaiYNgQfAgkoDhYTsPUB4wPGB4HMFeGVU0Eo9UNAZzptpNj+d1nht7aqT3Z1x4jpdeY0xG/Y3g2CUxJBnXCbl2H8zsNZ+yOwuSzlhtP/xL0olymbHvp2Q/FGg8cbIvhcmSr4SZfoM0xP09cdJkxolU/t9/PmOMvxXmS8Yw/zHClP8vIeaLqVXysTvAbB12rB4rd8b1S7yCZOXKnkKCvZEuscoToCsUSwbYDUAT4AlOaQapk0uIl6jgEEMGDkdj8M2RZPjFl95YCgkac6tL7EmgSMQhiYH6nuKAnQS+L7FHWYyIJIEENzl6ypyJOAWe4izOgKOPriWXFIExbsQ50jOIKcRuM10CSyF19ih3rZ5mznU0ySAlkFJnELsaOzp0M+IziF006Zgu1XaDvUhRuaumodXd+SwQjffR8z0X7qeLa/Aqb0QhG3wZHt1JAuxF4zrCE210a2E6RBbW6l50W1WaR2kt7jLwl9iLB2Hl8R2izcTtsaVuza+9tm91M+xaA1Dqhpx91g2djdnZa5zEMwWfK5KZIp2Nl1/k1aiBwUjk172Z4KKq3jvE89WAmfylbU5veimeOq0uw8gX/pHJ5VA2qlKi/R2L1bG4vMD05vjranpzOKOTI7qvHk8GKxiOf8pe4x1Dk1sy/8Pb5xRU8UsVHrgphWu+hFxqsLdOX1PxwC335yMSR3mOvu5VNR+/N290U51z4cN/Kzo79P7XAnrXu6B+autG+hLxjY1PcflU6ONjqI042Pp46nBGAn9R+7QDXg0swdeyHmURpMc4x84o4jHEI8hUbKo66+mKeYSXRZAehdUbXBsDpVOUlEw0yvgLjUQXbeNL3z3sQ6vswzSxqnx6jtThPwy7Qp4L6NIk/Y9M5osXBZY/yb6VzVjPeJCDHkxoz1mpV7JUO5wGxZgQ4Q7rN3QgrFay7uXkd+N/h4V0eS2Zl+pny97Uu17v3rf7j1gJLxzIF5OXuSl71bl6gwLfgCf5XFOVMgKfkGq+zzUghl66pwLTY11qsDUHu9W9/6mFNwpKxzCH+nYcf0ve/wNQSwcI2ajKq1gEAADoCgAAUEsBAhQAFAAICAgAzUJZQ9Y3vbkZAAAAFwAAABYAAAAAAAAAAAAAAAAAAAAAAGdlb2dlYnJhX2phdmFzY3JpcHQuanNQSwECFAAUAAgICADNQllD2ajKq1gEAADoCgAADAAAAAAAAAAAAAAAAABdAAAAZ2VvZ2VicmEueG1sUEsFBgAAAAACAAIAfgAAAO8EAAAAAA=="></article></nowiki><br/><script type="text/javascript"><br/>function maConstruction()<nowiki>{</nowiki> <br/>var applet = document.ggbApplet;<br/>applet.evalCommand("A = (1,1)");<br/>applet.evalCommand("B = (3,2)");<br/>applet.evalCommand("s = Droite[A, B]");<br/><nowiki>}</nowiki><br/></script><br/><form><br/><input type="button" value="Faire la construction" onclick="maConstruction();"><br/></form></code>}}
  
= Available Methods =
+
{{Exemple| 1 = Explorez le code source de l'exemple suivant qui utilise JavaScript.<br>
<table style="width: 100%;" class="pretty">
+
http://www.geogebra.org/source/program/applet/geogebra_applet_javascript_test.htm
    <tr>
+
}}
      <th>Method Signature</th>
+
 
      <th style="text-align: center;">Since</th>
+
{{Exemple | 1 = Ceci est un exemple de fichier qui utilise un  ''add listener'' pour savoir si une construction particulière a été complétée (et alors envoie le message  "Well done").<br>
      <th>Description</th>
+
http://www.geogebra.org/en/examples/javascriptAutomaticCheckingExercise.html
    </tr>
+
}}
    <tr>
+
 
      <td>boolean evalCommand(String cmdString)</td>
+
{{Exemple | 1 = Ceci est un exemple montrant comment coupler JavaScript avec GeoGebraWeb.<br/>
      <td style="text-align: center;">3.0</td>
+
http://www.geogebra.org/web/milestones/SlopeTestWeb.html
      <td> Evaluates the given string just like it would be evaluated when entered into GeoGebra's input bar. Returns whether command evaluation was successful. <br> From GeoGebra 3.2 you can pass multiple commands at once by separating them with \n. <br> Note: use the [[Reference:Applet_Parameters|language parameter]] to ensure your local command names will work.<br>
+
}}
      </td>
+
 
    </tr>
+
= Méthodes utilisables =
    <tr>
+
<table class="pretty" style="width: 100%;">
      <td>void setUndoPoint()</td>
+
<tr>
      <td style="text-align: center;">3.2</td>
+
<th>Méthode</th>
      <td> Sets an undo point. Useful if you want the user to be able to undo that action of evalCommand eg if you have made an HTML button to act as a custom tool<br>
+
<th>Description</th>
      </td>
+
</tr>
    </tr>
+
<tr>
 +
<td>evalCommand(commande)</td>
 +
<td>Évalue la chaîne comme si vous l’aviez entrée dans le champ de saisie  [ex : evalCommand('s = Droite[A, B]')]. <br> Vous pouvez utiliser plusieurs commandes en les séparant par "\n"{{Note | Utilisez le  [[Référence:Paramètres_Appliquette|paramètre “language” ]] pour vous assurer que la commande dans votre langue est reconnue.}}
 +
La valeur retournée indique si la commande est exécutée avec succès.
 +
{{Note | Mais vous devriez utiliser les noms anglais des commandes pour vous assurer que la commande fonctionne dans toutes les versions de GeoGebra.}}</td>
 +
</tr>
 +
<tr>
 +
<td>evalCommandGetLabels(commande)</td><td>Analogue à evalCommand(), mais la valeur retournée est une chaîne contenant l'étiquette de l'objet créé, ou une liste des étiquettes, séparées par une virgule, des objets créés par ex. : <code>"A,B,C"</code></td>
 +
</tr>
 +
<tr>
 +
<td>evalCommandCAS(commande)</td>
 +
<td>Passe la commande au CAS de GeoGebra</td>
 +
</tr>
 +
<tr>
 +
<td>setUndoPoint()</td>
 +
<td>Définit un point de restauration. Utile si vous désirez que l'utilisateur puisse annuler l'action d'un ''evalCommand'', par exemple si vous avez créé un bouton dans l'HTML pour agir comme un outil personnalisé.</td>
 +
</tr>
 
</table>
 
</table>
With these methods you can implement Applet to JavaScript communication. When you use any of the following methods, you should make sure to insert the MAYSCRIPT option add the end of the first line of your applet tag. For example:
 
  <applet name="ggbApplet" code="geogebra.GeoGebraApplet" codebase="." archive="geogebra.jar" width="500" height="250" MAYSCRIPT>
 
The MAYSCRIPT option is only needed for GeoGebraApplet to JavaScript communication; it is not needed for JavaScript to access the GeoGebraApplet methods.
 
  
For example, these methods can be used to
+
= Définir l’état d’un objet =
* monitor user actions (see [http://www.geogebra.org/source/program/applet/geogebra_applet_java2javascript.htm java2javascript example] ) or
 
* communicate between two GeoGebra applets (see [http://www.geogebra.org/source/program/applet/geogebra_applet_java2java.htm java2java example] ).
 
  
= Setting the state of objects =
 
  
==General methods==
+
<table class="pretty" style="width: 100%;">
<table style="width: 100%;" class="pretty">
+
<th>Méthode</th>
    <tr>
+
<th>Description</th>
      <th>Method Signature</th>
+
<tr>
      <th style="text-align: center;">Since</th>
+
<td> deleteObject(nom)</td>
      <th>Description</th>
+
<td>Efface l’objet cité.{{Exemple|1= deleteObject('A')}}</td>
    </tr>
+
</tr>
    <tr>
+
<tr>
      <td> void deleteObject(String objName)</td>
+
<td> setAuxiliary(geo, true/false)</td>
      <td style="text-align: center;">2.7</td>
+
<td>Affecte (ou non) le statut d'"Auxiliaire" à l'objet</td>
      <td>Deletes the object with the given name.</td>
+
</tr>
    </tr>
+
<tr>
    <tr>
+
<td>setValue(nom, valeur)</td>
      <td>void setValue(String objName, double value)</td>
+
<td>Affecte la valeur à l’objet cité {{Exemple|1=setValue('n',36)}}
      <td style="text-align: center;">3.2</td>
+
{{Note |Si cet objet n’est pas un nombre, rien ne se passe. <br/>Si l’objet est un booléen, utiliser la valeur 1 pour le mettre à ‘Vrai’, n’importe quelle valeur pour le mettre à ‘Faux’.}}</td>
      <td>Sets the double value of the object with the given name. Note: if the specified object is boolean, use a value of 1 to set it to true and any other value to set it to false. For any other object type, nothing is done.</td>
+
</tr>
    </tr>
+
<tr>  
    <tr>
+
<td>setTextValue(nom, texte)</td>
      <td>void setCoords(String objName, double x, double y)</td>
+
<td>Affecte le texte à l'objet texte cité. Rien ne se passe pour tout autre type d'objet.</td>
      <td style="text-align: center;">3.0</td>
+
</tr>
      <td>Sets the coordinates of the object with the given name.
+
<tr>
Note: if the specified object is not a point or a vector, nothing is done.</td>
+
<td>setListValue(nom, position, valeur)</td>
    </tr>
+
<td>Affecte la valeur à l'élément à la position donnée dans la liste</td>
    <tr>
+
</tr>
      <td>void setColor(String objName, int red, int green, int
+
<tr>
blue)</td>
+
<td>setCoords(nom, x, y)<br/>setCoords(nom, x, y,z)</td>
      <td style="text-align: center;">2.7</td>
+
<td>Affecte les coordonnées à l’objet{{Exemple|1= setCoords('A',-1,3)}}
      <td>Sets the color of the object with the given name.</td>
+
{{Note| Si cet objet n’est ni point ni vecteur, rien ne se passe.}}</td>
    </tr>
+
</tr>
    <tr>
+
<tr>
      <td>void setVisible(String objName, boolean visible) </td>
+
<td>setColor(nom, rouge, vert, bleu)</td>
      <td style="text-align: center;">2.7</td>
+
<td>Affecte la couleur RVB à l’objet  {{Exemple|1=setColor('A',200,100,100)}}</td>
      <td>Shows or hides the object with the given name in the graphics window.</td>
+
</tr>
    </tr>
+
<tr>
    <tr>
+
<td>setDisplayStyle(objet, style)</td>
      <td>void setLabelVisible(String objName, boolean visible) </td>
+
<td>Affecte le style d'affichage à l'objet. Style doit être parmi "parametric", "explicit", "implicit", "specific"</td>
      <td style="text-align: center;">3.0</td>
+
</tr>
      <td>Shows or hides the label of the object with the given name in the graphics window.</td>
+
<tr>
    </tr>
+
<td>setVisible(nom, booléen) </td>
    <tr>
+
<td>Affiche (true) ou Cache (false) l’objet cité dans la vue Graphique {{Exemple|1=setVisible('A',true)}}</td>
      <td>void setLabelStyle(String objName, boolean visible)</td>
+
</tr>
       <td style="text-align: center;">3.0</td>
+
<tr>
      <td>Sets the label style of the object with the given name in the graphics window. Possible label styles are NAME = 0, NAME_VALUE = 1, VALUE = 2 and (from GeoGebra 3.2) CAPTION = 3</td>
+
<td>setLabelVisible(nom, booléen) </td>
    </tr>
+
<td>Affiche (true) ou Cache (false) l’étiquette de l’objet cité dans la vue Graphique {{Exemple|1=setLabelVisible('A',false)}}</td>
    <tr>
+
</tr>
       <td>void setFixed(String objName, boolean flag)</td>
+
<tr>
       <td style="text-align: center;">3.0</td>
+
<td>setLabelStyle(nom, entier)</td>
       <td>Sets the fixed state of the object with the given name. Note: fixed objects cannot be changed.</td>
+
       <td>Définit le style de l’étiquette de l’objet cité dans  Graphique. <br/>Nom = 0, Nom & Valeur = 1, Valeur = 2,  Légende=3 et Légende  & Valeur =9. {{Exemple|1=setLabelStyle('A',1)}}
    </tr>
+
</td>
    <tr>
+
</tr>
       <td>void setTrace(String objName, boolean flag)</td>
+
<tr>
       <td style="text-align: center;">3.0</td>
+
       <td>setCaption(nom, texte)</td>
       <td>Turns the trace of the object with the given name on or off.</td>
+
       <td>Définit la Légende de l'objet</td>
    </tr>
+
</tr>
    <tr>
+
<tr>
       <td>boolean renameObject(String oldObjName, String newObjName)</td>
+
      <td>setFixed(nom, booléen Fixé, booléen Sélectionnable) </td>
       <td style="text-align: center;">3.2</td>
+
       <td>Définit la liberté de l’objet cité {{Exemple|1=setFixed('A',true)}}
       <td>Renames oldObjName to newObjName. Returns whether the rename was successful</td>
+
{{Note | Les objets fixes ne peuvent être modifiés.}}</td>
    </tr>
+
</tr>
    <tr>
+
<tr>
       <td>void setLayer(String objName)</td>
+
       <td>setTrace(nom, booléen)</td>
       <td style="text-align: center;">3.2</td>
+
       <td>Active ou non la trace de l’objet cité {{Exemple|1=setTrace('A',false)}}</td>
       <td>Sets the layer of the object</td>
+
</tr>
    </tr>
+
<tr>
    <tr>
+
      <td>renameObject(ancien nom, nouveau nom)</td>
       <td>void setLayerVisible(int layer, boolean visible)</td>
+
       <td>Renomme l’objet ancien nom en l’objet nouveau nom</td>
       <td style="text-align: center;">3.2</td>
+
</tr>
       <td>Shows or hides the all objects in the given layer</td>
+
<tr>
    </tr>
+
       <td>setLayer(nom,entier)</td>
    <tr>
+
       <td>Définit le calque de l’objet cité.</td>
       <td>void setLineStyle(String objName, int style)</td>
+
</tr>
       <td style="text-align: center;">3.2</td>
+
<tr>
       <td>Sets the line style for the object (0 to 4)</td>
+
      <td>setLayerVisible(n°, booléen)</td>
    </tr>
+
       <td>Affiche ou cache tous les objets du calque n°</td>
    <tr>
+
</tr>
       <td>void setLineThickness(String objName, int thickness)</td>
+
<tr>
       <td style="text-align: center;">3.2</td>
+
       <td>setLineStyle(nom,entier)</td>
       <td>sets the thickness of the object (1 to 13, -1 for default)</td>
+
       <td>Définit le style du trait (de 0 à 4)</td>
    </tr>
+
</tr>
    <tr>
+
<tr>
       <td>void setPointStyle(String objName, int style)</td>
+
      <td>setLineThickness(nom,entier)</td>
       <td style="text-align: center;">3.2</td>
+
       <td>Définit l’épaisseur de l’objet (de 1 à 13) (1 par défaut)</td>
       <td>Sets the style of points (-1 default, 0 filled circle, 1 circle, 2 cross, 3 plus, 4 filled diamond, 5 unfilled diamond, 6 triangle (north), 7 triangle (south), 8 triangle (east), 9 triangle (west))</td>
+
</tr>
    </tr>
+
<tr>
    <tr>
+
       <td>setPointStyle(nom,entier)</td>
       <td>void setPointSize(String objName, int size)</td>
+
       <td>Définit le style du point (-1 par défaut, 0 disque, 1 cercle, 2 croix,3 plus, 4 diamant plein, 5 diamant vide, 6 triangle (nord), 7 triangle (sud), 8 triangle (est), 9 triangle (ouest))<br/> Voir [[Commande_SoitStylePoint]]</td>
       <td style="text-align: center;">3.2</td>
+
</tr>
       <td>Sets the size of a point (from 1 to 9)</td>
+
<tr>
    </tr>
+
      <td>setPointSize(nom,entier)</td>
    <tr>
+
       <td>Définit la taille du point (de 1 à 9)</td>
       <td>void setFilling(String objName, double filling)</td>
+
</tr>
       <td style="text-align: center;">3.2</td>
+
<tr>
       <td>Sets the filling of an object (from 0 to 1)</td>
+
       <td>setFilling(nom,nombre)</td>
    </tr>
+
       <td>Définit le remplissage de l’objet (de 0 à 1)</td>
 +
</tr>
 +
<td>setRounding(chaine)</td>
 +
       <td>La chaîne est constituée d'un nombre et d'un drapeau :  "s" pour chiffres significatifs, "d" pour décimales  (par défaut). <br/>Les entiers JavaScript sont automatiquement gérés comme chaînes. Exemple: "10s", "5", 3<br/>Définit l'option d'arrondi, {{Exemple|1=ggbApplet.setRounding("4") règle l'arrondi à 4 décimales, </br> ggbApplet.setRounding("5r") à 5 chiffres significatifs}} </td>
 +
</tr>
 +
<tr>
 +
       <td>getPNGBase64(échelle, booléen transparent, DPI)</td>
 +
       <td>Retourne Graphique1 sous forme d'une chaîne encodée en base64.{{Exemple|1= var str = ggbApplet.getPNGBase64(1, true, 72);}} <br> Le paramètre DPI n'est actuellement pas pris en compte en version HTML5    </td>
 +
</tr>
 +
<tr>
 +
      <td>getPNGBase64(échelle, booléen transparent,  DPI,copyToClipboard)</td>
 +
       <td>Retourne Graphique1 sous forme d'une chaîne encodée en base64.{{Exemple|1= var str = ggbApplet.getPNGBase64(1, true, 72);}}      </td>
 +
</tr>
 +
<tr>
 +
       <td>getScreenshotBase64(fonction) HTML5 slt</td>
 +
       <td>Récupère une copie d'écran de l'appliquette entière en PNG et la renvoit à la fonction d'appel en chaîne encodée en base64.
 +
{{Exemple: <code>ggbApplet.getScreenshotBase64(function(url){window.open("data:image/png;base64,"+url);});</code>}}<br><b>Pour utilisation dans GeoGebra ! Il est possible que cela ne fonctionne pas dans tous les navigateurs </b></td>
 +
</tr>
 +
<tr>
 +
       <td>writePNGtoFile(Nomfichier, échelle, booléen transparent, DPI)</td>
 +
      <td>Exporte Graphique1 dans un fichier PNG. '''(ne fonctionne que pour les appliquettes signées)''' <br/>
 +
{{Exemple|1= var success = ggbApplet.writePNGtoFile("c:\\test.png", 1, false, 300);  }}    </td>
 +
</tr>
 +
<tr>
 +
      <td>isIndependent(nom)</td>
 +
      <td> teste si ''nom'' est indépendant      </td>
 +
</tr>
 +
<tr>
 +
       <td>isMoveable(nom)</td>
 +
       <td> teste si ''nom'' est déplaçable</td>
 +
</tr>
 +
<tr>
 +
       <td>getBase64()</td>
 +
      <td> Récupère la construction courante dans un fichier .ggb encodée en  base64</td>
 +
</tr>
 +
<tr>
 +
       <td>String getBase64(callback function)<br/>4.4(HTML5 only)</td>
 +
       <td> Gets the current construction as a base64-encoded .ggb file asynchronously, passes as parameter to the callback function when ready. The callback function should take one parameter (the base64 string).</td>
 +
</tr>
 +
<tr>
 +
       <td>setBase64(chaîne)</td>
 +
      <td> Définit la construction courante à partir d'un fichier .ggb encodé en  base64</td>
 +
</tr>
 
</table>
 
</table>
  
==Automatic Animation==
+
==Animation automatique==
<table style="width: 100%;" class="pretty">
+
<table class="pretty" style="width: 100%;">
 
     <tr>
 
     <tr>
       <th>Method Signature</th>
+
       <th>Méthode </th>
      <th style="text-align: center;">Since</th>
 
 
       <th>Description</th>
 
       <th>Description</th>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
       <td>void setAnimating(String objName, boolean animate)</td>
+
       <td>setAnimating(nom, booléen)</td>
       <td style="text-align: center;">3.2</td>
+
       <td>Définit si l’objet cité peut être animé. Cela ne lance pas l'animation, utilisez startAnimation() pour le faire.</td>
      <td>Sets whether an object should be animated. This does not start the animation yet, use startAnimation() to do so.</td>
 
 
     </tr>
 
     </tr>
 
       <tr>
 
       <tr>
       <td>void setAnimationSpeed(String objName, double speed)</td>
+
       <td>setAnimationSpeed(nom, nombre)</td>
       <td style="text-align: center;">3.2</td>
+
       <td>Définit la vitesse d’animation de l’objet cité.</td>
      <td>Sets the animation speed of an object.</td>
 
 
     </tr>
 
     </tr>
 
   <tr>
 
   <tr>
       <td>void startAnimation()</td>
+
       <td>startAnimation()</td>
       <td style="text-align: center;">3.2</td>
+
       <td>Lance l’animation pour les objets pouvant être animés.</td>
      <td>Starts automatic animation for all objects with the animating flag set, see setAnimating()</td>
 
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
       <td>void stopAnimation()</td>
+
       <td>stopAnimation()</td>
       <td style="text-align: center;">3.2</td>
+
       <td>Arrête l’animation en cours.</td>
      <td>Stops animation for all objects with the animating flag set, see setAnimating()</td>
 
 
     </tr>
 
     </tr>
 
   <tr>
 
   <tr>
       <td>boolean isAnimationRunning()</td>
+
       <td>isAnimationRunning()</td>
       <td style="text-align: center;">3.2</td>
+
       <td>Retourne un booléen précisant si une animation est en cours ou non.</td>
      <td>Returns whether automatic animation is currently running.</td>
 
 
     </tr>
 
     </tr>
 
</table>
 
</table>
  
= Getting the state of objects =
+
= Connaître l’état d’un objet =
  
<table style="width: 100%;" class="pretty">
+
<table class="pretty" style="width: 100%;">
    <tr>
+
<tr>
       <th>Method Signature</th>
+
       <th>Méthode</th>
      <th style="text-align: center;">Since</th>
 
 
       <th>Description</th>
 
       <th>Description</th>
 +
</tr>
 +
<tr>
 +
      <td>getXcoord(nom)</td>
 +
      <td>Retourne l’abscisse de l’objet cité.{{Exemple|1= getXcoord('A')}}
 +
{{Note | Retourne 0 si l’objet n’est ni un point ni un vecteur.}}</td>
 +
</tr>
 +
<tr>
 +
      <td>getYcoord(nom)</td>
 +
      <td>Retourne l’ordonnée de l’objet cité. {{Exemple|1= getYcoord('u')]}}
 +
{{Note | Retourne 0 si l’objet n’est ni un point ni un vecteur.}}</td>
 +
</tr>
 +
<tr>
 +
      <td>getZcoord(nom)</td>
 +
      <td>Retourne la cote de l’objet cité. {{Exemple|1= getYcoord('u')]}}
 +
{{Note | Retourne 0 si l’objet n’est ni un point ni un vecteur.}}</td>
 +
</tr>
 +
<tr>
 +
      <td>getValue(nom)</td>
 +
      <td>Retourne la valeur de l’objet cité ( longueur pour un segment, aire pour un polygone, etc.). {{Exemple|1=  getValue('poly1')]}}
 +
{{Note |Retourne 0 s’il l’objet n’a pas de valeur associée.<br/> Si l’objet est un booléen, retourne 1 pour ‘Vrai’, 0 pour ‘Faux’. }}    </td>
 +
</tr>
 +
<tr>
 +
      <td>getListValue(nom, indice)</td>
 +
      <td>Retourne la valeur de l’objet de la liste dans la position précisée. {{Note | Si l’objet est un booléen, retourne 1 pour ‘Vrai’, 0 pour ‘Faux’. }} </td>
 +
</tr>
 +
<tr>
 +
      <td>getColor(nom)</td>
 +
      <td>Retourne la couleur de l’objet cité sous forme d’une chaîne hexadécimale.{{Exemple|1= getColor('A') retourne "#FF0000" si A est rouge.}} {{Note | la chaîne hexadécimale commence toujours par # et ne contient pas de lettres minuscules.}}</td>
 +
</tr>
 +
  <tr>
 +
      <td>getVisible(nom)</td>
 +
      <td>Retourne ‘'true'’ ou '‘false’' suivant que l’objet cité est affiché ou non dans la vue Graphique. Retourne  ‘'false'’  si l'objet n'existe pas.</td>
 +
</tr>
 +
<tr>
 +
      <td>getVisible(nom,1|2)</td>
 +
      <td>Retourne ‘'true'’ ou '‘false’' suivant que l’objet cité est affiché ou non dans la vue Graphique 1 ou 2. Retourne  ‘'false'’  si l'objet n'existe pas.</td>
 +
</tr>
 +
  <tr>
 +
      <td> getValueString(nom)</td>
 +
      <td>Retourne la valeur de l’objet cité sous forme de chaîne.</td>
 +
</tr>
 +
  <tr>
 +
      <td>getDefinitionString(nom) </td>
 +
      <td>Retourne la définition (l’info bulle) de l’objet cité.</td>
 +
  </tr>
 +
  <tr>
 +
      <td>getCommandString(nom)</td>
 +
      <td>Retourne la commande à saisir pour créer l’objet cité.</td>
 +
</tr>
 +
<tr>
 +
      <td>getCommandString(nom, booléen)</td>
 +
      <td>Retourne la commande à saisir pour créer l’objet cité en anglais si false, dans la langue actuelle de l'interface sinon.</td>
 +
</tr>
 +
<tr>
 +
<td>getLaTeXString(nom)</td>
 +
<td>Retourne la valeur de l'objet cité n syntaxe LaTeX </td>
 +
</tr>
 +
<tr>
 +
<td>getLaTeXBase64(nom, booléen)</td>
 +
<td>Retourne une image PNG en base64 de l'objet en LaTeX. Pour le booléen = false l'objet est représenté selon sa définition, pour le booléen=true c'est la valeur de l'objet qui est représentée.</td>
 +
</tr>
 +
<tr>
 +
      <td>getObjectType(nom)</td>
 +
      <td>Retourne le type de l’objet cité sous forme de chaîne (comme "point", "line", "circle", etc. en Anglais !).</td>
 +
</tr>
 +
<tr>
 +
      <td>exists(nom)</td>
 +
      <td>Retourne un booléen attestant l’existence ou non de l’objet cité dans la construction.</td>
 +
  </tr>
 +
  <tr>
 +
      <td>isDefined(nom)</td>
 +
      <td>Retourne un booléen attestant la validité actuelle ou non de l’objet .</td>
 +
  </tr>
 +
  <tr>
 +
      <td>getObjectNumber()</td>
 +
      <td>Retourne le nombre d’objets dans la construction.</td>
 +
  </tr>
 +
<tr>
 +
      <td>getCASObjectNumber()</td>
 +
      <td>Retourne le nombre d’objets (lignes non vides) du CAS.</td>
 +
</tr>
 +
<tr>
 +
      <td>getObjectName(n)</td>
 +
      <td>Retourne le nom du n-ème objet de la construction (attention,  le compteur commence à 0).</td>
 +
</tr>
 +
<tr>
 +
      <td>getLayer(nom)</td>
 +
      <td>Retourne le numéro du calque de l’objet cité.</td>
 +
  </tr>
 +
  <tr>
 +
      <td>getLineStyle(nom)</td>
 +
      <td>Retourne le style du trait (de 0 à 4)</td>
 +
  </tr>
 +
  <tr>
 +
      <td>getLineThickness(nom)</td>
 +
      <td>Retourne l’épaisseur de l’objet (de 1 à 13) (1 par défaut)</td>
 +
  </tr>
 +
  <tr>
 +
      <td>getPointStyle(nom)</td>
 +
      <td>Retourne le style du point (-1 par défaut, 0 disque, 1 cercle, 2 croix,3 plus, 4 diamant plein, 5 diamant vide, 6 triangle (nord), 7 triangle (sud), 8 triangle (est), 9 triangle (ouest))</td>
 +
  </tr>
 +
  <tr>
 +
      <td>getPointSize(nom)</td>
 +
      <td>Retourne la taille du point (de 1 à 9)</td>
 +
  </tr>
 +
  <tr>
 +
      <td>getFilling(nom)</td>
 +
      <td>Retourne le remplissage de l’objet (de 0 à 1)</td>
 +
  </tr>
 +
<tr>
 +
      <td>getCaption(nom, booléen)</td>
 +
      <td>Retourne la légende de l'objet. Si elle contient des substituts (%n, %v,...), vous pouvez utiliser le booléen pour préciser si vous voulez qu'ils soient remplacés ou non.</td>
 +
  </tr>
 +
<tr>
 +
      <td>getLabelStyle(nom)</td>
 +
      <td>Retourne le type d'étiquette de l'objet, Voir setLabelStyle pour les valeurs possibles</td>
 +
    </tr>
 +
<tr>
 +
      <td>getLabelVisible()</td>
 +
      <td></td>
 +
  </tr>
 +
</table>
 +
 +
= Construction / Interface Utilisateur  =
 +
 +
<table class="pretty" style="width: 100%;">
 +
  <tr>
 +
      <th>Méthode</th>
 +
      <th style="font-weight: bold;">Description</th>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
       <td>double getXcoord(String objName)</td>
+
       <td>setMode(code du mode)</td>
       <td style="text-align: center;">2.7</td>
+
       <td>Définit le mode au code fourni
      <td>Returns the cartesian x-coord of the object with the given name.
+
{{Exemple|1=setMode(0)  pour mode Déplacer.}}
Note: returns 0 if the object is not a point or a vector.</td>
+
 
 +
(voir [[Référence:BarreOutils|Codes]] et [[Référence:Paramètres_Appliquette|paramètre “showToolBar”]]  et &nbsp;[[Référence:Paramètres_Appliquette|paramètre "customToolBar"]]  )</td>
 
     </tr>
 
     </tr>
 +
<tr>
 +
      <td>getMode()</td>
 +
      <td>Retourne le code du mode actuel
 +
</tr>
 
     <tr>
 
     <tr>
       <td>double getYcoord(String objName)</td>
+
       <td>openFile(URL)</td>
       <td style="text-align: center;">2.7</td>
+
       <td>Ouvre le  fichier dont l’URL est donnée sous forme absolue ou relative)[ex : openFile('fichier.ggb')].</td>
      <td>Returns the cartesian y-coord of the object with the given name.
 
Note: returns 0 if the object is not a point or a vector.</td>
 
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
       <td>double getValue(String objName)</td>
+
       <td>reset()</td>
       <td style="text-align: center;">3.2</td>
+
       <td>Réinitialise la construction.<br>
      <td>Returns the double value of the object with the given name (e.g. length of segment, area of polygon). Note: returns 1 for a boolean object with value true. Otherwise 0 is returned.<br>
 
 
       </td>
 
       </td>
    </tr>
+
  </tr>
 
     <tr>
 
     <tr>
      <td>String getColor(String objName)</td>
+
      <td>void newConstruction()</td>
       <td style="text-align: center;">2.7</td>
+
       <td>Efface tous les objets de la construction<br>
       <td>Returns the color of the object with the given name as a hex string, e.g. "#FF0000" for red. Note that the hex string always starts with # and contains no lower case letters.</td>
+
  <tr>
 +
      <td>refreshViews()</td>
 +
       <td>Rafraîchit l’affichage. {{Note| Cela efface toutes les traces dans la vue Graphique.}}</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
       <td> boolean getVisible(String objName)</td>
+
       <td>setOnTheFlyPointCreationActive(booléen)<br>
       <td style="text-align: center;">3.2</td>
+
       </td>
       <td>Returns true or false depending on whether the object is visible in the Graphics View. Returns false if the object does not exist.</td>
+
       <td>Autorise (true)  ou non (false) la création de points "à la volée". {{Note | À utiliser si vous ne désirez pas que les outils créent des points.}}</td>
 
     </tr>
 
     </tr>
    <tr>
+
  <tr>
       <td> String getValueString(String objName)</td>
+
       <td>setPointCapture(view, mode)</td>
       <td style="text-align: center;">2.7</td>
+
       <td>Définit l'option de Capture des points dans la vue citée<br/> 0 - Désactivée, 1 - Approché de la Grille, 2 - Attaché à la Grille, 3 - Automatique</td>
      <td>Returns the value of the object with the given name as a string.</td>
 
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
       <td>String getDefinitionString(String objName) </td>
+
       <td>hideCursorWhenDragging(booléen)<br></td>
      <td style="text-align: center;">2.7</td>
+
       <td>Affiche(true) ou non (false) le curseur de la souris quand on déplace un object. </td>
       <td>Returns the definition of the object with the given name as a string.</td>
 
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
       <td>String getCommandString(String objName)</td>
+
       <td>setRepaintingActive(booléen)<br>
       <td style="text-align: center;">2.7</td>
+
       </td>
       <td>Returns the command of the object with the given name as a string.</td>
+
       <td>Active (true) ou non (false) le recalcul de la figure.
 +
{{Note | Cette méthode est surtout à utiliser quand vous utilisez plusieurs méthodes.}}</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
       <td>String getObjectType(String objName)</td>
+
       <td>setErrorDialogsActive(booléen)</td>
       <td style="text-align: center;">2.7</td>
+
       <td>Bascule pour l’affichage ou non du dialogue d’erreur. {{Note | C'est très utile avec l'utilisation de evalCommand().}}</td>
      <td>Returns the type of the given object as a string (like "point", "line", "circle", etc.).</td>
 
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
       <td>boolean exists(String objName)</td>
+
       <td>setCoordSystem(xmin, xmax,ymin,ymax)</td>
       <td style="text-align: center;">2.7</td>
+
       <td>Définit la fenêtre '''Graphique'''.
      <td>Returns whether an object with the given name exists in the construction.</td>
+
{{Exemple|1=setCoordSystem(-5,10,-1,20)}}
 +
</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
       <td>boolean isDefined(String objName)</td>
+
       <td>setCoordSystem(xmin, xmax, ymin, ymax, zmin, zmax, booléen yVertical)</td>
       <td style="text-align: center;">2.7</td>
+
       <td>Définit la fenêtre '''Graphique 3D'''. Le booléen yVertical précisant si axeY est "vertical" ou non.
      <td>Returns whether the given object's value is valid at the moment.</td>
+
</td>
    </tr>
+
</tr>
 +
 
 
     <tr>
 
     <tr>
       <td>String [] getAllObjectNames()<br>
+
       <td>setAxesVisible(booléen, booléen)</td>
      <small style="font-style: italic; font-weight: bold;">Deprecated since 3.0</small> </td>
+
       <td>Affiche (true) ou Cache (false) indépendamment chacun des axes. {{Exemple|1=setAxesVisible(true, false)}}</td>
      <td style="text-align: center;">2.7</td>
 
       <td>Returns an array with all object names in the construction.
 
Note: using arrays in JavaScript causes problems with some browsers. Use getObjectNumber() and getObjectName() instead.</td>
 
 
     </tr>
 
     </tr>
    <tr>
+
<tr>
       <td>int getObjectNumber()</td>
+
       <td>setAxesVisible(vue,booléen, booléen,booléen)</td>
       <td style="text-align: center;">3.0</td>
+
       <td>Affiche (true) ou Cache (false) indépendamment chacun des axes dans la vue nommée. {{Exemple|<code>ggbApplet.setAxesVisible(3, false, true, true)</code>}}</td>
      <td>Returns the number of objects in the construction.</td>
 
 
     </tr>
 
     </tr>
  <tr>
+
<tr>
       <td>String getObjectName(int i)</td>
+
       <td>setAxisLabels(vue,x, y, z)</td>
       <td style="text-align: center;">3.0</td>
+
       <td>Définit les étiquettes des axes de la ''vue'' nommée. {{Exemple| <code>ggbApplet.setAxisLabels(3,"larg","long","haut")</code>}}</td>
      <td>Returns the name of the n-th object of the construction.</td>
 
 
     </tr>
 
     </tr>
 
   <tr>
 
   <tr>
       <td>String getLayer(String objName)</td>
+
       <td>setAxisSteps(vue, x, y, z) </td>
       <td style="text-align: center;">3.2</td>
+
       <td>Définit les pas de graduations sur les axes de la ''vue'' nommée. {{Exemple| <code>ggbApplet.setAxisSteps(1,"pi/4",1,1);</code>}}</td>
      <td>Returns the layer of the object.</td>
 
 
     </tr>
 
     </tr>
    <tr>
+
<tr>
       <td>int getLineStyle(String objName)</td>
+
       <td>setAxisUnits(vue, x, y, z) </td>
       <td style="text-align: center;">3.2</td>
+
       <td>Définit les unités sur les axes de la ''vue'' nommée. {{Exemple| <code>ggbApplet.setAxisUnits(3, "cm","cm","cm²")</code>}}</td>
      <td>Gets the line style for the object (0 to 4)</td>
 
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
       <td>int getLineThickness(String objName)</td>
+
       <td>setGridVisible(booléen) </td>
       <td style="text-align: center;">3.2</td>
+
       <td>Affiche (true) ou Cache (false) la grille dans Graphique et Graphique2.</td>
      <td>Gets the thickness of the line (1 to 13)</td>
 
 
     </tr>
 
     </tr>
    <tr>
+
  <tr>
       <td>int getPointStyle(String objName)</td>
+
       <td>setGridVisible(vue, booléen) </td>
      <td style="text-align: center;">3.2</td>
+
       <td>Affiche (true) ou Cache (false) la grille dans la ''vue'' nommée .</td>
       <td>Gets the style of points (-1 default, 0 filled circle, 1 circle, 2 cross, 3 plus, 4 filled diamond, 5 unfilled diamond, 6 triangle (north), 7 triangle (south), 8 triangle (east), 9 triangle (west))</td>
 
 
     </tr>
 
     </tr>
    <tr>
+
<tr>
       <td>int getPointSize(String objName)</td>
+
       <td>getGridVisible(vue) </td>
       <td style="text-align: center;">3.2</td>
+
       <td>Retourne ''true'' si la grille est affichée dans la ''vue'' nommée . Si le numéro de la vue est omis, retourne ''true'' si la grille est affichée dans</td>
      <td>Gets the size of a point (from 1 to 9)</td>
 
 
     </tr>
 
     </tr>
    <tr>
+
<tr>
       <td>double getFilling(String objName)</td>
+
       <td>getPerspectiveXML()</td>
       <td style="text-align: center;">3.2</td>
+
       <td>Retourne une définition XML de la disposition actuelle.  <br/>  chaine=ggbApplet.getPerspectiveXML();<br/>
       <td>Gets the filling of an object (from 0 to 1)</td>
+
alert(""+chaine); </td>
 +
  </tr>
 +
<tr>
 +
      <td>undo()</td>
 +
      <td>Annule une action de l'utilisateur</td>
 +
</tr>
 +
<tr>
 +
      <td>redo()</td>
 +
      <td>Refait une action annulée de l'utilisateur</td>
 +
</tr>
 +
<tr>
 +
      <td>showToolBar(booléen)</td>
 +
      <td>Affichage ou non de la barre d 'outils</td>
 +
</tr>
 +
<tr>
 +
      <td>setCustomToolBar(chaîne)</td>
 +
      <td>Vous permet de personnaliser la barre d’outils à l'aide d'une chaîne composée des [[Référence:BarreOutils|numéros]] des outils<br/>
 +
{{KeyCode| ,}} ajoute un séparateur dans un menu, {{KeyCode| &#124; }} démarre un nouveau menu et {{KeyCode| &#124;  &#124; }} ajoute un séparateur dans la barre d’outils avant de créer un nouveau menu.</td>
 +
</tr>
 +
<tr>
 +
      <td>showMenuBar(booléen)</td>
 +
      <td>Affichage ou non de la barre des menus</td>
 +
</tr>
 +
<tr>
 +
      <td>showAlgebraInput(booléen)</td>
 +
      <td>Affichage ou non du champ de saisie</td>
 +
</tr>
 +
<tr>
 +
       <td>showResetIcon(booléen)</td>
 +
      <td>Affichage ou non de l'icône de réinitialisation</td>
 
     </tr>
 
     </tr>
</table>
+
<tr>
 
+
      <td>enableRightClick(booléen)</td>
= Construction / User Interface =
+
    <td>Autoriser ou non le clic droit</td>
 
+
</tr>
<table style="width: 100%;" class="pretty">
+
<tr>
  <tr>
+
      <td>enableLabelDrags(booléen)</td>
       <th>Method Signature</th>
+
      <td>Autoriser ou non le déplacement des étiquettes</td>
       <th style="text-align: center;">Since</th>
+
</tr>
       <th style="font-weight: bold;">Description</th>
+
<tr>
 +
       <td>enableShiftDragZoom(booléen)</td>
 +
      <td>Autoriser ou non le déplacement et le zoom de la vue, à la souris ou au clavier</td>
 +
</tr>
 +
<tr>
 +
       <td>enableCAS(booléen)</td>
 +
       <td>Autorise ou non les fonctionnalités CAS  (fenêtre et commandes)</td>
 
     </tr>
 
     </tr>
    <tr>
+
<tr>
       <td>void setMode(int mode)</td>
+
       <td>enable3D(booléen)</td>
       <td style="text-align: center;">2.7</td>
+
       <td>Autorise ou non la fenêtre 3D</td>
      <td>Sets the mouse mode (i.e. tool) for the graphics window
 
(see [[Reference:Toolbar|toolbar reference]] and the [[Reference:Applet_Parameters|applet parameters]] "showToolBar" and &nbsp;"customToolBar"  )</td>
 
 
     </tr>
 
     </tr>
    <tr>
+
<tr>
       <td>void openFile(String strURL)</td>
+
       <td>setPerspective(chaîne)</td>
       <td style="text-align: center;">2.7</td>
+
       <td>Modifie la dispositions des vues ouvertes, voir [[Commande_SoitDispositions]] pour la définition de la chaîne.<br>     </td>
      <td>Opens a construction from a&nbsp; file (given as absolute or relative URL string)</td>
 
    </tr>
 
    <tr>
 
      <td>void reset()</td>
 
      <td style="text-align: center;">2.7</td>
 
      <td>Reloads the initial construction (given in filename parameter) of this applet.<br>
 
      </td>
 
 
   </tr>
 
   </tr>
  <tr>
+
<tr>
       <td>void refreshViews()</td>
+
       <td>setWidth(entier)<br/>(HTML5)</td>
      <td style="text-align: center;">2.7</td>
+
       <td>Définit la largeur de l'appliquette (en pixels)</td>
       <td>Refreshs all views. Note: this clears all traces in the graphics window.</td>
 
 
     </tr>
 
     </tr>
    <tr>
+
<tr>
       <td>void setOnTheFlyPointCreationActive(boolean flag)<br>
+
       <td>setHeight(entier)<br/>(HTML5)</td>
      </td>
+
       <td>Définit la hauteur de l'appliquette (en pixels)</td>
      <td style="text-align: center;">3.2</td>
 
      <td>Turns on the fly creation of points in graphics view on (true) or off (false). Note: this is useful if you don't want tools to have the side effect of creating points. For example, when this flag is set to false, the tool "line through two points" will not create points on the fly when you click on the background of the graphics view.</td>
 
    </tr>
 
    <tr>
 
       <td>void hideCursorWhenDragging(boolean flag)<br>
 
      </td>
 
      <td style="text-align: center;">3.2</td>
 
      <td>Hides (true) or shows (false) the mouse cursor (pointer) when dragging an object to change the construction. </td>
 
    </tr>
 
    <tr>
 
      <td>void setRepaintingActive(boolean flag)<br>
 
      </td>
 
      <td style="text-align: center;">2.7</td>
 
      <td>Turns the repainting of this applet on (true) or off (false).
 
Note: use this method for efficient repainting when you invoke several methods.</td>
 
    </tr>
 
    <tr>
 
      <td>void setErrorDialogsActive(boolean flag)</td>
 
      <td style="text-align: center;">3.0</td>
 
      <td>Turns showing of error dialogs on (true) or off (false). Note: this is especially useful together with evalCommand().</td>
 
    </tr>
 
    <tr>
 
      <td>void setCoordSystem(double xmin, double xmax, double ymin, double ymax)</td>
 
      <td style="text-align: center;">3.0</td>
 
      <td>Sets the Cartesian coordinate system of the graphics window.</td>
 
    </tr>
 
    <tr>
 
      <td>void setAxesVisible(boolean xAxis, boolean yAxis)</td>
 
      <td style="text-align: center;">3.0</td>
 
      <td>Shows or hides the x- and y-axis of the coordinate system in the graphics window.</td>
 
    </tr>
 
    <tr>
 
      <td>void setGridVisible(boolean flag) </td>
 
      <td style="text-align: center;">3.0</td>
 
      <td>Shows or hides the coordinate grid in the graphics window.</td>
 
 
     </tr>
 
     </tr>
 +
<tr>
 +
      <td>setSize(entier largeur, entier hauteur)<br/>(HTML5)</td>
 +
      <td>Définit la largeur et la hauteur de l'appliquette (en pixels)</td>
 +
    </tr>
 +
<tr>
 +
      <td>recalculateEnvironments()<br/>(HTML5)</td>
 +
      <td>Mise à jour de l'appliquette après redimensionnement par une feuille de style en cascade externe</td>
 +
    </tr>
 
</table>
 
</table>
  
=GeoGebraApplet to JavaScript Communication=
+
=Communication de GeoGebraApplet à JavaScript=
  
With these methods you can implement Applet to JavaScript communication. When you use any of the following methods, you should make sure to insert the <span class="term"><span class="highlightedSearchTerm"><span style="font-weight: bold;">MAYSCRIPT</span> option add the end of the first line of your applet tag. For example:
+
Avec ces méthodes vous pouvez implémenter une communication de l’appliquette au JavaScript. Par exemple, ces méthodes peuvent être utilisées pour :
  
<span style="font-family: monospace;">&lt;applet name="ggbApplet" code="geogebra.GeoGebraApplet" codebase="." archive="geogebra.jar" width="500" height="250" </span><span style="font-weight: bold; font-family: monospace; color: rgb(255, 0, 0);">MAYSCRIPT</span><span style="font-family: monospace;">&gt;</span>.
+
* noter les actions de l'utilisateur (voir l'exemple [http://www.geogebra.org/source/program/applet/geogebra_applet_java2javascript.htm java2javascript])
The <span class="highlightedSearchTerm">MAYSCRIPT</span> option <span class="highlightedSearchTerm">is</span> only needed for GeoGebraApplet to JavaScript communication; it <span class="highlightedSearchTerm">is</span> not needed for JavaScript to access the GeoGebraApplet methods.
+
* communiquer entre deux appliquettes GeoGebra (voir l'exemple [http://www.geogebra.org/source/program/applet/geogebra_applet_java2java.htm java2java])
For example, these methods can be used to:
+
 
* monitor user actions (see [http://www.geogebra.org/source/program/applet/geogebra_applet_java2javascript.htm java2javascript example])
+
<table class="pretty" style="width: 100%;">
* communicate between two GeoGebra applets (see [http://www.geogebra.org/source/program/applet/geogebra_applet_java2java.htm java2java example])
 
<table style="width: 100%;" class="pretty">
 
 
  <tr>
 
  <tr>
  <th>Method Signature</th>
+
  <th>Méthode</th>
<th style="text-align: center;">Since</th>
 
 
  <th style="font-weight: bold;">Description</th>
 
  <th style="font-weight: bold;">Description</th>
 
  </tr>
 
  </tr>
 
  <tr>
 
  <tr>
  <td>void registerAddListener(String JSFunctionName)</td>
+
  <td>registerAddListener(String JSFunctionName)<br/> (supp. par unregisterAddListener(nom))</td>
<td style="text-align: center;">3.0</td>
+
  <td>Déclare une fonction JavaScript en tant que mouchard des <span style="font-weight: bold;"> ajouts </span>dans l’appliquette de construction.
  <td>Registers a JavaScript function as an <span style="font-weight: bold;">add</span> listener for the applet's construction. Whenever a new object is created in the GeoGebraApplet's construction, the JavaScript function <span style="font-style: italic;">JSFunctionName</span> is called using the name of the newly created object as its single argument. <br>
+
Dès qu’un nouvel objet est créé, la fonction JS est appelée avec comme argument le nouvel objet.  
<span style="font-style: italic;">Example</span>: First, register a listening JavaScript function:<br>
+
 
<div style="margin-left: 40px;"><span style="font-family: monospace;">ggbApplet.registerAddListener("myAddListenerFunction");</span> <br>
+
{{Exemple|1= Déclarez d’abord, une fonction JS d’écoute : <br/>
</div>
+
''ggbApplet.registerAddListener''("'''suiviAjout'''");
When an object "A" is created, the GeoGebra Applet will call the Javascript function<br>
+
Dès qu’un objet "A" est créé, l’appliquette GeoGebra appelle la fonction '''suiviAjout'''("A")}}</td>
<div style="margin-left: 40px;"><span style="font-family: monospace;">myAddListenerFunction("</span><span style="font-family: monospace;">A");<br>
 
</span></div>
 
</td>
 
 
  </tr>
 
  </tr>
 
  <tr>
 
  <tr>
  <td>void unregisterAddListener(String objName)</td>
+
  <td>registerRemoveListener(fonctionJS)<br/> (supp. par unregisterRemoveListener(nom))</td>
  <td style="text-align: center;">3.0</td>
+
  <td>Déclare une fonction JavaScript en tant que mouchard des <span style="font-weight: bold;">retraits</span> dans l’appliquette de construction.
  <td>Removes a previously registered add listener, see <span style="font-style: italic;">registerAddListener()</span></td>
+
Dès qu’un objet est supprimé, la fonction <span style="font-style: italic;">fonctionJS</span> est appelée avec comme argument le nom de l’objet effacé.
 +
{{Note | Quand une construction est mise à zéro, le mouchard n’est pas appelé pour chacun des objets élémentaires, voir registerClearListener().}}
 +
{{Exemple|1= Déclarez d’abord, une fonction JS d’écoute :<br/>
 +
''ggbApplet.registerRemoveListener''("'''suiviRetrait'''");
 +
Dès qu’un objet "A" est effacé, l’appliquette GeoGebra appelle la fonction '''suiviRetrait'''("A")}} </td>
 
  </tr>
 
  </tr>
<tr>
+
<tr>
  <td>void registerRemoveListener(String JSFunctionName)</td>
+
  <td>registerUpdateListener(fonctionJS)<br/> (supp. par unregisterUpdateListener(nom)) </td>
<td style="text-align: center;">3.0</td>
+
  <td>Déclare une fonction JavaScript en tant que mouchard des <span style="font-weight: bold;">modifications</span> dans l’appliquette de construction. Dès qu’un objet quelconque est modifié, la fonction <span style="font-style: italic;">fonctionJS</span>est appelée avec comme argument le nom de l’objet modifié.  
  <td>Registers a JavaScript function as a <span style="font-weight: bold;">remove</span> listener for the applet's construction. Whenever an object is deleted from the GeoGebraApplet's construction, the JavaScript function <span style="font-style: italic;">JSFunctionName</span> is called using the name of the deleted object as its single argument. Note: when a construction is cleared, remove is not called for every single object, see registerClearListener().<br>
+
{{Note | si vous voulez suivre les modifications d’un seul objet utilisez plutôt registerObjectUpdateListener().}}
<span style="font-style: italic;">Example</span>: First, register a listening JavaScript function:<br>
+
 
<div style="margin-left: 40px;"><span style="font-family: monospace;">ggbApplet.registerRemoveListener("myRemoveListenerFunction");</span> </div>
+
{{Exemple|1= Déclarez d’abord, une fonction JS d’écoute : <br/>
When the object "A" is deleted, the GeoGebra Applet will call the Javascript function<br>
+
''ggbApplet.registerUpdateListener''("'''suiviModifs'''");
<div style="margin-left: 40px;"><span style="font-family: monospace;">myRemoveListenerFunction</span><span style="font-family: monospace;">("</span><span style="font-family: monospace;">A");<br>
+
Dès que l’objet "A" est modifié, l’appliquette GeoGebra appelle la fonction '''suiviModifs'''("A")}}</td>
</span></div>
 
</td>
 
 
  </tr>
 
  </tr>
<tr>
+
<tr>
  <td>void unregisterRemoveListener(String objName)</td>
+
  <td>registerClickListener(fonctionJS)<br/> (supp. par unregisterregisterClickListener(nom)) </td>
  <td style="text-align: center;">3.0</td>
+
  <td>Déclare une fonction JavaScript en tant que mouchard des <span style="font-weight: bold;">clics</span> dans l’appliquette de construction. Dès qu’un objet quelconque est cliqué, la fonction <span style="font-style: italic;">fonctionJS</span>est appelée avec comme argument le nom de l’objet cliqué.
<td>Removes a previously registered remove listener, see <span style="font-style: italic;">registerRemoveListener()</span></td>
+
{{Note | si vous voulez suivre les clics sur un seul objet utilisez plutôt registerObjectClickListener().}}
 +
</td>
 
  </tr>
 
  </tr>
 
  <tr>
 
  <tr>
  <td>void registerUpdateListener(String JSFunctionName)</td>
+
  <td>registerObjectUpdateListener(nom, fonctionJS)<br/> (supp. par unregisterClickListener(nom)) </td>
<td style="text-align: center;">3.0</td>
+
  <td>Déclare une fonction JavaScript en tant que mouchard des <span style="font-weight: bold;">modifications </span> pour un simple objet dans l’appliquette de construction. Dès que l’objet suivi est modifié, la fonction <span style="font-style: italic;">fonctionJS</span> est appelée avec comme argument le nom de l’objet modifié. Si l’objet avait auparavant une valeur par la fonction JS, l’ancienne valeur est actualisée. {{Note| toutes les écoutes de modifications d’objets sont effacées quand l’objet associé est supprimé ou que la construction est remise à zéro, voir registerRemoveListener() et registerClearListener().}}
<td>Registers a JavaScript function as a <span style="font-weight: bold;">update</span> listener for the applet's construction. Whenever any object is updated in the GeoGebraApplet's construction, the JavaScript function <span style="font-style: italic;">JSFunctionName</span>is called using the name of the updated object as its single argument. Note: when you only want to listen for the updates of a single object use registerObjectUpdateListener() instead.<br>
+
{{Exemple|1= Déclarez d’abord, une fonction JS d’écoute : <br/>
<span style="font-style: italic;">Example</span>: First, register a listening JavaScript function:<br>
+
''ggbApplet.registerObjectUpdateListener''("A", "'''monsuiviA'''");
<div style="margin-left: 40px;"><span style="font-family: monospace;">ggbApplet.registerUpdateListener("myUpdateListenerFunction");</span> </div>
+
Dès que A est modifié, l’appliquette appelle la fonction '''monsuiviA'''("A") }}
When the object "A" is updated, the GeoGebra Applet will call the Javascript function<br>
+
{{Note | un mouchard de modifications d’un objet continue à fonctionner après que cet objet ait été renommé.}}
<div style="margin-left: 40px;"><span style="font-family: monospace;">myUpdateListenerFunction</span><span style="font-family: monospace;">("</span><span style="font-family: monospace;">A");<br>
 
</span></div>
 
</td>
 
</tr>
 
<tr>
 
<td>void unregisterUpdateListener(String objName)</td>
 
<td style="text-align: center;">3.0</td>
 
<td>Removes a previously registered update listener, see <span style="font-style: italic;">registerUpdateListener()</span></td>
 
</tr>
 
<tr>
 
<td>void registerObjectUpdateListener(String objName, String JSFunctionName)</td>
 
  <td style="text-align: center;">3.0</td>
 
  <td>Registers a JavaScript function as an <span style="font-weight: bold;">update</span> listener for a single object. Whenever the object with the given name is updated, the JavaScript function <span style="font-style: italic;">JSFunctionName</span>is called using the name of the updated object as its single argument. If objName previously had a mapping JavaScript function, the old value is replaced. Note: all object updated listeners are unregistered when their object is removed or the construction is cleared, see registerRemoveListener() and registerClearListener().<br>
 
<span style="font-style: italic;">Example</span>: First, register a listening JavaScript function:<br>
 
<div style="margin-left: 40px;"><span style="font-family: monospace;">ggbApplet.registerObjectUpdateListener("A", "</span><span style="font-family: monospace;">myAupdateListenerFunction</span><span style="font-family: monospace;">");</span> <br>
 
</div>
 
Whenever the object A is updated, the GeoGebra Applet will call the Javascript function<br>
 
  <div style="margin-left: 40px;"><span style="font-family: monospace;"></span><span style="font-family: monospace;">myAupdateListenerFunction</span><span style="font-family: monospace;"></span><span style="font-family: monospace;">("A");<br>
 
</span></div>
 
Note: an object update listener will still work after an object is renamed.<span style="font-family: monospace;"></span>
 
 
</td>
 
</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
  <td>void unregisterObjectUpdateListener(String objName)</td>
+
  <td>registerObjectClickListener(nom, fonctionJS)<br/> (supp. par unregisterObjectClickListener(nom)) </td>
  <td style="text-align: center;">3.0</td>
+
  <td>Déclare une fonction JavaScript en tant que mouchard des  <span style="font-weight: bold;">clics </span> pour un seul objet dans l’appliquette de construction. Dès que l’objet suivi est cliqué, la fonction <span style="font-style: italic;">fonctionJS</span> est appelée avec comme argument le nom de l’objet modifié. Si l’objet avait auparavant une valeur par la fonction JS, l’ancienne valeur est actualisée. {{Note| toutes les écoutes de clics d’objets sont effacées quand l’objet associé est supprimé ou que la construction est remise à zéro, voir registerRemoveListener() et registerClearListener().}}
<td>Removes a previously registered object update listener of the object with the given name, see <span style="font-style: italic;">registerObjectUpdateListener()</span></td>
+
{{Exemple|1= Déclarez d’abord, une fonction JS d’écoute : <br/>
</tr>
+
''ggbApplet.registerObjectClickListener''("A", "'''monsuiviA'''");
 +
Dès que A est modifié, l’appliquette  appelle la fonction '''monsuiviA'''("A") }}
 +
{{Note | un mouchard de clics sur un objet continue à fonctionner après que cet objet ait été renommé.}}
 +
</td>
 +
</tr>
 
  <tr>
 
  <tr>
  <td>void registerRenameListener(String JSFunctionName)</td>
+
  <td>registerRenameListener(fonctionJS) <br/> (supp. par unregisterRenameListener(nom))</td>
<td style="text-align: center;">3.0</td>
+
  <td>Déclare une fonction JavaScript en tant que mouchard des  <span style="font-weight: bold;">changements de nom </span> dans l’appliquette de construction. Dès qu’un objet est renommé, la fonction <span style="font-style: italic;">fonctionJS</span> est appelée avec comme argument l’ancien nom de l’objet et le nouveau.
  <td>Registers a JavaScript function as a <span style="font-weight: bold;">rename</span> listener for the applet's construction. Whenever an object is renamed in the GeoGebraApplet's construction, the JavaScript function <span style="font-style: italic;">JSFunctionName</span> is called using the old name and the new name of the renamed object as its two arguments. <br>
+
{{Exemple|1=Déclarez d’abord, une fonction JS d'écoute :<br/>
<span style="font-style: italic;">Example</span>: First, register a listening JavaScript function:<br>
+
''ggbApplet.registerRenameListener''("'''monsuiviRenommer'''");
<div style="margin-left: 40px;"><span style="font-family: monospace;">ggbApplet.registerRenameListener("myRenameListenerFunction");</span> </div>
+
Dès qu’un objet "A" est renommé en "B", l’appliquette appelle la fonction''' monsuiviRenommer'''("A", "B")}} </td>
When an object "A" is renamed to "B", the GeoGebra Applet will call the Javascript function<br>
 
<div style="margin-left: 40px;"><span style="font-family: monospace;">myRenameListenerFunction</span><span style="font-family: monospace;">("</span><span style="font-family: monospace;">A", "B");<br>
 
</span></div>
 
</td>
 
 
  </tr>
 
  </tr>
<tr>
+
<tr>
  <td>void unregisterRenameListener(String objName)</td>
+
  <td>registerClearListener(fonctionJS) <br/>(supp. par unregisterClearListener(nom))</td>
<td style="text-align: center;">3.0</td>
+
  <td>Déclare une fonction JavaScript en tant que mouchard des <span style="font-weight: bold;">remises à zéro </span> dans l’appliquette de construction. Dès que la construction est remise à zéro (i.e. tous les objets sont supprimés), la fonction <span style="font-style: italic;">fonctionJS</span> est appelée sans argument. {{Note| tous les mouchards de modifications ne sont plus déclarés quand une construction est remise à zéro. Voir registerUpdateListener() et registerRemoveListener().}}
<td>Removes a previously registered rename listener, see <span style="font-style: italic;">registerRenameListener()</span></td>
+
{{Exemple|1=Déclarez d’abord, une fonction JS d'écoute :<br/>
</tr>
+
''ggbApplet.registerClearListener''("'''suiviRAZ'''");
<tr>
+
Quand la construction est remise à zéro , l’appliquette appelle la fonction '''suiviRAZ'''()}}</td>
<td>void registerClearListener(String JSFunctionName)</td>
 
  <td style="text-align: center;">3.0</td>
 
  <td>Registers a JavaScript function as a <span style="font-weight: bold;">clear</span> listener for the applet's construction. Whenever the construction in the GeoGebraApplet is cleared (i.e. all objects are removed), the JavaScript function JSFunctionName is called using no arguments. Note: all update listeners are unregistered when a construction is cleared. See registerUpdateListener() and registerRemoveListener().<br>
 
<span style="font-style: italic;">Example</span>: First, register a listening JavaScript function:<br>
 
<div style="margin-left: 40px;"><span style="font-family: monospace;">ggbApplet.registerClearListener("myClearListenerFunction");</span> </div>
 
When the construction is cleared (i.e. after reseting a construction or opening a new construction file), the GeoGebra Applet will call the Javascript function<br>
 
<div style="margin-left: 40px;"><span style="font-family: monospace;">myClearListenerFunction</span><span style="font-family: monospace;">(</span><span style="font-family: monospace;">);</span></div>
 
</td>
 
</tr>
 
<tr>
 
<td>void unregisterClearListener(String JSFunctionName)</td>
 
<td style="text-align: center;">3.0</td>
 
<td>Removes a previously registered clear listener, see <span style="font-style: italic;">registerClearListener()</span></td>
 
 
  </tr>
 
  </tr>
 +
<tr>
 +
<td>registerStoreUndoListener(fonctionJS) <br/>(supp. par unregisterStoreUndoListener(nom))</td>
 +
<td>Déclare une fonction JavaScript en tant que mouchard des  <span style="font-weight: bold;">création de points de restauration </span> dans l’appliquette de construction. (appelé sans arguments) .</td>
 +
</tr>
 
</table>
 
</table>
  
= GeoGebra's XML format =
+
= Format XML de GeoGebra =
  
With these methods you can set everything in a construction (see [[Reference:Xml|XML Reference]] ).
+
Avec ces méthodes vous pouvez définir tout objet dans une construction. (voir [[Référence:XML|Références XML ]] ).
<table style="width: 100%;" class="pretty">
+
<table class="pretty" style="width: 100%;">
 
     <tr>
 
     <tr>
       <th>Method Signature</th>
+
       <th>Méthode</th>
      <th style="text-align: center;">Since</th>
 
 
       <th>Description</th>
 
       <th>Description</th>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
       <td>void evalXML(String xmlString) </td>
+
       <td>evalXML(chaînexml) </td>
       <td style="text-align: center;">2.7</td>
+
       <td>Évalue la chaîne fournie et modifie la construction actuelle. {{Note| la construction n’est pas effacée avant l’évaluation de la chaîne XML.}}
      <td>Evaluates the given XML string and changes the current construction. Note: the construction is NOT cleared before evaluating the XML string.
 
 
       </td>
 
       </td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
       <td>void setXML(String xmlString) </td>
+
       <td>setXML(chaînexml) </td>
       <td style="text-align: center;">2.7</td>
+
       <td>Évalue la chaîne fournie et modifie la construction actuelle. {{Note| la construction est effacée avant l’évaluation de la chaîne XML. Cette méthode peut être utilisée pour charger des constructions.}}
      <td>Evaluates the given XML string and changes the current construction. Note: the construction is cleared before evaluating the XML string. This method could be used to load constructions.
 
 
       </td>
 
       </td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
       <td>String getXML()<br>
+
       <td>getXML()<br>
 
       </td>
 
       </td>
       <td style="text-align: center;">2.7</td>
+
       <td>Retourne l’actuelle construction sous forme d’une chaîne dans le format XML de GeoGebra. Cette méthode peut être utilisée pour sauvegarder des constructions.
      <td>Returns the current construction in GeoGebra's XML format. This method could be used to save constructions.<br>
+
 
 +
<span style="font-style: italic;">Exemple</span> :
 +
<form name="nonof"><input type="button" value="get"
 +
onclick="document.nonof.nonot.value=document.ggbApplet.getXML()";">
 +
<textarea name="nonot" rows=8 cols=60> </textarea>
 +
</form>
 +
<br>
 
       </td>
 
       </td>
 
     </tr>
 
     </tr>
 
   <tr>
 
   <tr>
       <td>String getXML(String objName)<br>
+
       <td>getXML(nom)<br>
 
       </td>
 
       </td>
       <td style="text-align: center;">3.2</td>
+
       <td>Retourne uniquement la chaîne de construction XML de l’objet cité., i.e. seulement le paragraphe  &lt;element&gt;.
      <td>Returns the GeoGebra XML string for the given object, i.e. only the &lt;element&gt; tag is returned.
 
 
       </td>
 
       </td>
 
     </tr>
 
     </tr>
 
<tr>
 
<tr>
       <td>String getAlgorithmXML(String objName)<br>
+
       <td>getAlgorithmXML(nom)<br>
 
       </td>
 
       </td>
       <td style="text-align: center;">3.2</td>
+
       <td>
      <td>For a dependent GeoElement objName the XML string of the parent algorithm and all its output objects is returned. For a free GeoElement objName "" is returned.
+
Retourne une chaîne vide pour un objet libre.
 +
Retourne la chaîne de construction XML de l’ascendant (et de tous ses descendants) de l’objet cité pour un objet dépendant
 +
 
 
       </td>
 
       </td>
 
     </tr>
 
     </tr>
 
</table>
 
</table>
  
= Miscellaneous =
+
= Divers =
  
 +
* drawToImage(label,x[],y[]), clearImage(label) to draw
 +
::{{exemple|1=<div>Zbynĕk
 +
:::<code>for(var i=0;i<5;i+=0.07){
 +
:::&nbsp;for(var j=0;j<5;j+=0.07){
 +
:::&nbsp;ggbApplet.setPenColor(j*51,i*51,0);
 +
:::&nbsp;ggbApplet.drawToImage("img1",new Array(i,i),new Array(j,j));
 +
:::&nbsp;}
 +
:::}</code>
 +
:::</div>}}
 +
* String evalGeoGebraCAS(String casCommand)
 +
* String evalGeoGebraCAS(String casCommand, boolean printDebugInfo)
 +
* void setPenColor(int red, int green, int blue); valeurs entre 0 et 255
 +
* void setPenSize(int size); définit la taille tracé du stylo en pixels
 +
* int getPenSize(); retourne la taille tracé du stylo en pixels
 +
* String getPenColor(); retourne la couleur RVB du tracé du stylo sous forme de chaîne hexadécimale (par ex. #AB1234)
 +
* boolean evalCommand(String cmd, boolean waitForResult)
 +
* public void setListValue(String objName, int index, double x);
 +
:Définit la valeur de l'élément à la position indiquée dans la liste. Peut être utilisé pour augmenter la longueur d'une liste. Ne pas oublier que l'indice du premier élément est 1 non pas 0
 +
* public double getListValue(String objName, int index);
 +
:Retourne la valeur de l'élément à la position indiquée dans la liste. Retourne NaN si l'objet n'est ni un nombre, ni un booléen.
  
<table style="width: 100%;" class="pretty">
+
 
 +
 
 +
::{{Exemple|1=<div>Noël registerClickListener
 +
:::<code>
 +
:::function ggbOnInit() {
 +
:::ggbApplet.registerClickListener("HLS");
 +
:::select='Segment[(0,0),(0,0)]';
 +
:::}
 +
:::function HLS(obj) {
 +
:::type=ggbApplet.getObjectType(obj);
 +
:::if (type=="segment") {
 +
:::cmd='SetLineThickness['+select+',3]';
 +
:::ggbApplet.evalCommand(cmd);
 +
:::cmd='SetColor['+select+',"Black"]';
 +
:::ggbApplet.evalCommand(cmd);
 +
:::cmd='SetLineThickness['+obj+',13]';
 +
:::ggbApplet.evalCommand(cmd);
 +
:::cmd='SetColor['+obj+',"Red"]';
 +
:::ggbApplet.evalCommand(cmd);
 +
:::select=obj;
 +
:::}
 +
:::else{
 +
:::cmd='SetLineThickness['+select+',3]';
 +
:::ggbApplet.evalCommand(cmd);
 +
:::cmd='SetColor['+select+',"Black"]';
 +
:::ggbApplet.evalCommand(cmd);
 +
:::select='Segment[(0,0),(0,0)]';
 +
:::}
 +
:::}</code>
 +
:::</div>}}
 +
 
 +
 
 +
 
 +
<table class="pretty" style="width: 100%;">
 
     <tr>
 
     <tr>
       <th>Method Signature</th>
+
       <th>Méthode</th>
      <th>Since</th>
 
 
       <th>Description</th>
 
       <th>Description</th>
 
     </tr>
 
     </tr>
 +
   
 
     <tr>
 
     <tr>
       <td>String evalMathPiper(String string) </td>
+
       <td>debug(chaîne) </td>
       <td style="text-align: center;">3.2</td>
+
       <td>Écrit la chaîne dans la  Console Java       </td>
      <td>Passes the string to MathPiper and returns the result as a String.
 
       </td>
 
 
     </tr>
 
     </tr>
 +
<tr>
 +
<td>getVersion()</td>
 +
<td>Retourne la version de GeoGebra</td>
 +
</tr>
 +
</table>
 +
 +
==Évaluation automatique d'exercice ==
 +
 +
<table class="pretty" style="width: 100%;">
 
     <tr>
 
     <tr>
       <td>String getIPAddress()</td>
+
       <th>Méthode</th>
       <td style="text-align: center;">3.2</td>
+
       <th>Description</th>
      <td>Returns the IP address of the local computer as a String eg "192.168.0.4"
 
      </td>
 
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
       <td>String getHostname() </td>
+
       <td>JSONObject getExerciseResult()</td>
       <td style="text-align: center;">3.2</td>
+
       <td>S'il y a des Macros ou un Exercice présents dans le fichier courant, cette méthode peut être utilisée pour évaluer si des parties de la construction sont équivalentes aux Macros de ce fichier.<br>Si vous ne voulez pas qu'un Exercice Standard (utilisant toutes les Macros dans la Construction et les fractionnant chacune jusqu'à 100) soit créé, tester d'abord si c'est un Exercice avec isExercise() . <br>Aide restera vide, sauf indication contraire dans le constructeur d'exercice.<br>Les fractions seront de 0 or 1 sauf indication contraire dans le constructeur d'exercice.<br>Le résultat sera dans Résultat,i.e:<br>CORRECTE, L'affectation est CORRECTE <br>WRONG, if the assignment is WRONG and we can't tell why <br>NOT_ENOUGH_INPUTS if there are not enough input geos, so we cannot check <br>WRONG_INPUT_TYPES, if there are enough input geos, but one or more are of the wrong type <br>WRONG_OUTPUT_TYPE, if there is no output geo matching our macro <br>WRONG_AFTER_RANDOMIZE, if the assignment was correct in the first place but wrong after randomization <br>UNKNOWN, if the assignment could not be checked
       <td>Returns the hostname of the local computer as a String
+
</td>
      </td>
+
    </tr>
 +
<tr>
 +
      <td>getExerciseFraction()</td>
 +
       <td>If there are Macros or an Exercise present in the current file this can be used to check if parts of the construction are equivalent to the Macros in the file. <br>It will return the overall Fraction of the Exercise.<br>This is the sum of all the Fractions in the Assignment or 1 if one of the Assignments has a fraction of 100 and no negative fractions are present. Use getExerciseResult() to get the fractions of each Assignment. If you don't want that a standard exercise (using all the Macros in the Construction and setting each fraction to 100) will be created, check if this is a Exercise with isExercise() first. </td>
 
     </tr>
 
     </tr>
    <tr>
+
     
       <td>void debug(String string) </td>
+
  <tr>
       <td style="text-align: center;">3.2</td>
+
       <td>isExercise()</td>
      <td>Prints the string to the Java Console
+
       <td>Check whether this applet is an Exercise<br>Returns:true if the Exercise has assignments, this will happen when either getExerciseResult() or getExerciseFraction() are called with user defined Tools present in the applet or if the ExerciseBuilderDialog was used to create the Exercise.</td>
      </td>
 
 
     </tr>
 
     </tr>
 +
<tr>
 +
      <td>boolean startExercise()</td>
 +
      <td>If you want to make use of the values of random geos a BoolAssignment depends on, this is an easy way to retrieve these values for displaying in the question text and stop randomizing them in order to store the same assignment that was presented to the student.</td>
 +
    </tr>
 +
</table>
 +
Un exemple utilisant ces fonctionnalités :    http://archive.geogebra.org/source/program/applet/exerciseExample.html
  
</table>
+
== Obtenir Objet Appliquette ==
 +
 +
Dans les situations basiques l'appliquette est dans la  variable globale ''ggbApplet'' . Les exceptions sont :
 +
 +
*plusieurs appliquettes dans une page, par défaut, une seule est accessible pour JavaScript. Pour accéder à  plusieurs appliquettes, vous devez définir le paramètre "id" pour chaque appliquette, il deviendra le nom de la variable globale  représentant l'appliquette ;
 +
 +
*export depuis GeoGebra 4.0 et antérieurs : l'appliquette est accessible en tant que document.applets[0], les autres appliquettes de la même page le sont  par document.applets[1], ...
 +
 
 +
 
 +
 
 +
[[en:Reference:JavaScript]]
 +
[[es:Referencia:JavaScript]]
 +
[[it:Riferimenti:JavaScript]]
 +
[[Catégorie:Référence|JavaScript]]

Version actuelle datée du 23 avril 2018 à 10:46

Cette page vous explique comment vous pouvez interagir avec l'appliquette GeoGebra en utilisant JavaScript.

L'appliquette GeoGebra est considérée comme un objet JavaScript, dans cette page, nous supposons que l'objet est enregistré dans la variable nommée ggbApplet.

Ce qui est le cas si vous utilisez JavaScript depuis GeoGebra ou dans une page web contenant une seule appliquette GeoGebra exportée

  • soit directement depuis GeoGebra (Ctrl + Maj + M)
  • soit en utilisant le lien dans le dossier complet (hors ligne) fourni par GeoGebra.

Les scripts ne sont pas activables pour les appliquettes exportées depuis GeoGebra via la fonctionnalité Insérer.

Dans le cas où sont intégrées plusieurs appliquettes, consultez la section Obtenir Objet Appliquette .


Exemples

Exemple : le fragment de code HTML suivant ajoute un bouton "Réinitialiser" dans une page HTML, ce qui permet à l’utilisateur de ramener la construction affichée par GeoGebra dans son état initial :
<form>
<input type="button" value="Réinitialiser" onclick="ggbApplet.reset();">
</form>
Exemple : celui-ci ajoute deux boutons "Cacher A" et " Afficher A" pour changer l’état d’affichage de l’objet nommé “A" dans la construction
<form>
<input type="button" value="Cacher A" onclick="ggbApplet.setVisible('A', false);">
<input type="button" value="Afficher A" onclick="ggbApplet.setVisible('A', true);">
</form>
Exemple : Une fonction JavaScript "maConstruction()" est utilisée pour appeler plusieurs méthodes de l’appliquette GeoGebra.
Note : La langue est fixée à Français ("fr") avec le paramètre "language" dans la balise de l’appliquette afin de faire en sorte que la commande française "Droite" fonctionne.
<script type="text/javascript" language="javascript" src="http://www.geogebra.org/web/4.4/web/web.nocache.js"></script><article class="geogebraweb" data-param-width="500" data-param-height="500" data-param-ggbbase64="UEsDBBQACAgIAM1CWUMAAAAAAAAAAAAAAAAWAAAAZ2VvZ2VicmFfamF2YXNjcmlwdC5qc0srzUsuyczPU0hPT/LP88zLLNHQVKiuBQBQSwcI1je9uRkAAAAXAAAAUEsDBBQACAgIAM1CWUMAAAAAAAAAAAAAAAAMAAAAZ2VvZ2VicmEueG1svVZtb9s2EP6c/oqDPicxSVGyHMgp1gIFCmTdgHTDsG+URMtcZFEQKb8M/fE7kpIjpy/o0GFB7CN5D++5O96Rzl8fdw3sZW+UbtcRvSURyLbUlWrrdTTYzU0Wvb5/lddS17LoBWx0vxN2HXGHVNU62iSblBPGbgou0hu+yuKbjONXucrKpCJVma14BHA06q7VH8ROmk6U8rHcyp140KWwnnhrbXe3WBwOh9uJ6lb39aKui9ujqSJAN1uzjsbBHZq72HSIPZwRQhd//PwQzN+o1ljRljICF8Kg7l9d5QfVVvoAB1XZ7TrKCIaxlareYkypmywcqMOEdLK0ai8Nbp1Nfcx210UeJlqnvwojaM7hRFCpvapkv47ILUsi0L2SrR21dGRZTPvzvZKHYMiNPAcmzWrdFMLZgE+fgBFG4NoJGgRDkaZBRcIaiYNgQfAgkoDhYTsPUB4wPGB4HMFeGVU0Eo9UNAZzptpNj+d1nht7aqT3Z1x4jpdeY0xG/Y3g2CUxJBnXCbl2H8zsNZ+yOwuSzlhtP/xL0olymbHvp2Q/FGg8cbIvhcmSr4SZfoM0xP09cdJkxolU/t9/PmOMvxXmS8Yw/zHClP8vIeaLqVXysTvAbB12rB4rd8b1S7yCZOXKnkKCvZEuscoToCsUSwbYDUAT4AlOaQapk0uIl6jgEEMGDkdj8M2RZPjFl95YCgkac6tL7EmgSMQhiYH6nuKAnQS+L7FHWYyIJIEENzl6ypyJOAWe4izOgKOPriWXFIExbsQ50jOIKcRuM10CSyF19ih3rZ5mznU0ySAlkFJnELsaOzp0M+IziF006Zgu1XaDvUhRuaumodXd+SwQjffR8z0X7qeLa/Aqb0QhG3wZHt1JAuxF4zrCE210a2E6RBbW6l50W1WaR2kt7jLwl9iLB2Hl8R2izcTtsaVuza+9tm91M+xaA1Dqhpx91g2djdnZa5zEMwWfK5KZIp2Nl1/k1aiBwUjk172Z4KKq3jvE89WAmfylbU5veimeOq0uw8gX/pHJ5VA2qlKi/R2L1bG4vMD05vjranpzOKOTI7qvHk8GKxiOf8pe4x1Dk1sy/8Pb5xRU8UsVHrgphWu+hFxqsLdOX1PxwC335yMSR3mOvu5VNR+/N290U51z4cN/Kzo79P7XAnrXu6B+autG+hLxjY1PcflU6ONjqI042Pp46nBGAn9R+7QDXg0swdeyHmURpMc4x84o4jHEI8hUbKo66+mKeYSXRZAehdUbXBsDpVOUlEw0yvgLjUQXbeNL3z3sQ6vswzSxqnx6jtThPwy7Qp4L6NIk/Y9M5osXBZY/yb6VzVjPeJCDHkxoz1mpV7JUO5wGxZgQ4Q7rN3QgrFay7uXkd+N/h4V0eS2Zl+pny97Uu17v3rf7j1gJLxzIF5OXuSl71bl6gwLfgCf5XFOVMgKfkGq+zzUghl66pwLTY11qsDUHu9W9/6mFNwpKxzCH+nYcf0ve/wNQSwcI2ajKq1gEAADoCgAAUEsBAhQAFAAICAgAzUJZQ9Y3vbkZAAAAFwAAABYAAAAAAAAAAAAAAAAAAAAAAGdlb2dlYnJhX2phdmFzY3JpcHQuanNQSwECFAAUAAgICADNQllD2ajKq1gEAADoCgAADAAAAAAAAAAAAAAAAABdAAAAZ2VvZ2VicmEueG1sUEsFBgAAAAACAAIAfgAAAO8EAAAAAA=="></article>
<script type="text/javascript">
function maConstruction(){
var applet = document.ggbApplet;
applet.evalCommand("A = (1,1)");
applet.evalCommand("B = (3,2)");
applet.evalCommand("s = Droite[A, B]");
}
</script>
<form>
<input type="button" value="Faire la construction" onclick="maConstruction();">
</form>
Exemple : Explorez le code source de l'exemple suivant qui utilise JavaScript.
http://www.geogebra.org/source/program/applet/geogebra_applet_javascript_test.htm
Exemple : Ceci est un exemple de fichier qui utilise un add listener pour savoir si une construction particulière a été complétée (et alors envoie le message "Well done").
http://www.geogebra.org/en/examples/javascriptAutomaticCheckingExercise.html
Exemple : Ceci est un exemple montrant comment coupler JavaScript avec GeoGebraWeb.
http://www.geogebra.org/web/milestones/SlopeTestWeb.html

Méthodes utilisables

Méthode Description
evalCommand(commande) Évalue la chaîne comme si vous l’aviez entrée dans le champ de saisie [ex : evalCommand('s = Droite[A, B]')].
Vous pouvez utiliser plusieurs commandes en les séparant par "\n"
Note : Utilisez le paramètre “language” pour vous assurer que la commande dans votre langue est reconnue.

La valeur retournée indique si la commande est exécutée avec succès.

Note : Mais vous devriez utiliser les noms anglais des commandes pour vous assurer que la commande fonctionne dans toutes les versions de GeoGebra.
evalCommandGetLabels(commande)Analogue à evalCommand(), mais la valeur retournée est une chaîne contenant l'étiquette de l'objet créé, ou une liste des étiquettes, séparées par une virgule, des objets créés par ex. : "A,B,C"
evalCommandCAS(commande) Passe la commande au CAS de GeoGebra
setUndoPoint() Définit un point de restauration. Utile si vous désirez que l'utilisateur puisse annuler l'action d'un evalCommand, par exemple si vous avez créé un bouton dans l'HTML pour agir comme un outil personnalisé.

Définir l’état d’un objet

Méthode Description
deleteObject(nom) Efface l’objet cité.
Exemple : deleteObject('A')
setAuxiliary(geo, true/false) Affecte (ou non) le statut d'"Auxiliaire" à l'objet
setValue(nom, valeur) Affecte la valeur à l’objet cité
Exemple : setValue('n',36)
Note : Si cet objet n’est pas un nombre, rien ne se passe.
Si l’objet est un booléen, utiliser la valeur 1 pour le mettre à ‘Vrai’, n’importe quelle valeur pour le mettre à ‘Faux’.
setTextValue(nom, texte) Affecte le texte à l'objet texte cité. Rien ne se passe pour tout autre type d'objet.
setListValue(nom, position, valeur) Affecte la valeur à l'élément à la position donnée dans la liste
setCoords(nom, x, y)
setCoords(nom, x, y,z)
Affecte les coordonnées à l’objet
Exemple : setCoords('A',-1,3)
Note : Si cet objet n’est ni point ni vecteur, rien ne se passe.
setColor(nom, rouge, vert, bleu) Affecte la couleur RVB à l’objet
Exemple : setColor('A',200,100,100)
setDisplayStyle(objet, style) Affecte le style d'affichage à l'objet. Style doit être parmi "parametric", "explicit", "implicit", "specific"
setVisible(nom, booléen) Affiche (true) ou Cache (false) l’objet cité dans la vue Graphique
Exemple : setVisible('A',true)
setLabelVisible(nom, booléen) Affiche (true) ou Cache (false) l’étiquette de l’objet cité dans la vue Graphique
Exemple : setLabelVisible('A',false)
setLabelStyle(nom, entier) Définit le style de l’étiquette de l’objet cité dans Graphique.
Nom = 0, Nom & Valeur = 1, Valeur = 2, Légende=3 et Légende & Valeur =9.
Exemple : setLabelStyle('A',1)
setCaption(nom, texte) Définit la Légende de l'objet
setFixed(nom, booléen Fixé, booléen Sélectionnable) Définit la liberté de l’objet cité
Exemple : setFixed('A',true)
Note : Les objets fixes ne peuvent être modifiés.
setTrace(nom, booléen) Active ou non la trace de l’objet cité
Exemple : setTrace('A',false)
renameObject(ancien nom, nouveau nom) Renomme l’objet ancien nom en l’objet nouveau nom
setLayer(nom,entier) Définit le calque de l’objet cité.
setLayerVisible(n°, booléen) Affiche ou cache tous les objets du calque n°
setLineStyle(nom,entier) Définit le style du trait (de 0 à 4)
setLineThickness(nom,entier) Définit l’épaisseur de l’objet (de 1 à 13) (1 par défaut)
setPointStyle(nom,entier) Définit le style du point (-1 par défaut, 0 disque, 1 cercle, 2 croix,3 plus, 4 diamant plein, 5 diamant vide, 6 triangle (nord), 7 triangle (sud), 8 triangle (est), 9 triangle (ouest))
Voir Commande_SoitStylePoint
setPointSize(nom,entier) Définit la taille du point (de 1 à 9)
setFilling(nom,nombre) Définit le remplissage de l’objet (de 0 à 1)
setRounding(chaine) La chaîne est constituée d'un nombre et d'un drapeau : "s" pour chiffres significatifs, "d" pour décimales (par défaut).
Les entiers JavaScript sont automatiquement gérés comme chaînes. Exemple: "10s", "5", 3
Définit l'option d'arrondi,
Exemple : ggbApplet.setRounding("4") règle l'arrondi à 4 décimales,
ggbApplet.setRounding("5r") à 5 chiffres significatifs
getPNGBase64(échelle, booléen transparent, DPI) Retourne Graphique1 sous forme d'une chaîne encodée en base64.
Exemple : var str = ggbApplet.getPNGBase64(1, true, 72);

Le paramètre DPI n'est actuellement pas pris en compte en version HTML5
getPNGBase64(échelle, booléen transparent, DPI,copyToClipboard) Retourne Graphique1 sous forme d'une chaîne encodée en base64.
Exemple : var str = ggbApplet.getPNGBase64(1, true, 72);
getScreenshotBase64(fonction) HTML5 slt Récupère une copie d'écran de l'appliquette entière en PNG et la renvoit à la fonction d'appel en chaîne encodée en base64. {{Exemple: ggbApplet.getScreenshotBase64(function(url){window.open("data:image/png;base64,"+url);});}}
Pour utilisation dans GeoGebra ! Il est possible que cela ne fonctionne pas dans tous les navigateurs
writePNGtoFile(Nomfichier, échelle, booléen transparent, DPI) Exporte Graphique1 dans un fichier PNG. (ne fonctionne que pour les appliquettes signées)
Exemple : var success = ggbApplet.writePNGtoFile("c:\\test.png", 1, false, 300);
isIndependent(nom) teste si nom est indépendant
isMoveable(nom) teste si nom est déplaçable
getBase64() Récupère la construction courante dans un fichier .ggb encodée en base64
String getBase64(callback function)
4.4(HTML5 only)
Gets the current construction as a base64-encoded .ggb file asynchronously, passes as parameter to the callback function when ready. The callback function should take one parameter (the base64 string).
setBase64(chaîne) Définit la construction courante à partir d'un fichier .ggb encodé en base64

Animation automatique

Méthode Description
setAnimating(nom, booléen) Définit si l’objet cité peut être animé. Cela ne lance pas l'animation, utilisez startAnimation() pour le faire.
setAnimationSpeed(nom, nombre) Définit la vitesse d’animation de l’objet cité.
startAnimation() Lance l’animation pour les objets pouvant être animés.
stopAnimation() Arrête l’animation en cours.
isAnimationRunning() Retourne un booléen précisant si une animation est en cours ou non.

Connaître l’état d’un objet

Méthode Description
getXcoord(nom) Retourne l’abscisse de l’objet cité.
Exemple : getXcoord('A')
Note : Retourne 0 si l’objet n’est ni un point ni un vecteur.
getYcoord(nom) Retourne l’ordonnée de l’objet cité.
Exemple : getYcoord('u')]
Note : Retourne 0 si l’objet n’est ni un point ni un vecteur.
getZcoord(nom) Retourne la cote de l’objet cité.
Exemple : getYcoord('u')]
Note : Retourne 0 si l’objet n’est ni un point ni un vecteur.
getValue(nom) Retourne la valeur de l’objet cité ( longueur pour un segment, aire pour un polygone, etc.).
Exemple : getValue('poly1')]
Note : Retourne 0 s’il l’objet n’a pas de valeur associée.
Si l’objet est un booléen, retourne 1 pour ‘Vrai’, 0 pour ‘Faux’.
getListValue(nom, indice) Retourne la valeur de l’objet de la liste dans la position précisée.
Note : Si l’objet est un booléen, retourne 1 pour ‘Vrai’, 0 pour ‘Faux’.
getColor(nom) Retourne la couleur de l’objet cité sous forme d’une chaîne hexadécimale.
Exemple : getColor('A') retourne "#FF0000" si A est rouge.
Note : la chaîne hexadécimale commence toujours par # et ne contient pas de lettres minuscules.
getVisible(nom) Retourne ‘'true'’ ou '‘false’' suivant que l’objet cité est affiché ou non dans la vue Graphique. Retourne ‘'false'’ si l'objet n'existe pas.
getVisible(nom,1|2) Retourne ‘'true'’ ou '‘false’' suivant que l’objet cité est affiché ou non dans la vue Graphique 1 ou 2. Retourne ‘'false'’ si l'objet n'existe pas.
getValueString(nom) Retourne la valeur de l’objet cité sous forme de chaîne.
getDefinitionString(nom) Retourne la définition (l’info bulle) de l’objet cité.
getCommandString(nom) Retourne la commande à saisir pour créer l’objet cité.
getCommandString(nom, booléen) Retourne la commande à saisir pour créer l’objet cité en anglais si false, dans la langue actuelle de l'interface sinon.
getLaTeXString(nom) Retourne la valeur de l'objet cité n syntaxe LaTeX
getLaTeXBase64(nom, booléen) Retourne une image PNG en base64 de l'objet en LaTeX. Pour le booléen = false l'objet est représenté selon sa définition, pour le booléen=true c'est la valeur de l'objet qui est représentée.
getObjectType(nom) Retourne le type de l’objet cité sous forme de chaîne (comme "point", "line", "circle", etc. en Anglais !).
exists(nom) Retourne un booléen attestant l’existence ou non de l’objet cité dans la construction.
isDefined(nom) Retourne un booléen attestant la validité actuelle ou non de l’objet .
getObjectNumber() Retourne le nombre d’objets dans la construction.
getCASObjectNumber() Retourne le nombre d’objets (lignes non vides) du CAS.
getObjectName(n) Retourne le nom du n-ème objet de la construction (attention, le compteur commence à 0).
getLayer(nom) Retourne le numéro du calque de l’objet cité.
getLineStyle(nom) Retourne le style du trait (de 0 à 4)
getLineThickness(nom) Retourne l’épaisseur de l’objet (de 1 à 13) (1 par défaut)
getPointStyle(nom) Retourne le style du point (-1 par défaut, 0 disque, 1 cercle, 2 croix,3 plus, 4 diamant plein, 5 diamant vide, 6 triangle (nord), 7 triangle (sud), 8 triangle (est), 9 triangle (ouest))
getPointSize(nom) Retourne la taille du point (de 1 à 9)
getFilling(nom) Retourne le remplissage de l’objet (de 0 à 1)
getCaption(nom, booléen) Retourne la légende de l'objet. Si elle contient des substituts (%n, %v,...), vous pouvez utiliser le booléen pour préciser si vous voulez qu'ils soient remplacés ou non.
getLabelStyle(nom) Retourne le type d'étiquette de l'objet, Voir setLabelStyle pour les valeurs possibles
getLabelVisible()

Construction / Interface Utilisateur

Méthode Description
setMode(code du mode) Définit le mode au code fourni
Exemple : setMode(0) pour mode Déplacer.
(voir Codes et paramètre “showToolBar” et  paramètre "customToolBar" )
getMode() Retourne le code du mode actuel
openFile(URL) Ouvre le fichier dont l’URL est donnée sous forme absolue ou relative)[ex : openFile('fichier.ggb')].
reset() Réinitialise la construction.
void newConstruction() Efface tous les objets de la construction
refreshViews() Rafraîchit l’affichage.
Note : Cela efface toutes les traces dans la vue Graphique.
setOnTheFlyPointCreationActive(booléen)
Autorise (true) ou non (false) la création de points "à la volée".
Note : À utiliser si vous ne désirez pas que les outils créent des points.
setPointCapture(view, mode) Définit l'option de Capture des points dans la vue citée
0 - Désactivée, 1 - Approché de la Grille, 2 - Attaché à la Grille, 3 - Automatique
hideCursorWhenDragging(booléen)
Affiche(true) ou non (false) le curseur de la souris quand on déplace un object.
setRepaintingActive(booléen)
Active (true) ou non (false) le recalcul de la figure.
Note : Cette méthode est surtout à utiliser quand vous utilisez plusieurs méthodes.
setErrorDialogsActive(booléen) Bascule pour l’affichage ou non du dialogue d’erreur.
Note : C'est très utile avec l'utilisation de evalCommand().
setCoordSystem(xmin, xmax,ymin,ymax) Définit la fenêtre Graphique.
Exemple : setCoordSystem(-5,10,-1,20)
setCoordSystem(xmin, xmax, ymin, ymax, zmin, zmax, booléen yVertical) Définit la fenêtre Graphique 3D. Le booléen yVertical précisant si axeY est "vertical" ou non.
setAxesVisible(booléen, booléen) Affiche (true) ou Cache (false) indépendamment chacun des axes.
Exemple : setAxesVisible(true, false)
setAxesVisible(vue,booléen, booléen,booléen) Affiche (true) ou Cache (false) indépendamment chacun des axes dans la vue nommée.
Exemple : ggbApplet.setAxesVisible(3, false, true, true)
setAxisLabels(vue,x, y, z) Définit les étiquettes des axes de la vue nommée.
Exemple : ggbApplet.setAxisLabels(3,"larg","long","haut")
setAxisSteps(vue, x, y, z) Définit les pas de graduations sur les axes de la vue nommée.
Exemple : ggbApplet.setAxisSteps(1,"pi/4",1,1);
setAxisUnits(vue, x, y, z) Définit les unités sur les axes de la vue nommée.
Exemple : ggbApplet.setAxisUnits(3, "cm","cm","cm²")
setGridVisible(booléen) Affiche (true) ou Cache (false) la grille dans Graphique et Graphique2.
setGridVisible(vue, booléen) Affiche (true) ou Cache (false) la grille dans la vue nommée .
getGridVisible(vue) Retourne true si la grille est affichée dans la vue nommée . Si le numéro de la vue est omis, retourne true si la grille est affichée dans
getPerspectiveXML() Retourne une définition XML de la disposition actuelle.
chaine=ggbApplet.getPerspectiveXML();
alert(""+chaine);
undo() Annule une action de l'utilisateur
redo() Refait une action annulée de l'utilisateur
showToolBar(booléen) Affichage ou non de la barre d 'outils
setCustomToolBar(chaîne) Vous permet de personnaliser la barre d’outils à l'aide d'une chaîne composée des numéros des outils
, ajoute un séparateur dans un menu, | démarre un nouveau menu et | | ajoute un séparateur dans la barre d’outils avant de créer un nouveau menu.
showMenuBar(booléen) Affichage ou non de la barre des menus
showAlgebraInput(booléen) Affichage ou non du champ de saisie
showResetIcon(booléen) Affichage ou non de l'icône de réinitialisation
enableRightClick(booléen) Autoriser ou non le clic droit
enableLabelDrags(booléen) Autoriser ou non le déplacement des étiquettes
enableShiftDragZoom(booléen) Autoriser ou non le déplacement et le zoom de la vue, à la souris ou au clavier
enableCAS(booléen) Autorise ou non les fonctionnalités CAS (fenêtre et commandes)
enable3D(booléen) Autorise ou non la fenêtre 3D
setPerspective(chaîne) Modifie la dispositions des vues ouvertes, voir Commande_SoitDispositions pour la définition de la chaîne.
setWidth(entier)
(HTML5)
Définit la largeur de l'appliquette (en pixels)
setHeight(entier)
(HTML5)
Définit la hauteur de l'appliquette (en pixels)
setSize(entier largeur, entier hauteur)
(HTML5)
Définit la largeur et la hauteur de l'appliquette (en pixels)
recalculateEnvironments()
(HTML5)
Mise à jour de l'appliquette après redimensionnement par une feuille de style en cascade externe

Communication de GeoGebraApplet à JavaScript

Avec ces méthodes vous pouvez implémenter une communication de l’appliquette au JavaScript. Par exemple, ces méthodes peuvent être utilisées pour :

  • noter les actions de l'utilisateur (voir l'exemple java2javascript)
  • communiquer entre deux appliquettes GeoGebra (voir l'exemple java2java)
Méthode Description
registerAddListener(String JSFunctionName)
(supp. par unregisterAddListener(nom))
Déclare une fonction JavaScript en tant que mouchard des ajouts dans l’appliquette de construction.

Dès qu’un nouvel objet est créé, la fonction JS est appelée avec comme argument le nouvel objet.

Exemple : Déclarez d’abord, une fonction JS d’écoute :

ggbApplet.registerAddListener("suiviAjout");

Dès qu’un objet "A" est créé, l’appliquette GeoGebra appelle la fonction suiviAjout("A")
registerRemoveListener(fonctionJS)
(supp. par unregisterRemoveListener(nom))
Déclare une fonction JavaScript en tant que mouchard des retraits dans l’appliquette de construction.

Dès qu’un objet est supprimé, la fonction fonctionJS est appelée avec comme argument le nom de l’objet effacé.

Note : Quand une construction est mise à zéro, le mouchard n’est pas appelé pour chacun des objets élémentaires, voir registerClearListener().
Exemple : Déclarez d’abord, une fonction JS d’écoute :

ggbApplet.registerRemoveListener("suiviRetrait");

Dès qu’un objet "A" est effacé, l’appliquette GeoGebra appelle la fonction suiviRetrait("A")
registerUpdateListener(fonctionJS)
(supp. par unregisterUpdateListener(nom))
Déclare une fonction JavaScript en tant que mouchard des modifications dans l’appliquette de construction. Dès qu’un objet quelconque est modifié, la fonction fonctionJSest appelée avec comme argument le nom de l’objet modifié.
Note : si vous voulez suivre les modifications d’un seul objet utilisez plutôt registerObjectUpdateListener().
Exemple : Déclarez d’abord, une fonction JS d’écoute :

ggbApplet.registerUpdateListener("suiviModifs");

Dès que l’objet "A" est modifié, l’appliquette GeoGebra appelle la fonction suiviModifs("A")
registerClickListener(fonctionJS)
(supp. par unregisterregisterClickListener(nom))
Déclare une fonction JavaScript en tant que mouchard des clics dans l’appliquette de construction. Dès qu’un objet quelconque est cliqué, la fonction fonctionJSest appelée avec comme argument le nom de l’objet cliqué.
Note : si vous voulez suivre les clics sur un seul objet utilisez plutôt registerObjectClickListener().
registerObjectUpdateListener(nom, fonctionJS)
(supp. par unregisterClickListener(nom))
Déclare une fonction JavaScript en tant que mouchard des modifications pour un simple objet dans l’appliquette de construction. Dès que l’objet suivi est modifié, la fonction fonctionJS est appelée avec comme argument le nom de l’objet modifié. Si l’objet avait auparavant une valeur par la fonction JS, l’ancienne valeur est actualisée.
Note : toutes les écoutes de modifications d’objets sont effacées quand l’objet associé est supprimé ou que la construction est remise à zéro, voir registerRemoveListener() et registerClearListener().
Exemple : Déclarez d’abord, une fonction JS d’écoute :

ggbApplet.registerObjectUpdateListener("A", "monsuiviA");

Dès que A est modifié, l’appliquette appelle la fonction monsuiviA("A")
Note : un mouchard de modifications d’un objet continue à fonctionner après que cet objet ait été renommé.
registerObjectClickListener(nom, fonctionJS)
(supp. par unregisterObjectClickListener(nom))
Déclare une fonction JavaScript en tant que mouchard des clics pour un seul objet dans l’appliquette de construction. Dès que l’objet suivi est cliqué, la fonction fonctionJS est appelée avec comme argument le nom de l’objet modifié. Si l’objet avait auparavant une valeur par la fonction JS, l’ancienne valeur est actualisée.
Note : toutes les écoutes de clics d’objets sont effacées quand l’objet associé est supprimé ou que la construction est remise à zéro, voir registerRemoveListener() et registerClearListener().
Exemple : Déclarez d’abord, une fonction JS d’écoute :

ggbApplet.registerObjectClickListener("A", "monsuiviA");

Dès que A est modifié, l’appliquette appelle la fonction monsuiviA("A")
Note : un mouchard de clics sur un objet continue à fonctionner après que cet objet ait été renommé.
registerRenameListener(fonctionJS)
(supp. par unregisterRenameListener(nom))
Déclare une fonction JavaScript en tant que mouchard des changements de nom dans l’appliquette de construction. Dès qu’un objet est renommé, la fonction fonctionJS est appelée avec comme argument l’ancien nom de l’objet et le nouveau.
Exemple : Déclarez d’abord, une fonction JS d'écoute :

ggbApplet.registerRenameListener("monsuiviRenommer");

Dès qu’un objet "A" est renommé en "B", l’appliquette appelle la fonction monsuiviRenommer("A", "B")
registerClearListener(fonctionJS)
(supp. par unregisterClearListener(nom))
Déclare une fonction JavaScript en tant que mouchard des remises à zéro dans l’appliquette de construction. Dès que la construction est remise à zéro (i.e. tous les objets sont supprimés), la fonction fonctionJS est appelée sans argument.
Note : tous les mouchards de modifications ne sont plus déclarés quand une construction est remise à zéro. Voir registerUpdateListener() et registerRemoveListener().
Exemple : Déclarez d’abord, une fonction JS d'écoute :

ggbApplet.registerClearListener("suiviRAZ");

Quand la construction est remise à zéro , l’appliquette appelle la fonction suiviRAZ()
registerStoreUndoListener(fonctionJS)
(supp. par unregisterStoreUndoListener(nom))
Déclare une fonction JavaScript en tant que mouchard des création de points de restauration dans l’appliquette de construction. (appelé sans arguments) .

Format XML de GeoGebra

Avec ces méthodes vous pouvez définir tout objet dans une construction. (voir Références XML ).

Méthode Description
evalXML(chaînexml) Évalue la chaîne fournie et modifie la construction actuelle.
Note : la construction n’est pas effacée avant l’évaluation de la chaîne XML.
setXML(chaînexml) Évalue la chaîne fournie et modifie la construction actuelle.
Note : la construction est effacée avant l’évaluation de la chaîne XML. Cette méthode peut être utilisée pour charger des constructions.
getXML()
Retourne l’actuelle construction sous forme d’une chaîne dans le format XML de GeoGebra. Cette méthode peut être utilisée pour sauvegarder des constructions.

Exemple :

<form name="nonof"><input type="button" value="get" 
onclick="document.nonof.nonot.value=document.ggbApplet.getXML()";">
<textarea name="nonot" rows=8 cols=60> </textarea>
</form>


getXML(nom)
Retourne uniquement la chaîne de construction XML de l’objet cité., i.e. seulement le paragraphe <element>.
getAlgorithmXML(nom)

Retourne une chaîne vide pour un objet libre. Retourne la chaîne de construction XML de l’ascendant (et de tous ses descendants) de l’objet cité pour un objet dépendant

Divers

  • drawToImage(label,x[],y[]), clearImage(label) to draw
Exemple :
Zbynĕk
for(var i=0;i<5;i+=0.07){
 for(var j=0;j<5;j+=0.07){
 ggbApplet.setPenColor(j*51,i*51,0);
 ggbApplet.drawToImage("img1",new Array(i,i),new Array(j,j));
 }
}
  • String evalGeoGebraCAS(String casCommand)
  • String evalGeoGebraCAS(String casCommand, boolean printDebugInfo)
  • void setPenColor(int red, int green, int blue); valeurs entre 0 et 255
  • void setPenSize(int size); définit la taille tracé du stylo en pixels
  • int getPenSize(); retourne la taille tracé du stylo en pixels
  • String getPenColor(); retourne la couleur RVB du tracé du stylo sous forme de chaîne hexadécimale (par ex. #AB1234)
  • boolean evalCommand(String cmd, boolean waitForResult)
  • public void setListValue(String objName, int index, double x);
Définit la valeur de l'élément à la position indiquée dans la liste. Peut être utilisé pour augmenter la longueur d'une liste. Ne pas oublier que l'indice du premier élément est 1 non pas 0
  • public double getListValue(String objName, int index);
Retourne la valeur de l'élément à la position indiquée dans la liste. Retourne NaN si l'objet n'est ni un nombre, ni un booléen.


Exemple :
Noël registerClickListener
function ggbOnInit() {
ggbApplet.registerClickListener("HLS");
select='Segment[(0,0),(0,0)]';
}
function HLS(obj) {
type=ggbApplet.getObjectType(obj);
if (type=="segment") {
cmd='SetLineThickness['+select+',3]';
ggbApplet.evalCommand(cmd);
cmd='SetColor['+select+',"Black"]';
ggbApplet.evalCommand(cmd);
cmd='SetLineThickness['+obj+',13]';
ggbApplet.evalCommand(cmd);
cmd='SetColor['+obj+',"Red"]';
ggbApplet.evalCommand(cmd);
select=obj;
}
else{
cmd='SetLineThickness['+select+',3]';
ggbApplet.evalCommand(cmd);
cmd='SetColor['+select+',"Black"]';
ggbApplet.evalCommand(cmd);
select='Segment[(0,0),(0,0)]';
}
}


Méthode Description
debug(chaîne) Écrit la chaîne dans la Console Java
getVersion() Retourne la version de GeoGebra

Évaluation automatique d'exercice

Méthode Description
JSONObject getExerciseResult() S'il y a des Macros ou un Exercice présents dans le fichier courant, cette méthode peut être utilisée pour évaluer si des parties de la construction sont équivalentes aux Macros de ce fichier.
Si vous ne voulez pas qu'un Exercice Standard (utilisant toutes les Macros dans la Construction et les fractionnant chacune jusqu'à 100) soit créé, tester d'abord si c'est un Exercice avec isExercise() .
Aide restera vide, sauf indication contraire dans le constructeur d'exercice.
Les fractions seront de 0 or 1 sauf indication contraire dans le constructeur d'exercice.
Le résultat sera dans Résultat,i.e:
CORRECTE, L'affectation est CORRECTE
WRONG, if the assignment is WRONG and we can't tell why
NOT_ENOUGH_INPUTS if there are not enough input geos, so we cannot check
WRONG_INPUT_TYPES, if there are enough input geos, but one or more are of the wrong type
WRONG_OUTPUT_TYPE, if there is no output geo matching our macro
WRONG_AFTER_RANDOMIZE, if the assignment was correct in the first place but wrong after randomization
UNKNOWN, if the assignment could not be checked
getExerciseFraction() If there are Macros or an Exercise present in the current file this can be used to check if parts of the construction are equivalent to the Macros in the file.
It will return the overall Fraction of the Exercise.
This is the sum of all the Fractions in the Assignment or 1 if one of the Assignments has a fraction of 100 and no negative fractions are present. Use getExerciseResult() to get the fractions of each Assignment. If you don't want that a standard exercise (using all the Macros in the Construction and setting each fraction to 100) will be created, check if this is a Exercise with isExercise() first.
isExercise() Check whether this applet is an Exercise
Returns:true if the Exercise has assignments, this will happen when either getExerciseResult() or getExerciseFraction() are called with user defined Tools present in the applet or if the ExerciseBuilderDialog was used to create the Exercise.
boolean startExercise() If you want to make use of the values of random geos a BoolAssignment depends on, this is an easy way to retrieve these values for displaying in the question text and stop randomizing them in order to store the same assignment that was presented to the student.

Un exemple utilisant ces fonctionnalités : http://archive.geogebra.org/source/program/applet/exerciseExample.html

Obtenir Objet Appliquette

Dans les situations basiques l'appliquette est dans la variable globale ggbApplet . Les exceptions sont :

  • plusieurs appliquettes dans une page, par défaut, une seule est accessible pour JavaScript. Pour accéder à plusieurs appliquettes, vous devez définir le paramètre "id" pour chaque appliquette, il deviendra le nom de la variable globale représentant l'appliquette ;
  • export depuis GeoGebra 4.0 et antérieurs : l'appliquette est accessible en tant que document.applets[0], les autres appliquettes de la même page le sont par document.applets[1], ...


en:Reference:JavaScript es:Referencia:JavaScript it:Riferimenti:JavaScript

© 2024 International GeoGebra Institute